forked from OSchip/llvm-project
[RDF] Cache register aliases in PhysicalRegisterInfo
This improves performance of PhysicalRegisterInfo::makeRegRef.
This commit is contained in:
parent
47fe1b63f4
commit
f0f467aeec
|
@ -132,6 +132,10 @@ namespace rdf {
|
|||
return MaskInfos[Register::stackSlot2Index(MaskId)].Units;
|
||||
}
|
||||
|
||||
const BitVector &getUnitAliases(uint32_t U) const {
|
||||
return AliasInfos[U].Regs;
|
||||
}
|
||||
|
||||
RegisterRef mapTo(RegisterRef RR, unsigned R) const;
|
||||
const TargetRegisterInfo &getTRI() const { return TRI; }
|
||||
|
||||
|
@ -146,12 +150,16 @@ namespace rdf {
|
|||
struct MaskInfo {
|
||||
BitVector Units;
|
||||
};
|
||||
struct AliasInfo {
|
||||
BitVector Regs;
|
||||
};
|
||||
|
||||
const TargetRegisterInfo &TRI;
|
||||
IndexedSet<const uint32_t*> RegMasks;
|
||||
std::vector<RegInfo> RegInfos;
|
||||
std::vector<UnitInfo> UnitInfos;
|
||||
std::vector<MaskInfo> MaskInfos;
|
||||
std::vector<AliasInfo> AliasInfos;
|
||||
|
||||
bool aliasRR(RegisterRef RA, RegisterRef RB) const;
|
||||
bool aliasRM(RegisterRef RR, RegisterRef RM) const;
|
||||
|
|
|
@ -92,6 +92,15 @@ PhysicalRegisterInfo::PhysicalRegisterInfo(const TargetRegisterInfo &tri,
|
|||
}
|
||||
MaskInfos[M].Units = PU.flip();
|
||||
}
|
||||
|
||||
AliasInfos.resize(TRI.getNumRegUnits());
|
||||
for (uint32_t U = 0, NU = TRI.getNumRegUnits(); U != NU; ++U) {
|
||||
BitVector AS(TRI.getNumRegs());
|
||||
for (MCRegUnitRootIterator R(U, &TRI); R.isValid(); ++R)
|
||||
for (MCSuperRegIterator S(*R, &TRI, true); S.isValid(); ++S)
|
||||
AS.set(*S);
|
||||
AliasInfos[U].Regs = AS;
|
||||
}
|
||||
}
|
||||
|
||||
std::set<RegisterId> PhysicalRegisterInfo::getAliasSet(RegisterId Reg) const {
|
||||
|
@ -317,26 +326,17 @@ RegisterRef RegisterAggr::makeRegRef() const {
|
|||
if (U < 0)
|
||||
return RegisterRef();
|
||||
|
||||
auto AliasedRegs = [this] (uint32_t Unit, BitVector &Regs) {
|
||||
for (MCRegUnitRootIterator R(Unit, &PRI.getTRI()); R.isValid(); ++R)
|
||||
for (MCSuperRegIterator S(*R, &PRI.getTRI(), true); S.isValid(); ++S)
|
||||
Regs.set(*S);
|
||||
};
|
||||
|
||||
// Find the set of all registers that are aliased to all the units
|
||||
// in this aggregate.
|
||||
|
||||
// Get all the registers aliased to the first unit in the bit vector.
|
||||
BitVector Regs(PRI.getTRI().getNumRegs());
|
||||
AliasedRegs(U, Regs);
|
||||
BitVector Regs = PRI.getUnitAliases(U);
|
||||
U = Units.find_next(U);
|
||||
|
||||
// For each other unit, intersect it with the set of all registers
|
||||
// aliased that unit.
|
||||
while (U >= 0) {
|
||||
BitVector AR(PRI.getTRI().getNumRegs());
|
||||
AliasedRegs(U, AR);
|
||||
Regs &= AR;
|
||||
Regs &= PRI.getUnitAliases(U);
|
||||
U = Units.find_next(U);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue