aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/llvm.zig
AgeCommit message (Collapse)Author
2025-11-20update deprecated ArrayListUnmanaged usage (#25958)Benjamin Jurk
2025-11-19llvm: fix lowering of packed struct constantsMatthew Lugg
The big-endian logic here was simply incorrect. Luckily, it was also overcomplicated; after calling `Value.writeToPackedMemory`, there is a method on `std.math.big.int.Mutable` which just does the correct endianness load for us.
2025-11-16Dedupe types when printing error messagesProkop Randáček
2025-11-15Legalize: implement soft-float legalizationsMatthew Lugg
A new `Legalize.Feature` tag is introduced for each float bit width (16/32/64/80/128). When e.g. `soft_f16` is enabled, all arithmetic and comparison operations on `f16` are converted to calls to the appropriate compiler_rt function using the new AIR tag `.legalize_compiler_rt_call`. This includes casts where the source *or* target type is `f16`, or integer<=>float conversions to or from `f16`. Occasionally, operations are legalized to blocks because there is extra code required; for instance, legalizing `@floatFromInt` where the integer type is larger than 64 bits requires calling an arbitrary-width integer conversion function which accepts a pointer to the integer, so we need to use `alloc` to create such a pointer, and store the integer there (after possibly zero-extending or sign-extending it). No backend currently uses these new legalizations (and as such, no backend currently needs to implement `.legalize_compiler_rt_call`). However, for testing purposes, I tried modifying the self-hosted x86_64 backend to enable all of the soft-float features (and implement the AIR instruction). This modified backend was able to pass all of the behavior tests (except for one `@mod` test where the LLVM backend has a bug resulting in incorrect compiler-rt behavior!), including the tests specific to the self-hosted x86_64 backend. `f16` and `f80` legalizations are likely of particular interest to backend developers, because most architectures do not have instructions to operate on these types. However, enabling *all* of these legalization passes can be useful when developing a new backend to hit the ground running and pass a good amount of tests more easily.
2025-11-14represent Mac Catalyst as aarch64-maccatalyst-none rather than ↵Alex Rønne Petersen
aarch64-ios-macabi Apple's own headers and tbd files prefer to think of Mac Catalyst as a distinct OS target. Earlier, when DriverKit support was added to LLVM, it was represented a distinct OS. So why Apple decided to only represent Mac Catalyst as an ABI in the target triple is beyond me. But this isn't the first time they've ignored established target triple norms (see: armv7k and aarch64_32) and it probably won't be the last. While doing this, I also audited all Darwin OS prongs throughout the codebase and made sure they cover all the tags.
2025-11-12Merge pull request #25772 from mlugg/kill-dead-codeMatthew Lugg
compiler: rewrite some legalizations, and remove a bunch of dead code
2025-11-12std.Target: remove Abi.cygnusAlex Rønne Petersen
There is approximately zero chance of the Zig team ever spending any effort on supporting Cygwin; the MSVC and MinGW-w64 ABIs are superior in every way that matters, and not least because they lead to binaries that just run natively on Windows without needing a POSIX emulation environment installed.
2025-11-12Air.Legalize: revert to loops for scalarizationsMatthew Lugg
I had tried unrolling the loops to avoid requiring the `vector_store_elem` instruction, but it's arguably a problem to generate O(N) code for an operation on `@Vector(N, T)`. In addition, that lowering emitted a lot of `.aggregate_init` instructions, which is itself a quite difficult operation to codegen. This requires reintroducing runtime vector indexing internally. However, I've put it in a couple of instructions which are intended only for use by `Air.Legalize`, named `legalize_vec_elem_val` (like `array_elem_val`, but for indexing a vector with a runtime-known index) and `legalize_vec_store_elem` (like the old `vector_store_elem` instruction). These are explicitly documented as *not* being emitted by Sema, so need only be implemented by backends if they actually use an `Air.Legalize.Feature` which emits them (otherwise they can be marked as `unreachable`).
2025-11-12compiler: spring cleaningMatthew Lugg
I started this diff trying to remove a little dead code from the C backend, but ended up finding a bunch of dead code sprinkled all over the place: * `packed` handling in the C backend which was made dead by `Legalize` * Representation of pointers to runtime-known vector indices * Handling for the `vector_store_elem` AIR instruction (now removed) * Old tuple handling from when they used the InternPool repr of structs * Straightforward unused functions * TODOs in the LLVM backend for features which Zig just does not support
2025-11-10Merge pull request #25886 from alexrp/kvxAlex Rønne Petersen
beginnings of KVX target support (via CBE)
2025-11-10llvm: set sub-arch for spirv 1.6Alex Rønne Petersen
2025-11-10std.Target: add Arch tag and info for kvxAlex Rønne Petersen
2025-11-06llvm: add extra clobbers to valgrind requestsDavid Rubin
This seems to work around a very puzzling miscompilation first present in LLVM 21.x. We already unconditionally add these clobbers to inline assembly that came from the source, the valgrind requests should also contain them.
2025-11-06llvm: clobber `rdx` instead of `edx` for x86-64 valgrind requestDavid Rubin
2025-10-29Merge pull request #25592 from ziglang/init-std.IoAndrew Kelley
std: Introduce `Io` Interface
2025-10-29remove all IBM AIX and z/OS supportAlex Rønne Petersen
As with Solaris (dba1bf935390ddb0184a4dc72245454de6c06fd2), we have no way to actually audit contributions for these OSs. IBM also makes it even harder than Oracle to actually obtain these OSs. closes #23695 closes #23694 closes #3655 closes #23693
2025-10-29compiler: update for introduction of std.IoAndrew Kelley
only thing remaining is using libc dns resolution when linking libc
2025-10-28Merge pull request #25691 from GasInfinity-Forks/x86_16-gccAlex Rønne Petersen
feat: init x86_16 arch via CBE
2025-10-27remove all Oracle Solaris supportAlex Rønne Petersen
There is no straightforward way for the Zig team to access the Solaris system headers; to do this, one has to create an Oracle account, accept their EULA to download the installer ISO, and finally install it on a machine or VM. We do not have to jump through hoops like this for any other OS that we support, and no one on the team has expressed willingness to do it. As a result, we cannot audit any Solaris contributions to std.c or other similarly sensitive parts of the standard library. The best we would be able to do is assume that Solaris and illumos are 100% compatible with no way to verify that assumption. But at that point, the solaris and illumos OS tags would be functionally identical anyway. For Solaris especially, any contributions that involve APIs introduced after the OS was made closed-source would also be inherently more risky than equivalent contributions for other proprietary OSs due to the case of Google LLC v. Oracle America, Inc., wherein Oracle clearly demonstrated its willingness to pursue legal action against entities that merely copy API declarations. Finally, Oracle laid off most of the Solaris team in 2017; the OS has been in maintenance mode since, presumably to be retired completely sometime in the 2030s. For these reasons, this commit removes all Oracle Solaris support. Anyone who still wishes to use Zig on Solaris can try their luck by simply using illumos instead of solaris in target triples - chances are it'll work. But there will be no effort from the Zig team to support this use case; we recommend that people move to illumos instead.
2025-10-27feat: init x86_16 arch via CBEGasInfinity
2025-10-25llvm: remove some workarounds in loadTruncate()Alex Rønne Petersen
No longer needed with LLVM 21.
2025-10-23std.builtin: add CallingConvention.sh_interruptAlex Rønne Petersen
Only supported in CBE.
2025-10-23std.builtin: add CallingConvention.microblaze_interruptAlex Rønne Petersen
Only supported in CBE.
2025-10-23std.builtin: add CallingConvention.msp430_interruptAlex Rønne Petersen
Supported by LLVM and CBE.
2025-10-23std.builtin: add CallingConvention.x86_64_x32Alex Rønne Petersen
This was forgotten during the refactoring of std.builtin.CallingConvention. It mirrors mips64_n32 for MIPS.
2025-10-23std.Target: add tags and info for alpha, hppa, microblaze, shAlex Rønne Petersen
2025-10-23std.Target: add arceb and xtensaeb Cpu.Arch tagsAlex Rønne Petersen
2025-10-19compiler: add support for arc_interrupt calling conventionAlex Rønne Petersen
Only for use with the C backend at the moment.
2025-10-16llvm-backend: fix uefi data layoutbnuuydev
the old logic caused the uefi case to fall through which caused an assertion assertion in llvm to fail, as the data layout was wrong.
2025-10-07llvm.Builder: allow `Metadata` to reference metadata stringsJacob Young
Closes #25486
2025-10-02x86_64: fix windows calling convention abiJacob Young
2025-09-26compiler: move self-hosted backends from src/arch to src/codegenAlex Rønne Petersen
2025-09-20llvm backend: remove canElideLoad mechanismAndrew Kelley
2025-09-16llvm: fix tagged union payload size in debug infomlugg
Resolves: #24415
2025-08-30Merge pull request #25077 from ziglang/GenericReaderAndrew Kelley
std.Io: delete GenericReader, AnyReader, FixedBufferStream; and related API breakage
2025-08-30Revert "llvm: workaround crashes in llvm loop optimizations"Alex Rønne Petersen
This reverts commit b4fd57a9c114748afb9ba0a04bede61089a02ddf. https://github.com/llvm/llvm-project/pull/149743
2025-08-30llvm: switch to native f16 IR type for all hexagon targetsAlex Rønne Petersen
This was fixed in LLVM 21, in particular for targets older than v68.
2025-08-30llvm: remove f16 special case for soft float aarch64Alex Rønne Petersen
2025-08-30llvm: switch to native f128 IR type for nvptxAlex Rønne Petersen
LLVM 21 added support for this.
2025-08-30llvm: switch to native f16 IR type for s390xAlex Rønne Petersen
LLVM 21 added support for this.
2025-08-30llvm: update data layout strings for LLVM 21Alex Rønne Petersen
2025-08-30std.Target: add managarm OS tagAlex Rønne Petersen
2025-08-29std.Io: delete GenericReaderAndrew Kelley
and delete deprecated alias std.io
2025-08-29LLVM backend:fix align 1 sret parameter load returnedAndrew Kelley
closes #25067
2025-08-26std.Target: add vita osMaciej 'vesim' Kuliński
Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
2025-08-25start adding big endian RISC-V supportAlex Rønne Petersen
The big endian RISC-V effort is mostly driven by MIPS (the company) which is pivoting to RISC-V, and presumably needs a big endian variant to fill the niche that big endian MIPS (the ISA) did. GCC already supports these targets, but LLVM support will only appear in 22; this commit just adds the necessary target knowledge and checks on our end.
2025-08-22feat(std.Target): add 3ds osGasInfinity
2025-08-13Merge pull request #24816 from mlugg/small-fixesMatthew Lugg
two small fixes
2025-08-13Merge pull request #24674 from Justus2308/undef-shift-bitwiseMatthew Lugg
Sema: Improve comptime arithmetic undef handling
2025-08-13llvm: unions which are equivalent to enums are not by-refmlugg
The LLVM backend lowers unions where all fields are zero-bit as equivalent to their backing enum, and expects them to have the same by-ref-ness in at least one place in the backend, probably more. Resolves: #23577