Legalize: make the feature set comptime-known in zig1

This allows legalizations to be added that aren't used by zig1 without
affecting the size of zig1.
This commit is contained in:
Jacob Young
2025-06-15 11:36:15 -04:00
parent 1ca213dab0
commit 6e72026e3b
2 changed files with 78 additions and 42 deletions

View File

@@ -23,12 +23,19 @@ const BigIntLimb = std.math.big.Limb;
const BigInt = std.math.big.int;
pub fn legalizeFeatures(_: *const std.Target) ?*const Air.Legalize.Features {
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
return comptime switch (dev.env.supports(.legalize)) {
inline false, true => |supports_legalize| &.init(.{
// we don't currently ask zig1 to use safe optimization modes
.expand_intcast_safe = supports_legalize,
.expand_add_safe = supports_legalize,
.expand_sub_safe = supports_legalize,
.expand_mul_safe = supports_legalize,
.expand_packed_load = true,
.expand_packed_store = true,
.expand_packed_struct_field_val = true,
}),
};
}
/// For most backends, MIR is basically a sequence of machine code instructions, perhaps with some