[cfe-commits] r44521 - in /cfe/trunk: CodeGen/CGBuiltin.cpp include/clang/AST/Builtins.def
Anders Carlsson
andersca at mac.com
Sun Dec 2 13:58:13 PST 2007
Author: andersca
Date: Sun Dec 2 15:58:10 2007
New Revision: 44521
URL: http://llvm.org/viewvc/llvm-project?rev=44521&view=rev
Log:
Implement __builtin_bswap32 and __builtin_bswap64.
Modified:
cfe/trunk/CodeGen/CGBuiltin.cpp
cfe/trunk/include/clang/AST/Builtins.def
Modified: cfe/trunk/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGBuiltin.cpp?rev=44521&r1=44520&r2=44521&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/CodeGen/CGBuiltin.cpp Sun Dec 2 15:58:10 2007
@@ -100,6 +100,18 @@
llvm::Value *Condition = EmitScalarExpr(E->getArg(0));
return RValue::get(Condition);
}
+ case Builtin::BI__builtin_bswap32:
+ case Builtin::BI__builtin_bswap64: {
+ llvm::Value *ArgValue = EmitScalarExpr(E->getArg(0));
+ const llvm::Type *ArgType = ArgValue->getType();
+ llvm::Value *F =
+ llvm::Intrinsic::getDeclaration(&CGM.getModule(),
+ llvm::Intrinsic::bswap,
+ &ArgType, 1);
+ llvm::Value *V = Builder.CreateCall(F, ArgValue, "tmp");
+
+ return RValue::get(V);
+ }
}
return RValue::get(0);
Modified: cfe/trunk/include/clang/AST/Builtins.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Builtins.def?rev=44521&r1=44520&r2=44521&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Builtins.def (original)
+++ cfe/trunk/include/clang/AST/Builtins.def Sun Dec 2 15:58:10 2007
@@ -74,6 +74,8 @@
// Random GCC builtins
+BUILTIN(__builtin_bswap32, "UiUi", "nc")
+BUILTIN(__builtin_bswap64, "ULLiULLi", "nc")
BUILTIN(__builtin_constant_p, "UsUs", "nc")
BUILTIN(__builtin_classify_type, "i.", "nc")
BUILTIN(__builtin___CFStringMakeConstantString, "FC*cC*", "nc")
More information about the cfe-commits
mailing list