summaryrefslogtreecommitdiff
path: root/include/llvm/iMemory.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-07-08 23:22:50 +0000
committerChris Lattner <sabre@nondot.org>2001-07-08 23:22:50 +0000
commitab5ac6bb384ec1e4f1cbc4e0ad0fb32d39eb7ff3 (patch)
tree1f05b07519bbc5138edde0c8dc04302c47d1f987 /include/llvm/iMemory.h
parent0bd654a049490a56b6c39f56acf7c8e634085c23 (diff)
downloadllvm-ab5ac6bb384ec1e4f1cbc4e0ad0fb32d39eb7ff3.tar.gz
llvm-ab5ac6bb384ec1e4f1cbc4e0ad0fb32d39eb7ff3.tar.bz2
llvm-ab5ac6bb384ec1e4f1cbc4e0ad0fb32d39eb7ff3.tar.xz
Implementation of Store & GetElementPtr
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/iMemory.h')
-rw-r--r--include/llvm/iMemory.h95
1 files changed, 85 insertions, 10 deletions
diff --git a/include/llvm/iMemory.h b/include/llvm/iMemory.h
index dc8d759236..feed3a2f88 100644
--- a/include/llvm/iMemory.h
+++ b/include/llvm/iMemory.h
@@ -11,6 +11,13 @@
#include "llvm/Instruction.h"
#include "llvm/DerivedTypes.h"
+//===----------------------------------------------------------------------===//
+// AllocationInst Class
+//===----------------------------------------------------------------------===//
+//
+// AllocationInst - This class is the common base class of MallocInst and
+// AllocaInst.
+//
class AllocationInst : public Instruction {
public:
AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
@@ -38,6 +45,10 @@ public:
};
+//===----------------------------------------------------------------------===//
+// MallocInst Class
+//===----------------------------------------------------------------------===//
+
class MallocInst : public AllocationInst {
public:
MallocInst(const Type *Ty, Value *ArraySize = 0, const string &Name = "")
@@ -51,6 +62,10 @@ public:
};
+//===----------------------------------------------------------------------===//
+// AllocaInst Class
+//===----------------------------------------------------------------------===//
+
class AllocaInst : public AllocationInst {
public:
AllocaInst(const Type *Ty, Value *ArraySize = 0, const string &Name = "")
@@ -64,6 +79,10 @@ public:
};
+//===----------------------------------------------------------------------===//
+// FreeInst Class
+//===----------------------------------------------------------------------===//
+
class FreeInst : public Instruction {
public:
FreeInst(Value *Ptr, const string &Name = "")
@@ -79,8 +98,36 @@ public:
};
-class LoadInst : public Instruction {
- LoadInst(const LoadInst &LI) : Instruction(LI.getType(), Load) {
+//===----------------------------------------------------------------------===//
+// MemAccessInst Class
+//===----------------------------------------------------------------------===//
+//
+// MemAccessInst - Common base class of LoadInst, StoreInst, and
+// GetElementPtrInst...
+//
+class MemAccessInst : public Instruction {
+protected:
+ inline MemAccessInst(const Type *Ty, unsigned Opcode, const string &Nam = "")
+ : Instruction(Ty, Opcode, Nam) {}
+public:
+ // getIndexedType - Returns the type of the element that would be loaded with
+ // a load instruction with the specified parameters.
+ //
+ // A null type is returned if the indices are invalid for the specified
+ // pointer type.
+ //
+ static const Type *getIndexedType(const Type *Ptr,
+ const vector<ConstPoolVal*> &Indices,
+ bool AllowStructLeaf = false);
+};
+
+
+//===----------------------------------------------------------------------===//
+// LoadInst Class
+//===----------------------------------------------------------------------===//
+
+class LoadInst : public MemAccessInst {
+ LoadInst(const LoadInst &LI) : MemAccessInst(LI.getType(), Load) {
Operands.reserve(LI.Operands.size());
for (unsigned i = 0, E = LI.Operands.size(); i != E; ++i)
Operands.push_back(Use(LI.Operands[i], this));
@@ -90,15 +137,43 @@ public:
const string &Name = "");
virtual Instruction *clone() const { return new LoadInst(*this); }
virtual const char *getOpcodeName() const { return "load"; }
+};
- // getIndexedType - Returns the type of the element that would be loaded with
- // a load instruction with the specified parameters.
- //
- // A null type is returned if the indices are invalid for the specified
- // pointer type.
- //
- static const Type *getIndexedType(const Type *Ptr,
- const vector<ConstPoolVal*> &);
+
+//===----------------------------------------------------------------------===//
+// StoreInst Class
+//===----------------------------------------------------------------------===//
+
+class StoreInst : public MemAccessInst {
+ StoreInst(const StoreInst &SI) : MemAccessInst(SI.getType(), Store) {
+ Operands.reserve(SI.Operands.size());
+ for (unsigned i = 0, E = SI.Operands.size(); i != E; ++i)
+ Operands.push_back(Use(SI.Operands[i], this));
+ }
+public:
+ StoreInst(Value *Val, Value *Ptr, const vector<ConstPoolVal*> &Idx,
+ const string &Name = "");
+ virtual Instruction *clone() const { return new StoreInst(*this); }
+ virtual const char *getOpcodeName() const { return "store"; }
+};
+
+
+//===----------------------------------------------------------------------===//
+// GetElementPtrInst Class
+//===----------------------------------------------------------------------===//
+
+class GetElementPtrInst : public MemAccessInst {
+ GetElementPtrInst(const GetElementPtrInst &EPI)
+ : MemAccessInst(EPI.getType(), GetElementPtr) {
+ Operands.reserve(EPI.Operands.size());
+ for (unsigned i = 0, E = EPI.Operands.size(); i != E; ++i)
+ Operands.push_back(Use(EPI.Operands[i], this));
+ }
+public:
+ GetElementPtrInst(Value *Ptr, const vector<ConstPoolVal*> &Idx,
+ const string &Name = "");
+ virtual Instruction *clone() const { return new GetElementPtrInst(*this); }
+ virtual const char *getOpcodeName() const { return "getelementptr"; }
};
#endif // LLVM_IMEMORY_H