SPARC: Use RegClassByHwMode instead of PointerLikeRegClass#158271
Merged
SPARC: Use RegClassByHwMode instead of PointerLikeRegClass#158271
Conversation
Contributor
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Member
|
@llvm/pr-subscribers-backend-sparc Author: Matt Arsenault (arsenm) ChangesFull diff: https://github.com/llvm/llvm-project/pull/158271.diff 2 Files Affected:
diff --git a/llvm/lib/Target/Sparc/Disassembler/SparcDisassembler.cpp b/llvm/lib/Target/Sparc/Disassembler/SparcDisassembler.cpp
index c3d60f3689e1f..e585e5af42d32 100644
--- a/llvm/lib/Target/Sparc/Disassembler/SparcDisassembler.cpp
+++ b/llvm/lib/Target/Sparc/Disassembler/SparcDisassembler.cpp
@@ -159,14 +159,6 @@ static DecodeStatus DecodeI64RegsRegisterClass(MCInst &Inst, unsigned RegNo,
return DecodeIntRegsRegisterClass(Inst, RegNo, Address, Decoder);
}
-// This is used for the type "ptr_rc", which is either IntRegs or I64Regs
-// depending on SparcRegisterInfo::getPointerRegClass.
-static DecodeStatus DecodePointerLikeRegClass0(MCInst &Inst, unsigned RegNo,
- uint64_t Address,
- const MCDisassembler *Decoder) {
- return DecodeIntRegsRegisterClass(Inst, RegNo, Address, Decoder);
-}
-
static DecodeStatus DecodeFPRegsRegisterClass(MCInst &Inst, unsigned RegNo,
uint64_t Address,
const MCDisassembler *Decoder) {
diff --git a/llvm/lib/Target/Sparc/SparcInstrInfo.td b/llvm/lib/Target/Sparc/SparcInstrInfo.td
index 53972d6c105a4..97e7fd7769edb 100644
--- a/llvm/lib/Target/Sparc/SparcInstrInfo.td
+++ b/llvm/lib/Target/Sparc/SparcInstrInfo.td
@@ -95,10 +95,27 @@ def HasFSMULD : Predicate<"!Subtarget->hasNoFSMULD()">;
// will pick deprecated instructions.
def UseDeprecatedInsts : Predicate<"Subtarget->useV8DeprecatedInsts()">;
+//===----------------------------------------------------------------------===//
+// HwModes Pattern Stuff
+//===----------------------------------------------------------------------===//
+
+defvar SPARC32 = DefaultMode;
+def SPARC64 : HwMode<[Is64Bit]>;
+
//===----------------------------------------------------------------------===//
// Instruction Pattern Stuff
//===----------------------------------------------------------------------===//
+def sparc_ptr_rc : RegClassByHwMode<
+ [SPARC32, SPARC64],
+ [IntRegs, I64Regs]>;
+
+// Both cases can use the same decoder method, so avoid the dispatch
+// by hwmode by setting an explicit DecoderMethod
+def ptr_op : RegisterOperand<sparc_ptr_rc> {
+ let DecoderMethod = "DecodeIntRegsRegisterClass";
+}
+
// FIXME these should have AsmOperandClass.
def uimm3 : PatLeaf<(imm), [{ return isUInt<3>(N->getZExtValue()); }]>;
@@ -178,12 +195,12 @@ def simm13Op : Operand<iPTR> {
def MEMrr : Operand<iPTR> {
let PrintMethod = "printMemOperand";
- let MIOperandInfo = (ops ptr_rc, ptr_rc);
+ let MIOperandInfo = (ops ptr_op, ptr_op);
let ParserMatchClass = SparcMEMrrAsmOperand;
}
def MEMri : Operand<iPTR> {
let PrintMethod = "printMemOperand";
- let MIOperandInfo = (ops ptr_rc, simm13Op);
+ let MIOperandInfo = (ops ptr_op, simm13Op);
let ParserMatchClass = SparcMEMriAsmOperand;
}
|
This was referenced Sep 12, 2025
Comment on lines
+102
to
+103
| defvar SPARC32 = DefaultMode; | ||
| def SPARC64 : HwMode<[Is64Bit]>; |
Contributor
There was a problem hiding this comment.
There isn't a default mode really, so maybe:
Suggested change
| defvar SPARC32 = DefaultMode; | |
| def SPARC64 : HwMode<[Is64Bit]>; | |
| def Mode32Bit : HwMode<[Is32Bit]>; | |
| def Mode64Bit : HwMode<[Is64Bit]>; |
Contributor
Author
There was a problem hiding this comment.
Not sure what you mean, there is a default mode. It's also weirdly baked into the tablegen APIs for it too
Contributor
There was a problem hiding this comment.
I meant default mode in hardware. This is more of a stylistic suggestion.
ba508eb to
b0954df
Compare
a349f1a to
7827021
Compare
b0954df to
480926a
Compare
480926a to
bdfdc33
Compare
0836893 to
34d9fc2
Compare
34d9fc2 to
e7ef891
Compare
da6fc27 to
8bfcdcc
Compare
Base automatically changed from
users/arsenm/codegen/targetinstrinfo-add-regclass-by-hwmode
to
main
September 19, 2025 11:08
e7ef891 to
4ed7550
Compare
This was referenced Sep 19, 2025
This file contains hidden or 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
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.

No description provided.