LLVM 17.0.0git
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 (const BlockFrequency &LocalFreq)
Create a MappingCost assuming that most of the instructions will occur in a basic block with LocalFreq frequency.

Add Cost to the local 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.

## ◆ MappingCost()

 RegBankSelect::MappingCost::MappingCost ( const BlockFrequency & LocalFreq )

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

Definition at line 974 of file RegBankSelect.cpp.

## Member Function Documentation

 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 977 of file RegBankSelect.cpp.

References Cost.

 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 987 of file RegBankSelect.cpp.

References Cost.

## ◆ dump()

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

Print this on dbgs() stream.

Definition at line 1094 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 1007 of file RegBankSelect.cpp.

References UINT64_MAX.

## ◆ 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.

References Cost.

## ◆ operator<()

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

Check if this is less than Cost.

Definition at line 1011 of file RegBankSelect.cpp.

References Cost, and LLVM_LIKELY.

## ◆ operator==()

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

Check if this is equal to Cost.

Definition at line 1088 of file RegBankSelect.cpp.

References Cost.

## ◆ 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.

References Cost.

## ◆ print()

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

Print this on OS;.

Definition at line 1100 of file RegBankSelect.cpp.

References OS.

## ◆ saturate()

 void RegBankSelect::MappingCost::saturate ( )

Saturate the cost to the maximal representable value.

Definition at line 1002 of file RegBankSelect.cpp.

## ◆ 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: