[llvm][tblgen] Add Source Filename for emitSourceFileHeader (#65744)

I think this is very helpful for reading generated `.inc` files.
This commit is contained in:
Shao-Ce SUN 2023-09-26 13:40:56 +08:00 committed by GitHub
parent f74e274af7
commit b0e28eb832
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 88 additions and 67 deletions

View File

@ -169,7 +169,7 @@ void ClangASTNodesEmitter::deriveChildTree() {
void ClangASTNodesEmitter::run(raw_ostream &OS) {
deriveChildTree();
emitSourceFileHeader("List of AST nodes of a particular kind", OS);
emitSourceFileHeader("List of AST nodes of a particular kind", OS, Records);
// Write the preamble
OS << "#ifndef ABSTRACT_" << macroHierarchyName() << "\n";
@ -205,7 +205,7 @@ void clang::EmitClangASTNodes(RecordKeeper &RK, raw_ostream &OS,
void clang::EmitClangDeclContext(RecordKeeper &Records, raw_ostream &OS) {
// FIXME: Find a .td file format to allow for this to be represented better.
emitSourceFileHeader("List of AST Decl nodes", OS);
emitSourceFileHeader("List of AST Decl nodes", OS, Records);
OS << "#ifndef DECL_CONTEXT\n";
OS << "# define DECL_CONTEXT(DECL)\n";

View File

@ -593,7 +593,7 @@ void ASTPropsEmitter::emitWriteOfProperty(StringRef writerName,
template <class NodeClass>
static void emitASTReader(RecordKeeper &records, raw_ostream &out,
StringRef description) {
emitSourceFileHeader(description, out);
emitSourceFileHeader(description, out, records);
ASTPropsEmitter(records, out).emitNodeReaderClass<NodeClass>();
}
@ -607,7 +607,7 @@ void clang::EmitClangTypeReader(RecordKeeper &records, raw_ostream &out) {
template <class NodeClass>
static void emitASTWriter(RecordKeeper &records, raw_ostream &out,
StringRef description) {
emitSourceFileHeader(description, out);
emitSourceFileHeader(description, out, records);
ASTPropsEmitter(records, out).emitNodeWriterClass<NodeClass>();
}
@ -852,7 +852,7 @@ void ASTPropsEmitter::emitBasicReaderWriterFile(const ReaderWriterInfo &info) {
/// Emit an .inc file that defines some helper classes for reading
/// basic values.
void clang::EmitClangBasicReader(RecordKeeper &records, raw_ostream &out) {
emitSourceFileHeader("Helper classes for BasicReaders", out);
emitSourceFileHeader("Helper classes for BasicReaders", out, records);
// Use any property, we won't be using those properties.
auto info = ReaderWriterInfo::forReader<TypeNode>();
@ -862,7 +862,7 @@ void clang::EmitClangBasicReader(RecordKeeper &records, raw_ostream &out) {
/// Emit an .inc file that defines some helper classes for writing
/// basic values.
void clang::EmitClangBasicWriter(RecordKeeper &records, raw_ostream &out) {
emitSourceFileHeader("Helper classes for BasicWriters", out);
emitSourceFileHeader("Helper classes for BasicWriters", out, records);
// Use any property, we won't be using those properties.
auto info = ReaderWriterInfo::forWriter<TypeNode>();

View File

@ -2921,7 +2921,7 @@ static void emitAttributes(RecordKeeper &Records, raw_ostream &OS,
}
// Emits the class definitions for attributes.
void clang::EmitClangAttrClass(RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("Attribute classes' definitions", OS);
emitSourceFileHeader("Attribute classes' definitions", OS, Records);
OS << "#ifndef LLVM_CLANG_ATTR_CLASSES_INC\n";
OS << "#define LLVM_CLANG_ATTR_CLASSES_INC\n\n";
@ -2933,7 +2933,8 @@ void clang::EmitClangAttrClass(RecordKeeper &Records, raw_ostream &OS) {
// Emits the class method definitions for attributes.
void clang::EmitClangAttrImpl(RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("Attribute classes' member function definitions", OS);
emitSourceFileHeader("Attribute classes' member function definitions", OS,
Records);
emitAttributes(Records, OS, false);
@ -3169,7 +3170,8 @@ namespace clang {
// Emits the enumeration list for attributes.
void EmitClangAttrList(RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("List of all attributes that Clang recognizes", OS);
emitSourceFileHeader("List of all attributes that Clang recognizes", OS,
Records);
AttrClassHierarchy Hierarchy(Records);
@ -3211,7 +3213,8 @@ void EmitClangAttrList(RecordKeeper &Records, raw_ostream &OS) {
void EmitClangAttrPrintList(const std::string &FieldName, RecordKeeper &Records,
raw_ostream &OS) {
emitSourceFileHeader(
"List of attributes that can be print on the left side of a decl", OS);
"List of attributes that can be print on the left side of a decl", OS,
Records);
AttrClassHierarchy Hierarchy(Records);
@ -3240,7 +3243,8 @@ void EmitClangAttrPrintList(const std::string &FieldName, RecordKeeper &Records,
// Emits the enumeration list for attributes.
void EmitClangAttrSubjectMatchRuleList(RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader(
"List of all attribute subject matching rules that Clang recognizes", OS);
"List of all attribute subject matching rules that Clang recognizes", OS,
Records);
PragmaClangAttributeSupport &PragmaAttributeSupport =
getPragmaAttributeSupport(Records);
emitDefaultDefine(OS, "ATTR_MATCH_RULE", nullptr);
@ -3250,7 +3254,7 @@ void EmitClangAttrSubjectMatchRuleList(RecordKeeper &Records, raw_ostream &OS) {
// Emits the code to read an attribute from a precompiled header.
void EmitClangAttrPCHRead(RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("Attribute deserialization code", OS);
emitSourceFileHeader("Attribute deserialization code", OS, Records);
Record *InhClass = Records.getClass("InheritableAttr");
std::vector<Record*> Attrs = Records.getAllDerivedDefinitions("Attr"),
@ -3305,7 +3309,7 @@ void EmitClangAttrPCHRead(RecordKeeper &Records, raw_ostream &OS) {
// Emits the code to write an attribute to a precompiled header.
void EmitClangAttrPCHWrite(RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("Attribute serialization code", OS);
emitSourceFileHeader("Attribute serialization code", OS, Records);
Record *InhClass = Records.getClass("InheritableAttr");
std::vector<Record*> Attrs = Records.getAllDerivedDefinitions("Attr"), Args;
@ -3506,7 +3510,8 @@ void EmitClangAttrTokenKinds(RecordKeeper &Records, raw_ostream &OS) {
// Emits the list of spellings for attributes.
void EmitClangAttrHasAttrImpl(RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("Code to implement the __has_attribute logic", OS);
emitSourceFileHeader("Code to implement the __has_attribute logic", OS,
Records);
// Separate all of the attributes out into four group: generic, C++11, GNU,
// and declspecs. Then generate a big switch statement for each of them.
@ -3586,9 +3591,9 @@ void EmitClangAttrHasAttrImpl(RecordKeeper &Records, raw_ostream &OS) {
}
void EmitClangAttrSpellingListIndex(RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("Code to translate different attribute spellings "
"into internal identifiers",
OS);
emitSourceFileHeader("Code to translate different attribute spellings into "
"internal identifiers",
OS, Records);
OS << " switch (getParsedKind()) {\n";
OS << " case IgnoredAttribute:\n";
@ -3618,7 +3623,8 @@ void EmitClangAttrSpellingListIndex(RecordKeeper &Records, raw_ostream &OS) {
// Emits code used by RecursiveASTVisitor to visit attributes
void EmitClangAttrASTVisitor(RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("Used by RecursiveASTVisitor to visit attributes.", OS);
emitSourceFileHeader("Used by RecursiveASTVisitor to visit attributes.", OS,
Records);
std::vector<Record*> Attrs = Records.getAllDerivedDefinitions("Attr");
@ -3743,7 +3749,8 @@ void EmitClangAttrTemplateInstantiateHelper(const std::vector<Record *> &Attrs,
// Emits code to instantiate dependent attributes on templates.
void EmitClangAttrTemplateInstantiate(RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("Template instantiation code for attributes", OS);
emitSourceFileHeader("Template instantiation code for attributes", OS,
Records);
std::vector<Record*> Attrs = Records.getAllDerivedDefinitions("Attr");
@ -3765,7 +3772,8 @@ void EmitClangAttrTemplateInstantiate(RecordKeeper &Records, raw_ostream &OS) {
// Emits the list of parsed attributes.
void EmitClangAttrParsedAttrList(RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("List of all attributes that Clang recognizes", OS);
emitSourceFileHeader("List of all attributes that Clang recognizes", OS,
Records);
OS << "#ifndef PARSED_ATTR\n";
OS << "#define PARSED_ATTR(NAME) NAME\n";
@ -4351,7 +4359,7 @@ static bool IsKnownToGCC(const Record &Attr) {
/// Emits the parsed attribute helpers
void EmitClangAttrParsedAttrImpl(RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("Parsed attribute helpers", OS);
emitSourceFileHeader("Parsed attribute helpers", OS, Records);
OS << "#if !defined(WANT_DECL_MERGE_LOGIC) && "
<< "!defined(WANT_STMT_MERGE_LOGIC)\n";
@ -4513,7 +4521,7 @@ void EmitClangAttrParsedAttrImpl(RecordKeeper &Records, raw_ostream &OS) {
// Emits the kind list of parsed attributes
void EmitClangAttrParsedAttrKinds(RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("Attribute name matcher", OS);
emitSourceFileHeader("Attribute name matcher", OS, Records);
std::vector<Record *> Attrs = Records.getAllDerivedDefinitions("Attr");
std::vector<StringMatcher::StringPair> GNU, Declspec, Microsoft, CXX11,
@ -4614,7 +4622,7 @@ void EmitClangAttrParsedAttrKinds(RecordKeeper &Records, raw_ostream &OS) {
// Emits the code to dump an attribute.
void EmitClangAttrTextNodeDump(RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("Attribute text node dumper", OS);
emitSourceFileHeader("Attribute text node dumper", OS, Records);
std::vector<Record*> Attrs = Records.getAllDerivedDefinitions("Attr"), Args;
for (const auto *Attr : Attrs) {
@ -4653,7 +4661,7 @@ void EmitClangAttrTextNodeDump(RecordKeeper &Records, raw_ostream &OS) {
}
void EmitClangAttrNodeTraverse(RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("Attribute text node traverser", OS);
emitSourceFileHeader("Attribute text node traverser", OS, Records);
std::vector<Record *> Attrs = Records.getAllDerivedDefinitions("Attr"), Args;
for (const auto *Attr : Attrs) {
@ -4682,7 +4690,7 @@ void EmitClangAttrNodeTraverse(RecordKeeper &Records, raw_ostream &OS) {
}
void EmitClangAttrParserStringSwitches(RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("Parser-related llvm::StringSwitch cases", OS);
emitSourceFileHeader("Parser-related llvm::StringSwitch cases", OS, Records);
emitClangAttrArgContextList(Records, OS);
emitClangAttrIdentifierArgList(Records, OS);
emitClangAttrUnevaluatedStringLiteralList(Records, OS);
@ -4699,7 +4707,7 @@ void EmitClangAttrSubjectMatchRulesParserStringSwitches(RecordKeeper &Records,
}
void EmitClangAttrDocTable(RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("Clang attribute documentation", OS);
emitSourceFileHeader("Clang attribute documentation", OS, Records);
std::vector<Record *> Attrs = Records.getAllDerivedDefinitions("Attr");
for (const auto *A : Attrs) {

View File

@ -22,9 +22,8 @@ using namespace llvm;
void clang::EmitClangCommentCommandInfo(RecordKeeper &Records,
raw_ostream &OS) {
emitSourceFileHeader("A list of commands useable in documentation "
"comments",
OS);
emitSourceFileHeader("A list of commands useable in documentation comments",
OS, Records);
OS << "namespace {\n"
"const CommandInfo Commands[] = {\n";
@ -116,9 +115,8 @@ static std::string MangleName(StringRef Str) {
void clang::EmitClangCommentCommandList(RecordKeeper &Records,
raw_ostream &OS) {
emitSourceFileHeader("A list of commands useable in documentation "
"comments",
OS);
emitSourceFileHeader("A list of commands useable in documentation comments",
OS, Records);
OS << "#ifndef COMMENT_COMMAND\n"
<< "# define COMMENT_COMMAND(NAME)\n"

View File

@ -70,9 +70,8 @@ void clang::EmitClangCommentHTMLNamedCharacterReferences(RecordKeeper &Records,
NameToUTF8.push_back(Match);
}
emitSourceFileHeader("HTML named character reference to UTF-8 "
"translation",
OS);
emitSourceFileHeader("HTML named character reference to UTF-8 translation",
OS, Records);
OS << "StringRef translateHTMLNamedCharacterReferenceToUTF8(\n"
" StringRef Name) {\n";

View File

@ -27,7 +27,7 @@ void clang::EmitClangCommentHTMLTags(RecordKeeper &Records, raw_ostream &OS) {
"return true;");
}
emitSourceFileHeader("HTML tag name matcher", OS);
emitSourceFileHeader("HTML tag name matcher", OS, Records);
OS << "bool isHTMLTagName(StringRef Name) {\n";
StringMatcher("Name", Matches, OS).Emit();
@ -49,7 +49,7 @@ void clang::EmitClangCommentHTMLTagsProperties(RecordKeeper &Records,
MatchesEndTagForbidden.push_back(Match);
}
emitSourceFileHeader("HTML tag properties", OS);
emitSourceFileHeader("HTML tag properties", OS, Records);
OS << "bool isHTMLEndTagOptional(StringRef Name) {\n";
StringMatcher("Name", MatchesEndTagOptional, OS).Emit();

View File

@ -339,7 +339,7 @@ public:
} // namespace
void BuiltinNameEmitter::Emit() {
emitSourceFileHeader("OpenCL Builtin handling", OS);
emitSourceFileHeader("OpenCL Builtin handling", OS, Records);
OS << "#include \"llvm/ADT/StringRef.h\"\n";
OS << "using namespace clang;\n\n";
@ -1215,7 +1215,7 @@ StringRef OpenCLBuiltinFileEmitterBase::emitTypeExtensionGuards(
}
void OpenCLBuiltinTestEmitter::emit() {
emitSourceFileHeader("OpenCL Builtin exhaustive testing", OS);
emitSourceFileHeader("OpenCL Builtin exhaustive testing", OS, Records);
emitExtensionSetup();
@ -1273,7 +1273,7 @@ void OpenCLBuiltinTestEmitter::emit() {
}
void OpenCLBuiltinHeaderEmitter::emit() {
emitSourceFileHeader("OpenCL Builtin declarations", OS);
emitSourceFileHeader("OpenCL Builtin declarations", OS, Records);
emitExtensionSetup();

View File

@ -129,7 +129,7 @@ struct SyntaxConstraint {
void clang::EmitClangSyntaxNodeList(llvm::RecordKeeper &Records,
llvm::raw_ostream &OS) {
llvm::emitSourceFileHeader("Syntax tree node list", OS);
llvm::emitSourceFileHeader("Syntax tree node list", OS, Records);
Hierarchy H(Records);
OS << R"cpp(
#ifndef NODE
@ -188,7 +188,7 @@ static void printDoc(llvm::StringRef Doc, llvm::raw_ostream &OS) {
void clang::EmitClangSyntaxNodeClasses(llvm::RecordKeeper &Records,
llvm::raw_ostream &OS) {
llvm::emitSourceFileHeader("Syntax tree node list", OS);
llvm::emitSourceFileHeader("Syntax tree node list", OS, Records);
Hierarchy H(Records);
OS << "\n// Forward-declare node types so we don't have to carefully "

View File

@ -104,7 +104,7 @@ void TypeNodeEmitter::emit() {
if (Types.empty())
PrintFatalError("no Type records in input!");
emitSourceFileHeader("An x-macro database of Clang type nodes", Out);
emitSourceFileHeader("An x-macro database of Clang type nodes", Out, Records);
// Preamble
addMacroToUndef(TypeMacroName);

View File

@ -171,7 +171,7 @@ static void emitOptions(std::string Command, std::vector<Record *> Records,
}
void lldb_private::EmitOptionDefs(RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("Options for LLDB command line commands.", OS);
emitSourceFileHeader("Options for LLDB command line commands.", OS, Records);
std::vector<Record *> Options = Records.getAllDerivedDefinitions("Option");
for (auto &CommandRecordPair : getRecordsByName(Options, "Command")) {

View File

@ -168,7 +168,7 @@ static void emitPropertyEnum(std::string PropertyName,
}
void lldb_private::EmitPropertyDefs(RecordKeeper &Records, raw_ostream &OS) {
emitSourceFileHeader("Property definitions for LLDB.", OS);
emitSourceFileHeader("Property definitions for LLDB.", OS, Records);
std::vector<Record *> Properties =
Records.getAllDerivedDefinitions("Property");
@ -179,7 +179,7 @@ void lldb_private::EmitPropertyDefs(RecordKeeper &Records, raw_ostream &OS) {
void lldb_private::EmitPropertyEnumDefs(RecordKeeper &Records,
raw_ostream &OS) {
emitSourceFileHeader("Property definition enum for LLDB.", OS);
emitSourceFileHeader("Property definition enum for LLDB.", OS, Records);
std::vector<Record *> Properties =
Records.getAllDerivedDefinitions("Property");

View File

@ -16,6 +16,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/TableGen/Record.h"
namespace llvm {
@ -50,7 +51,8 @@ public:
/// emitSourceFileHeader - Output an LLVM style file header to the specified
/// raw_ostream.
void emitSourceFileHeader(StringRef Desc, raw_ostream &OS);
void emitSourceFileHeader(StringRef Desc, raw_ostream &OS,
const RecordKeeper &Record = RecordKeeper());
} // End llvm namespace

View File

@ -12,6 +12,7 @@
#include "llvm/TableGen/TableGenBackend.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
@ -40,7 +41,8 @@ static void printLine(raw_ostream &OS, const Twine &Prefix, char Fill,
OS << Suffix << '\n';
}
void llvm::emitSourceFileHeader(StringRef Desc, raw_ostream &OS) {
void llvm::emitSourceFileHeader(StringRef Desc, raw_ostream &OS,
const RecordKeeper &Record) {
printLine(OS, "/*===- TableGen'erated file ", '-', "*- C++ -*-===*\\");
StringRef Prefix("|* ");
StringRef Suffix(" *|");
@ -56,6 +58,12 @@ void llvm::emitSourceFileHeader(StringRef Desc, raw_ostream &OS) {
printLine(OS, Prefix, ' ', Suffix);
printLine(OS, Prefix + "Automatically generated file, do not edit!", ' ',
Suffix);
// Print the filename of source file
if (!Record.getInputFilename().empty())
printLine(
OS, Prefix + "From: " + sys::path::filename(Record.getInputFilename()),
' ', Suffix);
printLine(OS, Prefix, ' ', Suffix);
printLine(OS, "\\*===", '-', "===*/");
OS << '\n';

View File

@ -3204,7 +3204,7 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
Record *AsmParser = Target.getAsmParser();
StringRef ClassName = AsmParser->getValueAsString("AsmParserClassName");
emitSourceFileHeader("Assembly Matcher Source Fragment", OS);
emitSourceFileHeader("Assembly Matcher Source Fragment", OS, Records);
// Compute the information on the instructions to match.
AsmMatcherInfo Info(AsmParser, Target, Records);

View File

@ -1302,7 +1302,7 @@ void AsmWriterEmitter::run(raw_ostream &O) {
std::vector<std::vector<std::string>> TableDrivenOperandPrinters;
unsigned BitsLeft = 0;
unsigned AsmStrBits = 0;
emitSourceFileHeader("Assembly Writer Source Fragment", O);
emitSourceFileHeader("Assembly Writer Source Fragment", O, Records);
EmitGetMnemonic(O, TableDrivenOperandPrinters, BitsLeft, AsmStrBits);
EmitPrintInstruction(O, TableDrivenOperandPrinters, BitsLeft, AsmStrBits);
EmitGetRegisterName(O);

View File

@ -30,7 +30,7 @@ public:
} // End anonymous namespace.
void VTEmitter::run(raw_ostream &OS) {
emitSourceFileHeader("ValueTypes Source Fragment", OS);
emitSourceFileHeader("ValueTypes Source Fragment", OS, Records);
std::array<const Record *, 256> VTsByNumber = {};
auto ValueTypes = Records.getAllDerivedDefinitions("ValueType");

View File

@ -229,7 +229,7 @@ static void emitDialectDecl(Dialect &dialect, raw_ostream &os) {
static bool emitDialectDecls(const llvm::RecordKeeper &recordKeeper,
raw_ostream &os) {
emitSourceFileHeader("Dialect Declarations", os);
emitSourceFileHeader("Dialect Declarations", os, recordKeeper);
auto dialectDefs = recordKeeper.getAllDerivedDefinitions("Dialect");
if (dialectDefs.empty())
@ -300,7 +300,7 @@ static void emitDialectDef(Dialect &dialect, raw_ostream &os) {
static bool emitDialectDefs(const llvm::RecordKeeper &recordKeeper,
raw_ostream &os) {
emitSourceFileHeader("Dialect Definitions", os);
emitSourceFileHeader("Dialect Definitions", os, recordKeeper);
auto dialectDefs = recordKeeper.getAllDerivedDefinitions("Dialect");
if (dialectDefs.empty())

View File

@ -643,7 +643,7 @@ public:
}
static bool emitEnumDecls(const RecordKeeper &recordKeeper, raw_ostream &os) {
llvm::emitSourceFileHeader("Enum Utility Declarations", os);
llvm::emitSourceFileHeader("Enum Utility Declarations", os, recordKeeper);
auto defs = recordKeeper.getAllDerivedDefinitionsIfDefined("EnumAttrInfo");
for (const auto *def : defs)
@ -681,7 +681,7 @@ static void emitEnumDef(const Record &enumDef, raw_ostream &os) {
}
static bool emitEnumDefs(const RecordKeeper &recordKeeper, raw_ostream &os) {
llvm::emitSourceFileHeader("Enum Utility Definitions", os);
llvm::emitSourceFileHeader("Enum Utility Definitions", os, recordKeeper);
auto defs = recordKeeper.getAllDerivedDefinitionsIfDefined("EnumAttrInfo");
for (const auto *def : defs)

View File

@ -249,7 +249,7 @@ static bool emitIntrinsic(const llvm::Record &record, llvm::raw_ostream &os) {
/// the name matching the filter.
static bool emitIntrinsics(const llvm::RecordKeeper &records,
llvm::raw_ostream &os) {
llvm::emitSourceFileHeader("Operations for LLVM intrinsics", os);
llvm::emitSourceFileHeader("Operations for LLVM intrinsics", os, records);
os << "include \"mlir/Dialect/LLVMIR/LLVMOpBase.td\"\n";
os << "include \"mlir/Interfaces/SideEffectInterfaces.td\"\n\n";

View File

@ -4225,7 +4225,7 @@ static void emitOpList(const std::vector<Record *> &defs, raw_ostream &os) {
}
static bool emitOpDecls(const RecordKeeper &recordKeeper, raw_ostream &os) {
emitSourceFileHeader("Op Declarations", os);
emitSourceFileHeader("Op Declarations", os, recordKeeper);
std::vector<Record *> defs = getRequestedOpDefinitions(recordKeeper);
emitOpClasses(recordKeeper, defs, os, /*emitDecl=*/true);
@ -4234,7 +4234,7 @@ static bool emitOpDecls(const RecordKeeper &recordKeeper, raw_ostream &os) {
}
static bool emitOpDefs(const RecordKeeper &recordKeeper, raw_ostream &os) {
emitSourceFileHeader("Op Definitions", os);
emitSourceFileHeader("Op Definitions", os, recordKeeper);
std::vector<Record *> defs = getRequestedOpDefinitions(recordKeeper);
emitOpList(defs, os);

View File

@ -1873,7 +1873,7 @@ StringRef StaticMatcherHelper::getVerifierName(DagLeaf leaf) {
}
static void emitRewriters(const RecordKeeper &recordKeeper, raw_ostream &os) {
emitSourceFileHeader("Rewriters", os);
emitSourceFileHeader("Rewriters", os, recordKeeper);
const auto &patterns = recordKeeper.getAllDerivedDefinitions("Pattern");

View File

@ -197,7 +197,8 @@ static void emitInterfaceDef(const Availability &availability,
static bool emitInterfaceDefs(const RecordKeeper &recordKeeper,
raw_ostream &os) {
llvm::emitSourceFileHeader("Availability Interface Definitions", os);
llvm::emitSourceFileHeader("Availability Interface Definitions", os,
recordKeeper);
auto defs = recordKeeper.getAllDerivedDefinitions("Availability");
SmallVector<const Record *, 1> handledClasses;
@ -286,7 +287,8 @@ static void emitInterfaceDecl(const Availability &availability,
static bool emitInterfaceDecls(const RecordKeeper &recordKeeper,
raw_ostream &os) {
llvm::emitSourceFileHeader("Availability Interface Declarations", os);
llvm::emitSourceFileHeader("Availability Interface Declarations", os,
recordKeeper);
auto defs = recordKeeper.getAllDerivedDefinitions("Availability");
SmallVector<const Record *, 4> handledClasses;
@ -449,7 +451,8 @@ static void emitEnumDecl(const Record &enumDef, raw_ostream &os) {
}
static bool emitEnumDecls(const RecordKeeper &recordKeeper, raw_ostream &os) {
llvm::emitSourceFileHeader("SPIR-V Enum Availability Declarations", os);
llvm::emitSourceFileHeader("SPIR-V Enum Availability Declarations", os,
recordKeeper);
auto defs = recordKeeper.getAllDerivedDefinitions("EnumAttrInfo");
for (const auto *def : defs)
@ -480,7 +483,8 @@ static void emitEnumDef(const Record &enumDef, raw_ostream &os) {
}
static bool emitEnumDefs(const RecordKeeper &recordKeeper, raw_ostream &os) {
llvm::emitSourceFileHeader("SPIR-V Enum Availability Definitions", os);
llvm::emitSourceFileHeader("SPIR-V Enum Availability Definitions", os,
recordKeeper);
auto defs = recordKeeper.getAllDerivedDefinitions("EnumAttrInfo");
for (const auto *def : defs)
@ -1178,7 +1182,8 @@ emitExtendedSetDeserializationDispatch(const RecordKeeper &recordKeeper,
/// SPIRV_Ops.
static bool emitSerializationFns(const RecordKeeper &recordKeeper,
raw_ostream &os) {
llvm::emitSourceFileHeader("SPIR-V Serialization Utilities/Functions", os);
llvm::emitSourceFileHeader("SPIR-V Serialization Utilities/Functions", os,
recordKeeper);
std::string dSerFnString, dDesFnString, serFnString, deserFnString,
utilsString;
@ -1257,7 +1262,7 @@ static void emitEnumGetAttrNameFnDefn(const EnumAttr &enumAttr,
}
static bool emitAttrUtils(const RecordKeeper &recordKeeper, raw_ostream &os) {
llvm::emitSourceFileHeader("SPIR-V Attribute Utilities", os);
llvm::emitSourceFileHeader("SPIR-V Attribute Utilities", os, recordKeeper);
auto defs = recordKeeper.getAllDerivedDefinitions("EnumAttrInfo");
os << "#ifndef MLIR_DIALECT_SPIRV_IR_ATTR_UTILS_H_\n";
@ -1402,7 +1407,8 @@ static void emitAvailabilityImpl(const Operator &srcOp, raw_ostream &os) {
static bool emitAvailabilityImpl(const RecordKeeper &recordKeeper,
raw_ostream &os) {
llvm::emitSourceFileHeader("SPIR-V Op Availability Implementations", os);
llvm::emitSourceFileHeader("SPIR-V Op Availability Implementations", os,
recordKeeper);
auto defs = recordKeeper.getAllDerivedDefinitions("SPIRV_Op");
for (const auto *def : defs) {
@ -1430,7 +1436,7 @@ static mlir::GenRegistration
static bool emitCapabilityImplication(const RecordKeeper &recordKeeper,
raw_ostream &os) {
llvm::emitSourceFileHeader("SPIR-V Capability Implication", os);
llvm::emitSourceFileHeader("SPIR-V Capability Implication", os, recordKeeper);
EnumAttr enumAttr(
recordKeeper.getDef("SPIRV_CapabilityAttr")->getValueAsDef("enum"));