[llvm] 058a4e8 - [LoongArch] Rename VariantKind to Specifier

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 20 23:59:27 PDT 2025


Author: Fangrui Song
Date: 2025-03-20T23:59:23-07:00
New Revision: 058a4e8170f2c66764b78c88e574d5c364c6bd93

URL: https://github.com/llvm/llvm-project/commit/058a4e8170f2c66764b78c88e574d5c364c6bd93
DIFF: https://github.com/llvm/llvm-project/commit/058a4e8170f2c66764b78c88e574d5c364c6bd93.diff

LOG: [LoongArch] Rename VariantKind to Specifier

Follow the X86, Mips, and RISCV renaming.

> "Relocation modifier" suggests adjustments happen during the linker's relocation step rather than the assembler's expression evaluation.
> "Relocation specifier" is clear, aligns with Arm and IBM AIX's documentation, and fits the assembler's role seamlessly.

In addition, rename *MCExpr::getKind, which confusingly shadows the base class getKind.

The parseSpecifier name follows Sparc.

Added: 
    

Modified: 
    llvm/lib/Target/LoongArch/AsmParser/LoongArchAsmParser.cpp
    llvm/lib/Target/LoongArch/LoongArchMCInstLower.cpp
    llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCCodeEmitter.cpp
    llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCExpr.cpp
    llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCExpr.h

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/LoongArch/AsmParser/LoongArchAsmParser.cpp b/llvm/lib/Target/LoongArch/AsmParser/LoongArchAsmParser.cpp
index 9cfb5803eb270..4c6512d1284b8 100644
--- a/llvm/lib/Target/LoongArch/AsmParser/LoongArchAsmParser.cpp
+++ b/llvm/lib/Target/LoongArch/AsmParser/LoongArchAsmParser.cpp
@@ -45,9 +45,8 @@ class LoongArchAsmParser : public MCTargetAsmParser {
 
   struct Inst {
     unsigned Opc;
-    LoongArchMCExpr::VariantKind VK;
-    Inst(unsigned Opc,
-         LoongArchMCExpr::VariantKind VK = LoongArchMCExpr::VK_LoongArch_None)
+    LoongArchMCExpr::Specifier VK;
+    Inst(unsigned Opc, LoongArchMCExpr::Specifier VK = LoongArchMCExpr::VK_None)
         : Opc(Opc), VK(VK) {}
   };
   using InstSeq = SmallVector<Inst>;
@@ -189,7 +188,7 @@ class LoongArchAsmParser : public MCTargetAsmParser {
   };
 
   static bool classifySymbolRef(const MCExpr *Expr,
-                                LoongArchMCExpr::VariantKind &Kind);
+                                LoongArchMCExpr::Specifier &Kind);
 
   LoongArchAsmParser(const MCSubtargetInfo &STI, MCAsmParser &Parser,
                      const MCInstrInfo &MII, const MCTargetOptions &Options)
@@ -242,9 +241,9 @@ class LoongArchOperand : public MCParsedAsmOperand {
   }
 
   static bool evaluateConstantImm(const MCExpr *Expr, int64_t &Imm,
-                                  LoongArchMCExpr::VariantKind &VK) {
+                                  LoongArchMCExpr::Specifier &VK) {
     if (auto *LE = dyn_cast<LoongArchMCExpr>(Expr)) {
-      VK = LE->getKind();
+      VK = LE->getSpecifier();
       return false;
     }
 
@@ -261,10 +260,10 @@ class LoongArchOperand : public MCParsedAsmOperand {
       return false;
 
     int64_t Imm;
-    LoongArchMCExpr::VariantKind VK = LoongArchMCExpr::VK_LoongArch_None;
+    LoongArchMCExpr::Specifier VK = LoongArchMCExpr::VK_None;
     bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK);
     return IsConstantImm && isUInt<N>(Imm - P) &&
-           VK == LoongArchMCExpr::VK_LoongArch_None;
+           VK == LoongArchMCExpr::VK_None;
   }
 
   template <unsigned N, unsigned S = 0> bool isSImm() const {
@@ -272,30 +271,30 @@ class LoongArchOperand : public MCParsedAsmOperand {
       return false;
 
     int64_t Imm;
-    LoongArchMCExpr::VariantKind VK = LoongArchMCExpr::VK_LoongArch_None;
+    LoongArchMCExpr::Specifier VK = LoongArchMCExpr::VK_None;
     bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK);
     return IsConstantImm && isShiftedInt<N, S>(Imm) &&
-           VK == LoongArchMCExpr::VK_LoongArch_None;
+           VK == LoongArchMCExpr::VK_None;
   }
 
   bool isBareSymbol() const {
     int64_t Imm;
-    LoongArchMCExpr::VariantKind VK = LoongArchMCExpr::VK_LoongArch_None;
+    LoongArchMCExpr::Specifier VK = LoongArchMCExpr::VK_None;
     // Must be of 'immediate' type but not a constant.
     if (!isImm() || evaluateConstantImm(getImm(), Imm, VK))
       return false;
     return LoongArchAsmParser::classifySymbolRef(getImm(), VK) &&
-           VK == LoongArchMCExpr::VK_LoongArch_None;
+           VK == LoongArchMCExpr::VK_None;
   }
 
   bool isTPRelAddSymbol() const {
     int64_t Imm;
-    LoongArchMCExpr::VariantKind VK = LoongArchMCExpr::VK_LoongArch_None;
+    LoongArchMCExpr::Specifier VK = LoongArchMCExpr::VK_None;
     // Must be of 'immediate' type but not a constant.
     if (!isImm() || evaluateConstantImm(getImm(), Imm, VK))
       return false;
     return LoongArchAsmParser::classifySymbolRef(getImm(), VK) &&
-           VK == LoongArchMCExpr::VK_LoongArch_TLS_LE_ADD_R;
+           VK == LoongArchMCExpr::VK_TLS_LE_ADD_R;
   }
 
   bool isUImm1() const { return isUImm<1>(); }
@@ -323,15 +322,15 @@ class LoongArchOperand : public MCParsedAsmOperand {
       return false;
 
     int64_t Imm;
-    LoongArchMCExpr::VariantKind VK = LoongArchMCExpr::VK_LoongArch_None;
+    LoongArchMCExpr::Specifier VK = LoongArchMCExpr::VK_None;
     bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK);
-    bool IsValidKind = VK == LoongArchMCExpr::VK_LoongArch_None ||
-                       VK == LoongArchMCExpr::VK_LoongArch_PCALA_LO12 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_GOT_PC_LO12 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_IE_PC_LO12 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_LE_LO12_R ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_DESC_PC_LO12 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_DESC_LD;
+    bool IsValidKind = VK == LoongArchMCExpr::VK_None ||
+                       VK == LoongArchMCExpr::VK_PCALA_LO12 ||
+                       VK == LoongArchMCExpr::VK_GOT_PC_LO12 ||
+                       VK == LoongArchMCExpr::VK_TLS_IE_PC_LO12 ||
+                       VK == LoongArchMCExpr::VK_TLS_LE_LO12_R ||
+                       VK == LoongArchMCExpr::VK_TLS_DESC_PC_LO12 ||
+                       VK == LoongArchMCExpr::VK_TLS_DESC_LD;
     return IsConstantImm
                ? isInt<12>(Imm) && IsValidKind
                : LoongArchAsmParser::classifySymbolRef(getImm(), VK) &&
@@ -343,18 +342,18 @@ class LoongArchOperand : public MCParsedAsmOperand {
       return false;
 
     int64_t Imm;
-    LoongArchMCExpr::VariantKind VK = LoongArchMCExpr::VK_LoongArch_None;
+    LoongArchMCExpr::Specifier VK = LoongArchMCExpr::VK_None;
     bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK);
-    bool IsValidKind = VK == LoongArchMCExpr::VK_LoongArch_None ||
-                       VK == LoongArchMCExpr::VK_LoongArch_ABS64_HI12 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_PCALA64_HI12 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_GOT64_HI12 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_GOT64_PC_HI12 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_LE64_HI12 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_IE64_HI12 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_IE64_PC_HI12 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_DESC64_HI12 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_DESC64_PC_HI12;
+    bool IsValidKind = VK == LoongArchMCExpr::VK_None ||
+                       VK == LoongArchMCExpr::VK_ABS64_HI12 ||
+                       VK == LoongArchMCExpr::VK_PCALA64_HI12 ||
+                       VK == LoongArchMCExpr::VK_GOT64_HI12 ||
+                       VK == LoongArchMCExpr::VK_GOT64_PC_HI12 ||
+                       VK == LoongArchMCExpr::VK_TLS_LE64_HI12 ||
+                       VK == LoongArchMCExpr::VK_TLS_IE64_HI12 ||
+                       VK == LoongArchMCExpr::VK_TLS_IE64_PC_HI12 ||
+                       VK == LoongArchMCExpr::VK_TLS_DESC64_HI12 ||
+                       VK == LoongArchMCExpr::VK_TLS_DESC64_PC_HI12;
     return IsConstantImm
                ? isInt<12>(Imm) && IsValidKind
                : LoongArchAsmParser::classifySymbolRef(getImm(), VK) &&
@@ -368,17 +367,17 @@ class LoongArchOperand : public MCParsedAsmOperand {
       return false;
 
     int64_t Imm;
-    LoongArchMCExpr::VariantKind VK = LoongArchMCExpr::VK_LoongArch_None;
+    LoongArchMCExpr::Specifier VK = LoongArchMCExpr::VK_None;
     bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK);
-    bool IsValidKind = VK == LoongArchMCExpr::VK_LoongArch_None ||
-                       VK == LoongArchMCExpr::VK_LoongArch_ABS_LO12 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_PCALA_LO12 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_GOT_LO12 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_GOT_PC_LO12 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_LE_LO12 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_IE_LO12 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_IE_PC_LO12 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_DESC_LO12;
+    bool IsValidKind = VK == LoongArchMCExpr::VK_None ||
+                       VK == LoongArchMCExpr::VK_ABS_LO12 ||
+                       VK == LoongArchMCExpr::VK_PCALA_LO12 ||
+                       VK == LoongArchMCExpr::VK_GOT_LO12 ||
+                       VK == LoongArchMCExpr::VK_GOT_PC_LO12 ||
+                       VK == LoongArchMCExpr::VK_TLS_LE_LO12 ||
+                       VK == LoongArchMCExpr::VK_TLS_IE_LO12 ||
+                       VK == LoongArchMCExpr::VK_TLS_IE_PC_LO12 ||
+                       VK == LoongArchMCExpr::VK_TLS_DESC_LO12;
     return IsConstantImm
                ? isUInt<12>(Imm) && IsValidKind
                : LoongArchAsmParser::classifySymbolRef(getImm(), VK) &&
@@ -397,12 +396,12 @@ class LoongArchOperand : public MCParsedAsmOperand {
       return false;
 
     int64_t Imm;
-    LoongArchMCExpr::VariantKind VK = LoongArchMCExpr::VK_LoongArch_None;
+    LoongArchMCExpr::Specifier VK = LoongArchMCExpr::VK_None;
     bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK);
-    bool IsValidKind = VK == LoongArchMCExpr::VK_LoongArch_None ||
-                       VK == LoongArchMCExpr::VK_LoongArch_B16 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_PCALA_LO12 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_DESC_CALL;
+    bool IsValidKind = VK == LoongArchMCExpr::VK_None ||
+                       VK == LoongArchMCExpr::VK_B16 ||
+                       VK == LoongArchMCExpr::VK_PCALA_LO12 ||
+                       VK == LoongArchMCExpr::VK_TLS_DESC_CALL;
     return IsConstantImm
                ? isShiftedInt<16, 2>(Imm) && IsValidKind
                : LoongArchAsmParser::classifySymbolRef(getImm(), VK) &&
@@ -416,15 +415,15 @@ class LoongArchOperand : public MCParsedAsmOperand {
       return false;
 
     int64_t Imm;
-    LoongArchMCExpr::VariantKind VK = LoongArchMCExpr::VK_LoongArch_None;
+    LoongArchMCExpr::Specifier VK = LoongArchMCExpr::VK_None;
     bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK);
-    bool IsValidKind = VK == LoongArchMCExpr::VK_LoongArch_None ||
-                       VK == LoongArchMCExpr::VK_LoongArch_PCALA_HI20 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_GOT_PC_HI20 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_IE_PC_HI20 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_LD_PC_HI20 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_GD_PC_HI20 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_DESC_PC_HI20;
+    bool IsValidKind = VK == LoongArchMCExpr::VK_None ||
+                       VK == LoongArchMCExpr::VK_PCALA_HI20 ||
+                       VK == LoongArchMCExpr::VK_GOT_PC_HI20 ||
+                       VK == LoongArchMCExpr::VK_TLS_IE_PC_HI20 ||
+                       VK == LoongArchMCExpr::VK_TLS_LD_PC_HI20 ||
+                       VK == LoongArchMCExpr::VK_TLS_GD_PC_HI20 ||
+                       VK == LoongArchMCExpr::VK_TLS_DESC_PC_HI20;
     return IsConstantImm
                ? isInt<20>(Imm) && IsValidKind
                : LoongArchAsmParser::classifySymbolRef(getImm(), VK) &&
