Commit graph

2054 commits

Author SHA1 Message Date
Robin Voetter
89b1dafa78
spirv: aggregate_init for structs 2023-10-15 13:59:55 +02:00
Robin Voetter
08ea9a9ff6
spirv: cast result of .elem pointers to right type if needed 2023-10-15 13:59:23 +02:00
Robin Voetter
a7c3d5e4ec
spirv: constant elem ptr fix 2023-10-15 13:59:22 +02:00
Xavier Bouchoux
78fe3feedb tests: enable already passing behaviour tests for self-hosted wasm
1611 passed; 262 skipped; 0 failed.
(was: 1543 passed; 330 skipped; 0 failed.)
2023-10-14 12:50:39 +02:00
Xavier Bouchoux
d5991ee7ca codegen/wasm: fix non-byte-sized signed integer comparison 2023-10-14 10:23:36 +02:00
Xavier Bouchoux
27a19908ed codegen/wasm: fix tuple member offset computation
It didn't account for field alignement.
2023-10-14 10:23:36 +02:00
Andrew Kelley
ab4d6bf468 LLVM: work around @floatFromInt bug
see #17381
2023-10-14 00:33:46 -07:00
Andrew Kelley
b6762c2473 Sema: fix crash when ref coercion dest is var args
When analyzing the `validate_ref_ty` ZIR instruction, an assertion would
trip if the result type was a var args function argument. The fix is the
same as e6b73be870 - inline the logic of
`resolveType` and handle the case of var args.

Closes #17494
2023-10-13 00:31:22 -07:00
Andrew Kelley
e6b73be870 Sema: fix crash when coercion dest is var args
When analyzing the `as` ZIR instruction, an assertion would trip if the
result type was a var args function argument. The fix is simple: inline
a little bit of the `resolveType` logic into `analyzeAs` to make it
detect this situation - which it was already attempting to do.

Closes #16197
2023-10-12 22:03:39 -07:00
Andrew Kelley
aaf46187ab
Merge pull request #17391 from xxxbxxx/load-i4
codegen/llvm: truncate padding bits when loading a non-byte-sized value
2023-10-09 22:06:49 -07:00
Jacob Young
922b5b5453 x86_64: implement 128-bit integer multiply and divide 2023-10-09 05:23:23 -04:00
Luuk de Gram
54e7f58fcb
Merge pull request #17438 from Luukdegram/issue-17436
wasm - fix `@tagName` for signed enums
2023-10-08 21:58:35 +02:00
Luuk de Gram
9402f8b74a
add behavior test @tagName with signed values 2023-10-08 15:23:50 +02:00
Xavier Bouchoux
703fe0f121 test: add a pair of cases from bug reports 2023-10-08 11:37:49 +02:00
Xavier Bouchoux
370662c565 codegen/llvm: truncate padding bits when loading a non-byte-sized value 2023-10-08 11:37:49 +02:00
Xavier Bouchoux
85315bb535 codegen/wasm: fix intcast accross 32-bits boundary 2023-10-08 11:37:49 +02:00
Xavier Bouchoux
c86ba0f9d0 test: add behaviour test for casting accross 32-bits boundary 2023-10-08 11:36:53 +02:00
Jacob Young
b5dedd7c00 x86_64: implement @mulAdd of floats for baseline 2023-10-08 04:41:55 -04:00
Jacob Young
35c9b717f7 x86_64: implement @rem for floats 2023-10-08 04:41:55 -04:00
Jacob Young
3bf9a8feb5 x86_64: fix @divTrunc and @divFloor of f16 2023-10-08 04:41:55 -04:00
Jacob Young
9fc9235ac8 x86_64: fix undersized vector binary operations 2023-10-08 04:41:55 -04:00
Jacob Young
b8f00ae337 x86_64: implement @abs for some integer vector types 2023-10-08 04:41:55 -04:00
Jacob Young
24d76500d2 x86_64: fix bitcast from f80 2023-10-08 04:41:55 -04:00
Jacob Young
24c67992e0 x86_64: hack around silent f80 miscompilations
The x87 kind sucks.
2023-10-07 19:47:46 -04:00
Jacob Young
b19fd485b1 x86_64: improve inline assembly support
* instruction prefixes
 * mnemonic fixes
 * labels
 * memory operands
 * read-write constraint modifier
 * register and memory alternative constraint
