Commit graph

66 commits

Author SHA1 Message Date
David Rubin
d9e0cafe64 riscv: add stage2_riscv to test matrix and bypass failing tests 2024-05-11 02:17:24 -07:00
Tristan Ross
6067d39522
std.builtin: make atomic order fields lowercase 2024-03-11 07:09:10 -07:00
Jacob Young
917b4ad5e0 x86_64: implement more atomic ops 2023-12-03 10:22:06 -05:00
Jacob Young
8a9f8a1d77 behavior: disable another test regressed by LLVM 17 for mips
Tracked by #16846
2023-09-19 09:37:53 -07:00
Jacob Young
d65318847f compiler_rt: fix fp sub being optimized to call itself
Closes #16844
Reduces #16846
2023-09-19 09:37:52 -07:00
Andrew Kelley
8219711063 disable behavior tests regressed by LLVM 17
See #16844
See #16845
See #16846
See #16848
2023-09-19 09:37:50 -07:00
mlugg
f26dda2117 all: migrate code to new cast builtin syntax
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-24 16:56:39 -07:00
Eric Joldasov
d884d7050e
all: replace comptime try with try comptime
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-13 23:46:58 +06:00
Luuk de Gram
1042deb86f
enable passing behavior tests 2023-05-31 18:04:33 +02:00
Robin Voetter
37aa343079
spirv: more passing tests 2023-05-20 17:30:22 +02:00
Ali Chraghi
ccc490ef68
setup spirv backend in behavior tests 2023-05-11 20:31:52 +02:00
Jacob Young
c388960042 x86_64: fix large not and atomicrmw 2023-05-01 19:22:52 -04:00
Luuk de Gram
1d97181703
wasm: enable atomics behavior tests 2023-04-26 16:28:41 +02:00
Jacob Young
d56c6c7791 cbe: implement 128-bit atomics support
* Disable 128-bit atomics for x86_64 generic (currently also baseline)
   because they require heavy abi agreement to correctly lower.
   ** This is a breaking change **
 * Enable 128-bit atomics for aarch64 in Sema since it just works.
2023-04-21 16:36:31 -04:00
Jacob Young
d98974e826 cbe: fix issues with atomic floats
Since the Zig language documentation claims support for `.Min` and
`.Max` in `@atomicRmw` with floats, allow in Sema and implement for both
the llvm and C backends.
2023-04-21 16:36:30 -04:00
Andrew Kelley
4a233d1871 CI: more C backend test coverage
The CI now runs C backend tests in addition to compiling them. It uses
-std=c99 -pedantic -Werror in order to catch non-conformant C code.

This necessitated disabling a test case that caused a C compile error,
in addition to disabling a handful of warnings that are already being
triggered by Zig's C backend output for the behavior tests.

The upshot is that I was able to, very cleanly, integrate the C backend
tests into the build system, so that it communicates via the test runner
protocol along with all the other behavior tests.
2023-04-15 10:33:08 -07:00
Jacob Young
3b22ce8264 x86_64: fix atomic loop implementation 2023-04-13 04:17:47 -04:00
Jacob Young
6d9bdc8733 x86_64: fix cmpxchg 2023-03-25 16:23:55 -04:00
Jacob Young
f316cb29cc x86_64: implement atomic and fence ops 2023-03-21 08:49:54 +01:00
Andrew Kelley
0b99c83c21 fix behavior test compile error
I bungled the commit 995c36dcb1 during the
merge. Sorry about that.
2023-01-02 15:02:33 -07:00
Andrew Kelley
995c36dcb1 avoid testing inline for in unrelated behavior tests 2023-01-02 14:09:01 -07:00
kcbanner
4776128099 skip "atomicrmw with 128-bit ints" on everything except cbe 2023-01-02 13:56:32 -07:00
kcbanner
8ebf18635c skip "atomicrmw with 128-bit ints" on linux x64_64 due to linker error 2023-01-02 13:56:32 -07:00
kcbanner
9c951cc874 fmt fixups 2023-01-02 13:56:32 -07:00
kcbanner
9c70315854 tests: add more coverage for 128 bit operations
- fixup 128-bit atomics test to only run on x86_64
- add truncation test for 128-bit types, including non power of two targets (there was a bug with broken non-power-of-two truncation in the cbe)
- add 128-bit binary not test (covers another bug fixed in the cbe)
2023-01-02 13:55:45 -07:00
kcbanner
5d59799641 cbe: add msvc flt atomics, re-enable test 2023-01-01 16:44:29 -05:00
kcbanner
6ed049fe36 cbe: all behaviour tests now pass on msvc
- Fix zig_clz_u128 not respecting the bits argument. This was crashing the compile-rt addxf3 tests with the cbe
- Instead of redering a negation for negative 128 bit int literals, render the literal as twos complement. This allows
rendering int representations of floats correctly (specifically f80).
2023-01-01 16:44:29 -05:00
kcbanner
6445196fab tests: disable function alignment test for cbe, add 128-bit atomicrmw tests 2023-01-01 16:44:29 -05:00
kcbanner
5470708a89 cbe: implement 128 bit atomic operations with cmpxchg loops
- Enable 128 bit atomic int tests for the cbe only
2023-01-01 16:44:29 -05:00
kcbanner
5b8245d35a tests: update "atomicrmw with ints" to test u8 through u64 2023-01-01 16:44:29 -05:00
kcbanner
2d34477dbb cbe: msvc atomics
- Implement most atomic operations for msvc
- Disable "atomicrmw with floats" test for cbe
2023-01-01 16:44:28 -05:00
Andrew Kelley
5ca1753ff1 Revert "aarch64: reenable tests that are no longer regressed"
This reverts commit 3370d58956.

