31class DetailedRecordsEmitter {
33 const RecordKeeper &Records;
36 explicit DetailedRecordsEmitter(
const RecordKeeper &RK) : Records(RK) {}
38 void run(raw_ostream &OS);
39 void printReportHeading(raw_ostream &OS);
40 void printSectionHeading(StringRef Title,
int Count, raw_ostream &OS);
41 void printVariables(raw_ostream &OS);
42 void printClasses(raw_ostream &OS);
43 void printRecords(raw_ostream &OS);
44 void printAllocationStats(raw_ostream &OS);
45 void printDefms(
const Record &Rec, raw_ostream &OS);
46 void printTemplateArgs(
const Record &Rec, raw_ostream &OS);
47 void printSuperclasses(
const Record &Rec, raw_ostream &OS);
48 void printFields(
const Record &Rec, raw_ostream &OS);
55 printReportHeading(OS);
59 printAllocationStats(OS);
63void DetailedRecordsEmitter::printReportHeading(raw_ostream &OS) {
68void DetailedRecordsEmitter::printSectionHeading(StringRef Title,
int Count,
70 OS <<
formatv(
"\n{0} {1} ({2}) {0}\n",
"--------------------", Title,
Count);
74void DetailedRecordsEmitter::printVariables(raw_ostream &OS) {
76 printSectionHeading(
"Global Variables", GlobalList.size(), OS);
79 for (
const auto &Var : GlobalList)
80 OS << Var.first <<
" = " << Var.second->getAsString() <<
'\n';
84void DetailedRecordsEmitter::printClasses(raw_ostream &OS) {
86 printSectionHeading(
"Classes", ClassList.size(), OS);
88 for (
const auto &[Name, Class] : ClassList) {
89 OS <<
formatv(
"\n{0} |{1}|\n",
Class->getNameInitAsString(),
91 printTemplateArgs(*Class, OS);
92 printSuperclasses(*Class, OS);
93 printFields(*Class, OS);
98void DetailedRecordsEmitter::printRecords(raw_ostream &OS) {
99 const auto &RecordList = Records.
getDefs();
100 printSectionHeading(
"Records", RecordList.size(), OS);
102 for (
const auto &[DefName, Rec] : RecordList) {
103 std::string
Name = Rec->getNameInitAsString();
104 OS <<
formatv(
"\n{0} |{1}|\n",
Name.empty() ?
"\"\"" : Name,
106 printDefms(*Rec, OS);
107 printSuperclasses(*Rec, OS);
108 printFields(*Rec, OS);
113void DetailedRecordsEmitter::printAllocationStats(raw_ostream &OS) {
114 OS <<
formatv(
"\n{0} Memory Allocation Stats {0}\n",
"--------------------");
120void DetailedRecordsEmitter::printDefms(
const Record &Rec, raw_ostream &OS) {
121 const auto &LocList = Rec.
getLoc();
122 if (LocList.size() < 2)
125 OS <<
" Defm sequence:";
126 for (
const SMLoc Loc :
reverse(LocList))
132void DetailedRecordsEmitter::printTemplateArgs(
const Record &Rec,
136 OS <<
" Template args: (none)\n";
140 OS <<
" Template args:\n";
141 for (
const Init *ArgName : Args) {
143 assert(
Value &&
"Template argument value not found.");
145 Value->print(OS,
false);
153void DetailedRecordsEmitter::printSuperclasses(
const Record &Rec,
156 if (Superclasses.empty()) {
157 OS <<
" Superclasses: (none)\n";
161 OS <<
" Superclasses:";
162 for (
const Record *ClassRec : Superclasses) {
164 OS <<
formatv(
" {0}", ClassRec->getNameInitAsString());
166 OS <<
formatv(
" ({0})", ClassRec->getNameInitAsString());
172void DetailedRecordsEmitter::printFields(
const Record &Rec, raw_ostream &OS) {
174 if (ValueList.empty()) {
175 OS <<
" Fields: (none)\n";
180 for (
const RecordVal &
Value : ValueList)
183 Value.print(OS,
false);
192 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)