diff --git a/flang/lib/Lower/IntrinsicCall.cpp b/flang/lib/Lower/IntrinsicCall.cpp --- a/flang/lib/Lower/IntrinsicCall.cpp +++ b/flang/lib/Lower/IntrinsicCall.cpp @@ -542,6 +542,7 @@ void genRandomInit(llvm::ArrayRef); void genRandomNumber(llvm::ArrayRef); void genRandomSeed(llvm::ArrayRef); + fir::ExtendedValue genReduce(mlir::Type, llvm::ArrayRef); fir::ExtendedValue genRepeat(mlir::Type, llvm::ArrayRef); fir::ExtendedValue genReshape(mlir::Type, llvm::ArrayRef); mlir::Value genRRSpacing(mlir::Type resultType, @@ -907,6 +908,15 @@ {"put", asBox, handleDynamicOptional}, {"get", asBox, handleDynamicOptional}}}, /*isElemental=*/false}, + {"reduce", + &I::genReduce, + {{{"array", asBox}, + {"operation", asAddr}, + {"dim", asValue}, + {"mask", asBox, handleDynamicOptional}, + {"identity", asValue}, + {"ordered", asValue}}}, + /*isElemental=*/false}, {"repeat", &I::genRepeat, {{{"string", asAddr}, {"ncopies", asValue}}}, @@ -3686,6 +3696,13 @@ Fortran::lower::genRandomSeed(builder, loc, size, put, get); } +// REDUCE +fir::ExtendedValue +IntrinsicLibrary::genReduce(mlir::Type resultType, + llvm::ArrayRef args) { + TODO(loc, "intrinsic: reduce"); +} + // REPEAT fir::ExtendedValue IntrinsicLibrary::genRepeat(mlir::Type resultType, diff --git a/flang/test/Lower/Intrinsics/Todo/reduce.f90 b/flang/test/Lower/Intrinsics/Todo/reduce.f90 new file mode 100644 --- /dev/null +++ b/flang/test/Lower/Intrinsics/Todo/reduce.f90 @@ -0,0 +1,13 @@ +! RUN: %not_todo_cmd bbc -emit-fir %s -o - 2>&1 | FileCheck %s + +interface + pure function chfunc(a,b) + character(*),intent(in) :: a,b + character(3) :: chfunc + end function + end interface + character(3) x(5) + print*, reduce(x,chfunc) +end program + +! CHECK: not yet implemented: intrinsic: reduce