+// 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 {
+ unsigned iType; // Operation type
+
+protected:
+ 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);
+ ~ConstantExpr() {}
+
+public:
+ // Static methods to construct a ConstantExpr of different kinds.
+
+ /// Cast constant expr
+ static ConstantExpr *getCast(Constant *C, const Type *Ty);
+
+ /// 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);
+
+ /// 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.
+ const char *getOpcodeName() const;
+
+ /// isConstantExpr - Return true if this is a ConstantExpr
+ virtual bool isConstantExpr() const { return true; }
+
+ virtual void destroyConstant();
+ virtual void replaceUsesOfWithOnConstant(Value *From, Value *To);
+
+ /// 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));
+ }
+};