17719 Commits

Author SHA1 Message Date
Cody Tapscott
5374e245c5 stage2: Remove premature elem_val index check
We were enforcing bounds on the index of an elem_ptr in pointerDeref,
but we want to support out-of-bounds accesses by reinterpreting memory.
This removes that check, so that the deref falls back to bitcasting, as
usual.

This was masked by another bug that was forcing bitcasts incorrectly,
which is why this wasn't noticed earlier.
2022-03-23 13:44:31 -07:00
Cody Tapscott
1c22381909 stage2: Properly "flatten" elem_ptrs before deref
Sema.pointerDeref() assumes that elem_ptrs have been "flattened" when
they were created, so that you an elem_ptr will never be the array_ptr
of another elem_ptr when they share the same type.

Value.elemPtr does this already, but a couple of places in Sema were
bypassing this logic.
2022-03-23 13:44:31 -07:00
William Sengir
b872539a13 stage2: enable some passing array & vector tests 2022-03-23 16:39:29 -04:00
William Sengir
d7530c8f7b stage2: make zero-sized array not cause recursive type definition 2022-03-23 16:38:33 -04:00
Cody Tapscott
6fc07f49a9 stage2: concat/mult of slices yields ptr to array 2022-03-23 16:34:48 -04:00
Locria Cyber
23bae382c9 Add sem_open & sem_close 2022-03-23 16:31:03 -04:00
Cody Tapscott
a9a91a5d49 stage2 CBE: Improve support for unions and error sets
This includes various fixes/improvements to the C backend to improve
error/union support. It also fixes up our handling of decls, where some
decls were not correctly marked alive.
2022-03-23 16:29:38 -04:00
Andrew Kelley
2f9264d8dc stage2: fix -Domit-stage2 regression
This flag is used when building stage1 to omit the stage2 backends from
the compiler to save memory on the CI server. It regressed with the
merging of e8813b296bc55a13b534bd9b2a03e1f6af366915 because Value
functions started calling into Sema functions.

