CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
52 lines
3.2 KiB
Plaintext
52 lines
3.2 KiB
Plaintext
// Test hlfir.get_length code generation
|
|
// RUN: fir-opt %s --bufferize-hlfir | FileCheck %s
|
|
|
|
func.func @_QPtest_char_get_length(%arg0: !fir.boxchar<1> {fir.bindc_name = "ch"}) -> index {
|
|
%c3 = arith.constant 3 : index
|
|
%0:2 = fir.unboxchar %arg0 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
|
|
%1:2 = hlfir.declare %0#0 typeparams %0#1 {uniq_name = "_QFtest_char_get_lengthEch"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
|
|
%2 = fir.alloca i32 {bindc_name = "x", uniq_name = "_QFtest_char_get_lengthEx"}
|
|
%3:2 = hlfir.declare %2 {uniq_name = "_QFtest_char_get_lengthEx"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)
|
|
%4 = fir.address_of(@_QQclX616263) : !fir.ref<!fir.char<1,3>>
|
|
%5:2 = hlfir.declare %4 typeparams %c3 {fortran_attrs = #fir.var_attrs<parameter>, uniq_name = "_QQclX616263"} : (!fir.ref<!fir.char<1,3>>, index) -> (!fir.ref<!fir.char<1,3>>, !fir.ref<!fir.char<1,3>>)
|
|
%6 = arith.addi %0#1, %c3 : index
|
|
%7 = hlfir.concat %5#0, %1#0 len %6 : (!fir.ref<!fir.char<1,3>>, !fir.boxchar<1>, index) -> !hlfir.expr<!fir.char<1,?>>
|
|
%8:3 = hlfir.associate %7 typeparams %6 {uniq_name = ".tmp.assign"} : (!hlfir.expr<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>, i1)
|
|
%9 = hlfir.as_expr %8#0 : (!fir.boxchar<1>) -> !hlfir.expr<!fir.char<1,?>>
|
|
%10 = hlfir.get_length %9 : (!hlfir.expr<!fir.char<1,?>>) -> index
|
|
hlfir.destroy %9 : !hlfir.expr<!fir.char<1,?>>
|
|
hlfir.end_associate %8#1, %8#2 : !fir.ref<!fir.char<1,?>>, i1
|
|
return %10 : index
|
|
}
|
|
fir.global linkonce @_QQclX616263 constant : !fir.char<1,3> {
|
|
%0 = fir.string_lit "abc"(3) : !fir.char<1,3>
|
|
fir.has_value %0 : !fir.char<1,3>
|
|
}
|
|
// CHECK-LABEL: func.func @_QPtest_char_get_length(
|
|
// CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1> {fir.bindc_name = "ch"}) -> index {
|
|
// CHECK: %[[VAL_1:.*]] = arith.constant 3 : index
|
|
// CHECK: %[[VAL_2:.*]]:2 = fir.unboxchar %[[VAL_0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
|
|
// CHECK: %[[VAL_9:.*]] = arith.addi %[[VAL_1]], %[[VAL_2]]#1 : index
|
|
// CHECK: %[[VAL_33:.*]]:2 = hlfir.declare %[[VAL_31:.*]] typeparams %[[VAL_9]] {uniq_name = ".tmp"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
|
|
// CHECK: return %[[VAL_9]] : index
|
|
// CHECK: }
|
|
|
|
// Test get_length taking the length from an expression with i32 length parameter.
|
|
func.func @i32_length(%char: !fir.boxchar<1>, %shape : i32, %len : i32) -> index {
|
|
%14 = fir.shape %shape : (i32) -> !fir.shape<1>
|
|
%15 = hlfir.elemental %14 typeparams %len unordered : (!fir.shape<1>, i32) -> !hlfir.expr<?x!fir.char<1,?>> {
|
|
^bb0(%arg0: index):
|
|
hlfir.yield_element %char : !fir.boxchar<1>
|
|
}
|
|
%18 = hlfir.get_length %15 : (!hlfir.expr<?x!fir.char<1,?>>) -> index
|
|
hlfir.destroy %15 : !hlfir.expr<?x!fir.char<1,?>>
|
|
return %18 : index
|
|
}
|
|
// CHECK-LABEL: func.func @i32_length(
|
|
// CHECK-SAME: %[[VAL_0:.*]]: !fir.boxchar<1>,
|
|
// CHECK-SAME: %[[VAL_1:.*]]: i32,
|
|
// CHECK-SAME: %[[VAL_2:.*]]: i32) -> index {
|
|
// CHECK: %[[VAL_14:.*]] = fir.convert %[[VAL_2]] : (i32) -> index
|
|
// CHECK: return %[[VAL_14]] : index
|
|
// CHECK: }
|