@@ -436,17 +435,17 @@ class LoongArchOperand : public MCParsedAsmOperand {
       return false;
 
     int64_t Imm;
-    LoongArchMCExpr::VariantKind VK = LoongArchMCExpr::VK_LoongArch_None;
+    LoongArchMCExpr::Specifier VK = LoongArchMCExpr::VK_None;
     bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK);
-    bool IsValidKind = VK == LoongArchMCExpr::VK_LoongArch_None ||
-                       VK == LoongArchMCExpr::VK_LoongArch_ABS_HI20 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_GOT_HI20 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_GD_HI20 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_LD_HI20 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_IE_HI20 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_LE_HI20 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_LE_HI20_R ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_DESC_HI20;
+    bool IsValidKind = VK == LoongArchMCExpr::VK_None ||
+                       VK == LoongArchMCExpr::VK_ABS_HI20 ||
+                       VK == LoongArchMCExpr::VK_GOT_HI20 ||
+                       VK == LoongArchMCExpr::VK_TLS_GD_HI20 ||
+                       VK == LoongArchMCExpr::VK_TLS_LD_HI20 ||
+                       VK == LoongArchMCExpr::VK_TLS_IE_HI20 ||
+                       VK == LoongArchMCExpr::VK_TLS_LE_HI20 ||
+                       VK == LoongArchMCExpr::VK_TLS_LE_HI20_R ||
+                       VK == LoongArchMCExpr::VK_TLS_DESC_HI20;
     return IsConstantImm
                ? isInt<20>(Imm) && IsValidKind
                : LoongArchAsmParser::classifySymbolRef(getImm(), VK) &&
@@ -458,18 +457,18 @@ class LoongArchOperand : public MCParsedAsmOperand {
       return false;
 
     int64_t Imm;
-    LoongArchMCExpr::VariantKind VK = LoongArchMCExpr::VK_LoongArch_None;
+    LoongArchMCExpr::Specifier VK = LoongArchMCExpr::VK_None;
     bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK);
-    bool IsValidKind = VK == LoongArchMCExpr::VK_LoongArch_None ||
-                       VK == LoongArchMCExpr::VK_LoongArch_ABS64_LO20 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_PCALA64_LO20 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_GOT64_LO20 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_GOT64_PC_LO20 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_IE64_LO20 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_IE64_PC_LO20 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_LE64_LO20 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_DESC64_PC_LO20 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_DESC64_LO20;
+    bool IsValidKind = VK == LoongArchMCExpr::VK_None ||
+                       VK == LoongArchMCExpr::VK_ABS64_LO20 ||
+                       VK == LoongArchMCExpr::VK_PCALA64_LO20 ||
+                       VK == LoongArchMCExpr::VK_GOT64_LO20 ||
+                       VK == LoongArchMCExpr::VK_GOT64_PC_LO20 ||
+                       VK == LoongArchMCExpr::VK_TLS_IE64_LO20 ||
+                       VK == LoongArchMCExpr::VK_TLS_IE64_PC_LO20 ||
+                       VK == LoongArchMCExpr::VK_TLS_LE64_LO20 ||
+                       VK == LoongArchMCExpr::VK_TLS_DESC64_PC_LO20 ||
+                       VK == LoongArchMCExpr::VK_TLS_DESC64_LO20;
 
     return IsConstantImm
                ? isInt<20>(Imm) && IsValidKind
@@ -482,10 +481,10 @@ class LoongArchOperand : public MCParsedAsmOperand {
       return false;
 
     int64_t Imm;
-    LoongArchMCExpr::VariantKind VK = LoongArchMCExpr::VK_LoongArch_None;
+    LoongArchMCExpr::Specifier VK = LoongArchMCExpr::VK_None;
     bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK);
-    bool IsValidKind = VK == LoongArchMCExpr::VK_LoongArch_None ||
-                       VK == LoongArchMCExpr::VK_LoongArch_CALL36;
+    bool IsValidKind =
+        VK == LoongArchMCExpr::VK_None || VK == LoongArchMCExpr::VK_CALL36;
 
     return IsConstantImm
                ? isInt<20>(Imm) && IsValidKind
@@ -498,13 +497,13 @@ class LoongArchOperand : public MCParsedAsmOperand {
       return false;
 
     int64_t Imm;
-    LoongArchMCExpr::VariantKind VK = LoongArchMCExpr::VK_LoongArch_None;
+    LoongArchMCExpr::Specifier VK = LoongArchMCExpr::VK_None;
     bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK);
-    bool IsValidKind = VK == LoongArchMCExpr::VK_LoongArch_None ||
-                       VK == LoongArchMCExpr::VK_LoongArch_PCREL20_S2 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_LD_PCREL20_S2 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_GD_PCREL20_S2 ||
-                       VK == LoongArchMCExpr::VK_LoongArch_TLS_DESC_PCREL20_S2;
+    bool IsValidKind = VK == LoongArchMCExpr::VK_None ||
+                       VK == LoongArchMCExpr::VK_PCREL20_S2 ||
+                       VK == LoongArchMCExpr::VK_TLS_LD_PCREL20_S2 ||
+                       VK == LoongArchMCExpr::VK_TLS_GD_PCREL20_S2 ||
+                       VK == LoongArchMCExpr::VK_TLS_DESC_PCREL20_S2;
     return IsConstantImm
                ? isInt<20>(Imm) && IsValidKind
                : LoongArchAsmParser::classifySymbolRef(getImm(), VK) &&
@@ -516,10 +515,10 @@ class LoongArchOperand : public MCParsedAsmOperand {
       return false;
 
     int64_t Imm;
-    LoongArchMCExpr::VariantKind VK = LoongArchMCExpr::VK_LoongArch_None;
+    LoongArchMCExpr::Specifier VK = LoongArchMCExpr::VK_None;
     bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK);
-    bool IsValidKind = VK == LoongArchMCExpr::VK_LoongArch_None ||
-                       VK == LoongArchMCExpr::VK_LoongArch_B21;
+    bool IsValidKind =
+        VK == LoongArchMCExpr::VK_None || VK == LoongArchMCExpr::VK_B21;
     return IsConstantImm
                ? isShiftedInt<21, 2>(Imm) && IsValidKind
                : LoongArchAsmParser::classifySymbolRef(getImm(), VK) &&
@@ -531,12 +530,11 @@ class LoongArchOperand : public MCParsedAsmOperand {
       return false;
 
     int64_t Imm;
-    LoongArchMCExpr::VariantKind VK = LoongArchMCExpr::VK_LoongArch_None;
+    LoongArchMCExpr::Specifier VK = LoongArchMCExpr::VK_None;
     bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK);
-    bool IsValidKind = VK == LoongArchMCExpr::VK_LoongArch_None ||
-                       VK == LoongArchMCExpr::VK_LoongArch_CALL ||
-                       VK == LoongArchMCExpr::VK_LoongArch_CALL_PLT ||
-                       VK == LoongArchMCExpr::VK_LoongArch_B26;
+    bool IsValidKind =
+        VK == LoongArchMCExpr::VK_None || VK == LoongArchMCExpr::VK_CALL ||
+        VK == LoongArchMCExpr::VK_CALL_PLT || VK == LoongArchMCExpr::VK_B26;
     return IsConstantImm
                ? isShiftedInt<26, 2>(Imm) && IsValidKind
                : LoongArchAsmParser::classifySymbolRef(getImm(), VK) &&
@@ -548,9 +546,9 @@ class LoongArchOperand : public MCParsedAsmOperand {
     if (!isImm())
       return false;
     int64_t Imm;
-    LoongArchMCExpr::VariantKind VK = LoongArchMCExpr::VK_LoongArch_None;
+    LoongArchMCExpr::Specifier VK = LoongArchMCExpr::VK_None;
     bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK);
-    return IsConstantImm && VK == LoongArchMCExpr::VK_LoongArch_None;
+    return IsConstantImm && VK == LoongArchMCExpr::VK_None;
   }
 
   /// Gets location of the first token of this operand.
@@ -699,17 +697,17 @@ ParseStatus LoongArchAsmParser::tryParseRegister(MCRegister &Reg,
 }
 
 bool LoongArchAsmParser::classifySymbolRef(const MCExpr *Expr,
-                                           LoongArchMCExpr::VariantKind &Kind) {
-  Kind = LoongArchMCExpr::VK_LoongArch_None;
+                                           LoongArchMCExpr::Specifier &Kind) {
+  Kind = LoongArchMCExpr::VK_None;
 
   if (const LoongArchMCExpr *RE = dyn_cast<LoongArchMCExpr>(Expr)) {
-    Kind = RE->getKind();
+    Kind = RE->getSpecifier();
     Expr = RE->getSubExpr();
   }
 
   MCValue Res;
   if (Expr->evaluateAsRelocatable(Res, nullptr))
-    return Res.getRefKind() == LoongArchMCExpr::VK_LoongArch_None;
+    return Res.getRefKind() == LoongArchMCExpr::VK_None;
   return false;
 }
 
@@ -774,10 +772,9 @@ LoongArchAsmParser::parseOperandWithModifier(OperandVector &Operands) {
   if (getLexer().getKind() != AsmToken::Identifier)
     return Error(getLoc(), "expected valid identifier for operand modifier");
   StringRef Identifier = getParser().getTok().getIdentifier();
-  LoongArchMCExpr::VariantKind VK =
-      LoongArchMCExpr::getVariantKindForName(Identifier);
-  if (VK == LoongArchMCExpr::VK_LoongArch_Invalid)
-    return Error(getLoc(), "unrecognized operand modifier");
+  LoongArchMCExpr::Specifier VK = LoongArchMCExpr::parseSpecifier(Identifier);
+  if (VK == LoongArchMCExpr::VK_None)
+    return Error(getLoc(), "invalid relocation specifier");
 
   getParser().Lex(); // Eat the identifier
   if (getLexer().getKind() != AsmToken::LParen)
@@ -811,8 +808,7 @@ ParseStatus LoongArchAsmParser::parseSImm26Operand(OperandVector &Operands) {
 
   MCSymbol *Sym = getContext().getOrCreateSymbol(Identifier);
   Res = MCSymbolRefExpr::create(Sym, getContext());
-  Res = LoongArchMCExpr::create(Res, LoongArchMCExpr::VK_LoongArch_CALL,
-                                getContext());
+  Res = LoongArchMCExpr::create(Res, LoongArchMCExpr::VK_CALL, getContext());
   Operands.push_back(LoongArchOperand::createImm(Res, S, E));
   return ParseStatus::Success;
 }
@@ -892,7 +888,7 @@ void LoongArchAsmParser::emitLAInstSeq(MCRegister DestReg, MCRegister TmpReg,
   MCContext &Ctx = getContext();
   for (LoongArchAsmParser::Inst &Inst : Insts) {
     unsigned Opc = Inst.Opc;
-    LoongArchMCExpr::VariantKind VK = Inst.VK;
+    LoongArchMCExpr::Specifier VK = Inst.VK;
     const LoongArchMCExpr *LE =
         LoongArchMCExpr::create(Symbol, VK, Ctx, RelaxHint);
     switch (Opc) {
@@ -907,12 +903,12 @@ void LoongArchAsmParser::emitLAInstSeq(MCRegister DestReg, MCRegister TmpReg,
     case LoongArch::ADDI_W:
     case LoongArch::LD_W:
     case LoongArch::LD_D: {
-      if (VK == LoongArchMCExpr::VK_LoongArch_None) {
+      if (VK == LoongArchMCExpr::VK_None) {
         Out.emitInstruction(
             MCInstBuilder(Opc).addReg(DestReg).addReg(DestReg).addImm(0),
             getSTI());
         continue;
-      } else if (VK == LoongArchMCExpr::VK_LoongArch_TLS_DESC_LD) {
+      } else if (VK == LoongArchMCExpr::VK_TLS_DESC_LD) {
         Out.emitInstruction(MCInstBuilder(Opc)
                                 .addReg(LoongArch::R1)
                                 .addReg(DestReg)
@@ -978,16 +974,16 @@ void LoongArchAsmParser::emitLoadAddressAbs(MCInst &Inst, SMLoc IDLoc,
                              : Inst.getOperand(2).getExpr();
   InstSeq Insts;
 
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::LU12I_W, LoongArchMCExpr::VK_LoongArch_ABS_HI20));
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::ORI, LoongArchMCExpr::VK_LoongArch_ABS_LO12));
+  Insts.push_back(LoongArchAsmParser::Inst(LoongArch::LU12I_W,
+                                           LoongArchMCExpr::VK_ABS_HI20));
+  Insts.push_back(
+      LoongArchAsmParser::Inst(LoongArch::ORI, LoongArchMCExpr::VK_ABS_LO12));
 
   if (is64Bit()) {
-    Insts.push_back(LoongArchAsmParser::Inst(
-        LoongArch::LU32I_D, LoongArchMCExpr::VK_LoongArch_ABS64_LO20));
-    Insts.push_back(LoongArchAsmParser::Inst(
-        LoongArch::LU52I_D, LoongArchMCExpr::VK_LoongArch_ABS64_HI12));
+    Insts.push_back(LoongArchAsmParser::Inst(LoongArch::LU32I_D,
+                                             LoongArchMCExpr::VK_ABS64_LO20));
+    Insts.push_back(LoongArchAsmParser::Inst(LoongArch::LU52I_D,
+                                             LoongArchMCExpr::VK_ABS64_HI12));
   }
 
   emitLAInstSeq(DestReg, DestReg, Symbol, Insts, IDLoc, Out);
@@ -1004,10 +1000,10 @@ void LoongArchAsmParser::emitLoadAddressPcrel(MCInst &Inst, SMLoc IDLoc,
   InstSeq Insts;
   unsigned ADDI = is64Bit() ? LoongArch::ADDI_D : LoongArch::ADDI_W;
 
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::PCALAU12I, LoongArchMCExpr::VK_LoongArch_PCALA_HI20));
+  Insts.push_back(LoongArchAsmParser::Inst(LoongArch::PCALAU12I,
+                                           LoongArchMCExpr::VK_PCALA_HI20));
   Insts.push_back(
-      LoongArchAsmParser::Inst(ADDI, LoongArchMCExpr::VK_LoongArch_PCALA_LO12));
+      LoongArchAsmParser::Inst(ADDI, LoongArchMCExpr::VK_PCALA_LO12));
 
   emitLAInstSeq(DestReg, DestReg, Symbol, Insts, IDLoc, Out,
                 /*RelaxHint=*/true);
@@ -1027,14 +1023,14 @@ void LoongArchAsmParser::emitLoadAddressPcrelLarge(MCInst &Inst, SMLoc IDLoc,
   const MCExpr *Symbol = Inst.getOperand(2).getExpr();
   InstSeq Insts;
 
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::PCALAU12I, LoongArchMCExpr::VK_LoongArch_PCALA_HI20));
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::ADDI_D, LoongArchMCExpr::VK_LoongArch_PCALA_LO12));
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::LU32I_D, LoongArchMCExpr::VK_LoongArch_PCALA64_LO20));
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::LU52I_D, LoongArchMCExpr::VK_LoongArch_PCALA64_HI12));
+  Insts.push_back(LoongArchAsmParser::Inst(LoongArch::PCALAU12I,
+                                           LoongArchMCExpr::VK_PCALA_HI20));
+  Insts.push_back(LoongArchAsmParser::Inst(LoongArch::ADDI_D,
+                                           LoongArchMCExpr::VK_PCALA_LO12));
+  Insts.push_back(LoongArchAsmParser::Inst(LoongArch::LU32I_D,
+                                           LoongArchMCExpr::VK_PCALA64_LO20));
+  Insts.push_back(LoongArchAsmParser::Inst(LoongArch::LU52I_D,
+                                           LoongArchMCExpr::VK_PCALA64_HI12));
   Insts.push_back(LoongArchAsmParser::Inst(LoongArch::ADD_D));
 
   emitLAInstSeq(DestReg, TmpReg, Symbol, Insts, IDLoc, Out);
