aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.zig
AgeCommit message (Collapse)Author
2023-04-28compiler: use `@memcpy` instead of `std.mem.copy`Andrew Kelley
2023-04-21elf: do not reserve a GOT slot for every AtomJakub Konka
2023-04-15x86_64: cleanup different memory load typesJakub Konka
Split `MCValue.linker_load` into `.load_got`, `.load_direct`, and `.lea_direct`.
2023-04-15x86_64: split MCValue.tlv_reloc into .load_tlv and .lea_tlvJakub Konka
`.load_tlv` signifies we want to load the value of a TLV `.lea_tlv` signifies we want to load effective address of a TLV
2023-04-13x86_64: make TLV a separate MCValueJakub Konka
2023-04-13x86_64: emit pointer to TLV for machoJakub Konka
2023-04-13codegen: use non-debug Type/Value formattingJakub Konka
2023-04-13x86_64: fix constant pointers to zero-bit typesJacob Young
These non-dereferencable pointers still need to have the correct alignment and non-null-ness.
2023-04-03x86_64: implement cmp_lt_errors_lenJacob Young
2023-04-02x86_64: implement error nameJacob Young
2023-03-25codegen: fix ptr-like optional constantsJacob Young
2023-03-21x86_64: (re)implement optional opsJacob Young
Note that this commit also changes the layout of optional for all other backends using `src/codegen.zig` without updating them!
2023-03-03codegen: rename GenerateSymbolError to CodeGenErrorJakub Konka
2023-03-03codegen: refactor generating Int as immediate where appropriateJakub Konka
2023-03-03codegen: move gen logic for typed values, consts and decl ref to common codegenJakub Konka
2023-02-19implement `writeToMemory`/`readFromMemory` for pointersVeikka Tuominen
2023-02-18update std lib and compiler sources to new for loop syntaxAndrew Kelley
2023-01-25self-hosted: rename codegen Result.appended to Result.okJakub Konka
2023-01-25self-hosted: remove unused `externally_managed` prong for Decls codeJakub Konka
2022-12-16codegen - lower str_lit to vectorTravis Staloch
2022-12-12codegen: implement generating vector valuesLuuk de Gram
2022-12-06remove most conditional compilation based on stage1Andrew Kelley
There are still a few occurrences of "stage1" in the standard library and self-hosted compiler source, however, these instances need a bit more careful inspection to ensure no breakage.
2022-12-03Merge pull request #13744 from Vexu/stage2-fixesAndrew Kelley
Improve error messages, fix dependency loops
2022-12-03Sema: fix comparisons between lazy and runtime valuesVeikka Tuominen
Closes #12498
2022-12-01codegen: make LinkerLoad a common struct shared by backendsJakub Konka
2022-11-30wasm: enable behavior tests for packed structsLuuk de Gram
2022-11-30codegen: support generating packed structsLuuk de Gram
2022-11-04all: rename i386 to x86Ali Chraghi
2022-10-28stage2: Use mem.readPackedInt etc. for packed bitcastsCody Tapscott
Packed memory has a well-defined layout that doesn't require conversion from an integer to read from. Let's use it :-) This change means that for bitcasting to/from a packed value that is N layers deep, we no longer have to create N temporary big-ints and perform N copies. Other miscellaneous improvements: - Adds support for casting to packed enums and vectors - Fixes bitcasting to/from vectors outside of a packed struct - Adds a fast path for bitcasting <= u/i64 - Fixes bug when bitcasting f80 which would clear following fields This also changes the bitcast memory layout of exotic integers on big-endian systems to match what's empirically observed on our targets. Technically, this layout is not guaranteed by LLVM so we should probably ban bitcasts that reveal these padding bits, but for now this is an improvement.
2022-10-27Sema: use `runtime_value` instead of creating allocsVeikka Tuominen
2022-10-12codegen: add support for lowering .field_ptr on a slicejacobly0
Closes #13068
2022-08-21Sema: handle union and enum field order being differentVeikka Tuominen
Closes #12543
2022-06-11stage2: make `error{}` the same size as `anyerror`Veikka Tuominen
Having `error{}` be a zero bit type causes issues when it interracts with empty inferred error sets which are the same size as `anyerror`.
2022-05-27math: make `cast` return optional instead of an errorAli Chraghi
2022-05-24stage2: fixes for error unions, optionals, errorsAndrew Kelley
* `?E` where E is an error set with only one field now lowers the same as `bool`. * Fix implementation of errUnionErrOffset and errUnionPayloadOffset to properly compute the offset of each field. Also name them the same as the corresponding LLVM functions and have the same function signature, to avoid confusion. This fixes a bug where wasm was passing the error union type instead of the payload type. * Fix C backend handling of optionals with zero-bit payload types. * C backend: separate out airOptionalPayload and airOptionalPayloadPtr which reduces branching and cleans up control flow. * Make Type.isNoReturn return true for error sets with no fields. * Make `?error{}` have only one possible value (null).
2022-05-24aarch64: update for new error union layoutJakub Konka
2022-05-24x64: update for new error union layoutJakub Konka
2022-05-24stage2: make `?anyerror` represented the same as `anyerror`Andrew Kelley
I was able to get the backend implementation working on LLVM and the C backend, but I'm going to ask for some help on the other backends.
2022-05-24wasm: Fixes for error union semanticsLuuk de Gram
2022-05-24codegen: Order error union fields per alignmentLuuk de Gram
Based on the size of the payload the native backends will lower the error union with its fields (errorset & payload) in the correct order. e.g. ErrorA!u8 will first lower the error set's value and then the payload. In the event of ErrorA!u32 will lower the payload first.
2022-05-24stage2: string literal interningAndrew Kelley
This is a temporary addition to stage2 in order to match stage1 behavior, however the end-game once the lang spec is settled will be to use a global InternPool for comptime memoized objects, making this behavior consistent across all types, not only string literals. Or, we might decide to not guarantee string literals to have equal comptime pointers, in which case this commit can be reverted.
2022-05-13target: Rename sparcv9 -> sparc64Koakuma
Rename all references of sparcv9 to sparc64, to make Zig align more with other projects. Also, added new function to convert glibc arch name to Zig arch name, since it refers to the architecture as sparcv9. This is based on the suggestion by @kubkon in PR 11847. (https://github.com/ziglang/zig/pull/11487#pullrequestreview-963761757)
2022-04-20stage2: use indexes for Decl objectsAndrew Kelley
Rather than allocating Decl objects with an Allocator, we instead allocate them with a SegmentedList. This provides four advantages: * Stable memory so that one thread can access a Decl object while another thread allocates additional Decl objects from this list. * It allows us to use u32 indexes to reference Decl objects rather than pointers, saving memory in Type, Value, and dependency sets. * Using integers to reference Decl objects rather than pointers makes serialization trivial. * It provides a unique integer to be used for anonymous symbol names, avoiding multi-threaded contention on an atomic counter.
2022-04-15stage2: lower u128, and refactor some bits in x64Jakub Konka
2022-04-13dwarf: gen debug info for arraysJakub Konka
2022-03-30dwarf: pass DeclState around instead of storing a temp global in DwarfJakub Konka
Avoids many pitfalls connected with premature/early return in case there are errors with Decl, etc. This is effectively bringing back the old design however in a much nicer packaging, where every mechanism related to tracking Decl's debug info is now nicely wrapped in a single struct (aka the `DeclState`). This includes relocation table, type arena, etc. It is now the caller's responsibility to deinit the state (so that no memory is leaked) after `Decl` has been analysed (or errored out). The caller here is typically a linker such as `Elf` or `MachO`.
2022-03-27dwarf: track type relocation state in Dwarf moduleJakub Konka
2022-03-27dwarf: move DbgInfoTypeRelocsTable into Dwarf moduleJakub Konka
2022-03-27dwarf: add debug info for error unionsJakub Konka
2022-03-27dwarf: add debug info for error setsJakub Konka