[dragonegg] r185090 - Implement support for FMA_EXPR.
Peter Collingbourne
peter at pcc.me.uk
Thu Jun 27 11:10:52 PDT 2013
Author: pcc
Date: Thu Jun 27 13:10:51 2013
New Revision: 185090
URL: http://llvm.org/viewvc/llvm-project?rev=185090&view=rev
Log:
Implement support for FMA_EXPR.
Added:
dragonegg/trunk/test/validator/c/fma.c
Modified:
dragonegg/trunk/include/dragonegg/Internals.h
dragonegg/trunk/src/Convert.cpp
Modified: dragonegg/trunk/include/dragonegg/Internals.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/Internals.h?rev=185090&r1=185089&r2=185090&view=diff
==============================================================================
--- dragonegg/trunk/include/dragonegg/Internals.h (original)
+++ dragonegg/trunk/include/dragonegg/Internals.h Thu Jun 27 13:10:51 2013
@@ -584,6 +584,9 @@ private:
// Ternary expressions.
llvm::Value *EmitReg_CondExpr(tree_node *op0, tree_node *op1, tree_node *op2);
+#if (GCC_MINOR > 5)
+ llvm::Value *EmitReg_FMA_EXPR(tree_node *op0, tree_node *op1, tree_node *op2);
+#endif
#if (GCC_MINOR > 6)
llvm::Value *EmitReg_VEC_PERM_EXPR(tree_node *op0, tree_node *op1,
tree_node *op2);
Modified: dragonegg/trunk/src/Convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=185090&r1=185089&r2=185090&view=diff
==============================================================================
--- dragonegg/trunk/src/Convert.cpp (original)
+++ dragonegg/trunk/src/Convert.cpp Thu Jun 27 13:10:51 2013
@@ -8000,6 +8000,18 @@ bool TreeToLLVM::EmitBuiltinCall(gimple
}
#endif
+#if (GCC_MINOR > 5)
+ Value *TreeToLLVM::EmitReg_FMA_EXPR(tree op0, tree op1, tree op2) {
+ Value *V0 = EmitRegister(op0);
+ Value *V1 = EmitRegister(op1);
+ Value *V2 = EmitRegister(op2);
+
+ Value *FMAIntr = Intrinsic::getDeclaration(TheModule, Intrinsic::fma,
+ V0->getType());
+ return Builder.CreateCall3(FMAIntr, V0, V1, V2);
+ }
+#endif
+
Value *TreeToLLVM::EmitReg_VecUnpackHiExpr(tree type, tree op0) {
// Eg: <2 x double> = VEC_UNPACK_HI_EXPR(<4 x float>)
Value *Op = EmitRegister(op0);
@@ -8946,7 +8958,7 @@ bool TreeToLLVM::EmitBuiltinCall(gimple
tree_code code = gimple_assign_rhs_code(stmt);
tree rhs1 = gimple_assign_rhs1(stmt);
tree rhs2 = gimple_assign_rhs2(stmt);
-#if (GCC_MINOR > 6)
+#if (GCC_MINOR > 5)
tree rhs3 = gimple_assign_rhs3(stmt);
#endif
@@ -9138,6 +9150,11 @@ bool TreeToLLVM::EmitBuiltinCall(gimple
break;
// Ternary expressions.
+#if (GCC_MINOR > 5)
+ case FMA_EXPR:
+ RHS = EmitReg_FMA_EXPR(rhs1, rhs2, rhs3);
+ break;
+#endif
#if (GCC_MINOR > 6)
case COND_EXPR:
case VEC_COND_EXPR:
Added: dragonegg/trunk/test/validator/c/fma.c
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/test/validator/c/fma.c?rev=185090&view=auto
==============================================================================
--- dragonegg/trunk/test/validator/c/fma.c (added)
+++ dragonegg/trunk/test/validator/c/fma.c Thu Jun 27 13:10:51 2013
@@ -0,0 +1,10 @@
+// RUN: %dragonegg -mfma4 -S %s -o - | FileCheck %s
+// XFAIL: gcc-4.5
+
+// CHECK: @fmaftest
+// CHECK: call float @llvm.fma.f32
+float fmaftest(float a, float b, float c) { return __builtin_fmaf(a, b, c); }
+
+// CHECK: @fmatest
+// CHECK: call double @llvm.fma.f64
+double fmatest(double a, double b, double c) { return __builtin_fma(a, b, c); }
More information about the llvm-commits
mailing list