+static void ReplaceFPIntrinsicWithCall(CallInst *CI, Constant *FCache,
+ Constant *DCache, Constant *LDCache,
+ 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);
+ break;
+ case Type::DoubleTyID:
+ ReplaceCallWith(Dname, CI, CI->op_begin()+1, CI->op_end(),
+ Type::DoubleTy, DCache);
+ 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);
+ break;
+ }
+}