Skip to content

Commit 6e190b2

Browse files
feat: implemented c_single_vector_type and fixed logical errors in
from_param of X86IntrinsicType
1 parent 758d7ec commit 6e190b2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::collections::HashMap;
22
use std::str::FromStr;
33

44
use itertools::Itertools;
5+
use regex::Regex;
56

67
use super::intrinsic::X86IntrinsicType;
78
use crate::common::cli::Language;
@@ -19,7 +20,12 @@ impl IntrinsicTypeDefinition for X86IntrinsicType {
1920
}
2021

2122
fn c_single_vector_type(&self) -> String {
22-
todo!("c_single_vector_type for X86IntrinsicType needs to be implemented!");
23+
// matches __m128, __m256 and similar types
24+
let re = Regex::new(r"\__m\d+\").unwrap();
25+
match self.metadata.get("type") {
26+
Some(type_data) if re.is_match(type_data) => type_data.to_string(),
27+
_ => unreachable!("Shouldn't be called on this type"),
28+
}
2329
}
2430

2531
fn rust_type(&self) -> String {
@@ -150,10 +156,10 @@ impl X86IntrinsicType {
150156
// then check the param.type and extract numeric part if there are double
151157
// underscores. divide this number with bit-len and set this as simd-len.
152158

153-
let mut type_processed = param.etype.clone();
159+
let mut type_processed = param.type_data.clone();
154160
type_processed.retain(|c| c.is_numeric());
155161

156-
ret.vec_len = match str::parse::<u32>(etype_processed.as_str()) {
162+
ret.vec_len = match str::parse::<u32>(type_processed.as_str()) {
157163
// If bit_len is None, vec_len will be None.
158164
// Else vec_len will be (num_bits / bit_len).
159165
Ok(num_bits) => ret.bit_len.and(Some(num_bits / ret.bit_len.unwrap())),

0 commit comments

Comments
 (0)