class AllocationInst : public Instruction {
protected:
AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
- const std::string &Name = "");
+ const std::string &Name = "", Instruction *InsertBefore = 0);
public:
// isArrayAllocation - Return true if there is an allocation size parameter
// MallocInst Class
//===----------------------------------------------------------------------===//
-struct MallocInst : public AllocationInst {
- MallocInst(const Type *Ty, Value *ArraySize = 0, const std::string &Name = "")
- : AllocationInst(Ty, ArraySize, Malloc, Name) {}
+class MallocInst : public AllocationInst {
+ MallocInst(const MallocInst &MI);
+public:
+ MallocInst(const Type *Ty, Value *ArraySize = 0, const std::string &Name = "",
+ Instruction *InsertBefore = 0)
+ : AllocationInst(Ty, ArraySize, Malloc, Name, InsertBefore) {}
virtual Instruction *clone() const {
- return new MallocInst((Type*)getType(), (Value*)Operands[0].get());
+ return new MallocInst(*this);
}
// Methods for support type inquiry through isa, cast, and dyn_cast:
// AllocaInst Class
//===----------------------------------------------------------------------===//
-struct AllocaInst : public AllocationInst {
- AllocaInst(const Type *Ty, Value *ArraySize = 0, const std::string &Name = "")
- : AllocationInst(Ty, ArraySize, Alloca, Name) {}
+class AllocaInst : public AllocationInst {
+ AllocaInst(const AllocaInst &);
+public:
+ AllocaInst(const Type *Ty, Value *ArraySize = 0, const std::string &Name = "",
+ Instruction *InsertBefore = 0)
+ : AllocationInst(Ty, ArraySize, Alloca, Name, InsertBefore) {}
virtual Instruction *clone() const {
- return new AllocaInst((Type*)getType(), (Value*)Operands[0].get());
+ return new AllocaInst(*this);
}
// Methods for support type inquiry through isa, cast, and dyn_cast:
//===----------------------------------------------------------------------===//
struct FreeInst : public Instruction {
- FreeInst(Value *Ptr);
+ FreeInst(Value *Ptr, Instruction *InsertBefore = 0);
virtual Instruction *clone() const { return new FreeInst(Operands[0]); }
- virtual bool hasSideEffects() const { return true; }
+ virtual bool mayWriteToMemory() const { return true; }
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const FreeInst *) { return true; }
Operands.push_back(Use(LI.Operands[0], this));
}
public:
- LoadInst(Value *Ptr, const std::string &Name = "");
+ LoadInst(Value *Ptr, const std::string &Name = "",
+ Instruction *InsertBefore = 0);
virtual Instruction *clone() const { return new LoadInst(*this); }
Value *getPointerOperand() { return getOperand(0); }
const Value *getPointerOperand() const { return getOperand(0); }
+ static unsigned getPointerOperandIndex() { return 0U; }
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const LoadInst *) { return true; }
Operands.push_back(Use(SI.Operands[1], this));
}
public:
- StoreInst(Value *Val, Value *Ptr);
+ StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore = 0);
virtual Instruction *clone() const { return new StoreInst(*this); }
- virtual bool hasSideEffects() const { return true; }
+ virtual bool mayWriteToMemory() const { return true; }
Value *getPointerOperand() { return getOperand(1); }
const Value *getPointerOperand() const { return getOperand(1); }
+ static unsigned getPointerOperandIndex() { return 1U; }
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const StoreInst *) { return true; }
}
public:
GetElementPtrInst(Value *Ptr, const std::vector<Value*> &Idx,
- const std::string &Name = "");
+ const std::string &Name = "", Instruction *InsertBefore =0);
virtual Instruction *clone() const { return new GetElementPtrInst(*this); }
// getType - Overload to return most specific pointer type...
const Value *getPointerOperand() const {
return getOperand(0);
}
-
+ static unsigned getPointerOperandIndex() {
+ return 0U; // get index for modifying correct operand
+ }
+
inline unsigned getNumIndices() const { // Note: always non-negative
return getNumOperands() - 1;
}