[llvm] 75c6fd3 - [Sparc] Rename VariantKind to Specifier

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


Author: Fangrui Song
Date: 2025-03-20T23:03:47-07:00
New Revision: 75c6fd3c8324d82daf713bcd1c6031dae64759f6

URL: https://github.com/llvm/llvm-project/commit/75c6fd3c8324d82daf713bcd1c6031dae64759f6
DIFF: https://github.com/llvm/llvm-project/commit/75c6fd3c8324d82daf713bcd1c6031dae64759f6.diff

LOG: [Sparc] 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.

Added: 
    

Modified: 
    llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp
    llvm/lib/Target/Sparc/MCTargetDesc/SparcELFObjectWriter.cpp
    llvm/lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.cpp
    llvm/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.cpp
    llvm/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.h
    llvm/lib/Target/Sparc/SparcAsmPrinter.cpp
    llvm/lib/Target/Sparc/SparcISelLowering.cpp
    llvm/lib/Target/Sparc/SparcMCInstLower.cpp
    llvm/lib/Target/Sparc/SparcTargetObjectFile.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp b/llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp
index 62854ea896179..8a730932ce9f8 100644
--- a/llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp
+++ b/llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp
@@ -109,7 +109,7 @@ class SparcAsmParser : public MCTargetAsmParser {
   ParseStatus parseExpression(int64_t &Val);
 
   // Helper function for dealing with %lo / %hi in PIC mode.
-  const SparcMCExpr *adjustPICRelocation(SparcMCExpr::VariantKind VK,
+  const SparcMCExpr *adjustPICRelocation(SparcMCExpr::Specifier VK,
                                          const MCExpr *subExpr);
 
   // Helper function to see if current token can start an expression.
@@ -701,7 +701,7 @@ bool SparcAsmParser::expandSET(MCInst &Inst, SMLoc IDLoc,
   // In either case, start with the 'sethi'.
   if (!IsEffectivelyImm13) {
     MCInst TmpInst;
-    const MCExpr *Expr = adjustPICRelocation(SparcMCExpr::VK_Sparc_HI, ValExpr);
+    const MCExpr *Expr = adjustPICRelocation(SparcMCExpr::VK_HI, ValExpr);
     TmpInst.setLoc(IDLoc);
     TmpInst.setOpcode(SP::SETHIi);
     TmpInst.addOperand(MCRegOp);
@@ -726,7 +726,7 @@ bool SparcAsmParser::expandSET(MCInst &Inst, SMLoc IDLoc,
     if (IsEffectivelyImm13)
       Expr = ValExpr;
     else
-      Expr = adjustPICRelocation(SparcMCExpr::VK_Sparc_LO, ValExpr);
+      Expr = adjustPICRelocation(SparcMCExpr::VK_LO, ValExpr);
     TmpInst.setLoc(IDLoc);
     TmpInst.setOpcode(SP::ORri);
     TmpInst.addOperand(MCRegOp);
@@ -766,7 +766,7 @@ bool SparcAsmParser::expandSETSW(MCInst &Inst, SMLoc IDLoc,
     Instructions.push_back(
         MCInstBuilder(SP::SETHIi)
             .addReg(MCRegOp.getReg())
-            .addExpr(adjustPICRelocation(SparcMCExpr::VK_Sparc_HI, ValExpr)));
+            .addExpr(adjustPICRelocation(SparcMCExpr::VK_HI, ValExpr)));
 
     PrevReg = MCRegOp;
   }
@@ -774,8 +774,7 @@ bool SparcAsmParser::expandSETSW(MCInst &Inst, SMLoc IDLoc,
   // If the immediate has the lower bits set or is small, we need to emit an or.
   if (!NoLowBitsImm || IsSmallImm) {
     const MCExpr *Expr =
-        IsSmallImm ? ValExpr
-                   : adjustPICRelocation(SparcMCExpr::VK_Sparc_LO, ValExpr);
+        IsSmallImm ? ValExpr : adjustPICRelocation(SparcMCExpr::VK_LO, ValExpr);
 
     // or rd, %lo(val), rd
     Instructions.push_back(MCInstBuilder(SP::ORri)
@@ -831,13 +830,13 @@ bool SparcAsmParser::expandSETX(MCInst &Inst, SMLoc IDLoc,
   Instructions.push_back(
       MCInstBuilder(SP::SETHIi)
           .addReg(MCRegOp.getReg())
-          .addExpr(adjustPICRelocation(SparcMCExpr::VK_Sparc_HI, ValExpr)));
+          .addExpr(adjustPICRelocation(SparcMCExpr::VK_HI, ValExpr)));
   // or    rd, %lo(val), rd
   Instructions.push_back(
       MCInstBuilder(SP::ORri)
           .addReg(MCRegOp.getReg())
           .addReg(MCRegOp.getReg())
-          .addExpr(adjustPICRelocation(SparcMCExpr::VK_Sparc_LO, ValExpr)));
+          .addExpr(adjustPICRelocation(SparcMCExpr::VK_LO, ValExpr)));
 
   // Small positive immediates can be expressed as a single `sethi`+`or`
   // combination, so we can just return here.
@@ -851,13 +850,13 @@ bool SparcAsmParser::expandSETX(MCInst &Inst, SMLoc IDLoc,
   Instructions.push_back(
       MCInstBuilder(SP::SETHIi)
           .addReg(MCTmpOp.getReg())
-          .addExpr(adjustPICRelocation(SparcMCExpr::VK_Sparc_HH, ValExpr)));
+          .addExpr(adjustPICRelocation(SparcMCExpr::VK_HH, ValExpr)));
   // or    tmp, %hm(val), tmp
   Instructions.push_back(
       MCInstBuilder(SP::ORri)
           .addReg(MCTmpOp.getReg())
           .addReg(MCTmpOp.getReg())
-          .addExpr(adjustPICRelocation(SparcMCExpr::VK_Sparc_HM, ValExpr)));
+          .addExpr(adjustPICRelocation(SparcMCExpr::VK_HM, ValExpr)));
   // sllx  tmp, 32, tmp
   Instructions.push_back(MCInstBuilder(SP::SLLXri)
                              .addReg(MCTmpOp.getReg())
@@ -1115,20 +1114,20 @@ ParseStatus SparcAsmParser::parseTailRelocSym(OperandVector &Operands) {
   SMLoc S = getLoc();
   SMLoc E = SMLoc::getFromPointer(S.getPointer() - 1);
 
-  auto MatchesKind = [](SparcMCExpr::VariantKind VK) -> bool {
+  auto MatchesKind = [](SparcMCExpr::Specifier VK) -> bool {
     switch (Kind) {
     case TailRelocKind::Load_GOT:
       // Non-TLS relocations on ld (or ldx).
       // ld [%rr + %rr], %rr, %rel(sym)
-      return VK == SparcMCExpr::VK_Sparc_GOTDATA_OP;
+      return VK == SparcMCExpr::VK_GOTDATA_OP;
     case TailRelocKind::Add_TLS:
       // TLS relocations on add.
       // add %rr, %rr, %rr, %rel(sym)
       switch (VK) {
-      case SparcMCExpr::VK_Sparc_TLS_GD_ADD:
-      case SparcMCExpr::VK_Sparc_TLS_IE_ADD:
-      case SparcMCExpr::VK_Sparc_TLS_LDM_ADD:
-      case SparcMCExpr::VK_Sparc_TLS_LDO_ADD:
+      case SparcMCExpr::VK_TLS_GD_ADD:
+      case SparcMCExpr::VK_TLS_IE_ADD:
+      case SparcMCExpr::VK_TLS_LDM_ADD:
+      case SparcMCExpr::VK_TLS_LDO_ADD:
         return true;
       default:
         return false;
@@ -1137,8 +1136,8 @@ ParseStatus SparcAsmParser::parseTailRelocSym(OperandVector &Operands) {
       // TLS relocations on ld (or ldx).
       // ld[x] %addr, %rr, %rel(sym)
       switch (VK) {
-      case SparcMCExpr::VK_Sparc_TLS_IE_LD:
-      case SparcMCExpr::VK_Sparc_TLS_IE_LDX:
+      case SparcMCExpr::VK_TLS_IE_LD:
+      case SparcMCExpr::VK_TLS_IE_LDX:
         return true;
       default:
         return false;
@@ -1147,8 +1146,8 @@ ParseStatus SparcAsmParser::parseTailRelocSym(OperandVector &Operands) {
       // TLS relocations on call.
       // call sym, %rel(sym)
       switch (VK) {
-      case SparcMCExpr::VK_Sparc_TLS_GD_CALL:
-      case SparcMCExpr::VK_Sparc_TLS_LDM_CALL:
+      case SparcMCExpr::VK_TLS_GD_CALL:
+      case SparcMCExpr::VK_TLS_LDM_CALL:
         return true;
       default:
         return false;
@@ -1167,9 +1166,9 @@ ParseStatus SparcAsmParser::parseTailRelocSym(OperandVector &Operands) {
     return Error(getLoc(), "expected valid identifier for operand modifier");
 
   StringRef Name = getParser().getTok().getIdentifier();
-  SparcMCExpr::VariantKind VK = SparcMCExpr::parseVariantKind(Name);
-  if (VK == SparcMCExpr::VK_Sparc_None)
-    return Error(getLoc(), "invalid operand modifier");
+  SparcMCExpr::Specifier VK = SparcMCExpr::parseSpecifier(Name);
+  if (VK == SparcMCExpr::VK_None)
+    return Error(getLoc(), "invalid relocation specifier");
 
   if (!MatchesKind(VK)) {
     // Did not match the specified set of relocation types, put '%' back.
@@ -1325,8 +1324,8 @@ ParseStatus SparcAsmParser::parseCallTarget(OperandVector &Operands) {
     return ParseStatus::NoMatch;
 
   bool IsPic = getContext().getObjectFileInfo()->isPositionIndependent();
-  SparcMCExpr::VariantKind Kind =
-      IsPic ? SparcMCExpr::VK_Sparc_WPLT30 : SparcMCExpr::VK_Sparc_WDISP30;
+  SparcMCExpr::Specifier Kind =
+      IsPic ? SparcMCExpr::VK_WPLT30 : SparcMCExpr::VK_WDISP30;
 
   const MCExpr *DestExpr = SparcMCExpr::create(Kind, DestValue, getContext());
   Operands.push_back(SparcOperand::CreateImm(DestExpr, S, E));
@@ -1483,13 +1482,13 @@ SparcAsmParser::parseSparcAsmOperand(std::unique_ptr<SparcOperand> &Op,
 
     int64_t Res;
     if (!EVal->evaluateAsAbsolute(Res)) {
-      SparcMCExpr::VariantKind Kind = SparcMCExpr::VK_Sparc_13;
+      SparcMCExpr::Specifier Kind = SparcMCExpr::VK_13;
 
       if (getContext().getObjectFileInfo()->isPositionIndependent()) {
         if (isCall)
-          Kind = SparcMCExpr::VK_Sparc_WPLT30;
+          Kind = SparcMCExpr::VK_WPLT30;
         else
-          Kind = SparcMCExpr::VK_Sparc_GOT13;
+          Kind = SparcMCExpr::VK_GOT13;
       }
       EVal = SparcMCExpr::create(Kind, EVal, getContext());
     }
@@ -1686,7 +1685,7 @@ static bool hasGOTReference(const MCExpr *Expr) {
 }
 
 const SparcMCExpr *
-SparcAsmParser::adjustPICRelocation(SparcMCExpr::VariantKind VK,
+SparcAsmParser::adjustPICRelocation(SparcMCExpr::Specifier VK,
                                     const MCExpr *subExpr) {
   // When in PIC mode, "%lo(...)" and "%hi(...)" behave 
diff erently.
   // If the expression refers contains _GLOBAL_OFFSET_TABLE, it is
@@ -1696,13 +1695,13 @@ SparcAsmParser::adjustPICRelocation(SparcMCExpr::VariantKind VK,
   if (getContext().getObjectFileInfo()->isPositionIndependent()) {
     switch(VK) {
     default: break;
-    case SparcMCExpr::VK_Sparc_LO:
-      VK = (hasGOTReference(subExpr) ? SparcMCExpr::VK_Sparc_PC10
-                                     : SparcMCExpr::VK_Sparc_GOT10);
+    case SparcMCExpr::VK_LO:
+      VK = (hasGOTReference(subExpr) ? SparcMCExpr::VK_PC10
+                                     : SparcMCExpr::VK_GOT10);
       break;
-    case SparcMCExpr::VK_Sparc_HI:
-      VK = (hasGOTReference(subExpr) ? SparcMCExpr::VK_Sparc_PC22
-                                     : SparcMCExpr::VK_Sparc_GOT22);
+    case SparcMCExpr::VK_HI:
+      VK = (hasGOTReference(subExpr) ? SparcMCExpr::VK_PC22
+                                     : SparcMCExpr::VK_GOT22);
       break;
     }
   }
@@ -1718,21 +1717,21 @@ bool SparcAsmParser::matchSparcAsmModifiers(const MCExpr *&EVal,
 
   StringRef name = Tok.getString();
 
-  SparcMCExpr::VariantKind VK = SparcMCExpr::parseVariantKind(name);
+  SparcMCExpr::Specifier VK = SparcMCExpr::parseSpecifier(name);
   switch (VK) {
-  case SparcMCExpr::VK_Sparc_None:
-    Error(getLoc(), "invalid operand modifier");
+  case SparcMCExpr::VK_None:
+    Error(getLoc(), "invalid relocation specifier");
     return false;
 
-  case SparcMCExpr::VK_Sparc_GOTDATA_OP:
-  case SparcMCExpr::VK_Sparc_TLS_GD_ADD:
-  case SparcMCExpr::VK_Sparc_TLS_GD_CALL:
-  case SparcMCExpr::VK_Sparc_TLS_IE_ADD:
-  case SparcMCExpr::VK_Sparc_TLS_IE_LD:
-  case SparcMCExpr::VK_Sparc_TLS_IE_LDX:
-  case SparcMCExpr::VK_Sparc_TLS_LDM_ADD:
-  case SparcMCExpr::VK_Sparc_TLS_LDM_CALL:
-  case SparcMCExpr::VK_Sparc_TLS_LDO_ADD:
+  case SparcMCExpr::VK_GOTDATA_OP:
+  case SparcMCExpr::VK_TLS_GD_ADD:
+  case SparcMCExpr::VK_TLS_GD_CALL:
+  case SparcMCExpr::VK_TLS_IE_ADD:
+  case SparcMCExpr::VK_TLS_IE_LD:
+  case SparcMCExpr::VK_TLS_IE_LDX:
+  case SparcMCExpr::VK_TLS_LDM_ADD:
+  case SparcMCExpr::VK_TLS_LDM_CALL:
+  case SparcMCExpr::VK_TLS_LDO_ADD:
     // These are special-cased at tablegen level.
     return false;
 

diff  --git a/llvm/lib/Target/Sparc/MCTargetDesc/SparcELFObjectWriter.cpp b/llvm/lib/Target/Sparc/MCTargetDesc/SparcELFObjectWriter.cpp
index 6e1c3f7016d9e..2a39d991e2985 100644
--- a/llvm/lib/Target/Sparc/MCTargetDesc/SparcELFObjectWriter.cpp
+++ b/llvm/lib/Target/Sparc/MCTargetDesc/SparcELFObjectWriter.cpp
@@ -47,22 +47,22 @@ unsigned SparcELFObjectWriter::getRelocType(MCContext &Ctx,
     return Kind - FirstLiteralRelocationKind;
 
   switch (Target.getRefKind()) {
-  case SparcMCExpr::VK_Sparc_TLS_GD_HI22:
-  case SparcMCExpr::VK_Sparc_TLS_GD_LO10:
-  case SparcMCExpr::VK_Sparc_TLS_GD_ADD:
-  case SparcMCExpr::VK_Sparc_TLS_LDM_HI22:
-  case SparcMCExpr::VK_Sparc_TLS_LDM_LO10:
-  case SparcMCExpr::VK_Sparc_TLS_LDM_ADD:
-  case SparcMCExpr::VK_Sparc_TLS_LDO_HIX22:
-  case SparcMCExpr::VK_Sparc_TLS_LDO_LOX10:
-  case SparcMCExpr::VK_Sparc_TLS_LDO_ADD:
-  case SparcMCExpr::VK_Sparc_TLS_IE_HI22:
-  case SparcMCExpr::VK_Sparc_TLS_IE_LO10:
-  case SparcMCExpr::VK_Sparc_TLS_IE_LD:
-  case SparcMCExpr::VK_Sparc_TLS_IE_LDX:
-  case SparcMCExpr::VK_Sparc_TLS_IE_ADD:
-  case SparcMCExpr::VK_Sparc_TLS_LE_HIX22:
-  case SparcMCExpr::VK_Sparc_TLS_LE_LOX10:
+  case SparcMCExpr::VK_TLS_GD_HI22:
+  case SparcMCExpr::VK_TLS_GD_LO10:
+  case SparcMCExpr::VK_TLS_GD_ADD:
+  case SparcMCExpr::VK_TLS_LDM_HI22:
+  case SparcMCExpr::VK_TLS_LDM_LO10:
+  case SparcMCExpr::VK_TLS_LDM_ADD:
+  case SparcMCExpr::VK_TLS_LDO_HIX22:
+  case SparcMCExpr::VK_TLS_LDO_LOX10:
+  case SparcMCExpr::VK_TLS_LDO_ADD:
+  case SparcMCExpr::VK_TLS_IE_HI22:
+  case SparcMCExpr::VK_TLS_IE_LO10:
+  case SparcMCExpr::VK_TLS_IE_LD:
+  case SparcMCExpr::VK_TLS_IE_LDX:
+  case SparcMCExpr::VK_TLS_IE_ADD:
+  case SparcMCExpr::VK_TLS_LE_HIX22:
+  case SparcMCExpr::VK_TLS_LE_LOX10:
     if (auto *S = Target.getSymA())
       cast<MCSymbolELF>(S->getSymbol()).setType(ELF::STT_TLS);
     break;
@@ -71,7 +71,7 @@ unsigned SparcELFObjectWriter::getRelocType(MCContext &Ctx,
   }
 
   if (const SparcMCExpr *SExpr = dyn_cast<SparcMCExpr>(Fixup.getValue())) {
-    if (SExpr->getKind() == SparcMCExpr::VK_Sparc_R_DISP32)
+    if (SExpr->getSpecifier() == SparcMCExpr::VK_R_DISP32)
       return ELF::R_SPARC_DISP32;
   }
 

diff  --git a/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.cpp b/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.cpp
index f98a9dd138d44..99ed3b60d618f 100644
--- a/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.cpp
+++ b/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.cpp
@@ -49,7 +49,7 @@ SparcELFMCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
                                                MCStreamer &Streamer) const {
   if (Encoding & dwarf::DW_EH_PE_pcrel) {
     MCContext &Ctx = Streamer.getContext();
-    return SparcMCExpr::create(SparcMCExpr::VK_Sparc_R_DISP32,
+    return SparcMCExpr::create(SparcMCExpr::VK_R_DISP32,
                                MCSymbolRefExpr::create(Sym, Ctx), Ctx);
   }
 
@@ -62,7 +62,7 @@ SparcELFMCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
                                        MCStreamer &Streamer) const {
   if (Encoding & dwarf::DW_EH_PE_pcrel) {
     MCContext &Ctx = Streamer.getContext();
-    return SparcMCExpr::create(SparcMCExpr::VK_Sparc_R_DISP32,
+    return SparcMCExpr::create(SparcMCExpr::VK_R_DISP32,
                                MCSymbolRefExpr::create(Sym, Ctx), Ctx);
   }
   return MCAsmInfo::getExprForFDESymbol(Sym, Encoding, Streamer);

diff  --git a/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.cpp b/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.cpp
index aaf973e16f71a..574b9c46658ae 100644
--- a/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.cpp
+++ b/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.cpp
@@ -24,15 +24,14 @@ using namespace llvm;
 
 #define DEBUG_TYPE "sparcmcexpr"
 
-const SparcMCExpr*
-SparcMCExpr::create(VariantKind Kind, const MCExpr *Expr,
-                      MCContext &Ctx) {
-    return new (Ctx) SparcMCExpr(Kind, Expr);
+const SparcMCExpr *SparcMCExpr::create(Specifier S, const MCExpr *Expr,
+                                       MCContext &Ctx) {
+  return new (Ctx) SparcMCExpr(S, Expr);
 }
 
 void SparcMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
 
-  bool closeParen = printVariantKind(OS, Kind);
+  bool closeParen = printSpecifier(OS, specifier);
 
   const MCExpr *Expr = getSubExpr();
   Expr->print(OS, MAI);
@@ -41,152 +40,154 @@ void SparcMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
     OS << ')';
 }
 
-bool SparcMCExpr::printVariantKind(raw_ostream &OS, VariantKind Kind)
-{
-  switch (Kind) {
-  case VK_Sparc_None:     return false;
-  case VK_Sparc_LO:       OS << "%lo(";  return true;
-  case VK_Sparc_HI:       OS << "%hi(";  return true;
-  case VK_Sparc_H44:      OS << "%h44("; return true;
-  case VK_Sparc_M44:      OS << "%m44("; return true;
-  case VK_Sparc_L44:      OS << "%l44("; return true;
-  case VK_Sparc_HH:       OS << "%hh(";  return true;
-  case VK_Sparc_HM:       OS << "%hm(";  return true;
-  case VK_Sparc_LM:       OS << "%lm(";  return true;
+bool SparcMCExpr::printSpecifier(raw_ostream &OS, Specifier S) {
+  // clang-format off
+  switch (S) {
+  case VK_None:          return false;
+  case VK_LO:            OS << "%lo(";  return true;
+  case VK_HI:            OS << "%hi(";  return true;
+  case VK_H44:           OS << "%h44("; return true;
+  case VK_M44:           OS << "%m44("; return true;
+  case VK_L44:           OS << "%l44("; return true;
+  case VK_HH:            OS << "%hh(";  return true;
+  case VK_HM:            OS << "%hm(";  return true;
+  case VK_LM:            OS << "%lm(";  return true;
     // FIXME: use %pc22/%pc10, if system assembler supports them.
-  case VK_Sparc_PC22:     OS << "%hi("; return true;
-  case VK_Sparc_PC10:     OS << "%lo("; return true;
+  case VK_PC22:          OS << "%hi(";  return true;
+  case VK_PC10:          OS << "%lo(";  return true;
     // FIXME: use %got22/%got10, if system assembler supports them.
-  case VK_Sparc_GOT22:    OS << "%hi("; return true;
-  case VK_Sparc_GOT10:    OS << "%lo("; return true;
-  case VK_Sparc_GOT13:    return false;
-  case VK_Sparc_13:       return false;
-  case VK_Sparc_WDISP30:  return false;
-  case VK_Sparc_WPLT30:   return false;
-  case VK_Sparc_R_DISP32: OS << "%r_disp32("; return true;
-  case VK_Sparc_TLS_GD_HI22:   OS << "%tgd_hi22(";   return true;
-  case VK_Sparc_TLS_GD_LO10:   OS << "%tgd_lo10(";   return true;
-  case VK_Sparc_TLS_GD_ADD:    OS << "%tgd_add(";    return true;
-  case VK_Sparc_TLS_GD_CALL:   OS << "%tgd_call(";   return true;
-  case VK_Sparc_TLS_LDM_HI22:  OS << "%tldm_hi22(";  return true;
-  case VK_Sparc_TLS_LDM_LO10:  OS << "%tldm_lo10(";  return true;
-  case VK_Sparc_TLS_LDM_ADD:   OS << "%tldm_add(";   return true;
-  case VK_Sparc_TLS_LDM_CALL:  OS << "%tldm_call(";  return true;
-  case VK_Sparc_TLS_LDO_HIX22: OS << "%tldo_hix22("; return true;
-  case VK_Sparc_TLS_LDO_LOX10: OS << "%tldo_lox10("; return true;
-  case VK_Sparc_TLS_LDO_ADD:   OS << "%tldo_add(";   return true;
-  case VK_Sparc_TLS_IE_HI22:   OS << "%tie_hi22(";   return true;
-  case VK_Sparc_TLS_IE_LO10:   OS << "%tie_lo10(";   return true;
-  case VK_Sparc_TLS_IE_LD:     OS << "%tie_ld(";     return true;
-  case VK_Sparc_TLS_IE_LDX:    OS << "%tie_ldx(";    return true;
-  case VK_Sparc_TLS_IE_ADD:    OS << "%tie_add(";    return true;
-  case VK_Sparc_TLS_LE_HIX22:  OS << "%tle_hix22(";  return true;
-  case VK_Sparc_TLS_LE_LOX10:  OS << "%tle_lox10(";  return true;
-  case VK_Sparc_HIX22:         OS << "%hix(";        return true;
-  case VK_Sparc_LOX10:         OS << "%lox(";        return true;
-  case VK_Sparc_GOTDATA_HIX22: OS << "%gdop_hix22("; return true;
-  case VK_Sparc_GOTDATA_LOX10: OS << "%gdop_lox10("; return true;
-  case VK_Sparc_GOTDATA_OP:    OS << "%gdop(";       return true;
+  case VK_GOT22:         OS << "%hi(";  return true;
+  case VK_GOT10:         OS << "%lo(";  return true;
+  case VK_GOT13:         return false;
+  case VK_13:            return false;
+  case VK_WDISP30:       return false;
+  case VK_WPLT30:        return false;
+  case VK_R_DISP32:      OS << "%r_disp32(";   return true;
+  case VK_TLS_GD_HI22:   OS << "%tgd_hi22(";   return true;
+  case VK_TLS_GD_LO10:   OS << "%tgd_lo10(";   return true;
+  case VK_TLS_GD_ADD:    OS << "%tgd_add(";    return true;
+  case VK_TLS_GD_CALL:   OS << "%tgd_call(";   return true;
+  case VK_TLS_LDM_HI22:  OS << "%tldm_hi22(";  return true;
+  case VK_TLS_LDM_LO10:  OS << "%tldm_lo10(";  return true;
+  case VK_TLS_LDM_ADD:   OS << "%tldm_add(";   return true;
+  case VK_TLS_LDM_CALL:  OS << "%tldm_call(";  return true;
+  case VK_TLS_LDO_HIX22: OS << "%tldo_hix22("; return true;
+  case VK_TLS_LDO_LOX10: OS << "%tldo_lox10("; return true;
+  case VK_TLS_LDO_ADD:   OS << "%tldo_add(";   return true;
+  case VK_TLS_IE_HI22:   OS << "%tie_hi22(";   return true;
+  case VK_TLS_IE_LO10:   OS << "%tie_lo10(";   return true;
+  case VK_TLS_IE_LD:     OS << "%tie_ld(";     return true;
+  case VK_TLS_IE_LDX:    OS << "%tie_ldx(";    return true;
+  case VK_TLS_IE_ADD:    OS << "%tie_add(";    return true;
+  case VK_TLS_LE_HIX22:  OS << "%tle_hix22(";  return true;
+  case VK_TLS_LE_LOX10:  OS << "%tle_lox10(";  return true;
+  case VK_HIX22:         OS << "%hix(";        return true;
+  case VK_LOX10:         OS << "%lox(";        return true;
+  case VK_GOTDATA_HIX22: OS << "%gdop_hix22("; return true;
+  case VK_GOTDATA_LOX10: OS << "%gdop_lox10("; return true;
+  case VK_GOTDATA_OP:    OS << "%gdop(";       return true;
   }
-  llvm_unreachable("Unhandled SparcMCExpr::VariantKind");
+  // clang-format on
+  llvm_unreachable("Unhandled SparcMCExpr::Specifier");
 }
 
-SparcMCExpr::VariantKind SparcMCExpr::parseVariantKind(StringRef name)
-{
-  return StringSwitch<SparcMCExpr::VariantKind>(name)
-      .Case("lo", VK_Sparc_LO)
-      .Case("hi", VK_Sparc_HI)
-      .Case("h44", VK_Sparc_H44)
-      .Case("m44", VK_Sparc_M44)
-      .Case("l44", VK_Sparc_L44)
-      .Case("hh", VK_Sparc_HH)
-      .Case("uhi", VK_Sparc_HH) // Nonstandard GNU extension
-      .Case("hm", VK_Sparc_HM)
-      .Case("ulo", VK_Sparc_HM) // Nonstandard GNU extension
-      .Case("lm", VK_Sparc_LM)
-      .Case("pc22", VK_Sparc_PC22)
-      .Case("pc10", VK_Sparc_PC10)
-      .Case("got22", VK_Sparc_GOT22)
-      .Case("got10", VK_Sparc_GOT10)
-      .Case("got13", VK_Sparc_GOT13)
-      .Case("r_disp32", VK_Sparc_R_DISP32)
-      .Case("tgd_hi22", VK_Sparc_TLS_GD_HI22)
-      .Case("tgd_lo10", VK_Sparc_TLS_GD_LO10)
-      .Case("tgd_add", VK_Sparc_TLS_GD_ADD)
-      .Case("tgd_call", VK_Sparc_TLS_GD_CALL)
-      .Case("tldm_hi22", VK_Sparc_TLS_LDM_HI22)
-      .Case("tldm_lo10", VK_Sparc_TLS_LDM_LO10)
-      .Case("tldm_add", VK_Sparc_TLS_LDM_ADD)
-      .Case("tldm_call", VK_Sparc_TLS_LDM_CALL)
-      .Case("tldo_hix22", VK_Sparc_TLS_LDO_HIX22)
-      .Case("tldo_lox10", VK_Sparc_TLS_LDO_LOX10)
-      .Case("tldo_add", VK_Sparc_TLS_LDO_ADD)
-      .Case("tie_hi22", VK_Sparc_TLS_IE_HI22)
-      .Case("tie_lo10", VK_Sparc_TLS_IE_LO10)
-      .Case("tie_ld", VK_Sparc_TLS_IE_LD)
-      .Case("tie_ldx", VK_Sparc_TLS_IE_LDX)
-      .Case("tie_add", VK_Sparc_TLS_IE_ADD)
-      .Case("tle_hix22", VK_Sparc_TLS_LE_HIX22)
-      .Case("tle_lox10", VK_Sparc_TLS_LE_LOX10)
-      .Case("hix", VK_Sparc_HIX22)
-      .Case("lox", VK_Sparc_LOX10)
-      .Case("gdop_hix22", VK_Sparc_GOTDATA_HIX22)
-      .Case("gdop_lox10", VK_Sparc_GOTDATA_LOX10)
-      .Case("gdop", VK_Sparc_GOTDATA_OP)
-      .Default(VK_Sparc_None);
+SparcMCExpr::Specifier SparcMCExpr::parseSpecifier(StringRef name) {
+  return StringSwitch<SparcMCExpr::Specifier>(name)
+      .Case("lo", VK_LO)
+      .Case("hi", VK_HI)
+      .Case("h44", VK_H44)
+      .Case("m44", VK_M44)
+      .Case("l44", VK_L44)
+      .Case("hh", VK_HH)
+      .Case("uhi", VK_HH) // Nonstandard GNU extension
+      .Case("hm", VK_HM)
+      .Case("ulo", VK_HM) // Nonstandard GNU extension
+      .Case("lm", VK_LM)
+      .Case("pc22", VK_PC22)
+      .Case("pc10", VK_PC10)
+      .Case("got22", VK_GOT22)
+      .Case("got10", VK_GOT10)
+      .Case("got13", VK_GOT13)
+      .Case("r_disp32", VK_R_DISP32)
+      .Case("tgd_hi22", VK_TLS_GD_HI22)
+      .Case("tgd_lo10", VK_TLS_GD_LO10)
+      .Case("tgd_add", VK_TLS_GD_ADD)
+      .Case("tgd_call", VK_TLS_GD_CALL)
+      .Case("tldm_hi22", VK_TLS_LDM_HI22)
+      .Case("tldm_lo10", VK_TLS_LDM_LO10)
+      .Case("tldm_add", VK_TLS_LDM_ADD)
+      .Case("tldm_call", VK_TLS_LDM_CALL)
+      .Case("tldo_hix22", VK_TLS_LDO_HIX22)
+      .Case("tldo_lox10", VK_TLS_LDO_LOX10)
+      .Case("tldo_add", VK_TLS_LDO_ADD)
+      .Case("tie_hi22", VK_TLS_IE_HI22)
+      .Case("tie_lo10", VK_TLS_IE_LO10)
+      .Case("tie_ld", VK_TLS_IE_LD)
+      .Case("tie_ldx", VK_TLS_IE_LDX)
+      .Case("tie_add", VK_TLS_IE_ADD)
+      .Case("tle_hix22", VK_TLS_LE_HIX22)
+      .Case("tle_lox10", VK_TLS_LE_LOX10)
+      .Case("hix", VK_HIX22)
+      .Case("lox", VK_LOX10)
+      .Case("gdop_hix22", VK_GOTDATA_HIX22)
+      .Case("gdop_lox10", VK_GOTDATA_LOX10)
+      .Case("gdop", VK_GOTDATA_OP)
+      .Default(VK_None);
 }
 
-Sparc::Fixups SparcMCExpr::getFixupKind(SparcMCExpr::VariantKind Kind) {
-  switch (Kind) {
-  default: llvm_unreachable("Unhandled SparcMCExpr::VariantKind");
-  case VK_Sparc_LO:       return Sparc::fixup_sparc_lo10;
-  case VK_Sparc_HI:       return Sparc::fixup_sparc_hi22;
-  case VK_Sparc_H44:      return Sparc::fixup_sparc_h44;
-  case VK_Sparc_M44:      return Sparc::fixup_sparc_m44;
-  case VK_Sparc_L44:      return Sparc::fixup_sparc_l44;
-  case VK_Sparc_HH:       return Sparc::fixup_sparc_hh;
-  case VK_Sparc_HM:       return Sparc::fixup_sparc_hm;
-  case VK_Sparc_LM:       return Sparc::fixup_sparc_lm;
-  case VK_Sparc_PC22:     return Sparc::fixup_sparc_pc22;
-  case VK_Sparc_PC10:     return Sparc::fixup_sparc_pc10;
-  case VK_Sparc_GOT22:    return Sparc::fixup_sparc_got22;
-  case VK_Sparc_GOT10:    return Sparc::fixup_sparc_got10;
-  case VK_Sparc_GOT13:    return Sparc::fixup_sparc_got13;
-  case VK_Sparc_13:       return Sparc::fixup_sparc_13;
-  case VK_Sparc_WPLT30:   return Sparc::fixup_sparc_wplt30;
-  case VK_Sparc_WDISP30:  return Sparc::fixup_sparc_call30;
-  case VK_Sparc_TLS_GD_HI22:   return Sparc::fixup_sparc_tls_gd_hi22;
-  case VK_Sparc_TLS_GD_LO10:   return Sparc::fixup_sparc_tls_gd_lo10;
-  case VK_Sparc_TLS_GD_ADD:    return Sparc::fixup_sparc_tls_gd_add;
-  case VK_Sparc_TLS_GD_CALL:   return Sparc::fixup_sparc_tls_gd_call;
-  case VK_Sparc_TLS_LDM_HI22:  return Sparc::fixup_sparc_tls_ldm_hi22;
-  case VK_Sparc_TLS_LDM_LO10:  return Sparc::fixup_sparc_tls_ldm_lo10;
-  case VK_Sparc_TLS_LDM_ADD:   return Sparc::fixup_sparc_tls_ldm_add;
-  case VK_Sparc_TLS_LDM_CALL:  return Sparc::fixup_sparc_tls_ldm_call;
-  case VK_Sparc_TLS_LDO_HIX22: return Sparc::fixup_sparc_tls_ldo_hix22;
-  case VK_Sparc_TLS_LDO_LOX10: return Sparc::fixup_sparc_tls_ldo_lox10;
-  case VK_Sparc_TLS_LDO_ADD:   return Sparc::fixup_sparc_tls_ldo_add;
-  case VK_Sparc_TLS_IE_HI22:   return Sparc::fixup_sparc_tls_ie_hi22;
-  case VK_Sparc_TLS_IE_LO10:   return Sparc::fixup_sparc_tls_ie_lo10;
-  case VK_Sparc_TLS_IE_LD:     return Sparc::fixup_sparc_tls_ie_ld;
-  case VK_Sparc_TLS_IE_LDX:    return Sparc::fixup_sparc_tls_ie_ldx;
-  case VK_Sparc_TLS_IE_ADD:    return Sparc::fixup_sparc_tls_ie_add;
-  case VK_Sparc_TLS_LE_HIX22:  return Sparc::fixup_sparc_tls_le_hix22;
-  case VK_Sparc_TLS_LE_LOX10:  return Sparc::fixup_sparc_tls_le_lox10;
-  case VK_Sparc_HIX22:         return Sparc::fixup_sparc_hix22;
-  case VK_Sparc_LOX10:         return Sparc::fixup_sparc_lox10;
-  case VK_Sparc_GOTDATA_HIX22: return Sparc::fixup_sparc_gotdata_hix22;
-  case VK_Sparc_GOTDATA_LOX10: return Sparc::fixup_sparc_gotdata_lox10;
-  case VK_Sparc_GOTDATA_OP:    return Sparc::fixup_sparc_gotdata_op;
+Sparc::Fixups SparcMCExpr::getFixupKind(SparcMCExpr::Specifier S) {
+  // clang-format off
+  switch (S) {
+  default: llvm_unreachable("Unhandled SparcMCExpr::Specifier");
+  case VK_LO:            return Sparc::fixup_sparc_lo10;
+  case VK_HI:            return Sparc::fixup_sparc_hi22;
+  case VK_H44:           return Sparc::fixup_sparc_h44;
+  case VK_M44:           return Sparc::fixup_sparc_m44;
+  case VK_L44:           return Sparc::fixup_sparc_l44;
+  case VK_HH:            return Sparc::fixup_sparc_hh;
+  case VK_HM:            return Sparc::fixup_sparc_hm;
+  case VK_LM:            return Sparc::fixup_sparc_lm;
+  case VK_PC22:          return Sparc::fixup_sparc_pc22;
+  case VK_PC10:          return Sparc::fixup_sparc_pc10;
+  case VK_GOT22:         return Sparc::fixup_sparc_got22;
+  case VK_GOT10:         return Sparc::fixup_sparc_got10;
+  case VK_GOT13:         return Sparc::fixup_sparc_got13;
+  case VK_13:            return Sparc::fixup_sparc_13;
+  case VK_WPLT30:        return Sparc::fixup_sparc_wplt30;
+  case VK_WDISP30:       return Sparc::fixup_sparc_call30;
+  case VK_TLS_GD_HI22:   return Sparc::fixup_sparc_tls_gd_hi22;
+  case VK_TLS_GD_LO10:   return Sparc::fixup_sparc_tls_gd_lo10;
+  case VK_TLS_GD_ADD:    return Sparc::fixup_sparc_tls_gd_add;
+  case VK_TLS_GD_CALL:   return Sparc::fixup_sparc_tls_gd_call;
+  case VK_TLS_LDM_HI22:  return Sparc::fixup_sparc_tls_ldm_hi22;
+  case VK_TLS_LDM_LO10:  return Sparc::fixup_sparc_tls_ldm_lo10;
+  case VK_TLS_LDM_ADD:   return Sparc::fixup_sparc_tls_ldm_add;
+  case VK_TLS_LDM_CALL:  return Sparc::fixup_sparc_tls_ldm_call;
+  case VK_TLS_LDO_HIX22: return Sparc::fixup_sparc_tls_ldo_hix22;
+  case VK_TLS_LDO_LOX10: return Sparc::fixup_sparc_tls_ldo_lox10;
+  case VK_TLS_LDO_ADD:   return Sparc::fixup_sparc_tls_ldo_add;
+  case VK_TLS_IE_HI22:   return Sparc::fixup_sparc_tls_ie_hi22;
+  case VK_TLS_IE_LO10:   return Sparc::fixup_sparc_tls_ie_lo10;
+  case VK_TLS_IE_LD:     return Sparc::fixup_sparc_tls_ie_ld;
+  case VK_TLS_IE_LDX:    return Sparc::fixup_sparc_tls_ie_ldx;
+  case VK_TLS_IE_ADD:    return Sparc::fixup_sparc_tls_ie_add;
+  case VK_TLS_LE_HIX22:  return Sparc::fixup_sparc_tls_le_hix22;
+  case VK_TLS_LE_LOX10:  return Sparc::fixup_sparc_tls_le_lox10;
+  case VK_HIX22:         return Sparc::fixup_sparc_hix22;
+  case VK_LOX10:         return Sparc::fixup_sparc_lox10;
+  case VK_GOTDATA_HIX22: return Sparc::fixup_sparc_gotdata_hix22;
+  case VK_GOTDATA_LOX10: return Sparc::fixup_sparc_gotdata_lox10;
+  case VK_GOTDATA_OP:    return Sparc::fixup_sparc_gotdata_op;
   }
+  // clang-format on
 }
 
 bool SparcMCExpr::evaluateAsRelocatableImpl(MCValue &Res,
                                             const MCAssembler *Asm) const {
   if (!getSubExpr()->evaluateAsRelocatable(Res, Asm))
     return false;
-  Res =
-      MCValue::get(Res.getSymA(), Res.getSymB(), Res.getConstant(), getKind());
+  Res = MCValue::get(Res.getSymA(), Res.getSymB(), Res.getConstant(),
+                     getSpecifier());
   return true;
 }
 

diff  --git a/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.h b/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.h
index 42969c8ba2c95..05d9a5ce67104 100644
--- a/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.h
+++ b/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCExpr.h
@@ -22,75 +22,70 @@ namespace llvm {
 class StringRef;
 class SparcMCExpr : public MCTargetExpr {
 public:
-  enum VariantKind {
-    VK_Sparc_None,
-    VK_Sparc_LO,
-    VK_Sparc_HI,
-    VK_Sparc_H44,
-    VK_Sparc_M44,
-    VK_Sparc_L44,
-    VK_Sparc_HH,
-    VK_Sparc_HM,
-    VK_Sparc_LM,
-    VK_Sparc_PC22,
-    VK_Sparc_PC10,
-    VK_Sparc_GOT22,
-    VK_Sparc_GOT10,
-    VK_Sparc_GOT13,
-    VK_Sparc_13,
-    VK_Sparc_WPLT30,
-    VK_Sparc_WDISP30,
-    VK_Sparc_R_DISP32,
-    VK_Sparc_TLS_GD_HI22,
-    VK_Sparc_TLS_GD_LO10,
-    VK_Sparc_TLS_GD_ADD,
-    VK_Sparc_TLS_GD_CALL,
-    VK_Sparc_TLS_LDM_HI22,
-    VK_Sparc_TLS_LDM_LO10,
-    VK_Sparc_TLS_LDM_ADD,
-    VK_Sparc_TLS_LDM_CALL,
-    VK_Sparc_TLS_LDO_HIX22,
-    VK_Sparc_TLS_LDO_LOX10,
-    VK_Sparc_TLS_LDO_ADD,
-    VK_Sparc_TLS_IE_HI22,
-    VK_Sparc_TLS_IE_LO10,
-    VK_Sparc_TLS_IE_LD,
-    VK_Sparc_TLS_IE_LDX,
-    VK_Sparc_TLS_IE_ADD,
-    VK_Sparc_TLS_LE_HIX22,
-    VK_Sparc_TLS_LE_LOX10,
-    VK_Sparc_HIX22,
-    VK_Sparc_LOX10,
-    VK_Sparc_GOTDATA_HIX22,
-    VK_Sparc_GOTDATA_LOX10,
-    VK_Sparc_GOTDATA_OP,
+  enum Specifier {
+    VK_None,
+    VK_LO,
+    VK_HI,
+    VK_H44,
+    VK_M44,
+    VK_L44,
+    VK_HH,
+    VK_HM,
+    VK_LM,
+    VK_PC22,
+    VK_PC10,
+    VK_GOT22,
+    VK_GOT10,
+    VK_GOT13,
+    VK_13,
+    VK_WPLT30,
+    VK_WDISP30,
+    VK_R_DISP32,
+    VK_TLS_GD_HI22,
+    VK_TLS_GD_LO10,
+    VK_TLS_GD_ADD,
+    VK_TLS_GD_CALL,
+    VK_TLS_LDM_HI22,
+    VK_TLS_LDM_LO10,
+    VK_TLS_LDM_ADD,
+    VK_TLS_LDM_CALL,
+    VK_TLS_LDO_HIX22,
+    VK_TLS_LDO_LOX10,
+    VK_TLS_LDO_ADD,
+    VK_TLS_IE_HI22,
+    VK_TLS_IE_LO10,
+    VK_TLS_IE_LD,
+    VK_TLS_IE_LDX,
+    VK_TLS_IE_ADD,
+    VK_TLS_LE_HIX22,
+    VK_TLS_LE_LOX10,
+    VK_HIX22,
+    VK_LOX10,
+    VK_GOTDATA_HIX22,
+    VK_GOTDATA_LOX10,
+    VK_GOTDATA_OP,
   };
 
 private:
-  const VariantKind Kind;
+  const Specifier specifier;
   const MCExpr *Expr;
 
-  explicit SparcMCExpr(VariantKind Kind, const MCExpr *Expr)
-      : Kind(Kind), Expr(Expr) {}
+  explicit SparcMCExpr(Specifier S, const MCExpr *Expr)
+      : specifier(S), Expr(Expr) {}
 
 public:
   /// @name Construction
   /// @{
 
-  static const SparcMCExpr *create(VariantKind Kind, const MCExpr *Expr,
-                                 MCContext &Ctx);
+  static const SparcMCExpr *create(Specifier S, const MCExpr *Expr,
+                                   MCContext &Ctx);
   /// @}
   /// @name Accessors
   /// @{
 
-  /// getOpcode - Get the kind of this expression.
-  VariantKind getKind() const { return Kind; }
-
-  /// getSubExpr - Get the child of this expression.
+  Specifier getSpecifier() const { return specifier; }
   const MCExpr *getSubExpr() const { return Expr; }
-
-  /// getFixupKind - Get the fixup kind of this expression.
-  Sparc::Fixups getFixupKind() const { return getFixupKind(Kind); }
+  Sparc::Fixups getFixupKind() const { return getFixupKind(specifier); }
 
   /// @}
   void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
@@ -105,9 +100,9 @@ class SparcMCExpr : public MCTargetExpr {
     return E->getKind() == MCExpr::Target;
   }
 
-  static VariantKind parseVariantKind(StringRef name);
-  static bool printVariantKind(raw_ostream &OS, VariantKind Kind);
-  static Sparc::Fixups getFixupKind(VariantKind Kind);
+  static Specifier parseSpecifier(StringRef name);
+  static bool printSpecifier(raw_ostream &OS, Specifier Kind);
+  static Sparc::Fixups getFixupKind(Specifier Kind);
 };
 
 } // end namespace llvm.

diff  --git a/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp b/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp
index 7fb67ebfe2200..c3813c52ab00c 100644
--- a/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp
+++ b/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp
@@ -70,24 +70,21 @@ namespace {
   };
 } // end of anonymous namespace
 
-static MCOperand createSparcMCOperand(SparcMCExpr::VariantKind Kind,
+static MCOperand createSparcMCOperand(SparcMCExpr::Specifier Kind,
                                       MCSymbol *Sym, MCContext &OutContext) {
   const MCSymbolRefExpr *MCSym = MCSymbolRefExpr::create(Sym,
                                                          OutContext);
   const SparcMCExpr *expr = SparcMCExpr::create(Kind, MCSym, OutContext);
   return MCOperand::createExpr(expr);
-
 }
 static MCOperand createPCXCallOP(MCSymbol *Label,
                                  MCContext &OutContext) {
-  return createSparcMCOperand(SparcMCExpr::VK_Sparc_WDISP30, Label, OutContext);
+  return createSparcMCOperand(SparcMCExpr::VK_WDISP30, Label, OutContext);
 }
 
-static MCOperand createPCXRelExprOp(SparcMCExpr::VariantKind Kind,
+static MCOperand createPCXRelExprOp(SparcMCExpr::Specifier Kind,
                                     MCSymbol *GOTLabel, MCSymbol *StartLabel,
-                                    MCSymbol *CurLabel,
-                                    MCContext &OutContext)
-{
+                                    MCSymbol *CurLabel, MCContext &OutContext) {
   const MCSymbolRefExpr *GOT = MCSymbolRefExpr::create(GOTLabel, OutContext);
   const MCSymbolRefExpr *Start = MCSymbolRefExpr::create(StartLabel,
                                                          OutContext);
@@ -161,13 +158,10 @@ static void EmitSHL(MCStreamer &OutStreamer,
   EmitBinary(OutStreamer, SP::SLLri, RS1, Imm, RD, STI);
 }
 
-
-static void EmitHiLo(MCStreamer &OutStreamer,  MCSymbol *GOTSym,
-                     SparcMCExpr::VariantKind HiKind,
-                     SparcMCExpr::VariantKind LoKind,
-                     MCOperand &RD,
-                     MCContext &OutContext,
-                     const MCSubtargetInfo &STI) {
+static void EmitHiLo(MCStreamer &OutStreamer, MCSymbol *GOTSym,
+                     SparcMCExpr::Specifier HiKind,
+                     SparcMCExpr::Specifier LoKind, MCOperand &RD,
+                     MCContext &OutContext, const MCSubtargetInfo &STI) {
 
   MCOperand hi = createSparcMCOperand(HiKind, GOTSym, OutContext);
   MCOperand lo = createSparcMCOperand(LoKind, GOTSym, OutContext);
@@ -194,33 +188,29 @@ void SparcAsmPrinter::LowerGETPCXAndEmitMCInsts(const MachineInstr *MI,
     default:
       llvm_unreachable("Unsupported absolute code model");
     case CodeModel::Small:
-      EmitHiLo(*OutStreamer, GOTLabel,
-               SparcMCExpr::VK_Sparc_HI, SparcMCExpr::VK_Sparc_LO,
+      EmitHiLo(*OutStreamer, GOTLabel, SparcMCExpr::VK_HI, SparcMCExpr::VK_LO,
                MCRegOP, OutContext, STI);
       break;
     case CodeModel::Medium: {
-      EmitHiLo(*OutStreamer, GOTLabel,
-               SparcMCExpr::VK_Sparc_H44, SparcMCExpr::VK_Sparc_M44,
+      EmitHiLo(*OutStreamer, GOTLabel, SparcMCExpr::VK_H44, SparcMCExpr::VK_M44,
                MCRegOP, OutContext, STI);
       MCOperand imm = MCOperand::createExpr(MCConstantExpr::create(12,
                                                                    OutContext));
       EmitSHL(*OutStreamer, MCRegOP, imm, MCRegOP, STI);
-      MCOperand lo = createSparcMCOperand(SparcMCExpr::VK_Sparc_L44,
-                                          GOTLabel, OutContext);
+      MCOperand lo =
+          createSparcMCOperand(SparcMCExpr::VK_L44, GOTLabel, OutContext);
       EmitOR(*OutStreamer, MCRegOP, lo, MCRegOP, STI);
       break;
     }
     case CodeModel::Large: {
-      EmitHiLo(*OutStreamer, GOTLabel,
-               SparcMCExpr::VK_Sparc_HH, SparcMCExpr::VK_Sparc_HM,
+      EmitHiLo(*OutStreamer, GOTLabel, SparcMCExpr::VK_HH, SparcMCExpr::VK_HM,
                MCRegOP, OutContext, STI);
       MCOperand imm = MCOperand::createExpr(MCConstantExpr::create(32,
                                                                    OutContext));
       EmitSHL(*OutStreamer, MCRegOP, imm, MCRegOP, STI);
       // Use register %o7 to load the lower 32 bits.
       MCOperand RegO7 = MCOperand::createReg(SP::O7);
-      EmitHiLo(*OutStreamer, GOTLabel,
-               SparcMCExpr::VK_Sparc_HI, SparcMCExpr::VK_Sparc_LO,
+      EmitHiLo(*OutStreamer, GOTLabel, SparcMCExpr::VK_HI, SparcMCExpr::VK_LO,
                RegO7, OutContext, STI);
       EmitADD(*OutStreamer, MCRegOP, RegO7, MCRegOP, STI);
     }
@@ -255,14 +245,12 @@ void SparcAsmPrinter::LowerGETPCXAndEmitMCInsts(const MachineInstr *MI,
     EmitRDPC(*OutStreamer, RegO7, STI);
   }
   OutStreamer->emitLabel(SethiLabel);
-  MCOperand hiImm = createPCXRelExprOp(SparcMCExpr::VK_Sparc_PC22,
-                                       GOTLabel, StartLabel, SethiLabel,
-                                       OutContext);
+  MCOperand hiImm = createPCXRelExprOp(SparcMCExpr::VK_PC22, GOTLabel,
+                                       StartLabel, SethiLabel, OutContext);
   EmitSETHI(*OutStreamer, hiImm, MCRegOP, STI);
   OutStreamer->emitLabel(EndLabel);
-  MCOperand loImm = createPCXRelExprOp(SparcMCExpr::VK_Sparc_PC10,
-                                       GOTLabel, StartLabel, EndLabel,
-                                       OutContext);
+  MCOperand loImm = createPCXRelExprOp(SparcMCExpr::VK_PC10, GOTLabel,
+                                       StartLabel, EndLabel, OutContext);
   EmitOR(*OutStreamer, MCRegOP, loImm, MCRegOP, STI);
   EmitADD(*OutStreamer, MCRegOP, RegO7, MCRegOP, STI);
 }
@@ -317,9 +305,9 @@ void SparcAsmPrinter::printOperand(const MachineInstr *MI, int opNum,
                                    raw_ostream &O) {
   const DataLayout &DL = getDataLayout();
   const MachineOperand &MO = MI->getOperand (opNum);
-  SparcMCExpr::VariantKind TF = (SparcMCExpr::VariantKind) MO.getTargetFlags();
+  SparcMCExpr::Specifier TF = (SparcMCExpr::Specifier)MO.getTargetFlags();
 
-  bool CloseParen = SparcMCExpr::printVariantKind(O, TF);
+  bool CloseParen = SparcMCExpr::printSpecifier(O, TF);
 
   switch (MO.getType()) {
   case MachineOperand::MO_Register:

diff  --git a/llvm/lib/Target/Sparc/SparcISelLowering.cpp b/llvm/lib/Target/Sparc/SparcISelLowering.cpp
index c2c3a59ed0500..85b8750d40f46 100644
--- a/llvm/lib/Target/Sparc/SparcISelLowering.cpp
+++ b/llvm/lib/Target/Sparc/SparcISelLowering.cpp
@@ -1055,8 +1055,8 @@ SparcTargetLowering::LowerCall_32(TargetLowering::CallLoweringInfo &CLI,
   // If the callee is a GlobalAddress node (quite common, every direct call is)
   // turn it into a TargetGlobalAddress node so that legalize doesn't hack it.
   // Likewise ExternalSymbol -> TargetExternalSymbol.
-  unsigned TF = isPositionIndependent() ? SparcMCExpr::VK_Sparc_WPLT30
-                                        : SparcMCExpr::VK_Sparc_WDISP30;
+  unsigned TF = isPositionIndependent() ? SparcMCExpr::VK_WPLT30
+                                        : SparcMCExpr::VK_WDISP30;
   if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee))
     Callee = DAG.getTargetGlobalAddress(G->getGlobal(), dl, MVT::i32, 0, TF);
   else if (ExternalSymbolSDNode *E = dyn_cast<ExternalSymbolSDNode>(Callee))
@@ -1389,8 +1389,8 @@ SparcTargetLowering::LowerCall_64(TargetLowering::CallLoweringInfo &CLI,
   // Likewise ExternalSymbol -> TargetExternalSymbol.
   SDValue Callee = CLI.Callee;
   bool hasReturnsTwice = hasReturnsTwiceAttr(DAG, Callee, CLI.CB);
-  unsigned TF = isPositionIndependent() ? SparcMCExpr::VK_Sparc_WPLT30
-                                        : SparcMCExpr::VK_Sparc_WDISP30;
+  unsigned TF = isPositionIndependent() ? SparcMCExpr::VK_WPLT30
+                                        : SparcMCExpr::VK_WDISP30;
   if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee))
     Callee = DAG.getTargetGlobalAddress(G->getGlobal(), DL, PtrVT, 0, TF);
   else if (ExternalSymbolSDNode *E = dyn_cast<ExternalSymbolSDNode>(Callee))
@@ -2138,11 +2138,10 @@ SDValue SparcTargetLowering::makeAddress(SDValue Op, SelectionDAG &DAG) const {
     if (picLevel == PICLevel::SmallPIC) {
       // This is the pic13 code model, the GOT is known to be smaller than 8KiB.
       Idx = DAG.getNode(SPISD::Lo, DL, Op.getValueType(),
-                        withTargetFlags(Op, SparcMCExpr::VK_Sparc_GOT13, DAG));
+                        withTargetFlags(Op, SparcMCExpr::VK_GOT13, DAG));
     } else {
       // This is the pic32 code model, the GOT is known to be smaller than 4GB.
-      Idx = makeHiLoPair(Op, SparcMCExpr::VK_Sparc_GOT22,
-                         SparcMCExpr::VK_Sparc_GOT10, DAG);
+      Idx = makeHiLoPair(Op, SparcMCExpr::VK_GOT22, SparcMCExpr::VK_GOT10, DAG);
     }
 
     SDValue GlobalBase = DAG.getNode(SPISD::GLOBAL_BASE_REG, DL, VT);
@@ -2161,24 +2160,21 @@ SDValue SparcTargetLowering::makeAddress(SDValue Op, SelectionDAG &DAG) const {
     llvm_unreachable("Unsupported absolute code model");
   case CodeModel::Small:
     // abs32.
-    return makeHiLoPair(Op, SparcMCExpr::VK_Sparc_HI,
-                        SparcMCExpr::VK_Sparc_LO, DAG);
+    return makeHiLoPair(Op, SparcMCExpr::VK_HI, SparcMCExpr::VK_LO, DAG);
   case CodeModel::Medium: {
     // abs44.
-    SDValue H44 = makeHiLoPair(Op, SparcMCExpr::VK_Sparc_H44,
-                               SparcMCExpr::VK_Sparc_M44, DAG);
+    SDValue H44 =
+        makeHiLoPair(Op, SparcMCExpr::VK_H44, SparcMCExpr::VK_M44, DAG);
     H44 = DAG.getNode(ISD::SHL, DL, VT, H44, DAG.getConstant(12, DL, MVT::i32));
-    SDValue L44 = withTargetFlags(Op, SparcMCExpr::VK_Sparc_L44, DAG);
+    SDValue L44 = withTargetFlags(Op, SparcMCExpr::VK_L44, DAG);
     L44 = DAG.getNode(SPISD::Lo, DL, VT, L44);
     return DAG.getNode(ISD::ADD, DL, VT, H44, L44);
   }
   case CodeModel::Large: {
     // abs64.
-    SDValue Hi = makeHiLoPair(Op, SparcMCExpr::VK_Sparc_HH,
-                              SparcMCExpr::VK_Sparc_HM, DAG);
+    SDValue Hi = makeHiLoPair(Op, SparcMCExpr::VK_HH, SparcMCExpr::VK_HM, DAG);
     Hi = DAG.getNode(ISD::SHL, DL, VT, Hi, DAG.getConstant(32, DL, MVT::i32));
-    SDValue Lo = makeHiLoPair(Op, SparcMCExpr::VK_Sparc_HI,
-                              SparcMCExpr::VK_Sparc_LO, DAG);
+    SDValue Lo = makeHiLoPair(Op, SparcMCExpr::VK_HI, SparcMCExpr::VK_LO, DAG);
     return DAG.getNode(ISD::ADD, DL, VT, Hi, Lo);
   }
   }
@@ -2213,18 +2209,18 @@ SDValue SparcTargetLowering::LowerGlobalTLSAddress(SDValue Op,
   TLSModel::Model model = getTargetMachine().getTLSModel(GV);
 
   if (model == TLSModel::GeneralDynamic || model == TLSModel::LocalDynamic) {
-    unsigned HiTF = ((model == TLSModel::GeneralDynamic)
-                     ? SparcMCExpr::VK_Sparc_TLS_GD_HI22
-                     : SparcMCExpr::VK_Sparc_TLS_LDM_HI22);
-    unsigned LoTF = ((model == TLSModel::GeneralDynamic)
-                     ? SparcMCExpr::VK_Sparc_TLS_GD_LO10
-                     : SparcMCExpr::VK_Sparc_TLS_LDM_LO10);
-    unsigned addTF = ((model == TLSModel::GeneralDynamic)
-                      ? SparcMCExpr::VK_Sparc_TLS_GD_ADD
-                      : SparcMCExpr::VK_Sparc_TLS_LDM_ADD);
-    unsigned callTF = ((model == TLSModel::GeneralDynamic)
-                       ? SparcMCExpr::VK_Sparc_TLS_GD_CALL
-                       : SparcMCExpr::VK_Sparc_TLS_LDM_CALL);
+    unsigned HiTF =
+        ((model == TLSModel::GeneralDynamic) ? SparcMCExpr::VK_TLS_GD_HI22
+                                             : SparcMCExpr::VK_TLS_LDM_HI22);
+    unsigned LoTF =
+        ((model == TLSModel::GeneralDynamic) ? SparcMCExpr::VK_TLS_GD_LO10
+                                             : SparcMCExpr::VK_TLS_LDM_LO10);
+    unsigned addTF =
+        ((model == TLSModel::GeneralDynamic) ? SparcMCExpr::VK_TLS_GD_ADD
+                                             : SparcMCExpr::VK_TLS_LDM_ADD);
+    unsigned callTF =
+        ((model == TLSModel::GeneralDynamic) ? SparcMCExpr::VK_TLS_GD_CALL
+                                             : SparcMCExpr::VK_TLS_LDM_CALL);
 
     SDValue HiLo = makeHiLoPair(Op, HiTF, LoTF, DAG);
     SDValue Base = DAG.getNode(SPISD::GLOBAL_BASE_REG, DL, PtrVT);
@@ -2259,18 +2255,20 @@ SDValue SparcTargetLowering::LowerGlobalTLSAddress(SDValue Op,
     if (model != TLSModel::LocalDynamic)
       return Ret;
 
-    SDValue Hi = DAG.getNode(SPISD::Hi, DL, PtrVT,
-                 withTargetFlags(Op, SparcMCExpr::VK_Sparc_TLS_LDO_HIX22, DAG));
-    SDValue Lo = DAG.getNode(SPISD::Lo, DL, PtrVT,
-                 withTargetFlags(Op, SparcMCExpr::VK_Sparc_TLS_LDO_LOX10, DAG));
+    SDValue Hi =
+        DAG.getNode(SPISD::Hi, DL, PtrVT,
+                    withTargetFlags(Op, SparcMCExpr::VK_TLS_LDO_HIX22, DAG));
+    SDValue Lo =
+        DAG.getNode(SPISD::Lo, DL, PtrVT,
+                    withTargetFlags(Op, SparcMCExpr::VK_TLS_LDO_LOX10, DAG));
     HiLo =  DAG.getNode(ISD::XOR, DL, PtrVT, Hi, Lo);
     return DAG.getNode(SPISD::TLS_ADD, DL, PtrVT, Ret, HiLo,
-                   withTargetFlags(Op, SparcMCExpr::VK_Sparc_TLS_LDO_ADD, DAG));
+                       withTargetFlags(Op, SparcMCExpr::VK_TLS_LDO_ADD, DAG));
   }
 
   if (model == TLSModel::InitialExec) {
-    unsigned ldTF     = ((PtrVT == MVT::i64)? SparcMCExpr::VK_Sparc_TLS_IE_LDX
-                         : SparcMCExpr::VK_Sparc_TLS_IE_LD);
+    unsigned ldTF = ((PtrVT == MVT::i64) ? SparcMCExpr::VK_TLS_IE_LDX
+                                         : SparcMCExpr::VK_TLS_IE_LD);
 
     SDValue Base = DAG.getNode(SPISD::GLOBAL_BASE_REG, DL, PtrVT);
 
@@ -2279,24 +2277,24 @@ SDValue SparcTargetLowering::LowerGlobalTLSAddress(SDValue Op,
     MachineFrameInfo &MFI = DAG.getMachineFunction().getFrameInfo();
     MFI.setHasCalls(true);
 
-    SDValue TGA = makeHiLoPair(Op,
-                               SparcMCExpr::VK_Sparc_TLS_IE_HI22,
-                               SparcMCExpr::VK_Sparc_TLS_IE_LO10, DAG);
+    SDValue TGA = makeHiLoPair(Op, SparcMCExpr::VK_TLS_IE_HI22,
+                               SparcMCExpr::VK_TLS_IE_LO10, DAG);
     SDValue Ptr = DAG.getNode(ISD::ADD, DL, PtrVT, Base, TGA);
     SDValue Offset = DAG.getNode(SPISD::TLS_LD,
                                  DL, PtrVT, Ptr,
                                  withTargetFlags(Op, ldTF, DAG));
     return DAG.getNode(SPISD::TLS_ADD, DL, PtrVT,
                        DAG.getRegister(SP::G7, PtrVT), Offset,
-                       withTargetFlags(Op,
-                                       SparcMCExpr::VK_Sparc_TLS_IE_ADD, DAG));
+                       withTargetFlags(Op, SparcMCExpr::VK_TLS_IE_ADD, DAG));
   }
 
   assert(model == TLSModel::LocalExec);
-  SDValue Hi = DAG.getNode(SPISD::Hi, DL, PtrVT,
-                  withTargetFlags(Op, SparcMCExpr::VK_Sparc_TLS_LE_HIX22, DAG));
-  SDValue Lo = DAG.getNode(SPISD::Lo, DL, PtrVT,
-                  withTargetFlags(Op, SparcMCExpr::VK_Sparc_TLS_LE_LOX10, DAG));
+  SDValue Hi =
+      DAG.getNode(SPISD::Hi, DL, PtrVT,
+                  withTargetFlags(Op, SparcMCExpr::VK_TLS_LE_HIX22, DAG));
+  SDValue Lo =
+      DAG.getNode(SPISD::Lo, DL, PtrVT,
+                  withTargetFlags(Op, SparcMCExpr::VK_TLS_LE_LOX10, DAG));
   SDValue Offset =  DAG.getNode(ISD::XOR, DL, PtrVT, Hi, Lo);
 
   return DAG.getNode(ISD::ADD, DL, PtrVT,

diff  --git a/llvm/lib/Target/Sparc/SparcMCInstLower.cpp b/llvm/lib/Target/Sparc/SparcMCInstLower.cpp
index 4e7e7bb5c81b0..8b8d9d7f835ad 100644
--- a/llvm/lib/Target/Sparc/SparcMCInstLower.cpp
+++ b/llvm/lib/Target/Sparc/SparcMCInstLower.cpp
@@ -30,8 +30,7 @@ static MCOperand LowerSymbolOperand(const MachineInstr *MI,
                                     const MachineOperand &MO,
                                     AsmPrinter &AP) {
 
-  SparcMCExpr::VariantKind Kind =
-    (SparcMCExpr::VariantKind)MO.getTargetFlags();
+  SparcMCExpr::Specifier Kind = (SparcMCExpr::Specifier)MO.getTargetFlags();
   const MCSymbol *Symbol = nullptr;
 
   switch(MO.getType()) {

diff  --git a/llvm/lib/Target/Sparc/SparcTargetObjectFile.cpp b/llvm/lib/Target/Sparc/SparcTargetObjectFile.cpp
index c03510fa090df..6c1ecccec85cc 100644
--- a/llvm/lib/Target/Sparc/SparcTargetObjectFile.cpp
+++ b/llvm/lib/Target/Sparc/SparcTargetObjectFile.cpp
@@ -38,7 +38,7 @@ const MCExpr *SparcELFTargetObjectFile::getTTypeGlobalReference(
     }
 
     MCContext &Ctx = getContext();
-    return SparcMCExpr::create(SparcMCExpr::VK_Sparc_R_DISP32,
+    return SparcMCExpr::create(SparcMCExpr::VK_R_DISP32,
                                MCSymbolRefExpr::create(SSym, Ctx), Ctx);
   }
 


        


More information about the llvm-commits mailing list