llvm-project
45 строк · 2.3 Кб
1// RUN: tco %s | FileCheck %s
2
3func.func @array_coor_box_value(%29 : !fir.box<!fir.array<2xf64>>,
4%33 : index) -> f64 {
5%34 = fir.array_coor %29 %33 : (!fir.box<!fir.array<2xf64>>, index) ->
6!fir.ref<f64>
7%35 = fir.load %34 : !fir.ref<f64>
8return %35 : f64
9}
10
11// CHECK-LABEL: define double @array_coor_box_value
12// CHECK: %[[t3:.*]] = sub nsw i64 %{{.*}}, 1
13// CHECK: %[[t4:.*]] = mul nsw i64 %[[t3]], 1
14// CHECK: %[[t5:.*]] = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %{{.*}}, i32 0, i32 7, i32 0, i32 2
15// CHECK: %[[t6:.*]] = load i64, ptr %[[t5]]
16// CHECK: %[[t7:.*]] = mul nsw i64 %[[t4]], %[[t6]]
17// CHECK: %[[t8:.*]] = add nsw i64 %[[t7]], 0
18// CHECK: %[[t9:.*]] = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %{{.*}}, i32 0, i32 0
19// CHECK: %[[t10:.*]] = load ptr, ptr %[[t9]]
20// CHECK: %[[t11:.*]] = getelementptr i8, ptr %[[t10]], i64 %[[t8]]
21// CHECK: %[[t12:.*]] = load double, ptr %[[t11]]
22// CHECK: ret double %[[t12]]
23
24func.func @test_array_coor_box_component_slice(%arg0: !fir.box<!fir.array<2x!fir.type<t{i:i32,j:i32}>>>) {
25%c2 = arith.constant 2 : index
26%c1 = arith.constant 1 : index
27%0 = fir.field_index j, !fir.type<t{i:i32,j:i32}>
28%1 = fir.slice %c1, %c2, %c1 path %0 : (index, index, index, !fir.field) -> !fir.slice<1>
29%2 = fir.array_coor %arg0 [%1] %c2 : (!fir.box<!fir.array<2x!fir.type<t{i:i32,j:i32}>>>, !fir.slice<1>, index) -> !fir.ref<i32>
30fir.call @take_int(%2) : (!fir.ref<i32>) -> ()
31return
32}
33func.func private @take_int(%arg0: !fir.ref<i32>) -> ()
34
35// CHECK-LABEL: define void @test_array_coor_box_component_slice(
36// CHECK-SAME: ptr %[[VAL_0:.*]])
37// CHECK: %[[VAL_1:.*]] = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]], ptr, [1 x i64] }, ptr %[[VAL_0]], i32 0, i32 7, i32 0, i32 2
38// CHECK: %[[VAL_2:.*]] = load i64, ptr %[[VAL_1]]
39// CHECK: %[[VAL_3:.*]] = mul nsw i64 1, %[[VAL_2]]
40// CHECK: %[[VAL_4:.*]] = add nsw i64 %[[VAL_3]], 0
41// CHECK: %[[VAL_5:.*]] = getelementptr { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]], ptr, [1 x i64] }, ptr %[[VAL_0]], i32 0, i32 0
42// CHECK: %[[VAL_6:.*]] = load ptr, ptr %[[VAL_5]]
43// CHECK: %[[VAL_7:.*]] = getelementptr i8, ptr %[[VAL_6]], i64 %[[VAL_4]]
44// CHECK: %[[VAL_8:.*]] = getelementptr %t, ptr %[[VAL_7]], i32 0, i32 1
45// CHECK: call void @take_int(ptr %[[VAL_8]])
46