[flang] [llvm] [flang] Implement SPLIT intrinsic subroutine with tests (PR #185584)
Tarun Prabhu via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 10 06:59:37 PDT 2026
================
@@ -8538,6 +8545,50 @@ void IntrinsicLibrary::genSleep(llvm::ArrayRef<fir::ExtendedValue> args) {
fir::runtime::genSleep(builder, loc, fir::getBase(args[0]));
}
+// SPLIT
+void IntrinsicLibrary::genSplit(llvm::ArrayRef<fir::ExtendedValue> args) {
+ assert(args.size() == 4 && "SPLIT requires 3 or 4 arguments");
+
+ // Handle required STRING base and length args
+ mlir::Value stringBase = fir::getBase(args[0]);
+ mlir::Value stringLen = fir::getLen(args[0]);
+
+ // Handle required SET string base and length args
+ mlir::Value setBase = fir::getBase(args[1]);
+ mlir::Value setLen = fir::getLen(args[1]);
+
+ // POS is INTENT(INOUT) - it's passed as an address
+ mlir::Value posAddr = fir::getBase(args[2]);
+
+ // Determine character kind
+ fir::KindTy kind =
+ fir::factory::CharacterExprHelper{builder, loc}.getCharacterKind(
+ stringBase.getType());
+
+ // Handle optional BACK argument
----------------
tarunprabhu wrote:
This is the one place where a comment would be helpful because an optional defaults to `.FALSE.` - something that is not obvious when one looks at the code.
https://github.com/llvm/llvm-project/pull/185584
More information about the llvm-commits
mailing list