MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / infer_native_flags

Function infer_native_flags

cranelift/native/src/lib.rs:45–177  ·  view source on GitHub ↗

Return an `isa` builder configured for the current host machine, or `Err(())` if the host machine is not supported in the current configuration. Selects the given backend variant specifically; this is useful when more than one backend exists for a given target (e.g., on x86-64).

(isa_builder: &mut dyn Configurable)

Source from the content-addressed store, hash-verified

43/// useful when more than one backend exists for a given target
44/// (e.g., on x86-64).
45pub fn infer_native_flags(isa_builder: &mut dyn Configurable) -> Result<(), &'static str> {
46 #[cfg(target_arch = "x86_64")]
47 {
48 if !std::is_x86_feature_detected!("sse2") {
49 return Err("x86 support requires SSE2");
50 }
51
52 if std::is_x86_feature_detected!("cmpxchg16b") {
53 isa_builder.enable("has_cmpxchg16b").unwrap();
54 }
55 if std::is_x86_feature_detected!("sse3") {
56 isa_builder.enable("has_sse3").unwrap();
57 }
58 if std::is_x86_feature_detected!("ssse3") {
59 isa_builder.enable("has_ssse3").unwrap();
60 }
61 if std::is_x86_feature_detected!("sse4.1") {
62 isa_builder.enable("has_sse41").unwrap();
63 }
64 if std::is_x86_feature_detected!("sse4.2") {
65 isa_builder.enable("has_sse42").unwrap();
66 }
67 if std::is_x86_feature_detected!("popcnt") {
68 isa_builder.enable("has_popcnt").unwrap();
69 }
70 if std::is_x86_feature_detected!("avx") {
71 isa_builder.enable("has_avx").unwrap();
72 }
73 if std::is_x86_feature_detected!("avx2") {
74 isa_builder.enable("has_avx2").unwrap();
75 }
76 if std::is_x86_feature_detected!("fma") {
77 isa_builder.enable("has_fma").unwrap();
78 }
79 if std::is_x86_feature_detected!("bmi1") {
80 isa_builder.enable("has_bmi1").unwrap();
81 }
82 if std::is_x86_feature_detected!("bmi2") {
83 isa_builder.enable("has_bmi2").unwrap();
84 }
85 if std::is_x86_feature_detected!("avx512bitalg") {
86 isa_builder.enable("has_avx512bitalg").unwrap();
87 }
88 if std::is_x86_feature_detected!("avx512dq") {
89 isa_builder.enable("has_avx512dq").unwrap();
90 }
91 if std::is_x86_feature_detected!("avx512f") {
92 isa_builder.enable("has_avx512f").unwrap();
93 }
94 if std::is_x86_feature_detected!("avx512vl") {
95 isa_builder.enable("has_avx512vl").unwrap();
96 }
97 if std::is_x86_feature_detected!("avx512vbmi") {
98 isa_builder.enable("has_avx512vbmi").unwrap();
99 }
100 if std::is_x86_feature_detected!("lzcnt") {
101 isa_builder.enable("has_lzcnt").unwrap();
102 }

Callers 2

builder_with_optionsFunction · 0.85
newMethod · 0.85

Calls 5

hwcap_detectFunction · 0.85
cpuinfo_detectFunction · 0.85
OkFunction · 0.85
unwrapMethod · 0.45
enableMethod · 0.45

Tested by

no test coverage detected