The end goal for this build option is to eliminate it.
2022-03-23 13:24:55 -07:00
Marc Tiehuis
2e0de0b4e2
math/big: correct fix for divmod (#11271)
Fixes #11166.
2022-03-23 19:24:25 +01:00
Andrew Kelley
1cf1346323 Sema: rename isArrayLike to isArrayOrVector 2022-03-22 22:00:03 -07:00
Andrew Kelley
8326ab7adb Sema: fix merge conflicts with previous commit
The previous commit and e8813b296bc55a13b534bd9b2a03e1f6af366915 had
merge conflicts which didn't get caught by git.
2022-03-22 20:44:32 -07:00
Mitchell Hashimoto
e81ebc24e9 stage2: runtime safety checks for slicing 2022-03-22 23:41:59 -04:00
Jakub Konka
47f1a43bb7 dwarf: lower enums 2022-03-22 23:37:20 -04:00
Daniele Cocca
8f9c3fd3df
CBE: enable more passing tests (#11258) 2022-03-22 23:24:36 -04:00
Locria Cyber
eb5e0cba21 Fix ucontext_t 2022-03-22 23:19:02 -04:00
Andrew Kelley
4a837dddd0
Merge pull request #11266 from joachimschmidt557/stage2-arm
stage2 ARM: move closer to test runner output working
2022-03-22 23:18:26 -04:00
Andrew Kelley
98b932cfab fix merge conflicts 2022-03-22 20:17:43 -07:00
joachimschmidt557
be1cca3416 stage2 ARM: implement comparison of optional pointers 2022-03-22 20:16:05 -07:00
joachimschmidt557
95e166b2e1 stage2 ARM: implement min, max for integers <= 32 bits 2022-03-22 20:16:05 -07:00
joachimschmidt557
62529a291b stage2 ARM: More support for error unions 2022-03-22 20:16:05 -07:00
joachimschmidt557
a4e8294c91 stage2 ARM: change semantics of MCValue.stack_argument_offset
MCValue.stack_argument_offset now has the same semantics as
MCValue.stack_offset
2022-03-22 20:16:05 -07:00
joachimschmidt557
6ac04d8fd7 stage2 ARM: change semantics of MCValue.stack_offset
A stack_offset will now denote the exact offset applied to the start
of the stack frame (=fp when frame pointer is emitted)
2022-03-22 20:16:05 -07:00
Andrew Kelley
e8813b296b
Merge pull request #11260 from ziglang/lazy-alignof
stage2: lazy `@alignOf`
2022-03-22 22:30:38 -04:00
Mitchell Hashimoto
cb6364624f stage2: slice behavior test passes, just has diff behavior from stage1
This is from discussions from #11249. The stage2 behavior is correct and
is strictly more accurate, so we'd prefer to keep it. In that case, I
modified the behavior tests to have the conditional between
stage1/stage2 and get this test passing.
2022-03-22 19:56:10 -04:00
Andrew Kelley
44f9061b71 fix merge conflicts and test cases 2022-03-22 15:58:19 -07:00
Andrew Kelley
60d8c4739d Sema: introduce a mechanism in Value to resolve types
This commit adds a new optional argument to several Value methods which
provides the ability to resolve types if it comes to it. This prevents
having duplicated logic inside both Sema and Value.

With this commit, the "struct contains slice of itself" test is passing
by exploiting the new lazy_align Value Tag.
2022-03-22 15:45:59 -07:00
Andrew Kelley
593130ce0a stage2: lazy @alignOf
Add a `target` parameter to every function that deals with Type and
Value.
2022-03-22 15:45:58 -07:00
Jakub Konka
b74f292410 Revert "ignore target lib dirs when invoked with -feach-lib-rpath"
This reverts commit 3701697a0a586e630a2452dea29951f0051a47fd.

The commit introduced a regression when building stage2 on nixOS where
the linker would fail to find relevant LLVM dynamic libraries as some
search dirs were missing.
2022-03-22 20:51:34 +01:00
Jan200101
3701697a0a ignore target lib dirs when invoked with -feach-lib-rpath 2022-03-22 09:03:22 +01:00
Jakub Konka
0376fd09bc macho: extend CodeSignature to accept entitlements
With this change, we can now bake in entitlements into the binary.
Additionally, I see this as the first step towards full code signature
support which includes baking in Apple issued certificates for
redistribution, etc.
2022-03-22 07:06:39 +01:00
Mitchell Hashimoto
91fd0f42c8 stage2: out of bounds error for slicing 2022-03-21 22:10:34 -04:00
Andrew Kelley
0fb005d1d0 Sema: dummy implementation of @errorReturnTrace
Also update std/build.zig to use stage2 function pointer semantics.

This gets us a little bit closer to `zig build` working, although it is
now hitting a new crash in the compiler.
2022-03-21 19:08:30 -07:00
Luuk de Gram
be579d4797 wasm: Implement @popCount 2022-03-21 22:01:34 -04:00
Andrew Kelley
7141356838
Merge pull request #11237 from wsengir/stage2-vectors
stage2: implement most vector operations in Sema and LLVM backend
2022-03-21 20:05:29 -04:00
Andrew Kelley
7eddef423d behavior tests: alter test coverage for vectors
* Use `@Vector` syntax instead of `std.meta.Vector`.
 * Use `var` instead of `const` for tests so that we get runtime
   coverage instead of only comptime coverage. Comptime coverage is done
   with `comptime doTheTest()` calls.
2022-03-21 17:03:24 -07:00
Andrew Kelley
513a53e9aa Sema: restore propagation of error.GenericPoison for checking vectors 2022-03-21 17:03:05 -07:00
William Sengir
c9598c4cd3 behavior tests: enable all vector tests for the stage2 LLVM backend 2022-03-21 16:54:19 -07:00
William Sengir
afdcfb005e Sema: make most instructions vector-agnostic
Made most `Value` functions require a `Type`. If the provided type is a
vector, then automatically vectorize the operation and return with
another vector. The Sema side can then automatically become vectorized
with minimal changes. There are already a few manually vectorized
instructions, but we can simplify those later.
2022-03-21 16:54:19 -07:00
William Sengir
3f4676901a stage2: return Value.zero when truncating int to 0 bits at comptime 2022-03-21 16:54:19 -07:00
William Sengir
2d8fef5680 stage2: make bool binop AIR return types based on operand type
This allows vector-of-bools operands to return a vector-of-bools.
2022-03-21 16:54:19 -07:00
William Sengir
4e357151a5 stage2: align store for vector-to-array bitcast in LLVM backend
This was causing a very rare segfault when LLVM would emit `vmovdqa`
using an unaligned memory operand on the stack.
2022-03-21 16:54:19 -07:00
William Sengir
961248cde3 stage2: make more instructions vector-compatible in LLVM backend 2022-03-21 16:54:19 -07:00
William Sengir
b96699059c stage2: implement cmp_vector for LLVM backend 2022-03-21 16:54:19 -07:00
William Sengir
0f48307041 stage2: add AIR instruction cmp_vector
The existing `cmp_*` instructions get their result type from `lhs`, but
vector comparison will always return a vector of bools with only the
length derived from its operands. This necessitates the creation of a
new AIR instruction.
2022-03-21 16:54:19 -07:00
William Sengir
862e63f535 stage2: fix typo in print_air.zig 2022-03-21 16:54:19 -07:00
William Sengir
cda8f65489 behavior tests: use expect instead of expectEqual in vector.zig 2022-03-21 16:54:19 -07:00
Jakub Konka
2f4473b653 macho: add more codesig constants 2022-03-22 00:03:13 +01:00
Jakub Konka
d71bd0300b
Merge pull request #11195 from mparadinha/float-to-int
stage2: x86_64: implement `@floatToInt` for `f32` and `f64`
2022-03-21 23:54:36 +01:00
Jakub Konka
a9b6de693c
Merge pull request #11223 from mparadinha/ptr-elem-val
stage2: x86_64: implement `ptr_elem_val`
2022-03-21 23:54:17 +01:00
Jakub Konka
00e2113c8b x64: refactor fix reg aliasing in genSetReg 2022-03-21 23:38:01 +01:00