[flang] [llvm] [Flang][OpenMP] Initial defaultmap implementation (PR #135226)
Krzysztof Parzyszek via llvm-commits
llvm-commits at lists.llvm.org
Sat May 10 06:40:59 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];
+ }
----------------
kparzysz wrote:
You didn't use braces in the 3 other similar ifs above.
https://github.com/llvm/llvm-project/pull/135226
More information about the llvm-commits
mailing list