Move ConstantFP construction back to the 2.5-ish API.
[oota-llvm.git] / lib / Transforms / Scalar / SimplifyLibCalls.cpp
index 9a5ed456ba7ffc2b3300ac6c86de1390b00a4bd7..0bf583a52ab1caea730fe1ed519bfbfb24593cf7 100644 (file)
@@ -31,6 +31,7 @@
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/Support/raw_ostream.h"
 #include "llvm/Config/config.h"
 using namespace llvm;
 
@@ -1034,7 +1035,7 @@ struct VISIBILITY_HIDDEN PowOpt : public LibCallOptimization {
     if (Op2C == 0) return 0;
     
     if (Op2C->getValueAPF().isZero())  // pow(x, 0.0) -> 1.0
-      return Context->getConstantFP(CI->getType(), 1.0);
+      return ConstantFP::get(CI->getType(), 1.0);
     
     if (Op2C->isExactlyValue(0.5)) {
       // FIXME: This is not safe for -0.0 and -inf.  This can only be done when
@@ -1054,7 +1055,7 @@ struct VISIBILITY_HIDDEN PowOpt : public LibCallOptimization {
     if (Op2C->isExactlyValue(2.0))  // pow(x, 2.0) -> x*x
       return B.CreateFMul(Op1, Op1, "pow2");
     if (Op2C->isExactlyValue(-1.0)) // pow(x, -1.0) -> 1.0/x
-      return B.CreateFDiv(Context->getConstantFP(CI->getType(), 1.0),
+      return B.CreateFDiv(ConstantFP::get(CI->getType(), 1.0),
                           Op1, "powrecip");
     return 0;
   }
@@ -1093,7 +1094,7 @@ struct VISIBILITY_HIDDEN Exp2Opt : public LibCallOptimization {
       else
         Name = "ldexpl";
 
-      Constant *One = Context->getConstantFP(APFloat(1.0f));
+      Constant *One = ConstantFP::get(*Context, APFloat(1.0f));
       if (Op->getType() != Type::FloatTy)
         One = Context->getConstantExprFPExtend(One, Op->getType());
 
@@ -1655,20 +1656,18 @@ bool SimplifyLibCalls::runOnFunction(Function &F) {
         continue;
       
       // Ignore unknown calls.
-      const char *CalleeName = Callee->getNameStart();
-      StringMap<LibCallOptimization*>::iterator OMI =
-        Optimizations.find(StringRef(CalleeName, Callee->getNameLen()));
-      if (OMI == Optimizations.end()) continue;
+      LibCallOptimization *LCO = Optimizations.lookup(Callee->getName());
+      if (!LCO) continue;
       
       // Set the builder to the instruction after the call.
       Builder.SetInsertPoint(BB, I);
       
       // Try to optimize this call.
-      Value *Result = OMI->second->OptimizeCall(CI, TD, Builder);
+      Value *Result = LCO->OptimizeCall(CI, TD, Builder);
       if (Result == 0) continue;
 
-      DEBUG(DOUT << "SimplifyLibCalls simplified: " << *CI;
-            DOUT << "  into: " << *Result << "\n");
+      DEBUG(errs() << "SimplifyLibCalls simplified: " << *CI;
+            errs() << "  into: " << *Result << "\n");
       
       // Something changed!
       Changed = true;