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