aboutsummaryrefslogtreecommitdiff
path: root/src/arch/x86_64/Lower.zig
AgeCommit message (Collapse)Author
2025-09-26compiler: move self-hosted backends from src/arch to src/codegenAlex Rønne Petersen
2025-06-12x86_64.Lower: replace slow stringToEnum callmlugg
Looking at a compilation of 'test/behavior/x86_64/unary.zig' in callgrind showed that a full 30% of the compiler runtime was spent in this `stringToEnum` call, so optimizing it was low-hanging fruit. We tried replacing it with nested `switch` statements using `inline else`, but that generated too much code; it didn't emit huge binaries or anything, but LLVM used a *ridiculous* amount of memory compiling it in some cases. The core problem here is that only a small subset of the cases are actually used (the rest fell through to an "error" path), but that subset is computed at comptime, so we must rely on the optimizer to eliminate the thousands of redundant cases. This would be solved by #21507. Instead, we pre-compute a lookup table at comptime. This table is pretty big (I guess a couple hundred k?), but only the "valid" subset of entries will be accessed in practice (unless a bug in the backend is hit), so it's not too awful on the cache; and it performs much better than the old `std.meta.stringToEnum` call.
2025-06-12x86_64: remove linker references from codegenJacob Young
2025-06-12x86_64: remove air references from mirJacob Young
2025-06-06x86_64: add support for pie executablesJacob Young
2025-05-28x86_64: implement optimized float `@reduce(.Add)`Jacob Young
2025-05-28x86_64: implement integer `@reduce(.Mul)`Jacob Young
2025-04-10x86_64: support rip-relative addressing to labels in inline asmJacob Young
2025-03-21x86_64: rewrite wrapping multiplicationJacob Young
2025-02-15x86_64: rewrite unsafe scalar int multiplicationJacob Young
2025-02-15x86_64: rewrite array accessJacob Young
2025-01-18x86_64: add a bunch of instruction encodingsJacob Young
Closes #19773
2025-01-16x86_64: implement switch jump tablesJacob Young
2025-01-16x86_64: implement clz and notJacob Young
2025-01-16x86_64: demolish the oldJacob Young
2024-11-24dwarf: fix stepping through an inline loop containing one statementJacob Young
Previously, stepping from the single statement within the loop would always exit the loop because all of the code unrolled from the loop is associated with the same line and treated by the debugger as one line.
2024-11-12AstGen: add missing `rvalue` call to `labeledBlockExpr`mlugg
...and fix a minor x86_64 backend bug exposed by this fix. Resolves: #21974
2024-10-09Dwarf: implement and test lexical blocksJacob Young
2024-08-29compiler: avoid field/decl name conflictsmlugg
Most of the required renames here are net wins for readaibility, I'd say. The ones in `arch` are a little more verbose, but I think better. I didn't bother renaming the non-conflicting functions in `arch/arm/bits.zig` and `arch/aarch64/bits.zig`, since these backends are pretty bit-rotted anyway AIUI.
2024-08-28std: update `std.builtin.Type` fields to follow naming conventionsmlugg
The compiler actually doesn't need any functional changes for this: Sema does reification based on the tag indices of `std.builtin.Type` already! So, no zig1.wasm update is necessary. This change is necessary to disallow name clashes between fields and decls on a type, which is a prerequisite of #9938.
2024-08-27Dwarf: implement .eh_frameJacob Young
2024-08-27compiler,lib,test,langref: migrate `@setCold` to `@branchHint`mlugg
2024-08-22Dwarf: add missing var args info on function declsJacob Young
2024-08-20x86_64: support more dwarf locationsJacob Young
2024-08-20Dwarf: emit info about inline call sitesJacob Young
2024-08-17macho: update codegen and linker to distributed jump table approachJakub Konka
2024-08-15x86_64: deref GOT pointer when requesting var valueJakub Konka
2024-08-15x86_64: fix handling on externs in lower/emitJakub Konka
2024-08-13x86_64: emit call rel32 for near calls with linker relocJakub Konka
2024-08-13x86_64: remove handling of .call since it's unused for nowJakub Konka
2024-08-13x86_64: start converting away from .got.zig knowledgeJakub Konka
2024-08-13elf: nuke ZigGotSection from existenceJakub Konka
2024-08-11compiler: split Decl into Nav and Caumlugg
The type `Zcu.Decl` in the compiler is problematic: over time it has gained many responsibilities. Every source declaration, container type, generic instantiation, and `@extern` has a `Decl`. The functions of these `Decl`s are in some cases entirely disjoint. After careful analysis, I determined that the two main responsibilities of `Decl` are as follows: * A `Decl` acts as the "subject" of semantic analysis at comptime. A single unit of analysis is either a runtime function body, or a `Decl`. It registers incremental dependencies, tracks analysis errors, etc. * A `Decl` acts as a "global variable": a pointer to it is consistent, and it may be lowered to a specific symbol by the codegen backend. This commit eliminates `Decl` and introduces new types to model these responsibilities: `Cau` (Comptime Analysis Unit) and `Nav` (Named Addressable Value). Every source declaration, and every container type requiring resolution (so *not* including `opaque`), has a `Cau`. For a source declaration, this `Cau` performs the resolution of its value. (When #131 is implemented, it is unsolved whether type and value resolution will share a `Cau` or have two distinct `Cau`s.) For a type, this `Cau` is the context in which type resolution occurs. Every non-`comptime` source declaration, every generic instantiation, and every distinct `extern` has a `Nav`. These are sent to codegen/link: the backends by definition do not care about `Cau`s. This commit has some minor technically-breaking changes surrounding `usingnamespace`. I don't think they'll impact anyone, since the changes are fixes around semantics which were previously inconsistent (the behavior changed depending on hashmap iteration order!). Aside from that, this changeset has no significant user-facing changes. Instead, it is an internal refactor which makes it easier to correctly model the responsibilities of different objects, particularly regarding incremental compilation. The performance impact should be negligible, but I will take measurements before merging this work into `master`. Co-authored-by: Jacob Young <jacobly0@users.noreply.github.com> Co-authored-by: Jakub Konka <kubkon@jakubkonka.com>
2024-08-07elf: fix compile errorsJakub Konka
2024-07-22macho: run more things in parallelJakub Konka
2024-07-18macho: update ZigObject to use new ownership modelJakub Konka
2024-07-14riscv: truncate `airStructFieldVal` resultDavid Rubin
2024-07-07Zcu: introduce `PerThread` and pass to all the functionsJacob Young
2024-07-04Zcu: store `LazySrcLoc` in error messagesmlugg
This change modifies `Zcu.ErrorMsg` to store a `Zcu.LazySrcLoc` rather than a `Zcu.SrcLoc`. Everything else is dominoes. The reason for this change is incremental compilation. If a failed `AnalUnit` is up-to-date on an update, we want to re-use the old error messages. However, the file containing the error location may have been modified, and `SrcLoc` cannot survive such a modification. `LazySrcLoc` is designed to be correct across incremental updates. Therefore, we defer source location resolution until `Compilation` gathers the compile errors into the `ErrorBundle`.
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-03-11std.builtin: make link mode fields lowercaseTristan Ross
2024-02-25x86_64: implement `@select`Jacob Young
2024-01-24macho: ensure we zero-out regions after copying them overJakub Konka
This is to ensure that the loader correctly zeroes-out zerofill sections when mapping them. For context, Apple's loader dyld will map the regions where any zerofill would theoretically reside as belonging to zerofill section.
2024-01-24macho: actually lower TLS variablesJakub Konka
2024-01-24x86_64: emit MachO TLV sequenceJakub Konka
2024-01-24macho: again fix symbol index dereference in codegen wrt ZigObjectJakub Konka
2024-01-24codegen: re-implement enough of codegen to error out instead panicJakub Konka
2024-01-01fix more compilation errors introduced by this branchAndrew Kelley
2023-11-19compiler: correct unnecessary uses of 'var'mlugg
2023-11-12x86_64: use .rax for local exec as prescribed by the specJakub Konka