Skip to content

Commit f918b57

Browse files
feat: added the simple set of argument types for X86 intrinsics
1 parent ae72698 commit f918b57

File tree

3 files changed

+32
-22
lines changed

3 files changed

+32
-22
lines changed

crates/intrinsic-test/src/arm/intrinsic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ impl IntrinsicDefinition<ArmIntrinsicType> for Intrinsic<ArmIntrinsicType> {
7373
TypeKind::Float if self.results().inner_size() == 16 => "float16_t".to_string(),
7474
TypeKind::Float if self.results().inner_size() == 32 => "float".to_string(),
7575
TypeKind::Float if self.results().inner_size() == 64 => "double".to_string(),
76-
TypeKind::Int => format!("int{}_t", self.results().inner_size()),
77-
TypeKind::UInt => format!("uint{}_t", self.results().inner_size()),
76+
TypeKind::Int(true) => format!("int{}_t", self.results().inner_size()),
77+
TypeKind::Int(false) => format!("uint{}_t", self.results().inner_size()),
7878
TypeKind::Poly => format!("poly{}_t", self.results().inner_size()),
7979
ty => todo!("print_result_c - Unknown type: {:#?}", ty),
8080
},

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ impl IntrinsicTypeDefinition for ArmIntrinsicType {
7373
format!(
7474
"vld{len}{quad}_{type}{size}",
7575
type = match k {
76-
TypeKind::UInt => "u",
77-
TypeKind::Int => "s",
76+
TypeKind::Int(false) => "u",
77+
TypeKind::Int(true) => "s",
7878
TypeKind::Float => "f",
7979
// The ACLE doesn't support 64-bit polynomial loads on Armv7
8080
// if armv7 and bl == 64, use "s", else "p"
@@ -107,8 +107,8 @@ impl IntrinsicTypeDefinition for ArmIntrinsicType {
107107
format!(
108108
"vget{quad}_lane_{type}{size}",
109109
type = match k {
110-
TypeKind::UInt => "u",
111-
TypeKind::Int => "s",
110+
TypeKind::Int(false) => "u",
111+
TypeKind::Int(true) => "s",
112112
TypeKind::Float => "f",
113113
TypeKind::Poly => "p",
114114
x => todo!("get_load_function TypeKind: {:#?}", x),
@@ -175,7 +175,7 @@ impl IntrinsicTypeDefinition for ArmIntrinsicType {
175175
} else {
176176
let kind = start.parse::<TypeKind>()?;
177177
let bit_len = match kind {
178-
TypeKind::Int => Some(32),
178+
TypeKind::Int(_) => Some(32),
179179
_ => None,
180180
};
181181
Ok(ArmIntrinsicType(IntrinsicType {

crates/intrinsic-test/src/common/intrinsic_helpers.rs

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ use super::values::value_for_array;
1212
pub enum TypeKind {
1313
BFloat,
1414
Float,
15-
Int,
16-
UInt,
15+
Double,
16+
17+
// if signed, then the inner value is true
18+
Int(bool),
19+
Char(bool),
20+
Short(bool),
1721
Poly,
1822
Void,
1923
}
@@ -25,9 +29,10 @@ impl FromStr for TypeKind {
2529
match s {
2630
"bfloat" => Ok(Self::BFloat),
2731
"float" => Ok(Self::Float),
28-
"int" => Ok(Self::Int),
32+
"int" => Ok(Self::Int(true)),
2933
"poly" => Ok(Self::Poly),
30-
"uint" | "unsigned" => Ok(Self::UInt),
34+
"char" => Ok(Self::Char(true)),
35+
"uint" | "unsigned" => Ok(Self::Int(false)),
3136
"void" => Ok(Self::Void),
3237
_ => Err(format!("Impossible to parse argument kind {s}")),
3338
}
@@ -42,10 +47,15 @@ impl fmt::Display for TypeKind {
4247
match self {
4348
Self::BFloat => "bfloat",
4449
Self::Float => "float",
45-
Self::Int => "int",
46-
Self::UInt => "uint",
50+
Self::Double => "double",
51+
Self::Int(true) => "int",
52+
Self::Int(false) => "uint",
4753
Self::Poly => "poly",
4854
Self::Void => "void",
55+
Self::Char(true) => "char",
56+
Self::Char(false) => "unsigned char",
57+
Self::Short(true) => "short",
58+
Self::Short(false) => "unsigned short"
4959
}
5060
)
5161
}
@@ -56,8 +66,8 @@ impl TypeKind {
5666
pub fn c_prefix(&self) -> &str {
5767
match self {
5868
Self::Float => "float",
59-
Self::Int => "int",
60-
Self::UInt => "uint",
69+
Self::Int(true) => "int",
70+
Self::Int(false) => "uint",
6171
Self::Poly => "poly",
6272
_ => unreachable!("Not used: {:#?}", self),
6373
}
@@ -67,8 +77,8 @@ impl TypeKind {
6777
pub fn rust_prefix(&self) -> &str {
6878
match self {
6979
Self::Float => "f",
70-
Self::Int => "i",
71-
Self::UInt => "u",
80+
Self::Int(true) => "i",
81+
Self::Int(false) => "u",
7282
Self::Poly => "u",
7383
_ => unreachable!("Unused type kind: {:#?}", self),
7484
}
@@ -155,8 +165,8 @@ impl IntrinsicType {
155165
bit_len: Some(8),
156166
..
157167
} => match kind {
158-
TypeKind::Int => "(int)",
159-
TypeKind::UInt => "(unsigned int)",
168+
TypeKind::Int(true) => "(int)",
169+
TypeKind::Int(false) => "(unsigned int)",
160170
TypeKind::Poly => "(unsigned int)(uint8_t)",
161171
_ => "",
162172
},
@@ -185,7 +195,7 @@ impl IntrinsicType {
185195
match self {
186196
IntrinsicType {
187197
bit_len: Some(bit_len @ (8 | 16 | 32 | 64)),
188-
kind: kind @ (TypeKind::Int | TypeKind::UInt | TypeKind::Poly),
198+
kind: kind @ (TypeKind::Int(_) | TypeKind::Poly),
189199
simd_len,
190200
vec_len,
191201
..
@@ -201,7 +211,7 @@ impl IntrinsicType {
201211
.format_with(",\n", |i, fmt| {
202212
let src = value_for_array(*bit_len, i);
203213
assert!(src == 0 || src.ilog2() < *bit_len);
204-
if *kind == TypeKind::Int && (src >> (*bit_len - 1)) != 0 {
214+
if *kind == TypeKind::Int(true) && (src >> (*bit_len - 1)) != 0 {
205215
// `src` is a two's complement representation of a negative value.
206216
let mask = !0u64 >> (64 - *bit_len);
207217
let ones_compl = src ^ mask;
@@ -257,7 +267,7 @@ impl IntrinsicType {
257267
..
258268
} => false,
259269
IntrinsicType {
260-
kind: TypeKind::Int | TypeKind::UInt | TypeKind::Poly,
270+
kind: TypeKind::Int(_) | TypeKind::Poly,
261271
..
262272
} => true,
263273
_ => unimplemented!(),

0 commit comments

Comments
 (0)