LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
llvm::ConstantInt Class Reference

Class for constant integers. More...

#include <Constants.h>

Inheritance diagram for llvm::ConstantInt:
Inheritance graph
[legend]
Collaboration diagram for llvm::ConstantInt:
Collaboration graph
[legend]

Public Member Functions

const APIntgetValue () const
 Return the constant's value. More...
 
unsigned getBitWidth () const
 getBitWidth - Return the bitwidth of this constant. More...
 
uint64_t getZExtValue () const
 Return the zero extended value. More...
 
int64_t getSExtValue () const
 Return the sign extended value. More...
 
bool equalsInt (uint64_t V) const
 Determine if this constant's value is same as an unsigned char. More...
 
IntegerTypegetType () const
 
bool isNegative () const
 
bool isZero () const
 
bool isOne () const
 Determine if the value is one. More...
 
bool isMinusOne () const
 Determine if the value is all ones. More...
 
bool isMaxValue (bool isSigned) const
 Determine if the value is maximal. More...
 
bool isMinValue (bool isSigned) const
 Determine if the value is minimal. More...
 
bool uge (uint64_t Num) const
 Determine if the value is greater or equal to the given number. More...
 
uint64_t getLimitedValue (uint64_t Limit=~0ULL) const
 Get the constant's value with a saturation limit. More...
 
- Public Member Functions inherited from llvm::Constant
bool isNullValue () const
 
bool isAllOnesValue () const
 
bool isNegativeZeroValue () const
 
bool isZeroValue () const
 Return true if the value is negative zero or null value. More...
 
bool canTrap () const
 
bool isThreadDependent () const
 isThreadDependent - Return true if the value can vary between threads. More...
 
bool isConstantUsed () const
 
PossibleRelocationsTy getRelocationInfo () const
 
ConstantgetAggregateElement (unsigned Elt) const
 
ConstantgetAggregateElement (Constant *Elt) const
 
ConstantgetSplatValue () const
 
const APIntgetUniqueInteger () const
 
virtual void destroyConstant ()
 
virtual void replaceUsesOfWithOnConstant (Value *, Value *, Use *)
 
void removeDeadConstantUsers () const
 
- Public Member Functions inherited from llvm::User
 ~User ()
 
void operator delete (void *Usr)
 operator delete - free memory allocated for User and Use objects More...
 
void operator delete (void *, unsigned)
 placement delete - required by std, but never called. More...
 
void operator delete (void *, unsigned, bool)
 placement delete - required by std, but never called. More...
 
ValuegetOperand (unsigned i) const
 
void setOperand (unsigned i, Value *Val)
 
const UsegetOperandUse (unsigned i) const
 
UsegetOperandUse (unsigned i)
 
unsigned getNumOperands () const
 
op_iterator op_begin ()
 
const_op_iterator op_begin () const
 
op_iterator op_end ()
 
const_op_iterator op_end () const
 
value_op_iterator value_op_begin ()
 
value_op_iterator value_op_end ()
 
void dropAllReferences ()
 
void replaceUsesOfWith (Value *From, Value *To)
 
- Public Member Functions inherited from llvm::Value
virtual ~Value ()
 
void dump () const
 dump - Support for debugging, callable in GDB: V->dump() More...
 
void print (raw_ostream &O, AssemblyAnnotationWriter *AAW=0) const
 
TypegetType () const
 
LLVMContextgetContext () const
 All values hold a context through their type. More...
 
bool hasName () const
 
ValueNamegetValueName () const
 
void setValueName (ValueName *VN)
 
StringRef getName () const
 
void setName (const Twine &Name)
 
void takeName (Value *V)
 
void replaceAllUsesWith (Value *V)
 
bool use_empty () const
 
use_iterator use_begin ()
 
const_use_iterator use_begin () const
 
use_iterator use_end ()
 
const_use_iterator use_end () const
 
Useruse_back ()
 
const Useruse_back () const
 
bool hasOneUse () const
 
bool hasNUses (unsigned N) const
 
