Commit graph

2283 commits

Author SHA1 Message Date
Ali Cheraghi
aec0f9b3e7
test: skip failing tests with spirv-vulkan 2025-02-24 19:39:42 +01:00
mlugg
5e20e9b449 Sema: allow @ptrCast of slices changing the length
Also, refactor `Sema.ptrCastFull` to not be a horrifying hellscape.
2025-02-23 08:28:58 +00:00
Jacob Young
220f80e71d Dwarf: fix lowering of comptime-only optional pointer null values
Closes #22974
2025-02-22 22:47:32 -05:00
David Rubin
84aac8b6c7 Type: resolve union tag type before checking for runtime bits 2025-02-22 22:22:55 -05:00
Andrew Kelley
eb3c7f5706 zig build fmt 2025-02-22 17:09:20 -08:00
Pavel Verigo
b25d93e7d9 stage2-wasm: implement switch_dispatch + handle > 32 bit integers in switches
Updated solution is future proof for arbitary size integer handling for both strategies .br_table lowering if switch case is dense, .br_if base jump table if values are too sparse.
2025-02-22 18:34:00 -05:00
Jacob Young
300cb4881f x86_64: rewrite scalar @bitReverse 2025-02-22 00:05:47 -05:00
Alex Rønne Petersen
fc7a0c4878 Sema: Fix fnptr alignment safety checks to account for potential ISA tag.
As seen on e.g. Arm/Thumb and MIPS (MIPS16/microMIPS).

Fixes #22888.
2025-02-22 04:12:46 +01:00
Jacob Young
7d70d7b215 x86_64: rewrite scalar @popCount 2025-02-18 09:47:44 -05:00
Jacob Young
ebea56d279 x86_64: rewrite scalar @ctz 2025-02-18 09:47:44 -05:00
Andrew Kelley
d2e70ef84a
Merge pull request #22913 from jacobly0/x86_64-rewrite
x86_64: rewrite unsafe int vector multiplication
2025-02-17 16:13:22 -08:00
Alex Rønne Petersen
481b7bf3f0
std.Target: Remove functions that just wrap component functions.
Functions like isMinGW() and isGnuLibC() have a good reason to exist: They look
at multiple components of the target. But functions like isWasm(), isDarwin(),
isGnu(), etc only exist to save 4-8 characters. I don't think this is a good
enough reason to keep them, especially given that:

* It's not immediately obvious to a reader whether target.isDarwin() means the
  same thing as target.os.tag.isDarwin() precisely because isMinGW() and similar
  functions *do* look at multiple components.
* It's not clear where we would draw the line. The logical conclusion before
  this commit would be to also wrap Arch.isX86(), Os.Tag.isSolarish(),
  Abi.isOpenHarmony(), etc... this obviously quickly gets out of hand.
* It's nice to just have a single correct way of doing something.
2025-02-17 19:18:19 +01:00
Jacob Young
82eedf56d7 x86_64: rewrite scalar @byteSwap 2025-02-17 05:36:18 -05:00
Jacob Young
cec6867d76 x86_64: rewrite unsafe int vector multiplication 2025-02-17 00:10:24 -05:00
Jacob Young
dcc9fe322e x86_64: rewrite unsafe scalar int multiplication 2025-02-15 04:13:21 -05:00
Jacob Young
4ea18c22f9 x86_64: rewrite array access 2025-02-15 03:45:21 -05:00
Jacob Young
f6bcc9dbcb x86_64: rewrite scalar and vector int @rem 2025-02-15 03:45:21 -05:00
Jacob Young
8c48376d64 x86_64: rewrite scalar and vector int @divTrunc 2025-02-15 03:45:21 -05:00
Jacob Young
9f121ec8fb x86_64: implement unsafe scalar and vector integer add/sub 2025-02-15 03:45:21 -05:00
Jacob Young
13ca87e204 x86_64: implement conversions between float and int vectors 2025-02-12 10:11:54 -05:00
Jacob Young
5433e0438c cbe: fix ub triggered by mulw overflowing the promoted type
Closes #21914
2025-02-10 17:22:16 -08:00
Jacob Young
74fbcd22e6 cbe: fix crash rendering argument names in lazy functions
Closes #19905
2025-02-10 17:20:52 -08:00
Jacob Young
4e4775d6bd x86_64: implement conversions between scalar floats and ints
Closes #22797
2025-02-09 00:42:55 -08:00
Andrew Kelley
2d4954ad63
Merge pull request #22717 from jacobly0/x86_64-rewrite
x86_64: rewrite `@truncate`
2025-02-07 04:06:50 -08:00
Isaac Freund
87bbb49d5f test: check @tagName() in callconv C function
This is a regression test for an x86_64 backend miscompilation when
using @tagName() in a callconv(.c) function with -fPIC.
2025-02-07 07:20:53 +01:00
Jacob Young
6afc5770d3 wasm: disable failing tests 2025-02-06 17:02:54 -05:00
Jacob Young
c2718c4803 x86_64: rewrite float @mod 2025-02-06 16:14:53 -05:00
Jacob Young
288d3062d0 x86_64: avoid comparing different transcendental function impls 2025-02-06 16:14:53 -05:00
Jacob Young
fa9b0fa6d3 x86_64: rewrite most of the remaining float ops 2025-02-06 16:14:53 -05:00
Jacob Young
39119088f9 x86_64: rewrite vector @truncate 2025-02-06 16:14:53 -05:00
Jacob Young
c58e60a042 x86_64: rewrite scalar @truncate 2025-02-06 16:14:53 -05:00
mlugg
5d935e1137
behavior: add test for old bug
Resolves: #18435
2025-02-06 01:23:27 +00:00
mlugg
164700740b
behavior: add test for old bug
Resolves: #13013
2025-02-06 00:52:03 +00:00
mlugg
6bd92a21b7
behavior: add test for old bug
Resolves: #2289
2025-02-06 00:51:59 +00:00
mlugg
3031d81387
Sema: fix @typeInfo of function with generic return type and IES
Resolves: #20088
2025-02-05 21:26:04 +00:00
mlugg
5317d88414
Sema: fix @errorCast with error unions
Resolves: #20169
2025-02-05 21:17:40 +00:00
mlugg
fbbf34e563
Sema: disable runtime safety checks in comptime blocks
Sometimes we emit runtime instructions in comptime scopes. These
instructions will be discarded, but they allow comptime blocks to
contain intermediate runtime-known values, which is necessary for
expressions like `runtime_array.len` to work.

