[enco] Get Code from Session (#1720)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Tue, 2 Oct 2018 04:48:57 +0000 (13:48 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Tue, 2 Oct 2018 04:48:57 +0000 (13:48 +0900)
With this commit, enco Backend class no longer declares Code variable.
Instead, it accesses the Code entity through Session.

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

index 64b8a36..c97ee5f 100644 (file)
@@ -79,16 +79,14 @@ private:
 
 void BackendImpl::compile(coco::Module *m, coco::Data *d)
 {
-  make_session(m, d);
-
-  Code code{m, d};
+  auto sess = make_session(m, d);
 
   // As explained below, the current implementation does not work if there is a pair of input/ouput
   // that share the same bag as their underlying bag.
   //
   // This DuplicatePass creates a copy of such bags in order to eliminate such a pair.
   DuplicatePass duplicate;
-  duplicate.runOnCode(&code);
+  duplicate.runOnCode(code(sess));
 
   // The current implementation will assign memory region for each bag as follows:
   //   Bind input bag to the region provided by Network_input_bind
@@ -97,42 +95,42 @@ void BackendImpl::compile(coco::Module *m, coco::Data *d)
   //
   // Note that this scheme does not work if there is a pair of input/output
   // that share the same bag as their underlying bag
-  assert(!has_inout_bag(code.module()));
+  assert(!has_inout_bag(code(sess)->module()));
 
-  unify_feature(&code);
+  unify_feature(code(sess));
 
   AvgPoolRewritePass avgpool_rewrite;
-  avgpool_rewrite.runOnCode(&code);
+  avgpool_rewrite.runOnCode(code(sess));
 
   // Insert data ordering if necessary
   NormalizePass normalize;
-  normalize.runOnCode(&code);
+  normalize.runOnCode(code(sess));
 
-  eliminate_indirect_copy(&code);
-  reduce_identical_object(&code);
-  reduce_duplicated_object(&code);
+  eliminate_indirect_copy(code(sess));
+  reduce_identical_object(code(sess));
+  reduce_duplicated_object(code(sess));
 
   // Eliminate dead object
   //
   // NOTE Dead Object Elimination (DOE) is performed before Copy lowering
   //      in order to reduce compilation overhead.
-  eliminate_dead_object(&code);
+  eliminate_dead_object(code(sess));
 
   // Lower Copy as Shuffle
-  lower_copy(&code);
+  lower_copy(code(sess));
 
-  generate_bypass_shuffle(&code);
+  generate_bypass_shuffle(code(sess));
 
-  eliminate_dead_bag(&code);
+  eliminate_dead_bag(code(sess));
 
   // Split instructions into a set of phases (each block serves as a phase)
   SplitPass split;
-  split.runOnCode(&code);
+  split.runOnCode(code(sess));
 
   // TODO Run various transforms over enco::Code
 
   std::ofstream ofs{_prefix + ".cpp"};
-  ofs << CppCode{&code} << std::endl;
+  ofs << CppCode{code(sess)} << std::endl;
 }
 
 } // namespace enco