1// RUN: mlir-opt --test-data-layout-query %s | FileCheck %s 2 3// CHECK-LABEL: @no_layout_builtin 4func.func @no_layout_builtin() { 5 // CHECK: alignment = 4 6 // CHECK: bitsize = 32 7 // CHECK: index = 0 8 // CHECK: preferred = 4 9 // CHECK: size = 4 10 "test.data_layout_query"() : () -> i32 11 // CHECK: alignment = 8 12 // CHECK: bitsize = 64 13 // CHECK: index = 0 14 // CHECK: preferred = 8 15 // CHECK: size = 8 16 "test.data_layout_query"() : () -> f64 17 // CHECK: alignment = 4 18 // CHECK: bitsize = 64 19 // CHECK: index = 0 20 // CHECK: preferred = 4 21 // CHECK: size = 8 22 "test.data_layout_query"() : () -> complex<f32> 23 // CHECK: alignment = 1 24 // CHECK: bitsize = 14 25 // CHECK: index = 0 26 // CHECK: preferred = 1 27 // CHECK: size = 2 28 "test.data_layout_query"() : () -> complex<i6> 29 // CHECK: alignment = 4 30 // CHECK: bitsize = 64 31 // CHECK: index = 64 32 // CHECK: preferred = 8 33 // CHECK: size = 8 34 "test.data_layout_query"() : () -> index 35 // CHECK: alignment = 16 36 // CHECK: bitsize = 128 37 // CHECK: index = 0 38 // CHECK: preferred = 16 39 // CHECK: size = 16 40 "test.data_layout_query"() : () -> vector<4xi32> 41 // CHECK: alignment = 16 42 // CHECK: bitsize = {minimal_size = 128 : index, scalable} 43 // CHECK: index = 0 44 // CHECK: preferred = 16 45 // CHECK: size = {minimal_size = 16 : index, scalable} 46 "test.data_layout_query"() : () -> vector<[4]xi32> 47 return 48 49} 50 51// CHECK-LABEL: @no_layout_custom 52func.func @no_layout_custom() { 53 // CHECK: alignment = 1 54 // CHECK: bitsize = 1 55 // CHECK: index = 1 56 // CHECK: preferred = 1 57 // CHECK: size = 1 58 "test.data_layout_query"() : () -> !test.test_type_with_layout<10> 59 return 60} 61 62// CHECK-LABEL: @layout_op_no_layout 63func.func @layout_op_no_layout() { 64 "test.op_with_data_layout"() ({ 65 // CHECK: alignment = 1 66 // CHECK: bitsize = 1 67 // CHECK: index = 1 68 // CHECK: preferred = 1 69 // CHECK: size = 1 70 "test.data_layout_query"() : () -> !test.test_type_with_layout<1000> 71 "test.maybe_terminator"() : () -> () 72 }) : () -> () 73 return 74} 75 76// CHECK-LABEL: @layout_op 77func.func @layout_op() { 78 "test.op_with_data_layout"() ({ 79 // CHECK: alignment = 20 80 // CHECK: bitsize = 10 81 // CHECK: index = 30 82 // CHECK: preferred = 1 83 // CHECK: size = 2 84 "test.data_layout_query"() : () -> !test.test_type_with_layout<10> 85 "test.maybe_terminator"() : () -> () 86 }) { dlti.dl_spec = #dlti.dl_spec< 87 #dlti.dl_entry<!test.test_type_with_layout<10>, ["size", 10]>, 88 #dlti.dl_entry<!test.test_type_with_layout<20>, ["alignment", 20]>, 89 #dlti.dl_entry<!test.test_type_with_layout<30>, ["index", 30]> 90 >} : () -> () 91 return 92} 93 94// Make sure the outer op with layout may be missing the spec. 95// CHECK-LABEL: @nested_inner_only 96func.func @nested_inner_only() { 97 "test.op_with_data_layout"() ({ 98 "test.op_with_data_layout"() ({ 99 // CHECK: alignment = 20 100 // CHECK: bitsize = 10 101 // CHECK: index = 30 102 // CHECK: preferred = 1 103 // CHECK: size = 2 104 "test.data_layout_query"() : () -> !test.test_type_with_layout<10> 105 "test.maybe_terminator"() : () -> () 106 }) { dlti.dl_spec = #dlti.dl_spec< 107 #dlti.dl_entry<!test.test_type_with_layout<10>, ["size", 10]>, 108 #dlti.dl_entry<!test.test_type_with_layout<20>, ["alignment", 20]>, 109 #dlti.dl_entry<!test.test_type_with_layout<30>, ["index", 30]> 110 >} : () -> () 111 "test.maybe_terminator"() : () -> () 112 }) : () -> () 113 return 114} 115 116// Make sure the inner op with layout may be missing the spec. 117// CHECK-LABEL: @nested_outer_only 118func.func @nested_outer_only() { 119 "test.op_with_data_layout"() ({ 120 "test.op_with_data_layout"() ({ 121 // CHECK: alignment = 20 122 // CHECK: bitsize = 10 123 // CHECK: index = 30 124 // CHECK: preferred = 1 125 // CHECK: size = 2 126 "test.data_layout_query"() : () -> !test.test_type_with_layout<10> 127 "test.maybe_terminator"() : () -> () 128 }) : () -> () 129 "test.maybe_terminator"() : () -> () 130 }) { dlti.dl_spec = #dlti.dl_spec< 131 #dlti.dl_entry<!test.test_type_with_layout<10>, ["size", 10]>, 132 #dlti.dl_entry<!test.test_type_with_layout<20>, ["alignment", 20]>, 133 #dlti.dl_entry<!test.test_type_with_layout<30>, ["index", 30]> 134 >} : () -> () 135 return 136} 137 138// CHECK-LABEL: @nested_middle_only 139func.func @nested_middle_only() { 140 "test.op_with_data_layout"() ({ 141 "test.op_with_data_layout"() ({ 142 "test.op_with_data_layout"() ({ 143 // CHECK: alignment = 20 144 // CHECK: bitsize = 10 145 // CHECK: index = 30 146 // CHECK: preferred = 1 147 // CHECK: size = 2 148 "test.data_layout_query"() : () -> !test.test_type_with_layout<10> 149 "test.maybe_terminator"() : () -> () 150 }) : () -> () 151 "test.maybe_terminator"() : () -> () 152 }) { dlti.dl_spec = #dlti.dl_spec< 153 #dlti.dl_entry<!test.test_type_with_layout<10>, ["size", 10]>, 154 #dlti.dl_entry<!test.test_type_with_layout<20>, ["alignment", 20]>, 155 #dlti.dl_entry<!test.test_type_with_layout<30>, ["index", 30]> 156 >} : () -> () 157 "test.maybe_terminator"() : () -> () 158 }) : () -> () 159 return 160} 161 162// CHECK-LABEL: @nested_combine_with_missing 163func.func @nested_combine_with_missing() { 164 "test.op_with_data_layout"() ({ 165 "test.op_with_data_layout"() ({ 166 "test.op_with_data_layout"() ({ 167 // CHECK: alignment = 20 168 // CHECK: bitsize = 10 169 // CHECK: index = 21 170 // CHECK: preferred = 30 171 // CHECK: size = 2 172 "test.data_layout_query"() : () -> !test.test_type_with_layout<10> 173 "test.maybe_terminator"() : () -> () 174 }) : () -> () 175 "test.maybe_terminator"() : () -> () 176 }) { dlti.dl_spec = #dlti.dl_spec< 177 #dlti.dl_entry<!test.test_type_with_layout<10>, ["size", 10]>, 178 #dlti.dl_entry<!test.test_type_with_layout<20>, ["alignment", 20]> 179 >} : () -> () 180 // CHECK: alignment = 1 181 // CHECK: bitsize = 42 182 // CHECK: index = 21 183 // CHECK: preferred = 30 184 // CHECK: size = 6 185 "test.data_layout_query"() : () -> !test.test_type_with_layout<10> 186 "test.maybe_terminator"() : () -> () 187 }) { dlti.dl_spec = #dlti.dl_spec< 188 #dlti.dl_entry<!test.test_type_with_layout<10>, ["size", 42]>, 189 #dlti.dl_entry<!test.test_type_with_layout<30>, ["preferred", 30]>, 190 #dlti.dl_entry<!test.test_type_with_layout<40>, ["index", 21]> 191 >}: () -> () 192 return 193} 194 195// CHECK-LABEL: @nested_combine_all 196func.func @nested_combine_all() { 197 "test.op_with_data_layout"() ({ 198 "test.op_with_data_layout"() ({ 199 "test.op_with_data_layout"() ({ 200 // CHECK: alignment = 20 201 // CHECK: bitsize = 3 202 // CHECK: index = 40 203 // CHECK: preferred = 30 204 // CHECK: size = 1 205 "test.data_layout_query"() : () -> !test.test_type_with_layout<10> 206 "test.maybe_terminator"() : () -> () 207 }) { dlti.dl_spec = #dlti.dl_spec< 208 #dlti.dl_entry<!test.test_type_with_layout<10>, ["size", 3]>, 209 #dlti.dl_entry<!test.test_type_with_layout<30>, ["preferred", 30]> 210 >} : () -> () 211 // CHECK: alignment = 20 212 // CHECK: bitsize = 10 213 // CHECK: index = 40 214 // CHECK: preferred = 30 215 // CHECK: size = 2 216 "test.data_layout_query"() : () -> !test.test_type_with_layout<10> 217 "test.maybe_terminator"() : () -> () 218 }) { dlti.dl_spec = #dlti.dl_spec< 219 #dlti.dl_entry<!test.test_type_with_layout<10>, ["size", 10]>, 220 #dlti.dl_entry<!test.test_type_with_layout<20>, ["alignment", 20]>, 221 #dlti.dl_entry<!test.test_type_with_layout<40>, ["index", 40]> 222 >} : () -> () 223 // CHECK: alignment = 1 224 // CHECK: bitsize = 42 225 // CHECK: index = 1 226 // CHECK: preferred = 30 227 // CHECK: size = 6 228 "test.data_layout_query"() : () -> !test.test_type_with_layout<10> 229 "test.maybe_terminator"() : () -> () 230 }) { dlti.dl_spec = #dlti.dl_spec< 231 #dlti.dl_entry<!test.test_type_with_layout<10>, ["size", 42]>, 232 #dlti.dl_entry<!test.test_type_with_layout<30>, ["preferred", 30]> 233 >}: () -> () 234 return 235} 236 237// CHECK-LABEL: @integers 238func.func @integers() { 239 "test.op_with_data_layout"() ({ 240 // CHECK: alignment = 8 241 // CHECK: bitsize = 32 242 // CHECK: index = 0 243 // CHECK: preferred = 8 244 "test.data_layout_query"() : () -> i32 245 // CHECK: alignment = 16 246 // CHECK: bitsize = 56 247 // CHECK: index = 0 248 // CHECK: preferred = 16 249 "test.data_layout_query"() : () -> i56 250 // CHECK: alignment = 16 251 // CHECK: bitsize = 64 252 // CHECK: index = 0 253 // CHECK: preferred = 16 254 "test.data_layout_query"() : () -> i64 255 // CHECK: alignment = 16 256 // CHECK: bitsize = 128 257 // CHECK: index = 0 258 // CHECK: preferred = 16 259 "test.data_layout_query"() : () -> i128 260 "test.maybe_terminator"() : () -> () 261 }) { dlti.dl_spec = #dlti.dl_spec< 262 #dlti.dl_entry<i32, dense<64> : vector<1xi64>>, 263 #dlti.dl_entry<i64, dense<128> : vector<1xi64>> 264 >} : () -> () 265 "test.op_with_data_layout"() ({ 266 // CHECK: alignment = 8 267 // CHECK: bitsize = 32 268 // CHECK: index = 0 269 // CHECK: preferred = 16 270 "test.data_layout_query"() : () -> i32 271 // CHECK: alignment = 16 272 // CHECK: bitsize = 56 273 // CHECK: index = 0 274 // CHECK: preferred = 32 275 "test.data_layout_query"() : () -> i56 276 // CHECK: alignment = 16 277 // CHECK: bitsize = 64 278 // CHECK: index = 0 279 // CHECK: preferred = 32 280 "test.data_layout_query"() : () -> i64 281 // CHECK: alignment = 16 282 // CHECK: bitsize = 128 283 // CHECK: index = 0 284 // CHECK: preferred = 32 285 "test.data_layout_query"() : () -> i128 286 "test.maybe_terminator"() : () -> () 287 }) { dlti.dl_spec = #dlti.dl_spec< 288 #dlti.dl_entry<i32, dense<[64, 128]> : vector<2xi64>>, 289 #dlti.dl_entry<i64, dense<[128, 256]> : vector<2xi64>> 290 >} : () -> () 291 return 292} 293 294func.func @floats() { 295 "test.op_with_data_layout"() ({ 296 // CHECK: alignment = 8 297 // CHECK: bitsize = 32 298 // CHECK: index = 0 299 // CHECK: preferred = 8 300 "test.data_layout_query"() : () -> f32 301 // CHECK: alignment = 16 302 // CHECK: bitsize = 80 303 // CHECK: index = 0 304 // CHECK: preferred = 16 305 "test.data_layout_query"() : () -> f80 306 "test.maybe_terminator"() : () -> () 307 }) { dlti.dl_spec = #dlti.dl_spec< 308 #dlti.dl_entry<f32, dense<64> : vector<1xi64>>, 309 #dlti.dl_entry<f80, dense<128> : vector<1xi64>> 310 >} : () -> () 311 "test.op_with_data_layout"() ({ 312 // CHECK: alignment = 8 313 // CHECK: bitsize = 32 314 // CHECK: index = 0 315 // CHECK: preferred = 16 316 "test.data_layout_query"() : () -> f32 317 // CHECK: alignment = 16 318 // CHECK: bitsize = 80 319 // CHECK: index = 0 320 // CHECK: preferred = 32 321 "test.data_layout_query"() : () -> f80 322 "test.maybe_terminator"() : () -> () 323 }) { dlti.dl_spec = #dlti.dl_spec< 324 #dlti.dl_entry<f32, dense<[64, 128]> : vector<2xi64>>, 325 #dlti.dl_entry<f80, dense<[128, 256]> : vector<2xi64>> 326 >} : () -> () 327 return 328} 329