9 Commits

Author SHA1 Message Date
Luuk de Gram
588b88b987
Move passing behavior tests
Singular tests (such as in the bug ones) are moved to top level with exclusions for non-passing backends.
The big behavior tests such as array_llvm and slice are moved to the inner scope with the C backend disabled.
They all pass for the wasm backend now
2022-02-03 22:31:29 +01:00
Andrew Kelley
e86ff712a6 stage2: implement tuples
* AIR instruction vector_init gains the ability to init arrays and
   tuples in addition to vectors. This will probably also gain the
   ability to initialize structs and be renamed to `aggregate_init`.
 * AstGen prefers to use an `anon_array_init` ZIR instruction for
   local variables when the init expr is an array literal and there is
   no type.
2022-01-20 16:17:16 -07:00
Andrew Kelley
0f3938e498 behavior tests: move tests around 2022-01-16 10:14:57 -07:00
Andrew Kelley
7f41e20802 AstGen: emit as instructions for branching expressions
There is a mechanism to avoid redundant `as` ZIR instructions which is
to pass `ResultLoc.coerced_ty` instead of `ResultLoc.ty` when it is
known by AstGen that Sema will do the coercion.

This commit downgrades `coerced_ty` to `ty` when a result location
passes through an expression that branches, such as `if`, `switch`,
`while`, and `for`, causing the `as` ZIR instruction to be emitted.

This ensures that the type of a result location will be applied to, e.g.
a `comptime_int` on either side of a branch on a runtime condition.
2022-01-15 23:13:44 -07:00
Andrew Kelley
7c6f5d26ea Sema: populate the sentinel for comptime array inits 2022-01-15 22:46:39 -07:00
Andrew Kelley
a5c7742ba6 stage2: fix Decl garbage collection not marking enough
It is the job of codegen backends to mark Decls that are referenced as
alive so that the frontend does not sweep them with the garbage. This
commit unifies the code between the backends with an added method on
Decl.

The implementation is more complete than before, switching on the Decl
val tag and recursing into sub-values.

As a result, two more array tests are passing.
2022-01-15 00:17:25 -07:00
Andrew Kelley
41f3799bf0 Sema: fix array_init with runtime element
Previously it emitted an invalid AIR encoding.
2022-01-14 23:08:11 -07:00
Andrew Kelley
b019a19b55 Sema: comptime loads and stores for elem_ptr
The index is checked against actual array lengths, and now handles
coerced or casted pointers to single items.
2022-01-13 22:13:44 -07:00
drew
2f53406ad8
CBE; implement airLoad and airStore for arrays (#10452)
Effectively a small continuation of #10152

This allows the for.zig behavior tests to pass. Unfortunately to fully test everything I had to move a lot of behavior tests from array.zig; most of them now pass (sorry @rainbowbismuth!)

I'm also conflicted on how I store constants into arrays because it's kind of stupid; array's can't be re-initialized using the same syntax, so instead of initializing each element, a new array is made which is copied into the destination. This also required that renderValue can't emit string literals for byte arrays given that they need to always have an extra byte for the NULL terminator, meaning that strings are no longer grep-able in the output.
2021-12-30 15:19:12 -05:00