aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/IntrinsicLowering.cpp
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2009-06-27 10:44:33 +0000
committerEd Schouten <ed@FreeBSD.org>2009-06-27 10:44:33 +0000
commitf859468f5a21b6952ab62917777f9fb3bba57003 (patch)
tree9794dc36f22f2a2b3f8063829d8a9b3a7794acc8 /lib/CodeGen/IntrinsicLowering.cpp
parentf76359690a7035ad21498f2ba6be6991d3b2032d (diff)
downloadsrc-f859468f5a21b6952ab62917777f9fb3bba57003.tar.gz
src-f859468f5a21b6952ab62917777f9fb3bba57003.zip
Import LLVM r74383.vendor/llvm/llvm-r74383
Notes
Notes: svn path=/vendor/llvm/dist/; revision=195098 svn path=/vendor/llvm/llvm-r74383/; revision=195100; tag=vendor/llvm/llvm-r74383
Diffstat (limited to 'lib/CodeGen/IntrinsicLowering.cpp')
-rw-r--r--lib/CodeGen/IntrinsicLowering.cpp97
1 files changed, 28 insertions, 69 deletions
diff --git a/lib/CodeGen/IntrinsicLowering.cpp b/lib/CodeGen/IntrinsicLowering.cpp
index e6912b82c38f..052334a05ba5 100644
--- a/lib/CodeGen/IntrinsicLowering.cpp
+++ b/lib/CodeGen/IntrinsicLowering.cpp
@@ -61,18 +61,16 @@ static void EnsureFPIntrinsicsExist(Module &M, Function *Fn,
template <class ArgIt>
static CallInst *ReplaceCallWith(const char *NewFn, CallInst *CI,
ArgIt ArgBegin, ArgIt ArgEnd,
- const Type *RetTy, Constant *&FCache) {
- if (!FCache) {
- // If we haven't already looked up this function, check to see if the
- // program already contains a function with this name.
- Module *M = CI->getParent()->getParent()->getParent();
- // Get or insert the definition now.
- std::vector<const Type *> ParamTys;
- for (ArgIt I = ArgBegin; I != ArgEnd; ++I)
- ParamTys.push_back((*I)->getType());
- FCache = M->getOrInsertFunction(NewFn,
- FunctionType::get(RetTy, ParamTys, false));
- }
+ const Type *RetTy) {
+ // If we haven't already looked up this function, check to see if the
+ // program already contains a function with this name.
+ Module *M = CI->getParent()->getParent()->getParent();
+ // Get or insert the definition now.
+ std::vector<const Type *> ParamTys;
+ for (ArgIt I = ArgBegin; I != ArgEnd; ++I)
+ ParamTys.push_back((*I)->getType());
+ Constant* FCache = M->getOrInsertFunction(NewFn,
+ FunctionType::get(RetTy, ParamTys, false));
IRBuilder<> Builder(CI->getParent(), CI);
SmallVector<Value *, 8> Args(ArgBegin, ArgEnd);
@@ -624,25 +622,24 @@ static Instruction *LowerPartSet(CallInst *CI) {
return NewCI;
}
-static void ReplaceFPIntrinsicWithCall(CallInst *CI, Constant *FCache,
- Constant *DCache, Constant *LDCache,
- const char *Fname, const char *Dname,
+static void ReplaceFPIntrinsicWithCall(CallInst *CI, const char *Fname,
+ const char *Dname,
const char *LDname) {
switch (CI->getOperand(1)->getType()->getTypeID()) {
default: assert(0 && "Invalid type in intrinsic"); abort();
case Type::FloatTyID:
ReplaceCallWith(Fname, CI, CI->op_begin() + 1, CI->op_end(),
- Type::FloatTy, FCache);
+ Type::FloatTy);
break;
case Type::DoubleTyID:
ReplaceCallWith(Dname, CI, CI->op_begin() + 1, CI->op_end(),
- Type::DoubleTy, DCache);
+ Type::DoubleTy);
break;
case Type::X86_FP80TyID:
case Type::FP128TyID:
case Type::PPC_FP128TyID:
ReplaceCallWith(LDname, CI, CI->op_begin() + 1, CI->op_end(),
- CI->getOperand(1)->getType(), LDCache);
+ CI->getOperand(1)->getType());
break;
}
}
@@ -668,9 +665,8 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
// by the lowerinvoke pass. In both cases, the right thing to do is to
// convert the call to an explicit setjmp or longjmp call.
case Intrinsic::setjmp: {
- static Constant *SetjmpFCache = 0;
Value *V = ReplaceCallWith("setjmp", CI, CI->op_begin() + 1, CI->op_end(),
- Type::Int32Ty, SetjmpFCache);
+ Type::Int32Ty);
if (CI->getType() != Type::VoidTy)
CI->replaceAllUsesWith(V);
break;
@@ -681,17 +677,15 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
break;
case Intrinsic::longjmp: {
- static Constant *LongjmpFCache = 0;
ReplaceCallWith("longjmp", CI, CI->op_begin() + 1, CI->op_end(),
- Type::VoidTy, LongjmpFCache);
+ Type::VoidTy);
break;
}
case Intrinsic::siglongjmp: {
// Insert the call to abort
- static Constant *AbortFCache = 0;
ReplaceCallWith("abort", CI, CI->op_end(), CI->op_end(),
- Type::VoidTy, AbortFCache);
+ Type::VoidTy);
break;
}
case Intrinsic::ctpop:
@@ -728,7 +722,6 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
case Intrinsic::stacksave:
case Intrinsic::stackrestore: {
- static bool Warned = false;
if (!Warned)
cerr << "WARNING: this target does not support the llvm.stack"
<< (Callee->getIntrinsicID() == Intrinsic::stacksave ?
@@ -783,7 +776,6 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
break; // Strip out annotate intrinsic
case Intrinsic::memcpy: {
- static Constant *MemcpyFCache = 0;
const IntegerType *IntPtr = TD.getIntPtrType();
Value *Size = Builder.CreateIntCast(CI->getOperand(3), IntPtr,
/* isSigned */ false);
@@ -791,12 +783,10 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
Ops[0] = CI->getOperand(1);
Ops[1] = CI->getOperand(2);
Ops[2] = Size;
- ReplaceCallWith("memcpy", CI, Ops, Ops+3, CI->getOperand(1)->getType(),
- MemcpyFCache);
+ ReplaceCallWith("memcpy", CI, Ops, Ops+3, CI->getOperand(1)->getType());
break;
}
case Intrinsic::memmove: {
- static Constant *MemmoveFCache = 0;
const IntegerType *IntPtr = TD.getIntPtrType();
Value *Size = Builder.CreateIntCast(CI->getOperand(3), IntPtr,
/* isSigned */ false);
@@ -804,12 +794,10 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
Ops[0] = CI->getOperand(1);
Ops[1] = CI->getOperand(2);
Ops[2] = Size;
- ReplaceCallWith("memmove", CI, Ops, Ops+3, CI->getOperand(1)->getType(),
- MemmoveFCache);
+ ReplaceCallWith("memmove", CI, Ops, Ops+3, CI->getOperand(1)->getType());
break;
}
case Intrinsic::memset: {
- static Constant *MemsetFCache = 0;
const IntegerType *IntPtr = TD.getIntPtrType();
Value *Size = Builder.CreateIntCast(CI->getOperand(3), IntPtr,
/* isSigned */ false);
@@ -819,64 +807,35 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
Ops[1] = Builder.CreateIntCast(CI->getOperand(2), Type::Int32Ty,
/* isSigned */ false);
Ops[2] = Size;
- ReplaceCallWith("memset", CI, Ops, Ops+3, CI->getOperand(1)->getType(),
- MemsetFCache);
+ ReplaceCallWith("memset", CI, Ops, Ops+3, CI->getOperand(1)->getType());
break;
}
case Intrinsic::sqrt: {
- static Constant *sqrtFCache = 0;
- static Constant *sqrtDCache = 0;
- static Constant *sqrtLDCache = 0;
- ReplaceFPIntrinsicWithCall(CI, sqrtFCache, sqrtDCache, sqrtLDCache,
- "sqrtf", "sqrt", "sqrtl");
+ ReplaceFPIntrinsicWithCall(CI, "sqrtf", "sqrt", "sqrtl");
break;
}
case Intrinsic::log: {
- static Constant *logFCache = 0;
- static Constant *logDCache = 0;
- static Constant *logLDCache = 0;
- ReplaceFPIntrinsicWithCall(CI, logFCache, logDCache, logLDCache,
- "logf", "log", "logl");
+ ReplaceFPIntrinsicWithCall(CI, "logf", "log", "logl");
break;
}
case Intrinsic::log2: {
- static Constant *log2FCache = 0;
- static Constant *log2DCache = 0;
- static Constant *log2LDCache = 0;
- ReplaceFPIntrinsicWithCall(CI, log2FCache, log2DCache, log2LDCache,
- "log2f", "log2", "log2l");
+ ReplaceFPIntrinsicWithCall(CI, "log2f", "log2", "log2l");
break;
}
case Intrinsic::log10: {
- static Constant *log10FCache = 0;
- static Constant *log10DCache = 0;
- static Constant *log10LDCache = 0;
- ReplaceFPIntrinsicWithCall(CI, log10FCache, log10DCache, log10LDCache,
- "log10f", "log10", "log10l");
+ ReplaceFPIntrinsicWithCall(CI, "log10f", "log10", "log10l");
break;
}
case Intrinsic::exp: {
- static Constant *expFCache = 0;
- static Constant *expDCache = 0;
- static Constant *expLDCache = 0;
- ReplaceFPIntrinsicWithCall(CI, expFCache, expDCache, expLDCache,
- "expf", "exp", "expl");
+ ReplaceFPIntrinsicWithCall(CI, "expf", "exp", "expl");
break;
}
case Intrinsic::exp2: {
- static Constant *exp2FCache = 0;
- static Constant *exp2DCache = 0;
- static Constant *exp2LDCache = 0;
- ReplaceFPIntrinsicWithCall(CI, exp2FCache, exp2DCache, exp2LDCache,
- "exp2f", "exp2", "exp2l");
+ ReplaceFPIntrinsicWithCall(CI, "exp2f", "exp2", "exp2l");
break;
}
case Intrinsic::pow: {
- static Constant *powFCache = 0;
- static Constant *powDCache = 0;
- static Constant *powLDCache = 0;
- ReplaceFPIntrinsicWithCall(CI, powFCache, powDCache, powLDCache,
- "powf", "pow", "powl");
+ ReplaceFPIntrinsicWithCall(CI, "powf", "pow", "powl");
break;
}
case Intrinsic::flt_rounds: