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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224547 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Roman Divacky 2014-12-18 23:12:34 +00:00
parent 82a4ce31b2
commit 4be95036e7

View File

@ -286,166 +286,86 @@ StringRef MCSymbolRefExpr::getVariantKindName(VariantKind Kind) {
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@L", VK_PPC_GOT_LO)
.Case("got@l", VK_PPC_GOT_LO)
.Case("GOT@H", VK_PPC_GOT_HI)
.Case("got@h", VK_PPC_GOT_HI)
.Case("GOT@HA", VK_PPC_GOT_HA)
.Case("got@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@L", VK_PPC_TOC_LO)
.Case("toc@l", VK_PPC_TOC_LO)
.Case("TOC@H", VK_PPC_TOC_HI)
.Case("toc@h", VK_PPC_TOC_HI)
.Case("TOC@HA", VK_PPC_TOC_HA)
.Case("toc@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@L", VK_PPC_TPREL_LO)
.Case("tprel@l", VK_PPC_TPREL_LO)
.Case("TPREL@H", VK_PPC_TPREL_HI)
.Case("tprel@h", VK_PPC_TPREL_HI)
.Case("TPREL@HA", VK_PPC_TPREL_HA)
.Case("tprel@ha", VK_PPC_TPREL_HA)
.Case("TPREL@HIGHER", VK_PPC_TPREL_HIGHER)
.Case("tprel@higher", VK_PPC_TPREL_HIGHER)
.Case("TPREL@HIGHERA", VK_PPC_TPREL_HIGHERA)
.Case("tprel@highera", VK_PPC_TPREL_HIGHERA)
.Case("TPREL@HIGHEST", VK_PPC_TPREL_HIGHEST)
.Case("tprel@highest", VK_PPC_TPREL_HIGHEST)
.Case("TPREL@HIGHESTA", VK_PPC_TPREL_HIGHESTA)
.Case("tprel@highesta", VK_PPC_TPREL_HIGHESTA)
.Case("DTPREL", VK_PPC_DTPREL)
.Case("dtprel", VK_PPC_DTPREL)
.Case("DTPREL@L", VK_PPC_DTPREL_LO)
.Case("dtprel@l", VK_PPC_DTPREL_LO)
.Case("DTPREL@H", VK_PPC_DTPREL_HI)
.Case("dtprel@h", VK_PPC_DTPREL_HI)
.Case("DTPREL@HA", VK_PPC_DTPREL_HA)
.Case("dtprel@ha", VK_PPC_DTPREL_HA)
.Case("DTPREL@HIGHER", VK_PPC_DTPREL_HIGHER)
.Case("dtprel@higher", VK_PPC_DTPREL_HIGHER)
.Case("DTPREL@HIGHERA", VK_PPC_DTPREL_HIGHERA)
.Case("dtprel@highera", VK_PPC_DTPREL_HIGHERA)
.Case("DTPREL@HIGHEST", VK_PPC_DTPREL_HIGHEST)
.Case("dtprel@highest", VK_PPC_DTPREL_HIGHEST)
.Case("DTPREL@HIGHESTA", VK_PPC_DTPREL_HIGHESTA)
.Case("dtprel@highesta", VK_PPC_DTPREL_HIGHESTA)
.Case("GOT@TPREL", VK_PPC_GOT_TPREL)
.Case("got@tprel", VK_PPC_GOT_TPREL)
.Case("GOT@TPREL@L", VK_PPC_GOT_TPREL_LO)
.Case("got@tprel@l", VK_PPC_GOT_TPREL_LO)
.Case("GOT@TPREL@H", VK_PPC_GOT_TPREL_HI)
.Case("got@tprel@h", VK_PPC_GOT_TPREL_HI)
.Case("GOT@TPREL@HA", VK_PPC_GOT_TPREL_HA)
.Case("got@tprel@ha", VK_PPC_GOT_TPREL_HA)
.Case("GOT@DTPREL", VK_PPC_GOT_DTPREL)
.Case("got@dtprel", VK_PPC_GOT_DTPREL)
.Case("GOT@DTPREL@L", VK_PPC_GOT_DTPREL_LO)
.Case("got@dtprel@l", VK_PPC_GOT_DTPREL_LO)
.Case("GOT@DTPREL@H", VK_PPC_GOT_DTPREL_HI)
.Case("got@dtprel@h", VK_PPC_GOT_DTPREL_HI)
.Case("GOT@DTPREL@HA", VK_PPC_GOT_DTPREL_HA)
.Case("got@dtprel@ha", VK_PPC_GOT_DTPREL_HA)
.Case("GOT@TLSGD", VK_PPC_GOT_TLSGD)
.Case("got@tlsgd", VK_PPC_GOT_TLSGD)
.Case("GOT@TLSGD@L", VK_PPC_GOT_TLSGD_LO)
.Case("got@tlsgd@l", VK_PPC_GOT_TLSGD_LO)
.Case("GOT@TLSGD@H", VK_PPC_GOT_TLSGD_HI)
.Case("got@tlsgd@h", VK_PPC_GOT_TLSGD_HI)
.Case("GOT@TLSGD@HA", VK_PPC_GOT_TLSGD_HA)
.Case("got@tlsgd@ha", VK_PPC_GOT_TLSGD_HA)
.Case("GOT@TLSLD", VK_PPC_GOT_TLSLD)
.Case("got@tlsld", VK_PPC_GOT_TLSLD)
.Case("GOT@TLSLD@L", VK_PPC_GOT_TLSLD_LO)
.Case("got@tlsld@l", VK_PPC_GOT_TLSLD_LO)
.Case("GOT@TLSLD@H", VK_PPC_GOT_TLSLD_HI)
.Case("got@tlsld@h", VK_PPC_GOT_TLSLD_HI)
.Case("GOT@TLSLD@HA", VK_PPC_GOT_TLSLD_HA)
.Case("got@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);
}