0b3784f0d6d703007b91c754fa3c01f50445ead5
[oota-llvm.git] / include / llvm / Constants.h
1 //===-- llvm/Constants.h - Constant class subclass definitions --*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
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.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains the declarations for the subclasses of Constant, which
11 // represent the different flavors of constant values that live in LLVM.  Note
12 // that Constants are immutable (once created they never change) and are fully
13 // 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.
17 //
18 //===----------------------------------------------------------------------===//
19
20 #ifndef LLVM_CONSTANTS_H
21 #define LLVM_CONSTANTS_H
22
23 #include "llvm/Constant.h"
24 #include "llvm/Type.h"
25 #include "llvm/Support/DataTypes.h"
26
27 namespace llvm {
28
29 class ArrayType;
30 class StructType;
31 class PointerType;
32 class PackedType;
33
34 template<class ConstantClass, class TypeClass, class ValType>
35 struct ConstantCreator;
36 template<class ConstantClass, class TypeClass>
37 struct ConvertConstantType;
38
39 //===----------------------------------------------------------------------===//
40 /// ConstantIntegral - Shared superclass of boolean and integer constants.
41 ///
42 /// This class just defines some common interfaces to be implemented.
43 ///
44 class ConstantIntegral : public Constant {
45 protected:
46   union {
47     int64_t  Signed;
48     uint64_t Unsigned;
49   } Val;
50   ConstantIntegral(const Type *Ty, ValueTy VT, uint64_t V);
51 public:
52
53   /// getRawValue - return the underlying value of this constant as a 64-bit
54   /// unsigned integer value.
55   ///
56   inline uint64_t getRawValue() const { return Val.Unsigned; }
57   
58   /// getZExtValue - Return the constant zero extended as appropriate for this
59   /// type.
60   inline uint64_t getZExtValue() const {
61     unsigned Size = getType()->getPrimitiveSizeInBits();
62     return Val.Unsigned & (~0ULL >> (64-Size));
63   }
64
65   /// getSExtValue - Return the constant sign extended as appropriate for this
66   /// type.
67   inline int64_t getSExtValue() const {
68     unsigned Size = getType()->getPrimitiveSizeInBits();
69     return (Val.Signed << (64-Size)) >> (64-Size);
70   }
71   
72   /// isNullValue - Return true if this is the value that would be returned by
73   /// getNullValue.
74   ///
75   virtual bool isNullValue() const = 0;
76
77   /// isMaxValue - Return true if this is the largest value that may be
78   /// represented by this type.
79   ///
80   virtual bool isMaxValue() const = 0;
81
82   /// isMinValue - Return true if this is the smallest value that may be
83   /// represented by this type.
84   ///
85   virtual bool isMinValue() const = 0;
86
87   /// isAllOnesValue - Return true if every bit in this constant is set to true.
88   ///
89   virtual bool isAllOnesValue() const = 0;
90
91   /// Static constructor to get the maximum/minimum/allones constant of
92   /// specified (integral) type...
93   ///
94   static ConstantIntegral *getMaxValue(const Type *Ty);
95   static ConstantIntegral *getMinValue(const Type *Ty);
96   static ConstantIntegral *getAllOnesValue(const Type *Ty);
97
98   /// Methods for support type inquiry through isa, cast, and dyn_cast:
99   static inline bool classof(const ConstantIntegral *) { return true; }
100   static bool classof(const Value *V) {
101     return V->getValueType() == ConstantBoolVal ||
102            V->getValueType() == ConstantSIntVal ||
103            V->getValueType() == ConstantUIntVal;
104   }
105 };
106
107
108 //===----------------------------------------------------------------------===//
109 /// ConstantBool - Boolean Values
110 ///
111 class ConstantBool : public ConstantIntegral {
112   ConstantBool(bool V);
113 public:
114   static ConstantBool *True, *False;  // The True & False values
115
116   /// get() - Static factory methods - Return objects of the specified value
117   static ConstantBool *get(bool Value) { return Value ? True : False; }
118   static ConstantBool *get(const Type *Ty, bool Value) { return get(Value); }
119
120   /// inverted - Return the opposite value of the current value.
121   inline ConstantBool *inverted() const { return (this==True) ? False : True; }
122
123   /// getValue - return the boolean value of this constant.
124   ///
125   inline bool getValue() const { return static_cast<bool>(getRawValue()); }
126
127   /// isNullValue - Return true if this is the value that would be returned by
128   /// getNullValue.
129   ///
130   virtual bool isNullValue() const { return this == False; }
131   virtual bool isMaxValue() const { return this == True; }
132   virtual bool isMinValue() const { return this == False; }
133   virtual bool isAllOnesValue() const { return this == True; }
134
135   /// Methods for support type inquiry through isa, cast, and dyn_cast:
136   static inline bool classof(const ConstantBool *) { return true; }
137   static bool classof(const Value *V) {
138     return V->getValueType() == ConstantBoolVal;
139   }
140 };
141
142
143 //===----------------------------------------------------------------------===//
144 /// ConstantInt - Superclass of ConstantSInt & ConstantUInt, to make dealing
145 /// with integral constants easier.
146 ///
147 class ConstantInt : public ConstantIntegral {
148 protected:
149   ConstantInt(const ConstantInt &);      // DO NOT IMPLEMENT
150   ConstantInt(const Type *Ty, ValueTy VT, uint64_t V);
151 public:
152   /// equalsInt - Provide a helper method that can be used to determine if the
153   /// constant contained within is equal to a constant.  This only works for
154   /// very small values, because this is all that can be represented with all
155   /// types.
156   ///
157   bool equalsInt(unsigned char V) const {
158     assert(V <= 127 &&
159            "equalsInt: Can only be used with very small positive constants!");
160     return Val.Unsigned == V;
161   }
162
163   /// ConstantInt::get static method: return a ConstantInt with the specified
164   /// value.  as above, we work only with very small values here.
165   ///
166   static ConstantInt *get(const Type *Ty, unsigned char V);
167
168   /// isNullValue - Return true if this is the value that would be returned by
169   /// getNullValue.
170   virtual bool isNullValue() const { return Val.Unsigned == 0; }
171   virtual bool isMaxValue() const = 0;
172   virtual bool isMinValue() const = 0;
173
174   /// Methods for support type inquiry through isa, cast, and dyn_cast:
175   static inline bool classof(const ConstantInt *) { return true; }
176   static bool classof(const Value *V) {
177     return V->getValueType() == ConstantSIntVal ||
178            V->getValueType() == ConstantUIntVal;
179   }
180 };
181
182
183 //===----------------------------------------------------------------------===//
184 /// ConstantSInt - Signed Integer Values [sbyte, short, int, long]
185 ///
186 class ConstantSInt : public ConstantInt {
187   ConstantSInt(const ConstantSInt &);      // DO NOT IMPLEMENT
188   friend struct ConstantCreator<ConstantSInt, Type, int64_t>;
189
190 protected:
191   ConstantSInt(const Type *Ty, int64_t V);
192 public:
193   /// get() - Static factory methods - Return objects of the specified value
194   ///
195   static ConstantSInt *get(const Type *Ty, int64_t V);
196
197   /// isValueValidForType - return true if Ty is big enough to represent V.
198   ///
199   static bool isValueValidForType(const Type *Ty, int64_t V);
200
201   /// getValue - return the underlying value of this constant.
202   ///
203   inline int64_t getValue() const { return Val.Signed; }
204
205   virtual bool isAllOnesValue() const { return getValue() == -1; }
206
207   /// isMaxValue - Return true if this is the largest value that may be
208   /// represented by this type.
209   ///
210   virtual bool isMaxValue() const {
211     int64_t V = getValue();
212     if (V < 0) return false;    // Be careful about wrap-around on 'long's
213     ++V;
214     return !isValueValidForType(getType(), V) || V < 0;
215   }
216
217   /// isMinValue - Return true if this is the smallest value that may be
218   /// represented by this type.
219   ///
220   virtual bool isMinValue() const {
221     int64_t V = getValue();
222     if (V > 0) return false;    // Be careful about wrap-around on 'long's
223     --V;
224     return !isValueValidForType(getType(), V) || V > 0;
225   }
226
227   /// Methods for support type inquiry through isa, cast, and dyn_cast:
228   ///
229   static inline bool classof(const ConstantSInt *) { return true; }
230   static bool classof(const Value *V) {
231     return V->getValueType() == ConstantSIntVal;
232   }
233 };
234
235 //===----------------------------------------------------------------------===//
236 /// ConstantUInt - Unsigned Integer Values [ubyte, ushort, uint, ulong]
237 ///
238 class ConstantUInt : public ConstantInt {
239   ConstantUInt(const ConstantUInt &);      // DO NOT IMPLEMENT
240   friend struct ConstantCreator<ConstantUInt, Type, uint64_t>;
241 protected:
242   ConstantUInt(const Type *Ty, uint64_t V);
243 public:
244   /// get() - Static factory methods - Return objects of the specified value
245   ///
246   static ConstantUInt *get(const Type *Ty, uint64_t V);
247
248   /// isValueValidForType - return true if Ty is big enough to represent V.
249   ///
250   static bool isValueValidForType(const Type *Ty, uint64_t V);
251
252   /// getValue - return the underlying value of this constant.
253   ///
254   inline uint64_t getValue() const { return Val.Unsigned; }
255
256   /// isMaxValue - Return true if this is the largest value that may be
257   /// represented by this type.
258   ///
259   virtual bool isAllOnesValue() const;
260   virtual bool isMaxValue() const { return isAllOnesValue(); }
261   virtual bool isMinValue() const { return getValue() == 0; }
262
263   /// Methods for support type inquiry through isa, cast, and dyn_cast:
264   static inline bool classof(const ConstantUInt *) { return true; }
265   static bool classof(const Value *V) {
266     return V->getValueType() == ConstantUIntVal;
267   }
268 };
269
270
271 //===----------------------------------------------------------------------===//
272 /// ConstantFP - Floating Point Values [float, double]
273 ///
274 class ConstantFP : public Constant {
275   double Val;
276   friend struct ConstantCreator<ConstantFP, Type, uint64_t>;
277   friend struct ConstantCreator<ConstantFP, Type, uint32_t>;
278   ConstantFP(const ConstantFP &);      // DO NOT IMPLEMENT
279 protected:
280   ConstantFP(const Type *Ty, double V);
281 public:
282   /// get() - Static factory methods - Return objects of the specified value
283   static ConstantFP *get(const Type *Ty, double V);
284
285   /// isValueValidForType - return true if Ty is big enough to represent V.
286   static bool isValueValidForType(const Type *Ty, double V);
287   inline double getValue() const { return Val; }
288
289   /// isNullValue - Return true if this is the value that would be returned by
290   /// getNullValue.  Don't depend on == for doubles to tell us it's zero, it
291   /// considers -0.0 to be null as well as 0.0.  :(
292   virtual bool isNullValue() const;
293
294   /// isExactlyValue - We don't rely on operator== working on double values, as
295   /// it returns true for things that are clearly not equal, like -0.0 and 0.0.
296   /// As such, this method can be used to do an exact bit-for-bit comparison of
297   /// two floating point values.
298   bool isExactlyValue(double V) const;
299
300   /// Methods for support type inquiry through isa, cast, and dyn_cast:
301   static inline bool classof(const ConstantFP *) { return true; }
302   static bool classof(const Value *V) {
303     return V->getValueType() == ConstantFPVal;
304   }
305 };
306
307 //===----------------------------------------------------------------------===//
308 /// ConstantAggregateZero - All zero aggregate value
309 ///
310 class ConstantAggregateZero : public Constant {
311   friend struct ConstantCreator<ConstantAggregateZero, Type, char>;
312   ConstantAggregateZero(const ConstantAggregateZero &);      // DO NOT IMPLEMENT
313 protected:
314   ConstantAggregateZero(const Type *Ty)
315     : Constant(Ty, ConstantAggregateZeroVal, 0, 0) {}
316 public:
317   /// get() - static factory method for creating a null aggregate.  It is
318   /// illegal to call this method with a non-aggregate type.
319   static Constant *get(const Type *Ty);
320
321   /// isNullValue - Return true if this is the value that would be returned by
322   /// getNullValue.
323   virtual bool isNullValue() const { return true; }
324
325   virtual void destroyConstant();
326   virtual void replaceUsesOfWithOnConstant(Value *From, Value *To,
327                                            bool DisableChecking = false);
328
329   /// Methods for support type inquiry through isa, cast, and dyn_cast:
330   ///
331   static bool classof(const ConstantAggregateZero *) { return true; }
332   static bool classof(const Value *V) {
333     return V->getValueType() == ConstantAggregateZeroVal;
334   }
335 };
336
337
338 //===----------------------------------------------------------------------===//
339 /// ConstantArray - Constant Array Declarations
340 ///
341 class ConstantArray : public Constant {
342   friend struct ConstantCreator<ConstantArray, ArrayType,
343                                     std::vector<Constant*> >;
344   ConstantArray(const ConstantArray &);      // DO NOT IMPLEMENT
345 protected:
346   ConstantArray(const ArrayType *T, const std::vector<Constant*> &Val);
347   ~ConstantArray();
348 public:
349   /// get() - Static factory methods - Return objects of the specified value
350   static Constant *get(const ArrayType *T, const std::vector<Constant*> &);
351   static Constant *get(const std::string &Initializer);
352
353   /// getType - Specialize the getType() method to always return an ArrayType,
354   /// which reduces the amount of casting needed in parts of the compiler.
355   ///
356   inline const ArrayType *getType() const {
357     return reinterpret_cast<const ArrayType*>(Value::getType());
358   }
359
360   /// isString - This method returns true if the array is an array of sbyte or
361   /// ubyte, and if the elements of the array are all ConstantInt's.
362   bool isString() const;
363
364   /// getAsString - If this array is isString(), then this method converts the
365   /// array to an std::string and returns it.  Otherwise, it asserts out.
366   ///
367   std::string getAsString() const;
368
369   /// isNullValue - Return true if this is the value that would be returned by
370   /// getNullValue.  This always returns false because zero arrays are always
371   /// created as ConstantAggregateZero objects.
372   virtual bool isNullValue() const { return false; }
373
374   virtual void destroyConstant();
375   virtual void replaceUsesOfWithOnConstant(Value *From, Value *To,
376                                            bool DisableChecking = false);
377
378   /// Methods for support type inquiry through isa, cast, and dyn_cast:
379   static inline bool classof(const ConstantArray *) { return true; }
380   static bool classof(const Value *V) {
381     return V->getValueType() == ConstantArrayVal;
382   }
383 };
384
385
386 //===----------------------------------------------------------------------===//
387 // ConstantStruct - Constant Struct Declarations
388 //
389 class ConstantStruct : public Constant {
390   friend struct ConstantCreator<ConstantStruct, StructType,
391                                     std::vector<Constant*> >;
392   ConstantStruct(const ConstantStruct &);      // DO NOT IMPLEMENT
393 protected:
394   ConstantStruct(const StructType *T, const std::vector<Constant*> &Val);
395   ~ConstantStruct();
396 public:
397   /// get() - Static factory methods - Return objects of the specified value
398   ///
399   static Constant *get(const StructType *T, const std::vector<Constant*> &V);
400   static Constant *get(const std::vector<Constant*> &V);
401
402   /// getType() specialization - Reduce amount of casting...
403   ///
404   inline const StructType *getType() const {
405     return reinterpret_cast<const StructType*>(Value::getType());
406   }
407
408   /// isNullValue - Return true if this is the value that would be returned by
409   /// getNullValue.  This always returns false because zero structs are always
410   /// created as ConstantAggregateZero objects.
411   virtual bool isNullValue() const {
412     return false;
413   }
414
415   virtual void destroyConstant();
416   virtual void replaceUsesOfWithOnConstant(Value *From, Value *To,
417                                            bool DisableChecking = false);
418
419   /// Methods for support type inquiry through isa, cast, and dyn_cast:
420   static inline bool classof(const ConstantStruct *) { return true; }
421   static bool classof(const Value *V) {
422     return V->getValueType() == ConstantStructVal;
423   }
424 };
425
426 //===----------------------------------------------------------------------===//
427 /// ConstantPacked - Constant Packed Declarations
428 ///
429 class ConstantPacked : public Constant {
430   friend struct ConstantCreator<ConstantPacked, PackedType,
431                                     std::vector<Constant*> >;
432   ConstantPacked(const ConstantPacked &);      // DO NOT IMPLEMENT
433 protected:
434   ConstantPacked(const PackedType *T, const std::vector<Constant*> &Val);
435   ~ConstantPacked();
436 public:
437   /// get() - Static factory methods - Return objects of the specified value
438   static Constant *get(const PackedType *T, const std::vector<Constant*> &);
439   static Constant *get(const std::vector<Constant*> &V);
440
441   /// getType - Specialize the getType() method to always return an PackedType,
442   /// which reduces the amount of casting needed in parts of the compiler.
443   ///
444   inline const PackedType *getType() const {
445     return reinterpret_cast<const PackedType*>(Value::getType());
446   }
447
448   /// isNullValue - Return true if this is the value that would be returned by
449   /// getNullValue.  This always returns false because zero arrays are always
450   /// created as ConstantAggregateZero objects.
451   virtual bool isNullValue() const { return false; }
452
453   virtual void destroyConstant();
454   virtual void replaceUsesOfWithOnConstant(Value *From, Value *To,
455                                            bool DisableChecking = false);
456
457   /// Methods for support type inquiry through isa, cast, and dyn_cast:
458   static inline bool classof(const ConstantPacked *) { return true; }
459   static bool classof(const Value *V) {
460     return V->getValueType() == ConstantPackedVal;
461   }
462 };
463
464 //===----------------------------------------------------------------------===//
465 /// ConstantPointerNull - a constant pointer value that points to null
466 ///
467 class ConstantPointerNull : public Constant {
468   friend struct ConstantCreator<ConstantPointerNull, PointerType, char>;
469   ConstantPointerNull(const ConstantPointerNull &);      // DO NOT IMPLEMENT
470 protected:
471   ConstantPointerNull(const PointerType *T)
472     : Constant(reinterpret_cast<const Type*>(T),
473                Value::ConstantPointerNullVal, 0, 0) {}
474
475 public:
476
477   /// get() - Static factory methods - Return objects of the specified value
478   static ConstantPointerNull *get(const PointerType *T);
479
480   /// isNullValue - Return true if this is the value that would be returned by
481   /// getNullValue.
482   virtual bool isNullValue() const { return true; }
483
484   virtual void destroyConstant();
485
486   /// getType - Specialize the getType() method to always return an PointerType,
487   /// which reduces the amount of casting needed in parts of the compiler.
488   ///
489   inline const PointerType *getType() const {
490     return reinterpret_cast<const PointerType*>(Value::getType());
491   }
492
493   /// Methods for support type inquiry through isa, cast, and dyn_cast:
494   static inline bool classof(const ConstantPointerNull *) { return true; }
495   static bool classof(const Value *V) {
496     return V->getValueType() == ConstantPointerNullVal;
497   }
498 };
499
500
501 /// ConstantExpr - a constant value that is initialized with an expression using
502 /// other constant values.
503 ///
504 /// This class uses the standard Instruction opcodes to define the various
505 /// constant expressions.  The Opcode field for the ConstantExpr class is
506 /// maintained in the Value::SubclassData field.
507 class ConstantExpr : public Constant {
508   friend struct ConstantCreator<ConstantExpr,Type,
509                             std::pair<unsigned, std::vector<Constant*> > >;
510   friend struct ConvertConstantType<ConstantExpr, Type>;
511
512 protected:
513   ConstantExpr(const Type *Ty, unsigned Opcode, Use *Ops, unsigned NumOps)
514     : Constant(Ty, ConstantExprVal, Ops, NumOps) {
515     // Operation type (an Instruction opcode) is stored as the SubclassData.
516     SubclassData = Opcode;
517   }
518
519   // These private methods are used by the type resolution code to create
520   // ConstantExprs in intermediate forms.
521   static Constant *getTy(const Type *Ty, unsigned Opcode,
522                          Constant *C1, Constant *C2);
523   static Constant *getShiftTy(const Type *Ty,
524                               unsigned Opcode, Constant *C1, Constant *C2);
525   static Constant *getSelectTy(const Type *Ty,
526                                Constant *C1, Constant *C2, Constant *C3);
527   static Constant *getGetElementPtrTy(const Type *Ty, Constant *C,
528                                       const std::vector<Value*> &IdxList);
529
530 public:
531   // Static methods to construct a ConstantExpr of different kinds.  Note that
532   // these methods may return a object that is not an instance of the
533   // ConstantExpr class, because they will attempt to fold the constant
534   // expression into something simpler if possible.
535
536   /// Cast constant expr
537   ///
538   static Constant *getCast(Constant *C, const Type *Ty);
539   static Constant *getSignExtend(Constant *C, const Type *Ty);
540   static Constant *getZeroExtend(Constant *C, const Type *Ty);
541
542   /// Select constant expr
543   ///
544   static Constant *getSelect(Constant *C, Constant *V1, Constant *V2) {
545     return getSelectTy(V1->getType(), C, V1, V2);
546   }
547
548   /// getSizeOf constant expr - computes the size of a type in a target
549   /// independent way (Note: the return type is ULong but the object is not
550   /// necessarily a ConstantUInt).
551   ///
552   static Constant *getSizeOf(const Type *Ty);
553
554   /// getPtrPtrFromArrayPtr constant expr - given a pointer to a constant array,
555   /// return a pointer to a pointer of the array element type.
556   static Constant *getPtrPtrFromArrayPtr(Constant *C);
557
558   /// ConstantExpr::get - Return a binary or shift operator constant expression,
559   /// folding if possible.
560   ///
561   static Constant *get(unsigned Opcode, Constant *C1, Constant *C2);
562
563   /// ConstantExpr::get* - Return some common constants without having to
564   /// specify the full Instruction::OPCODE identifier.
565   ///
566   static Constant *getNeg(Constant *C);
567   static Constant *getNot(Constant *C);
568   static Constant *getAdd(Constant *C1, Constant *C2);
569   static Constant *getSub(Constant *C1, Constant *C2);
570   static Constant *getMul(Constant *C1, Constant *C2);
571   static Constant *getDiv(Constant *C1, Constant *C2);
572   static Constant *getRem(Constant *C1, Constant *C2);
573   static Constant *getAnd(Constant *C1, Constant *C2);
574   static Constant *getOr(Constant *C1, Constant *C2);
575   static Constant *getXor(Constant *C1, Constant *C2);
576   static Constant *getSetEQ(Constant *C1, Constant *C2);
577   static Constant *getSetNE(Constant *C1, Constant *C2);
578   static Constant *getSetLT(Constant *C1, Constant *C2);
579   static Constant *getSetGT(Constant *C1, Constant *C2);
580   static Constant *getSetLE(Constant *C1, Constant *C2);
581   static Constant *getSetGE(Constant *C1, Constant *C2);
582   static Constant *getShl(Constant *C1, Constant *C2);
583   static Constant *getShr(Constant *C1, Constant *C2);
584
585   static Constant *getUShr(Constant *C1, Constant *C2); // unsigned shr
586   static Constant *getSShr(Constant *C1, Constant *C2); // signed shr
587
588   /// Getelementptr form.  std::vector<Value*> is only accepted for convenience:
589   /// all elements must be Constant's.
590   ///
591   static Constant *getGetElementPtr(Constant *C,
592                                     const std::vector<Constant*> &IdxList);
593   static Constant *getGetElementPtr(Constant *C,
594                                     const std::vector<Value*> &IdxList);
595
596   /// isNullValue - Return true if this is the value that would be returned by
597   /// getNullValue.
598   virtual bool isNullValue() const { return false; }
599
600   /// getOpcode - Return the opcode at the root of this constant expression
601   unsigned getOpcode() const { return SubclassData; }
602
603   /// getOpcodeName - Return a string representation for an opcode.
604   const char *getOpcodeName() const;
605
606   virtual void destroyConstant();
607   virtual void replaceUsesOfWithOnConstant(Value *From, Value *To,
608                                            bool DisableChecking = false);
609
610   /// Override methods to provide more type information...
611   inline Constant *getOperand(unsigned i) {
612     return cast<Constant>(User::getOperand(i));
613   }
614   inline Constant *getOperand(unsigned i) const {
615     return const_cast<Constant*>(cast<Constant>(User::getOperand(i)));
616   }
617
618
619   /// Methods for support type inquiry through isa, cast, and dyn_cast:
620   static inline bool classof(const ConstantExpr *) { return true; }
621   static inline bool classof(const Value *V) {
622     return V->getValueType() == ConstantExprVal;
623   }
624 };
625
626
627 //===----------------------------------------------------------------------===//
628 /// UndefValue - 'undef' values are things that do not have specified contents.
629 /// These are used for a variety of purposes, including global variable
630 /// initializers and operands to instructions.  'undef' values can occur with
631 /// any type.
632 ///
633 class UndefValue : public Constant {
634   friend struct ConstantCreator<UndefValue, Type, char>;
635   UndefValue(const UndefValue &);      // DO NOT IMPLEMENT
636 protected:
637   UndefValue(const Type *T) : Constant(T, UndefValueVal, 0, 0) {}
638 public:
639   /// get() - Static factory methods - Return an 'undef' object of the specified
640   /// type.
641   ///
642   static UndefValue *get(const Type *T);
643
644   /// isNullValue - Return true if this is the value that would be returned by
645   /// getNullValue.
646   virtual bool isNullValue() const { return false; }
647
648   virtual void destroyConstant();
649
650   /// Methods for support type inquiry through isa, cast, and dyn_cast:
651   static inline bool classof(const UndefValue *) { return true; }
652   static bool classof(const Value *V) {
653     return V->getValueType() == UndefValueVal;
654   }
655 };
656
657 } // End llvm namespace
658
659 #endif