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

    <tr>
        <th>Summary</th>
        <td>
            Move MCSymbolRefExpr::VK_AMDGPU_ to AMDGPUMCExpr::
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          MaskRay
      </td>
    </tr>
</table>

<pre>
    `MCSymbolRefExpr::VariantKind` isn't ideal for encoding relocation operators because:

* other expressions, like MCConstantExpr (e.g., PPC `4@l`) and MCBinaryExpr (e.g., PPC `(a+1)@l`), also need it
* semantics become unclear (e.g., folding expressions with `@`).
* The generic interface `MCSymbolRefExpr` offers no target-specific extension point. Any target-specific logic will pollute the generic interface.

`MCTargetExpr` subclasses, as used by AArch64 and RISC-V, offer a cleaner approach.
(MIPS, while also uses `MCTargetExpr`, has significant tech debt.)
Ideally, limit `MCTargetExpr` to top-level use to encode one single relocation and avoid its inclusion as a subexpression.

`AMDMCExpr::VariantKind` is already present. Should just move more `VK_AMDGPU_*` there. @arsenm 

Similar issue for VE: #130003

---

AArch64 is a good model where the `VariantKind` information is incoded as `AArch64MCExpr` (derived from `MCTargetExpr`)
```
// llvm/lib/Target/AArch64/AArch64MCInstLower.cpp
  Expr = AArch64MCExpr::create(Expr, RefKind, Ctx);
// llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
ImmVal = AArch64MCExpr::create(ImmVal, RefKind, getContext());
```

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUVcFu2zgQ_Rr6MrBAU7ZiH3RQlHoRdA0ESTfXgiJHEluKFEjKjv9-Qcqp09a7iwV0oKjhzJv33ojce9UZxJJs7snmYcGn0FtXHrj__szPi8bKc0kKeqhfzkNj9TO2n95GR_KK5NUrd4qb8FkZSQoKyhvC7gIoiVxDax2gE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