LLVM 20.0.0git
Public Member Functions | Public Attributes | List of all members
llvm::RegisterBankInfo::ValueMapping Struct Reference

Helper struct that represents how a value is mapped through different register banks. More...

#include "llvm/CodeGen/RegisterBankInfo.h"

Public Member Functions

 ValueMapping ()
 The default constructor creates an invalid (isValid() == false) instance.
 
constexpr ValueMapping (const PartialMapping *BreakDown, unsigned NumBreakDowns)
 Initialize a ValueMapping with the given parameter.
 
const PartialMappingbegin () const
 Iterators through the PartialMappings.
 
const PartialMappingend () const
 
bool partsAllUniform () const
 
bool isValid () const
 Check if this ValueMapping is valid.
 
bool verify (const RegisterBankInfo &RBI, TypeSize MeaningfulBitWidth) const
 Verify that this mapping makes sense for a value of MeaningfulBitWidth.
 
void dump () const
 Print this on dbgs() stream.
 
void print (raw_ostream &OS) const
 Print this on OS;.
 

Public Attributes

const PartialMappingBreakDown
 How the value is broken down between the different register banks.
 
unsigned NumBreakDowns
 Number of partial mapping to break down this value.
 

Detailed Description

Helper struct that represents how a value is mapped through different register banks.

Note
: So far we do not have any users of the complex mappings (mappings with more than one partial mapping), but when we do, we would have needed to duplicate partial mappings. The alternative could be to use an array of pointers of partial mapping (i.e., PartialMapping **BreakDown) and duplicate the pointers instead.

E.g., Let say we have a 32-bit add and a <2 x 32-bit> vadd. We can expand the <2 x 32-bit> add into 2 x 32-bit add.

Currently the TableGen-like file would look like:

/*32-bit add*/ {0, 32, GPR}, // Scalar entry repeated for first
// vec elt.
/*2x32-bit add*/ {0, 32, GPR}, {32, 32, GPR},
/*<2x32-bit> vadd*/ {0, 64, VPR}
}; // PartialMapping duplicated.
/*plain 32-bit add*/ {&PartialMapping[0], 1},
/*expanded vadd on 2xadd*/ {&PartialMapping[1], 2},
/*plain <2x32-bit> vadd*/ {&PartialMapping[3], 1}
};
Helper struct that represents how a value is partially mapped into a register.
ValueMapping()
The default constructor creates an invalid (isValid() == false) instance.

With the array of pointer, we would have:

/*32-bit add lower */ { 0, 32, GPR},
/*32-bit add upper */ {32, 32, GPR},
/*<2x32-bit> vadd */ { 0, 64, VPR}
}; // No more duplication.
BreakDowns[] = {
/*AddBreakDown*/ &PartialMapping[0],
/*2xAddBreakDown*/ &PartialMapping[0], &PartialMapping[1],
/*VAddBreakDown*/ &PartialMapping[2]
}; // Addresses of PartialMapping duplicated (smaller).
/*plain 32-bit add*/ {&BreakDowns[0], 1},
/*expanded vadd on 2xadd*/ {&BreakDowns[1], 2},
/*plain <2x32-bit> vadd*/ {&BreakDowns[3], 1}
};

Given that a PartialMapping is actually small, the code size impact is actually a degradation. Moreover the compile time will be hit by the additional indirection. If PartialMapping gets bigger we may reconsider.

Definition at line 146 of file RegisterBankInfo.h.

Constructor & Destructor Documentation

◆ ValueMapping() [1/2]

llvm::RegisterBankInfo::ValueMapping::ValueMapping ( )
inline

The default constructor creates an invalid (isValid() == false) instance.

Definition at line 155 of file RegisterBankInfo.h.

◆ ValueMapping() [2/2]

constexpr llvm::RegisterBankInfo::ValueMapping::ValueMapping ( const PartialMapping BreakDown,
unsigned  NumBreakDowns 
)
inlineconstexpr

Initialize a ValueMapping with the given parameter.

BreakDown needs to have a life time at least as long as this instance.

Definition at line 160 of file RegisterBankInfo.h.

Member Function Documentation

◆ begin()

const PartialMapping * llvm::RegisterBankInfo::ValueMapping::begin ( ) const
inline

Iterators through the PartialMappings.

Definition at line 165 of file RegisterBankInfo.h.

References BreakDown.

Referenced by llvm::RegisterBankInfo::OperandsMapper::createVRegs().

◆ dump()

LLVM_DUMP_METHOD void RegisterBankInfo::ValueMapping::dump ( ) const

Print this on dbgs() stream.

Definition at line 589 of file RegisterBankInfo.cpp.

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

◆ end()

const PartialMapping * llvm::RegisterBankInfo::ValueMapping::end ( ) const
inline

Definition at line 166 of file RegisterBankInfo.h.

References BreakDown, and NumBreakDowns.

Referenced by llvm::RegisterBankInfo::OperandsMapper::createVRegs().

◆ isValid()

bool llvm::RegisterBankInfo::ValueMapping::isValid ( ) const
inline

Check if this ValueMapping is valid.

Definition at line 173 of file RegisterBankInfo.h.

References BreakDown, and NumBreakDowns.

◆ partsAllUniform()

bool RegisterBankInfo::ValueMapping::partsAllUniform ( ) const
Returns
true if all partial mappings are the same size and register bank.

Definition at line 544 of file RegisterBankInfo.cpp.

References llvm::First.

Referenced by llvm::RegBankSelect::repairReg().

◆ print()

void RegisterBankInfo::ValueMapping::print ( raw_ostream OS) const

Print this on OS;.

Definition at line 595 of file RegisterBankInfo.cpp.

References OS.

Referenced by llvm::operator<<().

◆ verify()

bool RegisterBankInfo::ValueMapping::verify ( const RegisterBankInfo RBI,
TypeSize  MeaningfulBitWidth 
) const

Verify that this mapping makes sense for a value of MeaningfulBitWidth.

Note
This method does not check anything when assertions are disabled.
Returns
True is the check was successful.

Definition at line 557 of file RegisterBankInfo.cpp.

References assert(), llvm::APInt::getBitsSet(), llvm::RegisterBankInfo::PartialMapping::getHighBitIdx(), llvm::APInt::isAllOnes(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::isScalable(), llvm::RegisterBankInfo::PartialMapping::StartIdx, and llvm::RegisterBankInfo::PartialMapping::verify().

Referenced by llvm::RegisterBankInfo::InstructionMapping::verify().

Member Data Documentation

◆ BreakDown

const PartialMapping* llvm::RegisterBankInfo::ValueMapping::BreakDown

◆ NumBreakDowns

unsigned llvm::RegisterBankInfo::ValueMapping::NumBreakDowns

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