[mips] Use MipsMCExpr instead of MCSymbolRefExpr for all relocations.

Summary:
This is much closer to the way MIPS relocation expressions work
(%hi(foo + 2) rather than %hi(foo) + 2) and removes the need for the
various bodges in MipsAsmParser::evaluateRelocExpr().

Removing those bodges ensures that the constant stored in MCValue is the
full 32 or 64-bit (depending on ABI) offset from the symbol. This will be used
to correct the %hi/%lo matching needed to sort the relocation table correctly.

As part of this:
* Gave MCExpr::print() the ability to omit parenthesis when emitting a
  symbol reference inside a MipsMCExpr operator like %hi(X). Without this
  we print things like %lo(($L1)).
* %hi(%neg(%gprel(X))) is now three MipsMCExpr's instead of one. Most of
  the related special cases have been removed or moved to MipsMCExpr. We
  can remove the rest as we gain support for the less common relocations
  when they are not part of this specific combination.
* Renamed MipsMCExpr::VariantKind and the enum prefix ('VK_') to avoid confusion
  with MCSymbolRefExpr::VariantKind and its prefix (also 'VK_').
* fixup_Mips_GOT_Local and fixup_Mips_GOT_Global were found to be identical
  and merged into fixup_Mips_GOT.
* MO_GOT16 and MO_GOT turned out to be identical and have been merged into
  MO_GOT.
* VK_Mips_GOT and VK_Mips_GOT16 turned out to be the same thing so they
  have been merged into MEK_GOT

Reviewers: sdardis

Subscribers: dsanders, sdardis, llvm-commits

Differential Revision: http://reviews.llvm.org/D19716


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268379 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Sanders 2016-05-03 13:35:44 +00:00
parent d56fee3447
commit c8b0a11468
29 changed files with 719 additions and 608 deletions

View File

@ -73,7 +73,8 @@ public:
/// \name Utility Methods /// \name Utility Methods
/// @{ /// @{
void print(raw_ostream &OS, const MCAsmInfo *MAI) const; void print(raw_ostream &OS, const MCAsmInfo *MAI,
bool InParens = false) const;
void dump() const; void dump() const;
/// @} /// @}
@ -250,33 +251,6 @@ public:
VK_PPC_TLSLD, // symbol@tlsld VK_PPC_TLSLD, // symbol@tlsld
VK_PPC_LOCAL, // symbol@local VK_PPC_LOCAL, // symbol@local
VK_Mips_GPREL,
VK_Mips_GOT_CALL,
VK_Mips_GOT16,
VK_Mips_GOT,
VK_Mips_ABS_HI,
VK_Mips_ABS_LO,
VK_Mips_TLSGD,
VK_Mips_TLSLDM,
VK_Mips_DTPREL_HI,
VK_Mips_DTPREL_LO,
VK_Mips_GOTTPREL,
VK_Mips_TPREL_HI,
VK_Mips_TPREL_LO,
VK_Mips_GPOFF_HI,
VK_Mips_GPOFF_LO,
VK_Mips_GOT_DISP,
VK_Mips_GOT_PAGE,
VK_Mips_GOT_OFST,
VK_Mips_HIGHER,
VK_Mips_HIGHEST,
VK_Mips_GOT_HI16,
VK_Mips_GOT_LO16,
VK_Mips_CALL_HI16,
VK_Mips_CALL_LO16,
VK_Mips_PCREL_HI16,
VK_Mips_PCREL_LO16,
VK_COFF_IMGREL32, // symbol@imgrel (image-relative) VK_COFF_IMGREL32, // symbol@imgrel (image-relative)
VK_Hexagon_PCREL, VK_Hexagon_PCREL,

View File

