LLVM  8.0.1
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
llvm::KnownBits Struct Reference

#include "llvm/Support/KnownBits.h"

Collaboration diagram for llvm::KnownBits:
Collaboration graph
[legend]

Public Member Functions

 KnownBits ()
 
 KnownBits (unsigned BitWidth)
 Create a known bits object of BitWidth bits initialized to unknown. More...
 
unsigned getBitWidth () const
 Get the bit width of this value. More...
 
bool hasConflict () const
 Returns true if there is conflicting information. More...
 
bool isConstant () const
 Returns true if we know the value of all bits. More...
 
const APIntgetConstant () const
 Returns the value when all bits have a known value. More...
 
bool isUnknown () const
 Returns true if we don't know any bits. More...
 
void resetAll ()
 Resets the known state of all bits. More...
 
bool isZero () const
 Returns true if value is all zero. More...
 
bool isAllOnes () const
 Returns true if value is all one bits. More...
 
void setAllZero ()
 Make all bits known to be zero and discard any previous information. More...
 
void setAllOnes ()
 Make all bits known to be one and discard any previous information. More...
 
bool isNegative () const
 Returns true if this value is known to be negative. More...
 
bool isNonNegative () const
 Returns true if this value is known to be non-negative. More...
 
void makeNegative ()
 Make this value negative. More...
 
void makeNonNegative ()
 Make this value non-negative. More...
 
KnownBits trunc (unsigned BitWidth)
 Truncate the underlying known Zero and One bits. More...
 
KnownBits zext (unsigned BitWidth)
 Zero extends the underlying known Zero and One bits. More...
 
KnownBits sext (unsigned BitWidth)
 Sign extends the underlying known Zero and One bits. More...
 
KnownBits zextOrTrunc (unsigned BitWidth)
 Zero extends or truncates the underlying known Zero and One bits. More...
 
unsigned countMinTrailingZeros () const
 Returns the minimum number of trailing zero bits. More...
 
unsigned countMinTrailingOnes () const
 Returns the minimum number of trailing one bits. More...
 
unsigned countMinLeadingZeros () const
 Returns the minimum number of leading zero bits. More...
 
unsigned countMinLeadingOnes () const
 Returns the minimum number of leading one bits. More...
 
unsigned countMinSignBits () const
 Returns the number of times the sign bit is replicated into the other bits. More...
 
unsigned countMaxTrailingZeros () const
 Returns the maximum number of trailing zero bits possible. More...
 
unsigned countMaxTrailingOnes () const
 Returns the maximum number of trailing one bits possible. More...
 
unsigned countMaxLeadingZeros () const
 Returns the maximum number of leading zero bits possible. More...
 
unsigned countMaxLeadingOnes () const
 Returns the maximum number of leading one bits possible. More...
 
unsigned countMinPopulation () const
 Returns the number of bits known to be one. More...
 
unsigned countMaxPopulation () const
 Returns the maximum number of bits that could be one. More...
 

Static Public Member Functions

static KnownBits computeForAddSub (bool Add, bool NSW, const KnownBits &LHS, KnownBits RHS)
 Compute known bits resulting from adding LHS and RHS. More...
 

Public Attributes

APInt Zero
 
APInt One
 

Detailed Description

Definition at line 23 of file KnownBits.h.

Constructor & Destructor Documentation

◆ KnownBits() [1/2]

llvm::KnownBits::KnownBits ( )
inline

Definition at line 34 of file KnownBits.h.

Referenced by sext(), trunc(), zext(), and zextOrTrunc().

◆ KnownBits() [2/2]

llvm::KnownBits::KnownBits ( unsigned  BitWidth)
inline

Create a known bits object of BitWidth bits initialized to unknown.

Definition at line 37 of file KnownBits.h.

Member Function Documentation

◆ computeForAddSub()

KnownBits KnownBits::computeForAddSub ( bool  Add,
bool  NSW,
const KnownBits LHS,
KnownBits  RHS 
)
static

Compute known bits resulting from adding LHS and RHS.

Definition at line 19 of file KnownBits.cpp.

References assert(), isNegative(), isNonNegative(), makeNegative(), makeNonNegative(), One, std::swap(), and Zero.

Referenced by computeKnownBitsAddSub(), countMaxPopulation(), and ShrinkDemandedConstant().

◆ countMaxLeadingOnes()

unsigned llvm::KnownBits::countMaxLeadingOnes ( ) const
inline

Returns the maximum number of leading one bits possible.

Definition at line 181 of file KnownBits.h.

References llvm::APInt::countLeadingZeros().

