1 //===-- llvm/Constants.h - Constant class subclass definitions --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 /// @file This file contains the declarations for the subclasses of Constant,
11 /// which represent the different flavors of constant values that live in LLVM.
12 /// Note that Constants are immutable (once created they never change) and are
13 /// fully shared by structural equivalence. This means that two structurally
14 /// equivalent constants will always have the same address. Constant's are
15 /// created on demand as needed and never deleted: thus clients don't have to
16 /// worry about the lifetime of the objects.
18 //===----------------------------------------------------------------------===//
20 #ifndef LLVM_CONSTANTS_H
21 #define LLVM_CONSTANTS_H
23 #include "llvm/Constant.h"
24 #include "llvm/Type.h"
25 #include "llvm/ADT/APInt.h"
34 template<class ConstantClass, class TypeClass, class ValType>
35 struct ConstantCreator;
36 template<class ConstantClass, class TypeClass>
37 struct ConvertConstantType;
39 //===----------------------------------------------------------------------===//
40 /// This is the shared class of boolean and integer constants. This class
41 /// represents both boolean and integral constants.
42 /// @brief Class for constant integers.
43 class ConstantInt : public Constant {
44 static ConstantInt *TheTrueVal, *TheFalseVal;
45 ConstantInt(const ConstantInt &); // DO NOT IMPLEMENT
46 ConstantInt(const IntegerType *Ty, const APInt& V);
49 /// Return the constant as an APInt value reference. This allows clients to
50 /// obtain a copy of the value, with all its precision in tact.
51 /// @brief Return the constant's value.
52 inline const APInt& getValue() const {
56 /// Return the constant as a 64-bit unsigned integer value after it
57 /// has been zero extended as appropriate for the type of this constant. Note
58 /// that this method can assert if the value does not fit in 64 bits.
60 /// @brief Return the zero extended value.
61 inline uint64_t getZExtValue() const {
62 return Val.getZExtValue();
65 /// Return the constant as a 64-bit integer value after it has been sign
66 /// sign extended as appropriate for the type of this constant. Note that
67 /// this method can assert if the value does not fit in 64 bits.
69 /// @brief Return the sign extended value.
70 inline int64_t getSExtValue() const {
71 return Val.getSExtValue();
74 /// A helper method that can be used to determine if the constant contained
75 /// within is equal to a constant. This only works for very small values,
76 /// because this is all that can be represented with all types.
77 /// @brief Determine if this constant's value is same as an unsigned char.
78 bool equalsInt(uint64_t V) const {
82 /// getTrue/getFalse - Return the singleton true/false values.
83 static inline ConstantInt *getTrue() {
84 if (TheTrueVal) return TheTrueVal;
85 return CreateTrueFalseVals(true);
87 static inline ConstantInt *getFalse() {
88 if (TheFalseVal) return TheFalseVal;
89 return CreateTrueFalseVals(false);
92 /// Return a ConstantInt with the specified value for the specified type. The
93 /// value V will be canonicalized to a an unsigned APInt. Accessing it with
94 /// either getSExtValue() or getZExtValue() will yield a correctly sized and
95 /// signed value for the type Ty.
96 /// @brief Get a ConstantInt for a specific value.
97 static ConstantInt *get(const Type *Ty, uint64_t V);
99 /// Return a ConstantInt with the specified value and an implied Type. The
100 /// type is the integer type that corresponds to the bit width of the value.
101 static ConstantInt *get(const APInt &V);
103 /// getType - Specialize the getType() method to always return an IntegerType,
104 /// which reduces the amount of casting needed in parts of the compiler.
106 inline const IntegerType *getType() const {
107 return reinterpret_cast<const IntegerType*>(Value::getType());
110 /// This static method returns true if the type Ty is big enough to
111 /// represent the value V. This can be used to avoid having the get method
112 /// assert when V is larger than Ty can represent. Note that there are two
113 /// versions of this method, one for unsigned and one for signed integers.
114 /// Although ConstantInt canonicalizes everything to an unsigned integer,
115 /// the signed version avoids callers having to convert a signed quantity
116 /// to the appropriate unsigned type before calling the method.
117 /// @returns true if V is a valid value for type Ty
118 /// @brief Determine if the value is in range for the given type.
119 static bool isValueValidForType(const Type *Ty, uint64_t V);
120 static bool isValueValidForType(const Type *Ty, int64_t V);
122 /// This function will return true iff this constant represents the "null"
123 /// value that would be returned by the getNullValue method.
124 /// @returns true if this is the null integer value.
125 /// @brief Determine if the value is null.
126 virtual bool isNullValue() const {
130 /// This is just a convenience method to make client code smaller for a
131 /// common code. It also correctly performs the comparison without the
132 /// potential for an assertion from getZExtValue().
133 bool isZero() const {
137 /// This is just a convenience method to make client code smaller for a
138 /// common case. It also correctly performs the comparison without the
139 /// potential for an assertion from getZExtValue().
140 /// @brief Determine if the value is one.
145 /// This function will return true iff every bit in this constant is set
147 /// @returns true iff this constant's bits are all set to true.
148 /// @brief Determine if the value is all ones.
149 bool isAllOnesValue() const {
150 return Val.isAllOnesValue();
153 /// This function will return true iff this constant represents the largest
154 /// value that may be represented by the constant's type.
155 /// @returns true iff this is the largest value that may be represented
157 /// @brief Determine if the value is maximal.
158 bool isMaxValue(bool isSigned) const {
160 return Val.isMaxSignedValue();
162 return Val.isMaxValue();
165 /// This function will return true iff this constant represents the smallest
166 /// value that may be represented by this constant's type.
167 /// @returns true if this is the smallest value that may be represented by
169 /// @brief Determine if the value is minimal.
170 bool isMinValue(bool isSigned) const {
172 return Val.isMinSignedValue();
174 return Val.isMinValue();
177 /// @returns the value for an integer constant of the given type that has all
178 /// its bits set to true.
179 /// @brief Get the all ones value
180 static ConstantInt *getAllOnesValue(const Type *Ty);
182 /// @brief Methods to support type inquiry through isa, cast, and dyn_cast.
183 static inline bool classof(const ConstantInt *) { return true; }
184 static bool classof(const Value *V) {
185 return V->getValueType() == ConstantIntVal;
187 static void ResetTrueFalse() { TheTrueVal = TheFalseVal = 0; }
189 static ConstantInt *CreateTrueFalseVals(bool WhichOne);
193 //===----------------------------------------------------------------------===//
194 /// ConstantFP - Floating Point Values [float, double]
196 class ConstantFP : public Constant {
198 ConstantFP(const ConstantFP &); // DO NOT IMPLEMENT
200 ConstantFP(const Type *Ty, double V);
202 /// get() - Static factory methods - Return objects of the specified value
203 static ConstantFP *get(const Type *Ty, double V);
205 /// isValueValidForType - return true if Ty is big enough to represent V.
206 static bool isValueValidForType(const Type *Ty, double V);
207 inline double getValue() const { return Val; }
209 /// isNullValue - Return true if this is the value that would be returned by
210 /// getNullValue. Don't depend on == for doubles to tell us it's zero, it
211 /// considers -0.0 to be null as well as 0.0. :(
212 virtual bool isNullValue() const;
214 /// isExactlyValue - We don't rely on operator== working on double values, as
215 /// it returns true for things that are clearly not equal, like -0.0 and 0.0.
216 /// As such, this method can be used to do an exact bit-for-bit comparison of
217 /// two floating point values.
218 bool isExactlyValue(double V) const;
220 /// Methods for support type inquiry through isa, cast, and dyn_cast:
221 static inline bool classof(const ConstantFP *) { return true; }
222 static bool classof(const Value *V) {
223 return V->getValueType() == ConstantFPVal;
227 //===----------------------------------------------------------------------===//
228 /// ConstantAggregateZero - All zero aggregate value
230 class ConstantAggregateZero : public Constant {
231 friend struct ConstantCreator<ConstantAggregateZero, Type, char>;
232 ConstantAggregateZero(const ConstantAggregateZero &); // DO NOT IMPLEMENT
234 ConstantAggregateZero(const Type *Ty)
235 : Constant(Ty, ConstantAggregateZeroVal, 0, 0) {}
237 /// get() - static factory method for creating a null aggregate. It is
238 /// illegal to call this method with a non-aggregate type.
239 static Constant *get(const Type *Ty);
241 /// isNullValue - Return true if this is the value that would be returned by
243 virtual bool isNullValue() const { return true; }
245 virtual void destroyConstant();
247 /// Methods for support type inquiry through isa, cast, and dyn_cast:
249 static bool classof(const ConstantAggregateZero *) { return true; }
250 static bool classof(const Value *V) {
251 return V->getValueType() == ConstantAggregateZeroVal;
256 //===----------------------------------------------------------------------===//
257 /// ConstantArray - Constant Array Declarations
259 class ConstantArray : public Constant {
260 friend struct ConstantCreator<ConstantArray, ArrayType,
261 std::vector<Constant*> >;
262 ConstantArray(const ConstantArray &); // DO NOT IMPLEMENT
264 ConstantArray(const ArrayType *T, const std::vector<Constant*> &Val);
267 /// get() - Static factory methods - Return objects of the specified value
268 static Constant *get(const ArrayType *T, const std::vector<Constant*> &);
269 static Constant *get(const ArrayType *T,
270 Constant*const*Vals, unsigned NumVals) {
271 // FIXME: make this the primary ctor method.
272 return get(T, std::vector<Constant*>(Vals, Vals+NumVals));
275 /// This method constructs a ConstantArray and initializes it with a text
276 /// string. The default behavior (AddNull==true) causes a null terminator to
277 /// be placed at the end of the array. This effectively increases the length
278 /// of the array by one (you've been warned). However, in some situations
279 /// this is not desired so if AddNull==false then the string is copied without
280 /// null termination.
281 static Constant *get(const std::string &Initializer, bool AddNull = true);
283 /// getType - Specialize the getType() method to always return an ArrayType,
284 /// which reduces the amount of casting needed in parts of the compiler.
286 inline const ArrayType *getType() const {
287 return reinterpret_cast<const ArrayType*>(Value::getType());
290 /// isString - This method returns true if the array is an array of sbyte or
291 /// ubyte, and if the elements of the array are all ConstantInt's.
292 bool isString() const;
294 /// isCString - This method returns true if the array is a string (see
295 /// isString) and it ends in a null byte \0 and does not contains any other
296 /// null bytes except its terminator.
297 bool isCString() const;
299 /// getAsString - If this array is isString(), then this method converts the
300 /// array to an std::string and returns it. Otherwise, it asserts out.
302 std::string getAsString() const;
304 /// isNullValue - Return true if this is the value that would be returned by
305 /// getNullValue. This always returns false because zero arrays are always
306 /// created as ConstantAggregateZero objects.
307 virtual bool isNullValue() const { return false; }
309 virtual void destroyConstant();
310 virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
312 /// Methods for support type inquiry through isa, cast, and dyn_cast:
313 static inline bool classof(const ConstantArray *) { return true; }
314 static bool classof(const Value *V) {
315 return V->getValueType() == ConstantArrayVal;
320 //===----------------------------------------------------------------------===//
321 // ConstantStruct - Constant Struct Declarations
323 class ConstantStruct : public Constant {
324 friend struct ConstantCreator<ConstantStruct, StructType,
325 std::vector<Constant*> >;
326 ConstantStruct(const ConstantStruct &); // DO NOT IMPLEMENT
328 ConstantStruct(const StructType *T, const std::vector<Constant*> &Val);
331 /// get() - Static factory methods - Return objects of the specified value
333 static Constant *get(const StructType *T, const std::vector<Constant*> &V);
334 static Constant *get(const std::vector<Constant*> &V, bool Packed = false);
335 static Constant *get(Constant*const* Vals, unsigned NumVals,
336 bool Packed = false) {
337 // FIXME: make this the primary ctor method.
338 return get(std::vector<Constant*>(Vals, Vals+NumVals), Packed);
341 /// getType() specialization - Reduce amount of casting...
343 inline const StructType *getType() const {
344 return reinterpret_cast<const StructType*>(Value::getType());
347 /// isNullValue - Return true if this is the value that would be returned by
348 /// getNullValue. This always returns false because zero structs are always
349 /// created as ConstantAggregateZero objects.
350 virtual bool isNullValue() const {
354 virtual void destroyConstant();
355 virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
357 /// Methods for support type inquiry through isa, cast, and dyn_cast:
358 static inline bool classof(const ConstantStruct *) { return true; }
359 static bool classof(const Value *V) {
360 return V->getValueType() == ConstantStructVal;
364 //===----------------------------------------------------------------------===//
365 /// ConstantVector - Constant Vector Declarations
367 class ConstantVector : public Constant {
368 friend struct ConstantCreator<ConstantVector, VectorType,
369 std::vector<Constant*> >;
370 ConstantVector(const ConstantVector &); // DO NOT IMPLEMENT
372 ConstantVector(const VectorType *T, const std::vector<Constant*> &Val);
375 /// get() - Static factory methods - Return objects of the specified value
376 static Constant *get(const VectorType *T, const std::vector<Constant*> &);
377 static Constant *get(const std::vector<Constant*> &V);
378 static Constant *get(Constant*const* Vals, unsigned NumVals) {
379 // FIXME: make this the primary ctor method.
380 return get(std::vector<Constant*>(Vals, Vals+NumVals));
383 /// getType - Specialize the getType() method to always return an VectorType,
384 /// which reduces the amount of casting needed in parts of the compiler.
386 inline const VectorType *getType() const {
387 return reinterpret_cast<const VectorType*>(Value::getType());
390 /// @returns the value for an packed integer constant of the given type that
391 /// has all its bits set to true.
392 /// @brief Get the all ones value
393 static ConstantVector *getAllOnesValue(const VectorType *Ty);
395 /// isNullValue - Return true if this is the value that would be returned by
396 /// getNullValue. This always returns false because zero arrays are always
397 /// created as ConstantAggregateZero objects.
398 virtual bool isNullValue() const { return false; }
400 /// This function will return true iff every element in this packed constant
401 /// is set to all ones.
402 /// @returns true iff this constant's emements are all set to all ones.
403 /// @brief Determine if the value is all ones.
404 bool isAllOnesValue() const;
406 virtual void destroyConstant();
407 virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
409 /// Methods for support type inquiry through isa, cast, and dyn_cast:
410 static inline bool classof(const ConstantVector *) { return true; }
411 static bool classof(const Value *V) {
412 return V->getValueType() == ConstantVectorVal;
416 //===----------------------------------------------------------------------===//
417 /// ConstantPointerNull - a constant pointer value that points to null
419 class ConstantPointerNull : public Constant {
420 friend struct ConstantCreator<ConstantPointerNull, PointerType, char>;
421 ConstantPointerNull(const ConstantPointerNull &); // DO NOT IMPLEMENT
423 ConstantPointerNull(const PointerType *T)
424 : Constant(reinterpret_cast<const Type*>(T),
425 Value::ConstantPointerNullVal, 0, 0) {}
429 /// get() - Static factory methods - Return objects of the specified value
430 static ConstantPointerNull *get(const PointerType *T);
432 /// isNullValue - Return true if this is the value that would be returned by
434 virtual bool isNullValue() const { return true; }
436 virtual void destroyConstant();
438 /// getType - Specialize the getType() method to always return an PointerType,
439 /// which reduces the amount of casting needed in parts of the compiler.
441 inline const PointerType *getType() const {
442 return reinterpret_cast<const PointerType*>(Value::getType());
445 /// Methods for support type inquiry through isa, cast, and dyn_cast:
446 static inline bool classof(const ConstantPointerNull *) { return true; }
447 static bool classof(const Value *V) {
448 return V->getValueType() == ConstantPointerNullVal;
453 /// ConstantExpr - a constant value that is initialized with an expression using
454 /// other constant values.
456 /// This class uses the standard Instruction opcodes to define the various
457 /// constant expressions. The Opcode field for the ConstantExpr class is
458 /// maintained in the Value::SubclassData field.
459 class ConstantExpr : public Constant {
460 friend struct ConstantCreator<ConstantExpr,Type,
461 std::pair<unsigned, std::vector<Constant*> > >;
462 friend struct ConvertConstantType<ConstantExpr, Type>;
465 ConstantExpr(const Type *Ty, unsigned Opcode, Use *Ops, unsigned NumOps)
466 : Constant(Ty, ConstantExprVal, Ops, NumOps) {
467 // Operation type (an Instruction opcode) is stored as the SubclassData.
468 SubclassData = Opcode;
471 // These private methods are used by the type resolution code to create
472 // ConstantExprs in intermediate forms.
473 static Constant *getTy(const Type *Ty, unsigned Opcode,
474 Constant *C1, Constant *C2);
475 static Constant *getCompareTy(unsigned short pred, Constant *C1,
477 static Constant *getSelectTy(const Type *Ty,
478 Constant *C1, Constant *C2, Constant *C3);
479 static Constant *getGetElementPtrTy(const Type *Ty, Constant *C,
480 Value* const *Idxs, unsigned NumIdxs);
481 static Constant *getExtractElementTy(const Type *Ty, Constant *Val,
483 static Constant *getInsertElementTy(const Type *Ty, Constant *Val,
484 Constant *Elt, Constant *Idx);
485 static Constant *getShuffleVectorTy(const Type *Ty, Constant *V1,
486 Constant *V2, Constant *Mask);
489 // Static methods to construct a ConstantExpr of different kinds. Note that
490 // these methods may return a object that is not an instance of the
491 // ConstantExpr class, because they will attempt to fold the constant
492 // expression into something simpler if possible.
494 /// Cast constant expr
496 static Constant *getTrunc (Constant *C, const Type *Ty);
497 static Constant *getSExt (Constant *C, const Type *Ty);
498 static Constant *getZExt (Constant *C, const Type *Ty);
499 static Constant *getFPTrunc (Constant *C, const Type *Ty);
500 static Constant *getFPExtend(Constant *C, const Type *Ty);
501 static Constant *getUIToFP (Constant *C, const Type *Ty);
502 static Constant *getSIToFP (Constant *C, const Type *Ty);
503 static Constant *getFPToUI (Constant *C, const Type *Ty);
504 static Constant *getFPToSI (Constant *C, const Type *Ty);
505 static Constant *getPtrToInt(Constant *C, const Type *Ty);
506 static Constant *getIntToPtr(Constant *C, const Type *Ty);
507 static Constant *getBitCast (Constant *C, const Type *Ty);
509 // @brief Convenience function for getting one of the casting operations
510 // using a CastOps opcode.
511 static Constant *getCast(
512 unsigned ops, ///< The opcode for the conversion
513 Constant *C, ///< The constant to be converted
514 const Type *Ty ///< The type to which the constant is converted
517 // @brief Create a ZExt or BitCast cast constant expression
518 static Constant *getZExtOrBitCast(
519 Constant *C, ///< The constant to zext or bitcast
520 const Type *Ty ///< The type to zext or bitcast C to
523 // @brief Create a SExt or BitCast cast constant expression
524 static Constant *getSExtOrBitCast(
525 Constant *C, ///< The constant to sext or bitcast
526 const Type *Ty ///< The type to sext or bitcast C to
529 // @brief Create a Trunc or BitCast cast constant expression
530 static Constant *getTruncOrBitCast(
531 Constant *C, ///< The constant to trunc or bitcast
532 const Type *Ty ///< The type to trunc or bitcast C to
535 /// @brief Create a BitCast or a PtrToInt cast constant expression
536 static Constant *getPointerCast(
537 Constant *C, ///< The pointer value to be casted (operand 0)
538 const Type *Ty ///< The type to which cast should be made
541 /// @brief Create a ZExt, Bitcast or Trunc for integer -> integer casts
542 static Constant *getIntegerCast(
543 Constant *C, ///< The integer constant to be casted
544 const Type *Ty, ///< The integer type to cast to
545 bool isSigned ///< Whether C should be treated as signed or not
548 /// @brief Create a FPExt, Bitcast or FPTrunc for fp -> fp casts
549 static Constant *getFPCast(
550 Constant *C, ///< The integer constant to be casted
551 const Type *Ty ///< The integer type to cast to
554 /// @brief Return true if this is a convert constant expression
557 /// @brief Return true if this is a compare constant expression
558 bool isCompare() const;
560 /// Select constant expr
562 static Constant *getSelect(Constant *C, Constant *V1, Constant *V2) {
563 return getSelectTy(V1->getType(), C, V1, V2);
566 /// getSizeOf constant expr - computes the size of a type in a target
567 /// independent way (Note: the return type is a ULong).
569 static Constant *getSizeOf(const Type *Ty);
571 /// ConstantExpr::get - Return a binary or shift operator constant expression,
572 /// folding if possible.
574 static Constant *get(unsigned Opcode, Constant *C1, Constant *C2);
576 /// @brief Return an ICmp or FCmp comparison operator constant expression.
577 static Constant *getCompare(unsigned short pred, Constant *C1, Constant *C2);
579 /// ConstantExpr::get* - Return some common constants without having to
580 /// specify the full Instruction::OPCODE identifier.
582 static Constant *getNeg(Constant *C);
583 static Constant *getNot(Constant *C);
584 static Constant *getAdd(Constant *C1, Constant *C2);
585 static Constant *getSub(Constant *C1, Constant *C2);
586 static Constant *getMul(Constant *C1, Constant *C2);
587 static Constant *getUDiv(Constant *C1, Constant *C2);
588 static Constant *getSDiv(Constant *C1, Constant *C2);
589 static Constant *getFDiv(Constant *C1, Constant *C2);
590 static Constant *getURem(Constant *C1, Constant *C2); // unsigned rem
591 static Constant *getSRem(Constant *C1, Constant *C2); // signed rem
592 static Constant *getFRem(Constant *C1, Constant *C2);
593 static Constant *getAnd(Constant *C1, Constant *C2);
594 static Constant *getOr(Constant *C1, Constant *C2);
595 static Constant *getXor(Constant *C1, Constant *C2);
596 static Constant* getICmp(unsigned short pred, Constant* LHS, Constant* RHS);
597 static Constant* getFCmp(unsigned short pred, Constant* LHS, Constant* RHS);
598 static Constant *getShl(Constant *C1, Constant *C2);
599 static Constant *getLShr(Constant *C1, Constant *C2);
600 static Constant *getAShr(Constant *C1, Constant *C2);
602 /// Getelementptr form. std::vector<Value*> is only accepted for convenience:
603 /// all elements must be Constant's.
605 static Constant *getGetElementPtr(Constant *C,
606 Constant* const *IdxList, unsigned NumIdx);
607 static Constant *getGetElementPtr(Constant *C,
608 Value* const *IdxList, unsigned NumIdx);
610 static Constant *getExtractElement(Constant *Vec, Constant *Idx);
611 static Constant *getInsertElement(Constant *Vec, Constant *Elt,Constant *Idx);
612 static Constant *getShuffleVector(Constant *V1, Constant *V2, Constant *Mask);
614 /// Floating point negation must be implemented with f(x) = -0.0 - x. This
615 /// method returns the negative zero constant for floating point or packed
616 /// floating point types; for all other types, it returns the null value.
617 static Constant *getZeroValueForNegationExpr(const Type *Ty);
619 /// isNullValue - Return true if this is the value that would be returned by
621 virtual bool isNullValue() const { return false; }
623 /// getOpcode - Return the opcode at the root of this constant expression
624 unsigned getOpcode() const { return SubclassData; }
626 /// getPredicate - Return the ICMP or FCMP predicate value. Assert if this is
627 /// not an ICMP or FCMP constant expression.
628 unsigned getPredicate() const;
630 /// getOpcodeName - Return a string representation for an opcode.
631 const char *getOpcodeName() const;
633 /// getWithOperandReplaced - Return a constant expression identical to this
634 /// one, but with the specified operand set to the specified value.
635 Constant *getWithOperandReplaced(unsigned OpNo, Constant *Op) const;
637 /// getWithOperands - This returns the current constant expression with the
638 /// operands replaced with the specified values. The specified operands must
639 /// match count and type with the existing ones.
640 Constant *getWithOperands(const std::vector<Constant*> &Ops) const;
642 virtual void destroyConstant();
643 virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
645 /// Override methods to provide more type information...
646 inline Constant *getOperand(unsigned i) {
647 return cast<Constant>(User::getOperand(i));
649 inline Constant *getOperand(unsigned i) const {
650 return const_cast<Constant*>(cast<Constant>(User::getOperand(i)));
654 /// Methods for support type inquiry through isa, cast, and dyn_cast:
655 static inline bool classof(const ConstantExpr *) { return true; }
656 static inline bool classof(const Value *V) {
657 return V->getValueType() == ConstantExprVal;
662 //===----------------------------------------------------------------------===//
663 /// UndefValue - 'undef' values are things that do not have specified contents.
664 /// These are used for a variety of purposes, including global variable
665 /// initializers and operands to instructions. 'undef' values can occur with
668 class UndefValue : public Constant {
669 friend struct ConstantCreator<UndefValue, Type, char>;
670 UndefValue(const UndefValue &); // DO NOT IMPLEMENT
672 UndefValue(const Type *T) : Constant(T, UndefValueVal, 0, 0) {}
674 /// get() - Static factory methods - Return an 'undef' object of the specified
677 static UndefValue *get(const Type *T);
679 /// isNullValue - Return true if this is the value that would be returned by
681 virtual bool isNullValue() const { return false; }
683 virtual void destroyConstant();
685 /// Methods for support type inquiry through isa, cast, and dyn_cast:
686 static inline bool classof(const UndefValue *) { return true; }
687 static bool classof(const Value *V) {
688 return V->getValueType() == UndefValueVal;
692 } // End llvm namespace