On Sat, Jul 19, 2025 at 12:08:44AM +0800, Yuao Ma wrote: > Hi Tobias, > > On 7/18/2025 3:16 PM, Tobias Burnus wrote: > > I am wondering whether we should implement it – for kind=1 (and at > > least for set len=1) by a call to BUILT_IN_MEMCHR / BUILT_IN_MEMRCHR. > > For set len > 1, a loop around it has to be generated, and for kind=4, > > it could be implemented manual walk of the array elements (+ another > > loop for set len > 1). > > I don't have a strong opinion on whether split/tokenize should be > implemented as compiler intrinsics.
This makes no sense to me. If gfortran is going to support Fortran 2023, then there is no option. It must supply the intrinsics subprograms. > It seems LLVM's Flang maintainers also > believe these functions belong in a vendor support library rather than being > compiler intrinsics. The runtime library is part of the compiler. > Either way, I've already learned a lot about adding procedure intrinsics to > gfortran from working on the split patch! If we decide not to implement > these, should we at least add a replacement recommendation to the intrinsic > documentation? These must be implemented. There seems to be some confusion. There are three situations to consider: 1. Some intrinsics subprograms are in-lined by the compiler, so a function call to a routine in the run-time is not necessary. 2. Some functions exist only in the run-time, and a function call is always generated. 3. Some functions are a hybred. The fortran FE will massage the arguments to generate a function to a help functions. These typically convert integer(1) and integer(2) to integer(4) and handle the necessary conversions in-line. SPLIT is in the last class. There is one routine for CHARACTER(kind=1) and one for CHARACTER(kind=4). The POS is an INTENT(INOUT) argument as converted to an appropriate int on entry into the library routine and then converted back the INTEGER kind of the actual argument on return. BACK is an INTENT(IN) LOGICAL argument, all possible LOGICAL kind values are evaluated and converted to an appropriate bool type for the library. -- steve Steve