bool hasNUsesOrMore (unsigned N) const
 
bool isUsedInBasicBlock (const BasicBlock *BB) const
 
unsigned getNumUses () const
 
void addUse (Use &U)
 
unsigned getValueID () const
 
unsigned getRawSubclassOptionalData () const
 
void clearSubclassOptionalData ()
 
bool hasSameSubclassOptionalData (const Value *V) const
 
void intersectOptionalDataWith (const Value *V)
 
bool hasValueHandle () const
 
ValuestripPointerCasts ()
 Strips off any unneeded pointer casts, all-zero GEPs and aliases from the specified value, returning the original uncasted value. More...
 
const ValuestripPointerCasts () const
 
ValuestripPointerCastsNoFollowAliases ()
 Strips off any unneeded pointer casts and all-zero GEPs from the specified value, returning the original uncasted value. More...
 
const ValuestripPointerCastsNoFollowAliases () const
 
ValuestripInBoundsConstantOffsets ()
 Strips off unneeded pointer casts and all-constant GEPs from the specified value, returning the original pointer value. More...
 
const ValuestripInBoundsConstantOffsets () const
 
ValuestripAndAccumulateInBoundsConstantOffsets (const DataLayout &DL, APInt &Offset)
 Strips like stripInBoundsConstantOffsets but also accumulates the constant offset stripped. More...
 
const ValuestripAndAccumulateInBoundsConstantOffsets (const DataLayout &DL, APInt &Offset) const
 
ValuestripInBoundsOffsets ()
 Strips off unneeded pointer casts and any in-bounds offsets from the specified value, returning the original pointer value. More...
 
const ValuestripInBoundsOffsets () const
 
bool isDereferenceablePointer () const
 
ValueDoPHITranslation (const BasicBlock *CurBB, const BasicBlock *PredBB)
 
const ValueDoPHITranslation (const BasicBlock *CurBB, const BasicBlock *PredBB) const
 
void mutateType (Type *Ty)
 

Static Public Member Functions

static ConstantIntgetTrue (LLVMContext &Context)
 
static ConstantIntgetFalse (LLVMContext &Context)
 
static ConstantgetTrue (Type *Ty)
 
static ConstantgetFalse (Type *Ty)
 
static Constantget (Type *Ty, uint64_t V, bool isSigned=false)
 
static ConstantIntget (IntegerType *Ty, uint64_t V, bool isSigned=false)
 Get a ConstantInt for a specific value. More...
 
static ConstantIntgetSigned (IntegerType *Ty, int64_t V)
 Get a ConstantInt for a specific signed value. More...
 
static ConstantgetSigned (Type *Ty, int64_t V)
 
static ConstantIntget (LLVMContext &Context, const APInt &V)
 
static ConstantIntget (IntegerType *Ty, StringRef Str, uint8_t radix)
 
static Constantget (Type *Ty, const APInt &V)
 
static bool isValueValidForType (Type *Ty, uint64_t V)
 Determine if the value is in range for the given type. More...
 
static bool isValueValidForType (Type *Ty, int64_t V)
 
static bool classof (const Value *V)
 Methods to support type inquiry through isa, cast, and dyn_cast. More...
 
- Static Public Member Functions inherited from llvm::Constant
static bool classof (const Value *V)
 
static ConstantgetNullValue (Type *Ty)
 
static ConstantgetAllOnesValue (Type *Ty)
 Get the all ones value. More...
 
static ConstantgetIntegerValue (Type *Ty, const APInt &V)
 
- Static Public Member Functions inherited from llvm::User
static bool classof (const Value *V)
 

Protected Member Functions

void * operator new (size_t s)
 
- Protected Member Functions inherited from llvm::Constant
 Constant (Type *ty, ValueTy vty, Use *Ops, unsigned NumOps)
 
void destroyConstantImpl ()
 
- Protected Member Functions inherited from llvm::User
void * operator new (size_t s, unsigned Us)
 
 User (Type *ty, unsigned vty, Use *OpList, unsigned NumOps)
 
