21 #ifndef LLVM_IR_CONSTANTS_H 22 #define LLVM_IR_CONSTANTS_H 68 void *
operator new(
size_t s) {
return User::operator
new(s, 0); }
75 return V->
getValueID() >= ConstantDataFirstVal &&
91 void destroyConstantImpl();
112 bool isSigned =
false);
185 static bool isValueValidForType(
Type *Ty, uint64_t V);
186 static bool isValueValidForType(
Type *Ty, int64_t V);
242 bool uge(uint64_t Num)
const {
271 void destroyConstantImpl();
293 static Constant *getNaN(
Type *Ty,
bool Negative =
false,
unsigned type = 0);
295 static Constant *getInfinity(
Type *Ty,
bool Negative =
false);
298 static bool isValueValidForType(
Type *Ty,
const APFloat &V);
319 bool isExactlyValue(
const APFloat &V)
const;
325 return isExactlyValue(FV);
343 void destroyConstantImpl();
352 Constant *getSequentialElement()
const;
356 Constant *getStructElement(
unsigned Elt)
const;
363 Constant *getElementValue(
unsigned Idx)
const;
366 unsigned getNumElements()
const;
371 return V->
getValueID() == ConstantAggregateZeroVal;
396 return V->
getValueID() >= ConstantAggregateFirstVal &&
416 void destroyConstantImpl();
448 void destroyConstantImpl();
455 template <
typename... Csts>
460 return get(
T, Values);
466 return get(getTypeForElements(V, Packed), V);
470 return get(getTypeForElements(Ctx, V, Packed), V);
476 bool Packed =
false);
480 bool Packed =
false);
502 void destroyConstantImpl();
541 void destroyConstantImpl();
557 return V->
getValueID() == ConstantPointerNullVal;
576 const char *DataElements;
584 void destroyConstantImpl();
588 :
ConstantData(ty, VT), DataElements(Data), Next(nullptr) {}
600 static bool isElementTypeCompatible(
Type *Ty);
604 uint64_t getElementAsInteger(
unsigned i)
const;
608 APInt getElementAsAPInt(
unsigned i)
const;
612 APFloat getElementAsAPFloat(
unsigned i)
const;
616 float getElementAsFloat(
unsigned i)
const;
620 double getElementAsDouble(
unsigned i)
const;
625 Constant *getElementAsConstant(
unsigned i)
const;
634 Type *getElementType()
const;
637 unsigned getNumElements()
const;
641 uint64_t getElementByteSize()
const;
644 bool isString(
unsigned CharSize = 8)
const;
648 bool isCString()
const;
653 assert(isString() &&
"Not a string");
654 return getRawDataValues();
660 assert(isCString() &&
"Isn't a C string");
672 return V->
getValueID() == ConstantDataArrayVal ||
677 const char *getElementPointer(
unsigned Elt)
const;
698 template <
typename ElementTy>
700 const char *
Data =
reinterpret_cast<const char *
>(Elts.data());
701 return getRaw(
StringRef(Data, Elts.size() *
sizeof(ElementTy)), Elts.
size(),
702 Type::getScalarTy<ElementTy>(
Context));
707 template <
typename ArrayTy>
738 bool AddNull =
true);
748 return V->
getValueID() == ConstantDataArrayVal;
807 return V->
getValueID() == ConstantDataVectorVal;
820 void destroyConstantImpl();
830 return V->
getValueID() == ConstantTokenNoneVal;
841 void *
operator new(
size_t s) {
return User::operator
new(s, 2); }
843 void destroyConstantImpl();
889 void destroyConstantImpl();
894 :
Constant(ty, ConstantExprVal, Ops, NumOps) {
929 bool HasNUW =
false,
bool HasNSW =
false);
932 bool HasNUW =
false,
bool HasNSW =
false);
935 bool HasNUW =
false,
bool HasNSW =
false);
947 bool HasNUW =
false,
bool HasNSW =
false);
954 bool OnlyIfReduced =
false);
956 bool OnlyIfReduced =
false);
962 bool OnlyIfReduced =
false);
964 bool OnlyIfReduced =
false);
966 bool OnlyIfReduced =
false);
968 bool OnlyIfReduced =
false);
974 return getAdd(C1, C2,
false,
true);
978 return getAdd(C1, C2,
true,
false);
982 return getSub(C1, C2,
false,
true);
986 return getSub(C1, C2,
true,
false);
990 return getMul(C1, C2,
false,
true);
994 return getMul(C1, C2,
true,
false);
998 return getShl(C1, C2,
false,
true);
1002 return getShl(C1, C2,
true,
false);
1006 return getSDiv(C1, C2,
true);
1010 return getUDiv(C1, C2,
true);
1014 return getAShr(C1, C2,
true);
1018 return getLShr(C1, C2,
true);
1028 static Constant *getBinOpIdentity(
unsigned Opcode,
Type *Ty,
1029 bool AllowRHSConstant =
false);
1035 static Constant *getBinOpAbsorber(
unsigned Opcode,
Type *Ty);
1047 bool OnlyIfReduced =
false);
1062 static Constant *getTruncOrBitCast(
1076 static Constant *getPointerBitCastOrAddrSpaceCast(
1095 bool isCast()
const;
1098 bool isCompare()
const;
1102 bool hasIndices()
const;
1109 bool isGEPWithNoNotionalOverIndexing()
const;
1115 Type *OnlyIfReducedTy =
nullptr);
1122 unsigned Flags = 0,
Type *OnlyIfReducedTy =
nullptr);
1128 bool OnlyIfReduced =
false);
1134 bool OnlyIfReduced =
false);
1136 bool OnlyIfReduced =
false);
1145 bool InBounds =
false,
1147 Type *OnlyIfReducedTy =
nullptr) {
1148 return getGetElementPtr(
1150 InBounds, InRangeIndex, OnlyIfReducedTy);
1153 bool InBounds =
false,
1155 Type *OnlyIfReducedTy =
nullptr) {
1159 return getGetElementPtr(Ty, C, cast<Value>(Idx), InBounds, InRangeIndex,
1164 bool InBounds =
false,
1166 Type *OnlyIfReducedTy =
nullptr);
1172 return getGetElementPtr(Ty, C, IdxList,
true);
1179 return getGetElementPtr(Ty, C, Idx,
true);
1183 return getGetElementPtr(Ty, C, IdxList,
true);
1187 Type *OnlyIfReducedTy =
nullptr);
1189 Type *OnlyIfReducedTy =
nullptr);
1191 Type *OnlyIfReducedTy =
nullptr);
1193 Type *OnlyIfReducedTy =
nullptr);
1196 Type *OnlyIfReducedTy =
nullptr);
1210 const char *getOpcodeName()
const;
1220 return getWithOperands(Ops,
getType());
1233 bool OnlyIfReduced =
false,
1234 Type *SrcTy =
nullptr)
const;
1280 void destroyConstantImpl();
1294 UndefValue *getStructElement(
unsigned Elt)
const;
1301 UndefValue *getElementValue(
unsigned Idx)
const;
1304 unsigned getNumElements()
const;
1314 #endif // LLVM_IR_CONSTANTS_H A vector constant whose element type is a simple 1/2/4/8-byte integer or float/double, and whose elements are just simple data values (i.e.
unsigned short getSubclassDataFromValue() const
IntegerType * getType() const
getType - Specialize the getType() method to always return an IntegerType, which reduces the amount o...
unsigned getOpcode() const
Return the opcode at the root of this constant expression.
uint64_t getZExtValue() const
Get zero extended value.
unsigned getValueID() const
Return an ID for the concrete type of this object.
Compute iterated dominance frontiers using a linear time algorithm.
static Constant * getNSWAdd(Constant *C1, Constant *C2)
static Constant * getGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant *> IdxList, bool InBounds=false, Optional< unsigned > InRangeIndex=None, Type *OnlyIfReducedTy=nullptr)
Getelementptr form.
ConstantDataSequential(Type *ty, ValueTy VT, const char *Data)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
static Constant * getExactSDiv(Constant *C1, Constant *C2)
static bool classof(const Value *V)
Methods for support type inquiry through isa, cast, and dyn_cast:
StringRef getAsCString() const
If this array is isCString(), then this method returns the array (without the trailing null byte) as ...
static Constant * getNUWShl(Constant *C1, Constant *C2)
const fltSemantics & getSemantics() const
bool equalsInt(uint64_t V) const
A helper method that can be used to determine if the constant contained within is equal to a constant...
static Constant * getRaw(StringRef Data, uint64_t NumElements, Type *ElementTy)
get() constructor - Return a constant with array type with an element count and element type matching...
static bool classof(const Value *V)
Methods for support type inquiry through isa, cast, and dyn_cast:
static Constant * getTrue(Type *Ty)
For a boolean type or a vector of boolean type, return true or a vector with every element true...
static bool classof(const Value *V)
Methods for support type inquiry through isa, cast, and dyn_cast:
unsigned getBitWidth() const
getBitWidth - Return the bitwidth of this constant.
unsigned getBitWidth() const
Return the number of bits in the APInt.
Function * getFunction() const
The address of a basic block.
bool isExactlyValue(double V) const
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
'undef' values are things that do not have specified contents.
Class to represent struct types.
A Use represents the edge between a Value definition and its users.
static bool classof(const Value *V)
Methods for support type inquiry through isa, cast, and dyn_cast:
static Constant * getNUWNeg(Constant *C)
bool uge(uint64_t Num) const
This function will return true iff this constant represents a value with active bits bigger than 64 b...
static Constant * getExactAShr(Constant *C1, Constant *C2)
static bool classof(const Value *V)
Methods for support type inquiry through isa, cast, and dyn_cast:
static const uint16_t * lookup(unsigned opcode, unsigned domain, ArrayRef< uint16_t[3]> Table)
static bool classof(const Value *V)
Methods for support type inquiry through isa, cast, and dyn_cast:
This file implements a class to represent arbitrary precision integral constant values and operations...
All zero aggregate value.
bool isOne() const
This is just a convenience method to make client code smaller for a common case.
#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)
Macro for generating out-of-class operand accessor definitions.
A constant value that is initialized with an expression using other constant values.
int64_t getSExtValue() const
Get sign extended value.
Type * getType() const
All values are typed, get the type of this value.
ArrayType * getType() const
Specialize the getType() method to always return an ArrayType, which reduces the amount of casting ne...
opStatus convert(const fltSemantics &ToSemantics, roundingMode RM, bool *losesInfo)
static bool classof(const Value *V)
Methods to support type inquiry through isa, cast, and dyn_cast.
static Constant * getGetElementPtr(Type *Ty, Constant *C, Constant *Idx, bool InBounds=false, Optional< unsigned > InRangeIndex=None, Type *OnlyIfReducedTy=nullptr)
static bool classof(const Value *V)
Methods for support type inquiry through isa, cast, and dyn_cast:
ConstantDataSequential - A vector or array constant whose element type is a simple 1/2/4/8-byte integ...
bool isNegative() const
Return true if the sign bit is set.
Class to represent array types.
static bool classof(const Value *V)
Methods for support type inquiry through isa, cast, and dyn_cast:
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
const APInt & getValue() const
Return the constant as an APInt value reference.
BasicBlock * getBasicBlock() const
bool isMinusOne() const
This function will return true iff every bit in this constant is set to true.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
static Constant * getNSWNeg(Constant *C)
Class to represent pointers.
VectorType * getType() const
Specialize the getType() method to always return a VectorType, which reduces the amount of casting ne...
bool isNegative() const
Determine sign of this APInt.
bool isAllOnesValue() const
Determine if all bits are set.
ConstantExpr(Type *ty, unsigned Opcode, Use *Ops, unsigned NumOps)
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
An array constant whose element type is a simple 1/2/4/8-byte integer or float/double, and whose elements are just simple data values (i.e.
LLVM Basic Block Representation.
static Constant * getAnon(LLVMContext &Ctx, ArrayRef< Constant *> V, bool Packed=false)
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
A constant token which is empty.
size_t size() const
size - Get the array size.
This is an important base class in LLVM.
ConstantFP - Floating Point Values [float, double].
bool isOneValue() const
Determine if this is a value of 1.
static Constant * getNSWShl(Constant *C1, Constant *C2)
bool isMinSignedValue() const
Determine if this is the smallest signed value.
This file declares a class to represent arbitrary precision floating point values and provide a varie...
bool isMaxValue(bool isSigned) const
This function will return true iff this constant represents the largest value that may be represented...
static bool classof(const Value *V)
Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const Value *V)
Methods to support type inquiry through isa, cast, and dyn_cast.
Class to represent integer types.
Constant Vector Declarations.
#define DECLARE_TRANSPARENT_OPERAND_ACCESSORS(VALUECLASS)
Macro for generating in-class operand accessor declarations.
Constant * getWithOperands(ArrayRef< Constant *> Ops) const
This returns the current constant expression with the operands replaced with the specified values...
static Constant * getInBoundsGetElementPtr(Type *Ty, Constant *C, Constant *Idx)
Constant * getSplatValue() const
If this is a splat vector constant, meaning that all of the elements have the same value...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const APFloat & getValueAPF() const
bool isMinValue(bool isSigned) const
This function will return true iff this constant represents the smallest value that may be represente...
This is the superclass of the array and vector type classes.
static bool classof(const Value *V)
Methods for support type inquiry through isa, cast, and dyn_cast:
Predicate getPredicate(unsigned Condition, unsigned Hint)
Return predicate consisting of specified condition and hint bits.
uint64_t getLimitedValue(uint64_t Limit=~0ULL) const
getLimitedValue - If the value is smaller than the specified limit, return it, otherwise return the l...
bool isMaxSignedValue() const
Determine if this is the largest signed value.
This is the shared class of boolean and integer constants.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
StringRef getAsString() const
If this array is isString(), then this method returns the array as a StringRef.
A constant pointer value that points to null.
static Constant * getNUWMul(Constant *C1, Constant *C2)
bool isMaxValue() const
Determine if this is the largest unsigned value.
static Constant * getNSWSub(Constant *C1, Constant *C2)
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static bool classof(const Value *V)
Methods for support type inquiry through isa, cast, and dyn_cast:
bool uge(const APInt &RHS) const
Unsigned greater or equal comparison.
ValueTy
Concrete subclass of this.
void setValueSubclassData(unsigned short D)
Class to represent vector types.
ConstantArray - Constant Array Declarations.
Class for arbitrary precision integers.
static Constant * getFalse(Type *Ty)
For a boolean type or a vector of boolean type, return false or a vector with every element false...
~ConstantDataSequential()
ArrayType * getType() const
Specialize the getType() method to always return an ArrayType, which reduces the amount of casting ne...
Common super class of ArrayType, StructType and VectorType.
static bool classof(const Value *V)
Methods for support type inquiry through isa, cast, and dyn_cast:
static Constant * getInBoundsGetElementPtr(Type *Ty, Constant *C, ArrayRef< Value *> IdxList)
static Constant * getNSWMul(Constant *C1, Constant *C2)
SequentialType * getType() const
Specialize the getType() method to always return a SequentialType, which reduces the amount of castin...
uint64_t getLimitedValue(uint64_t Limit=UINT64_MAX) const
If this value is smaller than the specified limit, return it, otherwise return the limit value...
bool isZero() const
Return true if the value is positive or negative zero.
VectorType * getType() const
Specialize the getType() method to always return a VectorType, which reduces the amount of casting ne...
bool isNaN() const
Return true if the value is a NaN.
static bool isSigned(Value *V)
Can the given value generate sign bits.
static Constant * getInBoundsGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant *> IdxList)
Create an "inbounds" getelementptr.
static Constant * getExactLShr(Constant *C1, Constant *C2)
PointerType * getType() const
Specialize the getType() method to always return an PointerType, which reduces the amount of casting ...
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
bool isInfinity() const
Return true if the value is infinity.
static ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
Compile-time customization of User operands.
bool isMinValue() const
Determine if this is the smallest unsigned value.
static bool classof(const Value *V)
Methods to support type inquiry through isa, cast, and dyn_cast.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Base class for aggregate constants (with operands).
traits class for checking whether type T is a base class for all the given types in the variadic list...
LLVM Value Representation.
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
static Constant * getAnon(ArrayRef< Constant *> V, bool Packed=false)
Return an anonymous struct that has the specified elements.
static Constant * get(LLVMContext &Context, ArrayRef< ElementTy > Elts)
get() constructor - Return a constant with array type with an element count and element type matching...
StringRef - Represent a constant reference to a string, i.e.
FixedNumOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
static bool isSplat(ArrayRef< Value *> VL)
ConstantData(Type *Ty, ValueTy VT)
static Constant * getExactUDiv(Constant *C1, Constant *C2)
static bool classof(const Value *V)
Methods for support type inquiry through isa, cast, and dyn_cast:
VariadicOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
int64_t getSExtValue() const
Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the ...
static LazyValueInfoImpl & getImpl(void *&PImpl, AssumptionCache *AC, const DataLayout *DL, DominatorTree *DT=nullptr)
This lazily constructs the LazyValueInfoImpl.
static Constant * getNUWSub(Constant *C1, Constant *C2)
Base class for constants with no operands.
static Constant * getNUWAdd(Constant *C1, Constant *C2)
StructType * getType() const
Specialization - reduce amount of casting.
bool isNullValue() const
Determine if all bits are clear.