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());
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<uint32_t, 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)))
87 MaskInfos[M].Units = PU.flip();
90 AliasInfos.resize(
TRI.getNumRegUnits());
91 for (uint32_t U = 0, NU =
TRI.getNumRegUnits(); U != NU; ++U) {
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;
137 if ((M & RR.
Mask).any())
144 unsigned NumRegs = TRI.getNumRegs();
146 for (
unsigned I = 0,
E = (NumRegs + 31) / 32;
I !=
E; ++
I) {
150 if (
I + 1 ==
E && NumRegs % 32 != 0)
156 unsigned CR = 32 *
I +
T;
168 if (
unsigned Idx = TRI.getSubRegIndex(R, RR.
Reg))
170 if (
unsigned Idx = TRI.getSubRegIndex(RR.
Reg, R)) {
171 const RegInfo &RI = RegInfos[R];
181 if (!
A.isReg() || !
B.isReg()) {
183 return A.Reg ==
B.Reg;
187 return A.Mask ==
B.Mask;
193 auto [AReg, AMask] = *AI;
194 auto [BReg, BMask] = *BI;
198 if ((AMask &
A.Mask).any() && (BMask &
B.Mask).any()) {
207 if ((AMask &
A.Mask).none())
209 if ((BMask &
B.Mask).none())
213 return static_cast<int>(AI.
isValid()) ==
static_cast<int>(BI.
isValid());
217 if (!
A.isReg() || !
B.isReg()) {
219 return A.Reg <
B.Reg;
223 return A.Mask <
B.Mask;
224 if (
A.Mask ==
B.Mask)
225 return A.Reg <
B.Reg;
231 auto [AReg, AMask] = *AI;
232 auto [BReg, BMask] = *BI;
236 if ((AMask &
A.Mask).any() && (BMask &
B.Mask).any()) {
245 if ((AMask &
A.Mask).none())
247 if ((BMask &
B.Mask).none())
251 return static_cast<int>(AI.
isValid()) <
static_cast<int>(BI.
isValid());
255 if (
A.Reg == 0 ||
A.isReg()) {
256 if (0 <
A.idx() &&
A.idx() < TRI.getNumRegs())
257 OS << TRI.getName(
A.idx());
261 }
else if (
A.isUnit()) {
266 unsigned Idx =
Register(
A.idx()).stackSlotIndex();
267 const char *Fmt = Idx < 0x10000 ?
"%04x" :
"%08x";
268 OS <<
"M#" <<
format(Fmt, Idx);
274 for (
unsigned U :
A.units())
281 return Units.anyCommon(PRI.getMaskUnits(RR.
Reg));
284 std::pair<uint32_t, LaneBitmask>
P = *U;
285 if ((
P.second & RR.
Mask).any())
286 if (Units.test(
P.first))
295 return T.reset(Units).none();
299 std::pair<uint32_t, LaneBitmask>
P = *U;
300 if ((
P.second & RR.
Mask).any())
301 if (!Units.test(
P.first))
309 Units |= PRI.getMaskUnits(RR.
Reg);
314 std::pair<uint32_t, LaneBitmask>
P = *U;
315 if ((
P.second & RR.
Mask).any())
340 Units.reset(RG.Units);
346 T.insert(RR).intersect(*
this);
355 return RegisterAggr(PRI).insert(RR).clear(*this).makeRegRef();
359 int U = Units.find_first();
373 Regs &= PRI.getUnitAliases(U);
387 std::pair<uint32_t, LaneBitmask>
P = *
I;
388 if (Units.test(
P.first))
397 RegisterRef R = RG.PRI.getRefForUnit(U);
398 Masks[R.Reg] |= R.Mask;
400 Pos = End ? Masks.end() : Masks.begin();
401 Index = End ? Masks.size() : 0;
405 A.getPRI().print(OS,
A);
413 return OS <<
":*none*";
416 if ((Val & 0xffff) == Val)
417 return OS <<
':' <<
format(
"%04llX", Val);
418 if ((Val & 0xffffffff) == Val)
419 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)
Promote Memory to Register
SI optimize exec mask operations pre RA
int find_first() const
find_first - Returns the index of the first set bit, -1 if none of the bits are set.
int find_next(unsigned Prev) const
find_next - 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.
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.
raw_ostream & operator<<(raw_ostream &OS, const Print< RegisterRef > &P)
bool disjoint(const std::set< T > &A, const std::set< T > &B)
LLVM_ABI Printable printRegUnit(unsigned Unit, const TargetRegisterInfo *TRI)
Create Printable object to print register units on a raw_ostream.
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.
int countr_zero(T Val)
Count number of 0's from the least significant bit to the most stopping at the first 1.
unsigned MCRegUnit
Register units are used to compute register aliasing.
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
PhysicalRegisterInfo(const TargetRegisterInfo &tri, const MachineFunction &mf)
void print(raw_ostream &OS, RegisterRef A) const
const TargetRegisterInfo & getTRI() const
const uint32_t * getRegMaskBits(RegisterId R) const
std::set< RegisterId > getAliasSet(RegisterId Reg) const
bool equal_to(RegisterRef A, RegisterRef B) const
bool alias(RegisterRef RA, RegisterRef RB) const
RegisterRef mapTo(RegisterRef RR, unsigned R) const
bool less(RegisterRef A, RegisterRef B) const
std::set< RegisterId > getUnits(RegisterRef RR) const
ref_iterator(const RegisterAggr &RG, bool End)
RegisterAggr & insert(RegisterRef RR)
RegisterAggr(const PhysicalRegisterInfo &pri)
RegisterRef clearIn(RegisterRef RR) const
RegisterAggr & clear(RegisterRef RR)
RegisterRef makeRegRef() const
RegisterAggr & intersect(RegisterRef RR)
bool hasAliasOf(RegisterRef RR) const
RegisterRef intersectWith(RegisterRef RR) const
bool hasCoverOf(RegisterRef RR) const
constexpr unsigned idx() const
constexpr bool isReg() const
constexpr bool isMask() const
static constexpr bool isMaskId(unsigned Id)
static constexpr bool isRegId(unsigned Id)
static constexpr bool isUnitId(unsigned Id)