Index: flang/include/flang/Optimizer/Dialect/FIROps.td =================================================================== --- flang/include/flang/Optimizer/Dialect/FIROps.td +++ flang/include/flang/Optimizer/Dialect/FIROps.td @@ -98,9 +98,8 @@ "any reference or box">; // A vector of Fortran triple notation describing a multidimensional array -def fir_DimsType : Type()">, "dim type">; def AnyEmboxLike : TypeConstraint, + Index.predicate, fir_IntegerType.predicate]>, "any legal embox argument type">; def AnyEmboxArg : Type; @@ -1077,17 +1076,12 @@ } else { return emitOpError("LEN parameters require !fir.type type"); } - for (auto lp : getLenParams()) - if (lp.getType().isa()) - return emitOpError("LEN parameters must be integral type"); } if (dims().size() == 0) { // Ok. If there is no dims and no layout map, then emboxing a scalar. // TODO: Should the type be enforced? It already must agree. } else if (dims().size() == 1) { auto d = *dims().begin(); - if (!d.getType().isa()) - return emitOpError("dimension argument must have !fir.dims type"); } else { return emitOpError("embox can only have one !fir.dim argument"); } @@ -1263,7 +1257,7 @@ AnyIntegerLike, // rank of data fir_TypeDescType, // abstract type descriptor AnyIntegerLike, // attribute flags (bitfields) - fir_DimsType // dimension information (if any) + fir_SequenceType // dimension information (if any) ); } @@ -1722,42 +1716,6 @@ }]; } -def fir_GenDimsOp : fir_OneResultOp<"gendims", [NoSideEffect]> { - - let summary = "generate a value of type `!fir.dims`"; - - let description = [{ - The arguments are an ordered list of integral type values that is a - multiple of 3 in length. Each such triple is defined as: the lower - index, the extent, and the stride for that dimension. The dimension - information is given in the same row-to-column order as Fortran. This - abstract dimension value must describe a reified object, so all dimension - information must be specified. The extent must be nonnegative and the - stride must not be zero. - - ```mlir - %d = fir.gendims %lo, %ext, %str : (index, index, index) -> !fir.dims<1> - ``` - }]; - - let arguments = (ins Variadic:$triples); - - let results = (outs fir_DimsType); - - let assemblyFormat = [{ - operands attr-dict `:` functional-type(operands, results) - }]; - - let verifier = [{ - auto size = triples().size(); - if (size < 1 || size > 16 * 3) - return emitOpError("incorrect number of args"); - if (size % 3 != 0) - return emitOpError("requires a multiple of 3 args"); - return mlir::success(); - }]; -} - def fir_InsertValueOp : fir_OneResultOp<"insert_value", [NoSideEffect]> { let summary = "insert a new sub-value into a copy of an existing aggregate"; Index: flang/include/flang/Optimizer/Dialect/FIRType.h =================================================================== --- flang/include/flang/Optimizer/Dialect/FIRType.h +++ flang/include/flang/Optimizer/Dialect/FIRType.h @@ -40,7 +40,6 @@ struct BoxProcTypeStorage; struct CharacterTypeStorage; struct ComplexTypeStorage; -struct DimsTypeStorage; struct FieldTypeStorage; struct HeapTypeStorage; struct IntegerTypeStorage; @@ -191,20 +190,6 @@ mlir::Type eleTy); }; -/// The type of a runtime vector that describes triples of array dimension -/// information. A triple consists of a lower bound, upper bound, and -/// stride. Each dimension of an array entity may have an associated triple that -/// maps how elements of the array are accessed. -class DimsType : public mlir::Type::TypeBase { -public: - using Base::Base; - static DimsType get(mlir::MLIRContext *ctx, unsigned rank); - - /// returns -1 if the rank is unknown - 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. Index: flang/lib/Optimizer/Dialect/FIRDialect.cpp =================================================================== --- flang/lib/Optimizer/Dialect/FIRDialect.cpp +++ flang/lib/Optimizer/Dialect/FIRDialect.cpp @@ -16,9 +16,9 @@ fir::FIROpsDialect::FIROpsDialect(mlir::MLIRContext *ctx) : mlir::Dialect("fir", ctx, mlir::TypeID::get()) { addTypes(); + FieldType, HeapType, fir::IntegerType, LenType, LogicalType, + PointerType, RealType, RecordType, ReferenceType, SequenceType, + TypeDescType>(); addAttributes(); addOperations< Index: flang/lib/Optimizer/Dialect/FIRType.cpp =================================================================== --- flang/lib/Optimizer/Dialect/FIRType.cpp +++ flang/lib/Optimizer/Dialect/FIRType.cpp @@ -91,11 +91,6 @@ return parseKindSingleton(parser); } -// `dims` `<` rank `>` -DimsType parseDims(mlir::DialectAsmParser &parser) { - return parseRankSingleton(parser); -} - // `field` FieldType parseField(mlir::DialectAsmParser &parser) { return FieldType::get(parser.getBuilder().getContext()); @@ -186,9 +181,8 @@ bool verifyRecordMemberType(mlir::Type ty) { return !(ty.isa() || ty.isa() || - ty.isa() || ty.isa() || ty.isa() || - ty.isa() || ty.isa() || - ty.isa()); + ty.isa() || ty.isa() || ty.isa() || + ty.isa() || ty.isa()); } bool verifySameLists(llvm::ArrayRef a1, @@ -325,8 +319,6 @@ return parseCharacter(parser); if (typeNameLit == "complex") return parseComplex(parser); - if (typeNameLit == "dims") - return parseDims(parser); if (typeNameLit == "field") return parseField(parser); if (typeNameLit == "heap") @@ -383,29 +375,6 @@ explicit CharacterTypeStorage(KindTy kind) : kind{kind} {} }; -struct DimsTypeStorage : public mlir::TypeStorage { - using KeyTy = unsigned; - - static unsigned hashKey(const KeyTy &key) { return llvm::hash_combine(key); } - - bool operator==(const KeyTy &key) const { return key == getRank(); } - - static DimsTypeStorage *construct(mlir::TypeStorageAllocator &allocator, - unsigned rank) { - auto *storage = allocator.allocate(); - return new (storage) DimsTypeStorage{rank}; - } - - unsigned getRank() const { return rank; } - -protected: - unsigned rank; - -private: - DimsTypeStorage() = delete; - explicit DimsTypeStorage(unsigned rank) : rank{rank} {} -}; - /// The type of a derived type part reference struct FieldTypeStorage : public mlir::TypeStorage { using KeyTy = KindTy; @@ -871,14 +840,6 @@ int fir::CharacterType::getFKind() const { return getImpl()->getFKind(); } -// Dims - -DimsType fir::DimsType::get(mlir::MLIRContext *ctxt, unsigned rank) { - return Base::get(ctxt, rank); -} - -unsigned fir::DimsType::getRank() const { return getImpl()->getRank(); } - // Field FieldType fir::FieldType::get(mlir::MLIRContext *ctxt) { @@ -992,7 +953,7 @@ mlir::LogicalResult fir::ReferenceType::verifyConstructionInvariants(mlir::Location loc, mlir::Type eleTy) { - if (eleTy.isa() || eleTy.isa() || eleTy.isa() || + if (eleTy.isa() || eleTy.isa() || eleTy.isa() || eleTy.isa()) return mlir::emitError(loc, "cannot build a reference to type: ") << eleTy << '\n'; @@ -1012,10 +973,10 @@ static bool canBePointerOrHeapElementType(mlir::Type eleTy) { return eleTy.isa() || eleTy.isa() || - eleTy.isa() || eleTy.isa() || - eleTy.isa() || eleTy.isa() || - eleTy.isa() || eleTy.isa() || - eleTy.isa() || eleTy.isa(); + eleTy.isa() || eleTy.isa() || + eleTy.isa() || eleTy.isa() || + eleTy.isa() || eleTy.isa() || + eleTy.isa(); } mlir::LogicalResult @@ -1100,8 +1061,8 @@ mlir::AffineMapAttr map) { // DIMENSION attribute can only be applied to an intrinsic or record type if (eleTy.isa() || eleTy.isa() || - eleTy.isa() || eleTy.isa() || - eleTy.isa() || eleTy.isa() || eleTy.isa() || + eleTy.isa() || eleTy.isa() || + eleTy.isa() || eleTy.isa() || eleTy.isa() || eleTy.isa() || eleTy.isa() || eleTy.isa()) return mlir::emitError(loc, "cannot build an array of this element type: ") @@ -1186,9 +1147,9 @@ fir::TypeDescType::verifyConstructionInvariants(mlir::Location loc, mlir::Type eleTy) { if (eleTy.isa() || eleTy.isa() || - eleTy.isa() || eleTy.isa() || - eleTy.isa() || eleTy.isa() || - eleTy.isa() || eleTy.isa()) + eleTy.isa() || eleTy.isa() || + eleTy.isa() || eleTy.isa() || + eleTy.isa()) return mlir::emitError(loc, "cannot build a type descriptor of type: ") << eleTy << '\n'; return mlir::success(); @@ -1276,10 +1237,6 @@ os << '>'; return; } - if (auto type = ty.dyn_cast()) { - os << "dims<" << type.getRank() << '>'; - return; - } if (ty.isa()) { os << "field"; return; Index: flang/test/Fir/fir-ops.fir =================================================================== --- flang/test/Fir/fir-ops.fir +++ flang/test/Fir/fir-ops.fir @@ -97,12 +97,10 @@ %23 = fir.extract_value %22, %21 : (!fir.type, !fir.field) -> f32 // CHECK: [[VAL_26:%.*]] = constant 1 : i32 -// CHECK: [[VAL_27:%.*]] = fir.gendims [[VAL_26]], [[VAL_21]], [[VAL_26]] : (i32, i32, i32) -> !fir.dims<1> // CHECK: [[VAL_28:%.*]] = constant 1.0 // CHECK: [[VAL_29:%.*]] = fir.insert_value [[VAL_24]], [[VAL_28]], [[VAL_23]] : (!fir.type, f32, !fir.field) -> !fir.type // CHECK: [[VAL_30:%.*]] = fir.len_param_index f, !fir.type %c1 = constant 1 : i32 - %24 = fir.gendims %c1, %19, %c1 : (i32, i32, i32) -> !fir.dims<1> %cf1 = constant 1.0 : f32 %25 = fir.insert_value %22, %cf1, %21 : (!fir.type, f32, !fir.field) -> !fir.type %26 = fir.len_param_index f, !fir.type @@ -142,7 +140,7 @@ // CHECK: [[VAL_40:%.*]] = fir.alloca !fir.char<1> // CHECK: [[VAL_41:%.*]] = fir.alloca tuple // CHECK: [[VAL_42:%.*]] = fir.embox [[VAL_38]] : (!fir.ref) -> !fir.box -// CHECK: [[VAL_43:%.*]]:6 = fir.unbox [[VAL_42]] : (!fir.box) -> (!fir.ref, i32, i32, !fir.tdesc, i32, !fir.dims<0>) +// CHECK: [[VAL_43:%.*]]:6 = fir.unbox [[VAL_42]] : (!fir.box) -> (!fir.ref, i32, i32, !fir.tdesc, i32, !fir.array<3x?xindex>) // CHECK: [[VAL_44:%.*]] = constant 8 : i32 // CHECK: [[VAL_45:%.*]] = fir.undefined !fir.char<1> // CHECK: [[VAL_46:%.*]] = fir.emboxchar [[VAL_40]], [[VAL_44]] : (!fir.ref>, i32) -> !fir.boxchar<1> @@ -168,7 +166,7 @@ %d3 = fir.alloca !fir.char<1> %e6 = fir.alloca tuple %1 = fir.embox %0 : (!fir.ref) -> !fir.box - %2:6 = fir.unbox %1 : (!fir.box) -> (!fir.ref,i32,i32,!fir.tdesc,i32,!fir.dims<0>) + %2:6 = fir.unbox %1 : (!fir.box) -> (!fir.ref,i32,i32,!fir.tdesc,i32,!fir.array<3x?xindex>) %c8 = constant 8 : i32 %3 = fir.undefined !fir.char<1> %4 = fir.emboxchar %d3, %c8 : (!fir.ref>, i32) -> !fir.boxchar<1> Index: flang/test/Fir/fir-types.fir =================================================================== --- flang/test/Fir/fir-types.fir +++ flang/test/Fir/fir-types.fir @@ -67,11 +67,7 @@ func private @box5() -> !fir.box> // FIR misc. types -// CHECK-LABEL: func private @oth1() -> !fir.dims<1> // CHECK-LABEL: func private @oth2() -> !fir.field // CHECK-LABEL: func private @oth3() -> !fir.tdesc> -// CHECK-LABEL: func private @oth4() -> !fir.dims<15> -func private @oth1() -> !fir.dims<1> func private @oth2() -> !fir.field func private @oth3() -> !fir.tdesc> -func private @oth4() -> !fir.dims<15>