X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FCodeGen%2FIntrinsicLowering.cpp;h=bd3d74d27ac82203590d07e42b49abea3c9e5733;hb=cc41586b9d79532172b37e1f44a9077da4b73fc9;hp=42b09c2d3ae332175c09f058232988998c73f1d4;hpb=8806c7b1f5317a9679a5779ffc08c552f2091bce;p=oota-llvm.git diff --git a/lib/CodeGen/IntrinsicLowering.cpp b/lib/CodeGen/IntrinsicLowering.cpp index 42b09c2d3ae..bd3d74d27ac 100644 --- a/lib/CodeGen/IntrinsicLowering.cpp +++ b/lib/CodeGen/IntrinsicLowering.cpp @@ -99,14 +99,65 @@ void IntrinsicLowering::AddPrototypes(Module &M) { PointerType::get(Type::Int8Ty), Type::Int32Ty, TD.getIntPtrType(), (Type *)0); break; - case Intrinsic::sqrt_f32: - case Intrinsic::sqrt_f64: - if(I->arg_begin()->getType() == Type::FloatTy) + case Intrinsic::sqrt: + switch((int)I->arg_begin()->getType()->getTypeID()) { + case Type::FloatTyID: EnsureFunctionExists(M, "sqrtf", I->arg_begin(), I->arg_end(), Type::FloatTy); - else + case Type::DoubleTyID: EnsureFunctionExists(M, "sqrt", I->arg_begin(), I->arg_end(), Type::DoubleTy); + case Type::X86_FP80TyID: + case Type::FP128TyID: + case Type::PPC_FP128TyID: + EnsureFunctionExists(M, "sqrtl", I->arg_begin(), I->arg_end(), + I->arg_begin()->getType()); + } + break; + case Intrinsic::sin: + switch((int)I->arg_begin()->getType()->getTypeID()) { + case Type::FloatTyID: + EnsureFunctionExists(M, "sinf", I->arg_begin(), I->arg_end(), + Type::FloatTy); + case Type::DoubleTyID: + EnsureFunctionExists(M, "sin", I->arg_begin(), I->arg_end(), + Type::DoubleTy); + case Type::X86_FP80TyID: + case Type::FP128TyID: + case Type::PPC_FP128TyID: + EnsureFunctionExists(M, "sinl", I->arg_begin(), I->arg_end(), + I->arg_begin()->getType()); + } + break; + case Intrinsic::cos: + switch((int)I->arg_begin()->getType()->getTypeID()) { + case Type::FloatTyID: + EnsureFunctionExists(M, "cosf", I->arg_begin(), I->arg_end(), + Type::FloatTy); + case Type::DoubleTyID: + EnsureFunctionExists(M, "cos", I->arg_begin(), I->arg_end(), + Type::DoubleTy); + case Type::X86_FP80TyID: + case Type::FP128TyID: + case Type::PPC_FP128TyID: + EnsureFunctionExists(M, "cosl", I->arg_begin(), I->arg_end(), + I->arg_begin()->getType()); + } + break; + case Intrinsic::pow: + switch((int)I->arg_begin()->getType()->getTypeID()) { + case Type::FloatTyID: + EnsureFunctionExists(M, "powf", I->arg_begin(), I->arg_end(), + Type::FloatTy); + case Type::DoubleTyID: + EnsureFunctionExists(M, "pow", I->arg_begin(), I->arg_end(), + Type::DoubleTy); + case Type::X86_FP80TyID: + case Type::FP128TyID: + case Type::PPC_FP128TyID: + EnsureFunctionExists(M, "powl", I->arg_begin(), I->arg_end(), + I->arg_begin()->getType()); + } break; } } @@ -782,16 +833,27 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) { MemsetFCache); break; } - case Intrinsic::sqrt_f32: { + case Intrinsic::sqrt: { static Constant *sqrtfFCache = 0; - ReplaceCallWith("sqrtf", CI, CI->op_begin()+1, CI->op_end(), - Type::FloatTy, sqrtfFCache); - break; - } - case Intrinsic::sqrt_f64: { static Constant *sqrtFCache = 0; - ReplaceCallWith("sqrt", CI, CI->op_begin()+1, CI->op_end(), + static Constant *sqrtLDCache = 0; + switch (CI->getOperand(1)->getType()->getTypeID()) { + default: assert(0 && "Invalid type in sqrt"); abort(); + case Type::FloatTyID: + ReplaceCallWith("sqrtf", CI, CI->op_begin()+1, CI->op_end(), + Type::FloatTy, sqrtfFCache); + break; + case Type::DoubleTyID: + ReplaceCallWith("sqrt", CI, CI->op_begin()+1, CI->op_end(), Type::DoubleTy, sqrtFCache); + break; + case Type::X86_FP80TyID: + case Type::FP128TyID: + case Type::PPC_FP128TyID: + ReplaceCallWith("sqrtl", CI, CI->op_begin()+1, CI->op_end(), + CI->getOperand(1)->getType(), sqrtLDCache); + break; + } break; } }