This commit was done with an LLVM build that did not have assertions
enabled. There are LLVM assertions being triggered due to this commit.

Reopens #10627
Reopens #12013
Reopens #12027
2022-12-27 20:54:27 -07:00
r00ster91
3370d58956 aarch64: reenable tests that are no longer regressed
Closes #12013
Closes #10627
Closes #12027
2022-12-10 12:34:34 +01:00
Andrew Kelley
c8aba15c22 remove references to stage1 in behavior tests
Good riddance.
2022-12-06 19:06:48 -07:00
Jacob Young
b35514ecfe cbe: disable aarch64 behavior tests that are broken with gcc 2022-10-31 21:01:04 -04:00
Jacob Young
912b84bbad cbe: fix atomics 2022-10-25 05:11:29 -04:00
Jacob Young
6a4266d62a cbe: fix infinite recursion on recursive types 2022-10-25 05:11:28 -04:00
Koakuma
672d6df429 stage2: sparc64: Skip Sema-failing tests for now 2022-06-24 21:19:33 +07:00
Andrew Kelley
5b1c0d922c stage2: improve semantics of atomic operations
ZIR instructions updated: atomic_load, atomic_rmw, atomic_store, cmpxchg
These no longer construct a pointer type as the result location. This
solves a TODO that was preventing the pointer from possibly being
volatile, as well as properly handling allowzero and addrspace.
It also allows the pointer to be over-aligned, which may be needed
depending on the target. As a consequence, the element type needs to be
communicated in the ZIR. This is done by strategically making one of the
operands be ResultLoc.ty instead of ResultLoc.coerced_ty if possible, or
otherwise explicitly adding elem_type into the ZIR encoding, such as in
the case of atomic_load.

The pointer type of atomic operations is now checked in Sema by coercing
it to an expected pointer type, that maybe over-aligned according to
target requirements.

Together with the previous commit, Zig now has smaller alignment for
large integers, depending on the target, and yet still has type safety
for atomic operations that specially require higher alignment.
2022-05-04 17:34:16 -07:00
Andrew Kelley
cf4aad4858 AstGen: fix referencing unreferencable instructions
Sema avoids adding map entries for certain instructions such as
`set_eval_branch_quota` and `atomic_store`. This means that result
location semantics in AstGen must not emit any instructions that attempt
to use the result of any of these instructions.

This commit makes AstGen replace such instructions with
`Zir.Inst.Ref.void_value` if their result value ends up being
referenced.

This fixes a compiler crash when running std lib atomic tests.
2022-03-30 23:19:10 -07:00
Andrew Kelley
d4a0d5f959 Sema: implement @truncate for SIMD vectors 2022-03-15 15:09:48 -07:00
Andrew Kelley
de5908548c disable failing atomicrmw test on llvm + aarch64 2022-01-18 21:25:22 -07:00
Andrew Kelley
4d05f2ae5f remove zig_is_stage2 from @import("builtin")
Instead use the standarized option for communicating the
zig compiler backend at comptime, which is `zig_backend`. This was
introduced in commit 1c24ef0d0b.
2022-01-17 21:55:49 -07:00
Andrew Kelley
b0f80ef0d5 stage2: remove use of builtin.stage2_arch workaround
The LLVM backend no longer needs this hack! However, the other backends
still do. So there are still some traces of this workaround in use for now.
2021-10-13 18:43:43 -07:00
Andrew Kelley
6115cf2240 migrate from std.Target.current to @import("builtin").target
closes #9388
closes #9321
2021-10-04 23:48:55 -07:00
Andrew Kelley
abc30f7948 stage2: improve handling of 0 bit types
* Sema: zirAtomicLoad handles 0-bit types correctly
 * LLVM backend: when lowering function types, elide parameters
   with 0-bit types.
 * Type: abiSize handles u0/i0 correctly
2021-09-20 16:48:42 -07:00
Andrew Kelley
4b2d7a9c67 stage2: implement comptime bitwise nand 2021-09-20 15:44:09 -07:00
Andrew Kelley
b9d3527e0e stage2: implement comptime @atomicRmw
* introduce float_to_int and int_to_float AIR instructionts and
   implement for the LLVM backend and C backend.
 * Sema: implement `zirIntToFloat`.
 * Sema: implement `@atomicRmw` comptime evaluation
   - introduce `storePtrVal` for when one needs to store a Value to a
     pointer which is a Value, and assert it happens at comptime.
 * Value: introduce new functionality:
   - intToFloat
   - numberAddWrap
   - numberSubWrap
   - numberMax
   - numberMin
   - bitwiseAnd
   - bitwiseNand (not implemented yet)
   - bitwiseOr
   - bitwiseXor
 * Sema: hook up `zirBitwise` to the new Value bitwise implementations
 * Type: rename `isFloat` to `isRuntimeFloat` because it returns `false`
   for `comptime_float`.
2021-09-20 14:24:43 -07:00
Andrew Kelley
9fa723ee50 stage2: implement @atomicStore 2021-09-19 15:08:38 -07:00
Andrew Kelley
b58d8aa05f stage2: improve LLVM backend for enums
* support lowering enum types and constants to LLVM IR
 * fix cmp instruction to support enum operands
2021-09-16 21:57:46 -07:00