[enco] Introduce DuplicatedObjectReductionPass (#3057)
author박종현/On-Device Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Mon, 11 Mar 2019 02:19:12 +0000 (11:19 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Mon, 11 Mar 2019 02:19:12 +0000 (11:19 +0900)
This commit introduces DuplicatedObjectReductionPass and revises
backend implementation to use this new pass implementation.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
contrib/enco/core/src/Backend.cpp
contrib/enco/core/src/Transforms/DuplicatedObjectReduction.h

index 2eddde8..0578436 100644 (file)
@@ -110,6 +110,7 @@ void BackendImpl::compile(coco::Module *m, coco::Data *d)
   pipeline.append(make_unique<DataLayoutConversionPass>());
   pipeline.append(make_unique<IndirectCopyEliminationPass>());
   pipeline.append(make_unique<IdenticalObjectReductionPass>());
+  pipeline.append(make_unique<DuplicatedObjectReductionPass>());
 
   // Apply transforms in the pipeline
   for (uint32_t n = 0; n < pipeline.size(); ++n)
@@ -128,8 +129,6 @@ void BackendImpl::compile(coco::Module *m, coco::Data *d)
   // that share the same bag as their underlying bag
   assert(!has_inout_bag(code(sess)->module()));
 
-  reduce_duplicated_object(code(sess));
-
   fold_constants(code(sess));
 
   // Eliminate dead object
index 14d288a..3aa2005 100644 (file)
@@ -18,6 +18,7 @@
 #define __ENCO_TRANSFORM_DUPLICATED_OBJECT_REDUCTION_H__
 
 #include "Code.h"
+#include "Pass.h"
 
 namespace enco
 {
@@ -57,6 +58,16 @@ namespace enco
  */
 void reduce_duplicated_object(enco::Code *code);
 
+struct DuplicatedObjectReductionPass final : public Pass
+{
+  PASS_CTOR(DuplicatedObjectReductionPass)
+  {
+    // DO NOTHING
+  }
+
+  void run(const SessionID &sess) const override { reduce_duplicated_object(code(sess)); }
+};
+
 } // namespace enco
 
 #endif // __ENCO_TRANSFORM_DUPLICATED_OBJECT_REDUCTION_H__