forked from OSchip/llvm-project
[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
This commit is contained in:
parent
df1eeaa7b4
commit
8c1b63307f
|
@ -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">;
|
||||
|
|
|
@ -46,7 +46,6 @@ struct BoxCharTypeStorage;
|
|||
struct BoxProcTypeStorage;
|
||||
struct CharacterTypeStorage;
|
||||
struct ComplexTypeStorage;
|
||||
struct FieldTypeStorage;
|
||||
struct HeapTypeStorage;
|
||||
struct IntegerTypeStorage;
|
||||
struct LenTypeStorage;
|
||||
|
@ -213,16 +212,6 @@ public:
|
|||
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
|
||||
|
|
|
@ -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";
|
||||
|
||||
|
|
|
@ -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 @@ private:
|
|||
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());
|
||||
|
|
Loading…
Reference in New Issue