[llvm] Move X86-specific MCSymbolRefExpr::VariantKind to X86MCExpr::Specifier (PR #132149)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 20 08:57:10 PDT 2025


================
@@ -31,6 +31,38 @@ class X86MCExpr : public MCTargetExpr {
   explicit X86MCExpr(MCRegister R) : Reg(R) {}
 
 public:
+  // Relocation specifier. Named VK_ for legacy reasons.
+  enum Specifier {
+    VK_None,
+
+    VK_ABS8 = MCSymbolRefExpr::FirstTargetSpecifier,
+    VK_DTPOFF,
+    VK_DTPREL,
+    VK_GOT,
+    VK_GOTENT,
+    VK_GOTNTPOFF,
+    VK_GOTOFF,
+    VK_GOTPCREL,
----------------
MaskRay wrote:

Every ELF constant in `MCSymbolRefExpr::VariantKind` is target-specific while some targets might share a specifier of a similar name (e.g., `@got`, `@plt`). It looks cleaner for targets to define relocation specifiers they use

https://github.com/llvm/llvm-project/pull/132149


More information about the llvm-commits mailing list