diff options
author | Chris Lattner <sabre@nondot.org> | 2004-02-12 18:11:20 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-02-12 18:11:20 +0000 |
commit | 5ed171e317306df7547bce08aeebf17f1e2a1895 (patch) | |
tree | 8cd4e5808cd11c7d5fa3def2ee76245ff0748a74 /llvm | |
parent | f30152e4808b8e1bd3f719c98a38d675d87ccd31 (diff) | |
download | bcm5719-llvm-5ed171e317306df7547bce08aeebf17f1e2a1895.tar.gz bcm5719-llvm-5ed171e317306df7547bce08aeebf17f1e2a1895.zip |
Add support for the llvm.memmove intrinsic
Patch graciously contributed by Reid Spencer!
llvm-svn: 11355
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/VMCore/Function.cpp | 1 | ||||
-rw-r--r-- | llvm/lib/VMCore/IntrinsicLowering.cpp | 13 | ||||
-rw-r--r-- | llvm/lib/VMCore/Verifier.cpp | 1 |
3 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Function.cpp b/llvm/lib/VMCore/Function.cpp index a4bc4eab2a8..8875661ff04 100644 --- a/llvm/lib/VMCore/Function.cpp +++ b/llvm/lib/VMCore/Function.cpp @@ -219,6 +219,7 @@ unsigned Function::getIntrinsicID() const { break; case 'm': if (getName() == "llvm.memcpy") return Intrinsic::memcpy; + if (getName() == "llvm.memmove") return Intrinsic::memmove; break; case 's': if (getName() == "llvm.setjmp") return Intrinsic::setjmp; diff --git a/llvm/lib/VMCore/IntrinsicLowering.cpp b/llvm/lib/VMCore/IntrinsicLowering.cpp index 48ae01540bb..6eaaafa2e26 100644 --- a/llvm/lib/VMCore/IntrinsicLowering.cpp +++ b/llvm/lib/VMCore/IntrinsicLowering.cpp @@ -71,6 +71,19 @@ void DefaultIntrinsicLowering::LowerIntrinsicCall(CallInst *CI) { CI->getName(), CI); break; } + case Intrinsic::memmove: { + // The memmove intrinsic take an extra alignment argument that the memcpy + // libc function does not. + const FunctionType *CFT = Callee->getFunctionType(); + FunctionType *FT = + FunctionType::get(*CFT->param_begin(), + std::vector<const Type*>(CFT->param_begin(), CFT->param_end()-1), + false); + Function *MemMove = M->getOrInsertFunction("memmove", FT); + new CallInst(MemMove, std::vector<Value*>(CI->op_begin()+1, CI->op_end()-1), + CI->getName(), CI); + break; + } } assert(CI->use_empty() && diff --git a/llvm/lib/VMCore/Verifier.cpp b/llvm/lib/VMCore/Verifier.cpp index 71ea54e58b2..e2ccb5b12b9 100644 --- a/llvm/lib/VMCore/Verifier.cpp +++ b/llvm/lib/VMCore/Verifier.cpp @@ -563,6 +563,7 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) { case Intrinsic::dbg_declare: NumArgs = 1; break; case Intrinsic::memcpy: NumArgs = 4; break; + case Intrinsic::memmove: NumArgs = 4; break; case Intrinsic::alpha_ctlz: NumArgs = 1; break; case Intrinsic::alpha_cttz: NumArgs = 1; break; |