Skip to content

[NFC][TableGen] Adopt Emitter::OptClass in InstrInfoEmitter #125971

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 6, 2025

Conversation

jurahul
Copy link
Contributor

@jurahul jurahul commented Feb 6, 2025

  • Use Emitter::OptClass to invoke InstrInfoEmitter::run and eliminate the EmitInstrInfo function.

- Use `Emitter::OptClass` to invoke `InstrInfoEmitter::run` and
  eliminate the `EmitInstrInfo` function.
@jurahul jurahul marked this pull request as ready for review February 6, 2025 13:13
@jurahul jurahul requested review from topperc and mshockwave February 6, 2025 13:13
@llvmbot
Copy link
Member

llvmbot commented Feb 6, 2025

@llvm/pr-subscribers-tablegen

Author: Rahul Joshi (jurahul)

Changes
  • Use Emitter::OptClass to invoke InstrInfoEmitter::run and eliminate the EmitInstrInfo function.

Full diff: https://github.com/llvm/llvm-project/pull/125971.diff

1 Files Affected:

  • (modified) llvm/utils/TableGen/InstrInfoEmitter.cpp (+8-11)
diff --git a/llvm/utils/TableGen/InstrInfoEmitter.cpp b/llvm/utils/TableGen/InstrInfoEmitter.cpp
index 97c00ad4924197..7c46890a49c81c 100644
--- a/llvm/utils/TableGen/InstrInfoEmitter.cpp
+++ b/llvm/utils/TableGen/InstrInfoEmitter.cpp
@@ -890,6 +890,9 @@ void InstrInfoEmitter::emitTIIHelperMethods(raw_ostream &OS,
 
 // run - Emit the main instruction description records for the target...
 void InstrInfoEmitter::run(raw_ostream &OS) {
+  TGTimer &Timer = Records.getTimer();
+  Timer.startTimer("Analyze DAG patterns");
+
   emitSourceFileHeader("Target Instruction Enum Values and Descriptors", OS);
   emitEnums(OS);
 
@@ -898,7 +901,6 @@ void InstrInfoEmitter::run(raw_ostream &OS) {
   const Record *InstrInfo = Target.getInstructionSet();
 
   // Collect all of the operand info records.
-  TGTimer &Timer = Records.getTimer();
   Timer.startTimer("Collect operand info");
   OperandInfoListTy OperandInfoList;
   OperandInfoMapTy OperandInfoMap;
@@ -1138,6 +1140,9 @@ void InstrInfoEmitter::run(raw_ostream &OS) {
 
   Timer.startTimer("Emit verifier methods");
   emitFeatureVerifier(OS, Target);
+
+  Timer.startTimer("Emit map table");
+  EmitMapTable(Records, OS);
 }
 
 void InstrInfoEmitter::emitRecord(
@@ -1314,13 +1319,5 @@ void InstrInfoEmitter::emitEnums(raw_ostream &OS) {
   OS << "#endif // GET_INSTRINFO_SCHED_ENUM\n\n";
 }
 
-static void EmitInstrInfo(const RecordKeeper &Records, raw_ostream &OS) {
-  TGTimer &Timer = Records.getTimer();
-  Timer.startTimer("Analyze DAG patterns");
-  InstrInfoEmitter(Records).run(OS);
-  Timer.startTimer("Emit map table");
-  EmitMapTable(Records, OS);
-}
-
-static TableGen::Emitter::Opt X("gen-instr-info", EmitInstrInfo,
-                                "Generate instruction descriptions");
+static TableGen::Emitter::OptClass<InstrInfoEmitter>
+    X("gen-instr-info", "Generate instruction descriptions");

Copy link
Collaborator

@topperc topperc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jurahul jurahul merged commit 337604e into llvm:main Feb 6, 2025
12 checks passed
@jurahul jurahul deleted the instrinfoemtter_optclass branch February 6, 2025 18:45
Icohedron pushed a commit to Icohedron/llvm-project that referenced this pull request Feb 11, 2025
…25971)

- Use `Emitter::OptClass` to invoke `InstrInfoEmitter::run` and
eliminate the `EmitInstrInfo` function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants