Added an instruction and constant expression for the extractelement
[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
327   /// Methods for support type inquiry through isa, cast, and dyn_cast:
328   ///
329   static bool classof(const ConstantAggregateZero *) { return true; }
330   static bool classof(const Value *V) {
331     return V->getValueType() == ConstantAggregateZeroVal;
332   }
333 };
334
335
336 //===----------------------------------------------------------------------===//
337 /// ConstantArray - Constant Array Declarations
338 ///
339 class ConstantArray : public Constant {
340   friend struct ConstantCreator<ConstantArray, ArrayType,
341                                     std::vector<Constant*> >;
342   ConstantArray(const ConstantArray &);      // DO NOT IMPLEMENT
343 protected:
344   ConstantArray(const ArrayType *T, const std::vector<Constant*> &Val);
345   ~ConstantArray();
346 public:
347   /// get() - Static factory methods - Return objects of the specified value
348   static Constant *get(const ArrayType *T, const std::vector<Constant*> &);
349   static Constant *get(const std::string &Initializer);
350
351   /// getType - Specialize the getType() method to always return an ArrayType,
352   /// which reduces the amount of casting needed in parts of the compiler.
353   ///
354   inline const ArrayType *getType() const {
355     return reinterpret_cast<const ArrayType*>(Value::getType());
356   }
357
358   /// isString - This method returns true if the array is an array of sbyte or
359   /// ubyte, and if the elements of the array are all ConstantInt's.
360   bool isString() const;
361
362   /// getAsString - If this array is isString(), then this method converts the
363   /// array to an std::string and returns it.  Otherwise, it asserts out.
364   ///
365   std::string getAsString() const;
366
367   /// isNullValue - Return true if this is the value that would be returned by
368   /// getNullValue.  This always returns false because zero arrays are always
369   /// created as ConstantAggregateZero objects.
370   virtual bool isNullValue() const { return false; }
371
372   virtual void destroyConstant();
373   virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
374
375   /// Methods for support type inquiry through isa, cast, and dyn_cast:
376   static inline bool classof(const ConstantArray *) { return true; }
377   static bool classof(const Value *V) {
378     return V->getValueType() == ConstantArrayVal;
379   }
380 };
381
382
383 //===----------------------------------------------------------------------===//
384 // ConstantStruct - Constant Struct Declarations
385 //
386 class ConstantStruct : public Constant {
387   friend struct ConstantCreator<ConstantStruct, StructType,
388                                     std::vector<Constant*> >;
389   ConstantStruct(const ConstantStruct &);      // DO NOT IMPLEMENT
390 protected:
391   ConstantStruct(const StructType *T, const std::vector<Constant*> &Val);
392   ~ConstantStruct();
393 public:
394   /// get() - Static factory methods - Return objects of the specified value
395   ///
396   static Constant *get(const StructType *T, const std::vector<Constant*> &V);
397   static Constant *get(const std::vector<Constant*> &V);
398
399   /// getType() specialization - Reduce amount of casting...
400   ///
401   inline const StructType *getType() const {
402     return reinterpret_cast<const StructType*>(Value::getType());
403   }
404
405   /// isNullValue - Return true if this is the value that would be returned by
406   /// getNullValue.  This always returns false because zero structs are always
407   /// created as ConstantAggregateZero objects.
408   virtual bool isNullValue() const {
409     return false;
410   }
411
412   virtual void destroyConstant();
413   virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
414
415   /// Methods for support type inquiry through isa, cast, and dyn_cast:
416   static inline bool classof(const ConstantStruct *) { return true; }
417   static bool classof(const Value *V) {
418     return V->getValueType() == ConstantStructVal;
419   }
420 };
421
422 //===----------------------------------------------------------------------===//
423 /// ConstantPacked - Constant Packed Declarations
424 ///
425 class ConstantPacked : public Constant {
426   friend struct ConstantCreator<ConstantPacked, PackedType,
427                                     std::vector<Constant*> >;
428   ConstantPacked(const ConstantPacked &);      // DO NOT IMPLEMENT
429 protected:
430   ConstantPacked(const PackedType *T, const std::vector<Constant*> &Val);
431   ~ConstantPacked();
432 public:
433   /// get() - Static factory methods - Return objects of the specified value
434   static Constant *get(const PackedType *T, const std::vector<Constant*> &);
435   static Constant *get(const std::vector<Constant*> &V);
436
437   /// getType - Specialize the getType() method to always return an PackedType,
438   /// which reduces the amount of casting needed in parts of the compiler.
439   ///
440   inline const PackedType *getType() const {
441     return reinterpret_cast<const PackedType*>(Value::getType());
442   }
443
444   /// isNullValue - Return true if this is the value that would be returned by
445   /// getNullValue.  This always returns false because zero arrays are always
446   /// created as ConstantAggregateZero objects.
447   virtual bool isNullValue() const { return false; }
448
449   virtual void destroyConstant();
450   virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
451
452   /// Methods for support type inquiry through isa, cast, and dyn_cast:
453   static inline bool classof(const ConstantPacked *) { return true; }
454   static bool classof(const Value *V) {
455     return V->getValueType() == ConstantPackedVal;
456   }
457 };
458
459 //===----------------------------------------------------------------------===//
460 /// ConstantPointerNull - a constant pointer value that points to null
461 ///
462 class ConstantPointerNull : public Constant {
463   friend struct ConstantCreator<ConstantPointerNull, PointerType, char>;
464   ConstantPointerNull(const ConstantPointerNull &);      // DO NOT IMPLEMENT
465 protected:
466   ConstantPointerNull(const PointerType *T)
467     : Constant(reinterpret_cast<const Type*>(T),
468                Value::ConstantPointerNullVal, 0, 0) {}
469
470 public:
471
472   /// get() - Static factory methods - Return objects of the specified value
473   static ConstantPointerNull *get(const PointerType *T);
474
475   /// isNullValue - Return true if this is the value that would be returned by
476   /// getNullValue.
477   virtual bool isNullValue() const { return true; }
478
479   virtual void destroyConstant();
480
481   /// getType - Specialize the getType() method to always return an PointerType,
482   /// which reduces the amount of casting needed in parts of the compiler.
483   ///
484   inline const PointerType *getType() const {
485     return reinterpret_cast<const PointerType*>(Value::getType());
486   }
487
488   /// Methods for support type inquiry through isa, cast, and dyn_cast:
489   static inline bool classof(const ConstantPointerNull *) { return true; }
490   static bool classof(const Value *V) {
491     return V->getValueType() == ConstantPointerNullVal;
492   }
493 };
494
495
496 /// ConstantExpr - a constant value that is initialized with an expression using
497 /// other constant values.
498 ///
499 /// This class uses the standard Instruction opcodes to define the various
500 /// constant expressions.  The Opcode field for the ConstantExpr class is
501 /// maintained in the Value::SubclassData field.
502 class ConstantExpr : public Constant {
503   friend struct ConstantCreator<ConstantExpr,Type,
504                             std::pair<unsigned, std::vector<Constant*> > >;
505   friend struct ConvertConstantType<ConstantExpr, Type>;
506
507 protected:
508   ConstantExpr(const Type *Ty, unsigned Opcode, Use *Ops, unsigned NumOps)
509     : Constant(Ty, ConstantExprVal, Ops, NumOps) {
510     // Operation type (an Instruction opcode) is stored as the SubclassData.
511     SubclassData = Opcode;
512   }
513
514   // These private methods are used by the type resolution code to create
515   // ConstantExprs in intermediate forms.
516   static Constant *getTy(const Type *Ty, unsigned Opcode,
517                          Constant *C1, Constant *C2);
518   static Constant *getShiftTy(const Type *Ty,
519                               unsigned Opcode, Constant *C1, Constant *C2);
520   static Constant *getSelectTy(const Type *Ty,
521                                Constant *C1, Constant *C2, Constant *C3);
522   static Constant *getGetElementPtrTy(const Type *Ty, Constant *C,
523                                       const std::vector<Value*> &IdxList);
524   static Constant *getExtractElementTy(const Type *Ty, Constant *Val,
525                                        Constant *Idx);
526
527 public:
528   // Static methods to construct a ConstantExpr of different kinds.  Note that
529   // these methods may return a object that is not an instance of the
530   // ConstantExpr class, because they will attempt to fold the constant
531   // expression into something simpler if possible.
532
533   /// Cast constant expr
534   ///
535   static Constant *getCast(Constant *C, const Type *Ty);
536   static Constant *getSignExtend(Constant *C, const Type *Ty);
537   static Constant *getZeroExtend(Constant *C, const Type *Ty);
538
539   /// Select constant expr
540   ///
541   static Constant *getSelect(Constant *C, Constant *V1, Constant *V2) {
542     return getSelectTy(V1->getType(), C, V1, V2);
543   }
544
545   /// getSizeOf constant expr - computes the size of a type in a target
546   /// independent way (Note: the return type is ULong but the object is not
547   /// necessarily a ConstantUInt).
548   ///
549   static Constant *getSizeOf(const Type *Ty);
550
551   /// getPtrPtrFromArrayPtr constant expr - given a pointer to a constant array,
552   /// return a pointer to a pointer of the array element type.
553   static Constant *getPtrPtrFromArrayPtr(Constant *C);
554
555   /// ConstantExpr::get - Return a binary or shift operator constant expression,
556   /// folding if possible.
557   ///
558   static Constant *get(unsigned Opcode, Constant *C1, Constant *C2);
559
560   /// ConstantExpr::get* - Return some common constants without having to
561   /// specify the full Instruction::OPCODE identifier.
562   ///
563   static Constant *getNeg(Constant *C);
564   static Constant *getNot(Constant *C);
565   static Constant *getAdd(Constant *C1, Constant *C2);
566   static Constant *getSub(Constant *C1, Constant *C2);
567   static Constant *getMul(Constant *C1, Constant *C2);
568   static Constant *getDiv(Constant *C1, Constant *C2);
569   static Constant *getRem(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 *getSetEQ(Constant *C1, Constant *C2);
574   static Constant *getSetNE(Constant *C1, Constant *C2);
575   static Constant *getSetLT(Constant *C1, Constant *C2);
576   static Constant *getSetGT(Constant *C1, Constant *C2);
577   static Constant *getSetLE(Constant *C1, Constant *C2);
578   static Constant *getSetGE(Constant *C1, Constant *C2);
579   static Constant *getShl(Constant *C1, Constant *C2);
580   static Constant *getShr(Constant *C1, Constant *C2);
581
582   static Constant *getUShr(Constant *C1, Constant *C2); // unsigned shr
583   static Constant *getSShr(Constant *C1, Constant *C2); // signed shr
584
585   /// Getelementptr form.  std::vector<Value*> is only accepted for convenience:
586   /// all elements must be Constant's.
587   ///
588   static Constant *getGetElementPtr(Constant *C,
589                                     const std::vector<Constant*> &IdxList);
590   static Constant *getGetElementPtr(Constant *C,
591                                     const std::vector<Value*> &IdxList);
592
593   /// Extractelement form.
594   ///
595   static Constant *getExtractElement(Constant *Val, Constant *Idx);
596
597   /// isNullValue - Return true if this is the value that would be returned by
598   /// getNullValue.
599   virtual bool isNullValue() const { return false; }
600
601   /// getOpcode - Return the opcode at the root of this constant expression
602   unsigned getOpcode() const { return SubclassData; }
603
604   /// getOpcodeName - Return a string representation for an opcode.
605   const char *getOpcodeName() const;
606
607   virtual void destroyConstant();
608   virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
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