Index: llvm/trunk/include/llvm/Target/TargetSchedule.td =================================================================== --- llvm/trunk/include/llvm/Target/TargetSchedule.td +++ llvm/trunk/include/llvm/Target/TargetSchedule.td @@ -281,10 +281,9 @@ // ProcResources indicates the set of resources consumed by the write. // Optionally, ResourceCycles indicates the number of cycles the // resource is consumed. Each ResourceCycles item is paired with the -// ProcResource item at the same position in its list. Since -// ResourceCycles are rarely specialized, the list may be -// incomplete. By default, resources are consumed for a single cycle, -// regardless of latency, which models a fully pipelined processing +// ProcResource item at the same position in its list. ResourceCycles +// can be `[]`: in that case, all resources are consumed for a single +// cycle, regardless of latency, which models a fully pipelined processing // unit. A value of 0 for ResourceCycles means that the resource must // be available but is not consumed, which is only relevant for // unbuffered resources. Index: llvm/trunk/lib/Target/AArch64/AArch64SchedThunderX2T99.td =================================================================== --- llvm/trunk/lib/Target/AArch64/AArch64SchedThunderX2T99.td +++ llvm/trunk/lib/Target/AArch64/AArch64SchedThunderX2T99.td @@ -416,7 +416,7 @@ // Address generation def : WriteRes { let Latency = 1; - let ResourceCycles = [1, 3]; + let ResourceCycles = [1]; let NumMicroOps = 2; } @@ -438,7 +438,7 @@ // ALU, extend and/or shift def : WriteRes { let Latency = 2; - let ResourceCycles = [2, 3]; + let ResourceCycles = [2]; let NumMicroOps = 2; } @@ -457,7 +457,7 @@ def : WriteRes { let Latency = 1; - let ResourceCycles = [1, 3]; + let ResourceCycles = [1]; let NumMicroOps = 2; } @@ -500,14 +500,14 @@ // Latency range of 13-23/13-39. def : WriteRes { let Latency = 39; - let ResourceCycles = [13, 39]; + let ResourceCycles = [39]; let NumMicroOps = 4; } // Divide, X-form def : WriteRes { let Latency = 23; - let ResourceCycles = [13, 23]; + let ResourceCycles = [23]; let NumMicroOps = 4; } @@ -1252,7 +1252,7 @@ def : WriteRes { let Latency = 7; let NumMicroOps = 4; - let ResourceCycles = [4, 23]; + let ResourceCycles = [4]; } // ASIMD arith, reduce, 4H/4S Index: llvm/trunk/utils/TableGen/SubtargetEmitter.cpp =================================================================== --- llvm/trunk/utils/TableGen/SubtargetEmitter.cpp +++ llvm/trunk/utils/TableGen/SubtargetEmitter.cpp @@ -941,8 +941,7 @@ void SubtargetEmitter::ExpandProcResources(RecVec &PRVec, std::vector &Cycles, const CodeGenProcModel &PM) { - // Default to 1 resource cycle. - Cycles.resize(PRVec.size(), 1); + assert(PRVec.size() == Cycles.size() && "failed precondition"); for (unsigned i = 0, e = PRVec.size(); i != e; ++i) { Record *PRDef = PRVec[i]; RecVec SubResources; @@ -1111,6 +1110,21 @@ std::vector Cycles = WriteRes->getValueAsListOfInts("ResourceCycles"); + if (Cycles.empty()) { + // If ResourceCycles is not provided, default to one cycle per + // resource. + Cycles.resize(PRVec.size(), 1); + } else if (Cycles.size() != PRVec.size()) { + // If ResourceCycles is provided, check consistency. + PrintFatalError( + WriteRes->getLoc(), + Twine("Inconsistent resource cycles: !size(ResourceCycles) != " + "!size(ProcResources): ") + .concat(Twine(PRVec.size())) + .concat(" vs ") + .concat(Twine(Cycles.size()))); + } + ExpandProcResources(PRVec, Cycles, ProcModel); for (unsigned PRIdx = 0, PREnd = PRVec.size();