1873 Commits

Author SHA1 Message Date
Matthew Lugg
b3462b7cec
Merge pull request #17692 from kcbanner/struct_field_init_pass
sema: analyze struct field bodies in a second pass, to allow them to use the layout of the struct itself
2023-11-07 07:44:32 +00:00
mlugg
d78eda34c5 Sema: emit @intCast safety check correctly for vectors
This code was previously tripping an assertion by not making this value
used in the safety check a vector.
2023-11-07 06:42:15 +00:00
mlugg
9b394a200a Sema: allow destructuring vectors
This was intended to work when destructuring was first implemented, and
was just unintentionally missed out.
2023-11-07 06:11:01 +00:00
kcbanner
f10499be0a
sema: analyze field init bodies in a second pass
This change allows struct field inits to use layout information
of their own struct without causing a circular dependency.

`semaStructFields` caches the ranges of the init bodies in the `StructType`
trailing data. The init bodies are then resolved by `resolveStructFieldInits`,
which is called before the inits are actually required.

Within the init bodies, the struct decl's instruction is repurposed to refer
to the field type itself. This is to allow us to easily rebuild the inst_map
mapping required for the init body instructions to refer to the field type.

Thanks to @mlugg for the guidance on this one!
2023-11-07 00:49:35 +00:00
Jacob Young
9ced27dace x86_64: fix passing register-sized payload as non-reigster-sized union
Closes #17885
2023-11-06 14:11:31 -05:00
Jacob Young
0ea7189c23 behavior: enable test passing with x86_64 backend 2023-11-05 11:54:29 -05:00
Jacob Young
509be7cf1f x86_64: fix std test failures 2023-11-03 23:18:21 -04:00
Luuk de Gram
db1825e931
wasm: re-enable regressed tests 2023-11-01 19:47:15 +01:00
Andrew Kelley
3fc6fc6812 std.builtin.Endian: make the tags lower case
Let's take this breaking change opportunity to fix the style of this
enum.
2023-10-31 21:37:35 -04:00
Jacob Young
d890e81761 mem: fix ub in writeInt
Use inline to vastly simplify the exposed API.  This allows a
comptime-known endian parameter to be propogated, making extra functions
for a specific endianness completely unnecessary.
2023-10-31 21:37:35 -04:00
Jacob Young
50cdb65784 Sema: fix incorrect error comptime-mutating empty array 2023-10-31 21:37:35 -04:00
kcbanner
fb523c6283 sema: when guessing union alignment, save the result and check if the guess was correct 2023-10-31 01:35:58 +00:00
Jakub Konka
10d03acdb5
Merge pull request #17773 from ziglang/elf-exports
link: implement exporting anon decls
2023-10-30 17:29:05 +01:00
DilithiumNitrate
91e117697a
Fix hasRuntimeBitsAdvanced lazy case for pointers and optionals
As suggested by mlugg, always returns `error.NeedLazy`. If this has a
performance impact, it could be replaced by adding lazy handling to
`comptimeOnlyAdvanced`.
2023-10-29 21:12:43 +00:00
Jakub Konka
71dfea1f17 coff: implement exporting anon decls 2023-10-29 18:55:58 +01:00
Jakub Konka
a7a95ce9c4 macho: implement exporting anon decls 2023-10-29 18:55:58 +01:00
Jakub Konka
eaca72534c elf: implement exporting anon decls 2023-10-29 18:55:58 +01:00
Jakub Konka
209fd8cb93 elf: add partial implementation of exporting anon decls 2023-10-29 18:55:58 +01:00
Jacob Young
f6f2708d82 x86_64: fix compiler rt test failures 2023-10-29 07:20:36 -04:00
mlugg
c1c9bc0c41 Sema: do not assume switch item indices align with union field indices
Resolves: #17754
2023-10-28 06:30:28 +01:00
Andrew Kelley
24d9438bcc split export behavior test into export_keyword and export_builtin 2023-10-27 12:45:04 -07:00
Andrew Kelley
9f0fd72321 categorize nan behavior test
move it from bugs/xxx.zig to its own category
2023-10-27 12:43:34 -07:00
Andrew Kelley
3fb301b16a categorize fn ptr behavior test
move a function pointer test from bugs/xxx.zig to fn.zig
2023-10-27 12:43:34 -07:00
Andrew Kelley
dfe9cae4eb categorize globals behavior tests
moves some tests that store to global variables to their own category
instead of being named after a GitHub issue.
2023-10-27 12:43:34 -07:00
Andrew Kelley
1c85b0acbb
Merge pull request #17735 from ziglang/export-anon
link: support exporting constant values without a Decl
2023-10-27 15:20:13 -04:00
Andrew Kelley
4bc88dd116 link: support exporting constant values without a Decl
The main motivating change here is to prevent the creation of a fake
Decl object by the frontend in order to `@export()` a value.

