[flang-commits] [flang] [flang][OpenMP] Add support for copyprivate (PR #80485)
Kiran Chandramohan via flang-commits
flang-commits at lists.llvm.org
Mon Feb 19 09:25:00 PST 2024
================
@@ -1178,6 +1183,102 @@ class ReductionProcessor {
}
};
+/// Class that extracts information from the specified type.
+class TypeInfo {
+public:
+ TypeInfo(mlir::Type ty) { typeScan(ty); }
+
+ // 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:
+ void typeScan(mlir::Type type);
+
+ std::optional<fir::CharacterType::LenType> charLen;
+ llvm::SmallVector<int64_t> shape;
+ bool inBox = false;
+};
+
+void TypeInfo::typeScan(mlir::Type ty) {
+ if (auto sty = mlir::dyn_cast<fir::SequenceType>(ty)) {
+ assert(shape.empty() && !sty.getShape().empty());
+ shape = llvm::SmallVector<int64_t>(sty.getShape());
+ typeScan(sty.getEleTy());
+ } else if (auto bty = mlir::dyn_cast<fir::BoxType>(ty)) {
+ inBox = true;
+ typeScan(bty.getEleTy());
+ } else if (auto cty = mlir::dyn_cast<fir::CharacterType>(ty)) {
+ charLen = cty.getLen();
+ } else if (auto hty = mlir::dyn_cast<fir::HeapType>(ty)) {
+ typeScan(hty.getEleTy());
+ } else if (auto pty = mlir::dyn_cast<fir::PointerType>(ty)) {
+ typeScan(pty.getEleTy());
+ }
----------------
kiranchandramohan wrote:
Nit: should there be an assert here?
https://github.com/llvm/llvm-project/pull/80485
More information about the flang-commits
mailing list