Skip to content

Commit c6f8bb1

Browse files
committed
[RISCV] Use TImmLeaf for csr_sysreg
And use `getTargetConstant` to create operands. This PR addresses comments after committing llvm#82322.
1 parent 44b717d commit c6f8bb1

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11734,14 +11734,14 @@ void RISCVTargetLowering::ReplaceNodeResults(SDNode *N,
1173411734
SDValue LoCounter, HiCounter;
1173511735
MVT XLenVT = Subtarget.getXLenVT();
1173611736
if (N->getOpcode() == ISD::READCYCLECOUNTER) {
11737-
LoCounter = DAG.getConstant(
11737+
LoCounter = DAG.getTargetConstant(
1173811738
RISCVSysReg::lookupSysRegByName("CYCLE")->Encoding, DL, XLenVT);
11739-
HiCounter = DAG.getConstant(
11739+
HiCounter = DAG.getTargetConstant(
1174011740
RISCVSysReg::lookupSysRegByName("CYCLEH")->Encoding, DL, XLenVT);
1174111741
} else {
11742-
LoCounter = DAG.getConstant(
11742+
LoCounter = DAG.getTargetConstant(
1174311743
RISCVSysReg::lookupSysRegByName("TIME")->Encoding, DL, XLenVT);
11744-
HiCounter = DAG.getConstant(
11744+
HiCounter = DAG.getTargetConstant(
1174511745
RISCVSysReg::lookupSysRegByName("TIMEH")->Encoding, DL, XLenVT);
1174611746
}
1174711747
SDVTList VTs = DAG.getVTList(MVT::i32, MVT::i32, MVT::Other);

llvm/lib/Target/RISCV/RISCVISelLowering.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ enum NodeType : unsigned {
127127
FMAX, FMIN,
128128

129129
// A read of the 64-bit counter CSR on a 32-bit target (returns (Lo, Hi)).
130-
// It takes a chain operand.
130+
// It takes a chain operand and another two target constant operands (the
131+
// low and high parts of the counter).
131132
READ_COUNTER_WIDE,
132133

133134
// brev8, orc.b, zip, and unzip from Zbb and Zbkb. All operands are i32 or

llvm/lib/Target/RISCV/RISCVInstrInfo.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ def CSRSystemRegister : AsmOperandClass {
365365
let DiagnosticType = "InvalidCSRSystemRegister";
366366
}
367367

368-
def csr_sysreg : RISCVOp, ImmLeaf<XLenVT, "return isUInt<12>(Imm);"> {
368+
def csr_sysreg : RISCVOp, TImmLeaf<XLenVT, "return isUInt<12>(Imm);"> {
369369
let ParserMatchClass = CSRSystemRegister;
370370
let PrintMethod = "printCSRSystemRegister";
371371
let DecoderMethod = "decodeUImmOperand<12>";

0 commit comments

Comments
 (0)