Skip to content

Commit 758d7ec

Browse files
Feat: setup load function for x86 intrinsics
1 parent d0f2d78 commit 758d7ec

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

crates/intrinsic-test/src/x86/types.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,32 @@ impl IntrinsicTypeDefinition for X86IntrinsicType {
2828

2929
/// Determines the load function for this type.
3030
fn get_load_function(&self, _language: Language) -> String {
31-
todo!("get_load_function for X86IntrinsicType needs to be implemented!");
31+
if let Some(type_value) = self.metadata.get("type") {
32+
if type_value.starts_with("__mmask") {
33+
// no need of loads, since they work directly
34+
// with hex constants
35+
String::from("*")
36+
} else if type_value.starts_with("__m") {
37+
// the structure is like the follows:
38+
// if "type" starts with __m<num>{h/i/<null>},
39+
// then use either _mm_set1_epi64,
40+
// _mm256_set1_epi64 or _mm512_set1_epi64
41+
let type_val_filtered = type_value
42+
.chars()
43+
.filter(|c| c.is_numeric())
44+
.join("")
45+
.replace("128", "");
46+
format!("_mm{type_val_filtered}_set1_epi64")
47+
} else {
48+
// if it is a pointer, then rely on type conversion
49+
// If it is not any of the above type (__int<num>, __bfloat16, unsigned short, etc)
50+
// then typecast it.
51+
format!("({type_value})")
52+
}
53+
// Look for edge cases (constexpr, literal, etc)
54+
} else {
55+
unimplemented!("the value for key 'type' is not present!");
56+
}
3257
}
3358

3459
/// Determines the get lane function for this type.

0 commit comments

Comments
 (0)