[llvm] d793168 - MIPS: Rename MipsMCExpr::MEK_ to Mips::S_
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 15 18:04:28 PDT 2025
Author: Fangrui Song
Date: 2025-06-15T18:04:23-07:00
New Revision: d793168e3b1a0343debfdfe143d7fb4127f9038c
URL: https://github.com/llvm/llvm-project/commit/d793168e3b1a0343debfdfe143d7fb4127f9038c
DIFF: https://github.com/llvm/llvm-project/commit/d793168e3b1a0343debfdfe143d7fb4127f9038c.diff
LOG: MIPS: Rename MipsMCExpr::MEK_ to Mips::S_
Prepare for removing MipsMCExpr. Adopt the newer naming convention (S_)
used by AMDGPU/WebAssembly/VE/M68k/PowerPC/LoongArch/RISCV.
Added:
Modified:
llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
llvm/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp
llvm/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.h
llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp
llvm/lib/Target/Mips/MCTargetDesc/MipsMCExpr.cpp
llvm/lib/Target/Mips/MCTargetDesc/MipsMCExpr.h
llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
llvm/lib/Target/Mips/MipsAsmPrinter.cpp
llvm/lib/Target/Mips/MipsMCInstLower.cpp
llvm/lib/Target/Mips/MipsTargetObjectFile.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
index 76bbdef7ae22d..8d9c3a96b32a1 100644
--- a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
+++ b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
@@ -9,7 +9,7 @@
#include "MCTargetDesc/MipsABIFlagsSection.h"
#include "MCTargetDesc/MipsABIInfo.h"
#include "MCTargetDesc/MipsBaseInfo.h"
-#include "MCTargetDesc/MipsMCExpr.h"
+#include "MCTargetDesc/MipsMCAsmInfo.h"
#include "MCTargetDesc/MipsMCTargetDesc.h"
#include "MCTargetDesc/MipsTargetStreamer.h"
#include "TargetInfo/MipsTargetInfo.h"
@@ -2964,10 +2964,10 @@ bool MipsAsmParser::loadAndAddSymbolAddress(const MCExpr *SymExpr,
if ((DstReg == Mips::T9 || DstReg == Mips::T9_64) && !UseSrcReg &&
Res.getConstant() == 0 && !IsLocalSym) {
if (UseXGOT) {
- const MCExpr *CallHiExpr = MipsMCExpr::create(MipsMCExpr::MEK_CALL_HI16,
- SymExpr, getContext());
- const MCExpr *CallLoExpr = MipsMCExpr::create(MipsMCExpr::MEK_CALL_LO16,
- SymExpr, getContext());
+ const MCExpr *CallHiExpr =
+ MipsMCExpr::create(Mips::S_CALL_HI16, SymExpr, getContext());
+ const MCExpr *CallLoExpr =
+ MipsMCExpr::create(Mips::S_CALL_LO16, SymExpr, getContext());
TOut.emitRX(Mips::LUi, DstReg, MCOperand::createExpr(CallHiExpr), IDLoc,
STI);
TOut.emitRRR(IsPtr64 ? Mips::DADDu : Mips::ADDu, DstReg, DstReg, GPReg,
@@ -2976,7 +2976,7 @@ bool MipsAsmParser::loadAndAddSymbolAddress(const MCExpr *SymExpr,
MCOperand::createExpr(CallLoExpr), IDLoc, STI);
} else {
const MCExpr *CallExpr =
- MipsMCExpr::create(MipsMCExpr::MEK_GOT_CALL, SymExpr, getContext());
+ MipsMCExpr::create(Mips::S_GOT_CALL, SymExpr, getContext());
TOut.emitRRX(IsPtr64 ? Mips::LD : Mips::LW, DstReg, GPReg,
MCOperand::createExpr(CallExpr), IDLoc, STI);
}
@@ -3009,9 +3009,9 @@ bool MipsAsmParser::loadAndAddSymbolAddress(const MCExpr *SymExpr,
// this happens then the last instruction must use $rd as the result
// register.
const MCExpr *CallHiExpr =
- MipsMCExpr::create(MipsMCExpr::MEK_GOT_HI16, SymExpr, getContext());
- const MCExpr *CallLoExpr = MipsMCExpr::create(
- Res.getAddSym(), MipsMCExpr::MEK_GOT_LO16, getContext());
+ MipsMCExpr::create(Mips::S_GOT_HI16, SymExpr, getContext());
+ const MCExpr *CallLoExpr =
+ MipsMCExpr::create(Res.getAddSym(), Mips::S_GOT_LO16, getContext());
TOut.emitRX(Mips::LUi, TmpReg, MCOperand::createExpr(CallHiExpr), IDLoc,
STI);
@@ -3042,8 +3042,8 @@ bool MipsAsmParser::loadAndAddSymbolAddress(const MCExpr *SymExpr,
// The daddiu's marked with a '>' may be omitted if they are redundant. If
// this happens then the last instruction must use $rd as the result
// register.
- GotExpr = MipsMCExpr::create(Res.getAddSym(), MipsMCExpr::MEK_GOT_DISP,
- getContext());
+ GotExpr =
+ MipsMCExpr::create(Res.getAddSym(), Mips::S_GOT_DISP, getContext());
if (Res.getConstant() != 0) {
// Symbols fully resolve with just the %got_disp(symbol) but we
// must still account for any offset to the symbol for
@@ -3070,15 +3070,14 @@ bool MipsAsmParser::loadAndAddSymbolAddress(const MCExpr *SymExpr,
// this happens then the last instruction must use $rd as the result
// register.
if (IsLocalSym) {
- GotExpr =
- MipsMCExpr::create(MipsMCExpr::MEK_GOT, SymExpr, getContext());
- LoExpr = MipsMCExpr::create(MipsMCExpr::MEK_LO, SymExpr, getContext());
+ GotExpr = MipsMCExpr::create(Mips::S_GOT, SymExpr, getContext());
+ LoExpr = MipsMCExpr::create(Mips::S_LO, SymExpr, getContext());
} else {
// External symbols fully resolve the symbol with just the %got(symbol)
// but we must still account for any offset to the symbol for
// expressions like symbol+8.
- GotExpr = MipsMCExpr::create(Res.getAddSym(), MipsMCExpr::MEK_GOT,
- getContext());
+ GotExpr =
+ MipsMCExpr::create(Res.getAddSym(), Mips::S_GOT, getContext());
if (Res.getConstant() != 0)
LoExpr = MCConstantExpr::create(Res.getConstant(), getContext());
}
@@ -3099,9 +3098,9 @@ bool MipsAsmParser::loadAndAddSymbolAddress(const MCExpr *SymExpr,
}
const MipsMCExpr *HiExpr =
- MipsMCExpr::create(MipsMCExpr::MEK_HI, SymExpr, getContext());
+ MipsMCExpr::create(Mips::S_HI, SymExpr, getContext());
const MipsMCExpr *LoExpr =
- MipsMCExpr::create(MipsMCExpr::MEK_LO, SymExpr, getContext());
+ MipsMCExpr::create(Mips::S_LO, SymExpr, getContext());
// This is the 64-bit symbol address expansion.
if (ABI.ArePtrs64bit() && isGP64bit()) {
@@ -3113,9 +3112,9 @@ bool MipsAsmParser::loadAndAddSymbolAddress(const MCExpr *SymExpr,
// source register.
const MipsMCExpr *HighestExpr =
- MipsMCExpr::create(MipsMCExpr::MEK_HIGHEST, SymExpr, getContext());
+ MipsMCExpr::create(Mips::S_HIGHEST, SymExpr, getContext());
const MipsMCExpr *HigherExpr =
- MipsMCExpr::create(MipsMCExpr::MEK_HIGHER, SymExpr, getContext());
+ MipsMCExpr::create(Mips::S_HIGHER, SymExpr, getContext());
bool RdRegIsRsReg =
UseSrcReg &&
@@ -3314,7 +3313,7 @@ bool MipsAsmParser::emitPartialAddress(MipsTargetStreamer &TOut, SMLoc IDLoc,
if(IsPicEnabled) {
const MCExpr *GotSym = MCSymbolRefExpr::create(Sym, getContext());
const MipsMCExpr *GotExpr =
- MipsMCExpr::create(MipsMCExpr::MEK_GOT, GotSym, getContext());
+ MipsMCExpr::create(Mips::S_GOT, GotSym, getContext());
if(isABI_O32() || isABI_N32()) {
TOut.emitRRX(Mips::LW, ATReg, GPReg, MCOperand::createExpr(GotExpr),
@@ -3326,7 +3325,7 @@ bool MipsAsmParser::emitPartialAddress(MipsTargetStreamer &TOut, SMLoc IDLoc,
} else { //!IsPicEnabled
const MCExpr *HiSym = MCSymbolRefExpr::create(Sym, getContext());
const MipsMCExpr *HiExpr =
- MipsMCExpr::create(MipsMCExpr::MEK_HI, HiSym, getContext());
+ MipsMCExpr::create(Mips::S_HI, HiSym, getContext());
// FIXME: This is technically correct but gives a
diff erent result to gas,
// but gas is incomplete there (it has a fixme noting it doesn't work with
@@ -3339,10 +3338,10 @@ bool MipsAsmParser::emitPartialAddress(MipsTargetStreamer &TOut, SMLoc IDLoc,
} else { //isABI_N64()
const MCExpr *HighestSym = MCSymbolRefExpr::create(Sym, getContext());
const MipsMCExpr *HighestExpr =
- MipsMCExpr::create(MipsMCExpr::MEK_HIGHEST, HighestSym, getContext());
+ MipsMCExpr::create(Mips::S_HIGHEST, HighestSym, getContext());
const MCExpr *HigherSym = MCSymbolRefExpr::create(Sym, getContext());
const MipsMCExpr *HigherExpr =
- MipsMCExpr::create(MipsMCExpr::MEK_HIGHER, HigherSym, getContext());
+ MipsMCExpr::create(Mips::S_HIGHER, HigherSym, getContext());
TOut.emitRX(Mips::LUi, ATReg, MCOperand::createExpr(HighestExpr), IDLoc,
STI);
@@ -3430,7 +3429,7 @@ bool MipsAsmParser::expandLoadSingleImmToFPR(MCInst &Inst, SMLoc IDLoc,
MCSymbol *Sym = getContext().createTempSymbol();
const MCExpr *LoSym = MCSymbolRefExpr::create(Sym, getContext());
const MipsMCExpr *LoExpr =
- MipsMCExpr::create(MipsMCExpr::MEK_LO, LoSym, getContext());
+ MipsMCExpr::create(Mips::S_LO, LoSym, getContext());
getStreamer().switchSection(ReadOnlySection);
getStreamer().emitLabel(Sym, IDLoc);
@@ -3481,7 +3480,7 @@ bool MipsAsmParser::expandLoadDoubleImmToGPR(MCInst &Inst, SMLoc IDLoc,
MCSymbol *Sym = getContext().createTempSymbol();
const MCExpr *LoSym = MCSymbolRefExpr::create(Sym, getContext());
const MipsMCExpr *LoExpr =
- MipsMCExpr::create(MipsMCExpr::MEK_LO, LoSym, getContext());
+ MipsMCExpr::create(Mips::S_LO, LoSym, getContext());
getStreamer().switchSection(ReadOnlySection);
getStreamer().emitLabel(Sym, IDLoc);
@@ -3562,7 +3561,7 @@ bool MipsAsmParser::expandLoadDoubleImmToFPR(MCInst &Inst, bool Is64FPU,
MCSymbol *Sym = getContext().createTempSymbol();
const MCExpr *LoSym = MCSymbolRefExpr::create(Sym, getContext());
const MipsMCExpr *LoExpr =
- MipsMCExpr::create(MipsMCExpr::MEK_LO, LoSym, getContext());
+ MipsMCExpr::create(Mips::S_LO, LoSym, getContext());
getStreamer().switchSection(ReadOnlySection);
getStreamer().emitLabel(Sym, IDLoc);
@@ -3785,15 +3784,15 @@ void MipsAsmParser::expandMem16Inst(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
// sw $8, %lo(sym)($at)
const MCExpr *OffExpr = OffsetOp.getExpr();
MCOperand LoOperand = MCOperand::createExpr(
- MipsMCExpr::create(MipsMCExpr::MEK_LO, OffExpr, getContext()));
+ MipsMCExpr::create(Mips::S_LO, OffExpr, getContext()));
MCOperand HiOperand = MCOperand::createExpr(
- MipsMCExpr::create(MipsMCExpr::MEK_HI, OffExpr, getContext()));
+ MipsMCExpr::create(Mips::S_HI, OffExpr, getContext()));
if (ABI.IsN64()) {
MCOperand HighestOperand = MCOperand::createExpr(
- MipsMCExpr::create(MipsMCExpr::MEK_HIGHEST, OffExpr, getContext()));
+ MipsMCExpr::create(Mips::S_HIGHEST, OffExpr, getContext()));
MCOperand HigherOperand = MCOperand::createExpr(
- MipsMCExpr::create(MipsMCExpr::MEK_HIGHER, OffExpr, getContext()));
+ MipsMCExpr::create(Mips::S_HIGHER, OffExpr, getContext()));
TOut.emitRX(Mips::LUi, TmpReg, HighestOperand, IDLoc, STI);
TOut.emitRRX(Mips::DADDiu, TmpReg, TmpReg, HigherOperand, IDLoc, STI);
@@ -6355,31 +6354,31 @@ MCRegister MipsAsmParser::getReg(int RC, int RegNo) {
const MCExpr *MipsAsmParser::parseRelocExpr() {
auto getOp = [](StringRef Op) {
return StringSwitch<MipsMCExpr::Specifier>(Op)
- .Case("call16", MipsMCExpr::MEK_GOT_CALL)
- .Case("call_hi", MipsMCExpr::MEK_CALL_HI16)
- .Case("call_lo", MipsMCExpr::MEK_CALL_LO16)
- .Case("dtprel_hi", MipsMCExpr::MEK_DTPREL_HI)
- .Case("dtprel_lo", MipsMCExpr::MEK_DTPREL_LO)
- .Case("got", MipsMCExpr::MEK_GOT)
- .Case("got_disp", MipsMCExpr::MEK_GOT_DISP)
- .Case("got_hi", MipsMCExpr::MEK_GOT_HI16)
- .Case("got_lo", MipsMCExpr::MEK_GOT_LO16)
- .Case("got_ofst", MipsMCExpr::MEK_GOT_OFST)
- .Case("got_page", MipsMCExpr::MEK_GOT_PAGE)
- .Case("gottprel", MipsMCExpr::MEK_GOTTPREL)
- .Case("gp_rel", MipsMCExpr::MEK_GPREL)
- .Case("hi", MipsMCExpr::MEK_HI)
- .Case("higher", MipsMCExpr::MEK_HIGHER)
- .Case("highest", MipsMCExpr::MEK_HIGHEST)
- .Case("lo", MipsMCExpr::MEK_LO)
- .Case("neg", MipsMCExpr::MEK_NEG)
- .Case("pcrel_hi", MipsMCExpr::MEK_PCREL_HI16)
- .Case("pcrel_lo", MipsMCExpr::MEK_PCREL_LO16)
- .Case("tlsgd", MipsMCExpr::MEK_TLSGD)
- .Case("tlsldm", MipsMCExpr::MEK_TLSLDM)
- .Case("tprel_hi", MipsMCExpr::MEK_TPREL_HI)
- .Case("tprel_lo", MipsMCExpr::MEK_TPREL_LO)
- .Default(MipsMCExpr::MEK_None);
+ .Case("call16", Mips::S_GOT_CALL)
+ .Case("call_hi", Mips::S_CALL_HI16)
+ .Case("call_lo", Mips::S_CALL_LO16)
+ .Case("dtprel_hi", Mips::S_DTPREL_HI)
+ .Case("dtprel_lo", Mips::S_DTPREL_LO)
+ .Case("got", Mips::S_GOT)
+ .Case("got_disp", Mips::S_GOT_DISP)
+ .Case("got_hi", Mips::S_GOT_HI16)
+ .Case("got_lo", Mips::S_GOT_LO16)
+ .Case("got_ofst", Mips::S_GOT_OFST)
+ .Case("got_page", Mips::S_GOT_PAGE)
+ .Case("gottprel", Mips::S_GOTTPREL)
+ .Case("gp_rel", Mips::S_GPREL)
+ .Case("hi", Mips::S_HI)
+ .Case("higher", Mips::S_HIGHER)
+ .Case("highest", Mips::S_HIGHEST)
+ .Case("lo", Mips::S_LO)
+ .Case("neg", Mips::S_NEG)
+ .Case("pcrel_hi", Mips::S_PCREL_HI16)
+ .Case("pcrel_lo", Mips::S_PCREL_LO16)
+ .Case("tlsgd", Mips::S_TLSGD)
+ .Case("tlsldm", Mips::S_TLSLDM)
+ .Case("tprel_hi", Mips::S_TPREL_HI)
+ .Case("tprel_lo", Mips::S_TPREL_LO)
+ .Default(Mips::S_None);
};
MCAsmParser &Parser = getParser();
@@ -6391,7 +6390,7 @@ const MCExpr *MipsAsmParser::parseRelocExpr() {
Parser.parseToken(AsmToken::LParen, "expected '('"))
return nullptr;
auto Op = getOp(Name);
- if (Op == MipsMCExpr::MEK_None) {
+ if (Op == Mips::S_None) {
Error(Parser.getTok().getLoc(), "invalid relocation operator");
return nullptr;
}
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
index d5e19ccaa1689..58aa374e5302d 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "MCTargetDesc/MipsFixupKinds.h"
-#include "MCTargetDesc/MipsMCExpr.h"
+#include "MCTargetDesc/MipsMCAsmInfo.h"
#include "MCTargetDesc/MipsMCTargetDesc.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/BinaryFormat/ELF.h"
@@ -157,14 +157,14 @@ unsigned MipsELFObjectWriter::getRelocType(const MCFixup &Fixup,
// Determine the type of the relocation.
unsigned Kind = Fixup.getTargetKind();
switch (Target.getSpecifier()) {
- case MipsMCExpr::MEK_DTPREL:
- case MipsMCExpr::MEK_DTPREL_HI:
- case MipsMCExpr::MEK_DTPREL_LO:
- case MipsMCExpr::MEK_TLSLDM:
- case MipsMCExpr::MEK_TLSGD:
- case MipsMCExpr::MEK_GOTTPREL:
- case MipsMCExpr::MEK_TPREL_HI:
- case MipsMCExpr::MEK_TPREL_LO:
+ case Mips::S_DTPREL:
+ case Mips::S_DTPREL_HI:
+ case Mips::S_DTPREL_LO:
+ case Mips::S_TLSLDM:
+ case Mips::S_TLSGD:
+ case Mips::S_GOTTPREL:
+ case Mips::S_TPREL_HI:
+ case Mips::S_TPREL_LO:
if (auto *SA = Target.getAddSym())
cast<MCSymbolELF>(SA)->setType(ELF::STT_TLS);
break;
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp
index 11df6fecaf37b..97c173618167b 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp
@@ -12,6 +12,7 @@
#include "MipsMCAsmInfo.h"
#include "MipsABIInfo.h"
+#include "llvm/Support/Casting.h"
#include "llvm/TargetParser/Triple.h"
using namespace llvm;
@@ -57,3 +58,134 @@ MipsCOFFMCAsmInfo::MipsCOFFMCAsmInfo() {
PrivateLabelPrefix = ".L";
AllowAtInName = true;
}
+
+void MipsMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
+ int64_t AbsVal;
+
+ switch (specifier) {
+ case Mips::S_None:
+ case Mips::S_Special:
+ llvm_unreachable("Mips::S_None and MEK_Special are invalid");
+ break;
+ case Mips::S_DTPREL:
+ // Mips::S_DTPREL is used for marking TLS DIEExpr only
+ // and contains a regular sub-expression.
+ MAI->printExpr(OS, *getSubExpr());
+ return;
+ case Mips::S_CALL_HI16:
+ OS << "%call_hi";
+ break;
+ case Mips::S_CALL_LO16:
+ OS << "%call_lo";
+ break;
+ case Mips::S_DTPREL_HI:
+ OS << "%dtprel_hi";
+ break;
+ case Mips::S_DTPREL_LO:
+ OS << "%dtprel_lo";
+ break;
+ case Mips::S_GOT:
+ OS << "%got";
+ break;
+ case Mips::S_GOTTPREL:
+ OS << "%gottprel";
+ break;
+ case Mips::S_GOT_CALL:
+ OS << "%call16";
+ break;
+ case Mips::S_GOT_DISP:
+ OS << "%got_disp";
+ break;
+ case Mips::S_GOT_HI16:
+ OS << "%got_hi";
+ break;
+ case Mips::S_GOT_LO16:
+ OS << "%got_lo";
+ break;
+ case Mips::S_GOT_PAGE:
+ OS << "%got_page";
+ break;
+ case Mips::S_GOT_OFST:
+ OS << "%got_ofst";
+ break;
+ case Mips::S_GPREL:
+ OS << "%gp_rel";
+ break;
+ case Mips::S_HI:
+ OS << "%hi";
+ break;
+ case Mips::S_HIGHER:
+ OS << "%higher";
+ break;
+ case Mips::S_HIGHEST:
+ OS << "%highest";
+ break;
+ case Mips::S_LO:
+ OS << "%lo";
+ break;
+ case Mips::S_NEG:
+ OS << "%neg";
+ break;
+ case Mips::S_PCREL_HI16:
+ OS << "%pcrel_hi";
+ break;
+ case Mips::S_PCREL_LO16:
+ OS << "%pcrel_lo";
+ break;
+ case Mips::S_TLSGD:
+ OS << "%tlsgd";
+ break;
+ case Mips::S_TLSLDM:
+ OS << "%tlsldm";
+ break;
+ case Mips::S_TPREL_HI:
+ OS << "%tprel_hi";
+ break;
+ case Mips::S_TPREL_LO:
+ OS << "%tprel_lo";
+ break;
+ }
+
+ OS << '(';
+ if (Expr->evaluateAsAbsolute(AbsVal))
+ OS << AbsVal;
+ else
+ Expr->print(OS, MAI);
+ OS << ')';
+}
+
+bool MipsMCExpr::isGpOff(Specifier &S) const {
+ if (getSpecifier() == Mips::S_HI || getSpecifier() == Mips::S_LO) {
+ if (const MipsMCExpr *S1 = dyn_cast<const MipsMCExpr>(getSubExpr())) {
+ if (const MipsMCExpr *S2 = dyn_cast<const MipsMCExpr>(S1->getSubExpr())) {
+ if (S1->getSpecifier() == Mips::S_NEG &&
+ S2->getSpecifier() == Mips::S_GPREL) {
+ S = getSpecifier();
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+
+bool MipsMCExpr::evaluateAsRelocatableImpl(MCValue &Res,
+ const MCAssembler *Asm) const {
+ // Look for the %hi(%neg(%gp_rel(X))) and %lo(%neg(%gp_rel(X)))
+ // special cases.
+ if (isGpOff()) {
+ const MCExpr *SubExpr =
+ cast<MipsMCExpr>(cast<MipsMCExpr>(getSubExpr())->getSubExpr())
+ ->getSubExpr();
+ if (!SubExpr->evaluateAsRelocatable(Res, Asm))
+ return false;
+
+ Res.setSpecifier(Mips::S_Special);
+ return true;
+ }
+
+ if (!getSubExpr()->evaluateAsRelocatable(Res, Asm))
+ return false;
+ Res.setSpecifier(specifier);
+ return !Res.getSubSym();
+}
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.h b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.h
index 3a2895a79f9c7..d8b96f8b568c7 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.h
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.h
@@ -13,8 +13,10 @@
#ifndef LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSMCASMINFO_H
#define LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSMCASMINFO_H
+#include "MCTargetDesc/MipsMCExpr.h"
#include "llvm/MC/MCAsmInfoCOFF.h"
#include "llvm/MC/MCAsmInfoELF.h"
+#include "llvm/MC/MCFixup.h"
namespace llvm {
class Triple;
@@ -34,6 +36,38 @@ class MipsCOFFMCAsmInfo : public MCAsmInfoGNUCOFF {
explicit MipsCOFFMCAsmInfo();
};
+namespace Mips {
+enum {
+ S_None,
+ S_CALL_HI16 = FirstTargetFixupKind,
+ S_CALL_LO16,
+ S_DTPREL,
+ S_DTPREL_HI,
+ S_DTPREL_LO,
+ S_GOT,
+ S_GOTTPREL,
+ S_GOT_CALL,
+ S_GOT_DISP,
+ S_GOT_HI16,
+ S_GOT_LO16,
+ S_GOT_OFST,
+ S_GOT_PAGE,
+ S_GPREL,
+ S_HI,
+ S_HIGHER,
+ S_HIGHEST,
+ S_LO,
+ S_NEG,
+ S_PCREL_HI16,
+ S_PCREL_LO16,
+ S_TLSGD,
+ S_TLSLDM,
+ S_TPREL_HI,
+ S_TPREL_LO,
+ S_Special,
+};
+}
+
} // namespace llvm
#endif
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp
index a426ca7360ce7..4035618e02526 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCCodeEmitter.cpp
@@ -13,7 +13,7 @@
#include "MipsMCCodeEmitter.h"
#include "MCTargetDesc/MipsBaseInfo.h"
#include "MCTargetDesc/MipsFixupKinds.h"
-#include "MCTargetDesc/MipsMCExpr.h"
+#include "MCTargetDesc/MipsMCAsmInfo.h"
#include "MCTargetDesc/MipsMCTargetDesc.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
@@ -585,62 +585,62 @@ getExprOpValue(const MCExpr *Expr, SmallVectorImpl<MCFixup> &Fixups,
Mips::Fixups FixupKind = Mips::Fixups(0);
switch (MipsExpr->getSpecifier()) {
- case MipsMCExpr::MEK_None:
- case MipsMCExpr::MEK_Special:
+ case Mips::S_None:
+ case Mips::S_Special:
llvm_unreachable("Unhandled fixup kind!");
break;
- case MipsMCExpr::MEK_DTPREL:
+ case Mips::S_DTPREL:
// MEK_DTPREL is used for marking TLS DIEExpr only
// and contains a regular sub-expression.
return getExprOpValue(MipsExpr->getSubExpr(), Fixups, STI);
- case MipsMCExpr::MEK_CALL_HI16:
+ case Mips::S_CALL_HI16:
FixupKind = Mips::fixup_Mips_CALL_HI16;
break;
- case MipsMCExpr::MEK_CALL_LO16:
+ case Mips::S_CALL_LO16:
FixupKind = Mips::fixup_Mips_CALL_LO16;
break;
- case MipsMCExpr::MEK_DTPREL_HI:
+ case Mips::S_DTPREL_HI:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_TLS_DTPREL_HI16
: Mips::fixup_Mips_DTPREL_HI;
break;
- case MipsMCExpr::MEK_DTPREL_LO:
+ case Mips::S_DTPREL_LO:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_TLS_DTPREL_LO16
: Mips::fixup_Mips_DTPREL_LO;
break;
- case MipsMCExpr::MEK_GOTTPREL:
+ case Mips::S_GOTTPREL:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_GOTTPREL
: Mips::fixup_Mips_GOTTPREL;
break;
- case MipsMCExpr::MEK_GOT:
+ case Mips::S_GOT:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_GOT16
: Mips::fixup_Mips_GOT;
break;
- case MipsMCExpr::MEK_GOT_CALL:
+ case Mips::S_GOT_CALL:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_CALL16
: Mips::fixup_Mips_CALL16;
break;
- case MipsMCExpr::MEK_GOT_DISP:
+ case Mips::S_GOT_DISP:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_GOT_DISP
: Mips::fixup_Mips_GOT_DISP;
break;
- case MipsMCExpr::MEK_GOT_HI16:
+ case Mips::S_GOT_HI16:
FixupKind = Mips::fixup_Mips_GOT_HI16;
break;
- case MipsMCExpr::MEK_GOT_LO16:
+ case Mips::S_GOT_LO16:
FixupKind = Mips::fixup_Mips_GOT_LO16;
break;
- case MipsMCExpr::MEK_GOT_PAGE:
+ case Mips::S_GOT_PAGE:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_GOT_PAGE
: Mips::fixup_Mips_GOT_PAGE;
break;
- case MipsMCExpr::MEK_GOT_OFST:
+ case Mips::S_GOT_OFST:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_GOT_OFST
: Mips::fixup_Mips_GOT_OFST;
break;
- case MipsMCExpr::MEK_GPREL:
+ case Mips::S_GPREL:
FixupKind = Mips::fixup_Mips_GPREL16;
break;
- case MipsMCExpr::MEK_LO:
+ case Mips::S_LO:
// Check for %lo(%neg(%gp_rel(X)))
if (MipsExpr->isGpOff())
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_GPOFF_LO
@@ -649,15 +649,15 @@ getExprOpValue(const MCExpr *Expr, SmallVectorImpl<MCFixup> &Fixups,
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_LO16
: Mips::fixup_Mips_LO16;
break;
- case MipsMCExpr::MEK_HIGHEST:
+ case Mips::S_HIGHEST:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_HIGHEST
: Mips::fixup_Mips_HIGHEST;
break;
- case MipsMCExpr::MEK_HIGHER:
+ case Mips::S_HIGHER:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_HIGHER
: Mips::fixup_Mips_HIGHER;
break;
- case MipsMCExpr::MEK_HI:
+ case Mips::S_HI:
// Check for %hi(%neg(%gp_rel(X)))
if (MipsExpr->isGpOff())
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_GPOFF_HI
@@ -666,29 +666,29 @@ getExprOpValue(const MCExpr *Expr, SmallVectorImpl<MCFixup> &Fixups,
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_HI16
: Mips::fixup_Mips_HI16;
break;
- case MipsMCExpr::MEK_PCREL_HI16:
+ case Mips::S_PCREL_HI16:
FixupKind = Mips::fixup_MIPS_PCHI16;
break;
- case MipsMCExpr::MEK_PCREL_LO16:
+ case Mips::S_PCREL_LO16:
FixupKind = Mips::fixup_MIPS_PCLO16;
break;
- case MipsMCExpr::MEK_TLSGD:
+ case Mips::S_TLSGD:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_TLS_GD
: Mips::fixup_Mips_TLSGD;
break;
- case MipsMCExpr::MEK_TLSLDM:
+ case Mips::S_TLSLDM:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_TLS_LDM
: Mips::fixup_Mips_TLSLDM;
break;
- case MipsMCExpr::MEK_TPREL_HI:
+ case Mips::S_TPREL_HI:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_TLS_TPREL_HI16
: Mips::fixup_Mips_TPREL_HI;
break;
- case MipsMCExpr::MEK_TPREL_LO:
+ case Mips::S_TPREL_LO:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_TLS_TPREL_LO16
: Mips::fixup_Mips_TPREL_LO;
break;
- case MipsMCExpr::MEK_NEG:
+ case Mips::S_NEG:
FixupKind =
isMicroMips(STI) ? Mips::fixup_MICROMIPS_SUB : Mips::fixup_Mips_SUB;
break;
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCExpr.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCExpr.cpp
index 704ee0375f7a6..821f662f0cbfb 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCExpr.cpp
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCExpr.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "MipsMCExpr.h"
+#include "MCTargetDesc/MipsMCAsmInfo.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCContext.h"
@@ -33,135 +34,6 @@ const MipsMCExpr *MipsMCExpr::create(const MCSymbol *Sym, Specifier S,
const MipsMCExpr *MipsMCExpr::createGpOff(MipsMCExpr::Specifier S,
const MCExpr *Expr, MCContext &Ctx) {
- return create(S, create(MEK_NEG, create(MEK_GPREL, Expr, Ctx), Ctx), Ctx);
-}
-
-void MipsMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
- int64_t AbsVal;
-
- switch (specifier) {
- case MEK_None:
- case MEK_Special:
- llvm_unreachable("MEK_None and MEK_Special are invalid");
- break;
- case MEK_DTPREL:
- // MEK_DTPREL is used for marking TLS DIEExpr only
- // and contains a regular sub-expression.
- MAI->printExpr(OS, *getSubExpr());
- return;
- case MEK_CALL_HI16:
- OS << "%call_hi";
- break;
- case MEK_CALL_LO16:
- OS << "%call_lo";
- break;
- case MEK_DTPREL_HI:
- OS << "%dtprel_hi";
- break;
- case MEK_DTPREL_LO:
- OS << "%dtprel_lo";
- break;
- case MEK_GOT:
- OS << "%got";
- break;
- case MEK_GOTTPREL:
- OS << "%gottprel";
- break;
- case MEK_GOT_CALL:
- OS << "%call16";
- break;
- case MEK_GOT_DISP:
- OS << "%got_disp";
- break;
- case MEK_GOT_HI16:
- OS << "%got_hi";
- break;
- case MEK_GOT_LO16:
- OS << "%got_lo";
- break;
- case MEK_GOT_PAGE:
- OS << "%got_page";
- break;
- case MEK_GOT_OFST:
- OS << "%got_ofst";
- break;
- case MEK_GPREL:
- OS << "%gp_rel";
- break;
- case MEK_HI:
- OS << "%hi";
- break;
- case MEK_HIGHER:
- OS << "%higher";
- break;
- case MEK_HIGHEST:
- OS << "%highest";
- break;
- case MEK_LO:
- OS << "%lo";
- break;
- case MEK_NEG:
- OS << "%neg";
- break;
- case MEK_PCREL_HI16:
- OS << "%pcrel_hi";
- break;
- case MEK_PCREL_LO16:
- OS << "%pcrel_lo";
- break;
- case MEK_TLSGD:
- OS << "%tlsgd";
- break;
- case MEK_TLSLDM:
- OS << "%tlsldm";
- break;
- case MEK_TPREL_HI:
- OS << "%tprel_hi";
- break;
- case MEK_TPREL_LO:
- OS << "%tprel_lo";
- break;
- }
-
- OS << '(';
- if (Expr->evaluateAsAbsolute(AbsVal))
- OS << AbsVal;
- else
- Expr->print(OS, MAI);
- OS << ')';
-}
-
-bool MipsMCExpr::evaluateAsRelocatableImpl(MCValue &Res,
- const MCAssembler *Asm) const {
- // Look for the %hi(%neg(%gp_rel(X))) and %lo(%neg(%gp_rel(X)))
- // special cases.
- if (isGpOff()) {
- const MCExpr *SubExpr =
- cast<MipsMCExpr>(cast<MipsMCExpr>(getSubExpr())->getSubExpr())
- ->getSubExpr();
- if (!SubExpr->evaluateAsRelocatable(Res, Asm))
- return false;
-
- Res.setSpecifier(MEK_Special);
- return true;
- }
-
- if (!getSubExpr()->evaluateAsRelocatable(Res, Asm))
- return false;
- Res.setSpecifier(specifier);
- return !Res.getSubSym();
-}
-
-bool MipsMCExpr::isGpOff(Specifier &S) const {
- if (getSpecifier() == MEK_HI || getSpecifier() == MEK_LO) {
- if (const MipsMCExpr *S1 = dyn_cast<const MipsMCExpr>(getSubExpr())) {
- if (const MipsMCExpr *S2 = dyn_cast<const MipsMCExpr>(S1->getSubExpr())) {
- if (S1->getSpecifier() == MEK_NEG && S2->getSpecifier() == MEK_GPREL) {
- S = getSpecifier();
- return true;
- }
- }
- }
- }
- return false;
+ return create(S, create(Mips::S_NEG, create(Mips::S_GPREL, Expr, Ctx), Ctx),
+ Ctx);
}
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCExpr.h b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCExpr.h
index 5aad02c38d6ec..216077a1aa489 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCExpr.h
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCExpr.h
@@ -17,35 +17,6 @@ namespace llvm {
class MipsMCExpr : public MCSpecifierExpr {
public:
using Specifier = Spec;
- enum {
- MEK_None,
- MEK_CALL_HI16,
- MEK_CALL_LO16,
- MEK_DTPREL,
- MEK_DTPREL_HI,
- MEK_DTPREL_LO,
- MEK_GOT,
- MEK_GOTTPREL,
- MEK_GOT_CALL,
- MEK_GOT_DISP,
- MEK_GOT_HI16,
- MEK_GOT_LO16,
- MEK_GOT_OFST,
- MEK_GOT_PAGE,
- MEK_GPREL,
- MEK_HI,
- MEK_HIGHER,
- MEK_HIGHEST,
- MEK_LO,
- MEK_NEG,
- MEK_PCREL_HI16,
- MEK_PCREL_LO16,
- MEK_TLSGD,
- MEK_TLSLDM,
- MEK_TPREL_HI,
- MEK_TPREL_LO,
- MEK_Special,
- };
private:
explicit MipsMCExpr(const MCExpr *Expr, Specifier S)
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
index 49aea9c691629..80a854c799014 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
@@ -12,6 +12,7 @@
#include "MipsTargetStreamer.h"
#include "MCTargetDesc/MipsABIInfo.h"
+#include "MCTargetDesc/MipsMCAsmInfo.h"
#include "MipsBaseInfo.h"
#include "MipsELFStreamer.h"
#include "MipsInstPrinter.h"
@@ -1266,7 +1267,7 @@ void MipsTargetELFStreamer::emitDirectiveCpLoad(unsigned RegNo) {
TmpInst.setOpcode(Mips::LUi);
TmpInst.addOperand(MCOperand::createReg(GPReg));
const MCExpr *HiSym = MipsMCExpr::create(
- MipsMCExpr::MEK_HI, MCSymbolRefExpr::create(GP_Disp, MCA.getContext()),
+ Mips::S_HI, MCSymbolRefExpr::create(GP_Disp, MCA.getContext()),
MCA.getContext());
TmpInst.addOperand(MCOperand::createExpr(HiSym));
getStreamer().emitInstruction(TmpInst, STI);
@@ -1277,7 +1278,7 @@ void MipsTargetELFStreamer::emitDirectiveCpLoad(unsigned RegNo) {
TmpInst.addOperand(MCOperand::createReg(GPReg));
TmpInst.addOperand(MCOperand::createReg(GPReg));
const MCExpr *LoSym = MipsMCExpr::create(
- MipsMCExpr::MEK_LO, MCSymbolRefExpr::create(GP_Disp, MCA.getContext()),
+ Mips::S_LO, MCSymbolRefExpr::create(GP_Disp, MCA.getContext()),
MCA.getContext());
TmpInst.addOperand(MCOperand::createExpr(LoSym));
getStreamer().emitInstruction(TmpInst, STI);
@@ -1342,10 +1343,10 @@ void MipsTargetELFStreamer::emitDirectiveCpsetup(unsigned RegNo,
}
const MipsMCExpr *HiExpr = MipsMCExpr::createGpOff(
- MipsMCExpr::MEK_HI, MCSymbolRefExpr::create(&Sym, MCA.getContext()),
+ Mips::S_HI, MCSymbolRefExpr::create(&Sym, MCA.getContext()),
MCA.getContext());
const MipsMCExpr *LoExpr = MipsMCExpr::createGpOff(
- MipsMCExpr::MEK_LO, MCSymbolRefExpr::create(&Sym, MCA.getContext()),
+ Mips::S_LO, MCSymbolRefExpr::create(&Sym, MCA.getContext()),
MCA.getContext());
// lui $gp, %hi(%neg(%gp_rel(funcSym)))
diff --git a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
index 1a3e99ec7f68f..da3f7cb55b301 100644
--- a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
+++ b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
@@ -15,6 +15,7 @@
#include "MCTargetDesc/MipsABIInfo.h"
#include "MCTargetDesc/MipsBaseInfo.h"
#include "MCTargetDesc/MipsInstPrinter.h"
+#include "MCTargetDesc/MipsMCAsmInfo.h"
#include "MCTargetDesc/MipsMCNaCl.h"
#include "MCTargetDesc/MipsMCTargetDesc.h"
#include "MCTargetDesc/MipsTargetStreamer.h"
@@ -1244,7 +1245,7 @@ void MipsAsmPrinter::PrintDebugValueComment(const MachineInstr *MI,
// and value for debug thread local expression.
void MipsAsmPrinter::emitDebugValue(const MCExpr *Value, unsigned Size) const {
if (auto *MipsExpr = dyn_cast<MipsMCExpr>(Value)) {
- if (MipsExpr && MipsExpr->getSpecifier() == MipsMCExpr::MEK_DTPREL) {
+ if (MipsExpr && MipsExpr->getSpecifier() == Mips::S_DTPREL) {
switch (Size) {
case 4:
getTargetStreamer().emitDTPRel32Value(MipsExpr->getSubExpr());
diff --git a/llvm/lib/Target/Mips/MipsMCInstLower.cpp b/llvm/lib/Target/Mips/MipsMCInstLower.cpp
index d1eef1775aa6d..3c3690a7f983d 100644
--- a/llvm/lib/Target/Mips/MipsMCInstLower.cpp
+++ b/llvm/lib/Target/Mips/MipsMCInstLower.cpp
@@ -13,7 +13,7 @@
#include "MipsMCInstLower.h"
#include "MCTargetDesc/MipsBaseInfo.h"
-#include "MCTargetDesc/MipsMCExpr.h"
+#include "MCTargetDesc/MipsMCAsmInfo.h"
#include "MipsAsmPrinter.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineInstr.h"
@@ -35,7 +35,7 @@ void MipsMCInstLower::Initialize(MCContext *C) {
MCOperand MipsMCInstLower::LowerSymbolOperand(const MachineOperand &MO,
MachineOperandType MOTy,
int64_t Offset) const {
- MipsMCExpr::Specifier TargetKind = MipsMCExpr::MEK_None;
+ MipsMCExpr::Specifier TargetKind = Mips::S_None;
bool IsGpOff = false;
const MCSymbol *Symbol;
SmallString<128> Name;
@@ -53,75 +53,75 @@ MCOperand MipsMCInstLower::LowerSymbolOperand(const MachineOperand &MO,
case MipsII::MO_NO_FLAG:
break;
case MipsII::MO_GPREL:
- TargetKind = MipsMCExpr::MEK_GPREL;
+ TargetKind = Mips::S_GPREL;
break;
case MipsII::MO_GOT_CALL:
- TargetKind = MipsMCExpr::MEK_GOT_CALL;
+ TargetKind = Mips::S_GOT_CALL;
break;
case MipsII::MO_GOT:
- TargetKind = MipsMCExpr::MEK_GOT;
+ TargetKind = Mips::S_GOT;
break;
case MipsII::MO_ABS_HI:
- TargetKind = MipsMCExpr::MEK_HI;
+ TargetKind = Mips::S_HI;
break;
case MipsII::MO_ABS_LO:
- TargetKind = MipsMCExpr::MEK_LO;
+ TargetKind = Mips::S_LO;
break;
case MipsII::MO_TLSGD:
- TargetKind = MipsMCExpr::MEK_TLSGD;
+ TargetKind = Mips::S_TLSGD;
break;
case MipsII::MO_TLSLDM:
- TargetKind = MipsMCExpr::MEK_TLSLDM;
+ TargetKind = Mips::S_TLSLDM;
break;
case MipsII::MO_DTPREL_HI:
- TargetKind = MipsMCExpr::MEK_DTPREL_HI;
+ TargetKind = Mips::S_DTPREL_HI;
break;
case MipsII::MO_DTPREL_LO:
- TargetKind = MipsMCExpr::MEK_DTPREL_LO;
+ TargetKind = Mips::S_DTPREL_LO;
break;
case MipsII::MO_GOTTPREL:
- TargetKind = MipsMCExpr::MEK_GOTTPREL;
+ TargetKind = Mips::S_GOTTPREL;
break;
case MipsII::MO_TPREL_HI:
- TargetKind = MipsMCExpr::MEK_TPREL_HI;
+ TargetKind = Mips::S_TPREL_HI;
break;
case MipsII::MO_TPREL_LO:
- TargetKind = MipsMCExpr::MEK_TPREL_LO;
+ TargetKind = Mips::S_TPREL_LO;
break;
case MipsII::MO_GPOFF_HI:
- TargetKind = MipsMCExpr::MEK_HI;
+ TargetKind = Mips::S_HI;
IsGpOff = true;
break;
case MipsII::MO_GPOFF_LO:
- TargetKind = MipsMCExpr::MEK_LO;
+ TargetKind = Mips::S_LO;
IsGpOff = true;
break;
case MipsII::MO_GOT_DISP:
- TargetKind = MipsMCExpr::MEK_GOT_DISP;
+ TargetKind = Mips::S_GOT_DISP;
break;
case MipsII::MO_GOT_HI16:
- TargetKind = MipsMCExpr::MEK_GOT_HI16;
+ TargetKind = Mips::S_GOT_HI16;
break;
case MipsII::MO_GOT_LO16:
- TargetKind = MipsMCExpr::MEK_GOT_LO16;
+ TargetKind = Mips::S_GOT_LO16;
break;
case MipsII::MO_GOT_PAGE:
- TargetKind = MipsMCExpr::MEK_GOT_PAGE;
+ TargetKind = Mips::S_GOT_PAGE;
break;
case MipsII::MO_GOT_OFST:
- TargetKind = MipsMCExpr::MEK_GOT_OFST;
+ TargetKind = Mips::S_GOT_OFST;
break;
case MipsII::MO_HIGHER:
- TargetKind = MipsMCExpr::MEK_HIGHER;
+ TargetKind = Mips::S_HIGHER;
break;
case MipsII::MO_HIGHEST:
- TargetKind = MipsMCExpr::MEK_HIGHEST;
+ TargetKind = Mips::S_HIGHEST;
break;
case MipsII::MO_CALL_HI16:
- TargetKind = MipsMCExpr::MEK_CALL_HI16;
+ TargetKind = Mips::S_CALL_HI16;
break;
case MipsII::MO_CALL_LO16:
- TargetKind = MipsMCExpr::MEK_CALL_LO16;
+ TargetKind = Mips::S_CALL_LO16;
break;
case MipsII::MO_JALR:
return MCOperand();
@@ -176,7 +176,7 @@ MCOperand MipsMCInstLower::LowerSymbolOperand(const MachineOperand &MO,
if (IsGpOff)
Expr = MipsMCExpr::createGpOff(TargetKind, Expr, *Ctx);
- else if (TargetKind != MipsMCExpr::MEK_None)
+ else if (TargetKind != Mips::S_None)
Expr = MipsMCExpr::create(TargetKind, Expr, *Ctx);
return MCOperand::createExpr(Expr);
@@ -230,16 +230,16 @@ lowerLongBranchLUi(const MachineInstr *MI, MCInst &OutMI) const {
unsigned TargetFlags = MI->getOperand(1).getTargetFlags();
switch (TargetFlags) {
case MipsII::MO_HIGHEST:
- Spec = MipsMCExpr::MEK_HIGHEST;
+ Spec = Mips::S_HIGHEST;
break;
case MipsII::MO_HIGHER:
- Spec = MipsMCExpr::MEK_HIGHER;
+ Spec = Mips::S_HIGHER;
break;
case MipsII::MO_ABS_HI:
- Spec = MipsMCExpr::MEK_HI;
+ Spec = Mips::S_HI;
break;
case MipsII::MO_ABS_LO:
- Spec = MipsMCExpr::MEK_LO;
+ Spec = Mips::S_LO;
break;
default:
report_fatal_error("Unexpected flags for lowerLongBranchLUi");
@@ -265,16 +265,16 @@ void MipsMCInstLower::lowerLongBranchADDiu(const MachineInstr *MI,
unsigned TargetFlags = MI->getOperand(2).getTargetFlags();
switch (TargetFlags) {
case MipsII::MO_HIGHEST:
- Spec = MipsMCExpr::MEK_HIGHEST;
+ Spec = Mips::S_HIGHEST;
break;
case MipsII::MO_HIGHER:
- Spec = MipsMCExpr::MEK_HIGHER;
+ Spec = Mips::S_HIGHER;
break;
case MipsII::MO_ABS_HI:
- Spec = MipsMCExpr::MEK_HI;
+ Spec = Mips::S_HI;
break;
case MipsII::MO_ABS_LO:
- Spec = MipsMCExpr::MEK_LO;
+ Spec = Mips::S_LO;
break;
default:
report_fatal_error("Unexpected flags for lowerLongBranchADDiu");
diff --git a/llvm/lib/Target/Mips/MipsTargetObjectFile.cpp b/llvm/lib/Target/Mips/MipsTargetObjectFile.cpp
index e74b3ad5ebca3..23aa699318a2e 100644
--- a/llvm/lib/Target/Mips/MipsTargetObjectFile.cpp
+++ b/llvm/lib/Target/Mips/MipsTargetObjectFile.cpp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#include "MipsTargetObjectFile.h"
-#include "MCTargetDesc/MipsMCExpr.h"
+#include "MCTargetDesc/MipsMCAsmInfo.h"
#include "MipsSubtarget.h"
#include "MipsTargetMachine.h"
#include "llvm/BinaryFormat/ELF.h"
@@ -189,5 +189,5 @@ MipsTargetObjectFile::getDebugThreadLocalSymbol(const MCSymbol *Sym) const {
const MCExpr *Expr = MCSymbolRefExpr::create(Sym, getContext());
Expr = MCBinaryExpr::createAdd(
Expr, MCConstantExpr::create(0x8000, getContext()), getContext());
- return MipsMCExpr::create(MipsMCExpr::MEK_DTPREL, Expr, getContext());
+ return MipsMCExpr::create(Mips::S_DTPREL, Expr, getContext());
}
More information about the llvm-commits
mailing list