2603 Commits

Author SHA1 Message Date
Alex Rønne Petersen 1af476d5d8 behavior: re-enable a bunch of behavior tests that now pass
closes https://github.com/ziglang/zig/issues/9660
closes https://github.com/ziglang/zig/issues/21050
closes https://github.com/ziglang/zig/issues/21090
closes https://github.com/ziglang/zig/issues/21091
2026-04-25 21:54:48 +02:00
Alex Rønne Petersen 4eb8640213 Revert "test: skip alternative constraints behavior test on LoongArch"
This reverts commit f90548e740.

The bug was fixed in LLVM 22.
2026-04-25 21:54:48 +02:00
Alex Rønne Petersen a0ad35d0ba Revert "test: disable some vector ctz/clz behavior tests on LoongArch with LSX"
This reverts commit beb25b0430.

The bug was fixed in LLVM 22.
2026-04-25 21:54:48 +02:00
Alex Rønne Petersen 67fa822300 test: disable switch on pointer type behavior test with LLVM
See: https://github.com/llvm/llvm-project/issues/176634

ref https://github.com/ziglang/zig/issues/23509
2026-04-25 21:54:48 +02:00
Pavel Verigo 22945fbbdc stage2-wasm: vector, std tests 2026-04-22 00:19:46 +02:00
rpkak f564a7733c remove code, which is only reached if c_longdouble is only 16 or 32 bits big 2026-04-16 07:05:31 +02:00
K4 bf40264941 add test for comptime-only functions 2026-04-16 01:04:41 +02:00
Andrew Kelley e00b5daa1f Merge pull request 'stage2-wasm: finish bigint support' (#31784) from pavelverigo/zig:wasm-bigint-finish into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31784
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-04-15 23:07:40 +02:00
Pavel Verigo c32f7a4513 stage2-wasm: support assembly 2026-04-15 22:57:41 +02:00
David Rubin 06ab4f702e llvm: correctly bitcast for memset intrinsic path 2026-04-12 05:28:54 +02:00
Andrew Kelley 2322d45d80 Merge pull request 'Implement variadic functions for Win64 in the x86_64 backend' (#31672) from kcbanner/zig:win64_varargs into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31672
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-04-12 01:34:16 +02:00
kcbanner 91dce64d10 - Fixup != .stage2_x86_64 -> == .stage2_llvm in var_args tests 2026-04-11 14:53:55 -04:00
Andrew Kelley 29225ae11b Merge pull request 'x64_86 fix: RMI can accept imm16 only for imul r16,r/m16' (#31234) from mathk/zig:x64_86-misscompfix-rmi16 into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31234
Reviewed-by: jacobly <jacobly@noreply.codeberg.org>
2026-04-11 18:08:07 +02:00
Andrew Kelley cbe468a787 Merge pull request 'Sema: allow @round, @floor, @ceil, and @trunc to coerce to integer types' (#30906) from adria/zig:sema-rounding-casts into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30906
2026-04-11 16:44:41 +02:00
glowsquid 8111d3d63c fix comptime @ptrcasting from a larger type to a smaller one (#31774)
closes #30180

Note from mlugg: this fix is very much a hack, but it definitely won't break anything and it demonstrably fixes one case, so I'm merging it for now with the expectation that I'll be replacing the broken code soon.

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31774
Reviewed-by: mlugg <mlugg@noreply.codeberg.org>
Co-authored-by: glowsquid <sachabarsayuracko@gmail.com>
Co-committed-by: glowsquid <sachabarsayuracko@gmail.com>
2026-04-10 23:31:21 +02:00
David 2c6e5006ed Sema: fix comptime @ptrCast to optional slices 2026-04-10 23:27:13 +02:00
Mathieu Suen 244f5aafca fixup! Adding unwrapped error multiply regression test 2026-04-10 23:23:33 +02:00
Mathieu Suen 7addae8f7d Adding unwrapped error multiply regression test 2026-04-10 23:23:33 +02:00
Jacob Young 1552bc7ad0 x86_64: fix mir rmi signedness 2026-04-10 23:23:33 +02:00
Pavel Verigo 773def30c2 stage2-wasm: fix bug in big endian limb64 + tiny fixes 2026-04-09 00:15:33 +02:00
Pavel Verigo 5b5f828019 test: skip .stage2_c for > 128 bits tests + remove skip for x86_64 2026-04-09 00:14:09 +02:00
Pavel Verigo 07e3e50fd2 stage2-wasm: enabling bigint blocked tests + final fixes 2026-04-09 00:14:09 +02:00
Pavel Verigo f2a842db5c stage2-wasm: sat ops 2026-04-09 00:14:09 +02:00
Pavel Verigo aa7874657b stage2-wasm: bigint div mod rem 2026-04-09 00:14:09 +02:00
Pavel Verigo fff887874e stage2-wasm: @intFromFloat and @floatFromInt 2026-04-09 00:14:09 +02:00
Pavel Verigo df79ea941b stage2-wasm: bigint abs + test min/max 2026-04-09 00:14:09 +02:00
Pavel Verigo 0ebd270d90 stage2-wasm: bigint mulo 2026-04-09 00:14:08 +02:00
Pavel Verigo 58944586be stage2-wasm: bigint support bitops and intcast 2026-04-09 00:14:08 +02:00
Neel 86853ba0a4 Add RISC-V ABI register alias names for inline asm clobbers 2026-04-08 14:37:48 +02:00
Pavel Verigo 557caecaaa stage2-wasm: start big int support 2026-04-02 15:48:43 +02:00
Andrew Kelley 3e0f55fcc7 Merge pull request 'add an ast smith' (#31635) from gooncreeper/zig:ast-smith into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31635
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-04-02 15:41:05 +02:00
Jacob Young 28ae5d4158 llvm: fix missing return attributes
Closes #31636
2026-04-02 14:31:12 +02:00
kcbanner 2b72c0d304 - Fixup producesCompilerRtDynLib conditions
- Fixup skipping the new float varags test on .stage2_llvm
2026-03-28 02:51:20 -04:00
kcbanner 571b151423 - Skip "floating point VaList args" on failing platforms 2026-03-26 00:33:15 -04:00
kcbanner ca99896d73 - x86_64: Copy arguments into the shadow store when generating a variadic function on Win64
- x86_64: Implement @cVaStart for Win64
- x86_64: Implement @cVaArg for Win64
- x86_64: Duplicate floating point register args equivalent integer registers when calling variadic functions on Win64
- tests: Enable var_args tests for the self-hosted backend on windows
- tests: Add var_args test for floating point arguments
2026-03-25 20:05:51 -04:00
Kendall Condon ebca8c2dbb x86_64: fix runtime array concat with comptime slice 2026-03-25 17:27:18 -04:00
squidy239 4c3877069d remove various workarounds for issues that are now fixed (#31567)
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31567
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: squidy239 <sachabarsayuracko@gmail.com>
Co-committed-by: squidy239 <sachabarsayuracko@gmail.com>
2026-03-20 19:58:33 +01:00
Adrià Arrufat c10cb44701 Zir: unify float rounding instructions into round_op 2026-03-20 21:27:38 +09:00
Matthew Lugg 10d523f068 Air.Legalize: fix typo in bitcast legalization
A typo meant that the legalization of vector `@bitCast` was literally
just not considering the operand. Oops!

We had a behavior test which should have caught this, but it wasn't
really testing the right thing, so failed to do so. I've updated it to
test what it's supposed to test, so it fails before this patch and
passes after this patch.

Resolves: https://github.com/ziglang/zig/issues/26008
2026-03-19 15:41:22 +00:00
Justus Klausecker c10089d060 test: enable 'switch arbitrary int size' behavior test for cbe
was disabled in b25d93e7d9
2026-03-18 16:57:40 +01:00
Justus Klausecker 0b857eebeb test: disable 'switch on large types' behavior tests for wasm backend
The self-hosted wasm backend doesn't properly support very large integers yet.
2026-03-18 15:49:14 +01:00
Justus Klausecker dbe787a984 Revert "test: disable switch behavior test switching on type >64bits for cbe"
This reverts commit e91654b1e7.
2026-03-18 15:49:14 +01:00
Justus Klausecker 047df44d71 cbe: fix switch statements on large types
`switch` statements on types >128bits are now lowered to conditionals.
This is necessary because Zig lowers integers with more than 128 bits to
bigints, which are not 'native' integers and thus cannot be used as case
values.
128-bit integers get special treatment because Zig will emit actual 128bit
ints if they are supported by the target. They still *may* be lowered to
bigints though, e.g. for 32-bit targets or MSVC. To solve this, this commit
adds a bunch of switch macros to `zig.h` which will either resolve to an
actual `switch` statement or to conditionals. The `if` statements this
approach can generate are not as optimal as they could be but I think this
is a good trade-off since the generated `switch` statements are still the
same as the ones generated for smaller integers. Also the macros result
in pretty readable code.
2026-03-18 15:47:18 +01:00
Justus Klausecker 524345b635 Sema: handle containers as inline assembly output types correctly
Inline assembly now rejects output types that don't have a well-defined
in-memory layout and correctly resolves the layout of the ones that do.
2026-03-17 01:51:55 +01:00
Andrew Kelley 58890066d9 Merge pull request 'Sema: Support peer type resolution for floats and small integers' (#30921) from jayschwa/zig:ptr-small-int-and-floats into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30921
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-03-12 00:41:05 +01:00
Andrew Kelley 109d01371e Merge pull request 'Sema: implement switch for packed structs/unions' (#31464) from justusk/zig:packed-switch into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31464
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-03-12 00:39:19 +01:00
Pavel Verigo 2802276091 stage2-wasm: address TODO in instruction selection code
This PR started as addressing the long-standing TODO above `buildOpcode`:

    /// TODO: deprecated, should be split up per tag.

The code around this area was written a long time ago and has effectively
become a legacy approach. When I started doing semi-occasional work for
bringing >128-bit integer operations to the wasm backend, which is
the last big missing piece of this backend, this design became annoying.

While thinking about how to support that work, and also how vector unrolling
should be handled (in cases where we do not rely purely on the legalize pass),
I decided to do some architectural changes were needed.

The first step is removing helpers like `intBinOp`, `floatBinOp`, `UnOp`, etc.
They do not really capture all operations and resulted in a lot of small
pieces of code trying to artificially unify different ops.

Instead, the direction taken here is similar to `Sema/arith.zig`,  introduce
backend-oriented helpers such as `int*Op*Scalar` and `float*Op*` that operate
purely in backend structures without referencing AIR at all.

Additionally, the idea of introducing dedicated `IntType` and `FloatType`
types was chosen. Using `Type` from Sema inside the backend is awkward,
especially when strange or temporary types are needed. Creating them through
`PerThread` is also undesirable since the backend strives to not modify
`InternPool`. This goal is not fully achieved yet, some parts still require
changes, and `InternPool` type formatting still requires `pt` for error
reporting.

This PR also enables legalize passes for some packed operations. The previous
code in this area was buggy, and given the current state of the backend,
relying on legalization is simpler.

Finally, this PR disables one behavior test: `atomicrmw` with floats. The test
seems to only run the non-concurrency path, because it would crash otherwise,
and since we do not currently run behavior tests for the self-hosted backend
with concurrency or atomics enabled, it does not provide meaningful coverage yet.

In summary, this refactor reworks instruction selection in the wasm backend
to simplify the code and make future work, especially adding big integer
support.
2026-03-11 22:46:58 +01:00
Justus Klausecker e91654b1e7 test: disable switch behavior test switching on type >64bits for cbe
workaround for #31467
2026-03-11 21:14:43 +01:00
Justus Klausecker 28886ca9ec Sema: implement switch for packed structs/unions
Since packed containers are now represented by `bitpack` and can't include
pointers anymore this has become a very easy change to make. This commit
largely just reuses the logic already in place for integers.

Also fixes a small bug where captures-by-ref of errors wouldn't cause a
compile error for regular switch statements. There was already an astgen
error in place for error handling switch statements (`switch_block_err_union`)
capturing their error by reference.
2026-03-11 21:04:04 +01:00
Jay Petacat fcf64761d0 Sema: Support peer type resolution for floats and small integers
This builds on the changes in PR #30053 / commit 484cc15366.

Previously, peer type resolution would always result in a conflict for
fixed-width integer and float types. Now that small integer types can
coerce to floats, peer type resolution can take that into account. This
primarily benefits arithmetic with mixed float and integer operands. If
the integer operand can coerce to the float operand's type, it will do
so without requiring an explicit cast. If the integer type can't coerce,
there will be a compiler error; no float widening will occur. Explicit
casting will still be required to make it work.
2026-03-11 11:31:58 -06:00