Files
TheRock/compiler/amd-llvm/mlir/test/mlir-tblgen/op-format-verify.td
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

167 lines
7.2 KiB
TableGen

// 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)>;