mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
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:
parent
4c4dacf81a
commit
d9b6d1ed33
@ -51,7 +51,7 @@ const Instruction = encoding.Instruction;
|
||||
|
||||
const InnerError = CodeGenError || error{OutOfRegisters};
|
||||
|
||||
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,
|
||||
|
||||
@ -31,7 +31,7 @@ const libcFloatSuffix = target_util.libcFloatSuffix;
|
||||
const compilerRtFloatAbbrev = target_util.compilerRtFloatAbbrev;
|
||||
const compilerRtIntAbbrev = target_util.compilerRtIntAbbrev;
|
||||
|
||||
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,
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
pub const Env = enum {
|
||||
/// zig1 features
|
||||
/// - `-ofmt=c` only
|
||||
/// - `-OReleaseFast` or `-OReleaseSmall` only
|
||||
/// - no `@setRuntimeSafety(true)`
|
||||
bootstrap,
|
||||
|
||||
/// zig2 features
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user