[flang-commits] [mlir] [llvm] [flang] [flang][mlir][OpenMP] Add support for COPYPRIVATE (PR #73128)

Valentin Clement バレンタイン クレメン via flang-commits flang-commits at lists.llvm.org
Wed Dec 20 09:05:16 PST 2023


================
@@ -880,6 +884,156 @@ createReductionDecl(fir::FirOpBuilder &builder, llvm::StringRef reductionOpName,
   return decl;
 }
 
+/// Class that extracts information from the specified type.
+class TypeInfo {
+public:
+  TypeInfo(mlir::Location loc, mlir::Type ty) : loc(loc) {
+    name = typeScan(ty);
+  }
+
+  // Returns a textual representation of the type, with characters that are
+  // valid in identifiers.
+  const std::string &getName() const { return name; }
+
+  // Returns the length of character types.
+  std::optional<fir::CharacterType::LenType> getCharLength() const {
+    return charLen;
+  }
+
+  // Returns the shape of array types.
+  const llvm::SmallVector<int64_t> &getShape() const { return shape; }
+
+  // Is the type inside a box?
+  bool isBox() const { return inBox; }
+
+private:
+  // Scan type and return an unique name for it.
+  std::string typeScan(mlir::Type type);
+
+  mlir::Location loc;
+  std::string name;
+  std::optional<fir::CharacterType::LenType> charLen;
+  llvm::SmallVector<int64_t> shape;
+  bool inBox = false;
+};
+
+std::string TypeInfo::typeScan(mlir::Type ty) {
----------------
clementval wrote:

Can you use `getTypeAsString` from `FIRType.h`? It looks pretty similar. 

https://github.com/llvm/llvm-project/blob/2c257cf8721a030af03bd84f72e77864a7cf561b/flang/lib/Optimizer/Dialect/FIRType.cpp#L514

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


More information about the flang-commits mailing list