1 // RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -verify-diagnostics | FileCheck %s
2 // Verify that extensible dialects can register dynamic operations and types.
4 //===----------------------------------------------------------------------===//
6 //===----------------------------------------------------------------------===//
8 // CHECK-LABEL: func @succeededDynamicTypeVerifier
9 func.func @succeededDynamicTypeVerifier() {
10 // CHECK: %{{.*}} = "unregistered_op"() : () -> !test.dynamic_singleton
11 "unregistered_op"() : () -> !test.dynamic_singleton
12 // CHECK-NEXT: "unregistered_op"() : () -> !test.dynamic_pair<i32, f64>
13 "unregistered_op"() : () -> !test.dynamic_pair<i32, f64>
14 // CHECK-NEXT: %{{.*}} = "unregistered_op"() : () -> !test.dynamic_pair<!test.dynamic_pair<i32, f64>, !test.dynamic_singleton>
15 "unregistered_op"() : () -> !test.dynamic_pair<!test.dynamic_pair<i32, f64>, !test.dynamic_singleton>
21 func.func @failedDynamicTypeVerifier() {
22 // expected-error@+1 {{expected 0 type arguments, but had 1}}
23 "unregistered_op"() : () -> !test.dynamic_singleton<f64>
29 func.func @failedDynamicTypeVerifier2() {
30 // expected-error@+1 {{expected 2 type arguments, but had 1}}
31 "unregistered_op"() : () -> !test.dynamic_pair<f64>
37 // CHECK-LABEL: func @customTypeParserPrinter
38 func.func @customTypeParserPrinter() {
39 // CHECK: "unregistered_op"() : () -> !test.dynamic_custom_assembly_format<f32:f64>
40 "unregistered_op"() : () -> !test.dynamic_custom_assembly_format<f32 : f64>
46 //===----------------------------------------------------------------------===//
48 //===----------------------------------------------------------------------===//
50 // CHECK-LABEL: func @succeededDynamicAttributeVerifier
51 func.func @succeededDynamicAttributeVerifier() {
52 // CHECK: "unregistered_op"() {test_attr = #test.dynamic_singleton} : () -> ()
53 "unregistered_op"() {test_attr = #test.dynamic_singleton} : () -> ()
54 // CHECK-NEXT: "unregistered_op"() {test_attr = #test.dynamic_pair<3 : i32, 5 : i32>} : () -> ()
55 "unregistered_op"() {test_attr = #test.dynamic_pair<3 : i32, 5 : i32>} : () -> ()
56 // CHECK-NEXT: "unregistered_op"() {test_attr = #test.dynamic_pair<#test.dynamic_pair<3 : i32, 5 : i32>, f64>} : () -> ()
57 "unregistered_op"() {test_attr = #test.dynamic_pair<#test.dynamic_pair<3 : i32, 5 : i32>, f64>} : () -> ()
63 func.func @failedDynamicAttributeVerifier() {
64 // expected-error@+1 {{expected 0 attribute arguments, but had 1}}
65 "unregistered_op"() {test_attr = #test.dynamic_singleton<f64>} : () -> ()
71 func.func @failedDynamicAttributeVerifier2() {
72 // expected-error@+1 {{expected 2 attribute arguments, but had 1}}
73 "unregistered_op"() {test_attr = #test.dynamic_pair<f64>} : () -> ()
79 // CHECK-LABEL: func @customAttributeParserPrinter
80 func.func @customAttributeParserPrinter() {
81 // CHECK: "unregistered_op"() {test_attr = #test.dynamic_custom_assembly_format<f32:f64>} : () -> ()
82 "unregistered_op"() {test_attr = #test.dynamic_custom_assembly_format<f32:f64>} : () -> ()
86 //===----------------------------------------------------------------------===//
88 //===----------------------------------------------------------------------===//
92 // CHECK-LABEL: func @succeededDynamicOpVerifier
93 func.func @succeededDynamicOpVerifier(%a: f32) {
94 // CHECK: "test.dynamic_generic"() : () -> ()
95 // CHECK-NEXT: %{{.*}} = "test.dynamic_generic"(%{{.*}}) : (f32) -> f64
96 // CHECK-NEXT: %{{.*}}:2 = "test.dynamic_one_operand_two_results"(%{{.*}}) : (f32) -> (f64, f64)
97 "test.dynamic_generic"() : () -> ()
98 "test.dynamic_generic"(%a) : (f32) -> f64
99 "test.dynamic_one_operand_two_results"(%a) : (f32) -> (f64, f64)
105 func.func @failedDynamicOpVerifier() {
106 // expected-error@+1 {{expected 1 operand, but had 0}}
107 "test.dynamic_one_operand_two_results"() : () -> (f64, f64)
113 func.func @failedDynamicOpVerifier2(%a: f32) {
114 // expected-error@+1 {{expected 2 results, but had 0}}
115 "test.dynamic_one_operand_two_results"(%a) : (f32) -> ()
121 // CHECK-LABEL: func @customOpParserPrinter
122 func.func @customOpParserPrinter() {
123 // CHECK: test.dynamic_custom_parser_printer custom_keyword
124 test.dynamic_custom_parser_printer custom_keyword
128 //===----------------------------------------------------------------------===//
130 //===----------------------------------------------------------------------===//
134 // Check that the verifier of a dynamic operation in a dynamic dialect
135 // can fail. This shows that the dialect is correctly registered.
137 func.func @failedDynamicDialectOpVerifier() {
138 // expected-error@+1 {{expected a single result, no operands and no regions}}
139 "test_dyn.one_result"() : () -> ()