[clang] f63d763 - [TableGen] Use a table to lookup MVE intrinsic names
Reid Kleckner via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 21 11:05:51 PST 2020
Author: Reid Kleckner
Date: 2020-01-21T11:05:45-08:00
New Revision: f63d7637387995765e9ece0e10fe1b5a4f0612b5
URL: https://github.com/llvm/llvm-project/commit/f63d7637387995765e9ece0e10fe1b5a4f0612b5
DIFF: https://github.com/llvm/llvm-project/commit/f63d7637387995765e9ece0e10fe1b5a4f0612b5.diff
LOG: [TableGen] Use a table to lookup MVE intrinsic names
Summary:
Speeds up compilation of SemaDeclAttr.cpp by nine seconds:
0m49.555s - > 0m40.249s
Reviewers: simon_tatham, dmgreen, ostannard, MarkMurrayARM
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D72984
Added:
Modified:
clang/lib/Sema/SemaDeclAttr.cpp
clang/utils/TableGen/MveEmitter.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 5c51b0f9b8cb..77194de87ba4 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -4937,11 +4937,7 @@ static void handlePatchableFunctionEntryAttr(Sema &S, Decl *D,
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) {
diff --git a/clang/utils/TableGen/MveEmitter.cpp b/clang/utils/TableGen/MveEmitter.cpp
index c39e41ac6e5b..165c757d9a84 100644
--- a/clang/utils/TableGen/MveEmitter.cpp
+++ b/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::EmitBuiltinCG(raw_ostream &OS) {
}
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
More information about the cfe-commits
mailing list