1 // Test hlfir.count operation lowering with different default integer kinds.
2 // RUN: fir-opt %s -lower-hlfir-intrinsics | FileCheck %s
4 module attributes {fir.defaultkind = "a1c4d8i8l4r4", fir.kindmap = ""} {
5 func.func @test_i8(%arg0: !fir.box<!fir.array<?x?x!fir.logical<4>>> {fir.bindc_name = "x"}, %arg1: i64) -> !hlfir.expr<?xi64> {
6 %4 = hlfir.count %arg0 dim %arg1 : (!fir.box<!fir.array<?x?x!fir.logical<4>>>, i64) -> !hlfir.expr<?xi64>
7 return %4 : !hlfir.expr<?xi64>
10 // CHECK-LABEL: func.func @test_i8
11 // CHECK: %[[KIND:.*]] = arith.constant 8 : i32
12 // CHECK: fir.call @_FortranACountDim(%{{.*}}, %{{.*}}, %{{.*}}, %[[KIND]], %{{.*}}, %{{.*}}) : (!fir.ref<!fir.box<none>>, !fir.box<none>, i32, i32, !fir.ref<i8>, i32) -> ()
14 module attributes {fir.defaultkind = "a1c4d8i4l4r4", fir.kindmap = ""} {
15 func.func @test_i4(%arg0: !fir.box<!fir.array<?x?x!fir.logical<4>>> {fir.bindc_name = "x"}, %arg1: i64) -> !hlfir.expr<?xi32> {
16 %4 = hlfir.count %arg0 dim %arg1 : (!fir.box<!fir.array<?x?x!fir.logical<4>>>, i64) -> !hlfir.expr<?xi32>
17 return %4 : !hlfir.expr<?xi32>
20 // CHECK-LABEL: func.func @test_i4
21 // CHECK: %[[KIND:.*]] = arith.constant 4 : i32
22 // CHECK: fir.call @_FortranACountDim(%{{.*}}, %{{.*}}, %{{.*}}, %[[KIND]], %{{.*}}, %{{.*}}) : (!fir.ref<!fir.box<none>>, !fir.box<none>, i32, i32, !fir.ref<i8>, i32) -> ()
24 module attributes {fir.defaultkind = "a1c4d8i2l4r4", fir.kindmap = ""} {
25 func.func @test_i2(%arg0: !fir.box<!fir.array<?x?x!fir.logical<4>>> {fir.bindc_name = "x"}, %arg1: i64) -> !hlfir.expr<?xi16> {
26 %4 = hlfir.count %arg0 dim %arg1 : (!fir.box<!fir.array<?x?x!fir.logical<4>>>, i64) -> !hlfir.expr<?xi16>
27 return %4 : !hlfir.expr<?xi16>
30 // CHECK-LABEL: func.func @test_i2
31 // CHECK: %[[KIND:.*]] = arith.constant 2 : i32
32 // CHECK: fir.call @_FortranACountDim(%{{.*}}, %{{.*}}, %{{.*}}, %[[KIND]], %{{.*}}, %{{.*}}) : (!fir.ref<!fir.box<none>>, !fir.box<none>, i32, i32, !fir.ref<i8>, i32) -> ()
34 module attributes {fir.defaultkind = "a1c4d8i1l4r4", fir.kindmap = ""} {
35 func.func @test_i1(%arg0: !fir.box<!fir.array<?x?x!fir.logical<4>>> {fir.bindc_name = "x"}, %arg1: i64) -> !hlfir.expr<?xi8> {
36 %4 = hlfir.count %arg0 dim %arg1 : (!fir.box<!fir.array<?x?x!fir.logical<4>>>, i64) -> !hlfir.expr<?xi8>
37 return %4 : !hlfir.expr<?xi8>
40 // CHECK-LABEL: func.func @test_i1
41 // CHECK: %[[KIND:.*]] = arith.constant 1 : i32
42 // CHECK: fir.call @_FortranACountDim(%{{.*}}, %{{.*}}, %{{.*}}, %[[KIND]], %{{.*}}, %{{.*}}) : (!fir.ref<!fir.box<none>>, !fir.box<none>, i32, i32, !fir.ref<i8>, i32) -> ()