UseallocHungoffUses (unsigned) const
 
void dropHungoffUses ()
 
template<int Idx>
UseOp ()
 
template<int Idx>
const UseOp () const
 
- Protected Member Functions inherited from llvm::Value
virtual void printCustom (raw_ostream &O) const
 
 Value (Type *Ty, unsigned scid)
 
unsigned short getSubclassDataFromValue () const
 
void setValueSubclassData (unsigned short D)
 

Additional Inherited Members

- Public Types inherited from llvm::Constant
enum  PossibleRelocationsTy { NoRelocation = 0, LocalRelocation = 1, GlobalRelocations = 2 }
 
- Public Types inherited from llvm::User
typedef Useop_iterator
 
typedef const Useconst_op_iterator
 
- Public Types inherited from llvm::Value
enum  ValueTy {
  ArgumentVal, BasicBlockVal, FunctionVal, GlobalAliasVal,
  GlobalVariableVal, UndefValueVal, BlockAddressVal, ConstantExprVal,
  ConstantAggregateZeroVal, ConstantDataArrayVal, ConstantDataVectorVal, ConstantIntVal,
  ConstantFPVal, ConstantArrayVal, ConstantStructVal, ConstantVectorVal,
  ConstantPointerNullVal, MDNodeVal, MDStringVal, InlineAsmVal,
  PseudoSourceValueVal, FixedStackPseudoSourceValueVal, InstructionVal, ConstantFirstVal = FunctionVal,
  ConstantLastVal = ConstantPointerNullVal
}
 
typedef value_use_iterator< Useruse_iterator
 
typedef value_use_iterator
< const User
const_use_iterator
 
- Static Public Attributes inherited from llvm::Value
static const unsigned MaximumAlignment = 1u << 29
 
- Static Protected Member Functions inherited from llvm::User
template<int Idx, typename U >
static UseOpFrom (const U *that)
 
- Protected Attributes inherited from llvm::User
UseOperandList
 
unsigned NumOperands
 
- Protected Attributes inherited from llvm::Value
unsigned char SubclassOptionalData: 7
 

Detailed Description

Class for constant integers.

This is the shared class of boolean and integer constants. This class represents both boolean and integral constants.

Definition at line 51 of file Constants.h.

Member Function Documentation

static bool llvm::ConstantInt::classof ( const Value V)
inlinestatic

Methods to support type inquiry through isa, cast, and dyn_cast.

Definition at line 223 of file Constants.h.

References llvm::Value::ConstantIntVal, and llvm::Value::getValueID().

bool llvm::ConstantInt::equalsInt ( uint64_t  V) const
inline

Determine if this constant's value is same as an unsigned char.

A helper method that can be used to determine if the constant contained within is equal to a constant. This only works for very small values, because this is all that can be represented with all types.

Definition at line 132 of file Constants.h.

Constant * ConstantInt::get ( Type Ty,
uint64_t  V,
bool  isSigned = false 
)
static

If Ty is a vector type, return a Constant with a splat of the given value. Otherwise return a ConstantInt for the given value.

Definition at line 492 of file Constants.cpp.

References llvm::CallingConv::C, llvm::Type::getScalarType(), and llvm::ConstantVector::getSplat().

