aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/CGBuiltin.cpp15
-rw-r--r--lib/CodeGen/TargetInfo.cpp4
-rw-r--r--lib/CodeGen/TargetInfo.h4
3 files changed, 19 insertions, 4 deletions
diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp
index 7f1709e10f..0d5be26a5e 100644
--- a/lib/CodeGen/CGBuiltin.cpp
+++ b/lib/CodeGen/CGBuiltin.cpp
@@ -1293,10 +1293,17 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
case Builtin::BIpow:
case Builtin::BIpowf:
case Builtin::BIpowl: {
- // LOCALMOD: For PNACl we don't want pow* calls to ever turn into
- // intrinsics. We want them to be resolved vs. the newlib implementation
- // within the pexe during bitcode linking.
- // TODO(eliben): upstream this
+ // Transform a call to pow* into a @llvm.pow.* intrinsic call, but only
+ // if the target agrees.
+ if (getTargetHooks().emitIntrinsicForPow()) {
+ if (!FD->hasAttr<ConstAttr>())
+ break;
+ Value *Base = EmitScalarExpr(E->getArg(0));
+ Value *Exponent = EmitScalarExpr(E->getArg(1));
+ llvm::Type *ArgType = Base->getType();
+ Value *F = CGM.getIntrinsic(Intrinsic::pow, ArgType);
+ return RValue::get(Builder.CreateCall2(F, Base, Exponent));
+ }
break;
}
diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp
index b870ae9eb1..6ca2910d79 100644
--- a/lib/CodeGen/TargetInfo.cpp
+++ b/lib/CodeGen/TargetInfo.cpp
@@ -416,6 +416,10 @@ class PNaClTargetCodeGenInfo : public TargetCodeGenInfo {
public:
PNaClTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT)
: TargetCodeGenInfo(new PNaClABIInfo(CGT)) {}
+
+ /// For PNaCl we don't want llvm.pow.* intrinsics to be emitted instead
+ /// of library function calls.
+ bool emitIntrinsicForPow() const { return false; }
};
void PNaClABIInfo::computeInfo(CGFunctionInfo &FI) const {
diff --git a/lib/CodeGen/TargetInfo.h b/lib/CodeGen/TargetInfo.h
index bb50ce69e3..a682c183f0 100644
--- a/lib/CodeGen/TargetInfo.h
+++ b/lib/CodeGen/TargetInfo.h
@@ -73,6 +73,10 @@ namespace clang {
/// through such registers.
virtual bool extendPointerWithSExt() const { return false; }
+ /// Controls whether BIpow* emit an intrinsic call instead of a library
+ /// function call.
+ virtual bool emitIntrinsicForPow() const { return true; }
+
/// Determines the DWARF register number for the stack pointer, for
/// exception-handling purposes. Implements __builtin_dwarf_sp_column.
///