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.
This commit is contained in:
Jacob Young
2025-05-30 14:38:46 -04:00
committed by mlugg
parent 4c4dacf81a
commit d9b6d1ed33
5 changed files with 13 additions and 4 deletions

View File

@@ -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");