LLVM API Documentation
00001 //===-- llvm/Constants.h - Constant class subclass definitions --*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file was developed by the LLVM research group and is distributed under 00006 // the University of Illinois Open Source License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file contains the declarations for the subclasses of Constant, which 00011 // represent the different flavors of constant values that live in LLVM. Note 00012 // that Constants are immutable (once created they never change) and are fully 00013 // shared by structural equivalence. This means that two structurally 00014 // equivalent constants will always have the same address. Constant's are 00015 // created on demand as needed and never deleted: thus clients don't have to 00016 // worry about the lifetime of the objects. 00017 // 00018 //===----------------------------------------------------------------------===// 00019 00020 #ifndef LLVM_CONSTANTS_H 00021 #define LLVM_CONSTANTS_H 00022 00023 #include "llvm/Constant.h" 00024 #include "llvm/Type.h" 00025 #include "llvm/Support/DataTypes.h" 00026 00027 namespace llvm { 00028 00029 class ArrayType; 00030 class StructType; 00031 class PointerType; 00032 class PackedType; 00033 00034 template<class ConstantClass, class TypeClass, class ValType> 00035 struct ConstantCreator; 00036 template<class ConstantClass, class TypeClass> 00037 struct ConvertConstantType; 00038 00039 //===----------------------------------------------------------------------===// 00040 /// ConstantIntegral - Shared superclass of boolean and integer constants. 00041 /// 00042 /// This class just defines some common interfaces to be implemented. 00043 /// 00044 class ConstantIntegral : public Constant { 00045 protected: 00046 union { 00047 int64_t Signed; 00048 uint64_t Unsigned; 00049 } Val; 00050 ConstantIntegral(const Type *Ty, uint64_t V); 00051 public: 00052 00053 /// getRawValue - return the underlying value of this constant as a 64-bit 00054 /// unsigned integer value. 00055 /// 00056 inline uint64_t getRawValue() const { return Val.Unsigned; } 00057 00058 /// isNullValue - Return true if this is the value that would be returned by 00059 /// getNullValue. 00060 /// 00061 virtual bool isNullValue() const = 0; 00062 00063 /// isMaxValue - Return true if this is the largest value that may be 00064 /// represented by this type. 00065 /// 00066 virtual bool isMaxValue() const = 0; 00067 00068 /// isMinValue - Return true if this is the smallest value that may be 00069 /// represented by this type. 00070 /// 00071 virtual bool isMinValue() const = 0; 00072 00073 /// isAllOnesValue - Return true if every bit in this constant is set to true. 00074 /// 00075 virtual bool isAllOnesValue() const = 0; 00076 00077 /// Static constructor to get the maximum/minimum/allones constant of 00078 /// specified (integral) type... 00079 /// 00080 static ConstantIntegral *getMaxValue(const Type *Ty); 00081 static ConstantIntegral *getMinValue(const Type *Ty); 00082 static ConstantIntegral *getAllOnesValue(const Type *Ty); 00083 00084 /// Methods for support type inquiry through isa, cast, and dyn_cast: 00085 static inline bool classof(const ConstantIntegral *) { return true; } 00086 static bool classof(const Value *V) { 00087 return V->getValueType() == SimpleConstantVal && 00088 V->getType()->isIntegral(); 00089 } 00090 }; 00091 00092 00093 //===----------------------------------------------------------------------===// 00094 /// ConstantBool - Boolean Values 00095 /// 00096 class ConstantBool : public ConstantIntegral { 00097 ConstantBool(bool V); 00098 public: 00099 static ConstantBool *True, *False; // The True & False values 00100 00101 /// get() - Static factory methods - Return objects of the specified value 00102 static ConstantBool *get(bool Value) { return Value ? True : False; } 00103 static ConstantBool *get(const Type *Ty, bool Value) { return get(Value); } 00104 00105 /// inverted - Return the opposite value of the current value. 00106 inline ConstantBool *inverted() const { return (this==True) ? False : True; } 00107 00108 /// getValue - return the boolean value of this constant. 00109 /// 00110 inline bool getValue() const { return static_cast<bool>(getRawValue()); } 00111 00112 /// isNullValue - Return true if this is the value that would be returned by 00113 /// getNullValue. 00114 /// 00115 virtual bool isNullValue() const { return this == False; } 00116 virtual bool isMaxValue() const { return this == True; } 00117 virtual bool isMinValue() const { return this == False; } 00118 virtual bool isAllOnesValue() const { return this == True; } 00119 00120 /// Methods for support type inquiry through isa, cast, and dyn_cast: 00121 static inline bool classof(const ConstantBool *) { return true; } 00122 static bool classof(const Value *V) { 00123 return (V == True) | (V == False); 00124 } 00125 }; 00126 00127 00128 //===----------------------------------------------------------------------===// 00129 /// ConstantInt - Superclass of ConstantSInt & ConstantUInt, to make dealing 00130 /// with integral constants easier. 00131 /// 00132 class ConstantInt : public ConstantIntegral { 00133 protected: 00134 ConstantInt(const ConstantInt &); // DO NOT IMPLEMENT 00135 ConstantInt(const Type *Ty, uint64_t V); 00136 public: 00137 /// equalsInt - Provide a helper method that can be used to determine if the 00138 /// constant contained within is equal to a constant. This only works for 00139 /// very small values, because this is all that can be represented with all 00140 /// types. 00141 /// 00142 bool equalsInt(unsigned char V) const { 00143 assert(V <= 127 && 00144 "equalsInt: Can only be used with very small positive constants!"); 00145 return Val.Unsigned == V; 00146 } 00147 00148 /// ConstantInt::get static method: return a ConstantInt with the specified 00149 /// value. as above, we work only with very small values here. 00150 /// 00151 static ConstantInt *get(const Type *Ty, unsigned char V); 00152 00153 /// isNullValue - Return true if this is the value that would be returned by 00154 /// getNullValue. 00155 virtual bool isNullValue() const { return Val.Unsigned == 0; } 00156 virtual bool isMaxValue() const = 0; 00157 virtual bool isMinValue() const = 0; 00158 00159 /// Methods for support type inquiry through isa, cast, and dyn_cast: 00160 static inline bool classof(const ConstantInt *) { return true; } 00161 static bool classof(const Value *V) { 00162 return V->getValueType() == SimpleConstantVal && 00163 V->getType()->isInteger(); 00164 } 00165 }; 00166 00167 00168 //===----------------------------------------------------------------------===// 00169 /// ConstantSInt - Signed Integer Values [sbyte, short, int, long] 00170 /// 00171 class ConstantSInt : public ConstantInt { 00172 ConstantSInt(const ConstantSInt &); // DO NOT IMPLEMENT 00173 friend struct ConstantCreator<ConstantSInt, Type, int64_t>; 00174 00175 protected: 00176 ConstantSInt(const Type *Ty, int64_t V); 00177 public: 00178 /// get() - Static factory methods - Return objects of the specified value 00179 /// 00180 static ConstantSInt *get(const Type *Ty, int64_t V); 00181 00182 /// isValueValidForType - return true if Ty is big enough to represent V. 00183 /// 00184 static bool isValueValidForType(const Type *Ty, int64_t V); 00185 00186 /// getValue - return the underlying value of this constant. 00187 /// 00188 inline int64_t getValue() const { return Val.Signed; } 00189 00190 virtual bool isAllOnesValue() const { return getValue() == -1; } 00191 00192 /// isMaxValue - Return true if this is the largest value that may be 00193 /// represented by this type. 00194 /// 00195 virtual bool isMaxValue() const { 00196 int64_t V = getValue(); 00197 if (V < 0) return false; // Be careful about wrap-around on 'long's 00198 ++V; 00199 return !isValueValidForType(getType(), V) || V < 0; 00200 } 00201 00202 /// isMinValue - Return true if this is the smallest value that may be 00203 /// represented by this type. 00204 /// 00205 virtual bool isMinValue() const { 00206 int64_t V = getValue(); 00207 if (V > 0) return false; // Be careful about wrap-around on 'long's 00208 --V; 00209 return !isValueValidForType(getType(), V) || V > 0; 00210 } 00211 00212 /// Methods for support type inquiry through isa, cast, and dyn_cast: 00213 /// 00214 static inline bool classof(const ConstantSInt *) { return true; } 00215 static bool classof(const Value *V) { 00216 return V->getValueType() == SimpleConstantVal && 00217 V->getType()->isSigned(); 00218 } 00219 }; 00220 00221 //===----------------------------------------------------------------------===// 00222 /// ConstantUInt - Unsigned Integer Values [ubyte, ushort, uint, ulong] 00223 /// 00224 class ConstantUInt : public ConstantInt { 00225 ConstantUInt(const ConstantUInt &); // DO NOT IMPLEMENT 00226 friend struct ConstantCreator<ConstantUInt, Type, uint64_t>; 00227 protected: 00228 ConstantUInt(const Type *Ty, uint64_t V); 00229 public: 00230 /// get() - Static factory methods - Return objects of the specified value 00231 /// 00232 static ConstantUInt *get(const Type *Ty, uint64_t V); 00233 00234 /// isValueValidForType - return true if Ty is big enough to represent V. 00235 /// 00236 static bool isValueValidForType(const Type *Ty, uint64_t V); 00237 00238 /// getValue - return the underlying value of this constant. 00239 /// 00240 inline uint64_t getValue() const { return Val.Unsigned; } 00241 00242 /// isMaxValue - Return true if this is the largest value that may be 00243 /// represented by this type. 00244 /// 00245 virtual bool isAllOnesValue() const; 00246 virtual bool isMaxValue() const { return isAllOnesValue(); } 00247 virtual bool isMinValue() const { return getValue() == 0; } 00248 00249 /// Methods for support type inquiry through isa, cast, and dyn_cast: 00250 static inline bool classof(const ConstantUInt *) { return true; } 00251 static bool classof(const Value *V) { 00252 return V->getValueType() == SimpleConstantVal && 00253 V->getType()->isUnsigned(); 00254 } 00255 }; 00256 00257 00258 //===----------------------------------------------------------------------===// 00259 /// ConstantFP - Floating Point Values [float, double] 00260 /// 00261 class ConstantFP : public Constant { 00262 double Val; 00263 friend struct ConstantCreator<ConstantFP, Type, uint64_t>; 00264 friend struct ConstantCreator<ConstantFP, Type, uint32_t>; 00265 ConstantFP(const ConstantFP &); // DO NOT IMPLEMENT 00266 protected: 00267 ConstantFP(const Type *Ty, double V); 00268 public: 00269 /// get() - Static factory methods - Return objects of the specified value 00270 static ConstantFP *get(const Type *Ty, double V); 00271 00272 /// isValueValidForType - return true if Ty is big enough to represent V. 00273 static bool isValueValidForType(const Type *Ty, double V); 00274 inline double getValue() const { return Val; } 00275 00276 /// isNullValue - Return true if this is the value that would be returned by 00277 /// getNullValue. Don't depend on == for doubles to tell us it's zero, it 00278 /// considers -0.0 to be null as well as 0.0. :( 00279 virtual bool isNullValue() const { 00280 union { 00281 double V; 00282 uint64_t I; 00283 } T; 00284 T.V = Val; 00285 return T.I == 0; 00286 } 00287 00288 /// isExactlyValue - We don't rely on operator== working on double values, as 00289 /// it returns true for things that are clearly not equal, like -0.0 and 0.0. 00290 /// As such, this method can be used to do an exact bit-for-bit comparison of 00291 /// two floating point values. 00292 bool isExactlyValue(double V) const { 00293 union { 00294 double V; 00295 uint64_t I; 00296 } T1; 00297 T1.V = Val; 00298 union { 00299 double V; 00300 uint64_t I; 00301 } T2; 00302 T2.V = V; 00303 return T1.I == T2.I; 00304 } 00305 00306 /// Methods for support type inquiry through isa, cast, and dyn_cast: 00307 static inline bool classof(const ConstantFP *) { return true; } 00308 static bool classof(const Value *V) { 00309 return V->getValueType() == SimpleConstantVal && 00310 V->getType()->isFloatingPoint(); 00311 } 00312 }; 00313 00314 //===----------------------------------------------------------------------===// 00315 /// ConstantAggregateZero - All zero aggregate value 00316 /// 00317 class ConstantAggregateZero : public Constant { 00318 friend struct ConstantCreator<ConstantAggregateZero, Type, char>; 00319 ConstantAggregateZero(const ConstantAggregateZero &); // DO NOT IMPLEMENT 00320 protected: 00321 ConstantAggregateZero(const Type *Ty) 00322 : Constant(Ty, ConstantAggregateZeroVal) {} 00323 public: 00324 /// get() - static factory method for creating a null aggregate. It is 00325 /// illegal to call this method with a non-aggregate type. 00326 static Constant *get(const Type *Ty); 00327 00328 /// isNullValue - Return true if this is the value that would be returned by 00329 /// getNullValue. 00330 virtual bool isNullValue() const { return true; } 00331 00332 virtual void destroyConstant(); 00333 virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, 00334 bool DisableChecking = false); 00335 00336 /// Methods for support type inquiry through isa, cast, and dyn_cast: 00337 /// 00338 static bool classof(const ConstantAggregateZero *) { return true; } 00339 static bool classof(const Value *V) { 00340 return V->getValueType() == ConstantAggregateZeroVal; 00341 } 00342 }; 00343 00344 00345 //===----------------------------------------------------------------------===// 00346 /// ConstantArray - Constant Array Declarations 00347 /// 00348 class ConstantArray : public Constant { 00349 friend struct ConstantCreator<ConstantArray, ArrayType, 00350 std::vector<Constant*> >; 00351 ConstantArray(const ConstantArray &); // DO NOT IMPLEMENT 00352 protected: 00353 ConstantArray(const ArrayType *T, const std::vector<Constant*> &Val); 00354 public: 00355 /// get() - Static factory methods - Return objects of the specified value 00356 static Constant *get(const ArrayType *T, const std::vector<Constant*> &); 00357 static Constant *get(const std::string &Initializer); 00358 00359 /// getType - Specialize the getType() method to always return an ArrayType, 00360 /// which reduces the amount of casting needed in parts of the compiler. 00361 /// 00362 inline const ArrayType *getType() const { 00363 return reinterpret_cast<const ArrayType*>(Value::getType()); 00364 } 00365 00366 /// isString - This method returns true if the array is an array of sbyte or 00367 /// ubyte, and if the elements of the array are all ConstantInt's. 00368 bool isString() const; 00369 00370 /// getAsString - If this array is isString(), then this method converts the 00371 /// array to an std::string and returns it. Otherwise, it asserts out. 00372 /// 00373 std::string getAsString() const; 00374 00375 /// isNullValue - Return true if this is the value that would be returned by 00376 /// getNullValue. This always returns false because zero arrays are always 00377 /// created as ConstantAggregateZero objects. 00378 virtual bool isNullValue() const { return false; } 00379 00380 virtual void destroyConstant(); 00381 virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, 00382 bool DisableChecking = false); 00383 00384 /// Methods for support type inquiry through isa, cast, and dyn_cast: 00385 static inline bool classof(const ConstantArray *) { return true; } 00386 static bool classof(const Value *V) { 00387 return V->getValueType() == SimpleConstantVal && 00388 V->getType()->getTypeID() == Type::ArrayTyID; 00389 } 00390 }; 00391 00392 00393 //===----------------------------------------------------------------------===// 00394 // ConstantStruct - Constant Struct Declarations 00395 // 00396 class ConstantStruct : public Constant { 00397 friend struct ConstantCreator<ConstantStruct, StructType, 00398 std::vector<Constant*> >; 00399 ConstantStruct(const ConstantStruct &); // DO NOT IMPLEMENT 00400 protected: 00401 ConstantStruct(const StructType *T, const std::vector<Constant*> &Val); 00402 public: 00403 /// get() - Static factory methods - Return objects of the specified value 00404 /// 00405 static Constant *get(const StructType *T, const std::vector<Constant*> &V); 00406 static Constant *get(const std::vector<Constant*> &V); 00407 00408 /// getType() specialization - Reduce amount of casting... 00409 /// 00410 inline const StructType *getType() const { 00411 return reinterpret_cast<const StructType*>(Value::getType()); 00412 } 00413 00414 /// isNullValue - Return true if this is the value that would be returned by 00415 /// getNullValue. This always returns false because zero structs are always 00416 /// created as ConstantAggregateZero objects. 00417 virtual bool isNullValue() const { 00418 return false; 00419 } 00420 00421 virtual void destroyConstant(); 00422 virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, 00423 bool DisableChecking = false); 00424 00425 /// Methods for support type inquiry through isa, cast, and dyn_cast: 00426 static inline bool classof(const ConstantStruct *) { return true; } 00427 static bool classof(const Value *V) { 00428 return V->getValueType() == SimpleConstantVal && 00429 V->getType()->getTypeID() == Type::StructTyID; 00430 } 00431 }; 00432 00433 //===----------------------------------------------------------------------===// 00434 /// ConstantPacked - Constant Packed Declarations 00435 /// 00436 class ConstantPacked : public Constant { 00437 friend struct ConstantCreator<ConstantPacked, PackedType, 00438 std::vector<Constant*> >; 00439 ConstantPacked(const ConstantPacked &); // DO NOT IMPLEMENT 00440 protected: 00441 ConstantPacked(const PackedType *T, const std::vector<Constant*> &Val); 00442 public: 00443 /// get() - Static factory methods - Return objects of the specified value 00444 static Constant *get(const PackedType *T, const std::vector<Constant*> &); 00445 static Constant *get(const std::vector<Constant*> &V); 00446 00447 /// getType - Specialize the getType() method to always return an PackedType, 00448 /// which reduces the amount of casting needed in parts of the compiler. 00449 /// 00450 inline const PackedType *getType() const { 00451 return reinterpret_cast<const PackedType*>(Value::getType()); 00452 } 00453 00454 /// isNullValue - Return true if this is the value that would be returned by 00455 /// getNullValue. This always returns false because zero arrays are always 00456 /// created as ConstantAggregateZero objects. 00457 virtual bool isNullValue() const { return false; } 00458 00459 virtual void destroyConstant(); 00460 virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, 00461 bool DisableChecking = false); 00462 00463 /// Methods for support type inquiry through isa, cast, and dyn_cast: 00464 static inline bool classof(const ConstantPacked *) { return true; } 00465 static bool classof(const Value *V) { 00466 return V->getValueType() == SimpleConstantVal && 00467 V->getType()->getTypeID() == Type::PackedTyID; 00468 } 00469 }; 00470 00471 //===----------------------------------------------------------------------===// 00472 /// ConstantPointerNull - a constant pointer value that points to null 00473 /// 00474 class ConstantPointerNull : public Constant { 00475 friend struct ConstantCreator<ConstantPointerNull, PointerType, char>; 00476 ConstantPointerNull(const ConstantPointerNull &); // DO NOT IMPLEMENT 00477 protected: 00478 ConstantPointerNull(const PointerType *T) 00479 : Constant(reinterpret_cast<const Type*>(T)) {} 00480 00481 public: 00482 00483 /// get() - Static factory methods - Return objects of the specified value 00484 static ConstantPointerNull *get(const PointerType *T); 00485 00486 /// isNullValue - Return true if this is the value that would be returned by 00487 /// getNullValue. 00488 virtual bool isNullValue() const { return true; } 00489 00490 virtual void destroyConstant(); 00491 00492 /// getType - Specialize the getType() method to always return an PointerType, 00493 /// which reduces the amount of casting needed in parts of the compiler. 00494 /// 00495 inline const PointerType *getType() const { 00496 return reinterpret_cast<const PointerType*>(Value::getType()); 00497 } 00498 00499 /// Methods for support type inquiry through isa, cast, and dyn_cast: 00500 static inline bool classof(const ConstantPointerNull *) { return true; } 00501 static bool classof(const Value *V) { 00502 return V->getValueType() == SimpleConstantVal && 00503 isa<PointerType>(V->getType()); 00504 } 00505 }; 00506 00507 00508 /// ConstantExpr - a constant value that is initialized with an expression using 00509 /// other constant values. This is only used to represent values that cannot be 00510 /// evaluated at compile-time (e.g., something derived from an address) because 00511 /// it does not have a mechanism to store the actual value. Use the appropriate 00512 /// Constant subclass above for known constants. 00513 /// 00514 class ConstantExpr : public Constant { 00515 unsigned iType; // Operation type (an Instruction opcode) 00516 friend struct ConstantCreator<ConstantExpr,Type, 00517 std::pair<unsigned, std::vector<Constant*> > >; 00518 friend struct ConvertConstantType<ConstantExpr, Type>; 00519 00520 protected: 00521 // Cast creation ctor 00522 ConstantExpr(unsigned Opcode, Constant *C, const Type *Ty); 00523 // Binary/Shift instruction creation ctor 00524 ConstantExpr(unsigned Opcode, Constant *C1, Constant *C2); 00525 // Select instruction creation ctor 00526 ConstantExpr(Constant *C, Constant *V1, Constant *V2); 00527 // GEP instruction creation ctor 00528 ConstantExpr(Constant *C, const std::vector<Constant*> &IdxList, 00529 const Type *DestTy); 00530 00531 // These private methods are used by the type resolution code to create 00532 // ConstantExprs in intermediate forms. 00533 static Constant *getTy(const Type *Ty, unsigned Opcode, 00534 Constant *C1, Constant *C2); 00535 static Constant *getShiftTy(const Type *Ty, 00536 unsigned Opcode, Constant *C1, Constant *C2); 00537 static Constant *getSelectTy(const Type *Ty, 00538 Constant *C1, Constant *C2, Constant *C3); 00539 static Constant *getGetElementPtrTy(const Type *Ty, Constant *C, 00540 const std::vector<Value*> &IdxList); 00541 00542 public: 00543 // Static methods to construct a ConstantExpr of different kinds. Note that 00544 // these methods may return a object that is not an instance of the 00545 // ConstantExpr class, because they will attempt to fold the constant 00546 // expression into something simpler if possible. 00547 00548 /// Cast constant expr 00549 /// 00550 static Constant *getCast(Constant *C, const Type *Ty); 00551 static Constant *getSignExtend(Constant *C, const Type *Ty); 00552 static Constant *getZeroExtend(Constant *C, const Type *Ty); 00553 00554 /// Select constant expr 00555 /// 00556 static Constant *getSelect(Constant *C, Constant *V1, Constant *V2) { 00557 return getSelectTy(V1->getType(), C, V1, V2); 00558 } 00559 00560 /// getSizeOf constant expr - computes the size of a type in a target 00561 /// independent way (Note: the return type is UInt but the object is not 00562 /// necessarily a ConstantUInt). 00563 /// 00564 static Constant *getSizeOf(const Type *Ty); 00565 00566 /// ConstantExpr::get - Return a binary or shift operator constant expression, 00567 /// folding if possible. 00568 /// 00569 static Constant *get(unsigned Opcode, Constant *C1, Constant *C2); 00570 00571 /// ConstantExpr::get* - Return some common constants without having to 00572 /// specify the full Instruction::OPCODE identifier. 00573 /// 00574 static Constant *getNeg(Constant *C); 00575 static Constant *getNot(Constant *C); 00576 static Constant *getAdd(Constant *C1, Constant *C2); 00577 static Constant *getSub(Constant *C1, Constant *C2); 00578 static Constant *getMul(Constant *C1, Constant *C2); 00579 static Constant *getDiv(Constant *C1, Constant *C2); 00580 static Constant *getRem(Constant *C1, Constant *C2); 00581 static Constant *getAnd(Constant *C1, Constant *C2); 00582 static Constant *getOr(Constant *C1, Constant *C2); 00583 static Constant *getXor(Constant *C1, Constant *C2); 00584 static Constant *getSetEQ(Constant *C1, Constant *C2); 00585 static Constant *getSetNE(Constant *C1, Constant *C2); 00586 static Constant *getSetLT(Constant *C1, Constant *C2); 00587 static Constant *getSetGT(Constant *C1, Constant *C2); 00588 static Constant *getSetLE(Constant *C1, Constant *C2); 00589 static Constant *getSetGE(Constant *C1, Constant *C2); 00590 static Constant *getShl(Constant *C1, Constant *C2); 00591 static Constant *getShr(Constant *C1, Constant *C2); 00592 00593 static Constant *getUShr(Constant *C1, Constant *C2); // unsigned shr 00594 static Constant *getSShr(Constant *C1, Constant *C2); // signed shr 00595 00596 /// Getelementptr form. std::vector<Value*> is only accepted for convenience: 00597 /// all elements must be Constant's. 00598 /// 00599 static Constant *getGetElementPtr(Constant *C, 00600 const std::vector<Constant*> &IdxList); 00601 static Constant *getGetElementPtr(Constant *C, 00602 const std::vector<Value*> &IdxList); 00603 00604 /// isNullValue - Return true if this is the value that would be returned by 00605 /// getNullValue. 00606 virtual bool isNullValue() const { return false; } 00607 00608 /// getOpcode - Return the opcode at the root of this constant expression 00609 unsigned getOpcode() const { return iType; } 00610 00611 /// getOpcodeName - Return a string representation for an opcode. 00612 const char *getOpcodeName() const; 00613 00614 virtual void destroyConstant(); 00615 virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, 00616 bool DisableChecking = false); 00617 00618 /// Override methods to provide more type information... 00619 inline Constant *getOperand(unsigned i) { 00620 return cast<Constant>(User::getOperand(i)); 00621 } 00622 inline Constant *getOperand(unsigned i) const { 00623 return const_cast<Constant*>(cast<Constant>(User::getOperand(i))); 00624 } 00625 00626 00627 /// Methods for support type inquiry through isa, cast, and dyn_cast: 00628 static inline bool classof(const ConstantExpr *) { return true; } 00629 static inline bool classof(const Value *V) { 00630 return V->getValueType() == ConstantExprVal; 00631 } 00632 }; 00633 00634 00635 //===----------------------------------------------------------------------===// 00636 /// UndefValue - 'undef' values are things that do not have specified contents. 00637 /// These are used for a variety of purposes, including global variable 00638 /// initializers and operands to instructions. 'undef' values can occur with 00639 /// any type. 00640 /// 00641 class UndefValue : public Constant { 00642 friend struct ConstantCreator<UndefValue, Type, char>; 00643 UndefValue(const UndefValue &); // DO NOT IMPLEMENT 00644 protected: 00645 UndefValue(const Type *T) : Constant(T, UndefValueVal) {} 00646 public: 00647 /// get() - Static factory methods - Return an 'undef' object of the specified 00648 /// type. 00649 /// 00650 static UndefValue *get(const Type *T); 00651 00652 /// isNullValue - Return true if this is the value that would be returned by 00653 /// getNullValue. 00654 virtual bool isNullValue() const { return false; } 00655 00656 virtual void destroyConstant(); 00657 00658 /// Methods for support type inquiry through isa, cast, and dyn_cast: 00659 static inline bool classof(const UndefValue *) { return true; } 00660 static bool classof(const Value *V) { 00661 return V->getValueType() == UndefValueVal; 00662 } 00663 }; 00664 00665 } // End llvm namespace 00666 00667 #endif