aboutsummaryrefslogtreecommitdiff
path: root/src/target.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-12-19 15:22:47 -0700
committerAndrew Kelley <andrew@ziglang.org>2024-01-01 17:51:20 -0700
commit529d01c2baf695c2844b5dd42642a74749bef0d0 (patch)
treed5c54c9a9f9d835ab0a7f0e8789fda1957cb8224 /src/target.zig
parent8944dea23fb554290a4b54ca40b0594f6e3f77a9 (diff)
downloadzig-529d01c2baf695c2844b5dd42642a74749bef0d0.tar.gz
zig-529d01c2baf695c2844b5dd42642a74749bef0d0.zip
resolve error tracing logic at module creation time
rather than checking multiple conditions in Sema
Diffstat (limited to 'src/target.zig')
-rw-r--r--src/target.zig19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/target.zig b/src/target.zig
index 4adc26aff8..d1a98601cf 100644
--- a/src/target.zig
+++ b/src/target.zig
@@ -2,6 +2,7 @@ const std = @import("std");
const Type = @import("type.zig").Type;
const AddressSpace = std.builtin.AddressSpace;
const Alignment = @import("InternPool.zig").Alignment;
+const Feature = @import("Module.zig").Feature;
pub const default_stack_protector_buffer_size = 4;
@@ -665,6 +666,24 @@ pub fn zigBackend(target: std.Target, use_llvm: bool) std.builtin.CompilerBacken
};
}
+pub fn backendSupportsFeature(
+ cpu_arch: std.Target.Cpu.Arch,
+ ofmt: std.Target.ObjectFormat,
+ use_llvm: bool,
+ feature: Feature,
+) bool {
+ return switch (feature) {
+ .panic_fn => ofmt == .c or use_llvm or cpu_arch == .x86_64,
+ .panic_unwrap_error => ofmt == .c or use_llvm,
+ .safety_check_formatted => ofmt == .c or use_llvm,
+ .error_return_trace => use_llvm,
+ .is_named_enum_value => use_llvm,
+ .error_set_has_value => use_llvm or cpu_arch.isWasm(),
+ .field_reordering => use_llvm,
+ .safety_checked_instructions => use_llvm,
+ };
+}
+
pub fn defaultEntrySymbolName(
target: std.Target,
/// May be `undefined` when `target` is not WASI.