mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Simplify CodeGenRegBank::inferMatchingSuperRegClass & its caller by passing an iterator rather than index
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223262 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7a16f34aa6
commit
4496906657
@ -1816,7 +1816,7 @@ void CodeGenRegBank::inferSubClassWithSubReg(CodeGenRegisterClass *RC) {
|
|||||||
//
|
//
|
||||||
|
|
||||||
void CodeGenRegBank::inferMatchingSuperRegClass(CodeGenRegisterClass *RC,
|
void CodeGenRegBank::inferMatchingSuperRegClass(CodeGenRegisterClass *RC,
|
||||||
unsigned FirstSubRegRC) {
|
std::list<CodeGenRegisterClass>::iterator FirstSubRegRC) {
|
||||||
SmallVector<std::pair<const CodeGenRegister*,
|
SmallVector<std::pair<const CodeGenRegister*,
|
||||||
const CodeGenRegister*>, 16> SSPairs;
|
const CodeGenRegister*>, 16> SSPairs;
|
||||||
BitVector TopoSigs(getNumTopoSigs());
|
BitVector TopoSigs(getNumTopoSigs());
|
||||||
@ -1843,11 +1843,10 @@ void CodeGenRegBank::inferMatchingSuperRegClass(CodeGenRegisterClass *RC,
|
|||||||
|
|
||||||
// Iterate over sub-register class candidates. Ignore classes created by
|
// Iterate over sub-register class candidates. Ignore classes created by
|
||||||
// this loop. They will never be useful.
|
// this loop. They will never be useful.
|
||||||
// Careful if trying to transform this loop to use iterators - as this loop
|
// Store an iterator to the last element (not end) so that this loop doesn't
|
||||||
// will add new classes it will invalidate iterators to RegClasses.
|
// visit newly inserted elements.
|
||||||
assert(!RegClasses.empty());
|
assert(!RegClasses.empty());
|
||||||
for (auto I = std::next(RegClasses.begin(), FirstSubRegRC),
|
for (auto I = FirstSubRegRC, E = std::prev(RegClasses.end());
|
||||||
E = std::prev(RegClasses.end());
|
|
||||||
I != std::next(E); ++I) {
|
I != std::next(E); ++I) {
|
||||||
CodeGenRegisterClass &SubRC = *I;
|
CodeGenRegisterClass &SubRC = *I;
|
||||||
// Topological shortcut: SubRC members have the wrong shape.
|
// Topological shortcut: SubRC members have the wrong shape.
|
||||||
@ -1879,16 +1878,19 @@ void CodeGenRegBank::inferMatchingSuperRegClass(CodeGenRegisterClass *RC,
|
|||||||
// Infer missing register classes.
|
// Infer missing register classes.
|
||||||
//
|
//
|
||||||
void CodeGenRegBank::computeInferredRegisterClasses() {
|
void CodeGenRegBank::computeInferredRegisterClasses() {
|
||||||
|
assert(!RegClasses.empty());
|
||||||
// When this function is called, the register classes have not been sorted
|
// When this function is called, the register classes have not been sorted
|
||||||
// and assigned EnumValues yet. That means getSubClasses(),
|
// and assigned EnumValues yet. That means getSubClasses(),
|
||||||
// getSuperClasses(), and hasSubClass() functions are defunct.
|
// getSuperClasses(), and hasSubClass() functions are defunct.
|
||||||
unsigned FirstNewRC = RegClasses.size();
|
|
||||||
|
// Use one-before-the-end so it doesn't move forward when new elements are
|
||||||
|
// added.
|
||||||
|
auto FirstNewRC = std::prev(RegClasses.end());
|
||||||
|
|
||||||
// Visit all register classes, including the ones being added by the loop.
|
// Visit all register classes, including the ones being added by the loop.
|
||||||
// Watch out for iterator invalidation here.
|
// Watch out for iterator invalidation here.
|
||||||
unsigned rci = 0;
|
for (auto I = RegClasses.begin(), E = RegClasses.end(); I != E; ++I) {
|
||||||
for (auto &RCR : RegClasses) {
|
CodeGenRegisterClass *RC = &*I;
|
||||||
CodeGenRegisterClass *RC = &RCR;
|
|
||||||
|
|
||||||
// Synthesize answers for getSubClassWithSubReg().
|
// Synthesize answers for getSubClassWithSubReg().
|
||||||
inferSubClassWithSubReg(RC);
|
inferSubClassWithSubReg(RC);
|
||||||
@ -1905,13 +1907,11 @@ void CodeGenRegBank::computeInferredRegisterClasses() {
|
|||||||
// after inferMatchingSuperRegClass was called. At this point,
|
// after inferMatchingSuperRegClass was called. At this point,
|
||||||
// inferMatchingSuperRegClass has checked SuperRC = [0..rci] with SubRC =
|
// inferMatchingSuperRegClass has checked SuperRC = [0..rci] with SubRC =
|
||||||
// [0..FirstNewRC). We need to cover SubRC = [FirstNewRC..rci].
|
// [0..FirstNewRC). We need to cover SubRC = [FirstNewRC..rci].
|
||||||
if (rci + 1 == FirstNewRC) {
|
if (I == FirstNewRC) {
|
||||||
unsigned NextNewRC = RegClasses.size();
|
auto NextNewRC = std::prev(RegClasses.end());
|
||||||
auto I2 = RegClasses.begin();
|
for (auto I2 = RegClasses.begin(), E2 = std::next(FirstNewRC); I2 != E2;
|
||||||
for (unsigned rci2 = 0; rci2 != FirstNewRC; ++rci2, ++I2)
|
++I2)
|
||||||
// This can add more things to RegClasses, be careful about iterator
|
inferMatchingSuperRegClass(&*I2, E2);
|
||||||
// invalidation of outer loop variables.
|
|
||||||
inferMatchingSuperRegClass(&*I2, FirstNewRC);
|
|
||||||
FirstNewRC = NextNewRC;
|
FirstNewRC = NextNewRC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -504,8 +504,13 @@ namespace llvm {
|
|||||||
void computeInferredRegisterClasses();
|
void computeInferredRegisterClasses();
|
||||||
void inferCommonSubClass(CodeGenRegisterClass *RC);
|
void inferCommonSubClass(CodeGenRegisterClass *RC);
|
||||||
void inferSubClassWithSubReg(CodeGenRegisterClass *RC);
|
void inferSubClassWithSubReg(CodeGenRegisterClass *RC);
|
||||||
void inferMatchingSuperRegClass(CodeGenRegisterClass *RC,
|
void inferMatchingSuperRegClass(CodeGenRegisterClass *RC) {
|
||||||
unsigned FirstSubRegRC = 0);
|
inferMatchingSuperRegClass(RC, RegClasses.begin());
|
||||||
|
}
|
||||||
|
|
||||||
|
void inferMatchingSuperRegClass(
|
||||||
|
CodeGenRegisterClass *RC,
|
||||||
|
std::list<CodeGenRegisterClass>::iterator FirstSubRegRC);
|
||||||
|
|
||||||
// Iteratively prune unit sets.
|
// Iteratively prune unit sets.
|
||||||
void pruneUnitSets();
|
void pruneUnitSets();
|
||||||
|
Loading…
Reference in New Issue
Block a user