OSDN Git Service

llvm-mc: Fast path EvaluateAbsolute of constants.
authorDaniel Dunbar <daniel@zuster.org>
Tue, 23 Mar 2010 23:47:07 +0000 (23:47 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 23 Mar 2010 23:47:07 +0000 (23:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99348 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCExpr.cpp

index 2759944..d0025f3 100644 (file)
@@ -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;