BUILTIN(__builtin_copysign, "ddd", "ncF")
BUILTIN(__builtin_copysignf, "fff", "ncF")
BUILTIN(__builtin_copysignl, "LdLdLd", "ncF")
+BUILTIN(__builtin_powi , "ddi" , "nc")
+BUILTIN(__builtin_powif, "ffi" , "nc")
+BUILTIN(__builtin_powil, "LdLdi", "nc")
// FP Comparisons.
BUILTIN(__builtin_isgreater , "i.", "nc")
}
case Builtin::BI__builtin_expect:
+ // FIXME: pass expect through to LLVM
return RValue::get(EmitScalarExpr(E->getArg(0)));
case Builtin::BI__builtin_bswap32:
case Builtin::BI__builtin_bswap64: {
// Otherwise, call libm 'nan'.
break;
}
+ case Builtin::BI__builtin_powi:
+ case Builtin::BI__builtin_powif:
+ case Builtin::BI__builtin_powil: {
+ Value *Base = EmitScalarExpr(E->getArg(0));
+ Value *Exponent = EmitScalarExpr(E->getArg(1));
+
+ const llvm::Type *ArgType = Base->getType();
+ Value *F = CGM.getIntrinsic(Intrinsic::powi, &ArgType, 1);
+
+ const llvm::Type *ResultType = ConvertType(E->getType());
+ return RValue::get(Builder.CreateCall2(F, Base, Exponent, "tmp"));
+ }
+
case Builtin::BI__builtin_isgreater:
case Builtin::BI__builtin_isgreaterequal:
case Builtin::BI__builtin_isless:
--- /dev/null
+// RUN: clang -emit-llvm -o - %s > %t
+// RUN: ! grep "__builtin" %t
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+void test(long double a, int b) {
+ printf("%Lf**%d: %08x %08x %016Lx\n",
+ a, b,
+ __builtin_powi(a, b),
+ __builtin_powif(a, b),
+ __builtin_powil(a, b)
+ );
+}
+
+int main() {
+ int i;
+
+ test(-1,-1LL);
+ test(0,0);
+ test(1,1);
+
+ for (i=0; i<3; i++) {
+ test(random(), i);
+ }
+
+ return 0;
+}