diff options
author | Chris Lattner <sabre@nondot.org> | 2010-09-06 01:44:44 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-09-06 01:44:44 +0000 |
commit | 2738ff9c22d27ce3e4aee6f250eb68f594db1ce9 (patch) | |
tree | 3f4a97ec0e6765ea13b8b4c650bd9382348efda3 /utils | |
parent | c5a5cf26fd4ea1050e8ed18b7c8b02b3f7f16d19 (diff) | |
download | external_llvm-2738ff9c22d27ce3e4aee6f250eb68f594db1ce9.zip external_llvm-2738ff9c22d27ce3e4aee6f250eb68f594db1ce9.tar.gz external_llvm-2738ff9c22d27ce3e4aee6f250eb68f594db1ce9.tar.bz2 |
slightly improve the runtime and code size of the Intrinsics info table by not
comparing the "llvm." prefix in the memcmp, and not storing it in the string literal.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113136 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r-- | utils/TableGen/IntrinsicEmitter.cpp | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/utils/TableGen/IntrinsicEmitter.cpp b/utils/TableGen/IntrinsicEmitter.cpp index ba30d97..cd992c8 100644 --- a/utils/TableGen/IntrinsicEmitter.cpp +++ b/utils/TableGen/IntrinsicEmitter.cpp @@ -99,33 +99,35 @@ EmitFnNameRecognizer(const std::vector<CodeGenIntrinsic> &Ints, // Build a function name -> intrinsic name mapping. std::map<std::string, unsigned> IntMapping; for (unsigned i = 0, e = Ints.size(); i != e; ++i) - IntMapping[Ints[i].Name] = i; + IntMapping[Ints[i].Name.substr(5)] = i; OS << "// Function name -> enum value recognizer code.\n"; OS << "#ifdef GET_FUNCTION_RECOGNIZER\n"; - OS << " switch (Name[5]) {\n"; + OS << " Name += 5; Len -= 5; // Skip over 'llvm.'\n"; + OS << " switch (*Name) { // Dispatch on first letter.\n"; OS << " default:\n"; // Emit the intrinsics in sorted order. char LastChar = 0; for (std::map<std::string, unsigned>::iterator I = IntMapping.begin(), E = IntMapping.end(); I != E; ++I) { - if (I->first[5] != LastChar) { - LastChar = I->first[5]; + if (I->first[0] != LastChar) { + LastChar = I->first[0]; OS << " break;\n"; OS << " case '" << LastChar << "':\n"; } // For overloaded intrinsics, only the prefix needs to match - if (Ints[I->second].isOverloaded) - OS << " if (Len > " << I->first.size() - << " && !memcmp(Name, \"" << I->first << ".\", " - << (I->first.size() + 1) << ")) return " << TargetPrefix << "Intrinsic::" + std::string TheStr = I->first; + if (Ints[I->second].isOverloaded) { + TheStr += '.'; // Require "bswap." instead of bswap. + OS << " if (Len > " << I->first.size(); + } else { + OS << " if (Len == " << I->first.size(); + } + + OS << " && !memcmp(Name, \"" << TheStr << "\", " + << TheStr.size() << ")) return " << TargetPrefix << "Intrinsic::" << Ints[I->second].EnumName << ";\n"; - else - OS << " if (Len == " << I->first.size() - << " && !memcmp(Name, \"" << I->first << "\", " - << I->first.size() << ")) return " << TargetPrefix << "Intrinsic::" - << Ints[I->second].EnumName << ";\n"; } OS << " }\n"; OS << "#endif\n\n"; |