17605 Commits

Author SHA1 Message Date
joachimschmidt557
7cdc47a4e0
stage2 RISCV64: implement move register to register 2022-03-19 19:48:27 +01:00
joachimschmidt557
956d9f4ce0
stage2 RISCV64: remove MCValue.embedded_in_code 2022-03-19 10:52:59 +01:00
Andrew Kelley
ad5770eba4 organize behavior tests
* Identify the ones that are passing and stop skipping them.
 * Flatten out the main behavior.zig file and have each individual test
   disable itself if it is not passing.
2022-03-18 15:02:52 -07:00
Andrew Kelley
d5803441cd
Merge pull request #11220 from schmee/vector-bitreverse
stage2: implement `@bitReverse` for vectors
2022-03-18 15:27:08 -04:00
Andrew Kelley
e60c0468aa
Merge pull request #11217 from jmc-88/cbe-tuples
CBE: add support for tuples
2022-03-18 15:23:40 -04:00
Jakub Konka
338bf55e84
Merge pull request #11216 from joachimschmidt557/stage2-arm
stage2 ARM: remove MCValue.embedded_in_code
2022-03-18 20:02:33 +01:00
Mitchell Hashimoto
3865a61a99 stage2: formatting an error_set value should print members, not decl 2022-03-18 14:53:54 -04:00
Andrew Kelley
5765755fcd
Merge pull request #11218 from mitchellh/labeled-break
AstGen: labeled blocks should always complete with a normal break
2022-03-18 14:50:40 -04:00
Andrew Kelley
de8f3bc885 AstGen: remove unused parameter
This function took a parameter that was only ever used with one value,
obscuring the fact that it was a regular `block` which should be used with
`.break` and not `.break_inline`.
2022-03-18 11:49:18 -07:00
Mitchell Hashimoto
3e74acb139 AstGen: labeled blocks should always complete with a normal break
They aren't inline blocks by nature of being labeled.

Fixes #11213
2022-03-18 11:40:39 -07:00
joachimschmidt557
13321c8070 stage2 regalloc: fix tryAllocRegs for specific situations
Previously, tryAllocRegs did not take frozen registers into account
when checking if enough registers are available.
2022-03-18 19:37:01 +01:00
Daniele Cocca
6fdca525de CBE: add support for tuples
Also promote tests that are now passing.
2022-03-18 16:50:34 +00:00
John Schmidt
e99b1b398a Refactor to sema.typeHasOnePossibleValue 2022-03-18 16:28:38 +01:00
John Schmidt
870341e32e stage2: implement @bitReverse for vectors 2022-03-18 16:28:38 +01:00
Daniele Cocca
085e122e29 bugs/3779: replace expectEqual*() with expect() 2022-03-18 11:20:28 +00:00
joachimschmidt557
c32e2c4d3c
stage2 ARM: remove MCValue.embedded_in_code 2022-03-18 12:19:22 +01:00
Daniele Cocca
af8586da3a tuple: replace expectEqual() with expect() 2022-03-18 11:18:12 +00:00
joachimschmidt557
3ecba7d7a2
stage2 ARM: implement slice_elem_ptr, ptr_elem_ptr 2022-03-18 12:12:14 +01:00
Andrew Kelley
f3f5a5d05b stage2: improve @typeName
* make it always return a fully qualified name. stage1 is inconsistent
   about this.
 * AstGen: fix anon_name_strategy to correctly be `func` when anon type
   creation happens in the operand of the return expression.
 * Sema: implement type names for the "function" naming strategy.
 * Put "enum", "union", "opaque", or "struct" in place of "anon" when
   creating respective anonymous Decl names.
 * std.testing: add `expectStringStartsWith`. Didn't end up using it
   after all.

