diff options
author | Craig Topper <craig.topper@gmail.com> | 2011-12-25 06:25:37 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2011-12-25 06:25:37 +0000 |
commit | f2855ade2b4cdcdd2b6a0de2b3851bd2b76546c0 (patch) | |
tree | fadb7f24d3e136f6a8468f2bc34ccfc78a532dff /clang/lib/CodeGen/CGBuiltin.cpp | |
parent | 22967d4a6175fa501a782b48ae1423b61d0a43af (diff) | |
download | bcm5719-llvm-f2855ade2b4cdcdd2b6a0de2b3851bd2b76546c0.tar.gz bcm5719-llvm-f2855ade2b4cdcdd2b6a0de2b3851bd2b76546c0.zip |
Add intrinsics for lzcnt and tzcnt instructions.
llvm-svn: 147263
Diffstat (limited to 'clang/lib/CodeGen/CGBuiltin.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGBuiltin.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 71d515646e3..2a467b59bc9 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -2063,6 +2063,32 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID, switch (BuiltinID) { default: return 0; + case X86::BI__builtin_clzs: { + Value *ArgValue = EmitScalarExpr(E->getArg(0)); + + llvm::Type *ArgType = ArgValue->getType(); + Value *F = CGM.getIntrinsic(Intrinsic::ctlz, ArgType); + + llvm::Type *ResultType = ConvertType(E->getType()); + Value *Result = Builder.CreateCall2(F, ArgValue, Builder.getTrue()); + if (Result->getType() != ResultType) + Result = Builder.CreateIntCast(Result, ResultType, /*isSigned*/true, + "cast"); + return Result; + } + case X86::BI__builtin_ctzs: { + Value *ArgValue = EmitScalarExpr(E->getArg(0)); + + llvm::Type *ArgType = ArgValue->getType(); + Value *F = CGM.getIntrinsic(Intrinsic::cttz, ArgType); + + llvm::Type *ResultType = ConvertType(E->getType()); + Value *Result = Builder.CreateCall2(F, ArgValue, Builder.getTrue()); + if (Result->getType() != ResultType) + Result = Builder.CreateIntCast(Result, ResultType, /*isSigned*/true, + "cast"); + return Result; + } case X86::BI__builtin_ia32_pslldi128: case X86::BI__builtin_ia32_psllqi128: case X86::BI__builtin_ia32_psllwi128: |