[dragonegg] r182593 - Backport iround support from mainline.
Duncan Sands
baldrick at free.fr
Thu May 23 10:04:21 PDT 2013
Author: baldrick
Date: Thu May 23 12:04:20 2013
New Revision: 182593
URL: http://llvm.org/viewvc/llvm-project?rev=182593&view=rev
Log:
Backport iround support from mainline.
Added:
dragonegg/branches/release_33/test/validator/c/lround.c
- copied unchanged from r182591, dragonegg/trunk/test/validator/c/lround.c
Modified:
dragonegg/branches/release_33/ (props changed)
dragonegg/branches/release_33/include/dragonegg/Internals.h
dragonegg/branches/release_33/src/Convert.cpp
Propchange: dragonegg/branches/release_33/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu May 23 12:04:20 2013
@@ -1 +1 @@
-/dragonegg/trunk:181689-182277,182565
+/dragonegg/trunk:181689-182277,182565,182591
Modified: dragonegg/branches/release_33/include/dragonegg/Internals.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/branches/release_33/include/dragonegg/Internals.h?rev=182593&r1=182592&r2=182593&view=diff
==============================================================================
--- dragonegg/branches/release_33/include/dragonegg/Internals.h (original)
+++ dragonegg/branches/release_33/include/dragonegg/Internals.h Thu May 23 12:04:20 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/branches/release_33/src/Convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/branches/release_33/src/Convert.cpp?rev=182593&r1=182592&r2=182593&view=diff
==============================================================================
--- dragonegg/branches/release_33/src/Convert.cpp (original)
+++ dragonegg/branches/release_33/src/Convert.cpp Thu May 23 12:04:20 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;
More information about the llvm-commits
mailing list