Referenced by llvm::Module::addModuleFlag(), AddOne(), AddWithOverflow(), AnalyzeLoadFromClobberingMemInst(), BitCastConstantVector(), llvm::X86TargetLowering::BuildFILD(), CoerceAvailableValueToLoadType(), CollectInsertionElements(), CollectShuffleElements(), CollectSingleShuffleElements(), llvm::InstCombiner::commonShiftTransforms(), llvm::ComputeMultiple(), computePointerICmp(), ConnectProlog(), llvm::ConstantFoldBinaryInstruction(), llvm::ConstantFoldCall(), llvm::ConstantFoldCastInstruction(), llvm::ConstantFoldCompareInstruction(), ConstantFoldConvertToInt(), ConstantFoldGetElementPtrImpl(), llvm::ConstantFoldInsertElementInstruction(), llvm::ConstantFoldInstOperands(), llvm::ConstantFoldLoadFromConstPtr(), llvm::ConstantFoldSelectInstruction(), llvm::ConstantFoldShuffleVectorInstruction(), convertMemSetToLoop(), ConvertShiftToMul(), convertTransferToLoop(), llvm::IRBuilder< true, TargetFolder >::CreateAnd(), createAndInstr(), llvm::DIBuilder::createArrayType(), llvm::DIBuilder::createArtificialType(), llvm::IRBuilder< true, TargetFolder >::CreateAShr(), llvm::DIBuilder::createBasicType(), llvm::MDBuilder::createBranchWeights(), llvm::DIBuilder::createClassType(), llvm::DIBuilder::createCompileUnit(), llvm::DIBuilder::createComplexVariable(), llvm::IRBuilder< true, TargetFolder >::CreateConstGEP1_32(), llvm::IRBuilder< true, TargetFolder >::CreateConstGEP1_64(), llvm::IRBuilder< true, TargetFolder >::CreateConstGEP2_32(), llvm::IRBuilder< true, TargetFolder >::CreateConstGEP2_64(), llvm::IRBuilder< true, TargetFolder >::CreateConstInBoundsGEP1_32(), llvm::IRBuilder< true, TargetFolder >::CreateConstInBoundsGEP1_64(), llvm::IRBuilder< true, TargetFolder >::CreateConstInBoundsGEP2_32(), llvm::IRBuilder< true, TargetFolder >::CreateConstInBoundsGEP2_64(), llvm::DIBuilder::createEnumerationType(), llvm::DIBuilder::createEnumerator(), llvm::DIBuilder::createForwardDecl(), llvm::DIBuilder::createFriend(), llvm::DIBuilder::createFunction(), llvm::IRBuilder< true, TargetFolder >::CreateGlobalStringPtr(), llvm::DIBuilder::createGlobalVariable(), llvm::DIBuilder::createImportedDeclaration(), createImportedModule(), llvm::DIBuilder::createInheritance(), llvm::DIBuilder::createLexicalBlock(), llvm::DIBuilder::createLocalVariable(), llvm::IRBuilder< true, TargetFolder >::CreateLShr(), createMalloc(), llvm::DIBuilder::createMemberPointerType(), llvm::DIBuilder::createMemberType(), llvm::DIBuilder::createMethod(), llvm::DIBuilder::createNameSpace(), llvm::DIBuilder::createObjCIVar(), llvm::DIBuilder::createObjCProperty(), llvm::DIBuilder::createObjectPointerType(), llvm::IRBuilder< true, TargetFolder >::CreateOr(), llvm::DIBuilder::createPointerType(), CreatePrologue(), llvm::DIBuilder::createQualifiedType(), llvm::MDBuilder::createRange(), llvm::DIBuilder::createReferenceType(), llvm::IRBuilder< true, TargetFolder >::CreateShl(), llvm::DIBuilder::createStaticMemberType(), llvm::DIBuilder::createStaticVariable(), llvm::DIBuilder::createStructType(), llvm::DIBuilder::createSubroutineType(), llvm::MDBuilder::createTBAANode(), llvm::MDBuilder::createTBAAScalarTypeNode(), llvm::MDBuilder::createTBAAStructNode(), llvm::MDBuilder::createTBAAStructTagNode(), llvm::MDBuilder::createTBAAStructTypeNode(), llvm::DIBuilder::createTemplateTypeParameter(), llvm::DIBuilder::createTypedef(), llvm::DIBuilder::createUnionType(), llvm::DIBuilder::createUnspecifiedType(), llvm::IRBuilder< true, TargetFolder >::CreateVectorSplat(), llvm::DIBuilder::createVectorType(), llvm::IRBuilder< true, TargetFolder >::CreateXor(), decomposeBitTestICmp(), DecomposeSimpleLinearExpr(), dyn_castFoldableMul(), dyn_castNotVal(), llvm::EmitFWrite(), llvm::EmitGEPOffset(), llvm::Thumb2RegisterInfo::emitLoadConstPool(), llvm::Thumb1RegisterInfo::emitLoadConstPool(), llvm::ARMBaseRegisterInfo::emitLoadConstPool(), llvm::EmitStrChr(), EvaluateGEPOffsetExpression(), ExtractConstantBytes(), FactorOutConstant(), llvm::FastISel::FastEmit_ri_(), llvm::InstCombiner::FoldAndOfFCmps(), llvm::InstCombiner::FoldAndOfICmps(), FoldBitCast(), llvm::InstCombiner::FoldCmpLoadFromIndexedGlobal(), llvm::InstCombiner::FoldICmpAddOpCst(), llvm::InstCombiner::FoldICmpShrCst(), llvm::InstCombiner::FoldOrOfFCmps(), FoldReinterpretLoadFromConstPtr(), foldSelectICmpAnd(), llvm::InstCombiner::FoldShiftByConstant(), foldUDivNegCst(), foldUDivPow2Cst(), foldUDivShl(), for(), GatherConstantCompares(), getAISize(), llvm::ConstantExpr::getAlignOf(), llvm::Constant::getAllOnesValue(), llvm::DebugLoc::getAsMDNode(), llvm::ConstantExpr::getBinOpIdentity(), llvm::LazyValueInfo::getConstant(), llvm::SelectionDAG::getConstant(), llvm::ScalarEvolution::getConstant(), GetConstantInt(), llvm::LazyValueInfo::getConstantOnEdge(), getEdgeValueLocal(), llvm::ConstantDataSequential::getElementAsConstant(), getFalse(), getFoldedAlignOf(), getFoldedSizeOf(), llvm::getICmpValue(), llvm::IRBuilderBase::getInt(), llvm::IRBuilderBase::getInt1(), llvm::IRBuilderBase::getInt16(), llvm::IRBuilderBase::getInt32(), llvm::IRBuilderBase::getInt64(), llvm::IRBuilderBase::getInt8(), llvm::Constant::getIntegerValue(), getLogBase2Vector(), GetMemInstValueForLoad(), llvm::MDNode::getMostGenericTBAA(), llvm::ScalarEvolution::getMulExpr(), llvm::Constant::getNullValue(), llvm::SCEVAddRecExpr::getNumIterationsInRange(), llvm::ConstantExpr::getOffsetOf(), getOne(), llvm::DIBuilder::getOrCreateSubrange(), GetSelectFoldableConstant(), GetShiftedValue(), llvm::ConstantExpr::getSizeOf(), llvm::ScalarEvolution::getSMaxExpr(), GetTagConstant(), getTrue(), llvm::ScalarEvolution::getUMaxExpr(), HandleByValArgument(), llvm::InlineFunction(), llvm::DIBuilder::insertDbgValueIntrinsic(), InstallGlobalCtors(), llvm::isBytewiseValue(), LLVMConstInt(), LLVMConstIntOfArbitraryPrecision(), LLVMConstIntOfString(), LLVMConstIntOfStringAndSize(), LowerBSWAP(), LowerCTLZ(), LowerCTPOP(), llvm::IntrinsicLowering::LowerIntrinsicCall(), LowerSIGN_EXTEND_AVX512(), llvm::MergeBasicBlockIntoOnlyPred(), llvm::ObjectSizeOffsetEvaluator::ObjectSizeOffsetEvaluator(), PerformHeapAllocSRoA(), llvm::replaceDbgDeclareForAlloca(), llvm::JIT::runFunction(), llvm::NVPTXLowerAggrCopies::runOnFunction(), ShrinkDemandedConstant(), SimplifyCondBranchToCondBranch(), SimplifyDiv(), SimplifyFCmpInst(), SimplifyICmpInst(), llvm::InstCombiner::SliceUpIllegalIntegerPHI(), SolveQuadraticEquation(), stripAndComputeConstantOffsets(), SubOne(), SubWithOverflow(), SymbolicallyEvaluateBinop(), SymbolicallyEvaluateGEP(), tryMergeRange(), TryToOptimizeStoreOfMallocToGlobal(), TryToShrinkGlobalToBoolean(), TurnSwitchRangeIntoICmp(), llvm::UnrollRuntimeLoopProlog(), llvm::UpgradeIntrinsicCall(), llvm::InstCombiner::visitAdd(), llvm::InstCombiner::visitAllocaInst(), llvm::ObjectSizeOffsetEvaluator::visitAllocaInst(), llvm::InstCombiner::visitAllocSite(), llvm::InstCombiner::visitCallInst(), llvm::InstCombiner::visitExtractElementInst(), llvm::InstCombiner::visitICmpInst(), llvm::InstCombiner::visitICmpInstWithInstAndIntCst(), llvm::InstCombiner::visitMul(), llvm::InstCombiner::visitSDiv(), llvm::InstCombiner::visitSelectInstWithICmp(), llvm::InstCombiner::visitSExt(), llvm::InstCombiner::visitShuffleVectorInst(), llvm::InstCombiner::visitSub(), llvm::InstCombiner::visitTrunc(), llvm::InstCombiner::visitXor(), llvm::InstCombiner::visitZExt(), and llvm::BasicBlock::~BasicBlock().

