brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.8 KiB · cf03414 Raw
142 lines · plain
1// RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -verify-diagnostics | FileCheck %s2// Verify that extensible dialects can register dynamic operations and types.3 4//===----------------------------------------------------------------------===//5// Dynamic type6//===----------------------------------------------------------------------===//7 8// CHECK-LABEL: func @succeededDynamicTypeVerifier9func.func @succeededDynamicTypeVerifier() {10  // CHECK: %{{.*}} = "unregistered_op"() : () -> !test.dynamic_singleton11  "unregistered_op"() : () -> !test.dynamic_singleton12  // 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>16  return17}18 19// -----20 21func.func @failedDynamicTypeVerifier() {22  // expected-error@+1 {{expected 0 type arguments, but had 1}}23  "unregistered_op"() : () -> !test.dynamic_singleton<f64>24  return25}26 27// -----28 29func.func @failedDynamicTypeVerifier2() {30  // expected-error@+1 {{expected 2 type arguments, but had 1}}31  "unregistered_op"() : () -> !test.dynamic_pair<f64>32  return33}34 35// -----36 37// CHECK-LABEL: func @customTypeParserPrinter38func.func @customTypeParserPrinter() {39  // CHECK: "unregistered_op"() : () -> !test.dynamic_custom_assembly_format<f32:f64>40  "unregistered_op"() : () -> !test.dynamic_custom_assembly_format<f32 : f64>41  return42}43 44// -----45 46//===----------------------------------------------------------------------===//47// Dynamic attribute48//===----------------------------------------------------------------------===//49 50// CHECK-LABEL: func @succeededDynamicAttributeVerifier51func.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>} : () -> ()58  return59}60 61// -----62 63func.func @failedDynamicAttributeVerifier() {64  // expected-error@+1 {{expected 0 attribute arguments, but had 1}}65  "unregistered_op"() {test_attr = #test.dynamic_singleton<f64>} : () -> ()66  return67}68 69// -----70 71func.func @failedDynamicAttributeVerifier2() {72  // expected-error@+1 {{expected 2 attribute arguments, but had 1}}73  "unregistered_op"() {test_attr = #test.dynamic_pair<f64>} : () -> ()74  return75}76 77// -----78 79// CHECK-LABEL: func @customAttributeParserPrinter80func.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>} : () -> ()83  return84}85 86//===----------------------------------------------------------------------===//87// Dynamic op88//===----------------------------------------------------------------------===//89 90// -----91 92// CHECK-LABEL: func @succeededDynamicOpVerifier93func.func @succeededDynamicOpVerifier(%a: f32) {94  // CHECK: "test.dynamic_generic"() : () -> ()95  // CHECK-NEXT: %{{.*}} = "test.dynamic_generic"(%{{.*}}) : (f32) -> f6496  // CHECK-NEXT: %{{.*}}:2 = "test.dynamic_one_operand_two_results"(%{{.*}}) : (f32) -> (f64, f64)97  "test.dynamic_generic"() : () -> ()98  "test.dynamic_generic"(%a) : (f32) -> f6499  "test.dynamic_one_operand_two_results"(%a) : (f32) -> (f64, f64)100  return101}102 103// -----104 105func.func @failedDynamicOpVerifier() {106  // expected-error@+1 {{expected 1 operand, but had 0}}107  "test.dynamic_one_operand_two_results"() : () -> (f64, f64)108  return109}110 111// -----112 113func.func @failedDynamicOpVerifier2(%a: f32) {114  // expected-error@+1 {{expected 2 results, but had 0}}115  "test.dynamic_one_operand_two_results"(%a) : (f32) -> ()116  return117}118 119// -----120 121// CHECK-LABEL: func @customOpParserPrinter122func.func @customOpParserPrinter() {123  // CHECK: test.dynamic_custom_parser_printer custom_keyword124  test.dynamic_custom_parser_printer custom_keyword125  return126}127 128//===----------------------------------------------------------------------===//129// Dynamic dialect130//===----------------------------------------------------------------------===//131 132// -----133 134// Check that the verifier of a dynamic operation in a dynamic dialect135// can fail. This shows that the dialect is correctly registered.136 137func.func @failedDynamicDialectOpVerifier() {138  // expected-error@+1 {{expected a single result, no operands and no regions}}139  "test_dyn.one_result"() : () -> ()140  return141}142