Adjust to changes in the User class.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19888 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2005-01-29 00:33:00 +00:00
parent ec285706ae
commit 5181ac8081
4 changed files with 30 additions and 21 deletions

View File

@ -319,7 +319,7 @@ class ConstantAggregateZero : public Constant {
ConstantAggregateZero(const ConstantAggregateZero &); // DO NOT IMPLEMENT
protected:
ConstantAggregateZero(const Type *Ty)
: Constant(Ty, ConstantAggregateZeroVal) {}
: Constant(Ty, ConstantAggregateZeroVal, 0, 0) {}
public:
/// get() - static factory method for creating a null aggregate. It is
/// illegal to call this method with a non-aggregate type.
@ -351,6 +351,7 @@ class ConstantArray : public Constant {
ConstantArray(const ConstantArray &); // DO NOT IMPLEMENT
protected:
ConstantArray(const ArrayType *T, const std::vector<Constant*> &Val);
~ConstantArray();
public:
/// get() - Static factory methods - Return objects of the specified value
static Constant *get(const ArrayType *T, const std::vector<Constant*> &);
@ -399,6 +400,7 @@ class ConstantStruct : public Constant {
ConstantStruct(const ConstantStruct &); // DO NOT IMPLEMENT
protected:
ConstantStruct(const StructType *T, const std::vector<Constant*> &Val);
~ConstantStruct();
public:
/// get() - Static factory methods - Return objects of the specified value
///
@ -439,6 +441,7 @@ class ConstantPacked : public Constant {
ConstantPacked(const ConstantPacked &); // DO NOT IMPLEMENT
protected:
ConstantPacked(const PackedType *T, const std::vector<Constant*> &Val);
~ConstantPacked();
public:
/// get() - Static factory methods - Return objects of the specified value
static Constant *get(const PackedType *T, const std::vector<Constant*> &);
@ -476,7 +479,8 @@ class ConstantPointerNull : public Constant {
ConstantPointerNull(const ConstantPointerNull &); // DO NOT IMPLEMENT
protected:
ConstantPointerNull(const PointerType *T)
: Constant(reinterpret_cast<const Type*>(T)) {}
: Constant(reinterpret_cast<const Type*>(T),
Value::SimpleConstantVal, 0, 0) {}
public:
@ -518,10 +522,9 @@ class ConstantExpr : public Constant {
friend struct ConvertConstantType<ConstantExpr, Type>;
protected:
// Cast creation ctor
ConstantExpr(unsigned Opcode, Constant *C, const Type *Ty);
// Binary/Shift instruction creation ctor
ConstantExpr(unsigned Opcode, Constant *C1, Constant *C2);
ConstantExpr(const Type *Ty, unsigned Opcode, Use *Ops, unsigned NumOps)
: Constant(Ty, ConstantExprVal, Ops, NumOps), iType(Opcode) {}
// Select instruction creation ctor
ConstantExpr(Constant *C, Constant *V1, Constant *V2);
// GEP instruction creation ctor
@ -642,7 +645,7 @@ class UndefValue : public Constant {
friend struct ConstantCreator<UndefValue, Type, char>;
UndefValue(const UndefValue &); // DO NOT IMPLEMENT
protected:
UndefValue(const Type *T) : Constant(T, UndefValueVal) {}
UndefValue(const Type *T) : Constant(T, UndefValueVal, 0, 0) {}
public:
/// get() - Static factory methods - Return an 'undef' object of the specified
/// type.

View File

@ -36,9 +36,9 @@ public:
GhostLinkage // Stand-in functions for streaming fns from BC files
};
protected:
GlobalValue(const Type *Ty, ValueTy vty, LinkageTypes linkage,
const std::string &name = "")
: Constant(Ty, vty, name), Linkage(linkage), Parent(0) { }
GlobalValue(const Type *Ty, ValueTy vty, Use *Ops, unsigned NumOps,
LinkageTypes linkage, const std::string &name = "")
: Constant(Ty, vty, Ops, NumOps, name), Linkage(linkage), Parent(0) { }
LinkageTypes Linkage; // The linkage of this global
Module *Parent;

View File

@ -41,6 +41,8 @@ class GlobalVariable : public GlobalValue {
void setPrev(GlobalVariable *N) { Prev = N; }
bool isConstantGlobal; // Is this a global constant?
Use Initializer;
public:
/// GlobalVariable ctor - If a parent module is specified, the global is
/// automatically inserted into the end of the specified modules global list.
@ -56,11 +58,11 @@ public:
/// global variable is defined in some other translation unit, and is thus
/// externally defined here.
///
virtual bool isExternal() const { return Operands.empty(); }
virtual bool isExternal() const { return getNumOperands() == 0; }
/// hasInitializer - Unless a global variable isExternal(), it has an
/// initializer. The initializer for the global variable/constant is held by
/// Operands[0] if an initializer is specified.
/// Initializer if an initializer is specified.
///
inline bool hasInitializer() const { return !isExternal(); }
@ -70,18 +72,22 @@ public:
///
inline Constant *getInitializer() const {
assert(hasInitializer() && "GV doesn't have initializer!");
return reinterpret_cast<Constant*>(Operands[0].get());
return reinterpret_cast<Constant*>(Initializer.get());
}
inline Constant *getInitializer() {
assert(hasInitializer() && "GV doesn't have initializer!");
return reinterpret_cast<Constant*>(Operands[0].get());
return reinterpret_cast<Constant*>(Initializer.get());
}
inline void setInitializer(Constant *CPV) {
if (CPV == 0) {
if (hasInitializer()) Operands.pop_back();
if (hasInitializer()) {
Initializer.set(0);
NumOperands = 0;
}
} else {
if (!hasInitializer()) Operands.push_back(Use(0, this));
Operands[0] = reinterpret_cast<Value*>(CPV);
if (!hasInitializer())
NumOperands = 1;
Initializer.set(CPV);
}
}

View File

@ -36,7 +36,6 @@ class Instruction : public User {
friend class SymbolTableListTraits<Instruction, BasicBlock, Function,
ilist_traits<Instruction> >;
void setParent(BasicBlock *P);
void init();
private:
// FIXME: This is a dirty hack. Setcc instructions shouldn't encode the CC
@ -44,10 +43,11 @@ private:
void setOpcode(unsigned NewOpcode);
friend class BinaryOperator;
protected:
Instruction(const Type *Ty, unsigned iType, const std::string &Name = "",
Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
const std::string &Name = "",
Instruction *InsertBefore = 0);
Instruction(const Type *Ty, unsigned iType, const std::string &Name,
BasicBlock *InsertAtEnd);
Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
const std::string &Name, BasicBlock *InsertAtEnd);
public:
~Instruction() {