Skip to content

Commit 9a040ed

Browse files
jayfoadDanielCChen
authored andcommitted
[AMDGPU] Rewrite RegSeqNames using !foreach. NFC. (llvm#111994)
This reduces the total number of TableGen records produced by AMDGPU.td by about 6%.
1 parent 6f64e9e commit 9a040ed

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

llvm/lib/Target/AMDGPU/SIRegisterInfo.td

+4-9
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,10 @@ class getSubRegs<int size> {
8888

8989
// Generates list of sequential register tuple names.
9090
// E.g. RegSeq<3,2,2,"s">.ret -> [ "s[0:1]", "s[2:3]" ]
91-
class RegSeqNames<int last_reg, int stride, int size, string prefix,
92-
int start = 0> {
93-
int next = !add(start, stride);
94-
int end_reg = !add(start, size, -1);
95-
list<string> ret =
96-
!if(!le(end_reg, last_reg),
97-
!listconcat([prefix # "[" # start # ":" # end_reg # "]"],
98-
RegSeqNames<last_reg, stride, size, prefix, next>.ret),
99-
[]);
91+
class RegSeqNames<int last_reg, int stride, int size, string prefix> {
92+
defvar numtuples = !div(!sub(!add(last_reg, stride, 1), size), stride);
93+
defvar range = !range(0, !mul(numtuples, stride), stride);
94+
list<string> ret = !foreach(n, range, prefix # "[" # n # ":" # !add(n, size, -1) # "]");
10095
}
10196

10297
// Generates list of dags for register tuples.

0 commit comments

Comments
 (0)