Simplify EvaluateAsAbsolute now that EvaluateAsRelocatableImpl does all

the folding it can.

llvm-svn: 122359
This commit is contained in:
Rafael Espindola 2010-12-21 20:51:42 +00:00
parent 6bdb49ded8
commit a468ae02cb
1 changed files with 5 additions and 19 deletions

View File

@ -269,27 +269,13 @@ bool MCExpr::EvaluateAsAbsolute(int64_t &Res, const MCAssembler *Asm,
// FIXME: The use if InSet = Addrs is a hack. Setting InSet causes us
// absolutize differences across sections and that is what the MachO writer
// uses Addrs for.
if (!EvaluateAsRelocatableImpl(Value, Asm, Layout, Addrs, /*InSet*/ Addrs) ||
!Value.isAbsolute()) {
// EvaluateAsAbsolute is defined to return the "current value" of
// the expression if we are given a Layout object, even in cases
// when the value is not fixed.
if (Layout) {
Res = Value.getConstant();
if (Value.getSymA()) {
Res += Layout->getSymbolOffset(
&Layout->getAssembler().getSymbolData(Value.getSymA()->getSymbol()));
}
if (Value.getSymB()) {
Res -= Layout->getSymbolOffset(
&Layout->getAssembler().getSymbolData(Value.getSymB()->getSymbol()));
}
}
return false;
}
bool IsRelocatable =
EvaluateAsRelocatableImpl(Value, Asm, Layout, Addrs, /*InSet*/ Addrs);
// Record the current value.
Res = Value.getConstant();
return true;
return IsRelocatable && Value.isAbsolute();
}
/// \brief Helper method for \see EvaluateSymbolAdd().