Since we will always throw away these runtime instructions, including
safety checks is a time waste at best and trips an assertion at worst!

Resolves: #20064
2025-02-05 21:17:40 +00:00
mlugg
cac814cf58
Sema: fix comparison between error set and comptime-known error union
Resolves: #20613
2025-02-05 20:13:56 +00:00
mlugg
fbe0ae4fd4
Sema: fix PTR of slice of sentinel-terminated array
Resolves: #20901
2025-02-05 19:53:12 +00:00
mlugg
0f38558435
compiler: provide result type to sentinel expression in slice operation
Resolves: #21867
2025-02-05 19:36:14 +00:00
Mason Remaley
13c6eb0d71
compiler,std: implement ZON support
This commit allows using ZON (Zig Object Notation) in a few ways.

* `@import` can be used to load ZON at comptime and convert it to a
  normal Zig value. In this case, `@import` must have a result type.
* `std.zon.parse` can be used to parse ZON at runtime, akin to the
  parsing logic in `std.json`.
* `std.zon.stringify` can be used to convert arbitrary data structures
  to ZON at runtime, again akin to `std.json`.
2025-02-03 09:14:37 +00:00
Andrew Kelley
963651bbf2
Merge pull request #22672 from jacobly0/x86_64-rewrite
x86_64: rewrite float conversions
2025-02-01 14:32:43 -08:00
mlugg
3924f173af compiler: do not propagate result type to try operand
This commit effectively reverts 9e683f0, and hence un-accepts #19777.
While nice in theory, this proposal turned out to have a few problems.

Firstly, supplying a result type implicitly coerces the operand to this
type -- that's the main point of result types! But for `try`, this is
actually a bad idea; we want a redundant `try` to be a compile error,
not to silently coerce the non-error value to an error union. In
practice, this didn't always happen, because the implementation was
buggy anyway; but when it did, it was really quite silly. For instance,
`try try ... try .{ ... }` was an accepted expression, with the inner
initializer being initially coerced to `E!E!...E!T`.

Secondly, the result type inference here didn't play nicely with
`return`. If you write `return try`, the operand would actually receive
a result type of `E!E!T`, since the `return` gave a result type of `E!T`
and the `try` wrapped it in *another* error union. More generally, the
problem here is that `try` doesn't know when it should or shouldn't
nest error unions. This occasionally broke code which looked like it
should work.

So, this commit prevents `try` from propagating result types through to
its operand. A key motivation for the original proposal here was decl
literals; so, as a special case, `try .foo(...)` is still an allowed
syntax form, caught by AstGen and specially lowered. This does open the
doors to allowing other special cases for decl literals in future, such
as `.foo(...) catch ...`, but those proposals are for another time.

Resolves: #21991
Resolves: #22633
2025-02-01 15:48:45 +00:00
mlugg
149031204c
Sema: skip aliasing check and runtime operation for @memcpy of zero-bit type
This check isn't valid in such cases, because the source and destination
pointers both refer to zero bits of memory, meaning they effectively
never alias.

Resolves: #21655
2025-02-01 09:48:18 +00:00
Jacob Young
4c5abe5ac6 x86_64: rewrite vector @intCast 2025-01-31 23:09:58 -05:00
Jacob Young
f0ac14ce97 x86_64: rewrite scalar @intCast 2025-01-31 23:09:36 -05:00
Jacob Young
b9531f5de6 x86_64: rewrite float vector conversions 2025-01-31 23:00:34 -05:00
Jacob Young
8195b64f57 x86_64: rewrite scalar float conversions 2025-01-31 23:00:34 -05:00
Jacob Young
e4c049e410 x86_64: rewrite comparisons 2025-01-29 22:00:08 -08:00
Jacob Young
654da648b3 x86_64: rewrite @min/@max for float vectors 2025-01-26 09:51:07 -05:00