diff options
author | Anders Carlsson <andersca@mac.com> | 2007-12-02 21:58:10 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2007-12-02 21:58:10 +0000 |
commit | df4852ac816e6050d53b808b86d7c1c9738eb99e (patch) | |
tree | 4e574f0b34bef40f0db75221fc5b8f5b3c7a8c46 /CodeGen/CGBuiltin.cpp | |
parent | 12f65f6513afe10181aa68eb387ccac23e9e2b6e (diff) |
Implement __builtin_bswap32 and __builtin_bswap64.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44521 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CodeGen/CGBuiltin.cpp')
-rw-r--r-- | CodeGen/CGBuiltin.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/CodeGen/CGBuiltin.cpp b/CodeGen/CGBuiltin.cpp index a1d5af19dd..27c82e8cd0 100644 --- a/CodeGen/CGBuiltin.cpp +++ b/CodeGen/CGBuiltin.cpp @@ -100,6 +100,18 @@ RValue CodeGenFunction::EmitBuiltinExpr(unsigned BuiltinID, const CallExpr *E) { 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); |