File: builtin-pattern-errors.td

package info (click to toggle)
llvm-toolchain-21 1%3A21.1.6-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,245,028 kB
  • sloc: cpp: 7,619,726; ansic: 1,434,018; asm: 1,058,748; python: 252,740; f90: 94,671; objc: 70,685; lisp: 42,813; pascal: 18,401; sh: 8,601; ml: 5,111; perl: 4,720; makefile: 3,675; awk: 3,523; javascript: 2,409; xml: 892; fortran: 770
file content (94 lines) | stat: -rw-r--r-- 3,539 bytes parent folder | download | duplicates (9)
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
87
88
89
90
91
92
93
94
// RUN: not llvm-tblgen -I %p/../../../../include -gen-global-isel-combiner \
// RUN:     -combiners=MyCombiner %s 2>&1| \
// RUN: FileCheck %s -implicit-check-not=error:

include "llvm/Target/Target.td"
include "llvm/Target/GlobalISel/Combine.td"

def MyTargetISA : InstrInfo;
def MyTarget : Target { let InstructionSet = MyTargetISA; }

// CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: expected operand 1 of 'GIReplaceReg' to be a name
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(GIReplaceReg ?:$dst, (i32 0))'
def builtinpat_immop : GICombineRule<
  (defs root:$dst),
  (match (COPY $dst, $src)),
  (apply (GIReplaceReg $dst, (i32 0)))>;

// CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: expected operand 1 of 'GIReplaceReg' to be a name
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(GIReplaceReg ?:$dst, (i32 0):$k)'
def builtinpat_namedimmop : GICombineRule<
  (defs root:$dst),
  (match (COPY $dst, $src)),
  (apply (GIReplaceReg $dst, (i32 0):$k))>;


// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: 'GIEraseRoot' cannot be used in a 'match' pattern
def eraseroot_in_match : GICombineRule<
  (defs root:$dst),
  (match (GIEraseRoot):$mi),
  (apply (COPY $dst, $src))>;

// CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: 'GIEraseRoot' expected 0 operands, got 1
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(GIEraseRoot ?:$dst)'
def eraseroot_ops : GICombineRule<
  (defs root:$dst),
  (match (COPY $dst, $src)),
  (apply (GIEraseRoot $dst), (COPY $dst, $src))>;

// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: GIEraseRoot must be the only 'apply' pattern
def eraseroot_multiapply : GICombineRule<
  (defs root:$dst),
  (match (COPY $dst, $src)),
  (apply (GIEraseRoot), (COPY $dst, $src))>;

// CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: GIEraseRoot can only be used if on roots that do not have any output operand
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: note: 'COPY' has 1 output operands
def eraseroot_root_has_def: GICombineRule<
  (defs root:$dst),
  (match (COPY $dst, $src)),
  (apply (GIEraseRoot))>;

def TestPF: GICombinePatFrag<
    (outs root:$def),
    (ins),
    [(pattern (COPY $def, $src))]>;
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: GIEraseRoot can only be used if the root is a CodeGenInstruction or Intrinsic
def eraseroot_notinstmatch: GICombineRule<
  (defs root:$mi),
  (match (TestPF $dst):$mi),
  (apply (GIEraseRoot))>;

// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: 'GIReplaceReg' cannot be used in a 'match' pattern
def replacereg_in_match : GICombineRule<
  (defs root:$dst),
  (match (GIReplaceReg $dst, $src)),
  (apply (COPY $dst, $src))>;

// CHECK: :[[@LINE+2]]:{{[0-9]+}}: error: 'GIReplaceReg' expected 2 operands, got 1
// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: Failed to parse pattern: '(GIReplaceReg ?:$dst)'
def replacereg_ops : GICombineRule<
  (defs root:$dst),
  (match (COPY $dst, $src)),
  (apply (GIReplaceReg $dst))>;

// CHECK: :[[@LINE+1]]:{{[0-9]+}}: error: GIReplaceReg cannot replace 'tmp': this builtin can only replace a register defined by the match root
def replacereg_nonroot : GICombineRule<
  (defs root:$dst),
  (match (COPY $dst, $tmp), (COPY $tmp, $src)),
  (apply (GIReplaceReg $dst, $src), (GIReplaceReg $tmp, $src))>;

// CHECK: error: Failed to parse one or more rules

def MyCombiner: GICombiner<"GenMyCombiner", [
  builtinpat_immop,
  builtinpat_namedimmop,
  eraseroot_in_match,
  eraseroot_ops,
  eraseroot_multiapply,
  eraseroot_root_has_def,
  eraseroot_notinstmatch,
  replacereg_in_match,
  replacereg_ops,
  replacereg_nonroot
]>;