[llvm] 77313dd - [RISCV] Use PseudoInstExpansion for PseudoReadVLENB and PseudoReadVL. NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 6 09:33:13 PDT 2023
Author: Craig Topper
Date: 2023-04-06T09:33:01-07:00
New Revision: 77313ddfb211ba854ecc2bb042d4847e82925604
URL: https://github.com/llvm/llvm-project/commit/77313ddfb211ba854ecc2bb042d4847e82925604
DIFF: https://github.com/llvm/llvm-project/commit/77313ddfb211ba854ecc2bb042d4847e82925604.diff
LOG: [RISCV] Use PseudoInstExpansion for PseudoReadVLENB and PseudoReadVL. NFC
This lets tablegen generated the code and avoids a string lookup
of the CSR name at runtime.
Added:
Modified:
llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
llvm/lib/Target/RISCV/RISCVSystemOperands.td
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
index 7a51cba39f4c6..f528c199e050e 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
@@ -5427,12 +5427,14 @@ let Predicates = [HasVInstructions] in {
let hasSideEffects = 0, mayLoad = 0, mayStore = 0, isCodeGenOnly = 1 in {
def PseudoReadVLENB : Pseudo<(outs GPR:$rd), (ins),
[(set GPR:$rd, (riscv_read_vlenb))]>,
+ PseudoInstExpansion<(CSRRS GPR:$rd, SysRegVLENB.Encoding, X0)>,
Sched<[WriteRdVLENB]>;
}
let hasSideEffects = 0, mayLoad = 0, mayStore = 0, isCodeGenOnly = 1,
Uses = [VL] in
-def PseudoReadVL : Pseudo<(outs GPR:$rd), (ins), []>;
+def PseudoReadVL : Pseudo<(outs GPR:$rd), (ins), []>,
+ PseudoInstExpansion<(CSRRS GPR:$rd, SysRegVL.Encoding, X0)>;
foreach lmul = MxList in {
foreach nf = NFSet<lmul>.L in {
diff --git a/llvm/lib/Target/RISCV/RISCVMCInstLower.cpp b/llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
index da7b03c3a5419..4cd20f04a501c 100644
--- a/llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
+++ b/llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
@@ -253,18 +253,6 @@ bool llvm::lowerRISCVMachineInstrToMCInst(const MachineInstr *MI, MCInst &OutMI,
}
break;
}
- case RISCV::PseudoReadVLENB:
- OutMI.setOpcode(RISCV::CSRRS);
- OutMI.addOperand(MCOperand::createImm(
- RISCVSysReg::lookupSysRegByName("VLENB")->Encoding));
- OutMI.addOperand(MCOperand::createReg(RISCV::X0));
- break;
- case RISCV::PseudoReadVL:
- OutMI.setOpcode(RISCV::CSRRS);
- OutMI.addOperand(
- MCOperand::createImm(RISCVSysReg::lookupSysRegByName("VL")->Encoding));
- OutMI.addOperand(MCOperand::createReg(RISCV::X0));
- break;
}
return false;
}
diff --git a/llvm/lib/Target/RISCV/RISCVSystemOperands.td b/llvm/lib/Target/RISCV/RISCVSystemOperands.td
index b9aa25b321b08..524ed0b45ec10 100644
--- a/llvm/lib/Target/RISCV/RISCVSystemOperands.td
+++ b/llvm/lib/Target/RISCV/RISCVSystemOperands.td
@@ -352,7 +352,7 @@ def : SysReg<"vstart", 0x008>;
def : SysReg<"vxsat", 0x009>;
def : SysReg<"vxrm", 0x00A>;
def : SysReg<"vcsr", 0x00F>;
-def : SysReg<"vl", 0xC20>;
+def SysRegVL : SysReg<"vl", 0xC20>;
def : SysReg<"vtype", 0xC21>;
def SysRegVLENB: SysReg<"vlenb", 0xC22>;
More information about the llvm-commits
mailing list