[flang-commits] [flang] [flang][runtime] Runtime support for REDUCE() (PR #86214)

via flang-commits flang-commits at lists.llvm.org
Fri Mar 22 02:17:22 PDT 2024


================
@@ -0,0 +1,254 @@
+//===-- include/flang/Runtime/reduce.h --------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// Defines the API for implementations of the transformational intrinsic
+// functionREDUCE(); see F'2023 16.9.173.
+//
+// Similar to the definition of the APIs for SUM(), &c., in reduction.h,
+// there are typed functions here like ReduceInteger4() for total reductions
+// to scalars and void functions like ReduceInteger4Dim() for partial
+// reductions to smaller arrays.
+
+#ifndef FORTRAN_RUNTIME_REDUCE_H_
+#define FORTRAN_RUNTIME_REDUCE_H_
+
+#include "flang/Common/float128.h"
+#include "flang/Common/uint128.h"
+#include "flang/Runtime/cpp-type.h"
+#include "flang/Runtime/entry-names.h"
+#include <complex>
+#include <cstdint>
+
+namespace Fortran::runtime {
+
+class Descriptor;
+
+template <typename T> using ReductionOperation = T (*)(const T *, const T *);
+template <typename CHAR>
+using ReductionCharOperation = void (*)(CHAR *hiddenResult, const CHAR *x,
----------------
jeanPerier wrote:

Thanks Slava for catching this. I mislead Peter here. You are right, result length is always the second argument and is not trailing. Only character arguments length are trailing.

This matches the F77 ABI "convention" (ifort, gfortran, nvfortran all handle character results like this).

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


More information about the flang-commits mailing list