diff options
author | Chris Lattner <sabre@nondot.org> | 2010-12-26 22:49:25 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-12-26 22:49:25 +0000 |
commit | c0d5496b8aa9993e61ac5770e58184dd32f709bf (patch) | |
tree | a0527d4606a65849ea07bd9e28817a6c3e9b48ed /include | |
parent | 390b693dac1816685cce3074c0ec96e5d1a6c5a4 (diff) | |
download | external_llvm-c0d5496b8aa9993e61ac5770e58184dd32f709bf.zip external_llvm-c0d5496b8aa9993e61ac5770e58184dd32f709bf.tar.gz external_llvm-c0d5496b8aa9993e61ac5770e58184dd32f709bf.tar.bz2 |
add methods to IRBuilder to create memcpy/memset/memmove.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122571 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Support/IRBuilder.h | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/include/llvm/Support/IRBuilder.h b/include/llvm/Support/IRBuilder.h index 10d9628..e6c3cd8 100644 --- a/include/llvm/Support/IRBuilder.h +++ b/include/llvm/Support/IRBuilder.h @@ -235,13 +235,48 @@ public: return Type::getVoidTy(Context); } - const PointerType *getInt8PtrTy() { - return Type::getInt8PtrTy(Context); + const PointerType *getInt8PtrTy(unsigned AddrSpace = 0) { + return Type::getInt8PtrTy(Context, AddrSpace); } /// getCurrentFunctionReturnType - Get the return type of the current function /// that we're emitting into. const Type *getCurrentFunctionReturnType() const; + + /// CreateMemSet - Create and insert a memset to the specified pointer and the + /// specified value. If the pointer isn't an i8*, it will be converted. If a + /// TBAA tag is specified, it will be added to the instruction. + CallInst *CreateMemSet(Value *Ptr, Value *Val, uint64_t Size, unsigned Align, + bool isVolatile = false, MDNode *TBAATag = 0) { + return CreateMemSet(Ptr, Val, getInt64(Size), Align, isVolatile, TBAATag); + } + + CallInst *CreateMemSet(Value *Ptr, Value *Val, Value *Size, unsigned Align, + bool isVolatile = false, MDNode *TBAATag = 0); + + /// CreateMemCpy - Create and insert a memcpy between the specified pointers. + /// If the pointers aren't i8*, they will be converted. If a TBAA tag is + /// specified, it will be added to the instruction. + CallInst *CreateMemCpy(Value *Dst, Value *Src, uint64_t Size, unsigned Align, + bool isVolatile = false, MDNode *TBAATag = 0) { + return CreateMemCpy(Dst, Src, getInt64(Size), Align, isVolatile, TBAATag); + } + + CallInst *CreateMemCpy(Value *Dst, Value *Src, Value *Size, unsigned Align, + bool isVolatile = false, MDNode *TBAATag = 0); + + /// CreateMemMove - Create and insert a memmove between the specified + /// pointers. If the pointers aren't i8*, they will be converted. If a TBAA + /// tag is specified, it will be added to the instruction. + CallInst *CreateMemMove(Value *Dst, Value *Src, uint64_t Size, unsigned Align, + bool isVolatile = false, MDNode *TBAATag = 0) { + return CreateMemMove(Dst, Src, getInt64(Size), Align, isVolatile, TBAATag); + } + + CallInst *CreateMemMove(Value *Dst, Value *Src, Value *Size, unsigned Align, + bool isVolatile = false, MDNode *TBAATag = 0); +private: + Value *getCastedInt8PtrValue(Value *Ptr); }; /// IRBuilder - This provides a uniform API for creating instructions and @@ -279,6 +314,11 @@ public: SetInsertPoint(TheBB); } + explicit IRBuilder(Instruction *IP) + : IRBuilderBase(IP->getContext()), Folder(Context) { + SetInsertPoint(IP); + } + IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T& F) : IRBuilderBase(TheBB->getContext()), Folder(F) { SetInsertPoint(TheBB, IP); |