LLVM 22.0.0git
llvm::bfi_detail::BlockMass Class Reference

Mass of a block. More...

#include "llvm/Analysis/BlockFrequencyInfoImpl.h"

Public Member Functions

 BlockMass ()=default
 BlockMass (uint64_t Mass)
uint64_t getMass () const
bool isFull () const
bool isEmpty () const
bool operator! () const
BlockMassoperator+= (BlockMass X)
 Add another mass.
BlockMassoperator-= (BlockMass X)
 Subtract another mass.
BlockMassoperator*= (BranchProbability P)
bool operator== (BlockMass X) const
bool operator!= (BlockMass X) const
bool operator<= (BlockMass X) const
bool operator>= (BlockMass X) const
bool operator< (BlockMass X) const
bool operator> (BlockMass X) const
ScaledNumber< uint64_ttoScaled () const
 Convert to scaled number.
void dump () const
raw_ostreamprint (raw_ostream &OS) const

Static Public Member Functions

static BlockMass getEmpty ()
static BlockMass getFull ()

Detailed Description

Mass of a block.

This class implements a sort of fixed-point fraction always between 0.0 and 1.0. getMass() == std::numeric_limits<uint64_t>::max() indicates a value of 1.0.

Masses can be added and subtracted. Simple saturation arithmetic is used, so arithmetic operations never overflow or underflow.

Masses can be multiplied. Multiplication treats full mass as 1.0 and uses an inexpensive floating-point algorithm that's off-by-one (almost, but not quite, maximum precision).

Masses can be scaled by BranchProbability at maximum precision.

Definition at line 89 of file BlockFrequencyInfoImpl.h.

Constructor & Destructor Documentation

◆ BlockMass() [1/2]

llvm::bfi_detail::BlockMass::BlockMass ( )
default

◆ BlockMass() [2/2]

llvm::bfi_detail::BlockMass::BlockMass ( uint64_t Mass)
inlineexplicit

Definition at line 94 of file BlockFrequencyInfoImpl.h.

Member Function Documentation

◆ dump()

LLVM_DUMP_METHOD void BlockMass::dump ( ) const

Definition at line 72 of file BlockFrequencyInfoImpl.cpp.

References llvm::dbgs(), LLVM_DUMP_METHOD, and print().

◆ getEmpty()

BlockMass llvm::bfi_detail::BlockMass::getEmpty ( )
inlinestatic

◆ getFull()

◆ getMass()

uint64_t llvm::bfi_detail::BlockMass::getMass ( ) const
inline

Definition at line 102 of file BlockFrequencyInfoImpl.h.

Referenced by toScaled().

◆ isEmpty()

bool llvm::bfi_detail::BlockMass::isEmpty ( ) const
inline

◆ isFull()

bool llvm::bfi_detail::BlockMass::isFull ( ) const
inline

Definition at line 104 of file BlockFrequencyInfoImpl.h.

Referenced by toScaled().

◆ operator!()

bool llvm::bfi_detail::BlockMass::operator! ( ) const
inline

Definition at line 107 of file BlockFrequencyInfoImpl.h.

References isEmpty().

◆ operator!=()

Definition at line 134 of file BlockFrequencyInfoImpl.h.

References BlockMass(), and X.

◆ operator*=()

BlockMass & llvm::bfi_detail::BlockMass::operator*= ( BranchProbability P)
inline

Definition at line 128 of file BlockFrequencyInfoImpl.h.

References BlockMass(), and P.

◆ operator+=()

BlockMass & llvm::bfi_detail::BlockMass::operator+= ( BlockMass X)
inline

Add another mass.

Adds another mass, saturating at isFull() rather than overflowing.

Definition at line 112 of file BlockFrequencyInfoImpl.h.

References BlockMass(), and X.

◆ operator-=()

BlockMass & llvm::bfi_detail::BlockMass::operator-= ( BlockMass X)
inline

Subtract another mass.

Subtracts another mass, saturating at isEmpty() rather than undeflowing.

Definition at line 122 of file BlockFrequencyInfoImpl.h.

References BlockMass(), and X.

◆ operator<()

bool llvm::bfi_detail::BlockMass::operator< ( BlockMass X) const
inline

Definition at line 137 of file BlockFrequencyInfoImpl.h.

References BlockMass(), and X.

◆ operator<=()

bool llvm::bfi_detail::BlockMass::operator<= ( BlockMass X) const
inline

Definition at line 135 of file BlockFrequencyInfoImpl.h.

References BlockMass(), and X.

◆ operator==()

bool llvm::bfi_detail::BlockMass::operator== ( BlockMass X) const
inline

Definition at line 133 of file BlockFrequencyInfoImpl.h.

References BlockMass(), and X.

◆ operator>()

bool llvm::bfi_detail::BlockMass::operator> ( BlockMass X) const
inline

Definition at line 138 of file BlockFrequencyInfoImpl.h.

References BlockMass(), and X.

◆ operator>=()

bool llvm::bfi_detail::BlockMass::operator>= ( BlockMass X) const
inline

Definition at line 136 of file BlockFrequencyInfoImpl.h.

References BlockMass(), and X.

◆ print()

raw_ostream & BlockMass::print ( raw_ostream & OS) const

Definition at line 82 of file BlockFrequencyInfoImpl.cpp.

References getHexDigit().

Referenced by dump().

◆ toScaled()

ScaledNumber< uint64_t > BlockMass::toScaled ( ) const

Convert to scaled number.

Convert to ScaledNumber. isFull() gives 1.0, while isEmpty() gives slightly above 0.0.

Definition at line 65 of file BlockFrequencyInfoImpl.cpp.

References getMass(), and isFull().

Referenced by llvm::BlockFrequencyInfoImplBase::computeLoopScale(), and llvm::BlockFrequencyInfoImplBase::unwrapLoops().


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