[llvm] [X86] Use MCRegister instead of int64_t in X86MCExpr. NFC (PR #106569)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 29 08:24:36 PDT 2024


https://github.com/topperc created https://github.com/llvm/llvm-project/pull/106569

None

>From 26eee8c978664deeefd3e1d15a899703036e0ae8 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Thu, 29 Aug 2024 08:23:54 -0700
Subject: [PATCH] [X86] Use MCRegister instead of int64_t in X86MCExpr. NFC

---
 llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp |  6 +++---
 llvm/lib/Target/X86/MCTargetDesc/X86MCExpr.h   | 14 +++++++-------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
index 864b7d8e769ab1..2b6b0ad16bcf76 100644
--- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -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)
@@ -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));
@@ -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,
diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86MCExpr.h b/llvm/lib/Target/X86/MCTargetDesc/X86MCExpr.h
index c159d30194cc64..37e15193b04357 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86MCExpr.h
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86MCExpr.h
@@ -26,16 +26,16 @@ 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);
   }
 
   /// @}
@@ -43,14 +43,14 @@ class X86MCExpr : public MCTargetExpr {
   /// @{
 
   /// 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,
@@ -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 {}



More information about the llvm-commits mailing list