[TableGen] Hoist the code for copying InstRWs from an old scheduling class to a new one out of the loop that assigns instructions to the new class. NFCI

We already know all the of instructions we're processing in the instruction loop belong to no class or all to the same class. So we only have to worry about remapping one class. So hoist it all out and remove the SmallPtrSet that tracked which class we'd already remapped.

I had to introduce new instruction loop inside this code to print an error message, but that only occurs on the error path.

llvm-svn: 328142
This commit is contained in:
Craig Topper 2018-03-21 19:52:13 +00:00
parent 4d7bde068f
commit 989d94ddde
1 changed files with 12 additions and 12 deletions

View File

@ -800,25 +800,25 @@ void CodeGenSchedModels::createInstRWClass(Record *InstRWDef) {
SC.Writes = SchedClasses[OldSCIdx].Writes;
SC.Reads = SchedClasses[OldSCIdx].Reads;
SC.ProcIndices.push_back(0);
// Map each Instr to this new class.
// Note that InstDefs may be a smaller list than InstRWDef's "Instrs".
Record *RWModelDef = InstRWDef->getValueAsDef("SchedModel");
SmallSet<unsigned, 4> RemappedClassIDs;
for (Record *InstDef : InstDefs) {
if (OldSCIdx && RemappedClassIDs.insert(OldSCIdx).second) {
for (Record *OldRWDef : SchedClasses[OldSCIdx].InstRWs) {
if (OldRWDef->getValueAsDef("SchedModel") == RWModelDef) {
// If we had an old class, copy it's InstRWs to this new class.
if (OldSCIdx) {
Record *RWModelDef = InstRWDef->getValueAsDef("SchedModel");
for (Record *OldRWDef : SchedClasses[OldSCIdx].InstRWs) {
if (OldRWDef->getValueAsDef("SchedModel") == RWModelDef) {
for (Record *InstDef : InstDefs) {
PrintFatalError(OldRWDef->getLoc(), "Overlapping InstRW def " +
InstDef->getName() + " also matches " +
OldRWDef->getValue("Instrs")->getValue()->getAsString());
}
assert(OldRWDef != InstRWDef &&
"SchedClass has duplicate InstRW def");
SC.InstRWs.push_back(OldRWDef);
}
assert(OldRWDef != InstRWDef &&
"SchedClass has duplicate InstRW def");
SC.InstRWs.push_back(OldRWDef);
}
InstrClassMap[InstDef] = SCIdx;
}
// Map each Instr to this new class.
for (Record *InstDef : InstDefs)
InstrClassMap[InstDef] = SCIdx;
SC.InstRWs.push_back(InstRWDef);
}
}