[PATCH] D72984: [TableGen] Use a table to lookup MVE intrinsic names
Reid Kleckner via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 18 13:02:50 PST 2020
rnk created this revision.
rnk added reviewers: simon_tatham, dmgreen, ostannard, MarkMurrayARM.
Herald added a project: clang.
Speeds up compilation of SemaDeclAttr.cpp by nine seconds:
0m49.555s - > 0m40.249s
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D72984
Files:
clang/lib/Sema/SemaDeclAttr.cpp
clang/utils/TableGen/MveEmitter.cpp
Index: clang/utils/TableGen/MveEmitter.cpp
===================================================================
--- clang/utils/TableGen/MveEmitter.cpp
+++ clang/utils/TableGen/MveEmitter.cpp
@@ -64,6 +64,7 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/TableGen/Error.h"
#include "llvm/TableGen/Record.h"
+#include "llvm/TableGen/StringToOffsetTable.h"
#include <cassert>
#include <cstddef>
#include <cstdint>
@@ -1846,14 +1847,46 @@
}
void MveEmitter::EmitBuiltinAliases(raw_ostream &OS) {
+ // Build a sorted table of:
+ // - intrinsic id number
+ // - full name
+ // - polymorphic name or -1
+ StringToOffsetTable StringTable;
+ OS << "struct IntrinToName {\n"
+ " uint32_t Id;\n"
+ " int32_t FullName;\n"
+ " int32_t ShortName;\n"
+ "};\n";
+ OS << "static const IntrinToName Map[] = {\n";
for (const auto &kv : ACLEIntrinsics) {
const ACLEIntrinsic &Int = *kv.second;
- OS << "case ARM::BI__builtin_arm_mve_" << Int.fullName() << ":\n"
- << " return AliasName == \"" << Int.fullName() << "\"";
- if (Int.polymorphic())
- OS << " || AliasName == \"" << Int.shortName() << "\"";
- OS << ";\n";
- }
+ int32_t ShortNameOffset =
+ Int.polymorphic() ? StringTable.GetOrAddStringOffset(Int.shortName())
+ : -1;
+ OS << " { ARM::BI__builtin_arm_mve_" << Int.fullName() << ", "
+ << StringTable.GetOrAddStringOffset(Int.fullName()) << ", "
+ << ShortNameOffset << "},\n";
+ }
+ OS << "};\n\n";
+
+ OS << "static const char IntrinNames[] = {\n";
+ StringTable.EmitString(OS);
+ OS << "};\n\n";
+
+ OS << "auto It = std::lower_bound(std::begin(Map), "
+ "std::end(Map), BuiltinID,\n"
+ " [](const IntrinToName &L, unsigned Id) {\n"
+ " return L.Id < Id;\n"
+ " });\n";
+ OS << "if (It == std::end(Map) || It->Id != BuiltinID)\n"
+ " return false;\n";
+ OS << "StringRef FullName(&IntrinNames[It->FullName]);\n";
+ OS << "if (AliasName == FullName)\n"
+ " return true;\n";
+ OS << "if (It->ShortName == -1)\n"
+ " return false;\n";
+ OS << "StringRef ShortName(&IntrinNames[It->ShortName]);\n";
+ OS << "return AliasName == ShortName;\n";
}
} // namespace
Index: clang/lib/Sema/SemaDeclAttr.cpp
===================================================================
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -4937,11 +4937,7 @@
static bool ArmMveAliasValid(unsigned BuiltinID, StringRef AliasName) {
if (AliasName.startswith("__arm_"))
AliasName = AliasName.substr(6);
- switch (BuiltinID) {
#include "clang/Basic/arm_mve_builtin_aliases.inc"
- default:
- return false;
- }
}
static void handleArmMveAliasAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72984.238963.patch
Type: text/x-patch
Size: 2806 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200118/83cfec81/attachment-0001.bin>
More information about the cfe-commits
mailing list