2023-10-07 16:02:01 -04:00
Jacob Young
7436f3efc9 x86_64: implement C var args 2023-10-07 02:10:34 -04:00
Jacob Young
20b4401cde x86_64: implement negation and @abs for f80
Also implement live-outs since the x87 requires so much care around
liveness tracking.
2023-10-07 00:29:17 -04:00
Jacob Young
5aeb13c350 x86_64: implement f80 movement 2023-10-07 00:29:17 -04:00
Jacob Young
54b2d6f072 x86_64: implement C abi for everything else 2023-10-05 04:38:25 -04:00
Jacob Young
cc6694a323 x86_64: implement C abi for f128 2023-10-05 04:10:38 -04:00
Jacob Young
644d943861 x86_64: implement 128-bit integer comparisons 2023-10-04 16:26:56 -04:00
Jacob Young
2a5335d7b6 x86_64: implement C abi for 128-bit integers 2023-10-04 14:42:35 -04:00
Jacob Young
08c24935b1 behavior: reenable passing x86_64 tests 2023-10-04 14:42:35 -04:00
Andrew Kelley
87d09edf2d
Merge pull request #17352 from kcbanner/extern_union_comptime_memory
sema: Support reinterpreting extern/packed unions at comptime via field access
2023-10-03 11:20:08 -07:00
Andrew Kelley
5c3393dc2e
Merge pull request #17375 from xxxbxxx/packed-struct
codegen: fix field offsets in packed structs
2023-10-03 11:13:40 -07:00
Ian Johnson
6734d2117e Add behavior test for empty tuple type
Closes #16412
2023-10-03 16:01:08 +03:00
Veikka Tuominen
0bdbd3e235 Sema: fix issues in @errorCast with error unions 2023-10-03 00:45:48 -07:00
Xavier Bouchoux
405705cb76 codegen: fix byte-aligned field offsets in unaligned nested packed structs 2023-10-03 05:34:19 +00:00
Xavier Bouchoux
62d178e91a codegen: fix field offsets in packed structs
* add nested packed struct/union behavior tests
 * use ptr_info.packed_offset rather than trying to duplicate the logic from Sema.structFieldPtrByIndex()
 * use the container_ptr_info.packed_offset to account for non-aligned nested structs.
 * dedup type.packedStructFieldBitOffset() and module.structPackedFieldBitOffset()
2023-10-03 06:39:20 +02:00
kcbanner
1b8a50ea5e union: skip failing tests on ppc 2023-10-02 20:39:02 -04:00
kcbanner
fb33bc99e1 sema: handle big-endian when bitcasting between different-sized union fields
Updated the tests to also run at runtime, and moved them to union.zig
2023-10-02 13:28:13 -04:00
kcbanner
d657b6c0e2 sema: support reinterpreting extern/packed unions at comptime via field access
My previous change for reading / writing to unions at comptime did not handle
union field read/writes correctly in all cases. Previously, if a field was
written to a union, it would overwrite the entire value. This is problematic
when a field of a larger size is subsequently read, because the value would not
be long enough, causing a panic.

Additionally, the writing behaviour itself was incorrect. Writing to a field of
a packed or extern union should only overwrite the bits corresponding to that
field, allowing for memory reintepretation via field writes / reads.

I addressed these problems as follows:

Add the concept of a "backing type" for extern / packed unions
(`Type.unionBackingType`).  For extern unions, this is a `u8` array, for packed
unions it's an integer matching the `bitSize` of the union. Whenever union
memory is read at comptime, it's read as this type.

When union memory is written at comptime, the tag may still be known. If so, the
memory is written using the tagged type. If the tag is unknown (because this
union had previously been read from memory), it's simply written back out as the
backing type.

I added `write_packed` to the `reinterpret` field of
`ComptimePtrMutationKit`. This causes writes of the operand to be packed - which
is necessary when writing to a field of a packed union. Without this, writing a
value to a `u1` field would overwrite the entire byte it occupied.

The final case to address was reading a different (potentially larger) field
from a union when it was written with a known tag. To handle this, a new kind of
bitcast was introduced (`bitCastUnionFieldVal`) which supports reading a larger
field by using a backing buffer that has the unwritten bits set to
undefined. The reason to support this (vs always just writing the union as it's
backing type), is that no reads to larger fields ever occur at comptime, it
would be strictly worse to have spent time writing the full backing type.
2023-10-02 13:15:28 -04:00
Jacob Young
da335f0ee4 x86_64: implement float @sqrt builtin 2023-10-01 15:09:52 -04:00
Jacob Young
fbe5bf469e x86_64: implement float arithmetic builtins 2023-10-01 15:09:52 -04:00
Jacob Young
1eb023908d x86_64: implement float round builtins 2023-10-01 15:09:52 -04:00
Jacob Young
8470652f10 x86_64: implement float compare and cast builtins 2023-10-01 15:09:52 -04:00
Jacob Young
6d5cbdb863 behavior: cleanup floatop tests 2023-10-01 15:09:52 -04:00
Jacob Young
3bd1b9e15f x86_64: implement and test unary float builtins 2023-10-01 15:09:52 -04:00
Veikka Tuominen
63bd2bff12 Sema: add @errorCast which works for both error sets and error unions
Closes #17343
2023-10-01 17:00:01 +03:00
Andrew Kelley
937138cb90
Merge pull request #17248 from antlilja/abs
Replace @fabs builtin with new @abs builtin
2023-09-27 17:25:19 -07:00