diff options
author | Evan Cheng <evan.cheng@apple.com> | 2011-01-08 01:24:27 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2011-01-08 01:24:27 +0000 |
commit | 078b0b095e2f006ab09599f93fe3a3c9f118ef42 (patch) | |
tree | c58670a2bb5d4ffdaf098ac15d4b93c8250fcfdc /llvm/lib/CodeGen/IntrinsicLowering.cpp | |
parent | b0848c5d911b8bd0d13231cbe79e018925edc8a3 (diff) | |
download | bcm5719-llvm-078b0b095e2f006ab09599f93fe3a3c9f118ef42.tar.gz bcm5719-llvm-078b0b095e2f006ab09599f93fe3a3c9f118ef42.zip |
Recognize inline asm 'rev /bin/bash, ' as a bswap intrinsic call.
llvm-svn: 123048
Diffstat (limited to 'llvm/lib/CodeGen/IntrinsicLowering.cpp')
-rw-r--r-- | llvm/lib/CodeGen/IntrinsicLowering.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/IntrinsicLowering.cpp b/llvm/lib/CodeGen/IntrinsicLowering.cpp index 47625110ffa..3861ddadf65 100644 --- a/llvm/lib/CodeGen/IntrinsicLowering.cpp +++ b/llvm/lib/CodeGen/IntrinsicLowering.cpp @@ -538,3 +538,27 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) { "Lowering should have eliminated any uses of the intrinsic call!"); CI->eraseFromParent(); } + +bool IntrinsicLowering::LowerToByteSwap(CallInst *CI) { + // Verify this is a simple bswap. + if (CI->getNumArgOperands() != 1 || + CI->getType() != CI->getArgOperand(0)->getType() || + !CI->getType()->isIntegerTy()) + return false; + + const IntegerType *Ty = dyn_cast<IntegerType>(CI->getType()); + if (!Ty) + return false; + + // Okay, we can do this xform, do so now. + const Type *Tys[] = { Ty }; + Module *M = CI->getParent()->getParent()->getParent(); + Constant *Int = Intrinsic::getDeclaration(M, Intrinsic::bswap, Tys, 1); + + Value *Op = CI->getArgOperand(0); + Op = CallInst::Create(Int, Op, CI->getName(), CI); + + CI->replaceAllUsesWith(Op); + CI->eraseFromParent(); + return true; +} |