[llvm] [RISCV][NFC] Use !range bang operator (PR #66494)
Wang Pengcheng via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 26 21:10:12 PDT 2023
https://github.com/wangpc-pp updated https://github.com/llvm/llvm-project/pull/66494
>From d2cea80d01145b092bbd3ebed8ab08b909e3c738 Mon Sep 17 00:00:00 2001
From: wangpc <wangpengcheng.pp at bytedance.com>
Date: Fri, 15 Sep 2023 18:51:07 +0800
Subject: [PATCH 1/2] [RISCV][NFC] Use !range bang operator
To simplify some code.
This PR is stacked on #66489.
---
llvm/lib/Target/RISCV/RISCVRegisterInfo.td | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
index 1a6145f92908134..b639a33e3a0bc49 100644
--- a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
+++ b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
@@ -350,7 +350,7 @@ class NFList<int lmul> {
// Generate [start, end) SubRegIndex list.
class SubRegSet<int nf, int lmul> {
list<SubRegIndex> L = !foldl([]<SubRegIndex>,
- [0, 1, 2, 3, 4, 5, 6, 7],
+ !range(0, 8),
AccList, i,
!listconcat(AccList,
!if(!lt(i, nf),
@@ -420,8 +420,7 @@ foreach Index = 0-31 in {
def V#Index : RISCVReg<Index, "v"#Index>, DwarfRegNum<[!add(Index, 96)]>;
}
-foreach Index = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22,
- 24, 26, 28, 30] in {
+foreach Index = !range(0, 32, 2) in {
def V#Index#M2 : RISCVRegWithSubRegs<Index, "v"#Index,
[!cast<Register>("V"#Index),
!cast<Register>("V"#!add(Index, 1))]>,
@@ -430,7 +429,7 @@ foreach Index = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22,
}
}
-foreach Index = [0, 4, 8, 12, 16, 20, 24, 28] in {
+foreach Index = !range(0, 32, 4) in {
def V#Index#M4 : RISCVRegWithSubRegs<Index, "v"#Index,
[!cast<Register>("V"#Index#"M2"),
!cast<Register>("V"#!add(Index, 2)#"M2")]>,
@@ -439,7 +438,7 @@ foreach Index = [0, 4, 8, 12, 16, 20, 24, 28] in {
}
}
-foreach Index = [0, 8, 16, 24] in {
+foreach Index = !range(0, 32, 8) in {
def V#Index#M8 : RISCVRegWithSubRegs<Index, "v"#Index,
[!cast<Register>("V"#Index#"M4"),
!cast<Register>("V"#!add(Index, 4)#"M4")]>,
>From 33dec911d7e740477384c32050802b0b899b99c9 Mon Sep 17 00:00:00 2001
From: wangpc <wangpengcheng.pp at bytedance.com>
Date: Wed, 27 Sep 2023 11:28:07 +0800
Subject: [PATCH 2/2] Replace 0-31 with !range to align others
---
llvm/lib/Target/RISCV/RISCVRegisterInfo.td | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
index b639a33e3a0bc49..89e64ba6cdb0438 100644
--- a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
+++ b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
@@ -416,7 +416,7 @@ class VRegList<list<dag> LIn, int start, int nf, int lmul, bit isV0> {
}
// Vector registers
-foreach Index = 0-31 in {
+foreach Index = !range(0, 32, 1) in {
def V#Index : RISCVReg<Index, "v"#Index>, DwarfRegNum<[!add(Index, 96)]>;
}
More information about the llvm-commits
mailing list