15#ifndef LLVM_MC_MCREGISTERINFO_H
16#define LLVM_MC_MCREGISTERINFO_H
87 return reinterpret_cast<iterator>(
reinterpret_cast<const char *
>(
this) +
113 unsigned InByte = RegSetIdx % 8;
114 unsigned Byte = RegSetIdx / 8;
116 return (RegSet[Byte] & (1 << InByte)) != 0;
138 return CopyCost == std::numeric_limits<uint8_t>::max();
188 return reinterpret_cast<const uint32_t *
>(
197 return reinterpret_cast<const uint32_t *
>(
205 return reinterpret_cast<const uint32_t *
>(
206 reinterpret_cast<const char *
>(
this) +
Offset);
217 return reinterpret_cast<const uint16_t *
>(
225 const unsigned *SuperClasses =
reinterpret_cast<const unsigned *
>(
236template <
unsigned RegClassCount,
unsigned RegCount,
unsigned BitSetSize,
237 unsigned SubClassMaskSize,
unsigned SuperRegMaskOffsetSize,
238 unsigned SuperRegIdxSeqSize,
unsigned SuperClassSize>
246 ? SuperRegMaskOffsetSize
316 unsigned NumRegUnits;
318 const int16_t *DiffLists;
321 const char *RegStrings;
322 const char *RegClassStrings;
325 unsigned NumSubRegIndices;
328 const unsigned (*RegUnitIntervals)[2];
330 unsigned L2DwarfRegsSize;
331 unsigned EHL2DwarfRegsSize;
332 unsigned Dwarf2LRegsSize;
333 unsigned EHDwarf2LRegsSize;
334 const DwarfLLVMRegPair *L2DwarfRegs;
335 const DwarfLLVMRegPair *EHL2DwarfRegs;
336 const DwarfLLVMRegPair *Dwarf2LRegs;
337 const DwarfLLVMRegPair *EHDwarf2LRegs;
341 mutable std::vector<std::vector<MCPhysReg>> RegAliasesCache;
346 class DiffListIterator
350 const int16_t *
List =
nullptr;
355 DiffListIterator() =
default;
358 void init(
unsigned InitVal,
const int16_t *DiffList) {
364 bool isValid()
const {
return List; }
367 const unsigned &
operator*()
const {
return Val; }
369 using DiffListIterator::iterator_facade_base::operator++;
371 DiffListIterator &operator++() {
381 bool operator==(
const DiffListIterator &Other)
const {
389 iterator_range<MCSubRegIterator> subregs(MCRegister
Reg)
const;
393 iterator_range<MCSubRegIterator> subregs_inclusive(MCRegister
Reg)
const;
397 iterator_range<MCSuperRegIterator> superregs(MCRegister
Reg)
const;
401 iterator_range<MCSuperRegIterator> superregs_inclusive(MCRegister
Reg)
const;
405 detail::concat_range<const MCPhysReg, iterator_range<MCSubRegIterator>,
406 iterator_range<MCSuperRegIterator>>
407 sub_and_superregs_inclusive(MCRegister
Reg)
const;
410 iota_range<MCRegUnit> regunits()
const;
413 iterator_range<MCRegUnitIterator> regunits(MCRegister
Reg)
const;
431 const MCPhysReg (*RURoots)[2],
unsigned NRU,
433 const char *Strings,
const char *ClassStrings,
434 const uint16_t *SubIndices,
unsigned NumIndices,
436 const unsigned (*RUI)[2] =
nullptr) {
443 RegUnitMaskSequences = RUMS;
444 RegStrings = Strings;
445 RegClassStrings = ClassStrings;
447 RegUnitRoots = RURoots;
449 SubRegIndices = SubIndices;
450 NumSubRegIndices = NumIndices;
451 RegEncodingTable = RET;
452 RegUnitIntervals = RUI;
455 EHL2DwarfRegs =
nullptr;
456 EHL2DwarfRegsSize = 0;
457 L2DwarfRegs =
nullptr;
459 EHDwarf2LRegs =
nullptr;
460 EHDwarf2LRegsSize = 0;
461 Dwarf2LRegs =
nullptr;
464 RegAliasesCache.resize(NumRegs);
474 EHL2DwarfRegsSize =
Size;
477 L2DwarfRegsSize =
Size;
488 EHDwarf2LRegsSize =
Size;
491 Dwarf2LRegsSize =
Size;
501 L2SEHRegs[LLVMReg] = SEHReg;
505 L2CVRegs[LLVMReg] = CVReg;
521 "Attempting to access record for invalid register number!");
522 return Desc[
Reg.id()];
549 return RegStrings +
get(RegNo).Name;
563 bool isArtificialRegUnit(MCRegUnit Unit)
const;
575 return NumSubRegIndices;
593 std::optional<MCRegister> getLLVMRegNum(
uint64_t RegNum,
bool isEH)
const;
597 int64_t getDwarfRegNumFromDwarfEHRegNum(
uint64_t RegNum)
const;
625 return RegClassStrings + Class->NameIdx;
631 "Attempting to get encoding for invalid register number!");
632 return RegEncodingTable[
Reg.id()];
670 "Target does not support regunit intervals");
671 assert(
Reg.id() < NumRegs &&
"Invalid register number");
673 RegUnitIntervals[
Reg.id()][1]);
688 MCRegisterInfo::DiffListIterator,
689 std::forward_iterator_tag, const MCPhysReg> {
698 bool IncludeSelf =
false) {
709 using iterator_adaptor_base::operator++;
729 : SRIter(
Reg, MCRI) {
730 SRIndex = MCRI->SubRegIndices + MCRI->
get(
Reg).SubRegIndices;
744 bool isValid()
const {
return SRIter.isValid(); }
758 MCRegisterInfo::DiffListIterator,
759 std::forward_iterator_tag, const MCPhysReg> {
768 bool IncludeSelf =
false) {
779 using iterator_adaptor_base::operator++;
803 MCRegisterInfo::DiffListIterator,
804 std::forward_iterator_tag, const MCRegUnit> {
806 static constexpr unsigned RegUnitBits = 12;
818 unsigned FirstRU = RU & ((1u << RegUnitBits) - 1);
819 unsigned Offset = RU >> RegUnitBits;
820 I.init(FirstRU, MCRI->DiffLists +
Offset);
826 using iterator_adaptor_base::operator++;
828 Val = MCRegUnit(*++
I);
849 : RUIter(
Reg, MCRI) {
851 MaskListIter = &MCRI->RegUnitMaskSequences[Idx];
856 return std::make_pair(*RUIter, *MaskListIter);
860 bool isValid()
const {
return RUIter.isValid(); }
889 "Invalid register unit");
890 Reg0 = MCRI->RegUnitRoots[
static_cast<unsigned>(RegUnit)][0];
891 Reg1 = MCRI->RegUnitRoots[
static_cast<unsigned>(RegUnit)][1];
968 return enum_seq(
static_cast<MCRegUnit
>(0),
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
This file defines the DenseMap class.
A common definition of LaneBitmask for use in TableGen and CodeGen.
bool operator==(const MergedFunctionsInfo &LHS, const MergedFunctionsInfo &RHS)
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
static constexpr MCPhysReg RAReg
static bool isValid(const char C)
Returns true if C is a valid mangled character: <0-9a-zA-Z_>.
SI optimize exec mask operations pre RA
Provides some synthesis utilities to produce sequences of values.
static unsigned getDwarfRegNum(MCRegister Reg, const TargetRegisterInfo *TRI)
Go up the super-register chain until we hit a valid dwarf register number.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
MCRegAliasIterator(MCRegister Reg, const MCRegisterInfo *MCRI, bool IncludeSelf)
MCRegister operator*() const
MCRegAliasIterator & operator++()
const MCRegUnit & operator*() const
MCRegUnitIterator()=default
Constructs an end iterator.
bool isValid() const
Returns true if this iterator is not yet at the end.
MCRegUnitIterator & operator++()
MCRegUnitIterator(MCRegister Reg, const MCRegisterInfo *MCRI)
MCRegUnitMaskIterator()=default
MCRegUnitMaskIterator(MCRegister Reg, const MCRegisterInfo *MCRI)
Constructs an iterator that traverses the register units and their associated LaneMasks in Reg.
std::pair< MCRegUnit, LaneBitmask > operator*() const
Returns a (RegUnit, LaneMask) pair.
MCRegUnitMaskIterator & operator++()
Moves to the next position.
bool isValid() const
Returns true if this iterator is not yet at the end.
MCRegUnitRootIterator()=default
MCRegUnitRootIterator & operator++()
Preincrement to move to the next root register.
unsigned operator*() const
Dereference to get the current root register.
MCRegUnitRootIterator(MCRegUnit RegUnit, const MCRegisterInfo *MCRI)
bool isValid() const
Check if the iterator is at the end of the list.
MCRegisterClass - Base class of TargetRegisterClass.
const uint8_t SpillStackID
ArrayRef< unsigned > superclasses() const
Returns a list of super-classes.
const MCPhysReg RegSetBegin
Register denoted by first bit in RegSet.
bool hasSuperClass(const MCRegisterClass *RC) const
Return true if the specified MCRegisterClass is a proper super-class of this MCRegisterClass.
const bool CoveredBySubRegs
Whether a combination of subregisters can cover every register in the class.
const uint32_t * getSubClassMask() const
Returns a bit vector of subclasses, including this one.
bool hasSuperClassEq(const MCRegisterClass *RC) const
Returns true if RC is a super-class of or equal to this class.
unsigned getID() const
getID() - Return the register class ID number.
ArrayRef< MCPhysReg > getRegisters() const
const uint32_t RegSizeInBits
bool isAllocatable() const
isAllocatable - Return true if this register class may be used to create virtual registers.
const uint32_t * getSuperRegClassMaskOffsets() const
Returns the relative offsets of this class's super-register class bit masks, one per entry of getSupe...
const uint8_t AllocationPriority
Classes with a higher priority value are assigned first by register allocators using a greedy heurist...
const uint32_t SuperRegMaskOffsetsOff
Relative offset to a uint32_t array holding, for each entry of getSuperRegIndices(),...
const MCPhysReg * iterator
MCRegister getRegister(unsigned i) const
getRegister - Return the specified register in the class.
const uint8_t TSFlags
Configurable target specific flags.
const uint32_t SuperClassesOff
Relative offset to unsigned array.
const LaneBitmask LaneMask
unsigned getSizeInBits() const
Return the size of the physical register in bits if we are able to determine it.
const uint32_t RegSetOff
Relative offset to uint8_t array.
const uint16_t RegSetSize
bool contains(MCRegister Reg1, MCRegister Reg2) const
contains - Return true if both registers are in this class.
LaneBitmask getLaneMask() const
Returns the combination of all lane masks of register in this class.
const uint32_t SuperRegIndicesOff
Relative offset to MCPhysReg array.
const bool GlobalPriority
const uint16_t * getSuperRegIndices() const
Returns a 0-terminated list of sub-register indices that project some super-register class into this ...
unsigned getNumRegs() const
getNumRegs - Return the number of registers in this class.
const uint32_t SubClassMaskOff
Relative offset to uint32_t array.
iterator begin() const
begin/end - Return all of the registers in this class.
bool contains(MCRegister Reg) const
contains - Return true if the specified register is included in this register class.
const uint32_t RegsOff
Relative offset to MCPhysReg array.
bool isBaseClass() const
Return true if this register class has a defined BaseClassOrder.
bool expensiveOrImpossibleToCopy() const
uint8_t getCopyCost() const
getCopyCost - Return the cost of copying a value between two registers in this class.
const uint32_t * getSuperRegClassMaskAt(uint32_t Offset) const
Returns the bit mask of register classes that the sub-register index belonging to Offset projects int...
const bool HasDisjunctSubRegs
Whether the class supports two (or more) disjunct subregister indices.
bool hasSubClass(const MCRegisterClass *RC) const
Return true if the specified TargetRegisterClass is a proper sub-class of this TargetRegisterClass.
const uint16_t SuperClassesSize
const MCPhysReg * const_iterator
bool hasSubClassEq(const MCRegisterClass *RC) const
Returns true if RC is a sub-class of or equal to this class.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
iota_range< unsigned > regunits_interval(MCRegister Reg) const
Returns an iterator range over all native regunits in the RegUnitInterval table for Reg.
void InitMCRegisterInfo(const MCRegisterDesc *D, unsigned NR, unsigned RA, unsigned PC, const MCRegisterClass *C, unsigned NC, const MCPhysReg(*RURoots)[2], unsigned NRU, const int16_t *DL, const LaneBitmask *RUMS, const char *Strings, const char *ClassStrings, const uint16_t *SubIndices, unsigned NumIndices, const uint16_t *RET, const unsigned(*RUI)[2]=nullptr)
Initialize MCRegisterInfo, called by TableGen auto-generated routines.
unsigned getNumSubRegIndices() const
Return the number of sub-register indices understood by the target.
const MCRegisterDesc & operator[](MCRegister Reg) const
bool isSuperRegisterEq(MCRegister RegA, MCRegister RegB) const
Returns true if RegB is a super-register of RegA or if RegB == RegA.
unsigned getNumRegClasses() const
MCRegister getRARegister() const
This method should return the register where the return address can be found.
virtual ~MCRegisterInfo()=default
MCRegister getProgramCounter() const
Return the register which is the program counter.
regclass_iterator regclass_end() const
void mapDwarfRegsToLLVMRegs(const DwarfLLVMRegPair *Map, unsigned Size, bool isEH)
Used to initialize Dwarf register to LLVM register number mapping.
unsigned getNumRegUnits() const
Return the number of (native) register units in the target.
friend class MCRegAliasIterator
const MCRegisterDesc & get(MCRegister Reg) const
Provide a get method, equivalent to [], but more useful with a pointer to this object.
const MCRegisterClass * regclass_iterator
iterator_range< regclass_iterator > regclasses() const
regclass_iterator regclass_begin() const
iota_range< MCRegUnit > regunits() const
Returns an iterator range over all regunits.
void mapLLVMRegToCVReg(MCRegister LLVMReg, int CVReg)
iterator_range< MCSuperRegIterator > superregs(MCRegister Reg) const
Return an iterator range over all super-registers of Reg, excluding Reg.
const char * getName(MCRegister RegNo) const
Return the human-readable symbolic target-specific name for the specified physical register.
bool hasRegUnitIntervals() const
Returns true if this target uses regunit intervals.
const char * getRegClassName(const MCRegisterClass *Class) const
friend class MCSubRegIterator
friend class MCRegUnitRootIterator
uint16_t getEncodingValue(MCRegister Reg) const
Returns the encoding for Reg.
iterator_range< MCSubRegIterator > subregs_inclusive(MCRegister Reg) const
Return an iterator range over all sub-registers of Reg, including Reg.
bool isSuperOrSubRegisterEq(MCRegister RegA, MCRegister RegB) const
Returns true if RegB is a super-register or sub-register of RegA or if RegB == RegA.
bool isSubRegister(MCRegister RegA, MCRegister RegB) const
Returns true if RegB is a sub-register of RegA.
friend class MCSuperRegIterator
iterator_range< MCSubRegIterator > subregs(MCRegister Reg) const
Return an iterator range over all sub-registers of Reg, excluding Reg.
bool isConstant(MCRegister RegNo) const
Returns true if the given register is constant.
friend class MCRegUnitMaskIterator
void mapLLVMRegsToDwarfRegs(const DwarfLLVMRegPair *Map, unsigned Size, bool isEH)
Used to initialize LLVM register to Dwarf register number mapping.
bool isSuperRegister(MCRegister RegA, MCRegister RegB) const
Returns true if RegB is a super-register of RegA.
bool isArtificial(MCRegister RegNo) const
Returns true if the given register is artificial, which means it represents a regunit that is not sep...
bool isSubRegisterEq(MCRegister RegA, MCRegister RegB) const
Returns true if RegB is a sub-register of RegA or if RegB == RegA.
friend class MCRegUnitIterator
void mapLLVMRegToSEHReg(MCRegister LLVMReg, int SEHReg)
mapLLVMRegToSEHReg - Used to initialize LLVM register to SEH register number mapping.
iterator_range< MCSuperRegIterator > superregs_inclusive(MCRegister Reg) const
Return an iterator range over all super-registers of Reg, including Reg.
detail::concat_range< const MCPhysReg, iterator_range< MCSubRegIterator >, iterator_range< MCSuperRegIterator > > sub_and_superregs_inclusive(MCRegister Reg) const
Return an iterator range over all sub- and super-registers of Reg, including Reg.
const MCRegisterClass & getRegClass(unsigned i) const
Returns the register class associated with the enumeration value.
unsigned getNumRegs() const
Return the number of registers this target has (useful for sizing arrays holding per register informa...
friend class MCSubRegIndexIterator
Wrapper class representing physical registers. Should be passed by value.
MCSubRegIndexIterator(MCRegister Reg, const MCRegisterInfo *MCRI)
Constructs an iterator that traverses subregisters and their associated subregister indices.
MCSubRegIndexIterator & operator++()
Moves to the next position.
bool isValid() const
Returns true if this iterator is not yet at the end.
unsigned getSubRegIndex() const
Returns sub-register index of the current sub-register.
MCRegister getSubReg() const
Returns current sub-register.
MCSubRegIterator enumerates all sub-registers of Reg.
const MCPhysReg & operator*() const
MCSubRegIterator & operator++()
bool isValid() const
Returns true if this iterator is not yet at the end.
MCSubRegIterator()=default
Constructs an end iterator.
MCSubRegIterator(MCRegister Reg, const MCRegisterInfo *MCRI, bool IncludeSelf=false)
MCSuperRegIterator enumerates all super-registers of Reg.
MCSuperRegIterator(MCRegister Reg, const MCRegisterInfo *MCRI, bool IncludeSelf=false)
MCSuperRegIterator & operator++()
const MCPhysReg & operator*() const
MCSuperRegIterator()=default
Constructs an end iterator.
bool isValid() const
Returns true if this iterator is not yet at the end.
Helper to store a sequence of ranges being concatenated and access them.
MCRegisterInfo::DiffListIterator I
iterator_adaptor_base()=default
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
A range adaptor for a pair of iterators.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
This is an optimization pass for GlobalISel generic memory operations.
APInt operator*(APInt a, uint64_t RHS)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
constexpr force_iteration_on_noniterable_enum_t force_iteration_on_noniterable_enum
detail::concat_range< ValueT, RangeTs... > concat(RangeTs &&...Ranges)
Returns a concatenated range across two or more ranges.
constexpr auto enum_seq(EnumT Begin, EnumT End)
Iterate over an enum type from Begin up to - but not including - End.
iterator_range(Container &&) -> iterator_range< llvm::detail::IterOfRange< Container > >
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
ArrayRef(const T &OneElt) -> ArrayRef< T >
constexpr auto seq(T Begin, T End)
Iterate over an integral type from Begin up to - but not including - End.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
uint8_t BitSets[BitSetSize]
uint32_t SuperRegMaskOffsets[SuperRegMaskOffsetSize > 0 ? SuperRegMaskOffsetSize :1]
MCRegisterClass Classes[RegClassCount]
uint32_t SubClassMasks[SubClassMaskSize]
uint16_t SuperRegIdxSeqs[SuperRegIdxSeqSize]
unsigned SuperClasses[SuperClassSize > 0 ? SuperClassSize :1]
MCRegisterDesc - This record contains information about a particular register.
uint16_t RegUnitLaneMasks
Index into list with lane mask sequences.
DwarfLLVMRegPair - Emitted by tablegen so Dwarf<->LLVM reg mappings can be performed with a binary se...
bool operator<(DwarfLLVMRegPair RHS) const