@@ -1061,16 +1057,16 @@ void LoongArchAsmParser::emitLoadAddressGot(MCInst &Inst, SMLoc IDLoc,
     //   lu32i.d $rd, %got64_lo20(sym)
     //   lu52i.d $rd, $rd, %got64_hi12(sym)
     //   ld.d    $rd, $rd, 0
-    Insts.push_back(LoongArchAsmParser::Inst(
-        LoongArch::LU12I_W, LoongArchMCExpr::VK_LoongArch_GOT_HI20));
-    Insts.push_back(LoongArchAsmParser::Inst(
-        LoongArch::ORI, LoongArchMCExpr::VK_LoongArch_GOT_LO12));
+    Insts.push_back(LoongArchAsmParser::Inst(LoongArch::LU12I_W,
+                                             LoongArchMCExpr::VK_GOT_HI20));
+    Insts.push_back(
+        LoongArchAsmParser::Inst(LoongArch::ORI, LoongArchMCExpr::VK_GOT_LO12));
 
     if (is64Bit()) {
-      Insts.push_back(LoongArchAsmParser::Inst(
-          LoongArch::LU32I_D, LoongArchMCExpr::VK_LoongArch_GOT64_LO20));
-      Insts.push_back(LoongArchAsmParser::Inst(
-          LoongArch::LU52I_D, LoongArchMCExpr::VK_LoongArch_GOT64_HI12));
+      Insts.push_back(LoongArchAsmParser::Inst(LoongArch::LU32I_D,
+                                               LoongArchMCExpr::VK_GOT64_LO20));
+      Insts.push_back(LoongArchAsmParser::Inst(LoongArch::LU52I_D,
+                                               LoongArchMCExpr::VK_GOT64_HI12));
     }
     Insts.push_back(LoongArchAsmParser::Inst(LD));
     emitLAInstSeq(DestReg, DestReg, Symbol, Insts, IDLoc, Out);
@@ -1079,10 +1075,10 @@ void LoongArchAsmParser::emitLoadAddressGot(MCInst &Inst, SMLoc IDLoc,
   // expands to:
   //   pcalau12i $rd, %got_pc_hi20(sym)
   //   ld.w/d    $rd, $rd, %got_pc_lo12(sym)
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::PCALAU12I, LoongArchMCExpr::VK_LoongArch_GOT_PC_HI20));
+  Insts.push_back(LoongArchAsmParser::Inst(LoongArch::PCALAU12I,
+                                           LoongArchMCExpr::VK_GOT_PC_HI20));
   Insts.push_back(
-      LoongArchAsmParser::Inst(LD, LoongArchMCExpr::VK_LoongArch_GOT_PC_LO12));
+      LoongArchAsmParser::Inst(LD, LoongArchMCExpr::VK_GOT_PC_LO12));
 
   emitLAInstSeq(DestReg, DestReg, Symbol, Insts, IDLoc, Out,
                 /*RelaxHint=*/true);
@@ -1102,14 +1098,14 @@ void LoongArchAsmParser::emitLoadAddressGotLarge(MCInst &Inst, SMLoc IDLoc,
   const MCExpr *Symbol = Inst.getOperand(2).getExpr();
   InstSeq Insts;
 
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::PCALAU12I, LoongArchMCExpr::VK_LoongArch_GOT_PC_HI20));
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::ADDI_D, LoongArchMCExpr::VK_LoongArch_GOT_PC_LO12));
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::LU32I_D, LoongArchMCExpr::VK_LoongArch_GOT64_PC_LO20));
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::LU52I_D, LoongArchMCExpr::VK_LoongArch_GOT64_PC_HI12));
+  Insts.push_back(LoongArchAsmParser::Inst(LoongArch::PCALAU12I,
+                                           LoongArchMCExpr::VK_GOT_PC_HI20));
+  Insts.push_back(LoongArchAsmParser::Inst(LoongArch::ADDI_D,
+                                           LoongArchMCExpr::VK_GOT_PC_LO12));
+  Insts.push_back(LoongArchAsmParser::Inst(LoongArch::LU32I_D,
+                                           LoongArchMCExpr::VK_GOT64_PC_LO20));
+  Insts.push_back(LoongArchAsmParser::Inst(LoongArch::LU52I_D,
+                                           LoongArchMCExpr::VK_GOT64_PC_HI12));
   Insts.push_back(LoongArchAsmParser::Inst(LoongArch::LDX_D));
 
   emitLAInstSeq(DestReg, TmpReg, Symbol, Insts, IDLoc, Out);
@@ -1125,10 +1121,10 @@ void LoongArchAsmParser::emitLoadAddressTLSLE(MCInst &Inst, SMLoc IDLoc,
   const MCExpr *Symbol = Inst.getOperand(1).getExpr();
   InstSeq Insts;
 
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::LU12I_W, LoongArchMCExpr::VK_LoongArch_TLS_LE_HI20));
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::ORI, LoongArchMCExpr::VK_LoongArch_TLS_LE_LO12));
+  Insts.push_back(LoongArchAsmParser::Inst(LoongArch::LU12I_W,
+                                           LoongArchMCExpr::VK_TLS_LE_HI20));
+  Insts.push_back(LoongArchAsmParser::Inst(LoongArch::ORI,
+                                           LoongArchMCExpr::VK_TLS_LE_LO12));
 
   emitLAInstSeq(DestReg, DestReg, Symbol, Insts, IDLoc, Out);
 }
@@ -1154,16 +1150,16 @@ void LoongArchAsmParser::emitLoadAddressTLSIE(MCInst &Inst, SMLoc IDLoc,
     //   lu32i.d $rd, %ie64_lo20(sym)
     //   lu52i.d $rd, $rd, %ie64_hi12(sym)
     //   ld.d    $rd, $rd, 0
-    Insts.push_back(LoongArchAsmParser::Inst(
-        LoongArch::LU12I_W, LoongArchMCExpr::VK_LoongArch_TLS_IE_HI20));
-    Insts.push_back(LoongArchAsmParser::Inst(
-        LoongArch::ORI, LoongArchMCExpr::VK_LoongArch_TLS_IE_LO12));
+    Insts.push_back(LoongArchAsmParser::Inst(LoongArch::LU12I_W,
+                                             LoongArchMCExpr::VK_TLS_IE_HI20));
+    Insts.push_back(LoongArchAsmParser::Inst(LoongArch::ORI,
+                                             LoongArchMCExpr::VK_TLS_IE_LO12));
 
     if (is64Bit()) {
       Insts.push_back(LoongArchAsmParser::Inst(
-          LoongArch::LU32I_D, LoongArchMCExpr::VK_LoongArch_TLS_IE64_LO20));
+          LoongArch::LU32I_D, LoongArchMCExpr::VK_TLS_IE64_LO20));
       Insts.push_back(LoongArchAsmParser::Inst(
-          LoongArch::LU52I_D, LoongArchMCExpr::VK_LoongArch_TLS_IE64_HI12));
+          LoongArch::LU52I_D, LoongArchMCExpr::VK_TLS_IE64_HI12));
     }
     Insts.push_back(LoongArchAsmParser::Inst(LD));
     emitLAInstSeq(DestReg, DestReg, Symbol, Insts, IDLoc, Out);
@@ -1173,10 +1169,10 @@ void LoongArchAsmParser::emitLoadAddressTLSIE(MCInst &Inst, SMLoc IDLoc,
   // expands to:
   //   pcalau12i $rd, %ie_pc_hi20(sym)
   //   ld.w/d    $rd, $rd, %ie_pc_lo12(sym)
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::PCALAU12I, LoongArchMCExpr::VK_LoongArch_TLS_IE_PC_HI20));
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LD, LoongArchMCExpr::VK_LoongArch_TLS_IE_PC_LO12));
+  Insts.push_back(LoongArchAsmParser::Inst(LoongArch::PCALAU12I,
+                                           LoongArchMCExpr::VK_TLS_IE_PC_HI20));
+  Insts.push_back(
+      LoongArchAsmParser::Inst(LD, LoongArchMCExpr::VK_TLS_IE_PC_LO12));
 
   emitLAInstSeq(DestReg, DestReg, Symbol, Insts, IDLoc, Out,
                 /*RelaxHint=*/true);
@@ -1196,14 +1192,14 @@ void LoongArchAsmParser::emitLoadAddressTLSIELarge(MCInst &Inst, SMLoc IDLoc,
   const MCExpr *Symbol = Inst.getOperand(2).getExpr();
   InstSeq Insts;
 
+  Insts.push_back(LoongArchAsmParser::Inst(LoongArch::PCALAU12I,
+                                           LoongArchMCExpr::VK_TLS_IE_PC_HI20));
+  Insts.push_back(LoongArchAsmParser::Inst(LoongArch::ADDI_D,
+                                           LoongArchMCExpr::VK_TLS_IE_PC_LO12));
   Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::PCALAU12I, LoongArchMCExpr::VK_LoongArch_TLS_IE_PC_HI20));
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::ADDI_D, LoongArchMCExpr::VK_LoongArch_TLS_IE_PC_LO12));
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::LU32I_D, LoongArchMCExpr::VK_LoongArch_TLS_IE64_PC_LO20));
+      LoongArch::LU32I_D, LoongArchMCExpr::VK_TLS_IE64_PC_LO20));
   Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::LU52I_D, LoongArchMCExpr::VK_LoongArch_TLS_IE64_PC_HI12));
+      LoongArch::LU52I_D, LoongArchMCExpr::VK_TLS_IE64_PC_HI12));
   Insts.push_back(LoongArchAsmParser::Inst(LoongArch::LDX_D));
 
   emitLAInstSeq(DestReg, TmpReg, Symbol, Insts, IDLoc, Out);
