LLVM 20.0.0git
Public Member Functions | Static Public Member Functions | Friends | List of all members
llvm::RegBankSelect::MappingCost Class Reference

Helper class used to represent the cost for mapping an instruction. More...

#include "llvm/CodeGen/GlobalISel/RegBankSelect.h"

Public Member Functions

 MappingCost (BlockFrequency LocalFreq)
 Create a MappingCost assuming that most of the instructions will occur in a basic block with LocalFreq frequency.
 
bool addLocalCost (uint64_t Cost)
 Add Cost to the local cost.
 
bool addNonLocalCost (uint64_t Cost)
 Add Cost to the non-local cost.
 
void saturate ()
 Saturate the cost to the maximal representable value.
 
bool operator< (const MappingCost &Cost) const
 Check if this is less than Cost.
 
bool operator== (const MappingCost &Cost) const
 Check if this is equal to Cost.
 
bool operator!= (const MappingCost &Cost) const
 Check if this is not equal to Cost.
 
bool operator> (const MappingCost &Cost) const
 Check if this is greater than Cost.
 
void dump () const
 Print this on dbgs() stream.
 
void print (raw_ostream &OS) const
 Print this on OS;.
 

Static Public Member Functions

static MappingCost ImpossibleCost ()
 Return an instance of MappingCost that represents an impossible mapping.
 

Friends

raw_ostreamoperator<< (raw_ostream &OS, const MappingCost &Cost)
 Overload the stream operator for easy debug printing.
 

Detailed Description

Helper class used to represent the cost for mapping an instruction.

When mapping an instruction, we may introduce some repairing code. In most cases, the repairing code is local to the instruction, thus, we can omit the basic block frequency from the cost. However, some alternatives may produce non-local cost, e.g., when repairing a phi, and thus we then need to scale the local cost to the non-local cost. This class does this for us.

Note
: We could simply always scale the cost. The problem is that there are higher chances that we saturate the cost easier and end up having the same cost for actually different alternatives. Another option would be to use APInt everywhere.

Definition at line 422 of file RegBankSelect.h.

Constructor & Destructor Documentation

◆ MappingCost()

RegBankSelect::MappingCost::MappingCost ( BlockFrequency  LocalFreq)

Create a MappingCost assuming that most of the instructions will occur in a basic block with LocalFreq frequency.

Definition at line 979 of file RegBankSelect.cpp.

Member Function Documentation

◆ addLocalCost()

bool RegBankSelect::MappingCost::addLocalCost ( uint64_t  Cost)

Add Cost to the local cost.

Returns
true if this cost is saturated, false otherwise.

Definition at line 982 of file RegBankSelect.cpp.

◆ addNonLocalCost()

bool RegBankSelect::MappingCost::addNonLocalCost ( uint64_t  Cost)

Add Cost to the non-local cost.

Non-local cost should reflect the frequency of their placement.

Returns
true if this cost is saturated, false otherwise.

Definition at line 992 of file RegBankSelect.cpp.

◆ dump()

LLVM_DUMP_METHOD void RegBankSelect::MappingCost::dump ( ) const

Print this on dbgs() stream.

Definition at line 1099 of file RegBankSelect.cpp.

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

◆ ImpossibleCost()

RegBankSelect::MappingCost RegBankSelect::MappingCost::ImpossibleCost ( )
static

Return an instance of MappingCost that represents an impossible mapping.

Definition at line 1012 of file RegBankSelect.cpp.

References UINT64_MAX.

Referenced by llvm::RegBankSelect::assignInstr(), llvm::RegBankSelect::computeMapping(), and llvm::RegBankSelect::findBestMapping().

◆ operator!=()

bool llvm::RegBankSelect::MappingCost::operator!= ( const MappingCost Cost) const
inline

Check if this is not equal to Cost.

Definition at line 466 of file RegBankSelect.h.

◆ operator<()

bool RegBankSelect::MappingCost::operator< ( const MappingCost Cost) const

Check if this is less than Cost.

Definition at line 1016 of file RegBankSelect.cpp.

References LLVM_LIKELY.

◆ operator==()

bool RegBankSelect::MappingCost::operator== ( const MappingCost Cost) const

Check if this is equal to Cost.

Definition at line 1093 of file RegBankSelect.cpp.

◆ operator>()

bool llvm::RegBankSelect::MappingCost::operator> ( const MappingCost Cost) const
inline

Check if this is greater than Cost.

Definition at line 468 of file RegBankSelect.h.

◆ print()

void RegBankSelect::MappingCost::print ( raw_ostream OS) const

Print this on OS;.

Definition at line 1105 of file RegBankSelect.cpp.

References OS.

◆ saturate()

void RegBankSelect::MappingCost::saturate ( )

Saturate the cost to the maximal representable value.

Definition at line 1007 of file RegBankSelect.cpp.

Friends And Related Function Documentation

◆ operator<<

raw_ostream & operator<< ( raw_ostream OS,
const MappingCost Cost 
)
friend

Overload the stream operator for easy debug printing.

Definition at line 479 of file RegBankSelect.h.


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