Home | History | Annotate | Download | only in llvm

Lines Matching refs:Constant

1 //===-- llvm/Constants.h - Constant class subclass definitions --*- C++ -*-===//
11 /// This file contains the declarations for the subclasses of Constant,
12 /// which represent the different flavors of constant values that live in LLVM.
15 /// equivalent constants will always have the same address. Constant's are
24 #include "llvm/Constant.h"
46 /// @brief Class for constant integers.
47 class ConstantInt : public Constant {
60 static Constant *getTrue(Type *Ty);
61 static Constant *getFalse(Type *Ty);
63 /// If Ty is a vector type, return a Constant with a splat of the given
65 static Constant *get(Type *Ty, uint64_t V, bool isSigned = false);
82 static Constant *getSigned(Type *Ty, int64_t V);
93 /// If Ty is a vector type, return a Constant with a splat of the given
95 static Constant *get(Type* Ty, const APInt& V);
97 /// Return the constant as an APInt value reference. This allows clients to
99 /// @brief Return the constant's value.
104 /// getBitWidth - Return the bitwidth of this constant.
107 /// Return the constant as a 64-bit unsigned integer value after it
108 /// has been zero extended as appropriate for the type of this constant. Note
116 /// Return the constant as a 64-bit integer value after it has been sign
117 /// extended as appropriate for the type of this constant. Note that
125 /// A helper method that can be used to determine if the constant contained
126 /// within is equal to a constant. This only works for very small values,
128 /// @brief Determine if this constant's value is same as an unsigned char.
169 /// This function will return true iff every bit in this constant is set
171 /// @returns true iff this constant's bits are all set to true.
177 /// This function will return true iff this constant represents the largest
178 /// value that may be represented by the constant's type.
189 /// This function will return true iff this constant represents the smallest
190 /// value that may be represented by this constant's type.
201 /// This function will return true iff this constant represents a value with
204 /// @returns true iff this constant is greater or equal to the given number.
213 /// @returns the min of the value of the constant and the specified value
214 /// @brief Get the constant's value with a saturation limit
230 class ConstantFP : public Constant {
244 /// method returns the negative zero constant for floating point or vector
246 static Constant *getZeroValueForNegation(Type *Ty);
250 /// only be used for simple constant values like 2.0/1.0 etc, that are
252 static Constant *get(Type* Ty, double V);
253 static Constant *get(Type* Ty, StringRef Str);
298 class ConstantAggregateZero : public Constant {
304 : Constant(ty, ConstantAggregateZeroVal, 0, 0) {}
325 /// ConstantArray - Constant Array Declarations
327 class ConstantArray : public Constant {
329 std::vector<Constant*> >;
332 ConstantArray(ArrayType *T, ArrayRef<Constant *> Val);
335 static Constant *get(ArrayType *T, ArrayRef<Constant*> V);
343 static Constant *get(LLVMContext &Context, StringRef Initializer,
347 DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
393 DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ConstantArray, Constant)
396 // ConstantStruct - Constant Struct Declarations
398 class ConstantStruct : public Constant {
400 std::vector<Constant*> >;
403 ConstantStruct(StructType *T, ArrayRef<Constant *> Val);
406 static Constant *get(StructType *T, ArrayRef<Constant*> V);
407 static Constant *get(StructType *T, ...) END_WITH_NULL;
412 static Constant *getAnon(ArrayRef<Constant*> V, bool Packed = false) {
415 static Constant *getAnon(LLVMContext &Ctx,
416 ArrayRef<Constant*> V, bool Packed = false) {
420 /// getTypeForElements - Return an anonymous struct type to use for a constant
422 static StructType *getTypeForElements(ArrayRef<Constant*> V,
426 ArrayRef<Constant*> V,
430 DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
453 DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ConstantStruct, Constant)
457 /// ConstantVector - Constant Vector Declarations
459 class ConstantVector : public Constant {
461 std::vector<Constant*> >;
464 ConstantVector(VectorType *T, ArrayRef<Constant *> Val);
467 static Constant *get(ArrayRef<Constant*> V);
470 DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
479 /// This function will return true iff every element in this vector constant
481 /// @returns true iff this constant's emements are all set to all ones.
485 /// getSplatValue - If this is a splat constant, meaning that all of the
487 Constant *getSplatValue() const;
504 DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ConstantVector, Constant)
507 /// ConstantPointerNull - a constant pointer value that points to null
509 class ConstantPointerNull : public Constant {
515 : Constant(reinterpret_cast<Type*>(T),
545 class BlockAddress : public Constant {
582 /// ConstantExpr - a constant value that is initialized with an expression using
583 /// other constant values.
586 /// constant expressions. The Opcode field for the ConstantExpr class is
588 class ConstantExpr : public Constant {
590 std::pair<unsigned, std::vector<Constant*> > >;
595 : Constant(ty, ConstantExprVal, Ops, NumOps) {
603 // ConstantExpr class, because they will attempt to fold the constant
606 /// getAlignOf constant expr - computes the alignment of a type in a target
608 static Constant *getAlignOf(Type *Ty);
610 /// getSizeOf constant expr - computes the (alloc) size of a type (in
614 static Constant *getSizeOf(Type *Ty);
616 /// getOffsetOf constant expr - computes the offset of a struct field in a
619 static Constant *getOffsetOf(StructType *STy, unsigned FieldNo);
621 /// getOffsetOf constant expr - This is a generalized form of getOffsetOf,
622 /// which supports any aggregate type, and any Constant index.
624 static Constant *getOffsetOf(Type *Ty, Constant *FieldNo);
626 static Constant *getNeg(Constant *C, bool HasNUW = false, bool HasNSW =false);
627 static Constant *getFNeg(Constant *C);
628 static Constant *getNot(Constant *C);
629 static Constant *getAdd(Constant *C1, Constant *C2,
631 static Constant *getFAdd(Constant *C1, Constant *C2);
632 static Constant *getSub(Constant *C1, Constant *C2,
634 static Constant *getFSub(Constant *C1, Constant *C2);
635 static Constant *getMul(Constant *C1, Constant *C2,
637 static Constant *getFMul(Constant *C1, Constant *C2);
638 static Constant *getUDiv(Constant *C1, Constant *C2, bool isExact = false);
639 static Constant *getSDiv(Constant *C1, Constant *C2, bool isExact = false);
640 static Constant *getFDiv(Constant *C1, Constant *C2);
641 static Constant *getURem(Constant *C1, Constant *C2);
642 static Constant *getSRem(Constant *C1, Constant *C2);
643 static Constant *getFRem(Constant *C1, Constant *C2);
644 static Constant *getAnd(Constant *C1, Constant *C2);
645 static Constant *getOr(Constant *C1, Constant *C2);
646 static Constant *getXor(Constant *C1, Constant *C2);
647 static Constant *getShl(Constant *C1, Constant *C2,
649 static Constant *getLShr(Constant *C1, Constant *C2, bool isExact = false);
650 static Constant *getAShr(Constant *C1, Constant *C2, bool isExact = false);
651 static Constant *getTrunc (Constant *C, Type *Ty);
652 static Constant *getSExt (Constant *C, Type *Ty);
653 static Constant *getZExt (Constant *C, Type *Ty);
654 static Constant *getFPTrunc (Constant *C, Type *Ty);
655 static Constant *getFPExtend(Constant *C, Type *Ty);
656 static Constant *getUIToFP (Constant *C, Type *Ty);
657 static Constant *getSIToFP (Constant *C, Type *Ty);
658 static Constant *getFPToUI (Constant *C, Type *Ty);
659 static Constant *getFPToSI (Constant *C, Type *Ty);
660 static Constant *getPtrToInt(Constant *C, Type *Ty);
661 static Constant *getIntToPtr(Constant *C, Type *Ty);
662 static Constant *getBitCast (Constant *C, Type *Ty);
664 static Constant *getNSWNeg(Constant *C) { return getNeg(C, false, true); }
665 static Constant *getNUWNeg(Constant *C) { return getNeg(C, true, false); }
666 static Constant *getNSWAdd(Constant *C1, Constant *C2) {
669 static Constant *getNUWAdd(Constant *C1, Constant *C2) {
672 static Constant *getNSWSub(Constant *C1, Constant *C2) {
675 static Constant *getNUWSub(Constant *C1, Constant *C2) {
678 static Constant *getNSWMul(Constant *C1, Constant *C2) {
681 static Constant *getNUWMul(Constant *C1, Constant *C2) {
684 static Constant *getNSWShl(Constant *C1, Constant *C2) {
687 static Constant *getNUWShl(Constant *C1, Constant *C2) {
690 static Constant *getExactSDiv(Constant *C1, Constant *C2) {
693 static Constant *getExactUDiv(Constant *C1, Constant *C2) {
696 static Constant *getExactAShr(Constant *C1, Constant *C2) {
699 static Constant *getExactLShr(Constant *C1, Constant *C2) {
704 DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
708 static Constant *getCast(
710 Constant *C, ///< The constant to be converted
711 Type *Ty ///< The type to which the constant is converted
714 // @brief Create a ZExt or BitCast cast constant expression
715 static Constant *getZExtOrBitCast(
716 Constant *C, ///< The constant to zext or bitcast
720 // @brief Create a SExt or BitCast cast constant expression
721 static Constant *getSExtOrBitCast(
722 Constant *C, ///< The constant to sext or bitcast
726 // @brief Create a Trunc or BitCast cast constant expression
727 static Constant *getTruncOrBitCast(
728 Constant *C, ///< The constant to trunc or bitcast
732 /// @brief Create a BitCast or a PtrToInt cast constant expression
733 static Constant *getPointerCast(
734 Constant *C, ///< The pointer value to be casted (operand 0)
739 static Constant *getIntegerCast(
740 Constant *C, ///< The integer constant to be casted
746 static Constant *getFPCast(
747 Constant *C, ///< The integer constant to be casted
751 /// @brief Return true if this is a convert constant expression
754 /// @brief Return true if this is a compare constant expression
768 /// Select constant expr
770 static Constant *getSelect(Constant *C, Constant *V1, Constant *V2);
772 /// get - Return a binary or shift operator constant expression,
775 static Constant *get(unsigned Opcode, Constant *C1, Constant *C2,
778 /// @brief Return an ICmp or FCmp comparison operator constant expression.
779 static Constant *getCompare(unsigned short pred, Constant *C1, Constant *C2);
784 static Constant *getICmp(unsigned short pred, Constant *LHS, Constant *RHS);
785 static Constant *getFCmp(unsigned short pred, Constant *LHS, Constant *RHS);
788 /// all elements must be Constant's.
790 static Constant *getGetElementPtr(Constant *C,
791 ArrayRef<Constant *> IdxList,
797 static Constant *getGetElementPtr(Constant *C,
798 Constant *Idx,
801 // warnings about whether to convert Idx to ArrayRef<Constant *> or
805 static ConstantConstant *C,
811 static Constant *getInBoundsGetElementPtr(Constant *C,
812 ArrayRef<Constant *> IdxList) {
815 static Constant *getInBoundsGetElementPtr(Constant *C,
816 Constant *Idx) {
818 // warnings about whether to convert Idx to ArrayRef<Constant *> or
822 static Constant *getInBoundsGetElementPtr(Constant *C,
827 static Constant *getExtractElement(Constant *Vec, Constant *Idx);
828 static Constant *getInsertElement(Constant *Vec, Constant *Elt,Constant *Idx);
829 static Constant *getShuffleVector(Constant *V1, Constant *V2, Constant *Mask);
830 static Constant *getExtractValue(Constant *Agg, ArrayRef<unsigned> Idxs);
831 static Constant *getInsertValue(Constant *Agg, Constant *Val,
834 /// getOpcode - Return the opcode at the root of this constant expression
838 /// not an ICMP or FCMP constant expression.
848 /// getWithOperandReplaced - Return a constant expression identical to this
850 Constant *getWithOperandReplaced(unsigned OpNo, Constant *Op) const;
852 /// getWithOperands - This returns the current constant expression with the
855 Constant *getWithOperands(ArrayRef<Constant*> Ops) const {
859 /// getWithOperands - This returns the current constant expression with the
863 Constant *getWithOperands(ArrayRef<Constant*> Ops, Type *Ty) const;
887 DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ConstantExpr, Constant)
899 class UndefValue : public Constant {
904 explicit UndefValue(Type *T) : Constant(T, UndefValueVal, 0, 0) {}