Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Couple cleanups to the flags/settings handling in Cranelift (#11744)

bjorn32a2e8f62b9f2
diff --git a/cranelift/codegen/meta/src/cdsl/mod.rs b/cranelift/codegen/meta/src/cdsl/mod.rs
index 4bde7d3e4a..14c1895b9a 100644
--- a/cranelift/codegen/meta/src/cdsl/mod.rs
+++ b/cranelift/codegen/meta/src/cdsl/mod.rs
@@ -11,17 +11,6 @@ pub mod settings;
pub mod types;
pub mod typevar;
-/// A macro that converts boolean settings into predicates to look more natural.
-#[macro_export]
-macro_rules! predicate {
- ($a:ident && $($b:tt)*) => {
- PredicateNode::And(Box::new($a.into()), Box::new(predicate!($($b)*)))
- };
- ($a:ident) => {
- $a.into()
- };
-}
-
/// A macro that joins boolean settings into a list (e.g. `preset!(feature_a && feature_b)`).
#[macro_export]
macro_rules! preset {
diff --git a/cranelift/codegen/meta/src/cdsl/settings.rs b/cranelift/codegen/meta/src/cdsl/settings.rs
index 6ed68d24a2..ca8c1185bc 100644
--- a/cranelift/codegen/meta/src/cdsl/settings.rs
+++ b/cranelift/codegen/meta/src/cdsl/settings.rs
@@ -127,7 +127,6 @@ pub(crate) struct SettingGroup {
pub bool_start_byte_offset: u8,
pub settings_size: u8,
pub presets: Vec<Preset>,
- pub predicates: Vec<Predicate>,
}
impl SettingGroup {
@@ -139,8 +138,7 @@ impl SettingGroup {
}
pub fn byte_size(&self) -> u8 {
- let num_predicates = self.num_bool_settings() + (self.predicates.len() as u8);
- self.bool_start_byte_offset + (num_predicates + 7) / 8
+ self.bool_start_byte_offset + (self.num_bool_settings() + 7) / 8
}
}
@@ -160,68 +158,10 @@ struct ProtoSetting {
specific: ProtoSpecificSetting,
}
-#[derive(Hash, PartialEq, Eq)]
-pub(crate) enum PredicateNode {
- OwnedBool(BoolSettingIndex),
- SharedBool(&'static str, &'static str),
- And(Box<PredicateNode>, Box<PredicateNode>),
-}
-
-impl From<BoolSettingIndex> for PredicateNode {
- fn from(bool_setting_index: BoolSettingIndex) -> Self {
- PredicateNode::OwnedBool(bool_setting_index)
- }
-}
-
-impl<'a> From<(BoolSettingIndex, &'a SettingGroup)> for PredicateNode {
- fn from(val: (BoolSettingIndex, &'a SettingGroup)) -> Self {
- let (index, group) = (val.0, val.1);
- let setting = &group.settings[index.0];
- PredicateNode::SharedBool(group.name, setting.name)
- }
-}
-
-impl PredicateNode {
- fn render(&self, group: &SettingGroup) -> String {
- match *self {
- PredicateNode::OwnedBool(bool_setting_index) => format!(
- "{}.{}()",
- group.name, group.settings[bool_setting_index.0].name
- ),
- PredicateNode::SharedBool(ref group_name, ref bool_name) => {
- format!("{group_name}.{bool_name}()")
- }
- PredicateNode::And(ref lhs, ref rhs) => {
- format!("{} && {}", lhs.render(group), rhs.render(group))
- }
- }
- }
-}
-
-struct ProtoPredicate {
- pub name: &'static str,
- node: PredicateNode,
-}
-
-pub(crate) type SettingPredicateNumber = u8;
-
-pub(crate) struct Predicate {
- pub name: &'static str,
- node: PredicateNode,
- pub number: SettingPredicateNumber,
-}
-
-impl Predicate {
- pub fn render(&self, group: &SettingGroup) -> String {
- self.node.render(group)
- }
-}
-
pub(crate) struct SettingGroupBuilder {
name: &'static str,
settings: Vec<ProtoSetting>,
presets: Vec<Preset>,
- predicates: Vec<ProtoPredicate>,
}
impl SettingGroupBuilder {
@@ -230,7 +170,6 @@ impl SettingGroupBuilder {
name,
settings: Vec::new(),
presets: Vec::new(),
- predicates: Vec::new(),
}
}
@@ -256,10 +195,6 @@ impl SettingGroupBuilder {
comment: &'static str,
default: bool,
) -> BoolSettingIndex {
- assert!(
- self.predicates.is_empty(),
- "predicates must be added after the boolean settings"
- );
self.add_setting(
name,
description,
@@ -299,10 +234,6 @@ impl SettingGroupBuilder {
);
}
- pub fn add_predicate(&mut self, name: &'static str, node: PredicateNode) {
- self.predicates.push(ProtoPredicate { name, node });
- }
-
pub fn add_preset(
&mut self,
name: &'static str,
@@ -333,9 +264,6 @@ impl SettingGroupBuilder {
///
/// 1. Byte-sized settings like `NumSetting` and `EnumSetting`.
/// 2. `BoolSetting` settings.
- /// 3. Precomputed named predicates.
- /// 4. Other numbered predicates, including parent predicates that need to be accessible by
- /// number.
///
/// Set `self.settings_size` to the length of the byte vector prefix that
/// contains the settings. All bytes after that are computed, not
@@ -352,7 +280,6 @@ impl SettingGroupBuilder {
bool_start_byte_offset: 0,
settings_size: 0,
presets: Vec::new(),
- predicates: Vec::new(),
};
let mut byte_offset = 0;
@@ -400,28 +327,8 @@ impl SettingGroupBuilder {
predicate_number += 1;
}
- assert!(
- group.predicates.is_empty(),
- "settings_size is the byte size before adding predicates"
- );
group.settings_size = group.byte_size();
- // Sort predicates by name to ensure the same order as the Python code.
- let mut predicates = self.predicates;
- predicates.sort_by_key(|predicate| predicate.name);
-
- group
- .predicates
- .extend(predicates.into_iter().map(|predicate| {
- let number = predicate_number;
- predicate_number += 1;
- Predicate {
- name: predicate.name,
- node: predicate.node,
- number,
- }
- }));
-
group.presets.extend(self.presets);
group
diff --git a/cranelift/codegen/meta/src/gen_asm.rs b/cranelift/codegen/meta/src/gen_asm.rs
index 734b0de314..30d42d808d 100644
--- a/cranelift/codegen/meta/src/gen_asm.rs
+++ b/cranelift/codegen/meta/src/gen_asm.rs
@@ -643,7 +643,7 @@ fn generate_isle_inst_decls(f: &mut Formatter, inst: &Inst) {
fmtln!(f, "(decl {rule_name_or_feat} ({param_tys}) {result_ty})");
fmtln!(f, "(rule 1 ({rule_name_or_feat} {param_names})");
f.indent(|f| {
- fmtln!(f, "(if-let true (use_{alt_feature}))");
+ fmtln!(f, "(if-let true (has_{alt_feature}))");
fmtln!(f, "(x64_{alt_name}{suffix} {param_names}))");
});
fmtln!(
diff --git a/cranelift/codegen/meta/src/gen_settings.rs b/cranelift/codegen/meta/src/gen_settings.rs
index bf9c54b38f..fe83ea7370 100644
--- a/cranelift/codegen/meta/src/gen_settings.rs
+++ b/cranelift/codegen/meta/src/gen_settings.rs
@@ -1,9 +1,7 @@
//! Generate the ISA-specific settings.
use crate::cdsl::camel_case;
-use crate::cdsl::settings::{
- BoolSetting, Predicate, Preset, Setting, SettingGroup, SpecificSetting,
-};
+use crate::cdsl::settings::{BoolSetting, Preset, Setting, SettingGroup, SpecificSetting};
use crate::constant_hash::generate_table;
use crate::unique_table::UniqueSeqTable;
use cranelift_codegen_shared::constant_hash::simple_hash;
@@ -47,20 +45,6 @@ fn gen_constructor(group: &SettingGroup, parent: ParentGroup, fmt: &mut Formatte
group.settings_size
);
- // Now compute the predicates.
- for p in &group.predicates {
- fmt.comment(format!("Precompute #{}.", p.number));
- fmt.add_block(&format!("if {}", p.render(group)), |fmt| {
- fmtln!(
- fmt,
- "{}.bytes[{}] |= 1 << {};",
- group.name,
- group.bool_start_byte_offset + p.number / 8,
- p.number % 8
- );
- });
- }
-
fmtln!(fmt, "{}", group.name);
});
});
@@ -193,16 +177,6 @@ fn gen_getter(setting: &Setting, fmt: &mut Formatter) {
}
}
-fn gen_pred_getter(predicate: &Predicate, group: &SettingGroup, fmt: &mut Formatter) {
- fmt.doc_comment(format!("Computed predicate `{}`.", predicate.render(group)));
- fmt.add_block(
- &format!("pub fn {}(&self) -> bool", predicate.name),
- |fmt| {
- fmtln!(fmt, "self.numbered_predicate({})", predicate.number);
- },
- );
-}
-
/// Emits getters for each setting value.
fn gen_getters(group: &SettingGroup, fmt: &mut Formatter) {
fmt.doc_comment("User-defined settings.");
@@ -222,9 +196,6 @@ fn gen_getters(group: &SettingGroup, fmt: &mut Formatter) {
for setting in &group.settings {
gen_getter(setting, fmt);
}
- for predicate in &group.predicates {
- gen_pred_getter(predicate, group, fmt);
- }
});
}
diff --git a/cranelift/codegen/meta/src/isa/riscv64.rs b/cranelift/codegen/meta/src/isa/riscv64.rs
index 8eaf74321e..624fa16da5 100644
--- a/cranelift/codegen/meta/src/isa/riscv64.rs
+++ b/cranelift/codegen/meta/src/isa/riscv64.rs
@@ -1,5 +1,5 @@
use crate::cdsl::isa::TargetIsa;
-use crate::cdsl::settings::{PredicateNode, SettingGroupBuilder};
+use crate::cdsl::settings::SettingGroupBuilder;
macro_rules! define_zvl_ext {
(DEF: $settings:expr, $size:expr) => {{
@@ -37,20 +37,20 @@ pub(crate) fn define() -> TargetIsa {
// * Zicsr (control and status register instructions)
// * Zifencei (instruction-fetch fence)
- let has_m = setting.add_bool(
+ let _has_m = setting.add_bool(
"has_m",
"has extension M?",
"Integer multiplication and division",
true,
);
- let has_a = setting.add_bool("has_a", "has extension A?", "Atomic instructions", true);
- let has_f = setting.add_bool(
+ let _has_a = setting.add_bool("has_a", "has extension A?", "Atomic instructions", true);
+ let _has_f = setting.add_bool(
"has_f",
"has extension F?",
"Single-precision floating point",
true,
);
- let has_d = setting.add_bool(
+ let _has_d = setting.add_bool(
"has_d",
"has extension D?",
"Double-precision floating point",
@@ -154,13 +154,13 @@ pub(crate) fn define() -> TargetIsa {
false,
);
- let has_zicsr = setting.add_bool(
+ let _has_zicsr = setting.add_bool(
"has_zicsr",
"has extension zicsr?",
"Zicsr: Control and Status Register (CSR) Instructions",
true,
);
- let has_zifencei = setting.add_bool(
+ let _has_zifencei = setting.add_bool(
"has_zifencei",
"has extension zifencei?",
"Zifencei: Instruction-Fetch Fence",
@@ -186,10 +186,5 @@ pub(crate) fn define() -> TargetIsa {
let (_, zvl32768b) = define_zvl_ext!(setting, 32768, zvl16384b);
let (_, _zvl65536b) = define_zvl_ext!(setting, 65536, zvl32768b);
- setting.add_predicate(
- "has_g",
- predicate!(has_m && has_a && has_f && has_d && has_zicsr && has_zifencei),
- );
-
TargetIsa::new("riscv64", setting.build())
}
diff --git a/cranelift/codegen/meta/src/isa/x86.rs b/cranelift/codegen/meta/src/isa/x86.rs
index 9f3c800f24..3f9f02bd18 100644
--- a/cranelift/codegen/meta/src/isa/x86.rs
+++ b/cranelift/codegen/meta/src/isa/x86.rs
@@ -1,5 +1,5 @@
use crate::cdsl::isa::TargetIsa;
-use crate::cdsl::settings::{PredicateNode, SettingGroupBuilder};
+use crate::cdsl::settings::SettingGroupBuilder;
pub(crate) fn define() -> TargetIsa {
let mut settings = SettingGroupBuilder::new("x86");
@@ -112,26 +112,6 @@ pub(crate) fn define() -> TargetIsa {
false,
);
- settings.add_predicate("use_cmpxchg16b", predicate!(has_cmpxchg16b));
- settings.add_predicate("use_sse3", predicate!(has_sse3));
- settings.add_predicate("use_ssse3", predicate!(has_ssse3));
- settings.add_predicate("use_sse41", predicate!(has_sse41));
- settings.add_predicate("use_sse42", predicate!(has_sse41 && has_sse42));
- settings.add_predicate("use_fma", predicate!(has_avx && has_fma));
-
- settings.add_predicate("use_avx", predicate!(has_avx));
- settings.add_predicate("use_avx2", predicate!(has_avx && has_avx2));
- settings.add_predicate("use_avx512bitalg", predicate!(has_avx512bitalg));
- settings.add_predicate("use_avx512dq", predicate!(has_avx512dq));
- settings.add_predicate("use_avx512vl", predicate!(has_avx512vl));
- settings.add_predicate("use_avx512vbmi", predicate!(has_avx512vbmi));
- settings.add_predicate("use_avx512f", predicate!(has_avx512f));
-
- settings.add_predicate("use_popcnt", predicate!(has_popcnt && has_sse42));
- settings.add_predicate("use_bmi1", predicate!(has_bmi1));
- settings.add_predicate("use_bmi2", predicate!(has_bmi2));
- settings.add_predicate("use_lzcnt", predicate!(has_lzcnt));
-
let sse3 = settings.add_preset("sse3", "SSE3 and earlier.", preset!(has_sse3));
let ssse3 = settings.add_preset("ssse3", "SSSE3 and earlier.", preset!(sse3 && has_ssse3));
let sse41 = settings.add_preset("sse41", "SSE4.1 and earlier.", preset!(ssse3 && has_sse41));
diff --git a/cranelift/codegen/meta/src/shared/settings.rs b/cranelift/codegen/meta/src/shared/settings.rs
index e7ea9af009..10d77ca692 100644
--- a/cranelift/codegen/meta/src/shared/settings.rs
+++ b/cranelift/codegen/meta/src/shared/settings.rs
@@ -112,15 +112,6 @@ pub(crate) fn define() -> SettingGroup {
false,
);
- settings.add_bool(
- "enable_float",
- "Enable the use of floating-point instructions.",
- r#"
- Disabling use of floating-point instructions is not yet implemented.
- "#,
- true,
- );
-
settings.add_bool(
"enable_nan_canonicalization",
"Enable NaN canonicalization.",
@@ -143,24 +134,6 @@ pub(crate) fn define() -> SettingGroup {
false,
);
- settings.add_bool(
- "enable_atomics",
- "Enable the use of atomic instructions",
- "",
- true,
- );
-
- settings.add_bool(
- "enable_safepoints",
- "Enable safepoint instruction insertions.",
- r#"
- This will allow the emit_stack_maps() function to insert the safepoint
- instruction on top of calls and interrupt traps in order to display the
- live reference values at that point in the program.
- "#,
- false,
- );
-
settings.add_enum(
"tls_model",
"Defines the model used to perform TLS accesses.",
@@ -324,16 +297,8 @@ pub(crate) fn define() -> SettingGroup {
vec!["outline", "inline"],
);
- // Jump table options.
-
- settings.add_bool(
- "enable_jump_tables",
- "Enable the use of jump tables in generated machine code.",
- "",
- true,
- );
-
- // Spectre options.
+ // Spectre options. (Only read by wasmtime-cranelift)
+ // FIXME move configuration out of Cranelift into Wasmtime
settings.add_bool(
"enable_heap_access_spectre_mitigation",
diff --git a/cranelift/codegen/src/isa/riscv64/mod.rs b/cranelift/codegen/src/isa/riscv64/mod.rs
index a196e53e89..3ae2b6dfb3 100644
--- a/cranelift/codegen/src/isa/riscv64/mod.rs
+++ b/cranelift/codegen/src/isa/riscv64/mod.rs
@@ -282,7 +282,13 @@ fn isa_constructor(
// - Zifencei: Instruction-Fetch Fence
//
// Ensure that those combination of features is enabled.
- if !isa_flags.has_g() {
+ if !(isa_flags.has_m()
+ && isa_flags.has_a()
+ && isa_flags.has_f()
+ && isa_flags.has_d()
+ && isa_flags.has_zicsr()
+ && isa_flags.has_zifencei())
+ {
return Err(CodegenError::Unsupported(
"The RISC-V Backend currently requires all the features in the G Extension enabled"
.into(),
diff --git a/cranelift/codegen/src/isa/x64/inst.isle b/cranelift/codegen/src/isa/x64/inst.isle
index 454a08637c..c8ea499e6e 100644
--- a/cranelift/codegen/src/isa/x64/inst.isle
+++ b/cranelift/codegen/src/isa/x64/inst.isle
@@ -973,29 +973,29 @@
;;;; Helpers for Querying Enabled ISA Extensions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(decl pure use_avx512vl () bool)
-(extern constructor use_avx512vl use_avx512vl)
+(decl pure has_avx512vl () bool)
+(extern constructor has_avx512vl has_avx512vl)
-(decl pure use_avx512dq () bool)
-(extern constructor use_avx512dq use_avx512dq)
+(decl pure has_avx512dq () bool)
+(extern constructor has_avx512dq has_avx512dq)
-(decl pure use_avx512f () bool)
-(extern constructor use_avx512f use_avx512f)
+(decl pure has_avx512f () bool)
+(extern constructor has_avx512f has_avx512f)
-(decl pure use_avx512bitalg () bool)
-(extern constructor use_avx512bitalg use_avx512bitalg)
+(decl pure has_avx512bitalg () bool)
+(extern constructor has_avx512bitalg has_avx512bitalg)
-(decl pure use_avx512vbmi () bool)
-(extern constructor use_avx512vbmi use_avx512vbmi)
+(decl pure has_avx512vbmi () bool)
+(extern constructor has_avx512vbmi has_avx512vbmi)
-(decl pure use_lzcnt () bool)
-(extern constructor use_lzcnt use_lzcnt)
+(decl pure has_lzcnt () bool)
+(extern constructor has_lzcnt has_lzcnt)
-(decl pure use_bmi1 () bool)
-(extern constructor use_bmi1 use_bmi1)
+(decl pure has_bmi1 () bool)
+(extern constructor has_bmi1 has_bmi1)
-(decl pure use_bmi2 () bool)
-(extern constructor use_bmi2 use_bmi2)
+(decl pure has_bmi2 () bool)
+(extern constructor has_bmi2 has_bmi2)
(decl pure use_popcnt () bool)
(extern constructor use_popcnt use_popcnt)
@@ -1003,26 +1003,26 @@
(decl pure use_fma () bool)
(extern constructor use_fma use_fma)
-(decl pure use_sse3 () bool)
-(extern constructor use_sse3 use_sse3)
+(decl pure has_sse3 () bool)
+(extern constructor has_sse3 has_sse3)
-(decl pure use_ssse3 () bool)
-(extern constructor use_ssse3 use_ssse3)
+(decl pure has_ssse3 () bool)
+(extern constructor has_ssse3 has_ssse3)
-(decl pure use_sse41 () bool)
-(extern constructor use_sse41 use_sse41)
+(decl pure has_sse41 () bool)
+(extern constructor has_sse41 has_sse41)
(decl pure use_sse42 () bool)
(extern constructor use_sse42 use_sse42)
-(decl pure use_avx () bool)
-(extern constructor use_avx use_avx)
+(decl pure has_avx () bool)
+(extern constructor has_avx has_avx)
(decl pure use_avx2 () bool)
(extern constructor use_avx2 use_avx2)
-(decl pure use_cmpxchg16b () bool)
-(extern constructor use_cmpxchg16b use_cmpxchg16b)
+(decl pure has_cmpxchg16b () bool)
+(extern constructor has_cmpxchg16b has_cmpxchg16b)
;;;; Helpers for Merging and Sinking Immediates/Loads ;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1454,28 +1454,28 @@
(decl x64_movd_to_gpr (Xmm) Gpr)
(rule (x64_movd_to_gpr from) (x64_movd_b from))
(rule 1 (x64_movd_to_gpr from)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vmovd_b from))
;; Helper for creating `movd` instructions.
(decl x64_movd_to_xmm (GprMem) Xmm)
(rule (x64_movd_to_xmm from) (x64_movd_a from))
(rule 1 (x64_movd_to_xmm from)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vmovd_a from))
;; Helper for creating `movq` instructions.
(decl x64_movq_to_xmm (GprMem) Xmm)
(rule (x64_movq_to_xmm src) (x64_movq_a src))
(rule 1 (x64_movq_to_xmm from)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vmovq_a from))
;; Helper for creating `movq` instructions.
(decl x64_movq_to_gpr (Xmm) Gpr)
(rule (x64_movq_to_gpr src) (x64_movq_b src))
(rule 1 (x64_movq_to_gpr from)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vmovq_b from))
(decl x64_movdqu_load (XmmMem) Xmm)
@@ -1759,11 +1759,11 @@
;; the second result, so here the result registers are swapped to match
;; `x64_mul` above.
(rule 1 (x64_mul $I32 false src1 src2)
- (if-let true (use_bmi2))
+ (if-let true (has_bmi2))
(let ((regs ValueRegs (x64_mulxl_rvm src2 src1)))
(value_regs (value_regs_get regs 1) (value_regs_get regs 0))))
(rule 1 (x64_mul $I64 false src1 src2)
- (if-let true (use_bmi2))
+ (if-let true (has_bmi2))
(let ((regs ValueRegs (x64_mulxq_rvm src2 src1)))
(value_regs (value_regs_get regs 1) (value_regs_get regs 0))))
@@ -1990,7 +1990,7 @@
(rule 1 (x64_rotl $I32 src1 (Imm8Gpr.Imm8 1)) (x64_roll_m1 src1))
(rule 1 (x64_rotl $I64 src1 (Imm8Gpr.Imm8 1)) (x64_rolq_m1 src1))
(rule 2 (x64_rotl (ty_32_or_64 ty) src (Imm8Gpr.Imm8 imm))
- (if-let true (use_bmi2))
+ (if-let true (has_bmi2))
(x64_rorx ty src (u8_wrapping_sub (ty_bits ty) imm)))
;; Helper for creating `rotr` instructions.
@@ -2008,7 +2008,7 @@
(rule 1 (x64_rotr $I32 src1 (Imm8Gpr.Imm8 1)) (x64_rorl_m1 src1))
(rule 1 (x64_rotr $I64 src1 (Imm8Gpr.Imm8 1)) (x64_rorq_m1 src1))
(rule 2 (x64_rotr (ty_32_or_64 ty) src (Imm8Gpr.Imm8 imm))
- (if-let true (use_bmi2))
+ (if-let true (has_bmi2))
(x64_rorx ty src imm))
;; Helper for creating `shl` instructions.
@@ -2030,7 +2030,7 @@
;; in regalloc since nothing is constrained. Note that the `shlx` instruction
;; doesn't encode an immediate so any immediate-based shift still uses `shl`.
(rule 1 (x64_shl (ty_32_or_64 ty) src1 (Imm8Gpr.Gpr src2))
- (if-let true (use_bmi2))
+ (if-let true (has_bmi2))
(x64_shlx ty src1 src2))
;; Helper for creating logical shift-right instructions.
@@ -2049,7 +2049,7 @@
(rule 1 (x64_shr $I64 src1 (Imm8Gpr.Imm8 1)) (x64_shrq_m1 src1))
;; see `x64_shl` for more info about this rule
(rule 1 (x64_shr (ty_32_or_64 ty) src1 (Imm8Gpr.Gpr src2))
- (if-let true (use_bmi2))
+ (if-let true (has_bmi2))
(x64_shrx ty src1 src2))
;; Helper for creating arithmetic shift-right instructions.
@@ -2068,7 +2068,7 @@
(rule 1 (x64_sar $I64 src1 (Imm8Gpr.Imm8 1)) (x64_sarq_m1 src1))
;; see `x64_shl` for more info about this rule
(rule 1 (x64_sar (ty_32_or_64 ty) src1 (Imm8Gpr.Gpr src2))
- (if-let true (use_bmi2))
+ (if-let true (has_bmi2))
(x64_sarx ty src1 src2))
;; Helper for creating `shld` instructions.
@@ -2432,21 +2432,21 @@
(decl x64_blendvpd (Xmm XmmMem Xmm) Xmm)
(rule 0 (x64_blendvpd src1 src2 mask) (x64_blendvpd_rm0 src1 src2 mask))
(rule 1 (x64_blendvpd src1 src2 mask)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vblendvpd_rvmr src1 src2 mask))
;; Helper for creating `blendvps` instructions.
(decl x64_blendvps (Xmm XmmMem Xmm) Xmm)
(rule 0 (x64_blendvps src1 src2 mask) (x64_blendvps_rm0 src1 src2 mask))
(rule 1 (x64_blendvps src1 src2 mask)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vblendvps_rvmr src1 src2 mask))
;; Helper for creating `pblendvb` instructions.
(decl x64_pblendvb (Xmm XmmMem Xmm) Xmm)
(rule 0 (x64_pblendvb src1 src2 mask) (x64_pblendvb_rm src1 src2 mask))
(rule 1 (x64_pblendvb src1 src2 mask)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vpblendvb_rvmr src1 src2 mask))
;; Helper for creating `pblendw` instructions.
@@ -2526,7 +2526,7 @@
(decl x64_cmpps (Xmm XmmMem FcmpImm) Xmm)
(rule 1 (x64_cmpps src1 src2 imm)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vcmpps_b src1 src2 (encode_fcmp_imm imm)))
(rule 0 (x64_cmpps src1 src2 imm) (x64_cmpps_a src1 src2 (encode_fcmp_imm imm)))
@@ -2535,42 +2535,42 @@
;; instruction.
(decl x64_cmppd (Xmm XmmMem FcmpImm) Xmm)
(rule 1 (x64_cmppd src1 src2 imm)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vcmppd_b src1 src2 (encode_fcmp_imm imm)))
(rule 0 (x64_cmppd src1 src2 imm) (x64_cmppd_a src1 src2 (encode_fcmp_imm imm)))
;; Helper for creating `pinsrb` instructions.
(decl x64_pinsrb (Xmm GprMem u8) Xmm)
(rule 1 (x64_pinsrb src1 src2 lane)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vpinsrb_b src1 src2 lane))
(rule 0 (x64_pinsrb src1 src2 lane) (x64_pinsrb_a src1 src2 lane))
;; Helper for creating `pinsrw` instructions.
(decl x64_pinsrw (Xmm GprMem u8) Xmm)
(rule 1 (x64_pinsrw src1 src2 lane)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vpinsrw_b src1 src2 lane))
(rule 0 (x64_pinsrw src1 src2 lane) (x64_pinsrw_a src1 src2 lane))
;; Helper for creating `pinsrd` instructions.
(decl x64_pinsrd (Xmm GprMem u8) Xmm)
(rule 1 (x64_pinsrd src1 src2 lane)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vpinsrd_b src1 src2 lane))
(rule 0 (x64_pinsrd src1 src2 lane) (x64_pinsrd_a src1 src2 lane))
;; Helper for creating `pinsrq` instructions.
(decl x64_pinsrq (Xmm GprMem u8) Xmm)
(rule 1 (x64_pinsrq src1 src2 lane)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vpinsrq_b src1 src2 lane))
(rule 0 (x64_pinsrq src1 src2 lane) (x64_pinsrq_a src1 src2 lane))
;; Helper for creating `roundss` instructions.
(decl x64_roundss (XmmMem RoundImm) Xmm)
(rule 1 (x64_roundss src1 round)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vroundss_rvmi (xmm_zero $F32X4) src1 (encode_round_imm round)))
(rule 0 (x64_roundss src1 round)
(x64_roundss_rmi src1 (encode_round_imm round)))
@@ -2578,7 +2578,7 @@
;; Helper for creating `roundsd` instructions.
(decl x64_roundsd (XmmMem RoundImm) Xmm)
(rule 1 (x64_roundsd src1 round)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vroundsd_rvmi (xmm_zero $F64X2) src1 (encode_round_imm round)))
(rule 0 (x64_roundsd src1 round)
(x64_roundsd_rmi src1 (encode_round_imm round)))
@@ -2586,7 +2586,7 @@
;; Helper for creating `roundps` instructions.
(decl x64_roundps (XmmMem RoundImm) Xmm)
(rule 1 (x64_roundps src1 round)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vroundps_rmi src1 (encode_round_imm round)))
(rule (x64_roundps src1 round)
(x64_roundps_rmi src1 (encode_round_imm round)))
@@ -2594,7 +2594,7 @@
;; Helper for creating `roundpd` instructions.
(decl x64_roundpd (XmmMem RoundImm) Xmm)
(rule 1 (x64_roundpd src1 round)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vroundpd_rmi src1 (encode_round_imm round)))
(rule 0 (x64_roundpd src1 round)
(x64_roundpd_rmi src1 (encode_round_imm round)))
@@ -2614,7 +2614,7 @@
(decl x64_pshufd (XmmMem u8) Xmm)
(rule (x64_pshufd src imm) (x64_pshufd_a src imm))
(rule 1 (x64_pshufd src imm)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vpshufd_a src imm))
;; Helper for creating `pshufb` instructions.
@@ -2633,14 +2633,14 @@
(decl x64_pshuflw (XmmMem u8) Xmm)
(rule (x64_pshuflw src imm) (x64_pshuflw_a src imm))
(rule 1 (x64_pshuflw src imm)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vpshuflw_a src imm))
;; Helper for creating `pshufhw` instructions.
(decl x64_pshufhw (XmmMem u8) Xmm)
(rule (x64_pshufhw src imm) (x64_pshufhw_a src imm))
(rule 1 (x64_pshufhw src imm)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vpshufhw_a src imm))
@@ -2739,21 +2739,21 @@
(decl x64_pmovmskb (Xmm) Gpr)
(rule (x64_pmovmskb src) (x64_pmovmskb_rm src))
(rule 1 (x64_pmovmskb src)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vpmovmskb_rm src))
;; Helper for creating `movmskps` instructions.
(decl x64_movmskps (Xmm) Gpr)
(rule (x64_movmskps src) (x64_movmskps_rm src))
(rule 1 (x64_movmskps src)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vmovmskps_rm src))
;; Helper for creating `movmskpd` instructions.
(decl x64_movmskpd (Xmm) Gpr)
(rule (x64_movmskpd src) (x64_movmskpd_rm src))
(rule 1 (x64_movmskpd src)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vmovmskpd_rm src))
;; Helper for creating `not` instructions.
@@ -3029,7 +3029,7 @@
;; NB: see `x64_sqrtss` for why this has two args (same reasoning, different op)
(decl x64_cvtss2sd (Xmm XmmMem) Xmm)
(rule 1 (x64_cvtss2sd x y)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vcvtss2sd_b x y))
(rule 0 (x64_cvtss2sd x y) (x64_cvtss2sd_a x y))
@@ -3038,45 +3038,45 @@
;; NB: see `x64_sqrtss` for why this has two args (same reasoning, different op)
(decl x64_cvtsd2ss (Xmm XmmMem) Xmm)
(rule 1 (x64_cvtsd2ss x y)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vcvtsd2ss_b x y))
(rule 0 (x64_cvtsd2ss x y) (x64_cvtsd2ss_a x y))
;; Helper for creating `cvtdq2ps` instructions.
(decl x64_cvtdq2ps (XmmMem) Xmm)
(rule 1 (x64_cvtdq2ps x)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vcvtdq2ps_a x))
(rule (x64_cvtdq2ps x) (x64_cvtdq2ps_a x))
;; Helper for creating `cvtps2pd` instructions.
(decl x64_cvtps2pd (XmmMem) Xmm)
(rule 1 (x64_cvtps2pd x)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vcvtps2pd_a x))
(rule 0 (x64_cvtps2pd x) (x64_cvtps2pd_a x))
;; Helper for creating `cvtpd2ps` instructions.
(decl x64_cvtpd2ps (XmmMem) Xmm)
(rule 1 (x64_cvtpd2ps x)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vcvtpd2ps_a x))
(rule 0 (x64_cvtpd2ps x) (x64_cvtpd2ps_a x))
;; Helper for creating `cvtdq2pd` instructions.
(decl x64_cvtdq2pd (XmmMem) Xmm)
(rule 1 (x64_cvtdq2pd x)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vcvtdq2pd_a x))
(rule 0 (x64_cvtdq2pd x) (x64_cvtdq2pd_a x))
;; Helper for creating `cvtsi2ss` instructions.
(decl x64_cvtsi2ss (Type Xmm GprMem) Xmm)
(rule 1 (x64_cvtsi2ss $I32 x y)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vcvtsi2ssl_b x y))
(rule 1 (x64_cvtsi2ss $I64 x y)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vcvtsi2ssq_b x y))
(rule 0 (x64_cvtsi2ss $I32 x y) (x64_cvtsi2ssl_a x y))
(rule 0 (x64_cvtsi2ss $I64 x y) (x64_cvtsi2ssq_a x y))
@@ -3084,10 +3084,10 @@
;; Helper for creating `cvtsi2sd` instructions.
(decl x64_cvtsi2sd (Type Xmm GprMem) Xmm)
(rule 1 (x64_cvtsi2sd $I32 x y)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vcvtsi2sdl_b x y))
(rule 1 (x64_cvtsi2sd $I64 x y)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vcvtsi2sdq_b x y))
(rule 0 (x64_cvtsi2sd $I32 x y) (x64_cvtsi2sdl_a x y))
(rule 0 (x64_cvtsi2sd $I64 x y) (x64_cvtsi2sdq_a x y))
@@ -3095,14 +3095,14 @@
;; Helper for creating `cvttps2dq` instructions.
(decl x64_cvttps2dq (XmmMem) Xmm)
(rule 1 (x64_cvttps2dq x)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vcvttps2dq_a x))
(rule 0 (x64_cvttps2dq x) (x64_cvttps2dq_a x))
;; Helper for creating `cvttpd2dq` instructions.
(decl x64_cvttpd2dq (XmmMem) Xmm)
(rule 1 (x64_cvttpd2dq x)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vcvttpd2dq_a x))
(rule 0 (x64_cvttpd2dq x) (x64_cvttpd2dq_a x))
@@ -3112,7 +3112,7 @@
(rule (x64_pcmpeq $I16X8 x y) (x64_pcmpeqw x y))
(rule (x64_pcmpeq $I32X4 x y) (x64_pcmpeqd x y))
(rule (x64_pcmpeq $I64X2 x y)
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_pcmpeqq x y))
;; Without SSE 4.1 there's no access to `pcmpeqq`, so it's emulated by comparing
@@ -3147,7 +3147,7 @@
;; AVX has a single-instruction lowering; we do not use the `or_avx` suffix so
;; we can match a non-AVX/SSE4.2 below.
(rule 2 (x64_pcmpgt $I64X2 x y)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vpcmpgtq_b x y))
;; SSE4.2 also gives a single-instruction for this lowering, but prior to that
;; it's a bit more complicated.
@@ -3309,7 +3309,7 @@
(decl x64_movddup (XmmMem) Xmm)
(rule (x64_movddup src) (x64_movddup_a src))
(rule 1 (x64_movddup src)
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vmovddup_a src))
;; Helpers for creating `vpbroadcast*` instructions.
diff --git a/cranelift/codegen/src/isa/x64/lower.isle b/cranelift/codegen/src/isa/x64/lower.isle
index a7a8104de9..1a051f41fd 100644
--- a/cranelift/codegen/src/isa/x64/lower.isle
+++ b/cranelift/codegen/src/isa/x64/lower.isle
@@ -390,12 +390,12 @@
(rule 10 (lower (has_type ty (band x (bnot y))))
(if (ty_int_ref_scalar_64 ty))
- (if-let true (use_bmi1))
+ (if-let true (has_bmi1))
;; the first argument is the one that gets inverted with andn
(x64_andn ty y x))
(rule 11 (lower (has_type ty (band (bnot y) x)))
(if (ty_int_ref_scalar_64 ty))
- (if-let true (use_bmi1))
+ (if-let true (has_bmi1))
(x64_andn ty y x))
;; Specialization of `blsr` for BMI1
@@ -406,21 +406,21 @@
(rule 1 (val_minus_one (iadd (i64_from_iconst -1) x)) x)
(rule 12 (lower (has_type (ty_32_or_64 ty) (band x y)))
- (if-let true (use_bmi1))
+ (if-let true (has_bmi1))
(if-let x (val_minus_one y))
(x64_blsr ty x))
(rule 13 (lower (has_type (ty_32_or_64 ty) (band y x)))
- (if-let true (use_bmi1))
+ (if-let true (has_bmi1))
(if-let x (val_minus_one y))
(x64_blsr ty x))
;; Specialization of `blsi` for BMI1
(rule 14 (lower (has_type (ty_32_or_64 ty) (band (ineg x) x)))
- (if-let true (use_bmi1))
+ (if-let true (has_bmi1))
(x64_blsi ty x))
(rule 15 (lower (has_type (ty_32_or_64 ty) (band x (ineg x))))
- (if-let true (use_bmi1))
+ (if-let true (has_bmi1))
(x64_blsi ty x))
;; Specialization of `bzhi` for BMI2
@@ -433,7 +433,7 @@
;; semantics of Cranelift's `ishl`.
(rule 16 (lower (has_type (ty_32_or_64 ty) (band x y)))
- (if-let true (use_bmi2))
+ (if-let true (has_bmi2))
(if-let (ishl (u64_from_iconst 1) index) (val_minus_one y))
(x64_bzhi ty x (x64_and ty index (RegMemImm.Imm (u32_wrapping_sub (ty_bits ty) 1)))))
@@ -549,11 +549,11 @@
;; Specialization of `blsmsk` for BMI1
(rule 8 (lower (has_type (ty_32_or_64 ty) (bxor x y)))
- (if-let true (use_bmi1))
+ (if-let true (has_bmi1))
(if-let x (val_minus_one y))
(x64_blsmsk ty x))
(rule 9 (lower (has_type (ty_32_or_64 ty) (bxor y x)))
- (if-let true (use_bmi1))
+ (if-let true (has_bmi1))
(if-let x (val_minus_one y))
(x64_blsmsk ty x))
@@ -874,13 +874,13 @@
;; feature sets. To remedy this, a small dance is done with an unsigned right
;; shift plus some extra ops.
(rule 3 (lower (has_type ty @ $I64X2 (sshr src (iconst n))))
- (if-let true (use_avx512vl))
- (if-let true (use_avx512f))
+ (if-let true (has_avx512vl))
+ (if-let true (has_avx512f))
(x64_vpsraq_imm src (shift_amount_masked ty n)))
(rule 2 (lower (has_type ty @ $I64X2 (sshr src amt)))
- (if-let true (use_avx512vl))
- (if-let true (use_avx512f))
+ (if-let true (has_avx512vl))
+ (if-let true (has_avx512f))
(let ((masked Gpr (x64_and $I64 amt (RegMemImm.Imm (shift_mask ty)))))
(x64_vpsraq src (x64_movd_to_xmm masked))))
@@ -1121,7 +1121,7 @@
(x64_pmullw x y))
(rule (lower (has_type (multi_lane 32 4) (imul x y)))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_pmulld x y))
;; Without `pmulld` the `pmuludq` instruction is used instead which performs
@@ -1141,8 +1141,8 @@
;; With AVX-512 we can implement `i64x2` multiplication with a single
;; instruction.
(rule 3 (lower (has_type (multi_lane 64 2) (imul x y)))
- (if-let true (use_avx512vl))
- (if-let true (use_avx512dq))
+ (if-let true (has_avx512vl))
+ (if-let true (has_avx512dq))
(x64_vpmullq x y))
;; Otherwise, for i64x2 multiplication we describe a lane A as being composed of
@@ -1204,7 +1204,7 @@
x))
(swiden_high (and (value_type (multi_lane 32 4))
y)))))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(let ((x2 Xmm (x64_pshufd x 0xFA))
(y2 Xmm (x64_pshufd y 0xFA)))
(x64_pmuldq x2 y2)))
@@ -1227,7 +1227,7 @@
x))
(swiden_low (and (value_type (multi_lane 32 4))
y)))))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(let ((x2 Xmm (x64_pshufd x 0x50))
(y2 Xmm (x64_pshufd y 0x50)))
(x64_pmuldq x2 y2)))
@@ -1279,7 +1279,7 @@
;;;; Rules for `iabs` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(rule 1 (lower (has_type $I8X16 (iabs x)))
- (if-let true (use_ssse3))
+ (if-let true (has_ssse3))
(x64_pabsb_a_or_avx x))
;; Note the use of `pminub` with signed inputs will produce the positive signed
@@ -1293,7 +1293,7 @@
(x64_pminub_a x negated)))
(rule 1 (lower (has_type $I16X8 (iabs x)))
- (if-let true (use_ssse3))
+ (if-let true (has_ssse3))
(x64_pabsw_a_or_avx x))
(rule (lower (has_type $I16X8 (iabs x)))
@@ -1304,7 +1304,7 @@
(x64_pmaxsw_a x negated)))
(rule 1 (lower (has_type $I32X4 (iabs x)))
- (if-let true (use_ssse3))
+ (if-let true (has_ssse3))
(x64_pabsd_a_or_avx x))
;; Generate a `negative_mask` which is either numerically -1 or 0 depending on
@@ -1323,8 +1323,8 @@
;; When AVX512 is available, we can use a single `vpabsq` instruction.
(rule 2 (lower (has_type $I64X2 (iabs x)))
- (if-let true (use_avx512vl))
- (if-let true (use_avx512f))
+ (if-let true (has_avx512vl))
+ (if-let true (has_avx512f))
(x64_vpabsq x))
;; Otherwise, we use a separate register, `neg`, to contain the results of `0 -
@@ -1332,7 +1332,7 @@
;; set to 1 (i.e. if `neg` was negative or, conversely, if `x` was originally
;; positive).
(rule 1 (lower (has_type $I64X2 (iabs x)))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(let ((rx Xmm x)
(neg Xmm (x64_psubq (imm $I64X2 0) rx)))
(x64_blendvpd neg rx neg)))
@@ -1512,7 +1512,7 @@
(bitselect condition
if_true
if_false)))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(if (all_ones_or_all_zeros condition))
(x64_pblendvb if_false if_true condition))
@@ -1562,26 +1562,26 @@
(rule (lower (has_type $I8X16
(x86_blendv condition if_true if_false)))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_pblendvb if_false if_true condition))
(rule (lower (has_type $I32X4
(x86_blendv condition if_true if_false)))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_blendvps if_false if_true condition))
(rule (lower (has_type $I64X2
(x86_blendv condition if_true if_false)))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_blendvpd if_false if_true condition))
;;;; Rules for `insertlane` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(rule 1 (lower (insertlane vec @ (value_type $I8X16) val (u8_from_uimm8 idx)))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_pinsrb vec val idx))
(rule 2 (lower (insertlane vec @ (value_type $I8X16) (sinkable_load_exact val) (u8_from_uimm8 idx)))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_pinsrb vec val idx))
;; This lowering is particularly unoptimized and is mostly just here to work
@@ -1633,7 +1633,7 @@
;; i32x4.replace_lane
(rule 1 (lower (insertlane vec @ (value_type $I32X4) val (u8_from_uimm8 idx)))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_pinsrd vec val idx))
(rule (lower (insertlane vec @ (value_type $I32X4) val (u8_from_uimm8 0)))
@@ -1662,7 +1662,7 @@
;; i64x2.replace_lane
(rule 1 (lower (insertlane vec @ (value_type $I64X2) val (u8_from_uimm8 idx)))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_pinsrq vec val idx))
(rule (lower (insertlane vec @ (value_type $I64X2) val (u8_from_uimm8 0)))
(x64_movsd_regmove vec (x64_movq_to_xmm val)))
@@ -1675,11 +1675,11 @@
(rule 3 (lower (insertlane (has_type $I64X2 (splat lane0))
lane1
(u8_from_uimm8 1)))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_pinsrq (bitcast_gpr_to_xmm 64 lane0) lane1 1))
(rule 1 (lower (insertlane vec @ (value_type $F32X4) (sinkable_load val) (u8_from_uimm8 idx)))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_insertps vec val (sse_insertps_lane_imm idx)))
(rule (lower (insertlane vec @ (value_type $F32X4) val (u8_from_uimm8 idx)))
(f32x4_insertlane vec val idx))
@@ -1689,7 +1689,7 @@
;; f32x4.replace_lane
(rule 1 (f32x4_insertlane vec val idx)
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_insertps vec val (sse_insertps_lane_imm idx)))
;; External rust code used to calculate the immediate value to `insertps`.
@@ -1769,22 +1769,22 @@
(decl pure has_pmins (Type) bool)
(rule 1 (has_pmins $I16X8) true)
(rule 1 (has_pmins $I64X2) false)
-(rule (has_pmins _) (use_sse41))
+(rule (has_pmins _) (has_sse41))
(decl pure has_pmaxs (Type) bool)
(rule 1 (has_pmaxs $I16X8) true)
(rule 1 (has_pmaxs $I64X2) false)
-(rule (has_pmaxs _) (use_sse41))
+(rule (has_pmaxs _) (has_sse41))
(decl pure has_pmaxu (Type) bool)
(rule 1 (has_pmaxu $I8X16) true)
(rule 1 (has_pmaxu $I64X2) false)
-(rule (has_pmaxu _) (use_sse41))
+(rule (has_pmaxu _) (has_sse41))
(decl pure has_pminu (Type) bool)
(rule 1 (has_pminu $I8X16) true)
(rule 1 (has_pminu $I64X2) false)
-(rule (has_pminu _) (use_sse41))
+(rule (has_pminu _) (has_sse41))
;; SSE `smax`.
@@ -2280,7 +2280,7 @@
;; instruction does what the CLIF expects for zero, i.e. it returns
;; zero.
(rule 1 (do_clz ty orig_ty src)
- (if-let true (use_lzcnt))
+ (if-let true (has_lzcnt))
(x64_lzcnt ty src))
(rule 0 (do_clz ty orig_ty src)
@@ -2316,7 +2316,7 @@
;; Analogous to `clz` cases above, but using mirror instructions
;; (tzcnt vs lzcnt, bsf vs bsr).
(rule 1 (do_ctz ty orig_ty src)
- (if-let true (use_bmi1))
+ (if-let true (has_bmi1))
(x64_tzcnt ty src))
(rule 0 (do_ctz ty orig_ty src)
@@ -2418,8 +2418,8 @@
(rule 2 (lower (has_type $I8X16 (popcnt src)))
- (if-let true (use_avx512vl))
- (if-let true (use_avx512bitalg))
+ (if-let true (has_avx512vl))
+ (if-let true (has_avx512bitalg))
(x64_vpopcntb src))
@@ -2444,7 +2444,7 @@
(rule 1 (lower (has_type $I8X16 (popcnt src)))
- (if-let true (use_ssse3))
+ (if-let true (has_ssse3))
(let ((low_mask XmmMem (emit_u128_le_const 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f))
(low_nibbles Xmm (sse_and $I8X16 src low_mask))
;; Note that this is a 16x8 shift, but that's OK; we mask
@@ -2621,7 +2621,7 @@
;; Rules for `x86_pmaddubsw` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(rule (lower (has_type $I16X8 (x86_pmaddubsw x y)))
- (if-let true (use_ssse3))
+ (if-let true (has_ssse3))
(x64_pmaddubsw y x))
;; Rules for `fadd` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -3065,22 +3065,22 @@
;; We also include widening vector loads; these sign- or zero-extend each lane
;; to the next wider width (e.g., 16x4 -> 32x4).
(rule 1 (lower (has_type $I16X8 (sload8x8 (little_or_native_endian flags) address offset)))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_pmovsxbw (to_amode flags address offset)))
(rule 1 (lower (has_type $I16X8 (uload8x8 (little_or_native_endian flags) address offset)))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_pmovzxbw (to_amode flags address offset)))
(rule 1 (lower (has_type $I32X4 (sload16x4 (little_or_native_endian flags) address offset)))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_pmovsxwd (to_amode flags address offset)))
(rule 1 (lower (has_type $I32X4 (uload16x4 (little_or_native_endian flags) address offset)))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_pmovzxwd (to_amode flags address offset)))
(rule 1 (lower (has_type $I64X2 (sload32x2 (little_or_native_endian flags) address offset)))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_pmovsxdq (to_amode flags address offset)))
(rule 1 (lower (has_type $I64X2 (uload32x2 (little_or_native_endian flags) address offset)))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_pmovzxdq (to_amode flags address offset)))
(rule (lower (has_type $I16X8 (sload8x8 (little_or_native_endian flags) address offset)))
@@ -3135,7 +3135,7 @@
value @ (value_type (is_xmm_type (ty_16 _)))
address
offset))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(side_effect
(x64_pextrw_store (to_amode flags address offset) value 0)))
@@ -3215,28 +3215,28 @@
(has_type $I8 (extractlane value (u8_from_uimm8 n)))
address
offset))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(side_effect
(x64_pextrb_store (to_amode flags address offset) value n)))
(rule 2 (lower (store (little_or_native_endian flags)
(has_type $I16 (extractlane value (u8_from_uimm8 n)))
address
offset))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(side_effect
(x64_pextrw_store (to_amode flags address offset) value n)))
(rule 2 (lower (store (little_or_native_endian flags)
(has_type $I32 (extractlane value (u8_from_uimm8 n)))
address
offset))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(side_effect
(x64_pextrd_store (to_amode flags address offset) value n)))
(rule 2 (lower (store (little_or_native_endian flags)
(has_type $I64 (extractlane value (u8_from_uimm8 n)))
address
offset))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(side_effect
(x64_pextrq_store (to_amode flags address offset) value n)))
@@ -3397,7 +3397,7 @@
(x64_movzx (ext_mode (ty_bits_u16 ty) 64) (to_amode flags address (zero_offset))))
;; Lower 128-bit `atomic_load` using `cmpxchg16b`.
(rule 1 (lower (has_type $I128 (atomic_load (little_or_native_endian flags) address)))
- (if-let true (use_cmpxchg16b))
+ (if-let true (has_cmpxchg16b))
(x64_cmpxchg16b (value_regs (imm $I64 0) (imm $I64 0)) (value_regs (imm $I64 0) (imm $I64 0)) (to_amode flags address (zero_offset))))
;; Rules for `atomic_store` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -3412,7 +3412,7 @@
(x64_mfence_zo))))
;; Lower 128-bit `atomic_store` using `cmpxchg16b`.
(rule 1 (lower (atomic_store (little_or_native_endian flags) value @ (value_type $I128) address))
- (if-let true (use_cmpxchg16b))
+ (if-let true (has_cmpxchg16b))
(side_effect (x64_atomic_128_store_seq (to_amode flags address (zero_offset)) value)))
;; Rules for `atomic_cas` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -3421,7 +3421,7 @@
(atomic_cas (little_or_native_endian flags) address expected replacement)))
(x64_cmpxchg ty expected replacement (to_amode flags address (zero_offset))))
(rule 1 (lower (has_type $I128 (atomic_cas flags address expected replacement)))
- (if-let true (use_cmpxchg16b))
+ (if-let true (has_cmpxchg16b))
(x64_cmpxchg16b expected replacement (to_amode flags address (zero_offset))))
;; Rules for `atomic_rmw` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -3474,7 +3474,7 @@
;; 128-bit integers always use a `lock cmpxchg16b` loop.
(rule 3 (lower (has_type $I128 (atomic_rmw (little_or_native_endian flags) op address input)))
- (if-let true (use_cmpxchg16b))
+ (if-let true (has_cmpxchg16b))
(x64_atomic_128_rmw_seq op (to_amode flags address (zero_offset)) input))
;; Rules for `call` and `call_indirect` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -3746,8 +3746,8 @@
;; When AVX512VL and AVX512F are available,
;; `fcvt_from_uint` can be lowered to a single instruction.
(rule 2 (lower (has_type $F32X4 (fcvt_from_uint src)))
- (if-let true (use_avx512vl))
- (if-let true (use_avx512f))
+ (if-let true (has_avx512vl))
+ (if-let true (has_avx512f))
(x64_vcvtudq2ps src))
;; Converting packed unsigned integers to packed floats
@@ -3950,7 +3950,7 @@
(rule 1 (lower (has_type $I16X8 (iadd_pairwise x y)))
- (if-let true (use_ssse3))
+ (if-let true (has_ssse3))
(x64_phaddw x y))
(rule (lower (has_type $I16X8 (iadd_pairwise x y)))
@@ -3980,7 +3980,7 @@
(x64_paddw evens odds)))
(rule 1 (lower (has_type $I32X4 (iadd_pairwise x y)))
- (if-let true (use_ssse3))
+ (if-let true (has_ssse3))
(x64_phaddd x y))
(rule (lower (has_type $I32X4 (iadd_pairwise x y)))
@@ -3999,7 +3999,7 @@
(has_type $I16X8 (iadd_pairwise
(swiden_low val @ (value_type $I8X16))
(swiden_high val))))
- (if-let true (use_ssse3))
+ (if-let true (has_ssse3))
(let ((mul_const Xmm (x64_xmm_load_const $I8X16
(emit_u128_le_const 0x01010101010101010101010101010101))))
(x64_pmaddubsw mul_const val)))
@@ -4017,7 +4017,7 @@
(has_type $I16X8 (iadd_pairwise
(uwiden_low val @ (value_type $I8X16))
(uwiden_high val))))
- (if-let true (use_ssse3))
+ (if-let true (has_ssse3))
(let ((mul_const XmmMem (emit_u128_le_const 0x01010101010101010101010101010101)))
(x64_pmaddubsw val mul_const)))
@@ -4046,13 +4046,13 @@
;; With SSE4.1 use the `pmovsx*` instructions for this
(rule 1 (lower (has_type $I16X8 (swiden_low val @ (value_type $I8X16))))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_pmovsxbw val))
(rule 1 (lower (has_type $I32X4 (swiden_low val @ (value_type $I16X8))))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_pmovsxwd val))
(rule 1 (lower (has_type $I64X2 (swiden_low val @ (value_type $I32X4))))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_pmovsxdq val))
(rule (lower (has_type ty (swiden_low val))) (lower_swiden_low ty val))
@@ -4079,17 +4079,17 @@
;; Similar to `swiden_low` with SSE4.1 except that the upper lanes are moved
;; to the lower lanes first.
(rule 1 (lower (has_type $I16X8 (swiden_high val @ (value_type $I8X16))))
- (if-let true (use_sse41))
- (if-let true (use_ssse3))
+ (if-let true (has_sse41))
+ (if-let true (has_ssse3))
(let ((x Xmm val))
(x64_pmovsxbw (x64_palignr x x 8))))
(rule 1 (lower (has_type $I32X4 (swiden_high val @ (value_type $I16X8))))
- (if-let true (use_sse41))
- (if-let true (use_ssse3))
+ (if-let true (has_sse41))
+ (if-let true (has_ssse3))
(let ((x Xmm val))
(x64_pmovsxwd (x64_palignr x x 8))))
(rule 1 (lower (has_type $I64X2 (swiden_high val @ (value_type $I32X4))))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_pmovsxdq (x64_pshufd val 0b11_10_11_10)))
;; Similar to `swiden_low` versions but using `punpckh*` instructions to
@@ -4111,13 +4111,13 @@
;; With SSE4.1 use the `pmovzx*` instructions for this
(rule 1 (lower (has_type $I16X8 (uwiden_low val @ (value_type $I8X16))))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_pmovzxbw val))
(rule 1 (lower (has_type $I32X4 (uwiden_low val @ (value_type $I16X8))))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_pmovzxwd val))
(rule 1 (lower (has_type $I64X2 (uwiden_low val @ (value_type $I32X4))))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_pmovzxdq val))
(rule (lower (has_type ty (uwiden_low val))) (lower_uwiden_low ty val))
@@ -4190,7 +4190,7 @@
(x64_packuswb a b))
(rule 1 (lower (has_type $I16X8 (unarrow a @ (value_type $I32X4) b)))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_packusdw a b))
;; For each input `a` and `b` take the four 32-bit lanes and compress them to
@@ -4278,16 +4278,16 @@
;; the appropriate libcall and sequence to call that.
(decl x64_round (Type RegMem RoundImm) Xmm)
(rule 1 (x64_round $F32 a imm)
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_roundss a imm))
(rule 1 (x64_round $F64 a imm)
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_roundsd a imm))
(rule 1 (x64_round $F32X4 a imm)
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_roundps a imm))
(rule 1 (x64_round $F64X2 a imm)
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_roundpd a imm))
(rule (x64_round $F32 (RegMem.Reg a) imm) (libcall_1 (round_libcall $F32 imm) a))
@@ -4482,7 +4482,7 @@
;; helps slightly reduce register pressure by ensuring only one register here is
;; clobbered.
(rule 2 (lower (umulhi a @ (value_type (ty_32_or_64 ty)) b))
- (if-let true (use_bmi2))
+ (if-let true (has_bmi2))
(x64_mulx_hi ty a b))
;; Rules for `smulhi` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -4520,7 +4520,7 @@
;; 0 chooses the corresponding 16-it lane from `a` and a bit of 1 chooses the
;; corresponding 16-bit lane from `b`.
(rule 14 (lower (shuffle a b (pblendw_imm n)))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_pblendw a b n))
(decl pblendw_imm (u8) Immediate)
(extern extractor pblendw_imm pblendw_imm)
@@ -4531,7 +4531,7 @@
;; operand as the low-order bytes and the first operand as high-order bytes,
;; so put `a` second.
(rule 13 (lower (shuffle a b (palignr_imm_from_immediate n)))
- (if-let true (use_ssse3))
+ (if-let true (has_ssse3))
(x64_palignr b a n))
(decl palignr_imm_from_immediate (u8) Immediate)
(extern extractor palignr_imm_from_immediate palignr_imm_from_immediate)
@@ -4605,7 +4605,7 @@
;; more efficient to execute the `pshufb` here-and-now with an xor'd-to-be-zero
;; register.
(rule 6 (lower (shuffle a _ (u128_from_immediate 0)))
- (if-let true (use_ssse3))
+ (if-let true (has_ssse3))
(x64_pshufb a (xmm_zero $I8X16)))
;; Special case for the `shufps` instruction which will select two 32-bit values
@@ -4634,22 +4634,22 @@
;; indices (may not be completely necessary: verification could fail incorrect
;; mask values) and fix the indexes to all point to the `dst` vector.
(rule 3 (lower (shuffle a a (vec_mask_from_immediate mask)))
- (if-let true (use_ssse3))
+ (if-let true (has_ssse3))
(x64_pshufb a (shuffle_0_31_mask mask)))
;; For the case where the shuffle mask contains out-of-bounds values (values
;; greater than 31) we must mask off those resulting values in the result of
;; `vpermi2b`.
(rule 2 (lower (shuffle a b (vec_mask_from_immediate (perm_from_mask_with_zeros mask zeros))))
- (if-let true (use_avx512vl))
- (if-let true (use_avx512vbmi))
+ (if-let true (has_avx512vl))
+ (if-let true (has_avx512vbmi))
(x64_andps (x64_vpermi2b (x64_xmm_load_const $I8X16 mask) a b) zeros))
;; However, if the shuffle mask contains no out-of-bounds values, we can use
;; `vpermi2b` without any masking.
(rule 1 (lower (shuffle a b (vec_mask_from_immediate mask)))
- (if-let true (use_avx512vl))
- (if-let true (use_avx512vbmi))
+ (if-let true (has_avx512vl))
+ (if-let true (has_avx512vbmi))
(x64_vpermi2b (x64_xmm_load_const $I8X16 (perm_from_mask mask)) a b))
;; If `lhs` and `rhs` are different, we must shuffle each separately and then OR
@@ -4675,7 +4675,7 @@
;; Rules for `x86_pshufb` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(rule (lower (x86_pshufb src mask))
- (if-let true (use_ssse3))
+ (if-let true (has_ssse3))
(x64_pshufb src mask))
;; A helper function to generate either the `pshufb` instruction or a libcall to
@@ -4685,7 +4685,7 @@
;; of SSSE3 to use the `pshufb` instruction itself.
(decl lower_pshufb (Xmm RegMem) Xmm)
(rule 1 (lower_pshufb src mask)
- (if-let true (use_ssse3))
+ (if-let true (has_ssse3))
(x64_pshufb src mask))
(rule (lower_pshufb src (RegMem.Reg mask))
(libcall_2 (LibCall.X86Pshufb) src mask))
@@ -4713,7 +4713,7 @@
;; Note that without SSE4.1 a 16-bit lane extraction is performed and then
;; the result is updated if the desired index is either odd or even.
(rule 2 (lower (extractlane val @ (value_type ty @ $I8X16) (u8_from_uimm8 lane)))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_pextrb val lane))
;; extracting an odd lane has an extra shift-right
(rule 1 (lower (extractlane val @ (value_type ty @ $I8X16) (u8_from_uimm8 lane)))
@@ -4733,7 +4733,7 @@
;; `i32x4.extract_lane N`
(rule 2 (lower (extractlane val @ (value_type ty @ $I32X4) (u8_from_uimm8 lane)))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_pextrd val lane))
(rule 1 (lower (extractlane val @ (value_type $I32X4) 0))
(x64_movd_to_gpr val))
@@ -4742,7 +4742,7 @@
;; `i64x2.extract_lane N`
(rule 1 (lower (extractlane val @ (value_type $I64X2) (u8_from_uimm8 lane)))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(x64_pextrq val lane))
(rule (lower (extractlane val @ (value_type $I64X2) 0))
(x64_movq_to_gpr val))
@@ -4789,14 +4789,14 @@
(let ((src Xmm (x64_movd_to_xmm src)))
(x64_pshufd (x64_pshuflw (x64_punpcklbw src src) 0) 0)))
(rule 1 (lower (has_type $I8X16 (splat src)))
- (if-let true (use_ssse3))
+ (if-let true (has_ssse3))
(x64_pshufb (bitcast_gpr_to_xmm 32 src) (xmm_zero $I8X16)))
(rule 2 (lower (has_type $I8X16 (splat src)))
(if-let true (use_avx2))
(x64_vpbroadcastb (bitcast_gpr_to_xmm 32 src)))
(rule 3 (lower (has_type $I8X16 (splat (sinkable_load_exact addr))))
- (if-let true (use_sse41))
- (if-let true (use_ssse3))
+ (if-let true (has_sse41))
+ (if-let true (has_ssse3))
(x64_pshufb (x64_pinsrb (xmm_uninit_value) addr 0) (xmm_zero $I8X16)))
(rule 4 (lower (has_type $I8X16 (splat (sinkable_load_exact addr))))
(if-let true (use_avx2))
@@ -4846,12 +4846,12 @@
;; that the memory-operand encoding of `vbroadcastss` is usable with AVX, but
;; the register-based encoding is only available with AVX2. With the
;; `sinkable_load` extractor this should be guaranteed to use the memory-based
-;; encoding hence the `use_avx` test.
+;; encoding hence the `has_avx` test.
(rule 5 (lower (has_type (multi_lane 32 4) (splat (sinkable_load addr))))
(let ((tmp Xmm (x64_movss_load addr)))
(x64_shufps tmp tmp 0)))
(rule 6 (lower (has_type (multi_lane 32 4) (splat (sinkable_load addr))))
- (if-let true (use_avx))
+ (if-let true (has_avx))
(x64_vbroadcastss addr))
;; t64x2.splat - use `pshufd` to broadcast the lower 64-bit lane to the upper
@@ -4862,7 +4862,7 @@
(rule 0 (lower (has_type $F64X2 (splat src)))
(x64_pshufd src 0b01_00_01_00))
(rule 6 (lower (has_type (multi_lane 64 2) (splat (sinkable_load addr))))
- (if-let true (use_sse3))
+ (if-let true (has_sse3))
(x64_movddup addr))
;; Rules for `vany_true` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -4881,7 +4881,7 @@
)
(CondResult.CC (x64_cmpl_mi mask 0xffff) (CC.NZ))))
(rule 1 (is_vany_true val)
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(let ((val Xmm val))
(CondResult.CC (x64_ptest val val) (CC.NZ))))
@@ -4891,7 +4891,7 @@
(decl is_vall_true (Value) CondResult)
(rule 1 (is_vall_true val @ (value_type ty))
- (if-let true (use_sse41))
+ (if-let true (has_sse41))
(let ((src Xmm val)
(zeros Xmm (xmm_zero ty))
(cmp Xmm (x64_pcmpeq (vec_int_type ty) src zeros)))
@@ -4964,7 +4964,7 @@
;; Rules for `sqmul_round_sat` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(rule 1 (lower (sqmul_round_sat qx @ (value_type $I16X8) qy))
- (if-let true (use_ssse3))
+ (if-let true (has_ssse3))
(let ((src1 Xmm qx)
(src2 Xmm qy)
@@ -5006,7 +5006,7 @@
;; Rules for `x86_pmulhrsw` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(rule (lower (x86_pmulhrsw qx @ (value_type $I16X8) qy))
- (if-let true (use_ssse3))
+ (if-let true (has_ssse3))
(x64_pmulhrsw qx qy))
;; Rules for `uunarrow` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
diff --git a/cranelift/codegen/src/isa/x64/lower/isle.rs b/cranelift/codegen/src/isa/x64/lower/isle.rs
index 78262fce53..ff28a91da4 100644
--- a/cranelift/codegen/src/isa/x64/lower/isle.rs
+++ b/cranelift/codegen/src/isa/x64/lower/isle.rs
@@ -244,88 +244,88 @@ impl Context for IsleContext<'_, '_, MInst, X64Backend> {
}
#[inline]
- fn use_avx(&mut self) -> bool {
- self.backend.x64_flags.use_avx()
+ fn has_avx(&mut self) -> bool {
+ self.backend.x64_flags.has_avx()
}
#[inline]
fn use_avx2(&mut self) -> bool {
- self.backend.x64_flags.use_avx2()
+ self.backend.x64_flags.has_avx() && self.backend.x64_flags.has_avx2()
}
#[inline]
- fn use_avx512vl(&mut self) -> bool {
- self.backend.x64_flags.use_avx512vl()
+ fn has_avx512vl(&mut self) -> bool {
+ self.backend.x64_flags.has_avx512vl()
}
#[inline]
- fn use_avx512dq(&mut self) -> bool {
- self.backend.x64_flags.use_avx512dq()
+ fn has_avx512dq(&mut self) -> bool {
+ self.backend.x64_flags.has_avx512dq()
}
#[inline]
- fn use_avx512f(&mut self) -> bool {
- self.backend.x64_flags.use_avx512f()
+ fn has_avx512f(&mut self) -> bool {
+ self.backend.x64_flags.has_avx512f()
}
#[inline]
- fn use_avx512bitalg(&mut self) -> bool {
- self.backend.x64_flags.use_avx512bitalg()
+ fn has_avx512bitalg(&mut self) -> bool {
+ self.backend.x64_flags.has_avx512bitalg()
}
#[inline]
- fn use_avx512vbmi(&mut self) -> bool {
- self.backend.x64_flags.use_avx512vbmi()
+ fn has_avx512vbmi(&mut self) -> bool {
+ self.backend.x64_flags.has_avx512vbmi()
}
#[inline]
- fn use_lzcnt(&mut self) -> bool {
- self.backend.x64_flags.use_lzcnt()
+ fn has_lzcnt(&mut self) -> bool {
+ self.backend.x64_flags.has_lzcnt()
}
#[inline]
- fn use_bmi1(&mut self) -> bool {
- self.backend.x64_flags.use_bmi1()
+ fn has_bmi1(&mut self) -> bool {
+ self.backend.x64_flags.has_bmi1()
}
#[inline]
- fn use_bmi2(&mut self) -> bool {
- self.backend.x64_flags.use_bmi2()
+ fn has_bmi2(&mut self) -> bool {
+ self.backend.x64_flags.has_bmi2()
}
#[inline]
fn use_popcnt(&mut self) -> bool {
- self.backend.x64_flags.use_popcnt()
+ self.backend.x64_flags.has_popcnt() && self.backend.x64_flags.has_sse42()
}
#[inline]
fn use_fma(&mut self) -> bool {
- self.backend.x64_flags.use_fma()
+ self.backend.x64_flags.has_avx() && self.backend.x64_flags.has_fma()
}
#[inline]
- fn use_sse3(&mut self) -> bool {
- self.backend.x64_flags.use_sse3()
+ fn has_sse3(&mut self) -> bool {
+ self.backend.x64_flags.has_sse3()
}
#[inline]
- fn use_ssse3(&mut self) -> bool {
- self.backend.x64_flags.use_ssse3()
+ fn has_ssse3(&mut self) -> bool {
+ self.backend.x64_flags.has_ssse3()
}
#[inline]
- fn use_sse41(&mut self) -> bool {
- self.backend.x64_flags.use_sse41()
+ fn has_sse41(&mut self) -> bool {
+ self.backend.x64_flags.has_sse41()
}
#[inline]
fn use_sse42(&mut self) -> bool {
- self.backend.x64_flags.use_sse42()
+ self.backend.x64_flags.has_sse41() && self.backend.x64_flags.has_sse42()
}
#[inline]
- fn use_cmpxchg16b(&mut self) -> bool {
- self.backend.x64_flags.use_cmpxchg16b()
+ fn has_cmpxchg16b(&mut self) -> bool {
+ self.backend.x64_flags.has_cmpxchg16b()
}
#[inline]
diff --git a/cranelift/codegen/src/isa/x64/mod.rs b/cranelift/codegen/src/isa/x64/mod.rs
index 80d154b434..2bdb367d77 100644
--- a/cranelift/codegen/src/isa/x64/mod.rs
+++ b/cranelift/codegen/src/isa/x64/mod.rs
@@ -177,11 +177,11 @@ impl TargetIsa for X64Backend {
}
fn has_native_fma(&self) -> bool {
- self.x64_flags.use_fma()
+ self.x64_flags.has_fma()
}
fn has_round(&self) -> bool {
- self.x64_flags.use_sse41()
+ self.x64_flags.has_sse41()
}
fn has_x86_blendv_lowering(&self, ty: Type) -> bool {
@@ -189,19 +189,19 @@ impl TargetIsa for X64Backend {
// available from SSE 4.1 and onwards. Otherwise the i16x8 type has no
// equivalent instruction which only looks at the top bit for a select
// operation, so that always returns `false`
- self.x64_flags.use_sse41() && ty != types::I16X8
+ self.x64_flags.has_sse41() && ty != types::I16X8
}
fn has_x86_pshufb_lowering(&self) -> bool {
- self.x64_flags.use_ssse3()
+ self.x64_flags.has_ssse3()
}
fn has_x86_pmulhrsw_lowering(&self) -> bool {
- self.x64_flags.use_ssse3()
+ self.x64_flags.has_ssse3()
}
fn has_x86_pmaddubsw_lowering(&self) -> bool {
- self.x64_flags.use_ssse3()
+ self.x64_flags.has_ssse3()
}
fn default_argument_extension(&self) -> ir::ArgumentExtension {
diff --git a/cranelift/codegen/src/settings.rs b/cranelift/codegen/src/settings.rs
index 516996cdf2..af8cbd5140 100644
--- a/cranelift/codegen/src/settings.rs
+++ b/cranelift/codegen/src/settings.rs
@@ -503,18 +503,14 @@ enable_verifier = true
enable_pcc = false
is_pic = false
use_colocated_libcalls = false
-enable_float = true
enable_nan_canonicalization = false
enable_pinned_reg = false
-enable_atomics = true
-enable_safepoints = false
enable_llvm_abi_extensions = false
enable_multi_ret_implicit_sret = false
unwind_info = true
preserve_frame_pointers = false
machine_code_cfg_info = false
enable_probestack = false
-enable_jump_tables = true
enable_heap_access_spectre_mitigation = true
enable_table_access_spectre_mitigation = true
enable_incremental_compilation_cache_checks = false
@@ -534,11 +530,11 @@ enable_incremental_compilation_cache_checks = false
fn modify_bool() {
let mut b = builder();
assert_eq!(b.enable("not_there"), Err(BadName("not_there".to_string())));
- assert_eq!(b.enable("enable_atomics"), Ok(()));
- assert_eq!(b.set("enable_atomics", "false"), Ok(()));
+ assert_eq!(b.enable("enable_verifier"), Ok(()));
+ assert_eq!(b.set("enable_verifier", "false"), Ok(()));
let f = Flags::new(b);
- assert_eq!(f.enable_atomics(), false);
+ assert_eq!(f.enable_verifier(), false);
}
#[test]
@@ -549,11 +545,11 @@ enable_incremental_compilation_cache_checks = false
Err(BadName("not_there".to_string()))
);
assert_eq!(
- b.set("enable_atomics", ""),
+ b.set("enable_verifier", ""),
Err(BadValue("bool".to_string()))
);
assert_eq!(
- b.set("enable_atomics", "best"),
+ b.set("enable_verifier", "best"),
Err(BadValue("bool".to_string()))
);
assert_eq!(
@@ -563,10 +559,10 @@ enable_incremental_compilation_cache_checks = false
))
);
assert_eq!(b.set("opt_level", "speed"), Ok(()));
- assert_eq!(b.set("enable_atomics", "0"), Ok(()));
+ assert_eq!(b.set("enable_verifier", "0"), Ok(()));
let f = Flags::new(b);
- assert_eq!(f.enable_atomics(), false);
+ assert_eq!(f.enable_verifier(), false);
assert_eq!(f.opt_level(), super::OptLevel::Speed);
}
}
diff --git a/cranelift/filetests/filetests/isa/riscv64/issue8847.clif b/cranelift/filetests/filetests/isa/riscv64/issue8847.clif
index 2ba42406ce..7a7ba8395d 100644
--- a/cranelift/filetests/filetests/isa/riscv64/issue8847.clif
+++ b/cranelift/filetests/filetests/isa/riscv64/issue8847.clif
@@ -6,7 +6,6 @@ set enable_alias_analysis=false
set enable_llvm_abi_extensions=true
set enable_multi_ret_implicit_sret
set machine_code_cfg_info=true
-set enable_jump_tables=false
set enable_heap_access_spectre_mitigation=false
target riscv64 has_zcd has_zbkb has_zbc has_zbs has_zicond has_zvl32b has_zvl64b has_zvl128b has_zvl1024b has_zvl2048b has_zvl4096b has_zvl8192b has_zvl16384b has_zvl32768b
diff --git a/cranelift/filetests/filetests/isa/riscv64/issue8866.clif b/cranelift/filetests/filetests/isa/riscv64/issue8866.clif
index 64736737fe..4aece94c59 100644
--- a/cranelift/filetests/filetests/isa/riscv64/issue8866.clif
+++ b/cranelift/filetests/filetests/isa/riscv64/issue8866.clif
@@ -6,7 +6,6 @@ set enable_alias_analysis=false
set enable_llvm_abi_extensions=true
set enable_multi_ret_implicit_sret
set machine_code_cfg_info=true
-set enable_jump_tables=false
set enable_heap_access_spectre_mitigation=false
target riscv64 has_zcd has_zbkb has_zbc has_zbs has_zicond has_zvl32b has_zvl64b has_zvl128b has_zvl1024b has_zvl2048b has_zvl4096b has_zvl8192b has_zvl16384b has_zvl32768b
diff --git a/cranelift/filetests/filetests/runtests/issue-5690.clif b/cranelift/filetests/filetests/runtests/issue-5690.clif
index b2729924c6..1ba6115982 100644
--- a/cranelift/filetests/filetests/runtests/issue-5690.clif
+++ b/cranelift/filetests/filetests/runtests/issue-5690.clif
@@ -1,7 +1,6 @@
test interpret
test run
set opt_level=speed
-set enable_safepoints=true
set unwind_info=false
set preserve_frame_pointers=true
set machine_code_cfg_info=true
diff --git a/cranelift/fuzzgen/src/lib.rs b/cranelift/fuzzgen/src/lib.rs
index 1fe703d584..fe8511de5a 100644
--- a/cranelift/fuzzgen/src/lib.rs
+++ b/cranelift/fuzzgen/src/lib.rs
@@ -185,10 +185,8 @@ where
// aarch64: https://github.com/bytecodealliance/wasmtime/issues/2735
let bool_settings = [
"enable_alias_analysis",
- "enable_safepoints",
"unwind_info",
"preserve_frame_pointers",
- "enable_jump_tables",
"enable_heap_access_spectre_mitigation",
"enable_table_access_spectre_mitigation",
"enable_incremental_compilation_cache_checks",
@@ -251,11 +249,6 @@ where
// This is the default, but we should ensure that it wasn't accidentally turned off anywhere.
builder.enable("enable_verifier").unwrap();
- // These settings just panic when they're not enabled and we try to use their respective functionality
- // so they aren't very interesting to be automatically generated.
- builder.enable("enable_atomics").unwrap();
- builder.enable("enable_float").unwrap();
-
// `machine_code_cfg_info` generates additional metadata for the embedder but this doesn't feed back
// into compilation anywhere, we leave it on unconditionally to make sure the generation doesn't panic.
builder.enable("machine_code_cfg_info").unwrap();
diff --git a/cranelift/reader/src/parser.rs b/cranelift/reader/src/parser.rs
index 080476a44f..29faadee23 100644
--- a/cranelift/reader/src/parser.rs
+++ b/cranelift/reader/src/parser.rs
@@ -3685,7 +3685,7 @@ mod tests {
r#"; before
test cfg option=5
test verify
- set enable_float=false
+ set unwind_info=false
feature "foo"
feature !"bar"
; still preamble
@@ -3699,7 +3699,7 @@ mod tests {
match tf.isa_spec {
IsaSpec::None(s) => {
assert!(s.enable_verifier());
- assert!(!s.enable_float());
+ assert!(!s.unwind_info());
}
_ => panic!("unexpected ISAs"),
}
@@ -3726,7 +3726,7 @@ mod tests {
assert!(
parse_test(
"target x86_64
- set enable_float=false
+ set unwind_info=false
function %foo() system_v {}",
ParseOptions::default()
)
@@ -3734,7 +3734,7 @@ mod tests {
);
match parse_test(
- "set enable_float=false
+ "set unwind_info=false
target x86_64
function %foo() system_v {}",
ParseOptions::default(),
diff --git a/crates/wasmtime/src/config.rs b/crates/wasmtime/src/config.rs
index ae61afcfa0..d136987cc4 100644
--- a/crates/wasmtime/src/config.rs
+++ b/crates/wasmtime/src/config.rs
@@ -2502,18 +2502,6 @@ impl Config {
}
}
- // check for incompatible compiler options and set required values
- if features.contains(WasmFeatures::REFERENCE_TYPES) {
- if !self
- .compiler_config
- .ensure_setting_unset_or_given("enable_safepoints", "true")
- {
- bail!(
- "compiler option 'enable_safepoints' must be enabled when 'reference types' is enabled"
- );
- }
- }
-
if features.contains(WasmFeatures::RELAXED_SIMD) && !features.contains(WasmFeatures::SIMD) {
bail!("cannot disable the simd proposal but enable the relaxed simd proposal");
}
diff --git a/crates/wasmtime/src/engine.rs b/crates/wasmtime/src/engine.rs
index 027e73efe3..d7cbaff0d3 100644
--- a/crates/wasmtime/src/engine.rs
+++ b/crates/wasmtime/src/engine.rs
@@ -92,9 +92,8 @@ impl Engine {
/// configurations are incompatible.
///
/// For example, feature `reference_types` will need to set
- /// the compiler setting `enable_safepoints` and `unwind_info`
- /// to `true`, but explicitly disable these two compiler settings
- /// will cause errors.
+ /// the compiler setting `unwind_info` to `true`, but explicitly
+ /// disable these two compiler settings will cause errors.
pub fn new(config: &Config) -> Result<Engine> {
let config = config.clone();
let (tunables, features) = config.validate()?;
@@ -416,17 +415,6 @@ information about this check\
"use_colocated_libcalls" => *value == FlagValue::Bool(false),
"use_pinned_reg_as_heap_base" => *value == FlagValue::Bool(false),
- // If reference types (or anything that depends on reference types,
- // like typed function references and GC) are enabled this must be
- // enabled, otherwise this setting can have any value.
- "enable_safepoints" => {
- if self.features().contains(WasmFeatures::REFERENCE_TYPES) {
- *value == FlagValue::Bool(true)
- } else {
- return Ok(())
- }
- }
-
// Windows requires unwind info as part of its ABI.
"unwind_info" => {
if target.operating_system == target_lexicon::OperatingSystem::Windows {
@@ -460,7 +448,6 @@ information about this check\
"enable_heap_access_spectre_mitigation"
| "enable_table_access_spectre_mitigation"
| "enable_nan_canonicalization"
- | "enable_jump_tables"
| "enable_float"
| "enable_verifier"
| "enable_pcc"