Skip to content
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

[RISCV][MC] Name the vector tuple registers. NFC #102726

Merged
merged 2 commits into from
Aug 23, 2024

Conversation

4vtomat
Copy link
Member

@4vtomat 4vtomat commented Aug 10, 2024

Currently vector tuple registers don't have the specified names, the
default name is, for example: VRN3M2 -> V8M2_V10M2_V12M2, however
it's equivalent to v8 in the assembly.

Currently vector tuple registers don't have the specified names, the
default name is, for example: `VRN3M2` -> `V8M2_V10M2_V12M2`, however
it's equivalent to `v8` in the assembly.
@llvmbot
Copy link
Member

llvmbot commented Aug 10, 2024

@llvm/pr-subscribers-backend-risc-v

Author: Brandon Wu (4vtomat)

Changes

Currently vector tuple registers don't have the specified names, the
default name is, for example: VRN3M2 -> V8M2_V10M2_V12M2, however
it's equivalent to v8 in the assembly.


Full diff: https://github.com/llvm/llvm-project/pull/102726.diff

2 Files Affected:

  • (modified) llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp (-13)
  • (modified) llvm/lib/Target/RISCV/RISCVRegisterInfo.td (+13-4)
diff --git a/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp b/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
index 93677433c04405..cca2676de61dd1 100644
--- a/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
+++ b/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
@@ -1008,19 +1008,6 @@ static bool lowerRISCVVMachineInstrToMCInst(const MachineInstr *MI,
       } else if (RISCV::FPR64RegClass.contains(Reg)) {
         Reg = TRI->getSubReg(Reg, RISCV::sub_32);
         assert(Reg && "Superregister does not exist");
-      } else if (RISCV::VRN2M1RegClass.contains(Reg) ||
-                 RISCV::VRN2M2RegClass.contains(Reg) ||
-                 RISCV::VRN2M4RegClass.contains(Reg) ||
-                 RISCV::VRN3M1RegClass.contains(Reg) ||
-                 RISCV::VRN3M2RegClass.contains(Reg) ||
-                 RISCV::VRN4M1RegClass.contains(Reg) ||
-                 RISCV::VRN4M2RegClass.contains(Reg) ||
-                 RISCV::VRN5M1RegClass.contains(Reg) ||
-                 RISCV::VRN6M1RegClass.contains(Reg) ||
-                 RISCV::VRN7M1RegClass.contains(Reg) ||
-                 RISCV::VRN8M1RegClass.contains(Reg)) {
-        Reg = TRI->getSubReg(Reg, RISCV::sub_vrm1_0);
-        assert(Reg && "Subregister does not exist");
       }
 
       MCOp = MCOperand::createReg(Reg);
diff --git a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
index b12634c24622f4..efdf6bebfce301 100644
--- a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
+++ b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
@@ -423,10 +423,12 @@ class IndexSet<int tuple_index, int nf, int lmul, bit isV0 = false> {
 
 // This class returns a list of vector register collections.
 // For example, for NF = 2 and LMUL = 4,
-// it will return
+// L would be:
 //   ([ V8M4, V12M4, V16M4, V20M4, V24M4, V4M4],
 //    [V12M4, V16M4, V20M4, V24M4, V28M4, V8M4])
-//
+// Names are the starting register of each register list,
+// in this example:
+//   ["v8", "v12", "v16", "v20", "v24", "v4"]
 class VRegList<list<dag> LIn, int start, int nf, int lmul, bit isV0> {
   list<dag> L =
     !if(!ge(start, nf),
@@ -440,6 +442,9 @@ class VRegList<list<dag> LIn, int start, int nf, int lmul, bit isV0> {
                 !listsplat("",
                   !size(IndexSet<start, nf, lmul, isV0>.R)))],
           VRegList<LIn, !add(start, 1), nf, lmul, isV0>.L));
+  list<string> Names =
+    !if(!ge(start, nf), [],
+        !foreach(i, IndexSet<start, nf, lmul, isV0>.R, "v" # i));
 }
 
 // Vector registers
@@ -491,12 +496,16 @@ def VCSR : RISCVRegisterClass<[XLenVT], 32,
 
 foreach m = [1, 2, 4] in {
   foreach n = NFList<m>.L in {
+    defvar RegListWOV0 = VRegList<[], 0, n, m, false>;
+    defvar RegListWV0 = VRegList<[], 0, n, m, true>;
     def "VN" # n # "M" # m # "NoV0": RegisterTuples<
                                        SubRegSet<n, m>.L,
-                                       VRegList<[], 0, n, m, false>.L>;
+                                       RegListWOV0.L,
+                                       RegListWOV0.Names>;
     def "VN" # n # "M" # m # "V0" : RegisterTuples<
                                        SubRegSet<n, m>.L,
-                                       VRegList<[], 0, n, m, true>.L>;
+                                       RegListWV0.L,
+                                       RegListWV0.Names>;
   }
 }
 

@4vtomat 4vtomat changed the title [RISCV][MC] Name the vector tuple registers [RISCV][MC] Name the vector tuple registers. NFC Aug 10, 2024
Copy link
Collaborator

@topperc topperc left a comment

Choose a reason for hiding this comment

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

LGTM

@4vtomat 4vtomat merged commit 002ba17 into llvm:main Aug 23, 2024
8 checks passed
@4vtomat 4vtomat deleted the reg_name_for_tuple branch August 23, 2024 13:46
cjdb pushed a commit to cjdb/llvm-project that referenced this pull request Aug 23, 2024
Currently vector tuple registers don't have the specified names, the
default name is, for example: `VRN3M2` -> `V8M2_V10M2_V12M2`, however
it's equivalent to `v8` in the assembly.
5chmidti pushed a commit that referenced this pull request Aug 24, 2024
Currently vector tuple registers don't have the specified names, the
default name is, for example: `VRN3M2` -> `V8M2_V10M2_V12M2`, however
it's equivalent to `v8` in the assembly.
dmpolukhin pushed a commit to dmpolukhin/llvm-project that referenced this pull request Sep 2, 2024
Currently vector tuple registers don't have the specified names, the
default name is, for example: `VRN3M2` -> `V8M2_V10M2_V12M2`, however
it's equivalent to `v8` in the assembly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants