30class DetailedRecordsEmitter {
32 const RecordKeeper &Records;
35 explicit DetailedRecordsEmitter(
const RecordKeeper &RK) : Records(RK) {}
37 void run(raw_ostream &OS);
38 void printReportHeading(raw_ostream &OS);
39 void printSectionHeading(StringRef Title,
int Count, raw_ostream &OS);
40 void printVariables(raw_ostream &OS);
41 void printClasses(raw_ostream &OS);
42 void printRecords(raw_ostream &OS);
43 void printAllocationStats(raw_ostream &OS);
44 void printDefms(
const Record &Rec, raw_ostream &OS);
45 void printTemplateArgs(
const Record &Rec, raw_ostream &OS);
46 void printSuperclasses(
const Record &Rec, raw_ostream &OS);
47 void printFields(
const Record &Rec, raw_ostream &OS);
54 printReportHeading(OS);
58 printAllocationStats(OS);
62void DetailedRecordsEmitter::printReportHeading(raw_ostream &OS) {
67void DetailedRecordsEmitter::printSectionHeading(StringRef Title,
int Count,
69 OS <<
formatv(
"\n{0} {1} ({2}) {0}\n",
"--------------------", Title,
Count);
73void DetailedRecordsEmitter::printVariables(raw_ostream &OS) {
75 printSectionHeading(
"Global Variables", GlobalList.size(), OS);
78 for (
const auto &Var : GlobalList)
79 OS << Var.first <<
" = " << Var.second->getAsString() <<
'\n';
83void DetailedRecordsEmitter::printClasses(raw_ostream &OS) {
85 printSectionHeading(
"Classes", ClassList.size(), OS);
87 for (
const auto &[Name, Class] : ClassList) {
88 OS <<
formatv(
"\n{0} |{1}|\n",
Class->getNameInitAsString(),
90 printTemplateArgs(*Class, OS);
91 printSuperclasses(*Class, OS);
92 printFields(*Class, OS);
97void DetailedRecordsEmitter::printRecords(raw_ostream &OS) {
98 const auto &RecordList = Records.
getDefs();
99 printSectionHeading(
"Records", RecordList.size(), OS);
101 for (
const auto &[DefName, Rec] : RecordList) {
102 std::string
Name = Rec->getNameInitAsString();
103 OS <<
formatv(
"\n{0} |{1}|\n",
Name.empty() ?
"\"\"" : Name,
105 printDefms(*Rec, OS);
106 printSuperclasses(*Rec, OS);
107 printFields(*Rec, OS);
112void DetailedRecordsEmitter::printAllocationStats(raw_ostream &OS) {
113 OS <<
formatv(
"\n{0} Memory Allocation Stats {0}\n",
"--------------------");
119void DetailedRecordsEmitter::printDefms(
const Record &Rec, raw_ostream &OS) {
120 const auto &LocList = Rec.
getLoc();
121 if (LocList.size() < 2)
124 OS <<
" Defm sequence:";
125 for (
const SMLoc Loc :
reverse(LocList))
131void DetailedRecordsEmitter::printTemplateArgs(
const Record &Rec,
135 OS <<
" Template args: (none)\n";
139 OS <<
" Template args:\n";
140 for (
const Init *ArgName : Args) {
142 assert(
Value &&
"Template argument value not found.");
144 Value->print(OS,
false);
152void DetailedRecordsEmitter::printSuperclasses(
const Record &Rec,
155 if (Superclasses.empty()) {
156 OS <<
" Superclasses: (none)\n";
160 OS <<
" Superclasses:";
161 for (
const Record *ClassRec : Superclasses) {
163 OS <<
formatv(
" {0}", ClassRec->getNameInitAsString());
165 OS <<
formatv(
" ({0})", ClassRec->getNameInitAsString());
171void DetailedRecordsEmitter::printFields(
const Record &Rec, raw_ostream &OS) {
173 if (ValueList.empty()) {
174 OS <<
" Fields: (none)\n";
179 for (
const RecordVal &
Value : ValueList)
182 Value.print(OS,
false);
191 DetailedRecordsEmitter(RK).run(OS);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
const RecordMap & getClasses() const
Get the map of classes.
const RecordMap & getDefs() const
Get the map of records (defs).
StringRef getInputFilename() const
Get the main TableGen input file's name.
const GlobalMap & getGlobals() const
Get the map of global variables.
void dumpAllocationStats(raw_ostream &OS) const
ArrayRef< SMLoc > getLoc() const
const RecordVal * getValue(const Init *Name) const
bool hasDirectSuperClass(const Record *SuperClass) const
Determine whether this record has the specified direct superclass.
bool isTemplateArg(const Init *Name) const
ArrayRef< RecordVal > getValues() const
ArrayRef< const Init * > getTemplateArgs() const
void getSuperClasses(std::vector< const Record * > &Classes) const
Append all superclasses in post-order to Classes.
LLVM_ABI std::string getFormattedLocationNoOffset(SMLoc Loc, bool IncludePath=false) const
Get a string with the SMLoc filename and line number formatted in the standard style.
This class implements an extremely fast bulk output stream that can only output to a stream.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
PointerTypeMap run(const Module &M)
Compute the PointerTypeMap for the module M.
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
auto reverse(ContainerTy &&C)
FunctionAddr VTableAddr Count
ArrayRef(const T &OneElt) -> ArrayRef< T >
void EmitDetailedRecords(const RecordKeeper &RK, raw_ostream &OS)