brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.8 KiB · 8da9109 Raw
93 lines · plain
1// RUN: mlir-opt -allow-unregistered-dialect -test-legalize-patterns="test-legalize-mode=full" -split-input-file -verify-diagnostics %s | FileCheck %s2 3// CHECK-LABEL: func @multi_level_mapping4func.func @multi_level_mapping() {5  // CHECK: "test.type_producer"() : () -> f646  // CHECK: "test.type_consumer"(%{{.*}}) : (f64) -> ()7  %result = "test.type_producer"() : () -> i328  "test.type_consumer"(%result) : (i32) -> ()9  "test.return"() : () -> ()10}11 12// -----13 14// Test that operations that are erased don't need to be legalized.15// CHECK-LABEL: func @dropped_region_with_illegal_ops16func.func @dropped_region_with_illegal_ops() {17  // CHECK-NEXT: test.return18  "test.drop_region_op"() ({19    %ignored = "test.illegal_op_f"() : () -> (i32)20    "test.return"() : () -> ()21  }) : () -> ()22  "test.return"() : () -> ()23}24 25// -----26 27// CHECK-LABEL: func @replace_non_root_illegal_op28func.func @replace_non_root_illegal_op() {29  // CHECK-NEXT: "test.legal_op_b"30  // CHECK-NEXT: test.return31  %result = "test.replace_non_root"() : () -> (i32)32  "test.return"() : () -> ()33}34 35// -----36 37// Test that children of recursively legal operations are ignored.38 39// CHECK-LABEL: func @recursively_legal_invalid_op40func.func @recursively_legal_invalid_op() {41  /// Operation that is statically legal.42  builtin.module attributes {test.recursively_legal} {43    // CHECK: "test.illegal_op_f"44    %ignored = "test.illegal_op_f"() : () -> (i32)45  }46  /// Operation that is dynamically legal, i.e. the function has a pattern47  /// applied to legalize the argument type before it becomes recursively legal.48  builtin.module {49    // CHECK: func @dynamic_func(%{{.*}}: f64)50    func.func @dynamic_func(%arg: i64) attributes {test.recursively_legal} {51      // CHECK: "test.illegal_op_f"52      %ignored = "test.illegal_op_f"() : () -> (i32)53      "test.return"() : () -> ()54    }55  }56 57  "test.return"() : () -> ()58}59 60// -----61 62// expected-remark@+1 {{applyFullConversion failed}}63builtin.module {64 65  // Test that unknown operations can be dynamically legal.66  func.func @test_unknown_dynamically_legal() {67    "foo.unknown_op"() {test.dynamically_legal} : () -> ()68 69    // expected-error@+1 {{failed to legalize operation 'foo.unknown_op'}}70    "foo.unknown_op"() {} : () -> ()71    "test.return"() : () -> ()72  }73 74}75 76// -----77 78// The region of "test.post_order_legalization" is converted before the op.79 80// expected-remark@+1 {{applyFullConversion failed}}81builtin.module {82func.func @test_preorder_legalization() {83  // expected-error@+1 {{failed to legalize operation 'test.post_order_legalization'}}84  "test.post_order_legalization"() ({85  ^bb0(%arg0: i64):86    // Not-explicitly-legal ops are not allowed to survive.87    "test.remaining_consumer"(%arg0) : (i64) -> ()88    "test.invalid"(%arg0) : (i64) -> ()89  }) : () -> ()90  return91}92}93