[llvm] [AMDGPU] Rewrite RegSeqNames using !foreach. NFC. (PR #111994)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 11 05:53:11 PDT 2024


https://github.com/jayfoad created https://github.com/llvm/llvm-project/pull/111994

This reduces the total number of TableGen records produced by AMDGPU.td
by about 6%.


>From ed465c18f3e3c119781790bcd691a8e469353e66 Mon Sep 17 00:00:00 2001
From: Jay Foad <jay.foad at amd.com>
Date: Fri, 11 Oct 2024 13:43:05 +0100
Subject: [PATCH] [AMDGPU] Rewrite RegSeqNames using !foreach. NFC.

This reduces the total number of TableGen records produced by AMDGPU.td
by about 6%.
---
 llvm/lib/Target/AMDGPU/SIRegisterInfo.td | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/SIRegisterInfo.td b/llvm/lib/Target/AMDGPU/SIRegisterInfo.td
index ef9adde13348fe..3556f6a95b521e 100644
--- a/llvm/lib/Target/AMDGPU/SIRegisterInfo.td
+++ b/llvm/lib/Target/AMDGPU/SIRegisterInfo.td
@@ -88,15 +88,10 @@ class getSubRegs<int size> {
 
 // Generates list of sequential register tuple names.
 // E.g. RegSeq<3,2,2,"s">.ret -> [ "s[0:1]", "s[2:3]" ]
-class RegSeqNames<int last_reg, int stride, int size, string prefix,
-                  int start = 0> {
-  int next = !add(start, stride);
-  int end_reg = !add(start, size, -1);
-  list<string> ret =
-    !if(!le(end_reg, last_reg),
-        !listconcat([prefix # "[" # start # ":" # end_reg # "]"],
-                    RegSeqNames<last_reg, stride, size, prefix, next>.ret),
-                    []);
+class RegSeqNames<int last_reg, int stride, int size, string prefix> {
+  defvar numtuples = !div(!sub(!add(last_reg, stride, 1), size), stride);
+  defvar range = !range(0, !mul(numtuples, stride), stride);
+  list<string> ret = !foreach(n, range, prefix # "[" # n # ":" # !add(n, size, -1) # "]");
 }
 
 // Generates list of dags for register tuples.



More information about the llvm-commits mailing list