Skip to content

Commit 1a488a9

Browse files
fix: sharpen the IntrinsicType recognition function from_values
1 parent 1ddb2d0 commit 1a488a9

File tree

1 file changed

+30
-38
lines changed
  • crates/intrinsic-test/src/loongarch

1 file changed

+30
-38
lines changed
Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
use super::intrinsic::LoongArchIntrinsicType;
22
use crate::common::cli::Language;
3-
<<<<<<< HEAD
4-
=======
53
use crate::common::intrinsic_helpers::Sign;
6-
>>>>>>> b094de07 (chenj)
74
use crate::common::intrinsic_helpers::{IntrinsicType, IntrinsicTypeDefinition, TypeKind};
85

96
impl IntrinsicTypeDefinition for LoongArchIntrinsicType {
@@ -32,42 +29,37 @@ impl LoongArchIntrinsicType {
3229
/// Accepts X, Y and Z.
3330
/// Returns a `LoongArchType`
3431
pub fn from_values(asm_fmt: &String, data_type: &String) -> Result<Self, String> {
35-
let bit_len = match data_type.as_str() {
36-
"A16QI" => Some(8),
37-
"AM16QI" => Some(8),
38-
"V16QI" => Some(8),
39-
"V32QI" => Some(8),
40-
"A32QI" => Some(8),
41-
"AM32QI" => Some(8),
42-
"V8HI" => Some(16),
43-
"V16HI" => Some(16),
44-
"V4SI" => Some(32),
45-
"V8SI" => Some(32),
46-
"V2DI" => Some(64),
47-
"V4DI" => Some(64),
48-
"UV16QI" => Some(8),
49-
"UV32QI" => Some(8),
50-
"UV8HI" => Some(16),
51-
"UV16HI" => Some(16),
52-
"UV4SI" => Some(32),
53-
"UV8SI" => Some(32),
54-
"UV2DI" => Some(64),
55-
"UV4DI" => Some(64),
56-
"V4SF" => Some(32),
57-
"V8SF" => Some(32),
58-
"V2DF" => Some(64),
59-
"V4DF" => Some(64),
60-
"SI" | "DI" | "USI" | "UDI" | "UQI" | "QI" | "CVPOINTER" | "HI" => None,
32+
let (bit_len, vec_len, type_kind) = match data_type.as_str() {
33+
"A16QI" => (Some(8), Some(16), TypeKind::Int(Sign::Signed)),
34+
"AM16QI" => (Some(8), Some(16), TypeKind::Int(Sign::Signed)),
35+
"V16QI" => (Some(8), Some(16), TypeKind::Int(Sign::Signed)),
36+
"V32QI" => (Some(8), Some(32), TypeKind::Int(Sign::Signed)),
37+
"A32QI" => (Some(8), Some(32), TypeKind::Int(Sign::Signed)),
38+
"AM32QI" => (Some(8), Some(32), TypeKind::Int(Sign::Signed)),
39+
"V8HI" => (Some(16), Some(8), TypeKind::Int(Sign::Signed)),
40+
"V16HI" => (Some(16), Some(16), TypeKind::Int(Sign::Signed)),
41+
"V4SI" => (Some(32), Some(4), TypeKind::Int(Sign::Signed)),
42+
"V8SI" => (Some(32), Some(8), TypeKind::Int(Sign::Signed)),
43+
"V2DI" => (Some(64), Some(2), TypeKind::Int(Sign::Signed)),
44+
"V4DI" => (Some(64), Some(4), TypeKind::Int(Sign::Signed)),
45+
"UV16QI" => (Some(8), Some(16), TypeKind::Int(Sign::Unsigned)),
46+
"UV32QI" => (Some(8), Some(32), TypeKind::Int(Sign::Unsigned)),
47+
"UV8HI" => (Some(16), Some(8), TypeKind::Int(Sign::Unsigned)),
48+
"UV16HI" => (Some(16), Some(16), TypeKind::Int(Sign::Unsigned)),
49+
"UV4SI" => (Some(32), Some(4), TypeKind::Int(Sign::Unsigned)),
50+
"UV8SI" => (Some(32), Some(8), TypeKind::Int(Sign::Unsigned)),
51+
"UV2DI" => (Some(64), Some(2), TypeKind::Int(Sign::Unsigned)),
52+
"UV4DI" => (Some(64), Some(4), TypeKind::Int(Sign::Unsigned)),
53+
"V4SF" => (Some(32), Some(4), TypeKind::Float),
54+
"V8SF" => (Some(32), Some(8), TypeKind::Float),
55+
"V2DF" => (Some(64), Some(2), TypeKind::Float),
56+
"V4DF" => (Some(64), Some(4), TypeKind::Float),
57+
"SI" | "DI" | "USI" | "UDI" | "UQI" | "QI" | "CVPOINTER" | "HI" => {
58+
(None, None, TypeKind::Int(Sign::Signed))
59+
}
6160
_ => panic!("unknown type {data_type} with ASM {asm_fmt}"),
6261
};
6362

64-
let vec_len = match data_type.as_str() {
65-
"SI" | "DI" | "USI" | "UDI" | "UQI" | "QI" | "HI" | => None,
66-
"V32QI" | "V16HI" | "V8SI" | "V4DI" | "UV32QI" | "UV16HI" | "UV8SI" | "UV4DI"
67-
| "V8SF" | "V4DF" => Some(4),
68-
_ => Some(2),
69-
};
70-
7163
Ok(LoongArchIntrinsicType {
7264
data: IntrinsicType {
7365
constant: false,
@@ -76,8 +68,8 @@ impl LoongArchIntrinsicType {
7668
kind: TypeKind::Mask,
7769
bit_len,
7870
vec_len,
79-
simd_len: None
80-
}
71+
simd_len: None,
72+
},
8173
})
8274
}
8375
}

0 commit comments

Comments
 (0)