83 Commits

Author SHA1 Message Date
Ali Cheraghi
dec1163fbb
all: replace all @Type usages
Co-authored-by: Matthew Lugg <mlugg@mlugg.co.uk>
2025-11-22 22:42:38 +00:00
Jacob Young
e1f3fc6ce2 Coff2: create a new linker from scratch 2025-10-02 17:44:52 -04:00
Jacob Young
d5f09f56e0 x86_64: fix windows calling convention abi 2025-10-02 15:59:51 -04:00
Jacob Young
a744fbd22f x86_64: fix ~/! miscomps 2025-09-27 18:30:52 -04:00
Andrew Kelley
426af68b7d compiler: require comptime vector indexes 2025-09-20 18:33:00 -07:00
Jacob Young
38dfa6537e cbe: emit nonstring attribute
Closes #24545
2025-08-11 11:30:51 -07:00
Justus Klausecker
6ec275ebd8 Sema: remove incorrect safety check for saturating left shift 2025-07-30 10:15:48 +01:00
Jacob Young
1f98c98fff x86_64: increase passing test coverage on windows
Now that codegen has no references to linker state this is much easier.

Closes #24153
2025-06-19 18:41:12 -04:00
Jacob Young
df4068cabd Build: change how the target is printed in step names
e.g. `x86_64-windows.win10...win11_dt-gnu` -> `x86_64-windows-gnu`

When the OS version is the default this is redundant with checking the
default in the standard library.
2025-06-19 11:45:06 -04:00
Alex Rønne Petersen
9d534790eb std.Target: Introduce Cpu convenience functions for feature tests.
Before:

* std.Target.arm.featureSetHas(target.cpu.features, .has_v7)
* std.Target.x86.featureSetHasAny(target.cpu.features, .{ .sse, .avx, .cmov })
* std.Target.wasm.featureSetHasAll(target.cpu.features, .{ .atomics, .bulk_memory })

After:

* target.cpu.has(.arm, .has_v7)
* target.cpu.hasAny(.x86, &.{ .sse, .avx, .cmov })
* target.cpu.hasAll(.wasm, &.{ .atomics, .bulk_memory })
2025-06-05 06:12:00 +02:00
Jacob Young
2543e2d97c x86_64: implement integer @divFloor and @mod
Closes #24039
2025-06-02 22:45:15 -04:00
Jacob Young
9edfccb9a7
Legalize: implement scalarization of overflow intrinsics 2025-06-01 08:24:01 +01:00
Jacob Young
b483defc5a Legalize: implement scalarization of binary operations 2025-05-31 18:54:28 -04:00
Jacob Young
c1e9ef9eaa Legalize: implement scalarization of unary operations 2025-05-31 18:54:28 -04:00
Jacob Young
9f9e7e398f x86_64: implement strict float @reduce(.Max) 2025-05-28 15:10:22 -04:00
Jacob Young
f5a1aaf2fc x86_64: implement strict float @reduce(.Min) 2025-05-28 15:10:22 -04:00
Jacob Young
d29ea656b0 x86_64: implement optimized float @reduce(.Max) 2025-05-28 15:10:22 -04:00
Jacob Young
114a4eaf5c x86_64: implement optimized float @reduce(.Min) 2025-05-28 15:10:22 -04:00
Jacob Young
8bacf3e757 x86_64: implement integer @reduce(.Max) 2025-05-28 15:10:22 -04:00
Jacob Young
3fd3358f37 x86_64: implement integer @reduce(.Min) 2025-05-28 15:10:22 -04:00
Jacob Young
7d727ed7df x86_64: implement strict float @reduce(.Mul) 2025-05-28 15:10:22 -04:00
Jacob Young
d1785cf61c x86_64: implement strict float @reduce(.Add) 2025-05-28 15:10:22 -04:00
Jacob Young
a4a1ebdeed x86_64: implement optimized float @reduce(.Mul) 2025-05-28 15:10:22 -04:00
Jacob Young
612f5784cf x86_64: implement optimized float @reduce(.Add) 2025-05-28 15:10:22 -04:00
Jacob Young
7bfdb7f26d x86_64: implement integer @reduce(.Mul) 2025-05-28 15:10:22 -04:00
Jacob Young
1f6f8b0ffe x86_64: implement integer @reduce(.Add) 2025-05-28 15:10:22 -04:00
Jacob Young
d69f4c48fc x86_64: rewrite bitwise @reduce 2025-05-28 15:10:22 -04:00
Jacob Young
a4eabd3979 x86_64: implement vector_store_elem 2025-05-17 20:31:25 -04:00
Jacob Young
a3b0c242b0 x86_64: rewrite @splat 2025-05-17 18:00:17 -04:00
Jacob Young
58d2bd601e x86_64: rewrite scalar <<|
Closes #23035
2025-05-17 18:00:17 -04:00
Jacob Young
d3dfe61eaa x86_64: rewrite scalar *| 2025-05-17 18:00:17 -04:00
Jacob Young
96e35b3652 x86_64: rewrite vector -| 2025-05-17 02:08:41 -04:00
Jacob Young
3529889cf3 x86_64: rewrite scalar -| 2025-05-17 02:08:41 -04:00
Jacob Young
6d68a494c8 x86_64: rewrite vector +| 2025-05-17 02:08:41 -04:00
Jacob Young
6dbf1c7682 x86_64: rewrite scalar +| 2025-05-17 02:08:41 -04:00
Jacob Young
932298679f x86_64: rewrite scalar @shlWithOverflow 2025-05-17 02:08:41 -04:00
Jacob Young
bc10131db1 x86_64: rewrite scalar @mulWithOverflow
Closes #19607
2025-04-09 20:14:12 -04:00
Jacob Young
55ce756868 x86_64: rewrite scalar @subWithOverflow 2025-04-09 20:14:12 -04:00
Jacob Young
80068b6e59 x86_64: rewrite scalar @addWithOverflow 2025-04-09 20:14:12 -04:00
Jacob Young
426684b2f8 behavior: fix issues with x86_64 backend tests
* Oops, I accidentally disabled most of them.
 * Cleanup some workarounds for now closed issues.
 * Test binary operations with more scalar integer types.
