2001-12-03 22:26:30 +00:00
|
|
|
//===-- llvm/ConstantVals.h - Constant Value nodes ---------------*- C++ -*--=//
|
2001-06-06 20:29:01 +00:00
|
|
|
//
|
2001-12-03 22:26:30 +00:00
|
|
|
// This file contains the declarations for the Constant class and all of
|
2001-06-06 20:29:01 +00:00
|
|
|
// its subclasses, which represent the different type of constant pool values
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_CONSTPOOLVALS_H
|
|
|
|
#define LLVM_CONSTPOOLVALS_H
|
|
|
|
|
|
|
|
#include "llvm/User.h"
|
2001-11-26 23:04:08 +00:00
|
|
|
#include "Support/DataTypes.h"
|
2001-06-06 20:29:01 +00:00
|
|
|
|
|
|
|
class ArrayType;
|
|
|
|
class StructType;
|
2001-09-30 20:14:07 +00:00
|
|
|
class PointerType;
|
2001-06-06 20:29:01 +00:00
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
2001-12-03 22:26:30 +00:00
|
|
|
// Constant Class
|
2001-06-06 20:29:01 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2001-12-03 22:26:30 +00:00
|
|
|
class Constant : public User {
|
2001-07-20 19:13:28 +00:00
|
|
|
protected:
|
2001-12-03 22:26:30 +00:00
|
|
|
inline Constant(const Type *Ty) : User(Ty, Value::ConstantVal) {}
|
|
|
|
~Constant() {}
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2001-10-13 06:11:10 +00:00
|
|
|
// destroyConstant - Called if some element of this constant is no longer
|
|
|
|
// valid. At this point only other constants may be on the use_list for this
|
|
|
|
// constant. Any constants on our Use list must also be destroy'd. The
|
|
|
|
// implementation must be sure to remove the constant from the list of
|
|
|
|
// available cached constants. Implementations should call
|
|
|
|
// destroyConstantImpl as the last thing they do, to destroy all users and
|
|
|
|
// delete this.
|
|
|
|
//
|
|
|
|
virtual void destroyConstant() { assert(0 && "Not reached!"); }
|
|
|
|
void destroyConstantImpl();
|
2001-07-20 19:13:28 +00:00
|
|
|
public:
|
2001-06-06 20:29:01 +00:00
|
|
|
// Specialize setName to handle symbol table majik...
|
2001-09-07 16:18:19 +00:00
|
|
|
virtual void setName(const string &name, SymbolTable *ST = 0);
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2001-10-29 13:22:49 +00:00
|
|
|
virtual string getStrValue() const = 0;
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2001-09-07 16:18:19 +00:00
|
|
|
// Static constructor to get a '0' constant of arbitrary type...
|
2001-12-03 22:26:30 +00:00
|
|
|
static Constant *getNullConstant(const Type *Ty);
|
2001-10-01 16:18:37 +00:00
|
|
|
|
2001-11-01 05:53:56 +00:00
|
|
|
// isNullValue - Return true if this is the value that would be returned by
|
|
|
|
// getNullConstant.
|
|
|
|
virtual bool isNullValue() const = 0;
|
|
|
|
|
2001-10-01 16:18:37 +00:00
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
2001-12-03 22:26:30 +00:00
|
|
|
static inline bool classof(const Constant *) { return true; }
|
2001-10-02 03:41:24 +00:00
|
|
|
static inline bool classof(const Value *V) {
|
2001-10-01 16:18:37 +00:00
|
|
|
return V->getValueType() == Value::ConstantVal;
|
|
|
|
}
|
2001-06-06 20:29:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Classes to represent constant pool variable defs
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
//===---------------------------------------------------------------------------
|
2001-12-03 22:26:30 +00:00
|
|
|
// ConstantBool - Boolean Values
|
2001-06-06 20:29:01 +00:00
|
|
|
//
|
2001-12-03 22:26:30 +00:00
|
|
|
class ConstantBool : public Constant {
|
2001-06-06 20:29:01 +00:00
|
|
|
bool Val;
|
2001-12-03 22:26:30 +00:00
|
|
|
ConstantBool(const ConstantBool &); // DO NOT IMPLEMENT
|
|
|
|
ConstantBool(bool V);
|
|
|
|
~ConstantBool() {}
|
2001-06-06 20:29:01 +00:00
|
|
|
public:
|
2001-12-03 22:26:30 +00:00
|
|
|
static ConstantBool *True, *False; // The True & False values
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2001-09-07 16:18:19 +00:00
|
|
|
// Factory objects - Return objects of the specified value
|
2001-12-03 22:26:30 +00:00
|
|
|
static ConstantBool *get(bool Value) { return Value ? True : False; }
|
|
|
|
static ConstantBool *get(const Type *Ty, bool Value) { return get(Value); }
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2001-09-07 16:18:19 +00:00
|
|
|
// inverted - Return the opposite value of the current value.
|
2001-12-03 22:26:30 +00:00
|
|
|
inline ConstantBool *inverted() const { return (this==True) ? False : True; }
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2001-10-29 13:22:49 +00:00
|
|
|
virtual string getStrValue() const;
|
2001-06-06 20:29:01 +00:00
|
|
|
inline bool getValue() const { return Val; }
|
2001-10-01 20:11:19 +00:00
|
|
|
|
2001-11-01 05:53:56 +00:00
|
|
|
// isNullValue - Return true if this is the value that would be returned by
|
|
|
|
// getNullConstant.
|
|
|
|
virtual bool isNullValue() const { return this == False; }
|
|
|
|
|
2001-10-01 20:11:19 +00:00
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
2001-12-03 22:26:30 +00:00
|
|
|
static inline bool classof(const ConstantBool *) { return true; }
|
|
|
|
static bool classof(const Constant *CPV) {
|
2001-10-01 20:11:19 +00:00
|
|
|
return (CPV == True) | (CPV == False);
|
|
|
|
}
|
2001-10-02 03:41:24 +00:00
|
|
|
static inline bool classof(const Value *V) {
|
2001-12-03 22:26:30 +00:00
|
|
|
return isa<Constant>(V) && classof(cast<Constant>(V));
|
2001-10-01 20:11:19 +00:00
|
|
|
}
|
2001-06-06 20:29:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-07-20 19:13:28 +00:00
|
|
|
//===---------------------------------------------------------------------------
|
2001-12-03 22:26:30 +00:00
|
|
|
// ConstantInt - Superclass of ConstantSInt & ConstantUInt, to make dealing
|
2001-07-20 19:13:28 +00:00
|
|
|
// with integral constants easier.
|
|
|
|
//
|
2001-12-03 22:26:30 +00:00
|
|
|
class ConstantInt : public Constant {
|
2001-07-20 19:13:28 +00:00
|
|
|
protected:
|
|
|
|
union {
|
|
|
|
int64_t Signed;
|
|
|
|
uint64_t Unsigned;
|
|
|
|
} Val;
|
2001-12-03 22:26:30 +00:00
|
|
|
ConstantInt(const ConstantInt &); // DO NOT IMPLEMENT
|
|
|
|
ConstantInt(const Type *Ty, uint64_t V);
|
|
|
|
~ConstantInt() {}
|
2001-07-20 19:13:28 +00:00
|
|
|
public:
|
2001-07-21 19:02:43 +00:00
|
|
|
// equalsInt - Provide a helper method that can be used to determine if the
|
2001-07-20 19:13:28 +00:00
|
|
|
// constant contained within is equal to a constant. This only works for very
|
|
|
|
// small values, because this is all that can be represented with all types.
|
|
|
|
//
|
2001-07-21 19:02:43 +00:00
|
|
|
bool equalsInt(unsigned char V) const {
|
2001-09-07 16:18:19 +00:00
|
|
|
assert(V <= 127 &&
|
|
|
|
"equals: Can only be used with very small positive constants!");
|
2001-07-20 19:13:28 +00:00
|
|
|
return Val.Unsigned == V;
|
|
|
|
}
|
|
|
|
|
2001-12-03 22:26:30 +00:00
|
|
|
// ConstantInt::get static method: return a constant pool int with the
|
2001-07-20 19:13:28 +00:00
|
|
|
// specified value. as above, we work only with very small values here.
|
|
|
|
//
|
2001-12-03 22:26:30 +00:00
|
|
|
static ConstantInt *get(const Type *Ty, unsigned char V);
|
2001-10-01 20:11:19 +00:00
|
|
|
|
2001-11-01 05:53:56 +00:00
|
|
|
// isNullValue - Return true if this is the value that would be returned by
|
|
|
|
// getNullConstant.
|
|
|
|
virtual bool isNullValue() const { return Val.Unsigned == 0; }
|
|
|
|
|
2001-10-01 20:11:19 +00:00
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
2001-12-03 22:26:30 +00:00
|
|
|
static inline bool classof(const ConstantInt *) { return true; }
|
|
|
|
static bool classof(const Constant *CPV); // defined in CPV.cpp
|
2001-10-02 03:41:24 +00:00
|
|
|
static inline bool classof(const Value *V) {
|
2001-12-03 22:26:30 +00:00
|
|
|
return isa<Constant>(V) && classof(cast<Constant>(V));
|
2001-10-01 20:11:19 +00:00
|
|
|
}
|
2001-07-20 19:13:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-06-06 20:29:01 +00:00
|
|
|
//===---------------------------------------------------------------------------
|
2001-12-03 22:26:30 +00:00
|
|
|
// ConstantSInt - Signed Integer Values [sbyte, short, int, long]
|
2001-06-06 20:29:01 +00:00
|
|
|
//
|
2001-12-03 22:26:30 +00:00
|
|
|
class ConstantSInt : public ConstantInt {
|
|
|
|
ConstantSInt(const ConstantSInt &); // DO NOT IMPLEMENT
|
2001-09-07 16:18:19 +00:00
|
|
|
protected:
|
2001-12-03 22:26:30 +00:00
|
|
|
ConstantSInt(const Type *Ty, int64_t V);
|
|
|
|
~ConstantSInt() {}
|
2001-06-06 20:29:01 +00:00
|
|
|
public:
|
2001-12-03 22:26:30 +00:00
|
|
|
static ConstantSInt *get(const Type *Ty, int64_t V);
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2001-10-29 13:22:49 +00:00
|
|
|
virtual string getStrValue() const;
|
2001-06-06 20:29:01 +00:00
|
|
|
|
|
|
|
static bool isValueValidForType(const Type *Ty, int64_t V);
|
2001-07-20 19:13:28 +00:00
|
|
|
inline int64_t getValue() const { return Val.Signed; }
|
2001-10-13 06:11:10 +00:00
|
|
|
|
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
2001-12-03 22:26:30 +00:00
|
|
|
static inline bool classof(const ConstantSInt *) { return true; }
|
|
|
|
static bool classof(const Constant *CPV); // defined in CPV.cpp
|
2001-10-13 06:11:10 +00:00
|
|
|
static inline bool classof(const Value *V) {
|
2001-12-03 22:26:30 +00:00
|
|
|
return isa<Constant>(V) && classof(cast<Constant>(V));
|
2001-10-13 06:11:10 +00:00
|
|
|
}
|
2001-06-06 20:29:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//===---------------------------------------------------------------------------
|
2001-12-03 22:26:30 +00:00
|
|
|
// ConstantUInt - Unsigned Integer Values [ubyte, ushort, uint, ulong]
|
2001-06-06 20:29:01 +00:00
|
|
|
//
|
2001-12-03 22:26:30 +00:00
|
|
|
class ConstantUInt : public ConstantInt {
|
|
|
|
ConstantUInt(const ConstantUInt &); // DO NOT IMPLEMENT
|
2001-09-07 16:18:19 +00:00
|
|
|
protected:
|
2001-12-03 22:26:30 +00:00
|
|
|
ConstantUInt(const Type *Ty, uint64_t V);
|
|
|
|
~ConstantUInt() {}
|
2001-06-06 20:29:01 +00:00
|
|
|
public:
|
2001-12-03 22:26:30 +00:00
|
|
|
static ConstantUInt *get(const Type *Ty, uint64_t V);
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2001-10-29 13:22:49 +00:00
|
|
|
virtual string getStrValue() const;
|
2001-06-06 20:29:01 +00:00
|
|
|
|
|
|
|
static bool isValueValidForType(const Type *Ty, uint64_t V);
|
2001-07-20 19:13:28 +00:00
|
|
|
inline uint64_t getValue() const { return Val.Unsigned; }
|
2001-10-13 06:11:10 +00:00
|
|
|
|
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
2001-12-03 22:26:30 +00:00
|
|
|
static inline bool classof(const ConstantUInt *) { return true; }
|
|
|
|
static bool classof(const Constant *CPV); // defined in CPV.cpp
|
2001-10-13 06:11:10 +00:00
|
|
|
static inline bool classof(const Value *V) {
|
2001-12-03 22:26:30 +00:00
|
|
|
return isa<Constant>(V) && classof(cast<Constant>(V));
|
2001-10-13 06:11:10 +00:00
|
|
|
}
|
2001-06-06 20:29:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//===---------------------------------------------------------------------------
|
2001-12-03 22:26:30 +00:00
|
|
|
// ConstantFP - Floating Point Values [float, double]
|
2001-06-06 20:29:01 +00:00
|
|
|
//
|
2001-12-03 22:26:30 +00:00
|
|
|
class ConstantFP : public Constant {
|
2001-06-06 20:29:01 +00:00
|
|
|
double Val;
|
2001-12-03 22:26:30 +00:00
|
|
|
ConstantFP(const ConstantFP &); // DO NOT IMPLEMENT
|
2001-09-07 16:18:19 +00:00
|
|
|
protected:
|
2001-12-03 22:26:30 +00:00
|
|
|
ConstantFP(const Type *Ty, double V);
|
|
|
|
~ConstantFP() {}
|
2001-06-06 20:29:01 +00:00
|
|
|
public:
|
2001-12-03 22:26:30 +00:00
|
|
|
static ConstantFP *get(const Type *Ty, double V);
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2001-10-29 13:22:49 +00:00
|
|
|
virtual string getStrValue() const;
|
2001-06-06 20:29:01 +00:00
|
|
|
|
|
|
|
static bool isValueValidForType(const Type *Ty, double V);
|
|
|
|
inline double getValue() const { return Val; }
|
2001-10-13 06:11:10 +00:00
|
|
|
|
2001-11-01 05:53:56 +00:00
|
|
|
// isNullValue - Return true if this is the value that would be returned by
|
|
|
|
// getNullConstant.
|
|
|
|
virtual bool isNullValue() const { return Val == 0; }
|
|
|
|
|
2001-10-13 06:11:10 +00:00
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
2001-12-03 22:26:30 +00:00
|
|
|
static inline bool classof(const ConstantFP *) { return true; }
|
|
|
|
static bool classof(const Constant *CPV); // defined in CPV.cpp
|
2001-10-13 06:11:10 +00:00
|
|
|
static inline bool classof(const Value *V) {
|
2001-12-03 22:26:30 +00:00
|
|
|
return isa<Constant>(V) && classof(cast<Constant>(V));
|
2001-10-13 06:11:10 +00:00
|
|
|
}
|
2001-06-06 20:29:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//===---------------------------------------------------------------------------
|
2001-12-03 22:26:30 +00:00
|
|
|
// ConstantArray - Constant Array Declarations
|
2001-06-06 20:29:01 +00:00
|
|
|
//
|
2001-12-03 22:26:30 +00:00
|
|
|
class ConstantArray : public Constant {
|
|
|
|
ConstantArray(const ConstantArray &); // DO NOT IMPLEMENT
|
2001-09-07 16:18:19 +00:00
|
|
|
protected:
|
2001-12-03 22:26:30 +00:00
|
|
|
ConstantArray(const ArrayType *T, const vector<Constant*> &Val);
|
|
|
|
~ConstantArray() {}
|
2001-10-13 06:11:10 +00:00
|
|
|
|
|
|
|
virtual void destroyConstant();
|
2001-06-06 20:29:01 +00:00
|
|
|
public:
|
2001-12-03 22:26:30 +00:00
|
|
|
static ConstantArray *get(const ArrayType *T, const vector<Constant*> &);
|
|
|
|
static ConstantArray *get(const string &Initializer);
|
2001-10-14 23:16:27 +00:00
|
|
|
|
2001-10-29 13:22:49 +00:00
|
|
|
virtual string getStrValue() const;
|
2001-12-13 00:38:57 +00:00
|
|
|
inline const ArrayType *getType() const {
|
|
|
|
return (ArrayType*)Value::getType();
|
|
|
|
}
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2001-07-07 08:36:50 +00:00
|
|
|
inline const vector<Use> &getValues() const { return Operands; }
|
2001-10-13 06:11:10 +00:00
|
|
|
|
2001-11-01 05:53:56 +00:00
|
|
|
// isNullValue - Return true if this is the value that would be returned by
|
|
|
|
// getNullConstant.
|
|
|
|
virtual bool isNullValue() const { return false; }
|
|
|
|
|
2001-10-13 06:11:10 +00:00
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
2001-12-03 22:26:30 +00:00
|
|
|
static inline bool classof(const ConstantArray *) { return true; }
|
|
|
|
static bool classof(const Constant *CPV); // defined in CPV.cpp
|
2001-10-13 06:11:10 +00:00
|
|
|
static inline bool classof(const Value *V) {
|
2001-12-03 22:26:30 +00:00
|
|
|
return isa<Constant>(V) && classof(cast<Constant>(V));
|
2001-10-13 06:11:10 +00:00
|
|
|
}
|
2001-06-06 20:29:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//===---------------------------------------------------------------------------
|
2001-12-03 22:26:30 +00:00
|
|
|
// ConstantStruct - Constant Struct Declarations
|
2001-06-06 20:29:01 +00:00
|
|
|
//
|
2001-12-03 22:26:30 +00:00
|
|
|
class ConstantStruct : public Constant {
|
|
|
|
ConstantStruct(const ConstantStruct &); // DO NOT IMPLEMENT
|
2001-09-07 16:18:19 +00:00
|
|
|
protected:
|
2001-12-03 22:26:30 +00:00
|
|
|
ConstantStruct(const StructType *T, const vector<Constant*> &Val);
|
|
|
|
~ConstantStruct() {}
|
2001-10-13 06:11:10 +00:00
|
|
|
|
|
|
|
virtual void destroyConstant();
|
2001-06-06 20:29:01 +00:00
|
|
|
public:
|
2001-12-03 22:26:30 +00:00
|
|
|
static ConstantStruct *get(const StructType *T,
|
|
|
|
const vector<Constant*> &V);
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2001-10-29 13:22:49 +00:00
|
|
|
virtual string getStrValue() const;
|
2001-12-13 00:38:57 +00:00
|
|
|
inline const StructType *getType() const {
|
|
|
|
return (StructType*)Value::getType();
|
|
|
|
}
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2001-07-07 08:36:50 +00:00
|
|
|
inline const vector<Use> &getValues() const { return Operands; }
|
2001-10-13 06:11:10 +00:00
|
|
|
|
2001-11-01 05:53:56 +00:00
|
|
|
// isNullValue - Return true if this is the value that would be returned by
|
|
|
|
// getNullConstant.
|
|
|
|
virtual bool isNullValue() const { return false; }
|
|
|
|
|
2001-10-13 06:11:10 +00:00
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
2001-12-03 22:26:30 +00:00
|
|
|
static inline bool classof(const ConstantStruct *) { return true; }
|
|
|
|
static bool classof(const Constant *CPV); // defined in CPV.cpp
|
2001-10-13 06:11:10 +00:00
|
|
|
static inline bool classof(const Value *V) {
|
2001-12-03 22:26:30 +00:00
|
|
|
return isa<Constant>(V) && classof(cast<Constant>(V));
|
2001-10-13 06:11:10 +00:00
|
|
|
}
|
2001-06-06 20:29:01 +00:00
|
|
|
};
|
|
|
|
|
2001-09-30 20:14:07 +00:00
|
|
|
//===---------------------------------------------------------------------------
|
2001-12-03 22:26:30 +00:00
|
|
|
// ConstantPointer - Constant Pointer Declarations
|
2001-09-30 20:14:07 +00:00
|
|
|
//
|
2001-12-03 22:26:30 +00:00
|
|
|
// The ConstantPointer class represents a null pointer of a specific type. For
|
|
|
|
// a more specific/useful instance, a subclass of ConstantPointer should be
|
2001-09-30 20:14:07 +00:00
|
|
|
// used.
|
|
|
|
//
|
2001-12-03 22:26:30 +00:00
|
|
|
class ConstantPointer : public Constant {
|
|
|
|
ConstantPointer(const ConstantPointer &); // DO NOT IMPLEMENT
|
2001-09-30 20:14:07 +00:00
|
|
|
protected:
|
2001-12-03 22:26:30 +00:00
|
|
|
inline ConstantPointer(const PointerType *T) : Constant((const Type*)T){}
|
|
|
|
~ConstantPointer() {}
|
2001-09-30 20:14:07 +00:00
|
|
|
public:
|
2001-10-29 13:22:49 +00:00
|
|
|
virtual string getStrValue() const = 0;
|
2001-12-13 00:38:57 +00:00
|
|
|
inline const PointerType *getType() const {
|
|
|
|
return (PointerType*)Value::getType();
|
|
|
|
}
|
2001-09-30 20:14:07 +00:00
|
|
|
|
2001-11-01 05:53:56 +00:00
|
|
|
// isNullValue - Return true if this is the value that would be returned by
|
|
|
|
// getNullConstant.
|
|
|
|
virtual bool isNullValue() const { return false; }
|
|
|
|
|
2001-10-13 06:11:10 +00:00
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
2001-12-03 22:26:30 +00:00
|
|
|
static inline bool classof(const ConstantPointer *) { return true; }
|
|
|
|
static bool classof(const Constant *CPV); // defined in CPV.cpp
|
2001-10-13 06:11:10 +00:00
|
|
|
static inline bool classof(const Value *V) {
|
2001-12-03 22:26:30 +00:00
|
|
|
return isa<Constant>(V) && classof(cast<Constant>(V));
|
2001-10-13 06:11:10 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2001-12-03 22:26:30 +00:00
|
|
|
// ConstantPointerNull - a constant pointer value that points to null
|
2001-10-13 06:11:10 +00:00
|
|
|
//
|
2001-12-03 22:26:30 +00:00
|
|
|
class ConstantPointerNull : public ConstantPointer {
|
|
|
|
ConstantPointerNull(const ConstantPointerNull &); // DO NOT IMPLEMENT
|
2001-10-13 06:11:10 +00:00
|
|
|
protected:
|
2001-12-03 22:26:30 +00:00
|
|
|
inline ConstantPointerNull(const PointerType *T) : ConstantPointer(T) {}
|
|
|
|
inline ~ConstantPointerNull() {}
|
2001-10-13 06:11:10 +00:00
|
|
|
public:
|
2001-10-29 13:22:49 +00:00
|
|
|
virtual string getStrValue() const;
|
2001-10-13 06:11:10 +00:00
|
|
|
|
2001-12-03 22:26:30 +00:00
|
|
|
static ConstantPointerNull *get(const PointerType *T);
|
2001-10-13 06:11:10 +00:00
|
|
|
|
2001-11-01 05:53:56 +00:00
|
|
|
// isNullValue - Return true if this is the value that would be returned by
|
|
|
|
// getNullConstant.
|
|
|
|
virtual bool isNullValue() const { return true; }
|
|
|
|
|
2001-10-13 06:11:10 +00:00
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
2001-12-03 22:26:30 +00:00
|
|
|
static inline bool classof(const ConstantPointerNull *) { return true; }
|
|
|
|
static inline bool classof(const ConstantPointer *P) {
|
2001-10-13 06:11:10 +00:00
|
|
|
return P->getNumOperands() == 0;
|
|
|
|
}
|
2001-12-03 22:26:30 +00:00
|
|
|
static inline bool classof(const Constant *CPV) {
|
|
|
|
return isa<ConstantPointer>(CPV) && classof(cast<ConstantPointer>(CPV));
|
2001-10-13 06:11:10 +00:00
|
|
|
}
|
|
|
|
static inline bool classof(const Value *V) {
|
2001-12-03 22:26:30 +00:00
|
|
|
return isa<ConstantPointer>(V) && classof(cast<ConstantPointer>(V));
|
2001-10-13 06:11:10 +00:00
|
|
|
}
|
2001-09-30 20:14:07 +00:00
|
|
|
};
|
|
|
|
|
2001-10-03 06:12:09 +00:00
|
|
|
|
2001-12-03 22:26:30 +00:00
|
|
|
// ConstantPointerRef - a constant pointer value that is initialized to
|
2001-10-03 14:53:21 +00:00
|
|
|
// point to a global value, which lies at a constant, fixed address.
|
2001-10-03 06:12:09 +00:00
|
|
|
//
|
2001-12-03 22:26:30 +00:00
|
|
|
class ConstantPointerRef : public ConstantPointer {
|
2001-10-13 06:11:10 +00:00
|
|
|
friend class Module; // Modules maintain these references
|
2001-12-03 22:26:30 +00:00
|
|
|
ConstantPointerRef(const ConstantPointerRef &); // DNI!
|
2001-10-13 06:11:10 +00:00
|
|
|
|
2001-10-03 06:12:09 +00:00
|
|
|
protected:
|
2001-12-03 22:26:30 +00:00
|
|
|
ConstantPointerRef(GlobalValue *GV);
|
|
|
|
~ConstantPointerRef() {}
|
2001-10-13 06:11:10 +00:00
|
|
|
|
|
|
|
virtual void destroyConstant() { destroyConstantImpl(); }
|
2001-10-03 06:12:09 +00:00
|
|
|
public:
|
2001-12-03 22:26:30 +00:00
|
|
|
static ConstantPointerRef *get(GlobalValue *GV);
|
2001-10-03 06:12:09 +00:00
|
|
|
|
2001-10-29 13:22:49 +00:00
|
|
|
virtual string getStrValue() const;
|
2001-10-03 06:12:09 +00:00
|
|
|
|
2001-10-03 14:53:21 +00:00
|
|
|
const GlobalValue *getValue() const {
|
|
|
|
return cast<GlobalValue>(Operands[0].get());
|
2001-10-03 06:12:09 +00:00
|
|
|
}
|
2001-10-03 14:53:21 +00:00
|
|
|
GlobalValue *getValue() {
|
|
|
|
return cast<GlobalValue>(Operands[0].get());
|
2001-10-03 06:12:09 +00:00
|
|
|
}
|
2001-10-13 06:11:10 +00:00
|
|
|
|
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
2001-12-03 22:26:30 +00:00
|
|
|
static inline bool classof(const ConstantPointerRef *) { return true; }
|
|
|
|
static inline bool classof(const ConstantPointer *CPV) {
|
2001-10-13 06:11:10 +00:00
|
|
|
return CPV->getNumOperands() == 1;
|
|
|
|
}
|
2001-12-03 22:26:30 +00:00
|
|
|
static inline bool classof(const Constant *CPV) {
|
|
|
|
return isa<ConstantPointer>(CPV) && classof(cast<ConstantPointer>(CPV));
|
2001-10-13 06:11:10 +00:00
|
|
|
}
|
|
|
|
static inline bool classof(const Value *V) {
|
2001-12-03 22:26:30 +00:00
|
|
|
return isa<ConstantPointer>(V) && classof(cast<ConstantPointer>(V));
|
2001-10-13 06:11:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// WARNING: Only to be used by Bytecode & Assembly Parsers! USER CODE SHOULD
|
|
|
|
// NOT USE THIS!!
|
|
|
|
void mutateReference(GlobalValue *NewGV);
|
|
|
|
// END WARNING!!
|
2001-10-03 06:12:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-06-06 20:29:01 +00:00
|
|
|
#endif
|