Also this enables the real test runner for stage2 LLVM backend (sans
wasm32) since it works now.
2022-03-18 00:12:22 -07:00
Andrew Kelley
69d78bdae4 stage2 test harness: ask for the backend explicitly
Follow-up to 35d6ee08c468642969b594b711dd6448bbaefa89
2022-03-17 20:10:00 -07:00
Andrew Kelley
1d1364c3cd Sema: change how undefined is handled in coerce
Instead of doing it before the switch tower, do it afterwards, so that
special handling may be done before undefined gets casted to the
destination type.

In this case the special handling we want to do is *[N]T to []T setting
the slice length based on the array length, even when the array value is
undefined.
2022-03-17 19:59:20 -07:00
Andrew Kelley
46ba24010a CI: explicitly pass -fno-LLVM
Needed because of previous commit.
2022-03-17 19:12:27 -07:00
Andrew Kelley
35d6ee08c4 stage2: default to LLVM backend
on targets for which self-hosted backends are not up to par.

See #89
2022-03-17 19:03:37 -07:00
Andrew Kelley
76b382072a
Merge pull request #11200 from Luukdegram/wasm-memcpy
stage2: wasm - Implement memcpy instruction
2022-03-17 18:25:15 -07:00
Luuk de Gram
79679be50d sema: Fix memory leak
When a generic call evaluates to a generic type, the call will be re-generated.
However, the old function was not freed before being re-generated, causing a memory leak.
So rather than only returning an error, we first free the old value.
2022-03-17 18:20:03 -07:00
Steven Fackler
9dc9219b2f Don't strip by default in cc or c++ 2022-03-17 18:16:24 -07:00
Andrew Kelley
ff21cb42a0
Merge pull request #11206 from schmee/vector-byteswap
Implement `@byteSwap` for vectors
2022-03-17 18:04:46 -07:00
Andrew Kelley
4fa5060633 Sema: take advantage of checkIntOrVectorAllowComptime 2022-03-17 18:04:06 -07:00
John Schmidt
d7d2ccb7af Avoid index out of bounds for one-valued types in zirValidateArrayInit
Previously, the code assumed that `ptr_elem_ptr` was always followed by
a `store`, but this is not true for types with one value (such as `u0`).
2022-03-17 18:00:48 -07:00
John Schmidt
adfcc8851b Implement @byteSwap for vectors
Make the behavior tests for this a little more primitive to exercise as
little extra functionality as possible.
2022-03-17 18:00:48 -07:00
Andrew Kelley
7233a3324a stage2: implement @reduce
Notably, Value.eql and Value.hash are improved to treat NaN as equal to
itself, so that Type/Value can be hash map keys. Likewise float hashing
normalizes the float value before computing the hash.
2022-03-17 17:24:35 -07:00
Andrew Kelley
76e103057e zig_llvm.h: fix some declarations not being C compatible 2022-03-17 17:24:11 -07:00
Andrew Kelley
9ed3eb9cde std.testing: fix incorrect docs that mentioned aborting
At some point we changed these functions to return errors instead of
aborting.
2022-03-17 17:23:22 -07:00
Andrew Kelley
73e51133c3 langref: small clarification of @reduce 2022-03-17 17:22:57 -07:00
Luuk de Gram
215a22541c
wasm: Improve memset implementation
When the length is comptime-known, we perform an inline loop instead of emitting
a runtime loop into the binary.

This also allows us to easily write 'undefined' to aggregate types.
We now do this when we set the error tag of an error union where the payload will be set to undefined.
2022-03-17 20:41:26 +01:00
Luuk de Gram
eafdc5562f
wasm: Implement 'memcpy' instruction
This implements the `memcpy` instruction and also updates the inline memcpy calls
to make use of the same implementation. We use the fast-loop when the length is comptime known,
and use a runtime loop when the length is runtime known.
We also perform feature-dection to emit a simply wasm memory.copy instruction when the feature
'bulk-memory' is enabled. (off by default).
2022-03-17 20:41:23 +01:00
Andrew Kelley
291f5055f4 disable x86_64 behavior test that does not run valgrind clean 2022-03-17 11:48:50 -07:00
Andrew Kelley
1ee7a81627 Revert "link.Elf: swap order of GOT and text program headers"
This reverts commit 8e7b1a74ac4568a2b806026f210ae59e52d2768d.

