aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/llvm.zig
AgeCommit message (Collapse)Author
2024-12-23Zir: refactor `declaration` instruction representationmlugg
The new representation is often more compact. It is also more straightforward to understand: for instance, `extern` is represented on the `declaration` instruction itself rather than using a special instruction. The same applies to `var`, making both of these far more compact. This commit also separates the type and value bodies of a `declaration` instruction. This is a prerequisite for #131. In general, `declaration` now directly encodes details of the syntax form used, and the embedded ZIR bodies are for actual expressions. The only exception to this is functions, where ZIR is effectively designed as if we had #1717. `extern fn` declarations are modeled as `extern const` with a function type, and normal `fn` definitions are modeled as `const` with a `func{,_fancy,_inferred}` instruction. This may change in the future, but improving on this was out of scope for this commit.
2024-12-11compiler: Improve the handling of unwind table levels.Alex Rønne Petersen
The goal here is to support both levels of unwind tables (sync and async) in zig cc and zig build. Previously, the LLVM backend always used async tables while zig cc was partially influenced by whatever was Clang's default.
2024-12-03llvm: Remove dead targetArch() and targetOs() functions.Alex Rønne Petersen
These were leftovers from when we used the LLVM API to create modules.
2024-12-03std.Target: Remove Os.Tag.bridgeos.Alex Rønne Petersen
It doesn't appear that targeting bridgeOS is meaningfully supported by Apple. Even LLVM/Clang appear to have incomplete support for it, suggesting that Apple never bothered to upstream that support. So there's really no sense in us pretending to support this.
2024-11-28llvm: Lower ohoseabi to ohos instead of verbatim.Alex Rønne Petersen
LLVM doesn't recognize ohoseabi.
2024-11-28Merge pull request #22067 from alexrp/pie-testsAlex Rønne Petersen
Add PIC/PIE tests and fix some bugs + some improvements to the test harness
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-24std.Target: Add Os.HurdVersionRange for Os.Tag.hurd.Alex Rønne Petersen
This is necessary since isGnuLibC() is true for hurd, so we need to be able to represent a glibc version for it. Also add an Os.TaggedVersionRange.gnuLibCVersion() convenience function.
2024-11-08llvm: Disable lowering to f16 on sparc.Alex Rønne Petersen
2024-11-05llvm: Also apply the nobuiltin attribute for the no_builtin module option.Alex Rønne Petersen
From `zig build-exe --help`: -fno-builtin Disable implicit builtin knowledge of functions It seems entirely reasonable and even expected that this option should imply both no-builtins on functions (which disables transformation of recognized code patterns to libcalls) and nobuiltin on call sites (which disables transformation of libcalls to intrinsics). We now match Clang's behavior for -fno-builtin. In both cases, we're painting with a fairly broad brush by applying this to an entire module, but it's better than nothing. #21833 proposes a more fine-grained way to apply nobuiltin.
2024-11-05Compilation: Move no_builtin to Package.Module.Alex Rønne Petersen
This option, by its very nature, needs to be attached to a module. If it isn't, the code in a module could break at random when compiled into an application that doesn't have this option set. After this change, skip_linker_dependencies no longer implies no_builtin in the LLVM backend.
2024-11-05Merge pull request #21907 from alexrp/valgrind-stuffAlex Rønne Petersen
Add client request support for all architectures supported by Valgrind
2024-11-04llvm: Use no-builtins attribute instead of nobuiltin.Alex Rønne Petersen
The former prevents recognizing code patterns and turning them into libcalls, which is what we want for compiler-rt. The latter is meant to be used on call sites to prevent them from being turned into intrinsics. Context: https://github.com/ziglang/zig/issues/21833
2024-11-04llvm: Add client request support for all archs supported by Valgrind.Alex Rønne Petersen
2024-11-03Merge pull request #21843 from alexrp/callconv-followupAlex Rønne Petersen
Some follow-up work for #21697
2024-11-03Merge pull request #21599 from alexrp/thumb-portingAlex Rønne Petersen
2024-11-03llvm: Update the list of address spaces for LLVM 19.Alex Rønne Petersen
Mainly affects amdgcn.
2024-11-03std.Target: Replace isARM() with isArmOrThumb() and rename it to isArm().Alex Rønne Petersen
The old isARM() function was a portability trap. With the name it had, it seemed like the obviously correct function to use, but it didn't include Thumb. In the vast majority of cases where someone wants to ask "is the target Arm?", Thumb *should* be included. There are exactly 3 cases in the codebase where we do actually need to exclude Thumb, although one of those is in Aro and mirrors a check in Clang that is itself likely a bug. These rare cases can just add an extra isThumb() check.
2024-11-02compiler: Handle arm_aapcs16_vfp alongside arm_aapcs_vfp in some places.Alex Rønne Petersen
2024-11-02llvm: Fix lowering of gnuilp32 ABI to be gnu_ilp32.Alex Rønne Petersen
LLVM doesn't even recognize the gnuilp32 spelling as an alternative.
2024-11-02std.Target: Add muslabin32 and muslabi64 tags to Abi.Alex Rønne Petersen
Once we upgrade to LLVM 20, these should be lowered verbatim rather than to simply musl. Similarly, the special case in llvmMachineAbi() should go away.
2024-11-02std.Target: Remove armv7k/armv7s.Alex Rønne Petersen
Like d1d95294fd657f771657ea671a6984b860347fb0, this is more Apple nonsense where they abused the arch component of the triple to encode what's really an ABI. Handling this correctly in Zig's target triple model would take quite a bit of work. Fortunately, the last Armv7-based Apple Watch was released in 2017 and these targets are now considered legacy. By the time Zig hits 1.0, they will be a distant memory. So just remove them.
2024-11-01std.Target: Add support for specifying Android API level.Alex Rønne Petersen
2024-11-01llvm: Set OS min version and libc version in ~all cases.Alex Rønne Petersen
Except Windows, because that just doesn't really fit into LLVM's target triple format currently.
2024-11-01llvm: Set vendor type in LLVM target triple for more OSs.Alex Rønne Petersen
Annoyingly, LLVM and Clang have various checks throughout that depend on these vendor types being set.
2024-10-31compiler: remove anonymous struct types, unify all tuplesmlugg
This commit reworks how anonymous struct literals and tuples work. Previously, an untyped anonymous struct literal (e.g. `const x = .{ .a = 123 }`) was given an "anonymous struct type", which is a special kind of struct which coerces using structural equivalence. This mechanism was a holdover from before we used RLS / result types as the primary mechanism of type inference. This commit changes the language so that the type assigned here is a "normal" struct type. It uses a form of equivalence based on the AST node and the type's structure, much like a reified (`@Type`) type. Additionally, tuples have been simplified. The distinction between "simple" and "complex" tuple types is eliminated. All tuples, even those explicitly declared using `struct { ... }` syntax, use structural equivalence, and do not undergo staged type resolution. Tuples are very restricted: they cannot have non-`auto` layouts, cannot have aligned fields, and cannot have default values with the exception of `comptime` fields. Tuples currently do not have optimized layout, but this can be changed in the future. This change simplifies the language, and fixes some problematic coercions through pointers which led to unintuitive behavior. Resolves: #16865
2024-10-31zig_llvm: Reduce our exposure to LLVM API breakage.Alex Rønne Petersen
LLVM recently introduced new Triple::ArchType members in 19.1.3 which broke our static assertions in zig_llvm.cpp. When implementing a fix for that, I realized that we don't even need a lot of the stuff we have in zig_llvm.(cpp,h) anymore. This commit trims the interface down considerably.
2024-10-27implement new interrupts in the llvm backendDavid Rubin
2024-10-25Merge pull request #21710 from alexrp/function-alignmentAlex Rønne Petersen
Some improvements to the compiler's handling of function alignment
2024-10-23Merge pull request #21758 from kcbanner/dll_storage_classAndrew Kelley
Add `is_dll_import` to @extern, to support `__declspec(dllimport)` with the MSVC ABI
2024-10-22Cause a compilation error to occur if using @extern with is_dll_import in a ↵kcbanner
comptime scope. Add a note about thread local / dll import being the cause.
2024-10-22Add support for specifying `dll_storage_class` in @externkcbanner
2024-10-20llvm: Add some missing fnptr alignment specifications in DataLayoutBuilder.Alex Rønne Petersen
2024-10-19llvm: fix lowering `arm_aapcs_vfp` functionsmlugg
2024-10-19llvn: fix incorrect mips64 callconv handlingmlugg
2024-10-19llvm: fix lowering of avr_interrupt and m68k_interrupt callconvsmlugg
2024-10-19std.Target: rename `defaultCCallingConvention` and `Cpu.Arch.fromCallconv`mlugg
2024-10-19std: update for new `CallingConvention`mlugg
The old `CallingConvention` type is replaced with the new `NewCallingConvention`. References to `NewCallingConvention` in the compiler are updated accordingly. In addition, a few parts of the standard library are updated to use the new type correctly.
2024-10-19compiler: introduce new `CallingConvention`mlugg
This commit begins implementing accepted proposal #21209 by making `std.builtin.CallingConvention` a tagged union. The stage1 dance here is a little convoluted. This commit introduces the new type as `NewCallingConvention`, keeping the old `CallingConvention` around. The compiler uses `std.builtin.NewCallingConvention` exclusively, but when fetching the type from `std` when running the compiler (e.g. with `getBuiltinType`), the name `CallingConvention` is used. This allows a prior build of Zig to be used to build this commit. The next commit will update `zig1.wasm`, and then the compiler and standard library can be updated to completely replace `CallingConvention` with `NewCallingConvention`. The second half of #21209 is to remove `@setAlignStack`, which will be implemented in another commit after updating `zig1.wasm`.
2024-10-17Merge pull request #21610 from alexrp/riscv-abisAndrew Kelley
Fix some RISC-V ABI issues and add ILP32/LP64 (soft float) to module tests
2024-10-16llvm: Disable f16 lowering for loongarch.Alex Rønne Petersen
This should be reverted with LLVM 20.
2024-10-16llvm: Fix natural int width specifications for loongarch in DataLayoutBuilder.Alex Rønne Petersen
2024-10-15llvm: Enable native f16 lowering for riscv32.Alex Rønne Petersen
2024-10-15llvm: Fix compiler crash when lowering f16 for riscv32 ilp32.Alex Rønne Petersen
2024-10-12implement packed struct equality (#21679)David Rubin
2024-10-06Merge pull request #21605 from alexrp/ohos-stuffAlex Rønne Petersen
`std.Target`: Introduce `Abi.ohoseabi` to distinguish the soft float case.
2024-10-06Merge pull request #21587 from alexrp/hexagon-portingAlex Rønne Petersen
Some initial `hexagon-linux` port work
2024-10-05std.Target: Introduce Abi.ohoseabi to distinguish the soft float case.Alex Rønne Petersen
For the same reason as #21504.
2024-10-05Merge pull request #21574 from alexrp/llvm-sub-archAlex Rønne Petersen
`llvm`: Implement sub-architecture translation in `targetTriple()`.
2024-10-04remove `@fence` (#21585)David Rubin
closes #11650