Skip to content

Commit 2913908

Browse files
chore: corrected the legal range of values for constrained arguments
such as _MM_FROUND_SAE and _MM_ROUND_MODE
1 parent f7f0d4e commit 2913908

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
use crate::common::constraint::Constraint;
22

3-
pub fn map_constraints(imm_type: &String) -> Option<Constraint> {
3+
pub fn map_constraints(imm_type: &String, imm_width: u32) -> Option<Constraint> {
4+
if imm_width > 0 {
5+
let max: i64 = 2i64.pow(imm_width);
6+
return Some(Constraint::Range(0..max));
7+
}
48
match imm_type.as_str() {
5-
"_MM_FROUND" => Some(Constraint::Range(0..4)),
9+
// Legal values for variables of `_MM_FROUND` type are:
10+
// 8 => (_MM_FROUND_TO_NEAREST_INT |_MM_FROUND_NO_EXC) // round to nearest, and suppress exceptions
11+
// 9 => (_MM_FROUND_TO_NEG_INF |_MM_FROUND_NO_EXC) // round down, and suppress exceptions
12+
// 10 => (_MM_FROUND_TO_POS_INF |_MM_FROUND_NO_EXC) // round up, and suppress exceptions
13+
// 11 => (_MM_FROUND_TO_ZERO |_MM_FROUND_NO_EXC) // truncate, and suppress exceptions
14+
// 4 => _MM_FROUND_CUR_DIRECTION // use MXCSR.RC; see _MM_SET_ROUNDING_MODE
15+
"_MM_FROUND" => Some(Constraint::Set(vec![4, 8, 9, 10, 11])),
616
"_MM_INDEX_SCALE" => Some(Constraint::Set(vec![1, 2, 4, 8])),
717
"_MM_CMPINT" => Some(Constraint::Range(0..8)),
818
"_MM_REDUCE" => Some(Constraint::Range(0..8)),
9-
"_MM_FROUND_SAE" => Some(Constraint::Range(0..8)),
19+
"_MM_FROUND_SAE" => Some(Constraint::Equal(8)),
1020
"_MM_MANTISSA_NORM" => Some(Constraint::Range(0..4)),
1121
"_MM_MANTISSA_NORM_ENUM" => Some(Constraint::Range(0..4)),
1222
"_MM_MANTISSA_SIGN" => Some(Constraint::Range(0..3)),
1323
"_MM_PERM" => Some(Constraint::Range(0..256)),
1424
"_MM_PERM_ENUM" => Some(Constraint::Range(0..256)),
1525
"_MM_CMPINT_ENUM" => Some(Constraint::Range(0..8)),
16-
"_MM_ROUND_MODE" => Some(Constraint::Set(vec![0, 0x2000, 0x4000, 0x6000])),
26+
"_MM_ROUND_MODE" => Some(Constraint::Set(vec![0, 0x2, 0x4, 0x6])),
1727
"_CMP_" => Some(Constraint::Range(0..32)),
1828
_ => None,
1929
}

0 commit comments

Comments
 (0)