[flang-commits] [flang] [flang][acc] Implement type categorization for FIR types (PR #126964)

Valentin Clement バレンタイン クレメン via flang-commits flang-commits at lists.llvm.org
Wed Feb 12 13:29:39 PST 2025


================
@@ -224,4 +226,157 @@ OpenACCMappableModel<fir::BaseBoxType>::generateAccBounds(
   return {};
 }
 
+static bool isScalarLike(mlir::Type type) {
+  return type.isIntOrIndexOrFloat() ||
+         mlir::isa<mlir::ComplexType, fir::LogicalType>(type) ||
+         fir::isa_ref_type(type);
+}
+
+static bool isArrayLike(mlir::Type type) {
+  return mlir::isa<fir::SequenceType>(type);
+}
+
+static bool isCompositeLike(mlir::Type type) {
+  return mlir::isa<fir::RecordType, fir::ClassType, mlir::TupleType>(type);
+}
+
+template <>
+mlir::acc::VariableTypeCategory
+OpenACCMappableModel<fir::SequenceType>::getTypeCategory(
+    mlir::Type type, mlir::Value var) const {
+  return mlir::acc::VariableTypeCategory::array;
+}
+
+template <>
+mlir::acc::VariableTypeCategory
+OpenACCMappableModel<fir::BaseBoxType>::getTypeCategory(mlir::Type type,
+                                                        mlir::Value var) const {
+
+  mlir::Type eleTy = fir::dyn_cast_ptrOrBoxEleTy(type);
+
+  // If the type enclosed by the box is a mappable type, then have it
+  // provide the type category.
+  if (auto mappableTy = mlir::dyn_cast<mlir::acc::MappableType>(eleTy)) {
+    return mappableTy.getTypeCategory(var);
+  }
----------------
clementval wrote:

no brace in simple if statement in upstream llvm 

https://github.com/llvm/llvm-project/pull/126964


More information about the flang-commits mailing list