Skip to content

[RISCV][NFC] Use !range bang operator #66494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 8 additions & 15 deletions llvm/lib/Target/RISCV/RISCVRegisterInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -378,15 +378,9 @@ class IndexSet<int tuple_index, int nf, int lmul, bit isV0 = false> {
!foldl([]<int>,
!if(isV0, [0],
!cond(
!eq(lmul, 1):
[8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31,
1, 2, 3, 4, 5, 6, 7],
!eq(lmul, 2):
[4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3],
!eq(lmul, 4):
[2, 3, 4, 5, 6, 7, 1])),
!eq(lmul, 1): !listconcat(!range(8, 32), !range(1, 8)),
!eq(lmul, 2): !listconcat(!range(4, 16), !range(1, 4)),
!eq(lmul, 4): !listconcat(!range(2, 8), !range(1, 2)))),
L, i,
!listconcat(L,
!if(!le(!mul(!add(i, tuple_index), lmul),
Expand Down Expand Up @@ -416,12 +410,11 @@ 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 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this better?

Copy link
Contributor Author

@wangpc-pp wangpc-pp Sep 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not better, just to align other foreachs below. It may be more uniformed from the style perspective.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to do this kind of rewriting, then there are still many similar codes in this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! IndexSet is rewritten.

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))]>,
Expand All @@ -430,7 +423,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")]>,
Expand All @@ -439,7 +432,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")]>,
Expand Down