-LoadInst::LoadInst(Value *Ptr, const vector<ConstPoolVal*> &Idx,
- const string &Name = "")
- : Instruction(getIndexedType(Ptr->getType(), Idx), Load, Name) {
- assert(getIndexedType(Ptr->getType(), Idx) && "Load operands invalid!");
- assert(Ptr->getType()->isPointerType() && "Can't free nonpointer!");
+//===----------------------------------------------------------------------===//
+// LoadInst Implementation
+//===----------------------------------------------------------------------===//
+
+LoadInst::LoadInst(Value *Ptr, const std::string &Name)
+ : Instruction(cast<PointerType>(Ptr->getType())->getElementType(),
+ Load, Name) {
+ Operands.reserve(1);
+ Operands.push_back(Use(Ptr, this));
+}
+
+
+//===----------------------------------------------------------------------===//
+// StoreInst Implementation
+//===----------------------------------------------------------------------===//
+
+StoreInst::StoreInst(Value *Val, Value *Ptr)
+ : Instruction(Type::VoidTy, Store, "") {
+
+ Operands.reserve(2);
+ Operands.push_back(Use(Val, this));
+ Operands.push_back(Use(Ptr, this));
+}
+
+
+//===----------------------------------------------------------------------===//
+// GetElementPtrInst Implementation
+//===----------------------------------------------------------------------===//
+
+GetElementPtrInst::GetElementPtrInst(Value *Ptr, const std::vector<Value*> &Idx,
+ const std::string &Name)
+ : Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(),
+ Idx, true))),
+ GetElementPtr, Name) {
+ assert(getIndexedType(Ptr->getType(), Idx, true) && "gep operands invalid!");