Skip to content

Commit d9a767c

Browse files
committed
[Mips,MC] Replace getSymA()->getSymbol() with getAddSym. NFC
We will replace the MCSymbolRefExpr member in MCValue with MCSymbol. This change reduces dependence on MCSymbolRefExpr. Create a MipsMCExpr::create overload that takes MCSymbol as an argument. We use the order preferred by other targets.
1 parent 0431fea commit d9a767c

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3009,7 +3009,7 @@ bool MipsAsmParser::loadAndAddSymbolAddress(const MCExpr *SymExpr,
30093009
const MCExpr *CallHiExpr =
30103010
MipsMCExpr::create(MipsMCExpr::MEK_GOT_HI16, SymExpr, getContext());
30113011
const MCExpr *CallLoExpr = MipsMCExpr::create(
3012-
MipsMCExpr::MEK_GOT_LO16, Res.getSymA(), getContext());
3012+
Res.getAddSym(), MipsMCExpr::MEK_GOT_LO16, getContext());
30133013

30143014
TOut.emitRX(Mips::LUi, TmpReg, MCOperand::createExpr(CallHiExpr), IDLoc,
30153015
STI);
@@ -3040,7 +3040,7 @@ bool MipsAsmParser::loadAndAddSymbolAddress(const MCExpr *SymExpr,
30403040
// The daddiu's marked with a '>' may be omitted if they are redundant. If
30413041
// this happens then the last instruction must use $rd as the result
30423042
// register.
3043-
GotExpr = MipsMCExpr::create(MipsMCExpr::MEK_GOT_DISP, Res.getSymA(),
3043+
GotExpr = MipsMCExpr::create(Res.getAddSym(), MipsMCExpr::MEK_GOT_DISP,
30443044
getContext());
30453045
if (Res.getConstant() != 0) {
30463046
// Symbols fully resolve with just the %got_disp(symbol) but we
@@ -3075,7 +3075,7 @@ bool MipsAsmParser::loadAndAddSymbolAddress(const MCExpr *SymExpr,
30753075
// External symbols fully resolve the symbol with just the %got(symbol)
30763076
// but we must still account for any offset to the symbol for
30773077
// expressions like symbol+8.
3078-
GotExpr = MipsMCExpr::create(MipsMCExpr::MEK_GOT, Res.getSymA(),
3078+
GotExpr = MipsMCExpr::create(Res.getAddSym(), MipsMCExpr::MEK_GOT,
30793079
getContext());
30803080
if (Res.getConstant() != 0)
30813081
LoExpr = MCConstantExpr::create(Res.getConstant(), getContext());
@@ -3771,8 +3771,9 @@ void MipsAsmParser::expandMem16Inst(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
37713771
return;
37723772
}
37733773

3774-
loadAndAddSymbolAddress(Res.getSymA(), TmpReg, BaseReg,
3775-
!ABI.ArePtrs64bit(), IDLoc, Out, STI);
3774+
loadAndAddSymbolAddress(
3775+
MCSymbolRefExpr::create(Res.getAddSym(), getContext()), TmpReg,
3776+
BaseReg, !ABI.ArePtrs64bit(), IDLoc, Out, STI);
37763777
emitInstWithOffset(MCOperand::createImm(int16_t(Res.getConstant())));
37773778
} else {
37783779
// FIXME: Implement 64-bit case.

llvm/lib/Target/Mips/MCTargetDesc/MipsMCExpr.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ using namespace llvm;
2626

2727
const MipsMCExpr *MipsMCExpr::create(MipsMCExpr::Specifier S,
2828
const MCExpr *Expr, MCContext &Ctx) {
29-
return new (Ctx) MipsMCExpr(S, Expr);
29+
return new (Ctx) MipsMCExpr(Expr, S);
30+
}
31+
32+
const MipsMCExpr *MipsMCExpr::create(const MCSymbol *Sym, Specifier S,
33+
MCContext &Ctx) {
34+
return new (Ctx) MipsMCExpr(MCSymbolRefExpr::create(Sym, Ctx), S);
3035
}
3136

3237
const MipsMCExpr *MipsMCExpr::createGpOff(MipsMCExpr::Specifier S,

llvm/lib/Target/Mips/MCTargetDesc/MipsMCExpr.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,17 @@ class MipsMCExpr : public MCTargetExpr {
4747
};
4848

4949
private:
50-
const Specifier specifier;
5150
const MCExpr *Expr;
51+
const Specifier specifier;
5252

53-
explicit MipsMCExpr(Specifier S, const MCExpr *Expr)
54-
: specifier(S), Expr(Expr) {}
53+
explicit MipsMCExpr(const MCExpr *Expr, Specifier S)
54+
: Expr(Expr), specifier(S) {}
5555

5656
public:
5757
static const MipsMCExpr *create(Specifier S, const MCExpr *Expr,
5858
MCContext &Ctx);
59+
static const MipsMCExpr *create(const MCSymbol *Sym, Specifier S,
60+
MCContext &Ctx);
5961
static const MipsMCExpr *createGpOff(Specifier S, const MCExpr *Expr,
6062
MCContext &Ctx);
6163

0 commit comments

Comments
 (0)