ConstantInt * ConstantInt::get ( IntegerType Ty,
uint64_t  V,
bool  isSigned = false 
)
static

Get a ConstantInt for a specific value.

Return a ConstantInt with the specified integer value for the specified type. If the type is wider than 64 bits, the value will be zero-extended to fit the type, unless isSigned is true, in which case the value will be interpreted as a 64-bit signed integer and sign-extended to fit the type.

Definition at line 502 of file Constants.cpp.

References llvm::IntegerType::getBitWidth(), and llvm::Type::getContext().

ConstantInt * ConstantInt::get ( LLVMContext Context,
const APInt V 
)
static

Return a ConstantInt with the specified value and an implied Type. The type is the integer type that corresponds to the bit width of the value.

Definition at line 482 of file Constants.cpp.

References llvm::IntegerType::get(), llvm::APInt::getBitWidth(), and llvm::LLVMContext::pImpl.

ConstantInt * ConstantInt::get ( IntegerType Ty,
StringRef  Str,
uint8_t  radix 
)
static

Return a ConstantInt constructed from the string strStart with the given radix.

Definition at line 527 of file Constants.cpp.

References llvm::IntegerType::getBitWidth(), and llvm::Type::getContext().

Constant * ConstantInt::get ( Type Ty,
const APInt V 
)
static

