[nest] Support 'push' statement construction (#716)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Thu, 19 Jul 2018 05:41:49 +0000 (14:41 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Thu, 19 Jul 2018 05:41:49 +0000 (14:41 +0900)
This commit allows users to construct 'push' statement through 'module'.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
contrib/nest/include/nest/Module.h
contrib/nest/src/Module.cpp [new file with mode: 0644]
contrib/nest/src/Module.test.cpp

index 59cd634..e8af83b 100644 (file)
@@ -3,6 +3,7 @@
 
 #include "nest/VarContext.h"
 #include "nest/DomainContext.h"
+#include "nest/Block.h"
 
 namespace nest
 {
@@ -29,6 +30,15 @@ private:
 public:
   DomainContext &domain(void) { return _domain_ctx; }
   const DomainContext &domain(void) const { return _domain_ctx; }
+
+private:
+  Block _block;
+
+public:
+  const Block &block(void) const { return _block; }
+
+public:
+  void push(const Expr &expr);
 };
 
 } // namespace nest
diff --git a/contrib/nest/src/Module.cpp b/contrib/nest/src/Module.cpp
new file mode 100644 (file)
index 0000000..18c953b
--- /dev/null
@@ -0,0 +1,12 @@
+#include "nest/Module.h"
+
+namespace nest
+{
+
+void Module::push(const Expr &expr)
+{
+  auto stmt = std::make_shared<stmt::PushNode>(expr);
+  _block.append(stmt);
+}
+
+} // namespace nest
index 119c3f1..5def2c7 100644 (file)
@@ -37,3 +37,19 @@ TEST(MODULE, create_domain)
   create(m, {1, 3, 3});
   check(m);
 }
+
+TEST(MODULE, push)
+{
+  nest::Module m;
+
+  auto ifm = m.domain().make({1, 3, 3});
+
+  auto var_ch = m.var().make();
+  auto var_row = m.var().make();
+  auto var_col = m.var().make();
+
+  m.push(ifm(var_ch, var_row, var_col));
+
+  ASSERT_EQ(m.block().size(), 1);
+  ASSERT_NE(m.block().at(0)->asPush(), nullptr);
+}