forked from OSchip/llvm-project
[Tablegen] Simplify code in CodeGenSchedule. NFCI
llvm-svn: 330935
This commit is contained in:
parent
fe17a78b86
commit
38fe227fd9
|
@ -447,14 +447,12 @@ std::string CodeGenSchedModels::genRWName(ArrayRef<unsigned> Seq, bool IsRead) {
|
||||||
return Name;
|
return Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned CodeGenSchedModels::getSchedRWIdx(Record *Def, bool IsRead) const {
|
unsigned CodeGenSchedModels::getSchedRWIdx(const Record *Def,
|
||||||
|
bool IsRead) const {
|
||||||
const std::vector<CodeGenSchedRW> &RWVec = IsRead ? SchedReads : SchedWrites;
|
const std::vector<CodeGenSchedRW> &RWVec = IsRead ? SchedReads : SchedWrites;
|
||||||
for (std::vector<CodeGenSchedRW>::const_iterator I = RWVec.begin(),
|
const auto I = find_if(
|
||||||
E = RWVec.end(); I != E; ++I) {
|
RWVec, [Def](const CodeGenSchedRW &RW) { return RW.TheDef == Def; });
|
||||||
if (I->TheDef == Def)
|
return I == RWVec.end() ? 0 : std::distance(RWVec.begin(), I);
|
||||||
return I - RWVec.begin();
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CodeGenSchedModels::hasReadOfWrite(Record *WriteDef) const {
|
bool CodeGenSchedModels::hasReadOfWrite(Record *WriteDef) const {
|
||||||
|
@ -486,11 +484,11 @@ static void splitSchedReadWrites(const RecVec &RWDefs,
|
||||||
// Split the SchedReadWrites defs and call findRWs for each list.
|
// Split the SchedReadWrites defs and call findRWs for each list.
|
||||||
void CodeGenSchedModels::findRWs(const RecVec &RWDefs,
|
void CodeGenSchedModels::findRWs(const RecVec &RWDefs,
|
||||||
IdxVec &Writes, IdxVec &Reads) const {
|
IdxVec &Writes, IdxVec &Reads) const {
|
||||||
RecVec WriteDefs;
|
RecVec WriteDefs;
|
||||||
RecVec ReadDefs;
|
RecVec ReadDefs;
|
||||||
splitSchedReadWrites(RWDefs, WriteDefs, ReadDefs);
|
splitSchedReadWrites(RWDefs, WriteDefs, ReadDefs);
|
||||||
findRWs(WriteDefs, Writes, false);
|
findRWs(WriteDefs, Writes, false);
|
||||||
findRWs(ReadDefs, Reads, true);
|
findRWs(ReadDefs, Reads, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call getSchedRWIdx for all elements in a sequence of SchedRW defs.
|
// Call getSchedRWIdx for all elements in a sequence of SchedRW defs.
|
||||||
|
@ -527,11 +525,10 @@ void CodeGenSchedModels::expandRWSeqForProc(
|
||||||
|
|
||||||
const CodeGenSchedRW &SchedWrite = getSchedRW(RWIdx, IsRead);
|
const CodeGenSchedRW &SchedWrite = getSchedRW(RWIdx, IsRead);
|
||||||
Record *AliasDef = nullptr;
|
Record *AliasDef = nullptr;
|
||||||
for (RecIter AI = SchedWrite.Aliases.begin(), AE = SchedWrite.Aliases.end();
|
for (const Record *Rec : SchedWrite.Aliases) {
|
||||||
AI != AE; ++AI) {
|
const CodeGenSchedRW &AliasRW = getSchedRW(Rec->getValueAsDef("AliasRW"));
|
||||||
const CodeGenSchedRW &AliasRW = getSchedRW((*AI)->getValueAsDef("AliasRW"));
|
if (Rec->getValueInit("SchedModel")->isComplete()) {
|
||||||
if ((*AI)->getValueInit("SchedModel")->isComplete()) {
|
Record *ModelDef = Rec->getValueAsDef("SchedModel");
|
||||||
Record *ModelDef = (*AI)->getValueAsDef("SchedModel");
|
|
||||||
if (&getProcModel(ModelDef) != &ProcModel)
|
if (&getProcModel(ModelDef) != &ProcModel)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -552,9 +549,9 @@ void CodeGenSchedModels::expandRWSeqForProc(
|
||||||
}
|
}
|
||||||
int Repeat =
|
int Repeat =
|
||||||
SchedWrite.TheDef ? SchedWrite.TheDef->getValueAsInt("Repeat") : 1;
|
SchedWrite.TheDef ? SchedWrite.TheDef->getValueAsInt("Repeat") : 1;
|
||||||
for (int i = 0; i < Repeat; ++i) {
|
for (int I = 0, E = Repeat; I < E; ++I) {
|
||||||
for (unsigned I : SchedWrite.Sequence) {
|
for (unsigned Idx : SchedWrite.Sequence) {
|
||||||
expandRWSeqForProc(I, RWSeq, IsRead, ProcModel);
|
expandRWSeqForProc(Idx, RWSeq, IsRead, ProcModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -564,13 +561,11 @@ unsigned CodeGenSchedModels::findRWForSequence(ArrayRef<unsigned> Seq,
|
||||||
bool IsRead) {
|
bool IsRead) {
|
||||||
std::vector<CodeGenSchedRW> &RWVec = IsRead ? SchedReads : SchedWrites;
|
std::vector<CodeGenSchedRW> &RWVec = IsRead ? SchedReads : SchedWrites;
|
||||||
|
|
||||||
for (std::vector<CodeGenSchedRW>::iterator I = RWVec.begin(), E = RWVec.end();
|
auto I = find_if(RWVec, [Seq](CodeGenSchedRW &RW) {
|
||||||
I != E; ++I) {
|
return makeArrayRef(RW.Sequence) == Seq;
|
||||||
if (makeArrayRef(I->Sequence) == Seq)
|
});
|
||||||
return I - RWVec.begin();
|
|
||||||
}
|
|
||||||
// Index zero reserved for invalid RW.
|
// Index zero reserved for invalid RW.
|
||||||
return 0;
|
return I == RWVec.end() ? 0 : std::distance(RWVec.begin(), I);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add this ReadWrite if it doesn't already exist.
|
/// Add this ReadWrite if it doesn't already exist.
|
||||||
|
@ -584,12 +579,10 @@ unsigned CodeGenSchedModels::findOrInsertRW(ArrayRef<unsigned> Seq,
|
||||||
if (Idx)
|
if (Idx)
|
||||||
return Idx;
|
return Idx;
|
||||||
|
|
||||||
unsigned RWIdx = IsRead ? SchedReads.size() : SchedWrites.size();
|
std::vector<CodeGenSchedRW> &RWVec = IsRead ? SchedReads : SchedWrites;
|
||||||
|
unsigned RWIdx = RWVec.size();
|
||||||
CodeGenSchedRW SchedRW(RWIdx, IsRead, Seq, genRWName(Seq, IsRead));
|
CodeGenSchedRW SchedRW(RWIdx, IsRead, Seq, genRWName(Seq, IsRead));
|
||||||
if (IsRead)
|
RWVec.push_back(SchedRW);
|
||||||
SchedReads.push_back(SchedRW);
|
|
||||||
else
|
|
||||||
SchedWrites.push_back(SchedRW);
|
|
||||||
return RWIdx;
|
return RWIdx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -630,13 +623,17 @@ void CodeGenSchedModels::collectSchedClasses() {
|
||||||
if (!EnableDump)
|
if (!EnableDump)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dbgs() << "\n+++ ITINERARIES and/or MACHINE MODELS (collectSchedClasses) +++\n";
|
DEBUG(
|
||||||
|
dbgs()
|
||||||
|
<< "\n+++ ITINERARIES and/or MACHINE MODELS (collectSchedClasses) +++\n");
|
||||||
for (const CodeGenInstruction *Inst : Target.getInstructionsByEnumValue()) {
|
for (const CodeGenInstruction *Inst : Target.getInstructionsByEnumValue()) {
|
||||||
StringRef InstName = Inst->TheDef->getName();
|
StringRef InstName = Inst->TheDef->getName();
|
||||||
unsigned SCIdx = getSchedClassIdx(*Inst);
|
unsigned SCIdx = getSchedClassIdx(*Inst);
|
||||||
if (!SCIdx) {
|
if (!SCIdx) {
|
||||||
if (!Inst->hasNoSchedulingInfo)
|
DEBUG({
|
||||||
dbgs() << "No machine model for " << Inst->TheDef->getName() << '\n';
|
if (!Inst->hasNoSchedulingInfo)
|
||||||
|
dbgs() << "No machine model for " << Inst->TheDef->getName() << '\n';
|
||||||
|
});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
CodeGenSchedClass &SC = getSchedClass(SCIdx);
|
CodeGenSchedClass &SC = getSchedClass(SCIdx);
|
||||||
|
@ -652,55 +649,50 @@ void CodeGenSchedModels::collectSchedClasses() {
|
||||||
}
|
}
|
||||||
if (!SC.Writes.empty()) {
|
if (!SC.Writes.empty()) {
|
||||||
ProcIndices.push_back(0);
|
ProcIndices.push_back(0);
|
||||||
dbgs() << "SchedRW machine model for " << InstName;
|
DEBUG({
|
||||||
for (IdxIter WI = SC.Writes.begin(), WE = SC.Writes.end(); WI != WE; ++WI)
|
dbgs() << "SchedRW machine model for " << InstName;
|
||||||
dbgs() << " " << SchedWrites[*WI].Name;
|
for (IdxIter WI = SC.Writes.begin(), WE = SC.Writes.end(); WI != WE;
|
||||||
for (IdxIter RI = SC.Reads.begin(), RE = SC.Reads.end(); RI != RE; ++RI)
|
++WI)
|
||||||
dbgs() << " " << SchedReads[*RI].Name;
|
dbgs() << " " << SchedWrites[*WI].Name;
|
||||||
dbgs() << '\n';
|
for (IdxIter RI = SC.Reads.begin(), RE = SC.Reads.end(); RI != RE; ++RI)
|
||||||
|
dbgs() << " " << SchedReads[*RI].Name;
|
||||||
|
dbgs() << '\n';
|
||||||
|
});
|
||||||
}
|
}
|
||||||
const RecVec &RWDefs = SchedClasses[SCIdx].InstRWs;
|
const RecVec &RWDefs = SchedClasses[SCIdx].InstRWs;
|
||||||
for (Record *RWDef : RWDefs) {
|
for (Record *RWDef : RWDefs) {
|
||||||
const CodeGenProcModel &ProcModel =
|
const CodeGenProcModel &ProcModel =
|
||||||
getProcModel(RWDef->getValueAsDef("SchedModel"));
|
getProcModel(RWDef->getValueAsDef("SchedModel"));
|
||||||
ProcIndices.push_back(ProcModel.Index);
|
ProcIndices.push_back(ProcModel.Index);
|
||||||
dbgs() << "InstRW on " << ProcModel.ModelName << " for " << InstName;
|
DEBUG(dbgs() << "InstRW on " << ProcModel.ModelName << " for " << InstName);
|
||||||
IdxVec Writes;
|
IdxVec Writes;
|
||||||
IdxVec Reads;
|
IdxVec Reads;
|
||||||
findRWs(RWDef->getValueAsListOfDefs("OperandReadWrites"),
|
findRWs(RWDef->getValueAsListOfDefs("OperandReadWrites"),
|
||||||
Writes, Reads);
|
Writes, Reads);
|
||||||
for (unsigned WIdx : Writes)
|
DEBUG({
|
||||||
dbgs() << " " << SchedWrites[WIdx].Name;
|
for (unsigned WIdx : Writes)
|
||||||
for (unsigned RIdx : Reads)
|
dbgs() << " " << SchedWrites[WIdx].Name;
|
||||||
dbgs() << " " << SchedReads[RIdx].Name;
|
for (unsigned RIdx : Reads)
|
||||||
dbgs() << '\n';
|
dbgs() << " " << SchedReads[RIdx].Name;
|
||||||
|
dbgs() << '\n';
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// If ProcIndices contains zero, the class applies to all processors.
|
// If ProcIndices contains zero, the class applies to all processors.
|
||||||
if (!std::count(ProcIndices.begin(), ProcIndices.end(), 0)) {
|
DEBUG({
|
||||||
for (const CodeGenProcModel &PM : ProcModels) {
|
if (!std::count(ProcIndices.begin(), ProcIndices.end(), 0)) {
|
||||||
if (!std::count(ProcIndices.begin(), ProcIndices.end(), PM.Index))
|
for (const CodeGenProcModel &PM : ProcModels) {
|
||||||
dbgs() << "No machine model for " << Inst->TheDef->getName()
|
if (!std::count(ProcIndices.begin(), ProcIndices.end(), PM.Index))
|
||||||
<< " on processor " << PM.ModelName << '\n';
|
dbgs() << "No machine model for " << Inst->TheDef->getName()
|
||||||
|
<< " on processor " << PM.ModelName << '\n';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Find an SchedClass that has been inferred from a per-operand list of
|
|
||||||
/// SchedWrites and SchedReads.
|
|
||||||
unsigned CodeGenSchedModels::findSchedClassIdx(Record *ItinClassDef,
|
|
||||||
ArrayRef<unsigned> Writes,
|
|
||||||
ArrayRef<unsigned> Reads) const {
|
|
||||||
for (SchedClassIter I = schedClassBegin(), E = schedClassEnd(); I != E; ++I)
|
|
||||||
if (I->isKeyEqual(ItinClassDef, Writes, Reads))
|
|
||||||
return I - schedClassBegin();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the SchedClass index for an instruction.
|
// Get the SchedClass index for an instruction.
|
||||||
unsigned CodeGenSchedModels::getSchedClassIdx(
|
unsigned
|
||||||
const CodeGenInstruction &Inst) const {
|
CodeGenSchedModels::getSchedClassIdx(const CodeGenInstruction &Inst) const {
|
||||||
|
|
||||||
return InstrClassMap.lookup(Inst.TheDef);
|
return InstrClassMap.lookup(Inst.TheDef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -744,7 +736,12 @@ unsigned CodeGenSchedModels::addSchedClass(Record *ItinClassDef,
|
||||||
ArrayRef<unsigned> ProcIndices) {
|
ArrayRef<unsigned> ProcIndices) {
|
||||||
assert(!ProcIndices.empty() && "expect at least one ProcIdx");
|
assert(!ProcIndices.empty() && "expect at least one ProcIdx");
|
||||||
|
|
||||||
unsigned Idx = findSchedClassIdx(ItinClassDef, OperWrites, OperReads);
|
auto IsKeyEqual = [=](const CodeGenSchedClass &SC) {
|
||||||
|
return SC.isKeyEqual(ItinClassDef, OperWrites, OperReads);
|
||||||
|
};
|
||||||
|
|
||||||
|
auto I = find_if(make_range(schedClassBegin(), schedClassEnd()), IsKeyEqual);
|
||||||
|
unsigned Idx = I == schedClassEnd() ? 0 : std::distance(schedClassBegin(), I);
|
||||||
if (Idx || SchedClasses[0].isKeyEqual(ItinClassDef, OperWrites, OperReads)) {
|
if (Idx || SchedClasses[0].isKeyEqual(ItinClassDef, OperWrites, OperReads)) {
|
||||||
IdxVec PI;
|
IdxVec PI;
|
||||||
std::set_union(SchedClasses[Idx].ProcIndices.begin(),
|
std::set_union(SchedClasses[Idx].ProcIndices.begin(),
|
||||||
|
@ -862,10 +859,9 @@ void CodeGenSchedModels::createInstRWClass(Record *InstRWDef) {
|
||||||
|
|
||||||
// True if collectProcItins found anything.
|
// True if collectProcItins found anything.
|
||||||
bool CodeGenSchedModels::hasItineraries() const {
|
bool CodeGenSchedModels::hasItineraries() const {
|
||||||
for (const CodeGenProcModel &PM : make_range(procModelBegin(),procModelEnd())) {
|
for (const CodeGenProcModel &PM : make_range(procModelBegin(),procModelEnd()))
|
||||||
if (PM.hasItineraries())
|
if (PM.hasItineraries())
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -885,13 +881,14 @@ void CodeGenSchedModels::collectProcItins() {
|
||||||
// Insert each itinerary data record in the correct position within
|
// Insert each itinerary data record in the correct position within
|
||||||
// the processor model's ItinDefList.
|
// the processor model's ItinDefList.
|
||||||
for (Record *ItinData : ItinRecords) {
|
for (Record *ItinData : ItinRecords) {
|
||||||
Record *ItinDef = ItinData->getValueAsDef("TheClass");
|
const Record *ItinDef = ItinData->getValueAsDef("TheClass");
|
||||||
bool FoundClass = false;
|
bool FoundClass = false;
|
||||||
for (SchedClassIter SCI = schedClassBegin(), SCE = schedClassEnd();
|
|
||||||
SCI != SCE; ++SCI) {
|
for (const CodeGenSchedClass &SC :
|
||||||
|
make_range(schedClassBegin(), schedClassEnd())) {
|
||||||
// Multiple SchedClasses may share an itinerary. Update all of them.
|
// Multiple SchedClasses may share an itinerary. Update all of them.
|
||||||
if (SCI->ItinClassDef == ItinDef) {
|
if (SC.ItinClassDef == ItinDef) {
|
||||||
ProcModel.ItinDefList[SCI->Index] = ItinData;
|
ProcModel.ItinDefList[SC.Index] = ItinData;
|
||||||
FoundClass = true;
|
FoundClass = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -968,18 +965,17 @@ void CodeGenSchedModels::inferFromItinClass(Record *ItinClassDef,
|
||||||
const CodeGenProcModel &PM = ProcModels[PIdx];
|
const CodeGenProcModel &PM = ProcModels[PIdx];
|
||||||
// For all ItinRW entries.
|
// For all ItinRW entries.
|
||||||
bool HasMatch = false;
|
bool HasMatch = false;
|
||||||
for (RecIter II = PM.ItinRWDefs.begin(), IE = PM.ItinRWDefs.end();
|
for (const Record *Rec : PM.ItinRWDefs) {
|
||||||
II != IE; ++II) {
|
RecVec Matched = Rec->getValueAsListOfDefs("MatchedItinClasses");
|
||||||
RecVec Matched = (*II)->getValueAsListOfDefs("MatchedItinClasses");
|
|
||||||
if (!std::count(Matched.begin(), Matched.end(), ItinClassDef))
|
if (!std::count(Matched.begin(), Matched.end(), ItinClassDef))
|
||||||
continue;
|
continue;
|
||||||
if (HasMatch)
|
if (HasMatch)
|
||||||
PrintFatalError((*II)->getLoc(), "Duplicate itinerary class "
|
PrintFatalError(Rec->getLoc(), "Duplicate itinerary class "
|
||||||
+ ItinClassDef->getName()
|
+ ItinClassDef->getName()
|
||||||
+ " in ItinResources for " + PM.ModelName);
|
+ " in ItinResources for " + PM.ModelName);
|
||||||
HasMatch = true;
|
HasMatch = true;
|
||||||
IdxVec Writes, Reads;
|
IdxVec Writes, Reads;
|
||||||
findRWs((*II)->getValueAsListOfDefs("OperandReadWrites"), Writes, Reads);
|
findRWs(Rec->getValueAsListOfDefs("OperandReadWrites"), Writes, Reads);
|
||||||
inferFromRW(Writes, Reads, FromClassIdx, PIdx);
|
inferFromRW(Writes, Reads, FromClassIdx, PIdx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1086,10 +1082,10 @@ bool PredTransitions::mutuallyExclusive(Record *PredDef,
|
||||||
const CodeGenSchedRW &SchedRW = SchedModels.getSchedRW(PC.RWIdx, PC.IsRead);
|
const CodeGenSchedRW &SchedRW = SchedModels.getSchedRW(PC.RWIdx, PC.IsRead);
|
||||||
assert(SchedRW.HasVariants && "PredCheck must refer to a SchedVariant");
|
assert(SchedRW.HasVariants && "PredCheck must refer to a SchedVariant");
|
||||||
RecVec Variants = SchedRW.TheDef->getValueAsListOfDefs("Variants");
|
RecVec Variants = SchedRW.TheDef->getValueAsListOfDefs("Variants");
|
||||||
for (RecIter VI = Variants.begin(), VE = Variants.end(); VI != VE; ++VI) {
|
if (any_of(Variants, [PredDef](const Record *R) {
|
||||||
if ((*VI)->getValueAsDef("Predicate") == PredDef)
|
return R->getValueAsDef("Predicate") == PredDef;
|
||||||
return true;
|
}))
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1107,12 +1103,10 @@ static bool hasAliasedVariants(const CodeGenSchedRW &RW,
|
||||||
if (AliasRW.IsSequence) {
|
if (AliasRW.IsSequence) {
|
||||||
IdxVec ExpandedRWs;
|
IdxVec ExpandedRWs;
|
||||||
SchedModels.expandRWSequence(AliasRW.Index, ExpandedRWs, AliasRW.IsRead);
|
SchedModels.expandRWSequence(AliasRW.Index, ExpandedRWs, AliasRW.IsRead);
|
||||||
for (IdxIter SI = ExpandedRWs.begin(), SE = ExpandedRWs.end();
|
for (unsigned SI : ExpandedRWs) {
|
||||||
SI != SE; ++SI) {
|
if (hasAliasedVariants(SchedModels.getSchedRW(SI, AliasRW.IsRead),
|
||||||
if (hasAliasedVariants(SchedModels.getSchedRW(*SI, AliasRW.IsRead),
|
SchedModels))
|
||||||
SchedModels)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1121,27 +1115,16 @@ static bool hasAliasedVariants(const CodeGenSchedRW &RW,
|
||||||
|
|
||||||
static bool hasVariant(ArrayRef<PredTransition> Transitions,
|
static bool hasVariant(ArrayRef<PredTransition> Transitions,
|
||||||
CodeGenSchedModels &SchedModels) {
|
CodeGenSchedModels &SchedModels) {
|
||||||
for (ArrayRef<PredTransition>::iterator
|
for (const PredTransition &PTI : Transitions) {
|
||||||
PTI = Transitions.begin(), PTE = Transitions.end();
|
for (const SmallVectorImpl<unsigned> &WSI : PTI.WriteSequences)
|
||||||
PTI != PTE; ++PTI) {
|
for (unsigned WI : WSI)
|
||||||
for (SmallVectorImpl<SmallVector<unsigned,4>>::const_iterator
|
if (hasAliasedVariants(SchedModels.getSchedWrite(WI), SchedModels))
|
||||||
WSI = PTI->WriteSequences.begin(), WSE = PTI->WriteSequences.end();
|
|
||||||
WSI != WSE; ++WSI) {
|
|
||||||
for (SmallVectorImpl<unsigned>::const_iterator
|
|
||||||
WI = WSI->begin(), WE = WSI->end(); WI != WE; ++WI) {
|
|
||||||
if (hasAliasedVariants(SchedModels.getSchedWrite(*WI), SchedModels))
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
for (const SmallVectorImpl<unsigned> &RSI : PTI.ReadSequences)
|
||||||
for (SmallVectorImpl<SmallVector<unsigned,4>>::const_iterator
|
for (unsigned RI : RSI)
|
||||||
RSI = PTI->ReadSequences.begin(), RSE = PTI->ReadSequences.end();
|
if (hasAliasedVariants(SchedModels.getSchedRead(RI), SchedModels))
|
||||||
RSI != RSE; ++RSI) {
|
|
||||||
for (SmallVectorImpl<unsigned>::const_iterator
|
|
||||||
RI = RSI->begin(), RE = RSI->end(); RI != RE; ++RI) {
|
|
||||||
if (hasAliasedVariants(SchedModels.getSchedRead(*RI), SchedModels))
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1165,7 +1148,7 @@ void PredTransitions::getIntersectingVariants(
|
||||||
// Push each variant. Assign TransVecIdx later.
|
// Push each variant. Assign TransVecIdx later.
|
||||||
const RecVec VarDefs = SchedRW.TheDef->getValueAsListOfDefs("Variants");
|
const RecVec VarDefs = SchedRW.TheDef->getValueAsListOfDefs("Variants");
|
||||||
for (Record *VarDef : VarDefs)
|
for (Record *VarDef : VarDefs)
|
||||||
Variants.push_back(TransVariant(VarDef, SchedRW.Index, VarProcIdx, 0));
|
Variants.emplace_back(VarDef, SchedRW.Index, VarProcIdx, 0);
|
||||||
if (VarProcIdx == 0)
|
if (VarProcIdx == 0)
|
||||||
GenericRW = true;
|
GenericRW = true;
|
||||||
}
|
}
|
||||||
|
@ -1185,12 +1168,10 @@ void PredTransitions::getIntersectingVariants(
|
||||||
if (AliasRW.HasVariants) {
|
if (AliasRW.HasVariants) {
|
||||||
const RecVec VarDefs = AliasRW.TheDef->getValueAsListOfDefs("Variants");
|
const RecVec VarDefs = AliasRW.TheDef->getValueAsListOfDefs("Variants");
|
||||||
for (Record *VD : VarDefs)
|
for (Record *VD : VarDefs)
|
||||||
Variants.push_back(TransVariant(VD, AliasRW.Index, AliasProcIdx, 0));
|
Variants.emplace_back(VD, AliasRW.Index, AliasProcIdx, 0);
|
||||||
}
|
|
||||||
if (AliasRW.IsSequence) {
|
|
||||||
Variants.push_back(
|
|
||||||
TransVariant(AliasRW.TheDef, SchedRW.Index, AliasProcIdx, 0));
|
|
||||||
}
|
}
|
||||||
|
if (AliasRW.IsSequence)
|
||||||
|
Variants.emplace_back(AliasRW.TheDef, SchedRW.Index, AliasProcIdx, 0);
|
||||||
if (AliasProcIdx == 0)
|
if (AliasProcIdx == 0)
|
||||||
GenericRW = true;
|
GenericRW = true;
|
||||||
}
|
}
|
||||||
|
@ -1249,7 +1230,7 @@ pushVariant(const TransVariant &VInfo, bool IsRead) {
|
||||||
IdxVec SelectedRWs;
|
IdxVec SelectedRWs;
|
||||||
if (VInfo.VarOrSeqDef->isSubClassOf("SchedVar")) {
|
if (VInfo.VarOrSeqDef->isSubClassOf("SchedVar")) {
|
||||||
Record *PredDef = VInfo.VarOrSeqDef->getValueAsDef("Predicate");
|
Record *PredDef = VInfo.VarOrSeqDef->getValueAsDef("Predicate");
|
||||||
Trans.PredTerm.push_back(PredCheck(IsRead, VInfo.RWIdx,PredDef));
|
Trans.PredTerm.emplace_back(IsRead, VInfo.RWIdx,PredDef);
|
||||||
RecVec SelectedDefs = VInfo.VarOrSeqDef->getValueAsListOfDefs("Selected");
|
RecVec SelectedDefs = VInfo.VarOrSeqDef->getValueAsListOfDefs("Selected");
|
||||||
SchedModels.findRWs(SelectedDefs, SelectedRWs, IsRead);
|
SchedModels.findRWs(SelectedDefs, SelectedRWs, IsRead);
|
||||||
}
|
}
|
||||||
|
@ -1266,11 +1247,8 @@ pushVariant(const TransVariant &VInfo, bool IsRead) {
|
||||||
if (SchedRW.IsVariadic) {
|
if (SchedRW.IsVariadic) {
|
||||||
unsigned OperIdx = RWSequences.size()-1;
|
unsigned OperIdx = RWSequences.size()-1;
|
||||||
// Make N-1 copies of this transition's last sequence.
|
// Make N-1 copies of this transition's last sequence.
|
||||||
for (unsigned i = 1, e = SelectedRWs.size(); i != e; ++i) {
|
RWSequences.insert(RWSequences.end(), SelectedRWs.size() - 1,
|
||||||
// Create a temporary copy the vector could reallocate.
|
RWSequences[OperIdx]);
|
||||||
RWSequences.reserve(RWSequences.size() + 1);
|
|
||||||
RWSequences.push_back(RWSequences[OperIdx]);
|
|
||||||
}
|
|
||||||
// Push each of the N elements of the SelectedRWs onto a copy of the last
|
// Push each of the N elements of the SelectedRWs onto a copy of the last
|
||||||
// sequence (split the current operand into N operands).
|
// sequence (split the current operand into N operands).
|
||||||
// Note that write sequences should be expanded within this loop--the entire
|
// Note that write sequences should be expanded within this loop--the entire
|
||||||
|
@ -1567,26 +1545,24 @@ void CodeGenSchedModels::collectProcResources() {
|
||||||
// Add any subtarget-specific SchedReadWrites that are directly associated
|
// Add any subtarget-specific SchedReadWrites that are directly associated
|
||||||
// with processor resources. Refer to the parent SchedClass's ProcIndices to
|
// with processor resources. Refer to the parent SchedClass's ProcIndices to
|
||||||
// determine which processors they apply to.
|
// determine which processors they apply to.
|
||||||
for (SchedClassIter SCI = schedClassBegin(), SCE = schedClassEnd();
|
for (const CodeGenSchedClass &SC :
|
||||||
SCI != SCE; ++SCI) {
|
make_range(schedClassBegin(), schedClassEnd())) {
|
||||||
if (SCI->ItinClassDef)
|
if (SC.ItinClassDef) {
|
||||||
collectItinProcResources(SCI->ItinClassDef);
|
collectItinProcResources(SC.ItinClassDef);
|
||||||
else {
|
continue;
|
||||||
// This class may have a default ReadWrite list which can be overriden by
|
|
||||||
// InstRW definitions.
|
|
||||||
if (!SCI->InstRWs.empty()) {
|
|
||||||
for (RecIter RWI = SCI->InstRWs.begin(), RWE = SCI->InstRWs.end();
|
|
||||||
RWI != RWE; ++RWI) {
|
|
||||||
Record *RWModelDef = (*RWI)->getValueAsDef("SchedModel");
|
|
||||||
unsigned PIdx = getProcModel(RWModelDef).Index;
|
|
||||||
IdxVec Writes, Reads;
|
|
||||||
findRWs((*RWI)->getValueAsListOfDefs("OperandReadWrites"),
|
|
||||||
Writes, Reads);
|
|
||||||
collectRWResources(Writes, Reads, PIdx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
collectRWResources(SCI->Writes, SCI->Reads, SCI->ProcIndices);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This class may have a default ReadWrite list which can be overriden by
|
||||||
|
// InstRW definitions.
|
||||||
|
for (Record *RW : SC.InstRWs) {
|
||||||
|
Record *RWModelDef = RW->getValueAsDef("SchedModel");
|
||||||
|
unsigned PIdx = getProcModel(RWModelDef).Index;
|
||||||
|
IdxVec Writes, Reads;
|
||||||
|
findRWs(RW->getValueAsListOfDefs("OperandReadWrites"), Writes, Reads);
|
||||||
|
collectRWResources(Writes, Reads, PIdx);
|
||||||
|
}
|
||||||
|
|
||||||
|
collectRWResources(SC.Writes, SC.Reads, SC.ProcIndices);
|
||||||
}
|
}
|
||||||
// Add resources separately defined by each subtarget.
|
// Add resources separately defined by each subtarget.
|
||||||
RecVec WRDefs = Records.getAllDerivedDefinitions("WriteRes");
|
RecVec WRDefs = Records.getAllDerivedDefinitions("WriteRes");
|
||||||
|
|
|
@ -384,11 +384,11 @@ public:
|
||||||
return const_cast<CodeGenSchedRW&>(
|
return const_cast<CodeGenSchedRW&>(
|
||||||
IsRead ? getSchedRead(Idx) : getSchedWrite(Idx));
|
IsRead ? getSchedRead(Idx) : getSchedWrite(Idx));
|
||||||
}
|
}
|
||||||
const CodeGenSchedRW &getSchedRW(Record*Def) const {
|
const CodeGenSchedRW &getSchedRW(Record *Def) const {
|
||||||
return const_cast<CodeGenSchedModels&>(*this).getSchedRW(Def);
|
return const_cast<CodeGenSchedModels&>(*this).getSchedRW(Def);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned getSchedRWIdx(Record *Def, bool IsRead) const;
|
unsigned getSchedRWIdx(const Record *Def, bool IsRead) const;
|
||||||
|
|
||||||
// Return true if the given write record is referenced by a ReadAdvance.
|
// Return true if the given write record is referenced by a ReadAdvance.
|
||||||
bool hasReadOfWrite(Record *WriteDef) const;
|
bool hasReadOfWrite(Record *WriteDef) const;
|
||||||
|
@ -427,9 +427,6 @@ public:
|
||||||
|
|
||||||
unsigned findOrInsertRW(ArrayRef<unsigned> Seq, bool IsRead);
|
unsigned findOrInsertRW(ArrayRef<unsigned> Seq, bool IsRead);
|
||||||
|
|
||||||
unsigned findSchedClassIdx(Record *ItinClassDef, ArrayRef<unsigned> Writes,
|
|
||||||
ArrayRef<unsigned> Reads) const;
|
|
||||||
|
|
||||||
Record *findProcResUnits(Record *ProcResKind, const CodeGenProcModel &PM,
|
Record *findProcResUnits(Record *ProcResKind, const CodeGenProcModel &PM,
|
||||||
ArrayRef<SMLoc> Loc) const;
|
ArrayRef<SMLoc> Loc) const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue