250 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
Pavel Verigo 07e3e50fd2 stage2-wasm: enabling bigint blocked tests + final fixes 2026-04-09 00:14:09 +02: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
Matthew Lugg a3d2f2999f tests: add new tests
Some for bugs which have been fixed, some for language changes.
2026-03-10 11:28:36 +00:00
Matthew Lugg bb78871aa4 behavior: re-introduce some previously-removed tests
Now that struct default value resolution is separate from struct layout
resolution, a handful of old behavior tests are now once again valid.

This partially reverts the commit titled "behavior: update for changes
to struct field default value resolution".
2026-03-10 10:26:13 +00:00
Matthew Lugg 12ddd5a698 behavior: update for changes to struct field default value resolution
This is separate from the previous commit so that these changes can be
easily reverted in the event that we decide to allow more granularity in
default value resolution in exchange for increased language complexity.
2026-03-10 10:26:11 +00:00
Matthew Lugg c9fc921abd tests: update for accepted language change
Pointers to comptime-only types (e.g. `*type`) are no longer themselves
comptime-only types. This means explicit `comptime` annotations are
required in a few more places. However, it also introduces the ability
to access pointers to (including slices of) comptime-only types at
runtime, provided only runtime fields are being accessed.
2026-03-10 10:26:10 +00:00
Andrew Kelley 4d6f4e9cfd behavior: add coverage for extern struct field overalignment 2026-01-29 19:56:46 +01:00
Jacob Young ac64c75876 Dwarf: implement pointers to more comptime values
Closes #30600
Closes #30602
2026-01-05 11:24:48 +01:00
Pavel Verigo bf58a3bc08 stage2_wasm: revival, enabling tests 2025-12-07 07:21:15 +01:00
Ali Cheraghi dec1163fbb all: replace all @Type usages
Co-authored-by: Matthew Lugg <mlugg@mlugg.co.uk>
2025-11-22 22:42:38 +00:00
Andrew Kelley 1c9ac9dbb7 add behavior test: avoid unused field function body compile error 2025-09-20 18:51:43 -07:00
Andrew Kelley 2ba03e98c8 disable failing stage2_aarch64 behavior tests 2025-09-20 18:33:01 -07:00
Jacob Young 2fdf0e29b3 aarch64: enable fixed behavior 2025-09-20 18:33:00 -07:00
Andrew Kelley 640c11171b LLVM backend:fix align 1 sret parameter load returned
closes #25067
2025-08-29 03:37:18 -07:00
Andrew Kelley 749f10af49 std.ArrayList: make unmanaged the default 2025-08-11 15:52:49 -07:00
Ali Cheraghi 64563e2fff test: skip tests that were not meant to pass for spirv 2025-08-09 13:27:45 +03:30
Jacob Young c334956a54 aarch64: workaround some optional/union issues 2025-07-28 09:03:17 -07:00
Jacob Young 7894703ee7 aarch64: implement more optional/error union/union support 2025-07-26 21:39:50 -04:00
Jacob Young 5060ab99c9 aarch64: add new from scratch self-hosted backend 2025-07-22 19:43:47 -07:00
Andrew Kelley 34f64432b0 remove usingnamespace from the language
closes #20663
2025-07-07 13:39:48 -07:00
Bingwu Zhang e8d6ecb9ce riscv64: skip failing tests 2025-06-28 06:47:09 +08:00
Jacob Young 1f98c98fff x86_64: increase passing test coverage on windows
Now that codegen has no references to linker state this is much easier.

