[flang-commits] [flang] [flang][OpenMP][NFC] Further refactoring for `genOpWithBody` & (PR #80839)
Sergio Afonso via flang-commits
flang-commits at lists.llvm.org
Tue Feb 6 07:40:45 PST 2024
================
@@ -2250,31 +2250,68 @@ createAndSetPrivatizedLoopVar(Fortran::lower::AbstractConverter &converter,
return storeOp;
}
-struct CreateBodyOfOpInfo {
+struct OpWithBodyGenInfo {
+ /// A type for a code-gen callback function. This takes as argument the op for
+ /// which the code is being generated and returns the arguments of the op's
+ /// region.
+ using GenOMPRegionEntryCBFn =
+ std::function<llvm::SmallVector<const Fortran::semantics::Symbol *>(
+ mlir::Operation *)>;
+
+ OpWithBodyGenInfo(Fortran::lower::AbstractConverter &converter,
+ mlir::Location loc, Fortran::lower::pft::Evaluation &eval)
+ : converter(converter), loc(loc), eval(eval) {}
+
+ OpWithBodyGenInfo &setGenNested(bool value) {
+ genNested = value;
+ return *this;
+ }
+
+ OpWithBodyGenInfo &setOuterCombined(bool value) {
+ outerCombined = value;
+ return *this;
+ }
+
+ OpWithBodyGenInfo &setClauses(const Fortran::parser::OmpClauseList *value) {
+ clauses = value;
+ return *this;
+ }
+
+ OpWithBodyGenInfo &setDataSharingProcessor(DataSharingProcessor *value) {
+ dsp = value;
+ return *this;
+ }
+
+ OpWithBodyGenInfo &setGenRegionEntryCb(GenOMPRegionEntryCBFn value) {
+ genRegionEntryCB = value;
+ return *this;
+ }
+
+ /// [inout] converter to use for the clauses.
Fortran::lower::AbstractConverter &converter;
- mlir::Location &loc;
+ /// [in] location in source code.
+ mlir::Location loc;
+ /// [in] current PFT node/evaluation.
Fortran::lower::pft::Evaluation &eval;
+ /// [in] whether to generate FIR for nested evaluations
bool genNested = true;
- const Fortran::parser::OmpClauseList *clauses = nullptr;
- const llvm::SmallVector<const Fortran::semantics::Symbol *> &args = {};
+ /// [in] is this an outer operation - prevents privatization.
bool outerCombined = false;
+ /// [in] list of clauses to process.
+ const Fortran::parser::OmpClauseList *clauses = nullptr;
+ /// [in] if provided, processes the construct's data-sharing attributes.
DataSharingProcessor *dsp = nullptr;
+ /// [in] if provided, emits the op's region entry. Otherwise, an emtpy block
+ /// is created in the region.
+ GenOMPRegionEntryCBFn genRegionEntryCB = nullptr;
};
/// Create the body (block) for an OpenMP Operation.
///
-/// \param [in] op - the operation the body belongs to.
-/// \param [inout] converter - converter to use for the clauses.
-/// \param [in] loc - location in source code.
-/// \param [in] eval - current PFT node/evaluation.
-/// \param [in] genNested - whether to generate FIR for nested evaluations
-/// \oaran [in] clauses - list of clauses to process.
-/// \param [in] args - block arguments (induction variable[s]) for the
-//// region.
-/// \param [in] outerCombined - is this an outer operation - prevents
-/// privatization.
+/// \param [in] op - the operation the body belongs to.
+/// \param [in] info - options controlling code-gen for the construction.
template <typename Op>
-static void createBodyOfOp(Op &op, CreateBodyOfOpInfo info) {
+static void createBodyOfOp(Op &op, OpWithBodyGenInfo info) {
----------------
skatrak wrote:
```suggestion
static void createBodyOfOp(Op &op, OpWithBodyGenInfo &info) {
```
https://github.com/llvm/llvm-project/pull/80839
More information about the flang-commits
mailing list