Skip to content

[X86] Use MCRegister instead of int64_t in X86MCExpr. NFC #106569

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 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2789,7 +2789,7 @@ bool X86AsmParser::parseATTOperand(OperandVector &Operands) {
if (auto *RE = dyn_cast<X86MCExpr>(Expr)) {
// Segment Register. Reset Expr and copy value to register.
Expr = nullptr;
Reg = RE->getRegNo();
Reg = RE->getReg();

// Check the register.
if (Reg == X86::EIZ || Reg == X86::RIZ)
Expand Down Expand Up @@ -3052,7 +3052,7 @@ bool X86AsmParser::ParseMemOperand(unsigned SegReg, const MCExpr *Disp,
return true;

// Check the register.
BaseReg = cast<X86MCExpr>(E)->getRegNo();
BaseReg = cast<X86MCExpr>(E)->getReg();
if (BaseReg == X86::EIZ || BaseReg == X86::RIZ)
return Error(BaseLoc, "eiz and riz can only be used as index registers",
SMRange(BaseLoc, EndLoc));
Expand All @@ -3079,7 +3079,7 @@ bool X86AsmParser::ParseMemOperand(unsigned SegReg, const MCExpr *Disp,
Warning(Loc, "scale factor without index register is ignored");
Scale = 1;
} else { // IndexReg Found.
IndexReg = cast<X86MCExpr>(E)->getRegNo();
IndexReg = cast<X86MCExpr>(E)->getReg();

if (BaseReg == X86::RIP)
return Error(Loc,
Expand Down
14 changes: 7 additions & 7 deletions llvm/lib/Target/X86/MCTargetDesc/X86MCExpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,31 @@ namespace llvm {
class X86MCExpr : public MCTargetExpr {

private:
const int64_t RegNo; // All
const MCRegister Reg; // All

explicit X86MCExpr(int64_t R) : RegNo(R) {}
explicit X86MCExpr(MCRegister R) : Reg(R) {}

public:
/// @name Construction
/// @{

static const X86MCExpr *create(int64_t RegNo, MCContext &Ctx) {
return new (Ctx) X86MCExpr(RegNo);
static const X86MCExpr *create(MCRegister Reg, MCContext &Ctx) {
return new (Ctx) X86MCExpr(Reg);
}

/// @}
/// @name Accessors
/// @{

/// getSubExpr - Get the child of this expression.
int64_t getRegNo() const { return RegNo; }
MCRegister getReg() const { return Reg; }

/// @}

void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override {
if (!MAI || MAI->getAssemblerDialect() == 0)
OS << '%';
OS << X86ATTInstPrinter::getRegisterName(RegNo);
OS << X86ATTInstPrinter::getRegisterName(Reg);
}

bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,
Expand All @@ -61,7 +61,7 @@ class X86MCExpr : public MCTargetExpr {
bool inlineAssignedExpr() const override { return true; }
bool isEqualTo(const MCExpr *X) const override {
if (auto *E = dyn_cast<X86MCExpr>(X))
return getRegNo() == E->getRegNo();
return getReg() == E->getReg();
return false;
}
void visitUsedExpr(MCStreamer &Streamer) const override {}
Expand Down
Loading