ConstantInt(const ConstantInt &); // DO NOT IMPLEMENT
ConstantInt(const IntegerType *Ty, const APInt& V);
APInt Val;
+protected:
+ static void destroyThis(ConstantInt*v) {
+ Constant::destroyThis(v);
+ }
+ friend class Value;
public:
/// Return the constant as an APInt value reference. This allows clients to
/// obtain a copy of the value, with all its precision in tact.
ConstantFP(const ConstantFP &); // DO NOT IMPLEMENT
protected:
ConstantFP(const Type *Ty, const APFloat& V);
+ static void destroyThis(ConstantFP*v) {
+ Constant::destroyThis(v);
+ }
+ friend class Value;
public:
/// get() - Static factory methods - Return objects of the specified value
static ConstantFP *get(const Type *Ty, const APFloat& V);
/// considers -0.0 to be null as well as 0.0. :(
virtual bool isNullValue() const;
+ // Get a negative zero.
+ static ConstantFP *getNegativeZero(const Type* Ty);
+
/// isExactlyValue - We don't rely on operator== working on double values, as
/// it returns true for things that are clearly not equal, like -0.0 and 0.0.
/// As such, this method can be used to do an exact bit-for-bit comparison of
return isExactlyValue(APFloat(V));
else if (&Val.getSemantics() == &APFloat::IEEEsingle)
return isExactlyValue(APFloat((float)V));
- else
- assert(0);
+ assert(0);
+ return false;
}
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const ConstantFP *) { return true; }
protected:
explicit ConstantAggregateZero(const Type *Ty)
: Constant(Ty, ConstantAggregateZeroVal, 0, 0) {}
+
+ static void destroyThis(ConstantAggregateZero*v) {
+ Constant::destroyThis(v);
+ }
+ friend class Value;
public:
/// get() - static factory method for creating a null aggregate. It is
/// illegal to call this method with a non-aggregate type.
ConstantArray(const ConstantArray &); // DO NOT IMPLEMENT
protected:
ConstantArray(const ArrayType *T, const std::vector<Constant*> &Val);
- ~ConstantArray();
+ static void destroyThis(ConstantArray*);
+ friend class Value;
public:
/// get() - Static factory methods - Return objects of the specified value
static Constant *get(const ArrayType *T, const std::vector<Constant*> &);
ConstantStruct(const ConstantStruct &); // DO NOT IMPLEMENT
protected:
ConstantStruct(const StructType *T, const std::vector<Constant*> &Val);
- ~ConstantStruct();
+ static void destroyThis(ConstantStruct*);
+ friend class Value;
public:
/// get() - Static factory methods - Return objects of the specified value
///
ConstantVector(const ConstantVector &); // DO NOT IMPLEMENT
protected:
ConstantVector(const VectorType *T, const std::vector<Constant*> &Val);
- ~ConstantVector();
+ static void destroyThis(ConstantVector*v);
+ friend class Value;
public:
/// get() - Static factory methods - Return objects of the specified value
static Constant *get(const VectorType *T, const std::vector<Constant*> &);
/// @brief Determine if the value is all ones.
bool isAllOnesValue() const;
+ /// getSplatValue - If this is a splat constant, meaning that all of the
+ /// elements have the same value, return that value. Otherwise return NULL.
+ Constant *getSplatValue();
+
virtual void destroyConstant();
virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
explicit ConstantPointerNull(const PointerType *T)
: Constant(reinterpret_cast<const Type*>(T),
Value::ConstantPointerNullVal, 0, 0) {}
-
+ static void destroyThis(ConstantPointerNull*v) {
+ Constant::destroyThis(v);
+ }
+ friend class Value;
public:
/// get() - Static factory methods - Return objects of the specified value
static Constant *getShuffleVectorTy(const Type *Ty, Constant *V1,
Constant *V2, Constant *Mask);
+ static void destroyThis(ConstantExpr* v) {
+ Constant::destroyThis(v);
+ }
+ friend class Value;
public:
// Static methods to construct a ConstantExpr of different kinds. Note that
// these methods may return a object that is not an instance of the
}
/// getSizeOf constant expr - computes the size of a type in a target
- /// independent way (Note: the return type is a ULong).
+ /// independent way (Note: the return type is an i64).
///
static Constant *getSizeOf(const Type *Ty);
static Constant *getAnd(Constant *C1, Constant *C2);
static Constant *getOr(Constant *C1, Constant *C2);
static Constant *getXor(Constant *C1, Constant *C2);
- static Constant* getICmp(unsigned short pred, Constant* LHS, Constant* RHS);
- static Constant* getFCmp(unsigned short pred, Constant* LHS, Constant* RHS);
+ static Constant *getICmp(unsigned short pred, Constant *LHS, Constant *RHS);
+ static Constant *getFCmp(unsigned short pred, Constant *LHS, Constant *RHS);
static Constant *getShl(Constant *C1, Constant *C2);
static Constant *getLShr(Constant *C1, Constant *C2);
static Constant *getAShr(Constant *C1, Constant *C2);
UndefValue(const UndefValue &); // DO NOT IMPLEMENT
protected:
explicit UndefValue(const Type *T) : Constant(T, UndefValueVal, 0, 0) {}
+ static void destroyThis(UndefValue*v) {
+ Constant::destroyThis(v);
+ }
+ friend class Value;
public:
/// get() - Static factory methods - Return an 'undef' object of the specified
/// type.
}
};
+/// GetElementPtrConstantExpr - Helper class for Constants.cpp,
+/// used behind the scenes to implement getelementpr constant exprs.
+class GetElementPtrConstantExpr : public ConstantExpr {
+protected:
+ static void destroyThis(GetElementPtrConstantExpr*v) {
+ delete [] v->OperandList;
+ ConstantExpr::destroyThis(v);
+ }
+ friend class Value;
+public:
+ GetElementPtrConstantExpr(Constant *C, const std::vector<Constant*> &IdxList,
+ const Type *DestTy);
+};
+
+/// UnaryConstantExpr - Helper class for Constants.cpp, used
+/// behind the scenes to implement unary constant exprs.
+class UnaryConstantExpr : public ConstantExpr {
+ Use Op;
+protected:
+ static void destroyThis(UnaryConstantExpr*v) {
+ ConstantExpr::destroyThis(v);
+ }
+ friend class Value;
+public:
+ UnaryConstantExpr(unsigned Opcode, Constant *C, const Type *Ty);
+};
+
+/// BinaryConstantExpr - Helper class for Constants.cpp, used
+/// behind the scenes to implement binary constant exprs.
+class BinaryConstantExpr : public ConstantExpr {
+ Use Ops[2];
+protected:
+ static void destroyThis(BinaryConstantExpr*v) {
+ ConstantExpr::destroyThis(v);
+ }
+ friend class Value;
+public:
+ BinaryConstantExpr(unsigned Opcode, Constant *C1, Constant *C2)
+ : ConstantExpr(C1->getType(), Opcode, Ops, 2) {
+ Ops[0].init(C1, this);
+ Ops[1].init(C2, this);
+ }
+};
+
+/// SelectConstantExpr - Helper class for Constants.cpp, used
+/// behind the scenes to implement select constant exprs.
+class SelectConstantExpr : public ConstantExpr {
+ Use Ops[3];
+protected:
+ static void destroyThis(SelectConstantExpr*v) {
+ ConstantExpr::destroyThis(v);
+ }
+ friend class Value;
+public:
+ SelectConstantExpr(Constant *C1, Constant *C2, Constant *C3);
+};
+
+/// ExtractElementConstantExpr - Helper class for Constants.cpp, used
+/// behind the scenes to implement extractelement constant exprs.
+class ExtractElementConstantExpr : public ConstantExpr {
+ Use Ops[2];
+protected:
+ static void destroyThis(ExtractElementConstantExpr*v) {
+ ConstantExpr::destroyThis(v);
+ }
+ friend class Value;
+public:
+ ExtractElementConstantExpr(Constant *C1, Constant *C2);
+};
+
+/// InsertElementConstantExpr - Helper class for Constants.cpp, used
+/// behind the scenes to implement insertelement constant exprs.
+class InsertElementConstantExpr : public ConstantExpr {
+ Use Ops[3];
+protected:
+ static void destroyThis(InsertElementConstantExpr*v) {
+ ConstantExpr::destroyThis(v);
+ }
+ friend class Value;
+public:
+ InsertElementConstantExpr(Constant *C1, Constant *C2, Constant *C3);
+};
+
+/// ShuffleVectorConstantExpr - Helper class for Constants.cpp, used
+/// behind the scenes to implement shufflevector constant exprs.
+class ShuffleVectorConstantExpr : public ConstantExpr {
+ Use Ops[3];
+protected:
+ static void destroyThis(ShuffleVectorConstantExpr*v) {
+ ConstantExpr::destroyThis(v);
+ }
+ friend class Value;
+public:
+ ShuffleVectorConstantExpr(Constant *C1, Constant *C2, Constant *C3);
+};
+
+
+
+// CompareConstantExpr - Helper class for Constants.cpp, used
+// behind the scenes to implement ICmp and FCmp constant expressions. This is
+// needed in order to store the predicate value for these instructions.
+class CompareConstantExpr : public ConstantExpr {
+protected:
+ static void destroyThis(CompareConstantExpr*v) {
+ ConstantExpr::destroyThis(v);
+ }
+ friend class Value;
+public:
+ unsigned short predicate;
+ Use Ops[2];
+ CompareConstantExpr(unsigned opc, unsigned short pred,
+ Constant* LHS, Constant* RHS);
+};
+
} // End llvm namespace
#endif