29#define DEBUG_TYPE "detailed-records-backend"
37class DetailedRecordsEmitter {
42 DetailedRecordsEmitter(
RecordKeeper &RK) : Records(RK) {}
60 printReportHeading(
OS);
67void DetailedRecordsEmitter::printReportHeading(
raw_ostream &
OS) {
68 OS <<
formatv(
"DETAILED RECORDS for file {0}\n",
Records.getInputFilename());
73 const auto GlobalList =
Records.getGlobals();
74 printSectionHeading(
"Global Variables", GlobalList.size(),
OS);
77 for (
const auto &Var : GlobalList) {
78 OS << Var.first <<
" = " << Var.second->getAsString() <<
NL;
85 const auto &ClassList =
Records.getClasses();
86 printSectionHeading(
"Classes", ClassList.size(),
OS);
88 for (
const auto &ClassPair : ClassList) {
89 auto *
const Class = ClassPair.second.get();
92 printTemplateArgs(Class,
OS);
93 printSuperclasses(Class,
OS);
94 printFields(Class,
OS);
101 const auto &RecordList =
Records.getDefs();
102 printSectionHeading(
"Records", RecordList.size(),
OS);
104 for (
const auto &RecPair : RecordList) {
105 auto *
const Rec = RecPair.second.get();
106 std::string
Name = Rec->getNameInitAsString();
110 printSuperclasses(Rec,
OS);
111 printFields(Rec,
OS);
117void DetailedRecordsEmitter::printSectionHeading(
StringRef Title,
int Count,
119 OS <<
formatv(
"\n{0} {1} ({2}) {0}\n",
"--------------------", Title, Count);
125 const auto &LocList = Rec->
getLoc();
126 if (LocList.size() < 2)
129 OS <<
" Defm sequence:";
130 for (
unsigned I = LocList.size() - 1;
I >= 1; --
I) {
137void DetailedRecordsEmitter::printTemplateArgs(
Record *Rec,
141 OS <<
" Template args: (none)\n";
145 OS <<
" Template args:\n";
146 for (
const Init *ArgName : Args) {
148 assert(
Value &&
"Template argument value not found.");
160 if (Superclasses.
empty()) {
161 OS <<
" Superclasses: (none)\n";
165 OS <<
" Superclasses:";
166 for (
const auto &SuperclassPair : Superclasses) {
167 auto *ClassRec = SuperclassPair.first;
169 OS <<
formatv(
" {0}", ClassRec->getNameInitAsString());
171 OS <<
formatv(
" ({0})", ClassRec->getNameInitAsString());
178 const auto &ValueList = Rec->
getValues();
179 if (ValueList.empty()) {
180 OS <<
" Fields: (none)\n";
200 DetailedRecordsEmitter(RK).run(
OS);
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool empty() const
empty - Check if the array is empty.
This class represents a field in a record, including its name, type, value, and source location.
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.
ArrayRef< Init * > getTemplateArgs() const
ArrayRef< RecordVal > getValues() const
bool isTemplateArg(Init *Name) const
ArrayRef< std::pair< Record *, SMRange > > getSuperClasses() const
std::string getFormattedLocationNoOffset(SMLoc Loc, bool IncludePath=false) const
Get a string with the SMLoc filename and line number formatted in the standard style.
StringRef - Represent a constant reference to a string, i.e.
LLVM Value Representation.
void print(raw_ostream &O, bool IsForDebug=false) const
Implement operator<< on Value.
This class implements an extremely fast bulk output stream that can only output to a stream.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
llvm::SmallVector< std::shared_ptr< RecordsSlice >, 4 > Records
This is an optimization pass for GlobalISel generic memory operations.
auto formatv(const char *Fmt, Ts &&...Vals) -> formatv_object< decltype(std::make_tuple(support::detail::build_format_adapter(std::forward< Ts >(Vals))...))>
void EmitDetailedRecords(RecordKeeper &RK, raw_ostream &OS)