◆ countMaxLeadingZeros()

unsigned llvm::KnownBits::countMaxLeadingZeros ( ) const
inline

Returns the maximum number of leading zero bits possible.

Definition at line 176 of file KnownBits.h.

References llvm::APInt::countLeadingZeros().

Referenced by llvm::SelectionDAG::computeKnownBits(), computeKnownBitsFromOperator(), foldCttzCtlz(), isAlwaysLive(), and isKnownNonZero().

◆ countMaxPopulation()

unsigned llvm::KnownBits::countMaxPopulation ( ) const
inline

◆ countMaxTrailingOnes()

unsigned llvm::KnownBits::countMaxTrailingOnes ( ) const
inline

Returns the maximum number of trailing one bits possible.

Definition at line 171 of file KnownBits.h.

References llvm::APInt::countTrailingZeros().

◆ countMaxTrailingZeros()

unsigned llvm::KnownBits::countMaxTrailingZeros ( ) const
inline

Returns the maximum number of trailing zero bits possible.

Definition at line 166 of file KnownBits.h.

References llvm::APInt::countTrailingZeros().

Referenced by llvm::SelectionDAG::computeKnownBits(), foldCttzCtlz(), and isAlwaysLive().

◆ countMinLeadingOnes()

unsigned llvm::KnownBits::countMinLeadingOnes ( ) const
inline

Returns the minimum number of leading one bits.

Definition at line 151 of file KnownBits.h.

References llvm::APInt::countLeadingOnes().

Referenced by llvm::SelectionDAG::computeKnownBits(), computeKnownBitsFromOperator(), countMinSignBits(), and llvm::InstCombiner::visitSwitchInst().

◆ countMinLeadingZeros()

unsigned llvm::KnownBits::countMinLeadingZeros ( ) const
inline

◆ countMinPopulation()

unsigned llvm::KnownBits::countMinPopulation ( ) const
inline

Returns the number of bits known to be one.

Definition at line 186 of file KnownBits.h.

References llvm::APInt::countPopulation().

Referenced by foldCtpop(), and llvm::SelectionDAG::isKnownToBeAPowerOfTwo().

◆ countMinSignBits()

unsigned llvm::KnownBits::countMinSignBits ( ) const
inline

Returns the number of times the sign bit is replicated into the other bits.

Definition at line 157 of file KnownBits.h.

References countMinLeadingOnes(), countMinLeadingZeros(), isNegative(), and isNonNegative().

Referenced by llvm::AMDGPUTargetLowering::computeKnownBitsForTargetNode(), and ComputeNumSignBitsImpl().

◆ countMinTrailingOnes()

unsigned llvm::KnownBits::countMinTrailingOnes ( ) const
inline

Returns the minimum number of trailing one bits.

Definition at line 141 of file KnownBits.h.

References llvm::APInt::countTrailingOnes().

Referenced by computeKnownBitsFromOperator().

◆ countMinTrailingZeros()

unsigned llvm::KnownBits::countMinTrailingZeros ( ) const
inline

◆ getBitWidth()

unsigned llvm::KnownBits::getBitWidth ( ) const
inline

◆ getConstant()

const APInt& llvm::KnownBits::getConstant ( ) const
inline

Returns the value when all bits have a known value.

This just returns One with a protective assertion.

Definition at line 57 of file KnownBits.h.

References assert(), isConstant(), and One.

Referenced by llvm::ConstantFoldLoadFromConstPtr(), llvm::AMDGPUTargetLowering::performTruncateCombine(), llvm::InstCombiner::run(), llvm::SimplifyInstruction(), and llvm::InstCombiner::visitReturnInst().

◆ hasConflict()

bool llvm::KnownBits::hasConflict ( ) const
inline

◆ isAllOnes()

bool llvm::KnownBits::isAllOnes ( ) const
inline

Returns true if value is all one bits.

Definition at line 78 of file KnownBits.h.

References assert(), hasConflict(), and llvm::APInt::isAllOnesValue().

Referenced by computeKnownBitsFromAssume(), and llvm::InstCombiner::visitCallInst().

◆ isConstant()

bool llvm::KnownBits::isConstant ( ) const
inline

◆ isNegative()

bool llvm::KnownBits::isNegative ( ) const
inline

◆ isNonNegative()

bool llvm::KnownBits::isNonNegative ( ) const
inline

◆ isUnknown()

bool llvm::KnownBits::isUnknown ( ) const
inline

◆ isZero()

bool llvm::KnownBits::isZero ( ) const
inline

Returns true if value is all zero.

