aboutsummaryrefslogtreecommitdiff
path: root/src/register_manager.zig
AgeCommit message (Collapse)Author
2025-07-07std.fmt.format: use {t} for tag name rather than {s}Andrew Kelley
prevents footgun when formatted type changes from string to enum
2025-07-07compiler: update a bunch of format stringsAndrew Kelley
2025-07-07compiler: fix a bunch of format stringsAndrew Kelley
2025-03-23codegen: fix packed byte-aligned relocationsJacob Young
Closes #23131
2025-01-16x86_64: fix crashes compiling the compiler and testsJacob Young
2025-01-16x86_64: fix unnecessary register savingJacob Young
2025-01-16x86_64: testingJacob Young
2025-01-16x86_64: rewrite arithmeticJacob Young
2025-01-15wasm linker: aggressive DODificationAndrew Kelley
The goals of this branch are to: * compile faster when using the wasm linker and backend * enable saving compiler state by directly copying in-memory linker state to disk. * more efficient compiler memory utilization * introduce integer type safety to wasm linker code * generate better WebAssembly code * fully participate in incremental compilation * do as much work as possible outside of flush(), while continuing to do linker garbage collection. * avoid unnecessary heap allocations * avoid unnecessary indirect function calls In order to accomplish this goals, this removes the ZigObject abstraction, as well as Symbol and Atom. These abstractions resulted in overly generic code, doing unnecessary work, and needless complications that simply go away by creating a better in-memory data model and emitting more things lazily. For example, this makes wasm codegen emit MIR which is then lowered to wasm code during linking, with optimal function indexes etc, or relocations are emitted if outputting an object. Previously, this would always emit relocations, which are fully unnecessary when emitting an executable, and required all function calls to use the maximum size LEB encoding. This branch introduces the concept of the "prelink" phase which occurs after all object files have been parsed, but before any Zcu updates are sent to the linker. This allows the linker to fully parse all objects into a compact memory model, which is guaranteed to be complete when Zcu code is generated. This commit is not a complete implementation of all these goals; it is not even passing semantic analysis.
2025-01-10x86_64: fix miscomp where in use register is marked as freeJacob Young
2024-09-12Replace deprecated default initializations with decl literalsLinus Groh
2024-08-21compiler: handle eval branch quota in memoized callsmlugg
In a `memoized_call`, store how many backwards braches the call performs. Add this to `sema.branch_count` when using a memoized call. If this exceeds the quota, perform a non-memoized call to get a correct "exceeded X backwards branches" error. Also, do not memoize calls which do `@setEvalBranchQuota` or similar, as this affects global state which must apply to the caller. Change some eval branch quotas so that the compiler itself still builds correctly. This commit manually changes a file in Aro which is automatically generated. The sources which generate the file are not in this repo. Upstream Aro should make the suitable changes on their end before the next sync of Aro sources into the Zig repo.
2024-08-16Dwarf: rework self-hosted debug info from scratchJacob Young
This is in preparation for incremental and actually being able to debug executables built by the x86_64 backend.
2024-07-07Zcu: introduce `PerThread` and pass to all the functionsJacob Young
2024-07-04compiler: type.zig -> Type.zigmlugg
2024-06-22rename src/Module.zig to src/Zcu.zigAndrew Kelley
This patch is a pure rename plus only changing the file path in `@import` sites, so it is expected to not create version control conflicts, even when rebasing.
2024-05-11riscv: big rewrite to use latest livenessDavid Rubin
this one is even harder to document then the last large overhaul. TLDR; - split apart Emit.zig into an Emit.zig and a Lower.zig - created seperate files for the encoding, and now adding a new instruction is as simple as just adding it to a couple of switch statements and providing the encoding. - relocs are handled in a more sane maner, and we have a clear defining boundary between lea_symbol and load_symbol now. - a lot of different abstractions for things like the stack, memory, registers, and others. - we're using x86_64's FrameIndex now, which simplifies a lot of the tougher design process. - a lot more that I don't have the energy to document. at this point, just read the commit itself :p
2024-05-11riscv: totally rewrite how we do loads and storesDavid Rubin
this commit is a little too large to document fully, however the main gist of it this - finish the `genInlineMemcpy` implement - rename `setValue` to `genCopy` as I agree with jacob that it's a better name - add in `genVarDbgInfo` for a better gdb experience - follow the x86_64's method for genCall, as the procedure is very similar for us - add `airSliceLen` as it's trivial - change up the `airAddWithOverflow implementation a bit - make sure to not spill of the elem_ty is 0 size - correctly follow the RISC-V calling convention and spill the used calle saved registers in the prologue and restore them in the epilogue - add `address`, `deref`, and `offset` helper functions for MCValue. I must say I love these, they make the code very readable and super verbose :) - fix a `register_manager.zig` issue where when using the last register in the set, the value would overflow at comptime. was happening because we were adding to `max_id` before subtracting from it.
2024-03-30Update uses of `@fieldParentPtr` to use RLSJacob Young
2024-03-30Update uses of `@fieldParentPtr` to pass a pointer typeJacob Young
2023-11-03x86_64: reduce `RegisterManager` performance regressionJacob Young
This reduces the regression from 0.11.0 by 95%. Closes #17678
2023-10-07x86_64: implement negation and `@abs` for `f80`Jacob Young
Also implement live-outs since the x87 requires so much care around liveness tracking.
2023-06-24all: migrate code to new cast builtin syntaxmlugg
Most of this migration was performed automatically with `zig fmt`. There were a few exceptions which I had to manually fix: * `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten * `@truncate`'s fixup is incorrect for vectors * Test cases are not formatted, and their error locations change
2023-06-19all: zig fmt and rename "@XToY" to "@YFromX"Eric Joldasov
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-04-20x86_64: rewrite inst trackingJacob Young
2023-03-25x86_64: implement saturating arithmeticJacob Young
2023-03-24x86_64: fix value tracking bugsJacob Young
2023-03-21x86_64: implement atomic and fence opsJacob Young
2023-03-03codegen: move gen logic for typed values, consts and decl ref to common codegenJakub Konka
2023-02-18update std lib and compiler sources to new for loop syntaxAndrew Kelley
2022-07-26std.fmt: require specifier for unwrapping ?T and E!TInKryption
2022-07-24Revert "std.fmt: require specifier for unwrapping ?T and E!T."Andrew Kelley
This reverts commit 7cbd586ace46a8e8cebab660ebca3cfc049305d9. This is causing a fail to build from source: ``` ./lib/std/fmt.zig:492:17: error: cannot format optional without a specifier (i.e. {?} or {any}) @compileError("cannot format optional without a specifier (i.e. {?} or {any})"); ^ ./src/link/MachO/Atom.zig:544:26: note: called from here log.debug(" RELA({s}) @ {x} => %{d} in object({d})", .{ ^ ``` I looked at the code to fix it but none of those args are optionals.
2022-07-24std.fmt: require specifier for unwrapping ?T and E!T.InKryption
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2022-06-07x64: simplify saving registers to stack in prologueJakub Konka
2022-05-26regalloc: use StaticBitSet internallyJakub Konka
2022-05-21regalloc: test allocating from multiple register claasesJakub Konka
2022-05-20regalloc: temporarily nerf back to raw ints until stage2 catches upJakub Konka
2022-05-19regalloc: make register class bitmask non-optionalJakub Konka
2022-05-19x64: use StaticBitSet instead of an integer internally in RegisterManagerJakub Konka
2022-05-19x64: re-enable incremental testsJakub Konka
2022-05-19x64: use register classes mask to select between gp and avxJakub Konka
2022-05-19regalloc: allow for optional selector mask when allocatingJakub Konka
2022-05-19x64: merge general purpose with simd register into one bitsetJakub Konka
This way, we do not have to tweak the `RegisterManager` to handle multiple register types - we have one linear space instead. Additionally we can use the bitset itself to separate the registers into overlapping (the ones that are aliases of differing bitwidths) and nonoverlapping classes (for example, AVX registers do not overlap general purpose registers, thus they can be allocated simultaneously). Another huge benefit of this simple approach is the fact that we can still refer to *all* registers regardless of their class via enum literals which makes the code so much more readable. Finally, `RegisterLock` is universal across different register classes.
2022-05-19x64: add unordered cmp with EFLAGSJakub Konka
2022-05-19x64: load/store to/from AVX registers for f64Jakub Konka
2022-05-07regalloc: refactor locking multiple registers at onceJakub Konka
2022-05-07x64: refactor code to avoid stage1 sema limitationsJakub Konka
2022-05-07regalloc: rename freeze/unfreeze to lock/unlock registersJakub Konka
2022-05-07x64: fix misused register locksJakub Konka
2022-05-07regalloc: ensure we only freeze/unfreeze at the outermost scopeJakub Konka
This prevents a nasty type of bugs where we accidentally unfreeze a register that was frozen purposely in the outer scope, risking accidental realloc of a taken register. Fix CF flags spilling on aarch64 backend.