diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2025-05-30 14:38:46 -0400 |
|---|---|---|
| committer | mlugg <mlugg@mlugg.co.uk> | 2025-06-01 08:24:00 +0100 |
| commit | d9b6d1ed33d18eb13fa2cb39da3e7a381742975b (patch) | |
| tree | afdfcb8ec66c779f9afc064f27befa3ce8036c63 /src/codegen | |
| parent | 4c4dacf81a5da85a1f7d1550ed45f5cb20fd1524 (diff) | |
| download | zig-d9b6d1ed33d18eb13fa2cb39da3e7a381742975b.tar.gz zig-d9b6d1ed33d18eb13fa2cb39da3e7a381742975b.zip | |
cbe: legalize safety instructions in non-zig1 builds
This is valid if the bootstrap dev env doesn't need to support runtime
safety. Another solution can always be implemented if needs change.
Diffstat (limited to 'src/codegen')
| -rw-r--r-- | src/codegen/c.zig | 8 | ||||
| -rw-r--r-- | src/codegen/spirv.zig | 2 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig index e76c8e069d..8d947ce56a 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -4,6 +4,7 @@ const assert = std.debug.assert; const mem = std.mem; const log = std.log.scoped(.c); +const dev = @import("../dev.zig"); const link = @import("../link.zig"); const Zcu = @import("../Zcu.zig"); const Module = @import("../Package/Module.zig"); @@ -21,7 +22,12 @@ const BigIntLimb = std.math.big.Limb; const BigInt = std.math.big.int; pub fn legalizeFeatures(_: *const std.Target) ?*const Air.Legalize.Features { - return null; + return if (dev.env.supports(.legalize)) comptime &.initMany(&.{ + .expand_intcast_safe, + .expand_add_safe, + .expand_sub_safe, + .expand_mul_safe, + }) else null; // we don't currently ask zig1 to use safe optimization modes } pub const CType = @import("c/Type.zig"); diff --git a/src/codegen/spirv.zig b/src/codegen/spirv.zig index e23ffbf66a..1381a79075 100644 --- a/src/codegen/spirv.zig +++ b/src/codegen/spirv.zig @@ -28,7 +28,7 @@ const SpvAssembler = @import("spirv/Assembler.zig"); const InstMap = std.AutoHashMapUnmanaged(Air.Inst.Index, IdRef); -pub fn legalizeFeatures(_: *const std.Target) ?*const Air.Legalize.Features { +pub fn legalizeFeatures(_: *const std.Target) *const Air.Legalize.Features { return comptime &.initMany(&.{ .expand_intcast_safe, .expand_add_safe, |
