summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/lldb/utils/TableGen
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2020-08-03 14:33:06 +0000
committerpatrick <patrick@openbsd.org>2020-08-03 14:33:06 +0000
commit061da546b983eb767bad15e67af1174fb0bcf31c (patch)
tree83c78b820819d70aa40c36d90447978b300078c5 /gnu/llvm/lldb/utils/TableGen
parentImport LLVM 10.0.0 release including clang, lld and lldb. (diff)
downloadwireguard-openbsd-061da546b983eb767bad15e67af1174fb0bcf31c.tar.xz
wireguard-openbsd-061da546b983eb767bad15e67af1174fb0bcf31c.zip
Import LLVM 10.0.0 release including clang, lld and lldb.
ok hackroom tested by plenty
Diffstat (limited to 'gnu/llvm/lldb/utils/TableGen')
-rw-r--r--gnu/llvm/lldb/utils/TableGen/CMakeLists.txt18
-rw-r--r--gnu/llvm/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp185
-rw-r--r--gnu/llvm/lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp180
-rw-r--r--gnu/llvm/lldb/utils/TableGen/LLDBTableGen.cpp83
-rw-r--r--gnu/llvm/lldb/utils/TableGen/LLDBTableGenBackends.h38
-rw-r--r--gnu/llvm/lldb/utils/TableGen/LLDBTableGenUtils.cpp21
-rw-r--r--gnu/llvm/lldb/utils/TableGen/LLDBTableGenUtils.h34
7 files changed, 559 insertions, 0 deletions
diff --git a/gnu/llvm/lldb/utils/TableGen/CMakeLists.txt b/gnu/llvm/lldb/utils/TableGen/CMakeLists.txt
new file mode 100644
index 00000000000..47a6400b428
--- /dev/null
+++ b/gnu/llvm/lldb/utils/TableGen/CMakeLists.txt
@@ -0,0 +1,18 @@
+# tablegen targets get exported via llvm for LLVMConfig.cmake. So standalone
+# builds of lldb can potentially import this via LLVMConfig and also attempt to
+# build it in tree. So only build it if it doesn't exist.
+if (NOT DEFINED LLDB_TABLEGEN_EXE)
+ if (TARGET lldb-tblgen)
+ set(LLDB_TABLEGEN_EXE $<TARGET_FILE:lldb-tblgen> CACHE STRING "")
+ else()
+ set(LLVM_LINK_COMPONENTS Support)
+
+ add_tablegen(lldb-tblgen LLDB
+ LLDBOptionDefEmitter.cpp
+ LLDBPropertyDefEmitter.cpp
+ LLDBTableGen.cpp
+ LLDBTableGenUtils.cpp
+ )
+ set_target_properties(lldb-tblgen PROPERTIES FOLDER "LLDB tablegenning")
+ endif()
+endif()
diff --git a/gnu/llvm/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp b/gnu/llvm/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp
new file mode 100644
index 00000000000..6e73d0c53de
--- /dev/null
+++ b/gnu/llvm/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp
@@ -0,0 +1,185 @@
+//===- LLDBOptionDefEmitter.cpp -------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// These tablegen backends emits LLDB's OptionDefinition values for different
+// LLDB commands.
+//
+//===----------------------------------------------------------------------===//
+
+#include "LLDBTableGenBackends.h"
+#include "LLDBTableGenUtils.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/TableGen/Record.h"
+#include "llvm/TableGen/StringMatcher.h"
+#include "llvm/TableGen/TableGenBackend.h"
+#include <vector>
+
+using namespace llvm;
+using namespace lldb_private;
+
+namespace {
+struct CommandOption {
+ std::vector<std::string> GroupsArg;
+ bool Required = false;
+ std::string FullName;
+ std::string ShortName;
+ std::string ArgType;
+ bool OptionalArg = false;
+ std::string Validator;
+ std::string ArgEnum;
+ std::vector<StringRef> Completions;
+ std::string Description;
+
+ CommandOption() = default;
+ CommandOption(Record *Option) {
+ if (Option->getValue("Groups")) {
+ // The user specified a list of groups.
+ auto Groups = Option->getValueAsListOfInts("Groups");
+ for (int Group : Groups)
+ GroupsArg.push_back("LLDB_OPT_SET_" + std::to_string(Group));
+ } else if (Option->getValue("GroupStart")) {
+ // The user specified a range of groups (with potentially only one
+ // element).
+ int GroupStart = Option->getValueAsInt("GroupStart");
+ int GroupEnd = Option->getValueAsInt("GroupEnd");
+ for (int i = GroupStart; i <= GroupEnd; ++i)
+ GroupsArg.push_back("LLDB_OPT_SET_" + std::to_string(i));
+ }
+
+ // Check if this option is required.
+ Required = Option->getValue("Required");
+
+ // Add the full and short name for this option.
+ FullName = Option->getValueAsString("FullName");
+ ShortName = Option->getValueAsString("ShortName");
+
+ if (auto A = Option->getValue("ArgType"))
+ ArgType = A->getValue()->getAsUnquotedString();
+ OptionalArg = Option->getValue("OptionalArg") != nullptr;
+
+ if (Option->getValue("Validator"))
+ Validator = Option->getValueAsString("Validator");
+
+ if (Option->getValue("ArgEnum"))
+ ArgEnum = Option->getValueAsString("ArgEnum");
+
+ if (Option->getValue("Completions"))
+ Completions = Option->getValueAsListOfStrings("Completions");
+
+ if (auto D = Option->getValue("Description"))
+ Description = D->getValue()->getAsUnquotedString();
+ }
+};
+} // namespace
+
+static void emitOption(const CommandOption &O, raw_ostream &OS) {
+ OS << " {";
+
+ // If we have any groups, we merge them. Otherwise we move this option into
+ // the all group.
+ if (O.GroupsArg.empty())
+ OS << "LLDB_OPT_SET_ALL";
+ else
+ OS << llvm::join(O.GroupsArg.begin(), O.GroupsArg.end(), " | ");
+
+ OS << ", ";
+
+ // Check if this option is required.
+ OS << (O.Required ? "true" : "false");
+
+ // Add the full and short name for this option.
+ OS << ", \"" << O.FullName << "\", ";
+ OS << '\'' << O.ShortName << "'";
+
+ // Decide if we have either an option, required or no argument for this
+ // option.
+ OS << ", OptionParser::";
+ if (!O.ArgType.empty()) {
+ if (O.OptionalArg)
+ OS << "eOptionalArgument";
+ else
+ OS << "eRequiredArgument";
+ } else
+ OS << "eNoArgument";
+ OS << ", ";
+
+ if (!O.Validator.empty())
+ OS << O.Validator;
+ else
+ OS << "nullptr";
+ OS << ", ";
+
+ if (!O.ArgEnum.empty())
+ OS << O.ArgEnum;
+ else
+ OS << "{}";
+ OS << ", ";
+
+ // Read the tab completions we offer for this option (if there are any)
+ if (!O.Completions.empty()) {
+ std::vector<std::string> CompletionArgs;
+ for (llvm::StringRef Completion : O.Completions)
+ CompletionArgs.push_back("CommandCompletions::e" + Completion.str() +
+ "Completion");
+
+ OS << llvm::join(CompletionArgs.begin(), CompletionArgs.end(), " | ");
+ } else
+ OS << "CommandCompletions::eNoCompletion";
+
+ // Add the argument type.
+ OS << ", eArgType";
+ if (!O.ArgType.empty()) {
+ OS << O.ArgType;
+ } else
+ OS << "None";
+ OS << ", ";
+
+ // Add the description if there is any.
+ if (!O.Description.empty()) {
+ OS << "\"";
+ llvm::printEscapedString(O.Description, OS);
+ OS << "\"";
+ } else
+ OS << "\"\"";
+ OS << "},\n";
+}
+
+/// Emits all option initializers to the raw_ostream.
+static void emitOptions(std::string Command, std::vector<Record *> Records,
+ raw_ostream &OS) {
+ std::vector<CommandOption> Options;
+ for (Record *R : Records)
+ Options.emplace_back(R);
+
+ std::string ID = Command;
+ std::replace(ID.begin(), ID.end(), ' ', '_');
+ // Generate the macro that the user needs to define before including the
+ // *.inc file.
+ std::string NeededMacro = "LLDB_OPTIONS_" + ID;
+
+ // All options are in one file, so we need put them behind macros and ask the
+ // user to define the macro for the options that are needed.
+ OS << "// Options for " << Command << "\n";
+ OS << "#ifdef " << NeededMacro << "\n";
+ OS << "constexpr static OptionDefinition g_" + ID + "_options[] = {\n";
+ for (CommandOption &CO : Options)
+ emitOption(CO, OS);
+ // We undefine the macro for the user like Clang's include files are doing it.
+ OS << "};\n";
+ OS << "#undef " << NeededMacro << "\n";
+ OS << "#endif // " << Command << " command\n\n";
+}
+
+void lldb_private::EmitOptionDefs(RecordKeeper &Records, raw_ostream &OS) {
+ emitSourceFileHeader("Options for LLDB command line commands.", OS);
+
+ std::vector<Record *> Options = Records.getAllDerivedDefinitions("Option");
+ for (auto &CommandRecordPair : getRecordsByName(Options, "Command")) {
+ emitOptions(CommandRecordPair.first, CommandRecordPair.second, OS);
+ }
+}
diff --git a/gnu/llvm/lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp b/gnu/llvm/lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp
new file mode 100644
index 00000000000..f36deeebf90
--- /dev/null
+++ b/gnu/llvm/lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp
@@ -0,0 +1,180 @@
+//===- LLDBPropertyDefEmitter.cpp -----------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// These tablegen backends emits LLDB's PropertyDefinition values.
+//
+//===----------------------------------------------------------------------===//
+
+#include "LLDBTableGenBackends.h"
+#include "LLDBTableGenUtils.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/TableGen/Record.h"
+#include "llvm/TableGen/StringMatcher.h"
+#include "llvm/TableGen/TableGenBackend.h"
+#include <vector>
+
+using namespace llvm;
+using namespace lldb_private;
+
+static void emitPropertyEnum(Record *Property, raw_ostream &OS) {
+ OS << "eProperty";
+ OS << Property->getName();
+ OS << ",\n";
+}
+
+static void emitProperty(Record *Property, raw_ostream &OS) {
+ OS << " {";
+
+ // Emit the property name.
+ OS << "\"" << Property->getValueAsString("Name") << "\"";
+ OS << ", ";
+
+ // Emit the property type.
+ OS << "OptionValue::eType";
+ OS << Property->getValueAsString("Type");
+ OS << ", ";
+
+ // Emit the property's global value.
+ OS << (Property->getValue("Global") ? "true" : "false");
+ OS << ", ";
+
+ bool hasDefaultUnsignedValue = Property->getValue("HasDefaultUnsignedValue");
+ bool hasDefaultEnumValue = Property->getValue("HasDefaultEnumValue");
+ bool hasDefaultStringValue = Property->getValue("HasDefaultStringValue");
+
+ // Guarantee that every property has a default value.
+ assert((hasDefaultUnsignedValue || hasDefaultEnumValue ||
+ hasDefaultStringValue) &&
+ "Property must have a default value");
+
+ // Guarantee that no property has both a default unsigned value and a default
+ // enum value, since they're bothed stored in the same field.
+ assert(!(hasDefaultUnsignedValue && hasDefaultEnumValue) &&
+ "Property cannot have both a unsigned and enum default value.");
+
+ // Guarantee that every boolean property has a boolean default value.
+ assert(!(Property->getValueAsString("Type") == "Boolean" &&
+ !Property->getValue("HasDefaultBooleanValue")) &&
+ "Boolean property must have a boolean default value.");
+
+ // Guarantee that every string property has a string default value.
+ assert(!(Property->getValueAsString("Type") == "String" &&
+ !hasDefaultStringValue) &&
+ "String property must have a string default value.");
+
+ // Guarantee that every enum property has an enum default value.
+ assert(
+ !(Property->getValueAsString("Type") == "Enum" && !hasDefaultEnumValue) &&
+ "Enum property must have a enum default value.");
+
+ // Emit the default uint value.
+ if (hasDefaultUnsignedValue) {
+ OS << std::to_string(Property->getValueAsInt("DefaultUnsignedValue"));
+ } else if (hasDefaultEnumValue) {
+ OS << Property->getValueAsString("DefaultEnumValue");
+ } else {
+ OS << "0";
+ }
+ OS << ", ";
+
+ // Emit the default string value.
+ if (hasDefaultStringValue) {
+ if (auto D = Property->getValue("DefaultStringValue")) {
+ OS << "\"";
+ OS << D->getValue()->getAsUnquotedString();
+ OS << "\"";
+ } else {
+ OS << "\"\"";
+ }
+ } else {
+ OS << "nullptr";
+ }
+ OS << ", ";
+
+ // Emit the enum values value.
+ if (Property->getValue("EnumValues"))
+ OS << Property->getValueAsString("EnumValues");
+ else
+ OS << "{}";
+ OS << ", ";
+
+ // Emit the property description.
+ if (auto D = Property->getValue("Description")) {
+ OS << "\"";
+ OS << D->getValue()->getAsUnquotedString();
+ OS << "\"";
+ } else {
+ OS << "\"\"";
+ }
+
+ OS << "},\n";
+}
+
+/// Emits all property initializers to the raw_ostream.
+static void emityProperties(std::string PropertyName,
+ std::vector<Record *> PropertyRecords,
+ raw_ostream &OS) {
+ // Generate the macro that the user needs to define before including the
+ // *.inc file.
+ std::string NeededMacro = "LLDB_PROPERTIES_" + PropertyName;
+ std::replace(NeededMacro.begin(), NeededMacro.end(), ' ', '_');
+
+ // All options are in one file, so we need put them behind macros and ask the
+ // user to define the macro for the options that are needed.
+ OS << "// Property definitions for " << PropertyName << "\n";
+ OS << "#ifdef " << NeededMacro << "\n";
+ OS << "static constexpr PropertyDefinition g_" << PropertyName
+ << "_properties[] = {\n";
+ for (Record *R : PropertyRecords)
+ emitProperty(R, OS);
+ OS << "};\n";
+ // We undefine the macro for the user like Clang's include files are doing it.
+ OS << "#undef " << NeededMacro << "\n";
+ OS << "#endif // " << PropertyName << " Property\n\n";
+}
+
+/// Emits all property initializers to the raw_ostream.
+static void emitPropertyEnum(std::string PropertyName,
+ std::vector<Record *> PropertyRecords,
+ raw_ostream &OS) {
+ // Generate the macro that the user needs to define before including the
+ // *.inc file.
+ std::string NeededMacro = "LLDB_PROPERTIES_" + PropertyName;
+ std::replace(NeededMacro.begin(), NeededMacro.end(), ' ', '_');
+
+ // All options are in one file, so we need put them behind macros and ask the
+ // user to define the macro for the options that are needed.
+ OS << "// Property enum cases for " << PropertyName << "\n";
+ OS << "#ifdef " << NeededMacro << "\n";
+ for (Record *R : PropertyRecords)
+ emitPropertyEnum(R, OS);
+ // We undefine the macro for the user like Clang's include files are doing it.
+ OS << "#undef " << NeededMacro << "\n";
+ OS << "#endif // " << PropertyName << " Property\n\n";
+}
+
+void lldb_private::EmitPropertyDefs(RecordKeeper &Records, raw_ostream &OS) {
+ emitSourceFileHeader("Property definitions for LLDB.", OS);
+
+ std::vector<Record *> Properties =
+ Records.getAllDerivedDefinitions("Property");
+ for (auto &PropertyRecordPair : getRecordsByName(Properties, "Definition")) {
+ emityProperties(PropertyRecordPair.first, PropertyRecordPair.second, OS);
+ }
+}
+
+void lldb_private::EmitPropertyEnumDefs(RecordKeeper &Records,
+ raw_ostream &OS) {
+ emitSourceFileHeader("Property definition enum for LLDB.", OS);
+
+ std::vector<Record *> Properties =
+ Records.getAllDerivedDefinitions("Property");
+ for (auto &PropertyRecordPair : getRecordsByName(Properties, "Definition")) {
+ emitPropertyEnum(PropertyRecordPair.first, PropertyRecordPair.second, OS);
+ }
+}
diff --git a/gnu/llvm/lldb/utils/TableGen/LLDBTableGen.cpp b/gnu/llvm/lldb/utils/TableGen/LLDBTableGen.cpp
new file mode 100644
index 00000000000..abb6589f0ca
--- /dev/null
+++ b/gnu/llvm/lldb/utils/TableGen/LLDBTableGen.cpp
@@ -0,0 +1,83 @@
+//===- LLDBTableGen.cpp - Top-Level TableGen implementation for LLDB ------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains the main function for LLDB's TableGen.
+//
+//===----------------------------------------------------------------------===//
+
+#include "LLDBTableGenBackends.h" // Declares all backends.
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/TableGen/Error.h"
+#include "llvm/TableGen/Main.h"
+#include "llvm/TableGen/Record.h"
+
+using namespace llvm;
+using namespace lldb_private;
+
+enum ActionType {
+ PrintRecords,
+ DumpJSON,
+ GenOptionDefs,
+ GenPropertyDefs,
+ GenPropertyEnumDefs,
+};
+
+static cl::opt<ActionType> Action(
+ cl::desc("Action to perform:"),
+ cl::values(clEnumValN(PrintRecords, "print-records",
+ "Print all records to stdout (default)"),
+ clEnumValN(DumpJSON, "dump-json",
+ "Dump all records as machine-readable JSON"),
+ clEnumValN(GenOptionDefs, "gen-lldb-option-defs",
+ "Generate lldb option definitions"),
+ clEnumValN(GenPropertyDefs, "gen-lldb-property-defs",
+ "Generate lldb property definitions"),
+ clEnumValN(GenPropertyEnumDefs, "gen-lldb-property-enum-defs",
+ "Generate lldb property enum definitions")));
+
+static bool LLDBTableGenMain(raw_ostream &OS, RecordKeeper &Records) {
+ switch (Action) {
+ case PrintRecords:
+ OS << Records; // No argument, dump all contents
+ break;
+ case DumpJSON:
+ EmitJSON(Records, OS);
+ break;
+ case GenOptionDefs:
+ EmitOptionDefs(Records, OS);
+ break;
+ case GenPropertyDefs:
+ EmitPropertyDefs(Records, OS);
+ break;
+ case GenPropertyEnumDefs:
+ EmitPropertyEnumDefs(Records, OS);
+ break;
+ }
+ return false;
+}
+
+int main(int argc, char **argv) {
+ sys::PrintStackTraceOnErrorSignal(argv[0]);
+ PrettyStackTraceProgram X(argc, argv);
+ cl::ParseCommandLineOptions(argc, argv);
+
+ llvm_shutdown_obj Y;
+
+ return TableGenMain(argv[0], &LLDBTableGenMain);
+}
+
+#ifdef __has_feature
+#if __has_feature(address_sanitizer)
+#include <sanitizer/lsan_interface.h>
+// Disable LeakSanitizer for this binary as it has too many leaks that are not
+// very interesting to fix. See compiler-rt/include/sanitizer/lsan_interface.h .
+int __lsan_is_turned_off() { return 1; }
+#endif // __has_feature(address_sanitizer)
+#endif // defined(__has_feature)
diff --git a/gnu/llvm/lldb/utils/TableGen/LLDBTableGenBackends.h b/gnu/llvm/lldb/utils/TableGen/LLDBTableGenBackends.h
new file mode 100644
index 00000000000..b424abfce9a
--- /dev/null
+++ b/gnu/llvm/lldb/utils/TableGen/LLDBTableGenBackends.h
@@ -0,0 +1,38 @@
+//===- LLDBTableGenBackends.h -----------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains the declarations for all of the LLDB TableGen
+// backends. A "TableGen backend" is just a function.
+//
+// See "$LLVM_ROOT/utils/TableGen/TableGenBackends.h" for more info.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LLDB_UTILS_TABLEGEN_TABLEGENBACKENDS_H
+#define LLVM_LLDB_UTILS_TABLEGEN_TABLEGENBACKENDS_H
+
+#include "llvm/ADT/StringRef.h"
+
+namespace llvm {
+class raw_ostream;
+class RecordKeeper;
+class Record;
+} // namespace llvm
+
+using llvm::raw_ostream;
+using llvm::RecordKeeper;
+
+namespace lldb_private {
+
+void EmitOptionDefs(RecordKeeper &RK, raw_ostream &OS);
+void EmitPropertyDefs(RecordKeeper &RK, raw_ostream &OS);
+void EmitPropertyEnumDefs(RecordKeeper &RK, raw_ostream &OS);
+
+} // namespace lldb_private
+
+#endif
diff --git a/gnu/llvm/lldb/utils/TableGen/LLDBTableGenUtils.cpp b/gnu/llvm/lldb/utils/TableGen/LLDBTableGenUtils.cpp
new file mode 100644
index 00000000000..8b4c7581c98
--- /dev/null
+++ b/gnu/llvm/lldb/utils/TableGen/LLDBTableGenUtils.cpp
@@ -0,0 +1,21 @@
+//===- LLDBTableGenUtils.cpp ----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "LLDBTableGenUtils.h"
+#include "llvm/TableGen/Record.h"
+
+using namespace llvm;
+using namespace lldb_private;
+
+RecordsByName lldb_private::getRecordsByName(std::vector<Record *> Records,
+ StringRef Name) {
+ RecordsByName Result;
+ for (Record *R : Records)
+ Result[R->getValueAsString(Name).str()].push_back(R);
+ return Result;
+}
diff --git a/gnu/llvm/lldb/utils/TableGen/LLDBTableGenUtils.h b/gnu/llvm/lldb/utils/TableGen/LLDBTableGenUtils.h
new file mode 100644
index 00000000000..5553cecafb1
--- /dev/null
+++ b/gnu/llvm/lldb/utils/TableGen/LLDBTableGenUtils.h
@@ -0,0 +1,34 @@
+//===- LLDBTableGenUtils.h --------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LLDB_UTILS_TABLEGEN_TABLEGENUTILS_H
+#define LLVM_LLDB_UTILS_TABLEGEN_TABLEGENUTILS_H
+
+#include "llvm/ADT/StringRef.h"
+#include <map>
+#include <string>
+#include <vector>
+
+namespace llvm {
+class RecordKeeper;
+class Record;
+} // namespace llvm
+
+namespace lldb_private {
+
+/// Map of names to their associated records. This map also ensures that our
+/// records are sorted in a deterministic way.
+typedef std::map<std::string, std::vector<llvm::Record *>> RecordsByName;
+
+/// Return records grouped by name.
+RecordsByName getRecordsByName(std::vector<llvm::Record *> Records,
+ llvm::StringRef);
+
+} // namespace lldb_private
+
+#endif