mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 11:02:59 +02:00
[TargetSchedule] Expose sub-units of a ProcResGroup in MCProcResourceDesc.
Summary: Right now using a ProcResource automatically counts as usage of all super ProcResGroups. All this is done during codegen, so there is no way for schedulers to get this information at runtime. This adds the information of which individual ProcRes units are contained in a ProcResGroup in MCProcResourceDesc. Reviewers: gchatelet Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D43023 llvm-svn: 324582
This commit is contained in:
parent
58f2da5889
commit
d7ed5a1734
@ -44,6 +44,11 @@ struct MCProcResourceDesc {
|
|||||||
// an out-of-order cpus.
|
// an out-of-order cpus.
|
||||||
int BufferSize;
|
int BufferSize;
|
||||||
|
|
||||||
|
// If the resource has sub-units, a pointer to the first element of an array
|
||||||
|
// of `NumUnits` elements containing the ProcResourceIdx of the sub units.
|
||||||
|
// nullptr if the resource does not have sub-units.
|
||||||
|
const unsigned *SubUnitsIdxBegin;
|
||||||
|
|
||||||
bool operator==(const MCProcResourceDesc &Other) const {
|
bool operator==(const MCProcResourceDesc &Other) const {
|
||||||
return NumUnits == Other.NumUnits && SuperIdx == Other.SuperIdx
|
return NumUnits == Other.NumUnits && SuperIdx == Other.SuperIdx
|
||||||
&& BufferSize == Other.BufferSize;
|
&& BufferSize == Other.BufferSize;
|
||||||
|
@ -175,8 +175,7 @@ class ProcResourceKind;
|
|||||||
// BufferSize=1.
|
// BufferSize=1.
|
||||||
//
|
//
|
||||||
// SchedModel ties these units to a processor for any stand-alone defs
|
// SchedModel ties these units to a processor for any stand-alone defs
|
||||||
// of this class. Instances of subclass ProcResource will be automatically
|
// of this class.
|
||||||
// attached to a processor, so SchedModel is not needed.
|
|
||||||
class ProcResourceUnits<ProcResourceKind kind, int num> {
|
class ProcResourceUnits<ProcResourceKind kind, int num> {
|
||||||
ProcResourceKind Kind = kind;
|
ProcResourceKind Kind = kind;
|
||||||
int NumUnits = num;
|
int NumUnits = num;
|
||||||
|
@ -92,6 +92,8 @@ class SubtargetEmitter {
|
|||||||
&ProcItinLists);
|
&ProcItinLists);
|
||||||
void EmitProcessorProp(raw_ostream &OS, const Record *R, StringRef Name,
|
void EmitProcessorProp(raw_ostream &OS, const Record *R, StringRef Name,
|
||||||
char Separator);
|
char Separator);
|
||||||
|
void EmitProcessorResourceSubUnits(const CodeGenProcModel &ProcModel,
|
||||||
|
raw_ostream &OS);
|
||||||
void EmitProcessorResources(const CodeGenProcModel &ProcModel,
|
void EmitProcessorResources(const CodeGenProcModel &ProcModel,
|
||||||
raw_ostream &OS);
|
raw_ostream &OS);
|
||||||
Record *FindWriteResources(const CodeGenSchedRW &SchedWrite,
|
Record *FindWriteResources(const CodeGenSchedRW &SchedWrite,
|
||||||
@ -578,24 +580,52 @@ void SubtargetEmitter::EmitProcessorProp(raw_ostream &OS, const Record *R,
|
|||||||
OS << '\n';
|
OS << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SubtargetEmitter::EmitProcessorResourceSubUnits(
|
||||||
|
const CodeGenProcModel &ProcModel, raw_ostream &OS) {
|
||||||
|
OS << "\nstatic const unsigned " << ProcModel.ModelName
|
||||||
|
<< "ProcResourceSubUnits[] = {\n"
|
||||||
|
<< " 0, // Invalid\n";
|
||||||
|
|
||||||
|
for (unsigned i = 0, e = ProcModel.ProcResourceDefs.size(); i < e; ++i) {
|
||||||
|
Record *PRDef = ProcModel.ProcResourceDefs[i];
|
||||||
|
if (!PRDef->isSubClassOf("ProcResGroup"))
|
||||||
|
continue;
|
||||||
|
RecVec ResUnits = PRDef->getValueAsListOfDefs("Resources");
|
||||||
|
for (Record *RUDef : ResUnits) {
|
||||||
|
Record *const RU =
|
||||||
|
SchedModels.findProcResUnits(RUDef, ProcModel, PRDef->getLoc());
|
||||||
|
for (unsigned J = 0; J < RU->getValueAsInt("NumUnits"); ++J) {
|
||||||
|
OS << " " << ProcModel.getProcResourceIdx(RU) << ", ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
OS << " // " << PRDef->getName() << "\n";
|
||||||
|
}
|
||||||
|
OS << "};\n";
|
||||||
|
}
|
||||||
|
|
||||||
void SubtargetEmitter::EmitProcessorResources(const CodeGenProcModel &ProcModel,
|
void SubtargetEmitter::EmitProcessorResources(const CodeGenProcModel &ProcModel,
|
||||||
raw_ostream &OS) {
|
raw_ostream &OS) {
|
||||||
OS << "\n// {Name, NumUnits, SuperIdx, IsBuffered}\n";
|
EmitProcessorResourceSubUnits(ProcModel, OS);
|
||||||
|
|
||||||
|
OS << "\n// {Name, NumUnits, SuperIdx, IsBuffered, SubUnitsIdxBegin}\n";
|
||||||
OS << "static const llvm::MCProcResourceDesc "
|
OS << "static const llvm::MCProcResourceDesc "
|
||||||
<< ProcModel.ModelName << "ProcResources" << "[] = {\n"
|
<< ProcModel.ModelName << "ProcResources" << "[] = {\n"
|
||||||
<< " {DBGFIELD(\"InvalidUnit\") 0, 0, 0},\n";
|
<< " {DBGFIELD(\"InvalidUnit\") 0, 0, 0},\n";
|
||||||
|
|
||||||
|
unsigned SubUnitsOffset = 1;
|
||||||
for (unsigned i = 0, e = ProcModel.ProcResourceDefs.size(); i < e; ++i) {
|
for (unsigned i = 0, e = ProcModel.ProcResourceDefs.size(); i < e; ++i) {
|
||||||
Record *PRDef = ProcModel.ProcResourceDefs[i];
|
Record *PRDef = ProcModel.ProcResourceDefs[i];
|
||||||
|
|
||||||
Record *SuperDef = nullptr;
|
Record *SuperDef = nullptr;
|
||||||
unsigned SuperIdx = 0;
|
unsigned SuperIdx = 0;
|
||||||
unsigned NumUnits = 0;
|
unsigned NumUnits = 0;
|
||||||
|
const unsigned SubUnitsBeginOffset = SubUnitsOffset;
|
||||||
int BufferSize = PRDef->getValueAsInt("BufferSize");
|
int BufferSize = PRDef->getValueAsInt("BufferSize");
|
||||||
if (PRDef->isSubClassOf("ProcResGroup")) {
|
if (PRDef->isSubClassOf("ProcResGroup")) {
|
||||||
RecVec ResUnits = PRDef->getValueAsListOfDefs("Resources");
|
RecVec ResUnits = PRDef->getValueAsListOfDefs("Resources");
|
||||||
for (Record *RU : ResUnits) {
|
for (Record *RU : ResUnits) {
|
||||||
NumUnits += RU->getValueAsInt("NumUnits");
|
NumUnits += RU->getValueAsInt("NumUnits");
|
||||||
|
SubUnitsOffset += NumUnits;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -612,8 +642,14 @@ void SubtargetEmitter::EmitProcessorResources(const CodeGenProcModel &ProcModel,
|
|||||||
OS << " {DBGFIELD(\"" << PRDef->getName() << "\") ";
|
OS << " {DBGFIELD(\"" << PRDef->getName() << "\") ";
|
||||||
if (PRDef->getName().size() < 15)
|
if (PRDef->getName().size() < 15)
|
||||||
OS.indent(15 - PRDef->getName().size());
|
OS.indent(15 - PRDef->getName().size());
|
||||||
OS << NumUnits << ", " << SuperIdx << ", "
|
OS << NumUnits << ", " << SuperIdx << ", " << BufferSize << ", ";
|
||||||
<< BufferSize << "}, // #" << i+1;
|
if (SubUnitsBeginOffset != SubUnitsOffset) {
|
||||||
|
OS << ProcModel.ModelName << "ProcResourceSubUnits + "
|
||||||
|
<< SubUnitsBeginOffset;
|
||||||
|
} else {
|
||||||
|
OS << "nullptr";
|
||||||
|
}
|
||||||
|
OS << "}, // #" << i+1;
|
||||||
if (SuperDef)
|
if (SuperDef)
|
||||||
OS << ", Super=" << SuperDef->getName();
|
OS << ", Super=" << SuperDef->getName();
|
||||||
OS << "\n";
|
OS << "\n";
|
||||||
|
Loading…
Reference in New Issue
Block a user