[llvm-commits] [dragonegg] r146359 - in /dragonegg/trunk: include/dragonegg/Internals.h src/Convert.cpp
Chandler Carruth
chandlerc at gmail.com
Sun Dec 11 20:30:23 PST 2011
Author: chandlerc
Date: Sun Dec 11 22:30:23 2011
New Revision: 146359
URL: http://llvm.org/viewvc/llvm-project?rev=146359&view=rev
Log:
Update DragonEgg for LLVM's r146357.
This causes DragonEgg to explicitly set the new argument to llvm.cttz and
llvm.ctlz intrinsics. These are set to true as that matches the semantics of
the GCC builtins.
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=146359&r1=146358&r2=146359&view=diff
==============================================================================
--- dragonegg/trunk/include/dragonegg/Internals.h (original)
+++ dragonegg/trunk/include/dragonegg/Internals.h Sun Dec 11 22:30:23 2011
@@ -622,6 +622,8 @@
tree_node *fndecl, const MemRef *DestLoc,
Value *&Result);
bool EmitBuiltinUnaryOp(Value *InVal, Value *&Result, Intrinsic::ID Id);
+ Value *EmitBuiltinBitCountIntrinsic(gimple_statement_d *stmt,
+ Intrinsic::ID Id);
Value *EmitBuiltinSQRT(gimple_statement_d *stmt);
Value *EmitBuiltinPOWI(gimple_statement_d *stmt);
Value *EmitBuiltinPOW(gimple_statement_d *stmt);
Modified: dragonegg/trunk/src/Convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=146359&r1=146358&r2=146359&view=diff
==============================================================================
--- dragonegg/trunk/src/Convert.cpp (original)
+++ dragonegg/trunk/src/Convert.cpp Sun Dec 11 22:30:23 2011
@@ -3792,28 +3792,14 @@
// Function* to be incorrectly shared across the different typed functions.
case BUILT_IN_CLZ: // These GCC builtins always return int.
case BUILT_IN_CLZL:
- case BUILT_IN_CLZLL: {
- Value *Amt = EmitMemory(gimple_call_arg(stmt, 0));
- EmitBuiltinUnaryOp(Amt, Result, Intrinsic::ctlz);
- tree return_type = gimple_call_return_type(stmt);
- Type *DestTy = ConvertType(return_type);
- Result = Builder.CreateIntCast(Result, DestTy,
- /*isSigned*/!TYPE_UNSIGNED(return_type),
- "cast");
+ case BUILT_IN_CLZLL:
+ Result = EmitBuiltinBitCountIntrinsic(stmt, Intrinsic::ctlz);
return true;
- }
case BUILT_IN_CTZ: // These GCC builtins always return int.
case BUILT_IN_CTZL:
- case BUILT_IN_CTZLL: {
- Value *Amt = EmitMemory(gimple_call_arg(stmt, 0));
- EmitBuiltinUnaryOp(Amt, Result, Intrinsic::cttz);
- tree return_type = gimple_call_return_type(stmt);
- Type *DestTy = ConvertType(return_type);
- Result = Builder.CreateIntCast(Result, DestTy,
- /*isSigned*/!TYPE_UNSIGNED(return_type),
- "cast");
+ case BUILT_IN_CTZLL:
+ Result = EmitBuiltinBitCountIntrinsic(stmt, Intrinsic::cttz);
return true;
- }
case BUILT_IN_PARITYLL:
case BUILT_IN_PARITYL:
case BUILT_IN_PARITY: {
@@ -4315,6 +4301,18 @@
return true;
}
+Value *TreeToLLVM::EmitBuiltinBitCountIntrinsic(gimple stmt, Intrinsic::ID Id) {
+ Value *Amt = EmitMemory(gimple_call_arg(stmt, 0));
+ Value *Result = Builder.CreateCall2(Intrinsic::getDeclaration(TheModule, Id,
+ Amt->getType()),
+ Amt, Builder.getTrue());
+ tree return_type = gimple_call_return_type(stmt);
+ Type *DestTy = ConvertType(return_type);
+ return Builder.CreateIntCast(Result, DestTy,
+ /*isSigned*/!TYPE_UNSIGNED(return_type),
+ "cast");
+}
+
Value *TreeToLLVM::EmitBuiltinSQRT(gimple stmt) {
Value *Amt = EmitMemory(gimple_call_arg(stmt, 0));
Type* Ty = Amt->getType();
More information about the llvm-commits
mailing list