[dragonegg] r182591 - Add support for the iround builtin, which gfortran-4.8 generates.
Duncan Sands
baldrick at free.fr
Thu May 23 09:33:26 PDT 2013
Author: baldrick
Date: Thu May 23 11:33:26 2013
New Revision: 182591
URL: http://llvm.org/viewvc/llvm-project?rev=182591&view=rev
Log:
Add support for the iround builtin, which gfortran-4.8 generates.
Added:
dragonegg/trunk/test/validator/c/lround.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=182591&r1=182590&r2=182591&view=diff
==============================================================================
--- dragonegg/trunk/include/dragonegg/Internals.h (original)
+++ dragonegg/trunk/include/dragonegg/Internals.h Thu May 23 11:33:26 2013
@@ -632,6 +632,7 @@ private:
llvm::Value *EmitBuiltinPOW(gimple_statement_d *stmt);
llvm::Value *EmitBuiltinLCEIL(gimple_statement_d *stmt);
llvm::Value *EmitBuiltinLFLOOR(gimple_statement_d *stmt);
+ llvm::Value *EmitBuiltinLROUND(gimple_statement_d *stmt);
llvm::Value *EmitBuiltinCEXPI(gimple_statement_d *stmt);
bool EmitBuiltinAdjustTrampoline(gimple_statement_d *stmt,
Modified: dragonegg/trunk/src/Convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=182591&r1=182590&r2=182591&view=diff
==============================================================================
--- dragonegg/trunk/src/Convert.cpp (original)
+++ dragonegg/trunk/src/Convert.cpp Thu May 23 11:33:26 2013
@@ -4568,6 +4568,16 @@ bool TreeToLLVM::EmitBuiltinCall(gimple
case BUILT_IN_LLFLOORL:
Result = EmitBuiltinLFLOOR(stmt);
return true;
+#if (GCC_MINOR > 6)
+ case BUILT_IN_IROUND:
+ case BUILT_IN_IROUNDF:
+ case BUILT_IN_IROUNDL:
+#endif
+ case BUILT_IN_LROUND:
+ case BUILT_IN_LROUNDF:
+ case BUILT_IN_LROUNDL:
+ Result = EmitBuiltinLROUND(stmt);
+ return true;
case BUILT_IN_CEXPI:
case BUILT_IN_CEXPIF:
case BUILT_IN_CEXPIL:
@@ -5203,6 +5213,26 @@ bool TreeToLLVM::EmitBuiltinCall(gimple
: Builder.CreateFPToSI(Call, RetTy);
}
+ Value *TreeToLLVM::EmitBuiltinLROUND(gimple stmt) {
+ if (!validate_gimple_arglist(stmt, REAL_TYPE, VOID_TYPE))
+ return 0;
+
+ // Cast the result of "lround" to the appropriate integer type.
+ // First call the appropriate version of "lround".
+ tree op = gimple_call_arg(stmt, 0);
+ StringRef Name = SelectFPName(TREE_TYPE(op),
+ "lroundf", "lround", "lroundl");
+ assert(!Name.empty() && "Unsupported floating point type!");
+ CallInst *Call = EmitSimpleCall(Name, long_integer_type_node, op, NULL);
+ Call->setDoesNotThrow();
+ Call->setDoesNotAccessMemory();
+
+ // Then type cast the result of the "lround" call.
+ tree type = gimple_call_return_type(stmt);
+ Type *RetTy = getRegType(type);
+ return Builder.CreateTrunc(Call, RetTy);
+ }
+
Value *TreeToLLVM::EmitBuiltinCEXPI(gimple stmt) {
if (!validate_gimple_arglist(stmt, REAL_TYPE, VOID_TYPE))
return 0;
Added: dragonegg/trunk/test/validator/c/lround.c
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/test/validator/c/lround.c?rev=182591&view=auto
==============================================================================
--- dragonegg/trunk/test/validator/c/lround.c (added)
+++ dragonegg/trunk/test/validator/c/lround.c Thu May 23 11:33:26 2013
@@ -0,0 +1,21 @@
+// RUN: %dragonegg -S %s -o - | FileCheck %s
+// XFAIL: gcc-4.5, gcc-4.6
+long int lr(double x) {
+ return __builtin_lround(x);
+}
+long int lrf(float x) {
+ return __builtin_lroundf(x);
+}
+long int lrl(long double x) {
+ return __builtin_lroundl(x);
+}
+int ir(double x) {
+ return __builtin_iround(x);
+}
+int irf(float x) {
+ return __builtin_iroundf(x);
+}
+int irl(long double x) {
+ return __builtin_iroundl(x);
+}
+// CHECK-NOT: builtin
More information about the llvm-commits
mailing list