[MSP430] Use MCRegister. NFC

This commit is contained in:
Craig Topper 2024-09-29 13:22:39 -07:00
parent c38b5c81bb
commit 2ab9233f4f

View File

@ -101,12 +101,12 @@ class MSP430Operand : public MCParsedAsmOperand {
} Kind;
struct Memory {
unsigned Reg;
MCRegister Reg;
const MCExpr *Offset;
};
union {
const MCExpr *Imm;
unsigned Reg;
MCRegister Reg;
StringRef Tok;
Memory Mem;
};
@ -116,11 +116,11 @@ class MSP430Operand : public MCParsedAsmOperand {
public:
MSP430Operand(StringRef Tok, SMLoc const &S)
: Kind(k_Tok), Tok(Tok), Start(S), End(S) {}
MSP430Operand(KindTy Kind, unsigned Reg, SMLoc const &S, SMLoc const &E)
MSP430Operand(KindTy Kind, MCRegister Reg, SMLoc const &S, SMLoc const &E)
: Kind(Kind), Reg(Reg), Start(S), End(E) {}
MSP430Operand(MCExpr const *Imm, SMLoc const &S, SMLoc const &E)
: Kind(k_Imm), Imm(Imm), Start(S), End(E) {}
MSP430Operand(unsigned Reg, MCExpr const *Expr, SMLoc const &S,
MSP430Operand(MCRegister Reg, MCExpr const *Expr, SMLoc const &S,
SMLoc const &E)
: Kind(k_Mem), Mem({Reg, Expr}), Start(S), End(E) {}
@ -188,7 +188,7 @@ public:
return Reg;
}
void setReg(unsigned RegNo) {
void setReg(MCRegister RegNo) {
assert(Kind == k_Reg && "Invalid access!");
Reg = RegNo;
}
@ -197,9 +197,9 @@ public:
return std::make_unique<MSP430Operand>(Str, S);
}
static std::unique_ptr<MSP430Operand> CreateReg(unsigned RegNum, SMLoc S,
static std::unique_ptr<MSP430Operand> CreateReg(MCRegister Reg, SMLoc S,
SMLoc E) {
return std::make_unique<MSP430Operand>(k_Reg, RegNum, S, E);
return std::make_unique<MSP430Operand>(k_Reg, Reg, S, E);
}
static std::unique_ptr<MSP430Operand> CreateImm(const MCExpr *Val, SMLoc S,
@ -207,20 +207,19 @@ public:
return std::make_unique<MSP430Operand>(Val, S, E);
}
static std::unique_ptr<MSP430Operand> CreateMem(unsigned RegNum,
const MCExpr *Val,
SMLoc S, SMLoc E) {
return std::make_unique<MSP430Operand>(RegNum, Val, S, E);
static std::unique_ptr<MSP430Operand>
CreateMem(MCRegister Reg, const MCExpr *Val, SMLoc S, SMLoc E) {
return std::make_unique<MSP430Operand>(Reg, Val, S, E);
}
static std::unique_ptr<MSP430Operand> CreateIndReg(unsigned RegNum, SMLoc S,
SMLoc E) {
return std::make_unique<MSP430Operand>(k_IndReg, RegNum, S, E);
static std::unique_ptr<MSP430Operand> CreateIndReg(MCRegister Reg, SMLoc S,
SMLoc E) {
return std::make_unique<MSP430Operand>(k_IndReg, Reg, S, E);
}
static std::unique_ptr<MSP430Operand> CreatePostIndReg(unsigned RegNum, SMLoc S,
SMLoc E) {
return std::make_unique<MSP430Operand>(k_PostIndReg, RegNum, S, E);
static std::unique_ptr<MSP430Operand> CreatePostIndReg(MCRegister Reg,
SMLoc S, SMLoc E) {
return std::make_unique<MSP430Operand>(k_PostIndReg, Reg, S, E);
}
SMLoc getStartLoc() const override { return Start; }
@ -545,8 +544,8 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMSP430AsmParser() {
#define GET_MATCHER_IMPLEMENTATION
#include "MSP430GenAsmMatcher.inc"
static unsigned convertGR16ToGR8(unsigned Reg) {
switch (Reg) {
static MCRegister convertGR16ToGR8(MCRegister Reg) {
switch (Reg.id()) {
default:
llvm_unreachable("Unknown GR16 register");
case MSP430::PC: return MSP430::PCB;
@ -575,7 +574,7 @@ unsigned MSP430AsmParser::validateTargetOperandClass(MCParsedAsmOperand &AsmOp,
if (!Op.isReg())
return Match_InvalidOperand;
unsigned Reg = Op.getReg();
MCRegister Reg = Op.getReg();
bool isGR16 =
MSP430MCRegisterClasses[MSP430::GR16RegClassID].contains(Reg);