4251 Commits

Author SHA1 Message Date
Daniele Cocca
d127c1d59e CBE: handle returning undefined for ErrorUnion
Just like for Struct in 8238d4b33585a715c58ab559cd001dd3ea1db55b, in the
case of ErrorUnion struct we need to return a compound literal "(T){...}"
instead of just "{}", which is invalid code when used in e.g. a "return"
expression.
2022-04-30 13:29:21 -04:00
sin-ack
032c722d20
Sema: Fix many-pointer array concatenation at comptime (#11512)
* Sema: Correctly determine whether array_cat lhs and rhs are single ptrs

Many-pointers are also not single-pointers and wouldn't be considered
here. This commit makes the conditions use the appropriately-named
isSinglePointer instead.

* Sema: Correctly obtain ArrayInfo for many-pointer concatenation

Many-pointers at comptime have a known size like slices and can be used
in array concatenation. This fixes a stage1 regression.

* test: Add comptime manyptr concatenation test

Co-authored-by: sin-ack <sin-ack@users.noreply.github.com>
2022-04-29 22:53:06 -04:00
Andrew Kelley
cc39d453c4
Merge pull request #11549 from Vexu/stage2-fixes
Stage2: fix comptime unreachable, adjust Zir.Extended
2022-04-29 22:50:53 -04:00
Jimmi Holst Christensen
a0a2ce92ca std: Do not allocate the result for ChildProcess.init
Instead, just return ChildProcess directly. This structure does not
require a stable address, so we can put it on the stack just fine. If
someone wants it on the heap they should do.

  const proc = try allocator.create(ChildProcess);
  proc.* = ChildProcess.init(args, allocator);
2022-04-29 22:50:34 -04:00
Veikka Tuominen
a6f254ec3e stage2: fix comptime unreachable 2022-04-30 01:05:48 +03:00
Jakub Konka
3b8187072f
Merge pull request #11530 from ziglang/test-harness
test: move compare and run tests to new test harness
2022-04-29 08:24:02 +02:00
Daniele Cocca
fda143d5d8 CBE: fix renderValue() for struct fields with no runtime bits
These shouldn't count towards the total emitted, or the stray comma
separators would cause compilation errors.
2022-04-28 23:41:42 -04:00
Veikka Tuominen
091fe78337
Merge pull request #11541 from Vexu/stage2-slice-field-ptr
Stage2: fix slice field modification at comptime
2022-04-28 22:27:50 +03:00
Jakub Konka
62625d9d95 test: migrate stage1 compile error tests to updated test manifest 2022-04-28 18:35:01 +02:00
Jakub Konka
c8d0fb0b21 test: migrate stage2 independent compile errors to test manifest parser 2022-04-28 18:35:01 +02:00
Jakub Konka
3c19f694d9 test: fix incorrect error loc in assert_function x86_64-linux test 2022-04-28 18:35:01 +02:00
Jakub Konka
2875216f8e test: fix x86_64-macos failures
This is just a temporary fix - I would like to unify all of x86_64
tests across linux and macos OSes.
2022-04-28 18:35:01 +02:00
Jakub Konka
5a5648c0f0 test: migrate llvm incremental tests 2022-04-28 18:35:01 +02:00
Jakub Konka
495bb12e6a test: migrate plan9 and sparcv9 incremental tests 2022-04-28 18:35:01 +02:00
Jakub Konka
ed51a5d02a test: migrate arm incremental tests 2022-04-28 18:35:01 +02:00
Jakub Konka
fc4fbfe8e1 test: migrate aarch64 incremental tests 2022-04-28 18:35:01 +02:00
Jakub Konka
7e17cbbda5 test: migrate riscv64 incremental tests 2022-04-28 18:35:01 +02:00
Jakub Konka
8e05e6a1ed test: migrate wasm incremental tests 2022-04-28 18:35:01 +02:00
Jakub Konka
8d5acf7693 test: recursively walk dir with tests
Prune incremental tests by moving non-incremental behavior tests to
behavior test suite instead.
2022-04-28 18:35:01 +02:00
Jakub Konka
e4a8a66504 test: remove incremental tests that were ported to the new harness 2022-04-28 18:35:01 +02:00
Jakub Konka
97b781955e test: fix incorrect default target spec; port all incremental tests 2022-04-28 18:35:01 +02:00
Jakub Konka
0998185f77 test: adjust error location for assert_function test 2022-04-28 18:35:01 +02:00
Jakub Konka
c1a98cd65d test: set case name from initial filename for a sequence
Port more incremental tests.
2022-04-28 18:35:01 +02:00
Jakub Konka
46db5e2a44 test: unroll into multiple cases, provide default parsers
Provide default parsers for obvious config options such as
`CrossTarget` or `Backend` (or any enum for that matter).

Unroll iterator loops into multiple cases - we need to create
a Cartesian product for all possibilities specified in the
test manifest.
2022-04-28 18:35:01 +02:00
Jakub Konka
f41dd3617e test: pass Strategy per directory of tests 2022-04-28 18:35:01 +02:00
Jakub Konka
d8d12d51ec test: abstract away test manifest parser into separate struct 2022-04-28 18:35:01 +02:00
Veikka Tuominen
095d51164f Sema: fix slice field modification at comptime 2022-04-28 17:45:33 +03:00
Andrew Kelley
9d098657a0 stage1: fix i386-windows f80 sizeof/alignof 2022-04-27 22:57:12 -07:00
Andrew Kelley
7d8067878d disable failing behavior test
This is a new test added in this branch but it is not yet passing for
i386-windows with the stage1 compiler.
2022-04-27 18:41:53 -07:00
Andrew Kelley
dc62dde982 behavior test: use expectApproxEqAbs instead of expectEqual
This is to account for the small differences in math functions of
different libcs. For example, if the compiler links against glibc,
but the target is musl libc, then these values might be
slightly different.

Arguably, this is a bug in the compiler because comptime should
emulate the target, including rounding errors in libc math
functions. However that behavior is not what this particular test
is intended to cover.
2022-04-27 17:58:26 -07:00
Andrew Kelley
758ec9bdd4 enable newly passing behavior tests
closes #11030
2022-04-27 17:24:36 -07:00
Andrew Kelley
09f1d62bdf add new builtin function @tan
The reason for having `@tan` is that we already have `@sin` and `@cos`
because some targets have machine code instructions for them, but in the
case that the implementation needs to go into compiler-rt, sin, cos, and
tan all share a common dependency which includes a table of data. To
avoid duplicating this table of data, we promote tan to become a builtin
alongside sin and cos.

ZIR: The tag enum is at capacity so this commit moves
`field_call_bind_named` to be `extended`. I measured this as one of
the least used tags in the zig codebase.

Fix libc math suffix for `f32` being wrong in both stage1 and stage2.
stage1: add missing libc prefix for float functions.
2022-04-27 16:45:23 -07:00
Andrew Kelley
c4eaff6665 disable failing behavior tests 2022-04-27 14:29:59 -07:00
Andrew Kelley
41dd2beaac compiler-rt: math functions reorg
* unify the logic for exporting math functions from compiler-rt,
   with the appropriate suffixes and prefixes.
   - add all missing f128 and f80 exports. Functions with missing
     implementations call other functions and have TODO comments.
   - also add f16 functions
 * move math functions from freestanding libc to compiler-rt (#7265)
 * enable all the f128 and f80 code in the stage2 compiler and behavior
   tests (#11161).
 * update std lib to use builtins rather than `std.math`.
2022-04-27 12:20:44 -07:00
Andrew Kelley
50f1856476
Merge pull request #11336 from wsengir/stage2-optimize-intcast
Sema: combine signed->unsigned and shrinkage runtime checks in intCast
2022-04-26 13:20:19 -04:00
Andrew Kelley
ab658e32bd Sema: fix export with Internal linkage
The Export tables should only be populated with non-internal exports.
2022-04-24 20:24:37 -07:00
William Sengir
eac09ac350
CBE: disable int128 test since airWrapOp is needed for runtime safety 2022-04-22 22:22:30 -07:00
Andrew Kelley
cf20b97b71
Merge pull request #11279 from igor84/s1_packed_struct
stage1: Fix packed structs (#2627, #10104)
2022-04-22 11:39:12 -04:00
Andrew Kelley
0e830b1630 clean up behavior tests
Split big test into the two separate things it is testing.
Add missing checks to the test which revealed the test is not actually
passing yet for the C backend.
2022-04-22 07:52:21 -07:00
Annika L
c992b25908 C backend: Fix array declarations 2022-04-22 07:42:47 -07:00
joachimschmidt557
fa85a739d9
stage2 AArch64: fix shl, shr, shl_exact, shr_exact
Introduces the necessary truncation after shift
2022-04-19 22:40:51 +02:00
joachimschmidt557
0a909a6712
stage2 AArch64: implement addwrap, subwrap, mulwrap 2022-04-19 22:40:50 +02:00
joachimschmidt557
d9d9fea6ae
stage2 AArch64: Add ldrsb, ldrsh instructions 2022-04-19 22:40:48 +02:00
joachimschmidt557
f95a8ddafa
stage2 AArch64: Implement basic truncate functionality 2022-04-19 22:39:14 +02:00
Jakub Konka
8f75823728
Merge pull request #11446 from ziglang/aarch64-macos-llvm
stage2: fix behavior test failures on aarch64-macos (LLVM+native), and other minor fixes
2022-04-16 18:07:02 +02:00
Jakub Konka
897df18573 stage2: fix @mulAdd on aarch64 Darwin
According to Apple docs, the long double type is a double precision
IEEE754 binary floating-point type, which makes it identical to the
double type. This behavior contrasts to the standard specification,
in which a long double is a quad-precision, IEEE754 binary,
floating-point type.

Thus, we need to take this into account when using the compiler
intrinsics so that we select the correct function version for
FloatMulAdd.
2022-04-16 12:23:47 +02:00
Andrew Kelley
578a792b33
Merge pull request #11442 from Vexu/stage3
Make self hosted compiler capable of building itself
2022-04-16 05:42:25 -04:00
Veikka Tuominen
7be62f695f stage2 llvm: fix optional pointers to zero bit payloads 2022-04-15 19:17:50 +03:00
Andrew Kelley
4c83b11f71
Merge pull request #11438 from Vexu/stage2-fixes
Stage2 fixes
2022-04-15 12:02:55 -04:00
Veikka Tuominen
3723eb7f31
Merge pull request #11242 from schmee/sema-handle-more-union-errors
stage2: add more union compile errors / improve error messages
2022-04-15 11:34:04 +03:00