diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-03-23 23:47:07 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-03-23 23:47:07 +0000 |
commit | ef6e96f91fd812ba9ead6fdef3975abb1139c123 (patch) | |
tree | 90883618d5ceb4b13532588726772c8d9b50ce9f /lib/MC | |
parent | 9972aff7da15e5019b7cf6d0cc6dde0cd6192360 (diff) | |
download | external_llvm-ef6e96f91fd812ba9ead6fdef3975abb1139c123.zip external_llvm-ef6e96f91fd812ba9ead6fdef3975abb1139c123.tar.gz external_llvm-ef6e96f91fd812ba9ead6fdef3975abb1139c123.tar.bz2 |
llvm-mc: Fast path EvaluateAbsolute of constants.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99348 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC')
-rw-r--r-- | lib/MC/MCExpr.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/MC/MCExpr.cpp b/lib/MC/MCExpr.cpp index 2759944..d0025f3 100644 --- a/lib/MC/MCExpr.cpp +++ b/lib/MC/MCExpr.cpp @@ -194,6 +194,12 @@ void MCTargetExpr::Anchor() {} bool MCExpr::EvaluateAsAbsolute(int64_t &Res, const MCAsmLayout *Layout) const { MCValue Value; + // Fast path constants. + if (const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(this)) { + Res = CE->getValue(); + return true; + } + if (!EvaluateAsRelocatable(Value, Layout) || !Value.isAbsolute()) return false; |