-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[Sparc] Use MCRegister instead of unsigned. NFC #167464
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
Merged
Merged
Conversation
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
Member
|
@llvm/pr-subscribers-backend-sparc Author: Craig Topper (topperc) ChangesFull diff: https://github.com/llvm/llvm-project/pull/167464.diff 1 Files Affected:
diff --git a/llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp b/llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp
index 7c1db3cfcd6b4..ef45d31a029d3 100644
--- a/llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp
+++ b/llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp
@@ -235,7 +235,7 @@ class SparcOperand : public MCParsedAsmOperand {
};
struct RegOp {
- unsigned RegNum;
+ MCRegister Reg;
RegisterKind Kind;
};
@@ -244,8 +244,8 @@ class SparcOperand : public MCParsedAsmOperand {
};
struct MemOp {
- unsigned Base;
- unsigned OffsetReg;
+ MCRegister Base;
+ MCRegister OffsetReg;
const MCExpr *Off;
};
@@ -326,7 +326,7 @@ class SparcOperand : public MCParsedAsmOperand {
MCRegister getReg() const override {
assert((Kind == k_Register) && "Invalid access!");
- return Reg.RegNum;
+ return Reg.Reg;
}
const MCExpr *getImm() const {
@@ -334,12 +334,12 @@ class SparcOperand : public MCParsedAsmOperand {
return Imm.Val;
}
- unsigned getMemBase() const {
+ MCRegister getMemBase() const {
assert((Kind == k_MemoryReg || Kind == k_MemoryImm) && "Invalid access!");
return Mem.Base;
}
- unsigned getMemOffsetReg() const {
+ MCRegister getMemOffsetReg() const {
assert((Kind == k_MemoryReg) && "Invalid access!");
return Mem.OffsetReg;
}
@@ -376,12 +376,16 @@ class SparcOperand : public MCParsedAsmOperand {
void print(raw_ostream &OS, const MCAsmInfo &MAI) const override {
switch (Kind) {
case k_Token: OS << "Token: " << getToken() << "\n"; break;
- case k_Register: OS << "Reg: #" << getReg() << "\n"; break;
+ case k_Register:
+ OS << "Reg: #" << getReg().id() << "\n";
+ break;
case k_Immediate: OS << "Imm: " << getImm() << "\n"; break;
- case k_MemoryReg: OS << "Mem: " << getMemBase() << "+"
- << getMemOffsetReg() << "\n"; break;
+ case k_MemoryReg:
+ OS << "Mem: " << getMemBase().id() << "+" << getMemOffsetReg().id()
+ << "\n";
+ break;
case k_MemoryImm: assert(getMemOff() != nullptr);
- OS << "Mem: " << getMemBase() << "+";
+ OS << "Mem: " << getMemBase().id() << "+";
MAI.printExpr(OS, *getMemOff());
OS << "\n";
break;
@@ -432,7 +436,7 @@ class SparcOperand : public MCParsedAsmOperand {
Inst.addOperand(MCOperand::createReg(getMemBase()));
- assert(getMemOffsetReg() != 0 && "Invalid offset");
+ assert(getMemOffsetReg().isValid() && "Invalid offset");
Inst.addOperand(MCOperand::createReg(getMemOffsetReg()));
}
@@ -480,10 +484,10 @@ class SparcOperand : public MCParsedAsmOperand {
return Op;
}
- static std::unique_ptr<SparcOperand> CreateReg(unsigned RegNum, unsigned Kind,
+ static std::unique_ptr<SparcOperand> CreateReg(MCRegister Reg, unsigned Kind,
SMLoc S, SMLoc E) {
auto Op = std::make_unique<SparcOperand>(k_Register);
- Op->Reg.RegNum = RegNum;
+ Op->Reg.Reg = Reg;
Op->Reg.Kind = (SparcOperand::RegisterKind)Kind;
Op->StartLoc = S;
Op->EndLoc = E;
@@ -540,7 +544,7 @@ class SparcOperand : public MCParsedAsmOperand {
regIdx = Reg - Sparc::I0 + 24;
if (regIdx % 2 || regIdx > 31)
return false;
- Op.Reg.RegNum = IntPairRegs[regIdx / 2];
+ Op.Reg.Reg = IntPairRegs[regIdx / 2];
Op.Reg.Kind = rk_IntPairReg;
return true;
}
@@ -551,7 +555,7 @@ class SparcOperand : public MCParsedAsmOperand {
unsigned regIdx = Reg - Sparc::F0;
if (regIdx % 2 || regIdx > 31)
return false;
- Op.Reg.RegNum = DoubleRegs[regIdx / 2];
+ Op.Reg.Reg = DoubleRegs[regIdx / 2];
Op.Reg.Kind = rk_DoubleReg;
return true;
}
@@ -574,7 +578,7 @@ class SparcOperand : public MCParsedAsmOperand {
Reg = QuadFPRegs[regIdx / 2];
break;
}
- Op.Reg.RegNum = Reg;
+ Op.Reg.Reg = Reg;
Op.Reg.Kind = rk_QuadReg;
return true;
}
@@ -587,13 +591,13 @@ class SparcOperand : public MCParsedAsmOperand {
regIdx = Reg - Sparc::C0;
if (regIdx % 2 || regIdx > 31)
return false;
- Op.Reg.RegNum = CoprocPairRegs[regIdx / 2];
+ Op.Reg.Reg = CoprocPairRegs[regIdx / 2];
Op.Reg.Kind = rk_CoprocPairReg;
return true;
}
static std::unique_ptr<SparcOperand>
- MorphToMEMrr(unsigned Base, std::unique_ptr<SparcOperand> Op) {
+ MorphToMEMrr(MCRegister Base, std::unique_ptr<SparcOperand> Op) {
MCRegister offsetReg = Op->getReg();
Op->Kind = k_MemoryReg;
Op->Mem.Base = Base;
@@ -602,8 +606,8 @@ class SparcOperand : public MCParsedAsmOperand {
return Op;
}
- static std::unique_ptr<SparcOperand>
- CreateMEMr(unsigned Base, SMLoc S, SMLoc E) {
+ static std::unique_ptr<SparcOperand> CreateMEMr(MCRegister Base, SMLoc S,
+ SMLoc E) {
auto Op = std::make_unique<SparcOperand>(k_MemoryReg);
Op->Mem.Base = Base;
Op->Mem.OffsetReg = Sparc::G0; // always 0
@@ -614,11 +618,11 @@ class SparcOperand : public MCParsedAsmOperand {
}
static std::unique_ptr<SparcOperand>
- MorphToMEMri(unsigned Base, std::unique_ptr<SparcOperand> Op) {
+ MorphToMEMri(MCRegister Base, std::unique_ptr<SparcOperand> Op) {
const MCExpr *Imm = Op->getImm();
Op->Kind = k_MemoryImm;
Op->Mem.Base = Base;
- Op->Mem.OffsetReg = 0;
+ Op->Mem.OffsetReg = MCRegister();
Op->Mem.Off = Imm;
return Op;
}
|
s-barannikov
approved these changes
Nov 11, 2025
Contributor
s-barannikov
left a comment
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.
No description provided.