15 #ifndef LLVM_CODEGEN_GLOBALISEL_REGISTERBANKINFO_H
16 #define LLVM_CODEGEN_GLOBALISEL_REGISTERBANKINFO_H
24 #include <initializer_list>
30 class MachineRegisterInfo;
33 class TargetInstrInfo;
34 class TargetRegisterClass;
35 class TargetRegisterInfo;
66 : StartIdx(StartIdx), Length(Length), RegBank(&RegBank) {}
157 : BreakDown(BreakDown), NumBreakDowns(NumBreakDowns) {}
171 bool verify(
unsigned MeaningfulBitWidth)
const;
195 unsigned NumOperands = 0;
199 return OperandsMapping[i];
213 unsigned NumOperands)
214 : ID(ID), Cost(Cost), OperandsMapping(OperandsMapping),
215 NumOperands(NumOperands) {
217 "Use the default constructor for invalid mapping");
228 unsigned getID()
const {
return ID; }
246 OperandsMapping = OpdsMapping;
297 static const int DontKnowIdx;
306 getVRegsMem(
unsigned OpIdx);
312 getNewVRegsEnd(
unsigned StartIdx,
unsigned NumVal)
const;
359 void setVRegs(
unsigned OpIdx,
unsigned PartialMapIdx,
unsigned NewVReg);
374 getVRegs(
unsigned OpIdx,
bool ForDebug =
false)
const;
464 unsigned NumBreakDowns)
const;
480 template <
typename Iterator>
497 std::initializer_list<const ValueMapping *> OpdsMapping)
const;
509 unsigned NumOperands = 0)
const;
516 unsigned NumOperands)
const {
517 return getInstructionMappingImpl(
false, ID, Cost,
518 OperandsMapping, NumOperands);
523 return getInstructionMappingImpl(
true);
603 unsigned Size)
const {
703 const TargetRegisterInfo &TRI);
711 bool verify(
const TargetRegisterInfo &TRI)
const;
716 const RegisterBankInfo::PartialMapping &PartMapping) {
717 PartMapping.print(OS);
722 operator<<(raw_ostream &OS,
const RegisterBankInfo::ValueMapping &ValMapping) {
723 ValMapping.print(OS);
729 const RegisterBankInfo::InstructionMapping &InstrMapping) {
730 InstrMapping.print(OS);
735 operator<<(raw_ostream &OS,
const RegisterBankInfo::OperandsMapper &OpdMapper) {
736 OpdMapper.print(OS,
false);
742 hash_code
hash_value(
const RegisterBankInfo::PartialMapping &PartMapping);
746 #endif // LLVM_CODEGEN_GLOBALISEL_REGISTERBANKINFO_H
void setOperandsMapping(const ValueMapping *OpdsMapping)
Set the mapping for all the operands.
void dump() const
Print this on dbgs() stream.
static const unsigned InvalidMappingID
Identifier used when the related instruction mapping instance is generated by the default constructor...
virtual unsigned copyCost(const RegisterBank &A, const RegisterBank &B, unsigned Size) const
Get the cost of a copy from B to A, or put differently, get the cost of A = COPY B.
const InstructionMapping & getInvalidInstructionMapping() const
Method to get a uniquely generated invalid InstructionMapping.
Helper class that represents how the value of an instruction may be mapped and what is the related co...
const InstructionMapping & getInstructionMapping(unsigned ID, unsigned Cost, const ValueMapping *OperandsMapping, unsigned NumOperands) const
Method to get a uniquely generated InstructionMapping.
virtual const RegisterBank & getRegBankFromRegClass(const TargetRegisterClass &RC) const
Get a register bank that covers RC.
bool isValid() const
Check if this ValueMapping is valid.
unsigned getHighBitIdx() const
DenseMap< unsigned, std::unique_ptr< const PartialMapping > > MapOfPartialMappings
Keep dynamically allocated PartialMapping in a separate map.
Helper class that represents how the value of an instruction may be mapped and what is the related co...
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
const ValueMapping & getValueMapping(unsigned StartIdx, unsigned Length, const RegisterBank &RegBank) const
The most common ValueMapping consists of a single PartialMapping.
SmallVector< const InstructionMapping *, 4 > InstructionMappings
Convenient type to represent the alternatives for mapping an instruction.
iterator_range< SmallVectorImpl< unsigned >::const_iterator > getVRegs(unsigned OpIdx, bool ForDebug=false) const
Get all the virtual registers required to map the OpIdx-th operand of the instruction.
Helper class used to get/create the virtual registers that will be used to replace the MachineOperand...
virtual ~RegisterBankInfo()=default
Helper struct that represents how a value is partially mapped into a register.
const PartialMapping * BreakDown
How the value is broken down between the different register banks.
Holds all the information related to register banks.
virtual const InstructionMapping & getInstrMapping(const MachineInstr &MI) const
Get the mapping of the different operands of MI on the register bank.
void print(raw_ostream &OS, bool ForDebug=false) const
Print this operands mapper on OS stream.
const HexagonInstrInfo * TII
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Reg
All possible values of the reg field in the ModR/M byte.
unsigned StartIdx
Number of bits at which this partial mapping starts in the original value.
PartialMapping(unsigned StartIdx, unsigned Length, const RegisterBank &RegBank)
Provide a shortcut for quickly building PartialMapping.
const RegisterBank * getRegBankFromConstraints(const MachineInstr &MI, unsigned OpIdx, const TargetInstrInfo &TII, const TargetRegisterInfo &TRI) const
Get the register bank for the OpIdx-th operand of MI form the encoding constraints, if any.
bool verify(unsigned MeaningfulBitWidth) const
Verify that this mapping makes sense for a value of MeaningfulBitWidth.
virtual InstructionMappings getInstrAlternativeMappings(const MachineInstr &MI) const
Get the alternative mappings for MI.
bool verify() const
Check that the Mask is compatible with the RegBank.
hash_code hash_value(const APFloat &Arg)
See friend declarations above.
const ValueMapping * getOperandsMapping(Iterator Begin, Iterator End) const
Get the uniquely generated array of ValueMapping for the elements of between Begin and End...
const RegisterBank * RegBank
Register bank where the partial value lives.
TargetInstrInfo - Interface to description of machine instruction set.
void setVRegs(unsigned OpIdx, unsigned PartialMapIdx, unsigned NewVReg)
Set the virtual register of the PartialMapIdx-th partial mapping of the OpIdx-th operand to NewVReg...
bool verify(const TargetRegisterInfo &TRI) const
Check that information hold by this instance make sense for the given TRI.
ValueMapping(const PartialMapping *BreakDown, unsigned NumBreakDowns)
Initialize a ValueMapping with the given parameter.
unsigned const MachineRegisterInfo * MRI
static unsigned getSizeInBits(unsigned Reg, const MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI)
Get the size in bits of Reg.
const InstructionMapping & getInstrMapping() const
The final mapping of the instruction.
Helper struct that represents how a value is partially mapped into a register.
unsigned Length
Length of this mapping in bits.
unsigned NumRegBanks
Total number of register banks.
static const unsigned End
ValueMapping()
The default constructor creates an invalid (isValid() == false) instance.
static const unsigned DefaultMappingID
Identifier used when the related instruction mapping instance is generated by target independent code...
MachineInstr & getMI() const
const PartialMapping * begin() const
Iterators through the PartialMappings.
void dump() const
Print this partial mapping on dbgs() stream.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
const RegisterBank & getRegBank(unsigned ID) const
Get the register bank identified by ID.
Helper class used to get/create the virtual registers that will be used to replace the MachineOperand...
OperandsMapper(MachineInstr &MI, const InstructionMapping &InstrMapping, MachineRegisterInfo &MRI)
Create an OperandsMapper that will hold the information to apply InstrMapping to MI.
MachineRegisterInfo & getMRI() const
The MachineRegisterInfo we used to realize the mapping.
RegisterBank & getRegBank(unsigned ID)
Get the register bank identified by ID.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
static void applyDefaultMapping(const OperandsMapper &OpdMapper)
Helper method to apply something that is like the default mapping.
InstructionMapping()=default
Default constructor.
const ValueMapping & getOperandMapping(unsigned i) const
Get the value mapping of the ith operand.
This class implements the register bank concept.
Helper struct that represents how a value is mapped through different register banks.
unsigned getCost() const
Get the cost.
A range adaptor for a pair of iterators.
void dump() const
Print this operands mapper on dbgs() stream.
void print(raw_ostream &OS) const
Print this on OS;.
const InstructionMapping & getInstrMapping() const
The final mapping of the instruction.
bool isValid() const
Check whether this object is valid.
void createVRegs(unsigned OpIdx)
Create as many new virtual registers as needed for the mapping of the OpIdx-th operand.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
llvm_unreachable("Unknown RegBank!")
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Representation of each machine instruction.
void print(raw_ostream &OS) const
Print this on OS;.
DenseMap< unsigned, std::unique_ptr< ValueMapping[]> > MapOfOperandsMappings
Keep dynamically allocated array of ValueMapping in a separate map.
InstructionMapping(unsigned ID, unsigned Cost, const ValueMapping *OperandsMapping, unsigned NumOperands)
Constructor for the mapping of an instruction.
unsigned getNumRegBanks() const
Get the total number of register banks.
static const TargetRegisterClass * constrainGenericRegister(unsigned Reg, const TargetRegisterClass &RC, MachineRegisterInfo &MRI)
Constrain the (possibly generic) virtual register Reg to RC.
unsigned getNumOperands() const
Get the number of operands.
unsigned getID() const
Get the ID.
virtual void applyMappingImpl(const OperandsMapper &OpdMapper) const
See applyMapping.
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
Helper struct that represents how a value is mapped through different register banks.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const InstructionMapping & getInstrMappingImpl(const MachineInstr &MI) const
Try to get the mapping of MI.
void dump() const
Print this on dbgs() stream.
unsigned NumBreakDowns
Number of partial mapping to break down this value.
bool verify(const MachineInstr &MI) const
Verifiy that this mapping makes sense for MI.
const PartialMapping & getPartialMapping(unsigned StartIdx, unsigned Length, const RegisterBank &RegBank) const
Get the uniquely generated PartialMapping for the given arguments.
This class implements an extremely fast bulk output stream that can only output to a stream...
DenseMap< unsigned, std::unique_ptr< const InstructionMapping > > MapOfInstructionMappings
Keep dynamically allocated InstructionMapping in a separate map.
const PartialMapping * end() const
class llvm::RegisterBankInfo *void applyMapping(const OperandsMapper &OpdMapper) const
Apply OpdMapper.getInstrMapping() to OpdMapper.getMI().
RegisterBankInfo()
This constructor is meaningless.
DenseMap< unsigned, std::unique_ptr< const ValueMapping > > MapOfValueMappings
Keep dynamically allocated ValueMapping in a separate map.
RegisterBank ** RegBanks
Hold the set of supported register banks.
void print(raw_ostream &OS) const
Print this partial mapping on OS;.