[flang] [llvm] [flang] Implement SPLIT intrinsic subroutine with tests (PR #185584)

via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 10 11:58:44 PDT 2026


================
@@ -992,6 +992,56 @@ static RT_API_ATTRS void TokenizePositionsImpl(Descriptor &first,
   }
 }
 
+// SPLIT - scans for the next separator character in STRING.
+// When BACK is false (or absent), returns the position of the leftmost
+// character in SET whose position in STRING is greater than POS, or
+// LEN(STRING)+1 if no such character exists.
+// When BACK is true, returns the position of the rightmost character in
+// SET whose position in STRING is less than POS, or 0 if no such
+// character exists.
+template <typename CHAR>
+static RT_API_ATTRS std::size_t SplitImpl(const CHAR *string,
+    std::size_t stringLen, const CHAR *set, std::size_t setLen, std::size_t pos,
+    bool back) {
+  if (back) {
----------------
laoshd wrote:

I might not understand that well. Do you mean one implementation for both forward and backward, or one implementation for both SPLIT and SCAN, or both of these?

https://github.com/llvm/llvm-project/pull/185584


More information about the llvm-commits mailing list