If Ty is a vector type, return a Constant with a splat of the given value. Otherwise return a ConstantInt for the given value.

Definition at line 515 of file Constants.cpp.

References llvm::CallingConv::C, llvm::Type::getContext(), llvm::Type::getScalarType(), llvm::ConstantVector::getSplat(), and getType().

unsigned llvm::ConstantInt::getBitWidth ( ) const
inline
ConstantInt * ConstantInt::getFalse ( LLVMContext Context)
static
Constant * ConstantInt::getFalse ( Type Ty)
static
uint64_t llvm::ConstantInt::getLimitedValue ( uint64_t  Limit = ~0ULL) const
inline

Get the constant's value with a saturation limit.

getLimitedValue - If the value is smaller than the specified limit, return it, otherwise return the limit value. This causes the value to saturate to the limit.

Returns
the min of the value of the constant and the specified value

Definition at line 218 of file Constants.h.

References llvm::APInt::getLimitedValue().

Referenced by CanEvaluateShifted(), CanEvaluateShuffled(), dyn_castFoldableMul(), llvm::InstCombiner::FoldICmpShrCst(), llvm::InstCombiner::FoldShiftByConstant(), llvm::InstCombiner::visitICmpInst(), llvm::InstCombiner::visitICmpInstWithInstAndIntCst(), and llvm::InstCombiner::visitUDiv().

