Files
TheRock/compiler/amd-llvm/flang/test/Lower/Intrinsics/ichar.f90
T
derek.holloway 7502bf64a4
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
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

51 lines
2.7 KiB
Fortran
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s
! CHECK-LABEL: func.func @_QPichar_test(
! CHECK-SAME: %[[ARG0:.*]]: !fir.boxchar<1> {fir.bindc_name = "c"}) {
subroutine ichar_test(c)
character(1) :: c
character :: str(10)
! CHECK-DAG: %[[UNBOX:.*]]:2 = fir.unboxchar %[[ARG0]]
! CHECK-DAG: %[[CONV:.*]] = fir.convert %[[UNBOX]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.char<1>>
! CHECK-DAG: %[[C_DECL:.*]]:2 = hlfir.declare %[[CONV]] typeparams {{.*}} dummy_scope %{{.*}} arg 1 {uniq_name = "_QFichar_testEc"}
! CHECK-DAG: %[[J_ALLOC:.*]] = fir.alloca i32 {bindc_name = "j", uniq_name = "_QFichar_testEj"}
! CHECK-DAG: %[[J_DECL:.*]]:2 = hlfir.declare %[[J_ALLOC]] {uniq_name = "_QFichar_testEj"}
! CHECK-DAG: %[[STR_ALLOC:.*]] = fir.alloca !fir.array<10x!fir.char<1>> {bindc_name = "str", uniq_name = "_QFichar_testEstr"}
! CHECK-DAG: %[[STR_DECL:.*]]:2 = hlfir.declare %[[STR_ALLOC]]({{.*}}) typeparams {{.*}} {uniq_name = "_QFichar_testEstr"}
! CHECK: %[[C_VAL:.*]] = fir.load %[[C_DECL]]#0 : !fir.ref<!fir.char<1>>
! CHECK: %[[CHAR:.*]] = fir.extract_value %[[C_VAL]], [0 : index] : (!fir.char<1>) -> i8
! CHECK: %[[ARG:.*]] = arith.extui %[[CHAR]] : i8 to i32
! CHECK: fir.call @_FortranAioOutputInteger32({{.*}}, %[[ARG]])
! CHECK: fir.call @_FortranAioEndIoStatement
print *, ichar(c)
! CHECK: %[[J_VAL:.*]] = fir.load %[[J_DECL]]#0 : !fir.ref<i32>
! CHECK: %[[J_IDX:.*]] = fir.convert %[[J_VAL]] : (i32) -> i64
! CHECK: %[[STR_EL:.*]] = hlfir.designate %[[STR_DECL]]#0 (%[[J_IDX]]) typeparams {{.*}} : (!fir.ref<!fir.array<10x!fir.char<1>>>, i64, index) -> !fir.ref<!fir.char<1>>
! CHECK: %[[STR_VAL:.*]] = fir.load %[[STR_EL]] : !fir.ref<!fir.char<1>>
! CHECK: %[[CHAR2:.*]] = fir.extract_value %[[STR_VAL]], [0 : index] : (!fir.char<1>) -> i8
! CHECK: %[[ARG2:.*]] = arith.extui %[[CHAR2]] : i8 to i32
! CHECK: fir.call @_FortranAioOutputInteger32({{.*}}, %[[ARG2]])
! CHECK: fir.call @_FortranAioEndIoStatement
print *, ichar(str(J))
! "Magic" 88 below is the ASCII code for `X` and the value returned by IACHAR (’X’)
! CHECK: %[[c88:.*]] = arith.constant 88 : i32
! CHECK: fir.call @_FortranAioOutputInteger32({{.*}}, %[[c88]])
! CHECK: fir.call @_FortranAioEndIoStatement
print *, iachar('X')
end subroutine
! Check that 'arith.extui' op is not generated if type are matching.
! CHECK-LABEL: func.func @_QPno_extui(
subroutine no_extui(ch)
integer, parameter :: kind = selected_char_kind('ISO_10646')
character(*, kind), intent(in) :: ch(:)
integer :: i, j
! CHECK-NOT: arith.extui
! CHECK: %[[CHAR4:.*]] = fir.extract_value {{.*}}, [0 : index] : (!fir.char<4>) -> i32
! CHECK: hlfir.assign %[[CHAR4]] to {{.*}} : i32, !fir.ref<i32>
j = ichar(ch(i)(i:i))
end subroutine