@@ -1228,16 +1224,16 @@ void LoongArchAsmParser::emitLoadAddressTLSLD(MCInst &Inst, SMLoc IDLoc,
     //   ori     $rd, $rd, %got_lo12(sym)
     //   lu32i.d $rd, %got64_lo20(sym)
     //   lu52i.d $rd, $rd, %got64_hi12(sym)
-    Insts.push_back(LoongArchAsmParser::Inst(
-        LoongArch::LU12I_W, LoongArchMCExpr::VK_LoongArch_TLS_LD_HI20));
-    Insts.push_back(LoongArchAsmParser::Inst(
-        LoongArch::ORI, LoongArchMCExpr::VK_LoongArch_GOT_LO12));
+    Insts.push_back(LoongArchAsmParser::Inst(LoongArch::LU12I_W,
+                                             LoongArchMCExpr::VK_TLS_LD_HI20));
+    Insts.push_back(
+        LoongArchAsmParser::Inst(LoongArch::ORI, LoongArchMCExpr::VK_GOT_LO12));
 
     if (is64Bit()) {
-      Insts.push_back(LoongArchAsmParser::Inst(
-          LoongArch::LU32I_D, LoongArchMCExpr::VK_LoongArch_GOT64_LO20));
-      Insts.push_back(LoongArchAsmParser::Inst(
-          LoongArch::LU52I_D, LoongArchMCExpr::VK_LoongArch_GOT64_HI12));
+      Insts.push_back(LoongArchAsmParser::Inst(LoongArch::LU32I_D,
+                                               LoongArchMCExpr::VK_GOT64_LO20));
+      Insts.push_back(LoongArchAsmParser::Inst(LoongArch::LU52I_D,
+                                               LoongArchMCExpr::VK_GOT64_HI12));
     }
     emitLAInstSeq(DestReg, DestReg, Symbol, Insts, IDLoc, Out);
     return;
@@ -1246,10 +1242,10 @@ void LoongArchAsmParser::emitLoadAddressTLSLD(MCInst &Inst, SMLoc IDLoc,
   // expands to:
   //   pcalau12i $rd, %ld_pc_hi20(sym)
   //   addi.w/d  $rd, $rd, %got_pc_lo12(sym)
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::PCALAU12I, LoongArchMCExpr::VK_LoongArch_TLS_LD_PC_HI20));
-  Insts.push_back(LoongArchAsmParser::Inst(
-      ADDI, LoongArchMCExpr::VK_LoongArch_GOT_PC_LO12));
+  Insts.push_back(LoongArchAsmParser::Inst(LoongArch::PCALAU12I,
+                                           LoongArchMCExpr::VK_TLS_LD_PC_HI20));
+  Insts.push_back(
+      LoongArchAsmParser::Inst(ADDI, LoongArchMCExpr::VK_GOT_PC_LO12));
 
   emitLAInstSeq(DestReg, DestReg, Symbol, Insts, IDLoc, Out,
                 /*RelaxHint=*/true);
@@ -1269,14 +1265,14 @@ void LoongArchAsmParser::emitLoadAddressTLSLDLarge(MCInst &Inst, SMLoc IDLoc,
   const MCExpr *Symbol = Inst.getOperand(2).getExpr();
   InstSeq Insts;
 
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::PCALAU12I, LoongArchMCExpr::VK_LoongArch_TLS_LD_PC_HI20));
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::ADDI_D, LoongArchMCExpr::VK_LoongArch_GOT_PC_LO12));
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::LU32I_D, LoongArchMCExpr::VK_LoongArch_GOT64_PC_LO20));
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::LU52I_D, LoongArchMCExpr::VK_LoongArch_GOT64_PC_HI12));
+  Insts.push_back(LoongArchAsmParser::Inst(LoongArch::PCALAU12I,
+                                           LoongArchMCExpr::VK_TLS_LD_PC_HI20));
+  Insts.push_back(LoongArchAsmParser::Inst(LoongArch::ADDI_D,
+                                           LoongArchMCExpr::VK_GOT_PC_LO12));
+  Insts.push_back(LoongArchAsmParser::Inst(LoongArch::LU32I_D,
+                                           LoongArchMCExpr::VK_GOT64_PC_LO20));
+  Insts.push_back(LoongArchAsmParser::Inst(LoongArch::LU52I_D,
+                                           LoongArchMCExpr::VK_GOT64_PC_HI12));
   Insts.push_back(LoongArchAsmParser::Inst(LoongArch::ADD_D));
 
   emitLAInstSeq(DestReg, TmpReg, Symbol, Insts, IDLoc, Out);
@@ -1301,16 +1297,16 @@ void LoongArchAsmParser::emitLoadAddressTLSGD(MCInst &Inst, SMLoc IDLoc,
     //   ori     $rd, $rd, %got_lo12(sym)
     //   lu32i.d $rd, %got64_lo20(sym)
     //   lu52i.d $rd, $rd, %got64_hi12(sym)
-    Insts.push_back(LoongArchAsmParser::Inst(
-        LoongArch::LU12I_W, LoongArchMCExpr::VK_LoongArch_TLS_GD_HI20));
-    Insts.push_back(LoongArchAsmParser::Inst(
-        LoongArch::ORI, LoongArchMCExpr::VK_LoongArch_GOT_LO12));
+    Insts.push_back(LoongArchAsmParser::Inst(LoongArch::LU12I_W,
+                                             LoongArchMCExpr::VK_TLS_GD_HI20));
+    Insts.push_back(
+        LoongArchAsmParser::Inst(LoongArch::ORI, LoongArchMCExpr::VK_GOT_LO12));
 
     if (is64Bit()) {
-      Insts.push_back(LoongArchAsmParser::Inst(
-          LoongArch::LU32I_D, LoongArchMCExpr::VK_LoongArch_GOT64_LO20));
-      Insts.push_back(LoongArchAsmParser::Inst(
-          LoongArch::LU52I_D, LoongArchMCExpr::VK_LoongArch_GOT64_HI12));
+      Insts.push_back(LoongArchAsmParser::Inst(LoongArch::LU32I_D,
+                                               LoongArchMCExpr::VK_GOT64_LO20));
+      Insts.push_back(LoongArchAsmParser::Inst(LoongArch::LU52I_D,
+                                               LoongArchMCExpr::VK_GOT64_HI12));
     }
     emitLAInstSeq(DestReg, DestReg, Symbol, Insts, IDLoc, Out);
     return;
@@ -1319,10 +1315,10 @@ void LoongArchAsmParser::emitLoadAddressTLSGD(MCInst &Inst, SMLoc IDLoc,
   // expands to:
   //   pcalau12i $rd, %gd_pc_hi20(sym)
   //   addi.w/d  $rd, $rd, %got_pc_lo12(sym)
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::PCALAU12I, LoongArchMCExpr::VK_LoongArch_TLS_GD_PC_HI20));
-  Insts.push_back(LoongArchAsmParser::Inst(
-      ADDI, LoongArchMCExpr::VK_LoongArch_GOT_PC_LO12));
+  Insts.push_back(LoongArchAsmParser::Inst(LoongArch::PCALAU12I,
+                                           LoongArchMCExpr::VK_TLS_GD_PC_HI20));
+  Insts.push_back(
+      LoongArchAsmParser::Inst(ADDI, LoongArchMCExpr::VK_GOT_PC_LO12));
 
   emitLAInstSeq(DestReg, DestReg, Symbol, Insts, IDLoc, Out,
                 /*RelaxHint=*/true);
@@ -1342,14 +1338,14 @@ void LoongArchAsmParser::emitLoadAddressTLSGDLarge(MCInst &Inst, SMLoc IDLoc,
   const MCExpr *Symbol = Inst.getOperand(2).getExpr();
   InstSeq Insts;
 
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::PCALAU12I, LoongArchMCExpr::VK_LoongArch_TLS_GD_PC_HI20));
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::ADDI_D, LoongArchMCExpr::VK_LoongArch_GOT_PC_LO12));
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::LU32I_D, LoongArchMCExpr::VK_LoongArch_GOT64_PC_LO20));
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::LU52I_D, LoongArchMCExpr::VK_LoongArch_GOT64_PC_HI12));
+  Insts.push_back(LoongArchAsmParser::Inst(LoongArch::PCALAU12I,
+                                           LoongArchMCExpr::VK_TLS_GD_PC_HI20));
+  Insts.push_back(LoongArchAsmParser::Inst(LoongArch::ADDI_D,
+                                           LoongArchMCExpr::VK_GOT_PC_LO12));
+  Insts.push_back(LoongArchAsmParser::Inst(LoongArch::LU32I_D,
+                                           LoongArchMCExpr::VK_GOT64_PC_LO20));
+  Insts.push_back(LoongArchAsmParser::Inst(LoongArch::LU52I_D,
+                                           LoongArchMCExpr::VK_GOT64_PC_HI12));
   Insts.push_back(LoongArchAsmParser::Inst(LoongArch::ADD_D));
 
   emitLAInstSeq(DestReg, TmpReg, Symbol, Insts, IDLoc, Out);
@@ -1380,21 +1376,21 @@ void LoongArchAsmParser::emitLoadAddressTLSDesc(MCInst &Inst, SMLoc IDLoc,
     //   ld.d    $ra, $rd, %desc_ld(sym)
     //   jirl    $ra, $ra, %desc_call(sym)
     Insts.push_back(LoongArchAsmParser::Inst(
-        LoongArch::LU12I_W, LoongArchMCExpr::VK_LoongArch_TLS_DESC_HI20));
+        LoongArch::LU12I_W, LoongArchMCExpr::VK_TLS_DESC_HI20));
     Insts.push_back(LoongArchAsmParser::Inst(
-        LoongArch::ORI, LoongArchMCExpr::VK_LoongArch_TLS_DESC_LO12));
+        LoongArch::ORI, LoongArchMCExpr::VK_TLS_DESC_LO12));
 
     if (is64Bit()) {
       Insts.push_back(LoongArchAsmParser::Inst(
-          LoongArch::LU32I_D, LoongArchMCExpr::VK_LoongArch_TLS_DESC64_LO20));
+          LoongArch::LU32I_D, LoongArchMCExpr::VK_TLS_DESC64_LO20));
       Insts.push_back(LoongArchAsmParser::Inst(
-          LoongArch::LU52I_D, LoongArchMCExpr::VK_LoongArch_TLS_DESC64_HI12));
+          LoongArch::LU52I_D, LoongArchMCExpr::VK_TLS_DESC64_HI12));
     }
 
+    Insts.push_back(
+        LoongArchAsmParser::Inst(LD, LoongArchMCExpr::VK_TLS_DESC_LD));
     Insts.push_back(LoongArchAsmParser::Inst(
-        LD, LoongArchMCExpr::VK_LoongArch_TLS_DESC_LD));
-    Insts.push_back(LoongArchAsmParser::Inst(
-        LoongArch::JIRL, LoongArchMCExpr::VK_LoongArch_TLS_DESC_CALL));
+        LoongArch::JIRL, LoongArchMCExpr::VK_TLS_DESC_CALL));
 
     emitLAInstSeq(DestReg, DestReg, Symbol, Insts, IDLoc, Out);
     return;
@@ -1406,13 +1402,13 @@ void LoongArchAsmParser::emitLoadAddressTLSDesc(MCInst &Inst, SMLoc IDLoc,
   //   ld.w/d    $ra, $rd, %desc_ld(sym)
   //   jirl      $ra, $ra, %desc_call(sym)
   Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::PCALAU12I, LoongArchMCExpr::VK_LoongArch_TLS_DESC_PC_HI20));
-  Insts.push_back(LoongArchAsmParser::Inst(
-      ADDI, LoongArchMCExpr::VK_LoongArch_TLS_DESC_PC_LO12));
+      LoongArch::PCALAU12I, LoongArchMCExpr::VK_TLS_DESC_PC_HI20));
   Insts.push_back(
-      LoongArchAsmParser::Inst(LD, LoongArchMCExpr::VK_LoongArch_TLS_DESC_LD));
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::JIRL, LoongArchMCExpr::VK_LoongArch_TLS_DESC_CALL));
+      LoongArchAsmParser::Inst(ADDI, LoongArchMCExpr::VK_TLS_DESC_PC_LO12));
+  Insts.push_back(
+      LoongArchAsmParser::Inst(LD, LoongArchMCExpr::VK_TLS_DESC_LD));
+  Insts.push_back(LoongArchAsmParser::Inst(LoongArch::JIRL,
+                                           LoongArchMCExpr::VK_TLS_DESC_CALL));
 
   emitLAInstSeq(DestReg, DestReg, Symbol, Insts, IDLoc, Out,
                 /*RelaxHint=*/true);
@@ -1435,18 +1431,18 @@ void LoongArchAsmParser::emitLoadAddressTLSDescLarge(MCInst &Inst, SMLoc IDLoc,
   InstSeq Insts;
 
   Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::PCALAU12I, LoongArchMCExpr::VK_LoongArch_TLS_DESC_PC_HI20));
+      LoongArch::PCALAU12I, LoongArchMCExpr::VK_TLS_DESC_PC_HI20));
   Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::ADDI_D, LoongArchMCExpr::VK_LoongArch_TLS_DESC_PC_LO12));