int64_t llvm::ConstantInt::getSExtValue ( ) const
inline

Return the sign extended value.

Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the type of this constant. Note that this method can assert if the value does not fit in 64 bits.

Definition at line 124 of file Constants.h.

References llvm::APInt::getSExtValue().

Referenced by canFoldIVIncExpr(), EvaluateGEPOffsetExpression(), GetOffsetFromIndex(), isIndexInRangeOfSequentialType(), and X86ChooseCmpImmediateOpcode().

ConstantInt * ConstantInt::getSigned ( IntegerType Ty,
int64_t  V 
)
static

Get a ConstantInt for a specific signed value.

Return a ConstantInt with the specified value for the specified type. The value V will be canonicalized to a an unsigned APInt. Accessing it with either getSExtValue() or getZExtValue() will yield a correctly sized and signed value for the type Ty.

Definition at line 507 of file Constants.cpp.

Referenced by llvm::InstCombiner::FoldOrOfICmps(), generateUnsignedDivisionCode(), insertFastDiv(), llvm::InstCombiner::visitLShr(), and llvm::InstCombiner::visitOr().

Constant * ConstantInt::getSigned ( Type Ty,
int64_t  V 
)
static

Definition at line 511 of file Constants.cpp.

ConstantInt * ConstantInt::getTrue ( LLVMContext Context)
static
Constant * ConstantInt::getTrue ( Type Ty)
static
IntegerType* llvm::ConstantInt::getType ( ) const
inline
const APInt& llvm::ConstantInt::getValue ( ) const
inline

Return the constant's value.

Return the constant as an APInt value reference. This allows clients to obtain a copy of the value, with all its precision in tact.

Definition at line 105 of file Constants.h.

Referenced by llvm::GEPOperator::accumulateConstantOffset(), llvm::CompileUnit::addConstantValue(), AddOne(), CanEvaluateShifted(), canFoldIVIncExpr(), llvm::computeMaskedBitsLoad(), llvm::ComputeMultiple(), computePointerICmp(), llvm::ConstantFoldBinaryInstruction(), llvm::ConstantFoldInsertElementInstruction(), llvm::ConstantFoldTerminator(), ConstantIntSortPredicate(), DemandedBitsLHSMask(), emitDebugValueComment(), emitGlobalConstantLargeInt(), ExtractBranchMetadata(), FactorOutConstant(), llvm::InstCombiner::FoldAndOfICmps(), llvm::InstCombiner::FoldICmpAddOpCst(), llvm::InstCombiner::FoldICmpDivCst(), foldLogOpOfMaskedICmps(), llvm::InstCombiner::FoldOrOfICmps(), llvm::InstCombiner::FoldOrWithConstants(), foldSelectICmpAnd(), GatherConstantCompares(), gcd(), GetBranchWeights(), llvm::SelectionDAG::getConstant(), getEdgeValueLocal(), getExactSDiv(), llvm::MDNode::getMostGenericRange(), llvm::SCEVAddRecExpr::getNumIterationsInRange(), llvm::LazyValueInfo::getPredicateOnEdge(), GetShiftedValue(), llvm::ScalarEvolution::getSmallConstantTripCount(), llvm::ScalarEvolution::getSmallConstantTripMultiple(), getTypeOfMaskedICmp(), llvm::ScalarEvolution::getUDivExpr(), HasAddOverflow(), HasSubOverflow(), isDereferenceablePointer(), llvm::ConstantExpr::isGEPWithNoNotionalOverIndexing(), isHighOnes(), isIndexInRangeOfSequentialType(), isLikelyComplexAddressComputation(), llvm::SCEV::isNonConstantNegative(), isRemainderZero(), isRunOfOnes(), isSignBitCheck(), isStridedPtr(), MaintainNoSignedWrap(), MultiplyOverflows(), ProcessUGT_ADDCST_ADD(), sdiv(), ShrinkDemandedConstant(), SimplifyICmpInst(), srem(), SubOne(), SwitchToLookupTable(), tryMergeRange(), llvm::InstCombiner::visitAdd(), llvm::InstCombiner::visitAnd(), llvm::ObjectSizeOffsetVisitor::visitCallSite(), llvm::InstCombiner::visitICmpInst(), llvm::InstCombiner::visitICmpInstWithInstAndIntCst(), llvm::InstCombiner::visitOr(), llvm::InstCombiner::visitSelectInstWithICmp(), llvm::InstCombiner::visitSub(), and llvm::InstCombiner::visitXor().