Sorry, I should have put up a PR and ran that one by Jakub and done some
more inspection.

This causes problems with gdb:

BFD: /home/andy/dev/zig/build-release/test: invalid string offset 3254779904 >= 153524 for section `.shstrtab'
2022-03-17 11:41:17 -07:00
Daniele Cocca
00ed8d9c50 CBE: enable more tests that are currently passing 2022-03-17 11:39:56 -07:00
Andrew Kelley
8e7b1a74ac link.Elf: swap order of GOT and text program headers
This makes Valgrind happier because it results in the program headers
being sorted by VirtAddr in the ELF file.
2022-03-17 11:36:17 -07:00
Jakub Konka
fdee7dd60d debug: msync only current page when validation frame pointer
This fixes lack of stack traces on arm64 macOS which were regressed
and not getting generated at all after this addition to write
current stack traces. Prior to this, function `isValidMemory` would
sync two subsequent pages if the aligned (base) address was different
than the frame pointer. I fail to see what the logic for such assumption
here is as the manual of `msync` clearly states it will fail with error
if the passed in memory region length contains unmapped regions.

This was the very reason why there were no stack traces print on
arm64 macOS as the second page was unmapped thus incorrectly flagging
the frame pointer as invalid.
2022-03-17 18:21:04 +01:00
Jakub Konka
4012fcb0a3 macho: do not allocate new GOT atom when target atom has grown
That's the entire point of our GOT so that we don't have to do that;
simply overwrite the address in the GOT.
2022-03-17 12:48:02 +01:00
Jakub Konka
d53e0234a3 macho: fix snapshot generation 2022-03-17 11:41:08 +01:00
Jakub Konka
648afbc839 macos: update Mach routines for accessing page info 2022-03-17 10:42:11 +01:00
Joachim Schmidt
3c3826bf93
Merge pull request #11192 from joachimschmidt557/stage2-arm
stage2 ARM: misc improvements
2022-03-17 09:40:41 +01:00
Andrew Kelley
87779cfd93 stage2: prevent UB in the LLVM backend
* Sema: fix `zirTypeInfo` allocating with the wrong arenas for some
   stuff.
 * LLVM: split `airDbgInline` into two functions, one for each AIR tag.
   - remove the redundant copy to type_map_arena. This is the first
     thing that lowerDebugType does so this hack was probably just
     accidentally avoiding UB (which is still present prior to this
     commit).
   - don't store an inline fn inst into the di_map for the generic
     decl.
   - use a dummy function type for the debug info to avoid whatever UB
     is happening.
   - we are now ignoring the function type passed in with the
     dbg_inline_begin and dbg_inline_end.
 * behavior tests: prepare the vector tests to be enabled one at a time.

Mitigates #11199.
2022-03-17 00:00:41 -07:00
Mitchell Hashimoto
79d3780fbd stage2: bit_not on u0 is always 0 2022-03-16 23:18:35 -07:00
Andrew Kelley
1af51a0833
Merge pull request #11196 from schmee/vector-muladd
Implement `@mulAdd` for vectors
2022-03-16 20:37:42 -07:00
Andrew Kelley
80642b5984 remove unnecessary TODO comment
`testing.expect` is better than `testing.expectEqual` for behavior
tests. Better for behavior tests to stick to only testing the limited
behavior they are meant to test and avoid functions such as
`expectEqual` that drag in too much of the standard library (in this
case to print helpful diffs about why a value is not equal to another).
2022-03-16 20:35:41 -07:00
John Schmidt
c8ed813097 Implement @mulAdd for vectors 2022-03-16 20:11:05 -07:00