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

    <tr>
        <th>Summary</th>
        <td>
            [VE] Move MCSymbolRefExpr::VK_VE_ to VEMCExpr::
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            backend:VE
      </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 `@`).

`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.

The VE target added `MCSymbolRefExpr::VariantKind::VK_VE_` in 2020 (https://reviews.llvm.org/D83170).
I worry that new targets would follow suit and add inappropriate `VK_*` to the list...

---

VE should migrate to follow AArch64 where the `VariantKind` information is incoded as `AArch64MCExpr` (derived from `MCTargetExpr`), different from most other targets.
```
// 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());
```

@kaz7 @simoll 
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUVV1vqzgQ_TXOyyjIMeTrgYeUJlLUjVS1V3mtDB6Ct8ZGtkma_fUrG3LT3u1q90o8oGGYOXPOGZs7J08aMSfzBzJ_nPDeN8bmB-7eX_h1UhpxzcmCHorXa1sa9YL19qOzJN2QdHPkVnLtn6QWZEFBOk3Y0oMUyBXUxgL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