<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/151896>151896</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[MLIR] custom<SymbolName> in Symbol's assemblyFormat generates call to non-member versions of parseSymbolName and printSymbolName
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
xushengj
</td>
</tr>
</table>
<pre>
version: `llvmorg-20.1.8`
When I made the following Op definition: (`AssetDeclarationOp` has `Symbol` trait)
```
def ImageAssetOp : AssetDeclarationOp<"image_asset", []> {
...
let assemblyFormat = "custom<SymbolName>($sym_name) $asset_id `,` $imageattrs attr-dict `:` type($result)";
}
```
Tablegen emits the following code in `cpp.inc` that calls non-member version of parseSymbolName and printSymbolName:
```
::mlir::ParseResult ImageAssetOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
::mlir::StringAttr sym_nameAttr;
...
{
auto odsResult = parseSymbolName(parser, sym_nameAttr);
...
}
...
}
...
void ImageAssetOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
_odsPrinter << ' ';
printSymbolName(_odsPrinter, *this, getSymNameAttr());
...
}
```
However, in `mlir/IR/OpImplementation.h`, they are member functions of `AsmParser` and `AsmPrinter`, respectively, which causes the compilation to fail. I currently use the following workaround: (i.e., define non-member versions of the functions)
```
namespace mlir::preppipe::PrepPipe {
llvm::ParseResult parseSymbolName(AsmParser &parser,
StringAttr &result) {
return parser.parseSymbolName(result);
}
void printSymbolName(AsmPrinter &printer, Operation *op,
StringAttr symName) {
printer.printSymbolName(symName);
}
} // end namespace mlir::preppipe::PrepPipe
#define GET_OP_CLASSES
#include "preppipe-mlir/Dialect/PrepPipe/IR/PrepPipeOps.cpp.inc"
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyMVt2O4jgTfRpzUyIKDn-54CIDzfchzQ6tZqS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