[flang-commits] [flang] cc120e3 - [flang][mlir][NFC] Remove deprecated parser/printer/verifier utilities
Shraiysh Vaishay via flang-commits
flang-commits at lists.llvm.org
Mon Feb 14 22:24:34 PST 2022
Author: Shraiysh Vaishay
Date: 2022-02-15T11:54:24+05:30
New Revision: cc120e36c31a33ff46fa1a5b33d6df4235dcb740
URL: https://github.com/llvm/llvm-project/commit/cc120e36c31a33ff46fa1a5b33d6df4235dcb740
DIFF: https://github.com/llvm/llvm-project/commit/cc120e36c31a33ff46fa1a5b33d6df4235dcb740.diff
LOG: [flang][mlir][NFC] Remove deprecated parser/printer/verifier utilities
These have been replaced by `hasCustomAssemblyFormat` and `hasVerifier`
fields and aren't needed anymore.
Ops deriving from `fir_IntegralSwitchTerminatorOp` and `region_Op` are
not handled in this patch for ease of review.
Reviewed By: rriddle
Differential Revision: https://reviews.llvm.org/D119776
Added:
Modified:
flang/include/flang/Optimizer/Dialect/FIROps.td
flang/lib/Optimizer/Dialect/FIROps.cpp
Removed:
################################################################################
diff --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td
index cf20385f46317..8a06f188bf7d4 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -135,9 +135,8 @@ def fir_AllocaOp : fir_Op<"alloca", [AttrSizedOperandSegments,
let results = (outs fir_ReferenceType);
- let parser =
- "return parseAllocatableOp(wrapAllocaResultType, parser, result);";
- let printer = "printAllocatableOp(p, (*this));";
+ let hasCustomAssemblyFormat = 1;
+ let hasVerifier = 1;
let builders = [
OpBuilder<(ins "mlir::Type":$inType, "llvm::StringRef":$uniqName,
@@ -166,8 +165,6 @@ def fir_AllocaOp : fir_Op<"alloca", [AttrSizedOperandSegments,
CArg<"mlir::ValueRange", "{}">:$shape,
CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
- let verifier = "return ::verify(*this);";
-
let extraClassDeclaration = [{
mlir::Type getAllocatedType();
bool hasLenParams() { return !typeparams().empty(); }
@@ -205,9 +202,8 @@ def fir_AllocMemOp : fir_Op<"allocmem",
);
let results = (outs fir_HeapType);
- let parser =
- "return parseAllocatableOp(wrapAllocMemResultType, parser, result);";
- let printer = "printAllocatableOp(p, (*this));";
+ let hasCustomAssemblyFormat = 1;
+ let hasVerifier = 1;
let builders = [
OpBuilder<(ins "mlir::Type":$in_type, "llvm::StringRef":$uniq_name,
@@ -223,8 +219,6 @@ def fir_AllocMemOp : fir_Op<"allocmem",
CArg<"mlir::ValueRange", "{}">:$shape,
CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
- let verifier = "return ::verify(*this);";
-
let extraClassDeclaration = [{
mlir::Type getAllocatedType();
bool hasLenParams() { return !typeparams().empty(); }
@@ -279,9 +273,7 @@ def fir_LoadOp : fir_OneResultOp<"load"> {
let builders = [OpBuilder<(ins "mlir::Value":$refVal)>];
- let parser = "return parseLoadOp(parser, result);";
-
- let printer = "::print(p, *this);";
+ let hasCustomAssemblyFormat = 1;
let extraClassDeclaration = [{
static mlir::ParseResult getElementOf(mlir::Type &ele, mlir::Type ref);
@@ -325,7 +317,7 @@ def fir_CharConvertOp : fir_Op<"char_convert", []> {
$from `for` $count `to` $to attr-dict `:` type(operands)
}];
- let verifier = "return ::verify(*this);";
+ let hasVerifier = 1;
}
def fir_StoreOp : fir_Op<"store", []> {
@@ -350,11 +342,8 @@ def fir_StoreOp : fir_Op<"store", []> {
let arguments = (ins AnyType:$value,
Arg<AnyReferenceLike, "", [MemWrite]>:$memref);
- let parser = "return parseStoreOp(parser, result);";
-
- let printer = "::print(p, *this);";
-
- let verifier = "return ::verify(*this);";
+ let hasCustomAssemblyFormat = 1;
+ let hasVerifier = 1;
let extraClassDeclaration = [{
static mlir::Type elementType(mlir::Type refType);
@@ -407,7 +396,7 @@ def fir_SaveResultOp : fir_Op<"save_result", [AttrSizedOperandSegments]> {
attr-dict `:` type(operands)
}];
- let verifier = "return ::verify(*this);";
+ let hasVerifier = 1;
}
def fir_UndefOp : fir_OneResultOp<"undefined", [NoSideEffect]> {
@@ -731,11 +720,8 @@ def fir_SelectCaseOp : fir_SwitchTerminatorOp<"select_case"> {
CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
- let parser = "return parseSelectCase(parser, result);";
-
- let printer = "::print(p, *this);";
-
- let verifier = "return ::verify(*this);";
+ let hasCustomAssemblyFormat = 1;
+ let hasVerifier = 1;
let extraClassDeclaration = extraSwitchClassDeclaration#[{
unsigned compareOffsetSize();
@@ -769,11 +755,8 @@ def fir_SelectTypeOp : fir_SwitchTerminatorOp<"select_type"> {
CArg<"llvm::ArrayRef<mlir::ValueRange>", "{}">:$destOperands,
CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];
- let parser = "return parseSelectType(parser, result);";
-
- let printer = "::print(p, *this);";
-
- let verifier = "return ::verify(*this);";
+ let hasCustomAssemblyFormat = 1;
+ let hasVerifier = 1;
let extraClassDeclaration = extraSwitchClassDeclaration;
}
@@ -793,9 +776,8 @@ def fir_UnreachableOp : fir_Op<"unreachable", [Terminator]> {
```
}];
- let parser = "return mlir::success();";
+ let assemblyFormat = [{ attr-dict }];
- let printer = "";
}
def fir_FirEndOp : fir_Op<"end", [Terminator]> {
@@ -887,7 +869,7 @@ def fir_EmboxOp : fir_Op<"embox", [NoSideEffect, AttrSizedOperandSegments]> {
(`map` $accessMap^)? attr-dict `:` functional-type(operands, results)
}];
- let verifier = "return ::verify(*this);";
+ let hasVerifier = 1;
let extraClassDeclaration = [{
bool hasLenParams() { return !typeparams().empty(); }
@@ -944,7 +926,7 @@ def fir_ReboxOp : fir_Op<"rebox", [NoSideEffect, AttrSizedOperandSegments]> {
$box (`(` $shape^ `)`)? (`[` $slice^ `]`)? attr-dict `:` functional-type(operands, results)
}];
- let verifier = "return ::verify(*this);";
+ let hasVerifier = 1;
}
def fir_EmboxCharOp : fir_Op<"emboxchar", [NoSideEffect]> {
@@ -977,7 +959,7 @@ def fir_EmboxCharOp : fir_Op<"emboxchar", [NoSideEffect]> {
$memref `,` $len attr-dict `:` functional-type(operands, results)
}];
- let verifier = "return ::verify(*this);";
+ let hasVerifier = 1;
}
def fir_EmboxProcOp : fir_Op<"emboxproc", [NoSideEffect]> {
@@ -1009,11 +991,8 @@ def fir_EmboxProcOp : fir_Op<"emboxproc", [NoSideEffect]> {
let results = (outs fir_BoxProcType);
- let parser = "return parseEmboxProcOp(parser, result);";
-
- let printer = "::print(p, *this);";
-
- let verifier = "return ::verify(*this);";
+ let hasCustomAssemblyFormat = 1;
+ let hasVerifier = 1;
}
def fir_UnboxCharOp : fir_SimpleOp<"unboxchar", [NoSideEffect]> {
@@ -1047,7 +1026,7 @@ def fir_UnboxProcOp : fir_SimpleOp<"unboxproc", [NoSideEffect]> {
```
}];
- let verifier = "return ::verify(*this);";
+ let hasVerifier = 1;
let arguments = (ins fir_BoxProcType:$boxproc);
@@ -1367,7 +1346,7 @@ def fir_ArrayLoadOp : fir_Op<"array_load", [AttrSizedOperandSegments]> {
attr-dict `:` functional-type(operands, results)
}];
- let verifier = "return ::verify(*this);";
+ let hasVerifier = 1;
let extraClassDeclaration = [{
std::vector<mlir::Value> getExtents();
@@ -1417,7 +1396,7 @@ def fir_ArrayFetchOp : fir_Op<"array_fetch", [AttrSizedOperandSegments,
functional-type(operands, results)
}];
- let verifier = "return ::verify(*this);";
+ let hasVerifier = 1;
}
def fir_ArrayUpdateOp : fir_Op<"array_update", [AttrSizedOperandSegments,
@@ -1469,7 +1448,7 @@ def fir_ArrayUpdateOp : fir_Op<"array_update", [AttrSizedOperandSegments,
`:` functional-type(operands, results)
}];
- let verifier = "return ::verify(*this);";
+ let hasVerifier = 1;
}
def fir_ArrayModifyOp : fir_Op<"array_modify", [AttrSizedOperandSegments,
@@ -1530,7 +1509,7 @@ def fir_ArrayModifyOp : fir_Op<"array_modify", [AttrSizedOperandSegments,
`:` functional-type(operands, results)
}];
- let verifier = "return ::verify(*this);";
+ let hasVerifier = 1;
}
def fir_ArrayAccessOp : fir_Op<"array_access", [AttrSizedOperandSegments,
@@ -1592,7 +1571,7 @@ def fir_ArrayAccessOp : fir_Op<"array_access", [AttrSizedOperandSegments,
functional-type(operands, results)
}];
- let verifier = "return ::verify(*this);";
+ let hasVerifier = 1;
}
def fir_ArrayAmendOp : fir_Op<"array_amend", [NoSideEffect]> {
@@ -1669,7 +1648,7 @@ def fir_ArrayMergeStoreOp : fir_Op<"array_merge_store",
$typeparams^)? attr-dict `:` type(operands)
}];
- let verifier = "return ::verify(*this);";
+ let hasVerifier = 1;
}
//===----------------------------------------------------------------------===//
@@ -1718,7 +1697,7 @@ def fir_ArrayCoorOp : fir_Op<"array_coor",
$typeparams^)? attr-dict `:` functional-type(operands, results)
}];
- let verifier = "return ::verify(*this);";
+ let hasVerifier = 1;
}
def fir_CoordinateOp : fir_Op<"coordinate_of", [NoSideEffect]> {
@@ -1754,9 +1733,8 @@ def fir_CoordinateOp : fir_Op<"coordinate_of", [NoSideEffect]> {
let results = (outs RefOrLLVMPtr);
- let parser = "return parseCoordinateCustom(parser, result);";
- let printer = "::print(p, *this);";
- let verifier = "return ::verify(*this);";
+ let hasCustomAssemblyFormat = 1;
+ let hasVerifier = 1;
let builders = [
OpBuilder<(ins "mlir::Type":$resultType,
@@ -1818,9 +1796,7 @@ def fir_FieldIndexOp : fir_OneResultOp<"field_index", [NoSideEffect]> {
Variadic<AnyIntegerType>:$typeparams
);
- let parser = "return parseFieldIndexOp(parser, result);";
-
- let printer = "::print(p, *this);";
+ let hasCustomAssemblyFormat = 1;
let builders = [OpBuilder<(ins "llvm::StringRef":$fieldName,
"mlir::Type":$recTy, CArg<"mlir::ValueRange","{}">:$operands)>];
@@ -1856,7 +1832,7 @@ def fir_ShapeOp : fir_Op<"shape", [NoSideEffect]> {
operands attr-dict `:` functional-type(operands, results)
}];
- let verifier = "return ::verify(*this);";
+ let hasVerifier = 1;
}
def fir_ShapeShiftOp : fir_Op<"shape_shift", [NoSideEffect]> {
@@ -1886,7 +1862,7 @@ def fir_ShapeShiftOp : fir_Op<"shape_shift", [NoSideEffect]> {
operands attr-dict `:` functional-type(operands, results)
}];
- let verifier = "return ::verify(*this);";
+ let hasVerifier = 1;
let extraClassDeclaration = [{
// Logically unzip the origins from the extent values.
@@ -1933,7 +1909,7 @@ def fir_ShiftOp : fir_Op<"shift", [NoSideEffect]> {
operands attr-dict `:` functional-type(operands, results)
}];
- let verifier = "return ::verify(*this);";
+ let hasVerifier = 1;
}
def fir_SliceOp : fir_Op<"slice", [NoSideEffect, AttrSizedOperandSegments]> {
@@ -1991,7 +1967,7 @@ def fir_SliceOp : fir_Op<"slice", [NoSideEffect, AttrSizedOperandSegments]> {
CArg<"mlir::ValueRange", "llvm::None">:$substr)>
];
- let verifier = "return ::verify(*this);";
+ let hasVerifier = 1;
let extraClassDeclaration = [{
unsigned getOutRank() { return getOutputRank(triples()); }
@@ -2059,7 +2035,7 @@ def fir_InsertOnRangeOp : fir_OneResultOp<"insert_on_range", [NoSideEffect]> {
$seq `,` $val custom<CustomRangeSubscript>($coor) attr-dict `:` functional-type(operands, results)
}];
- let verifier = "return ::verify(*this);";
+ let hasVerifier = 1;
}
def fir_LenParamIndexOp : fir_OneResultOp<"len_param_index", [NoSideEffect]> {
@@ -2081,9 +2057,7 @@ def fir_LenParamIndexOp : fir_OneResultOp<"len_param_index", [NoSideEffect]> {
let arguments = (ins StrAttr:$field_id, TypeAttr:$on_type);
- let parser = "return parseLenParamIndexOp(parser, result);";
-
- let printer = "::print(p, *this);";
+ let hasCustomAssemblyFormat = 1;
let builders = [OpBuilder<(ins "llvm::StringRef":$fieldName,
"mlir::Type":$recTy),
@@ -2120,7 +2094,7 @@ def fir_ResultOp : fir_Op<"result",
let assemblyFormat = "($results^ `:` type($results))? attr-dict";
- let verifier = "return ::verify(*this);";
+ let hasVerifier = 1;
}
def FirRegionTerminator : SingleBlockImplicitTerminator<"ResultOp">;
@@ -2388,8 +2362,7 @@ def fir_CallOp : fir_Op<"call", [CallOpInterface]> {
);
let results = (outs Variadic<AnyType>);
- let parser = "return parseCallOp(parser, result);";
- let printer = "printCallOp(p, *this);";
+ let hasCustomAssemblyFormat = 1;
let builders = [
OpBuilder<(ins "mlir::FuncOp":$callee,
@@ -2452,9 +2425,7 @@ def fir_DispatchOp : fir_Op<"dispatch", []> {
let results = (outs Variadic<AnyType>);
- let parser = "return parseDispatchOp(parser, result);";
-
- let printer = "::print(p, *this);";
+ let hasCustomAssemblyFormat = 1;
let extraClassDeclaration = [{
mlir::FunctionType getFunctionType();
@@ -2490,9 +2461,8 @@ def fir_StringLitOp : fir_Op<"string_lit", [NoSideEffect]> {
let results = (outs fir_CharacterType);
- let parser = "return parseStringLitOp(parser, result);";
-
- let printer = "::print(p, *this);";
+ let hasCustomAssemblyFormat = 1;
+ let hasVerifier = 1;
let builders = [
OpBuilder<(ins "fir::CharacterType":$inType,
@@ -2508,8 +2478,6 @@ def fir_StringLitOp : fir_Op<"string_lit", [NoSideEffect]> {
"llvm::ArrayRef<char32_t>":$xlist,
CArg<"llvm::Optional<int64_t>", "{}">:$len)>];
- let verifier = "return ::verify(*this);";
-
let extraClassDeclaration = [{
static constexpr const char *size() { return "size"; }
static constexpr const char *value() { return "value"; }
@@ -2556,11 +2524,8 @@ def fir_ConstcOp : fir_Op<"constc", [NoSideEffect]> {
let results = (outs fir_ComplexType);
- let parser = "return parseConstcOp(parser, result);";
-
- let printer = "::print(p, *this);";
-
- let verifier = "return ::verify(*this);";
+ let hasCustomAssemblyFormat = 1;
+ let hasVerifier = 1;
let extraClassDeclaration = [{
static constexpr llvm::StringRef realAttrName() { return "real"; }
@@ -2599,9 +2564,7 @@ def fir_CmpcOp : fir_Op<"cmpc",
let results = (outs AnyLogicalLike);
- let parser = "return parseCmpcOp(parser, result);";
-
- let printer = "printCmpcOp(p, *this);";
+ let hasCustomAssemblyFormat = 1;
let builders = [OpBuilder<(ins "mlir::arith::CmpFPredicate":$predicate,
"mlir::Value":$lhs, "mlir::Value":$rhs), [{
@@ -2668,7 +2631,7 @@ def fir_ConvertOp : fir_OneResultOp<"convert", [NoSideEffect]> {
let hasFolder = 1;
- let verifier = "return ::verify(*this);";
+ let hasVerifier = 1;
let extraClassDeclaration = [{
static bool isIntegerCompatible(mlir::Type ty);
@@ -2706,13 +2669,10 @@ def fir_GenTypeDescOp : fir_OneResultOp<"gentypedesc", [NoSideEffect]> {
let arguments = (ins FortranTypeAttr:$in_type);
- let parser = "return parseGenTypeDescOp(parser, result);";
-
- let printer = "::print(p, *this);";
+ let hasCustomAssemblyFormat = 1;
+ let hasVerifier = 1;
let builders = [OpBuilder<(ins "mlir::TypeAttr":$inty)>];
-
- let verifier = "return ::verify(*this);";
}
def fir_NoReassocOp : fir_OneResultOp<"no_reassoc",
@@ -2777,9 +2737,7 @@ def fir_GlobalOp : fir_Op<"global", [IsolatedFromAbove, Symbol]> {
let regions = (region AtMostRegion<1>:$region);
- let parser = "return parseGlobalOp(parser, result);";
-
- let printer = "::print(p, *this);";
+ let hasCustomAssemblyFormat = 1;
let skipDefaultBuilders = 1;
let builders = [
@@ -2862,9 +2820,7 @@ def fir_GlobalLenOp : fir_Op<"global_len", []> {
let arguments = (ins StrAttr:$lenparam, APIntAttr:$intval);
- let parser = "return parseGlobalLenOp(parser, result);";
-
- let printer = "::print(p, *this);";
+ let hasCustomAssemblyFormat = 1;
let extraClassDeclaration = [{
static constexpr llvm::StringRef lenParamAttrName() { return "lenparam"; }
@@ -2894,11 +2850,8 @@ def fir_DispatchTableOp : fir_Op<"dispatch_table",
```
}];
- let parser = "return parseDispatchTableOp(parser, result);";
-
- let printer = "::print(p, *this);";
-
- let verifier = "return ::verify(*this);";
+ let hasCustomAssemblyFormat = 1;
+ let hasVerifier = 1;
let regions = (region SizedRegion<1>:$region);
@@ -2940,9 +2893,7 @@ def fir_DTEntryOp : fir_Op<"dt_entry", [HasParent<"DispatchTableOp">]> {
let arguments = (ins StrAttr:$method, SymbolRefAttr:$proc);
- let parser = "return parseDTEntryOp(parser, result);";
-
- let printer = "::print(p, *this);";
+ let hasCustomAssemblyFormat = 1;
let extraClassDeclaration = [{
static constexpr llvm::StringRef getMethodAttrNameStr() { return "method"; }
diff --git a/flang/lib/Optimizer/Dialect/FIROps.cpp b/flang/lib/Optimizer/Dialect/FIROps.cpp
index 3c3a6646aa4c3..8d2a2ff64a83c 100644
--- a/flang/lib/Optimizer/Dialect/FIROps.cpp
+++ b/flang/lib/Optimizer/Dialect/FIROps.cpp
@@ -237,17 +237,24 @@ void fir::AllocaOp::build(mlir::OpBuilder &builder,
result.addAttributes(attributes);
}
-static mlir::LogicalResult verify(fir::AllocaOp &op) {
+mlir::ParseResult fir::AllocaOp::parse(OpAsmParser &parser,
+ OperationState &result) {
+ return parseAllocatableOp(wrapAllocaResultType, parser, result);
+}
+
+void fir::AllocaOp::print(OpAsmPrinter &p) { printAllocatableOp(p, *this); }
+
+mlir::LogicalResult fir::AllocaOp::verify() {
llvm::SmallVector<llvm::StringRef> visited;
- if (verifyInType(op.getInType(), visited, op.numShapeOperands()))
- return op.emitOpError("invalid type for allocation");
- if (verifyTypeParamCount(op.getInType(), op.numLenParams()))
- return op.emitOpError("LEN params do not correspond to type");
- mlir::Type outType = op.getType();
+ if (verifyInType(getInType(), visited, numShapeOperands()))
+ return emitOpError("invalid type for allocation");
+ if (verifyTypeParamCount(getInType(), numLenParams()))
+ return emitOpError("LEN params do not correspond to type");
+ mlir::Type outType = getType();
if (!outType.isa<fir::ReferenceType>())
- return op.emitOpError("must be a !fir.ref type");
+ return emitOpError("must be a !fir.ref type");
if (fir::isa_unknown_size_box(fir::dyn_cast_ptrEleTy(outType)))
- return op.emitOpError("cannot allocate !fir.box of unknown rank or type");
+ return emitOpError("cannot allocate !fir.box of unknown rank or type");
return mlir::success();
}
@@ -306,17 +313,24 @@ void fir::AllocMemOp::build(mlir::OpBuilder &builder,
result.addAttributes(attributes);
}
-static mlir::LogicalResult verify(fir::AllocMemOp op) {
+mlir::ParseResult AllocMemOp::parse(OpAsmParser &parser,
+ OperationState &result) {
+ return parseAllocatableOp(wrapAllocMemResultType, parser, result);
+}
+
+void AllocMemOp::print(OpAsmPrinter &p) { printAllocatableOp(p, *this); }
+
+mlir::LogicalResult AllocMemOp::verify() {
llvm::SmallVector<llvm::StringRef> visited;
- if (verifyInType(op.getInType(), visited, op.numShapeOperands()))
- return op.emitOpError("invalid type for allocation");
- if (verifyTypeParamCount(op.getInType(), op.numLenParams()))
- return op.emitOpError("LEN params do not correspond to type");
- mlir::Type outType = op.getType();
+ if (verifyInType(getInType(), visited, numShapeOperands()))
+ return emitOpError("invalid type for allocation");
+ if (verifyTypeParamCount(getInType(), numLenParams()))
+ return emitOpError("LEN params do not correspond to type");
+ mlir::Type outType = getType();
if (!outType.dyn_cast<fir::HeapType>())
- return op.emitOpError("must be a !fir.heap type");
+ return emitOpError("must be a !fir.heap type");
if (fir::isa_unknown_size_box(fir::dyn_cast_ptrEleTy(outType)))
- return op.emitOpError("cannot allocate !fir.box of unknown rank or type");
+ return emitOpError("cannot allocate !fir.box of unknown rank or type");
return mlir::success();
}
@@ -324,14 +338,14 @@ static mlir::LogicalResult verify(fir::AllocMemOp op) {
// ArrayCoorOp
//===----------------------------------------------------------------------===//
-static mlir::LogicalResult verify(fir::ArrayCoorOp op) {
- auto eleTy = fir::dyn_cast_ptrOrBoxEleTy(op.memref().getType());
+mlir::LogicalResult ArrayCoorOp::verify() {
+ auto eleTy = fir::dyn_cast_ptrOrBoxEleTy(memref().getType());
auto arrTy = eleTy.dyn_cast<fir::SequenceType>();
if (!arrTy)
- return op.emitOpError("must be a reference to an array");
+ return emitOpError("must be a reference to an array");
auto arrDim = arrTy.getDimension();
- if (auto shapeOp = op.shape()) {
+ if (auto shapeOp = shape()) {
auto shapeTy = shapeOp.getType();
unsigned shapeTyRank = 0;
if (auto s = shapeTy.dyn_cast<fir::ShapeType>()) {
@@ -341,22 +355,22 @@ static mlir::LogicalResult verify(fir::ArrayCoorOp op) {
} else {
auto s = shapeTy.cast<fir::ShiftType>();
shapeTyRank = s.getRank();
- if (!op.memref().getType().isa<fir::BoxType>())
- return op.emitOpError("shift can only be provided with fir.box memref");
+ if (!memref().getType().isa<fir::BoxType>())
+ return emitOpError("shift can only be provided with fir.box memref");
}
if (arrDim && arrDim != shapeTyRank)
- return op.emitOpError("rank of dimension mismatched");
- if (shapeTyRank != op.indices().size())
- return op.emitOpError("number of indices do not match dim rank");
+ return emitOpError("rank of dimension mismatched");
+ if (shapeTyRank != indices().size())
+ return emitOpError("number of indices do not match dim rank");
}
- if (auto sliceOp = op.slice()) {
+ if (auto sliceOp = slice()) {
if (auto sl = mlir::dyn_cast_or_null<fir::SliceOp>(sliceOp.getDefiningOp()))
if (!sl.substr().empty())
- return op.emitOpError("array_coor cannot take a slice with substring");
+ return emitOpError("array_coor cannot take a slice with substring");
if (auto sliceTy = sliceOp.getType().dyn_cast<fir::SliceType>())
if (sliceTy.getRank() != arrDim)
- return op.emitOpError("rank of dimension in slice mismatched");
+ return emitOpError("rank of dimension in slice mismatched");
}
return mlir::success();
@@ -391,14 +405,14 @@ std::vector<mlir::Value> fir::ArrayLoadOp::getExtents() {
return {};
}
-static mlir::LogicalResult verify(fir::ArrayLoadOp op) {
- auto eleTy = fir::dyn_cast_ptrOrBoxEleTy(op.memref().getType());
+mlir::LogicalResult ArrayLoadOp::verify() {
+ auto eleTy = fir::dyn_cast_ptrOrBoxEleTy(memref().getType());
auto arrTy = eleTy.dyn_cast<fir::SequenceType>();
if (!arrTy)
- return op.emitOpError("must be a reference to an array");
+ return emitOpError("must be a reference to an array");
auto arrDim = arrTy.getDimension();
- if (auto shapeOp = op.shape()) {
+ if (auto shapeOp = shape()) {
auto shapeTy = shapeOp.getType();
unsigned shapeTyRank = 0;
if (auto s = shapeTy.dyn_cast<fir::ShapeType>()) {
@@ -408,20 +422,20 @@ static mlir::LogicalResult verify(fir::ArrayLoadOp op) {
} else {
auto s = shapeTy.cast<fir::ShiftType>();
shapeTyRank = s.getRank();
- if (!op.memref().getType().isa<fir::BoxType>())
- return op.emitOpError("shift can only be provided with fir.box memref");
+ if (!memref().getType().isa<fir::BoxType>())
+ return emitOpError("shift can only be provided with fir.box memref");
}
if (arrDim && arrDim != shapeTyRank)
- return op.emitOpError("rank of dimension mismatched");
+ return emitOpError("rank of dimension mismatched");
}
- if (auto sliceOp = op.slice()) {
+ if (auto sliceOp = slice()) {
if (auto sl = mlir::dyn_cast_or_null<fir::SliceOp>(sliceOp.getDefiningOp()))
if (!sl.substr().empty())
- return op.emitOpError("array_load cannot take a slice with substring");
+ return emitOpError("array_load cannot take a slice with substring");
if (auto sliceTy = sliceOp.getType().dyn_cast<fir::SliceType>())
if (sliceTy.getRank() != arrDim)
- return op.emitOpError("rank of dimension in slice mismatched");
+ return emitOpError("rank of dimension in slice mismatched");
}
return mlir::success();
@@ -431,41 +445,40 @@ static mlir::LogicalResult verify(fir::ArrayLoadOp op) {
// ArrayMergeStoreOp
//===----------------------------------------------------------------------===//
-static mlir::LogicalResult verify(fir::ArrayMergeStoreOp op) {
- if (!isa<ArrayLoadOp>(op.original().getDefiningOp()))
- return op.emitOpError("operand #0 must be result of a fir.array_load op");
- if (auto sl = op.slice()) {
+mlir::LogicalResult ArrayMergeStoreOp::verify() {
+ if (!isa<ArrayLoadOp>(original().getDefiningOp()))
+ return emitOpError("operand #0 must be result of a fir.array_load op");
+ if (auto sl = slice()) {
if (auto sliceOp =
mlir::dyn_cast_or_null<fir::SliceOp>(sl.getDefiningOp())) {
if (!sliceOp.substr().empty())
- return op.emitOpError(
+ return emitOpError(
"array_merge_store cannot take a slice with substring");
if (!sliceOp.fields().empty()) {
// This is an intra-object merge, where the slice is projecting the
// subfields that are to be overwritten by the merge operation.
- auto eleTy = fir::dyn_cast_ptrOrBoxEleTy(op.memref().getType());
+ auto eleTy = fir::dyn_cast_ptrOrBoxEleTy(memref().getType());
if (auto seqTy = eleTy.dyn_cast<fir::SequenceType>()) {
auto projTy =
fir::applyPathToType(seqTy.getEleTy(), sliceOp.fields());
- if (fir::unwrapSequenceType(op.original().getType()) != projTy)
- return op.emitOpError(
+ if (fir::unwrapSequenceType(original().getType()) != projTy)
+ return emitOpError(
"type of origin does not match sliced memref type");
- if (fir::unwrapSequenceType(op.sequence().getType()) != projTy)
- return op.emitOpError(
+ if (fir::unwrapSequenceType(sequence().getType()) != projTy)
+ return emitOpError(
"type of sequence does not match sliced memref type");
return mlir::success();
}
- return op.emitOpError("referenced type is not an array");
+ return emitOpError("referenced type is not an array");
}
}
return mlir::success();
}
- auto eleTy = fir::dyn_cast_ptrOrBoxEleTy(op.memref().getType());
- if (op.original().getType() != eleTy)
- return op.emitOpError("type of origin does not match memref element type");
- if (op.sequence().getType() != eleTy)
- return op.emitOpError(
- "type of sequence does not match memref element type");
+ auto eleTy = fir::dyn_cast_ptrOrBoxEleTy(memref().getType());
+ if (original().getType() != eleTy)
+ return emitOpError("type of origin does not match memref element type");
+ if (sequence().getType() != eleTy)
+ return emitOpError("type of sequence does not match memref element type");
return mlir::success();
}
@@ -480,19 +493,19 @@ mlir::Type validArraySubobject(A op) {
return fir::applyPathToType(ty, op.indices());
}
-static mlir::LogicalResult verify(fir::ArrayFetchOp op) {
- auto arrTy = op.sequence().getType().cast<fir::SequenceType>();
- auto indSize = op.indices().size();
+mlir::LogicalResult ArrayFetchOp::verify() {
+ auto arrTy = sequence().getType().cast<fir::SequenceType>();
+ auto indSize = indices().size();
if (indSize < arrTy.getDimension())
- return op.emitOpError("number of indices != dimension of array");
+ return emitOpError("number of indices != dimension of array");
if (indSize == arrTy.getDimension() &&
- ::adjustedElementType(op.element().getType()) != arrTy.getEleTy())
- return op.emitOpError("return type does not match array");
- auto ty = validArraySubobject(op);
- if (!ty || ty != ::adjustedElementType(op.getType()))
- return op.emitOpError("return type and/or indices do not type check");
- if (!isa<fir::ArrayLoadOp>(op.sequence().getDefiningOp()))
- return op.emitOpError("argument #0 must be result of fir.array_load");
+ ::adjustedElementType(element().getType()) != arrTy.getEleTy())
+ return emitOpError("return type does not match array");
+ auto ty = validArraySubobject(*this);
+ if (!ty || ty != ::adjustedElementType(getType()))
+ return emitOpError("return type and/or indices do not type check");
+ if (!isa<fir::ArrayLoadOp>(sequence().getDefiningOp()))
+ return emitOpError("argument #0 must be result of fir.array_load");
return mlir::success();
}
@@ -500,17 +513,17 @@ static mlir::LogicalResult verify(fir::ArrayFetchOp op) {
// ArrayAccessOp
//===----------------------------------------------------------------------===//
-static mlir::LogicalResult verify(fir::ArrayAccessOp op) {
- auto arrTy = op.sequence().getType().cast<fir::SequenceType>();
- std::size_t indSize = op.indices().size();
+mlir::LogicalResult ArrayAccessOp::verify() {
+ auto arrTy = sequence().getType().cast<fir::SequenceType>();
+ std::size_t indSize = indices().size();
if (indSize < arrTy.getDimension())
- return op.emitOpError("number of indices != dimension of array");
+ return emitOpError("number of indices != dimension of array");
if (indSize == arrTy.getDimension() &&
- op.element().getType() != fir::ReferenceType::get(arrTy.getEleTy()))
- return op.emitOpError("return type does not match array");
- mlir::Type ty = validArraySubobject(op);
- if (!ty || fir::ReferenceType::get(ty) != op.getType())
- return op.emitOpError("return type and/or indices do not type check");
+ element().getType() != fir::ReferenceType::get(arrTy.getEleTy()))
+ return emitOpError("return type does not match array");
+ mlir::Type ty = validArraySubobject(*this);
+ if (!ty || fir::ReferenceType::get(ty) != getType())
+ return emitOpError("return type and/or indices do not type check");
return mlir::success();
}
@@ -518,19 +531,19 @@ static mlir::LogicalResult verify(fir::ArrayAccessOp op) {
// ArrayUpdateOp
//===----------------------------------------------------------------------===//
-static mlir::LogicalResult verify(fir::ArrayUpdateOp op) {
- if (fir::isa_ref_type(op.merge().getType()))
- return op.emitOpError("does not support reference type for merge");
- auto arrTy = op.sequence().getType().cast<fir::SequenceType>();
- auto indSize = op.indices().size();
+mlir::LogicalResult ArrayUpdateOp::verify() {
+ if (fir::isa_ref_type(merge().getType()))
+ return emitOpError("does not support reference type for merge");
+ auto arrTy = sequence().getType().cast<fir::SequenceType>();
+ auto indSize = indices().size();
if (indSize < arrTy.getDimension())
- return op.emitOpError("number of indices != dimension of array");
+ return emitOpError("number of indices != dimension of array");
if (indSize == arrTy.getDimension() &&
- ::adjustedElementType(op.merge().getType()) != arrTy.getEleTy())
- return op.emitOpError("merged value does not have element type");
- auto ty = validArraySubobject(op);
- if (!ty || ty != ::adjustedElementType(op.merge().getType()))
- return op.emitOpError("merged value and/or indices do not type check");
+ ::adjustedElementType(merge().getType()) != arrTy.getEleTy())
+ return emitOpError("merged value does not have element type");
+ auto ty = validArraySubobject(*this);
+ if (!ty || ty != ::adjustedElementType(merge().getType()))
+ return emitOpError("merged value and/or indices do not type check");
return mlir::success();
}
@@ -538,11 +551,11 @@ static mlir::LogicalResult verify(fir::ArrayUpdateOp op) {
// ArrayModifyOp
//===----------------------------------------------------------------------===//
-static mlir::LogicalResult verify(fir::ArrayModifyOp op) {
- auto arrTy = op.sequence().getType().cast<fir::SequenceType>();
- auto indSize = op.indices().size();
+mlir::LogicalResult ArrayModifyOp::verify() {
+ auto arrTy = sequence().getType().cast<fir::SequenceType>();
+ auto indSize = indices().size();
if (indSize < arrTy.getDimension())
- return op.emitOpError("number of indices must match array dimension");
+ return emitOpError("number of indices must match array dimension");
return mlir::success();
}
@@ -594,24 +607,23 @@ mlir::FunctionType fir::CallOp::getFunctionType() {
getResultTypes());
}
-static void printCallOp(mlir::OpAsmPrinter &p, fir::CallOp &op) {
- auto callee = op.callee();
- bool isDirect = callee.hasValue();
+void fir::CallOp::print(mlir::OpAsmPrinter &p) {
+ bool isDirect = callee().hasValue();
p << ' ';
if (isDirect)
- p << callee.getValue();
+ p << callee().getValue();
else
- p << op.getOperand(0);
- p << '(' << op->getOperands().drop_front(isDirect ? 0 : 1) << ')';
- p.printOptionalAttrDict(op->getAttrs(),
+ p << getOperand(0);
+ p << '(' << (*this)->getOperands().drop_front(isDirect ? 0 : 1) << ')';
+ p.printOptionalAttrDict((*this)->getAttrs(),
{fir::CallOp::getCalleeAttrNameStr()});
- auto resultTypes{op.getResultTypes()};
+ auto resultTypes{getResultTypes()};
llvm::SmallVector<Type> argTypes(
- llvm::drop_begin(op.getOperandTypes(), isDirect ? 0 : 1));
- p << " : " << FunctionType::get(op.getContext(), argTypes, resultTypes);
+ llvm::drop_begin(getOperandTypes(), isDirect ? 0 : 1));
+ p << " : " << FunctionType::get(getContext(), argTypes, resultTypes);
}
-static mlir::ParseResult parseCallOp(mlir::OpAsmParser &parser,
+mlir::ParseResult fir::CallOp::parse(mlir::OpAsmParser &parser,
mlir::OperationState &result) {
llvm::SmallVector<mlir::OpAsmParser::OperandType> operands;
if (parser.parseOperandList(operands))
@@ -725,17 +737,17 @@ static mlir::ParseResult parseCmpOp(mlir::OpAsmParser &parser,
// CharConvertOp
//===----------------------------------------------------------------------===//
-static mlir::LogicalResult verify(fir::CharConvertOp op) {
+mlir::LogicalResult CharConvertOp::verify() {
auto unwrap = [&](mlir::Type t) {
t = fir::unwrapSequenceType(fir::dyn_cast_ptrEleTy(t));
return t.dyn_cast<fir::CharacterType>();
};
- auto inTy = unwrap(op.from().getType());
- auto outTy = unwrap(op.to().getType());
+ auto inTy = unwrap(from().getType());
+ auto outTy = unwrap(to().getType());
if (!(inTy && outTy))
- return op.emitOpError("not a reference to a character");
+ return emitOpError("not a reference to a character");
if (inTy.getFKind() == outTy.getFKind())
- return op.emitOpError("buffers must have
diff erent KIND values");
+ return emitOpError("buffers must have
diff erent KIND values");
return mlir::success();
}
@@ -759,10 +771,10 @@ fir::CmpcOp::getPredicateByName(llvm::StringRef name) {
return pred.getValue();
}
-static void printCmpcOp(OpAsmPrinter &p, fir::CmpcOp op) { printCmpOp(p, op); }
+void CmpcOp::print(OpAsmPrinter &p) { printCmpOp(p, *this); }
-mlir::ParseResult fir::parseCmpcOp(mlir::OpAsmParser &parser,
- mlir::OperationState &result) {
+mlir::ParseResult CmpcOp::parse(mlir::OpAsmParser &parser,
+ mlir::OperationState &result) {
return parseCmpOp<fir::CmpcOp>(parser, result);
}
@@ -770,8 +782,8 @@ mlir::ParseResult fir::parseCmpcOp(mlir::OpAsmParser &parser,
// ConstcOp
//===----------------------------------------------------------------------===//
-static mlir::ParseResult parseConstcOp(mlir::OpAsmParser &parser,
- mlir::OperationState &result) {
+mlir::ParseResult ConstcOp::parse(mlir::OpAsmParser &parser,
+ mlir::OperationState &result) {
fir::RealAttr realp;
fir::RealAttr imagp;
mlir::Type type;
@@ -787,16 +799,16 @@ static mlir::ParseResult parseConstcOp(mlir::OpAsmParser &parser,
return mlir::success();
}
-static void print(mlir::OpAsmPrinter &p, fir::ConstcOp &op) {
+void ConstcOp::print(mlir::OpAsmPrinter &p) {
p << '(';
- p << op.getOperation()->getAttr(fir::ConstcOp::realAttrName()) << ", ";
- p << op.getOperation()->getAttr(fir::ConstcOp::imagAttrName()) << ") : ";
- p.printType(op.getType());
+ p << getOperation()->getAttr(fir::ConstcOp::realAttrName()) << ", ";
+ p << getOperation()->getAttr(fir::ConstcOp::imagAttrName()) << ") : ";
+ p.printType(getType());
}
-static mlir::LogicalResult verify(fir::ConstcOp &op) {
- if (!op.getType().isa<fir::ComplexType>())
- return op.emitOpError("must be a !fir.complex type");
+mlir::LogicalResult ConstcOp::verify() {
+ if (!getType().isa<fir::ComplexType>())
+ return emitOpError("must be a !fir.complex type");
return mlir::success();
}
@@ -847,37 +859,37 @@ bool fir::ConvertOp::isPointerCompatible(mlir::Type ty) {
ty.isa<fir::TypeDescType>();
}
-static mlir::LogicalResult verify(fir::ConvertOp &op) {
- auto inType = op.value().getType();
- auto outType = op.getType();
+mlir::LogicalResult ConvertOp::verify() {
+ auto inType = value().getType();
+ auto outType = getType();
if (inType == outType)
return mlir::success();
- if ((op.isPointerCompatible(inType) && op.isPointerCompatible(outType)) ||
- (op.isIntegerCompatible(inType) && op.isIntegerCompatible(outType)) ||
- (op.isIntegerCompatible(inType) && op.isFloatCompatible(outType)) ||
- (op.isFloatCompatible(inType) && op.isIntegerCompatible(outType)) ||
- (op.isFloatCompatible(inType) && op.isFloatCompatible(outType)) ||
- (op.isIntegerCompatible(inType) && op.isPointerCompatible(outType)) ||
- (op.isPointerCompatible(inType) && op.isIntegerCompatible(outType)) ||
+ if ((isPointerCompatible(inType) && isPointerCompatible(outType)) ||
+ (isIntegerCompatible(inType) && isIntegerCompatible(outType)) ||
+ (isIntegerCompatible(inType) && isFloatCompatible(outType)) ||
+ (isFloatCompatible(inType) && isIntegerCompatible(outType)) ||
+ (isFloatCompatible(inType) && isFloatCompatible(outType)) ||
+ (isIntegerCompatible(inType) && isPointerCompatible(outType)) ||
+ (isPointerCompatible(inType) && isIntegerCompatible(outType)) ||
(inType.isa<fir::BoxType>() && outType.isa<fir::BoxType>()) ||
(fir::isa_complex(inType) && fir::isa_complex(outType)))
return mlir::success();
- return op.emitOpError("invalid type conversion");
+ return emitOpError("invalid type conversion");
}
//===----------------------------------------------------------------------===//
// CoordinateOp
//===----------------------------------------------------------------------===//
-static void print(mlir::OpAsmPrinter &p, fir::CoordinateOp op) {
- p << ' ' << op.ref() << ", " << op.coor();
- p.printOptionalAttrDict(op->getAttrs(), /*elideAttrs=*/{"baseType"});
+void CoordinateOp::print(mlir::OpAsmPrinter &p) {
+ p << ' ' << ref() << ", " << coor();
+ p.printOptionalAttrDict((*this)->getAttrs(), /*elideAttrs=*/{"baseType"});
p << " : ";
- p.printFunctionalType(op.getOperandTypes(), op->getResultTypes());
+ p.printFunctionalType(getOperandTypes(), (*this)->getResultTypes());
}
-static mlir::ParseResult parseCoordinateCustom(mlir::OpAsmParser &parser,
- mlir::OperationState &result) {
+mlir::ParseResult CoordinateOp::parse(mlir::OpAsmParser &parser,
+ mlir::OperationState &result) {
mlir::OpAsmParser::OperandType memref;
if (parser.parseOperand(memref) || parser.parseComma())
return mlir::failure();
@@ -899,29 +911,29 @@ static mlir::ParseResult parseCoordinateCustom(mlir::OpAsmParser &parser,
return mlir::success();
}
-static mlir::LogicalResult verify(fir::CoordinateOp op) {
- auto refTy = op.ref().getType();
+mlir::LogicalResult CoordinateOp::verify() {
+ auto refTy = ref().getType();
if (fir::isa_ref_type(refTy)) {
auto eleTy = fir::dyn_cast_ptrEleTy(refTy);
if (auto arrTy = eleTy.dyn_cast<fir::SequenceType>()) {
if (arrTy.hasUnknownShape())
- return op.emitOpError("cannot find coordinate in unknown shape");
+ return emitOpError("cannot find coordinate in unknown shape");
if (arrTy.getConstantRows() < arrTy.getDimension() - 1)
- return op.emitOpError("cannot find coordinate with unknown extents");
+ return emitOpError("cannot find coordinate with unknown extents");
}
if (!(fir::isa_aggregate(eleTy) || fir::isa_complex(eleTy) ||
fir::isa_char_string(eleTy)))
- return op.emitOpError("cannot apply coordinate_of to this type");
+ return emitOpError("cannot apply coordinate_of to this type");
}
// Recovering a LEN type parameter only makes sense from a boxed value. For a
// bare reference, the LEN type parameters must be passed as additional
// arguments to `op`.
- for (auto co : op.coor())
+ for (auto co : coor())
if (dyn_cast_or_null<fir::LenParamIndexOp>(co.getDefiningOp())) {
- if (op.getNumOperands() != 2)
- return op.emitOpError("len_param_index must be last argument");
- if (!op.ref().getType().isa<BoxType>())
- return op.emitOpError("len_param_index must be used on box type");
+ if (getNumOperands() != 2)
+ return emitOpError("len_param_index must be last argument");
+ if (!ref().getType().isa<BoxType>())
+ return emitOpError("len_param_index must be used on box type");
}
return mlir::success();
}
@@ -935,8 +947,8 @@ mlir::FunctionType fir::DispatchOp::getFunctionType() {
getResultTypes());
}
-static mlir::ParseResult parseDispatchOp(mlir::OpAsmParser &parser,
- mlir::OperationState &result) {
+mlir::ParseResult DispatchOp::parse(mlir::OpAsmParser &parser,
+ mlir::OperationState &result) {
mlir::FunctionType calleeType;
llvm::SmallVector<mlir::OpAsmParser::OperandType> operands;
auto calleeLoc = parser.getNameLoc();
@@ -961,16 +973,16 @@ static mlir::ParseResult parseDispatchOp(mlir::OpAsmParser &parser,
return mlir::success();
}
-static void print(mlir::OpAsmPrinter &p, fir::DispatchOp &op) {
- p << ' ' << op.getMethodAttr() << '(';
- p.printOperand(op.object());
- if (!op.args().empty()) {
+void DispatchOp::print(mlir::OpAsmPrinter &p) {
+ p << ' ' << getMethodAttr() << '(';
+ p.printOperand(object());
+ if (!args().empty()) {
p << ", ";
- p.printOperands(op.args());
+ p.printOperands(args());
}
p << ") : ";
- p.printFunctionalType(op.getOperation()->getOperandTypes(),
- op.getOperation()->getResultTypes());
+ p.printFunctionalType(getOperation()->getOperandTypes(),
+ getOperation()->getResultTypes());
}
//===----------------------------------------------------------------------===//
@@ -983,8 +995,8 @@ void fir::DispatchTableOp::appendTableEntry(mlir::Operation *op) {
block.getOperations().insert(block.end(), op);
}
-static mlir::ParseResult parseDispatchTableOp(mlir::OpAsmParser &parser,
- mlir::OperationState &result) {
+mlir::ParseResult DispatchTableOp::parse(mlir::OpAsmParser &parser,
+ mlir::OperationState &result) {
// Parse the name as a symbol reference attribute.
SymbolRefAttr nameAttr;
if (parser.parseAttribute(nameAttr, mlir::SymbolTable::getSymbolAttrName(),
@@ -1006,14 +1018,14 @@ static mlir::ParseResult parseDispatchTableOp(mlir::OpAsmParser &parser,
return mlir::success();
}
-static void print(mlir::OpAsmPrinter &p, fir::DispatchTableOp &op) {
+void DispatchTableOp::print(mlir::OpAsmPrinter &p) {
auto tableName =
- op.getOperation()
+ getOperation()
->getAttrOfType<StringAttr>(mlir::SymbolTable::getSymbolAttrName())
.getValue();
p << " @" << tableName;
- Region &body = op.getOperation()->getRegion(0);
+ Region &body = getOperation()->getRegion(0);
if (!body.empty()) {
p << ' ';
p.printRegion(body, /*printEntryBlockArgs=*/false,
@@ -1021,8 +1033,8 @@ static void print(mlir::OpAsmPrinter &p, fir::DispatchTableOp &op) {
}
}
-static mlir::LogicalResult verify(fir::DispatchTableOp &op) {
- for (auto &op : op.getBlock())
+mlir::LogicalResult DispatchTableOp::verify() {
+ for (auto &op : getBlock())
if (!(isa<fir::DTEntryOp>(op) || isa<fir::FirEndOp>(op)))
return op.emitOpError("dispatch table must contain dt_entry");
return mlir::success();
@@ -1032,33 +1044,33 @@ static mlir::LogicalResult verify(fir::DispatchTableOp &op) {
// EmboxOp
//===----------------------------------------------------------------------===//
-static mlir::LogicalResult verify(fir::EmboxOp op) {
- auto eleTy = fir::dyn_cast_ptrEleTy(op.memref().getType());
+mlir::LogicalResult EmboxOp::verify() {
+ auto eleTy = fir::dyn_cast_ptrEleTy(memref().getType());
bool isArray = false;
if (auto seqTy = eleTy.dyn_cast<fir::SequenceType>()) {
eleTy = seqTy.getEleTy();
isArray = true;
}
- if (op.hasLenParams()) {
- auto lenPs = op.numLenParams();
+ if (hasLenParams()) {
+ auto lenPs = numLenParams();
if (auto rt = eleTy.dyn_cast<fir::RecordType>()) {
if (lenPs != rt.getNumLenParams())
- return op.emitOpError("number of LEN params does not correspond"
- " to the !fir.type type");
+ return emitOpError("number of LEN params does not correspond"
+ " to the !fir.type type");
} else if (auto strTy = eleTy.dyn_cast<fir::CharacterType>()) {
if (strTy.getLen() != fir::CharacterType::unknownLen())
- return op.emitOpError("CHARACTER already has static LEN");
+ return emitOpError("CHARACTER already has static LEN");
} else {
- return op.emitOpError("LEN parameters require CHARACTER or derived type");
+ return emitOpError("LEN parameters require CHARACTER or derived type");
}
- for (auto lp : op.typeparams())
+ for (auto lp : typeparams())
if (!fir::isa_integer(lp.getType()))
- return op.emitOpError("LEN parameters must be integral type");
+ return emitOpError("LEN parameters must be integral type");
}
- if (op.getShape() && !isArray)
- return op.emitOpError("shape must not be provided for a scalar");
- if (op.getSlice() && !isArray)
- return op.emitOpError("slice must not be provided for a scalar");
+ if (getShape() && !isArray)
+ return emitOpError("shape must not be provided for a scalar");
+ if (getSlice() && !isArray)
+ return emitOpError("slice must not be provided for a scalar");
return mlir::success();
}
@@ -1066,8 +1078,8 @@ static mlir::LogicalResult verify(fir::EmboxOp op) {
// EmboxCharOp
//===----------------------------------------------------------------------===//
-static mlir::LogicalResult verify(fir::EmboxCharOp &op) {
- auto eleTy = fir::dyn_cast_ptrEleTy(op.memref().getType());
+mlir::LogicalResult EmboxCharOp::verify() {
+ auto eleTy = fir::dyn_cast_ptrEleTy(memref().getType());
if (!eleTy.dyn_cast_or_null<CharacterType>())
return mlir::failure();
return mlir::success();
@@ -1077,8 +1089,8 @@ static mlir::LogicalResult verify(fir::EmboxCharOp &op) {
// EmboxProcOp
//===----------------------------------------------------------------------===//
-static mlir::ParseResult parseEmboxProcOp(mlir::OpAsmParser &parser,
- mlir::OperationState &result) {
+mlir::ParseResult EmboxProcOp::parse(mlir::OpAsmParser &parser,
+ mlir::OperationState &result) {
mlir::SymbolRefAttr procRef;
if (parser.parseAttribute(procRef, "funcname", result.attributes))
return mlir::failure();
@@ -1106,22 +1118,22 @@ static mlir::ParseResult parseEmboxProcOp(mlir::OpAsmParser &parser,
return mlir::success();
}
-static void print(mlir::OpAsmPrinter &p, fir::EmboxProcOp &op) {
- p << ' ' << op.getOperation()->getAttr("funcname");
- auto h = op.host();
+void EmboxProcOp::print(mlir::OpAsmPrinter &p) {
+ p << ' ' << getOperation()->getAttr("funcname");
+ auto h = host();
if (h) {
p << ", ";
p.printOperand(h);
}
- p << " : (" << op.getOperation()->getAttr("functype");
+ p << " : (" << getOperation()->getAttr("functype");
if (h)
p << ", " << h.getType();
- p << ") -> " << op.getType();
+ p << ") -> " << getType();
}
-static mlir::LogicalResult verify(fir::EmboxProcOp &op) {
+mlir::LogicalResult EmboxProcOp::verify() {
// host bindings (optional) must be a reference to a tuple
- if (auto h = op.host()) {
+ if (auto h = host()) {
if (auto r = h.getType().dyn_cast<ReferenceType>()) {
if (!r.getEleTy().dyn_cast<mlir::TupleType>())
return mlir::failure();
@@ -1142,8 +1154,8 @@ void fir::GenTypeDescOp::build(OpBuilder &, OperationState &result,
result.addTypes(TypeDescType::get(inty.getValue()));
}
-static mlir::ParseResult parseGenTypeDescOp(mlir::OpAsmParser &parser,
- mlir::OperationState &result) {
+mlir::ParseResult GenTypeDescOp::parse(mlir::OpAsmParser &parser,
+ mlir::OperationState &result) {
mlir::Type intype;
if (parser.parseType(intype))
return mlir::failure();
@@ -1154,18 +1166,18 @@ static mlir::ParseResult parseGenTypeDescOp(mlir::OpAsmParser &parser,
return mlir::success();
}
-static void print(mlir::OpAsmPrinter &p, fir::GenTypeDescOp &op) {
- p << ' ' << op.getOperation()->getAttr("in_type");
- p.printOptionalAttrDict(op.getOperation()->getAttrs(), {"in_type"});
+void GenTypeDescOp::print(mlir::OpAsmPrinter &p) {
+ p << ' ' << getOperation()->getAttr("in_type");
+ p.printOptionalAttrDict(getOperation()->getAttrs(), {"in_type"});
}
-static mlir::LogicalResult verify(fir::GenTypeDescOp &op) {
- mlir::Type resultTy = op.getType();
+mlir::LogicalResult GenTypeDescOp::verify() {
+ mlir::Type resultTy = getType();
if (auto tdesc = resultTy.dyn_cast<TypeDescType>()) {
- if (tdesc.getOfTy() != op.getInType())
- return op.emitOpError("wrapped type mismatched");
+ if (tdesc.getOfTy() != getInType())
+ return emitOpError("wrapped type mismatched");
} else {
- return op.emitOpError("must be !fir.tdesc type");
+ return emitOpError("must be !fir.tdesc type");
}
return mlir::success();
}
@@ -1178,7 +1190,7 @@ mlir::Type fir::GlobalOp::resultType() {
return wrapAllocaResultType(getType());
}
-static ParseResult parseGlobalOp(OpAsmParser &parser, OperationState &result) {
+ParseResult GlobalOp::parse(OpAsmParser &parser, OperationState &result) {
// Parse the optional linkage
llvm::StringRef linkage;
auto &builder = parser.getBuilder();
@@ -1231,20 +1243,20 @@ static ParseResult parseGlobalOp(OpAsmParser &parser, OperationState &result) {
return mlir::success();
}
-static void print(mlir::OpAsmPrinter &p, fir::GlobalOp &op) {
- if (op.linkName().hasValue())
- p << ' ' << op.linkName().getValue();
+void GlobalOp::print(mlir::OpAsmPrinter &p) {
+ if (linkName().hasValue())
+ p << ' ' << linkName().getValue();
p << ' ';
- p.printAttributeWithoutType(op.getSymrefAttr());
- if (auto val = op.getValueOrNull())
+ p.printAttributeWithoutType(getSymrefAttr());
+ if (auto val = getValueOrNull())
p << '(' << val << ')';
- if (op.getOperation()->getAttr(fir::GlobalOp::getConstantAttrNameStr()))
+ if (getOperation()->getAttr(fir::GlobalOp::getConstantAttrNameStr()))
p << " constant";
p << " : ";
- p.printType(op.getType());
- if (op.hasInitializationBody()) {
+ p.printType(getType());
+ if (hasInitializationBody()) {
p << ' ';
- p.printRegion(op.getOperation()->getRegion(0),
+ p.printRegion(getOperation()->getRegion(0),
/*printEntryBlockArgs=*/false,
/*printBlockTerminators=*/true);
}
@@ -1313,8 +1325,8 @@ mlir::ParseResult fir::GlobalOp::verifyValidLinkage(StringRef linkage) {
// GlobalLenOp
//===----------------------------------------------------------------------===//
-static mlir::ParseResult parseGlobalLenOp(mlir::OpAsmParser &parser,
- mlir::OperationState &result) {
+mlir::ParseResult GlobalLenOp::parse(mlir::OpAsmParser &parser,
+ mlir::OperationState &result) {
llvm::StringRef fieldName;
if (failed(parser.parseOptionalKeyword(&fieldName))) {
mlir::StringAttr fieldAttr;
@@ -1333,17 +1345,17 @@ static mlir::ParseResult parseGlobalLenOp(mlir::OpAsmParser &parser,
return mlir::success();
}
-static void print(mlir::OpAsmPrinter &p, fir::GlobalLenOp &op) {
- p << ' ' << op.getOperation()->getAttr(fir::GlobalLenOp::lenParamAttrName())
- << ", " << op.getOperation()->getAttr(fir::GlobalLenOp::intAttrName());
+void GlobalLenOp::print(mlir::OpAsmPrinter &p) {
+ p << ' ' << getOperation()->getAttr(fir::GlobalLenOp::lenParamAttrName())
+ << ", " << getOperation()->getAttr(fir::GlobalLenOp::intAttrName());
}
//===----------------------------------------------------------------------===//
// FieldIndexOp
//===----------------------------------------------------------------------===//
-static mlir::ParseResult parseFieldIndexOp(mlir::OpAsmParser &parser,
- mlir::OperationState &result) {
+mlir::ParseResult FieldIndexOp::parse(mlir::OpAsmParser &parser,
+ mlir::OperationState &result) {
llvm::StringRef fieldName;
auto &builder = parser.getBuilder();
mlir::Type recty;
@@ -1371,17 +1383,17 @@ static mlir::ParseResult parseFieldIndexOp(mlir::OpAsmParser &parser,
return mlir::success();
}
-static void print(mlir::OpAsmPrinter &p, fir::FieldIndexOp &op) {
+void FieldIndexOp::print(mlir::OpAsmPrinter &p) {
p << ' '
- << op.getOperation()
+ << getOperation()
->getAttrOfType<mlir::StringAttr>(fir::FieldIndexOp::fieldAttrName())
.getValue()
- << ", " << op.getOperation()->getAttr(fir::FieldIndexOp::typeAttrName());
- if (op.getNumOperands()) {
+ << ", " << getOperation()->getAttr(fir::FieldIndexOp::typeAttrName());
+ if (getNumOperands()) {
p << '(';
- p.printOperands(op.typeparams());
+ p.printOperands(typeparams());
const auto *sep = ") : ";
- for (auto op : op.typeparams()) {
+ for (auto op : typeparams()) {
p << sep;
if (op)
p.printType(op.getType());
@@ -1449,24 +1461,24 @@ void printCustomRangeSubscript(mlir::OpAsmPrinter &printer, InsertOnRangeOp op,
}
/// Range bounds must be nonnegative, and the range must not be empty.
-static mlir::LogicalResult verify(fir::InsertOnRangeOp op) {
- if (fir::hasDynamicSize(op.seq().getType()))
- return op.emitOpError("must have constant shape and size");
- mlir::DenseIntElementsAttr coor = op.coor();
- if (coor.size() < 2 || coor.size() % 2 != 0)
- return op.emitOpError("has uneven number of values in ranges");
+mlir::LogicalResult InsertOnRangeOp::verify() {
+ if (fir::hasDynamicSize(seq().getType()))
+ return emitOpError("must have constant shape and size");
+ mlir::DenseIntElementsAttr coorAttr = coor();
+ if (coorAttr.size() < 2 || coorAttr.size() % 2 != 0)
+ return emitOpError("has uneven number of values in ranges");
bool rangeIsKnownToBeNonempty = false;
- for (auto i = coor.getValues<int64_t>().end(),
- b = coor.getValues<int64_t>().begin();
+ for (auto i = coorAttr.getValues<int64_t>().end(),
+ b = coorAttr.getValues<int64_t>().begin();
i != b;) {
int64_t ub = (*--i);
int64_t lb = (*--i);
if (lb < 0 || ub < 0)
- return op.emitOpError("negative range bound");
+ return emitOpError("negative range bound");
if (rangeIsKnownToBeNonempty)
continue;
if (lb > ub)
- return op.emitOpError("empty range");
+ return emitOpError("empty range");
rangeIsKnownToBeNonempty = lb < ub;
}
return mlir::success();
@@ -1778,8 +1790,8 @@ mlir::Value fir::IterWhileOp::blockArgToSourceOp(unsigned blockArgNum) {
// LenParamIndexOp
//===----------------------------------------------------------------------===//
-static mlir::ParseResult parseLenParamIndexOp(mlir::OpAsmParser &parser,
- mlir::OperationState &result) {
+mlir::ParseResult LenParamIndexOp::parse(mlir::OpAsmParser &parser,
+ mlir::OperationState &result) {
llvm::StringRef fieldName;
auto &builder = parser.getBuilder();
mlir::Type recty;
@@ -1798,13 +1810,13 @@ static mlir::ParseResult parseLenParamIndexOp(mlir::OpAsmParser &parser,
return mlir::success();
}
-static void print(mlir::OpAsmPrinter &p, fir::LenParamIndexOp &op) {
+void LenParamIndexOp::print(mlir::OpAsmPrinter &p) {
p << ' '
- << op.getOperation()
+ << getOperation()
->getAttrOfType<mlir::StringAttr>(
fir::LenParamIndexOp::fieldAttrName())
.getValue()
- << ", " << op.getOperation()->getAttr(fir::LenParamIndexOp::typeAttrName());
+ << ", " << getOperation()->getAttr(fir::LenParamIndexOp::typeAttrName());
}
//===----------------------------------------------------------------------===//
@@ -1832,8 +1844,8 @@ mlir::ParseResult fir::LoadOp::getElementOf(mlir::Type &ele, mlir::Type ref) {
return mlir::failure();
}
-static mlir::ParseResult parseLoadOp(mlir::OpAsmParser &parser,
- mlir::OperationState &result) {
+mlir::ParseResult LoadOp::parse(mlir::OpAsmParser &parser,
+ mlir::OperationState &result) {
mlir::Type type;
mlir::OpAsmParser::OperandType oper;
if (parser.parseOperand(oper) ||
@@ -1848,11 +1860,11 @@ static mlir::ParseResult parseLoadOp(mlir::OpAsmParser &parser,
return mlir::success();
}
-static void print(mlir::OpAsmPrinter &p, fir::LoadOp &op) {
+void LoadOp::print(mlir::OpAsmPrinter &p) {
p << ' ';
- p.printOperand(op.memref());
- p.printOptionalAttrDict(op.getOperation()->getAttrs(), {});
- p << " : " << op.memref().getType();
+ p.printOperand(memref());
+ p.printOptionalAttrDict(getOperation()->getAttrs(), {});
+ p << " : " << memref().getType();
}
//===----------------------------------------------------------------------===//
@@ -2081,8 +2093,8 @@ mlir::Value fir::DoLoopOp::blockArgToSourceOp(unsigned blockArgNum) {
// DTEntryOp
//===----------------------------------------------------------------------===//
-static mlir::ParseResult parseDTEntryOp(mlir::OpAsmParser &parser,
- mlir::OperationState &result) {
+mlir::ParseResult DTEntryOp::parse(mlir::OpAsmParser &parser,
+ mlir::OperationState &result) {
llvm::StringRef methodName;
// allow `methodName` or `"methodName"`
if (failed(parser.parseOptionalKeyword(&methodName))) {
@@ -2103,8 +2115,8 @@ static mlir::ParseResult parseDTEntryOp(mlir::OpAsmParser &parser,
return mlir::success();
}
-static void print(mlir::OpAsmPrinter &p, fir::DTEntryOp &op) {
- p << ' ' << op.getMethodAttr() << ", " << op.getProcAttr();
+void DTEntryOp::print(mlir::OpAsmPrinter &p) {
+ p << ' ' << getMethodAttr() << ", " << getProcAttr();
}
//===----------------------------------------------------------------------===//
@@ -2128,43 +2140,43 @@ static unsigned getBoxRank(mlir::Type boxTy) {
return 0;
}
-static mlir::LogicalResult verify(fir::ReboxOp op) {
- auto inputBoxTy = op.box().getType();
+mlir::LogicalResult ReboxOp::verify() {
+ auto inputBoxTy = box().getType();
if (fir::isa_unknown_size_box(inputBoxTy))
- return op.emitOpError("box operand must not have unknown rank or type");
- auto outBoxTy = op.getType();
+ return emitOpError("box operand must not have unknown rank or type");
+ auto outBoxTy = getType();
if (fir::isa_unknown_size_box(outBoxTy))
- return op.emitOpError("result type must not have unknown rank or type");
+ return emitOpError("result type must not have unknown rank or type");
auto inputRank = getBoxRank(inputBoxTy);
auto inputEleTy = getBoxScalarEleTy(inputBoxTy);
auto outRank = getBoxRank(outBoxTy);
auto outEleTy = getBoxScalarEleTy(outBoxTy);
- if (auto slice = op.slice()) {
+ if (auto sliceVal = slice()) {
// Slicing case
- if (slice.getType().cast<fir::SliceType>().getRank() != inputRank)
- return op.emitOpError("slice operand rank must match box operand rank");
- if (auto shape = op.shape()) {
- if (auto shiftTy = shape.getType().dyn_cast<fir::ShiftType>()) {
+ if (sliceVal.getType().cast<fir::SliceType>().getRank() != inputRank)
+ return emitOpError("slice operand rank must match box operand rank");
+ if (auto shapeVal = shape()) {
+ if (auto shiftTy = shapeVal.getType().dyn_cast<fir::ShiftType>()) {
if (shiftTy.getRank() != inputRank)
- return op.emitOpError("shape operand and input box ranks must match "
- "when there is a slice");
+ return emitOpError("shape operand and input box ranks must match "
+ "when there is a slice");
} else {
- return op.emitOpError("shape operand must absent or be a fir.shift "
- "when there is a slice");
+ return emitOpError("shape operand must absent or be a fir.shift "
+ "when there is a slice");
}
}
- if (auto sliceOp = slice.getDefiningOp()) {
+ if (auto sliceOp = sliceVal.getDefiningOp()) {
auto slicedRank = mlir::cast<fir::SliceOp>(sliceOp).getOutRank();
if (slicedRank != outRank)
- return op.emitOpError("result type rank and rank after applying slice "
- "operand must match");
+ return emitOpError("result type rank and rank after applying slice "
+ "operand must match");
}
} else {
// Reshaping case
unsigned shapeRank = inputRank;
- if (auto shape = op.shape()) {
- auto ty = shape.getType();
+ if (auto shapeVal = shape()) {
+ auto ty = shapeVal.getType();
if (auto shapeTy = ty.dyn_cast<fir::ShapeType>()) {
shapeRank = shapeTy.getRank();
} else if (auto shapeShiftTy = ty.dyn_cast<fir::ShapeShiftType>()) {
@@ -2173,19 +2185,19 @@ static mlir::LogicalResult verify(fir::ReboxOp op) {
auto shiftTy = ty.cast<fir::ShiftType>();
shapeRank = shiftTy.getRank();
if (shapeRank != inputRank)
- return op.emitOpError("shape operand and input box ranks must match "
- "when the shape is a fir.shift");
+ return emitOpError("shape operand and input box ranks must match "
+ "when the shape is a fir.shift");
}
}
if (shapeRank != outRank)
- return op.emitOpError("result type and shape operand ranks must match");
+ return emitOpError("result type and shape operand ranks must match");
}
if (inputEleTy != outEleTy)
// TODO: check that outBoxTy is a parent type of inputBoxTy for derived
// types.
if (!inputEleTy.isa<fir::RecordType>())
- return op.emitOpError(
+ return emitOpError(
"op input and output element types must match for intrinsic types");
return mlir::success();
}
@@ -2194,17 +2206,16 @@ static mlir::LogicalResult verify(fir::ReboxOp op) {
// ResultOp
//===----------------------------------------------------------------------===//
-static mlir::LogicalResult verify(fir::ResultOp op) {
- auto *parentOp = op->getParentOp();
+mlir::LogicalResult ResultOp::verify() {
+ auto *parentOp = (*this)->getParentOp();
auto results = parentOp->getResults();
- auto operands = op->getOperands();
+ auto operands = (*this)->getOperands();
- if (parentOp->getNumResults() != op.getNumOperands())
- return op.emitOpError() << "parent of result must have same arity";
+ if (parentOp->getNumResults() != getNumOperands())
+ return emitOpError() << "parent of result must have same arity";
for (auto e : llvm::zip(results, operands))
if (std::get<0>(e).getType() != std::get<1>(e).getType())
- return op.emitOpError()
- << "types mismatch between result op and its parent";
+ return emitOpError() << "types mismatch between result op and its parent";
return success();
}
@@ -2212,24 +2223,24 @@ static mlir::LogicalResult verify(fir::ResultOp op) {
// SaveResultOp
//===----------------------------------------------------------------------===//
-static mlir::LogicalResult verify(fir::SaveResultOp op) {
- auto resultType = op.value().getType();
- if (resultType != fir::dyn_cast_ptrEleTy(op.memref().getType()))
- return op.emitOpError("value type must match memory reference type");
+mlir::LogicalResult SaveResultOp::verify() {
+ auto resultType = value().getType();
+ if (resultType != fir::dyn_cast_ptrEleTy(memref().getType()))
+ return emitOpError("value type must match memory reference type");
if (fir::isa_unknown_size_box(resultType))
- return op.emitOpError("cannot save !fir.box of unknown rank or type");
+ return emitOpError("cannot save !fir.box of unknown rank or type");
if (resultType.isa<fir::BoxType>()) {
- if (op.shape() || !op.typeparams().empty())
- return op.emitOpError(
+ if (shape() || !typeparams().empty())
+ return emitOpError(
"must not have shape or length operands if the value is a fir.box");
return mlir::success();
}
// fir.record or fir.array case.
unsigned shapeTyRank = 0;
- if (auto shapeOp = op.shape()) {
- auto shapeTy = shapeOp.getType();
+ if (auto shapeVal = shape()) {
+ auto shapeTy = shapeVal.getType();
if (auto s = shapeTy.dyn_cast<fir::ShapeType>())
shapeTyRank = s.getRank();
else
@@ -2239,27 +2250,26 @@ static mlir::LogicalResult verify(fir::SaveResultOp op) {
auto eleTy = resultType;
if (auto seqTy = resultType.dyn_cast<fir::SequenceType>()) {
if (seqTy.getDimension() != shapeTyRank)
- op.emitOpError("shape operand must be provided and have the value rank "
- "when the value is a fir.array");
+ emitOpError("shape operand must be provided and have the value rank "
+ "when the value is a fir.array");
eleTy = seqTy.getEleTy();
} else {
if (shapeTyRank != 0)
- op.emitOpError(
+ emitOpError(
"shape operand should only be provided if the value is a fir.array");
}
if (auto recTy = eleTy.dyn_cast<fir::RecordType>()) {
- if (recTy.getNumLenParams() != op.typeparams().size())
- op.emitOpError("length parameters number must match with the value type "
- "length parameters");
+ if (recTy.getNumLenParams() != typeparams().size())
+ emitOpError("length parameters number must match with the value type "
+ "length parameters");
} else if (auto charTy = eleTy.dyn_cast<fir::CharacterType>()) {
- if (op.typeparams().size() > 1)
- op.emitOpError("no more than one length parameter must be provided for "
- "character value");
+ if (typeparams().size() > 1)
+ emitOpError("no more than one length parameter must be provided for "
+ "character value");
} else {
- if (!op.typeparams().empty())
- op.emitOpError(
- "length parameters must not be provided for this value type");
+ if (!typeparams().empty())
+ emitOpError("length parameters must not be provided for this value type");
}
return mlir::success();
@@ -2400,8 +2410,8 @@ fir::SelectCaseOp::getSuccessorOperands(mlir::ValueRange operands,
}
// parser for fir.select_case Op
-static mlir::ParseResult parseSelectCase(mlir::OpAsmParser &parser,
- mlir::OperationState &result) {
+mlir::ParseResult SelectCaseOp::parse(mlir::OpAsmParser &parser,
+ mlir::OperationState &result) {
mlir::OpAsmParser::OperandType selector;
mlir::Type type;
if (parseSelector(parser, result, selector, type))
@@ -2473,20 +2483,19 @@ static mlir::ParseResult parseSelectCase(mlir::OpAsmParser &parser,
return mlir::success();
}
-static void print(mlir::OpAsmPrinter &p, fir::SelectCaseOp &op) {
+void SelectCaseOp::print(mlir::OpAsmPrinter &p) {
p << ' ';
- p.printOperand(op.getSelector());
- p << " : " << op.getSelector().getType() << " [";
- auto cases = op.getOperation()
- ->getAttrOfType<mlir::ArrayAttr>(op.getCasesAttr())
- .getValue();
- auto count = op.getNumConditions();
+ p.printOperand(getSelector());
+ p << " : " << getSelector().getType() << " [";
+ auto cases =
+ getOperation()->getAttrOfType<mlir::ArrayAttr>(getCasesAttr()).getValue();
+ auto count = getNumConditions();
for (decltype(count) i = 0; i != count; ++i) {
if (i)
p << ", ";
p << cases[i] << ", ";
if (!cases[i].isa<mlir::UnitAttr>()) {
- auto caseArgs = *op.getCompareOperands(i);
+ auto caseArgs = *getCompareOperands(i);
p.printOperand(*caseArgs.begin());
p << ", ";
if (cases[i].isa<fir::ClosedIntervalAttr>()) {
@@ -2494,13 +2503,12 @@ static void print(mlir::OpAsmPrinter &p, fir::SelectCaseOp &op) {
p << ", ";
}
}
- op.printSuccessorAtIndex(p, i);
+ printSuccessorAtIndex(p, i);
}
p << ']';
- p.printOptionalAttrDict(op.getOperation()->getAttrs(),
- {op.getCasesAttr(), getCompareOffsetAttr(),
- getTargetOffsetAttr(),
- op.getOperandSegmentSizeAttr()});
+ p.printOptionalAttrDict(getOperation()->getAttrs(),
+ {getCasesAttr(), getCompareOffsetAttr(),
+ getTargetOffsetAttr(), getOperandSegmentSizeAttr()});
}
unsigned fir::SelectCaseOp::compareOffsetSize() {
@@ -2591,31 +2599,30 @@ void fir::SelectCaseOp::build(mlir::OpBuilder &builder,
destOperands, attributes);
}
-static mlir::LogicalResult verify(fir::SelectCaseOp &op) {
- if (!(op.getSelector().getType().isa<mlir::IntegerType>() ||
- op.getSelector().getType().isa<mlir::IndexType>() ||
- op.getSelector().getType().isa<fir::IntegerType>() ||
- op.getSelector().getType().isa<fir::LogicalType>() ||
- op.getSelector().getType().isa<fir::CharacterType>()))
- return op.emitOpError("must be an integer, character, or logical");
- auto cases = op.getOperation()
- ->getAttrOfType<mlir::ArrayAttr>(op.getCasesAttr())
- .getValue();
- auto count = op.getNumDest();
+mlir::LogicalResult SelectCaseOp::verify() {
+ if (!(getSelector().getType().isa<mlir::IntegerType>() ||
+ getSelector().getType().isa<mlir::IndexType>() ||
+ getSelector().getType().isa<fir::IntegerType>() ||
+ getSelector().getType().isa<fir::LogicalType>() ||
+ getSelector().getType().isa<fir::CharacterType>()))
+ return emitOpError("must be an integer, character, or logical");
+ auto cases =
+ getOperation()->getAttrOfType<mlir::ArrayAttr>(getCasesAttr()).getValue();
+ auto count = getNumDest();
if (count == 0)
- return op.emitOpError("must have at least one successor");
- if (op.getNumConditions() != count)
- return op.emitOpError("number of conditions and successors don't match");
- if (op.compareOffsetSize() != count)
- return op.emitOpError("incorrect number of compare operand groups");
- if (op.targetOffsetSize() != count)
- return op.emitOpError("incorrect number of successor operand groups");
+ return emitOpError("must have at least one successor");
+ if (getNumConditions() != count)
+ return emitOpError("number of conditions and successors don't match");
+ if (compareOffsetSize() != count)
+ return emitOpError("incorrect number of compare operand groups");
+ if (targetOffsetSize() != count)
+ return emitOpError("incorrect number of successor operand groups");
for (decltype(count) i = 0; i != count; ++i) {
auto &attr = cases[i];
if (!(attr.isa<fir::PointIntervalAttr>() ||
attr.isa<fir::LowerBoundAttr>() || attr.isa<fir::UpperBoundAttr>() ||
attr.isa<fir::ClosedIntervalAttr>() || attr.isa<mlir::UnitAttr>()))
- return op.emitOpError("incorrect select case attribute type");
+ return emitOpError("incorrect select case attribute type");
}
return mlir::success();
}
@@ -2695,8 +2702,7 @@ fir::SelectTypeOp::getSuccessorOperands(llvm::ArrayRef<mlir::Value> operands,
return {getSubOperands(oper, getSubOperands(2, operands, segments), a)};
}
-static ParseResult parseSelectType(OpAsmParser &parser,
- OperationState &result) {
+ParseResult SelectTypeOp::parse(OpAsmParser &parser, OperationState &result) {
mlir::OpAsmParser::OperandType selector;
mlir::Type type;
if (parseSelector(parser, result, selector, type))
@@ -2745,45 +2751,43 @@ unsigned fir::SelectTypeOp::targetOffsetSize() {
getTargetOffsetAttr()));
}
-static void print(mlir::OpAsmPrinter &p, fir::SelectTypeOp &op) {
+void SelectTypeOp::print(mlir::OpAsmPrinter &p) {
p << ' ';
- p.printOperand(op.getSelector());
- p << " : " << op.getSelector().getType() << " [";
- auto cases = op.getOperation()
- ->getAttrOfType<mlir::ArrayAttr>(op.getCasesAttr())
- .getValue();
- auto count = op.getNumConditions();
+ p.printOperand(getSelector());
+ p << " : " << getSelector().getType() << " [";
+ auto cases =
+ getOperation()->getAttrOfType<mlir::ArrayAttr>(getCasesAttr()).getValue();
+ auto count = getNumConditions();
for (decltype(count) i = 0; i != count; ++i) {
if (i)
p << ", ";
p << cases[i] << ", ";
- op.printSuccessorAtIndex(p, i);
+ printSuccessorAtIndex(p, i);
}
p << ']';
- p.printOptionalAttrDict(op.getOperation()->getAttrs(),
- {op.getCasesAttr(), getCompareOffsetAttr(),
+ p.printOptionalAttrDict(getOperation()->getAttrs(),
+ {getCasesAttr(), getCompareOffsetAttr(),
getTargetOffsetAttr(),
fir::SelectTypeOp::getOperandSegmentSizeAttr()});
}
-static mlir::LogicalResult verify(fir::SelectTypeOp &op) {
- if (!(op.getSelector().getType().isa<fir::BoxType>()))
- return op.emitOpError("must be a boxed type");
- auto cases = op.getOperation()
- ->getAttrOfType<mlir::ArrayAttr>(op.getCasesAttr())
- .getValue();
- auto count = op.getNumDest();
+mlir::LogicalResult SelectTypeOp::verify() {
+ if (!(getSelector().getType().isa<fir::BoxType>()))
+ return emitOpError("must be a boxed type");
+ auto cases =
+ getOperation()->getAttrOfType<mlir::ArrayAttr>(getCasesAttr()).getValue();
+ auto count = getNumDest();
if (count == 0)
- return op.emitOpError("must have at least one successor");
- if (op.getNumConditions() != count)
- return op.emitOpError("number of conditions and successors don't match");
- if (op.targetOffsetSize() != count)
- return op.emitOpError("incorrect number of successor operand groups");
+ return emitOpError("must have at least one successor");
+ if (getNumConditions() != count)
+ return emitOpError("number of conditions and successors don't match");
+ if (targetOffsetSize() != count)
+ return emitOpError("incorrect number of successor operand groups");
for (decltype(count) i = 0; i != count; ++i) {
auto &attr = cases[i];
if (!(attr.isa<fir::ExactTypeAttr>() || attr.isa<fir::SubclassAttr>() ||
attr.isa<mlir::UnitAttr>()))
- return op.emitOpError("invalid type-case alternative");
+ return emitOpError("invalid type-case alternative");
}
return mlir::success();
}
@@ -2823,12 +2827,12 @@ void fir::SelectTypeOp::build(mlir::OpBuilder &builder,
// ShapeOp
//===----------------------------------------------------------------------===//
-static mlir::LogicalResult verify(fir::ShapeOp &op) {
- auto size = op.extents().size();
- auto shapeTy = op.getType().dyn_cast<fir::ShapeType>();
+mlir::LogicalResult ShapeOp::verify() {
+ auto size = extents().size();
+ auto shapeTy = getType().dyn_cast<fir::ShapeType>();
assert(shapeTy && "must be a shape type");
if (shapeTy.getRank() != size)
- return op.emitOpError("shape type rank mismatch");
+ return emitOpError("shape type rank mismatch");
return mlir::success();
}
@@ -2836,16 +2840,16 @@ static mlir::LogicalResult verify(fir::ShapeOp &op) {
// ShapeShiftOp
//===----------------------------------------------------------------------===//
-static mlir::LogicalResult verify(fir::ShapeShiftOp &op) {
- auto size = op.pairs().size();
+mlir::LogicalResult ShapeShiftOp::verify() {
+ auto size = pairs().size();
if (size < 2 || size > 16 * 2)
- return op.emitOpError("incorrect number of args");
+ return emitOpError("incorrect number of args");
if (size % 2 != 0)
- return op.emitOpError("requires a multiple of 2 args");
- auto shapeTy = op.getType().dyn_cast<fir::ShapeShiftType>();
+ return emitOpError("requires a multiple of 2 args");
+ auto shapeTy = getType().dyn_cast<fir::ShapeShiftType>();
assert(shapeTy && "must be a shape shift type");
if (shapeTy.getRank() * 2 != size)
- return op.emitOpError("shape type rank mismatch");
+ return emitOpError("shape type rank mismatch");
return mlir::success();
}
@@ -2853,12 +2857,12 @@ static mlir::LogicalResult verify(fir::ShapeShiftOp &op) {
// ShiftOp
//===----------------------------------------------------------------------===//
-static mlir::LogicalResult verify(fir::ShiftOp &op) {
- auto size = op.origins().size();
- auto shiftTy = op.getType().dyn_cast<fir::ShiftType>();
+mlir::LogicalResult ShiftOp::verify() {
+ auto size = origins().size();
+ auto shiftTy = getType().dyn_cast<fir::ShiftType>();
assert(shiftTy && "must be a shift type");
if (shiftTy.getRank() != size)
- return op.emitOpError("shift type rank mismatch");
+ return emitOpError("shift type rank mismatch");
return mlir::success();
}
@@ -2889,16 +2893,16 @@ unsigned fir::SliceOp::getOutputRank(mlir::ValueRange triples) {
return rank;
}
-static mlir::LogicalResult verify(fir::SliceOp &op) {
- auto size = op.triples().size();
+mlir::LogicalResult SliceOp::verify() {
+ auto size = triples().size();
if (size < 3 || size > 16 * 3)
- return op.emitOpError("incorrect number of args for triple");
+ return emitOpError("incorrect number of args for triple");
if (size % 3 != 0)
- return op.emitOpError("requires a multiple of 3 args");
- auto sliceTy = op.getType().dyn_cast<fir::SliceType>();
+ return emitOpError("requires a multiple of 3 args");
+ auto sliceTy = getType().dyn_cast<fir::SliceType>();
assert(sliceTy && "must be a slice type");
if (sliceTy.getRank() * 3 != size)
- return op.emitOpError("slice type rank mismatch");
+ return emitOpError("slice type rank mismatch");
return mlir::success();
}
@@ -2910,8 +2914,8 @@ mlir::Type fir::StoreOp::elementType(mlir::Type refType) {
return fir::dyn_cast_ptrEleTy(refType);
}
-static mlir::ParseResult parseStoreOp(mlir::OpAsmParser &parser,
- mlir::OperationState &result) {
+mlir::ParseResult StoreOp::parse(mlir::OpAsmParser &parser,
+ mlir::OperationState &result) {
mlir::Type type;
mlir::OpAsmParser::OperandType oper;
mlir::OpAsmParser::OperandType store;
@@ -2926,20 +2930,20 @@ static mlir::ParseResult parseStoreOp(mlir::OpAsmParser &parser,
return mlir::success();
}
-static void print(mlir::OpAsmPrinter &p, fir::StoreOp &op) {
+void StoreOp::print(mlir::OpAsmPrinter &p) {
p << ' ';
- p.printOperand(op.value());
+ p.printOperand(value());
p << " to ";
- p.printOperand(op.memref());
- p.printOptionalAttrDict(op.getOperation()->getAttrs(), {});
- p << " : " << op.memref().getType();
+ p.printOperand(memref());
+ p.printOptionalAttrDict(getOperation()->getAttrs(), {});
+ p << " : " << memref().getType();
}
-static mlir::LogicalResult verify(fir::StoreOp &op) {
- if (op.value().getType() != fir::dyn_cast_ptrEleTy(op.memref().getType()))
- return op.emitOpError("store value type must match memory reference type");
- if (fir::isa_unknown_size_box(op.value().getType()))
- return op.emitOpError("cannot store !fir.box of unknown rank or type");
+mlir::LogicalResult StoreOp::verify() {
+ if (value().getType() != fir::dyn_cast_ptrEleTy(memref().getType()))
+ return emitOpError("store value type must match memory reference type");
+ if (fir::isa_unknown_size_box(value().getType()))
+ return emitOpError("cannot store !fir.box of unknown rank or type");
return mlir::success();
}
@@ -3015,8 +3019,8 @@ void fir::StringLitOp::build(mlir::OpBuilder &builder, OperationState &result,
result.addTypes(inType);
}
-static mlir::ParseResult parseStringLitOp(mlir::OpAsmParser &parser,
- mlir::OperationState &result) {
+mlir::ParseResult StringLitOp::parse(mlir::OpAsmParser &parser,
+ mlir::OperationState &result) {
auto &builder = parser.getBuilder();
mlir::Attribute val;
mlir::NamedAttrList attrs;
@@ -3049,20 +3053,20 @@ static mlir::ParseResult parseStringLitOp(mlir::OpAsmParser &parser,
return mlir::success();
}
-static void print(mlir::OpAsmPrinter &p, fir::StringLitOp &op) {
- p << ' ' << op.getValue() << '(';
- p << op.getSize().cast<mlir::IntegerAttr>().getValue() << ") : ";
- p.printType(op.getType());
+void StringLitOp::print(mlir::OpAsmPrinter &p) {
+ p << ' ' << getValue() << '(';
+ p << getSize().cast<mlir::IntegerAttr>().getValue() << ") : ";
+ p.printType(getType());
}
-static mlir::LogicalResult verify(fir::StringLitOp &op) {
- if (op.getSize().cast<mlir::IntegerAttr>().getValue().isNegative())
- return op.emitOpError("size must be non-negative");
- if (auto xl = op.getOperation()->getAttr(fir::StringLitOp::xlist())) {
+mlir::LogicalResult StringLitOp::verify() {
+ if (getSize().cast<mlir::IntegerAttr>().getValue().isNegative())
+ return emitOpError("size must be non-negative");
+ if (auto xl = getOperation()->getAttr(fir::StringLitOp::xlist())) {
auto xList = xl.cast<mlir::ArrayAttr>();
for (auto a : xList)
if (!a.isa<mlir::IntegerAttr>())
- return op.emitOpError("values in list must be integers");
+ return emitOpError("values in list must be integers");
}
return mlir::success();
}
@@ -3071,11 +3075,11 @@ static mlir::LogicalResult verify(fir::StringLitOp &op) {
// UnboxProcOp
//===----------------------------------------------------------------------===//
-static mlir::LogicalResult verify(fir::UnboxProcOp &op) {
- if (auto eleTy = fir::dyn_cast_ptrEleTy(op.refTuple().getType()))
+mlir::LogicalResult UnboxProcOp::verify() {
+ if (auto eleTy = fir::dyn_cast_ptrEleTy(refTuple().getType()))
if (eleTy.isa<mlir::TupleType>())
return mlir::success();
- return op.emitOpError("second output argument has bad type");
+ return emitOpError("second output argument has bad type");
}
//===----------------------------------------------------------------------===//
More information about the flang-commits
mailing list