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;
47 ConstantInt(const ConstantInt &); // DO NOT IMPLEMENT
48 ConstantInt(const IntegerType *Ty, uint64_t V);
49 friend struct ConstantCreator<ConstantInt, IntegerType, uint64_t>;
51 /// Return the constant as a 64-bit unsigned integer value after it
52 /// has been zero extended as appropriate for the type of this constant.
53 /// @brief Return the zero extended value.
54 inline uint64_t getZExtValue() const {
58 /// Return the constant as a 64-bit integer value after it has been sign
59 /// sign extended as appropriate for the type of this constant.
60 /// @brief Return the sign extended value.
61 inline int64_t getSExtValue() const {
62 unsigned Size = Value::getType()->getPrimitiveSizeInBits();
63 return (int64_t(Val) << (64-Size)) >> (64-Size);
65 /// A helper method that can be used to determine if the constant contained
66 /// within is equal to a constant. This only works for very small values,
67 /// because this is all that can be represented with all types.
68 /// @brief Determine if this constant's value is same as an unsigned char.
69 bool equalsInt(unsigned char V) const {
71 "equalsInt: Can only be used with very small positive constants!");
75 /// getTrue/getFalse - Return the singleton true/false values.
76 static inline ConstantInt *getTrue() {
77 if (TheTrueVal) return TheTrueVal;
78 return CreateTrueFalseVals(true);
80 static inline ConstantInt *getFalse() {
81 if (TheFalseVal) return TheFalseVal;
82 return CreateTrueFalseVals(false);
85 /// Return a ConstantInt with the specified value for the specified type. The
86 /// value V will be canonicalized to a uint64_t but accessing it with either
87 /// getSExtValue() or getZExtValue() (ConstantInt) will yield the correct
88 /// sized/signed value for the type Ty.
89 /// @brief Get a ConstantInt for a specific value.
90 static ConstantInt *get(const Type *Ty, int64_t V);
92 /// getType - Specialize the getType() method to always return an IntegerType,
93 /// which reduces the amount of casting needed in parts of the compiler.
95 inline const IntegerType *getType() const {
96 return reinterpret_cast<const IntegerType*>(Value::getType());
99 /// This static method returns true if the type Ty is big enough to
100 /// represent the value V. This can be used to avoid having the get method
101 /// assert when V is larger than Ty can represent. Note that there are two
102 /// versions of this method, one for unsigned and one for signed integers.
103 /// Although ConstantInt canonicalizes everything to an unsigned integer,
104 /// the signed version avoids callers having to convert a signed quantity
105 /// to the appropriate unsigned type before calling the method.
106 /// @returns true if V is a valid value for type Ty
107 /// @brief Determine if the value is in range for the given type.
108 static bool isValueValidForType(const Type *Ty, uint64_t V);
109 static bool isValueValidForType(const Type *Ty, int64_t V);
111 /// This function will return true iff this constant represents the "null"
112 /// value that would be returned by the getNullValue method.
113 /// @returns true if this is the null integer value.
114 /// @brief Determine if the value is null.
115 virtual bool isNullValue() const {
119 /// This function will return true iff every bit in this constant is set
121 /// @returns true iff this constant's bits are all set to true.
122 /// @brief Determine if the value is all ones.
123 bool isAllOnesValue() const {
124 return getSExtValue() == -1;
127 /// This function will return true iff this constant represents the largest
128 /// value that may be represented by the constant's type.
129 /// @returns true iff this is the largest value that may be represented
131 /// @brief Determine if the value is maximal.
132 bool isMaxValue(bool isSigned) const {
134 int64_t V = getSExtValue();
135 if (V < 0) return false; // Be careful about wrap-around on 'long's
137 return !isValueValidForType(Value::getType(), V) || V < 0;
139 return isAllOnesValue();
142 /// This function will return true iff this constant represents the smallest
143 /// value that may be represented by this constant's type.
144 /// @returns true if this is the smallest value that may be represented by
146 /// @brief Determine if the value is minimal.
147 bool isMinValue(bool isSigned) const {
149 int64_t V = getSExtValue();
150 if (V > 0) return false; // Be careful about wrap-around on 'long's
152 return !isValueValidForType(Value::getType(), V) || V > 0;
154 return getZExtValue() == 0;
157 /// @returns the value for an integer constant of the given type that has all
158 /// its bits set to true.
159 /// @brief Get the all ones value
160 static ConstantInt *getAllOnesValue(const Type *Ty);
162 /// @brief Methods to support type inquiry through isa, cast, and dyn_cast.
163 static inline bool classof(const ConstantInt *) { return true; }
164 static bool classof(const Value *V) {
165 return V->getValueType() == ConstantIntVal;
167 static void ResetTrueFalse() { TheTrueVal = TheFalseVal = 0; }
169 static ConstantInt *CreateTrueFalseVals(bool WhichOne);
173 //===----------------------------------------------------------------------===//
174 /// ConstantFP - Floating Point Values [float, double]
176 class ConstantFP : public Constant {
178 friend struct ConstantCreator<ConstantFP, Type, uint64_t>;
179 friend struct ConstantCreator<ConstantFP, Type, uint32_t>;
180 ConstantFP(const ConstantFP &); // DO NOT IMPLEMENT
182 ConstantFP(const Type *Ty, double V);
184 /// get() - Static factory methods - Return objects of the specified value
185 static ConstantFP *get(const Type *Ty, double V);
187 /// isValueValidForType - return true if Ty is big enough to represent V.
188 static bool isValueValidForType(const Type *Ty, double V);
189 inline double getValue() const { return Val; }
191 /// isNullValue - Return true if this is the value that would be returned by
192 /// getNullValue. Don't depend on == for doubles to tell us it's zero, it
193 /// considers -0.0 to be null as well as 0.0. :(
194 virtual bool isNullValue() const;
196 /// isExactlyValue - We don't rely on operator== working on double values, as
197 /// it returns true for things that are clearly not equal, like -0.0 and 0.0.
198 /// As such, this method can be used to do an exact bit-for-bit comparison of
199 /// two floating point values.
200 bool isExactlyValue(double V) const;
202 /// Methods for support type inquiry through isa, cast, and dyn_cast:
203 static inline bool classof(const ConstantFP *) { return true; }
204 static bool classof(const Value *V) {
205 return V->getValueType() == ConstantFPVal;
209 //===----------------------------------------------------------------------===//
210 /// ConstantAggregateZero - All zero aggregate value
212 class ConstantAggregateZero : public Constant {
213 friend struct ConstantCreator<ConstantAggregateZero, Type, char>;
214 ConstantAggregateZero(const ConstantAggregateZero &); // DO NOT IMPLEMENT
216 ConstantAggregateZero(const Type *Ty)
217 : Constant(Ty, ConstantAggregateZeroVal, 0, 0) {}
219 /// get() - static factory method for creating a null aggregate. It is
220 /// illegal to call this method with a non-aggregate type.
221 static Constant *get(const Type *Ty);
223 /// isNullValue - Return true if this is the value that would be returned by
225 virtual bool isNullValue() const { return true; }
227 virtual void destroyConstant();
229 /// Methods for support type inquiry through isa, cast, and dyn_cast:
231 static bool classof(const ConstantAggregateZero *) { return true; }
232 static bool classof(const Value *V) {
233 return V->getValueType() == ConstantAggregateZeroVal;
238 //===----------------------------------------------------------------------===//
239 /// ConstantArray - Constant Array Declarations
241 class ConstantArray : public Constant {
242 friend struct ConstantCreator<ConstantArray, ArrayType,
243 std::vector<Constant*> >;
244 ConstantArray(const ConstantArray &); // DO NOT IMPLEMENT
246 ConstantArray(const ArrayType *T, const std::vector<Constant*> &Val);
249 /// get() - Static factory methods - Return objects of the specified value
250 static Constant *get(const ArrayType *T, const std::vector<Constant*> &);
251 static Constant *get(const ArrayType *T,
252 Constant*const*Vals, unsigned NumVals) {
253 // FIXME: make this the primary ctor method.
254 return get(T, std::vector<Constant*>(Vals, Vals+NumVals));
257 /// This method constructs a ConstantArray and initializes it with a text
258 /// string. The default behavior (AddNull==true) causes a null terminator to
259 /// be placed at the end of the array. This effectively increases the length
260 /// of the array by one (you've been warned). However, in some situations
261 /// this is not desired so if AddNull==false then the string is copied without
262 /// null termination.
263 static Constant *get(const std::string &Initializer, bool AddNull = true);
265 /// getType - Specialize the getType() method to always return an ArrayType,
266 /// which reduces the amount of casting needed in parts of the compiler.
268 inline const ArrayType *getType() const {
269 return reinterpret_cast<const ArrayType*>(Value::getType());
272 /// isString - This method returns true if the array is an array of sbyte or
273 /// ubyte, and if the elements of the array are all ConstantInt's.
274 bool isString() const;
276 /// isCString - This method returns true if the array is a string (see
277 /// isString) and it ends in a null byte \0 and does not contains any other
278 /// null bytes except its terminator.
279 bool isCString() const;
281 /// getAsString - If this array is isString(), then this method converts the
282 /// array to an std::string and returns it. Otherwise, it asserts out.
284 std::string getAsString() const;
286 /// isNullValue - Return true if this is the value that would be returned by
287 /// getNullValue. This always returns false because zero arrays are always
288 /// created as ConstantAggregateZero objects.
289 virtual bool isNullValue() const { return false; }
291 virtual void destroyConstant();
292 virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
294 /// Methods for support type inquiry through isa, cast, and dyn_cast:
295 static inline bool classof(const ConstantArray *) { return true; }
296 static bool classof(const Value *V) {
297 return V->getValueType() == ConstantArrayVal;
302 //===----------------------------------------------------------------------===//
303 // ConstantStruct - Constant Struct Declarations
305 class ConstantStruct : public Constant {
306 friend struct ConstantCreator<ConstantStruct, StructType,
307 std::vector<Constant*> >;
308 ConstantStruct(const ConstantStruct &); // DO NOT IMPLEMENT
310 ConstantStruct(const StructType *T, const std::vector<Constant*> &Val);
313 /// get() - Static factory methods - Return objects of the specified value
315 static Constant *get(const StructType *T, const std::vector<Constant*> &V);
316 static Constant *get(const std::vector<Constant*> &V, bool Packed = false);
317 static Constant *get(Constant*const* Vals, unsigned NumVals,
318 bool Packed = false) {
319 // FIXME: make this the primary ctor method.
320 return get(std::vector<Constant*>(Vals, Vals+NumVals), Packed);
323 /// getType() specialization - Reduce amount of casting...
325 inline const StructType *getType() const {
326 return reinterpret_cast<const StructType*>(Value::getType());
329 /// isNullValue - Return true if this is the value that would be returned by
330 /// getNullValue. This always returns false because zero structs are always
331 /// created as ConstantAggregateZero objects.
332 virtual bool isNullValue() const {
336 virtual void destroyConstant();
337 virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
339 /// Methods for support type inquiry through isa, cast, and dyn_cast:
340 static inline bool classof(const ConstantStruct *) { return true; }
341 static bool classof(const Value *V) {
342 return V->getValueType() == ConstantStructVal;
346 //===----------------------------------------------------------------------===//
347 /// ConstantVector - Constant Vector Declarations
349 class ConstantVector : public Constant {
350 friend struct ConstantCreator<ConstantVector, VectorType,
351 std::vector<Constant*> >;
352 ConstantVector(const ConstantVector &); // DO NOT IMPLEMENT
354 ConstantVector(const VectorType *T, const std::vector<Constant*> &Val);
357 /// get() - Static factory methods - Return objects of the specified value
358 static Constant *get(const VectorType *T, const std::vector<Constant*> &);
359 static Constant *get(const std::vector<Constant*> &V);
360 static Constant *get(Constant*const* Vals, unsigned NumVals) {
361 // FIXME: make this the primary ctor method.
362 return get(std::vector<Constant*>(Vals, Vals+NumVals));
365 /// getType - Specialize the getType() method to always return an VectorType,
366 /// which reduces the amount of casting needed in parts of the compiler.
368 inline const VectorType *getType() const {
369 return reinterpret_cast<const VectorType*>(Value::getType());
372 /// @returns the value for an packed integer constant of the given type that
373 /// has all its bits set to true.
374 /// @brief Get the all ones value
375 static ConstantVector *getAllOnesValue(const VectorType *Ty);
377 /// isNullValue - Return true if this is the value that would be returned by
378 /// getNullValue. This always returns false because zero arrays are always
379 /// created as ConstantAggregateZero objects.
380 virtual bool isNullValue() const { return false; }
382 /// This function will return true iff every element in this packed constant
383 /// is set to all ones.
384 /// @returns true iff this constant's emements are all set to all ones.
385 /// @brief Determine if the value is all ones.
386 bool isAllOnesValue() const;
388 virtual void destroyConstant();
389 virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
391 /// Methods for support type inquiry through isa, cast, and dyn_cast:
392 static inline bool classof(const ConstantVector *) { return true; }
393 static bool classof(const Value *V) {
394 return V->getValueType() == ConstantVectorVal;
398 //===----------------------------------------------------------------------===//
399 /// ConstantPointerNull - a constant pointer value that points to null
401 class ConstantPointerNull : public Constant {
402 friend struct ConstantCreator<ConstantPointerNull, PointerType, char>;
403 ConstantPointerNull(const ConstantPointerNull &); // DO NOT IMPLEMENT
405 ConstantPointerNull(const PointerType *T)
406 : Constant(reinterpret_cast<const Type*>(T),
407 Value::ConstantPointerNullVal, 0, 0) {}
411 /// get() - Static factory methods - Return objects of the specified value
412 static ConstantPointerNull *get(const PointerType *T);
414 /// isNullValue - Return true if this is the value that would be returned by
416 virtual bool isNullValue() const { return true; }
418 virtual void destroyConstant();
420 /// getType - Specialize the getType() method to always return an PointerType,
421 /// which reduces the amount of casting needed in parts of the compiler.
423 inline const PointerType *getType() const {
424 return reinterpret_cast<const PointerType*>(Value::getType());
427 /// Methods for support type inquiry through isa, cast, and dyn_cast:
428 static inline bool classof(const ConstantPointerNull *) { return true; }
429 static bool classof(const Value *V) {
430 return V->getValueType() == ConstantPointerNullVal;
435 /// ConstantExpr - a constant value that is initialized with an expression using
436 /// other constant values.
438 /// This class uses the standard Instruction opcodes to define the various
439 /// constant expressions. The Opcode field for the ConstantExpr class is
440 /// maintained in the Value::SubclassData field.
441 class ConstantExpr : public Constant {
442 friend struct ConstantCreator<ConstantExpr,Type,
443 std::pair<unsigned, std::vector<Constant*> > >;
444 friend struct ConvertConstantType<ConstantExpr, Type>;
447 ConstantExpr(const Type *Ty, unsigned Opcode, Use *Ops, unsigned NumOps)
448 : Constant(Ty, ConstantExprVal, Ops, NumOps) {
449 // Operation type (an Instruction opcode) is stored as the SubclassData.
450 SubclassData = Opcode;
453 // These private methods are used by the type resolution code to create
454 // ConstantExprs in intermediate forms.
455 static Constant *getTy(const Type *Ty, unsigned Opcode,
456 Constant *C1, Constant *C2);
457 static Constant *getCompareTy(unsigned short pred, Constant *C1,
459 static Constant *getSelectTy(const Type *Ty,
460 Constant *C1, Constant *C2, Constant *C3);
461 static Constant *getGetElementPtrTy(const Type *Ty, Constant *C,
462 Value* const *Idxs, unsigned NumIdxs);
463 static Constant *getExtractElementTy(const Type *Ty, Constant *Val,
465 static Constant *getInsertElementTy(const Type *Ty, Constant *Val,
466 Constant *Elt, Constant *Idx);
467 static Constant *getShuffleVectorTy(const Type *Ty, Constant *V1,
468 Constant *V2, Constant *Mask);
471 // Static methods to construct a ConstantExpr of different kinds. Note that
472 // these methods may return a object that is not an instance of the
473 // ConstantExpr class, because they will attempt to fold the constant
474 // expression into something simpler if possible.
476 /// Cast constant expr
478 static Constant *getTrunc (Constant *C, const Type *Ty);
479 static Constant *getSExt (Constant *C, const Type *Ty);
480 static Constant *getZExt (Constant *C, const Type *Ty);
481 static Constant *getFPTrunc (Constant *C, const Type *Ty);
482 static Constant *getFPExtend(Constant *C, const Type *Ty);
483 static Constant *getUIToFP (Constant *C, const Type *Ty);
484 static Constant *getSIToFP (Constant *C, const Type *Ty);
485 static Constant *getFPToUI (Constant *C, const Type *Ty);
486 static Constant *getFPToSI (Constant *C, const Type *Ty);
487 static Constant *getPtrToInt(Constant *C, const Type *Ty);
488 static Constant *getIntToPtr(Constant *C, const Type *Ty);
489 static Constant *getBitCast (Constant *C, const Type *Ty);
491 // @brief Convenience function for getting one of the casting operations
492 // using a CastOps opcode.
493 static Constant *getCast(
494 unsigned ops, ///< The opcode for the conversion
495 Constant *C, ///< The constant to be converted
496 const Type *Ty ///< The type to which the constant is converted
499 // @brief Create a ZExt or BitCast cast constant expression
500 static Constant *getZExtOrBitCast(
501 Constant *C, ///< The constant to zext or bitcast
502 const Type *Ty ///< The type to zext or bitcast C to
505 // @brief Create a SExt or BitCast cast constant expression
506 static Constant *getSExtOrBitCast(
507 Constant *C, ///< The constant to sext or bitcast
508 const Type *Ty ///< The type to sext or bitcast C to
511 // @brief Create a Trunc or BitCast cast constant expression
512 static Constant *getTruncOrBitCast(
513 Constant *C, ///< The constant to trunc or bitcast
514 const Type *Ty ///< The type to trunc or bitcast C to
517 /// @brief Create a BitCast or a PtrToInt cast constant expression
518 static Constant *getPointerCast(
519 Constant *C, ///< The pointer value to be casted (operand 0)
520 const Type *Ty ///< The type to which cast should be made
523 /// @brief Create a ZExt, Bitcast or Trunc for integer -> integer casts
524 static Constant *getIntegerCast(
525 Constant *C, ///< The integer constant to be casted
526 const Type *Ty, ///< The integer type to cast to
527 bool isSigned ///< Whether C should be treated as signed or not
530 /// @brief Create a FPExt, Bitcast or FPTrunc for fp -> fp casts
531 static Constant *getFPCast(
532 Constant *C, ///< The integer constant to be casted
533 const Type *Ty ///< The integer type to cast to
536 /// @brief Return true if this is a convert constant expression
539 /// @brief Return true if this is a compare constant expression
540 bool isCompare() const;
542 /// Select constant expr
544 static Constant *getSelect(Constant *C, Constant *V1, Constant *V2) {
545 return getSelectTy(V1->getType(), C, V1, V2);
548 /// getSizeOf constant expr - computes the size of a type in a target
549 /// independent way (Note: the return type is a ULong).
551 static Constant *getSizeOf(const Type *Ty);
553 /// ConstantExpr::get - Return a binary or shift operator constant expression,
554 /// folding if possible.
556 static Constant *get(unsigned Opcode, Constant *C1, Constant *C2);
558 /// @brief Return an ICmp or FCmp comparison operator constant expression.
559 static Constant *getCompare(unsigned short pred, Constant *C1, Constant *C2);
561 /// ConstantExpr::get* - Return some common constants without having to
562 /// specify the full Instruction::OPCODE identifier.
564 static Constant *getNeg(Constant *C);
565 static Constant *getNot(Constant *C);
566 static Constant *getAdd(Constant *C1, Constant *C2);
567 static Constant *getSub(Constant *C1, Constant *C2);
568 static Constant *getMul(Constant *C1, Constant *C2);
569 static Constant *getUDiv(Constant *C1, Constant *C2);
570 static Constant *getSDiv(Constant *C1, Constant *C2);
571 static Constant *getFDiv(Constant *C1, Constant *C2);
572 static Constant *getURem(Constant *C1, Constant *C2); // unsigned rem
573 static Constant *getSRem(Constant *C1, Constant *C2); // signed rem
574 static Constant *getFRem(Constant *C1, Constant *C2);
575 static Constant *getAnd(Constant *C1, Constant *C2);
576 static Constant *getOr(Constant *C1, Constant *C2);
577 static Constant *getXor(Constant *C1, Constant *C2);
578 static Constant* getICmp(unsigned short pred, Constant* LHS, Constant* RHS);
579 static Constant* getFCmp(unsigned short pred, Constant* LHS, Constant* RHS);
580 static Constant *getShl(Constant *C1, Constant *C2);
581 static Constant *getLShr(Constant *C1, Constant *C2);
582 static Constant *getAShr(Constant *C1, Constant *C2);
584 /// Getelementptr form. std::vector<Value*> is only accepted for convenience:
585 /// all elements must be Constant's.
587 static Constant *getGetElementPtr(Constant *C,
588 Constant* const *IdxList, unsigned NumIdx);
589 static Constant *getGetElementPtr(Constant *C,
590 Value* const *IdxList, unsigned NumIdx);
592 static Constant *getExtractElement(Constant *Vec, Constant *Idx);
593 static Constant *getInsertElement(Constant *Vec, Constant *Elt,Constant *Idx);
594 static Constant *getShuffleVector(Constant *V1, Constant *V2, Constant *Mask);
596 /// Floating point negation must be implemented with f(x) = -0.0 - x. This
597 /// method returns the negative zero constant for floating point or packed
598 /// floating point types; for all other types, it returns the null value.
599 static Constant *getZeroValueForNegationExpr(const Type *Ty);
601 /// isNullValue - Return true if this is the value that would be returned by
603 virtual bool isNullValue() const { return false; }
605 /// getOpcode - Return the opcode at the root of this constant expression
606 unsigned getOpcode() const { return SubclassData; }
608 /// getPredicate - Return the ICMP or FCMP predicate value. Assert if this is
609 /// not an ICMP or FCMP constant expression.
610 unsigned getPredicate() const;
612 /// getOpcodeName - Return a string representation for an opcode.
613 const char *getOpcodeName() const;
615 /// getWithOperandReplaced - Return a constant expression identical to this
616 /// one, but with the specified operand set to the specified value.
617 Constant *getWithOperandReplaced(unsigned OpNo, Constant *Op) const;
619 /// getWithOperands - This returns the current constant expression with the
620 /// operands replaced with the specified values. The specified operands must
621 /// match count and type with the existing ones.
622 Constant *getWithOperands(const std::vector<Constant*> &Ops) const;
624 virtual void destroyConstant();
625 virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
627 /// Override methods to provide more type information...
628 inline Constant *getOperand(unsigned i) {
629 return cast<Constant>(User::getOperand(i));
631 inline Constant *getOperand(unsigned i) const {
632 return const_cast<Constant*>(cast<Constant>(User::getOperand(i)));
636 /// Methods for support type inquiry through isa, cast, and dyn_cast:
637 static inline bool classof(const ConstantExpr *) { return true; }
638 static inline bool classof(const Value *V) {
639 return V->getValueType() == ConstantExprVal;
644 //===----------------------------------------------------------------------===//
645 /// UndefValue - 'undef' values are things that do not have specified contents.
646 /// These are used for a variety of purposes, including global variable
647 /// initializers and operands to instructions. 'undef' values can occur with
650 class UndefValue : public Constant {
651 friend struct ConstantCreator<UndefValue, Type, char>;
652 UndefValue(const UndefValue &); // DO NOT IMPLEMENT
654 UndefValue(const Type *T) : Constant(T, UndefValueVal, 0, 0) {}
656 /// get() - Static factory methods - Return an 'undef' object of the specified
659 static UndefValue *get(const Type *T);
661 /// isNullValue - Return true if this is the value that would be returned by
663 virtual bool isNullValue() const { return false; }
665 virtual void destroyConstant();
667 /// Methods for support type inquiry through isa, cast, and dyn_cast:
668 static inline bool classof(const UndefValue *) { return true; }
669 static bool classof(const Value *V) {
670 return V->getValueType() == UndefValueVal;
674 } // End llvm namespace