Skip to content

Commit 58133f8

Browse files
Simplify GetLMULValue
Signed-off-by: Mikhail R. Gadelha <[email protected]>
1 parent 0fe1e1c commit 58133f8

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

llvm/lib/Target/RISCV/RISCVSchedSpacemitX60.td

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,24 @@
2020
// LMUL values map to array indices as follows:
2121
// MF8 -> Values[0], MF4 -> Values[1], MF2 -> Values[2], M1 -> Values[3],
2222
// M2 -> Values[4], M4 -> Values[5], M8 -> Values[6]
23-
// The !ge size checks ensure we don't access beyond the array bounds, for cases
24-
// where M8 is not set (e.g., widening operations)
25-
// TableGen will error if an invalid LMUL is passed or if the array is too short
23+
// Shorter lists are allowed, e.g., widening instructions don't work on M8
2624
class GetLMULValue<list<int> Values, string LMUL> {
27-
int c = !cond(
28-
!and(!eq(LMUL, "MF8"), !ge(!size(Values), 1)) : Values[0],
29-
!and(!eq(LMUL, "MF4"), !ge(!size(Values), 2)) : Values[1],
30-
!and(!eq(LMUL, "MF2"), !ge(!size(Values), 3)) : Values[2],
31-
!and(!eq(LMUL, "M1"), !ge(!size(Values), 4)) : Values[3],
32-
!and(!eq(LMUL, "M2"), !ge(!size(Values), 5)) : Values[4],
33-
!and(!eq(LMUL, "M4"), !ge(!size(Values), 6)) : Values[5],
34-
!and(!eq(LMUL, "M8"), !ge(!size(Values), 7)) : Values[6]
25+
int Index = !cond(
26+
!eq(LMUL, "MF8"): 0,
27+
!eq(LMUL, "MF4"): 1,
28+
!eq(LMUL, "MF2"): 2,
29+
!eq(LMUL, "M1"): 3,
30+
!eq(LMUL, "M2"): 4,
31+
!eq(LMUL, "M4"): 5,
32+
!eq(LMUL, "M8"): 6,
3533
);
34+
35+
assert !lt(Index, !size(Values)),
36+
"Missing LMUL value for '" # LMUL # "'. " #
37+
"Expected at least " # !add(Index, 1) # " elements, but got " #
38+
!size(Values) # ".";
39+
40+
int c = Values[Index];
3641
}
3742

3843
// Returns BaseValue for LMUL values before startLMUL, Value for startLMUL,

0 commit comments

Comments
 (0)