1967 Commits

Author SHA1 Message Date
Alex Rønne Petersen
3550cacd73
llvm: Fix compiler crash when lowering f16 for riscv32 ilp32. 2024-10-15 19:29:56 +02:00
Robin Voetter
e2e79960d2
Merge pull request #21688 from Snektron/spirv-fix
spirv: fix some bitrot
2024-10-13 22:33:03 +02:00
David Rubin
e131a2c8e2
implement packed struct equality (#21679) 2024-10-12 20:59:12 -07:00
Robin Voetter
c1132edd53
spirv: don't generate OpUnreachable after noreturn call
It seems that these are now automatically added to AIR in Sema.
2024-10-13 01:57:35 +02:00
Robin Voetter
973f846251
spirv: implement repeat and dbg_arg_inline 2024-10-13 01:57:06 +02:00
Robin Voetter
3cd19b8884
spirv: don't try to lower types which have no runtime bits 2024-10-13 01:56:33 +02:00
Alex Rønne Petersen
ece265b1c2
Merge pull request #21605 from alexrp/ohos-stuff
`std.Target`: Introduce `Abi.ohoseabi` to distinguish the soft float case.
2024-10-06 16:26:24 +02:00
Alex Rønne Petersen
be5378b038
Merge pull request #21587 from alexrp/hexagon-porting
Some initial `hexagon-linux` port work
2024-10-06 13:35:56 +02:00
Alex Rønne Petersen
84e192c88b
std.Target: Introduce Abi.ohoseabi to distinguish the soft float case.
For the same reason as #21504.
2024-10-05 15:13:37 +02:00
Alex Rønne Petersen
d23db9427b
Merge pull request #21574 from alexrp/llvm-sub-arch
`llvm`: Implement sub-architecture translation in `targetTriple()`.
2024-10-05 13:49:05 +02:00
David Rubin
043b1adb8d
remove @fence (#21585)
closes #11650
2024-10-04 22:21:27 +00:00
Felix Queißner
7c74edec8d
Adds new cpu architectures propeller1 and propeller2. (#21563)
* Adds new cpu architectures propeller1 and propeller2.

These cpu architectures allow targeting the Parallax Propeller 1 and Propeller 2, which are both very special microcontrollers with 512 registers and 8 cpu cores.

Resolves #21559

* Adds std.elf.EM.PROPELLER and std.elf.EM.PROPELLER2
* Fixes missing switch prongs in src/codegen/llvm.zig
* Fixes order in std.Target.Arch

---------

Co-authored-by: Felix "xq" Queißner <git@random-projects.net>
2024-10-04 13:53:28 -07:00
Alex Rønne Petersen
eb363bf845
Merge pull request #21572 from alexrp/tests-llvm-targets
`test`: Rewrite the target triple list for `llvm_targets`.
2024-10-04 19:37:12 +02:00
Alex Rønne Petersen
f31173d379
llvm: Disable f16 lowering for hexagon.
In theory, this should work for v68+. In practice, it runs into an LLVM
assertion when using a `freeze` instruction on `f16` values, similar to the
issue we had for LoongArch.
2024-10-03 09:53:59 +02:00
Alex Rønne Petersen
b4ddff396d
llvm: Fix C ABI integer promotion for s390x. 2024-10-03 06:19:23 +02:00
Alex Rønne Petersen
3f322c49bc
std.Target: Remove Os.Tag.shadermodel.
This was a leftover from the Cpu.Arch.dxil removal.
2024-10-03 05:01:24 +02:00
Alex Rønne Petersen
85bf1e2b1f
llvm: Implement sub-architecture translation in targetTriple(). 2024-10-03 02:39:12 +02:00
Alex Rønne Petersen
e0ac776749
Merge pull request #21504 from alexrp/android-softfp
`std.Target`: Introduce `Abi.androideabi` to distinguish the soft float case.
2024-10-03 00:15:35 +02:00
Andrew Kelley
1b491e640d fixes and make sema report errors when std.builtin wrong
instead of panicking
2024-09-26 16:06:05 -07:00
Andrew Kelley
b66cc5af41 reimplement integer overflow safety panic function calls
in the llvm backend.
2024-09-26 12:35:14 -07:00
Andrew Kelley
9ccf8d3332 fixes for this branch
I had to bring back some of the old API so that I could compile the new
compiler with an old compiler.
2024-09-26 12:35:14 -07:00
Alex Rønne Petersen
ebbc50d8be
std.Target: Introduce Abi.androideabi to distinguish the soft float case.
Abi.android on its own is not enough to know whether soft float or hard float
should be used. In the C world, androideabi is typically used for the soft float
case, so let's go with that.

Note that Android doesn't have a hard float ABI, so no androideabihf.

Closes #21488.
2024-09-24 09:23:24 +02:00
Alex Rønne Petersen
d1901c744c std.Target: Remove Cpu.Arch.dxil and ObjectFormat.dxcontainer.
See: https://devblogs.microsoft.com/directx/directx-adopting-spir-v

Since we never hooked up the (experimental) DirectX LLVM backend, we've never
actually supported targeting DXIL in Zig. With Microsoft moving away from DXIL,
that seems very unlikely to change.
2024-09-23 17:17:25 -07:00
Alex Rønne Petersen
894b732630 Partially revert "LLVM: work around @floatFromInt bug"
This partially reverts commit ab4d6bf468bd8cba4ffd2d700d83e9707f5307b1.
2024-09-19 18:20:21 -07:00
Alex Rønne Petersen
a4d0a01243 std.Target: Add bridgeos tag to Os. 2024-09-19 18:20:21 -07:00
Alex Rønne Petersen
a27f4072ec llvm: Stop emitting shl/xor ops for constant packed structs.
This is no longer supported in LLVM 19; fall back to the generic code path.
2024-09-19 18:20:21 -07:00
Alex Rønne Petersen
973ebeb610 zig_llvm: Update to LLVM 19. 2024-09-19 18:20:20 -07:00
Linus Groh
8588964972 Replace deprecated default initializations with decl literals 2024-09-12 16:01:23 +01:00
Andrew Kelley
4fba7336a9
Merge pull request #21269 from alexrp/soft-float
Fix soft float support, split musl triples by float ABI, and enable CI
2024-09-11 17:41:55 -07:00
Alex Rønne Petersen
2fc1f9b971 llvm: Don't use the optimized jump table construction logic for wasm. 2024-09-10 16:09:43 -07:00
Alex Rønne Petersen
70c92331c7
llvm: Limit f16/f128 lowering on arm to fp_armv8 and soft float. 2024-09-10 08:53:30 +02:00
Alex Rønne Petersen
6836799935
llvm: Set use-soft-float and noimplicitfloat on functions for soft float.
Closes #10961.
2024-09-10 08:53:30 +02:00
Maciej 'vesim' Kuliński
fb0028a0d7 mips: fix C ABI compatibility 2024-09-07 23:46:30 -07:00
Andrew Kelley
5f3d9e0b7a
Merge pull request #21261 from alexrp/riscv32
More `riscv32-linux` port work
2024-09-06 17:43:10 -07:00
Alex Rønne Petersen
92517fbd62
llvm: Set float ABI based on std.Target.floatAbi(). 2024-09-06 20:11:47 +02:00
Alex Rønne Petersen
ae10adb6ef
llvm: Don't lower to f16 for riscv32.
This causes so many test failures that I doubt this has been tested at all.
2024-09-06 20:03:15 +02:00
Andrew Kelley
3929cac154
Merge pull request #21257 from mlugg/computed-goto-3
compiler: implement labeled switch/continue
2024-09-04 18:31:28 -07:00
mlugg
289c704b60
cbe: don't emit 'x = x' in switch dispatch loop 2024-09-01 20:31:01 +01:00
mlugg
5e12ca9fe3
compiler: implement labeled switch/continue 2024-09-01 18:30:31 +01:00
mlugg
5fb4a7df38
Air: add explicit repeat instruction to repeat loops
This commit introduces a new AIR instruction, `repeat`, which causes
control flow to move back to the start of a given AIR loop. `loop`
instructions will no longer automatically perform this operation after
control flow reaches the end of the body.

The motivation for making this change now was really just consistency
with the upcoming implementation of #8220: it wouldn't make sense to
have this feature work significantly differently. However, there were
already some TODOs kicking around which wanted this feature. It's useful
for two key reasons:

* It allows loops over AIR instruction bodies to loop precisely until
  they reach a `noreturn` instruction. This allows for tail calling a
  few things, and avoiding a range check on each iteration of a hot
  path, plus gives a nice assertion that validates AIR structure a
  little. This is a very minor benefit, which this commit does apply to
  the LLVM and C backends.

* It should allow for more compact ZIR and AIR to be emitted by having
  AstGen emit `repeat` instructions more often rather than having
  `continue` statements `break` to a `block` which is *followed* by a
  `repeat`. This is done in status quo because `repeat` instructions
  only ever cause the direct parent block to repeat. Now that AIR is
  more flexible, this flexibility can be pretty trivially extended to
  ZIR, and we can then emit better ZIR. This commit does not implement
  this.

Support for this feature is currently regressed on all self-hosted
native backends, including x86_64. This support will be added where
necessary before this branch is merged.
2024-09-01 18:30:31 +01:00
mlugg
1b000b90c9
Air: direct representation of ranges in switch cases
This commit modifies the representation of the AIR `switch_br`
instruction to represent ranges in cases. Previously, Sema emitted
different AIR in the case of a range, where the `else` branch of the
`switch_br` contained a simple `cond_br` for each such case which did a
simple range check (`x > a and x < b`). Not only does this add
complexity to Sema, which we would like to minimize, but it also gets in
the way of the implementation of #8220. That proposal turns certain
`switch` statements into a looping construct, and for optimization
purposes, we want to lower this to AIR fairly directly (i.e. without
involving a `loop` instruction). That means we would ideally like a
single instruction to represent the entire `switch` statement, so that
we can dispatch back to it with a different operand as in #8220. This is
not really possible to do correctly under the status quo system.

This commit implements lowering of this new `switch_br` usage in the
LLVM and C backends. The C backend just turns any case containing ranges
entirely into conditionals, as before. The LLVM backend is a little
smarter, and puts scalar items into the `switch` instruction, only using
conditionals for the range cases (which direct to the same bb). All
remaining self-hosted backends are temporarily regressed in the presence
of switch range cases. This functionality will be restored for at least
the x86_64 backend before merge.
2024-09-01 18:30:31 +01:00
Jacob Young
49ad51b2fe
Builder: add indirectbr llvm instruction 2024-09-01 18:30:31 +01:00
antlilja
15b4c01ab1 Rename usesLargePIC to picLevel and return the PIC level 2024-09-01 15:12:49 +02:00
antlilja
76908da3ac LLVM: Set module flag behaviors to match what LLVM and clang does 2024-09-01 14:43:30 +02:00
antlilja
7cb87c14fe LLVM: Remove cpp bindings for setPICLevel, setPIELevel and setCodeModel 2024-09-01 14:21:19 +02:00
antlilja
629bd90e26 LLVM: Emit module flags through Builder instead of LLVM API 2024-09-01 14:10:56 +02:00
Andrew Kelley
e4e91a1314
Merge pull request #21224 from alexrp/mips-gnu-fixes
Fix MIPS PIC level and work around an LLVM bug for `mips(el)-linux-gnueabi(hf)`
2024-08-30 14:47:43 -07:00
Alex Rønne Petersen
5723fcaac1 llvm: Pass EmitOptions to libzigcpp by pointer.
Passing it by value means that bringup on new architectures is harder for no
real benefit. Passing it by pointer allows to get the compiler running without
needing to figure out the C calling convention details first. This manifested in
practice on LoongArch, for example.
2024-08-30 11:02:12 -07:00
mlugg
c62487da76
compiler: avoid field/decl name conflicts
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-29 23:43:52 +01:00
Andrew Kelley
c81219c573 LLVM: use @llvm.used instead of @llvm.compiler.used
because it marks the linker section, preventing garbage collection.

Also, name the members because that is required by this intrinsic.

Also, enable the StackDepth option in the sancov pass as a workaround
for https://github.com/llvm/llvm-project/pull/106464, otherwise, LLVM
enables TracePCGuard even though we explicitly disable it.
2024-08-28 18:07:13 -07:00