[flang-commits] [flang] [llvm] [flang] Implement SPLIT intrinsic subroutine with tests (PR #185584)
Tarun Prabhu via flang-commits
flang-commits at lists.llvm.org
Tue Mar 10 06:59:37 PDT 2026
================
@@ -0,0 +1,37 @@
+! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s
+
+! CHECK-LABEL: split_basic
+subroutine split_basic()
+ implicit none
+ character(20) :: string
+ character(5) :: set
+ integer :: pos
+ string = "one,two,three"
+ set = ","
+ pos = 0
+ call split(string, set, pos)
+ ! CHECK: %[[BACK:.*]] = arith.constant false
+ ! CHECK: %[[POS:.*]] = fir.load %{{.*}} : !fir.ref<i32>
+ ! CHECK: %[[POS_IDX:.*]] = fir.convert %[[POS]] : (i32) -> index
+ ! CHECK: %[[STRING:.*]] = fir.convert %{{.*}} : (!fir.ref<!fir.char<1,20>>) -> !fir.ref<i8>
+ ! CHECK: %[[SET:.*]] = fir.convert %{{.*}} : (!fir.ref<!fir.char<1,5>>) -> !fir.ref<i8>
+ ! CHECK: %[[POS_I64:.*]] = fir.convert %[[POS_IDX]] : (index) -> i64
+ ! CHECK: %[[RESULT:.*]] = fir.call @_FortranASplit1(%[[STRING]], %{{.*}}, %[[SET]], %{{.*}}, %[[POS_I64]], %[[BACK]]) {{.*}} : (!fir.ref<i8>, i64, !fir.ref<i8>, i64, i64, i1) -> i64
+ ! CHECK: %[[RESULT_I32:.*]] = fir.convert %[[RESULT]] : (i64) -> i32
+ ! CHECK: fir.store %[[RESULT_I32]] to %{{.*}} : !fir.ref<i32>
+end subroutine split_basic
+
+! CHECK-LABEL: split_back
+subroutine split_back()
+ implicit none
+ character(20) :: string
+ character(5) :: set
+ integer :: pos
+ logical :: back
+ string = "one,two,three"
+ set = ","
+ pos = 14
+ back = .true.
+ call split(string, set, pos, back)
+ ! CHECK: fir.call @_FortranASplit1(
----------------
tarunprabhu wrote:
What is the purpose of this test? Is it to check that back is passed correctly to the runtime? If so, there is nothing here that is actually checking for that.
https://github.com/llvm/llvm-project/pull/185584
More information about the flang-commits
mailing list