+      LoongArch::ADDI_D, LoongArchMCExpr::VK_TLS_DESC_PC_LO12));
   Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::LU32I_D, LoongArchMCExpr::VK_LoongArch_TLS_DESC64_PC_LO20));
+      LoongArch::LU32I_D, LoongArchMCExpr::VK_TLS_DESC64_PC_LO20));
   Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::LU52I_D, LoongArchMCExpr::VK_LoongArch_TLS_DESC64_PC_HI12));
+      LoongArch::LU52I_D, LoongArchMCExpr::VK_TLS_DESC64_PC_HI12));
   Insts.push_back(LoongArchAsmParser::Inst(LoongArch::ADD_D));
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::LD_D, LoongArchMCExpr::VK_LoongArch_TLS_DESC_LD));
-  Insts.push_back(LoongArchAsmParser::Inst(
-      LoongArch::JIRL, LoongArchMCExpr::VK_LoongArch_TLS_DESC_CALL));
+  Insts.push_back(LoongArchAsmParser::Inst(LoongArch::LD_D,
+                                           LoongArchMCExpr::VK_TLS_DESC_LD));
+  Insts.push_back(LoongArchAsmParser::Inst(LoongArch::JIRL,
+                                           LoongArchMCExpr::VK_TLS_DESC_CALL));
 
   emitLAInstSeq(DestReg, TmpReg, Symbol, Insts, IDLoc, Out);
 }
