|
1 | 1 | use crate::common::constraint::Constraint;
|
2 | 2 |
|
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 | + } |
4 | 8 | 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])), |
6 | 16 | "_MM_INDEX_SCALE" => Some(Constraint::Set(vec![1, 2, 4, 8])),
|
7 | 17 | "_MM_CMPINT" => Some(Constraint::Range(0..8)),
|
8 | 18 | "_MM_REDUCE" => Some(Constraint::Range(0..8)),
|
9 |
| - "_MM_FROUND_SAE" => Some(Constraint::Range(0..8)), |
| 19 | + "_MM_FROUND_SAE" => Some(Constraint::Equal(8)), |
10 | 20 | "_MM_MANTISSA_NORM" => Some(Constraint::Range(0..4)),
|
11 | 21 | "_MM_MANTISSA_NORM_ENUM" => Some(Constraint::Range(0..4)),
|
12 | 22 | "_MM_MANTISSA_SIGN" => Some(Constraint::Range(0..3)),
|
13 | 23 | "_MM_PERM" => Some(Constraint::Range(0..256)),
|
14 | 24 | "_MM_PERM_ENUM" => Some(Constraint::Range(0..256)),
|
15 | 25 | "_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])), |
17 | 27 | "_CMP_" => Some(Constraint::Range(0..32)),
|
18 | 28 | _ => None,
|
19 | 29 | }
|
|
0 commit comments