[cfe-commits] r46811 - /cfe/trunk/CodeGen/CGBuiltin.cpp
Anders Carlsson
andersca at mac.com
Tue Feb 5 23:19:27 PST 2008
Author: andersca
Date: Wed Feb 6 01:19:27 2008
New Revision: 46811
URL: http://llvm.org/viewvc/llvm-project?rev=46811&view=rev
Log:
Generate code for the various __builtin_ctz functions.
Modified:
cfe/trunk/CodeGen/CGBuiltin.cpp
Modified: cfe/trunk/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGBuiltin.cpp?rev=46811&r1=46810&r2=46811&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/CodeGen/CGBuiltin.cpp Wed Feb 6 01:19:27 2008
@@ -149,6 +149,20 @@
return RValue::get(Result);
}
+ case Builtin::BI__builtin_ctz:
+ case Builtin::BI__builtin_ctzl:
+ case Builtin::BI__builtin_ctzll: {
+ Value *ArgValue = EmitScalarExpr(E->getArg(0));
+
+ const llvm::Type *ArgType = ArgValue->getType();
+ Value *F = CGM.getIntrinsic(Intrinsic::cttz, &ArgType, 1);
+
+ const llvm::Type *ResultType = ConvertType(E->getType());
+ Value *Result = Builder.CreateCall(F, ArgValue, "tmp");
+ if (Result->getType() != ResultType)
+ Result = Builder.CreateIntCast(Result, ResultType, "cast");
+ return RValue::get(Result);
+ }
case Builtin::BI__builtin_expect:
return RValue::get(EmitScalarExpr(E->getArg(0)));
case Builtin::BI__builtin_bswap32:
More information about the cfe-commits
mailing list