Instead, `link.updateDeclExports` is renamed to `link.updateExports` and
accepts a tagged union which can be either a Decl.Index or a
InternPool.Index.
2023-10-26 20:32:16 -07:00
Jacob Young
48526c0eb6 test: enable c-abi-tests for the x86_64 backend
Add testing for `x86_64_v2` and `x86_64_v3` with the x86_64 backend.
2023-10-26 21:45:58 -04:00
Jacob Young
b55377a5ab x86_64: pass more tests
* 128-bit integer multiplication with overflow
 * more instruction encodings used by std inline asm
 * implement the `try_ptr` air instruction
 * follow correct stack frame abi
 * enable full panic handler
 * enable stack traces
2023-10-25 04:28:30 -04:00
Jacob Young
bb0419599a
Merge pull request #17666 from jacobly0/x86_64-unicode
x86_64: pass more std tests
2023-10-24 05:34:13 -04:00
Jacob Young
8f69e977f1 x86_64: implement 128-bit builtins
* `@clz`
 * `@ctz`
 * `@popCount`
 * `@byteSwap`
 * `@bitReverse`
 * various encodings used by std
2023-10-23 22:42:18 -04:00
Jacob Young
fbe8c8938b x86_64: implement @mod for floating-point types 2023-10-23 22:42:18 -04:00
Andrew Kelley
d4911794ae rename behavior test to better describe what it does
In general, let's not lean on GitHub issue numbers as having meaning.
The goal of behavior tests is to produce a minimum set of tests that
test 100% of the language.
2023-10-23 17:28:10 -07:00
Robin Voetter
4bf27da6a6 Revert "Revert "Merge pull request #17657 from Snektron/spirv-recursive-ptrs""
This reverts commit 9f0359d78f9facc38418e32b0e8c1bf6f99f0d26 in an attempt to
make the tests pass again. The CI failure from that merge should be unrelated
to this commit.
2023-10-23 06:27:12 -04:00
Jacob Young
27fe945a00 Revert "Revert "Merge pull request #17637 from jacobly0/x86_64-test-std""
This reverts commit 6f0198cadbe29294f2bf3153a27beebd64377566.
2023-10-22 15:46:43 -04:00
Andrew Kelley
6f0198cadb Revert "Merge pull request #17637 from jacobly0/x86_64-test-std"
This reverts commit 0c99ba1eab63865592bb084feb271cd4e4b0357e, reversing
changes made to 5f92b070bf284f1493b1b5d433dd3adde2f46727.

This caused a CI failure when it landed in master branch due to a
128-bit `@byteSwap` in std.mem.
2023-10-22 12:16:35 -07:00
Andrew Kelley
9f0359d78f Revert "Merge pull request #17657 from Snektron/spirv-recursive-ptrs"
This reverts commit b822e841cda0adabe3fec260ff51c18508f7ee32, reversing
changes made to 0c99ba1eab63865592bb084feb271cd4e4b0357e.

This caused a CI failure when it landed in master branch.
2023-10-22 12:15:31 -07:00
Robin Voetter
b822e841cd
Merge pull request #17657 from Snektron/spirv-recursive-ptrs
spirv: recursive pointers
2023-10-22 15:35:00 +02:00
Jacob Young
0c99ba1eab
Merge pull request #17637 from jacobly0/x86_64-test-std
x86_64: start to enable `test-std` and `test-compiler-rt` testing
2023-10-22 08:06:47 -04:00
Andrew Kelley
ecfb18286a migrate make_ptr_const to new anonymous decl mechanism
Instead of creating Module.Decl objects, directly create InternPool
pointer values using the anon_decl Addr encoding.

The LLVM backend needed code to notice the alignment of the pointer and
lower accordingly. The other backends likely need a similar change.
2023-10-21 21:38:41 -04:00
Robin Voetter
6281ad91df
spirv: self-referential pointers via new fwd_ptr_type
Its a little ugly but it works.
2023-10-21 17:46:54 +02:00
Robin Voetter
1deec09f03
spirv: improve union operations
This removes the strategy where union with different active
fields would be generated, and instead simply pointer casts
the active field type where required. This also allows removing
spv.ptrType and using self.ptrType instead, and allows caching
all union types (because there is only the canonical one).
2023-10-21 17:46:53 +02:00
Jacob Young
920e9668dd x86_64: enable fixed behavior test 2023-10-21 10:55:41 -04:00
Jacob Young
2e6e39a700 x86_64: fix bugs and disable erroring tests 2023-10-21 10:55:41 -04:00
Jacob Young
9358a7528f x86_64: fix crashes 2023-10-21 10:55:41 -04:00
Robin Voetter
c3120d5089
Merge pull request #17577 from alichraghi/spirv-1
spirv: switch on bool
2023-10-18 16:28:13 +02:00
Robin Voetter
24b065a6a8
Merge pull request #17561 from alichraghi/spirv-0
spirv: memcpy
2023-10-18 15:38:30 +02:00
Ali Chraghi
e5d5c1d423 spirv: switch on bool 2023-10-18 02:31:16 +03:30
Bogdan Romanyuk
ad168db727
Sema: disallow @intFromPtr for comptime-only types 2023-10-17 20:05:55 +00:00
Ali Chraghi
6d8a979265 spirv: memcpy 2023-10-17 13:02:30 +03:30
Ali Chraghi
e44152e252 spirv: fieldParentPtr 2023-10-16 20:27:28 -04:00