<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/56355>56355</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [MLIR Core] improvements to `SubElement{Type|Attr}Interface`
        </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>
    `SubElement{Type|Attr}Interface` is very nice for working with attributes and types generically, and `replaceImmediateSubAttribute` even supports transforming expression trees.  Two suggestions for improvement:

1) We should have a `replaceImmediateSubType` that is analogous to the above method.  This would allow things like FunctionType to conform and allow transforming one type into another with a convenient and consistent hook.

2) replaceImmediateSubAttribute should return Attr or Type (depending on which of SubElement{Type|Attr}Interface it is).  It is currently defined as returning `SubElementTypeInterface` presumably because (e.g.) a DictionaryAttr's implementation of this is going to return another DictionaryAttr.  This isn't true in general though: replacing an subattribute much allow simplifying from a complex dialect defined attribute to something like an IntegerAttr.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyNVE1v2zAM_TX2hZjhKF_NwYe2WYEA22UrsLMs07ZWWTL0kTT_fqSSdO1hQwHDjiTy8b1HKq3rzk2xqX-m9qvBCW0stg_P5xmL7eN9jL7Y7g82ou-lQgoDHeCI_gxWK4TeeTg5_6LtACcdR5CUodsUMYC0HUTCCTCgRa-VNOZciMd8QEgeZ0OYh2nCTsuIROD-ls2F8IgWQppn52OA6KUNVG7iUvg6ewxBO0v7iKECeD45Ch4GDJG2Q2amp9m740XT8r6o90V9fS8KsYNfCGF0yXQwyiOC_Aep7AXxiaOMrF5aadzgEnFytEmJLRWBCePoOmYyUtAp45Jid6IY4hzA6BeEp2QVE2RQzlfOsqjsyTX6vVBnMXsI2lKwtI7q-avTnEsWaVKX02kZdIi8HJ17qd7rFaz3f4bfnPAYk7fA-0AOZpqFuOtwRttdGMFp1GoE18NnRgY0m0blyZlD9k8l7ynFnKHDXlsk4eFalwt8GEUG_TB93Pc0yZayW1QyhUwPq6FihRL2Otsr_TkTEdvAU3ABk3zCvCN3iJ7BcUEy9qr65u9HkFtLdbCEF6lBiftxmWppCM2lYaQBuxrMmJInt327DDAlcuzS38B8dH_msN67KTeSKb4CdcWgin99ecsnjsHxhHFWHiSqwMYM6DPHS5vLrll2u-VOllFHg02xfvj-7fADHp3HYr1_fyHy9H7-2pfJm2aMcQ58k8QTPQNNYWorIk8LY463zxeq8Ztk0FKHkJCa_7TeLNfrcmxW9VKtdru2Q9GqRb1Yt0qtcLPrJG7oB5ZGtmgCEy-EmIz2VE4xeyFIQKkbUQtRb2ux2C4EDVWt7jYr0S3FAu9Q9m2xqnGS2lTMpHJ-KH2TSbVpCHRo6IaEv4eS_kQGi9kpxpeJukkZ5Dw1t8z8m0z-D3HVzEI">