[flang-commits] [flang] 8c1b633 - [flang][fir][NFC] Move FieldType to TableGen type definition
via flang-commits
flang-commits at lists.llvm.org
Fri Feb 12 19:23:10 PST 2021
Author: Valentin Clement
Date: 2021-02-12T22:23:05-05:00
New Revision: 8c1b63307f0696058bf4a9f7a54b012867f2457e
URL: https://github.com/llvm/llvm-project/commit/8c1b63307f0696058bf4a9f7a54b012867f2457e
DIFF: https://github.com/llvm/llvm-project/commit/8c1b63307f0696058bf4a9f7a54b012867f2457e.diff
LOG: [flang][fir][NFC] Move FieldType to TableGen type definition
This patch is a follow up of D96422 and move ComplexType to TableGen.
Reviewed By: schweitz, mehdi_amini
Differential Revision: https://reviews.llvm.org/D96610
Added:
Modified:
flang/include/flang/Optimizer/Dialect/FIROps.td
flang/include/flang/Optimizer/Dialect/FIRType.h
flang/include/flang/Optimizer/Dialect/FIRTypes.td
flang/lib/Optimizer/Dialect/FIRType.cpp
Removed:
################################################################################
diff --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td
index a0df05e7aeac..89665689aa6f 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -113,9 +113,6 @@ def AnyEmboxArg : Type<AnyEmboxLike.predicate, "embox argument type">;
def fir_TypeDescType : Type<CPred<"$_self.isa<fir::TypeDescType>()">,
"type desc type">;
-// A field (in a RecordType) argument's type
-def fir_FieldType : Type<CPred<"$_self.isa<fir::FieldType>()">, "field type">;
-
// A LEN parameter (in a RecordType) argument's type
def fir_LenType : Type<CPred<"$_self.isa<fir::LenType>()">,
"LEN parameter type">;
diff --git a/flang/include/flang/Optimizer/Dialect/FIRType.h b/flang/include/flang/Optimizer/Dialect/FIRType.h
index a531a514f224..a80c402000d2 100644
--- a/flang/include/flang/Optimizer/Dialect/FIRType.h
+++ b/flang/include/flang/Optimizer/Dialect/FIRType.h
@@ -46,7 +46,6 @@ struct BoxCharTypeStorage;
struct BoxProcTypeStorage;
struct CharacterTypeStorage;
struct ComplexTypeStorage;
-struct FieldTypeStorage;
struct HeapTypeStorage;
struct IntegerTypeStorage;
struct LenTypeStorage;
@@ -213,16 +212,6 @@ class SliceType : public mlir::Type::TypeBase<SliceType, mlir::Type,
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<FieldType, mlir::Type,
- detail::FieldTypeStorage> {
-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
index 7adef6b33d3f..ced993ea21d1 100644
--- a/flang/include/flang/Optimizer/Dialect/FIRTypes.td
+++ b/flang/include/flang/Optimizer/Dialect/FIRTypes.td
@@ -44,6 +44,25 @@ def BoxType : FIR_Type<"Box", "box"> {
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
index 35e71a7560ca..4001169104af 100644
--- a/flang/lib/Optimizer/Dialect/FIRType.cpp
+++ b/flang/lib/Optimizer/Dialect/FIRType.cpp
@@ -99,11 +99,6 @@ SliceType parseSlice(mlir::DialectAsmParser &parser) {
return parseRankSingleton<SliceType>(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<HeapType>(parser, loc);
@@ -344,7 +339,7 @@ mlir::Type fir::parseFirType(FIROpsDialect *dialect,
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 @@ struct SliceTypeStorage : public mlir::TypeStorage {
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<FieldTypeStorage>();
- 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 @@ CharacterType::LenType fir::CharacterType::getLen() const {
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 @@ void fir::printFirType(FIROpsDialect *, mlir::Type ty,
os << "slice<" << type.getRank() << '>';
return;
}
- if (ty.isa<FieldType>()) {
- os << "field";
- return;
- }
if (auto type = ty.dyn_cast<HeapType>()) {
os << "heap<";
p.printType(type.getEleTy());
More information about the flang-commits
mailing list