@@ -1506,9 +1502,8 @@ void LoongArchAsmParser::emitFuncCall36(MCInst &Inst, SMLoc IDLoc,
       IsTailCall ? Inst.getOperand(0).getReg() : MCRegister(LoongArch::R1);
   const MCExpr *Sym =
       IsTailCall ? Inst.getOperand(1).getExpr() : Inst.getOperand(0).getExpr();
-  const LoongArchMCExpr *LE =
-      LoongArchMCExpr::create(Sym, llvm::LoongArchMCExpr::VK_LoongArch_CALL36,
-                              getContext(), /*RelaxHint=*/true);
+  const LoongArchMCExpr *LE = LoongArchMCExpr::create(
+      Sym, LoongArchMCExpr::VK_CALL36, getContext(), /*RelaxHint=*/true);
 
   Out.emitInstruction(
       MCInstBuilder(LoongArch::PCADDU18I).addReg(ScratchReg).addExpr(LE),

diff  --git a/llvm/lib/Target/LoongArch/LoongArchMCInstLower.cpp b/llvm/lib/Target/LoongArch/LoongArchMCInstLower.cpp
index 5d561038960e1..5632859f73786 100644
--- a/llvm/lib/Target/LoongArch/LoongArchMCInstLower.cpp
+++ b/llvm/lib/Target/LoongArch/LoongArchMCInstLower.cpp
@@ -25,103 +25,103 @@ using namespace llvm;
 static MCOperand lowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym,
                                     const AsmPrinter &AP) {
   MCContext &Ctx = AP.OutContext;
-  LoongArchMCExpr::VariantKind Kind;
+  LoongArchMCExpr::Specifier Kind;
 
   switch (LoongArchII::getDirectFlags(MO)) {
   default:
     llvm_unreachable("Unknown target flag on GV operand");
   case LoongArchII::MO_None:
-    Kind = LoongArchMCExpr::VK_LoongArch_None;
+    Kind = LoongArchMCExpr::VK_None;
     break;
   case LoongArchII::MO_CALL:
-    Kind = LoongArchMCExpr::VK_LoongArch_CALL;
+    Kind = LoongArchMCExpr::VK_CALL;
     break;
   case LoongArchII::MO_CALL_PLT:
-    Kind = LoongArchMCExpr::VK_LoongArch_CALL_PLT;
+    Kind = LoongArchMCExpr::VK_CALL_PLT;
     break;
   case LoongArchII::MO_PCREL_HI:
-    Kind = LoongArchMCExpr::VK_LoongArch_PCALA_HI20;
+    Kind = LoongArchMCExpr::VK_PCALA_HI20;
     break;
   case LoongArchII::MO_PCREL_LO:
-    Kind = LoongArchMCExpr::VK_LoongArch_PCALA_LO12;
+    Kind = LoongArchMCExpr::VK_PCALA_LO12;
     break;
   case LoongArchII::MO_PCREL64_LO:
-    Kind = LoongArchMCExpr::VK_LoongArch_PCALA64_LO20;
+    Kind = LoongArchMCExpr::VK_PCALA64_LO20;
     break;
   case LoongArchII::MO_PCREL64_HI:
-    Kind = LoongArchMCExpr::VK_LoongArch_PCALA64_HI12;
+    Kind = LoongArchMCExpr::VK_PCALA64_HI12;
     break;
   case LoongArchII::MO_GOT_PC_HI:
-    Kind = LoongArchMCExpr::VK_LoongArch_GOT_PC_HI20;
+    Kind = LoongArchMCExpr::VK_GOT_PC_HI20;
     break;
   case LoongArchII::MO_GOT_PC_LO:
-    Kind = LoongArchMCExpr::VK_LoongArch_GOT_PC_LO12;
+    Kind = LoongArchMCExpr::VK_GOT_PC_LO12;
     break;
   case LoongArchII::MO_GOT_PC64_LO:
-    Kind = LoongArchMCExpr::VK_LoongArch_GOT64_PC_LO20;
+    Kind = LoongArchMCExpr::VK_GOT64_PC_LO20;
     break;
   case LoongArchII::MO_GOT_PC64_HI:
-    Kind = LoongArchMCExpr::VK_LoongArch_GOT64_PC_HI12;
+    Kind = LoongArchMCExpr::VK_GOT64_PC_HI12;
     break;
   case LoongArchII::MO_LE_HI:
-    Kind = LoongArchMCExpr::VK_LoongArch_TLS_LE_HI20;
+    Kind = LoongArchMCExpr::VK_TLS_LE_HI20;
     break;
   case LoongArchII::MO_LE_LO:
-    Kind = LoongArchMCExpr::VK_LoongArch_TLS_LE_LO12;
+    Kind = LoongArchMCExpr::VK_TLS_LE_LO12;
     break;
   case LoongArchII::MO_LE64_LO:
-    Kind = LoongArchMCExpr::VK_LoongArch_TLS_LE64_LO20;
+    Kind = LoongArchMCExpr::VK_TLS_LE64_LO20;
     break;
   case LoongArchII::MO_LE64_HI:
-    Kind = LoongArchMCExpr::VK_LoongArch_TLS_LE64_HI12;
+    Kind = LoongArchMCExpr::VK_TLS_LE64_HI12;
     break;
   case LoongArchII::MO_IE_PC_HI:
-    Kind = LoongArchMCExpr::VK_LoongArch_TLS_IE_PC_HI20;
+    Kind = LoongArchMCExpr::VK_TLS_IE_PC_HI20;
     break;
   case LoongArchII::MO_IE_PC_LO:
-    Kind = LoongArchMCExpr::VK_LoongArch_TLS_IE_PC_LO12;
+    Kind = LoongArchMCExpr::VK_TLS_IE_PC_LO12;
     break;
   case LoongArchII::MO_IE_PC64_LO:
-    Kind = LoongArchMCExpr::VK_LoongArch_TLS_IE64_PC_LO20;
+    Kind = LoongArchMCExpr::VK_TLS_IE64_PC_LO20;
     break;
   case LoongArchII::MO_IE_PC64_HI:
-    Kind = LoongArchMCExpr::VK_LoongArch_TLS_IE64_PC_HI12;
+    Kind = LoongArchMCExpr::VK_TLS_IE64_PC_HI12;
     break;
   case LoongArchII::MO_LD_PC_HI:
-    Kind = LoongArchMCExpr::VK_LoongArch_TLS_LD_PC_HI20;
+    Kind = LoongArchMCExpr::VK_TLS_LD_PC_HI20;
     break;
   case LoongArchII::MO_GD_PC_HI:
-    Kind = LoongArchMCExpr::VK_LoongArch_TLS_GD_PC_HI20;
+    Kind = LoongArchMCExpr::VK_TLS_GD_PC_HI20;
     break;
   case LoongArchII::MO_CALL36:
-    Kind = LoongArchMCExpr::VK_LoongArch_CALL36;
+    Kind = LoongArchMCExpr::VK_CALL36;
     break;
   case LoongArchII::MO_DESC_PC_HI:
-    Kind = LoongArchMCExpr::VK_LoongArch_TLS_DESC_PC_HI20;
+    Kind = LoongArchMCExpr::VK_TLS_DESC_PC_HI20;
     break;
   case LoongArchII::MO_DESC_PC_LO:
-    Kind = LoongArchMCExpr::VK_LoongArch_TLS_DESC_PC_LO12;
+    Kind = LoongArchMCExpr::VK_TLS_DESC_PC_LO12;
     break;
   case LoongArchII::MO_DESC64_PC_LO:
-    Kind = LoongArchMCExpr::VK_LoongArch_TLS_DESC64_PC_LO20;
+    Kind = LoongArchMCExpr::VK_TLS_DESC64_PC_LO20;
     break;
   case LoongArchII::MO_DESC64_PC_HI:
-    Kind = LoongArchMCExpr::VK_LoongArch_TLS_DESC64_PC_HI12;
+    Kind = LoongArchMCExpr::VK_TLS_DESC64_PC_HI12;
     break;
   case LoongArchII::MO_DESC_LD:
-    Kind = LoongArchMCExpr::VK_LoongArch_TLS_DESC_LD;
+    Kind = LoongArchMCExpr::VK_TLS_DESC_LD;
     break;
   case LoongArchII::MO_DESC_CALL:
-    Kind = LoongArchMCExpr::VK_LoongArch_TLS_DESC_CALL;
+    Kind = LoongArchMCExpr::VK_TLS_DESC_CALL;
     break;
   case LoongArchII::MO_LE_HI_R:
-    Kind = LoongArchMCExpr::VK_LoongArch_TLS_LE_HI20_R;
+    Kind = LoongArchMCExpr::VK_TLS_LE_HI20_R;
     break;
   case LoongArchII::MO_LE_ADD_R:
-    Kind = LoongArchMCExpr::VK_LoongArch_TLS_LE_ADD_R;
+    Kind = LoongArchMCExpr::VK_TLS_LE_ADD_R;
     break;
   case LoongArchII::MO_LE_LO_R:
-    Kind = LoongArchMCExpr::VK_LoongArch_TLS_LE_LO12_R;
+    Kind = LoongArchMCExpr::VK_TLS_LE_LO12_R;
     break;
     // TODO: Handle more target-flags.
   }
@@ -132,7 +132,7 @@ static MCOperand lowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym,
     ME = MCBinaryExpr::createAdd(
         ME, MCConstantExpr::create(MO.getOffset(), Ctx), Ctx);
 
-  if (Kind != LoongArchMCExpr::VK_LoongArch_None)
+  if (Kind != LoongArchMCExpr::VK_None)
     ME = LoongArchMCExpr::create(ME, Kind, Ctx, LoongArchII::hasRelaxFlag(MO));
   return MCOperand::createExpr(ME);
 }

diff  --git a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCCodeEmitter.cpp b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCCodeEmitter.cpp
index 02ec321857e57..b0785e34862d0 100644
--- a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCCodeEmitter.cpp
+++ b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCCodeEmitter.cpp
@@ -133,172 +133,171 @@ LoongArchMCCodeEmitter::getExprOpValue(const MCInst &MI, const MCOperand &MO,
     const LoongArchMCExpr *LAExpr = cast<LoongArchMCExpr>(Expr);
 
     RelaxCandidate = LAExpr->getRelaxHint();
-    switch (LAExpr->getKind()) {
-    case LoongArchMCExpr::VK_LoongArch_None:
-    case LoongArchMCExpr::VK_LoongArch_Invalid:
+    switch (LAExpr->getSpecifier()) {
+    case LoongArchMCExpr::VK_None:
       llvm_unreachable("Unhandled fixup kind!");
-    case LoongArchMCExpr::VK_LoongArch_TLS_LE_ADD_R:
-      llvm_unreachable("VK_LoongArch_TLS_LE_ADD_R should not represent an "
+    case LoongArchMCExpr::VK_TLS_LE_ADD_R:
+      llvm_unreachable("VK_TLS_LE_ADD_R should not represent an "
                        "instruction operand");
-    case LoongArchMCExpr::VK_LoongArch_B16:
+    case LoongArchMCExpr::VK_B16:
       FixupKind = LoongArch::fixup_loongarch_b16;
       break;
-    case LoongArchMCExpr::VK_LoongArch_B21:
+    case LoongArchMCExpr::VK_B21:
       FixupKind = LoongArch::fixup_loongarch_b21;
       break;
-    case LoongArchMCExpr::VK_LoongArch_B26:
-    case LoongArchMCExpr::VK_LoongArch_CALL:
-    case LoongArchMCExpr::VK_LoongArch_CALL_PLT:
+    case LoongArchMCExpr::VK_B26:
+    case LoongArchMCExpr::VK_CALL:
+    case LoongArchMCExpr::VK_CALL_PLT:
       FixupKind = LoongArch::fixup_loongarch_b26;
       break;
-    case LoongArchMCExpr::VK_LoongArch_ABS_HI20:
+    case LoongArchMCExpr::VK_ABS_HI20:
       FixupKind = LoongArch::fixup_loongarch_abs_hi20;
       break;
-    case LoongArchMCExpr::VK_LoongArch_ABS_LO12:
+    case LoongArchMCExpr::VK_ABS_LO12:
       FixupKind = LoongArch::fixup_loongarch_abs_lo12;
       break;
-    case LoongArchMCExpr::VK_LoongArch_ABS64_LO20:
+    case LoongArchMCExpr::VK_ABS64_LO20:
       FixupKind = LoongArch::fixup_loongarch_abs64_lo20;
       break;
-    case LoongArchMCExpr::VK_LoongArch_ABS64_HI12:
+    case LoongArchMCExpr::VK_ABS64_HI12:
       FixupKind = LoongArch::fixup_loongarch_abs64_hi12;
       break;
-    case LoongArchMCExpr::VK_LoongArch_PCALA_HI20:
+    case LoongArchMCExpr::VK_PCALA_HI20:
       FixupKind = LoongArch::fixup_loongarch_pcala_hi20;
       break;
-    case LoongArchMCExpr::VK_LoongArch_PCALA_LO12:
+    case LoongArchMCExpr::VK_PCALA_LO12:
       FixupKind = LoongArch::fixup_loongarch_pcala_lo12;
       break;
-    case LoongArchMCExpr::VK_LoongArch_PCALA64_LO20:
+    case LoongArchMCExpr::VK_PCALA64_LO20:
       FixupKind = LoongArch::fixup_loongarch_pcala64_lo20;
       break;
-    case LoongArchMCExpr::VK_LoongArch_PCALA64_HI12:
+    case LoongArchMCExpr::VK_PCALA64_HI12:
       FixupKind = LoongArch::fixup_loongarch_pcala64_hi12;
       break;
-    case LoongArchMCExpr::VK_LoongArch_GOT_PC_HI20:
+    case LoongArchMCExpr::VK_GOT_PC_HI20:
       FixupKind = LoongArch::fixup_loongarch_got_pc_hi20;
       break;
-    case LoongArchMCExpr::VK_LoongArch_GOT_PC_LO12:
+    case LoongArchMCExpr::VK_GOT_PC_LO12:
       FixupKind = LoongArch::fixup_loongarch_got_pc_lo12;
       break;
-    case LoongArchMCExpr::VK_LoongArch_GOT64_PC_LO20:
+    case LoongArchMCExpr::VK_GOT64_PC_LO20:
       FixupKind = LoongArch::fixup_loongarch_got64_pc_lo20;
       break;
-    case LoongArchMCExpr::VK_LoongArch_GOT64_PC_HI12:
+    case LoongArchMCExpr::VK_GOT64_PC_HI12:
       FixupKind = LoongArch::fixup_loongarch_got64_pc_hi12;
       break;
-    case LoongArchMCExpr::VK_LoongArch_GOT_HI20:
+    case LoongArchMCExpr::VK_GOT_HI20:
       FixupKind = LoongArch::fixup_loongarch_got_hi20;
       break;
-    case LoongArchMCExpr::VK_LoongArch_GOT_LO12:
+    case LoongArchMCExpr::VK_GOT_LO12:
       FixupKind = LoongArch::fixup_loongarch_got_lo12;
       break;
-    case LoongArchMCExpr::VK_LoongArch_GOT64_LO20:
+    case LoongArchMCExpr::VK_GOT64_LO20:
       FixupKind = LoongArch::fixup_loongarch_got64_lo20;
       break;
-    case LoongArchMCExpr::VK_LoongArch_GOT64_HI12:
+    case LoongArchMCExpr::VK_GOT64_HI12:
       FixupKind = LoongArch::fixup_loongarch_got64_hi12;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_LE_HI20:
+    case LoongArchMCExpr::VK_TLS_LE_HI20:
       FixupKind = LoongArch::fixup_loongarch_tls_le_hi20;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_LE_LO12:
+    case LoongArchMCExpr::VK_TLS_LE_LO12:
       FixupKind = LoongArch::fixup_loongarch_tls_le_lo12;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_LE64_LO20:
+    case LoongArchMCExpr::VK_TLS_LE64_LO20:
       FixupKind = LoongArch::fixup_loongarch_tls_le64_lo20;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_LE64_HI12:
+    case LoongArchMCExpr::VK_TLS_LE64_HI12:
       FixupKind = LoongArch::fixup_loongarch_tls_le64_hi12;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_IE_PC_HI20:
+    case LoongArchMCExpr::VK_TLS_IE_PC_HI20:
       FixupKind = LoongArch::fixup_loongarch_tls_ie_pc_hi20;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_IE_PC_LO12:
+    case LoongArchMCExpr::VK_TLS_IE_PC_LO12:
       FixupKind = LoongArch::fixup_loongarch_tls_ie_pc_lo12;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_IE64_PC_LO20:
+    case LoongArchMCExpr::VK_TLS_IE64_PC_LO20:
       FixupKind = LoongArch::fixup_loongarch_tls_ie64_pc_lo20;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_IE64_PC_HI12:
+    case LoongArchMCExpr::VK_TLS_IE64_PC_HI12:
       FixupKind = LoongArch::fixup_loongarch_tls_ie64_pc_hi12;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_IE_HI20:
+    case LoongArchMCExpr::VK_TLS_IE_HI20:
       FixupKind = LoongArch::fixup_loongarch_tls_ie_hi20;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_IE_LO12:
+    case LoongArchMCExpr::VK_TLS_IE_LO12:
       FixupKind = LoongArch::fixup_loongarch_tls_ie_lo12;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_IE64_LO20:
+    case LoongArchMCExpr::VK_TLS_IE64_LO20:
       FixupKind = LoongArch::fixup_loongarch_tls_ie64_lo20;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_IE64_HI12:
+    case LoongArchMCExpr::VK_TLS_IE64_HI12:
       FixupKind = LoongArch::fixup_loongarch_tls_ie64_hi12;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_LD_PC_HI20:
+    case LoongArchMCExpr::VK_TLS_LD_PC_HI20:
       FixupKind = LoongArch::fixup_loongarch_tls_ld_pc_hi20;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_LD_HI20:
+    case LoongArchMCExpr::VK_TLS_LD_HI20:
       FixupKind = LoongArch::fixup_loongarch_tls_ld_hi20;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_GD_PC_HI20:
+    case LoongArchMCExpr::VK_TLS_GD_PC_HI20:
       FixupKind = LoongArch::fixup_loongarch_tls_gd_pc_hi20;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_GD_HI20:
+    case LoongArchMCExpr::VK_TLS_GD_HI20:
       FixupKind = LoongArch::fixup_loongarch_tls_gd_hi20;
       break;
-    case LoongArchMCExpr::VK_LoongArch_CALL36:
+    case LoongArchMCExpr::VK_CALL36:
       FixupKind = LoongArch::fixup_loongarch_call36;
       RelaxCandidate = true;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_DESC_PC_HI20:
+    case LoongArchMCExpr::VK_TLS_DESC_PC_HI20:
       FixupKind = LoongArch::fixup_loongarch_tls_desc_pc_hi20;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_DESC_PC_LO12:
+    case LoongArchMCExpr::VK_TLS_DESC_PC_LO12:
       FixupKind = LoongArch::fixup_loongarch_tls_desc_pc_lo12;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_DESC64_PC_LO20:
+    case LoongArchMCExpr::VK_TLS_DESC64_PC_LO20:
       FixupKind = LoongArch::fixup_loongarch_tls_desc64_pc_lo20;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_DESC64_PC_HI12:
+    case LoongArchMCExpr::VK_TLS_DESC64_PC_HI12:
       FixupKind = LoongArch::fixup_loongarch_tls_desc64_pc_hi12;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_DESC_HI20:
+    case LoongArchMCExpr::VK_TLS_DESC_HI20:
       FixupKind = LoongArch::fixup_loongarch_tls_desc_hi20;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_DESC_LO12:
+    case LoongArchMCExpr::VK_TLS_DESC_LO12:
       FixupKind = LoongArch::fixup_loongarch_tls_desc_lo12;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_DESC64_LO20:
+    case LoongArchMCExpr::VK_TLS_DESC64_LO20:
       FixupKind = LoongArch::fixup_loongarch_tls_desc64_lo20;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_DESC64_HI12:
+    case LoongArchMCExpr::VK_TLS_DESC64_HI12:
       FixupKind = LoongArch::fixup_loongarch_tls_desc64_hi12;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_DESC_LD:
+    case LoongArchMCExpr::VK_TLS_DESC_LD:
       FixupKind = LoongArch::fixup_loongarch_tls_desc_ld;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_DESC_CALL:
+    case LoongArchMCExpr::VK_TLS_DESC_CALL:
       FixupKind = LoongArch::fixup_loongarch_tls_desc_call;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_LE_HI20_R:
+    case LoongArchMCExpr::VK_TLS_LE_HI20_R:
       FixupKind = LoongArch::fixup_loongarch_tls_le_hi20_r;
       RelaxCandidate = true;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_LE_LO12_R:
+    case LoongArchMCExpr::VK_TLS_LE_LO12_R:
       FixupKind = LoongArch::fixup_loongarch_tls_le_lo12_r;
       RelaxCandidate = true;
       break;
-    case LoongArchMCExpr::VK_LoongArch_PCREL20_S2:
+    case LoongArchMCExpr::VK_PCREL20_S2:
       FixupKind = LoongArch::fixup_loongarch_pcrel20_s2;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_LD_PCREL20_S2:
+    case LoongArchMCExpr::VK_TLS_LD_PCREL20_S2:
       FixupKind = LoongArch::fixup_loongarch_tls_ld_pcrel20_s2;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_GD_PCREL20_S2:
+    case LoongArchMCExpr::VK_TLS_GD_PCREL20_S2:
       FixupKind = LoongArch::fixup_loongarch_tls_gd_pcrel20_s2;
       break;
-    case LoongArchMCExpr::VK_LoongArch_TLS_DESC_PCREL20_S2:
+    case LoongArchMCExpr::VK_TLS_DESC_PCREL20_S2:
       FixupKind = LoongArch::fixup_loongarch_tls_desc_pcrel20_s2;
       break;
     }
@@ -385,8 +384,7 @@ void LoongArchMCCodeEmitter::expandAddTPRel(const MCInst &MI,
          "Expected expression as third input to TP-relative add");
 
   const LoongArchMCExpr *Expr = dyn_cast<LoongArchMCExpr>(Symbol.getExpr());
-  assert(Expr &&
-         Expr->getKind() == LoongArchMCExpr::VK_LoongArch_TLS_LE_ADD_R &&
+  assert(Expr && Expr->getSpecifier() == LoongArchMCExpr::VK_TLS_LE_ADD_R &&
          "Expected %le_add_r relocation on TP-relative symbol");
 
   // Emit the correct %le_add_r relocation for the symbol.

diff  --git a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCExpr.cpp b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCExpr.cpp
index d3d3b90b2527f..64774243b85e5 100644
--- a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCExpr.cpp
+++ b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCExpr.cpp
@@ -24,19 +24,17 @@ using namespace llvm;
 
 #define DEBUG_TYPE "loongarch-mcexpr"
 
-const LoongArchMCExpr *LoongArchMCExpr::create(const MCExpr *Expr,
-                                               VariantKind Kind, MCContext &Ctx,
-                                               bool Hint) {
-  return new (Ctx) LoongArchMCExpr(Expr, Kind, Hint);
+const LoongArchMCExpr *LoongArchMCExpr::create(const MCExpr *Expr, Specifier S,
+                                               MCContext &Ctx, bool Hint) {
+  return new (Ctx) LoongArchMCExpr(Expr, S, Hint);
 }
 
 void LoongArchMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
-  VariantKind Kind = getKind();
-  bool HasVariant =
-      ((Kind != VK_LoongArch_None) && (Kind != VK_LoongArch_CALL));
+  Specifier S = getSpecifier();
+  bool HasVariant = S != VK_None && S != VK_CALL;
 
   if (HasVariant)
-    OS << '%' << getVariantKindName(getKind()) << '(';
+    OS << '%' << getSpecifierName(specifier) << '(';
   Expr->print(OS, MAI);
   if (HasVariant)
     OS << ')';
@@ -52,188 +50,187 @@ bool LoongArchMCExpr::evaluateAsRelocatableImpl(
     return false;
 
   Res =
-      MCValue::get(Res.getSymA(), Res.getSymB(), Res.getConstant(), getKind());
+      MCValue::get(Res.getSymA(), Res.getSymB(), Res.getConstant(), specifier);
   // Custom fixup types are not valid with symbol 
diff erence expressions.
-  return Res.getSymB() ? getKind() == VK_LoongArch_None : true;
+  return Res.getSymB() ? specifier == VK_None : true;
 }
 
 void LoongArchMCExpr::visitUsedExpr(MCStreamer &Streamer) const {
   Streamer.visitUsedExpr(*getSubExpr());
 }
 
-StringRef LoongArchMCExpr::getVariantKindName(VariantKind Kind) {
-  switch (Kind) {
+StringRef LoongArchMCExpr::getSpecifierName(Specifier S) {
+  switch (S) {
   default:
     llvm_unreachable("Invalid ELF symbol kind");
-  case VK_LoongArch_CALL_PLT:
+  case VK_CALL_PLT:
     return "plt";
-  case VK_LoongArch_B16:
+  case VK_B16:
     return "b16";
-  case VK_LoongArch_B21:
+  case VK_B21:
     return "b21";
-  case VK_LoongArch_B26:
+  case VK_B26:
     return "b26";
-  case VK_LoongArch_ABS_HI20:
+  case VK_ABS_HI20:
     return "abs_hi20";
-  case VK_LoongArch_ABS_LO12:
+  case VK_ABS_LO12:
     return "abs_lo12";
-  case VK_LoongArch_ABS64_LO20:
+  case VK_ABS64_LO20:
     return "abs64_lo20";
-  case VK_LoongArch_ABS64_HI12:
+  case VK_ABS64_HI12:
     return "abs64_hi12";
-  case VK_LoongArch_PCALA_HI20:
+  case VK_PCALA_HI20:
     return "pc_hi20";
-  case VK_LoongArch_PCALA_LO12:
+  case VK_PCALA_LO12:
     return "pc_lo12";
-  case VK_LoongArch_PCALA64_LO20:
+  case VK_PCALA64_LO20:
     return "pc64_lo20";
-  case VK_LoongArch_PCALA64_HI12:
+  case VK_PCALA64_HI12:
     return "pc64_hi12";
-  case VK_LoongArch_GOT_PC_HI20:
+  case VK_GOT_PC_HI20:
     return "got_pc_hi20";
-  case VK_LoongArch_GOT_PC_LO12:
+  case VK_GOT_PC_LO12:
     return "got_pc_lo12";
-  case VK_LoongArch_GOT64_PC_LO20:
+  case VK_GOT64_PC_LO20:
     return "got64_pc_lo20";
-  case VK_LoongArch_GOT64_PC_HI12:
+  case VK_GOT64_PC_HI12:
     return "got64_pc_hi12";
-  case VK_LoongArch_GOT_HI20:
+  case VK_GOT_HI20:
     return "got_hi20";
-  case VK_LoongArch_GOT_LO12:
+  case VK_GOT_LO12:
     return "got_lo12";
-  case VK_LoongArch_GOT64_LO20:
+  case VK_GOT64_LO20:
     return "got64_lo20";
-  case VK_LoongArch_GOT64_HI12:
+  case VK_GOT64_HI12:
     return "got64_hi12";
-  case VK_LoongArch_TLS_LE_HI20:
+  case VK_TLS_LE_HI20:
     return "le_hi20";
-  case VK_LoongArch_TLS_LE_LO12:
+  case VK_TLS_LE_LO12:
     return "le_lo12";
-  case VK_LoongArch_TLS_LE64_LO20:
+  case VK_TLS_LE64_LO20:
     return "le64_lo20";
-  case VK_LoongArch_TLS_LE64_HI12:
+  case VK_TLS_LE64_HI12:
     return "le64_hi12";
-  case VK_LoongArch_TLS_IE_PC_HI20:
+  case VK_TLS_IE_PC_HI20:
     return "ie_pc_hi20";
-  case VK_LoongArch_TLS_IE_PC_LO12:
+  case VK_TLS_IE_PC_LO12:
     return "ie_pc_lo12";
-  case VK_LoongArch_TLS_IE64_PC_LO20:
+  case VK_TLS_IE64_PC_LO20:
     return "ie64_pc_lo20";
-  case VK_LoongArch_TLS_IE64_PC_HI12:
+  case VK_TLS_IE64_PC_HI12:
     return "ie64_pc_hi12";
-  case VK_LoongArch_TLS_IE_HI20:
+  case VK_TLS_IE_HI20:
     return "ie_hi20";
-  case VK_LoongArch_TLS_IE_LO12:
+  case VK_TLS_IE_LO12:
     return "ie_lo12";
-  case VK_LoongArch_TLS_IE64_LO20:
+  case VK_TLS_IE64_LO20:
     return "ie64_lo20";
-  case VK_LoongArch_TLS_IE64_HI12:
+  case VK_TLS_IE64_HI12:
     return "ie64_hi12";
-  case VK_LoongArch_TLS_LD_PC_HI20:
+  case VK_TLS_LD_PC_HI20:
     return "ld_pc_hi20";
-  case VK_LoongArch_TLS_LD_HI20:
+  case VK_TLS_LD_HI20:
     return "ld_hi20";
-  case VK_LoongArch_TLS_GD_PC_HI20:
+  case VK_TLS_GD_PC_HI20:
     return "gd_pc_hi20";
-  case VK_LoongArch_TLS_GD_HI20:
+  case VK_TLS_GD_HI20:
     return "gd_hi20";
-  case VK_LoongArch_CALL36:
+  case VK_CALL36:
     return "call36";
-  case VK_LoongArch_TLS_DESC_PC_HI20:
+  case VK_TLS_DESC_PC_HI20:
     return "desc_pc_hi20";
-  case VK_LoongArch_TLS_DESC_PC_LO12:
+  case VK_TLS_DESC_PC_LO12:
     return "desc_pc_lo12";
-  case VK_LoongArch_TLS_DESC64_PC_LO20:
+  case VK_TLS_DESC64_PC_LO20:
     return "desc64_pc_lo20";
-  case VK_LoongArch_TLS_DESC64_PC_HI12:
+  case VK_TLS_DESC64_PC_HI12:
     return "desc64_pc_hi12";
-  case VK_LoongArch_TLS_DESC_HI20:
+  case VK_TLS_DESC_HI20:
     return "desc_hi20";
-  case VK_LoongArch_TLS_DESC_LO12:
+  case VK_TLS_DESC_LO12:
     return "desc_lo12";
-  case VK_LoongArch_TLS_DESC64_LO20:
+  case VK_TLS_DESC64_LO20:
     return "desc64_lo20";
-  case VK_LoongArch_TLS_DESC64_HI12:
+  case VK_TLS_DESC64_HI12:
     return "desc64_hi12";
-  case VK_LoongArch_TLS_DESC_LD:
+  case VK_TLS_DESC_LD:
     return "desc_ld";
-  case VK_LoongArch_TLS_DESC_CALL:
+  case VK_TLS_DESC_CALL:
     return "desc_call";
-  case VK_LoongArch_TLS_LE_HI20_R:
+  case VK_TLS_LE_HI20_R:
     return "le_hi20_r";
-  case VK_LoongArch_TLS_LE_ADD_R:
+  case VK_TLS_LE_ADD_R:
     return "le_add_r";
-  case VK_LoongArch_TLS_LE_LO12_R:
+  case VK_TLS_LE_LO12_R:
     return "le_lo12_r";
-  case VK_LoongArch_PCREL20_S2:
+  case VK_PCREL20_S2:
     return "pcrel_20";
-  case VK_LoongArch_TLS_LD_PCREL20_S2:
+  case VK_TLS_LD_PCREL20_S2:
     return "ld_pcrel_20";
-  case VK_LoongArch_TLS_GD_PCREL20_S2:
+  case VK_TLS_GD_PCREL20_S2:
     return "gd_pcrel_20";
-  case VK_LoongArch_TLS_DESC_PCREL20_S2:
+  case VK_TLS_DESC_PCREL20_S2:
     return "desc_pcrel_20";
   }
 }
 
-LoongArchMCExpr::VariantKind
-LoongArchMCExpr::getVariantKindForName(StringRef name) {
-  return StringSwitch<LoongArchMCExpr::VariantKind>(name)
-      .Case("plt", VK_LoongArch_CALL_PLT)
-      .Case("b16", VK_LoongArch_B16)
-      .Case("b21", VK_LoongArch_B21)
-      .Case("b26", VK_LoongArch_B26)
-      .Case("abs_hi20", VK_LoongArch_ABS_HI20)
-      .Case("abs_lo12", VK_LoongArch_ABS_LO12)
-      .Case("abs64_lo20", VK_LoongArch_ABS64_LO20)
-      .Case("abs64_hi12", VK_LoongArch_ABS64_HI12)
-      .Case("pc_hi20", VK_LoongArch_PCALA_HI20)
-      .Case("pc_lo12", VK_LoongArch_PCALA_LO12)
-      .Case("pc64_lo20", VK_LoongArch_PCALA64_LO20)
-      .Case("pc64_hi12", VK_LoongArch_PCALA64_HI12)
-      .Case("got_pc_hi20", VK_LoongArch_GOT_PC_HI20)
-      .Case("got_pc_lo12", VK_LoongArch_GOT_PC_LO12)
-      .Case("got64_pc_lo20", VK_LoongArch_GOT64_PC_LO20)
-      .Case("got64_pc_hi12", VK_LoongArch_GOT64_PC_HI12)
-      .Case("got_hi20", VK_LoongArch_GOT_HI20)
-      .Case("got_lo12", VK_LoongArch_GOT_LO12)
-      .Case("got64_lo20", VK_LoongArch_GOT64_LO20)
-      .Case("got64_hi12", VK_LoongArch_GOT64_HI12)
-      .Case("le_hi20", VK_LoongArch_TLS_LE_HI20)
-      .Case("le_lo12", VK_LoongArch_TLS_LE_LO12)
-      .Case("le64_lo20", VK_LoongArch_TLS_LE64_LO20)
-      .Case("le64_hi12", VK_LoongArch_TLS_LE64_HI12)
-      .Case("ie_pc_hi20", VK_LoongArch_TLS_IE_PC_HI20)
-      .Case("ie_pc_lo12", VK_LoongArch_TLS_IE_PC_LO12)
-      .Case("ie64_pc_lo20", VK_LoongArch_TLS_IE64_PC_LO20)
-      .Case("ie64_pc_hi12", VK_LoongArch_TLS_IE64_PC_HI12)
-      .Case("ie_hi20", VK_LoongArch_TLS_IE_HI20)
-      .Case("ie_lo12", VK_LoongArch_TLS_IE_LO12)
-      .Case("ie64_lo20", VK_LoongArch_TLS_IE64_LO20)
-      .Case("ie64_hi12", VK_LoongArch_TLS_IE64_HI12)
-      .Case("ld_pc_hi20", VK_LoongArch_TLS_LD_PC_HI20)
-      .Case("ld_hi20", VK_LoongArch_TLS_LD_HI20)
-      .Case("gd_pc_hi20", VK_LoongArch_TLS_GD_PC_HI20)
-      .Case("gd_hi20", VK_LoongArch_TLS_GD_HI20)
-      .Case("call36", VK_LoongArch_CALL36)
-      .Case("desc_pc_hi20", VK_LoongArch_TLS_DESC_PC_HI20)
-      .Case("desc_pc_lo12", VK_LoongArch_TLS_DESC_PC_LO12)
-      .Case("desc64_pc_lo20", VK_LoongArch_TLS_DESC64_PC_LO20)
-      .Case("desc64_pc_hi12", VK_LoongArch_TLS_DESC64_PC_HI12)
-      .Case("desc_hi20", VK_LoongArch_TLS_DESC_HI20)
-      .Case("desc_lo12", VK_LoongArch_TLS_DESC_LO12)
-      .Case("desc64_lo20", VK_LoongArch_TLS_DESC64_LO20)
-      .Case("desc64_hi12", VK_LoongArch_TLS_DESC64_HI12)
-      .Case("desc_ld", VK_LoongArch_TLS_DESC_LD)
-      .Case("desc_call", VK_LoongArch_TLS_DESC_CALL)
-      .Case("le_hi20_r", VK_LoongArch_TLS_LE_HI20_R)
-      .Case("le_add_r", VK_LoongArch_TLS_LE_ADD_R)
-      .Case("le_lo12_r", VK_LoongArch_TLS_LE_LO12_R)
-      .Case("pcrel_20", VK_LoongArch_PCREL20_S2)
-      .Case("ld_pcrel_20", VK_LoongArch_TLS_LD_PCREL20_S2)
-      .Case("gd_pcrel_20", VK_LoongArch_TLS_GD_PCREL20_S2)
-      .Case("desc_pcrel_20", VK_LoongArch_TLS_DESC_PCREL20_S2)
-      .Default(VK_LoongArch_Invalid);
+LoongArchMCExpr::Specifier LoongArchMCExpr::parseSpecifier(StringRef name) {
+  return StringSwitch<LoongArchMCExpr::Specifier>(name)
+      .Case("plt", VK_CALL_PLT)
+      .Case("b16", VK_B16)
+      .Case("b21", VK_B21)
+      .Case("b26", VK_B26)
+      .Case("abs_hi20", VK_ABS_HI20)
+      .Case("abs_lo12", VK_ABS_LO12)
+      .Case("abs64_lo20", VK_ABS64_LO20)
+      .Case("abs64_hi12", VK_ABS64_HI12)
+      .Case("pc_hi20", VK_PCALA_HI20)
+      .Case("pc_lo12", VK_PCALA_LO12)
+      .Case("pc64_lo20", VK_PCALA64_LO20)
+      .Case("pc64_hi12", VK_PCALA64_HI12)
+      .Case("got_pc_hi20", VK_GOT_PC_HI20)
+      .Case("got_pc_lo12", VK_GOT_PC_LO12)
+      .Case("got64_pc_lo20", VK_GOT64_PC_LO20)
+      .Case("got64_pc_hi12", VK_GOT64_PC_HI12)
+      .Case("got_hi20", VK_GOT_HI20)
+      .Case("got_lo12", VK_GOT_LO12)
+      .Case("got64_lo20", VK_GOT64_LO20)
+      .Case("got64_hi12", VK_GOT64_HI12)
+      .Case("le_hi20", VK_TLS_LE_HI20)
+      .Case("le_lo12", VK_TLS_LE_LO12)
+      .Case("le64_lo20", VK_TLS_LE64_LO20)
+      .Case("le64_hi12", VK_TLS_LE64_HI12)
+      .Case("ie_pc_hi20", VK_TLS_IE_PC_HI20)
+      .Case("ie_pc_lo12", VK_TLS_IE_PC_LO12)
+      .Case("ie64_pc_lo20", VK_TLS_IE64_PC_LO20)
+      .Case("ie64_pc_hi12", VK_TLS_IE64_PC_HI12)
+      .Case("ie_hi20", VK_TLS_IE_HI20)
+      .Case("ie_lo12", VK_TLS_IE_LO12)
+      .Case("ie64_lo20", VK_TLS_IE64_LO20)
+      .Case("ie64_hi12", VK_TLS_IE64_HI12)
+      .Case("ld_pc_hi20", VK_TLS_LD_PC_HI20)
+      .Case("ld_hi20", VK_TLS_LD_HI20)
+      .Case("gd_pc_hi20", VK_TLS_GD_PC_HI20)
+      .Case("gd_hi20", VK_TLS_GD_HI20)
+      .Case("call36", VK_CALL36)
+      .Case("desc_pc_hi20", VK_TLS_DESC_PC_HI20)
+      .Case("desc_pc_lo12", VK_TLS_DESC_PC_LO12)
+      .Case("desc64_pc_lo20", VK_TLS_DESC64_PC_LO20)
+      .Case("desc64_pc_hi12", VK_TLS_DESC64_PC_HI12)
+      .Case("desc_hi20", VK_TLS_DESC_HI20)
+      .Case("desc_lo12", VK_TLS_DESC_LO12)
+      .Case("desc64_lo20", VK_TLS_DESC64_LO20)
+      .Case("desc64_hi12", VK_TLS_DESC64_HI12)
+      .Case("desc_ld", VK_TLS_DESC_LD)
+      .Case("desc_call", VK_TLS_DESC_CALL)
+      .Case("le_hi20_r", VK_TLS_LE_HI20_R)
+      .Case("le_add_r", VK_TLS_LE_ADD_R)
+      .Case("le_lo12_r", VK_TLS_LE_LO12_R)
+      .Case("pcrel_20", VK_PCREL20_S2)
+      .Case("ld_pcrel_20", VK_TLS_LD_PCREL20_S2)
+      .Case("gd_pcrel_20", VK_TLS_GD_PCREL20_S2)
+      .Case("desc_pcrel_20", VK_TLS_DESC_PCREL20_S2)
+      .Default(VK_None);
 }
 
 static void fixELFSymbolsInTLSFixupsImpl(const MCExpr *Expr, MCAssembler &Asm) {
@@ -263,21 +260,21 @@ static void fixELFSymbolsInTLSFixupsImpl(const MCExpr *Expr, MCAssembler &Asm) {
 }
 
 void LoongArchMCExpr::fixELFSymbolsInTLSFixups(MCAssembler &Asm) const {
-  switch (getKind()) {
+  switch (specifier) {
   default:
     return;
-  case VK_LoongArch_TLS_LE_HI20:
-  case VK_LoongArch_TLS_IE_PC_HI20:
-  case VK_LoongArch_TLS_IE_HI20:
-  case VK_LoongArch_TLS_LD_PC_HI20:
-  case VK_LoongArch_TLS_LD_HI20:
-  case VK_LoongArch_TLS_GD_PC_HI20:
-  case VK_LoongArch_TLS_GD_HI20:
-  case VK_LoongArch_TLS_DESC_PC_HI20:
-  case VK_LoongArch_TLS_DESC_HI20:
-  case VK_LoongArch_TLS_LD_PCREL20_S2:
-  case VK_LoongArch_TLS_GD_PCREL20_S2:
-  case VK_LoongArch_TLS_DESC_PCREL20_S2:
+  case VK_TLS_LE_HI20:
+  case VK_TLS_IE_PC_HI20:
+  case VK_TLS_IE_HI20:
+  case VK_TLS_LD_PC_HI20:
+  case VK_TLS_LD_HI20:
+  case VK_TLS_GD_PC_HI20:
+  case VK_TLS_GD_HI20:
+  case VK_TLS_DESC_PC_HI20:
+  case VK_TLS_DESC_HI20:
+  case VK_TLS_LD_PCREL20_S2:
+  case VK_TLS_GD_PCREL20_S2:
+  case VK_TLS_DESC_PCREL20_S2:
     break;
   }
   fixELFSymbolsInTLSFixupsImpl(getSubExpr(), Asm);

diff  --git a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCExpr.h b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCExpr.h
index 4f1de702a17ae..39b912d6728f3 100644
--- a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCExpr.h
+++ b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCExpr.h
@@ -22,79 +22,78 @@ class StringRef;
 
 class LoongArchMCExpr : public MCTargetExpr {
 public:
-  enum VariantKind {
-    VK_LoongArch_None,
-    VK_LoongArch_CALL,
-    VK_LoongArch_CALL_PLT,
-    VK_LoongArch_B16,
-    VK_LoongArch_B21,
-    VK_LoongArch_B26,
-    VK_LoongArch_ABS_HI20,
-    VK_LoongArch_ABS_LO12,
-    VK_LoongArch_ABS64_LO20,
-    VK_LoongArch_ABS64_HI12,
-    VK_LoongArch_PCALA_HI20,
-    VK_LoongArch_PCALA_LO12,
-    VK_LoongArch_PCALA64_LO20,
-    VK_LoongArch_PCALA64_HI12,
-    VK_LoongArch_GOT_PC_HI20,
-    VK_LoongArch_GOT_PC_LO12,
-    VK_LoongArch_GOT64_PC_LO20,
-    VK_LoongArch_GOT64_PC_HI12,
-    VK_LoongArch_GOT_HI20,
-    VK_LoongArch_GOT_LO12,
-    VK_LoongArch_GOT64_LO20,
-    VK_LoongArch_GOT64_HI12,
-    VK_LoongArch_TLS_LE_HI20,
-    VK_LoongArch_TLS_LE_LO12,
-    VK_LoongArch_TLS_LE64_LO20,
-    VK_LoongArch_TLS_LE64_HI12,
-    VK_LoongArch_TLS_IE_PC_HI20,
-    VK_LoongArch_TLS_IE_PC_LO12,
-    VK_LoongArch_TLS_IE64_PC_LO20,
-    VK_LoongArch_TLS_IE64_PC_HI12,
-    VK_LoongArch_TLS_IE_HI20,
-    VK_LoongArch_TLS_IE_LO12,
-    VK_LoongArch_TLS_IE64_LO20,
-    VK_LoongArch_TLS_IE64_HI12,
-    VK_LoongArch_TLS_LD_PC_HI20,
-    VK_LoongArch_TLS_LD_HI20,
-    VK_LoongArch_TLS_GD_PC_HI20,
-    VK_LoongArch_TLS_GD_HI20,
-    VK_LoongArch_CALL36,
-    VK_LoongArch_TLS_DESC_PC_HI20,
-    VK_LoongArch_TLS_DESC_PC_LO12,
-    VK_LoongArch_TLS_DESC64_PC_LO20,
-    VK_LoongArch_TLS_DESC64_PC_HI12,
-    VK_LoongArch_TLS_DESC_HI20,
-    VK_LoongArch_TLS_DESC_LO12,
-    VK_LoongArch_TLS_DESC64_LO20,
-    VK_LoongArch_TLS_DESC64_HI12,
-    VK_LoongArch_TLS_DESC_LD,
-    VK_LoongArch_TLS_DESC_CALL,
-    VK_LoongArch_TLS_LE_HI20_R,
-    VK_LoongArch_TLS_LE_ADD_R,
-    VK_LoongArch_TLS_LE_LO12_R,
-    VK_LoongArch_PCREL20_S2,
-    VK_LoongArch_TLS_LD_PCREL20_S2,
-    VK_LoongArch_TLS_GD_PCREL20_S2,
-    VK_LoongArch_TLS_DESC_PCREL20_S2,
-    VK_LoongArch_Invalid // Must be the last item.
+  enum Specifier {
+    VK_None,
+    VK_CALL,
+    VK_CALL_PLT,
+    VK_B16,
+    VK_B21,
+    VK_B26,
+    VK_ABS_HI20,
+    VK_ABS_LO12,
+    VK_ABS64_LO20,
+    VK_ABS64_HI12,
+    VK_PCALA_HI20,
+    VK_PCALA_LO12,
+    VK_PCALA64_LO20,
+    VK_PCALA64_HI12,
+    VK_GOT_PC_HI20,
+    VK_GOT_PC_LO12,
+    VK_GOT64_PC_LO20,
+    VK_GOT64_PC_HI12,
+    VK_GOT_HI20,
+    VK_GOT_LO12,
+    VK_GOT64_LO20,
+    VK_GOT64_HI12,
+    VK_TLS_LE_HI20,
+    VK_TLS_LE_LO12,
+    VK_TLS_LE64_LO20,
+    VK_TLS_LE64_HI12,
+    VK_TLS_IE_PC_HI20,
+    VK_TLS_IE_PC_LO12,
+    VK_TLS_IE64_PC_LO20,
+    VK_TLS_IE64_PC_HI12,
+    VK_TLS_IE_HI20,
+    VK_TLS_IE_LO12,
+    VK_TLS_IE64_LO20,
+    VK_TLS_IE64_HI12,
+    VK_TLS_LD_PC_HI20,
+    VK_TLS_LD_HI20,
+    VK_TLS_GD_PC_HI20,
+    VK_TLS_GD_HI20,
+    VK_CALL36,
+    VK_TLS_DESC_PC_HI20,
+    VK_TLS_DESC_PC_LO12,
+    VK_TLS_DESC64_PC_LO20,
+    VK_TLS_DESC64_PC_HI12,
+    VK_TLS_DESC_HI20,
+    VK_TLS_DESC_LO12,
+    VK_TLS_DESC64_LO20,
+    VK_TLS_DESC64_HI12,
+    VK_TLS_DESC_LD,
+    VK_TLS_DESC_CALL,
+    VK_TLS_LE_HI20_R,
+    VK_TLS_LE_ADD_R,
+    VK_TLS_LE_LO12_R,
+    VK_PCREL20_S2,
+    VK_TLS_LD_PCREL20_S2,
+    VK_TLS_GD_PCREL20_S2,
+    VK_TLS_DESC_PCREL20_S2,
   };
 
 private:
   const MCExpr *Expr;
-  const VariantKind Kind;
+  const Specifier specifier;
   const bool RelaxHint;
 
-  explicit LoongArchMCExpr(const MCExpr *Expr, VariantKind Kind, bool Hint)
-      : Expr(Expr), Kind(Kind), RelaxHint(Hint) {}
+  explicit LoongArchMCExpr(const MCExpr *Expr, Specifier S, bool Hint)
+      : Expr(Expr), specifier(S), RelaxHint(Hint) {}
 
 public:
-  static const LoongArchMCExpr *create(const MCExpr *Expr, VariantKind Kind,
+  static const LoongArchMCExpr *create(const MCExpr *Expr, Specifier Kind,
                                        MCContext &Ctx, bool Hint = false);
 
-  VariantKind getKind() const { return Kind; }
+  Specifier getSpecifier() const { return specifier; }
   const MCExpr *getSubExpr() const { return Expr; }
   bool getRelaxHint() const { return RelaxHint; }
 
@@ -112,8 +111,8 @@ class LoongArchMCExpr : public MCTargetExpr {
     return E->getKind() == MCExpr::Target;
   }
 
-  static StringRef getVariantKindName(VariantKind Kind);
-  static VariantKind getVariantKindForName(StringRef name);
+  static StringRef getSpecifierName(Specifier Kind);
+  static Specifier parseSpecifier(StringRef name);
 };
 
 } // end namespace llvm


        


More information about the llvm-commits mailing list