[TableGen] Add backend to generate command guide for tools using libOption.
For lldb and dsymutil, the command guide is essentially a copy of its
help output generated by libOption. Making sure the two stay in sync is
tedious and error prone. Given that we already generate the help from a
tablegen file, we might as well generate the RST as well.
This adds a tablegen backend for generating Sphinx/RST command guides
from the tablegen file.
Differential revision: https://reviews.llvm.org/D70610
diff --git a/llvm/utils/TableGen/TableGen.cpp b/llvm/utils/TableGen/TableGen.cpp
index f730d91..086560e 100644
--- a/llvm/utils/TableGen/TableGen.cpp
+++ b/llvm/utils/TableGen/TableGen.cpp
@@ -45,6 +45,7 @@
PrintEnums,
PrintSets,
GenOptParserDefs,
+ GenOptRST,
GenCTags,
GenAttributes,
GenSearchableTables,
@@ -110,6 +111,7 @@
"Print expanded sets for testing DAG exprs"),
clEnumValN(GenOptParserDefs, "gen-opt-parser-defs",
"Generate option definitions"),
+ clEnumValN(GenOptRST, "gen-opt-rst", "Generate option RST"),
clEnumValN(GenCTags, "gen-ctags", "Generate ctags-compatible index"),
clEnumValN(GenAttributes, "gen-attrs", "Generate attributes"),
clEnumValN(GenSearchableTables, "gen-searchable-tables",
@@ -126,8 +128,7 @@
"Generate registers bank descriptions"),
clEnumValN(GenExegesis, "gen-exegesis",
"Generate llvm-exegesis tables"),
- clEnumValN(GenAutomata, "gen-automata",
- "Generate generic automata")));
+ clEnumValN(GenAutomata, "gen-automata", "Generate generic automata")));
cl::OptionCategory PrintEnumsCat("Options for -print-enums");
cl::opt<std::string> Class("class", cl::desc("Print Enum list for this class"),
@@ -204,6 +205,9 @@
case GenOptParserDefs:
EmitOptParser(Records, OS);
break;
+ case GenOptRST:
+ EmitOptRST(Records, OS);
+ break;
case PrintEnums:
{
for (Record *Rec : Records.getAllDerivedDefinitions(Class))