FLANG
Fortran::lower::omp::ReductionProcessor Class Reference

Public Types

enum  ReductionIdentifier {
  ID , USER_DEF_OP , ADD , SUBTRACT ,
  MULTIPLY , AND , OR , EQV ,
  NEQV , MAX , MIN , IAND ,
  IOR , IEOR
}
using GenInitValueCBTy
using GenCombinerCBTy

Static Public Member Functions

static bool doReductionByRef (mlir::Type reductionType)
static bool doReductionByRef (mlir::Value reductionVar)
static ReductionIdentifier getReductionType (const omp::clause::ProcedureDesignator &pd)
static ReductionIdentifier getReductionType (omp::clause::DefinedOperator::IntrinsicOperator intrinsicOp)
static parser::DefinedOperator::IntrinsicOperator toParserIntrinsicOperator (omp::clause::DefinedOperator::IntrinsicOperator op)
static ReductionIdentifier getReductionType (const fir::ReduceOperationEnum &pd)
static bool supportedIntrinsicProcReduction (const omp::clause::ProcedureDesignator &pd)
static const semantics::SourceName getRealName (const semantics::Symbol *symbol)
static const semantics::SourceName getRealName (const omp::clause::ProcedureDesignator &pd)
static std::string getReductionName (llvm::StringRef name, const fir::KindMapping &kindMap, mlir::Type ty, bool isByRef)
static std::string getReductionName (ReductionIdentifier redId, const fir::KindMapping &kindMap, mlir::Type ty, bool isByRef)
static std::string getScopedUserReductionName (AbstractConverter &converter, const semantics::Symbol &reductionSymbol, mlir::Type reductionType, bool isByRef)
static int getOperationIdentity (ReductionIdentifier redId, mlir::Location loc)
static mlir::Value getReductionInitValue (mlir::Location loc, mlir::Type type, ReductionIdentifier redId, fir::FirOpBuilder &builder)
template<typename FloatOp, typename IntegerOp>
static mlir::Value getReductionOperation (fir::FirOpBuilder &builder, mlir::Type type, mlir::Location loc, mlir::Value op1, mlir::Value op2)
template<typename FloatOp, typename IntegerOp, typename ComplexOp>
static mlir::Value getReductionOperation (fir::FirOpBuilder &builder, mlir::Type type, mlir::Location loc, mlir::Value op1, mlir::Value op2)
static mlir::Value createScalarCombiner (fir::FirOpBuilder &builder, mlir::Location loc, ReductionIdentifier redId, mlir::Type type, mlir::Value op1, mlir::Value op2)
template<typename DeclareRedType>
static DeclareRedType createDeclareReductionHelper (AbstractConverter &converter, llvm::StringRef reductionOpName, mlir::Type type, mlir::Location loc, bool isByRef, GenCombinerCBTy genCombinerCB, GenInitValueCBTy genInitValueCB, const semantics::Symbol *sym=nullptr)
template<typename OpType>
static OpType createDeclareReduction (AbstractConverter &builder, llvm::StringRef reductionOpName, const ReductionIdentifier redId, mlir::Type type, mlir::Location loc, bool isByRef)
template<typename OpType, typename RedOperatorListTy>
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, llvm::ArrayRef< Object > reductionObjects, lower::SymMap &symMap, semantics::SemanticsContext *semaCtx=nullptr, llvm::DenseMap< const semantics::Symbol *, mlir::Value > *reductionVarCache=nullptr)
static bool isExpressionLoweredAsReductionObject (const Object *object)

Member Typedef Documentation

◆ GenCombinerCBTy

using Fortran::lower::omp::ReductionProcessor::GenCombinerCBTy
Initial value:
std::function<void(
fir::FirOpBuilder &builder, mlir::Location loc, mlir::Type type,
mlir::Value op1, mlir::Value op2, bool isByRef)>
Definition FIRBuilder.h:59

◆ GenInitValueCBTy

