brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.1 KiB · 4385446 Raw
160 lines · c
1/*===-- lib/runtime/complex-reduction.h -----------------------------*- C -*-===2 *3 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4 * See https://llvm.org/LICENSE.txt for license information.5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6 *7 *===----------------------------------------------------------------------===*/8 9/* Wraps the C++-coded complex-valued SUM and PRODUCT reductions with10 * C-coded wrapper functions returning _Complex values, to avoid problems11 * with C++ build compilers that don't support C's _Complex.12 */13 14#ifndef FLANG_RT_RUNTIME_COMPLEX_REDUCTION_H_15#define FLANG_RT_RUNTIME_COMPLEX_REDUCTION_H_16 17#include "flang/Common/float128.h"18#include "flang/Runtime/entry-names.h"19#include <complex.h>20#include <stdbool.h>21 22struct CppDescriptor; /* dummy type name for Fortran::runtime::Descriptor */23 24#if defined(_MSC_VER) && !(defined(__clang_major__) && __clang_major__ >= 12)25typedef _Fcomplex float_Complex_t;26typedef _Dcomplex double_Complex_t;27typedef _Lcomplex long_double_Complex_t;28#else29typedef float _Complex float_Complex_t;30typedef double _Complex double_Complex_t;31typedef long double _Complex long_double_Complex_t;32#endif33 34#define REDUCTION_ARGS \35  const struct CppDescriptor *x, const char *source, int line, int dim /*=0*/, \36      const struct CppDescriptor *mask /*=NULL*/37#define REDUCTION_ARG_NAMES x, source, line, dim, mask38 39float_Complex_t RTNAME(SumComplex2)(REDUCTION_ARGS);40float_Complex_t RTNAME(SumComplex3)(REDUCTION_ARGS);41float_Complex_t RTNAME(SumComplex4)(REDUCTION_ARGS);42double_Complex_t RTNAME(SumComplex8)(REDUCTION_ARGS);43long_double_Complex_t RTNAME(SumComplex10)(REDUCTION_ARGS);44#if HAS_LDBL128 || HAS_FLOAT12845CFloat128ComplexType RTNAME(SumComplex16)(REDUCTION_ARGS);46#endif47 48float_Complex_t RTNAME(ProductComplex2)(REDUCTION_ARGS);49float_Complex_t RTNAME(ProductComplex3)(REDUCTION_ARGS);50float_Complex_t RTNAME(ProductComplex4)(REDUCTION_ARGS);51double_Complex_t RTNAME(ProductComplex8)(REDUCTION_ARGS);52long_double_Complex_t RTNAME(ProductComplex10)(REDUCTION_ARGS);53#if HAS_LDBL128 || HAS_FLOAT12854CFloat128ComplexType RTNAME(ProductComplex16)(REDUCTION_ARGS);55#endif56 57#define DOT_PRODUCT_ARGS \58  const struct CppDescriptor *x, const struct CppDescriptor *y, \59      const char *source, int line, int dim /*=0*/, \60      const struct CppDescriptor *mask /*=NULL*/61#define DOT_PRODUCT_ARG_NAMES x, y, source, line, dim, mask62 63float_Complex_t RTNAME(DotProductComplex2)(DOT_PRODUCT_ARGS);64float_Complex_t RTNAME(DotProductComplex3)(DOT_PRODUCT_ARGS);65float_Complex_t RTNAME(DotProductComplex4)(DOT_PRODUCT_ARGS);66double_Complex_t RTNAME(DotProductComplex8)(DOT_PRODUCT_ARGS);67long_double_Complex_t RTNAME(DotProductComplex10)(DOT_PRODUCT_ARGS);68#if HAS_LDBL128 || HAS_FLOAT12869CFloat128ComplexType RTNAME(DotProductComplex16)(DOT_PRODUCT_ARGS);70#endif71 72#define REDUCE_ARGS(T, OP) \73  OP operation, const struct CppDescriptor *x, const struct CppDescriptor *y, \74      const char *source, int line, int dim /*=0*/, \75      const struct CppDescriptor *mask /*=NULL*/, const T *identity /*=NULL*/, \76      _Bool ordered /*=true*/77#define REDUCE_ARG_NAMES \78  operation, x, y, source, line, dim, mask, identity, ordered79 80typedef float_Complex_t (*float_Complex_t_ref_op)(81    const float_Complex_t *, const float_Complex_t *);82typedef float_Complex_t (*float_Complex_t_value_op)(83    float_Complex_t, float_Complex_t);84typedef double_Complex_t (*double_Complex_t_ref_op)(85    const double_Complex_t *, const double_Complex_t *);86typedef double_Complex_t (*double_Complex_t_value_op)(87    double_Complex_t, double_Complex_t);88typedef long_double_Complex_t (*long_double_Complex_t_ref_op)(89    const long_double_Complex_t *, const long_double_Complex_t *);90typedef long_double_Complex_t (*long_double_Complex_t_value_op)(91    long_double_Complex_t, long_double_Complex_t);92 93float_Complex_t RTNAME(ReduceComplex2Ref)(94    REDUCE_ARGS(float_Complex_t, float_Complex_t_ref_op));95float_Complex_t RTNAME(ReduceComplex2Value)(96    REDUCE_ARGS(float_Complex_t, float_Complex_t_value_op));97float_Complex_t RTNAME(ReduceComplex3Ref)(98    REDUCE_ARGS(float_Complex_t, float_Complex_t_ref_op));99float_Complex_t RTNAME(ReduceComplex3Value)(100    REDUCE_ARGS(float_Complex_t, float_Complex_t_value_op));101float_Complex_t RTNAME(ReduceComplex4Ref)(102    REDUCE_ARGS(float_Complex_t, float_Complex_t_ref_op));103float_Complex_t RTNAME(ReduceComplex4Value)(104    REDUCE_ARGS(float_Complex_t, float_Complex_t_value_op));105double_Complex_t RTNAME(ReduceComplex8Ref)(106    REDUCE_ARGS(double_Complex_t, double_Complex_t_ref_op));107double_Complex_t RTNAME(ReduceComplex8Value)(108    REDUCE_ARGS(double_Complex_t, double_Complex_t_value_op));109long_double_Complex_t RTNAME(ReduceComplex10Ref)(110    REDUCE_ARGS(long_double_Complex_t, long_double_Complex_t_ref_op));111long_double_Complex_t RTNAME(ReduceComplex10Value)(112    REDUCE_ARGS(long_double_Complex_t, long_double_Complex_t_value_op));113#if HAS_LDBL128 || HAS_FLOAT128114typedef CFloat128ComplexType (*CFloat128ComplexType_ref_op)(115    const CFloat128ComplexType *, const CFloat128ComplexType *);116typedef CFloat128ComplexType (*CFloat128ComplexType_value_op)(117    CFloat128ComplexType, CFloat128ComplexType);118CFloat128ComplexType RTNAME(ReduceComplex16Ref)(119    REDUCE_ARGS(CFloat128ComplexType, CFloat128ComplexType_ref_op));120CFloat128ComplexType RTNAME(ReduceComplex16Value)(121    REDUCE_ARGS(CFloat128ComplexType, CFloat128ComplexType_value_op));122#endif123 124#define REDUCE_DIM_ARGS(T, OP) \125  struct CppDescriptor *result, OP operation, const struct CppDescriptor *x, \126      const struct CppDescriptor *y, const char *source, int line, int dim, \127      const struct CppDescriptor *mask /*=NULL*/, const T *identity /*=NULL*/, \128      _Bool ordered /*=true*/129#define REDUCE_DIM_ARG_NAMES \130  result, operation, x, y, source, line, dim, mask, identity, ordered131 132void RTNAME(ReduceComplex2DimRef)(133    REDUCE_DIM_ARGS(float_Complex_t, float_Complex_t_ref_op));134void RTNAME(ReduceComplex2DimValue)(135    REDUCE_DIM_ARGS(float_Complex_t, float_Complex_t_value_op));136void RTNAME(ReduceComplex3DimRef)(137    REDUCE_DIM_ARGS(float_Complex_t, float_Complex_t_ref_op));138void RTNAME(ReduceComplex3DimValue)(139    REDUCE_DIM_ARGS(float_Complex_t, float_Complex_t_value_op));140void RTNAME(ReduceComplex4DimRef)(141    REDUCE_DIM_ARGS(float_Complex_t, float_Complex_t_ref_op));142void RTNAME(ReduceComplex4DimValue)(143    REDUCE_DIM_ARGS(float_Complex_t, float_Complex_t_value_op));144void RTNAME(ReduceComplex8DimRef)(145    REDUCE_DIM_ARGS(double_Complex_t, double_Complex_t_ref_op));146void RTNAME(ReduceComplex8DimValue)(147    REDUCE_DIM_ARGS(double_Complex_t, double_Complex_t_value_op));148void RTNAME(ReduceComplex10DimRef)(149    REDUCE_DIM_ARGS(long_double_Complex_t, long_double_Complex_t_ref_op));150void RTNAME(ReduceComplex10DimValue)(151    REDUCE_DIM_ARGS(long_double_Complex_t, long_double_Complex_t_value_op));152#if HAS_LDBL128 || HAS_FLOAT128153void RTNAME(ReduceComplex16DimRef)(154    REDUCE_DIM_ARGS(CFloat128ComplexType, CFloat128ComplexType_ref_op));155void RTNAME(ReduceComplex16DimValue)(156    REDUCE_DIM_ARGS(CFloat128ComplexType, CFloat128ComplexType_value_op));157#endif158 159#endif // FLANG_RT_RUNTIME_COMPLEX_REDUCTION_H_160