Closes #24153
2025-06-19 18:41:12 -04:00
Ali Cheraghi 872f68c9cb rename spirv backend name
`stage2_spirv64` -> `stage2_spirv`
2025-06-16 13:22:19 +03:30
Jacob Young 80170d017b Legalize: handle packed semantics
Closes #22915
2025-06-03 15:04:43 -04:00
Jacob Young 1f6f8b0ffe x86_64: implement integer @reduce(.Add) 2025-05-28 15:10:22 -04:00
Ali Cheraghi 9bd8f8ed56 test: skip "struct fields get automatically reordered" for spirv64 backend 2025-04-28 10:49:19 +03:30
Andrew Kelley 65bd8d52c8 Merge pull request #23061 from pavelverigo/stage2-wasm-misc
stage2-wasm: multiple fixes
2025-04-11 15:56:35 -04:00
Jacob Young 9827ffe1de x86_64: fix incorrect handling of unreusable operands
Closes #23448
2025-04-05 20:49:56 -04:00
Pavel Verigo 33ad2c949e stage2-wasm: packed store/load 128 bits 2025-03-24 15:00:00 +01:00
Ali Cheraghi 54c097f50d spirv: packed struct init + field val access 2025-03-18 07:05:48 +03:30
Ali Cheraghi aec0f9b3e7 test: skip failing tests with spirv-vulkan 2025-02-24 19:39:42 +01:00
Jacob Young e5d5a8bc4e x86_64: implement switch jump tables 2025-01-16 20:42:08 -05:00
mlugg d00e05f186 all: update to std.builtin.Type.Pointer.Size field renames
This was done by regex substitution with `sed`. I then manually went
over the entire diff and fixed any incorrect changes.

This diff also changes a lot of `callconv(.C)` to `callconv(.c)`, since
my regex happened to also trigger here. I opted to leave these changes
in, since they *are* a correct migration, even if they're not the one I
was trying to do!
2025-01-16 12:46:29 +00:00
mlugg e9bd2d45d4 Sema: rewrite semantic analysis of function calls
This rewrite improves some error messages, hugely simplifies the logic,
and fixes several bugs. One of these bugs is technically a new rule
which Andrew and I agreed on: if a parameter has a comptime-only type
but is not declared `comptime`, then the corresponding call argument
should not be *evaluated* at comptime; only resolved. Implementing this
required changing how function types work a little, which in turn
required allowing a new kind of function coercion for some generic use
cases: function coercions are now allowed to implicitly *remove*
`comptime` annotations from parameters with comptime-only types. This is
okay because removing the annotation affects only the call site.

Resolves: #22262
2025-01-09 06:46:47 +00:00
Alex Rønne Petersen c9e67e71c1 std.Target: Replace isARM() with isArmOrThumb() and rename it to isArm().
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-03 09:29:30 +01:00
mlugg d11bbde5f9 compiler: remove anonymous struct types, unify all tuples
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-31 20:42:53 +00:00
mlugg 097766bba3 compiler: implement @FieldType
Resolves: #21702
2024-10-18 08:50:40 +01:00
David Rubin bc161430b0 riscv: implement optional_payload_ptr_set 2024-09-12 20:29:10 -04:00
David Rubin fbac7afa0f riscv: implement errunion_payload_ptr_set 2024-09-01 17:34:06 +01:00
mlugg c3fb30803f behavior: avoid field/decl name conflicts 2024-08-29 23:43:52 +01:00
mlugg 0fe3fd01dd std: update std.builtin.Type fields to follow naming conventions
The compiler actually doesn't need any functional changes for this: Sema
does reification based on the tag indices of `std.builtin.Type` already!
So, no zig1.wasm update is necessary.

This change is necessary to disallow name clashes between fields and
decls on a type, which is a prerequisite of #9938.
2024-08-28 08:39:59 +01:00
David Rubin 8da212c11b riscv: update tests and fix reuse bug 2024-07-26 04:19:58 -07:00
David Rubin a1f6a8ef90 riscv: airAsm rewrite
with this rewrite we can call functions inside of
inline assembly, enabling us to use the default start.zig logic

all that's left is to implement lr/sc loops for atomically manipulating
1 and 2 byte values, after which we can use the segfault handler logic.
2024-07-26 04:19:55 -07:00
David Rubin b533e848a2 riscv: enable passing tests 2024-07-26 04:19:17 -07:00
David Rubin 9bc7e8c852 riscv: update tests 2024-07-26 04:05:43 -07:00
David Rubin 1820f44104 riscv: implement sub-byte addition 2024-07-26 04:05:42 -07:00
David Rubin cde6956b21 riscv: remove redundant assert in genBinOp 2024-07-26 04:05:41 -07:00
David Rubin 8d30fc45c4 riscv: implement more operators
we can run `std.debug.print` now, with both run-time strings and integers!
2024-07-26 04:05:39 -07:00
David Rubin 7a02878f4e riscv: truncate airStructFieldVal result 2024-07-14 23:02:33 -07:00