2002-04-28 19:55:58 +00:00
|
|
|
//===-- llvm/Constants.h - Constant class subclass definitions ---*- C++ -*--=//
|
2001-06-06 20:29:01 +00:00
|
|
|
//
|
2002-04-28 19:55:58 +00:00
|
|
|
// This file contains the declarations for the subclasses of Constant, which
|
|
|
|
// represent the different type of constant pool values
|
2001-06-06 20:29:01 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2002-04-28 19:55:58 +00:00
|
|
|
#ifndef LLVM_CONSTANTS_H
|
|
|
|
#define LLVM_CONSTANTS_H
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2002-04-28 19:55:58 +00:00
|
|
|
#include "llvm/Constant.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
|
|
|
// 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(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
|
|
|
|
|
|
|
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
|
2002-04-27 02:22:42 +00:00
|
|
|
// getNullValue.
|
2001-11-01 05:53:56 +00:00
|
|
|
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
|
2002-04-27 02:22:42 +00:00
|
|
|
// getNullValue.
|
2001-11-01 05:53:56 +00:00
|
|
|
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
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
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
|
2002-04-27 02:22:42 +00:00
|
|
|
// getNullValue.
|
2001-11-01 05:53:56 +00:00
|
|
|
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:
|
2002-01-20 22:54:45 +00:00
|
|
|
ConstantArray(const ArrayType *T, const std::vector<Constant*> &Val);
|
2001-12-03 22:26:30 +00:00
|
|
|
~ConstantArray() {}
|
2001-10-13 06:11:10 +00:00
|
|
|
|
|
|
|
virtual void destroyConstant();
|
2001-06-06 20:29:01 +00:00
|
|
|
public:
|
2002-01-20 22:54:45 +00:00
|
|
|
static ConstantArray *get(const ArrayType *T, const std::vector<Constant*> &);
|
|
|
|
static ConstantArray *get(const std::string &Initializer);
|
2001-10-14 23:16:27 +00:00
|
|
|
|
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
|
|
|
|
2002-01-20 22:54:45 +00:00
|
|
|
inline const std::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
|
2002-04-27 02:22:42 +00:00
|
|
|
// getNullValue.
|
2001-11-01 05:53:56 +00:00
|
|
|
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:
|
2002-01-20 22:54:45 +00:00
|
|
|
ConstantStruct(const StructType *T, const std::vector<Constant*> &Val);
|
2001-12-03 22:26:30 +00:00
|
|
|
~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,
|
2002-01-20 22:54:45 +00:00
|
|
|
const std::vector<Constant*> &V);
|
2001-06-06 20:29:01 +00:00
|
|
|
|
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
|
|
|
|
2002-01-20 22:54:45 +00:00
|
|
|
inline const std::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
|
2002-04-27 02:22:42 +00:00
|
|
|
// getNullValue.
|
2001-11-01 05:53:56 +00:00
|
|
|
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-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
|
2002-04-27 02:22:42 +00:00
|
|
|
// getNullValue.
|
2001-11-01 05:53:56 +00:00
|
|
|
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; }
|
2002-07-14 22:47:54 +00:00
|
|
|
static bool classof(const Constant *CPV); // defined in Constants.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-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
|
2002-04-27 02:22:42 +00:00
|
|
|
// getNullValue.
|
2001-11-01 05:53:56 +00:00
|
|
|
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) {
|
2002-07-14 22:47:54 +00:00
|
|
|
return (P->getNumOperands() == 0 && P->isNullValue());
|
2001-10-13 06:11:10 +00:00
|
|
|
}
|
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-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) {
|
2002-07-14 22:47:54 +00:00
|
|
|
// check for a single operand (the target value)
|
|
|
|
return (CPV->getNumOperands() == 1);
|
2001-10-13 06:11:10 +00:00
|
|
|
}
|
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!!
|
2002-07-14 22:47:54 +00:00
|
|
|
// Returns the number of uses of OldV that were replaced.
|
|
|
|
virtual unsigned mutateReferences(Value* OldV, Value *NewV);
|
2001-10-13 06:11:10 +00:00
|
|
|
// END WARNING!!
|
2001-10-03 06:12:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-07-14 22:47:54 +00:00
|
|
|
// ConstantExpr - a constant value that is initialized with
|
|
|
|
// an expression using other constant values. This is only used
|
|
|
|
// to represent values that cannot be evaluated at compile-time
|
|
|
|
// (e.g., something derived from an address) because it does
|
|
|
|
// not have a mechanism to store the actual value.
|
|
|
|
// Use the appropriate Constant subclass above for known constants.
|
|
|
|
//
|
|
|
|
class ConstantExpr : public Constant {
|
2002-07-30 18:54:22 +00:00
|
|
|
unsigned iType; // Operation type
|
2002-07-14 22:47:54 +00:00
|
|
|
|
|
|
|
protected:
|
2002-07-30 18:54:22 +00:00
|
|
|
ConstantExpr(unsigned Opcode, Constant *C, const Type *Ty);
|
|
|
|
ConstantExpr(unsigned Opcode, Constant *C1, Constant *C2);
|
|
|
|
ConstantExpr(Constant *C, const std::vector<Constant*> &IdxList,
|
|
|
|
const Type *DestTy);
|
2002-07-14 22:47:54 +00:00
|
|
|
~ConstantExpr() {}
|
|
|
|
|
2002-07-15 18:20:50 +00:00
|
|
|
virtual void destroyConstant();
|
2002-07-14 22:47:54 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
// Static methods to construct a ConstantExpr of different kinds.
|
2002-07-30 18:54:22 +00:00
|
|
|
|
|
|
|
// Unary constant expr - Use with unary operators and casts
|
2002-07-18 00:11:08 +00:00
|
|
|
static ConstantExpr *get(unsigned Opcode, Constant *C, const Type *Ty);
|
2002-07-30 18:54:22 +00:00
|
|
|
|
|
|
|
// Binary constant expr - Use with binary operators...
|
|
|
|
static ConstantExpr *get(unsigned Opcode, Constant *C1, Constant *C2);
|
|
|
|
|
|
|
|
// Getelementptr form...
|
|
|
|
static ConstantExpr *getGetElementPtr(Constant *C,
|
|
|
|
const std::vector<Constant*> &IdxList);
|
2002-07-14 22:47:54 +00:00
|
|
|
|
|
|
|
// isNullValue - Return true if this is the value that would be returned by
|
|
|
|
// getNullValue.
|
|
|
|
virtual bool isNullValue() const { return false; }
|
|
|
|
|
|
|
|
// getOpcode - Return the opcode at the root of this constant expression
|
|
|
|
unsigned getOpcode() const { return iType; }
|
|
|
|
|
|
|
|
// getOpcodeName - Return a string representation for an opcode.
|
2002-07-30 18:54:22 +00:00
|
|
|
const char *getOpcodeName() const;
|
2002-07-14 22:47:54 +00:00
|
|
|
|
|
|
|
// isConstantExpr - Return true if this is a ConstantExpr
|
|
|
|
virtual bool isConstantExpr() const { return true; }
|
|
|
|
|
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
|
|
|
static inline bool classof(const ConstantExpr *) { return true; }
|
|
|
|
static inline bool classof(const Constant *CPV) {
|
|
|
|
return CPV->isConstantExpr();
|
|
|
|
}
|
|
|
|
static inline bool classof(const Value *V) {
|
|
|
|
return isa<Constant>(V) && classof(cast<Constant>(V));
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
// WARNING: Only to be used by Bytecode & Assembly Parsers! USER CODE SHOULD
|
|
|
|
// NOT USE THIS!!
|
|
|
|
// Returns the number of uses of OldV that were replaced.
|
|
|
|
virtual unsigned mutateReferences(Value* OldV, Value *NewV);
|
|
|
|
// END WARNING!!
|
|
|
|
};
|
|
|
|
|
2001-10-03 06:12:09 +00:00
|
|
|
|
2001-06-06 20:29:01 +00:00
|
|
|
#endif
|