Implement __builtin_bswap32 and __builtin_bswap64.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44521 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/CodeGen/CGBuiltin.cpp b/CodeGen/CGBuiltin.cpp
index a1d5af1..27c82e8 100644
--- a/CodeGen/CGBuiltin.cpp
+++ b/CodeGen/CGBuiltin.cpp
@@ -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);