1// RUN: mlir-opt --test-data-layout-query %s | FileCheck %s 2 3// CHECK-LABEL: @no_layout_builtin 4func @no_layout_builtin() { 5 // CHECK: alignment = 4 6 // CHECK: bitsize = 32 7 // CHECK: preferred = 4 8 // CHECK: size = 4 9 "test.data_layout_query"() : () -> i32 10 // CHECK: alignment = 8 11 // CHECK: bitsize = 64 12 // CHECK: preferred = 8 13 // CHECK: size = 8 14 "test.data_layout_query"() : () -> f64 15 return 16} 17 18// CHECK-LABEL: @no_layout_custom 19func @no_layout_custom() { 20 // CHECK: alignment = 1 21 // CHECK: bitsize = 1 22 // CHECK: preferred = 1 23 // CHECK: size = 1 24 "test.data_layout_query"() : () -> !test.test_type_with_layout<10> 25 return 26} 27 28// CHECK-LABEL: @layout_op_no_layout 29func @layout_op_no_layout() { 30 "test.op_with_data_layout"() ({ 31 // CHECK: alignment = 1 32 // CHECK: bitsize = 1 33 // CHECK: preferred = 1 34 // CHECK: size = 1 35 "test.data_layout_query"() : () -> !test.test_type_with_layout<1000> 36 "test.maybe_terminator"() : () -> () 37 }) : () -> () 38 return 39} 40 41// CHECK-LABEL: @layout_op 42func @layout_op() { 43 "test.op_with_data_layout"() ({ 44 // CHECK: alignment = 20 45 // CHECK: bitsize = 10 46 // CHECK: preferred = 1 47 // CHECK: size = 2 48 "test.data_layout_query"() : () -> !test.test_type_with_layout<10> 49 "test.maybe_terminator"() : () -> () 50 }) { dlti.dl_spec = #dlti.dl_spec< 51 #dlti.dl_entry<!test.test_type_with_layout<10>, ["size", 10]>, 52 #dlti.dl_entry<!test.test_type_with_layout<20>, ["alignment", 20]> 53 >} : () -> () 54 return 55} 56 57// Make sure the outer op with layout may be missing the spec. 58// CHECK-LABEL: @nested_inner_only 59func @nested_inner_only() { 60 "test.op_with_data_layout"() ({ 61 "test.op_with_data_layout"() ({ 62 // CHECK: alignment = 20 63 // CHECK: bitsize = 10 64 // CHECK: preferred = 1 65 // CHECK: size = 2 66 "test.data_layout_query"() : () -> !test.test_type_with_layout<10> 67 "test.maybe_terminator"() : () -> () 68 }) { dlti.dl_spec = #dlti.dl_spec< 69 #dlti.dl_entry<!test.test_type_with_layout<10>, ["size", 10]>, 70 #dlti.dl_entry<!test.test_type_with_layout<20>, ["alignment", 20]> 71 >} : () -> () 72 "test.maybe_terminator"() : () -> () 73 }) : () -> () 74 return 75} 76 77// Make sure the inner op with layout may be missing the spec. 78// CHECK-LABEL: @nested_outer_only 79func @nested_outer_only() { 80 "test.op_with_data_layout"() ({ 81 "test.op_with_data_layout"() ({ 82 // CHECK: alignment = 20 83 // CHECK: bitsize = 10 84 // CHECK: preferred = 1 85 // CHECK: size = 2 86 "test.data_layout_query"() : () -> !test.test_type_with_layout<10> 87 "test.maybe_terminator"() : () -> () 88 }) : () -> () 89 "test.maybe_terminator"() : () -> () 90 }) { dlti.dl_spec = #dlti.dl_spec< 91 #dlti.dl_entry<!test.test_type_with_layout<10>, ["size", 10]>, 92 #dlti.dl_entry<!test.test_type_with_layout<20>, ["alignment", 20]> 93 >} : () -> () 94 return 95} 96 97// CHECK-LABEL: @nested_middle_only 98func @nested_middle_only() { 99 "test.op_with_data_layout"() ({ 100 "test.op_with_data_layout"() ({ 101 "test.op_with_data_layout"() ({ 102 // CHECK: alignment = 20 103 // CHECK: bitsize = 10 104 // CHECK: preferred = 1 105 // CHECK: size = 2 106 "test.data_layout_query"() : () -> !test.test_type_with_layout<10> 107 "test.maybe_terminator"() : () -> () 108 }) : () -> () 109 "test.maybe_terminator"() : () -> () 110 }) { dlti.dl_spec = #dlti.dl_spec< 111 #dlti.dl_entry<!test.test_type_with_layout<10>, ["size", 10]>, 112 #dlti.dl_entry<!test.test_type_with_layout<20>, ["alignment", 20]> 113 >} : () -> () 114 "test.maybe_terminator"() : () -> () 115 }) : () -> () 116 return 117} 118 119// CHECK-LABEL: @nested_combine_with_missing 120func @nested_combine_with_missing() { 121 "test.op_with_data_layout"() ({ 122 "test.op_with_data_layout"() ({ 123 "test.op_with_data_layout"() ({ 124 // CHECK: alignment = 20 125 // CHECK: bitsize = 10 126 // CHECK: preferred = 30 127 // CHECK: size = 2 128 "test.data_layout_query"() : () -> !test.test_type_with_layout<10> 129 "test.maybe_terminator"() : () -> () 130 }) : () -> () 131 "test.maybe_terminator"() : () -> () 132 }) { dlti.dl_spec = #dlti.dl_spec< 133 #dlti.dl_entry<!test.test_type_with_layout<10>, ["size", 10]>, 134 #dlti.dl_entry<!test.test_type_with_layout<20>, ["alignment", 20]> 135 >} : () -> () 136 // CHECK: alignment = 1 137 // CHECK: bitsize = 42 138 // CHECK: preferred = 30 139 // CHECK: size = 6 140 "test.data_layout_query"() : () -> !test.test_type_with_layout<10> 141 "test.maybe_terminator"() : () -> () 142 }) { dlti.dl_spec = #dlti.dl_spec< 143 #dlti.dl_entry<!test.test_type_with_layout<10>, ["size", 42]>, 144 #dlti.dl_entry<!test.test_type_with_layout<30>, ["preferred", 30]> 145 >}: () -> () 146 return 147} 148 149// CHECK-LABEL: @nested_combine_all 150func @nested_combine_all() { 151 "test.op_with_data_layout"() ({ 152 "test.op_with_data_layout"() ({ 153 "test.op_with_data_layout"() ({ 154 // CHECK: alignment = 20 155 // CHECK: bitsize = 3 156 // CHECK: preferred = 30 157 // CHECK: size = 1 158 "test.data_layout_query"() : () -> !test.test_type_with_layout<10> 159 "test.maybe_terminator"() : () -> () 160 }) { dlti.dl_spec = #dlti.dl_spec< 161 #dlti.dl_entry<!test.test_type_with_layout<10>, ["size", 3]>, 162 #dlti.dl_entry<!test.test_type_with_layout<30>, ["preferred", 30]> 163 >} : () -> () 164 // CHECK: alignment = 20 165 // CHECK: bitsize = 10 166 // CHECK: preferred = 30 167 // CHECK: size = 2 168 "test.data_layout_query"() : () -> !test.test_type_with_layout<10> 169 "test.maybe_terminator"() : () -> () 170 }) { dlti.dl_spec = #dlti.dl_spec< 171 #dlti.dl_entry<!test.test_type_with_layout<10>, ["size", 10]>, 172 #dlti.dl_entry<!test.test_type_with_layout<20>, ["alignment", 20]> 173 >} : () -> () 174 // CHECK: alignment = 1 175 // CHECK: bitsize = 42 176 // CHECK: preferred = 30 177 // CHECK: size = 6 178 "test.data_layout_query"() : () -> !test.test_type_with_layout<10> 179 "test.maybe_terminator"() : () -> () 180 }) { dlti.dl_spec = #dlti.dl_spec< 181 #dlti.dl_entry<!test.test_type_with_layout<10>, ["size", 42]>, 182 #dlti.dl_entry<!test.test_type_with_layout<30>, ["preferred", 30]> 183 >}: () -> () 184 return 185} 186