uint64_t llvm::ConstantInt::getZExtValue ( ) const
inline
bool llvm::ConstantInt::isMaxValue ( bool  isSigned) const
inline

Determine if the value is maximal.

This function will return true iff this constant represents the largest value that may be represented by the constant's type.

Returns
true iff this is the largest value that may be represented by this type.

Definition at line 185 of file Constants.h.

References llvm::APInt::isMaxSignedValue(), and llvm::APInt::isMaxValue().

Referenced by isSignBitCheck().

bool llvm::ConstantInt::isMinusOne ( ) const
inline

Determine if the value is all ones.

This function will return true iff every bit in this constant is set to true.

Returns
true iff this constant's bits are all set to true.

Definition at line 176 of file Constants.h.

References llvm::APInt::isAllOnesValue().

bool llvm::ConstantInt::isMinValue ( bool  isSigned) const
inline

Determine if the value is minimal.

This function will return true iff this constant represents the smallest value that may be represented by this constant's type.

Returns
true if this is the smallest value that may be represented by this type.

Definition at line 197 of file Constants.h.

References llvm::APInt::isMinSignedValue(), and llvm::APInt::isMinValue().

bool llvm::ConstantInt::isNegative ( ) const
inline
bool llvm::ConstantInt::isOne ( ) const
inline

Determine if the value is one.

This is just a convenience method to make client code smaller for a common case. It also correctly performs the comparison without the potential for an assertion from getZExtValue().

Definition at line 168 of file Constants.h.

Referenced by llvm::ConstantFoldCastInstruction(), llvm::FoldBranchToCommonDest(), llvm::InstCombiner::FoldICmpDivCst(), IsOneHotValue(), isSelect01(), and isSignTest().

bool ConstantInt::isValueValidForType ( Type Ty,
uint64_t  V 
)
static

Determine if the value is in range for the given type.

This static method returns true if the type Ty is big enough to represent the value V. This can be used to avoid having the get method assert when V is larger than Ty can represent. Note that there are two versions of this method, one for unsigned and one for signed integers. Although ConstantInt canonicalizes everything to an unsigned integer, the signed version avoids callers having to convert a signed quantity to the appropriate unsigned type before calling the method.

Returns
true if V is a valid value for type Ty

Definition at line 1159 of file Constants.cpp.

References llvm::Type::getIntegerBitWidth(), and llvm::Type::isIntegerTy().

Referenced by llvm::X86TargetLowering::LowerAsmOperandForConstraint().

bool ConstantInt::isValueValidForType ( Type Ty,
int64_t  V 
)
static

Definition at line 1169 of file Constants.cpp.

References llvm::Type::getIntegerBitWidth(), and llvm::Type::isIntegerTy().

bool llvm::ConstantInt::isZero ( ) const
inline
void* llvm::ConstantInt::operator new ( size_t  s)
inlineprotected

Definition at line 59 of file Constants.h.

bool llvm::ConstantInt::uge ( uint64_t  Num) const
inline

Determine if the value is greater or equal to the given number.

This function will return true iff this constant represents a value with active bits bigger than 64 bits or a value greater than the given uint64_t value.

Returns
true iff this constant is greater or equal to the given number.

Definition at line 209 of file Constants.h.

References llvm::APInt::getActiveBits(), and llvm::APInt::getZExtValue().

Referenced by llvm::InstCombiner::FoldShiftByConstant(), and llvm::InstCombiner::visitICmpInstWithInstAndIntCst().


The documentation for this class was generated from the following files: