[llvm] [MachineScheduler] Move the constructor definitions inside the class (NFC). (PR #126276)

Christudasan Devadasan via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 7 09:41:40 PST 2025


https://github.com/cdevadas created https://github.com/llvm/llvm-project/pull/126276

Authored by Akshat Oke <Akshat.Oke at amd.com>

>From f632a47222faa1f94f9978d4af44efe772386c3a Mon Sep 17 00:00:00 2001
From: Christudasan Devadasan <Christudasan.Devadasan at amd.com>
Date: Fri, 7 Feb 2025 22:43:06 +0530
Subject: [PATCH] [MachineScheduler] Move the constructor definitions inside
 the class (NFC).

Authored by Akshat Oke <Akshat.Oke at amd.com>
---
 llvm/lib/CodeGen/MachineScheduler.cpp | 110 ++++++++++++--------------
 1 file changed, 49 insertions(+), 61 deletions(-)

diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp
index df90077b15f331f..2dd55825282cfd8 100644
--- a/llvm/lib/CodeGen/MachineScheduler.cpp
+++ b/llvm/lib/CodeGen/MachineScheduler.cpp
@@ -228,10 +228,30 @@ class MachineSchedulerImpl : public MachineSchedulerBase {
   MachineFunctionAnalysisManager *MFAM = nullptr;
 
 public:
-  MachineSchedulerImpl(MachineFunction &Func, MachineFunctionPass *P);
+  MachineSchedulerImpl(MachineFunction &Func, MachineFunctionPass *P) : P(P) {
+    MF = &Func;
+    MLI = &P->getAnalysis<MachineLoopInfoWrapperPass>().getLI();
+    MDT = &P->getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree();
+    TM = &P->getAnalysis<TargetPassConfig>().getTM<TargetMachine>();
+    AA = &P->getAnalysis<AAResultsWrapperPass>().getAAResults();
+    LIS = &P->getAnalysis<LiveIntervalsWrapperPass>().getLIS();
+  }
+
   MachineSchedulerImpl(MachineFunction &Func,
                        MachineFunctionAnalysisManager &MFAM,
-                       const TargetMachine *TargetM);
+                       const TargetMachine *TargetM)
+      : MFAM(&MFAM) {
+    MF = &Func;
+    TM = TargetM;
+    MLI = &MFAM.getResult<MachineLoopAnalysis>(Func);
+    MDT = &MFAM.getResult<MachineDominatorTreeAnalysis>(Func);
+    auto &FAM =
+        MFAM.getResult<FunctionAnalysisManagerMachineFunctionProxy>(Func)
+            .getManager();
+    AA = &FAM.getResult<AAManager>(Func.getFunction());
+    LIS = &MFAM.getResult<LiveIntervalsAnalysis>(Func);
+  }
+
   bool run();
 
 protected:
@@ -244,10 +264,27 @@ class PostMachineSchedulerImpl : public MachineSchedulerBase {
   MachineFunctionAnalysisManager *MFAM = nullptr;
 
 public:
-  PostMachineSchedulerImpl(MachineFunction &Func, MachineFunctionPass *P);
+  PostMachineSchedulerImpl(MachineFunction &Func, MachineFunctionPass *P)
+      : P(P) {
+    MF = &Func;
+    MLI = &P->getAnalysis<MachineLoopInfoWrapperPass>().getLI();
+    TM = &P->getAnalysis<TargetPassConfig>().getTM<TargetMachine>();
+    AA = &P->getAnalysis<AAResultsWrapperPass>().getAAResults();
+  }
+
   PostMachineSchedulerImpl(MachineFunction &Func,
                            MachineFunctionAnalysisManager &MFAM,
-                           const TargetMachine *TargetM);
+                           const TargetMachine *TargetM)
+      : MFAM(&MFAM) {
+    MF = &Func;
+    TM = TargetM;
+    MLI = &MFAM.getResult<MachineLoopAnalysis>(Func);
+    auto &FAM =
+        MFAM.getResult<FunctionAnalysisManagerMachineFunctionProxy>(Func)
+            .getManager();
+    AA = &FAM.getResult<AAManager>(Func.getFunction());
+  }
+
   bool run();
 
 protected:
@@ -257,7 +294,10 @@ class PostMachineSchedulerImpl : public MachineSchedulerBase {
 /// MachineScheduler runs after coalescing and before register allocation.
 class MachineSchedulerLegacy : public MachineFunctionPass {
 public:
-  MachineSchedulerLegacy();
+  MachineSchedulerLegacy() : MachineFunctionPass(ID) {
+    initializeMachineSchedulerLegacyPass(*PassRegistry::getPassRegistry());
+  }
+
   void getAnalysisUsage(AnalysisUsage &AU) const override;
   bool runOnMachineFunction(MachineFunction&) override;
 
@@ -267,7 +307,10 @@ class MachineSchedulerLegacy : public MachineFunctionPass {
 /// PostMachineScheduler runs after shortly before code emission.
 class PostMachineSchedulerLegacy : public MachineFunctionPass {
 public:
-  PostMachineSchedulerLegacy();
+  PostMachineSchedulerLegacy() : MachineFunctionPass(ID) {
+    initializePostMachineSchedulerLegacyPass(*PassRegistry::getPassRegistry());
+  }
+
   void getAnalysisUsage(AnalysisUsage &AU) const override;
   bool runOnMachineFunction(MachineFunction&) override;
 
@@ -290,10 +333,6 @@ INITIALIZE_PASS_DEPENDENCY(LiveIntervalsWrapperPass)
 INITIALIZE_PASS_END(MachineSchedulerLegacy, DEBUG_TYPE,
                     "Machine Instruction Scheduler", false, false)
 
-MachineSchedulerLegacy::MachineSchedulerLegacy() : MachineFunctionPass(ID) {
-  initializeMachineSchedulerLegacyPass(*PassRegistry::getPassRegistry());
-}
-
 void MachineSchedulerLegacy::getAnalysisUsage(AnalysisUsage &AU) const {
   AU.setPreservesCFG();
   AU.addRequired<MachineDominatorTreeWrapperPass>();
@@ -319,11 +358,6 @@ INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass)
 INITIALIZE_PASS_END(PostMachineSchedulerLegacy, "postmisched",
                     "PostRA Machine Instruction Scheduler", false, false)
 
-PostMachineSchedulerLegacy::PostMachineSchedulerLegacy()
-    : MachineFunctionPass(ID) {
-  initializePostMachineSchedulerLegacyPass(*PassRegistry::getPassRegistry());
-}
-
 void PostMachineSchedulerLegacy::getAnalysisUsage(AnalysisUsage &AU) const {
   AU.setPreservesCFG();
   AU.addRequired<MachineDominatorTreeWrapperPass>();
@@ -403,31 +437,6 @@ nextIfDebug(MachineBasicBlock::iterator I,
       .getNonConstIterator();
 }
 
-MachineSchedulerImpl::MachineSchedulerImpl(MachineFunction &Func,
-                                           MachineFunctionPass *P)
-    : P(P) {
-  MF = &Func;
-  MLI = &P->getAnalysis<MachineLoopInfoWrapperPass>().getLI();
-  MDT = &P->getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree();
-  TM = &P->getAnalysis<TargetPassConfig>().getTM<TargetMachine>();
-  AA = &P->getAnalysis<AAResultsWrapperPass>().getAAResults();
-  LIS = &P->getAnalysis<LiveIntervalsWrapperPass>().getLIS();
-}
-
-MachineSchedulerImpl::MachineSchedulerImpl(MachineFunction &Func,
-                                           MachineFunctionAnalysisManager &MFAM,
-                                           const TargetMachine *TargetM)
-    : MFAM(&MFAM) {
-  MF = &Func;
-  TM = TargetM;
-  MLI = &MFAM.getResult<MachineLoopAnalysis>(Func);
-  MDT = &MFAM.getResult<MachineDominatorTreeAnalysis>(Func);
-  auto &FAM = MFAM.getResult<FunctionAnalysisManagerMachineFunctionProxy>(Func)
-                  .getManager();
-  AA = &FAM.getResult<AAManager>(Func.getFunction());
-  LIS = &MFAM.getResult<LiveIntervalsAnalysis>(Func);
-}
-
 /// Instantiate a ScheduleDAGInstrs that will be owned by the caller.
 ScheduleDAGInstrs *MachineSchedulerImpl::createMachineScheduler() {
   // Select the scheduler, or set the default.
@@ -471,27 +480,6 @@ bool MachineSchedulerImpl::run() {
   return true;
 }
 
-PostMachineSchedulerImpl::PostMachineSchedulerImpl(MachineFunction &Func,
-                                                   MachineFunctionPass *P)
-    : P(P) {
-  MF = &Func;
-  MLI = &P->getAnalysis<MachineLoopInfoWrapperPass>().getLI();
-  TM = &P->getAnalysis<TargetPassConfig>().getTM<TargetMachine>();
-  AA = &P->getAnalysis<AAResultsWrapperPass>().getAAResults();
-}
-
-PostMachineSchedulerImpl::PostMachineSchedulerImpl(
-    MachineFunction &Func, MachineFunctionAnalysisManager &MFAM,
-    const TargetMachine *TargetM)
-    : MFAM(&MFAM) {
-  MF = &Func;
-  TM = TargetM;
-  MLI = &MFAM.getResult<MachineLoopAnalysis>(Func);
-  auto &FAM = MFAM.getResult<FunctionAnalysisManagerMachineFunctionProxy>(Func)
-                  .getManager();
-  AA = &FAM.getResult<AAManager>(Func.getFunction());
-}
-
 /// Instantiate a ScheduleDAGInstrs for PostRA scheduling that will be owned by
 /// the caller. We don't have a command line option to override the postRA
 /// scheduler. The Target must configure it.



More information about the llvm-commits mailing list