Commit Graph

2476 Commits

Author SHA1 Message Date
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
Veikka Tuominen 9d9815fb9c Value: handle comparisons of runtime_values
Closes #15004
2023-03-21 00:34:12 +02:00
Veikka Tuominen 773b1c4c5c llvm: fix lowering packed union initiated to zero-bit value
Closes #14980
2023-03-21 00:34:12 +02:00
mlugg 71e873703f Sema: make @returnAddress return 0 at comptime
See also #14938.

Resolves: #14931
2023-03-17 15:55:02 -04:00
mlugg 4ec299007a Sema: allow dereferencing ill-defined pointers to zero-bit types at comptime
It doesn't matter if a pointer to a zero-bit (i.e. OPV) type is
undefined or runtime-known; we still know the result of the dereference
at comptime. Code may use this, for instance, when allocating zero-bit
types: `@as(*void, undefined)` is entirely reasonable to use at runtime,
since we know the pointer will never be accessed, thus it should be
valid at comptime too.
2023-03-17 01:56:36 -04:00
Andrew Kelley fbce6a749d disable failing aarch64 backend behavior tests 2023-03-15 10:48:14 -07:00
Jacob Young 05b12e6779 x86_64: handle duplicate prong deaths 2023-03-15 01:04:21 -04:00
Jacob Young c51930b060 behavior: enable passing behavior tests on stage2_x86_64 2023-03-15 01:04:21 -04:00
mlugg 1e6d7f7763 Sema: allow comptime mutation of multiple array elements
Previously, if you had a pointer to multiple array elements and tried to
write to it at comptime, it was incorrectly treated as a pointer to one
specific array value, leading to an assertion down the line. If we try
to mutate a value at an elem_ptr larger than the element type, we need
to perform a modification to multiple array elements.

This solution isn't ideal, since it will result in storePtrVal
serializing the whole array, modifying the relevant parts, and storing
it back. Ideally, it would only take the required elements. However,
this change would have been more complex, and this is a fairly rare
operation (nobody ever ran into the bug before after all), so it doesn't
matter all that much.
2023-03-14 13:06:23 +02:00
Ian Johnson adc6dec26b Sema: avoid panic on callconv(.C) generic return type
Fixes #14854
2023-03-13 13:17:13 +02:00
John Schmidt 0606f0aa55 sema: fix result ptr coercion array -> vector
Previously this worked for array to vector where the element type
matched exactly (e.g `[4]u8` to `@Vector(4, u8)`) since that is
performed with a simple `.bitcast` operation, but now it also works for
types where the array is coercible to the vector type (e.g `[4]u8` to
`@Vector(4, u16)`).
2023-03-09 00:55:33 +01:00
John Schmidt 505e720421 sema: add peer type resolution for vectors
This is consistent with how coercion for vectors work. So now you can do
this:

```
var a: @Vector(2, u16) = .{1, 2};
var b: @Vector(2, u8) = .{2, 1};
const c = @min(a, b);
```

where previously you had to cast explicitly:

```
var a: @Vector(2, u16) = .{1, 2};
var b: @Vector(2, u8) = .{2, 1};
var c: @Vector(2, u16) = b;
const c = @min(a, c);
```
2023-03-09 00:55:17 +01:00
Jacob Young 77d06012c2 CBE: implement unsigned big int div and mod 2023-03-07 03:03:35 -05:00
Jacob Young c1d16a2b80 compiler_rt: fix rare case in udivei4
Unsigned integers are never less than zero, and so zig
helpfully deleted the entire case. :D

Closes #14816
2023-03-07 03:00:08 -05:00
Andrew Kelley 2641feb9b9 Merge pull request #14789 from jacobly0/ditype
llvm: fix use after free with pointers to optional slices
2023-03-05 16:32:51 -05:00
r00ster91 f1ae688d37 AstGen: ensure certain builtin functions return void
Fixes #14779

Co-authored-by: Veikka Tuominen <git@vexu.eu>
2023-03-05 23:01:17 +02:00
Jacob Young 8ea1c1932e behavior: disable failing tests 2023-03-05 04:25:04 -05:00
Jacob Young 7352d461cf behavior: fix comptime issue and disable failing test 2023-03-05 03:34:57 -05:00
Jacob Young 33fa25ba44 CBE: ensure uniqueness of more internal identifiers 2023-03-05 02:59:02 -05:00
Jacob Young 0b0298aff2 CBE: implement select and shuffle 2023-03-05 02:59:02 -05:00
Jacob Young aac4707902 CBE: implement splat 2023-03-05 02:59:02 -05:00
Jacob Young ba69ee488b CBE: implement vector truncate 2023-03-05 02:59:02 -05:00
Jacob Young 8f6da78fb1 CBE: implement vector element pointers 2023-03-05 02:59:02 -05:00
Jacob Young c478c7609e CBE: implement vector operations
Also, bigint add and sub which is all I was actually trying to do.
2023-03-05 02:59:02 -05:00
Jacob Young 93d696e84e CBE: implement some big integer and vector unary operations 2023-03-05 02:59:01 -05:00
Jacob Young a8f4ac2b94 CBE: implement big integer and vector comparisons 2023-03-05 02:59:01 -05:00
Jacob Young 874ae81f1b CBE: implement big integer literals 2023-03-05 02:59:01 -05:00
Andrew Kelley 16302578d5 add behavior test case for previous commit 2023-03-04 14:04:58 -07:00
Jakub Konka 18e6d1e819 Merge pull request #14781 from ziglang/codegen-cleanup
codegen: move common logic for generating typed values from each native backend into codegen.zig
2023-03-04 03:38:12 +01:00
r00ster91 e0d3904638 Ast: properly handle sentinel-terminated slices in tuple
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2023-03-04 01:08:03 +02:00
Jakub Konka d8d8842190 arm: skip unimplemented behavior test for @fieldParentPtr 2023-03-03 18:42:29 +01:00
Jacob Young 1453a595aa CBE: reuse locals with the same CType instead of Type
Many `Type`s can correspond to the same `CType`, so this reduces the
number of used locals by 27760 when compiling only-c.

Also, disabled some tests that were only passing by accident and
shouldn't really be considered working.
2023-02-24 23:41:54 -05:00
Jacob Young f8aecef670 CBE: implement the future
Turns out f(...) will be supported one day.
2023-02-23 21:25:29 -05:00
Jacob Young 57f6adf85d CBE: implement c varargs
Removed some backend test skip checks for things disabled in std.
2023-02-23 01:21:59 -05:00
Jacob Young 597e8011f7 CType: fix lowering of generic function pointer 2023-02-23 00:29:23 -05:00
Jacob Young bdb1e014a0 CBE: cleanup field access
* Implement @fieldParentPtr on a union
 * Refactor field access to ensure that it is handled consistently
 * Remove `renderTypecast` as it is now behaves the same as `renderType`
2023-02-23 00:29:23 -05:00
Andrew Kelley c9e02d3e69 Merge pull request #14691 from jacobly0/ctype 2023-02-22 11:06:13 -05:00
Jacob Young 248fb40dcc CBE: fix windows test failures 2023-02-21 15:46:34 -05:00
Jacob Young 434c6f42ca behavior: enable passing CBE tests 2023-02-21 09:43:23 -05:00
Isaac Freund 05da5b32a8 Sema: implement @fieldParentPtr for unions 2023-02-21 15:57:13 +02:00
Jakub Konka dc1f50e505 Merge pull request #14685 from ziglang/bitcast-fixes
Bitcast fixes for self-hosted native backends
2023-02-20 23:01:21 +01:00