aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-07-14 06:07:58 +0000
committerChris Lattner <sabre@nondot.org>2001-07-14 06:07:58 +0000
commitdc4c3f2f5fc6132885d590631b54de0be2c659be (patch)
tree9d7577e07b0c344e83f9e36f0e19c1d7a106830e /include
parent49fec9638be606ab0d654bf5b03f56d179f0d33e (diff)
downloadexternal_llvm-dc4c3f2f5fc6132885d590631b54de0be2c659be.zip
external_llvm-dc4c3f2f5fc6132885d590631b54de0be2c659be.tar.gz
external_llvm-dc4c3f2f5fc6132885d590631b54de0be2c659be.tar.bz2
Made the following changes:
* ValueHolder became a 3 argument template. This allows for BasicBlock to use the value holder arg as a typesafe parent pointer. * SymTabValue no longer inherits from Value * Method does not inherit from only SymTabValue. Now it inherits from both STV & Value. * Module does not inherit from only SymTabValue. Now it inherits from both STV & Value. * Updated the SymTabValue.h file to reference SymTabValue instead of STDef in several places * Added isArraySelector & isStructSelector to GetElementPtr instruction git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/BasicBlock.h8
-rw-r--r--include/llvm/ConstPoolVals.h4
-rw-r--r--include/llvm/ConstantPool.h8
-rw-r--r--include/llvm/Function.h8
-rw-r--r--include/llvm/Instruction.h2
-rw-r--r--include/llvm/Module.h5
-rw-r--r--include/llvm/SymTabValue.h24
-rw-r--r--include/llvm/Value.h3
-rw-r--r--include/llvm/ValueHolder.h23
-rw-r--r--include/llvm/iMemory.h3
-rw-r--r--include/llvm/iOther.h2
11 files changed, 54 insertions, 36 deletions
diff --git a/include/llvm/BasicBlock.h b/include/llvm/BasicBlock.h
index 402b1fd..c0922d6 100644
--- a/include/llvm/BasicBlock.h
+++ b/include/llvm/BasicBlock.h
@@ -32,11 +32,11 @@ class TerminatorInst;
class BasicBlock : public Value { // Basic blocks are data objects also
public:
- typedef ValueHolder<Instruction, BasicBlock> InstListType;
+ typedef ValueHolder<Instruction, BasicBlock, Method> InstListType;
private :
InstListType InstList;
- friend class ValueHolder<BasicBlock,Method>;
+ friend class ValueHolder<BasicBlock,Method,Method>;
void setParent(Method *parent);
public:
@@ -57,8 +57,8 @@ public:
// Specialize setName to take care of symbol table majik
virtual void setName(const string &name);
- const Method *getParent() const { return (const Method*)InstList.getParent();}
- Method *getParent() { return (Method*)InstList.getParent(); }
+ const Method *getParent() const { return InstList.getParent(); }
+ Method *getParent() { return InstList.getParent(); }
// getTerminator() - If this is a well formed basic block, then this returns
// a pointer to the terminator instruction. If it is not, then you get a null
diff --git a/include/llvm/ConstPoolVals.h b/include/llvm/ConstPoolVals.h
index 47941eb..ff7baf5 100644
--- a/include/llvm/ConstPoolVals.h
+++ b/include/llvm/ConstPoolVals.h
@@ -23,7 +23,7 @@ class StructType;
class ConstPoolVal : public User {
SymTabValue *Parent;
- friend class ValueHolder<ConstPoolVal, SymTabValue>;
+ friend class ValueHolder<ConstPoolVal, SymTabValue, SymTabValue>;
inline void setParent(SymTabValue *parent) {
Parent = parent;
}
@@ -50,6 +50,8 @@ public:
inline const SymTabValue *getParent() const { return Parent; }
inline SymTabValue *getParent() { return Parent; }
+ inline const Value *getParentV() const { return Parent->getSTVParent(); }
+ inline Value *getParentV() { return Parent->getSTVParent(); }
};
diff --git a/include/llvm/ConstantPool.h b/include/llvm/ConstantPool.h
index 7c8e255..ad4d64a 100644
--- a/include/llvm/ConstantPool.h
+++ b/include/llvm/ConstantPool.h
@@ -10,14 +10,14 @@
#include <vector>
#include "llvm/ValueHolder.h"
-
-class ConstPoolVal;
class SymTabValue;
+class ConstPoolVal;
class Type;
+class Value;
class ConstantPool {
public:
- typedef ValueHolder<ConstPoolVal, SymTabValue> PlaneType;
+ typedef ValueHolder<ConstPoolVal, SymTabValue, SymTabValue> PlaneType;
private:
typedef vector<PlaneType*> PlanesType;
PlanesType Planes;
@@ -30,6 +30,8 @@ public:
inline SymTabValue *getParent() { return Parent; }
inline const SymTabValue *getParent() const { return Parent; }
+ const Value *getParentV() const;
+ Value *getParentV() ;
void setParent(SymTabValue *STV);
diff --git a/include/llvm/Function.h b/include/llvm/Function.h
index b7aa855..349dd61 100644
--- a/include/llvm/Function.h
+++ b/include/llvm/Function.h
@@ -21,10 +21,10 @@ class MethodArgument;
class MethodType;
class Module;
-class Method : public SymTabValue {
+class Method : public Value, public SymTabValue {
public:
- typedef ValueHolder<MethodArgument, Method> ArgumentListType;
- typedef ValueHolder<BasicBlock , Method> BasicBlocksType;
+ typedef ValueHolder<MethodArgument, Method, Method> ArgumentListType;
+ typedef ValueHolder<BasicBlock , Method, Method> BasicBlocksType;
// BasicBlock iterators...
typedef BasicBlocksType::iterator iterator;
@@ -40,7 +40,7 @@ private:
Module *Parent; // The module that contains this method
- friend class ValueHolder<Method,Module>;
+ friend class ValueHolder<Method,Module, Module>;
void setParent(Module *parent);
public:
diff --git a/include/llvm/Instruction.h b/include/llvm/Instruction.h
index 25be14f..6b6d31a 100644
--- a/include/llvm/Instruction.h
+++ b/include/llvm/Instruction.h
@@ -18,7 +18,7 @@ class Instruction : public User {
BasicBlock *Parent;
unsigned iType; // InstructionType
- friend class ValueHolder<Instruction,BasicBlock>;
+ friend class ValueHolder<Instruction,BasicBlock,Method>;
inline void setParent(BasicBlock *P) { Parent = P; }
public:
diff --git a/include/llvm/Module.h b/include/llvm/Module.h
index d02b3a0..740a887 100644
--- a/include/llvm/Module.h
+++ b/include/llvm/Module.h
@@ -8,12 +8,13 @@
#ifndef LLVM_MODULE_H
#define LLVM_MODULE_H
+#include "llvm/Value.h"
#include "llvm/SymTabValue.h"
class Method;
-class Module : public SymTabValue {
+class Module : public Value, public SymTabValue {
public:
- typedef ValueHolder<Method, Module> MethodListType;
+ typedef ValueHolder<Method, Module, Module> MethodListType;
// Method iterators...
typedef MethodListType::iterator iterator;
diff --git a/include/llvm/SymTabValue.h b/include/llvm/SymTabValue.h
index 556d5c7..f86218d 100644
--- a/include/llvm/SymTabValue.h
+++ b/include/llvm/SymTabValue.h
@@ -1,31 +1,35 @@
-//===-- llvm/SymTabDef.h - Implement SymbolTable Defs ------------*- C++ -*--=//
+//===-- llvm/SymTabValue.h - Implement SymbolTable Values --------*- C++ -*--=//
//
-// This subclass of Def implements a def that has a symbol table for keeping
-// track of children. This is used by the DefHolder template class...
+// This subclass of Value implements a def that has a symbol table for keeping
+// track of children. This is used by the ValueHolder template class...
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_SYMTABDEF_H
-#define LLVM_SYMTABDEF_H
+#ifndef LLVM_SYMTAB_VALUE_H
+#define LLVM_SYMTAB_VALUE_H
-#include "llvm/Value.h" // Get the definition of Value
#include "llvm/ConstantPool.h"
class SymbolTable;
class ConstPoolVal;
+class Value;
-class SymTabValue : public Value {
+class SymTabValue {
public:
typedef ConstantPool ConstantPoolType;
private:
SymbolTable *SymTab, *ParentSymTab;
ConstantPool ConstPool; // The constant pool
+ Value *ValueParent;
protected:
void setParentSymTab(SymbolTable *ST);
public:
- SymTabValue(const Type *Ty, ValueTy dty, const string &name = "");
- ~SymTabValue(); // Implemented in Def.cpp
+ SymTabValue(Value *Parent);
+ ~SymTabValue(); // Implemented in Value.cpp
+
+ inline Value *getSTVParent() { return ValueParent; }
+ inline const Value *getSTVParent() const { return ValueParent; }
// hasSymbolTable() - Returns true if there is a symbol table allocated to
// this object AND if there is at least one name in it!
@@ -45,7 +49,7 @@ public:
// the method does not already have a symtab, one is created. Use this if
// you intend to put something into the symbol table for the method.
//
- SymbolTable *getSymbolTableSure(); // Implemented in Def.cpp
+ SymbolTable *getSymbolTableSure(); // Implemented in Value.cpp
};
#endif
diff --git a/include/llvm/Value.h b/include/llvm/Value.h
index 4337332..07a61a6 100644
--- a/include/llvm/Value.h
+++ b/include/llvm/Value.h
@@ -19,7 +19,8 @@ class Instruction;
class BasicBlock;
class Method;
class Module;
-template<class ValueSubclass, class ItemParentType> class ValueHolder;
+template<class ValueSubclass, class ItemParentType, class SymTabType>
+ class ValueHolder;
//===----------------------------------------------------------------------===//
// Value Class
diff --git a/include/llvm/ValueHolder.h b/include/llvm/ValueHolder.h
index 18f6e3f..09aa49d 100644
--- a/include/llvm/ValueHolder.h
+++ b/include/llvm/ValueHolder.h
@@ -13,22 +13,27 @@
#define LLVM_VALUEHOLDER_H
#include <vector>
-class SymTabValue;
-// ItemParentType ItemParent - I call setParent() on all of my
-// "ValueSubclass" items, and this is the value that I pass in.
+// ValueSubClass - The type of objects that I hold
+// ItemParentType - I call setParent() on all of my "ValueSubclass" items, and
+// this is the value that I pass in.
+// SymTabType - This is the class type (which should be derived from
+// SymTabValue), whose symtab I insert my ValueSubClass items
+// into. Most of the time it is ItemParentType, but
+// Instructions have item parents of bb's but symtabtype's of
+// a Method
//
-template<class ValueSubclass, class ItemParentType>
+template<class ValueSubclass, class ItemParentType, class SymTabType>
class ValueHolder {
// TODO: Should I use a deque instead of a vector?
vector<ValueSubclass*> ValueList;
ItemParentType *ItemParent;
- SymTabValue *Parent;
+ SymTabType *Parent;
ValueHolder(const ValueHolder &V); // DO NOT IMPLEMENT
public:
- inline ValueHolder(ItemParentType *IP, SymTabValue *parent = 0) {
+ inline ValueHolder(ItemParentType *IP, SymTabType *parent = 0) {
assert(IP && "Item parent may not be null!");
ItemParent = IP;
Parent = 0;
@@ -41,9 +46,9 @@ public:
assert(Parent == 0 && "Should have been unlinked from method!");
}
- inline const SymTabValue *getParent() const { return Parent; }
- inline SymTabValue *getParent() { return Parent; }
- void setParent(SymTabValue *Parent); // Defined in ValueHolderImpl.h
+ inline const SymTabType *getParent() const { return Parent; }
+ inline SymTabType *getParent() { return Parent; }
+ void setParent(SymTabType *Parent); // Defined in ValueHolderImpl.h
inline unsigned size() const { return ValueList.size(); }
inline bool empty() const { return ValueList.empty(); }
diff --git a/include/llvm/iMemory.h b/include/llvm/iMemory.h
index fe045d7..92d6a6c 100644
--- a/include/llvm/iMemory.h
+++ b/include/llvm/iMemory.h
@@ -178,6 +178,9 @@ public:
const string &Name = "");
virtual Instruction *clone() const { return new GetElementPtrInst(*this); }
virtual const char *getOpcodeName() const { return "getelementptr"; }
+
+ inline bool isArraySelector() const { return !isStructSelector(); }
+ bool isStructSelector() const;
};
#endif // LLVM_IMEMORY_H
diff --git a/include/llvm/iOther.h b/include/llvm/iOther.h
index ce5aa93..e522e14 100644
--- a/include/llvm/iOther.h
+++ b/include/llvm/iOther.h
@@ -87,7 +87,7 @@ public:
class MethodArgument : public Value { // Defined in the InstrType.cpp file
Method *Parent;
- friend class ValueHolder<MethodArgument,Method>;
+ friend class ValueHolder<MethodArgument,Method,Method>;
inline void setParent(Method *parent) { Parent = parent; }
public: