Skip to content

Commit c66f1fd

Browse files
authored
[MC] Use MCRegister::id() to avoid implicit casts. NFC (#168233)
1 parent 35ae515 commit c66f1fd

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

llvm/include/llvm/MC/MCRegisterInfo.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ class LLVM_ABI MCRegisterInfo {
438438
/// number. Returns -1 if there is no equivalent value. The second
439439
/// parameter allows targets to use different numberings for EH info and
440440
/// debugging info.
441-
virtual int64_t getDwarfRegNum(MCRegister RegNum, bool isEH) const;
441+
virtual int64_t getDwarfRegNum(MCRegister Reg, bool isEH) const;
442442

443443
/// Map a dwarf register back to a target register. Returns std::nullopt if
444444
/// there is no mapping.
@@ -450,11 +450,11 @@ class LLVM_ABI MCRegisterInfo {
450450

451451
/// Map a target register to an equivalent SEH register
452452
/// number. Returns LLVM register number if there is no equivalent value.
453-
int getSEHRegNum(MCRegister RegNum) const;
453+
int getSEHRegNum(MCRegister Reg) const;
454454

455455
/// Map a target register to an equivalent CodeView register
456456
/// number.
457-
int getCodeViewRegNum(MCRegister RegNum) const;
457+
int getCodeViewRegNum(MCRegister Reg) const;
458458

459459
regclass_iterator regclass_begin() const { return Classes; }
460460
regclass_iterator regclass_end() const { return Classes+NumClasses; }

llvm/lib/MC/MCInst.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void MCOperand::print(raw_ostream &OS, const MCContext *Ctx) const {
2929
if (Ctx && Ctx->getRegisterInfo())
3030
OS << Ctx->getRegisterInfo()->getName(getReg());
3131
else
32-
OS << getReg();
32+
OS << getReg().id();
3333
} else if (isImm())
3434
OS << "Imm:" << getImm();
3535
else if (isSFPImm())

llvm/lib/MC/MCRegisterInfo.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ ArrayRef<MCPhysReg> MCRegisterInfo::getCachedAliasesOf(MCRegister R) const {
8989
return Aliases;
9090

9191
for (MCRegAliasIteratorImpl It(R, this); It.isValid(); ++It)
92-
Aliases.push_back(*It);
92+
Aliases.push_back((*It).id());
9393

9494
sort(Aliases);
9595
Aliases.erase(unique(Aliases), Aliases.end());
@@ -141,15 +141,15 @@ unsigned MCRegisterInfo::getSubRegIndex(MCRegister Reg,
141141
return 0;
142142
}
143143

144-
int64_t MCRegisterInfo::getDwarfRegNum(MCRegister RegNum, bool isEH) const {
144+
int64_t MCRegisterInfo::getDwarfRegNum(MCRegister Reg, bool isEH) const {
145145
const DwarfLLVMRegPair *M = isEH ? EHL2DwarfRegs : L2DwarfRegs;
146146
unsigned Size = isEH ? EHL2DwarfRegsSize : L2DwarfRegsSize;
147147

148148
if (!M)
149149
return -1;
150-
DwarfLLVMRegPair Key = { RegNum, 0 };
150+
DwarfLLVMRegPair Key = {Reg.id(), 0};
151151
const DwarfLLVMRegPair *I = std::lower_bound(M, M+Size, Key);
152-
if (I == M+Size || I->FromReg != RegNum)
152+
if (I == M + Size || I->FromReg != Reg)
153153
return -1;
154154
// Consumers need to be able to detect -1 and -2, but at various points
155155
// the numbers move between unsigned and signed representations, as well as
@@ -191,20 +191,21 @@ int64_t MCRegisterInfo::getDwarfRegNumFromDwarfEHRegNum(uint64_t RegNum) const {
191191
return RegNum;
192192
}
193193

194-
int MCRegisterInfo::getSEHRegNum(MCRegister RegNum) const {
195-
const DenseMap<MCRegister, int>::const_iterator I = L2SEHRegs.find(RegNum);
196-
if (I == L2SEHRegs.end()) return (int)RegNum;
194+
int MCRegisterInfo::getSEHRegNum(MCRegister Reg) const {
195+
const DenseMap<MCRegister, int>::const_iterator I = L2SEHRegs.find(Reg);
196+
if (I == L2SEHRegs.end())
197+
return (int)Reg.id();
197198
return I->second;
198199
}
199200

200-
int MCRegisterInfo::getCodeViewRegNum(MCRegister RegNum) const {
201+
int MCRegisterInfo::getCodeViewRegNum(MCRegister Reg) const {
201202
if (L2CVRegs.empty())
202203
report_fatal_error("target does not implement codeview register mapping");
203-
const DenseMap<MCRegister, int>::const_iterator I = L2CVRegs.find(RegNum);
204+
const DenseMap<MCRegister, int>::const_iterator I = L2CVRegs.find(Reg);
204205
if (I == L2CVRegs.end())
205-
report_fatal_error("unknown codeview register " + (RegNum < getNumRegs()
206-
? getName(RegNum)
207-
: Twine(RegNum)));
206+
report_fatal_error("unknown codeview register " + (Reg.id() < getNumRegs()
207+
? getName(Reg)
208+
: Twine(Reg.id())));
208209
return I->second;
209210
}
210211

0 commit comments

Comments
 (0)