using Fortran::lower::omp::ReductionProcessor::GenInitValueCBTy
Initial value:
std::function<mlir::Value(
fir::FirOpBuilder &builder, mlir::Location loc, mlir::Type type,
mlir::Value ompOrig, mlir::Value ompPriv)>

Member Function Documentation

◆ createDeclareReduction()

template<typename OpType>
OpType Fortran::lower::omp::ReductionProcessor::createDeclareReduction ( AbstractConverter & builder,
llvm::StringRef reductionOpName,
const ReductionIdentifier redId,
mlir::Type type,
mlir::Location loc,
bool isByRef )
static

Creates an OpenMP reduction declaration and inserts it into the provided symbol table. The declaration has a constant initializer with the neutral value initValue, and the reduction combiner carried over from reduce. TODO: add atomic region.

◆ createDeclareReductionHelper()

template<typename DeclareRedType>
DeclareRedType Fortran::lower::omp::ReductionProcessor::createDeclareReductionHelper ( AbstractConverter & converter,
llvm::StringRef reductionOpName,
mlir::Type type,
mlir::Location loc,
bool isByRef,
GenCombinerCBTy genCombinerCB,
GenInitValueCBTy genInitValueCB,
const semantics::Symbol * sym = nullptr )
static

Creates an OpenMP reduction declaration and inserts it into the provided symbol table. The init and combiner regions are generated by the callback functions genCombinerCB and genInitValueCB.

◆ getOperationIdentity()

int Fortran::lower::omp::ReductionProcessor::getOperationIdentity ( ReductionIdentifier redId,
mlir::Location loc )
static

This function returns the identity value of the operator reductionOpName. For example: 0 + x = x, 1 * x = x

◆ getScopedUserReductionName()

std::string Fortran::lower::omp::ReductionProcessor::getScopedUserReductionName ( AbstractConverter & converter,
const semantics::Symbol & reductionSymbol,
mlir::Type reductionType,
bool isByRef )
static

Returns the module-unique name of the omp.declare_reduction op for a user-defined reduction (named or operator). Derived from the reduction symbol's ultimate name, qualified with its owning scope via AbstractConverter::mangleName so same-spelling reductions in different modules do not collide, then suffixed with the reduction type (via getReductionName) so a reduction listing several types produces one op per type (single-type is N=1). The directive and clause sides must both call this with the same unwrapped type and isByRef, since both tokens are part of the name, or the names diverge.

◆ isExpressionLoweredAsReductionObject()

bool Fortran::lower::omp::ReductionProcessor::isExpressionLoweredAsReductionObject ( const Object * object)
static

Check if an expression is lowered as a Reduction object. This ensures reductions such as Array Elements are properly represented, rather than reducing the full array.

◆ processReductionArguments()

template<typename OpType, typename RedOperatorListTy>
bool Fortran::lower::omp::ReductionProcessor::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,
llvm::ArrayRef< Object > reductionObjects,
lower::SymMap & symMap,
semantics::SemanticsContext * semaCtx = nullptr,
llvm::DenseMap< const semantics::Symbol *, mlir::Value > * reductionVarCache = nullptr )
static

Creates a reduction declaration and associates it with an OpenMP block directive.

Parameters
[in,out]reductionVarCache- optional cache mapping reduction symbols to their SSA values. When provided, array/box reduction variables that have already been allocated will be reused instead of creating new allocas. This ensures that nested composite wrappers (e.g. wsloop and simd in DO SIMD) share the same SSA values, allowing the genLoopVars() mapper to correctly remap inner wrapper operands.

◆ toParserIntrinsicOperator()

parser::DefinedOperator::IntrinsicOperator Fortran::lower::omp::ReductionProcessor::toParserIntrinsicOperator ( omp::clause::DefinedOperator::IntrinsicOperator op)
static

Map a clause-level intrinsic operator to the parser-level one, so callers can build the operator's mangled reduction name (MangledIntrinsicOperatorReductionName) that semantics stores a user-defined intrinsic-operator reduction under. Only the operators a user reduction may use are handled.


The documentation for this class was generated from the following files: