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