[logo] Inherit PhaseRunnerMixinObservable (#6985)
author박세희/On-Device Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Wed, 28 Aug 2019 06:52:13 +0000 (15:52 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Wed, 28 Aug 2019 06:52:13 +0000 (15:52 +0900)
This will update PhaseRunner to inherit PhaseRunnerMixinObservable for notification
and add call methods to send notifications

Signed-off-by: SaeHie Park <saehie.park@samsung.com>
compiler/logo/include/logo/Phase.h
compiler/logo/src/Phase.cpp

index efbad2a..d1b7ccd 100644 (file)
@@ -157,7 +157,7 @@ enum class PhaseStrategy
 
 template <PhaseStrategy S> class PhaseRunner;
 
-template <> class PhaseRunner<PhaseStrategy::Saturate>
+template <> class PhaseRunner<PhaseStrategy::Saturate> final : public PhaseRunnerMixinObservable
 {
 public:
   PhaseRunner(loco::Graph *graph) : _graph{graph}
@@ -172,7 +172,7 @@ private:
   loco::Graph *_graph;
 };
 
-template <> class PhaseRunner<PhaseStrategy::Restart>
+template <> class PhaseRunner<PhaseStrategy::Restart> final : public PhaseRunnerMixinObservable
 {
 public:
   PhaseRunner(loco::Graph *graph) : _graph{graph}
index f842290..b929a31 100644 (file)
@@ -21,35 +21,51 @@ namespace logo
 
 void PhaseRunner<PhaseStrategy::Saturate>::run(const Phase &phase) const
 {
+  notifyPhaseBegin();
+
   for (bool changed = true; changed;)
   {
     changed = false;
 
     for (auto &pass : phase)
     {
+      notifyPassBegin(pass.get());
+
       bool pass_changed = pass->run(_graph);
       changed = changed || pass_changed;
+
+      notifyPassEnd(pass.get(), pass_changed);
     }
   }
+
+  notifyPhaseEnd();
 }
 
 void PhaseRunner<PhaseStrategy::Restart>::run(const Phase &phase) const
 {
+  notifyPhaseBegin();
+
   for (bool changed = true; changed;)
   {
     changed = false;
 
     for (auto &pass : phase)
     {
+      notifyPassBegin(pass.get());
+
       bool pass_changed = pass->run(_graph);
       changed = changed || pass_changed;
 
+      notifyPassEnd(pass.get(), pass_changed);
+
       if (changed)
       {
         break;
       }
     }
   }
+
+  notifyPhaseEnd();
 }
 
 } // namespace logo