diff options
author | Chris Lattner <sabre@nondot.org> | 2001-06-25 07:31:05 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-06-25 07:31:05 +0000 |
commit | 3bcd6394ecd3c928d2ea05bb64cacdcae8dc677a (patch) | |
tree | abd721b18f3210276939233081d5c4c5d2f47f52 | |
parent | 53b1c0161d7fb6e8eb4bd1c49114a5cf57258364 (diff) |
* Rename get.*Operator to create seeing that it would have to be qualified
with the classname anyways.
* Add an isPHINode() method to Instruction
* Add getUniqueName() to SymbolTable class
* Add an insert method to ValueHolder
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/InstrTypes.h | 15 | ||||
-rw-r--r-- | include/llvm/Instruction.h | 3 | ||||
-rw-r--r-- | include/llvm/SymbolTable.h | 6 | ||||
-rw-r--r-- | include/llvm/ValueHolder.h | 16 | ||||
-rw-r--r-- | lib/VMCore/ValueHolderImpl.h | 17 |
5 files changed, 45 insertions, 12 deletions
diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h index 23d6019866..6d35ed5d50 100644 --- a/include/llvm/InstrTypes.h +++ b/include/llvm/InstrTypes.h @@ -60,10 +60,10 @@ class UnaryOperator : public Instruction { Use Source; public: - // getUnaryOperator() - Construct a unary instruction, given the opcode + // create() - Construct a unary instruction, given the opcode // and its operand. // - static UnaryOperator *getUnaryOperator(unsigned Op, Value *Source); + static UnaryOperator *create(unsigned Op, Value *Source); UnaryOperator(Value *S, unsigned iType, const string &Name = "") : Instruction(S->getType(), iType, Name), Source(S, this) { @@ -71,7 +71,7 @@ public: inline ~UnaryOperator() { dropAllReferences(); } virtual Instruction *clone() const { - return getUnaryOperator(getInstType(), Source); + return create(getInstType(), Source); } virtual void dropAllReferences() { @@ -105,10 +105,11 @@ class BinaryOperator : public Instruction { Use Source1, Source2; public: - // getBinaryOperator() - Construct a binary instruction, given the opcode + // create() - Construct a binary instruction, given the opcode // and the two operands. // - static BinaryOperator *getBinaryOperator(unsigned Op, Value *S1, Value *S2); + static BinaryOperator *create(unsigned Op, Value *S1, Value *S2, + const string &Name = ""); BinaryOperator(unsigned iType, Value *S1, Value *S2, const string &Name = "") @@ -118,8 +119,8 @@ public: } inline ~BinaryOperator() { dropAllReferences(); } - virtual Instruction *clone() const { - return getBinaryOperator(getInstType(), Source1, Source2); + virtual Instruction *clone() const { + return create(getInstType(), Source1, Source2); } virtual void dropAllReferences() { diff --git a/include/llvm/Instruction.h b/include/llvm/Instruction.h index 0ac1921682..871ed037ef 100644 --- a/include/llvm/Instruction.h +++ b/include/llvm/Instruction.h @@ -85,6 +85,9 @@ public: return iType >= FirstBinaryOp && iType < NumBinaryOps; } + // isPHINode() - This is used frequently enough to allow it to exist + inline bool isPHINode() const { return iType == PHINode; } + //---------------------------------------------------------------------- // Exported enumerations... diff --git a/include/llvm/SymbolTable.h b/include/llvm/SymbolTable.h index dfb78eee82..91c5d613d4 100644 --- a/include/llvm/SymbolTable.h +++ b/include/llvm/SymbolTable.h @@ -58,6 +58,12 @@ public: void remove(Value *N); Value *type_remove(const type_iterator &It); + // getUniqueName - Given a base name, return a string that is either equal to + // it (or derived from it) that does not already occur in the symbol table for + // the specified type. + // + string getUniqueName(const Type *Ty, const string &BaseName); + inline unsigned type_size(const Type *TypeID) const { return find(TypeID)->second.size(); } diff --git a/include/llvm/ValueHolder.h b/include/llvm/ValueHolder.h index 134262354a..26ecd267f2 100644 --- a/include/llvm/ValueHolder.h +++ b/include/llvm/ValueHolder.h @@ -82,12 +82,18 @@ public: // specified by the iterator, and leaves the iterator pointing to the element // that used to follow the element deleted. // - ValueSubclass *remove(iterator &DI); // Defined in ValueHolderImpl.h - ValueSubclass *remove(const iterator &DI); // Defined in ValueHolderImpl.h - void remove(ValueSubclass *D); // Defined in ValueHolderImpl.h + ValueSubclass *remove(iterator &DI); // Defined in ValueHolderImpl.h + ValueSubclass *remove(const iterator &DI); // Defined in ValueHolderImpl.h + void remove(ValueSubclass *D); // Defined in ValueHolderImpl.h - inline void push_front(ValueSubclass *Inst); // Defined in ValueHolderImpl.h - inline void push_back(ValueSubclass *Inst); // Defined in ValueHolderImpl.h + void push_front(ValueSubclass *Inst); // Defined in ValueHolderImpl.h + void push_back(ValueSubclass *Inst); // Defined in ValueHolderImpl.h + + // ValueHolder::insert - This method inserts the specified value *BEFORE* the + // indicated iterator position, and returns an interator to the newly inserted + // value. + // + iterator insert(iterator Pos, ValueSubclass *Inst); }; #endif diff --git a/lib/VMCore/ValueHolderImpl.h b/lib/VMCore/ValueHolderImpl.h index 9ca5d94926..1bfdd2512e 100644 --- a/lib/VMCore/ValueHolderImpl.h +++ b/lib/VMCore/ValueHolderImpl.h @@ -100,4 +100,21 @@ void ValueHolder<ValueSubclass,ItemParentType>::push_back(ValueSubclass *Inst) { Parent->getSymbolTableSure()->insert(Inst); } +// ValueHolder::insert - This method inserts the specified value *BEFORE* the +// indicated iterator position, and returns an interator to the newly inserted +// value. +// +template<class ValueSubclass, class ItemParentType> +ValueHolder<ValueSubclass,ItemParentType>::iterator +ValueHolder<ValueSubclass,ItemParentType>::insert(iterator Pos, + ValueSubclass *Inst){ + assert(Inst->getParent() == 0 && "Value already has parent!"); + Inst->setParent(ItemParent); + + iterator I = ValueList.insert(Pos, Inst); + if (Inst->hasName() && Parent) + Parent->getSymbolTableSure()->insert(Inst); + return I; +} + #endif |