File: AcquireAtCycle.td

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (86 lines) | stat: -rw-r--r-- 2,691 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// RUN: llvm-tblgen -gen-subtarget -DCORRECT -I %p/../../include %s 2>&1 | \
// RUN:   FileCheck %s  --check-prefix=CORRECT

// RUN: not llvm-tblgen -gen-subtarget -DWRONG_SIZE -I %p/../../include %s 2>&1 | \
// RUN:   FileCheck %s --check-prefix=WRONG_SIZE

// RUN: not llvm-tblgen -gen-subtarget -DWRONG_VALUE -I %p/../../include %s 2>&1 | \
// RUN:   FileCheck %s --check-prefix=WRONG_VALUE

// RUN: not llvm-tblgen -gen-subtarget -DNEGATIVE_INVALID -I %p/../../include %s 2>&1 | \
// RUN:   FileCheck %s --check-prefix=NEGATIVE_INVALID

// Make sure that AcquireAtCycle in WriteRes is used to generate the
// correct data.

include "llvm/Target/Target.td"

def MyTarget : Target;

let BufferSize = 0 in {
def ResX0 : ProcResource<1>; // X0
def ResX1 : ProcResource<1>; // X1
def ResX2 : ProcResource<1>; // X2
}

let OutOperandList = (outs), InOperandList = (ins) in {
  def Inst_A : Instruction;
  def Inst_B : Instruction;
}

let CompleteModel = 0 in {
  def SchedModel_A: SchedMachineModel;
}

def WriteInst_A : SchedWrite;
def WriteInst_B : SchedWrite;

let SchedModel = SchedModel_A in {
// Check the generated data when there are no semantic issues.
#ifdef CORRECT
// CORRECT-LABEL: llvm::MCWriteProcResEntry MyTargetWriteProcResTable[] = {
// CORRECT-NEXT: { 0, 0, 0 }, // Invalid
def : WriteRes<WriteInst_A, [ResX0, ResX1, ResX2]> {
// CORRECT-NEXT: { 1, 2, 0}, // #1
// CORRECT-NEXT: { 2, 4, 1}, // #2
// CORRECT-NEXT: { 3, 3, 2}, // #3
    let ReleaseAtCycles = [2, 4, 3];
    let AcquireAtCycles = [0, 1, 2];
}
def : WriteRes<WriteInst_B, [ResX2]> {
// If unspecified, AcquireAtCycle is set to 0.
// CORRECT-NEXT: { 3, 1, 0} // #4
    let ReleaseAtCycles = [1];
}
#endif // CORRECT

#ifdef WRONG_SIZE
// WRONG_SIZE: AcquireAtCycle.td:[[@LINE+1]]:1: error: Inconsistent resource cycles: size(AcquireAtCycles) != size(ProcResources): 2 vs 3
def : WriteRes<WriteInst_A, [ResX0, ResX1, ResX2]> {
    let ReleaseAtCycles = [2, 4, 3];
    let AcquireAtCycles = [0, 1];
}
#endif

#ifdef WRONG_VALUE
// WRONG_VALUE: AcquireAtCycle.td:[[@LINE+1]]:1: error: Inconsistent resource cycles: AcquireAtCycles < ReleaseAtCycles must hold
def : WriteRes<WriteInst_A, [ResX0, ResX1, ResX2]> {
    let ReleaseAtCycles = [2, 4, 3];
    let AcquireAtCycles = [0, 1, 8];
}
#endif

#ifdef NEGATIVE_INVALID
// NEGATIVE_INVALID: AcquireAtCycle.td:[[@LINE+1]]:1: error: Invalid value: AcquireAtCycle must be a non-negative value.
def : WriteRes<WriteInst_A, [ResX0]> {
    let ReleaseAtCycles = [2];
    let AcquireAtCycles = [-1];
}
#endif

def : InstRW<[WriteInst_A], (instrs Inst_A)>;
def : InstRW<[WriteInst_B], (instrs Inst_B)>;
}

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