13#ifndef FORTRAN_LOWER_REDUCTIONPROCESSOR_H
14#define FORTRAN_LOWER_REDUCTIONPROCESSOR_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;
33class AbstractConverter;
44 enum ReductionIdentifier {
61 static ReductionIdentifier
62 getReductionType(
const omp::clause::ProcedureDesignator &pd);
64 static ReductionIdentifier
65 getReductionType(omp::clause::DefinedOperator::IntrinsicOperator intrinsicOp);
68 supportedIntrinsicProcReduction(
const omp::clause::ProcedureDesignator &pd);
74 getRealName(
const omp::clause::ProcedureDesignator &pd);
76 static std::string getReductionName(llvm::StringRef name,
78 mlir::Type ty,
bool isByRef);
81 getReductionName(omp::clause::DefinedOperator::IntrinsicOperator intrinsicOp,
92 static mlir::Value getReductionInitValue(mlir::Location loc, mlir::Type type,
93 ReductionIdentifier redId,
96 template <
typename FloatOp,
typename IntegerOp>
98 mlir::Type type, mlir::Location loc,
99 mlir::Value op1, mlir::Value op2);
100 template <
typename FloatOp,
typename IntegerOp,
typename ComplexOp>
102 mlir::Type type, mlir::Location loc,
103 mlir::Value op1, mlir::Value op2);
107 ReductionIdentifier redId,
108 mlir::Type type, mlir::Value op1,
115 static mlir::omp::DeclareReductionOp
117 llvm::StringRef reductionOpName,
118 const ReductionIdentifier redId, mlir::Type type,
119 mlir::Location loc,
bool isByRef);
125 const omp::clause::Reduction &reduction,
126 llvm::SmallVectorImpl<mlir::Value> &reductionVars,
127 llvm::SmallVectorImpl<bool> &reduceVarByRef,
128 llvm::SmallVectorImpl<mlir::Attribute> &reductionDeclSymbols,
129 llvm::SmallVectorImpl<const semantics::Symbol *> &reductionSymbols);
132template <
typename FloatOp,
typename IntegerOp>
135 mlir::Type type, mlir::Location loc,
136 mlir::Value op1, mlir::Value op2) {
137 type = fir::unwrapRefType(type);
138 assert(type.isIntOrIndexOrFloat() &&
139 "only integer, float and complex types are currently supported");
140 if (type.isIntOrIndex())
141 return builder.create<IntegerOp>(loc, op1, op2);
142 return builder.create<FloatOp>(loc, op1, op2);
145template <
typename FloatOp,
typename IntegerOp,
typename ComplexOp>
148 mlir::Type type, mlir::Location loc,
149 mlir::Value op1, mlir::Value op2) {
151 "only integer, float and complex types are currently supported");
152 if (type.isIntOrIndex())
153 return builder.create<IntegerOp>(loc, op1, op2);
155 return builder.create<FloatOp>(loc, op1, op2);
156 return builder.create<ComplexOp>(loc, op1, op2);
Definition: AbstractConverter.h:82
Definition: ReductionProcessor.h:41
static void addDeclareReduction(mlir::Location currentLocation, lower::AbstractConverter &converter, const omp::clause::Reduction &reduction, llvm::SmallVectorImpl< mlir::Value > &reductionVars, llvm::SmallVectorImpl< bool > &reduceVarByRef, llvm::SmallVectorImpl< mlir::Attribute > &reductionDeclSymbols, llvm::SmallVectorImpl< const semantics::Symbol * > &reductionSymbols)
Definition: ReductionProcessor.cpp:517
static mlir::omp::DeclareReductionOp createDeclareReduction(fir::FirOpBuilder &builder, llvm::StringRef reductionOpName, const ReductionIdentifier redId, mlir::Type type, mlir::Location loc, bool isByRef)
Definition: ReductionProcessor.cpp:468
static int getOperationIdentity(ReductionIdentifier redId, mlir::Location loc)
Definition: ReductionProcessor.cpp:665
Definition: char-block.h:28
Definition: FIRBuilder.h:55
Definition: KindMapping.h:48
Definition: bit-population-count.h:20
bool isa_complex(mlir::Type t)
Is t a floating point complex type?
Definition: FIRType.h:184
bool isa_real(mlir::Type t)
Is t a real type?
Definition: FIRType.h:163
Definition: AbstractConverter.h:27