13#ifndef FORTRAN_LOWER_REDUCTIONPROCESSOR_H
14#define FORTRAN_LOWER_REDUCTIONPROCESSOR_H
16#include "flang/Lower/OpenMP/Clauses.h"
17#include "flang/Optimizer/Builder/FIRBuilder.h"
18#include "flang/Optimizer/Dialect/FIRType.h"
19#include "flang/Parser/parse-tree.h"
20#include "flang/Semantics/symbol.h"
21#include "flang/Semantics/type.h"
22#include "mlir/IR/Location.h"
23#include "mlir/IR/Types.h"
27class DeclareReductionOp;
44 enum ReductionIdentifier {
61 static ReductionIdentifier
62 getReductionType(
const omp::clause::ProcedureDesignator &pd);
64 static ReductionIdentifier
65 getReductionType(omp::clause::DefinedOperator::IntrinsicOperator intrinsicOp);
67 static ReductionIdentifier
68 getReductionType(
const fir::ReduceOperationEnum &pd);
71 supportedIntrinsicProcReduction(
const omp::clause::ProcedureDesignator &pd);
73 static const semantics::SourceName
76 static const semantics::SourceName
77 getRealName(
const omp::clause::ProcedureDesignator &pd);
79 static std::string getReductionName(llvm::StringRef name,
81 mlir::Type ty,
bool isByRef);
83 static std::string getReductionName(ReductionIdentifier redId,
85 mlir::Type ty,
bool isByRef);
94 static mlir::Value getReductionInitValue(mlir::Location loc, mlir::Type type,
95 ReductionIdentifier redId,
98 template <
typename FloatOp,
typename IntegerOp>
100 mlir::Type type, mlir::Location loc,
101 mlir::Value op1, mlir::Value op2);
102 template <
typename FloatOp,
typename IntegerOp,
typename ComplexOp>
104 mlir::Type type, mlir::Location loc,
105 mlir::Value op1, mlir::Value op2);
109 ReductionIdentifier redId,
110 mlir::Type type, mlir::Value op1,
117 template <
typename OpType>
119 llvm::StringRef reductionOpName,
120 const ReductionIdentifier redId,
121 mlir::Type type, mlir::Location loc,
126 template <
typename OpType,
typename RedOperatorListTy>
129 const RedOperatorListTy &redOperatorList,
130 llvm::SmallVectorImpl<mlir::Value> &reductionVars,
131 llvm::SmallVectorImpl<bool> &reduceVarByRef,
132 llvm::SmallVectorImpl<mlir::Attribute> &reductionDeclSymbols,
133 const llvm::SmallVectorImpl<const semantics::Symbol *> &reductionSymbols);
136template <
typename FloatOp,
typename IntegerOp>
139 mlir::Type type, mlir::Location loc,
140 mlir::Value op1, mlir::Value op2) {
141 type = fir::unwrapRefType(type);
142 assert(type.isIntOrIndexOrFloat() &&
143 "only integer, float and complex types are currently supported");
144 if (type.isIntOrIndex())
145 return IntegerOp::create(builder, loc, op1, op2);
146 return FloatOp::create(builder, loc, op1, op2);
149template <
typename FloatOp,
typename IntegerOp,
typename ComplexOp>
152 mlir::Type type, mlir::Location loc,
153 mlir::Value op1, mlir::Value op2) {
155 "only integer, float and complex types are currently supported");
156 if (type.isIntOrIndex())
157 return IntegerOp::create(builder, loc, op1, op2);
159 return FloatOp::create(builder, loc, op1, op2);
160 return ComplexOp::create(builder, loc, op1, op2);
Definition AbstractConverter.h:85
Definition ReductionProcessor.h:41
static int getOperationIdentity(ReductionIdentifier redId, mlir::Location loc)
Definition ReductionProcessor.cpp:782
static OpType createDeclareReduction(AbstractConverter &builder, llvm::StringRef reductionOpName, const ReductionIdentifier redId, mlir::Type type, mlir::Location loc, bool isByRef)
Definition ReductionProcessor.cpp:560
static bool processReductionArguments(mlir::Location currentLocation, lower::AbstractConverter &converter, const RedOperatorListTy &redOperatorList, llvm::SmallVectorImpl< mlir::Value > &reductionVars, llvm::SmallVectorImpl< bool > &reduceVarByRef, llvm::SmallVectorImpl< mlir::Attribute > &reductionDeclSymbols, const llvm::SmallVectorImpl< const semantics::Symbol * > &reductionSymbols)
Definition ReductionProcessor.cpp:610
Definition FIRBuilder.h:55
Definition KindMapping.h:48
Definition ParserActions.h:24
Definition bit-population-count.h:20
bool isa_complex(mlir::Type t)
Is t a floating point complex type?
Definition FIRType.h:203
bool isa_real(mlir::Type t)
Is t a real type?
Definition FIRType.h:182
Definition AbstractConverter.h:29