aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.zig
AgeCommit message (Collapse)Author
2023-06-10compiler: move error union types and error set types to InternPoolAndrew Kelley
One change worth noting in this commit is that `module.global_error_set` is no longer kept strictly up-to-date. The previous code reserved integer error values when dealing with error set types, but this is no longer needed because the integer values are not needed for semantic analysis unless `@errorToInt` or `@intToError` are used and therefore may be assigned lazily.
2023-06-10compiler: eliminate legacy Type.Tag.pointerAndrew Kelley
Now pointer types are stored only in InternPool.
2023-06-10stage2: move function types to InternPoolAndrew Kelley
2023-06-10stage2: move enum tag values into the InternPoolAndrew Kelley
I'm seeing a new assertion trip: the call to `enumTagFieldIndex` in the implementation of `@Type` is attempting to query the field index of an union's enum tag, but the type of the enum tag value provided is not the same as the union's tag type. Most likely this is a problem with type coercion, since values are now typed. Another problem is that I added some hacks in std.builtin because I didn't see any convenient way to access them from Sema. That should definitely be cleaned up before merging this branch.
2023-06-10stage2: move enum types into the InternPoolAndrew Kelley
Unlike unions and structs, enums are actually *encoded* into the InternPool directly, rather than using the SegmentedList trick. This results in them being quite compact, and greatly improved the ergonomics of using enum types throughout the compiler. It did however require introducing a new concept to the InternPool which is an "incomplete" item - something that is added to gain a permanent Index, but which is then mutated in place. This was necessary because enum tag values and tag types may reference the namespaces created by the enum itself, which required constructing the namespace, decl, and calling analyzeDecl on the decl, which required the decl value, which required the enum type, which required an InternPool index to be assigned and for it to be meaningful. The API for updating enums in place turned out to be quite slick and efficient - the methods directly populate pre-allocated arrays and return the information necessary to output the same compilation errors as before.
2023-06-10stage2: move union types and values to InternPoolAndrew Kelley
2023-06-10stage2: move struct types and aggregate values to InternPoolAndrew Kelley
2023-06-10stage2: implement intTagType logicAndrew Kelley
This commit changes a lot of `*const Module` to `*Module` to make it work, since accessing the integer tag type of an enum might need to mutate the InternPool by adding a new integer type into it. An alternate strategy would be to pre-heat the InternPool with the integer tag type when creating an enum type, which would make it so that intTagType could accept a const Module instead of a mutable one, asserting that the InternPool already had the integer tag type.
2023-06-10Replace uses of Value.zero, Value.one, Value.negative_onemlugg
This is a bit nasty, mainly because Type.onePossibleValue is now errorable, which is a quite viral change.
2023-06-10stage2: move integer values to InternPoolAndrew Kelley
2023-06-10InternPool: add a slice encodingAndrew Kelley
This uses the data field to reference its pointer field type, which allows for efficient and infallible access of a slice type's pointer type.
2023-06-10stage2: move undef, unreach, null values to InternPoolAndrew Kelley
2023-06-10stage2: move many Type encodings to InternPoolAndrew Kelley
Notably, `vector`. Additionally, all alternate encodings of `pointer`, `optional`, and `array`.
2023-06-10Type.isSlice: make it InternPool awareAndrew Kelley
2023-06-10stage2: move most simple values to InternPoolAndrew Kelley
2023-06-10stage2: move named int types to InternPoolAndrew Kelley
2023-06-10stage2: start the InternPool transitionAndrew Kelley
Instead of doing everything at once which is a hopelessly large task, this introduces a piecemeal transition that can be done in small increments at a time. This is a minimal changeset that keeps the compiler compiling. It only uses the InternPool for a small set of types. Behavior tests are not passing. Air.Inst.Ref and Zir.Inst.Ref are separated into different enums but compile-time verified to have the same fields in the same order. The large set of changes is mainly to deal with the fact that most Type and Value methods now require a Module to be passed in, so that the InternPool object can be accessed.
2023-05-31codegen: Write padding bytes for unionsLuuk de Gram
Previously we did not write any missing padding bytes after the smallest field (either tag or payload, depending on alignment). This resulted in writing too few bytes and not matching the full abisize of the union.
2023-05-26std.Target adjustmentsVeikka Tuominen
* move `ptrBitWidth` from Arch to Target since it needs to know about the abi * double isn't always 8 bits * AVR uses 1-byte alignment for everything in GCC
2023-05-18codegen: emit global vector paddingJacob Young
2023-05-15x86_64: implement global payload pointersJacob Young
2023-05-15codegen: implement global enum_numberedJacob Young
2023-05-03codegen: handle variable and decl_ref_mut consistentlyJacob Young
2023-05-03codegen: fix global nested field_ptrJacob Young
2023-05-03x86_64: fix global slicesJacob Young
2023-05-01x86_64: implement tagNameJacob Young
2023-05-01link: cleanup lazy alignmentJacob Young
This gets the alignment from the code that creates a lazy symbol instead of guessing it at every use.
2023-05-01x86_64: fix emitting f80 globalsJacob Young
2023-05-01x86_64: implement a bunch of floating point stuffJacob Young
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