Changes so that iMemory.h doesn't include DerivedTypes.h
[oota-llvm.git] / lib / VMCore / iMemory.cpp
index cf80909d8b4bcefe1b4a6d07bde0a85d0374849e..0a62d1cae069f313e6cfaafad6e0dd28a5fa62d5 100644 (file)
@@ -5,7 +5,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/iMemory.h"
-#include "llvm/ConstantVals.h"
+#include "llvm/Constants.h"
+#include "llvm/DerivedTypes.h"
 
 static inline const Type *checkType(const Type *Ty) {
   assert(Ty && "Invalid indices for type!");
@@ -32,6 +33,11 @@ bool AllocationInst::isArrayAllocation() const {
          getOperand(0) != ConstantUInt::get(Type::UIntTy, 1);
 }
 
+const Type *AllocationInst::getAllocatedType() const {
+  return getType()->getElementType();
+}
+
+
 //===----------------------------------------------------------------------===//
 //                        MemAccessInst Implementation
 //===----------------------------------------------------------------------===//
@@ -93,9 +99,8 @@ LoadInst::LoadInst(Value *Ptr, const std::string &Name = "")
 //                           StoreInst Implementation
 //===----------------------------------------------------------------------===//
 
-StoreInst::StoreInst(Value *Val, Value *Ptr, const std::vector<Value*> &Idx,
-                    const std::string &Name = "")
-  : MemAccessInst(Type::VoidTy, Store, Name) {
+StoreInst::StoreInst(Value *Val, Value *Ptr, const std::vector<Value*> &Idx)
+  : MemAccessInst(Type::VoidTy, Store, "") {
   assert(getIndexedType(Ptr->getType(), Idx) && "Store operands invalid!");
   
   Operands.reserve(2+Idx.size());
@@ -106,8 +111,8 @@ StoreInst::StoreInst(Value *Val, Value *Ptr, const std::vector<Value*> &Idx,
     Operands.push_back(Use(Idx[i], this));
 }
 
-StoreInst::StoreInst(Value *Val, Value *Ptr, const std::string &Name = "")
-  : MemAccessInst(Type::VoidTy, Store, Name) {
+StoreInst::StoreInst(Value *Val, Value *Ptr)
+  : MemAccessInst(Type::VoidTy, Store, "") {
   
   Operands.reserve(2);
   Operands.push_back(Use(Val, this));
@@ -132,6 +137,14 @@ GetElementPtrInst::GetElementPtrInst(Value *Ptr, const std::vector<Value*> &Idx,
     Operands.push_back(Use(Idx[i], this));
 }
 
-bool GetElementPtrInst::isStructSelector() const {
-  return ((PointerType*)Operands[0]->getType())->getElementType()->isStructType();
+
+//===----------------------------------------------------------------------===//
+//                             FreeInst Implementation
+//===----------------------------------------------------------------------===//
+
+FreeInst::FreeInst(Value *Ptr) : Instruction(Type::VoidTy, Free, "") {
+  assert(Ptr->getType()->isPointerType() && "Can't free nonpointer!");
+  Operands.reserve(1);
+  Operands.push_back(Use(Ptr, this));
 }
+