LLVM  10.0.0svn
Public Types | Public Member Functions | Static Public Member Functions | List of all members
llvm::IntegerState Struct Reference

Simple state with integers encoding. More...

#include "llvm/Transforms/IPO/Attributor.h"

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

Public Types

using base_t = uint32_t
 Underlying integer type, we assume 32 bits to be enough. More...
 

Public Member Functions

 IntegerState (base_t BestState=~0)
 Initialize the (best) state. More...
 
bool isValidState () const override
 See AbstractState::isValidState() NOTE: For now we simply pretend that the worst possible state is invalid. More...
 
bool isAtFixpoint () const override
 See AbstractState::isAtFixpoint() More...
 
ChangeStatus indicateOptimisticFixpoint () override
 See AbstractState::indicateOptimisticFixpoint(...) More...
 
ChangeStatus indicatePessimisticFixpoint () override
 See AbstractState::indicatePessimisticFixpoint(...) More...
 
base_t getKnown () const
 Return the known state encoding. More...
 
base_t getAssumed () const
 Return the assumed state encoding. More...
 
bool isKnown (base_t BitsEncoding) const
 Return true if the bits set in BitsEncoding are "known bits". More...
 
bool isAssumed (base_t BitsEncoding) const
 Return true if the bits set in BitsEncoding are "assumed bits". More...
 
IntegerStateaddKnownBits (base_t Bits)
 Add the bits in BitsEncoding to the "known bits". More...
 
IntegerStateremoveAssumedBits (base_t BitsEncoding)
 Remove the bits in BitsEncoding from the "assumed bits" if not known. More...
 
IntegerStateremoveKnownBits (base_t BitsEncoding)
 Remove the bits in BitsEncoding from the "known bits". More...
 
IntegerStateintersectAssumedBits (base_t BitsEncoding)
 Keep only "assumed bits" also set in BitsEncoding but all known ones. More...
 
IntegerStatetakeAssumedMinimum (base_t Value)
 Take minimum of assumed and Value. More...
 
IntegerStatetakeKnownMaximum (base_t Value)
 Take maximum of known and Value. More...
 
bool operator== (const IntegerState &R) const
 Equality for IntegerState. More...
 
bool operator!= (const IntegerState &R) const
 Inequality for IntegerState. More...
 
IntegerState operator^= (const IntegerState &R)
 "Clamp" this state with R. More...
 
IntegerState operator+= (const IntegerState &R)
 "Clamp" this state with R. More...
 
IntegerState operator &= (const IntegerState &R)
 Make this the minimum, known and assumed, of this state and R. More...
 
IntegerState operator|= (const IntegerState &R)
 Make this the maximum, known and assumed, of this state and R. More...
 
- Public Member Functions inherited from llvm::AbstractState
virtual ~AbstractState ()
 

Static Public Member Functions

static constexpr base_t getWorstState ()
 Return the worst possible representable state. More...
 

Detailed Description

Simple state with integers encoding.

The interface ensures that the assumed bits are always a subset of the known bits. Users can only add known bits and, except through adding known bits, they can only remove assumed bits. This should guarantee monotoniticy and thereby the existence of a fixpoint (if used corretly). The fixpoint is reached when the assumed and known state/bits are equal. Users can force/inidicate a fixpoint. If an optimistic one is indicated, the known state will catch up with the assumed one, for a pessimistic fixpoint it is the other way around.

Definition at line 1071 of file Attributor.h.

Member Typedef Documentation

◆ base_t

Underlying integer type, we assume 32 bits to be enough.

Definition at line 1073 of file Attributor.h.

Constructor & Destructor Documentation

◆ IntegerState()

llvm::IntegerState::IntegerState ( base_t  BestState = ~0)
inline

Initialize the (best) state.

Definition at line 1076 of file Attributor.h.

Member Function Documentation

◆ addKnownBits()

IntegerState& llvm::IntegerState::addKnownBits ( base_t  Bits)
inline

Add the bits in BitsEncoding to the "known bits".

Definition at line 1117 of file Attributor.h.

References llvm::tgtok::Bits.

Referenced by llvm::IRPosition::getAttrs().

◆ getAssumed()

base_t llvm::IntegerState::getAssumed ( ) const
inline

Return the assumed state encoding.

Definition at line 1104 of file Attributor.h.

Referenced by llvm::IRPosition::getAttrs(), llvm::operator<<(), and operator==().

◆ getKnown()

base_t llvm::IntegerState::getKnown ( ) const
inline

Return the known state encoding.

Definition at line 1101 of file Attributor.h.

Referenced by llvm::operator<<(), and operator==().

◆ getWorstState()

static constexpr base_t llvm::IntegerState::getWorstState ( )
inlinestatic

Return the worst possible representable state.

Definition at line 1079 of file Attributor.h.

◆ indicateOptimisticFixpoint()

ChangeStatus llvm::IntegerState::indicateOptimisticFixpoint ( )
inlineoverridevirtual

◆ indicatePessimisticFixpoint()

ChangeStatus llvm::IntegerState::indicatePessimisticFixpoint ( )
inlineoverridevirtual

◆ intersectAssumedBits()

IntegerState& llvm::IntegerState::intersectAssumedBits ( base_t  BitsEncoding)
inline

Keep only "assumed bits" also set in BitsEncoding but all known ones.

Definition at line 1138 of file Attributor.h.

◆ isAssumed()

bool llvm::IntegerState::isAssumed ( base_t  BitsEncoding) const
inline

Return true if the bits set in BitsEncoding are "assumed bits".

Definition at line 1112 of file Attributor.h.

Referenced by llvm::IRPosition::getAttrs().

◆ isAtFixpoint()

bool llvm::IntegerState::isAtFixpoint ( ) const
inlineoverridevirtual

See AbstractState::isAtFixpoint()

Implements llvm::AbstractState.

Definition at line 1086 of file Attributor.h.

Referenced by llvm::DerefState::isAtFixpoint().

◆ isKnown()

bool llvm::IntegerState::isKnown ( base_t  BitsEncoding) const
inline

Return true if the bits set in BitsEncoding are "known bits".

Definition at line 1107 of file Attributor.h.

◆ isValidState()

bool llvm::IntegerState::isValidState ( ) const
inlineoverridevirtual

See AbstractState::isValidState() NOTE: For now we simply pretend that the worst possible state is invalid.

Implements llvm::AbstractState.

Definition at line 1083 of file Attributor.h.

Referenced by llvm::DerefState::isValidState().

◆ operator &=()

IntegerState llvm::IntegerState::operator&= ( const IntegerState R)
inline

Make this the minimum, known and assumed, of this state and R.

Definition at line 1187 of file Attributor.h.

◆ operator!=()

bool llvm::IntegerState::operator!= ( const IntegerState R) const
inline

Inequality for IntegerState.

Definition at line 1166 of file Attributor.h.

◆ operator+=()

IntegerState llvm::IntegerState::operator+= ( const IntegerState R)
inline

"Clamp" this state with R.

The result is the maximum of the known information but not more than what was assumed before.

Definition at line 1181 of file Attributor.h.

◆ operator==()

bool llvm::IntegerState::operator== ( const IntegerState R) const
inline

Equality for IntegerState.

Definition at line 1160 of file Attributor.h.

References getAssumed(), and getKnown().

◆ operator^=()

IntegerState llvm::IntegerState::operator^= ( const IntegerState R)
inline

"Clamp" this state with R.

The result is the minimum of the assumed information but not less than what was known before.

TODO: Consider replacing the operator with a call or using it only when we can also take the maximum of the known information, thus when R is not dependent on additional assumed state.

Definition at line 1174 of file Attributor.h.

◆ operator|=()

IntegerState llvm::IntegerState::operator|= ( const IntegerState R)
inline

Make this the maximum, known and assumed, of this state and R.

Definition at line 1194 of file Attributor.h.

References llvm::max().

◆ removeAssumedBits()

IntegerState& llvm::IntegerState::removeAssumedBits ( base_t  BitsEncoding)
inline

Remove the bits in BitsEncoding from the "assumed bits" if not known.

Definition at line 1125 of file Attributor.h.

Referenced by llvm::IRPosition::getAttrs().

◆ removeKnownBits()

IntegerState& llvm::IntegerState::removeKnownBits ( base_t  BitsEncoding)
inline

Remove the bits in BitsEncoding from the "known bits".

Definition at line 1132 of file Attributor.h.

◆ takeAssumedMinimum()

IntegerState& llvm::IntegerState::takeAssumedMinimum ( base_t  Value)
inline

Take minimum of assumed and Value.

Definition at line 1145 of file Attributor.h.

References llvm::max().

Referenced by llvm::DerefState::takeAssumedDerefBytesMinimum().

◆ takeKnownMaximum()

IntegerState& llvm::IntegerState::takeKnownMaximum ( base_t  Value)
inline

Take maximum of known and Value.

Definition at line 1152 of file Attributor.h.

References llvm::max().

Referenced by llvm::DerefState::takeKnownDerefBytesMaximum().


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