LLVM  6.0.0svn
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/GlobalISel/RegisterBankInfo.h"

Collaboration diagram for llvm::RegisterBankInfo::ValueMapping:
Collaboration graph
[legend]

Public Member Functions

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

Public Attributes

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

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},
/*2x32-bit add*/ {0, 32, GPR}, {0, 32, GPR}, // <-- Same entry 3x
/*<2x32-bit> vadd {0, 64, VPR}
* }; // PartialMapping duplicated.
* ValueMapping[] {
* /*plain 32-bit add*/ {&PartialMapping[0], 1},
/*expanded vadd on 2xadd*/ {&PartialMapping[1], 2},
/*plain <2x32-bit> vadd*/ {&PartialMapping[3], 1}
};

With the array of pointer, we would have:

/*32-bit add*/ {0, 32, GPR},
/*<2x32-bit> vadd {0, 64, VPR}
* }; // No more duplication.
* BreakDowns[] = {
* /*AddBreakDown*/ &PartialMapping[0],
/*2xAddBreakDown*/ &PartialMapping[0], &PartialMapping[0],
/*VAddBreakDown*/ &PartialMapping[1]
}; // 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 142 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 151 of file RegisterBankInfo.h.

◆ ValueMapping() [2/2]

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

Initialize a ValueMapping with the given parameter.

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

Definition at line 156 of file RegisterBankInfo.h.

Member Function Documentation

◆ begin()

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

Iterators through the PartialMappings.

Definition at line 160 of file RegisterBankInfo.h.

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

◆ dump()

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

Print this on dbgs() stream.

Definition at line 539 of file RegisterBankInfo.cpp.

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

◆ end()

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

◆ isValid()

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

◆ print()

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

Print this on OS;.

Definition at line 545 of file RegisterBankInfo.cpp.

◆ verify()

bool RegisterBankInfo::ValueMapping::verify ( unsigned  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 509 of file RegisterBankInfo.cpp.

References assert(), llvm::APInt::getBitsSet(), llvm::RegisterBankInfo::PartialMapping::getHighBitIdx(), llvm::APInt::isAllOnesValue(), llvm::max(), 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

How the value is broken down between the different register banks.

Definition at line 144 of file RegisterBankInfo.h.

Referenced by llvm::ARM::checkValueMapping(), and llvm::RegBankSelect::getAnalysisUsage().

◆ NumBreakDowns

unsigned llvm::RegisterBankInfo::ValueMapping::NumBreakDowns

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