diff --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td --- a/flang/include/flang/Optimizer/Dialect/FIROps.td +++ b/flang/include/flang/Optimizer/Dialect/FIROps.td @@ -113,9 +113,6 @@ def fir_TypeDescType : Type()">, "type desc type">; -// A field (in a RecordType) argument's type -def fir_FieldType : Type()">, "field type">; - // A LEN parameter (in a RecordType) argument's type def fir_LenType : Type()">, "LEN parameter type">; diff --git a/flang/include/flang/Optimizer/Dialect/FIRType.h b/flang/include/flang/Optimizer/Dialect/FIRType.h --- a/flang/include/flang/Optimizer/Dialect/FIRType.h +++ b/flang/include/flang/Optimizer/Dialect/FIRType.h @@ -46,7 +46,6 @@ struct BoxProcTypeStorage; struct CharacterTypeStorage; struct ComplexTypeStorage; -struct FieldTypeStorage; struct HeapTypeStorage; struct IntegerTypeStorage; struct LenTypeStorage; @@ -213,16 +212,6 @@ unsigned getRank() const; }; -/// The type of a field name. Implementations may defer the layout of a Fortran -/// derived type until runtime. This implies that the runtime must be able to -/// determine the offset of fields within the entity. -class FieldType : public mlir::Type::TypeBase { -public: - using Base::Base; - static FieldType get(mlir::MLIRContext *ctxt); -}; - /// The type of a heap pointer. Fortran entities with the ALLOCATABLE attribute /// may be allocated on the heap at runtime. These pointers are explicitly /// distinguished to disallow the composition of multiple levels of diff --git a/flang/include/flang/Optimizer/Dialect/FIRTypes.td b/flang/include/flang/Optimizer/Dialect/FIRTypes.td --- a/flang/include/flang/Optimizer/Dialect/FIRTypes.td +++ b/flang/include/flang/Optimizer/Dialect/FIRTypes.td @@ -44,6 +44,25 @@ let genVerifyInvariantsDecl = 1; } +def fir_FieldType : FIR_Type<"Field", "field"> { + let summary = "A field (in a RecordType) argument's type"; + + let description = [{ + The type of a field name. Implementations may defer the layout of a Fortran + derived type until runtime. This implies that the runtime must be able to + determine the offset of fields within the entity. + }]; + + let printer = [{ + $_printer << "field"; + }]; + + let parser = [{ + return get(context); + }]; + +} + def ShapeType : FIR_Type<"Shape", "shape"> { let summary = "shape of a multidimensional array object"; diff --git a/flang/lib/Optimizer/Dialect/FIRType.cpp b/flang/lib/Optimizer/Dialect/FIRType.cpp --- a/flang/lib/Optimizer/Dialect/FIRType.cpp +++ b/flang/lib/Optimizer/Dialect/FIRType.cpp @@ -99,11 +99,6 @@ return parseRankSingleton(parser); } -// `field` -FieldType parseField(mlir::DialectAsmParser &parser) { - return FieldType::get(parser.getBuilder().getContext()); -} - // `heap` `<` type `>` HeapType parseHeap(mlir::DialectAsmParser &parser, mlir::Location loc) { return parseTypeSingleton(parser, loc); @@ -344,7 +339,7 @@ if (typeNameLit == "complex") return parseComplex(parser); if (typeNameLit == "field") - return parseField(parser); + return generatedTypeParser(dialect->getContext(), parser, typeNameLit); if (typeNameLit == "heap") return parseHeap(parser, loc); if (typeNameLit == "int") @@ -439,25 +434,6 @@ explicit SliceTypeStorage(unsigned rank) : rank{rank} {} }; -/// The type of a derived type part reference -struct FieldTypeStorage : public mlir::TypeStorage { - using KeyTy = KindTy; - - static unsigned hashKey(const KeyTy &) { return llvm::hash_combine(0); } - - bool operator==(const KeyTy &) const { return true; } - - static FieldTypeStorage *construct(mlir::TypeStorageAllocator &allocator, - KindTy) { - auto *storage = allocator.allocate(); - return new (storage) FieldTypeStorage{0}; - } - -private: - FieldTypeStorage() = delete; - explicit FieldTypeStorage(KindTy) {} -}; - /// The type of a derived type LEN parameter reference struct LenTypeStorage : public mlir::TypeStorage { using KeyTy = KindTy; @@ -909,12 +885,6 @@ return getImpl()->getLen(); } -// Field - -FieldType fir::FieldType::get(mlir::MLIRContext *ctxt) { - return Base::get(ctxt, 0); -} - // Len LenType fir::LenType::get(mlir::MLIRContext *ctxt) { @@ -1332,10 +1302,6 @@ os << "slice<" << type.getRank() << '>'; return; } - if (ty.isa()) { - os << "field"; - return; - } if (auto type = ty.dyn_cast()) { os << "heap<"; p.printType(type.getEleTy());