File: decl.pdll

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (97 lines) | stat: -rw-r--r-- 3,320 bytes parent folder | download | duplicates (15)
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
95
96
97
// RUN: mlir-pdll %s -I %S -split-input-file -x mlir | FileCheck %s

//===----------------------------------------------------------------------===//
// PatternDecl
//===----------------------------------------------------------------------===//

// CHECK: pdl.pattern : benefit(0) {
Pattern => erase _: Op;

// -----

// CHECK: pdl.pattern @NamedPattern : benefit(0) {
Pattern NamedPattern => erase _: Op;

// -----

// CHECK: pdl.pattern @NamedPattern : benefit(10) {
Pattern NamedPattern with benefit(10), recursion => erase _: Op;

// -----

//===----------------------------------------------------------------------===//
// VariableDecl
//===----------------------------------------------------------------------===//

// Test the case of a variable with an initializer.

// CHECK: pdl.pattern @VarWithInit
// CHECK: %[[INIT:.*]] = operation "test.op"
// CHECK: rewrite %[[INIT]] {
// CHECK:   erase %[[INIT]]
Pattern VarWithInit {
  let var = op<test.op>;
  erase var;
}

// -----

// Test range based constraints.

// CHECK: pdl.pattern @VarWithRangeConstraints
// CHECK: %[[OPERAND_TYPES:.*]] = types
// CHECK: %[[OPERANDS:.*]] = operands : %[[OPERAND_TYPES]]
// CHECK: %[[RESULT_TYPES:.*]] = types
// CHECK: operation(%[[OPERANDS]] : !pdl.range<value>)  -> (%[[RESULT_TYPES]] : !pdl.range<type>)
Pattern VarWithRangeConstraints {
  erase op<>(operands: ValueRange<operandTypes: TypeRange>) -> (results: TypeRange);
}

// -----

// Test single entity constraints.

// CHECK: pdl.pattern @VarWithConstraints
// CHECK: %[[OPERAND_TYPE:.*]] = type
// CHECK: %[[OPERAND:.*]] = operand : %[[OPERAND_TYPES]]
// CHECK: %[[ATTR_TYPE:.*]] = type
// CHECK: %[[ATTR:.*]] = attribute : %[[ATTR_TYPE]]
// CHECK: %[[RESULT_TYPE:.*]] = type
// CHECK: operation(%[[OPERAND]] : !pdl.value)  {"attr" = %[[ATTR]]} -> (%[[RESULT_TYPE]] : !pdl.type)
Pattern VarWithConstraints {
  erase op<>(operand: Value<operandType: Type>) { attr = _: Attr<attrType: Type>} -> (result: Type);
}

// -----

// Test op constraint.

// CHECK: pdl.pattern @VarWithNoNameOpConstraint
// CHECK: %[[OPERANDS:.*]] = operands
// CHECK: %[[RESULT_TYPES:.*]] = types
// CHECK: operation(%[[OPERANDS]] : !pdl.range<value>)  -> (%[[RESULT_TYPES]] : !pdl.range<type>)
Pattern VarWithNoNameOpConstraint => erase _: Op;

// CHECK: pdl.pattern @VarWithNamedOpConstraint
// CHECK: %[[OPERANDS:.*]] = operands
// CHECK: %[[RESULT_TYPES:.*]] = types
// CHECK: operation "test.op"(%[[OPERANDS]] : !pdl.range<value>)  -> (%[[RESULT_TYPES]] : !pdl.range<type>)
Pattern VarWithNamedOpConstraint => erase _: Op<test.op>;

// -----

// Test user defined constraints.

// CHECK: pdl.pattern @VarWithUserConstraint
// CHECK: %[[OPERANDS:.*]] = operands
// CHECK: %[[RESULT_TYPES:.*]] = types
// CHECK: %[[OP:.*]] = operation(%[[OPERANDS]] : !pdl.range<value>)  -> (%[[RESULT_TYPES]] : !pdl.range<type>)
// CHECK: apply_native_constraint "NestedArgCst"(%[[OP]] : !pdl.operation)
// CHECK: apply_native_constraint "NestedResCst"(%[[OP]] : !pdl.operation)
// CHECK: apply_native_constraint "OpCst"(%[[OP]] : !pdl.operation)
// CHECK: rewrite %[[OP]]
Constraint NestedArgCst(op: Op);
Constraint NestedResCst(op: Op);
Constraint TestArgResCsts(op: NestedArgCst) -> NestedResCst => op;
Constraint OpCst(op: Op);
Pattern VarWithUserConstraint => erase _: [TestArgResCsts, OpCst];