Skip to content

Commit

Permalink
cranelift: Remove the enable_simd shared setting
Browse files Browse the repository at this point in the history
This commit removes a setting for Cranelift which I've found a bit
confusing historically and I think is no longer necessary. The setting
is currently documented as enabling SIMD instructions, but that only
sort of works for the x64 backend and none of the other backends look at
it. Historically this was used to flag to Cranelift that a higher x64
baseline feature set is required for codegen but as of bytecodealliance#6625 that's no
longer necessary.

Otherwise it seems more Cranelift-like nowadays to say that vector
instructions generate SIMD instructions where non-vector instructions
probably don't, but may still depending on activated CPU features. In
that sense I'm not sure if a dedicated `enable_simd` setting is still
motivated, so this PR removes it.

This renames some features in the x86 backend such as `use_avx_simd` to
`use_avx` since the `_simd` part is no longer part of the computation
now that `enable_simd` is gone.
  • Loading branch information
alexcrichton committed Jun 22, 2023
1 parent 48e140d commit 998ae31
Show file tree
Hide file tree
Showing 180 changed files with 254 additions and 482 deletions.
11 changes: 0 additions & 11 deletions cranelift/codegen/meta/src/cdsl/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,6 @@ impl SettingGroup {
let num_predicates = self.num_bool_settings() + (self.predicates.len() as u8);
self.bool_start_byte_offset + (num_predicates + 7) / 8
}

pub fn get_bool(&self, name: &'static str) -> (BoolSettingIndex, &Self) {
for (i, s) in self.settings.iter().enumerate() {
if let SpecificSetting::Bool(_) = s.specific {
if s.name == name {
return (BoolSettingIndex(i), self);
}
}
}
panic!("Should have found bool setting by name.");
}
}

/// This is the basic information needed to track the specific parts of a setting when building
Expand Down
53 changes: 10 additions & 43 deletions cranelift/codegen/meta/src/isa/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ use crate::cdsl::settings::{PredicateNode, SettingGroup, SettingGroupBuilder};

use crate::shared::Definitions as SharedDefinitions;

pub(crate) fn define(shared_defs: &mut SharedDefinitions) -> TargetIsa {
let settings = define_settings(&shared_defs.settings);
pub(crate) fn define(_shared_defs: &mut SharedDefinitions) -> TargetIsa {
let settings = define_settings();

TargetIsa::new("x86", settings)
}

fn define_settings(shared: &SettingGroup) -> SettingGroup {
fn define_settings() -> SettingGroup {
let mut settings = SettingGroupBuilder::new("x86");

// CPUID.01H:ECX
Expand Down Expand Up @@ -114,51 +114,18 @@ fn define_settings(shared: &SettingGroup) -> SettingGroup {
false,
);

let shared_enable_simd = shared.get_bool("enable_simd");

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_ssse3_simd",
predicate!(shared_enable_simd && has_ssse3),
);
settings.add_predicate(
"use_sse41_simd",
predicate!(shared_enable_simd && has_sse41),
);
settings.add_predicate(
"use_sse42_simd",
predicate!(shared_enable_simd && has_sse41 && has_sse42),
);

settings.add_predicate("use_avx_simd", predicate!(shared_enable_simd && has_avx));
settings.add_predicate(
"use_avx2_simd",
predicate!(shared_enable_simd && has_avx && has_avx2),
);
settings.add_predicate(
"use_avx512bitalg_simd",
predicate!(shared_enable_simd && has_avx512bitalg),
);
settings.add_predicate(
"use_avx512dq_simd",
predicate!(shared_enable_simd && has_avx512dq),
);
settings.add_predicate(
"use_avx512vl_simd",
predicate!(shared_enable_simd && has_avx512vl),
);
settings.add_predicate(
"use_avx512vbmi_simd",
predicate!(shared_enable_simd && has_avx512vbmi),
);
settings.add_predicate(
"use_avx512f_simd",
predicate!(shared_enable_simd && has_avx512f),
);
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));
Expand Down
7 changes: 0 additions & 7 deletions cranelift/codegen/meta/src/shared/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,6 @@ pub(crate) fn define() -> SettingGroup {
false,
);

settings.add_bool(
"enable_simd",
"Enable the use of SIMD instructions.",
"",
false,
);

settings.add_bool(
"enable_atomics",
"Enable the use of atomic instructions",
Expand Down
Loading

0 comments on commit 998ae31

Please sign in to comment.