1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 12:12:47 +01:00

* 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

llvm-svn: 73
This commit is contained in:
Chris Lattner 2001-06-25 07:31:05 +00:00
parent 105f271c39
commit b408df97c8
5 changed files with 45 additions and 12 deletions

View File

@ -60,10 +60,10 @@ class UnaryOperator : public Instruction {
Use Source; Use Source;
public: public:
// getUnaryOperator() - Construct a unary instruction, given the opcode // create() - Construct a unary instruction, given the opcode
// and its operand. // 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 = "") UnaryOperator(Value *S, unsigned iType, const string &Name = "")
: Instruction(S->getType(), iType, Name), Source(S, this) { : Instruction(S->getType(), iType, Name), Source(S, this) {
@ -71,7 +71,7 @@ public:
inline ~UnaryOperator() { dropAllReferences(); } inline ~UnaryOperator() { dropAllReferences(); }
virtual Instruction *clone() const { virtual Instruction *clone() const {
return getUnaryOperator(getInstType(), Source); return create(getInstType(), Source);
} }
virtual void dropAllReferences() { virtual void dropAllReferences() {
@ -105,10 +105,11 @@ class BinaryOperator : public Instruction {
Use Source1, Source2; Use Source1, Source2;
public: public:
// getBinaryOperator() - Construct a binary instruction, given the opcode // create() - Construct a binary instruction, given the opcode
// and the two operands. // 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, BinaryOperator(unsigned iType, Value *S1, Value *S2,
const string &Name = "") const string &Name = "")
@ -119,7 +120,7 @@ public:
inline ~BinaryOperator() { dropAllReferences(); } inline ~BinaryOperator() { dropAllReferences(); }
virtual Instruction *clone() const { virtual Instruction *clone() const {
return getBinaryOperator(getInstType(), Source1, Source2); return create(getInstType(), Source1, Source2);
} }
virtual void dropAllReferences() { virtual void dropAllReferences() {

View File

@ -85,6 +85,9 @@ public:
return iType >= FirstBinaryOp && iType < NumBinaryOps; 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... // Exported enumerations...

View File

@ -58,6 +58,12 @@ public:
void remove(Value *N); void remove(Value *N);
Value *type_remove(const type_iterator &It); 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 { inline unsigned type_size(const Type *TypeID) const {
return find(TypeID)->second.size(); return find(TypeID)->second.size();
} }

View File

@ -86,8 +86,14 @@ public:
ValueSubclass *remove(const iterator &DI); // Defined in ValueHolderImpl.h ValueSubclass *remove(const iterator &DI); // Defined in ValueHolderImpl.h
void remove(ValueSubclass *D); // Defined in ValueHolderImpl.h void remove(ValueSubclass *D); // Defined in ValueHolderImpl.h
inline void push_front(ValueSubclass *Inst); // Defined in ValueHolderImpl.h void push_front(ValueSubclass *Inst); // Defined in ValueHolderImpl.h
inline void push_back(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 #endif

View File

@ -100,4 +100,21 @@ void ValueHolder<ValueSubclass,ItemParentType>::push_back(ValueSubclass *Inst) {
Parent->getSymbolTableSure()->insert(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 #endif