Add FunctionEmitContext::MemcpyInst()
This commit is contained in:
30
ctx.cpp
30
ctx.cpp
@@ -2514,6 +2514,36 @@ FunctionEmitContext::StoreInst(llvm::Value *value, llvm::Value *ptr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
FunctionEmitContext::MemcpyInst(llvm::Value *dest, llvm::Value *src,
|
||||||
|
llvm::Value *count, llvm::Value *align) {
|
||||||
|
dest = BitCastInst(dest, LLVMTypes::VoidPointerType);
|
||||||
|
src = BitCastInst(src, LLVMTypes::VoidPointerType);
|
||||||
|
if (count->getType() != LLVMTypes::Int64Type) {
|
||||||
|
Assert(count->getType() == LLVMTypes::Int32Type);
|
||||||
|
count = ZExtInst(count, LLVMTypes::Int64Type, "count_to_64");
|
||||||
|
}
|
||||||
|
if (align == NULL)
|
||||||
|
align = LLVMInt32(1);
|
||||||
|
|
||||||
|
llvm::Constant *mcFunc =
|
||||||
|
m->module->getOrInsertFunction("llvm.memcpy.p0i8.p0i8.i64",
|
||||||
|
LLVMTypes::VoidType, LLVMTypes::VoidPointerType,
|
||||||
|
LLVMTypes::VoidPointerType, LLVMTypes::Int64Type,
|
||||||
|
LLVMTypes::Int32Type, LLVMTypes::BoolType, NULL);
|
||||||
|
Assert(mcFunc != NULL);
|
||||||
|
Assert(llvm::isa<llvm::Function>(mcFunc));
|
||||||
|
|
||||||
|
std::vector<llvm::Value *> args;
|
||||||
|
args.push_back(dest);
|
||||||
|
args.push_back(src);
|
||||||
|
args.push_back(count);
|
||||||
|
args.push_back(align);
|
||||||
|
args.push_back(LLVMFalse); /* not volatile */
|
||||||
|
CallInst(mcFunc, NULL, args, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FunctionEmitContext::BranchInst(llvm::BasicBlock *dest) {
|
FunctionEmitContext::BranchInst(llvm::BasicBlock *dest) {
|
||||||
llvm::Instruction *b = llvm::BranchInst::Create(dest, bblock);
|
llvm::Instruction *b = llvm::BranchInst::Create(dest, bblock);
|
||||||
|
|||||||
6
ctx.h
6
ctx.h
@@ -445,6 +445,12 @@ public:
|
|||||||
void StoreInst(llvm::Value *value, llvm::Value *ptr,
|
void StoreInst(llvm::Value *value, llvm::Value *ptr,
|
||||||
llvm::Value *storeMask, const Type *ptrType);
|
llvm::Value *storeMask, const Type *ptrType);
|
||||||
|
|
||||||
|
/** Copy count bytes of memory from the location pointed to by src to
|
||||||
|
the location pointed to by dest. (src and dest must not be
|
||||||
|
overlapping.) */
|
||||||
|
void MemcpyInst(llvm::Value *dest, llvm::Value *src, llvm::Value *count,
|
||||||
|
llvm::Value *align = NULL);
|
||||||
|
|
||||||
void BranchInst(llvm::BasicBlock *block);
|
void BranchInst(llvm::BasicBlock *block);
|
||||||
void BranchInst(llvm::BasicBlock *trueBlock, llvm::BasicBlock *falseBlock,
|
void BranchInst(llvm::BasicBlock *trueBlock, llvm::BasicBlock *falseBlock,
|
||||||
llvm::Value *test);
|
llvm::Value *test);
|
||||||
|
|||||||
Reference in New Issue
Block a user