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"
33 template<class ConstantClass, class TypeClass, class ValType>
34 struct ConstantCreator;
35 template<class ConstantClass, class TypeClass>
36 struct ConvertConstantType;
38 //===----------------------------------------------------------------------===//
39 /// This is the shared class of boolean and integer constants. This class
40 /// represents both boolean and integral constants.
41 /// @brief Class for constant integers.
42 class ConstantInt : public Constant {
43 static ConstantInt *TheTrueVal, *TheFalseVal;
44 ConstantInt(const ConstantInt &); // DO NOT IMPLEMENT
45 ConstantInt(const IntegerType *Ty, uint64_t V);
48 /// Return the constant as a 64-bit unsigned integer value after it
49 /// has been zero extended as appropriate for the type of this constant.
50 /// @brief Return the zero extended value.
51 inline uint64_t getZExtValue() const {
55 /// Return the constant as a 64-bit integer value after it has been sign
56 /// sign extended as appropriate for the type of this constant.
57 /// @brief Return the sign extended value.
58 inline int64_t getSExtValue() const {
59 unsigned Size = Value::getType()->getPrimitiveSizeInBits();
60 return (int64_t(Val) << (64-Size)) >> (64-Size);
62 /// A helper method that can be used to determine if the constant contained
63 /// within is equal to a constant. This only works for very small values,
64 /// because this is all that can be represented with all types.
65 /// @brief Determine if this constant's value is same as an unsigned char.
66 bool equalsInt(unsigned char V) const {
68 "equalsInt: Can only be used with very small positive constants!");
72 /// getTrue/getFalse - Return the singleton true/false values.
73 static inline ConstantInt *getTrue() {
74 if (TheTrueVal) return TheTrueVal;
75 return CreateTrueFalseVals(true);
77 static inline ConstantInt *getFalse() {
78 if (TheFalseVal) return TheFalseVal;
79 return CreateTrueFalseVals(false);
82 /// Return a ConstantInt with the specified value for the specified type. The
83 /// value V will be canonicalized to a uint64_t but accessing it with either
84 /// getSExtValue() or getZExtValue() (ConstantInt) will yield the correct
85 /// sized/signed value for the type Ty.
86 /// @brief Get a ConstantInt for a specific value.
87 static ConstantInt *get(const Type *Ty, int64_t V);
89 /// getType - Specialize the getType() method to always return an IntegerType,
90 /// which reduces the amount of casting needed in parts of the compiler.
92 inline const IntegerType *getType() const {
93 return reinterpret_cast<const IntegerType*>(Value::getType());
96 /// This static method returns true if the type Ty is big enough to
97 /// represent the value V. This can be used to avoid having the get method
98 /// assert when V is larger than Ty can represent. Note that there are two
99 /// versions of this method, one for unsigned and one for signed integers.
100 /// Although ConstantInt canonicalizes everything to an unsigned integer,
101 /// the signed version avoids callers having to convert a signed quantity
102 /// to the appropriate unsigned type before calling the method.
103 /// @returns true if V is a valid value for type Ty
104 /// @brief Determine if the value is in range for the given type.
105 static bool isValueValidForType(const Type *Ty, uint64_t V);
106 static bool isValueValidForType(const Type *Ty, int64_t V);
108 /// This function will return true iff this constant represents the "null"
109 /// value that would be returned by the getNullValue method.
110 /// @returns true if this is the null integer value.
111 /// @brief Determine if the value is null.
112 virtual bool isNullValue() const {
116 /// This function will return true iff every bit in this constant is set
118 /// @returns true iff this constant's bits are all set to true.
119 /// @brief Determine if the value is all ones.
120 bool isAllOnesValue() const {
121 return getSExtValue() == -1;
124 /// This function will return true iff this constant represents the largest
125 /// value that may be represented by the constant's type.
126 /// @returns true iff this is the largest value that may be represented
128 /// @brief Determine if the value is maximal.
129 bool isMaxValue(bool isSigned) const {
131 int64_t V = getSExtValue();
132 if (V < 0) return false; // Be careful about wrap-around on 'long's
134 return !isValueValidForType(Value::getType(), V) || V < 0;
136 return isAllOnesValue();
139 /// This function will return true iff this constant represents the smallest
140 /// value that may be represented by this constant's type.
141 /// @returns true if this is the smallest value that may be represented by
143 /// @brief Determine if the value is minimal.
144 bool isMinValue(bool isSigned) const {
146 int64_t V = getSExtValue();
147 if (V > 0) return false; // Be careful about wrap-around on 'long's
149 return !isValueValidForType(Value::getType(), V) || V > 0;
151 return getZExtValue() == 0;
154 /// @returns the value for an integer constant of the given type that has all
155 /// its bits set to true.
156 /// @brief Get the all ones value
157 static ConstantInt *getAllOnesValue(const Type *Ty);
159 /// @brief Methods to support type inquiry through isa, cast, and dyn_cast.
160 static inline bool classof(const ConstantInt *) { return true; }
161 static bool classof(const Value *V) {
162 return V->getValueType() == ConstantIntVal;
164 static void ResetTrueFalse() { TheTrueVal = TheFalseVal = 0; }
166 static ConstantInt *CreateTrueFalseVals(bool WhichOne);
170 //===----------------------------------------------------------------------===//
171 /// ConstantFP - Floating Point Values [float, double]
173 class ConstantFP : public Constant {
175 ConstantFP(const ConstantFP &); // DO NOT IMPLEMENT
177 ConstantFP(const Type *Ty, double V);
179 /// get() - Static factory methods - Return objects of the specified value
180 static ConstantFP *get(const Type *Ty, double V);
182 /// isValueValidForType - return true if Ty is big enough to represent V.
183 static bool isValueValidForType(const Type *Ty, double V);
184 inline double getValue() const { return Val; }
186 /// isNullValue - Return true if this is the value that would be returned by
187 /// getNullValue. Don't depend on == for doubles to tell us it's zero, it
188 /// considers -0.0 to be null as well as 0.0. :(
189 virtual bool isNullValue() const;
191 /// isExactlyValue - We don't rely on operator== working on double values, as
192 /// it returns true for things that are clearly not equal, like -0.0 and 0.0.
193 /// As such, this method can be used to do an exact bit-for-bit comparison of
194 /// two floating point values.
195 bool isExactlyValue(double V) const;
197 /// Methods for support type inquiry through isa, cast, and dyn_cast:
198 static inline bool classof(const ConstantFP *) { return true; }
199 static bool classof(const Value *V) {
200 return V->getValueType() == ConstantFPVal;
204 //===----------------------------------------------------------------------===//
205 /// ConstantAggregateZero - All zero aggregate value
207 class ConstantAggregateZero : public Constant {
208 friend struct ConstantCreator<ConstantAggregateZero, Type, char>;
209 ConstantAggregateZero(const ConstantAggregateZero &); // DO NOT IMPLEMENT
211 ConstantAggregateZero(const Type *Ty)
212 : Constant(Ty, ConstantAggregateZeroVal, 0, 0) {}
214 /// get() - static factory method for creating a null aggregate. It is
215 /// illegal to call this method with a non-aggregate type.
216 static Constant *get(const Type *Ty);
218 /// isNullValue - Return true if this is the value that would be returned by
220 virtual bool isNullValue() const { return true; }
222 virtual void destroyConstant();
224 /// Methods for support type inquiry through isa, cast, and dyn_cast:
226 static bool classof(const ConstantAggregateZero *) { return true; }
227 static bool classof(const Value *V) {
228 return V->getValueType() == ConstantAggregateZeroVal;
233 //===----------------------------------------------------------------------===//
234 /// ConstantArray - Constant Array Declarations
236 class ConstantArray : public Constant {
237 friend struct ConstantCreator<ConstantArray, ArrayType,
238 std::vector<Constant*> >;
239 ConstantArray(const ConstantArray &); // DO NOT IMPLEMENT
241 ConstantArray(const ArrayType *T, const std::vector<Constant*> &Val);
244 /// get() - Static factory methods - Return objects of the specified value
245 static Constant *get(const ArrayType *T, const std::vector<Constant*> &);
246 static Constant *get(const ArrayType *T,
247 Constant*const*Vals, unsigned NumVals) {
248 // FIXME: make this the primary ctor method.
249 return get(T, std::vector<Constant*>(Vals, Vals+NumVals));
252 /// This method constructs a ConstantArray and initializes it with a text
253 /// string. The default behavior (AddNull==true) causes a null terminator to
254 /// be placed at the end of the array. This effectively increases the length
255 /// of the array by one (you've been warned). However, in some situations
256 /// this is not desired so if AddNull==false then the string is copied without
257 /// null termination.
258 static Constant *get(const std::string &Initializer, bool AddNull = true);
260 /// getType - Specialize the getType() method to always return an ArrayType,
261 /// which reduces the amount of casting needed in parts of the compiler.
263 inline const ArrayType *getType() const {
264 return reinterpret_cast<const ArrayType*>(Value::getType());
267 /// isString - This method returns true if the array is an array of sbyte or
268 /// ubyte, and if the elements of the array are all ConstantInt's.
269 bool isString() const;
271 /// isCString - This method returns true if the array is a string (see
272 /// isString) and it ends in a null byte \0 and does not contains any other
273 /// null bytes except its terminator.
274 bool isCString() const;
276 /// getAsString - If this array is isString(), then this method converts the
277 /// array to an std::string and returns it. Otherwise, it asserts out.
279 std::string getAsString() const;
281 /// isNullValue - Return true if this is the value that would be returned by
282 /// getNullValue. This always returns false because zero arrays are always
283 /// created as ConstantAggregateZero objects.
284 virtual bool isNullValue() const { return false; }
286 virtual void destroyConstant();
287 virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
289 /// Methods for support type inquiry through isa, cast, and dyn_cast:
290 static inline bool classof(const ConstantArray *) { return true; }
291 static bool classof(const Value *V) {
292 return V->getValueType() == ConstantArrayVal;
297 //===----------------------------------------------------------------------===//
298 // ConstantStruct - Constant Struct Declarations
300 class ConstantStruct : public Constant {
301 friend struct ConstantCreator<ConstantStruct, StructType,
302 std::vector<Constant*> >;
303 ConstantStruct(const ConstantStruct &); // DO NOT IMPLEMENT
305 ConstantStruct(const StructType *T, const std::vector<Constant*> &Val);
308 /// get() - Static factory methods - Return objects of the specified value
310 static Constant *get(const StructType *T, const std::vector<Constant*> &V);
311 static Constant *get(const std::vector<Constant*> &V, bool Packed = false);
312 static Constant *get(Constant*const* Vals, unsigned NumVals,
313 bool Packed = false) {
314 // FIXME: make this the primary ctor method.
315 return get(std::vector<Constant*>(Vals, Vals+NumVals), Packed);
318 /// getType() specialization - Reduce amount of casting...
320 inline const StructType *getType() const {
321 return reinterpret_cast<const StructType*>(Value::getType());
324 /// isNullValue - Return true if this is the value that would be returned by
325 /// getNullValue. This always returns false because zero structs are always
326 /// created as ConstantAggregateZero objects.
327 virtual bool isNullValue() const {
331 virtual void destroyConstant();
332 virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
334 /// Methods for support type inquiry through isa, cast, and dyn_cast:
335 static inline bool classof(const ConstantStruct *) { return true; }
336 static bool classof(const Value *V) {
337 return V->getValueType() == ConstantStructVal;
341 //===----------------------------------------------------------------------===//
342 /// ConstantVector - Constant Vector Declarations
344 class ConstantVector : public Constant {
345 friend struct ConstantCreator<ConstantVector, VectorType,
346 std::vector<Constant*> >;
347 ConstantVector(const ConstantVector &); // DO NOT IMPLEMENT
349 ConstantVector(const VectorType *T, const std::vector<Constant*> &Val);
352 /// get() - Static factory methods - Return objects of the specified value
353 static Constant *get(const VectorType *T, const std::vector<Constant*> &);
354 static Constant *get(const std::vector<Constant*> &V);
355 static Constant *get(Constant*const* Vals, unsigned NumVals) {
356 // FIXME: make this the primary ctor method.
357 return get(std::vector<Constant*>(Vals, Vals+NumVals));
360 /// getType - Specialize the getType() method to always return an VectorType,
361 /// which reduces the amount of casting needed in parts of the compiler.
363 inline const VectorType *getType() const {
364 return reinterpret_cast<const VectorType*>(Value::getType());
367 /// @returns the value for an packed integer constant of the given type that
368 /// has all its bits set to true.
369 /// @brief Get the all ones value
370 static ConstantVector *getAllOnesValue(const VectorType *Ty);
372 /// isNullValue - Return true if this is the value that would be returned by
373 /// getNullValue. This always returns false because zero arrays are always
374 /// created as ConstantAggregateZero objects.
375 virtual bool isNullValue() const { return false; }
377 /// This function will return true iff every element in this packed constant
378 /// is set to all ones.
379 /// @returns true iff this constant's emements are all set to all ones.
380 /// @brief Determine if the value is all ones.
381 bool isAllOnesValue() const;
383 virtual void destroyConstant();
384 virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
386 /// Methods for support type inquiry through isa, cast, and dyn_cast:
387 static inline bool classof(const ConstantVector *) { return true; }
388 static bool classof(const Value *V) {
389 return V->getValueType() == ConstantVectorVal;
393 //===----------------------------------------------------------------------===//
394 /// ConstantPointerNull - a constant pointer value that points to null
396 class ConstantPointerNull : public Constant {
397 friend struct ConstantCreator<ConstantPointerNull, PointerType, char>;
398 ConstantPointerNull(const ConstantPointerNull &); // DO NOT IMPLEMENT
400 ConstantPointerNull(const PointerType *T)
401 : Constant(reinterpret_cast<const Type*>(T),
402 Value::ConstantPointerNullVal, 0, 0) {}
406 /// get() - Static factory methods - Return objects of the specified value
407 static ConstantPointerNull *get(const PointerType *T);
409 /// isNullValue - Return true if this is the value that would be returned by
411 virtual bool isNullValue() const { return true; }
413 virtual void destroyConstant();
415 /// getType - Specialize the getType() method to always return an PointerType,
416 /// which reduces the amount of casting needed in parts of the compiler.
418 inline const PointerType *getType() const {
419 return reinterpret_cast<const PointerType*>(Value::getType());
422 /// Methods for support type inquiry through isa, cast, and dyn_cast:
423 static inline bool classof(const ConstantPointerNull *) { return true; }
424 static bool classof(const Value *V) {
425 return V->getValueType() == ConstantPointerNullVal;
430 /// ConstantExpr - a constant value that is initialized with an expression using
431 /// other constant values.
433 /// This class uses the standard Instruction opcodes to define the various
434 /// constant expressions. The Opcode field for the ConstantExpr class is
435 /// maintained in the Value::SubclassData field.
436 class ConstantExpr : public Constant {
437 friend struct ConstantCreator<ConstantExpr,Type,
438 std::pair<unsigned, std::vector<Constant*> > >;
439 friend struct ConvertConstantType<ConstantExpr, Type>;
442 ConstantExpr(const Type *Ty, unsigned Opcode, Use *Ops, unsigned NumOps)
443 : Constant(Ty, ConstantExprVal, Ops, NumOps) {
444 // Operation type (an Instruction opcode) is stored as the SubclassData.
445 SubclassData = Opcode;
448 // These private methods are used by the type resolution code to create
449 // ConstantExprs in intermediate forms.
450 static Constant *getTy(const Type *Ty, unsigned Opcode,
451 Constant *C1, Constant *C2);
452 static Constant *getCompareTy(unsigned short pred, Constant *C1,
454 static Constant *getSelectTy(const Type *Ty,
455 Constant *C1, Constant *C2, Constant *C3);
456 static Constant *getGetElementPtrTy(const Type *Ty, Constant *C,
457 Value* const *Idxs, unsigned NumIdxs);
458 static Constant *getExtractElementTy(const Type *Ty, Constant *Val,
460 static Constant *getInsertElementTy(const Type *Ty, Constant *Val,
461 Constant *Elt, Constant *Idx);
462 static Constant *getShuffleVectorTy(const Type *Ty, Constant *V1,
463 Constant *V2, Constant *Mask);
466 // Static methods to construct a ConstantExpr of different kinds. Note that
467 // these methods may return a object that is not an instance of the
468 // ConstantExpr class, because they will attempt to fold the constant
469 // expression into something simpler if possible.
471 /// Cast constant expr
473 static Constant *getTrunc (Constant *C, const Type *Ty);
474 static Constant *getSExt (Constant *C, const Type *Ty);
475 static Constant *getZExt (Constant *C, const Type *Ty);
476 static Constant *getFPTrunc (Constant *C, const Type *Ty);
477 static Constant *getFPExtend(Constant *C, const Type *Ty);
478 static Constant *getUIToFP (Constant *C, const Type *Ty);
479 static Constant *getSIToFP (Constant *C, const Type *Ty);
480 static Constant *getFPToUI (Constant *C, const Type *Ty);
481 static Constant *getFPToSI (Constant *C, const Type *Ty);
482 static Constant *getPtrToInt(Constant *C, const Type *Ty);
483 static Constant *getIntToPtr(Constant *C, const Type *Ty);
484 static Constant *getBitCast (Constant *C, const Type *Ty);
486 // @brief Convenience function for getting one of the casting operations
487 // using a CastOps opcode.
488 static Constant *getCast(
489 unsigned ops, ///< The opcode for the conversion
490 Constant *C, ///< The constant to be converted
491 const Type *Ty ///< The type to which the constant is converted
494 // @brief Create a ZExt or BitCast cast constant expression
495 static Constant *getZExtOrBitCast(
496 Constant *C, ///< The constant to zext or bitcast
497 const Type *Ty ///< The type to zext or bitcast C to
500 // @brief Create a SExt or BitCast cast constant expression
501 static Constant *getSExtOrBitCast(
502 Constant *C, ///< The constant to sext or bitcast
503 const Type *Ty ///< The type to sext or bitcast C to
506 // @brief Create a Trunc or BitCast cast constant expression
507 static Constant *getTruncOrBitCast(
508 Constant *C, ///< The constant to trunc or bitcast
509 const Type *Ty ///< The type to trunc or bitcast C to
512 /// @brief Create a BitCast or a PtrToInt cast constant expression
513 static Constant *getPointerCast(
514 Constant *C, ///< The pointer value to be casted (operand 0)
515 const Type *Ty ///< The type to which cast should be made
518 /// @brief Create a ZExt, Bitcast or Trunc for integer -> integer casts
519 static Constant *getIntegerCast(
520 Constant *C, ///< The integer constant to be casted
521 const Type *Ty, ///< The integer type to cast to
522 bool isSigned ///< Whether C should be treated as signed or not
525 /// @brief Create a FPExt, Bitcast or FPTrunc for fp -> fp casts
526 static Constant *getFPCast(
527 Constant *C, ///< The integer constant to be casted
528 const Type *Ty ///< The integer type to cast to
531 /// @brief Return true if this is a convert constant expression
534 /// @brief Return true if this is a compare constant expression
535 bool isCompare() const;
537 /// Select constant expr
539 static Constant *getSelect(Constant *C, Constant *V1, Constant *V2) {
540 return getSelectTy(V1->getType(), C, V1, V2);
543 /// getSizeOf constant expr - computes the size of a type in a target
544 /// independent way (Note: the return type is a ULong).
546 static Constant *getSizeOf(const Type *Ty);
548 /// ConstantExpr::get - Return a binary or shift operator constant expression,
549 /// folding if possible.
551 static Constant *get(unsigned Opcode, Constant *C1, Constant *C2);
553 /// @brief Return an ICmp or FCmp comparison operator constant expression.
554 static Constant *getCompare(unsigned short pred, Constant *C1, Constant *C2);
556 /// ConstantExpr::get* - Return some common constants without having to
557 /// specify the full Instruction::OPCODE identifier.
559 static Constant *getNeg(Constant *C);
560 static Constant *getNot(Constant *C);
561 static Constant *getAdd(Constant *C1, Constant *C2);
562 static Constant *getSub(Constant *C1, Constant *C2);
563 static Constant *getMul(Constant *C1, Constant *C2);
564 static Constant *getUDiv(Constant *C1, Constant *C2);
565 static Constant *getSDiv(Constant *C1, Constant *C2);
566 static Constant *getFDiv(Constant *C1, Constant *C2);
567 static Constant *getURem(Constant *C1, Constant *C2); // unsigned rem
568 static Constant *getSRem(Constant *C1, Constant *C2); // signed rem
569 static Constant *getFRem(Constant *C1, Constant *C2);
570 static Constant *getAnd(Constant *C1, Constant *C2);
571 static Constant *getOr(Constant *C1, Constant *C2);
572 static Constant *getXor(Constant *C1, Constant *C2);
573 static Constant* getICmp(unsigned short pred, Constant* LHS, Constant* RHS);
574 static Constant* getFCmp(unsigned short pred, Constant* LHS, Constant* RHS);
575 static Constant *getShl(Constant *C1, Constant *C2);
576 static Constant *getLShr(Constant *C1, Constant *C2);
577 static Constant *getAShr(Constant *C1, Constant *C2);
579 /// Getelementptr form. std::vector<Value*> is only accepted for convenience:
580 /// all elements must be Constant's.
582 static Constant *getGetElementPtr(Constant *C,
583 Constant* const *IdxList, unsigned NumIdx);
584 static Constant *getGetElementPtr(Constant *C,
585 Value* const *IdxList, unsigned NumIdx);
587 static Constant *getExtractElement(Constant *Vec, Constant *Idx);
588 static Constant *getInsertElement(Constant *Vec, Constant *Elt,Constant *Idx);
589 static Constant *getShuffleVector(Constant *V1, Constant *V2, Constant *Mask);
591 /// Floating point negation must be implemented with f(x) = -0.0 - x. This
592 /// method returns the negative zero constant for floating point or packed
593 /// floating point types; for all other types, it returns the null value.
594 static Constant *getZeroValueForNegationExpr(const Type *Ty);
596 /// isNullValue - Return true if this is the value that would be returned by
598 virtual bool isNullValue() const { return false; }
600 /// getOpcode - Return the opcode at the root of this constant expression
601 unsigned getOpcode() const { return SubclassData; }
603 /// getPredicate - Return the ICMP or FCMP predicate value. Assert if this is
604 /// not an ICMP or FCMP constant expression.
605 unsigned getPredicate() const;
607 /// getOpcodeName - Return a string representation for an opcode.
608 const char *getOpcodeName() const;
610 /// getWithOperandReplaced - Return a constant expression identical to this
611 /// one, but with the specified operand set to the specified value.
612 Constant *getWithOperandReplaced(unsigned OpNo, Constant *Op) const;
614 /// getWithOperands - This returns the current constant expression with the
615 /// operands replaced with the specified values. The specified operands must
616 /// match count and type with the existing ones.
617 Constant *getWithOperands(const std::vector<Constant*> &Ops) const;
619 virtual void destroyConstant();
620 virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
622 /// Override methods to provide more type information...
623 inline Constant *getOperand(unsigned i) {
624 return cast<Constant>(User::getOperand(i));
626 inline Constant *getOperand(unsigned i) const {
627 return const_cast<Constant*>(cast<Constant>(User::getOperand(i)));
631 /// Methods for support type inquiry through isa, cast, and dyn_cast:
632 static inline bool classof(const ConstantExpr *) { return true; }
633 static inline bool classof(const Value *V) {
634 return V->getValueType() == ConstantExprVal;
639 //===----------------------------------------------------------------------===//
640 /// UndefValue - 'undef' values are things that do not have specified contents.
641 /// These are used for a variety of purposes, including global variable
642 /// initializers and operands to instructions. 'undef' values can occur with
645 class UndefValue : public Constant {
646 friend struct ConstantCreator<UndefValue, Type, char>;
647 UndefValue(const UndefValue &); // DO NOT IMPLEMENT
649 UndefValue(const Type *T) : Constant(T, UndefValueVal, 0, 0) {}
651 /// get() - Static factory methods - Return an 'undef' object of the specified
654 static UndefValue *get(const Type *T);
656 /// isNullValue - Return true if this is the value that would be returned by
658 virtual bool isNullValue() const { return false; }
660 virtual void destroyConstant();
662 /// Methods for support type inquiry through isa, cast, and dyn_cast:
663 static inline bool classof(const UndefValue *) { return true; }
664 static bool classof(const Value *V) {
665 return V->getValueType() == UndefValueVal;
669 } // End llvm namespace