aboutsummaryrefslogtreecommitdiffstats
path: root/lib/MC/MCExpr.cpp
diff options
context:
space:
mode:
authorKevin Enderby <enderby@apple.com>2010-09-30 16:42:21 +0000
committerKevin Enderby <enderby@apple.com>2010-09-30 16:42:21 +0000
commitb5a3ec17a4600b0e99bd0f4578e7639cfe46ba5a (patch)
treec11d45f252d39919b4ee375ba8f536b62a276ba3 /lib/MC/MCExpr.cpp
parent0bb83a84d4319030c0c9260dbfea461c40eea1b2 (diff)
downloadexternal_llvm-b5a3ec17a4600b0e99bd0f4578e7639cfe46ba5a.zip
external_llvm-b5a3ec17a4600b0e99bd0f4578e7639cfe46ba5a.tar.gz
external_llvm-b5a3ec17a4600b0e99bd0f4578e7639cfe46ba5a.tar.bz2
Changes EvaluateAsAbsolute() to return the "current value" of the expression
if we are given a Layout object, even in cases when the value is not fixed. This will be needed by the final patch for the dwarf .loc support to size a new MCDwarf fragment needed to build and emit dwarf line number tables. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115155 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCExpr.cpp')
-rw-r--r--lib/MC/MCExpr.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/MC/MCExpr.cpp b/lib/MC/MCExpr.cpp
index ddd82f3..e9a6062 100644
--- a/lib/MC/MCExpr.cpp
+++ b/lib/MC/MCExpr.cpp
@@ -215,8 +215,23 @@ bool MCExpr::EvaluateAsAbsolute(int64_t &Res, const MCAsmLayout *Layout) const {
return true;
}
- if (!EvaluateAsRelocatable(Value, Layout) || !Value.isAbsolute())
+ if (!EvaluateAsRelocatable(Value, Layout) || !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->getSymbolAddress(
+ &Layout->getAssembler().getSymbolData(Value.getSymA()->getSymbol()));
+ }
+ if (Value.getSymB()) {
+ Res -= Layout->getSymbolAddress(
+ &Layout->getAssembler().getSymbolData(Value.getSymB()->getSymbol()));
+ }
+ }
return false;
+ }
Res = Value.getConstant();
return true;