1 // RUN: llvm-tblgen -gen-subtarget -DCORRECT -I %p/../../include %s 2>&1 | \
2 // RUN: FileCheck %s --check-prefix=CORRECT
4 // RUN: not llvm-tblgen -gen-subtarget -DWRONG_SIZE -I %p/../../include %s 2>&1 | \
5 // RUN: FileCheck %s --check-prefix=WRONG_SIZE
7 // RUN: not llvm-tblgen -gen-subtarget -DWRONG_VALUE -I %p/../../include %s 2>&1 | \
8 // RUN: FileCheck %s --check-prefix=WRONG_VALUE
10 // RUN: not llvm-tblgen -gen-subtarget -DNEGATIVE_INVALID -I %p/../../include %s 2>&1 | \
11 // RUN: FileCheck %s --check-prefix=NEGATIVE_INVALID
13 // Make sure that AcquireAtCycle in WriteRes is used to generate the
16 include "llvm/Target/Target.td"
18 def MyTarget : Target;
20 let BufferSize = 0 in {
21 def ResX0 : ProcResource<1>; // X0
22 def ResX1 : ProcResource<1>; // X1
23 def ResX2 : ProcResource<1>; // X2
26 let OutOperandList = (outs), InOperandList = (ins) in {
27 def Inst_A : Instruction;
28 def Inst_B : Instruction;
31 let CompleteModel = 0 in {
32 def SchedModel_A: SchedMachineModel;
35 def WriteInst_A : SchedWrite;
36 def WriteInst_B : SchedWrite;
38 let SchedModel = SchedModel_A in {
39 // Check the generated data when there are no semantic issues.
41 // CORRECT-LABEL: llvm::MCWriteProcResEntry MyTargetWriteProcResTable[] = {
42 // CORRECT-NEXT: { 0, 0, 0 }, // Invalid
43 def : WriteRes<WriteInst_A, [ResX0, ResX1, ResX2]> {
44 // CORRECT-NEXT: { 1, 2, 0}, // #1
45 // CORRECT-NEXT: { 2, 4, 1}, // #2
46 // CORRECT-NEXT: { 3, 3, 2}, // #3
47 let ReleaseAtCycles = [2, 4, 3];
48 let AcquireAtCycles = [0, 1, 2];
50 def : WriteRes<WriteInst_B, [ResX2]> {
51 // If unspecified, AcquireAtCycle is set to 0.
52 // CORRECT-NEXT: { 3, 1, 0} // #4
53 let ReleaseAtCycles = [1];
58 // WRONG_SIZE: AcquireAtCycle.td:[[@LINE+1]]:1: error: Inconsistent resource cycles: size(AcquireAtCycles) != size(ProcResources): 2 vs 3
59 def : WriteRes<WriteInst_A, [ResX0, ResX1, ResX2]> {
60 let ReleaseAtCycles = [2, 4, 3];
61 let AcquireAtCycles = [0, 1];
66 // WRONG_VALUE: AcquireAtCycle.td:[[@LINE+1]]:1: error: Inconsistent resource cycles: AcquireAtCycles < ReleaseAtCycles must hold
67 def : WriteRes<WriteInst_A, [ResX0, ResX1, ResX2]> {
68 let ReleaseAtCycles = [2, 4, 3];
69 let AcquireAtCycles = [0, 1, 8];
73 #ifdef NEGATIVE_INVALID
74 // NEGATIVE_INVALID: AcquireAtCycle.td:[[@LINE+1]]:1: error: Invalid value: AcquireAtCycle must be a non-negative value.
75 def : WriteRes<WriteInst_A, [ResX0]> {
76 let ReleaseAtCycles = [2];
77 let AcquireAtCycles = [-1];
81 def : InstRW<[WriteInst_A], (instrs Inst_A)>;
82 def : InstRW<[WriteInst_B], (instrs Inst_B)>;
85 def ProcessorA: ProcessorModel<"ProcessorA", SchedModel_A, []>;