diff options
author | Tim Northover <Tim.Northover@arm.com> | 2013-01-10 16:47:31 +0000 |
---|---|---|
committer | Tim Northover <Tim.Northover@arm.com> | 2013-01-10 16:47:31 +0000 |
commit | 12da505d938ecfbc49b203e454bada99eda950e3 (patch) | |
tree | f0f800bf76544aa4d1760c2a6f90148074f3cfa2 /utils/TableGen | |
parent | 88abcde3b47dcd9b64e8b0cd6558481d692609eb (diff) |
Remove locale-dependence of enum mangling and use existing function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172077 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen')
-rw-r--r-- | utils/TableGen/AsmMatcherEmitter.cpp | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/utils/TableGen/AsmMatcherEmitter.cpp b/utils/TableGen/AsmMatcherEmitter.cpp index f0fb970802..a4b0694bc0 100644 --- a/utils/TableGen/AsmMatcherEmitter.cpp +++ b/utils/TableGen/AsmMatcherEmitter.cpp @@ -958,8 +958,12 @@ static std::string getEnumNameForToken(StringRef Str) { case ':': Res += "_COLON_"; break; case '!': Res += "_EXCLAIM_"; break; case '.': Res += "_DOT_"; break; + case '<': Res += "_LT_"; break; + case '>': Res += "_GT_"; break; default: - if (isalnum(*it)) + if ((*it >= 'A' && *it <= 'Z') || + (*it >= 'a' && *it <= 'z') || + (*it >= '0' && *it <= '9')) Res += *it; else Res += "_" + utostr((unsigned) *it) + "_"; @@ -1658,16 +1662,6 @@ void MatchableInfo::buildAliasResultOperands() { } } -// Modify a string so that it is suitable for use as an enum tag. -static std::string mangle(const std::string &Name) { - std::string MangledName = Name; - for (unsigned i = 0; i < MangledName.size(); ++i) { - if (!isalnum(MangledName[i]) && MangledName[i] != '_') - MangledName[i] = '_'; - } - return MangledName; -} - static unsigned getConverterOperandID(const std::string &Name, SetVector<std::string> &Table, bool &IsNew) { @@ -1764,7 +1758,8 @@ static void emitConvertFuncs(CodeGenTarget &Target, StringRef ClassName, // Remember this converter for the kind enum. unsigned KindID = OperandConversionKinds.size(); - OperandConversionKinds.insert("CVT_" + mangle(AsmMatchConverter)); + OperandConversionKinds.insert("CVT_" + + getEnumNameForToken(AsmMatchConverter)); // Add the converter row for this instruction. ConversionTable.push_back(std::vector<uint8_t>()); @@ -1772,7 +1767,8 @@ static void emitConvertFuncs(CodeGenTarget &Target, StringRef ClassName, ConversionTable.back().push_back(CVT_Done); // Add the handler to the conversion driver function. - CvtOS << " case CVT_" << mangle(AsmMatchConverter) << ":\n" + CvtOS << " case CVT_" + << getEnumNameForToken(AsmMatchConverter) << ":\n" << " " << AsmMatchConverter << "(Inst, Operands);\n" << " break;\n"; @@ -1810,7 +1806,7 @@ static void emitConvertFuncs(CodeGenTarget &Target, StringRef ClassName, // the index of its entry in the vector). std::string Name = "CVT_" + (Op.Class->isRegisterClass() ? "Reg" : Op.Class->RenderMethod); - Name = mangle(Name); + Name = getEnumNameForToken(Name); bool IsNewConverter = false; unsigned ID = getConverterOperandID(Name, OperandConversionKinds, |