diff --git a/clang/utils/TableGen/ClangASTNodesEmitter.cpp b/clang/utils/TableGen/ClangASTNodesEmitter.cpp index 2b8d7a9efdf1..16a1c74b9d91 100644 --- a/clang/utils/TableGen/ClangASTNodesEmitter.cpp +++ b/clang/utils/TableGen/ClangASTNodesEmitter.cpp @@ -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"; diff --git a/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp b/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp index 19613880641e..de8dda60681f 100644 --- a/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp +++ b/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp @@ -593,7 +593,7 @@ void ASTPropsEmitter::emitWriteOfProperty(StringRef writerName, template static void emitASTReader(RecordKeeper &records, raw_ostream &out, StringRef description) { - emitSourceFileHeader(description, out); + emitSourceFileHeader(description, out, records); ASTPropsEmitter(records, out).emitNodeReaderClass(); } @@ -607,7 +607,7 @@ void clang::EmitClangTypeReader(RecordKeeper &records, raw_ostream &out) { template static void emitASTWriter(RecordKeeper &records, raw_ostream &out, StringRef description) { - emitSourceFileHeader(description, out); + emitSourceFileHeader(description, out, records); ASTPropsEmitter(records, out).emitNodeWriterClass(); } @@ -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(); @@ -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(); diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp index 00bcbe115351..a015ec36a30d 100644 --- a/clang/utils/TableGen/ClangAttrEmitter.cpp +++ b/clang/utils/TableGen/ClangAttrEmitter.cpp @@ -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 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 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 Attrs = Records.getAllDerivedDefinitions("Attr"); @@ -3743,7 +3749,8 @@ void EmitClangAttrTemplateInstantiateHelper(const std::vector &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 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 Attrs = Records.getAllDerivedDefinitions("Attr"); std::vector 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 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 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 Attrs = Records.getAllDerivedDefinitions("Attr"); for (const auto *A : Attrs) { diff --git a/clang/utils/TableGen/ClangCommentCommandInfoEmitter.cpp b/clang/utils/TableGen/ClangCommentCommandInfoEmitter.cpp index a70e95408c89..a113b02e1999 100644 --- a/clang/utils/TableGen/ClangCommentCommandInfoEmitter.cpp +++ b/clang/utils/TableGen/ClangCommentCommandInfoEmitter.cpp @@ -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" diff --git a/clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp b/clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp index 04c627530479..47b871afdeeb 100644 --- a/clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp +++ b/clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp @@ -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"; diff --git a/clang/utils/TableGen/ClangCommentHTMLTagsEmitter.cpp b/clang/utils/TableGen/ClangCommentHTMLTagsEmitter.cpp index a3a124f10f76..3dc1098753e0 100644 --- a/clang/utils/TableGen/ClangCommentHTMLTagsEmitter.cpp +++ b/clang/utils/TableGen/ClangCommentHTMLTagsEmitter.cpp @@ -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(); diff --git a/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp b/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp index 1c3b7e4398a8..968b3e0661a8 100644 --- a/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp +++ b/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp @@ -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(); diff --git a/clang/utils/TableGen/ClangSyntaxEmitter.cpp b/clang/utils/TableGen/ClangSyntaxEmitter.cpp index a940edbb1d24..9720d5873184 100644 --- a/clang/utils/TableGen/ClangSyntaxEmitter.cpp +++ b/clang/utils/TableGen/ClangSyntaxEmitter.cpp @@ -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 " diff --git a/clang/utils/TableGen/ClangTypeNodesEmitter.cpp b/clang/utils/TableGen/ClangTypeNodesEmitter.cpp index 690042f3200e..66bdf5e67602 100644 --- a/clang/utils/TableGen/ClangTypeNodesEmitter.cpp +++ b/clang/utils/TableGen/ClangTypeNodesEmitter.cpp @@ -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); diff --git a/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp b/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp index b936b8fd653b..b48a0e4beda3 100644 --- a/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp +++ b/lldb/utils/TableGen/LLDBOptionDefEmitter.cpp @@ -171,7 +171,7 @@ static void emitOptions(std::string Command, std::vector 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 Options = Records.getAllDerivedDefinitions("Option"); for (auto &CommandRecordPair : getRecordsByName(Options, "Command")) { diff --git a/lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp b/lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp index e3522f2c7b2d..f27f0f39fbfd 100644 --- a/lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp +++ b/lldb/utils/TableGen/LLDBPropertyDefEmitter.cpp @@ -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 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 Properties = Records.getAllDerivedDefinitions("Property"); diff --git a/llvm/include/llvm/TableGen/TableGenBackend.h b/llvm/include/llvm/TableGen/TableGenBackend.h index 39f1e14bc950..9c5a785f45a4 100644 --- a/llvm/include/llvm/TableGen/TableGenBackend.h +++ b/llvm/include/llvm/TableGen/TableGenBackend.h @@ -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 diff --git a/llvm/lib/TableGen/TableGenBackend.cpp b/llvm/lib/TableGen/TableGenBackend.cpp index 705c3a17a765..035abe936e11 100644 --- a/llvm/lib/TableGen/TableGenBackend.cpp +++ b/llvm/lib/TableGen/TableGenBackend.cpp @@ -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 #include @@ -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'; diff --git a/llvm/utils/TableGen/AsmMatcherEmitter.cpp b/llvm/utils/TableGen/AsmMatcherEmitter.cpp index 1c195200a888..6231f5530d35 100644 --- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp +++ b/llvm/utils/TableGen/AsmMatcherEmitter.cpp @@ -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); diff --git a/llvm/utils/TableGen/AsmWriterEmitter.cpp b/llvm/utils/TableGen/AsmWriterEmitter.cpp index 92e71910a800..0220927295cf 100644 --- a/llvm/utils/TableGen/AsmWriterEmitter.cpp +++ b/llvm/utils/TableGen/AsmWriterEmitter.cpp @@ -1302,7 +1302,7 @@ void AsmWriterEmitter::run(raw_ostream &O) { std::vector> 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); diff --git a/llvm/utils/TableGen/VTEmitter.cpp b/llvm/utils/TableGen/VTEmitter.cpp index d398a7e7b58f..5ec1f59318f7 100644 --- a/llvm/utils/TableGen/VTEmitter.cpp +++ b/llvm/utils/TableGen/VTEmitter.cpp @@ -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 VTsByNumber = {}; auto ValueTypes = Records.getAllDerivedDefinitions("ValueType"); diff --git a/mlir/tools/mlir-tblgen/DialectGen.cpp b/mlir/tools/mlir-tblgen/DialectGen.cpp index 414408c8837d..f22434f755ab 100644 --- a/mlir/tools/mlir-tblgen/DialectGen.cpp +++ b/mlir/tools/mlir-tblgen/DialectGen.cpp @@ -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()) diff --git a/mlir/tools/mlir-tblgen/EnumsGen.cpp b/mlir/tools/mlir-tblgen/EnumsGen.cpp index 65fa63636fac..f1d7a233b66a 100644 --- a/mlir/tools/mlir-tblgen/EnumsGen.cpp +++ b/mlir/tools/mlir-tblgen/EnumsGen.cpp @@ -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) diff --git a/mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp b/mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp index 2c6aa32e2fe2..f627d2dd3ea0 100644 --- a/mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp +++ b/mlir/tools/mlir-tblgen/LLVMIRIntrinsicGen.cpp @@ -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"; diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp index ad4f53c5af3c..ff73e600819c 100644 --- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp @@ -4225,7 +4225,7 @@ static void emitOpList(const std::vector &defs, raw_ostream &os) { } static bool emitOpDecls(const RecordKeeper &recordKeeper, raw_ostream &os) { - emitSourceFileHeader("Op Declarations", os); + emitSourceFileHeader("Op Declarations", os, recordKeeper); std::vector 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 defs = getRequestedOpDefinitions(recordKeeper); emitOpList(defs, os); diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp index 78947b70f5cc..9f36a3b43027 100644 --- a/mlir/tools/mlir-tblgen/RewriterGen.cpp +++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp @@ -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"); diff --git a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp index ac00ddc6422c..9aeb14d14eec 100644 --- a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp +++ b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp @@ -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 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 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"));