mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-17 20:23:59 +00:00
Implement the llvm.memcpy intrinsic
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11349 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -13,8 +13,8 @@
|
|||||||
|
|
||||||
#include "llvm/IntrinsicLowering.h"
|
#include "llvm/IntrinsicLowering.h"
|
||||||
#include "llvm/Constant.h"
|
#include "llvm/Constant.h"
|
||||||
|
#include "llvm/DerivedTypes.h"
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "llvm/Type.h"
|
|
||||||
#include "llvm/iOther.h"
|
#include "llvm/iOther.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
@ -57,6 +57,20 @@ void DefaultIntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
|
|||||||
if (CI->getType() != Type::VoidTy)
|
if (CI->getType() != Type::VoidTy)
|
||||||
CI->replaceAllUsesWith(Constant::getNullValue(CI->getType()));
|
CI->replaceAllUsesWith(Constant::getNullValue(CI->getType()));
|
||||||
break; // Simply strip out debugging intrinsics
|
break; // Simply strip out debugging intrinsics
|
||||||
|
|
||||||
|
case Intrinsic::memcpy: {
|
||||||
|
// The memcpy 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 *MemCpy = M->getOrInsertFunction("memcpy", FT);
|
||||||
|
new CallInst(MemCpy, std::vector<Value*>(CI->op_begin()+1, CI->op_end()-1),
|
||||||
|
CI->getName(), CI);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(CI->use_empty() &&
|
assert(CI->use_empty() &&
|
||||||
|
@ -217,6 +217,9 @@ unsigned Function::getIntrinsicID() const {
|
|||||||
case 'l':
|
case 'l':
|
||||||
if (getName() == "llvm.longjmp") return Intrinsic::longjmp;
|
if (getName() == "llvm.longjmp") return Intrinsic::longjmp;
|
||||||
break;
|
break;
|
||||||
|
case 'm':
|
||||||
|
if (getName() == "llvm.memcpy") return Intrinsic::memcpy;
|
||||||
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
if (getName() == "llvm.setjmp") return Intrinsic::setjmp;
|
if (getName() == "llvm.setjmp") return Intrinsic::setjmp;
|
||||||
if (getName() == "llvm.sigsetjmp") return Intrinsic::sigsetjmp;
|
if (getName() == "llvm.sigsetjmp") return Intrinsic::sigsetjmp;
|
||||||
|
@ -13,8 +13,8 @@
|
|||||||
|
|
||||||
#include "llvm/IntrinsicLowering.h"
|
#include "llvm/IntrinsicLowering.h"
|
||||||
#include "llvm/Constant.h"
|
#include "llvm/Constant.h"
|
||||||
|
#include "llvm/DerivedTypes.h"
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "llvm/Type.h"
|
|
||||||
#include "llvm/iOther.h"
|
#include "llvm/iOther.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
@ -57,6 +57,20 @@ void DefaultIntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
|
|||||||
if (CI->getType() != Type::VoidTy)
|
if (CI->getType() != Type::VoidTy)
|
||||||
CI->replaceAllUsesWith(Constant::getNullValue(CI->getType()));
|
CI->replaceAllUsesWith(Constant::getNullValue(CI->getType()));
|
||||||
break; // Simply strip out debugging intrinsics
|
break; // Simply strip out debugging intrinsics
|
||||||
|
|
||||||
|
case Intrinsic::memcpy: {
|
||||||
|
// The memcpy 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 *MemCpy = M->getOrInsertFunction("memcpy", FT);
|
||||||
|
new CallInst(MemCpy, std::vector<Value*>(CI->op_begin()+1, CI->op_end()-1),
|
||||||
|
CI->getName(), CI);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(CI->use_empty() &&
|
assert(CI->use_empty() &&
|
||||||
|
@ -562,6 +562,8 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) {
|
|||||||
case Intrinsic::dbg_func_start: NumArgs = 1; break;
|
case Intrinsic::dbg_func_start: NumArgs = 1; break;
|
||||||
case Intrinsic::dbg_declare: NumArgs = 1; break;
|
case Intrinsic::dbg_declare: NumArgs = 1; break;
|
||||||
|
|
||||||
|
case Intrinsic::memcpy: NumArgs = 4; break;
|
||||||
|
|
||||||
case Intrinsic::alpha_ctlz: NumArgs = 1; break;
|
case Intrinsic::alpha_ctlz: NumArgs = 1; break;
|
||||||
case Intrinsic::alpha_cttz: NumArgs = 1; break;
|
case Intrinsic::alpha_cttz: NumArgs = 1; break;
|
||||||
case Intrinsic::alpha_ctpop: NumArgs = 1; break;
|
case Intrinsic::alpha_ctpop: NumArgs = 1; break;
|
||||||
|
Reference in New Issue
Block a user