[flang-commits] [flang] [llvm] [Flang][OpenMP] Initial defaultmap implementation (PR #135226)
Sergio Afonso via flang-commits
flang-commits at lists.llvm.org
Tue May 6 07:59:49 PDT 2025
================
@@ -2231,6 +2232,146 @@ genSingleOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
queue, item, clauseOps);
}
+static clause::Defaultmap::ImplicitBehavior
+getDefaultmapIfPresent(DefaultMapsTy &defaultMaps, mlir::Type varType) {
+ using DefMap = clause::Defaultmap;
+
+ if (defaultMaps.empty())
+ return DefMap::ImplicitBehavior::Default;
+
+ if (llvm::is_contained(defaultMaps, DefMap::VariableCategory::All))
+ return defaultMaps[DefMap::VariableCategory::All];
+
+ // NOTE: Unsure if complex and/or vector falls into a scalar type
+ // or aggregate, but the current default implicit behaviour is to
+ // treat them as such (c_ptr has its own behaviour, so perhaps
+ // being lumped in as a scalar isn't the right thing).
+ if ((fir::isa_trivial(varType) || fir::isa_char(varType) ||
+ fir::isa_builtin_cptr_type(varType)) &&
+ llvm::is_contained(defaultMaps, DefMap::VariableCategory::Scalar))
+ return defaultMaps[DefMap::VariableCategory::Scalar];
+
+ if (fir::isPointerType(varType) &&
+ llvm::is_contained(defaultMaps, DefMap::VariableCategory::Pointer))
+ return defaultMaps[DefMap::VariableCategory::Pointer];
+
+ if (fir::isAllocatableType(varType) &&
+ llvm::is_contained(defaultMaps, DefMap::VariableCategory::Allocatable))
+ return defaultMaps[DefMap::VariableCategory::Allocatable];
+
+ if (fir::isa_aggregate(varType) &&
+ llvm::is_contained(defaultMaps, DefMap::VariableCategory::Aggregate)) {
+ return defaultMaps[DefMap::VariableCategory::Aggregate];
+ }
+
+ return DefMap::ImplicitBehavior::Default;
+}
+
+static std::pair<llvm::omp::OpenMPOffloadMappingFlags,
+ mlir::omp::VariableCaptureKind>
+getImplicitMapTypeAndKind(fir::FirOpBuilder &firOpBuilder,
+ lower::AbstractConverter &converter,
+ DefaultMapsTy &defaultMaps, mlir::Type varType,
----------------
skatrak wrote:
```suggestion
const DefaultMapsTy &defaultMaps, mlir::Type varType,
```
https://github.com/llvm/llvm-project/pull/135226
More information about the flang-commits
mailing list