Skip to content

Commit 2c77067

Browse files
committed
[ARM] Use MCRegister in more places. NFC
1 parent 255870d commit 2c77067

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3851,11 +3851,11 @@ class ARMOperand : public MCParsedAsmOperand {
38513851
}
38523852

38533853
static std::unique_ptr<ARMOperand>
3854-
CreateVectorListIndexed(unsigned RegNum, unsigned Count, unsigned Index,
3854+
CreateVectorListIndexed(MCRegister Reg, unsigned Count, unsigned Index,
38553855
bool isDoubleSpaced, SMLoc S, SMLoc E,
38563856
ARMAsmParser &Parser) {
38573857
auto Op = std::make_unique<ARMOperand>(k_VectorListIndexed, Parser);
3858-
Op->VectorList.RegNum = RegNum;
3858+
Op->VectorList.RegNum = Reg;
38593859
Op->VectorList.Count = Count;
38603860
Op->VectorList.LaneIndex = Index;
38613861
Op->VectorList.isDoubleSpaced = isDoubleSpaced;
@@ -4568,13 +4568,13 @@ ParseStatus ARMAsmParser::parseCoprocOptionOperand(OperandVector &Operands) {
45684568
// For register list parsing, we need to map from raw GPR register numbering
45694569
// to the enumeration values. The enumeration values aren't sorted by
45704570
// register number due to our using "sp", "lr" and "pc" as canonical names.
4571-
static unsigned getNextRegister(unsigned Reg) {
4571+
static MCRegister getNextRegister(MCRegister Reg) {
45724572
// If this is a GPR, we need to do it manually, otherwise we can rely
45734573
// on the sort ordering of the enumeration since the other reg-classes
45744574
// are sane.
45754575
if (!ARMMCRegisterClasses[ARM::GPRRegClassID].contains(Reg))
45764576
return Reg + 1;
4577-
switch(Reg) {
4577+
switch (Reg.id()) {
45784578
default: llvm_unreachable("Invalid GPR number!");
45794579
case ARM::R0: return ARM::R1; case ARM::R1: return ARM::R2;
45804580
case ARM::R2: return ARM::R3; case ARM::R3: return ARM::R4;
@@ -6982,9 +6982,9 @@ bool ARMAsmParser::CDEConvertDualRegOperand(StringRef Mnemonic,
69826982
if (!Op2.isReg())
69836983
return Error(Op2.getStartLoc(), Op2Diag);
69846984

6985-
unsigned RNext;
6986-
unsigned RPair;
6987-
switch (Op2.getReg()) {
6985+
MCRegister RNext;
6986+
MCRegister RPair;
6987+
switch (Op2.getReg().id()) {
69886988
default:
69896989
return Error(Op2.getStartLoc(), Op2Diag);
69906990
case ARM::R0:
@@ -7459,7 +7459,7 @@ bool ARMAsmParser::parseInstruction(ParseInstructionInfo &Info, StringRef Name,
74597459
// 'false' otherwise. If Reg is in the register list or is HiReg, set
74607460
// 'containsReg' to true.
74617461
static bool checkLowRegisterList(const MCInst &Inst, unsigned OpNo,
7462-
unsigned Reg, unsigned HiReg,
7462+
MCRegister Reg, MCRegister HiReg,
74637463
bool &containsReg) {
74647464
containsReg = false;
74657465
for (unsigned i = OpNo; i < Inst.getNumOperands(); ++i) {
@@ -7475,9 +7475,9 @@ static bool checkLowRegisterList(const MCInst &Inst, unsigned OpNo,
74757475

74767476
// Check if the specified regisgter is in the register list of the inst,
74777477
// starting at the indicated operand number.
7478-
static bool listContainsReg(const MCInst &Inst, unsigned OpNo, unsigned Reg) {
7478+
static bool listContainsReg(const MCInst &Inst, unsigned OpNo, MCRegister Reg) {
74797479
for (unsigned i = OpNo, e = Inst.getNumOperands(); i < e; ++i) {
7480-
unsigned OpReg = Inst.getOperand(i).getReg();
7480+
MCRegister OpReg = Inst.getOperand(i).getReg();
74817481
if (OpReg == Reg)
74827482
return true;
74837483
}
@@ -8061,7 +8061,8 @@ bool ARMAsmParser::validateInstruction(MCInst &Inst,
80618061
.getToken() == "!");
80628062

80638063
bool ListContainsBase;
8064-
if (checkLowRegisterList(Inst, 3, Rn, 0, ListContainsBase) && !isThumbTwo())
8064+
if (checkLowRegisterList(Inst, 3, Rn, MCRegister(), ListContainsBase) &&
8065+
!isThumbTwo())
80658066
return Error(
80668067
Operands[getRegListInd(Operands, MnemonicOpsEndInd)]->getStartLoc(),
80678068
"registers must be in range r0-r7");
@@ -8140,7 +8141,8 @@ bool ARMAsmParser::validateInstruction(MCInst &Inst,
81408141
// switched to the t2 encodings in processInstruction() if necessary.
81418142
case ARM::tPOP: {
81428143
bool ListContainsBase;
8143-
if (checkLowRegisterList(Inst, 2, 0, ARM::PC, ListContainsBase) &&
8144+
if (checkLowRegisterList(Inst, 2, MCRegister(), ARM::PC,
8145+
ListContainsBase) &&
81448146
!isThumbTwo())
81458147
return Error(Operands[MnemonicOpsEndInd]->getStartLoc(),
81468148
"registers must be in range r0-r7 or pc");
@@ -8150,7 +8152,8 @@ bool ARMAsmParser::validateInstruction(MCInst &Inst,
81508152
}
81518153
case ARM::tPUSH: {
81528154
bool ListContainsBase;
8153-
if (checkLowRegisterList(Inst, 2, 0, ARM::LR, ListContainsBase) &&
8155+
if (checkLowRegisterList(Inst, 2, MCRegister(), ARM::LR,
8156+
ListContainsBase) &&
81548157
!isThumbTwo())
81558158
return Error(Operands[MnemonicOpsEndInd]->getStartLoc(),
81568159
"registers must be in range r0-r7 or lr");
@@ -10785,14 +10788,14 @@ bool ARMAsmParser::processInstruction(MCInst &Inst,
1078510788
// doesn't match what tLDMIA can do, we need to use the 32-bit encoding
1078610789
// instead if we're in Thumb2. Otherwise, this should have generated
1078710790
// an error in validateInstruction().
10788-
unsigned Rn = Inst.getOperand(0).getReg();
10791+
MCRegister Rn = Inst.getOperand(0).getReg();
1078910792
bool hasWritebackToken =
1079010793
(static_cast<ARMOperand &>(*Operands[MnemonicOpsEndInd + 1])
1079110794
.isToken() &&
1079210795
static_cast<ARMOperand &>(*Operands[MnemonicOpsEndInd + 1])
1079310796
.getToken() == "!");
1079410797
bool listContainsBase;
10795-
if (checkLowRegisterList(Inst, 3, Rn, 0, listContainsBase) ||
10798+
if (checkLowRegisterList(Inst, 3, Rn, MCRegister(), listContainsBase) ||
1079610799
(!listContainsBase && !hasWritebackToken) ||
1079710800
(listContainsBase && hasWritebackToken)) {
1079810801
// 16-bit encoding isn't sufficient. Switch to the 32-bit version.
@@ -10811,9 +10814,9 @@ bool ARMAsmParser::processInstruction(MCInst &Inst,
1081110814
// If the register list contains any high registers, we need to use
1081210815
// the 32-bit encoding instead if we're in Thumb2. Otherwise, this
1081310816
// should have generated an error in validateInstruction().
10814-
unsigned Rn = Inst.getOperand(0).getReg();
10817+
MCRegister Rn = Inst.getOperand(0).getReg();
1081510818
bool listContainsBase;
10816-
if (checkLowRegisterList(Inst, 4, Rn, 0, listContainsBase)) {
10819+
if (checkLowRegisterList(Inst, 4, Rn, MCRegister(), listContainsBase)) {
1081710820
// 16-bit encoding isn't sufficient. Switch to the 32-bit version.
1081810821
assert(isThumbTwo());
1081910822
Inst.setOpcode(ARM::t2STMIA_UPD);
@@ -10826,7 +10829,7 @@ bool ARMAsmParser::processInstruction(MCInst &Inst,
1082610829
// If the register list contains any high registers, we need to use
1082710830
// the 32-bit encoding instead if we're in Thumb2. Otherwise, this
1082810831
// should have generated an error in validateInstruction().
10829-
if (!checkLowRegisterList(Inst, 2, 0, ARM::PC, listContainsBase))
10832+
if (!checkLowRegisterList(Inst, 2, MCRegister(), ARM::PC, listContainsBase))
1083010833
return false;
1083110834
assert(isThumbTwo());
1083210835
Inst.setOpcode(ARM::t2LDMIA_UPD);
@@ -10837,7 +10840,7 @@ bool ARMAsmParser::processInstruction(MCInst &Inst,
1083710840
}
1083810841
case ARM::tPUSH: {
1083910842
bool listContainsBase;
10840-
if (!checkLowRegisterList(Inst, 2, 0, ARM::LR, listContainsBase))
10843+
if (!checkLowRegisterList(Inst, 2, MCRegister(), ARM::LR, listContainsBase))
1084110844
return false;
1084210845
assert(isThumbTwo());
1084310846
Inst.setOpcode(ARM::t2STMDB_UPD);
@@ -11224,7 +11227,7 @@ unsigned ARMAsmParser::checkTargetMatchPredicate(MCInst &Inst) {
1122411227
continue;
1122511228
}
1122611229

11227-
unsigned Reg = Op.getReg();
11230+
MCRegister Reg = Op.getReg();
1122811231
if ((Reg == ARM::SP) && !hasV8Ops())
1122911232
return Match_RequiresV8;
1123011233
else if (Reg == ARM::PC)

llvm/lib/Target/ARM/Disassembler/ARMDisassembler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1739,7 +1739,7 @@ static DecodeStatus DecodeRegListOperand(MCInst &Inst, unsigned Val,
17391739
DecodeStatus S = MCDisassembler::Success;
17401740

17411741
bool NeedDisjointWriteback = false;
1742-
unsigned WritebackReg = 0;
1742+
MCRegister WritebackReg;
17431743
bool CLRM = false;
17441744
switch (Inst.getOpcode()) {
17451745
default:

0 commit comments

Comments
 (0)