Skip to content

Commit 165fdaa

Browse files
authored
[flang][NFC] Remove hardcoded attr name for fir.dispatch and fid.dt_entry ops (#81348)
These hardcoded attribute name are a leftover from the upstreaming period when there was no way to get the attribute name without an instance of the operation. It is since possible to do without them and they should be removed to avoid duplication. This PR cleanup the fir.dt_entry and fir.dispatch ops of these hardcoded attribute name and use their generated getters. Some other PRs will follow to cleanup other operations.
1 parent 7d9c38a commit 165fdaa

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2433,7 +2433,6 @@ def fir_DispatchOp : fir_Op<"dispatch", []> {
24332433
// operand[0] is the object (of class type)
24342434
operand_iterator arg_operand_begin() { return operand_begin() + 1; }
24352435
operand_iterator arg_operand_end() { return operand_end(); }
2436-
static constexpr llvm::StringRef getMethodAttrNameStr() { return "method"; }
24372436
}];
24382437
}
24392438

@@ -2922,7 +2921,6 @@ def fir_DTEntryOp : fir_Op<"dt_entry", [HasParent<"TypeInfoOp">]> {
29222921
let hasCustomAssemblyFormat = 1;
29232922

29242923
let extraClassDeclaration = [{
2925-
static constexpr llvm::StringRef getMethodAttrNameStr() { return "method"; }
29262924
static constexpr llvm::StringRef getProcAttrNameStr() { return "proc"; }
29272925
}];
29282926
}

flang/lib/Optimizer/Dialect/FIROps.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2289,12 +2289,11 @@ mlir::ParseResult fir::DTEntryOp::parse(mlir::OpAsmParser &parser,
22892289
// allow `methodName` or `"methodName"`
22902290
if (failed(parser.parseOptionalKeyword(&methodName))) {
22912291
mlir::StringAttr methodAttr;
2292-
if (parser.parseAttribute(methodAttr,
2293-
fir::DTEntryOp::getMethodAttrNameStr(),
2292+
if (parser.parseAttribute(methodAttr, getMethodAttrName(result.name),
22942293
result.attributes))
22952294
return mlir::failure();
22962295
} else {
2297-
result.addAttribute(fir::DTEntryOp::getMethodAttrNameStr(),
2296+
result.addAttribute(getMethodAttrName(result.name),
22982297
parser.getBuilder().getStringAttr(methodName));
22992298
}
23002299
mlir::SymbolRefAttr calleeAttr;

0 commit comments

Comments
 (0)