Skip to content

Commit cd10d3d

Browse files
committed
[rebase] Remove explicit op names from fir op printers
The op name is now implicitly printed, the explicit printing of the op name in the printer cause duplication of the op name in the output. Remove all explicit op name printing in FIR op printers.
1 parent f5fd8d0 commit cd10d3d

File tree

2 files changed

+26
-27
lines changed

2 files changed

+26
-27
lines changed

flang/include/flang/Optimizer/Dialect/FIROps.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ class fir_IntegralSwitchTerminatorOp<string mnemonic,
597597
}];
598598

599599
let printer = [{
600-
p << getOperationName() << ' ';
600+
p << ' ';
601601
p.printOperand(getSelector());
602602
p << " : " << getSelector().getType() << " [";
603603
auto cases =
@@ -784,7 +784,7 @@ def fir_UnreachableOp : fir_Op<"unreachable", [Terminator]> {
784784

785785
let parser = "return mlir::success();";
786786

787-
let printer = "p << getOperationName();";
787+
let printer = "";
788788
}
789789

790790
def fir_FirEndOp : fir_Op<"end", [Terminator]> {

flang/lib/Optimizer/Dialect/FIROps.cpp

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static mlir::ParseResult parseAllocatableOp(FN wrapResultType,
131131

132132
template <typename OP>
133133
static void printAllocatableOp(mlir::OpAsmPrinter &p, OP &op) {
134-
p << op.getOperationName() << ' ' << op.in_type();
134+
p << ' ' << op.in_type();
135135
if (!op.typeparams().empty()) {
136136
p << '(' << op.typeparams() << " : " << op.typeparams().getTypes() << ')';
137137
}
@@ -592,7 +592,7 @@ mlir::FunctionType fir::CallOp::getFunctionType() {
592592
static void printCallOp(mlir::OpAsmPrinter &p, fir::CallOp &op) {
593593
auto callee = op.callee();
594594
bool isDirect = callee.hasValue();
595-
p << op.getOperationName() << ' ';
595+
p << ' ';
596596
if (isDirect)
597597
p << callee.getValue();
598598
else
@@ -685,7 +685,7 @@ static mlir::LogicalResult verify(fir::CharConvertOp op) {
685685

686686
template <typename OPTY>
687687
static void printCmpOp(OpAsmPrinter &p, OPTY op) {
688-
p << op.getOperationName() << ' ';
688+
p << ' ';
689689
auto predSym = mlir::arith::symbolizeCmpFPredicate(
690690
op->template getAttrOfType<mlir::IntegerAttr>(
691691
OPTY::getPredicateAttrName())
@@ -775,7 +775,7 @@ static mlir::ParseResult parseConstcOp(mlir::OpAsmParser &parser,
775775
}
776776

777777
static void print(mlir::OpAsmPrinter &p, fir::ConstcOp &op) {
778-
p << op.getOperationName() << " (0x";
778+
p << " (0x";
779779
auto f1 = op.getOperation()
780780
->getAttr(fir::ConstcOp::getRealAttrName())
781781
.cast<mlir::FloatAttr>();
@@ -867,7 +867,7 @@ static mlir::LogicalResult verify(fir::ConvertOp &op) {
867867
//===----------------------------------------------------------------------===//
868868

869869
static void print(mlir::OpAsmPrinter &p, fir::CoordinateOp op) {
870-
p << op.getOperationName() << ' ' << op.ref() << ", " << op.coor();
870+
p << ' ' << op.ref() << ", " << op.coor();
871871
p.printOptionalAttrDict(op->getAttrs(), /*elideAttrs=*/{"baseType"});
872872
p << " : ";
873873
p.printFunctionalType(op.getOperandTypes(), op->getResultTypes());
@@ -958,8 +958,8 @@ static mlir::ParseResult parseDispatchOp(mlir::OpAsmParser &parser,
958958
}
959959

960960
static void print(mlir::OpAsmPrinter &p, fir::DispatchOp &op) {
961-
p << op.getOperationName() << ' '
962-
<< op.getOperation()->getAttr(fir::DispatchOp::getMethodAttrName()) << '(';
961+
p << ' ' << op.getOperation()->getAttr(fir::DispatchOp::getMethodAttrName())
962+
<< '(';
963963
p.printOperand(op.object());
964964
if (!op.args().empty()) {
965965
p << ", ";
@@ -1009,7 +1009,7 @@ static void print(mlir::OpAsmPrinter &p, fir::DispatchTableOp &op) {
10091009
op.getOperation()
10101010
->getAttrOfType<StringAttr>(mlir::SymbolTable::getSymbolAttrName())
10111011
.getValue();
1012-
p << op.getOperationName() << " @" << tableName;
1012+
p << " @" << tableName;
10131013

10141014
Region &body = op.getOperation()->getRegion(0);
10151015
if (!body.empty())
@@ -1103,7 +1103,7 @@ static mlir::ParseResult parseEmboxProcOp(mlir::OpAsmParser &parser,
11031103
}
11041104

11051105
static void print(mlir::OpAsmPrinter &p, fir::EmboxProcOp &op) {
1106-
p << op.getOperationName() << ' ' << op.getOperation()->getAttr("funcname");
1106+
p << ' ' << op.getOperation()->getAttr("funcname");
11071107
auto h = op.host();
11081108
if (h) {
11091109
p << ", ";
@@ -1151,7 +1151,7 @@ static mlir::ParseResult parseGenTypeDescOp(mlir::OpAsmParser &parser,
11511151
}
11521152

11531153
static void print(mlir::OpAsmPrinter &p, fir::GenTypeDescOp &op) {
1154-
p << op.getOperationName() << ' ' << op.getOperation()->getAttr("in_type");
1154+
p << ' ' << op.getOperation()->getAttr("in_type");
11551155
p.printOptionalAttrDict(op.getOperation()->getAttrs(), {"in_type"});
11561156
}
11571157

@@ -1230,7 +1230,6 @@ static ParseResult parseGlobalOp(OpAsmParser &parser, OperationState &result) {
12301230
}
12311231

12321232
static void print(mlir::OpAsmPrinter &p, fir::GlobalOp &op) {
1233-
p << op.getOperationName();
12341233
if (op.linkName().hasValue())
12351234
p << ' ' << op.linkName().getValue();
12361235
p << ' ';
@@ -1333,7 +1332,7 @@ static mlir::ParseResult parseGlobalLenOp(mlir::OpAsmParser &parser,
13331332
}
13341333

13351334
static void print(mlir::OpAsmPrinter &p, fir::GlobalLenOp &op) {
1336-
p << op.getOperationName() << ' '
1335+
p << ' '
13371336
<< op.getOperation()->getAttr(fir::GlobalLenOp::getLenParamAttrName())
13381337
<< ", " << op.getOperation()->getAttr(fir::GlobalLenOp::getIntAttrName());
13391338
}
@@ -1417,7 +1416,7 @@ static mlir::ParseResult parseFieldIndexOp(mlir::OpAsmParser &parser,
14171416
}
14181417

14191418
static void print(mlir::OpAsmPrinter &p, fir::FieldIndexOp &op) {
1420-
p << op.getOperationName() << ' '
1419+
p << ' '
14211420
<< op.getOperation()
14221421
->getAttrOfType<mlir::StringAttr>(fir::FieldIndexOp::getFieldAttrName())
14231422
.getValue()
@@ -1726,7 +1725,7 @@ static mlir::LogicalResult verify(fir::IterWhileOp op) {
17261725
}
17271726

17281727
static void print(mlir::OpAsmPrinter &p, fir::IterWhileOp op) {
1729-
p << fir::IterWhileOp::getOperationName() << " (" << op.getInductionVar()
1728+
p << " (" << op.getInductionVar()
17301729
<< " = " << op.lowerBound() << " to " << op.upperBound() << " step "
17311730
<< op.step() << ") and (";
17321731
assert(op.hasIterOperands());
@@ -1810,7 +1809,7 @@ static mlir::ParseResult parseLenParamIndexOp(mlir::OpAsmParser &parser,
18101809
}
18111810

18121811
static void print(mlir::OpAsmPrinter &p, fir::LenParamIndexOp &op) {
1813-
p << op.getOperationName() << ' '
1812+
p << ' '
18141813
<< op.getOperation()
18151814
->getAttrOfType<mlir::StringAttr>(
18161815
fir::LenParamIndexOp::getFieldAttrName())
@@ -1861,7 +1860,7 @@ static mlir::ParseResult parseLoadOp(mlir::OpAsmParser &parser,
18611860
}
18621861

18631862
static void print(mlir::OpAsmPrinter &p, fir::LoadOp &op) {
1864-
p << op.getOperationName() << ' ';
1863+
p << ' ';
18651864
p.printOperand(op.memref());
18661865
p.printOptionalAttrDict(op.getOperation()->getAttrs(), {});
18671866
p << " : " << op.memref().getType();
@@ -2023,7 +2022,7 @@ static mlir::LogicalResult verify(fir::DoLoopOp op) {
20232022

20242023
static void print(mlir::OpAsmPrinter &p, fir::DoLoopOp op) {
20252024
bool printBlockTerminators = false;
2026-
p << fir::DoLoopOp::getOperationName() << ' ' << op.getInductionVar() << " = "
2025+
p << ' ' << op.getInductionVar() << " = "
20272026
<< op.lowerBound() << " to " << op.upperBound() << " step " << op.step();
20282027
if (op.unordered())
20292028
p << " unordered";
@@ -2113,7 +2112,7 @@ static mlir::ParseResult parseDTEntryOp(mlir::OpAsmParser &parser,
21132112
}
21142113

21152114
static void print(mlir::OpAsmPrinter &p, fir::DTEntryOp &op) {
2116-
p << op.getOperationName() << ' '
2115+
p << ' '
21172116
<< op.getOperation()->getAttr(fir::DTEntryOp::getMethodAttrName()) << ", "
21182117
<< op.getOperation()->getAttr(fir::DTEntryOp::getProcAttrName());
21192118
}
@@ -2456,7 +2455,7 @@ static mlir::ParseResult parseSelectCase(mlir::OpAsmParser &parser,
24562455
}
24572456

24582457
static void print(mlir::OpAsmPrinter &p, fir::SelectCaseOp &op) {
2459-
p << op.getOperationName() << ' ';
2458+
p << ' ';
24602459
p.printOperand(op.getSelector());
24612460
p << " : " << op.getSelector().getType() << " [";
24622461
auto cases = op.getOperation()
@@ -2718,7 +2717,7 @@ unsigned fir::SelectTypeOp::targetOffsetSize() {
27182717
}
27192718

27202719
static void print(mlir::OpAsmPrinter &p, fir::SelectTypeOp &op) {
2721-
p << op.getOperationName() << ' ';
2720+
p << ' ';
27222721
p.printOperand(op.getSelector());
27232722
p << " : " << op.getSelector().getType() << " [";
27242723
auto cases = op.getOperation()
@@ -2899,7 +2898,7 @@ static mlir::ParseResult parseStoreOp(mlir::OpAsmParser &parser,
28992898
}
29002899

29012900
static void print(mlir::OpAsmPrinter &p, fir::StoreOp &op) {
2902-
p << op.getOperationName() << ' ';
2901+
p << ' ';
29032902
p.printOperand(op.value());
29042903
p << " to ";
29052904
p.printOperand(op.memref());
@@ -3022,7 +3021,7 @@ static mlir::ParseResult parseStringLitOp(mlir::OpAsmParser &parser,
30223021
}
30233022

30243023
static void print(mlir::OpAsmPrinter &p, fir::StringLitOp &op) {
3025-
p << op.getOperationName() << ' ' << op.getValue() << '(';
3024+
p << ' ' << op.getValue() << '(';
30263025
p << op.getSize().cast<mlir::IntegerAttr>().getValue() << ") : ";
30273026
p.printType(op.getType());
30283027
}
@@ -3119,7 +3118,7 @@ static LogicalResult verify(fir::IfOp op) {
31193118

31203119
static void print(mlir::OpAsmPrinter &p, fir::IfOp op) {
31213120
bool printBlockTerminators = false;
3122-
p << fir::IfOp::getOperationName() << ' ' << op.condition();
3121+
p << ' ' << op.condition();
31233122
if (!op.results().empty()) {
31243123
p << " -> (" << op.getResultTypes() << ')';
31253124
printBlockTerminators = true;
@@ -3189,7 +3188,7 @@ static void printBinaryOp(Operation *op, OpAsmPrinter &p) {
31893188
assert(op->getNumOperands() == 2 && "binary op must have two operands");
31903189
assert(op->getNumResults() == 1 && "binary op must have one result");
31913190

3192-
p << op->getName() << ' ' << op->getOperand(0) << ", " << op->getOperand(1);
3191+
p << ' ' << op->getOperand(0) << ", " << op->getOperand(1);
31933192
p.printOptionalAttrDict(op->getAttrs());
31943193
p << " : " << op->getResult(0).getType();
31953194
}
@@ -3199,7 +3198,7 @@ static void printUnaryOp(Operation *op, OpAsmPrinter &p) {
31993198
assert(op->getNumOperands() == 1 && "unary op must have one operand");
32003199
assert(op->getNumResults() == 1 && "unary op must have one result");
32013200

3202-
p << op->getName() << ' ' << op->getOperand(0);
3201+
p << ' ' << op->getOperand(0);
32033202
p.printOptionalAttrDict(op->getAttrs());
32043203
p << " : " << op->getResult(0).getType();
32053204
}

0 commit comments

Comments
 (0)