<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/57202>57202</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[MLIR AsmPrinter] Would be nice to have `mlir::AsmPrinter` that emits to `std::string`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir:core
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
lattner
</td>
</tr>
</table>
<pre>
It is useful to convert MLIR objects to strings (e.g. for generating diagnostics). MLIR has some helpers for this, e.g. it can emit things like attributes and type to a raw_ostream, which can be put into a string.
That said, the asmprinter interface is very rich and not everything is a default printing of an MLIR object. For example, there are myriad "custom<>" hooks that have useful functionality for specific cases, and I want some of their stringizing ability sometimes too.
It would be really helpful to have a subclass of AsmPrinter that emitted to and returned an std::string. This would allow reusing the printCustom sorts of hooks in other code.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxdVMFu2zAM_Rr7Qsxw5CZODj507QoU2IBhKLDjIEu0rVW2DIlqln39KMVduwGOE1Mk3-N7dHqnL90jgQkQAw7RAjlQbnlBT_Dl8-M3cP1PVBRSPJA3yxigEEesxgoG52HEBb0kjoM2clxcIKNCIU4VXOsnGSC4GWFCu6IPuYomwzl3kNsYAiUXwJl_8EFCsOYZQRLj9ZEwgFw00GXFxEKCl-cfjONRzqnJeTJqyi16hDXyMEtOu9Ktivq-qG-v96dJEgRpdKqjiTHCvHIWoYd8H6TCJAbPfwGf-iboxRFgCmV66VyCxkFGS5DLU9QNnPteM1bggWfFX3JeLW6InjH5M1-8kZqVFCoGcnPR3BXNJ36EyblnVjsRneQLvtoyxEWRcYu0hi5Zw7CiMoNRPHnArGai-ghnudBVcWbEiMZvSpjfiabsTW6RMsjMmJx1_4jE63B20eokJ2ts7SV7ty1HJsXixl5ZGUICuQ3z103EzDs5SaizWUzJI0W_8DPLE0gXzS1fmzkAT7wKGx5DuTOnx5CIJnuyuHdZISbsKcNdFTILuKQnb6vGjX-J3e5wqNt2v2-Ppe4afWpOsiRDFrti_zGb88a22N_D99dJF6Pw73zFoZ6t8Veq7woO9duE-ZXgyH8jcaSM3nYT0RrSgXjgazQ0xb5S7LR4sPbl9evD6l3aFX40IcTk48O-FbUopw7rdhAHsWsb0YqhF8dW9VrfqBPu9n3fHEore7QhDcaLs_FVzvOqCR6tNB33EfVx1wrRiH1b9Tvd7tTpKGt9uNk1x-KmxlkaWyUmlfNj6btMqo9j4ENrAoW3Q3bbjAtmJVN_GWlyXMHvKf8HlJl_l8n_Ablyd_s">