[llvm] a445474 - [RISCV] Use TImmLeaf for csr_sysreg (#82463)

via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 20 23:04:33 PST 2024


Author: Wang Pengcheng
Date: 2024-02-21T15:04:29+08:00
New Revision: a445474d3fdec2bdaaa42a6dc83c2fb01867076f

URL: https://github.com/llvm/llvm-project/commit/a445474d3fdec2bdaaa42a6dc83c2fb01867076f
DIFF: https://github.com/llvm/llvm-project/commit/a445474d3fdec2bdaaa42a6dc83c2fb01867076f.diff

LOG: [RISCV] Use TImmLeaf for csr_sysreg (#82463)

And use `getTargetConstant` to create operands.

This PR addresses comments after committing #82322.

Added: 
    

Modified: 
    llvm/lib/Target/RISCV/RISCVISelLowering.cpp
    llvm/lib/Target/RISCV/RISCVISelLowering.h
    llvm/lib/Target/RISCV/RISCVInstrInfo.td

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 87f7813c5d5d59..25a27a91a16358 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -11734,14 +11734,14 @@ void RISCVTargetLowering::ReplaceNodeResults(SDNode *N,
     SDValue LoCounter, HiCounter;
     MVT XLenVT = Subtarget.getXLenVT();
     if (N->getOpcode() == ISD::READCYCLECOUNTER) {
-      LoCounter = DAG.getConstant(
+      LoCounter = DAG.getTargetConstant(
           RISCVSysReg::lookupSysRegByName("CYCLE")->Encoding, DL, XLenVT);
-      HiCounter = DAG.getConstant(
+      HiCounter = DAG.getTargetConstant(
           RISCVSysReg::lookupSysRegByName("CYCLEH")->Encoding, DL, XLenVT);
     } else {
-      LoCounter = DAG.getConstant(
+      LoCounter = DAG.getTargetConstant(
           RISCVSysReg::lookupSysRegByName("TIME")->Encoding, DL, XLenVT);
-      HiCounter = DAG.getConstant(
+      HiCounter = DAG.getTargetConstant(
           RISCVSysReg::lookupSysRegByName("TIMEH")->Encoding, DL, XLenVT);
     }
     SDVTList VTs = DAG.getVTList(MVT::i32, MVT::i32, MVT::Other);

diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.h b/llvm/lib/Target/RISCV/RISCVISelLowering.h
index 83b1c68eea61ac..a38463f810270a 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.h
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.h
@@ -127,7 +127,8 @@ enum NodeType : unsigned {
   FMAX, FMIN,
 
   // A read of the 64-bit counter CSR on a 32-bit target (returns (Lo, Hi)).
-  // It takes a chain operand.
+  // It takes a chain operand and another two target constant operands (the
+  // CSR numbers of the low and high parts of the counter).
   READ_COUNTER_WIDE,
 
   // brev8, orc.b, zip, and unzip from Zbb and Zbkb. All operands are i32 or

diff  --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.td b/llvm/lib/Target/RISCV/RISCVInstrInfo.td
index 0d2ffac4883a34..e753c1f1add0c6 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.td
@@ -365,7 +365,7 @@ def CSRSystemRegister : AsmOperandClass {
   let DiagnosticType = "InvalidCSRSystemRegister";
 }
 
-def csr_sysreg : RISCVOp, ImmLeaf<XLenVT, "return isUInt<12>(Imm);"> {
+def csr_sysreg : RISCVOp, TImmLeaf<XLenVT, "return isUInt<12>(Imm);"> {
   let ParserMatchClass = CSRSystemRegister;
   let PrintMethod = "printCSRSystemRegister";
   let DecoderMethod = "decodeUImmOperand<12>";


        


More information about the llvm-commits mailing list