diff options
| author | Alkis Evlogimenos <alkis@evlogimenos.com> | 2004-05-27 00:15:23 +0000 |
|---|---|---|
| committer | Alkis Evlogimenos <alkis@evlogimenos.com> | 2004-05-27 00:15:23 +0000 |
| commit | e3260007bc8b93359717f7e7cd0e5844e5578512 (patch) | |
| tree | b51196714b93246f5836d2a63a0c5870c57008bb /llvm/lib/VMCore/iMemory.cpp | |
| parent | 52a71340c15d46a0af14b92ce050dfe86aff7b92 (diff) | |
| download | bcm5719-llvm-e3260007bc8b93359717f7e7cd0e5844e5578512.tar.gz bcm5719-llvm-e3260007bc8b93359717f7e7cd0e5844e5578512.zip | |
Add constructors that take a BasicBlock to append to, to the rest of
the llvm::Instruction hierarchy.
llvm-svn: 13800
Diffstat (limited to 'llvm/lib/VMCore/iMemory.cpp')
| -rw-r--r-- | llvm/lib/VMCore/iMemory.cpp | 68 |
1 files changed, 61 insertions, 7 deletions
diff --git a/llvm/lib/VMCore/iMemory.cpp b/llvm/lib/VMCore/iMemory.cpp index 2b731b45c5a..bcba93e253a 100644 --- a/llvm/lib/VMCore/iMemory.cpp +++ b/llvm/lib/VMCore/iMemory.cpp @@ -16,10 +16,8 @@ #include "llvm/DerivedTypes.h" using namespace llvm; -AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, - const std::string &Name, Instruction *InsertBef) - : Instruction(PointerType::get(Ty), iTy, Name, InsertBef) { - +void AllocationInst::init(const Type *Ty, Value *ArraySize, unsigned iTy) +{ // ArraySize defaults to 1. if (!ArraySize) ArraySize = ConstantUInt::get(Type::UIntTy, 1); @@ -30,6 +28,20 @@ AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, Operands.push_back(Use(ArraySize, this)); } +AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, + const std::string &Name, + Instruction *InsertBefore) + : Instruction(PointerType::get(Ty), iTy, Name, InsertBefore) { + init(Ty, ArraySize, iTy); +} + +AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, + const std::string &Name, + BasicBlock *InsertAtEnd) + : Instruction(PointerType::get(Ty), iTy, Name, InsertAtEnd) { + init(Ty, ArraySize, iTy); +} + bool AllocationInst::isArrayAllocation() const { return getOperand(0) != ConstantUInt::get(Type::UIntTy, 1); } @@ -52,13 +64,23 @@ MallocInst::MallocInst(const MallocInst &MI) // FreeInst Implementation //===----------------------------------------------------------------------===// -FreeInst::FreeInst(Value *Ptr, Instruction *InsertBefore) - : Instruction(Type::VoidTy, Free, "", InsertBefore) { - assert(isa<PointerType>(Ptr->getType()) && "Can't free nonpointer!"); +void FreeInst::init(Value *Ptr) +{ + assert(Ptr && isa<PointerType>(Ptr->getType()) && "Can't free nonpointer!"); Operands.reserve(1); Operands.push_back(Use(Ptr, this)); } +FreeInst::FreeInst(Value *Ptr, Instruction *InsertBefore) + : Instruction(Type::VoidTy, Free, "", InsertBefore) { + init(Ptr); +} + +FreeInst::FreeInst(Value *Ptr, BasicBlock *InsertAtEnd) + : Instruction(Type::VoidTy, Free, "", InsertAtEnd) { + init(Ptr); +} + //===----------------------------------------------------------------------===// // LoadInst Implementation @@ -70,6 +92,12 @@ LoadInst::LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBef) init(Ptr); } +LoadInst::LoadInst(Value *Ptr, const std::string &Name, BasicBlock *InsertAE) + : Instruction(cast<PointerType>(Ptr->getType())->getElementType(), + Load, Name, InsertAE), Volatile(false) { + init(Ptr); +} + LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile, Instruction *InsertBef) : Instruction(cast<PointerType>(Ptr->getType())->getElementType(), @@ -77,6 +105,13 @@ LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile, init(Ptr); } +LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile, + BasicBlock *InsertAE) + : Instruction(cast<PointerType>(Ptr->getType())->getElementType(), + Load, Name, InsertAE), Volatile(isVolatile) { + init(Ptr); +} + //===----------------------------------------------------------------------===// // StoreInst Implementation //===----------------------------------------------------------------------===// @@ -86,12 +121,23 @@ StoreInst::StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore) init(Val, Ptr); } +StoreInst::StoreInst(Value *Val, Value *Ptr, BasicBlock *InsertAtEnd) + : Instruction(Type::VoidTy, Store, "", InsertAtEnd), Volatile(false) { + init(Val, Ptr); +} + StoreInst::StoreInst(Value *Val, Value *Ptr, bool isVolatile, Instruction *InsertBefore) : Instruction(Type::VoidTy, Store, "", InsertBefore), Volatile(isVolatile) { init(Val, Ptr); } +StoreInst::StoreInst(Value *Val, Value *Ptr, bool isVolatile, + BasicBlock *InsertAtEnd) + : Instruction(Type::VoidTy, Store, "", InsertAtEnd), Volatile(isVolatile) { + init(Val, Ptr); +} + //===----------------------------------------------------------------------===// // GetElementPtrInst Implementation @@ -122,6 +168,14 @@ GetElementPtrInst::GetElementPtrInst(Value *Ptr, const std::vector<Value*> &Idx, init(Ptr, Idx); } +GetElementPtrInst::GetElementPtrInst(Value *Ptr, const std::vector<Value*> &Idx, + const std::string &Name, BasicBlock *IAE) + : Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(), + Idx, true))), + GetElementPtr, Name, IAE) { + init(Ptr, Idx); +} + // getIndexedType - Returns the type of the element that would be loaded with // a load instruction with the specified parameters. // |

