Sema: add system for checking backend feature support

This commit is contained in:
Veikka Tuominen
2023-01-05 13:38:14 +02:00
parent 0ecec5fcca
commit 01dba1c054
2 changed files with 49 additions and 65 deletions

View File

@@ -6749,3 +6749,25 @@ pub fn getDeclExports(mod: Module, decl_index: Decl.Index) []const *Export {
return &[0]*Export{};
}
}
pub const Feature = enum {
panic_fn,
panic_unwrap_error,
safety_check_formatted,
error_return_trace,
is_named_enum_value,
error_set_has_value,
};
pub fn backendSupportsFeature(mod: Module, feature: Feature) bool {
return switch (feature) {
.panic_fn => mod.comp.bin_file.options.target.ofmt == .c or
mod.comp.bin_file.options.use_llvm,
.panic_unwrap_error => mod.comp.bin_file.options.target.ofmt == .c or
mod.comp.bin_file.options.use_llvm,
.safety_check_formatted => mod.comp.bin_file.options.use_llvm,
.error_return_trace => mod.comp.bin_file.options.use_llvm,
.is_named_enum_value => mod.comp.bin_file.options.use_llvm,
.error_set_has_value => mod.comp.bin_file.options.use_llvm,
};
}