Files
TheRock/compiler/amd-llvm/flang/test/HLFIR/region-assign.fir
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

88 lines
4.2 KiB
Plaintext

// Test hlfir.region_assign and hlfir.yield operation parse, verify (no errors),
// and unparse.
// RUN: fir-opt %s | fir-opt | FileCheck %s
func.func @region_assign_test(%y : !fir.box<!fir.array<?xi64>>, %x: !fir.box<!fir.array<?xf32>>) {
%c100 = arith.constant 100 : index
%shape = fir.shape %c100 : (index) -> !fir.shape<1>
hlfir.region_assign {
%expr = hlfir.elemental %shape : (!fir.shape<1>) -> !hlfir.expr<?xf32> {
^bb0(%i : index):
%yelt = hlfir.designate %y(%i) : (!fir.box<!fir.array<?xi64>>, index) -> !fir.ref<i64>
%elt = fir.call @some_elemental(%yelt) : (!fir.ref<i64>) -> f32
hlfir.yield_element %elt : f32
}
hlfir.yield %expr : !hlfir.expr<?xf32>
} to {
hlfir.yield %x : !fir.box<!fir.array<?xf32>>
}
return
}
// CHECK-LABEL: func.func @region_assign_test(
// CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xi64>>,
// CHECK-SAME: %[[VAL_1:.*]]: !fir.box<!fir.array<?xf32>>) {
// CHECK: %[[VAL_2:.*]] = arith.constant 100 : index
// CHECK: %[[VAL_3:.*]] = fir.shape %[[VAL_2]] : (index) -> !fir.shape<1>
// CHECK: hlfir.region_assign {
// CHECK: %[[VAL_4:.*]] = hlfir.elemental %[[VAL_3]] : (!fir.shape<1>) -> !hlfir.expr<?xf32> {
// CHECK: ^bb0(%[[VAL_5:.*]]: index):
// CHECK: %[[VAL_6:.*]] = hlfir.designate %[[VAL_0]] (%[[VAL_5]]) : (!fir.box<!fir.array<?xi64>>, index) -> !fir.ref<i64>
// CHECK: %[[VAL_7:.*]] = fir.call @some_elemental(%[[VAL_6]]) : (!fir.ref<i64>) -> f32
// CHECK: hlfir.yield_element %[[VAL_7]] : f32
// CHECK: }
// CHECK: hlfir.yield %[[VAL_8:.*]] : !hlfir.expr<?xf32>
// CHECK: } to {
// CHECK: hlfir.yield %[[VAL_1]] : !fir.box<!fir.array<?xf32>>
// CHECK: }
func.func @region_user_assign_test(%y : !fir.box<!fir.array<?xi64>>, %x: !fir.box<!fir.array<?xf32>>) {
hlfir.region_assign {
hlfir.yield %y : !fir.box<!fir.array<?xi64>>
} to {
hlfir.yield %x : !fir.box<!fir.array<?xf32>>
} user_defined_assign (%rhs : !fir.ref<i64>) to (%lhs : !fir.ref<f32>) {
%0 = fir.load %rhs : !fir.ref<i64>
fir.call @user_assign(%lhs, %0) : (!fir.ref<f32>, i64) -> ()
}
return
}
// CHECK-LABEL: func.func @region_user_assign_test(
// CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xi64>>,
// CHECK-SAME: %[[VAL_1:.*]]: !fir.box<!fir.array<?xf32>>) {
// CHECK: hlfir.region_assign {
// CHECK: hlfir.yield %[[VAL_0]] : !fir.box<!fir.array<?xi64>>
// CHECK: } to {
// CHECK: hlfir.yield %[[VAL_1]] : !fir.box<!fir.array<?xf32>>
// CHECK: } user_defined_assign (%[[VAL_2:.*]]: !fir.ref<i64>) to (%[[VAL_3:.*]]: !fir.ref<f32>) {
// CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_2]] : !fir.ref<i64>
// CHECK: fir.call @user_assign(%[[VAL_3]], %[[VAL_4]]) : (!fir.ref<f32>, i64) -> ()
// CHECK: }
func.func @yield_cleanup(%x: !fir.box<!fir.array<?xf32>>) {
hlfir.region_assign {
%0 = fir.allocmem !fir.array<100xf32>
fir.call @fillin_some_values(%0) : (!fir.heap<!fir.array<100xf32>>) -> ()
hlfir.yield %0 : !fir.heap<!fir.array<100xf32>> cleanup {
fir.freemem %0 : !fir.heap<!fir.array<100xf32>>
}
} to {
hlfir.yield %x : !fir.box<!fir.array<?xf32>>
}
return
}
// CHECK-LABEL: func.func @yield_cleanup(
// CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?xf32>>) {
// CHECK: hlfir.region_assign {
// CHECK: %[[VAL_1:.*]] = fir.allocmem !fir.array<100xf32>
// CHECK: fir.call @fillin_some_values(%[[VAL_1]]) : (!fir.heap<!fir.array<100xf32>>) -> ()
// CHECK: hlfir.yield %[[VAL_1]] : !fir.heap<!fir.array<100xf32>> cleanup {
// CHECK: fir.freemem %[[VAL_1]] : !fir.heap<!fir.array<100xf32>>
// CHECK: }
// CHECK: } to {
// CHECK: hlfir.yield %[[VAL_0]] : !fir.box<!fir.array<?xf32>>
// CHECK: }
func.func private @user_assign(!fir.ref<f32>, i64) -> ()
func.func private @some_elemental(!fir.ref<i64>) -> f32
func.func private @fillin_some_values(!fir.heap<!fir.array<100xf32>>) -> ()