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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
|
// RUN: mlir-tblgen -gen-op-decls -asmformat-error-is-fatal=false -I %S/../../include %s -o=%t 2>&1 | FileCheck %s
include "mlir/IR/OpBase.td"
def TestDialect : Dialect {
let name = "test";
}
class TestFormat_Op<string fmt, list<Trait> traits = []>
: Op<TestDialect, "format_op", traits> {
let assemblyFormat = fmt;
}
//===----------------------------------------------------------------------===//
// Format ambiguity caused by attribute followed by colon literal
//===----------------------------------------------------------------------===//
// Test attribute followed by a colon.
// CHECK: error: format ambiguity caused by `:` literal found after attribute `attr`
def AmbiguousTypeA : TestFormat_Op<[{
$attr `:` attr-dict
}]>, Arguments<(ins AnyAttr:$attr)>;
// Test optional attribute followed by colon.
// CHECK: error: format ambiguity caused by `:` literal found after attribute `attr`
def AmbiguousTypeB : TestFormat_Op<[{
(`foo` $attr^)? `:` attr-dict
}]>, Arguments<(ins OptionalAttr<AnyAttr>:$attr)>;
// Test attribute followed by whitespace and then colon.
// CHECK: error: format ambiguity caused by `:` literal found after attribute `attr`
def AmbiguousTypeC : TestFormat_Op<[{
$attr ` ` `:` attr-dict
}]>, Arguments<(ins AnyAttr:$attr)>;
// Test attribute followed by optional dictionary and then colon.
// CHECK: error: format ambiguity caused by `:` literal found after attribute `attr`
def AmbiguousTypeD : TestFormat_Op<[{
$attr attr-dict `:`
}]>, Arguments<(ins AnyAttr:$attr)>;
// Test attribute followed by optional group and then colon.
// CHECK: error: format ambiguity caused by `:` literal found after attribute `attr`
def AmbiguousTypeE : TestFormat_Op<[{
$attr ($a^)? `:` attr-dict type($a)
}]>, Arguments<(ins AnyAttr:$attr, Optional<I32>:$a)>;
// Test attribute followed by optional group with literals and then colon.
// CHECK: error: format ambiguity caused by `:` literal found after attribute `attr`
def AmbiguousTypeF : TestFormat_Op<[{
$attr (`(` $a^ `)`)? `:` attr-dict (`(` type($a)^ `)`)?
}]>, Arguments<(ins AnyAttr:$attr, Optional<I32>:$a)>;
// Test attribute followed by optional group with else group.
// CHECK: error: format ambiguity caused by `:` literal found after attribute `attr`
def AmbiguousTypeG : TestFormat_Op<[{
$attr (`(` $a^ `)`) : (`foo`)? `:` attr-dict (`(` type($a)^ `)`)?
}]>, Arguments<(ins AnyAttr:$attr, Optional<I32>:$a)>;
// Test attribute followed by optional group with colon.
// CHECK: error: format ambiguity caused by `:` literal found after attribute `attr`
def AmbiguousTypeH : TestFormat_Op<[{
$attr (`:` $a^ `)`)? attr-dict (`(` type($a)^ `)`)?
}]>, Arguments<(ins AnyAttr:$attr, Optional<I32>:$a)>;
// Test attribute followed by optional group with colon in else group.
// CHECK: error: format ambiguity caused by `:` literal found after attribute `attr`
def AmbiguousTypeI : TestFormat_Op<[{
$attr (`(` $a^ `)`) : (`:`)? attr-dict (`(` type($a)^ `)`)?
}]>, Arguments<(ins AnyAttr:$attr, Optional<I32>:$a)>;
// Test attribute followed by two optional groups and then a colon.
// CHECK: error: format ambiguity caused by `:` literal found after attribute `attr`
def AmbiguousTypeJ : TestFormat_Op<[{
$attr (`(` $a^ type($a) `)`) : (`foo`)? ` ` attr-dict (`(` $b^ type($b) `)`)?
`:`
}], [AttrSizedOperandSegments]>,
Arguments<(ins AnyAttr:$attr, Optional<I32>:$a, Optional<I32>:$b)>;
// Test attribute followed by two optional groups and then a colon in the else
// group.
// CHECK: error: format ambiguity caused by `:` literal found after attribute `attr`
def AmbiguousTypeK : TestFormat_Op<[{
$attr (`(` $a^ type($a) `)`) : (`foo`)? ` ` attr-dict
(`(` $b^ type($b) `)`) : (`:`)?
}], [AttrSizedOperandSegments]>,
Arguments<(ins AnyAttr:$attr, Optional<I32>:$a, Optional<I32>:$b)>;
// Test attribute followed by two optional groups with guarded colons but then a
// colon.
// CHECK: error: format ambiguity caused by `:` literal found after attribute `attr`
def AmbiguousTypeL : TestFormat_Op<[{
$attr (`(` $a^ `:` type($a) `)`) : (`foo` `:`)? ` ` attr-dict
(`(` $b^ `:` type($b) `)`) : (`foo` `:`)? `:`
}], [AttrSizedOperandSegments]>,
Arguments<(ins AnyAttr:$attr, Optional<I32>:$a, Optional<I32>:$b)>;
// Test optional attribute followed by optional groups with a colon along one
// path.
// CHECK: error: format ambiguity caused by `:` literal found after attribute `attr`
def AmbiguousTypeM : TestFormat_Op<[{
(`(` $attr^ ` `)? (`(` $a^ `:` type($a) `)`) : (`foo` `:`)? ` ` attr-dict
(`(` $b^ `:` type($b) `)`) : (`foo` `:`)? `:`
}], [AttrSizedOperandSegments]>,
Arguments<(ins OptionalAttr<AnyAttr>:$attr, Optional<I32>:$a,
Optional<I32>:$b)>;
// Test optional attribute followed by optional groups with a colon along one
// path inside an optional group.
// CHECK: error: format ambiguity caused by `:` literal found after attribute `attr`
def AmbiguousTypeN : TestFormat_Op<[{
(`(` $attr^ ` `)? (`(` $a^ `:` type($a) `)`) : (`foo` `:`)? ` ` attr-dict
(`(` $b^ `:` type($b) `)`) : (`:`)?
}], [AttrSizedOperandSegments]>,
Arguments<(ins OptionalAttr<AnyAttr>:$attr, Optional<I32>:$a,
Optional<I32>:$b)>;
// Test attribute followed by optional attribute, operand, successor, region,
// and a colon.
// CHECK: error: format ambiguity caused by `:` literal found after attribute `attr`
def AmbiguousTypeO : TestFormat_Op<[{
$attr attr-dict $a $b $c $d $e `:`
}], [AttrSizedOperandSegments]> {
let arguments = (ins AnyAttr:$attr, OptionalAttr<I32Attr>:$a,
Optional<I32>:$b, Variadic<I32>:$c);
let successors = (successor VariadicSuccessor<AnySuccessor>:$d);
let regions = (region VariadicRegion<AnyRegion>:$e);
}
// Test two attributes, where the second one is ambiguous.
// CHECK: error: format ambiguity caused by `:` literal found after attribute `b`
def AmbiguousTypeP : TestFormat_Op<[{
$a attr-dict `(` `:` $b (`:` $c^)?
}]>, Arguments<(ins AnyAttr:$a, AnyAttr:$b, Optional<I32>:$c)>;
// Test two attributes, where the second one is ambiguous.
// CHECK: error: format ambiguity caused by `:` literal found after attribute `b`
def AmbiguousTypeQ : TestFormat_Op<[{
$a attr-dict (`(` $c^ `:`)? `(` `:` $b `:`
}]>, Arguments<(ins AnyAttr:$a, AnyAttr:$b, Optional<I32>:$c)>;
// CHECK-NOT: error
// Test attribute followed by two optional groups with guarded colons.
def ValidTypeA : TestFormat_Op<[{
$attr (`(` $a^ `:` type($a) `)`) : (`foo` `:`)? ` ` attr-dict
(`(` $b^ `:` type($b) `)`) : (`foo` `:`)? ` ` `(` `:`
}], [AttrSizedOperandSegments]>,
Arguments<(ins AnyAttr:$attr, Optional<I32>:$a, Optional<I32>:$b)>;
// Test optional attribute followed by two optional groups with guarded colons.
def ValidTypeB : TestFormat_Op<[{
(`(` $attr^ ` `)? (`(` $a^ `:` type($a) `)`) : (`foo` `:`)? ` ` attr-dict
(`(` $b^ `:` type($b) `)`) : (`foo` `:`)? ` ` `(` `:`
}], [AttrSizedOperandSegments]>,
Arguments<(ins OptionalAttr<AnyAttr>:$attr, Optional<I32>:$a,
Optional<I32>:$b)>;
// Test optional attribute guarded colon along within segment.
def ValidTypeC : TestFormat_Op<[{
(`(` $attr^ `)`) : (`:`)? attr-dict `:`
}]>, Arguments<(ins OptionalAttr<AnyAttr>:$attr)>;
// Test optional group guard blocks colon.
def ValidTypeD : TestFormat_Op<[{
$a attr-dict ($c^ `:`)?
}]>, Arguments<(ins AnyAttr:$a, Optional<I32>:$c)>;
|