[llvm] a7e2b74 - llvm-tblgen: Cleanup for each EmitterClass to be invoked by uniform signature.
NAKAMURA Takumi via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 21 00:22:27 PDT 2023
Author: NAKAMURA Takumi
Date: 2023-03-21T16:21:27+09:00
New Revision: a7e2b749b551dc39fe2840af21759796ccaeb78f
URL: https://github.com/llvm/llvm-project/commit/a7e2b749b551dc39fe2840af21759796ccaeb78f
DIFF: https://github.com/llvm/llvm-project/commit/a7e2b749b551dc39fe2840af21759796ccaeb78f.diff
LOG: llvm-tblgen: Cleanup for each EmitterClass to be invoked by uniform signature.
Differential Revision: https://reviews.llvm.org/D144351
Added:
Modified:
llvm/utils/TableGen/AsmMatcherEmitter.cpp
llvm/utils/TableGen/AsmWriterEmitter.cpp
llvm/utils/TableGen/Attributes.cpp
llvm/utils/TableGen/CallingConvEmitter.cpp
llvm/utils/TableGen/CodeEmitterGen.cpp
llvm/utils/TableGen/DAGISelEmitter.cpp
llvm/utils/TableGen/DFAPacketizerEmitter.cpp
llvm/utils/TableGen/SubtargetEmitter.cpp
llvm/utils/TableGen/X86FoldTablesEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/AsmMatcherEmitter.cpp b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
index 57b25b237b3e..6bffd545f3c4 100644
--- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp
+++ b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
@@ -3205,6 +3205,8 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
Record *AsmParser = Target.getAsmParser();
StringRef ClassName = AsmParser->getValueAsString("AsmParserClassName");
+ emitSourceFileHeader("Assembly Matcher Source Fragment", OS);
+
// Compute the information on the instructions to match.
AsmMatcherInfo Info(AsmParser, Target, Records);
Info.buildInfo();
@@ -4005,7 +4007,6 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
namespace llvm {
void EmitAsmMatcher(RecordKeeper &RK, raw_ostream &OS) {
- emitSourceFileHeader("Assembly Matcher Source Fragment", OS);
AsmMatcherEmitter(RK).run(OS);
}
diff --git a/llvm/utils/TableGen/AsmWriterEmitter.cpp b/llvm/utils/TableGen/AsmWriterEmitter.cpp
index f905993ac78b..0d5109f9b3c9 100644
--- a/llvm/utils/TableGen/AsmWriterEmitter.cpp
+++ b/llvm/utils/TableGen/AsmWriterEmitter.cpp
@@ -1303,6 +1303,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);
EmitGetMnemonic(O, TableDrivenOperandPrinters, BitsLeft, AsmStrBits);
EmitPrintInstruction(O, TableDrivenOperandPrinters, BitsLeft, AsmStrBits);
EmitGetRegisterName(O);
@@ -1312,7 +1313,6 @@ void AsmWriterEmitter::run(raw_ostream &O) {
namespace llvm {
void EmitAsmWriter(RecordKeeper &RK, raw_ostream &OS) {
- emitSourceFileHeader("Assembly Writer Source Fragment", OS);
AsmWriterEmitter(RK).run(OS);
}
diff --git a/llvm/utils/TableGen/Attributes.cpp b/llvm/utils/TableGen/Attributes.cpp
index aa0d2b780fff..705fb0041585 100644
--- a/llvm/utils/TableGen/Attributes.cpp
+++ b/llvm/utils/TableGen/Attributes.cpp
@@ -18,7 +18,7 @@ namespace {
class Attributes {
public:
Attributes(RecordKeeper &R) : Records(R) {}
- void emit(raw_ostream &OS);
+ void run(raw_ostream &OS);
private:
void emitTargetIndependentNames(raw_ostream &OS);
@@ -124,7 +124,7 @@ void Attributes::emitAttributeProperties(raw_ostream &OS) {
OS << "#endif\n";
}
-void Attributes::emit(raw_ostream &OS) {
+void Attributes::run(raw_ostream &OS) {
emitTargetIndependentNames(OS);
emitFnAttrCompatCheck(OS, false);
emitAttributeProperties(OS);
@@ -133,7 +133,7 @@ void Attributes::emit(raw_ostream &OS) {
namespace llvm {
void EmitAttributes(RecordKeeper &RK, raw_ostream &OS) {
- Attributes(RK).emit(OS);
+ Attributes(RK).run(OS);
}
} // namespace llvm
diff --git a/llvm/utils/TableGen/CallingConvEmitter.cpp b/llvm/utils/TableGen/CallingConvEmitter.cpp
index 41e779daa539..048cccc07c70 100644
--- a/llvm/utils/TableGen/CallingConvEmitter.cpp
+++ b/llvm/utils/TableGen/CallingConvEmitter.cpp
@@ -42,6 +42,8 @@ class CallingConvEmitter {
} // End anonymous namespace
void CallingConvEmitter::run(raw_ostream &O) {
+ emitSourceFileHeader("Calling Convention Implementation Fragment", O);
+
std::vector<Record *> CCs = Records.getAllDerivedDefinitions("CallingConv");
// Emit prototypes for all of the non-custom CC's so that they can forward ref
@@ -430,7 +432,6 @@ void CallingConvEmitter::EmitArgRegisterLists(raw_ostream &O) {
namespace llvm {
void EmitCallingConv(RecordKeeper &RK, raw_ostream &OS) {
- emitSourceFileHeader("Calling Convention Implementation Fragment", OS);
CallingConvEmitter(RK).run(OS);
}
diff --git a/llvm/utils/TableGen/CodeEmitterGen.cpp b/llvm/utils/TableGen/CodeEmitterGen.cpp
index 11a57bb1bc31..4bbc26018617 100644
--- a/llvm/utils/TableGen/CodeEmitterGen.cpp
+++ b/llvm/utils/TableGen/CodeEmitterGen.cpp
@@ -358,6 +358,8 @@ void CodeEmitterGen::emitInstructionBaseValues(
}
void CodeEmitterGen::run(raw_ostream &o) {
+ emitSourceFileHeader("Machine Code Emitter", o);
+
CodeGenTarget Target(Records);
std::vector<Record*> Insts = Records.getAllDerivedDefinitions("Instruction");
@@ -505,7 +507,6 @@ void CodeEmitterGen::run(raw_ostream &o) {
namespace llvm {
void EmitCodeEmitter(RecordKeeper &RK, raw_ostream &OS) {
- emitSourceFileHeader("Machine Code Emitter", OS);
CodeEmitterGen(RK).run(OS);
}
diff --git a/llvm/utils/TableGen/DAGISelEmitter.cpp b/llvm/utils/TableGen/DAGISelEmitter.cpp
index 07febba6bc14..9ed9f5e88cea 100644
--- a/llvm/utils/TableGen/DAGISelEmitter.cpp
+++ b/llvm/utils/TableGen/DAGISelEmitter.cpp
@@ -125,6 +125,7 @@ struct PatternSortingPredicate {
void DAGISelEmitter::run(raw_ostream &OS) {
+ Records.startTimer("Parse patterns");
emitSourceFileHeader("DAG Instruction Selector for the " +
CGP.getTargetInfo().getName().str() + " target", OS);
@@ -190,7 +191,6 @@ void DAGISelEmitter::run(raw_ostream &OS) {
namespace llvm {
void EmitDAGISel(RecordKeeper &RK, raw_ostream &OS) {
- RK.startTimer("Parse patterns");
DAGISelEmitter(RK).run(OS);
}
diff --git a/llvm/utils/TableGen/DFAPacketizerEmitter.cpp b/llvm/utils/TableGen/DFAPacketizerEmitter.cpp
index e9fca57c3ef3..941846eca0fa 100644
--- a/llvm/utils/TableGen/DFAPacketizerEmitter.cpp
+++ b/llvm/utils/TableGen/DFAPacketizerEmitter.cpp
@@ -206,6 +206,7 @@ void DFAPacketizerEmitter::createScheduleClasses(unsigned ItineraryIdx,
// Run the worklist algorithm to generate the DFA.
//
void DFAPacketizerEmitter::run(raw_ostream &OS) {
+ emitSourceFileHeader("Target DFA Packetizer Tables", OS);
OS << "\n"
<< "#include \"llvm/CodeGen/DFAPacketizer.h\"\n";
OS << "namespace llvm {\n";
@@ -356,7 +357,6 @@ void DFAPacketizerEmitter::emitForItineraries(
namespace llvm {
void EmitDFAPacketizer(RecordKeeper &RK, raw_ostream &OS) {
- emitSourceFileHeader("Target DFA Packetizer Tables", OS);
DFAPacketizerEmitter(RK).run(OS);
}
diff --git a/llvm/utils/TableGen/SubtargetEmitter.cpp b/llvm/utils/TableGen/SubtargetEmitter.cpp
index c98048626c16..3ff25413b873 100644
--- a/llvm/utils/TableGen/SubtargetEmitter.cpp
+++ b/llvm/utils/TableGen/SubtargetEmitter.cpp
@@ -70,7 +70,7 @@ class SubtargetEmitter {
}
};
- const CodeGenTarget &TGT;
+ CodeGenTarget TGT;
RecordKeeper &Records;
CodeGenSchedModels &SchedModels;
std::string Target;
@@ -128,8 +128,8 @@ class SubtargetEmitter {
void ParseFeaturesFunction(raw_ostream &OS);
public:
- SubtargetEmitter(RecordKeeper &R, CodeGenTarget &TGT)
- : TGT(TGT), Records(R), SchedModels(TGT.getSchedModels()),
+ SubtargetEmitter(RecordKeeper &R)
+ : TGT(R), Records(R), SchedModels(TGT.getSchedModels()),
Target(TGT.getName()) {}
void run(raw_ostream &o);
@@ -1988,8 +1988,7 @@ void SubtargetEmitter::run(raw_ostream &OS) {
namespace llvm {
void EmitSubtarget(RecordKeeper &RK, raw_ostream &OS) {
- CodeGenTarget CGTarget(RK);
- SubtargetEmitter(RK, CGTarget).run(OS);
+ SubtargetEmitter(RK).run(OS);
}
} // end namespace llvm
diff --git a/llvm/utils/TableGen/X86FoldTablesEmitter.cpp b/llvm/utils/TableGen/X86FoldTablesEmitter.cpp
index 052151dfb007..e8555df7ba02 100644
--- a/llvm/utils/TableGen/X86FoldTablesEmitter.cpp
+++ b/llvm/utils/TableGen/X86FoldTablesEmitter.cpp
@@ -141,7 +141,7 @@ class X86FoldTablesEmitter {
X86FoldTablesEmitter(RecordKeeper &R) : Records(R), Target(R) {}
// run - Generate the 6 X86 memory fold tables.
- void run(formatted_raw_ostream &OS);
+ void run(raw_ostream &OS);
private:
// Decides to which table to add the entry with the given instructions.
@@ -522,7 +522,8 @@ void X86FoldTablesEmitter::updateTables(const CodeGenInstruction *RegInstr,
}
}
-void X86FoldTablesEmitter::run(formatted_raw_ostream &OS) {
+void X86FoldTablesEmitter::run(raw_ostream &o) {
+ formatted_raw_ostream OS(o);
emitSourceFileHeader("X86 fold tables", OS);
// Holds all memory instructions
@@ -615,8 +616,7 @@ void X86FoldTablesEmitter::run(formatted_raw_ostream &OS) {
namespace llvm {
-void EmitX86FoldTables(RecordKeeper &RK, raw_ostream &o) {
- formatted_raw_ostream OS(o);
+void EmitX86FoldTables(RecordKeeper &RK, raw_ostream &OS) {
X86FoldTablesEmitter(RK).run(OS);
}
} // namespace llvm
More information about the llvm-commits
mailing list