[llvm] r224547 - Instead of explicitely comparing both lowercase and uppercase variants.
Roman Divacky
rdivacky at freebsd.org
Thu Dec 18 15:12:35 PST 2014
Author: rdivacky
Date: Thu Dec 18 17:12:34 2014
New Revision: 224547
URL: http://llvm.org/viewvc/llvm-project?rev=224547&view=rev
Log:
Instead of explicitely comparing both lowercase and uppercase variants.
.lower() the Name and compare only the lowecase. Removing 81 compares/lines of
code. This changes the accepted string to be mixed lower/upper case but it
should be ok.
Discussed with Jim Grosbach.
Modified:
llvm/trunk/lib/MC/MCExpr.cpp
Modified: llvm/trunk/lib/MC/MCExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCExpr.cpp?rev=224547&r1=224546&r2=224547&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCExpr.cpp (original)
+++ llvm/trunk/lib/MC/MCExpr.cpp Thu Dec 18 17:12:34 2014
@@ -286,166 +286,86 @@ StringRef MCSymbolRefExpr::getVariantKin
MCSymbolRefExpr::VariantKind
MCSymbolRefExpr::getVariantKindForName(StringRef Name) {
- return StringSwitch<VariantKind>(Name)
- .Case("GOT", VK_GOT)
+ return StringSwitch<VariantKind>(Name.lower())
.Case("got", VK_GOT)
- .Case("GOTOFF", VK_GOTOFF)
.Case("gotoff", VK_GOTOFF)
- .Case("GOTPCREL", VK_GOTPCREL)
.Case("gotpcrel", VK_GOTPCREL)
- .Case("GOT_PREL", VK_GOTPCREL)
.Case("got_prel", VK_GOTPCREL)
- .Case("GOTTPOFF", VK_GOTTPOFF)
.Case("gottpoff", VK_GOTTPOFF)
- .Case("INDNTPOFF", VK_INDNTPOFF)
.Case("indntpoff", VK_INDNTPOFF)
- .Case("NTPOFF", VK_NTPOFF)
.Case("ntpoff", VK_NTPOFF)
- .Case("GOTNTPOFF", VK_GOTNTPOFF)
.Case("gotntpoff", VK_GOTNTPOFF)
- .Case("PLT", VK_PLT)
.Case("plt", VK_PLT)
- .Case("TLSGD", VK_TLSGD)
.Case("tlsgd", VK_TLSGD)
- .Case("TLSLD", VK_TLSLD)
.Case("tlsld", VK_TLSLD)
- .Case("TLSLDM", VK_TLSLDM)
.Case("tlsldm", VK_TLSLDM)
- .Case("TPOFF", VK_TPOFF)
.Case("tpoff", VK_TPOFF)
- .Case("DTPOFF", VK_DTPOFF)
.Case("dtpoff", VK_DTPOFF)
- .Case("TLVP", VK_TLVP)
.Case("tlvp", VK_TLVP)
- .Case("TLVPPAGE", VK_TLVPPAGE)
.Case("tlvppage", VK_TLVPPAGE)
- .Case("TLVPPAGEOFF", VK_TLVPPAGEOFF)
.Case("tlvppageoff", VK_TLVPPAGEOFF)
- .Case("PAGE", VK_PAGE)
.Case("page", VK_PAGE)
- .Case("PAGEOFF", VK_PAGEOFF)
.Case("pageoff", VK_PAGEOFF)
- .Case("GOTPAGE", VK_GOTPAGE)
.Case("gotpage", VK_GOTPAGE)
- .Case("GOTPAGEOFF", VK_GOTPAGEOFF)
.Case("gotpageoff", VK_GOTPAGEOFF)
- .Case("IMGREL", VK_COFF_IMGREL32)
.Case("imgrel", VK_COFF_IMGREL32)
- .Case("SECREL32", VK_SECREL)
.Case("secrel32", VK_SECREL)
- .Case("L", VK_PPC_LO)
.Case("l", VK_PPC_LO)
- .Case("H", VK_PPC_HI)
.Case("h", VK_PPC_HI)
- .Case("HA", VK_PPC_HA)
.Case("ha", VK_PPC_HA)
- .Case("HIGHER", VK_PPC_HIGHER)
.Case("higher", VK_PPC_HIGHER)
- .Case("HIGHERA", VK_PPC_HIGHERA)
.Case("highera", VK_PPC_HIGHERA)
- .Case("HIGHEST", VK_PPC_HIGHEST)
.Case("highest", VK_PPC_HIGHEST)
- .Case("HIGHESTA", VK_PPC_HIGHESTA)
.Case("highesta", VK_PPC_HIGHESTA)
- .Case("GOT at L", VK_PPC_GOT_LO)
.Case("got at l", VK_PPC_GOT_LO)
- .Case("GOT at H", VK_PPC_GOT_HI)
.Case("got at h", VK_PPC_GOT_HI)
- .Case("GOT at HA", VK_PPC_GOT_HA)
.Case("got at ha", VK_PPC_GOT_HA)
.Case("local", VK_PPC_LOCAL)
- .Case("LOCAL", VK_PPC_LOCAL)
- .Case("TOCBASE", VK_PPC_TOCBASE)
.Case("tocbase", VK_PPC_TOCBASE)
- .Case("TOC", VK_PPC_TOC)
.Case("toc", VK_PPC_TOC)
- .Case("TOC at L", VK_PPC_TOC_LO)
.Case("toc at l", VK_PPC_TOC_LO)
- .Case("TOC at H", VK_PPC_TOC_HI)
.Case("toc at h", VK_PPC_TOC_HI)
- .Case("TOC at HA", VK_PPC_TOC_HA)
.Case("toc at ha", VK_PPC_TOC_HA)
- .Case("TLS", VK_PPC_TLS)
.Case("tls", VK_PPC_TLS)
- .Case("DTPMOD", VK_PPC_DTPMOD)
.Case("dtpmod", VK_PPC_DTPMOD)
- .Case("TPREL", VK_PPC_TPREL)
.Case("tprel", VK_PPC_TPREL)
- .Case("TPREL at L", VK_PPC_TPREL_LO)
.Case("tprel at l", VK_PPC_TPREL_LO)
- .Case("TPREL at H", VK_PPC_TPREL_HI)
.Case("tprel at h", VK_PPC_TPREL_HI)
- .Case("TPREL at HA", VK_PPC_TPREL_HA)
.Case("tprel at ha", VK_PPC_TPREL_HA)
- .Case("TPREL at HIGHER", VK_PPC_TPREL_HIGHER)
.Case("tprel at higher", VK_PPC_TPREL_HIGHER)
- .Case("TPREL at HIGHERA", VK_PPC_TPREL_HIGHERA)
.Case("tprel at highera", VK_PPC_TPREL_HIGHERA)
- .Case("TPREL at HIGHEST", VK_PPC_TPREL_HIGHEST)
.Case("tprel at highest", VK_PPC_TPREL_HIGHEST)
- .Case("TPREL at HIGHESTA", VK_PPC_TPREL_HIGHESTA)
.Case("tprel at highesta", VK_PPC_TPREL_HIGHESTA)
- .Case("DTPREL", VK_PPC_DTPREL)
.Case("dtprel", VK_PPC_DTPREL)
- .Case("DTPREL at L", VK_PPC_DTPREL_LO)
.Case("dtprel at l", VK_PPC_DTPREL_LO)
- .Case("DTPREL at H", VK_PPC_DTPREL_HI)
.Case("dtprel at h", VK_PPC_DTPREL_HI)
- .Case("DTPREL at HA", VK_PPC_DTPREL_HA)
.Case("dtprel at ha", VK_PPC_DTPREL_HA)
- .Case("DTPREL at HIGHER", VK_PPC_DTPREL_HIGHER)
.Case("dtprel at higher", VK_PPC_DTPREL_HIGHER)
- .Case("DTPREL at HIGHERA", VK_PPC_DTPREL_HIGHERA)
.Case("dtprel at highera", VK_PPC_DTPREL_HIGHERA)
- .Case("DTPREL at HIGHEST", VK_PPC_DTPREL_HIGHEST)
.Case("dtprel at highest", VK_PPC_DTPREL_HIGHEST)
- .Case("DTPREL at HIGHESTA", VK_PPC_DTPREL_HIGHESTA)
.Case("dtprel at highesta", VK_PPC_DTPREL_HIGHESTA)
- .Case("GOT at TPREL", VK_PPC_GOT_TPREL)
.Case("got at tprel", VK_PPC_GOT_TPREL)
- .Case("GOT at TPREL@L", VK_PPC_GOT_TPREL_LO)
.Case("got at tprel@l", VK_PPC_GOT_TPREL_LO)
- .Case("GOT at TPREL@H", VK_PPC_GOT_TPREL_HI)
.Case("got at tprel@h", VK_PPC_GOT_TPREL_HI)
- .Case("GOT at TPREL@HA", VK_PPC_GOT_TPREL_HA)
.Case("got at tprel@ha", VK_PPC_GOT_TPREL_HA)
- .Case("GOT at DTPREL", VK_PPC_GOT_DTPREL)
.Case("got at dtprel", VK_PPC_GOT_DTPREL)
- .Case("GOT at DTPREL@L", VK_PPC_GOT_DTPREL_LO)
.Case("got at dtprel@l", VK_PPC_GOT_DTPREL_LO)
- .Case("GOT at DTPREL@H", VK_PPC_GOT_DTPREL_HI)
.Case("got at dtprel@h", VK_PPC_GOT_DTPREL_HI)
- .Case("GOT at DTPREL@HA", VK_PPC_GOT_DTPREL_HA)
.Case("got at dtprel@ha", VK_PPC_GOT_DTPREL_HA)
- .Case("GOT at TLSGD", VK_PPC_GOT_TLSGD)
.Case("got at tlsgd", VK_PPC_GOT_TLSGD)
- .Case("GOT at TLSGD@L", VK_PPC_GOT_TLSGD_LO)
.Case("got at tlsgd@l", VK_PPC_GOT_TLSGD_LO)
- .Case("GOT at TLSGD@H", VK_PPC_GOT_TLSGD_HI)
.Case("got at tlsgd@h", VK_PPC_GOT_TLSGD_HI)
- .Case("GOT at TLSGD@HA", VK_PPC_GOT_TLSGD_HA)
.Case("got at tlsgd@ha", VK_PPC_GOT_TLSGD_HA)
- .Case("GOT at TLSLD", VK_PPC_GOT_TLSLD)
.Case("got at tlsld", VK_PPC_GOT_TLSLD)
- .Case("GOT at TLSLD@L", VK_PPC_GOT_TLSLD_LO)
.Case("got at tlsld@l", VK_PPC_GOT_TLSLD_LO)
- .Case("GOT at TLSLD@H", VK_PPC_GOT_TLSLD_HI)
.Case("got at tlsld@h", VK_PPC_GOT_TLSLD_HI)
- .Case("GOT at TLSLD@HA", VK_PPC_GOT_TLSLD_HA)
.Case("got at tlsld@ha", VK_PPC_GOT_TLSLD_HA)
- .Case("NONE", VK_ARM_NONE)
.Case("none", VK_ARM_NONE)
- .Case("TARGET1", VK_ARM_TARGET1)
.Case("target1", VK_ARM_TARGET1)
- .Case("TARGET2", VK_ARM_TARGET2)
.Case("target2", VK_ARM_TARGET2)
- .Case("PREL31", VK_ARM_PREL31)
.Case("prel31", VK_ARM_PREL31)
- .Case("TLSLDO", VK_ARM_TLSLDO)
.Case("tlsldo", VK_ARM_TLSLDO)
- .Case("TLSCALL", VK_ARM_TLSCALL)
.Case("tlscall", VK_ARM_TLSCALL)
- .Case("TLSDESC", VK_ARM_TLSDESC)
.Case("tlsdesc", VK_ARM_TLSDESC)
.Default(VK_Invalid);
}
More information about the llvm-commits
mailing list