31 RegInfos.resize(TRI.getNumRegs());
35 for (MCPhysReg R : *RC) {
36 RegInfo &RI = RegInfos[R];
37 if (RI.RegClass != nullptr && !BadRC[R]) {
38 if (RC->LaneMask != RI.RegClass->LaneMask) {
40 RI.RegClass = nullptr;
47 UnitInfos.resize(
TRI.getNumRegUnits());
49 for (MCRegUnit U :
TRI.regunits()) {
50 if (UnitInfos[U].Reg != 0)
52 MCRegUnitRootIterator R(U, &TRI);
57 UnitInfos[U].Mask = LaneBitmask::getAll();
60 for (MCRegUnitMaskIterator I(F, &TRI); I.isValid(); ++I) {
61 std::pair<MCRegUnit, LaneBitmask> P = *I;
62 UnitInfo &UI = UnitInfos[P.first];
71 for (
const MachineBasicBlock &
B : mf)
72 for (
const MachineInstr &In :
B)
73 for (
const MachineOperand &
Op : In.operands())
75 RegMasks.insert(
Op.getRegMask());
77 MaskInfos.resize(RegMasks.size() + 1);
78 for (
uint32_t M = 1, NM = RegMasks.size(); M <= NM; ++M) {
79 BitVector PU(TRI.getNumRegUnits());
80 const uint32_t *MB = RegMasks.get(M);
81 for (unsigned I = 1, E = TRI.getNumRegs(); I != E; ++I) {
82 if (!(MB[I / 32] & (1u << (I % 32))))
84 for (MCRegUnit Unit : TRI.regunits(MCRegister::from(I)))
85 PU.set(static_cast<unsigned>(Unit));
87 MaskInfos[M].Units = PU.flip();
90 AliasInfos.resize(
TRI.getNumRegUnits());
91 for (MCRegUnit U :
TRI.regunits()) {
92 BitVector AS(TRI.getNumRegs());
93 for (MCRegUnitRootIterator R(U, &TRI); R.isValid(); ++R)
94 for (MCPhysReg S : TRI.superregs_inclusive(*R))
96 AliasInfos[U].Regs = AS;
106 std::set<RegisterId> AS;
111 for (
unsigned i = 1, e = TRI.getNumRegs(); i != e; ++i) {
112 if (MB[i / 32] & (1u << (i % 32)))
127 std::set<RegisterId> Units;
134 if ((M & RR.
Mask).any())
135 Units.insert(
static_cast<unsigned>(U));
141 unsigned NumRegs = TRI.getNumRegs();
143 for (
unsigned I = 0,
E = (NumRegs + 31) / 32;
I !=
E; ++
I) {
147 if (
I + 1 ==
E && NumRegs % 32 != 0)
153 unsigned CR = 32 *
I +
T;
154 for (MCRegUnit U : TRI.regunits(CR))
155 Units.insert(
static_cast<unsigned>(U));
169 const RegInfo &RI = RegInfos[R];
179 if (!
A.isReg() || !
B.isReg()) {
185 return A.Mask ==
B.Mask;
191 auto [AReg, AMask] = *AI;
192 auto [BReg, BMask] = *BI;
196 if ((AMask &
A.Mask).any() && (BMask &
B.Mask).any()) {
205 if ((AMask &
A.Mask).none())
207 if ((BMask &
B.Mask).none())
211 return static_cast<int>(AI.
isValid()) ==
static_cast<int>(BI.
isValid());
215 if (!
A.isReg() || !
B.isReg()) {
221 return A.Mask <
B.Mask;
222 if (
A.Mask ==
B.Mask)
229 auto [AReg, AMask] = *AI;
230 auto [BReg, BMask] = *BI;
234 if ((AMask &
A.Mask).any() && (BMask &
B.Mask).any()) {
243 if ((AMask &
A.Mask).none())
245 if ((BMask &
B.Mask).none())
249 return static_cast<int>(AI.
isValid()) <
static_cast<int>(BI.
isValid());
255 if (
Reg &&
Reg.id() < TRI.getNumRegs())
256 OS << TRI.getName(
Reg);
260 }
else if (
A.isUnit()) {
263 unsigned Idx =
A.asMaskIdx();
264 const char *Fmt = Idx < 0x10000 ?
"%04x" :
"%08x";
265 OS <<
"M#" <<
format(Fmt, Idx);
271 for (
unsigned U :
A.units())
272 OS << ' ' << printRegUnit(static_cast<MCRegUnit>(U), &TRI);
278 return Units.anyCommon(PRI.getMaskUnits(RR));
281 auto [Unit, LaneMask] = *U;
282 if ((LaneMask & RR.
Mask).any())
283 if (Units.test(
static_cast<unsigned>(Unit)))
291 return PRI.getMaskUnits(RR).subsetOf(Units);
294 auto [Unit, LaneMask] = *U;
295 if ((LaneMask & RR.
Mask).any())
296 if (!Units.test(
static_cast<unsigned>(Unit)))
304 Units |= PRI.getMaskUnits(RR);
309 auto [Unit, LaneMask] = *U;
310 if ((LaneMask & RR.
Mask).any())
311 Units.set(
static_cast<unsigned>(Unit));
335 Units.reset(RG.Units);
341 T.insert(RR).intersect(*
this);
350 return RegisterAggr(PRI).insert(RR).clear(*this).makeRegRef();
354 int U = Units.find_first();
362 BitVector Regs = PRI.getUnitAliases(
static_cast<MCRegUnit
>(U));
368 Regs &= PRI.getUnitAliases(
static_cast<MCRegUnit
>(U));
382 auto [Unit, LaneMask] = *
I;
383 if (Units.test(
static_cast<unsigned>(Unit)))
392 RegisterRef R = RG.PRI.getRefForUnit(static_cast<MCRegUnit>(U));
393 Masks[R.Id] |= R.Mask;
395 Pos = End ? Masks.end() : Masks.begin();
396 Index = End ? Masks.size() : 0;
400 A.getPRI().print(OS,
A);
408 return OS <<
":*none*";
411 if ((Val & 0xffff) == Val)
412 return OS <<
':' <<
format(
"%04llX", Val);
413 if ((Val & 0xffffffff) == Val)
414 return OS <<
':' <<
format(
"%08llX", Val);
for(const MachineOperand &MO :llvm::drop_begin(OldMI.operands(), Desc.getNumOperands()))
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file implements the BitVector class.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
A common definition of LaneBitmask for use in TableGen and CodeGen.
Register const TargetRegisterInfo * TRI
static Interval intersect(const Interval &I1, const Interval &I2)
SI optimize exec mask operations pre RA
int find_first() const
Returns the index of the first set bit, -1 if none of the bits are set.
int find_next(unsigned Prev) const
Returns the index of the next set bit following the "Prev" bit.
MCRegAliasIterator enumerates all registers aliasing Reg.
MCRegUnitMaskIterator enumerates a list of register units and their associated lane masks for Reg.
bool isValid() const
Returns true if this iterator is not yet at the end.
Wrapper class representing physical registers. Should be passed by value.
const LaneBitmask LaneMask
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
LLVM_ABI raw_ostream & operator<<(raw_ostream &OS, const Print< RegisterRef > &P)
bool disjoint(const std::set< T > &A, const std::set< T > &B)
constexpr T maskLeadingOnes(unsigned N)
Create a bitmask with the N left-most bits set to 1, and all other bits set to 0.
Printable PrintLaneMask(LaneBitmask LaneMask)
Create Printable object to print LaneBitmasks on a raw_ostream.
LLVM_ABI Printable printRegUnit(MCRegUnit Unit, const TargetRegisterInfo *TRI)
Create Printable object to print register units on a raw_ostream.
int countr_zero(T Val)
Count number of 0's from the least significant bit to the most stopping at the first 1.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
DWARFExpression::Operation Op
constexpr T maskTrailingOnes(unsigned N)
Create a bitmask with the N right-most bits set to 1, and all other bits set to 0.
LLVM_ABI Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
static constexpr LaneBitmask getAll()
constexpr bool none() const
LLVM_ABI PhysicalRegisterInfo(const TargetRegisterInfo &tri, const MachineFunction &mf)
LLVM_ABI void print(raw_ostream &OS, RegisterRef A) const
const TargetRegisterInfo & getTRI() const
LLVM_ABI bool equal_to(RegisterRef A, RegisterRef B) const
const uint32_t * getRegMaskBits(RegisterRef RR) const
LLVM_ABI bool alias(RegisterRef RA, RegisterRef RB) const
LLVM_ABI std::set< RegisterId > getAliasSet(RegisterRef RR) const
LLVM_ABI bool less(RegisterRef A, RegisterRef B) const
LLVM_ABI RegisterRef mapTo(RegisterRef RR, RegisterId R) const
LLVM_ABI std::set< RegisterId > getUnits(RegisterRef RR) const
LLVM_ABI ref_iterator(const RegisterAggr &RG, bool End)
LLVM_ABI RegisterAggr & insert(RegisterRef RR)
RegisterAggr(const PhysicalRegisterInfo &pri)
LLVM_ABI RegisterRef clearIn(RegisterRef RR) const
LLVM_ABI RegisterAggr & clear(RegisterRef RR)
LLVM_ABI RegisterRef makeRegRef() const
LLVM_ABI RegisterAggr & intersect(RegisterRef RR)
LLVM_ABI bool hasAliasOf(RegisterRef RR) const
LLVM_ABI RegisterRef intersectWith(RegisterRef RR) const
LLVM_ABI bool hasCoverOf(RegisterRef RR) const
constexpr bool isReg() const
constexpr bool isMask() const
constexpr bool isUnit() const
constexpr MCRegister asMCReg() const