1466 Commits

Author SHA1 Message Date
mlugg
407dc6eee4
Liveness: avoid emitting unused instructions or marking their operands as used
Backends want to avoid emitting unused instructions which do not have
side effects: to that end, they all have `Liveness.isUnused` checks for
many instructions. However, checking this in the backends avoids a lot
of potential optimizations. For instance, if a nested field is loaded,
then the first field access would still be emitted, since its result is
used by the next access (which is then unreferenced).

To elide more instructions, Liveness can track this data instead. For
operands which do not have to be lowered (i.e. are not side effecting
and are not something special like `arg), Liveness can ignore their
operand usages, and push the unused information further up, potentially
marking many more instructions as unreferenced.

In doing this, I also uncovered a bug in the LLVM backend relating to
discarding the result of `@cVaArg`, which this change fixes. A behaviour
test has been added to cover it.
2023-04-20 20:28:48 +01:00
mlugg
d5f1a8823e Sema: allow ptr field access on pointer-to-array
Also remove an incorrect piece of logic which allowed fetching the 'len'
property on non-single-ptrs (e.g. many-ptrs) and add a corresponding
compile error test case.

Resolves: #4765
2023-04-20 09:05:22 -07:00
Jacob Young
780f654e19 behavior: disable flaky test on x86_64
Also reenable stage2_x86_64 windows behavior tests in case it is failing
for the same reason.

Closes #15324
2023-04-16 17:07:07 -04:00
Jacob Young
c1a2da6b78 x86_64: implement packed load and store 2023-04-16 17:05:35 -04:00
Andrew Kelley
e9d854743a disable more failing C backend tests 2023-04-15 10:33:08 -07:00
Andrew Kelley
a281d29881 disable not-yet-passing C backend tests 2023-04-15 10:33:08 -07: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
Luuk de Gram
25e3851fe0
Merge pull request #15257 from Luukdegram/wasm-tagname
wasm: Implement `@tagName` instruction
2023-04-13 19:32:22 +02:00
Jacob Young
caa3d6a4f4 x86_64: fix constant pointers to zero-bit types
These non-dereferencable pointers still need to have the correct
alignment and non-null-ness.
2023-04-13 04:17:47 -04:00
Jacob Young
3b22ce8264 x86_64: fix atomic loop implementation 2023-04-13 04:17:47 -04:00
Jacob Young
0165187cd0 x86_64: fix some of the mass confusion about the meaning of MCValue 2023-04-13 04:17:47 -04:00
Luuk de Gram
abc1e52e08
wasm: enable @tagName behavior tests 2023-04-12 22:23:36 +02:00
mlugg
ccf670c2b0 Zir: implement explicit block_comptime instruction
Resolves: #7056
2023-04-12 12:06:19 -04:00
Andrew Kelley
a2793f8ab8
Merge pull request #14853 from schmee/vector-peer-type-resolution
Vector type resolution/coercion fixes
2023-04-10 12:21:55 -04:00
Auguste Rame
7225a15abe
Enable new tests 2023-04-07 20:55:04 -04:00
Luuk de Gram
4ebf483e0d
Merge pull request #14668 from Techatrix/wasm-floatops
wasm: implement float operations with compiler-rt
2023-04-07 18:22:41 +02:00
mlugg
1059b57898
Liveness: defer deaths of externally-scoped instructions in loop bodies 2023-04-07 01:29:20 +01:00
Veikka Tuominen
82a6acca93 Sema: implement inline switch capture at comptime
Closes #15157
2023-04-05 14:45:56 +03:00
Jacob Young
821eb595f4 x86_64: implement cmp_lt_errors_len 2023-04-03 15:19:07 -04:00
Jacob Young
5900dc0580 x86_64: fix typos 2023-04-03 18:02:55 +02:00
Jacob Young
1980f5479b x86_64: implement store to immediate address 2023-04-03 17:45:16 +02:00
Jacob Young
272acb7ee5 x86_64: implement storing large immediates 2023-04-03 17:45:16 +02:00
Jacob Young
f4b411314c Sema: defer stores to inferred allocs
This lets us generate the store with knowledge of the type to be stored.
Therefore, we can avoid generating garbage Air with stores through
pointers to comptime-only types which backends cannot lower.

Closes #13410
Closes #15122
2023-04-02 18:05:44 +03:00
Jacob Young
f4359531b1 x86_64: implement shl with overflow 2023-04-02 06:11:12 -04:00
Jacob Young
0e289cc826 x86_64: implement large add/sub with overflow 2023-04-02 05:16:46 -04:00
Jacob Young
b80cdde4f0 x86_64: implement struct_field_val for large packed structs 2023-04-02 04:49:53 -04:00
Jacob Young
83a208c355 x86_64: implement large cmp 2023-04-02 04:49:53 -04:00
Jacob Young
677427bc3a x86_64: implement error name 2023-04-02 04:49:53 -04:00
Jacob Young
ac68d72d24 x86_64: implement aggregate init of a packed struct 2023-04-02 04:49:53 -04:00
Jacob Young
0543def52f llvm: fix crashes when loading a struct field
The result of buildStructGEP is not always a GEP (sorry), so we can't
use getGEPResultElementType on it.

Closes #14641
2023-03-30 11:54:24 +03:00
Jacob Young
dd66e0addb Sema: fix empty slice pointer value
We just checked that inst_child_ty was effectively a zero-bit type, so
it is certainly not the non-zero alignment we are looking for.

Closes #15085
2023-03-28 23:12:19 +03:00
Jacob Young
802c2e4fae x86_64: fix popcnt and disable regressed test 2023-03-27 05:58:00 -04:00
Techatrix
8ec7723992 wasm: implement float operations with compiler-rt 2023-03-26 22:48:56 +02:00
Jacob Young
1e080e5056 x86_64: implement atomic loops 2023-03-25 16:23:55 -04:00
Jacob Young
6d9bdc8733 x86_64: fix cmpxchg 2023-03-25 16:23:55 -04:00
Jacob Young
8f385e77ca x86_64: implement struct_field_val for packed containers 2023-03-25 16:23:55 -04:00
Jacob Young
0cfc0d0d13 x86_64: implement struct_field_ptr for packed containers 2023-03-25 16:23:55 -04:00
Jacob Young
935ec9ec6a x86_64: canonicalize each br of a block 2023-03-24 17:57:58 -04:00
Jacob Young
12c07fcf20 x86_64: fix more value tracking bugs 2023-03-24 17:57:58 -04:00
Jacob Young
dbe1b4a7e5 x86_64: fix value tracking bugs 2023-03-24 17:57:58 -04:00
mlugg
f9b5829508 Sema: implement @export for arbitrary values 2023-03-21 15:04:39 +02:00
Xavier Bouchoux
898e4473e8 CBE: implement aggregateInit() for array of array case.
fixes `error(compilation): clang failed with stderr: error: array type 'uint32_t[10]' (aka 'unsigned int[10]') is not assignable`
2023-03-21 14:56:04 +02:00
Veikka Tuominen
f7204c7f37
Merge pull request #15028 from Vexu/compile-errors
Sema: improve error message of field access of wrapped type
2023-03-21 14:55:36 +02:00
Jacob Young
f316cb29cc x86_64: implement atomic and fence ops 2023-03-21 08:49:54 +01:00
Jacob Young
3f4569bf18 codegen: fix backend breakage due to optional layout change 2023-03-21 08:49:54 +01:00
Jacob Young
f95faac5ae x86_64: (re)implement optional ops
Note that this commit also changes the layout of optional for all
other backends using `src/codegen.zig` without updating them!
2023-03-21 08:49:54 +01:00
Jacob Young
24f0900ecb x86_64: implement some error union ops 2023-03-21 08:49:54 +01:00
Jacob Young
80427796df x86_64: implement @returnAddress and @frameAddress 2023-03-21 08:49:54 +01:00
Jacob Young
30e1daa746 x86_64: implement basic float ops 2023-03-21 08:49:54 +01:00
Veikka Tuominen
e70a0b2a6b Value: implement reinterpreting enum field index as integer
Closes #15019
2023-03-21 03:31:03 +02:00