@ -536,7 +536,6 @@ bool ELFObjectWriter::shouldRelocateWithSymbol(const MCAssembler &Asm,
case MCSymbolRefExpr::VK_GOT: case MCSymbolRefExpr::VK_GOT:
case MCSymbolRefExpr::VK_PLT: case MCSymbolRefExpr::VK_PLT:
case MCSymbolRefExpr::VK_GOTPCREL: case MCSymbolRefExpr::VK_GOTPCREL:
case MCSymbolRefExpr::VK_Mips_GOT:
case MCSymbolRefExpr::VK_PPC_GOT_LO: case MCSymbolRefExpr::VK_PPC_GOT_LO:
case MCSymbolRefExpr::VK_PPC_GOT_HI: case MCSymbolRefExpr::VK_PPC_GOT_HI:
case MCSymbolRefExpr::VK_PPC_GOT_HA: case MCSymbolRefExpr::VK_PPC_GOT_HA:

View File

@ -412,10 +412,6 @@ void MCELFStreamer::fixSymbolsInTLSFixups(const MCExpr *expr) {
case MCSymbolRefExpr::VK_TPREL: case MCSymbolRefExpr::VK_TPREL:
case MCSymbolRefExpr::VK_DTPOFF: case MCSymbolRefExpr::VK_DTPOFF:
case MCSymbolRefExpr::VK_DTPREL: case MCSymbolRefExpr::VK_DTPREL:
case MCSymbolRefExpr::VK_Mips_TLSGD:
case MCSymbolRefExpr::VK_Mips_GOTTPREL:
case MCSymbolRefExpr::VK_Mips_TPREL_HI:
case MCSymbolRefExpr::VK_Mips_TPREL_LO:
case MCSymbolRefExpr::VK_PPC_DTPMOD: case MCSymbolRefExpr::VK_PPC_DTPMOD:
case MCSymbolRefExpr::VK_PPC_TPREL_LO: case MCSymbolRefExpr::VK_PPC_TPREL_LO:
case MCSymbolRefExpr::VK_PPC_TPREL_HI: case MCSymbolRefExpr::VK_PPC_TPREL_HI:

View File

@ -30,7 +30,7 @@ STATISTIC(MCExprEvaluate, "Number of MCExpr evaluations");
} }
} }
void MCExpr::print(raw_ostream &OS, const MCAsmInfo *MAI) const { void MCExpr::print(raw_ostream &OS, const MCAsmInfo *MAI, bool InParens) const {
switch (getKind()) { switch (getKind()) {
case MCExpr::Target: case MCExpr::Target:
return cast<MCTargetExpr>(this)->printImpl(OS, MAI); return cast<MCTargetExpr>(this)->printImpl(OS, MAI);
@ -43,7 +43,8 @@ void MCExpr::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
const MCSymbol &Sym = SRE.getSymbol(); const MCSymbol &Sym = SRE.getSymbol();
// Parenthesize names that start with $ so that they don't look like // Parenthesize names that start with $ so that they don't look like
// absolute names. // absolute names.
bool UseParens = Sym.getName().size() && Sym.getName()[0] == '$'; bool UseParens =
!InParens && Sym.getName().size() && Sym.getName()[0] == '$';
if (UseParens) { if (UseParens) {
OS << '('; OS << '(';
Sym.print(OS, MAI); Sym.print(OS, MAI);
@ -264,32 +265,6 @@ StringRef MCSymbolRefExpr::getVariantKindName(VariantKind Kind) {
case VK_PPC_GOT_TLSLD_HA: return "got@tlsld@ha"; case VK_PPC_GOT_TLSLD_HA: return "got@tlsld@ha";
case VK_PPC_TLSLD: return "tlsld"; case VK_PPC_TLSLD: return "tlsld";
case VK_PPC_LOCAL: return "local"; case VK_PPC_LOCAL: return "local";
case VK_Mips_GPREL: return "GPREL";
case VK_Mips_GOT_CALL: return "GOT_CALL";
case VK_Mips_GOT16: return "GOT16";
case VK_Mips_GOT: return "GOT";
case VK_Mips_ABS_HI: return "ABS_HI";
case VK_Mips_ABS_LO: return "ABS_LO";
case VK_Mips_TLSGD: return "TLSGD";
case VK_Mips_TLSLDM: return "TLSLDM";
case VK_Mips_DTPREL_HI: return "DTPREL_HI";
case VK_Mips_DTPREL_LO: return "DTPREL_LO";
case VK_Mips_GOTTPREL: return "GOTTPREL";
case VK_Mips_TPREL_HI: return "TPREL_HI";
case VK_Mips_TPREL_LO: return "TPREL_LO";
case VK_Mips_GPOFF_HI: return "GPOFF_HI";
case VK_Mips_GPOFF_LO: return "GPOFF_LO";
case VK_Mips_GOT_DISP: return "GOT_DISP";
case VK_Mips_GOT_PAGE: return "GOT_PAGE";
case VK_Mips_GOT_OFST: return "GOT_OFST";
case VK_Mips_HIGHER: return "HIGHER";
case VK_Mips_HIGHEST: return "HIGHEST";
case VK_Mips_GOT_HI16: return "GOT_HI16";
case VK_Mips_GOT_LO16: return "GOT_LO16";
case VK_Mips_CALL_HI16: return "CALL_HI16";
case VK_Mips_CALL_LO16: return "CALL_LO16";
case VK_Mips_PCREL_HI16: return "PCREL_HI16";
case VK_Mips_PCREL_LO16: return "PCREL_LO16";
case VK_COFF_IMGREL32: return "IMGREL"; case VK_COFF_IMGREL32: return "IMGREL";
case VK_Hexagon_PCREL: return "PCREL"; case VK_Hexagon_PCREL: return "PCREL";
case VK_Hexagon_LO16: return "LO16"; case VK_Hexagon_LO16: return "LO16";

View File

@ -303,8 +303,6 @@ class MipsAsmParser : public MCTargetAsmParser {
bool parseInternalDirectiveReallowModule(); bool parseInternalDirectiveReallowModule();
MCSymbolRefExpr::VariantKind getVariantKind(StringRef Symbol);
bool eatComma(StringRef ErrorStr); bool eatComma(StringRef ErrorStr);
int matchCPURegisterName(StringRef Symbol); int matchCPURegisterName(StringRef Symbol);
@ -1631,9 +1629,7 @@ bool MipsAsmParser::processInstruction(MCInst &Inst, SMLoc IDLoc,
return Error(IDLoc, "jal doesn't support multiple symbols in PIC mode"); return Error(IDLoc, "jal doesn't support multiple symbols in PIC mode");
// FIXME: This is checking the expression can be handled by the later stages // FIXME: This is checking the expression can be handled by the later stages
// of the assembler. We ought to leave it to those later stages but // of the assembler. We ought to leave it to those later stages.
// we can't do that until we stop evaluateRelocExpr() rewriting the
// expressions into non-equivalent forms.
const MCSymbol *JalSym = getSingleMCSymbol(JalExpr); const MCSymbol *JalSym = getSingleMCSymbol(JalExpr);
// FIXME: Add support for label+offset operands (currently causes an error). // FIXME: Add support for label+offset operands (currently causes an error).
@ -1647,8 +1643,10 @@ bool MipsAsmParser::processInstruction(MCInst &Inst, SMLoc IDLoc,
// addiu $25, $25, 0 // addiu $25, $25, 0
// R_(MICRO)MIPS_LO16 label // R_(MICRO)MIPS_LO16 label
// jalr $25 // jalr $25
const MCExpr *Got16RelocExpr = evaluateRelocExpr(JalExpr, "got"); const MCExpr *Got16RelocExpr =
const MCExpr *Lo16RelocExpr = evaluateRelocExpr(JalExpr, "lo"); MipsMCExpr::create(MipsMCExpr::MEK_GOT, JalExpr, getContext());
const MCExpr *Lo16RelocExpr =
MipsMCExpr::create(MipsMCExpr::MEK_LO, JalExpr, getContext());
TOut.emitRRX(Mips::LW, Mips::T9, Mips::GP, TOut.emitRRX(Mips::LW, Mips::T9, Mips::GP,
MCOperand::createExpr(Got16RelocExpr), IDLoc, STI); MCOperand::createExpr(Got16RelocExpr), IDLoc, STI);
@ -1660,7 +1658,8 @@ bool MipsAsmParser::processInstruction(MCInst &Inst, SMLoc IDLoc,
// lw/ld $25, 0($gp) // lw/ld $25, 0($gp)
// R_(MICRO)MIPS_GOT_DISP label // R_(MICRO)MIPS_GOT_DISP label
// jalr $25 // jalr $25
const MCExpr *GotDispRelocExpr = evaluateRelocExpr(JalExpr, "got_disp"); const MCExpr *GotDispRelocExpr =
MipsMCExpr::create(MipsMCExpr::MEK_GOT_DISP, JalExpr, getContext());
TOut.emitRRX(ABI.ArePtrs64bit() ? Mips::LD : Mips::LW, Mips::T9, TOut.emitRRX(ABI.ArePtrs64bit() ? Mips::LD : Mips::LW, Mips::T9,
Mips::GP, MCOperand::createExpr(GotDispRelocExpr), IDLoc, Mips::GP, MCOperand::createExpr(GotDispRelocExpr), IDLoc,
@ -1671,7 +1670,8 @@ bool MipsAsmParser::processInstruction(MCInst &Inst, SMLoc IDLoc,
// lw/ld $25, 0($gp) // lw/ld $25, 0($gp)
// R_(MICRO)MIPS_CALL16 label // R_(MICRO)MIPS_CALL16 label
// jalr $25 // jalr $25
const MCExpr *Call16RelocExpr = evaluateRelocExpr(JalExpr, "call16"); const MCExpr *Call16RelocExpr =
MipsMCExpr::create(MipsMCExpr::MEK_GOT_CALL, JalExpr, getContext());
TOut.emitRRX(ABI.ArePtrs64bit() ? Mips::LD : Mips::LW, Mips::T9, Mips::GP, TOut.emitRRX(ABI.ArePtrs64bit() ? Mips::LD : Mips::LW, Mips::T9, Mips::GP,
MCOperand::createExpr(Call16RelocExpr), IDLoc, STI); MCOperand::createExpr(Call16RelocExpr), IDLoc, STI);
@ -2337,10 +2337,10 @@ bool MipsAsmParser::loadAndAddSymbolAddress(const MCExpr *SymExpr,
warnIfNoMacro(IDLoc); warnIfNoMacro(IDLoc);
const MCExpr *Symbol = cast<MCExpr>(SymExpr); const MCExpr *Symbol = cast<MCExpr>(SymExpr);
const MipsMCExpr *HiExpr = MipsMCExpr::create( const MipsMCExpr *HiExpr =
MCSymbolRefExpr::VK_Mips_ABS_HI, Symbol, getContext()); MipsMCExpr::create(MipsMCExpr::MEK_HI, Symbol, getContext());
const MipsMCExpr *LoExpr = MipsMCExpr::create( const MipsMCExpr *LoExpr =
MCSymbolRefExpr::VK_Mips_ABS_LO, Symbol, getContext()); MipsMCExpr::create(MipsMCExpr::MEK_LO, Symbol, getContext());
bool UseSrcReg = SrcReg != Mips::NoRegister; bool UseSrcReg = SrcReg != Mips::NoRegister;
@ -2352,10 +2352,10 @@ bool MipsAsmParser::loadAndAddSymbolAddress(const MCExpr *SymExpr,
if (!ATReg) if (!ATReg)
return true; return true;
const MipsMCExpr *HighestExpr = MipsMCExpr::create( const MipsMCExpr *HighestExpr =
MCSymbolRefExpr::VK_Mips_HIGHEST, Symbol, getContext()); MipsMCExpr::create(MipsMCExpr::MEK_HIGHEST, Symbol, getContext());
const MipsMCExpr *HigherExpr = MipsMCExpr::create( const MipsMCExpr *HigherExpr =
MCSymbolRefExpr::VK_Mips_HIGHER, Symbol, getContext()); MipsMCExpr::create(MipsMCExpr::MEK_HIGHER, Symbol, getContext());
if (UseSrcReg && if (UseSrcReg &&
getContext().getRegisterInfo()->isSuperOrSubRegisterEq(DstReg, getContext().getRegisterInfo()->isSuperOrSubRegisterEq(DstReg,
@ -2575,10 +2575,10 @@ void MipsAsmParser::expandLoadInst(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
} }
const MCExpr *ExprOffset = Inst.getOperand(2).getExpr(); const MCExpr *ExprOffset = Inst.getOperand(2).getExpr();
MCOperand LoOperand = MCOperand LoOperand = MCOperand::createExpr(
MCOperand::createExpr(evaluateRelocExpr(ExprOffset, "lo")); MipsMCExpr::create(MipsMCExpr::MEK_LO, ExprOffset, getContext()));
MCOperand HiOperand = MCOperand HiOperand = MCOperand::createExpr(
MCOperand::createExpr(evaluateRelocExpr(ExprOffset, "hi")); MipsMCExpr::create(MipsMCExpr::MEK_HI, ExprOffset, getContext()));
// Try to use DstReg as the temporary. // Try to use DstReg as the temporary.
if (IsGPR && (BaseReg != DstReg)) { if (IsGPR && (BaseReg != DstReg)) {
@ -2616,10 +2616,10 @@ void MipsAsmParser::expandStoreInst(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
} }
const MCExpr *ExprOffset = Inst.getOperand(2).getExpr(); const MCExpr *ExprOffset = Inst.getOperand(2).getExpr();
MCOperand LoOperand = MCOperand LoOperand = MCOperand::createExpr(
MCOperand::createExpr(evaluateRelocExpr(ExprOffset, "lo")); MipsMCExpr::create(MipsMCExpr::MEK_LO, ExprOffset, getContext()));
MCOperand HiOperand = MCOperand HiOperand = MCOperand::createExpr(
MCOperand::createExpr(evaluateRelocExpr(ExprOffset, "hi")); MipsMCExpr::create(MipsMCExpr::MEK_HI, ExprOffset, getContext()));
TOut.emitStoreWithSymOffset(Inst.getOpcode(), SrcReg, BaseReg, HiOperand, TOut.emitStoreWithSymOffset(Inst.getOpcode(), SrcReg, BaseReg, HiOperand,
LoOperand, ATReg, IDLoc, STI); LoOperand, ATReg, IDLoc, STI);
} }
@ -4073,64 +4073,41 @@ bool MipsAsmParser::parseOperand(OperandVector &Operands, StringRef Mnemonic) {
const MCExpr *MipsAsmParser::evaluateRelocExpr(const MCExpr *Expr, const MCExpr *MipsAsmParser::evaluateRelocExpr(const MCExpr *Expr,
StringRef RelocStr) { StringRef RelocStr) {
const MCExpr *Res; if (RelocStr == "hi(%neg(%gp_rel")
// Check the type of the expression. return MipsMCExpr::createGpOff(MipsMCExpr::MEK_HI, Expr, getContext());
if (const MCConstantExpr *MCE = dyn_cast<MCConstantExpr>(Expr)) { else if (RelocStr == "lo(%neg(%gp_rel")
// It's a constant, evaluate reloc value. return MipsMCExpr::createGpOff(MipsMCExpr::MEK_LO, Expr, getContext());
int16_t Val;
switch (getVariantKind(RelocStr)) {
case MCSymbolRefExpr::VK_Mips_ABS_LO:
// Get the 1st 16-bits.
Val = MCE->getValue() & 0xffff;
break;
case MCSymbolRefExpr::VK_Mips_ABS_HI:
case MCSymbolRefExpr::VK_Mips_GOT:
// Get the 2nd 16-bits. Also add 1 if bit 15 is 1, to compensate for low
// 16 bits being negative.
Val = ((MCE->getValue() + 0x8000) >> 16) & 0xffff;
break;
case MCSymbolRefExpr::VK_Mips_HIGHER:
// Get the 3rd 16-bits.
Val = ((MCE->getValue() + 0x80008000LL) >> 32) & 0xffff;
break;
case MCSymbolRefExpr::VK_Mips_HIGHEST:
// Get the 4th 16-bits.
Val = ((MCE->getValue() + 0x800080008000LL) >> 48) & 0xffff;
break;
default:
report_fatal_error("unsupported reloc value");
}
return MCConstantExpr::create(Val, getContext());
}
if (const MCSymbolRefExpr *MSRE = dyn_cast<MCSymbolRefExpr>(Expr)) { MipsMCExpr::MipsExprKind Kind =
// It's a symbol, create a symbolic expression from the symbol. StringSwitch<MipsMCExpr::MipsExprKind>(RelocStr)
const MCSymbol *Symbol = &MSRE->getSymbol(); .Case("call16", MipsMCExpr::MEK_GOT_CALL)
MCSymbolRefExpr::VariantKind VK = getVariantKind(RelocStr); .Case("call_hi", MipsMCExpr::MEK_CALL_HI16)
Res = MCSymbolRefExpr::create(Symbol, VK, getContext()); .Case("call_lo", MipsMCExpr::MEK_CALL_LO16)
return Res; .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);
if (const MCBinaryExpr *BE = dyn_cast<MCBinaryExpr>(Expr)) { assert(Kind != MipsMCExpr::MEK_None);
MCSymbolRefExpr::VariantKind VK = getVariantKind(RelocStr); return MipsMCExpr::create(Kind, Expr, getContext());
// Try to create target expression.
if (MipsMCExpr::isSupportedBinaryExpr(VK, BE))
return MipsMCExpr::create(VK, Expr, getContext());
const MCExpr *LExp = evaluateRelocExpr(BE->getLHS(), RelocStr);
const MCExpr *RExp = evaluateRelocExpr(BE->getRHS(), RelocStr);
Res = MCBinaryExpr::create(BE->getOpcode(), LExp, RExp, getContext());
return Res;
}
if (const MCUnaryExpr *UN = dyn_cast<MCUnaryExpr>(Expr)) {
const MCExpr *UnExp = evaluateRelocExpr(UN->getSubExpr(), RelocStr);
Res = MCUnaryExpr::create(UN->getOpcode(), UnExp, getContext());
return Res;
}
// Just return the original expression.
return Expr;
} }
bool MipsAsmParser::isEvaluated(const MCExpr *Expr) { bool MipsAsmParser::isEvaluated(const MCExpr *Expr) {
@ -4733,42 +4710,6 @@ MipsAsmParser::parseMovePRegPair(OperandVector &Operands) {
return MatchOperand_Success; return MatchOperand_Success;
} }
MCSymbolRefExpr::VariantKind MipsAsmParser::getVariantKind(StringRef Symbol) {
MCSymbolRefExpr::VariantKind VK =
StringSwitch<MCSymbolRefExpr::VariantKind>(Symbol)
.Case("hi", MCSymbolRefExpr::VK_Mips_ABS_HI)
.Case("lo", MCSymbolRefExpr::VK_Mips_ABS_LO)
.Case("gp_rel", MCSymbolRefExpr::VK_Mips_GPREL)
.Case("call16", MCSymbolRefExpr::VK_Mips_GOT_CALL)
.Case("got", MCSymbolRefExpr::VK_Mips_GOT)
.Case("tlsgd", MCSymbolRefExpr::VK_Mips_TLSGD)
.Case("tlsldm", MCSymbolRefExpr::VK_Mips_TLSLDM)
.Case("dtprel_hi", MCSymbolRefExpr::VK_Mips_DTPREL_HI)
.Case("dtprel_lo", MCSymbolRefExpr::VK_Mips_DTPREL_LO)
.Case("gottprel", MCSymbolRefExpr::VK_Mips_GOTTPREL)
.Case("tprel_hi", MCSymbolRefExpr::VK_Mips_TPREL_HI)
.Case("tprel_lo", MCSymbolRefExpr::VK_Mips_TPREL_LO)
.Case("got_disp", MCSymbolRefExpr::VK_Mips_GOT_DISP)
.Case("got_page", MCSymbolRefExpr::VK_Mips_GOT_PAGE)
.Case("got_ofst", MCSymbolRefExpr::VK_Mips_GOT_OFST)
.Case("hi(%neg(%gp_rel", MCSymbolRefExpr::VK_Mips_GPOFF_HI)
.Case("lo(%neg(%gp_rel", MCSymbolRefExpr::VK_Mips_GPOFF_LO)
.Case("got_hi", MCSymbolRefExpr::VK_Mips_GOT_HI16)
.Case("got_lo", MCSymbolRefExpr::VK_Mips_GOT_LO16)
.Case("call_hi", MCSymbolRefExpr::VK_Mips_CALL_HI16)
.Case("call_lo", MCSymbolRefExpr::VK_Mips_CALL_LO16)
.Case("higher", MCSymbolRefExpr::VK_Mips_HIGHER)
.Case("highest", MCSymbolRefExpr::VK_Mips_HIGHEST)
.Case("pcrel_hi", MCSymbolRefExpr::VK_Mips_PCREL_HI16)
.Case("pcrel_lo", MCSymbolRefExpr::VK_Mips_PCREL_LO16)
.Default(MCSymbolRefExpr::VK_None);
assert(VK != MCSymbolRefExpr::VK_None);
return VK;
}
/// Sometimes (i.e. load/stores) the operand may be followed immediately by /// Sometimes (i.e. load/stores) the operand may be followed immediately by
/// either this. /// either this.
/// ::= '(', register, ')' /// ::= '(', register, ')'

View File

@ -140,36 +140,7 @@ static void printExpr(const MCExpr *Expr, const MCAsmInfo *MAI,
MCSymbolRefExpr::VariantKind Kind = SRE->getKind(); MCSymbolRefExpr::VariantKind Kind = SRE->getKind();
switch (Kind) { assert(Kind == MCSymbolRefExpr::VK_None && "Invalid kind!");
default: llvm_unreachable("Invalid kind!");
case MCSymbolRefExpr::VK_None: break;
case MCSymbolRefExpr::VK_Mips_GPREL: OS << "%gp_rel("; break;
case MCSymbolRefExpr::VK_Mips_GOT_CALL: OS << "%call16("; break;
case MCSymbolRefExpr::VK_Mips_GOT16: OS << "%got("; break;
case MCSymbolRefExpr::VK_Mips_GOT: OS << "%got("; break;
case MCSymbolRefExpr::VK_Mips_ABS_HI: OS << "%hi("; break;
case MCSymbolRefExpr::VK_Mips_ABS_LO: OS << "%lo("; break;
case MCSymbolRefExpr::VK_Mips_TLSGD: OS << "%tlsgd("; break;
case MCSymbolRefExpr::VK_Mips_TLSLDM: OS << "%tlsldm("; break;
case MCSymbolRefExpr::VK_Mips_DTPREL_HI: OS << "%dtprel_hi("; break;
case MCSymbolRefExpr::VK_Mips_DTPREL_LO: OS << "%dtprel_lo("; break;
case MCSymbolRefExpr::VK_Mips_GOTTPREL: OS << "%gottprel("; break;
case MCSymbolRefExpr::VK_Mips_TPREL_HI: OS << "%tprel_hi("; break;
case MCSymbolRefExpr::VK_Mips_TPREL_LO: OS << "%tprel_lo("; break;
case MCSymbolRefExpr::VK_Mips_GPOFF_HI: OS << "%hi(%neg(%gp_rel("; break;
case MCSymbolRefExpr::VK_Mips_GPOFF_LO: OS << "%lo(%neg(%gp_rel("; break;
case MCSymbolRefExpr::VK_Mips_GOT_DISP: OS << "%got_disp("; break;
case MCSymbolRefExpr::VK_Mips_GOT_PAGE: OS << "%got_page("; break;
case MCSymbolRefExpr::VK_Mips_GOT_OFST: OS << "%got_ofst("; break;
case MCSymbolRefExpr::VK_Mips_HIGHER: OS << "%higher("; break;
case MCSymbolRefExpr::VK_Mips_HIGHEST: OS << "%highest("; break;
case MCSymbolRefExpr::VK_Mips_GOT_HI16: OS << "%got_hi("; break;
case MCSymbolRefExpr::VK_Mips_GOT_LO16: OS << "%got_lo("; break;
case MCSymbolRefExpr::VK_Mips_CALL_HI16: OS << "%call_hi("; break;
case MCSymbolRefExpr::VK_Mips_CALL_LO16: OS << "%call_lo("; break;
case MCSymbolRefExpr::VK_Mips_PCREL_HI16: OS << "%pcrel_hi("; break;
case MCSymbolRefExpr::VK_Mips_PCREL_LO16: OS << "%pcrel_lo("; break;
}
SRE->getSymbol().print(OS, MAI); SRE->getSymbol().print(OS, MAI);
@ -178,12 +149,6 @@ static void printExpr(const MCExpr *Expr, const MCAsmInfo *MAI,
OS << '+'; OS << '+';
OS << Offset; OS << Offset;
} }
if ((Kind == MCSymbolRefExpr::VK_Mips_GPOFF_HI) ||
(Kind == MCSymbolRefExpr::VK_Mips_GPOFF_LO))
OS << ")))";
else if (Kind != MCSymbolRefExpr::VK_None)
OS << ')';
} }
void MipsInstPrinter::printOperand(const MCInst *MI, unsigned OpNo, void MipsInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,

View File

@ -14,6 +14,7 @@
#include "MCTargetDesc/MipsFixupKinds.h" #include "MCTargetDesc/MipsFixupKinds.h"
#include "MCTargetDesc/MipsAsmBackend.h" #include "MCTargetDesc/MipsAsmBackend.h"
#include "MCTargetDesc/MipsMCExpr.h"
#include "MCTargetDesc/MipsMCTargetDesc.h" #include "MCTargetDesc/MipsMCTargetDesc.h"
#include "llvm/MC/MCAsmBackend.h" #include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCAssembler.h" #include "llvm/MC/MCAssembler.h"
@ -23,7 +24,9 @@
#include "llvm/MC/MCFixupKindInfo.h" #include "llvm/MC/MCFixupKindInfo.h"
#include "llvm/MC/MCObjectWriter.h" #include "llvm/MC/MCObjectWriter.h"
#include "llvm/MC/MCSubtargetInfo.h" #include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/MCValue.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/MathExtras.h" #include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
@ -40,9 +43,6 @@ static unsigned adjustFixupValue(const MCFixup &Fixup, uint64_t Value,
default: default:
return 0; return 0;
case FK_Data_2: case FK_Data_2:
case FK_GPRel_4:
case FK_Data_4:
case FK_Data_8:
case Mips::fixup_Mips_LO16: case Mips::fixup_Mips_LO16:
case Mips::fixup_Mips_GPREL16: case Mips::fixup_Mips_GPREL16:
case Mips::fixup_Mips_GPOFF_HI: case Mips::fixup_Mips_GPOFF_HI:
@ -57,6 +57,11 @@ static unsigned adjustFixupValue(const MCFixup &Fixup, uint64_t Value,
case Mips::fixup_MICROMIPS_GOT_OFST: case Mips::fixup_MICROMIPS_GOT_OFST:
case Mips::fixup_MICROMIPS_GOT_DISP: case Mips::fixup_MICROMIPS_GOT_DISP:
case Mips::fixup_MIPS_PCLO16: case Mips::fixup_MIPS_PCLO16:
Value &= 0xffff;
break;
case FK_GPRel_4:
case FK_Data_4:
case FK_Data_8:
break; break;
case Mips::fixup_Mips_PC16: case Mips::fixup_Mips_PC16:
// The displacement is then divided by 4 to give us an 18 bit // The displacement is then divided by 4 to give us an 18 bit
@ -85,7 +90,7 @@ static unsigned adjustFixupValue(const MCFixup &Fixup, uint64_t Value,
Value >>= 2; Value >>= 2;
break; break;
case Mips::fixup_Mips_HI16: case Mips::fixup_Mips_HI16:
case Mips::fixup_Mips_GOT_Local: case Mips::fixup_Mips_GOT:
case Mips::fixup_Mips_GOT_HI16: case Mips::fixup_Mips_GOT_HI16:
case Mips::fixup_Mips_CALL_HI16: case Mips::fixup_Mips_CALL_HI16:
case Mips::fixup_MICROMIPS_HI16: case Mips::fixup_MICROMIPS_HI16:
@ -295,8 +300,7 @@ getFixupKindInfo(MCFixupKind Kind) const {
{ "fixup_Mips_LO16", 0, 16, 0 }, { "fixup_Mips_LO16", 0, 16, 0 },
{ "fixup_Mips_GPREL16", 0, 16, 0 }, { "fixup_Mips_GPREL16", 0, 16, 0 },
{ "fixup_Mips_LITERAL", 0, 16, 0 }, { "fixup_Mips_LITERAL", 0, 16, 0 },
{ "fixup_Mips_GOT_Global", 0, 16, 0 }, { "fixup_Mips_GOT", 0, 16, 0 },
{ "fixup_Mips_GOT_Local", 0, 16, 0 },
{ "fixup_Mips_PC16", 0, 16, MCFixupKindInfo::FKF_IsPCRel }, { "fixup_Mips_PC16", 0, 16, MCFixupKindInfo::FKF_IsPCRel },
{ "fixup_Mips_CALL16", 0, 16, 0 }, { "fixup_Mips_CALL16", 0, 16, 0 },
{ "fixup_Mips_GPREL32", 0, 32, 0 }, { "fixup_Mips_GPREL32", 0, 32, 0 },
@ -364,8 +368,7 @@ getFixupKindInfo(MCFixupKind Kind) const {
{ "fixup_Mips_LO16", 16, 16, 0 }, { "fixup_Mips_LO16", 16, 16, 0 },
{ "fixup_Mips_GPREL16", 16, 16, 0 }, { "fixup_Mips_GPREL16", 16, 16, 0 },
{ "fixup_Mips_LITERAL", 16, 16, 0 }, { "fixup_Mips_LITERAL", 16, 16, 0 },
{ "fixup_Mips_GOT_Global", 16, 16, 0 }, { "fixup_Mips_GOT", 16, 16, 0 },
{ "fixup_Mips_GOT_Local", 16, 16, 0 },
{ "fixup_Mips_PC16", 16, 16, MCFixupKindInfo::FKF_IsPCRel }, { "fixup_Mips_PC16", 16, 16, MCFixupKindInfo::FKF_IsPCRel },
{ "fixup_Mips_CALL16", 16, 16, 0 }, { "fixup_Mips_CALL16", 16, 16, 0 },
{ "fixup_Mips_GPREL32", 0, 32, 0 }, { "fixup_Mips_GPREL32", 0, 32, 0 },
@ -460,6 +463,8 @@ void MipsAsmBackend::processFixupValue(const MCAssembler &Asm,
// we are only checking if the fixup can be applied correctly. We have // we are only checking if the fixup can be applied correctly. We have
// access to MCContext from here which allows us to report a fatal error // access to MCContext from here which allows us to report a fatal error
// with *possibly* a source code location. // with *possibly* a source code location.
// The caller will also ignore any changes we make to Value
// (recordRelocation() overwrites it with it's own calculation).
(void)adjustFixupValue(Fixup, Value, &Asm.getContext()); (void)adjustFixupValue(Fixup, Value, &Asm.getContext());
} }

View File

@ -33,9 +33,8 @@ namespace MipsII {
MO_NO_FLAG, MO_NO_FLAG,
/// MO_GOT16 - Represents the offset into the global offset table at which /// MO_GOT - Represents the offset into the global offset table at which
/// the address the relocation entry symbol resides during execution. /// the address the relocation entry symbol resides during execution.
MO_GOT16,
MO_GOT, MO_GOT,
/// MO_GOT_CALL - Represents the offset into the global offset table at /// MO_GOT_CALL - Represents the offset into the global offset table at

View File

@ -131,8 +131,7 @@ unsigned MipsELFObjectWriter::getRelocType(MCContext &Ctx,
return ELF::R_MIPS_26; return ELF::R_MIPS_26;
case Mips::fixup_Mips_CALL16: case Mips::fixup_Mips_CALL16:
return ELF::R_MIPS_CALL16; return ELF::R_MIPS_CALL16;
case Mips::fixup_Mips_GOT_Global: case Mips::fixup_Mips_GOT:
case Mips::fixup_Mips_GOT_Local:
return ELF::R_MIPS_GOT16; return ELF::R_MIPS_GOT16;
case Mips::fixup_Mips_HI16: case Mips::fixup_Mips_HI16:
return ELF::R_MIPS_HI16; return ELF::R_MIPS_HI16;
@ -402,7 +401,7 @@ bool MipsELFObjectWriter::needsRelocateWithSymbol(const MCSymbol &Sym,
case ELF::R_MIPS_GOT16: case ELF::R_MIPS_GOT16:
case ELF::R_MIPS16_GOT16: case ELF::R_MIPS16_GOT16:
case ELF::R_MICROMIPS_GOT16: case ELF::R_MICROMIPS_GOT16:
llvm_unreachable("Should have been handled already"); return true;
// These relocations might be paired with another relocation. The pairing is // These relocations might be paired with another relocation. The pairing is
// done by the static linker by matching the symbol. Since we only see one // done by the static linker by matching the symbol. Since we only see one

View File

@ -50,11 +50,8 @@ namespace Mips {
// 16 bit literal fixup resulting in - R_MIPS_LITERAL. // 16 bit literal fixup resulting in - R_MIPS_LITERAL.
fixup_Mips_LITERAL, fixup_Mips_LITERAL,
// Global symbol fixup resulting in - R_MIPS_GOT16. // Symbol fixup resulting in - R_MIPS_GOT16.
fixup_Mips_GOT_Global, fixup_Mips_GOT,
// Local symbol fixup resulting in - R_MIPS_GOT16.
fixup_Mips_GOT_Local,
// PC relative branch fixup resulting in - R_MIPS_PC16. // PC relative branch fixup resulting in - R_MIPS_PC16.
fixup_Mips_PC16, fixup_Mips_PC16,

View File

@ -509,20 +509,103 @@ getExprOpValue(const MCExpr *Expr, SmallVectorImpl<MCFixup> &Fixups,
Mips::Fixups FixupKind = Mips::Fixups(0); Mips::Fixups FixupKind = Mips::Fixups(0);
switch (MipsExpr->getKind()) { switch (MipsExpr->getKind()) {
default: llvm_unreachable("Unsupported fixup kind for target expression!"); case MipsMCExpr::MEK_NEG:
case MipsMCExpr::VK_Mips_HIGHEST: case MipsMCExpr::MEK_None:
case MipsMCExpr::MEK_Special:
llvm_unreachable("Unhandled fixup kind!");
break;
case MipsMCExpr::MEK_CALL_HI16:
FixupKind = Mips::fixup_Mips_CALL_HI16;
break;
case MipsMCExpr::MEK_CALL_LO16:
FixupKind = Mips::fixup_Mips_CALL_LO16;
break;
case MipsMCExpr::MEK_DTPREL_HI:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_TLS_DTPREL_HI16
: Mips::fixup_Mips_DTPREL_HI;
break;
case MipsMCExpr::MEK_DTPREL_LO:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_TLS_DTPREL_LO16
: Mips::fixup_Mips_DTPREL_LO;
break;
case MipsMCExpr::MEK_GOTTPREL:
FixupKind = Mips::fixup_Mips_GOTTPREL;
break;
case MipsMCExpr::MEK_GOT:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_GOT16
: Mips::fixup_Mips_GOT;
break;
case MipsMCExpr::MEK_GOT_CALL:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_CALL16
: Mips::fixup_Mips_CALL16;
break;
case MipsMCExpr::MEK_GOT_DISP:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_GOT_DISP
: Mips::fixup_Mips_GOT_DISP;
break;
case MipsMCExpr::MEK_GOT_HI16:
FixupKind = Mips::fixup_Mips_GOT_HI16;
break;
case MipsMCExpr::MEK_GOT_LO16:
FixupKind = Mips::fixup_Mips_GOT_LO16;
break;
case MipsMCExpr::MEK_GOT_PAGE:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_GOT_PAGE
: Mips::fixup_Mips_GOT_PAGE;
break;
case MipsMCExpr::MEK_GOT_OFST:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_GOT_OFST
: Mips::fixup_Mips_GOT_OFST;
break;
case MipsMCExpr::MEK_GPREL:
FixupKind = Mips::fixup_Mips_GPREL16;
break;
case MipsMCExpr::MEK_LO: {
// Check for %lo(%neg(%gp_rel(X)))
if (MipsExpr->isGpOff()) {
FixupKind = Mips::fixup_Mips_GPOFF_LO;
break;
}
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_LO16
: Mips::fixup_Mips_LO16;
break;
}
case MipsMCExpr::MEK_HIGHEST:
FixupKind = Mips::fixup_Mips_HIGHEST; FixupKind = Mips::fixup_Mips_HIGHEST;
break; break;
case MipsMCExpr::VK_Mips_HIGHER: case MipsMCExpr::MEK_HIGHER:
FixupKind = Mips::fixup_Mips_HIGHER; FixupKind = Mips::fixup_Mips_HIGHER;
break; break;
case MipsMCExpr::VK_Mips_HI: case MipsMCExpr::MEK_HI:
// Check for %hi(%neg(%gp_rel(X)))
if (MipsExpr->isGpOff()) {
FixupKind = Mips::fixup_Mips_GPOFF_HI;
break;
}
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_HI16 FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_HI16
: Mips::fixup_Mips_HI16; : Mips::fixup_Mips_HI16;
break; break;
case MipsMCExpr::VK_Mips_LO: case MipsMCExpr::MEK_PCREL_HI16:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_LO16 FixupKind = Mips::fixup_MIPS_PCHI16;
: Mips::fixup_Mips_LO16; break;
case MipsMCExpr::MEK_PCREL_LO16:
FixupKind = Mips::fixup_MIPS_PCLO16;
break;
case MipsMCExpr::MEK_TLSGD:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_TLS_GD
: Mips::fixup_Mips_TLSGD;
break;
case MipsMCExpr::MEK_TLSLDM:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_TLS_LDM
: Mips::fixup_Mips_TLSLDM;
break;
case MipsMCExpr::MEK_TPREL_HI:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_TLS_TPREL_HI16
: Mips::fixup_Mips_TPREL_HI;
break;
case MipsMCExpr::MEK_TPREL_LO:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_TLS_TPREL_LO16
: Mips::fixup_Mips_TPREL_LO;
break; break;
} }
Fixups.push_back(MCFixup::create(0, MipsExpr, MCFixupKind(FixupKind))); Fixups.push_back(MCFixup::create(0, MipsExpr, MCFixupKind(FixupKind)));
@ -538,98 +621,6 @@ getExprOpValue(const MCExpr *Expr, SmallVectorImpl<MCFixup> &Fixups,
case MCSymbolRefExpr::VK_None: case MCSymbolRefExpr::VK_None:
FixupKind = Mips::fixup_Mips_32; // FIXME: This is ok for O32/N32 but not N64. FixupKind = Mips::fixup_Mips_32; // FIXME: This is ok for O32/N32 but not N64.
break; break;
case MCSymbolRefExpr::VK_Mips_GPOFF_HI :
FixupKind = Mips::fixup_Mips_GPOFF_HI;
break;
case MCSymbolRefExpr::VK_Mips_GPOFF_LO :
FixupKind = Mips::fixup_Mips_GPOFF_LO;
break;
case MCSymbolRefExpr::VK_Mips_GOT_PAGE :
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_GOT_PAGE
: Mips::fixup_Mips_GOT_PAGE;
break;
case MCSymbolRefExpr::VK_Mips_GOT_OFST :
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_GOT_OFST
: Mips::fixup_Mips_GOT_OFST;
break;
case MCSymbolRefExpr::VK_Mips_GOT_DISP :
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_GOT_DISP
: Mips::fixup_Mips_GOT_DISP;
break;
case MCSymbolRefExpr::VK_Mips_GPREL:
FixupKind = Mips::fixup_Mips_GPREL16;
break;
case MCSymbolRefExpr::VK_Mips_GOT_CALL:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_CALL16
: Mips::fixup_Mips_CALL16;
break;
case MCSymbolRefExpr::VK_Mips_GOT16:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_GOT16
: Mips::fixup_Mips_GOT_Global;
break;
case MCSymbolRefExpr::VK_Mips_GOT:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_GOT16
: Mips::fixup_Mips_GOT_Local;
break;
case MCSymbolRefExpr::VK_Mips_ABS_HI:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_HI16
: Mips::fixup_Mips_HI16;
break;
case MCSymbolRefExpr::VK_Mips_ABS_LO:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_LO16
: Mips::fixup_Mips_LO16;
break;
case MCSymbolRefExpr::VK_Mips_TLSGD:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_TLS_GD
: Mips::fixup_Mips_TLSGD;
break;
case MCSymbolRefExpr::VK_Mips_TLSLDM:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_TLS_LDM
: Mips::fixup_Mips_TLSLDM;
break;
case MCSymbolRefExpr::VK_Mips_DTPREL_HI:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_TLS_DTPREL_HI16
: Mips::fixup_Mips_DTPREL_HI;
break;
case MCSymbolRefExpr::VK_Mips_DTPREL_LO:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_TLS_DTPREL_LO16
: Mips::fixup_Mips_DTPREL_LO;
break;
case MCSymbolRefExpr::VK_Mips_GOTTPREL:
FixupKind = Mips::fixup_Mips_GOTTPREL;
break;
case MCSymbolRefExpr::VK_Mips_TPREL_HI:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_TLS_TPREL_HI16
: Mips::fixup_Mips_TPREL_HI;
break;
case MCSymbolRefExpr::VK_Mips_TPREL_LO:
FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_TLS_TPREL_LO16
: Mips::fixup_Mips_TPREL_LO;
break;
case MCSymbolRefExpr::VK_Mips_HIGHER:
FixupKind = Mips::fixup_Mips_HIGHER;
break;
case MCSymbolRefExpr::VK_Mips_HIGHEST:
FixupKind = Mips::fixup_Mips_HIGHEST;
break;
case MCSymbolRefExpr::VK_Mips_GOT_HI16:
FixupKind = Mips::fixup_Mips_GOT_HI16;
break;
case MCSymbolRefExpr::VK_Mips_GOT_LO16:
FixupKind = Mips::fixup_Mips_GOT_LO16;
break;
case MCSymbolRefExpr::VK_Mips_CALL_HI16:
FixupKind = Mips::fixup_Mips_CALL_HI16;
break;
case MCSymbolRefExpr::VK_Mips_CALL_LO16:
FixupKind = Mips::fixup_Mips_CALL_LO16;
break;
case MCSymbolRefExpr::VK_Mips_PCREL_HI16:
FixupKind = Mips::fixup_MIPS_PCHI16;
break;
case MCSymbolRefExpr::VK_Mips_PCREL_LO16:
FixupKind = Mips::fixup_MIPS_PCLO16;
break;
} // switch } // switch
Fixups.push_back(MCFixup::create(0, Expr, MCFixupKind(FixupKind))); Fixups.push_back(MCFixup::create(0, Expr, MCFixupKind(FixupKind)));

View File

@ -12,69 +12,110 @@
#include "llvm/MC/MCAssembler.h" #include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCContext.h" #include "llvm/MC/MCContext.h"
#include "llvm/MC/MCObjectStreamer.h" #include "llvm/MC/MCObjectStreamer.h"
#include "llvm/MC/MCSymbolELF.h"
#include "llvm/Support/ELF.h"
using namespace llvm; using namespace llvm;
#define DEBUG_TYPE "mipsmcexpr" #define DEBUG_TYPE "mipsmcexpr"
bool MipsMCExpr::isSupportedBinaryExpr(MCSymbolRefExpr::VariantKind VK, const MipsMCExpr *MipsMCExpr::create(MipsMCExpr::MipsExprKind Kind,
const MCBinaryExpr *BE) { const MCExpr *Expr, MCContext &Ctx) {
switch (VK) {
case MCSymbolRefExpr::VK_Mips_ABS_LO:
case MCSymbolRefExpr::VK_Mips_ABS_HI:
case MCSymbolRefExpr::VK_Mips_HIGHER:
case MCSymbolRefExpr::VK_Mips_HIGHEST:
break;
default:
return false;
}
// We support expressions of the form "(sym1 binop1 sym2) binop2 const",
// where "binop2 const" is optional.
if (isa<MCBinaryExpr>(BE->getLHS())) {
if (!isa<MCConstantExpr>(BE->getRHS()))
return false;
BE = cast<MCBinaryExpr>(BE->getLHS());
}
return (isa<MCSymbolRefExpr>(BE->getLHS())
&& isa<MCSymbolRefExpr>(BE->getRHS()));
}
const MipsMCExpr*
MipsMCExpr::create(MCSymbolRefExpr::VariantKind VK, const MCExpr *Expr,
MCContext &Ctx) {
VariantKind Kind;
switch (VK) {
case MCSymbolRefExpr::VK_Mips_ABS_LO:
Kind = VK_Mips_LO;
break;
case MCSymbolRefExpr::VK_Mips_ABS_HI:
Kind = VK_Mips_HI;
break;
case MCSymbolRefExpr::VK_Mips_HIGHER:
Kind = VK_Mips_HIGHER;
break;
case MCSymbolRefExpr::VK_Mips_HIGHEST:
Kind = VK_Mips_HIGHEST;
break;
default:
llvm_unreachable("Invalid kind!");
}
return new (Ctx) MipsMCExpr(Kind, Expr); return new (Ctx) MipsMCExpr(Kind, Expr);
} }
const MipsMCExpr *MipsMCExpr::createGpOff(MipsMCExpr::MipsExprKind Kind,
const MCExpr *Expr, MCContext &Ctx) {
return create(Kind, create(MEK_NEG, create(MEK_GPREL, Expr, Ctx), Ctx), Ctx);
}
void MipsMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const { void MipsMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
int64_t AbsVal;
switch (Kind) { switch (Kind) {
default: llvm_unreachable("Invalid kind!"); case MEK_None:
case VK_Mips_LO: OS << "%lo"; break; case MEK_Special:
case VK_Mips_HI: OS << "%hi"; break; llvm_unreachable("MEK_None and MEK_Special are invalid");
case VK_Mips_HIGHER: OS << "%higher"; break; break;
case VK_Mips_HIGHEST: OS << "%highest"; break; 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 << '('; OS << '(';
Expr->print(OS, MAI); if (Expr->evaluateAsAbsolute(AbsVal))
OS << AbsVal;
else
Expr->print(OS, MAI, true);
OS << ')'; OS << ')';
} }
@ -82,9 +123,165 @@ bool
MipsMCExpr::evaluateAsRelocatableImpl(MCValue &Res, MipsMCExpr::evaluateAsRelocatableImpl(MCValue &Res,
const MCAsmLayout *Layout, const MCAsmLayout *Layout,
const MCFixup *Fixup) const { const MCFixup *Fixup) const {
return getSubExpr()->evaluateAsRelocatable(Res, Layout, Fixup); // 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, Layout, Fixup))
return false;
Res = MCValue::get(Res.getSymA(), Res.getSymB(), Res.getConstant(),
MEK_Special);
return true;
}
if (!getSubExpr()->evaluateAsRelocatable(Res, Layout, Fixup))
return false;
if (Res.getRefKind() != MCSymbolRefExpr::VK_None)
return false;
// evaluateAsAbsolute() and evaluateAsValue() require that we evaluate the
// %hi/%lo/etc. here. Fixup is a null pointer when either of these is the
// caller.
if (Res.isAbsolute() && Fixup == nullptr) {
int64_t AbsVal = Res.getConstant();
switch (Kind) {
case MEK_None:
case MEK_Special:
llvm_unreachable("MEK_None and MEK_Special are invalid");
case MEK_DTPREL_HI:
case MEK_DTPREL_LO:
case MEK_GOT:
case MEK_GOTTPREL:
case MEK_GOT_CALL:
case MEK_GOT_DISP:
case MEK_GOT_HI16:
case MEK_GOT_LO16:
case MEK_GOT_OFST:
case MEK_GOT_PAGE:
case MEK_GPREL:
case MEK_PCREL_HI16:
case MEK_PCREL_LO16:
case MEK_TLSGD:
case MEK_TLSLDM:
case MEK_TPREL_HI:
case MEK_TPREL_LO:
return false;
case MEK_LO:
case MEK_CALL_LO16:
AbsVal = SignExtend64<16>(AbsVal);
break;
case MEK_CALL_HI16:
case MEK_HI:
AbsVal = SignExtend64<16>((AbsVal + 0x8000) >> 16);
break;
case MEK_HIGHER:
AbsVal = SignExtend64<16>((AbsVal + 0x80008000LL) >> 32);
break;
case MEK_HIGHEST:
AbsVal = SignExtend64<16>((AbsVal + 0x800080008000LL) >> 48);
break;
case MEK_NEG:
AbsVal = -AbsVal;
break;
}
Res = MCValue::get(AbsVal);
return true;
}
// We want to defer it for relocatable expressions since the constant is
// applied to the whole symbol value.
//
// The value of getKind() that is given to MCValue is only intended to aid
// debugging when inspecting MCValue objects. It shouldn't be relied upon
// for decision making.
Res = MCValue::get(Res.getSymA(), Res.getSymB(), Res.getConstant(), getKind());
return true;
} }
void MipsMCExpr::visitUsedExpr(MCStreamer &Streamer) const { void MipsMCExpr::visitUsedExpr(MCStreamer &Streamer) const {
Streamer.visitUsedExpr(*getSubExpr()); Streamer.visitUsedExpr(*getSubExpr());
} }
static void fixELFSymbolsInTLSFixupsImpl(const MCExpr *Expr, MCAssembler &Asm) {
switch (Expr->getKind()) {
case MCExpr::Target:
fixELFSymbolsInTLSFixupsImpl(cast<MipsMCExpr>(Expr)->getSubExpr(), Asm);
break;
case MCExpr::Constant:
break;
case MCExpr::Binary: {
const MCBinaryExpr *BE = cast<MCBinaryExpr>(Expr);
fixELFSymbolsInTLSFixupsImpl(BE->getLHS(), Asm);
fixELFSymbolsInTLSFixupsImpl(BE->getRHS(), Asm);
break;
}
case MCExpr::SymbolRef: {
// We're known to be under a TLS fixup, so any symbol should be
// modified. There should be only one.
const MCSymbolRefExpr &SymRef = *cast<MCSymbolRefExpr>(Expr);
cast<MCSymbolELF>(SymRef.getSymbol()).setType(ELF::STT_TLS);
break;
}
case MCExpr::Unary:
fixELFSymbolsInTLSFixupsImpl(cast<MCUnaryExpr>(Expr)->getSubExpr(), Asm);
break;
}
}
void MipsMCExpr::fixELFSymbolsInTLSFixups(MCAssembler &Asm) const {
switch (getKind()) {
case MEK_None:
case MEK_Special:
llvm_unreachable("MEK_None and MEK_Special are invalid");
break;
case MEK_CALL_HI16:
case MEK_CALL_LO16:
case MEK_DTPREL_HI:
case MEK_DTPREL_LO:
case MEK_GOT:
case MEK_GOT_CALL:
case MEK_GOT_DISP:
case MEK_GOT_HI16:
case MEK_GOT_LO16:
case MEK_GOT_OFST:
case MEK_GOT_PAGE:
case MEK_GPREL:
case MEK_HI:
case MEK_HIGHER:
case MEK_HIGHEST:
case MEK_LO:
case MEK_NEG:
case MEK_PCREL_HI16:
case MEK_PCREL_LO16:
case MEK_TLSLDM:
// If we do have nested target-specific expressions, they will be in
// a consecutive chain.
if (const MipsMCExpr *E = dyn_cast<const MipsMCExpr>(getSubExpr()))
E->fixELFSymbolsInTLSFixups(Asm);
break;
case MEK_GOTTPREL:
case MEK_TLSGD:
case MEK_TPREL_HI:
case MEK_TPREL_LO:
fixELFSymbolsInTLSFixupsImpl(getSubExpr(), Asm);
break;
}
}
bool MipsMCExpr::isGpOff(MipsExprKind &Kind) const {
if (getKind() == MEK_HI || getKind() == MEK_LO) {
if (const MipsMCExpr *S1 = dyn_cast<const MipsMCExpr>(getSubExpr())) {
if (const MipsMCExpr *S2 = dyn_cast<const MipsMCExpr>(S1->getSubExpr())) {
if (S1->getKind() == MEK_NEG && S2->getKind() == MEK_GPREL) {
Kind = getKind();
return true;
}
}
}
}
return false;
}

View File

@ -18,49 +18,73 @@ namespace llvm {
class MipsMCExpr : public MCTargetExpr { class MipsMCExpr : public MCTargetExpr {
public: public:
enum VariantKind { enum MipsExprKind {
VK_Mips_None, MEK_None,
VK_Mips_LO, MEK_CALL_HI16,
VK_Mips_HI, MEK_CALL_LO16,
VK_Mips_HIGHER, MEK_DTPREL_HI,
VK_Mips_HIGHEST 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: private:
const VariantKind Kind; const MipsExprKind Kind;
const MCExpr *Expr; const MCExpr *Expr;
explicit MipsMCExpr(VariantKind Kind, const MCExpr *Expr) explicit MipsMCExpr(MipsExprKind Kind, const MCExpr *Expr)
: Kind(Kind), Expr(Expr) {} : Kind(Kind), Expr(Expr) {}
public: public:
static bool isSupportedBinaryExpr(MCSymbolRefExpr::VariantKind VK, static const MipsMCExpr *create(MipsExprKind Kind, const MCExpr *Expr,
const MCBinaryExpr *BE); MCContext &Ctx);
static const MipsMCExpr *createGpOff(MipsExprKind Kind, const MCExpr *Expr,
MCContext &Ctx);
static const MipsMCExpr *create(MCSymbolRefExpr::VariantKind VK, /// Get the kind of this expression.
const MCExpr *Expr, MCContext &Ctx); MipsExprKind getKind() const { return Kind; }
/// getOpcode - Get the kind of this expression. /// Get the child of this expression.
VariantKind getKind() const { return Kind; }
/// getSubExpr - Get the child of this expression.
const MCExpr *getSubExpr() const { return Expr; } const MCExpr *getSubExpr() const { return Expr; }
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override; void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
bool evaluateAsRelocatableImpl(MCValue &Res, bool evaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout,
const MCAsmLayout *Layout,
const MCFixup *Fixup) const override; const MCFixup *Fixup) const override;
void visitUsedExpr(MCStreamer &Streamer) const override; void visitUsedExpr(MCStreamer &Streamer) const override;
MCFragment *findAssociatedFragment() const override { MCFragment *findAssociatedFragment() const override {
return getSubExpr()->findAssociatedFragment(); return getSubExpr()->findAssociatedFragment();
} }
// There are no TLS MipsMCExprs at the moment. void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override;
void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {}
static bool classof(const MCExpr *E) { static bool classof(const MCExpr *E) {
return E->getKind() == MCExpr::Target; return E->getKind() == MCExpr::Target;
} }
bool isGpOff(MipsExprKind &Kind) const;
bool isGpOff() const {
MipsExprKind Kind;
return isGpOff(Kind);
}
}; };
} // end namespace llvm } // end namespace llvm

View File

@ -14,6 +14,7 @@
#include "MipsTargetStreamer.h" #include "MipsTargetStreamer.h"
#include "InstPrinter/MipsInstPrinter.h" #include "InstPrinter/MipsInstPrinter.h"
#include "MipsELFStreamer.h" #include "MipsELFStreamer.h"
#include "MipsMCExpr.h"
#include "MipsMCTargetDesc.h" #include "MipsMCTargetDesc.h"
#include "MipsTargetObjectFile.h" #include "MipsTargetObjectFile.h"
#include "llvm/MC/MCContext.h" #include "llvm/MC/MCContext.h"
@ -981,8 +982,11 @@ void MipsTargetELFStreamer::emitDirectiveCpLoad(unsigned RegNo) {
MCInst TmpInst; MCInst TmpInst;
TmpInst.setOpcode(Mips::LUi); TmpInst.setOpcode(Mips::LUi);
TmpInst.addOperand(MCOperand::createReg(Mips::GP)); TmpInst.addOperand(MCOperand::createReg(Mips::GP));
const MCSymbolRefExpr *HiSym = MCSymbolRefExpr::create( const MCExpr *HiSym = MipsMCExpr::create(
"_gp_disp", MCSymbolRefExpr::VK_Mips_ABS_HI, MCA.getContext()); MipsMCExpr::MEK_HI,
MCSymbolRefExpr::create("_gp_disp", MCSymbolRefExpr::VK_None,
MCA.getContext()),
MCA.getContext());
TmpInst.addOperand(MCOperand::createExpr(HiSym)); TmpInst.addOperand(MCOperand::createExpr(HiSym));
getStreamer().EmitInstruction(TmpInst, STI); getStreamer().EmitInstruction(TmpInst, STI);
@ -991,8 +995,11 @@ void MipsTargetELFStreamer::emitDirectiveCpLoad(unsigned RegNo) {
TmpInst.setOpcode(Mips::ADDiu); TmpInst.setOpcode(Mips::ADDiu);
TmpInst.addOperand(MCOperand::createReg(Mips::GP)); TmpInst.addOperand(MCOperand::createReg(Mips::GP));
TmpInst.addOperand(MCOperand::createReg(Mips::GP)); TmpInst.addOperand(MCOperand::createReg(Mips::GP));
const MCSymbolRefExpr *LoSym = MCSymbolRefExpr::create( const MCExpr *LoSym = MipsMCExpr::create(
"_gp_disp", MCSymbolRefExpr::VK_Mips_ABS_LO, MCA.getContext()); MipsMCExpr::MEK_LO,
MCSymbolRefExpr::create("_gp_disp", MCSymbolRefExpr::VK_None,
MCA.getContext()),
MCA.getContext());
TmpInst.addOperand(MCOperand::createExpr(LoSym)); TmpInst.addOperand(MCOperand::createExpr(LoSym));
getStreamer().EmitInstruction(TmpInst, STI); getStreamer().EmitInstruction(TmpInst, STI);
@ -1055,10 +1062,12 @@ void MipsTargetELFStreamer::emitDirectiveCpsetup(unsigned RegNo,
getStreamer().EmitInstruction(Inst, STI); getStreamer().EmitInstruction(Inst, STI);
Inst.clear(); Inst.clear();
const MCSymbolRefExpr *HiExpr = MCSymbolRefExpr::create( const MipsMCExpr *HiExpr = MipsMCExpr::createGpOff(
&Sym, MCSymbolRefExpr::VK_Mips_GPOFF_HI, MCA.getContext()); MipsMCExpr::MEK_HI, MCSymbolRefExpr::create(&Sym, MCA.getContext()),
const MCSymbolRefExpr *LoExpr = MCSymbolRefExpr::create( MCA.getContext());
&Sym, MCSymbolRefExpr::VK_Mips_GPOFF_LO, MCA.getContext()); const MipsMCExpr *LoExpr = MipsMCExpr::createGpOff(
MipsMCExpr::MEK_LO, MCSymbolRefExpr::create(&Sym, MCA.getContext()),
MCA.getContext());
// lui $gp, %hi(%neg(%gp_rel(funcSym))) // lui $gp, %hi(%neg(%gp_rel(funcSym)))
Inst.setOpcode(Mips::LUi); Inst.setOpcode(Mips::LUi);

View File

@ -1746,7 +1746,7 @@ SDValue MipsTargetLowering::lowerGlobalAddress(SDValue Op,
return getAddrGlobal( return getAddrGlobal(
N, SDLoc(N), Ty, DAG, N, SDLoc(N), Ty, DAG,
(ABI.IsN32() || ABI.IsN64()) ? MipsII::MO_GOT_DISP : MipsII::MO_GOT16, (ABI.IsN32() || ABI.IsN64()) ? MipsII::MO_GOT_DISP : MipsII::MO_GOT,
DAG.getEntryNode(), MachinePointerInfo::getGOT(DAG.getMachineFunction())); DAG.getEntryNode(), MachinePointerInfo::getGOT(DAG.getMachineFunction()));
} }

View File

@ -36,36 +36,87 @@ void MipsMCInstLower::Initialize(MCContext *C) {
MCOperand MipsMCInstLower::LowerSymbolOperand(const MachineOperand &MO, MCOperand MipsMCInstLower::LowerSymbolOperand(const MachineOperand &MO,
MachineOperandType MOTy, MachineOperandType MOTy,
unsigned Offset) const { unsigned Offset) const {
MCSymbolRefExpr::VariantKind Kind; MCSymbolRefExpr::VariantKind Kind = MCSymbolRefExpr::VK_None;
MipsMCExpr::MipsExprKind TargetKind = MipsMCExpr::MEK_None;
bool IsGpOff = false;
const MCSymbol *Symbol; const MCSymbol *Symbol;
switch(MO.getTargetFlags()) { switch(MO.getTargetFlags()) {
default: llvm_unreachable("Invalid target flag!"); default:
case MipsII::MO_NO_FLAG: Kind = MCSymbolRefExpr::VK_None; break; llvm_unreachable("Invalid target flag!");
case MipsII::MO_GPREL: Kind = MCSymbolRefExpr::VK_Mips_GPREL; break; case MipsII::MO_NO_FLAG:
case MipsII::MO_GOT_CALL: Kind = MCSymbolRefExpr::VK_Mips_GOT_CALL; break; break;
case MipsII::MO_GOT16: Kind = MCSymbolRefExpr::VK_Mips_GOT16; break; case MipsII::MO_GPREL:
case MipsII::MO_GOT: Kind = MCSymbolRefExpr::VK_Mips_GOT; break; TargetKind = MipsMCExpr::MEK_GPREL;
case MipsII::MO_ABS_HI: Kind = MCSymbolRefExpr::VK_Mips_ABS_HI; break; break;
case MipsII::MO_ABS_LO: Kind = MCSymbolRefExpr::VK_Mips_ABS_LO; break; case MipsII::MO_GOT_CALL:
case MipsII::MO_TLSGD: Kind = MCSymbolRefExpr::VK_Mips_TLSGD; break; TargetKind = MipsMCExpr::MEK_GOT_CALL;
case MipsII::MO_TLSLDM: Kind = MCSymbolRefExpr::VK_Mips_TLSLDM; break; break;
case MipsII::MO_DTPREL_HI: Kind = MCSymbolRefExpr::VK_Mips_DTPREL_HI; break; case MipsII::MO_GOT:
case MipsII::MO_DTPREL_LO: Kind = MCSymbolRefExpr::VK_Mips_DTPREL_LO; break; TargetKind = MipsMCExpr::MEK_GOT;
case MipsII::MO_GOTTPREL: Kind = MCSymbolRefExpr::VK_Mips_GOTTPREL; break; break;
case MipsII::MO_TPREL_HI: Kind = MCSymbolRefExpr::VK_Mips_TPREL_HI; break; case MipsII::MO_ABS_HI:
case MipsII::MO_TPREL_LO: Kind = MCSymbolRefExpr::VK_Mips_TPREL_LO; break; TargetKind = MipsMCExpr::MEK_HI;
case MipsII::MO_GPOFF_HI: Kind = MCSymbolRefExpr::VK_Mips_GPOFF_HI; break; break;
case MipsII::MO_GPOFF_LO: Kind = MCSymbolRefExpr::VK_Mips_GPOFF_LO; break; case MipsII::MO_ABS_LO:
case MipsII::MO_GOT_DISP: Kind = MCSymbolRefExpr::VK_Mips_GOT_DISP; break; TargetKind = MipsMCExpr::MEK_LO;
case MipsII::MO_GOT_PAGE: Kind = MCSymbolRefExpr::VK_Mips_GOT_PAGE; break; break;
case MipsII::MO_GOT_OFST: Kind = MCSymbolRefExpr::VK_Mips_GOT_OFST; break; case MipsII::MO_TLSGD:
case MipsII::MO_HIGHER: Kind = MCSymbolRefExpr::VK_Mips_HIGHER; break; TargetKind = MipsMCExpr::MEK_TLSGD;
case MipsII::MO_HIGHEST: Kind = MCSymbolRefExpr::VK_Mips_HIGHEST; break; break;
case MipsII::MO_GOT_HI16: Kind = MCSymbolRefExpr::VK_Mips_GOT_HI16; break; case MipsII::MO_TLSLDM:
case MipsII::MO_GOT_LO16: Kind = MCSymbolRefExpr::VK_Mips_GOT_LO16; break; TargetKind = MipsMCExpr::MEK_TLSLDM;
case MipsII::MO_CALL_HI16: Kind = MCSymbolRefExpr::VK_Mips_CALL_HI16; break; break;
case MipsII::MO_CALL_LO16: Kind = MCSymbolRefExpr::VK_Mips_CALL_LO16; break; case MipsII::MO_DTPREL_HI:
TargetKind = MipsMCExpr::MEK_DTPREL_HI;
break;
case MipsII::MO_DTPREL_LO:
TargetKind = MipsMCExpr::MEK_DTPREL_LO;
break;
case MipsII::MO_GOTTPREL:
TargetKind = MipsMCExpr::MEK_GOTTPREL;
break;
case MipsII::MO_TPREL_HI:
TargetKind = MipsMCExpr::MEK_TPREL_HI;
break;
case MipsII::MO_TPREL_LO:
TargetKind = MipsMCExpr::MEK_TPREL_LO;
break;
case MipsII::MO_GPOFF_HI:
TargetKind = MipsMCExpr::MEK_HI;
IsGpOff = true;
break;
case MipsII::MO_GPOFF_LO:
TargetKind = MipsMCExpr::MEK_LO;
IsGpOff = true;
break;
case MipsII::MO_GOT_DISP:
TargetKind = MipsMCExpr::MEK_GOT_DISP;
break;
case MipsII::MO_GOT_HI16:
TargetKind = MipsMCExpr::MEK_GOT_HI16;
break;
case MipsII::MO_GOT_LO16:
TargetKind = MipsMCExpr::MEK_GOT_LO16;
break;
case MipsII::MO_GOT_PAGE:
TargetKind = MipsMCExpr::MEK_GOT_PAGE;
break;
case MipsII::MO_GOT_OFST:
TargetKind = MipsMCExpr::MEK_GOT_OFST;
break;
case MipsII::MO_HIGHER:
TargetKind = MipsMCExpr::MEK_HIGHER;
break;
case MipsII::MO_HIGHEST:
TargetKind = MipsMCExpr::MEK_HIGHEST;
break;
case MipsII::MO_CALL_HI16:
TargetKind = MipsMCExpr::MEK_CALL_HI16;
break;
case MipsII::MO_CALL_LO16:
TargetKind = MipsMCExpr::MEK_CALL_LO16;
break;
} }
switch (MOTy) { switch (MOTy) {
@ -106,31 +157,24 @@ MCOperand MipsMCInstLower::LowerSymbolOperand(const MachineOperand &MO,
llvm_unreachable("<unknown operand type>"); llvm_unreachable("<unknown operand type>");
} }
const MCSymbolRefExpr *MCSym = MCSymbolRefExpr::create(Symbol, Kind, *Ctx); const MCExpr *Expr = MCSymbolRefExpr::create(Symbol, Kind, *Ctx);
if (!Offset) if (Offset) {
return MCOperand::createExpr(MCSym); // Assume offset is never negative.
assert(Offset > 0);
// Assume offset is never negative. Expr = MCBinaryExpr::createAdd(Expr, MCConstantExpr::create(Offset, *Ctx),
assert(Offset > 0); *Ctx);
}
const MCConstantExpr *OffsetExpr = MCConstantExpr::create(Offset, *Ctx); if (IsGpOff)
const MCBinaryExpr *Add = MCBinaryExpr::createAdd(MCSym, OffsetExpr, *Ctx); Expr = MipsMCExpr::createGpOff(TargetKind, Expr, *Ctx);
return MCOperand::createExpr(Add); else if (TargetKind != MipsMCExpr::MEK_None)
Expr = MipsMCExpr::create(TargetKind, Expr, *Ctx);
return MCOperand::createExpr(Expr);
} }
/*
static void CreateMCInst(MCInst& Inst, unsigned Opc, const MCOperand &Opnd0,
const MCOperand &Opnd1,
const MCOperand &Opnd2 = MCOperand()) {
Inst.setOpcode(Opc);
Inst.addOperand(Opnd0);
Inst.addOperand(Opnd1);
if (Opnd2.isValid())
Inst.addOperand(Opnd2);
}
*/
MCOperand MipsMCInstLower::LowerOperand(const MachineOperand &MO, MCOperand MipsMCInstLower::LowerOperand(const MachineOperand &MO,
unsigned offset) const { unsigned offset) const {
MachineOperandType MOTy = MO.getType(); MachineOperandType MOTy = MO.getType();
@ -160,7 +204,7 @@ MCOperand MipsMCInstLower::LowerOperand(const MachineOperand &MO,
MCOperand MipsMCInstLower::createSub(MachineBasicBlock *BB1, MCOperand MipsMCInstLower::createSub(MachineBasicBlock *BB1,
MachineBasicBlock *BB2, MachineBasicBlock *BB2,
MCSymbolRefExpr::VariantKind Kind) const { MipsMCExpr::MipsExprKind Kind) const {
const MCSymbolRefExpr *Sym1 = MCSymbolRefExpr::create(BB1->getSymbol(), *Ctx); const MCSymbolRefExpr *Sym1 = MCSymbolRefExpr::create(BB1->getSymbol(), *Ctx);
const MCSymbolRefExpr *Sym2 = MCSymbolRefExpr::create(BB2->getSymbol(), *Ctx); const MCSymbolRefExpr *Sym2 = MCSymbolRefExpr::create(BB2->getSymbol(), *Ctx);
const MCBinaryExpr *Sub = MCBinaryExpr::createSub(Sym1, Sym2, *Ctx); const MCBinaryExpr *Sub = MCBinaryExpr::createSub(Sym1, Sym2, *Ctx);
@ -178,12 +222,12 @@ lowerLongBranchLUi(const MachineInstr *MI, MCInst &OutMI) const {
// Create %hi($tgt-$baltgt). // Create %hi($tgt-$baltgt).
OutMI.addOperand(createSub(MI->getOperand(1).getMBB(), OutMI.addOperand(createSub(MI->getOperand(1).getMBB(),
MI->getOperand(2).getMBB(), MI->getOperand(2).getMBB(),
MCSymbolRefExpr::VK_Mips_ABS_HI)); MipsMCExpr::MEK_HI));
} }
void MipsMCInstLower:: void MipsMCInstLower::lowerLongBranchADDiu(
lowerLongBranchADDiu(const MachineInstr *MI, MCInst &OutMI, int Opcode, const MachineInstr *MI, MCInst &OutMI, int Opcode,
MCSymbolRefExpr::VariantKind Kind) const { MipsMCExpr::MipsExprKind Kind) const {
OutMI.setOpcode(Opcode); OutMI.setOpcode(Opcode);
// Lower two register operands. // Lower two register operands.
@ -206,17 +250,14 @@ bool MipsMCInstLower::lowerLongBranch(const MachineInstr *MI,
lowerLongBranchLUi(MI, OutMI); lowerLongBranchLUi(MI, OutMI);
return true; return true;
case Mips::LONG_BRANCH_ADDiu: case Mips::LONG_BRANCH_ADDiu:
lowerLongBranchADDiu(MI, OutMI, Mips::ADDiu, lowerLongBranchADDiu(MI, OutMI, Mips::ADDiu, MipsMCExpr::MEK_LO);
MCSymbolRefExpr::VK_Mips_ABS_LO);
return true; return true;
case Mips::LONG_BRANCH_DADDiu: case Mips::LONG_BRANCH_DADDiu:
unsigned TargetFlags = MI->getOperand(2).getTargetFlags(); unsigned TargetFlags = MI->getOperand(2).getTargetFlags();
if (TargetFlags == MipsII::MO_ABS_HI) if (TargetFlags == MipsII::MO_ABS_HI)
lowerLongBranchADDiu(MI, OutMI, Mips::DADDiu, lowerLongBranchADDiu(MI, OutMI, Mips::DADDiu, MipsMCExpr::MEK_HI);
MCSymbolRefExpr::VK_Mips_ABS_HI);
else if (TargetFlags == MipsII::MO_ABS_LO) else if (TargetFlags == MipsII::MO_ABS_LO)
lowerLongBranchADDiu(MI, OutMI, Mips::DADDiu, lowerLongBranchADDiu(MI, OutMI, Mips::DADDiu, MipsMCExpr::MEK_LO);
MCSymbolRefExpr::VK_Mips_ABS_LO);
else else
report_fatal_error("Unexpected flags for LONG_BRANCH_DADDiu"); report_fatal_error("Unexpected flags for LONG_BRANCH_DADDiu");
return true; return true;

View File

@ -37,11 +37,10 @@ private:
MCOperand LowerSymbolOperand(const MachineOperand &MO, MCOperand LowerSymbolOperand(const MachineOperand &MO,
MachineOperandType MOTy, unsigned Offset) const; MachineOperandType MOTy, unsigned Offset) const;
MCOperand createSub(MachineBasicBlock *BB1, MachineBasicBlock *BB2, MCOperand createSub(MachineBasicBlock *BB1, MachineBasicBlock *BB2,
MCSymbolRefExpr::VariantKind Kind) const; MipsMCExpr::MipsExprKind Kind) const;
void lowerLongBranchLUi(const MachineInstr *MI, MCInst &OutMI) const; void lowerLongBranchLUi(const MachineInstr *MI, MCInst &OutMI) const;
void lowerLongBranchADDiu(const MachineInstr *MI, MCInst &OutMI, void lowerLongBranchADDiu(const MachineInstr *MI, MCInst &OutMI, int Opcode,
int Opcode, MipsMCExpr::MipsExprKind Kind) const;
MCSymbolRefExpr::VariantKind Kind) const;
bool lowerLongBranch(const MachineInstr *MI, MCInst &OutMI) const; bool lowerLongBranch(const MachineInstr *MI, MCInst &OutMI) const;
}; };
} }

View File

@ -44,9 +44,9 @@ foo:
# CHECK: lw $gp, 8($sp) # encoding: [0x8f,0xbc,0x00,0x08] # CHECK: lw $gp, 8($sp) # encoding: [0x8f,0xbc,0x00,0x08]
# CHECK: lw $25, %got(foo)($gp) # encoding: [0x8f,0x99,A,A] # CHECK: lw $25, %got(foo)($gp) # encoding: [0x8f,0x99,A,A]
# CHECK: # fixup A - offset: 0, value: foo@GOT, kind: fixup_Mips_GOT_Local # CHECK: # fixup A - offset: 0, value: %got(foo), kind: fixup_Mips_GOT
# CHECK: addiu $25, $25, %lo(foo) # encoding: [0x27,0x39,A,A] # CHECK: addiu $25, $25, %lo(foo) # encoding: [0x27,0x39,A,A]
# CHECK: # fixup A - offset: 0, value: foo@ABS_LO, kind: fixup_Mips_LO16 # CHECK: # fixup A - offset: 0, value: %lo(foo), kind: fixup_Mips_LO16
# CHECK: jalr $25 # encoding: [0x03,0x20,0xf8,0x09] # CHECK: jalr $25 # encoding: [0x03,0x20,0xf8,0x09]
# CHECK: nop # encoding: [0x00,0x00,0x00,0x00] # CHECK: nop # encoding: [0x00,0x00,0x00,0x00]
# CHECK: lw $gp, 8($sp) # encoding: [0x8f,0xbc,0x00,0x08] # CHECK: lw $gp, 8($sp) # encoding: [0x8f,0xbc,0x00,0x08]
@ -62,9 +62,9 @@ foo:
# MICROMIPS: lw $gp, 8($sp) # encoding: [0xff,0x9d,0x00,0x08] # MICROMIPS: lw $gp, 8($sp) # encoding: [0xff,0x9d,0x00,0x08]
# MICROMIPS: lw $25, %got(foo)($gp) # encoding: [0xff,0x3c,A,A] # MICROMIPS: lw $25, %got(foo)($gp) # encoding: [0xff,0x3c,A,A]
# MICROMIPS: # fixup A - offset: 0, value: foo@GOT, kind: fixup_MICROMIPS_GOT16 # MICROMIPS: # fixup A - offset: 0, value: %got(foo), kind: fixup_MICROMIPS_GOT16
# MICROMIPS: addiu $25, $25, %lo(foo) # encoding: [0x33,0x39,A,A] # MICROMIPS: addiu $25, $25, %lo(foo) # encoding: [0x33,0x39,A,A]
# MICROMIPS: # fixup A - offset: 0, value: foo@ABS_LO, kind: fixup_MICROMIPS_LO16 # MICROMIPS: # fixup A - offset: 0, value: %lo(foo), kind: fixup_MICROMIPS_LO16
# MICROMIPS: jalrs $ra, $25 # encoding: [0x03,0xf9,0x4f,0x3c] # MICROMIPS: jalrs $ra, $25 # encoding: [0x03,0xf9,0x4f,0x3c]
# MICROMIPS: nop # encoding: [0x0c,0x00] # MICROMIPS: nop # encoding: [0x0c,0x00]
# MICROMIPS: lw $gp, 8($sp) # encoding: [0xff,0x9d,0x00,0x08] # MICROMIPS: lw $gp, 8($sp) # encoding: [0xff,0x9d,0x00,0x08]
@ -91,7 +91,7 @@ foo:
# BAD-ABI-N32: lw $25, %got_disp(foo)($gp) # encoding: [0x8f,0x99,A,A] # BAD-ABI-N32: lw $25, %got_disp(foo)($gp) # encoding: [0x8f,0x99,A,A]
# BAD-ABI-N64: ld $25, %got_disp(foo)($gp) # encoding: [0xdf,0x99,A,A] # BAD-ABI-N64: ld $25, %got_disp(foo)($gp) # encoding: [0xdf,0x99,A,A]
# BAD-ABI: # fixup A - offset: 0, value: foo@GOT_DISP, kind: fixup_Mips_GOT_DISP # BAD-ABI: # fixup A - offset: 0, value: %got_disp(foo), kind: fixup_Mips_GOT_DISP
# BAD-ABI: jalr $25 # encoding: [0x03,0x20,0xf8,0x09] # BAD-ABI: jalr $25 # encoding: [0x03,0x20,0xf8,0x09]
# BAD-ABI-NOT: lw $gp, 8($sp) # encoding: [0x8f,0xbc,0x00,0x08] # BAD-ABI-NOT: lw $gp, 8($sp) # encoding: [0x8f,0xbc,0x00,0x08]
# BAD-ABI: .end foo # BAD-ABI: .end foo

View File

@ -45,9 +45,9 @@ foo:
# CHECK: lw $gp, 8($sp) # encoding: [0x8f,0xbc,0x00,0x08] # CHECK: lw $gp, 8($sp) # encoding: [0x8f,0xbc,0x00,0x08]
# CHECK: lw $25, %got(foo)($gp) # encoding: [0x8f,0x99,A,A] # CHECK: lw $25, %got(foo)($gp) # encoding: [0x8f,0x99,A,A]
# CHECK: # fixup A - offset: 0, value: foo@GOT, kind: fixup_Mips_GOT_Local # CHECK: # fixup A - offset: 0, value: %got(foo), kind: fixup_Mips_GOT
# CHECK: addiu $25, $25, %lo(foo) # encoding: [0x27,0x39,A,A] # CHECK: addiu $25, $25, %lo(foo) # encoding: [0x27,0x39,A,A]
# CHECK: # fixup A - offset: 0, value: foo@ABS_LO, kind: fixup_Mips_LO16 # CHECK: # fixup A - offset: 0, value: %lo(foo), kind: fixup_Mips_LO16
# CHECK: jalr $25 # encoding: [0x03,0x20,0xf8,0x09] # CHECK: jalr $25 # encoding: [0x03,0x20,0xf8,0x09]
# CHECK: nop # encoding: [0x00,0x00,0x00,0x00] # CHECK: nop # encoding: [0x00,0x00,0x00,0x00]
# CHECK: lw $gp, 8($sp) # encoding: [0x8f,0xbc,0x00,0x08] # CHECK: lw $gp, 8($sp) # encoding: [0x8f,0xbc,0x00,0x08]
@ -63,9 +63,9 @@ foo:
# MICROMIPS: lw $gp, 8($sp) # encoding: [0xff,0x9d,0x00,0x08] # MICROMIPS: lw $gp, 8($sp) # encoding: [0xff,0x9d,0x00,0x08]
# MICROMIPS: lw $25, %got(foo)($gp) # encoding: [0xff,0x3c,A,A] # MICROMIPS: lw $25, %got(foo)($gp) # encoding: [0xff,0x3c,A,A]
# MICROMIPS: # fixup A - offset: 0, value: foo@GOT, kind: fixup_MICROMIPS_GOT16 # MICROMIPS: # fixup A - offset: 0, value: %got(foo), kind: fixup_MICROMIPS_GOT16
# MICROMIPS: addiu $25, $25, %lo(foo) # encoding: [0x33,0x39,A,A] # MICROMIPS: addiu $25, $25, %lo(foo) # encoding: [0x33,0x39,A,A]
# MICROMIPS: # fixup A - offset: 0, value: foo@ABS_LO, kind: fixup_MICROMIPS_LO16 # MICROMIPS: # fixup A - offset: 0, value: %lo(foo), kind: fixup_MICROMIPS_LO16
# MICROMIPS: jalrs $ra, $25 # encoding: [0x03,0xf9,0x4f,0x3c] # MICROMIPS: jalrs $ra, $25 # encoding: [0x03,0xf9,0x4f,0x3c]
# MICROMIPS: nop # encoding: [0x0c,0x00] # MICROMIPS: nop # encoding: [0x0c,0x00]
# MICROMIPS: lw $gp, 8($sp) # encoding: [0xff,0x9d,0x00,0x08] # MICROMIPS: lw $gp, 8($sp) # encoding: [0xff,0x9d,0x00,0x08]
@ -92,7 +92,7 @@ foo:
# BAD-ABI-N32: lw $25, %got_disp(foo)($gp) # encoding: [0x8f,0x99,A,A] # BAD-ABI-N32: lw $25, %got_disp(foo)($gp) # encoding: [0x8f,0x99,A,A]
# BAD-ABI-N64: ld $25, %got_disp(foo)($gp) # encoding: [0xdf,0x99,A,A] # BAD-ABI-N64: ld $25, %got_disp(foo)($gp) # encoding: [0xdf,0x99,A,A]
# BAD-ABI: # fixup A - offset: 0, value: foo@GOT_DISP, kind: fixup_Mips_GOT_DISP # BAD-ABI: # fixup A - offset: 0, value: %got_disp(foo), kind: fixup_Mips_GOT_DISP
# BAD-ABI: jalr $25 # encoding: [0x03,0x20,0xf8,0x09] # BAD-ABI: jalr $25 # encoding: [0x03,0x20,0xf8,0x09]
# BAD-ABI-NOT: lw $gp, 8($sp) # encoding: [0x8f,0xbc,0x00,0x08] # BAD-ABI-NOT: lw $gp, 8($sp) # encoding: [0x8f,0xbc,0x00,0x08]
# BAD-ABI: .end foo # BAD-ABI: .end foo

View File

@ -51,26 +51,26 @@ local_label:
# Expanding "jal local_label": # Expanding "jal local_label":
# O32: lw $25, %got(local_label)($gp) # encoding: [0x8f,0x99,A,A] # O32: lw $25, %got(local_label)($gp) # encoding: [0x8f,0x99,A,A]
# O32: # fixup A - offset: 0, value: local_label@GOT, kind: fixup_Mips_GOT_Local # O32: # fixup A - offset: 0, value: %got(local_label), kind: fixup_Mips_GOT
# O32: addiu $25, $25, %lo(local_label) # encoding: [0x27,0x39,A,A] # O32: addiu $25, $25, %lo(local_label) # encoding: [0x27,0x39,A,A]
# O32: # fixup A - offset: 0, value: local_label@ABS_LO, kind: fixup_Mips_LO16 # O32: # fixup A - offset: 0, value: %lo(local_label), kind: fixup_Mips_LO16
# N32: lw $25, %got_disp(local_label)($gp) # encoding: [0x8f,0x99,A,A] # N32: lw $25, %got_disp(local_label)($gp) # encoding: [0x8f,0x99,A,A]
# N32: # fixup A - offset: 0, value: local_label@GOT_DISP, kind: fixup_Mips_GOT_DISP # N32: # fixup A - offset: 0, value: %got_disp(local_label), kind: fixup_Mips_GOT_DISP
# N64: ld $25, %got_disp(local_label)($gp) # encoding: [0xdf,0x99,A,A] # N64: ld $25, %got_disp(local_label)($gp) # encoding: [0xdf,0x99,A,A]
# N64: # fixup A - offset: 0, value: local_label@GOT_DISP, kind: fixup_Mips_GOT_DISP # N64: # fixup A - offset: 0, value: %got_disp(local_label), kind: fixup_Mips_GOT_DISP
# O32-MICROMIPS: lw $25, %got(local_label)($gp) # encoding: [0xff,0x3c,A,A] # O32-MICROMIPS: lw $25, %got(local_label)($gp) # encoding: [0xff,0x3c,A,A]
# O32-MICROMIPS: # fixup A - offset: 0, value: local_label@GOT, kind: fixup_MICROMIPS_GOT16 # O32-MICROMIPS: # fixup A - offset: 0, value: %got(local_label), kind: fixup_MICROMIPS_GOT16
# O32-MICROMIPS: addiu $25, $25, %lo(local_label) # encoding: [0x33,0x39,A,A] # O32-MICROMIPS: addiu $25, $25, %lo(local_label) # encoding: [0x33,0x39,A,A]
# O32-MICROMIPS: # fixup A - offset: 0, value: local_label@ABS_LO, kind: fixup_MICROMIPS_LO16 # O32-MICROMIPS: # fixup A - offset: 0, value: %lo(local_label), kind: fixup_MICROMIPS_LO16
# N32-MICROMIPS: lw $25, %got_disp(local_label)($gp) # encoding: [0xff,0x3c,A,A] # N32-MICROMIPS: lw $25, %got_disp(local_label)($gp) # encoding: [0xff,0x3c,A,A]
# N32-MICROMIPS: # fixup A - offset: 0, value: local_label@GOT_DISP, kind: fixup_MICROMIPS_GOT_DISP # N32-MICROMIPS: # fixup A - offset: 0, value: %got_disp(local_label), kind: fixup_MICROMIPS_GOT_DISP
# N64-MICROMIPS: ld $25, %got_disp(local_label)($gp) # encoding: [0xdf,0x99,A,A] # N64-MICROMIPS: ld $25, %got_disp(local_label)($gp) # encoding: [0xdf,0x99,A,A]
# N64-MICROMIPS: # fixup A - offset: 0, value: local_label@GOT_DISP, kind: fixup_MICROMIPS_GOT_DISP # N64-MICROMIPS: # fixup A - offset: 0, value: %got_disp(local_label), kind: fixup_MICROMIPS_GOT_DISP
# NORMAL: jalr $25 # encoding: [0x03,0x20,0xf8,0x09] # NORMAL: jalr $25 # encoding: [0x03,0x20,0xf8,0x09]
# MICROMIPS: jalr $ra, $25 # encoding: [0x03,0xf9,0x0f,0x3c] # MICROMIPS: jalr $ra, $25 # encoding: [0x03,0xf9,0x0f,0x3c]
@ -79,22 +79,22 @@ local_label:
# Expanding "jal weak_label": # Expanding "jal weak_label":
# O32: lw $25, %call16(weak_label)($gp) # encoding: [0x8f,0x99,A,A] # O32: lw $25, %call16(weak_label)($gp) # encoding: [0x8f,0x99,A,A]
# O32: # fixup A - offset: 0, value: weak_label@GOT_CALL, kind: fixup_Mips_CALL16 # O32: # fixup A - offset: 0, value: %call16(weak_label), kind: fixup_Mips_CALL16
# N32: lw $25, %call16(weak_label)($gp) # encoding: [0x8f,0x99,A,A] # N32: lw $25, %call16(weak_label)($gp) # encoding: [0x8f,0x99,A,A]
# N32: # fixup A - offset: 0, value: weak_label@GOT_CALL, kind: fixup_Mips_CALL16 # N32: # fixup A - offset: 0, value: %call16(weak_label), kind: fixup_Mips_CALL16
# N64: ld $25, %call16(weak_label)($gp) # encoding: [0xdf,0x99,A,A] # N64: ld $25, %call16(weak_label)($gp) # encoding: [0xdf,0x99,A,A]
# N64: # fixup A - offset: 0, value: weak_label@GOT_CALL, kind: fixup_Mips_CALL16 # N64: # fixup A - offset: 0, value: %call16(weak_label), kind: fixup_Mips_CALL16
# O32-MICROMIPS: lw $25, %call16(weak_label)($gp) # encoding: [0xff,0x3c,A,A] # O32-MICROMIPS: lw $25, %call16(weak_label)($gp) # encoding: [0xff,0x3c,A,A]
# O32-MICROMIPS: # fixup A - offset: 0, value: weak_label@GOT_CALL, kind: fixup_MICROMIPS_CALL16 # O32-MICROMIPS: # fixup A - offset: 0, value: %call16(weak_label), kind: fixup_MICROMIPS_CALL16
# N32-MICROMIPS: lw $25, %call16(weak_label)($gp) # encoding: [0xff,0x3c,A,A] # N32-MICROMIPS: lw $25, %call16(weak_label)($gp) # encoding: [0xff,0x3c,A,A]
# N32-MICROMIPS: # fixup A - offset: 0, value: weak_label@GOT_CALL, kind: fixup_MICROMIPS_CALL16 # N32-MICROMIPS: # fixup A - offset: 0, value: %call16(weak_label), kind: fixup_MICROMIPS_CALL16
# N64-MICROMIPS: ld $25, %call16(weak_label)($gp) # encoding: [0xdf,0x99,A,A] # N64-MICROMIPS: ld $25, %call16(weak_label)($gp) # encoding: [0xdf,0x99,A,A]
# N64-MICROMIPS: # fixup A - offset: 0, value: weak_label@GOT_CALL, kind: fixup_MICROMIPS_CALL16 # N64-MICROMIPS: # fixup A - offset: 0, value: %call16(weak_label), kind: fixup_MICROMIPS_CALL16
# NORMAL: jalr $25 # encoding: [0x03,0x20,0xf8,0x09] # NORMAL: jalr $25 # encoding: [0x03,0x20,0xf8,0x09]
# MICROMIPS: jalr $ra, $25 # encoding: [0x03,0xf9,0x0f,0x3c] # MICROMIPS: jalr $ra, $25 # encoding: [0x03,0xf9,0x0f,0x3c]
@ -103,22 +103,22 @@ local_label:
# Expanding "jal global_label": # Expanding "jal global_label":
# O32: lw $25, %call16(global_label)($gp) # encoding: [0x8f,0x99,A,A] # O32: lw $25, %call16(global_label)($gp) # encoding: [0x8f,0x99,A,A]
# O32: # fixup A - offset: 0, value: global_label@GOT_CALL, kind: fixup_Mips_CALL16 # O32: # fixup A - offset: 0, value: %call16(global_label), kind: fixup_Mips_CALL16
# N32: lw $25, %call16(global_label)($gp) # encoding: [0x8f,0x99,A,A] # N32: lw $25, %call16(global_label)($gp) # encoding: [0x8f,0x99,A,A]
# N32: # fixup A - offset: 0, value: global_label@GOT_CALL, kind: fixup_Mips_CALL16 # N32: # fixup A - offset: 0, value: %call16(global_label), kind: fixup_Mips_CALL16
# N64: ld $25, %call16(global_label)($gp) # encoding: [0xdf,0x99,A,A] # N64: ld $25, %call16(global_label)($gp) # encoding: [0xdf,0x99,A,A]
# N64: # fixup A - offset: 0, value: global_label@GOT_CALL, kind: fixup_Mips_CALL16 # N64: # fixup A - offset: 0, value: %call16(global_label), kind: fixup_Mips_CALL16
# O32-MICROMIPS: lw $25, %call16(global_label)($gp) # encoding: [0xff,0x3c,A,A] # O32-MICROMIPS: lw $25, %call16(global_label)($gp) # encoding: [0xff,0x3c,A,A]
# O32-MICROMIPS: # fixup A - offset: 0, value: global_label@GOT_CALL, kind: fixup_MICROMIPS_CALL16 # O32-MICROMIPS: # fixup A - offset: 0, value: %call16(global_label), kind: fixup_MICROMIPS_CALL16
# N32-MICROMIPS: lw $25, %call16(global_label)($gp) # encoding: [0xff,0x3c,A,A] # N32-MICROMIPS: lw $25, %call16(global_label)($gp) # encoding: [0xff,0x3c,A,A]
# N32-MICROMIPS: # fixup A - offset: 0, value: global_label@GOT_CALL, kind: fixup_MICROMIPS_CALL16 # N32-MICROMIPS: # fixup A - offset: 0, value: %call16(global_label), kind: fixup_MICROMIPS_CALL16
# N64-MICROMIPS: ld $25, %call16(global_label)($gp) # encoding: [0xdf,0x99,A,A] # N64-MICROMIPS: ld $25, %call16(global_label)($gp) # encoding: [0xdf,0x99,A,A]
# N64-MICROMIPS: # fixup A - offset: 0, value: global_label@GOT_CALL, kind: fixup_MICROMIPS_CALL16 # N64-MICROMIPS: # fixup A - offset: 0, value: %call16(global_label), kind: fixup_MICROMIPS_CALL16
# NORMAL: jalr $25 # encoding: [0x03,0x20,0xf8,0x09] # NORMAL: jalr $25 # encoding: [0x03,0x20,0xf8,0x09]
# MICROMIPS: jalr $ra, $25 # encoding: [0x03,0xf9,0x0f,0x3c] # MICROMIPS: jalr $ra, $25 # encoding: [0x03,0xf9,0x0f,0x3c]
@ -129,26 +129,26 @@ local_label:
# it is created when generating an ELF object file. # it is created when generating an ELF object file.
# Expanding "jal .text": # Expanding "jal .text":
# O32-FIXME: lw $25, %got(.text)($gp) # encoding: [0x8f,0x99,A,A] # O32-FIXME: lw $25, %got(.text)($gp) # encoding: [0x8f,0x99,A,A]
# O32-FIXME: # fixup A - offset: 0, value: .text@GOT, kind: fixup_Mips_GOT_Local # O32-FIXME: # fixup A - offset: 0, value: %got(.text), kind: fixup_Mips_GOT
# O32-FIXME: addiu $25, $25, %lo(.text) # encoding: [0x27,0x39,A,A] # O32-FIXME: addiu $25, $25, %lo(.text) # encoding: [0x27,0x39,A,A]
# O32-FIXME: # fixup A - offset: 0, value: .text@ABS_LO, kind: fixup_Mips_LO16 # O32-FIXME: # fixup A - offset: 0, value: %lo(.text), kind: fixup_Mips_LO16
# N32-FIXME: lw $25, %got_disp(.text)($gp) # encoding: [0x8f,0x99,A,A] # N32-FIXME: lw $25, %got_disp(.text)($gp) # encoding: [0x8f,0x99,A,A]
# N32-FIXME: # fixup A - offset: 0, value: .text@GOT_DISP, kind: fixup_Mips_GOT_DISP # N32-FIXME: # fixup A - offset: 0, value: %got_disp(.text), kind: fixup_Mips_GOT_DISP
# N64-FIXME: ld $25, %got_disp(.text)($gp) # encoding: [0xdf,0x99,A,A] # N64-FIXME: ld $25, %got_disp(.text)($gp) # encoding: [0xdf,0x99,A,A]
# N64-FIXME: # fixup A - offset: 0, value: .text@GOT_DISP, kind: fixup_Mips_GOT_DISP # N64-FIXME: # fixup A - offset: 0, value: %got_disp(.text), kind: fixup_Mips_GOT_DISP
# O32-MICROMIPS-FIXME: lw $25, %got(.text)($gp) # encoding: [0xff,0x3c,A,A] # O32-MICROMIPS-FIXME: lw $25, %got(.text)($gp) # encoding: [0xff,0x3c,A,A]
# O32-MICROMIPS-FIXME: # fixup A - offset: 0, value: .text@GOT, kind: fixup_MICROMIPS_GOT16 # O32-MICROMIPS-FIXME: # fixup A - offset: 0, value: %got(.text), kind: fixup_MICROMIPS_GOT16
# O32-MICROMIPS-FIXME: addiu $25, $25, %lo(.text) # encoding: [0x33,0x39,A,A] # O32-MICROMIPS-FIXME: addiu $25, $25, %lo(.text) # encoding: [0x33,0x39,A,A]
# O32-MICROMIPS-FIXME: # fixup A - offset: 0, value: .text@ABS_LO, kind: fixup_MICROMIPS_LO16 # O32-MICROMIPS-FIXME: # fixup A - offset: 0, value: %lo(.text), kind: fixup_MICROMIPS_LO16
# N32-MICROMIPS-FIXME: lw $25, %got_disp(.text)($gp) # encoding: [0xff,0x3c,A,A] # N32-MICROMIPS-FIXME: lw $25, %got_disp(.text)($gp) # encoding: [0xff,0x3c,A,A]
# N32-MICROMIPS-FIXME: # fixup A - offset: 0, value: .text@GOT_DISP, kind: fixup_MICROMIPS_GOT_DISP # N32-MICROMIPS-FIXME: # fixup A - offset: 0, value: %got_disp(.text), kind: fixup_MICROMIPS_GOT_DISP
# N64-MICROMIPS-FIXME: ld $25, %got_disp(.text)($gp) # encoding: [0xdf,0x99,A,A] # N64-MICROMIPS-FIXME: ld $25, %got_disp(.text)($gp) # encoding: [0xdf,0x99,A,A]
# N64-MICROMIPS-FIXME: # fixup A - offset: 0, value: .text@GOT_DISP, kind: fixup_MICROMIPS_GOT_DISP # N64-MICROMIPS-FIXME: # fixup A - offset: 0, value: %got_disp(.text), kind: fixup_MICROMIPS_GOT_DISP
# NORMAL: jalr $25 # encoding: [0x03,0x20,0xf8,0x09] # NORMAL: jalr $25 # encoding: [0x03,0x20,0xf8,0x09]
# MICROMIPS: jalr $ra, $25 # encoding: [0x03,0xf9,0x0f,0x3c] # MICROMIPS: jalr $ra, $25 # encoding: [0x03,0xf9,0x0f,0x3c]
@ -157,26 +157,26 @@ local_label:
# Expanding "jal 1f": # Expanding "jal 1f":
# O32: lw $25, %got($tmp0)($gp) # encoding: [0x8f,0x99,A,A] # O32: lw $25, %got($tmp0)($gp) # encoding: [0x8f,0x99,A,A]
# O32: # fixup A - offset: 0, value: ($tmp0)@GOT, kind: fixup_Mips_GOT_Local # O32: # fixup A - offset: 0, value: %got($tmp0), kind: fixup_Mips_GOT
# O32: addiu $25, $25, %lo($tmp0) # encoding: [0x27,0x39,A,A] # O32: addiu $25, $25, %lo($tmp0) # encoding: [0x27,0x39,A,A]
# O32: # fixup A - offset: 0, value: ($tmp0)@ABS_LO, kind: fixup_Mips_LO16 # O32: # fixup A - offset: 0, value: %lo($tmp0), kind: fixup_Mips_LO16
# N32: lw $25, %got_disp($tmp0)($gp) # encoding: [0x8f,0x99,A,A] # N32: lw $25, %got_disp($tmp0)($gp) # encoding: [0x8f,0x99,A,A]
# N32: # fixup A - offset: 0, value: ($tmp0)@GOT_DISP, kind: fixup_Mips_GOT_DISP # N32: # fixup A - offset: 0, value: %got_disp($tmp0), kind: fixup_Mips_GOT_DISP
# N64: ld $25, %got_disp($tmp0)($gp) # encoding: [0xdf,0x99,A,A] # N64: ld $25, %got_disp($tmp0)($gp) # encoding: [0xdf,0x99,A,A]
# N64: # fixup A - offset: 0, value: ($tmp0)@GOT_DISP, kind: fixup_Mips_GOT_DISP # N64: # fixup A - offset: 0, value: %got_disp($tmp0), kind: fixup_Mips_GOT_DISP
# O32-MICROMIPS: lw $25, %got($tmp0)($gp) # encoding: [0xff,0x3c,A,A] # O32-MICROMIPS: lw $25, %got($tmp0)($gp) # encoding: [0xff,0x3c,A,A]
# O32-MICROMIPS: # fixup A - offset: 0, value: ($tmp0)@GOT, kind: fixup_MICROMIPS_GOT16 # O32-MICROMIPS: # fixup A - offset: 0, value: %got($tmp0), kind: fixup_MICROMIPS_GOT16
# O32-MICROMIPS: addiu $25, $25, %lo($tmp0) # encoding: [0x33,0x39,A,A] # O32-MICROMIPS: addiu $25, $25, %lo($tmp0) # encoding: [0x33,0x39,A,A]
# O32-MICROMIPS: # fixup A - offset: 0, value: ($tmp0)@ABS_LO, kind: fixup_MICROMIPS_LO16 # O32-MICROMIPS: # fixup A - offset: 0, value: %lo($tmp0), kind: fixup_MICROMIPS_LO16
# N32-MICROMIPS: lw $25, %got_disp($tmp0)($gp) # encoding: [0xff,0x3c,A,A] # N32-MICROMIPS: lw $25, %got_disp($tmp0)($gp) # encoding: [0xff,0x3c,A,A]
# N32-MICROMIPS: # fixup A - offset: 0, value: ($tmp0)@GOT_DISP, kind: fixup_MICROMIPS_GOT_DISP # N32-MICROMIPS: # fixup A - offset: 0, value: %got_disp($tmp0), kind: fixup_MICROMIPS_GOT_DISP
# N64-MICROMIPS: ld $25, %got_disp($tmp0)($gp) # encoding: [0xdf,0x99,A,A] # N64-MICROMIPS: ld $25, %got_disp($tmp0)($gp) # encoding: [0xdf,0x99,A,A]
# N64-MICROMIPS: # fixup A - offset: 0, value: ($tmp0)@GOT_DISP, kind: fixup_MICROMIPS_GOT_DISP # N64-MICROMIPS: # fixup A - offset: 0, value: %got_disp($tmp0), kind: fixup_MICROMIPS_GOT_DISP
# NORMAL: jalr $25 # encoding: [0x03,0x20,0xf8,0x09] # NORMAL: jalr $25 # encoding: [0x03,0x20,0xf8,0x09]
# MICROMIPS: jalr $ra, $25 # encoding: [0x03,0xf9,0x0f,0x3c] # MICROMIPS: jalr $ra, $25 # encoding: [0x03,0xf9,0x0f,0x3c]

View File

@ -8,38 +8,38 @@
# 32R2-EL: .globl foo # 32R2-EL: .globl foo
# 32R2-EL: foo: # 32R2-EL: foo:
# 32R2-EL: lw $4, %lo(foo)($4) # encoding: [A,A,0x84,0x8c] # 32R2-EL: lw $4, %lo(foo)($4) # encoding: [A,A,0x84,0x8c]
# 32R2-EL: # fixup A - offset: 0, value: foo@ABS_LO, kind: fixup_Mips_LO16 # 32R2-EL: # fixup A - offset: 0, value: %lo(foo), kind: fixup_Mips_LO16
# 32R2-EL: lw $4, 56($4) # encoding: [0x38,0x00,0x84,0x8c] # 32R2-EL: lw $4, 56($4) # encoding: [0x38,0x00,0x84,0x8c]
# 32R2-EL: lw $4, %lo(foo+8)($4) # encoding: [0x08'A',A,0x84,0x8c] # 32R2-EL: lw $4, %lo(8+foo)($4) # encoding: [A,A,0x84,0x8c]
# 32R2-EL: # fixup A - offset: 0, value: foo@ABS_LO, kind: fixup_Mips_LO16 # 32R2-EL: # fixup A - offset: 0, value: %lo(8+foo), kind: fixup_Mips_LO16
# 32R2-EL: lw $4, %lo(foo+8)($4) # encoding: [0x08'A',A,0x84,0x8c] # 32R2-EL: lw $4, %lo(8+foo)($4) # encoding: [A,A,0x84,0x8c]
# 32R2-EL: # fixup A - offset: 0, value: foo@ABS_LO, kind: fixup_Mips_LO16 # 32R2-EL: # fixup A - offset: 0, value: %lo(8+foo), kind: fixup_Mips_LO16
# 32R2-EL: lw $4, %lo(foo+8)($4) # encoding: [0x08'A',A,0x84,0x8c] # 32R2-EL: lw $4, %lo(8+foo)($4) # encoding: [A,A,0x84,0x8c]
# 32R2-EL: # fixup A - offset: 0, value: foo@ABS_LO, kind: fixup_Mips_LO16 # 32R2-EL: # fixup A - offset: 0, value: %lo(8+foo), kind: fixup_Mips_LO16
# 32R2-EL: lw $4, 10($4) # encoding: [0x0a,0x00,0x84,0x8c] # 32R2-EL: lw $4, 10($4) # encoding: [0x0a,0x00,0x84,0x8c]
# 32R2-EL: lw $4, 15($4) # encoding: [0x0f,0x00,0x84,0x8c] # 32R2-EL: lw $4, 15($4) # encoding: [0x0f,0x00,0x84,0x8c]
# 32R2-EL: lw $4, 21($4) # encoding: [0x15,0x00,0x84,0x8c] # 32R2-EL: lw $4, 21($4) # encoding: [0x15,0x00,0x84,0x8c]
# 32R2-EL: lw $4, 28($4) # encoding: [0x1c,0x00,0x84,0x8c] # 32R2-EL: lw $4, 28($4) # encoding: [0x1c,0x00,0x84,0x8c]
# 32R2-EL: lw $4, 6($4) # encoding: [0x06,0x00,0x84,0x8c] # 32R2-EL: lw $4, %lo(65542)($4) # encoding: [0x06,0x00,0x84,0x8c]
# 32R2-EL: .space 64 # 32R2-EL: .space 64
# MM-32R2-EL: .text # MM-32R2-EL: .text
# MM-32R2-EL: .globl foo # MM-32R2-EL: .globl foo
# MM-32R2-EL: foo: # MM-32R2-EL: foo:
# MM-32R2-EL: lw $4, %lo(foo)($4) # encoding: [0x84'A',0xfc'A',0x00,0x00] # MM-32R2-EL: lw $4, %lo(foo)($4) # encoding: [0x84'A',0xfc'A',0x00,0x00]
# MM-32R2-EL: # fixup A - offset: 0, value: foo@ABS_LO, kind: fixup_MICROMIPS_LO16 # MM-32R2-EL: # fixup A - offset: 0, value: %lo(foo), kind: fixup_MICROMIPS_LO16
# MM-32R2-EL: lw $4, 56($4) # encoding: [0x84,0xfc,0x38,0x00] # MM-32R2-EL: lw $4, 56($4) # encoding: [0x84,0xfc,0x38,0x00]
# MM-32R2-EL: lw $4, %lo(foo+8)($4) # encoding: [0x84'A',0xfc'A',0x08,0x00] # MM-32R2-EL: lw $4, %lo(8+foo)($4) # encoding: [0x84'A',0xfc'A',0x00,0x00]
# MM-32R2-EL: # fixup A - offset: 0, value: foo@ABS_LO, kind: fixup_MICROMIPS_LO16 # MM-32R2-EL: # fixup A - offset: 0, value: %lo(8+foo), kind: fixup_MICROMIPS_LO16
# MM-32R2-EL: lw $4, %lo(foo+8)($4) # encoding: [0x84'A',0xfc'A',0x08,0x00] # MM-32R2-EL: lw $4, %lo(8+foo)($4) # encoding: [0x84'A',0xfc'A',0x00,0x00]
# MM-32R2-EL: # fixup A - offset: 0, value: foo@ABS_LO, kind: fixup_MICROMIPS_LO16 # MM-32R2-EL: # fixup A - offset: 0, value: %lo(8+foo), kind: fixup_MICROMIPS_LO16
# MM-32R2-EL: lw $4, %lo(foo+8)($4) # encoding: [0x84'A',0xfc'A',0x08,0x00] # MM-32R2-EL: lw $4, %lo(8+foo)($4) # encoding: [0x84'A',0xfc'A',0x00,0x00]
# MM-32R2-EL: # fixup A - offset: 0, value: foo@ABS_LO, kind: fixup_MICROMIPS_LO16 # MM-32R2-EL: # fixup A - offset: 0, value: %lo(8+foo), kind: fixup_MICROMIPS_LO16
# MM-32R2-EL: lw $4, 10($4) # encoding: [0x84,0xfc,0x0a,0x00] # MM-32R2-EL: lw $4, 10($4) # encoding: [0x84,0xfc,0x0a,0x00]
# MM-32R2-EL: lw $4, 15($4) # encoding: [0x84,0xfc,0x0f,0x00] # MM-32R2-EL: lw $4, 15($4) # encoding: [0x84,0xfc,0x0f,0x00]
# MM-32R2-EL: lw $4, 21($4) # encoding: [0x84,0xfc,0x15,0x00] # MM-32R2-EL: lw $4, 21($4) # encoding: [0x84,0xfc,0x15,0x00]
# MM-32R2-EL: lw $4, 28($4) # encoding: [0x84,0xfc,0x1c,0x00] # MM-32R2-EL: lw $4, 28($4) # encoding: [0x84,0xfc,0x1c,0x00]
# MM-32R2-EL: lw $4, 6($4) # encoding: [0x84,0xfc,0x06,0x00] # MM-32R2-EL: lw $4, %lo(65542)($4) # encoding: [0x84,0xfc,0x06,0x00]
# MM-32R2-EL: .space 64 # MM-32R2-EL: .space 64
.globl foo .globl foo

View File

@ -272,8 +272,8 @@ la $6, symbol+8($6) # CHECK: lui $1, %hi(symbol+8) # encoding: [0x3c,0x0
# CHECK: addiu $1, $1, %lo(symbol+8) # encoding: [0x24,0x21,A,A] # CHECK: addiu $1, $1, %lo(symbol+8) # encoding: [0x24,0x21,A,A]
# CHECK: # fixup A - offset: 0, value: %lo(symbol+8), kind: fixup_Mips_LO16 # CHECK: # fixup A - offset: 0, value: %lo(symbol+8), kind: fixup_Mips_LO16
# CHECK: addu $6, $1, $6 # encoding: [0x00,0x26,0x30,0x21] # CHECK: addu $6, $1, $6 # encoding: [0x00,0x26,0x30,0x21]
la $5, 1f # CHECK: lui $5, %hi(($tmp0)) # encoding: [0x3c,0x05,A,A] la $5, 1f # CHECK: lui $5, %hi($tmp0) # encoding: [0x3c,0x05,A,A]
# CHECK: # fixup A - offset: 0, value: %hi(($tmp0)), kind: fixup_Mips_HI16 # CHECK: # fixup A - offset: 0, value: %hi($tmp0), kind: fixup_Mips_HI16
# CHECK: addiu $5, $5, %lo(($tmp0)) # encoding: [0x24,0xa5,A,A] # CHECK: addiu $5, $5, %lo($tmp0) # encoding: [0x24,0xa5,A,A]
# CHECK: # fixup A - offset: 0, value: %lo(($tmp0)), kind: fixup_Mips_LO16 # CHECK: # fixup A - offset: 0, value: %lo($tmp0), kind: fixup_Mips_LO16
1: 1:

View File

@ -18,21 +18,21 @@
# CHECK: addu $7, $7, $8 # encoding: [0x07,0x01,0x50,0x39] # CHECK: addu $7, $7, $8 # encoding: [0x07,0x01,0x50,0x39]
# CHECK: lui $10, %hi(symbol) # encoding: [0xaa'A',0x41'A',0x00,0x00] # CHECK: lui $10, %hi(symbol) # encoding: [0xaa'A',0x41'A',0x00,0x00]
# CHECK: # fixup A - offset: 0, # CHECK: # fixup A - offset: 0,
# CHECK: value: symbol@ABS_HI, # CHECK: value: %hi(symbol),
# CHECK: kind: fixup_MICROMIPS_HI16 # CHECK: kind: fixup_MICROMIPS_HI16
# CHECK: addu $10, $10, $4 # encoding: [0x8a,0x00,0x50,0x51] # CHECK: addu $10, $10, $4 # encoding: [0x8a,0x00,0x50,0x51]
# CHECK: lw $10, %lo(symbol)($10) # encoding: [0x4a'A',0xfd'A',0x00,0x00] # CHECK: lw $10, %lo(symbol)($10) # encoding: [0x4a'A',0xfd'A',0x00,0x00]
# CHECK: # fixup A - offset: 0, # CHECK: # fixup A - offset: 0,
# CHECK: value: symbol@ABS_LO, # CHECK: value: %lo(symbol),
# CHECK: kind: fixup_MICROMIPS_LO16 # CHECK: kind: fixup_MICROMIPS_LO16
# CHECK: lui $1, %hi(symbol) # encoding: [0xa1'A',0x41'A',0x00,0x00] # CHECK: lui $1, %hi(symbol) # encoding: [0xa1'A',0x41'A',0x00,0x00]
# CHECK: # fixup A - offset: 0, # CHECK: # fixup A - offset: 0,
# CHECK: value: symbol@ABS_HI, # CHECK: value: %hi(symbol),
# CHECK: kind: fixup_MICROMIPS_HI16 # CHECK: kind: fixup_MICROMIPS_HI16
# CHECK: addu $1, $1, $9 # encoding: [0x21,0x01,0x50,0x09] # CHECK: addu $1, $1, $9 # encoding: [0x21,0x01,0x50,0x09]
# CHECK: sw $10, %lo(symbol)($1) # encoding: [0x41'A',0xf9'A',0x00,0x00] # CHECK: sw $10, %lo(symbol)($1) # encoding: [0x41'A',0xf9'A',0x00,0x00]
# CHECK: # fixup A - offset: 0, # CHECK: # fixup A - offset: 0,
# CHECK: value: symbol@ABS_LO, # CHECK: value: %lo(symbol),
# CHECK: kind: fixup_MICROMIPS_LO16 # CHECK: kind: fixup_MICROMIPS_LO16
# CHECK: lui $10, 10 # encoding: [0xaa,0x41,0x0a,0x00] # CHECK: lui $10, 10 # encoding: [0xaa,0x41,0x0a,0x00]
# CHECK: addu $10, $10, $4 # encoding: [0x8a,0x00,0x50,0x51] # CHECK: addu $10, $10, $4 # encoding: [0x8a,0x00,0x50,0x51]

View File

@ -10,71 +10,71 @@
# CHECK-FIXUP: lui $2, %hi(_gp_disp) # CHECK-FIXUP: lui $2, %hi(_gp_disp)
# CHECK-FIXUP: # encoding: [0xa2'A',0x41'A',0x00,0x00] # CHECK-FIXUP: # encoding: [0xa2'A',0x41'A',0x00,0x00]
# CHECK-FIXUP: # fixup A - offset: 0, # CHECK-FIXUP: # fixup A - offset: 0,
# CHECK-FIXUP: value: _gp_disp@ABS_HI, # CHECK-FIXUP: value: %hi(_gp_disp),
# CHECK-FIXUP: kind: fixup_MICROMIPS_HI16 # CHECK-FIXUP: kind: fixup_MICROMIPS_HI16
# CHECK-FIXUP: addiu $2, $2, %lo(_gp_disp) # CHECK-FIXUP: addiu $2, $2, %lo(_gp_disp)
# CHECK-FIXUP: # encoding: [0x42'A',0x30'A',0x00,0x00] # CHECK-FIXUP: # encoding: [0x42'A',0x30'A',0x00,0x00]
# CHECK-FIXUP: # fixup A - offset: 0, # CHECK-FIXUP: # fixup A - offset: 0,
# CHECK-FIXUP: value: _gp_disp@ABS_LO, # CHECK-FIXUP: value: %lo(_gp_disp),
# CHECK-FIXUP: kind: fixup_MICROMIPS_LO16 # CHECK-FIXUP: kind: fixup_MICROMIPS_LO16
# CHECK-FIXUP: lw $25, %call16(strchr)($gp) # CHECK-FIXUP: lw $25, %call16(strchr)($gp)
# CHECK-FIXUP: # encoding: [0x3c'A',0xff'A',0x00,0x00] # CHECK-FIXUP: # encoding: [0x3c'A',0xff'A',0x00,0x00]
# CHECK-FIXUP: # fixup A - offset: 0, # CHECK-FIXUP: # fixup A - offset: 0,
# CHECK-FIXUP: value: strchr@GOT_CALL, # CHECK-FIXUP: value: %call16(strchr),
# CHECK-FIXUP: kind: fixup_MICROMIPS_CALL16 # CHECK-FIXUP: kind: fixup_MICROMIPS_CALL16
# CHECK-FIXUP: lw $3, %got(loop_1)($2) # CHECK-FIXUP: lw $3, %got(loop_1)($2)
# CHECK-FIXUP: # encoding: [0x62'A',0xfc'A',0x00,0x00] # CHECK-FIXUP: # encoding: [0x62'A',0xfc'A',0x00,0x00]
# CHECK-FIXUP: # fixup A - offset: 0, # CHECK-FIXUP: # fixup A - offset: 0,
# CHECK-FIXUP: value: loop_1@GOT, # CHECK-FIXUP: value: %got(loop_1),
# CHECK-FIXUP: kind: fixup_MICROMIPS_GOT16 # CHECK-FIXUP: kind: fixup_MICROMIPS_GOT16
# CHECK-FIXUP: lui $2, %dtprel_hi(_gp_disp) # CHECK-FIXUP: lui $2, %dtprel_hi(_gp_disp)
# CHECK-FIXUP: # encoding: [0xa2'A',0x41'A',0x00,0x00] # CHECK-FIXUP: # encoding: [0xa2'A',0x41'A',0x00,0x00]
# CHECK-FIXUP: # fixup A - offset: 0, # CHECK-FIXUP: # fixup A - offset: 0,
# CHECK-FIXUP: value: _gp_disp@DTPREL_HI, # CHECK-FIXUP: value: %dtprel_hi(_gp_disp),
# CHECK-FIXUP: kind: fixup_MICROMIPS_TLS_DTPREL_HI16 # CHECK-FIXUP: kind: fixup_MICROMIPS_TLS_DTPREL_HI16
# CHECK-FIXUP: addiu $2, $2, %dtprel_lo(_gp_disp) # CHECK-FIXUP: addiu $2, $2, %dtprel_lo(_gp_disp)
# CHECK-FIXUP: # encoding: [0x42'A',0x30'A',0x00,0x00] # CHECK-FIXUP: # encoding: [0x42'A',0x30'A',0x00,0x00]
# CHECK-FIXUP: # fixup A - offset: 0, # CHECK-FIXUP: # fixup A - offset: 0,
# CHECK-FIXUP: value: _gp_disp@DTPREL_LO, # CHECK-FIXUP: value: %dtprel_lo(_gp_disp),
# CHECK-FIXUP: kind: fixup_MICROMIPS_TLS_DTPREL_LO16 # CHECK-FIXUP: kind: fixup_MICROMIPS_TLS_DTPREL_LO16
# CHECK-FIXUP: lw $3, %got(loop_1)($2) # CHECK-FIXUP: lw $3, %got(loop_1)($2)
# CHECK-FIXUP: # encoding: [0x62'A',0xfc'A',0x00,0x00] # CHECK-FIXUP: # encoding: [0x62'A',0xfc'A',0x00,0x00]
# CHECK-FIXUP: # fixup A - offset: 0, # CHECK-FIXUP: # fixup A - offset: 0,
# CHECK-FIXUP: value: loop_1@GOT, # CHECK-FIXUP: value: %got(loop_1),
# CHECK-FIXUP: kind: fixup_MICROMIPS_GOT16 # CHECK-FIXUP: kind: fixup_MICROMIPS_GOT16
# CHECK-FIXUP: lw $4, %got_disp(loop_2)($3) # CHECK-FIXUP: lw $4, %got_disp(loop_2)($3)
# CHECK-FIXUP: # encoding: [0x83'A',0xfc'A',0x00,0x00] # CHECK-FIXUP: # encoding: [0x83'A',0xfc'A',0x00,0x00]
# CHECK-FIXUP: # fixup A - offset: 0, # CHECK-FIXUP: # fixup A - offset: 0,
# CHECK-FIXUP: value: loop_2@GOT_DISP, # CHECK-FIXUP: value: %got_disp(loop_2),
# CHECK-FIXUP: kind: fixup_MICROMIPS_GOT_DISP # CHECK-FIXUP: kind: fixup_MICROMIPS_GOT_DISP
# CHECK-FIXUP: lw $5, %got_page(loop_3)($4) # CHECK-FIXUP: lw $5, %got_page(loop_3)($4)
# CHECK-FIXUP: # encoding: [0xa4'A',0xfc'A',0x00,0x00] # CHECK-FIXUP: # encoding: [0xa4'A',0xfc'A',0x00,0x00]
# CHECK-FIXUP: # fixup A - offset: 0, # CHECK-FIXUP: # fixup A - offset: 0,
# CHECK-FIXUP: value: loop_3@GOT_PAGE, # CHECK-FIXUP: value: %got_page(loop_3),
# CHECK-FIXUP: kind: fixup_MICROMIPS_GOT_PAGE # CHECK-FIXUP: kind: fixup_MICROMIPS_GOT_PAGE
# CHECK-FIXUP: lw $6, %got_ofst(loop_4)($5) # CHECK-FIXUP: lw $6, %got_ofst(loop_4)($5)
# CHECK-FIXUP: # encoding: [0xc5'A',0xfc'A',0x00,0x00] # CHECK-FIXUP: # encoding: [0xc5'A',0xfc'A',0x00,0x00]
# CHECK-FIXUP: # fixup A - offset: 0, # CHECK-FIXUP: # fixup A - offset: 0,
# CHECK-FIXUP: value: loop_4@GOT_OFST, # CHECK-FIXUP: value: %got_ofst(loop_4),
# CHECK-FIXUP: kind: fixup_MICROMIPS_GOT_OFST # CHECK-FIXUP: kind: fixup_MICROMIPS_GOT_OFST
# CHECK-FIXUP: lui $2, %tprel_hi(_gp_disp) # CHECK-FIXUP: lui $2, %tprel_hi(_gp_disp)
# CHECK-FIXUP: # encoding: [0xa2'A',0x41'A',0x00,0x00] # CHECK-FIXUP: # encoding: [0xa2'A',0x41'A',0x00,0x00]
# CHECK-FIXUP: # fixup A - offset: 0, # CHECK-FIXUP: # fixup A - offset: 0,
# CHECK-FIXUP: value: _gp_disp@TPREL_HI, # CHECK-FIXUP: value: %tprel_hi(_gp_disp),
# CHECK-FIXUP: kind: fixup_MICROMIPS_TLS_TPREL_HI16 # CHECK-FIXUP: kind: fixup_MICROMIPS_TLS_TPREL_HI16
# CHECK-FIXUP: addiu $2, $2, %tprel_lo(_gp_disp) # CHECK-FIXUP: addiu $2, $2, %tprel_lo(_gp_disp)
# CHECK-FIXUP: # encoding: [0x42'A',0x30'A',0x00,0x00] # CHECK-FIXUP: # encoding: [0x42'A',0x30'A',0x00,0x00]
# CHECK-FIXUP: # fixup A - offset: 0, # CHECK-FIXUP: # fixup A - offset: 0,
# CHECK-FIXUP: value: _gp_disp@TPREL_LO, # CHECK-FIXUP: value: %tprel_lo(_gp_disp),
# CHECK-FIXUP: kind: fixup_MICROMIPS_TLS_TPREL_LO16 # CHECK-FIXUP: kind: fixup_MICROMIPS_TLS_TPREL_LO16
# CHECK-FIXUP: addiu $4, $gp, %tlsgd(a) # CHECK-FIXUP: addiu $4, $gp, %tlsgd(a)
# CHECK-FIXUP: # encoding: [0x9c'A',0x30'A',0x00,0x00] # CHECK-FIXUP: # encoding: [0x9c'A',0x30'A',0x00,0x00]
# CHECK-FIXUP: # fixup A - offset: 0, # CHECK-FIXUP: # fixup A - offset: 0,
# CHECK-FIXUP: value: a@TLSGD, kind: fixup_MICROMIPS_TLS_GD # CHECK-FIXUP: value: %tlsgd(a), kind: fixup_MICROMIPS_TLS_GD
# CHECK-FIXUP: addiu $4, $gp, %tlsldm(f.i) # CHECK-FIXUP: addiu $4, $gp, %tlsldm(f.i)
# CHECK-FIXUP: # encoding: [0x9c'A',0x30'A',0x00,0x00] # CHECK-FIXUP: # encoding: [0x9c'A',0x30'A',0x00,0x00]
# CHECK-FIXUP: # fixup A - offset: 0, # CHECK-FIXUP: # fixup A - offset: 0,
# CHECK-FIXUP: value: f.i@TLSLDM, kind: fixup_MICROMIPS_TLS_LDM # CHECK-FIXUP: value: %tlsldm(f.i), kind: fixup_MICROMIPS_TLS_LDM
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Check that the appropriate relocations were created. # Check that the appropriate relocations were created.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -8,37 +8,37 @@
# Load address, done by MipsAsmParser::expandLoadAddressReg() # Load address, done by MipsAsmParser::expandLoadAddressReg()
# and MipsAsmParser::expandLoadAddressImm(): # and MipsAsmParser::expandLoadAddressImm():
la $8, 1f la $8, 1f
# CHECK-LE: lui $8, %hi(($tmp0)) # encoding: [A,A,0x08,0x3c] # CHECK-LE: lui $8, %hi($tmp0) # encoding: [A,A,0x08,0x3c]
# CHECK-LE: # fixup A - offset: 0, value: %hi(($tmp0)), kind: fixup_Mips_HI16 # CHECK-LE: # fixup A - offset: 0, value: %hi($tmp0), kind: fixup_Mips_HI16
# CHECK-LE: addiu $8, $8, %lo(($tmp0)) # encoding: [A,A,0x08,0x25] # CHECK-LE: addiu $8, $8, %lo($tmp0) # encoding: [A,A,0x08,0x25]
# CHECK-LE: # fixup A - offset: 0, value: %lo(($tmp0)), kind: fixup_Mips_LO16 # CHECK-LE: # fixup A - offset: 0, value: %lo($tmp0), kind: fixup_Mips_LO16
# LW/SW and LDC1/SDC1 of symbol address, done by MipsAsmParser::expandMemInst(): # LW/SW and LDC1/SDC1 of symbol address, done by MipsAsmParser::expandMemInst():
.set noat .set noat
lw $10, symbol($4) lw $10, symbol($4)
# CHECK-LE: lui $10, %hi(symbol) # encoding: [A,A,0x0a,0x3c] # CHECK-LE: lui $10, %hi(symbol) # encoding: [A,A,0x0a,0x3c]
# CHECK-LE: # fixup A - offset: 0, value: symbol@ABS_HI, kind: fixup_Mips_HI16 # CHECK-LE: # fixup A - offset: 0, value: %hi(symbol), kind: fixup_Mips_HI16
# CHECK-LE: addu $10, $10, $4 # encoding: [0x21,0x50,0x44,0x01] # CHECK-LE: addu $10, $10, $4 # encoding: [0x21,0x50,0x44,0x01]
# CHECK-LE: lw $10, %lo(symbol)($10) # encoding: [A,A,0x4a,0x8d] # CHECK-LE: lw $10, %lo(symbol)($10) # encoding: [A,A,0x4a,0x8d]
# CHECK-LE: # fixup A - offset: 0, value: symbol@ABS_LO, kind: fixup_Mips_LO16 # CHECK-LE: # fixup A - offset: 0, value: %lo(symbol), kind: fixup_Mips_LO16
.set at .set at
sw $10, symbol($9) sw $10, symbol($9)
# CHECK-LE: lui $1, %hi(symbol) # encoding: [A,A,0x01,0x3c] # CHECK-LE: lui $1, %hi(symbol) # encoding: [A,A,0x01,0x3c]
# CHECK-LE: # fixup A - offset: 0, value: symbol@ABS_HI, kind: fixup_Mips_HI16 # CHECK-LE: # fixup A - offset: 0, value: %hi(symbol), kind: fixup_Mips_HI16
# CHECK-LE: addu $1, $1, $9 # encoding: [0x21,0x08,0x29,0x00] # CHECK-LE: addu $1, $1, $9 # encoding: [0x21,0x08,0x29,0x00]
# CHECK-LE: sw $10, %lo(symbol)($1) # encoding: [A,A,0x2a,0xac] # CHECK-LE: sw $10, %lo(symbol)($1) # encoding: [A,A,0x2a,0xac]
# CHECK-LE: # fixup A - offset: 0, value: symbol@ABS_LO, kind: fixup_Mips_LO16 # CHECK-LE: # fixup A - offset: 0, value: %lo(symbol), kind: fixup_Mips_LO16
lw $8, 1f lw $8, 1f
# CHECK-LE: lui $8, %hi($tmp0) # encoding: [A,A,0x08,0x3c] # CHECK-LE: lui $8, %hi($tmp0) # encoding: [A,A,0x08,0x3c]
# CHECK-LE: # fixup A - offset: 0, value: ($tmp0)@ABS_HI, kind: fixup_Mips_HI16 # CHECK-LE: # fixup A - offset: 0, value: %hi($tmp0), kind: fixup_Mips_HI16
# CHECK-LE: lw $8, %lo($tmp0)($8) # encoding: [A,A,0x08,0x8d] # CHECK-LE: lw $8, %lo($tmp0)($8) # encoding: [A,A,0x08,0x8d]
# CHECK-LE: # fixup A - offset: 0, value: ($tmp0)@ABS_LO, kind: fixup_Mips_LO16 # CHECK-LE: # fixup A - offset: 0, value: %lo($tmp0), kind: fixup_Mips_LO16
sw $8, 1f sw $8, 1f
# CHECK-LE: lui $1, %hi($tmp0) # encoding: [A,A,0x01,0x3c] # CHECK-LE: lui $1, %hi($tmp0) # encoding: [A,A,0x01,0x3c]
# CHECK-LE: # fixup A - offset: 0, value: ($tmp0)@ABS_HI, kind: fixup_Mips_HI16 # CHECK-LE: # fixup A - offset: 0, value: %hi($tmp0), kind: fixup_Mips_HI16
# CHECK-LE: sw $8, %lo($tmp0)($1) # encoding: [A,A,0x28,0xac] # CHECK-LE: sw $8, %lo($tmp0)($1) # encoding: [A,A,0x28,0xac]
# CHECK-LE: # fixup A - offset: 0, value: ($tmp0)@ABS_LO, kind: fixup_Mips_LO16 # CHECK-LE: # fixup A - offset: 0, value: %lo($tmp0), kind: fixup_Mips_LO16
lw $10, 655483($4) lw $10, 655483($4)
# CHECK-LE: lui $10, 10 # encoding: [0x0a,0x00,0x0a,0x3c] # CHECK-LE: lui $10, 10 # encoding: [0x0a,0x00,0x0a,0x3c]
@ -51,16 +51,16 @@
lw $8, symbol lw $8, symbol
# CHECK-LE: lui $8, %hi(symbol) # encoding: [A,A,0x08,0x3c] # CHECK-LE: lui $8, %hi(symbol) # encoding: [A,A,0x08,0x3c]
# CHECK-LE: # fixup A - offset: 0, value: symbol@ABS_HI, kind: fixup_Mips_HI16 # CHECK-LE: # fixup A - offset: 0, value: %hi(symbol), kind: fixup_Mips_HI16
# CHECK-LE-NOT: move $8, $8 # encoding: [0x21,0x40,0x00,0x01] # CHECK-LE-NOT: move $8, $8 # encoding: [0x21,0x40,0x00,0x01]
# CHECK-LE: lw $8, %lo(symbol)($8) # encoding: [A,A,0x08,0x8d] # CHECK-LE: lw $8, %lo(symbol)($8) # encoding: [A,A,0x08,0x8d]
# CHECK-LE: # fixup A - offset: 0, value: symbol@ABS_LO, kind: fixup_Mips_LO16 # CHECK-LE: # fixup A - offset: 0, value: %lo(symbol), kind: fixup_Mips_LO16
sw $8, symbol sw $8, symbol
# CHECK-LE: lui $1, %hi(symbol) # encoding: [A,A,0x01,0x3c] # CHECK-LE: lui $1, %hi(symbol) # encoding: [A,A,0x01,0x3c]
# CHECK-LE: # fixup A - offset: 0, value: symbol@ABS_HI, kind: fixup_Mips_HI16 # CHECK-LE: # fixup A - offset: 0, value: %hi(symbol), kind: fixup_Mips_HI16
# CHECK-LE-NOT: move $1, $1 # encoding: [0x21,0x08,0x20,0x00] # CHECK-LE-NOT: move $1, $1 # encoding: [0x21,0x08,0x20,0x00]
# CHECK-LE: sw $8, %lo(symbol)($1) # encoding: [A,A,0x28,0xac] # CHECK-LE: sw $8, %lo(symbol)($1) # encoding: [A,A,0x28,0xac]
# CHECK-LE: # fixup A - offset: 0, value: symbol@ABS_LO, kind: fixup_Mips_LO16 # CHECK-LE: # fixup A - offset: 0, value: %lo(symbol), kind: fixup_Mips_LO16
ldc1 $f0, symbol ldc1 $f0, symbol
# CHECK-LE: lui $1, %hi(symbol) # CHECK-LE: lui $1, %hi(symbol)

View File

@ -28,11 +28,11 @@
# CHECK-FIXUP: value: bar-4, kind: fixup_MIPS_PC26_S2 # CHECK-FIXUP: value: bar-4, kind: fixup_MIPS_PC26_S2
# CHECK-FIXUP: aluipc $2, %pcrel_hi(bar) # encoding: [0xec,0x5f,A,A] # CHECK-FIXUP: aluipc $2, %pcrel_hi(bar) # encoding: [0xec,0x5f,A,A]
# CHECK-FIXUP: # fixup A - offset: 0, # CHECK-FIXUP: # fixup A - offset: 0,
# CHECK-FIXUP: value: bar@PCREL_HI16, # CHECK-FIXUP: value: %pcrel_hi(bar),
# CHECK-FIXUP: kind: fixup_MIPS_PCHI16 # CHECK-FIXUP: kind: fixup_MIPS_PCHI16
# CHECK-FIXUP: addiu $2, $2, %pcrel_lo(bar) # encoding: [0x24,0x42,A,A] # CHECK-FIXUP: addiu $2, $2, %pcrel_lo(bar) # encoding: [0x24,0x42,A,A]
# CHECK-FIXUP: # fixup A - offset: 0, # CHECK-FIXUP: # fixup A - offset: 0,
# CHECK-FIXUP: value: bar@PCREL_LO16, # CHECK-FIXUP: value: %pcrel_lo(bar),
# CHECK-FIXUP: kind: fixup_MIPS_PCLO16 # CHECK-FIXUP: kind: fixup_MIPS_PCLO16
# CHECK-FIXUP: lwpc $2, bar # encoding: [0xec,0b01001AAA,A,A] # CHECK-FIXUP: lwpc $2, bar # encoding: [0xec,0b01001AAA,A,A]
# CHECK-FIXUP: # fixup A - offset: 0, # CHECK-FIXUP: # fixup A - offset: 0,

View File

@ -28,11 +28,11 @@
# CHECK-FIXUP: value: bar-4, kind: fixup_MIPS_PC26_S2 # CHECK-FIXUP: value: bar-4, kind: fixup_MIPS_PC26_S2
# CHECK-FIXUP: aluipc $2, %pcrel_hi(bar) # encoding: [0xec,0x5f,A,A] # CHECK-FIXUP: aluipc $2, %pcrel_hi(bar) # encoding: [0xec,0x5f,A,A]
# CHECK-FIXUP: # fixup A - offset: 0, # CHECK-FIXUP: # fixup A - offset: 0,
# CHECK-FIXUP: value: bar@PCREL_HI16, # CHECK-FIXUP: value: %pcrel_hi(bar),
# CHECK-FIXUP: kind: fixup_MIPS_PCHI16 # CHECK-FIXUP: kind: fixup_MIPS_PCHI16
# CHECK-FIXUP: addiu $2, $2, %pcrel_lo(bar) # encoding: [0x24,0x42,A,A] # CHECK-FIXUP: addiu $2, $2, %pcrel_lo(bar) # encoding: [0x24,0x42,A,A]
# CHECK-FIXUP: # fixup A - offset: 0, # CHECK-FIXUP: # fixup A - offset: 0,
# CHECK-FIXUP: value: bar@PCREL_LO16, # CHECK-FIXUP: value: %pcrel_lo(bar),
# CHECK-FIXUP: kind: fixup_MIPS_PCLO16 # CHECK-FIXUP: kind: fixup_MIPS_PCLO16
# CHECK-FIXUP: ldpc $2, bar # encoding: [0xec,0b010110AA,A,A] # CHECK-FIXUP: ldpc $2, bar # encoding: [0xec,0b010110AA,A,A]
# CHECK-FIXUP: # fixup A - offset: 0, # CHECK-FIXUP: # fixup A - offset: 0,

View File

@ -54,7 +54,7 @@ $BB0_4:
.set f6,$f6 .set f6,$f6
# CHECK: abs.s $f6, $f7 # encoding: [0x46,0x00,0x39,0x85] # CHECK: abs.s $f6, $f7 # encoding: [0x46,0x00,0x39,0x85]
# CHECK: lui $1, %hi($tmp7) # encoding: [0x3c,0x01,A,A] # CHECK: lui $1, %hi($tmp7) # encoding: [0x3c,0x01,A,A]
# CHECK: # fixup A - offset: 0, value: ($tmp7)@ABS_HI, kind: fixup_Mips_HI16 # CHECK: # fixup A - offset: 0, value: %hi($tmp7), kind: fixup_Mips_HI16
abs.s f6,FPU_MASK abs.s f6,FPU_MASK
lui $1, %hi($tmp7) lui $1, %hi($tmp7)

View File

@ -31,31 +31,31 @@
addiu $2, $3, %hi(foo) // RELOC: R_MIPS_HI16 foo addiu $2, $3, %hi(foo) // RELOC: R_MIPS_HI16 foo
// ENCBE: addiu $2, $3, %hi(foo) # encoding: [0x24,0x62,A,A] // ENCBE: addiu $2, $3, %hi(foo) # encoding: [0x24,0x62,A,A]
// ENCLE: addiu $2, $3, %hi(foo) # encoding: [A,A,0x62,0x24] // ENCLE: addiu $2, $3, %hi(foo) # encoding: [A,A,0x62,0x24]
// FIXUP: # fixup A - offset: 0, value: foo@ABS_HI, kind: fixup_Mips_HI16 // FIXUP: # fixup A - offset: 0, value: %hi(foo), kind: fixup_Mips_HI16
addiu $2, $3, %lo(foo) // RELOC: R_MIPS_LO16 foo addiu $2, $3, %lo(foo) // RELOC: R_MIPS_LO16 foo
// ENCBE: addiu $2, $3, %lo(foo) # encoding: [0x24,0x62,A,A] // ENCBE: addiu $2, $3, %lo(foo) # encoding: [0x24,0x62,A,A]
// ENCLE: addiu $2, $3, %lo(foo) # encoding: [A,A,0x62,0x24] // ENCLE: addiu $2, $3, %lo(foo) # encoding: [A,A,0x62,0x24]
// FIXUP: # fixup A - offset: 0, value: foo@ABS_LO, kind: fixup_Mips_LO16 // FIXUP: # fixup A - offset: 0, value: %lo(foo), kind: fixup_Mips_LO16
addiu $2, $3, %gp_rel(foo) // RELOC: R_MIPS_GPREL16 foo addiu $2, $3, %gp_rel(foo) // RELOC: R_MIPS_GPREL16 foo
// ENCBE: addiu $2, $3, %gp_rel(foo) # encoding: [0x24,0x62,A,A] // ENCBE: addiu $2, $3, %gp_rel(foo) # encoding: [0x24,0x62,A,A]
// ENCLE: addiu $2, $3, %gp_rel(foo) # encoding: [A,A,0x62,0x24] // ENCLE: addiu $2, $3, %gp_rel(foo) # encoding: [A,A,0x62,0x24]
// FIXUP: # fixup A - offset: 0, value: foo@GPREL, kind: fixup_Mips_GPREL // FIXUP: # fixup A - offset: 0, value: %gp_rel(foo), kind: fixup_Mips_GPREL
// ?????: R_MIPS_LITERAL foo // ?????: R_MIPS_LITERAL foo
addiu $2, $3, %got(foo) // RELOC: R_MIPS_GOT16 foo addiu $2, $3, %got(foo) // RELOC: R_MIPS_GOT16 foo
// ENCBE: addiu $2, $3, %got(foo) # encoding: [0x24,0x62,A,A] // ENCBE: addiu $2, $3, %got(foo) # encoding: [0x24,0x62,A,A]
// ENCLE: addiu $2, $3, %got(foo) # encoding: [A,A,0x62,0x24] // ENCLE: addiu $2, $3, %got(foo) # encoding: [A,A,0x62,0x24]
// FIXUP: # fixup A - offset: 0, value: foo@GOT, kind: fixup_Mips_GOT_Local // FIXUP: # fixup A - offset: 0, value: %got(foo), kind: fixup_Mips_GOT
.short foo-. // RELOC: R_MIPS_PC16 foo .short foo-. // RELOC: R_MIPS_PC16 foo
addiu $2, $3, %call16(foo) // RELOC: R_MIPS_CALL16 foo addiu $2, $3, %call16(foo) // RELOC: R_MIPS_CALL16 foo
// ENCBE: addiu $2, $3, %call16(foo) # encoding: [0x24,0x62,A,A] // ENCBE: addiu $2, $3, %call16(foo) # encoding: [0x24,0x62,A,A]
// ENCLE: addiu $2, $3, %call16(foo) # encoding: [A,A,0x62,0x24] // ENCLE: addiu $2, $3, %call16(foo) # encoding: [A,A,0x62,0x24]
// FIXUP: # fixup A - offset: 0, value: foo@GOT_CALL, kind: fixup_Mips_CALL16 // FIXUP: # fixup A - offset: 0, value: %call16(foo), kind: fixup_Mips_CALL16
.quad foo // RELOC: R_MIPS_64 foo .quad foo // RELOC: R_MIPS_64 foo
@ -69,27 +69,27 @@
addiu $2, $3, %got_disp(foo) // RELOC: R_MIPS_GOT_DISP foo addiu $2, $3, %got_disp(foo) // RELOC: R_MIPS_GOT_DISP foo
// ENCBE: addiu $2, $3, %got_disp(foo) # encoding: [0x24,0x62,A,A] // ENCBE: addiu $2, $3, %got_disp(foo) # encoding: [0x24,0x62,A,A]
// ENCLE: addiu $2, $3, %got_disp(foo) # encoding: [A,A,0x62,0x24] // ENCLE: addiu $2, $3, %got_disp(foo) # encoding: [A,A,0x62,0x24]
// FIXUP: # fixup A - offset: 0, value: foo@GOT_DISP, kind: fixup_Mips_GOT_DISP // FIXUP: # fixup A - offset: 0, value: %got_disp(foo), kind: fixup_Mips_GOT_DISP
addiu $2, $3, %got_page(foo) // RELOC: R_MIPS_GOT_PAGE foo addiu $2, $3, %got_page(foo) // RELOC: R_MIPS_GOT_PAGE foo
// ENCBE: addiu $2, $3, %got_page(foo) # encoding: [0x24,0x62,A,A] // ENCBE: addiu $2, $3, %got_page(foo) # encoding: [0x24,0x62,A,A]
// ENCLE: addiu $2, $3, %got_page(foo) # encoding: [A,A,0x62,0x24] // ENCLE: addiu $2, $3, %got_page(foo) # encoding: [A,A,0x62,0x24]
// FIXUP: # fixup A - offset: 0, value: foo@GOT_PAGE, kind: fixup_Mips_GOT_PAGE // FIXUP: # fixup A - offset: 0, value: %got_page(foo), kind: fixup_Mips_GOT_PAGE
addiu $2, $3, %got_ofst(foo) // RELOC: R_MIPS_GOT_OFST foo addiu $2, $3, %got_ofst(foo) // RELOC: R_MIPS_GOT_OFST foo
// ENCBE: addiu $2, $3, %got_ofst(foo) # encoding: [0x24,0x62,A,A] // ENCBE: addiu $2, $3, %got_ofst(foo) # encoding: [0x24,0x62,A,A]
// ENCLE: addiu $2, $3, %got_ofst(foo) # encoding: [A,A,0x62,0x24] // ENCLE: addiu $2, $3, %got_ofst(foo) # encoding: [A,A,0x62,0x24]
// FIXUP: # fixup A - offset: 0, value: foo@GOT_OFST, kind: fixup_Mips_GOT_OFST // FIXUP: # fixup A - offset: 0, value: %got_ofst(foo), kind: fixup_Mips_GOT_OFST
addiu $2, $3, %got_hi(foo) // RELOC: R_MIPS_GOT_HI16 foo addiu $2, $3, %got_hi(foo) // RELOC: R_MIPS_GOT_HI16 foo
// ENCBE: addiu $2, $3, %got_hi(foo) # encoding: [0x24,0x62,A,A] // ENCBE: addiu $2, $3, %got_hi(foo) # encoding: [0x24,0x62,A,A]
// ENCLE: addiu $2, $3, %got_hi(foo) # encoding: [A,A,0x62,0x24] // ENCLE: addiu $2, $3, %got_hi(foo) # encoding: [A,A,0x62,0x24]
// FIXUP: # fixup A - offset: 0, value: foo@GOT_HI16, kind: fixup_Mips_GOT_HI16 // FIXUP: # fixup A - offset: 0, value: %got_hi(foo), kind: fixup_Mips_GOT_HI16
addiu $2, $3, %got_lo(foo) // RELOC: R_MIPS_GOT_LO16 foo addiu $2, $3, %got_lo(foo) // RELOC: R_MIPS_GOT_LO16 foo
// ENCBE: addiu $2, $3, %got_lo(foo) # encoding: [0x24,0x62,A,A] // ENCBE: addiu $2, $3, %got_lo(foo) # encoding: [0x24,0x62,A,A]
// ENCLE: addiu $2, $3, %got_lo(foo) # encoding: [A,A,0x62,0x24] // ENCLE: addiu $2, $3, %got_lo(foo) # encoding: [A,A,0x62,0x24]
// FIXUP: # fixup A - offset: 0, value: foo@GOT_LO16, kind: fixup_Mips_GOT_LO16 // FIXUP: # fixup A - offset: 0, value: %got_lo(foo), kind: fixup_Mips_GOT_LO16
// addiu $2, $3, %neg(foo) // FIXME: R_MIPS_SUB foo // addiu $2, $3, %neg(foo) // FIXME: R_MIPS_SUB foo
// ?????: R_MIPS_INSERT_A // ?????: R_MIPS_INSERT_A
@ -100,23 +100,23 @@
daddiu $2, $3, %higher(foo) // RELOC: R_MIPS_HIGHER foo daddiu $2, $3, %higher(foo) // RELOC: R_MIPS_HIGHER foo
// ENCBE: daddiu $2, $3, %higher(foo) # encoding: [0x64,0x62,A,A] // ENCBE: daddiu $2, $3, %higher(foo) # encoding: [0x64,0x62,A,A]
// ENCLE: daddiu $2, $3, %higher(foo) # encoding: [A,A,0x62,0x64] // ENCLE: daddiu $2, $3, %higher(foo) # encoding: [A,A,0x62,0x64]
// FIXUP: # fixup A - offset: 0, value: foo@HIGHER, kind: fixup_Mips_HIGHER // FIXUP: # fixup A - offset: 0, value: %higher(foo), kind: fixup_Mips_HIGHER
daddiu $2, $3, %highest(foo) // RELOC: R_MIPS_HIGHEST foo daddiu $2, $3, %highest(foo) // RELOC: R_MIPS_HIGHEST foo
// ENCBE: daddiu $2, $3, %highest(foo) # encoding: [0x64,0x62,A,A] // ENCBE: daddiu $2, $3, %highest(foo) # encoding: [0x64,0x62,A,A]
// ENCLE: daddiu $2, $3, %highest(foo) # encoding: [A,A,0x62,0x64] // ENCLE: daddiu $2, $3, %highest(foo) # encoding: [A,A,0x62,0x64]
// FIXUP: # fixup A - offset: 0, value: foo@HIGHEST, kind: fixup_Mips_HIGHEST // FIXUP: # fixup A - offset: 0, value: %highest(foo), kind: fixup_Mips_HIGHEST
.set mips0 .set mips0
addiu $2, $3, %call_hi(foo) // RELOC: R_MIPS_CALL_HI16 foo addiu $2, $3, %call_hi(foo) // RELOC: R_MIPS_CALL_HI16 foo
// ENCBE: addiu $2, $3, %call_hi(foo) # encoding: [0x24,0x62,A,A] // ENCBE: addiu $2, $3, %call_hi(foo) # encoding: [0x24,0x62,A,A]
// ENCLE: addiu $2, $3, %call_hi(foo) # encoding: [A,A,0x62,0x24] // ENCLE: addiu $2, $3, %call_hi(foo) # encoding: [A,A,0x62,0x24]
// FIXUP: # fixup A - offset: 0, value: foo@CALL_HI16, kind: fixup_Mips_CALL_HI16 // FIXUP: # fixup A - offset: 0, value: %call_hi(foo), kind: fixup_Mips_CALL_HI16
addiu $2, $3, %call_lo(foo) // RELOC: R_MIPS_CALL_LO16 foo addiu $2, $3, %call_lo(foo) // RELOC: R_MIPS_CALL_LO16 foo
// ENCBE: addiu $2, $3, %call_lo(foo) # encoding: [0x24,0x62,A,A] // ENCBE: addiu $2, $3, %call_lo(foo) # encoding: [0x24,0x62,A,A]
// ENCLE: addiu $2, $3, %call_lo(foo) # encoding: [A,A,0x62,0x24] // ENCLE: addiu $2, $3, %call_lo(foo) # encoding: [A,A,0x62,0x24]
// FIXUP: # fixup A - offset: 0, value: foo@CALL_LO16, kind: fixup_Mips_CALL_LO16 // FIXUP: # fixup A - offset: 0, value: %call_lo(foo), kind: fixup_Mips_CALL_LO16
// ?????: R_MIPS_SCN_DISP foo // ?????: R_MIPS_SCN_DISP foo
// ?????: R_MIPS_REL16 foo // ?????: R_MIPS_REL16 foo
@ -132,39 +132,39 @@
addiu $2, $3, %tlsgd(foo) // RELOC: R_MIPS_TLS_GD foo addiu $2, $3, %tlsgd(foo) // RELOC: R_MIPS_TLS_GD foo
// ENCBE: addiu $2, $3, %tlsgd(foo) # encoding: [0x24,0x62,A,A] // ENCBE: addiu $2, $3, %tlsgd(foo) # encoding: [0x24,0x62,A,A]
// ENCLE: addiu $2, $3, %tlsgd(foo) # encoding: [A,A,0x62,0x24] // ENCLE: addiu $2, $3, %tlsgd(foo) # encoding: [A,A,0x62,0x24]
// FIXUP: # fixup A - offset: 0, value: foo@TLSGD, kind: fixup_Mips_TLSGD // FIXUP: # fixup A - offset: 0, value: %tlsgd(foo), kind: fixup_Mips_TLSGD
addiu $2, $3, %tlsldm(foo) // RELOC: R_MIPS_TLS_LDM foo addiu $2, $3, %tlsldm(foo) // RELOC: R_MIPS_TLS_LDM foo
// ENCBE: addiu $2, $3, %tlsldm(foo) # encoding: [0x24,0x62,A,A] // ENCBE: addiu $2, $3, %tlsldm(foo) # encoding: [0x24,0x62,A,A]
// ENCLE: addiu $2, $3, %tlsldm(foo) # encoding: [A,A,0x62,0x24] // ENCLE: addiu $2, $3, %tlsldm(foo) # encoding: [A,A,0x62,0x24]
// FIXUP: # fixup A - offset: 0, value: foo@TLSLDM, kind: fixup_Mips_TLSLDM // FIXUP: # fixup A - offset: 0, value: %tlsldm(foo), kind: fixup_Mips_TLSLDM
addiu $2, $3, %dtprel_hi(foo) // RELOC: R_MIPS_TLS_DTPREL_HI16 foo addiu $2, $3, %dtprel_hi(foo) // RELOC: R_MIPS_TLS_DTPREL_HI16 foo
// ENCBE: addiu $2, $3, %dtprel_hi(foo) # encoding: [0x24,0x62,A,A] // ENCBE: addiu $2, $3, %dtprel_hi(foo) # encoding: [0x24,0x62,A,A]
// ENCLE: addiu $2, $3, %dtprel_hi(foo) # encoding: [A,A,0x62,0x24] // ENCLE: addiu $2, $3, %dtprel_hi(foo) # encoding: [A,A,0x62,0x24]
// FIXUP: # fixup A - offset: 0, value: foo@DTPREL_HI, kind: fixup_Mips_DTPREL_HI // FIXUP: # fixup A - offset: 0, value: %dtprel_hi(foo), kind: fixup_Mips_DTPREL_HI
addiu $2, $3, %dtprel_lo(foo) // RELOC: R_MIPS_TLS_DTPREL_LO16 foo addiu $2, $3, %dtprel_lo(foo) // RELOC: R_MIPS_TLS_DTPREL_LO16 foo
// ENCBE: addiu $2, $3, %dtprel_lo(foo) # encoding: [0x24,0x62,A,A] // ENCBE: addiu $2, $3, %dtprel_lo(foo) # encoding: [0x24,0x62,A,A]
// ENCLE: addiu $2, $3, %dtprel_lo(foo) # encoding: [A,A,0x62,0x24] // ENCLE: addiu $2, $3, %dtprel_lo(foo) # encoding: [A,A,0x62,0x24]
// FIXUP: # fixup A - offset: 0, value: foo@DTPREL_LO, kind: fixup_Mips_DTPREL_LO // FIXUP: # fixup A - offset: 0, value: %dtprel_lo(foo), kind: fixup_Mips_DTPREL_LO
addiu $2, $3, %gottprel(foo) // RELOC: R_MIPS_TLS_GOTTPREL foo addiu $2, $3, %gottprel(foo) // RELOC: R_MIPS_TLS_GOTTPREL foo
// ENCBE: addiu $2, $3, %gottprel(foo) # encoding: [0x24,0x62,A,A] // ENCBE: addiu $2, $3, %gottprel(foo) # encoding: [0x24,0x62,A,A]
// ENCLE: addiu $2, $3, %gottprel(foo) # encoding: [A,A,0x62,0x24] // ENCLE: addiu $2, $3, %gottprel(foo) # encoding: [A,A,0x62,0x24]
// FIXUP: # fixup A - offset: 0, value: foo@GOTTPREL, kind: fixup_Mips_GOTTPREL // FIXUP: # fixup A - offset: 0, value: %gottprel(foo), kind: fixup_Mips_GOTTPREL
// .tprelword foo // FIXME: R_MIPS_TLS_TPREL32 foo // .tprelword foo // FIXME: R_MIPS_TLS_TPREL32 foo
// .tpreldword foo // FIXME: R_MIPS_TLS_TPREL64 foo // .tpreldword foo // FIXME: R_MIPS_TLS_TPREL64 foo
addiu $2, $3, %tprel_hi(foo) // RELOC: R_MIPS_TLS_TPREL_HI16 foo addiu $2, $3, %tprel_hi(foo) // RELOC: R_MIPS_TLS_TPREL_HI16 foo
// ENCBE: addiu $2, $3, %tprel_hi(foo) # encoding: [0x24,0x62,A,A] // ENCBE: addiu $2, $3, %tprel_hi(foo) # encoding: [0x24,0x62,A,A]
// ENCLE: addiu $2, $3, %tprel_hi(foo) # encoding: [A,A,0x62,0x24] // ENCLE: addiu $2, $3, %tprel_hi(foo) # encoding: [A,A,0x62,0x24]
// FIXUP: # fixup A - offset: 0, value: foo@TPREL_HI, kind: fixup_Mips_TPREL_HI // FIXUP: # fixup A - offset: 0, value: %tprel_hi(foo), kind: fixup_Mips_TPREL_HI
addiu $2, $3, %tprel_lo(foo) // RELOC: R_MIPS_TLS_TPREL_LO16 foo addiu $2, $3, %tprel_lo(foo) // RELOC: R_MIPS_TLS_TPREL_LO16 foo
// ENCBE: addiu $2, $3, %tprel_lo(foo) # encoding: [0x24,0x62,A,A] // ENCBE: addiu $2, $3, %tprel_lo(foo) # encoding: [0x24,0x62,A,A]
// ENCLE: addiu $2, $3, %tprel_lo(foo) # encoding: [A,A,0x62,0x24] // ENCLE: addiu $2, $3, %tprel_lo(foo) # encoding: [A,A,0x62,0x24]
// FIXUP: # fixup A - offset: 0, value: foo@TPREL_LO, kind: fixup_Mips_TPREL_LO // FIXUP: # fixup A - offset: 0, value: %tprel_lo(foo), kind: fixup_Mips_TPREL_LO
// ?????: R_MIPS_GLOB_DAT foo // ?????: R_MIPS_GLOB_DAT foo
.set mips32r6 .set mips32r6
@ -193,12 +193,12 @@
addiu $2, $3, %pcrel_hi(foo) // RELOC: R_MIPS_PCHI16 foo addiu $2, $3, %pcrel_hi(foo) // RELOC: R_MIPS_PCHI16 foo
// ENCBE: addiu $2, $3, %pcrel_hi(foo) # encoding: [0x24,0x62,A,A] // ENCBE: addiu $2, $3, %pcrel_hi(foo) # encoding: [0x24,0x62,A,A]
// ENCLE: addiu $2, $3, %pcrel_hi(foo) # encoding: [A,A,0x62,0x24] // ENCLE: addiu $2, $3, %pcrel_hi(foo) # encoding: [A,A,0x62,0x24]
// FIXUP: # fixup A - offset: 0, value: foo@PCREL_HI16, kind: fixup_MIPS_PCHI16 // FIXUP: # fixup A - offset: 0, value: %pcrel_hi(foo), kind: fixup_MIPS_PCHI16
addiu $2, $3, %pcrel_lo(foo) // RELOC: R_MIPS_PCLO16 foo addiu $2, $3, %pcrel_lo(foo) // RELOC: R_MIPS_PCLO16 foo
// ENCBE: addiu $2, $3, %pcrel_lo(foo) # encoding: [0x24,0x62,A,A] // ENCBE: addiu $2, $3, %pcrel_lo(foo) # encoding: [0x24,0x62,A,A]
// ENCLE: addiu $2, $3, %pcrel_lo(foo) # encoding: [A,A,0x62,0x24] // ENCLE: addiu $2, $3, %pcrel_lo(foo) # encoding: [A,A,0x62,0x24]
// FIXUP: # fixup A - offset: 0, value: foo@PCREL_LO16, kind: fixup_MIPS_PCLO16 // FIXUP: # fixup A - offset: 0, value: %pcrel_lo(foo), kind: fixup_MIPS_PCLO16
.set mips0 .set mips0
// FIXME: R_MIPS16_* // FIXME: R_MIPS16_*