-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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] Use TImmLeaf for csr_sysreg #82463
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
And use `getTargetConstant` to create operands. This PR addresses comments after committing llvm#82322.
@llvm/pr-subscribers-backend-risc-v Author: Wang Pengcheng (wangpc-pp) ChangesAnd use This PR addresses comments after committing #82322. Full diff: https://github.com/llvm/llvm-project/pull/82463.diff 3 Files Affected:
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..407206a0b96e10 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
+ // 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>";
|
topperc
reviewed
Feb 21, 2024
topperc
approved these changes
Feb 21, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
And use
getTargetConstant
to create operands.This PR addresses comments after committing #82322.