Skip to content

Commit 7fa104e

Browse files
authored
[TableGen][MCSched] Update error messages on the range of Acquire/ReleaseAtCycle (#131908)
I was looking at the value range of AcquireAtCycle / ReleaseAtCycle, and I noticed that while the TableGen error messages said AcquireAtCycle has to be less than ReleaseAtCycle, in reality they are actually allowed to be the same. This patch fixes it and add more test cases.
1 parent 06e2fd9 commit 7fa104e

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

llvm/test/TableGen/AcquireAtCycle.td

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def ResX2 : ProcResource<1>; // X2
2626
let OutOperandList = (outs), InOperandList = (ins) in {
2727
def Inst_A : Instruction;
2828
def Inst_B : Instruction;
29+
def Inst_C : Instruction;
2930
}
3031

3132
let CompleteModel = 0 in {
@@ -34,6 +35,7 @@ let CompleteModel = 0 in {
3435

3536
def WriteInst_A : SchedWrite;
3637
def WriteInst_B : SchedWrite;
38+
def WriteInst_C : SchedWrite;
3739

3840
let SchedModel = SchedModel_A in {
3941
// Check the generated data when there are no semantic issues.
@@ -49,9 +51,14 @@ def : WriteRes<WriteInst_A, [ResX0, ResX1, ResX2]> {
4951
}
5052
def : WriteRes<WriteInst_B, [ResX2]> {
5153
// If unspecified, AcquireAtCycle is set to 0.
52-
// CORRECT-NEXT: { 3, 1, 0} // #4
54+
// CORRECT-NEXT: { 3, 1, 0}, // #4
5355
let ReleaseAtCycles = [1];
5456
}
57+
def : WriteRes<WriteInst_C, [ResX0]> {
58+
// AcquireAtCycle and ReleaseAtCycle are allowed to be the same.
59+
// CORRECT-NEXT: { 1, 0, 0} // #5
60+
let ReleaseAtCycles = [0];
61+
}
5562
#endif // CORRECT
5663

5764
#ifdef WRONG_SIZE
@@ -63,7 +70,7 @@ def : WriteRes<WriteInst_A, [ResX0, ResX1, ResX2]> {
6370
#endif
6471

6572
#ifdef WRONG_VALUE
66-
// WRONG_VALUE: AcquireAtCycle.td:[[@LINE+1]]:1: error: Inconsistent resource cycles: AcquireAtCycles < ReleaseAtCycles must hold
73+
// WRONG_VALUE: AcquireAtCycle.td:[[@LINE+1]]:1: error: Inconsistent resource cycles: AcquireAtCycles <= ReleaseAtCycles must hold
6774
def : WriteRes<WriteInst_A, [ResX0, ResX1, ResX2]> {
6875
let ReleaseAtCycles = [2, 4, 3];
6976
let AcquireAtCycles = [0, 1, 8];
@@ -80,6 +87,7 @@ def : WriteRes<WriteInst_A, [ResX0]> {
8087

8188
def : InstRW<[WriteInst_A], (instrs Inst_A)>;
8289
def : InstRW<[WriteInst_B], (instrs Inst_B)>;
90+
def : InstRW<[WriteInst_C], (instrs Inst_C)>;
8391
}
8492

8593
def ProcessorA: ProcessorModel<"ProcessorA", SchedModel_A, []>;

llvm/utils/TableGen/SubtargetEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,7 @@ void SubtargetEmitter::genSchedClassTables(const CodeGenProcModel &ProcModel,
12451245
PrintFatalError(
12461246
WriteRes->getLoc(),
12471247
Twine("Inconsistent resource cycles: AcquireAtCycles "
1248-
"< ReleaseAtCycles must hold."));
1248+
"<= ReleaseAtCycles must hold."));
12491249
}
12501250
if (AcquireAtCycles[PRIdx] < 0) {
12511251
PrintFatalError(WriteRes->getLoc(),

0 commit comments

Comments
 (0)