Skip to content

Commit 081e4bb

Browse files
author
Simon Dardis
committedJun 23, 2016
[misched] Extend scheduler to handle unsupported features
Currently isComplete = 1 requires that every instruction must be described, declared unsupported or marked as having no scheduling information for a processor. For some backends such as MIPS, this requirement entails long regex lists of instructions that are unsupported. This patch teaches Tablegen to skip over instructions that are associated with unsupported feature when checking if the scheduling model is complete. Patch by: Daniel Sanders Contributions by: Simon Dardis Reviewers: MatzeB Differential Reviewer: http://reviews.llvm.org/D20522 llvm-svn: 273551
1 parent e440f99 commit 081e4bb

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed
 

‎llvm/include/llvm/Target/TargetSchedule.td

+16
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ include "llvm/Target/TargetItinerary.td"
5555

5656
class Instruction; // Forward def
5757

58+
class Predicate; // Forward def
59+
5860
// DAG operator that interprets the DAG args as Instruction defs.
5961
def instrs;
6062

@@ -97,6 +99,20 @@ class SchedMachineModel {
9799
// resulting from changes to the instruction definitions.
98100
bit CompleteModel = 1;
99101

102+
// A processor may only implement part of published ISA, due to either new ISA
103+
// extensions, (e.g. Pentium 4 doesn't have AVX) or implementation
104+
// (ARM/MIPS/PowerPC/SPARC soft float cores).
105+
//
106+
// For a processor which doesn't support some feature(s), the schedule model
107+
// can use:
108+
//
109+
// let<Predicate> UnsupportedFeatures = [HaveA,..,HaveY];
110+
//
111+
// to skip the checks for scheduling information when building LLVM for
112+
// instructions which have any of the listed predicates in their Predicates
113+
// field.
114+
list<Predicate> UnsupportedFeatures = [];
115+
100116
bit NoModel = 0; // Special tag to indicate missing machine model.
101117
}
102118

‎llvm/utils/TableGen/CodeGenSchedule.cpp

+29-1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ CodeGenSchedModels::CodeGenSchedModels(RecordKeeper &RK,
120120
// (For per-operand resources mapped to itinerary classes).
121121
collectProcItinRW();
122122

123+
// Find UnsupportedFeatures records for each processor.
124+
// (For per-operand resources mapped to itinerary classes).
125+
collectProcUnsupportedFeatures();
126+
123127
// Infer new SchedClasses from SchedVariant.
124128
inferSchedClasses();
125129

@@ -829,6 +833,15 @@ void CodeGenSchedModels::collectProcItinRW() {
829833
}
830834
}
831835

836+
// Gather the unsupported features for processor models.
837+
void CodeGenSchedModels::collectProcUnsupportedFeatures() {
838+
for (CodeGenProcModel &ProcModel : ProcModels) {
839+
for (Record *Pred : ProcModel.ModelDef->getValueAsListOfDefs("UnsupportedFeatures")) {
840+
ProcModel.UnsupportedFeaturesDefs.push_back(Pred);
841+
}
842+
}
843+
}
844+
832845
/// Infer new classes from existing classes. In the process, this may create new
833846
/// SchedWrites from sequences of existing SchedWrites.
834847
void CodeGenSchedModels::inferSchedClasses() {
@@ -1540,6 +1553,8 @@ void CodeGenSchedModels::checkCompleteness() {
15401553
for (const CodeGenInstruction *Inst : Target.getInstructionsByEnumValue()) {
15411554
if (Inst->hasNoSchedulingInfo)
15421555
continue;
1556+
if (ProcModel.isUnsupported(*Inst))
1557+
continue;
15431558
unsigned SCIdx = getSchedClassIdx(*Inst);
15441559
if (!SCIdx) {
15451560
if (Inst->TheDef->isValueUnset("SchedRW") && !HadCompleteModel) {
@@ -1575,7 +1590,10 @@ void CodeGenSchedModels::checkCompleteness() {
15751590
<< "- Consider setting 'CompleteModel = 0' while developing new models.\n"
15761591
<< "- Pseudo instructions can be marked with 'hasNoSchedulingInfo = 1'.\n"
15771592
<< "- Instructions should usually have Sched<[...]> as a superclass, "
1578-
"you may temporarily use an empty list.\n\n";
1593+
"you may temporarily use an empty list.\n"
1594+
<< "- Instructions related to unsupported features can be excluded with "
1595+
"list<Predicate> UnsupportedFeatures = [HasA,..,HasY]; in the "
1596+
"processor model.\n\n";
15791597
PrintFatalError("Incomplete schedule model");
15801598
}
15811599
}
@@ -1756,6 +1774,16 @@ unsigned CodeGenProcModel::getProcResourceIdx(Record *PRDef) const {
17561774
return 1 + (PRPos - ProcResourceDefs.begin());
17571775
}
17581776

1777+
bool CodeGenProcModel::isUnsupported(const CodeGenInstruction &Inst) const {
1778+
for (const Record *TheDef : UnsupportedFeaturesDefs) {
1779+
for (const Record *PredDef : Inst.TheDef->getValueAsListOfDefs("Predicates")) {
1780+
if (TheDef->getName() == PredDef->getName())
1781+
return true;
1782+
}
1783+
}
1784+
return false;
1785+
}
1786+
17591787
#ifndef NDEBUG
17601788
void CodeGenProcModel::dump() const {
17611789
dbgs() << Index << ": " << ModelName << " "

‎llvm/utils/TableGen/CodeGenSchedule.h

+8
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ struct CodeGenProcModel {
189189
// This list is empty if no ItinRW refers to this Processor.
190190
RecVec ItinRWDefs;
191191

192+
// List of unsupported feature.
193+
// This list is empty if the Processor has no UnsupportedFeatures.
194+
RecVec UnsupportedFeaturesDefs;
195+
192196
// All read/write resources associated with this processor.
193197
RecVec WriteResDefs;
194198
RecVec ReadAdvanceDefs;
@@ -211,6 +215,8 @@ struct CodeGenProcModel {
211215

212216
unsigned getProcResourceIdx(Record *PRDef) const;
213217

218+
bool isUnsupported(const CodeGenInstruction &Inst) const;
219+
214220
#ifndef NDEBUG
215221
void dump() const;
216222
#endif
@@ -402,6 +408,8 @@ class CodeGenSchedModels {
402408

403409
void collectProcItinRW();
404410

411+
void collectProcUnsupportedFeatures();
412+
405413
void inferSchedClasses();
406414

407415
void checkCompleteness();

0 commit comments

Comments
 (0)
Please sign in to comment.