Definition at line 72 of file KnownBits.h.

References assert(), hasConflict(), and llvm::APInt::isAllOnesValue().

Referenced by computeKnownBitsFromAssume(), isZero(), and llvm::InstCombiner::replacedSelectWithOperand().

◆ makeNegative()

void llvm::KnownBits::makeNegative ( )
inline

Make this value negative.

Definition at line 102 of file KnownBits.h.

References llvm::APInt::setSignBit().

Referenced by computeForAddSub(), computeKnownBitsFromAssume(), computeKnownBitsFromOperator(), and computeKnownBitsMul().

◆ makeNonNegative()

void llvm::KnownBits::makeNonNegative ( )
inline

◆ resetAll()

void llvm::KnownBits::resetAll ( )
inline

◆ setAllOnes()

void llvm::KnownBits::setAllOnes ( )
inline

Make all bits known to be one and discard any previous information.

Definition at line 90 of file KnownBits.h.

References llvm::APInt::clearAllBits(), and llvm::APInt::setAllBits().

Referenced by computeKnownBitsFromAssume().

◆ setAllZero()

void llvm::KnownBits::setAllZero ( )
inline

Make all bits known to be zero and discard any previous information.

Definition at line 84 of file KnownBits.h.

References llvm::APInt::clearAllBits(), and llvm::APInt::setAllBits().

Referenced by computeKnownBits(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromAssume(), and computeKnownBitsFromShiftOperator().

◆ sext()

KnownBits llvm::KnownBits::sext ( unsigned  BitWidth)
inline

Sign extends the underlying known Zero and One bits.

This is equivalent to sign extending the value we're tracking.

Definition at line 125 of file KnownBits.h.

References KnownBits(), and llvm::APInt::sext().

Referenced by llvm::SelectionDAG::computeKnownBits(), llvm::ARMTargetLowering::computeKnownBitsForTargetNode(), llvm::SystemZTargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromOperator(), and ShrinkDemandedConstant().

◆ trunc()

KnownBits llvm::KnownBits::trunc ( unsigned  BitWidth)
inline

Truncate the underlying known Zero and One bits.

This is equivalent to truncating the value we're tracking.

Definition at line 113 of file KnownBits.h.

References KnownBits(), and llvm::APInt::trunc().

Referenced by llvm::SelectionDAG::computeKnownBits(), llvm::AMDGPUTargetLowering::computeKnownBitsForTargetNode(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromOperator(), and llvm::TargetLowering::SimplifyDemandedBits().

◆ zext()

KnownBits llvm::KnownBits::zext ( unsigned  BitWidth)
inline

Zero extends the underlying known Zero and One bits.

This is equivalent to zero extending the value we're tracking.

Definition at line 119 of file KnownBits.h.

References KnownBits(), and llvm::APInt::zext().

Referenced by llvm::SelectionDAG::computeKnownBits(), llvm::ARMTargetLowering::computeKnownBitsForTargetNode(), and llvm::SystemZTargetLowering::computeKnownBitsForTargetNode().

◆ zextOrTrunc()

KnownBits llvm::KnownBits::zextOrTrunc ( unsigned  BitWidth)
inline

Zero extends or truncates the underlying known Zero and One bits.

This is equivalent to zero extending or truncating the value we're tracking.

Definition at line 131 of file KnownBits.h.

References KnownBits(), and llvm::APInt::zextOrTrunc().

Referenced by llvm::SystemZTargetLowering::computeKnownBitsForTargetNode(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromOperator(), llvm::FunctionLoweringInfo::GetLiveOutRegInfo(), and ShrinkDemandedConstant().

Member Data Documentation

◆ One

APInt llvm::KnownBits::One

Definition at line 25 of file KnownBits.h.

Referenced by llvm::FunctionLoweringInfo::AddLiveOutRegInfo(), aliasSameBasePointerGEPs(), calculateByteProvider(), canonicalizeSaturatedSubtract(), llvm::SelectionDAGISel::CheckOrMask(), checkRippleForSignedAdd(), computeForAddSub(), computeKnownBits(), llvm::SelectionDAG::computeKnownBits(), computeKnownBitsBinOp(), llvm::SparcTargetLowering::computeKnownBitsForTargetNode(), llvm::LanaiTargetLowering::computeKnownBitsForTargetNode(), llvm::AMDGPUTargetLowering::computeKnownBitsForTargetNode(), llvm::AArch64TargetLowering::computeKnownBitsForTargetNode(), llvm::ARMTargetLowering::computeKnownBitsForTargetNode(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromAssume(), computeKnownBitsFromOperator(), llvm::computeKnownBitsFromRangeMetadata(), computeKnownBitsFromShiftOperator(), computeKnownBitsMul(), llvm::SelectionDAG::ComputeNumSignBits(), llvm::computeOverflowForUnsignedMul(), llvm::FunctionLoweringInfo::ComputePHILiveOutRegInfo(), computeSignedMinMaxValuesFromKnownBits(), computeUnsignedMinMaxValuesFromKnownBits(), llvm::ConstantFoldLoadFromConstPtr(), eliminateDeadSwitchCases(), foldCttzCtlz(), generateEquivalentSub(), getConstant(), GetRangeFromMetadata(), isAlwaysLive(), isKnownNonEqual(), isKnownNonZero(), isKnownToBeAPowerOfTwo(), isOpcWithIntImmediate(), maskMatters(), processUGT_ADDCST_ADD(), llvm::InstCombiner::replacedSelectWithOperand(), ShrinkDemandedConstant(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), SimplifyRightShift(), SimplifyShift(), and llvm::InstCombiner::visitTrunc().

◆ Zero

APInt llvm::KnownBits::Zero

Definition at line 24 of file KnownBits.h.

Referenced by llvm::FunctionLoweringInfo::AddLiveOutRegInfo(), adjustForRedundantAnd(), aliasSameBasePointerGEPs(), calculateByteProvider(), canonicalizeSaturatedSubtract(), canTransformToMemCmp(), checkRippleForSignedAdd(), computeForAddSub(), computeKnownBits(), llvm::SelectionDAG::computeKnownBits(), computeKnownBitsBinOp(), llvm::SITargetLowering::computeKnownBitsForFrameIndex(), llvm::TargetLowering::computeKnownBitsForFrameIndex(), llvm::SparcTargetLowering::computeKnownBitsForTargetNode(), llvm::LanaiTargetLowering::computeKnownBitsForTargetNode(), llvm::AMDGPUTargetLowering::computeKnownBitsForTargetNode(), llvm::AArch64TargetLowering::computeKnownBitsForTargetNode(), llvm::ARMTargetLowering::computeKnownBitsForTargetNode(), llvm::SystemZTargetLowering::computeKnownBitsForTargetNode(), llvm::PPCTargetLowering::computeKnownBitsForTargetNode(), llvm::X86TargetLowering::computeKnownBitsForTargetNode(), computeKnownBitsFromAssume(), computeKnownBitsFromOperator(), llvm::computeKnownBitsFromRangeMetadata(), computeKnownBitsFromShiftOperator(), computeKnownBitsMul(), llvm::SelectionDAG::ComputeNumSignBits(), ComputeNumSignBitsImpl(), llvm::computeOverflowForUnsignedMul(), llvm::SelectionDAG::computeOverflowKind(), llvm::FunctionLoweringInfo::ComputePHILiveOutRegInfo(), computeSignedMinMaxValuesFromKnownBits(), computeUnsignedMinMaxValuesFromKnownBits(), llvm::ConstantFoldLoadFromConstPtr(), eliminateDeadSwitchCases(), llvm::XCoreTargetLowering::EmitInstrWithCustomInserter(), generateEquivalentSub(), getRangeForAffineARHelper(), GetRangeFromMetadata(), llvm::SelectionDAG::haveNoCommonBitsSet(), insertDAGNode(), isAlwaysLive(), isBitfieldPositioningOp(), isKnownNonEqual(), isKnownToBeAPowerOfTwo(), isOpcWithIntImmediate(), isTruePredicate(), isTruncateOf(), LowerMUL(), MaskedValueIsZero(), maskMatters(), matchRotateSub(), mayUseP9Setb(), llvm::ARMTargetLowering::PerformCMOVCombine(), llvm::ARMTargetLowering::PerformCMOVToBFICombine(), processUGT_ADDCST_ADD(), propagateMetadata(), llvm::InstCombiner::replacedSelectWithOperand(), llvm::PPCTargetLowering::SelectAddressRegImm(), llvm::PPCTargetLowering::SelectAddressRegReg(), ShrinkDemandedConstant(), llvm::TargetLowering::SimplifyDemandedBits(), llvm::X86TargetLowering::SimplifyDemandedBitsForTargetNode(), tryBitfieldInsertOpFromOr(), tryBitfieldInsertOpFromOrAndImm(), llvm::InstCombiner::visitAdd(), llvm::InstCombiner::visitSub(), llvm::InstCombiner::visitTrunc(), and llvm::InstCombiner::visitZExt().


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