Skip to content

Commit 7722d75

Browse files
committed
[MC] evaluateAsRelocatableImpl: remove the Fixup argument
Follow-up to d6fbffa . This commit updates all call sites and removes the argument from the function.
1 parent ff2ed15 commit 7722d75

File tree

47 files changed

+134
-164
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+134
-164
lines changed

llvm/include/llvm/MC/MCExpr.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,8 @@ class MCExpr {
113113
///
114114
/// \param Res - The relocatable value, if evaluation succeeds.
115115
/// \param Asm - The assembler object to use for evaluating values.
116-
/// \param Fixup - The Fixup object if available.
117116
/// \return - True on success.
118-
bool evaluateAsRelocatable(MCValue &Res, const MCAssembler *Asm,
119-
const MCFixup *Fixup) const;
117+
bool evaluateAsRelocatable(MCValue &Res, const MCAssembler *Asm) const;
120118

121119
/// Try to evaluate the expression to the form (a - b + constant) where
122120
/// neither a nor b are variables.
@@ -557,8 +555,8 @@ class MCTargetExpr : public MCExpr {
557555

558556
public:
559557
virtual void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const = 0;
560-
virtual bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,
561-
const MCFixup *Fixup) const = 0;
558+
virtual bool evaluateAsRelocatableImpl(MCValue &Res,
559+
const MCAssembler *Asm) const = 0;
562560
// allow Target Expressions to be checked for equality
563561
virtual bool isEqualTo(const MCExpr *x) const { return false; }
564562
virtual bool isSymbolUsedInExpression(const MCSymbol *Sym) const {

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3862,7 +3862,7 @@ static void handleIndirectSymViaGOTPCRel(AsmPrinter &AP, const MCExpr **ME,
38623862
// cstexpr := <gotequiv> - <foo> + gotpcrelcst, where
38633863
// gotpcrelcst := <offset from @foo base> + <cst>
38643864
MCValue MV;
3865-
if (!(*ME)->evaluateAsRelocatable(MV, nullptr, nullptr) || MV.isAbsolute())
3865+
if (!(*ME)->evaluateAsRelocatable(MV, nullptr) || MV.isAbsolute())
38663866
return;
38673867
const MCSymbolRefExpr *SymA = MV.getSymA();
38683868
if (!SymA)

llvm/lib/MC/MCAssembler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ bool MCAssembler::isThumbFunc(const MCSymbol *Symbol) const {
119119
const MCExpr *Expr = Symbol->getVariableValue();
120120

121121
MCValue V;
122-
if (!Expr->evaluateAsRelocatable(V, nullptr, nullptr))
122+
if (!Expr->evaluateAsRelocatable(V, nullptr))
123123
return false;
124124

125125
if (V.getSymB() || V.getRefKind() != MCSymbolRefExpr::VK_None)
@@ -155,7 +155,7 @@ bool MCAssembler::evaluateFixup(const MCFixup &Fixup, const MCFragment *DF,
155155
MCContext &Ctx = getContext();
156156
Value = 0;
157157
WasForced = false;
158-
if (!Expr->evaluateAsRelocatable(Target, this, &Fixup)) {
158+
if (!Expr->evaluateAsRelocatable(Target, this)) {
159159
Ctx.reportError(Fixup.getLoc(), "expected relocatable expression");
160160
return true;
161161
}

llvm/lib/MC/MCExpr.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ bool MCExpr::evaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm,
286286
}
287287

288288
bool IsRelocatable = evaluateAsRelocatableImpl(Value, Asm, Addrs, InSet);
289-
Res = Value.getConstant();
290-
// Value with RefKind (e.g. %hi(0xdeadbeef) in MIPS) is not considered
289+
Res = Value.getConstant(); // Value with RefKind (e.g. %hi(0xdeadbeef) in
290+
// MIPS) is not considered
291291
// absolute (the value is unknown at parse time), even if it might be resolved
292292
// by evaluateFixup.
293293
return IsRelocatable && Value.isAbsolute() && Value.getRefKind() == 0;
@@ -493,15 +493,12 @@ static bool evaluateSymbolicAdd(const MCAssembler *Asm,
493493
return true;
494494
}
495495

496-
bool MCExpr::evaluateAsRelocatable(MCValue &Res, const MCAssembler *Asm,
497-
const MCFixup *Fixup) const {
496+
bool MCExpr::evaluateAsRelocatable(MCValue &Res, const MCAssembler *Asm) const {
498497
return evaluateAsRelocatableImpl(Res, Asm, nullptr, false);
499498
}
500-
501499
bool MCExpr::evaluateAsValue(MCValue &Res, const MCAssembler &Asm) const {
502500
return evaluateAsRelocatableImpl(Res, &Asm, nullptr, true);
503501
}
504-
505502
static bool canExpand(const MCSymbol &Sym, bool InSet) {
506503
if (Sym.isWeakExternal())
507504
return false;
@@ -524,9 +521,7 @@ bool MCExpr::evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,
524521
++stats::MCExprEvaluate;
525522
switch (getKind()) {
526523
case Target:
527-
return cast<MCTargetExpr>(this)->evaluateAsRelocatableImpl(Res, Asm,
528-
nullptr);
529-
524+
return cast<MCTargetExpr>(this)->evaluateAsRelocatableImpl(Res, Asm);
530525
case Constant:
531526
Res = MCValue::get(cast<MCConstantExpr>(this)->getValue());
532527
return true;
@@ -589,7 +584,6 @@ bool MCExpr::evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,
589584

590585
if (!AUE->getSubExpr()->evaluateAsRelocatableImpl(Value, Asm, Addrs, InSet))
591586
return false;
592-
593587
switch (AUE->getOpcode()) {
594588
case MCUnaryExpr::LNot:
595589
if (!Value.isAbsolute())

llvm/lib/MC/MCMachOStreamer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ void MCMachOStreamer::emitLabel(MCSymbol *Symbol, SMLoc Loc) {
181181
void MCMachOStreamer::emitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
182182
MCValue Res;
183183

184-
if (Value->evaluateAsRelocatable(Res, nullptr, nullptr)) {
184+
if (Value->evaluateAsRelocatable(Res, nullptr)) {
185185
if (const MCSymbolRefExpr *SymAExpr = Res.getSymA()) {
186186
const MCSymbol &SymA = SymAExpr->getSymbol();
187187
if (!Res.getSymB() && (SymA.getName() == "" || Res.getConstant() != 0))

llvm/lib/MC/MCObjectStreamer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ getOffsetAndDataFragment(const MCSymbol &Symbol, uint32_t &RelocOffset,
588588
if (Symbol.isVariable()) {
589589
const MCExpr *SymbolExpr = Symbol.getVariableValue();
590590
MCValue OffsetVal;
591-
if(!SymbolExpr->evaluateAsRelocatable(OffsetVal, nullptr, nullptr))
591+
if (!SymbolExpr->evaluateAsRelocatable(OffsetVal, nullptr))
592592
return std::make_pair(false,
593593
std::string("symbol in .reloc offset is not "
594594
"relocatable"));
@@ -662,7 +662,7 @@ MCObjectStreamer::emitRelocDirective(const MCExpr &Offset, StringRef Name,
662662

663663
MCDataFragment *DF = getOrCreateDataFragment(&STI);
664664
MCValue OffsetVal;
665-
if (!Offset.evaluateAsRelocatable(OffsetVal, nullptr, nullptr))
665+
if (!Offset.evaluateAsRelocatable(OffsetVal, nullptr))
666666
return std::make_pair(false,
667667
std::string(".reloc offset is not relocatable"));
668668
if (OffsetVal.isAbsolute()) {

llvm/lib/MC/MCParser/AsmParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3125,7 +3125,7 @@ bool AsmParser::parseDirectiveReloc(SMLoc DirectiveLoc) {
31253125
return true;
31263126

31273127
MCValue Value;
3128-
if (!Expr->evaluateAsRelocatable(Value, nullptr, nullptr))
3128+
if (!Expr->evaluateAsRelocatable(Value, nullptr))
31293129
return Error(ExprLoc, "expression must be relocatable");
31303130
}
31313131

llvm/lib/MC/MCWinCOFFStreamer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ class MCCOFFSectionNumberTargetExpr final : public MCTargetExpr {
6666
SectionSymbol.print(OS, MAI);
6767
}
6868

69-
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,
70-
const MCFixup *Fixup) const override {
69+
bool evaluateAsRelocatableImpl(MCValue &Res,
70+
const MCAssembler *Asm) const override {
7171
auto sectionNumber = Writer.getSectionNumber(SectionSymbol.getSection());
7272
assert(sectionNumber != 0 &&
7373
"Containing section was not assigned a number");
@@ -102,8 +102,8 @@ class MCCOFFSectionOffsetTargetExpr final : public MCTargetExpr {
102102
Symbol.print(OS, MAI);
103103
}
104104

105-
bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,
106-
const MCFixup *Fixup) const override {
105+
bool evaluateAsRelocatableImpl(MCValue &Res,
106+
const MCAssembler *Asm) const override {
107107
uint64_t CallsiteOffset = 0;
108108
if (!Asm->getSymbolOffset(Symbol, CallsiteOffset)) {
109109
return true;

llvm/lib/MC/MachObjectWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ uint64_t MachObjectWriter::getSymbolAddress(const MCSymbol &S,
104104
return C->getValue();
105105

106106
MCValue Target;
107-
if (!S.getVariableValue()->evaluateAsRelocatable(Target, &Asm, nullptr))
107+
if (!S.getVariableValue()->evaluateAsRelocatable(Target, &Asm))
108108
report_fatal_error("unable to evaluate offset for variable '" +
109109
S.getName() + "'");
110110

llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8226,7 +8226,7 @@ AArch64AsmParser::classifySymbolRef(const MCExpr *Expr,
82268226

82278227
// Check that it looks like a symbol + an addend
82288228
MCValue Res;
8229-
bool Relocatable = Expr->evaluateAsRelocatable(Res, nullptr, nullptr);
8229+
bool Relocatable = Expr->evaluateAsRelocatable(Res, nullptr);
82308230
if (!Relocatable || Res.getSymB())
82318231
return false;
82328232

0 commit comments

Comments
 (0)