2025-04-09 20:14:12 -04:00
Jacob Young
2361468e23 x86_64: rewrite scalar shifts 2025-03-21 21:51:09 -04:00
Jacob Young
8e15321c7c behavior: split up x86_64 math tests 2025-03-21 21:51:08 -04:00
Jacob Young
c5c1c8538d x86_64: rewrite wrapping multiplication 2025-03-21 21:51:08 -04:00
mlugg
2a4e06bcb3 Sema: rewrite comptime arithmetic
This commit reworks how Sema handles arithmetic on comptime-known
values, fixing many bugs in the process.

The general pattern is that arithmetic on comptime-known values is now
handled by the new namespace `Sema.arith`. Functions handling comptime
arithmetic no longer live on `Value`; this is because some of them can
emit compile errors, so some *can't* go on `Value`. Only semantic
analysis should really be doing arithmetic on `Value`s anyway, so it
makes sense for it to integrate more tightly with `Sema`.

This commit also implements more coherent rules surrounding how
`undefined` interacts with comptime and mixed-comptime-runtime
arithmetic. The rules are as follows.

* If an operation cannot trigger Illegal Behavior, and any operand is
  `undefined`, the result is `undefined`. This includes operations like
  `0 *| undef`, where the LHS logically *could* be used to determine a
  defined result. This is partly to simplify the language, but mostly to
  permit codegen backends to represent `undefined` values as completely
  invalid states.

* If an operation *can* trigger Illegal Behvaior, and any operand is
  `undefined`, then Illegal Behavior results. This occurs even if the
  operand in question isn't the one that "decides" illegal behavior; for
  instance, `undef / 1` is undefined. This is for the same reasons as
  described above.

* An operation which would trigger Illegal Behavior, when evaluated at
  comptime, instead triggers a compile error. Additionally, if one
  operand is comptime-known undef, such that the other (runtime-known)
  operand isn't needed to determine that Illegal Behavior would occur,
  the compile error is triggered.

* The only situation in which an operation with one comptime-known
  operand has a comptime-known result is if that operand is undefined,
  in which case the result is either undefined or a compile error per
  the above rules. This could potentially be loosened in future (for
  instance, `0 * rt` could be comptime-known 0 with a runtime assertion
  that `rt` is not undefined), but at least for now, defining it more
  conservatively simplifies the language and allows us to easily change
  this in future if desired.

This commit fixes many bugs regarding the handling of `undefined`,
particularly in vectors. Along with a collection of smaller tests, two
very large test cases are added to check arithmetic on `undefined`.

The operations which have been rewritten in this PR are:

* `+`, `+%`, `+|`, `@addWithOverflow`
* `-`, `-%`, `-|`, `@subWithOverflow`
* `*`, `*%`, `*|`, `@mulWithOverflow`
* `/`, `@divFloor`, `@divTrunc`, `@divExact`
* `%`, `@rem`, `@mod`

Other arithmetic operations are currently unchanged.

Resolves: #22743
Resolves: #22745
Resolves: #22748
Resolves: #22749
Resolves: #22914
2025-03-16 08:17:50 +00:00
Jacob Young
50b40c9621 x86_64: rewrite wrapping add/sub 2025-03-01 16:29:22 -05:00
Jacob Young
300cb4881f x86_64: rewrite scalar @bitReverse 2025-02-22 00:05:47 -05: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
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