[enco] Introduce MemoryContext class (#1180)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Fri, 24 Aug 2018 07:54:13 +0000 (16:54 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Fri, 24 Aug 2018 07:54:13 +0000 (16:54 +0900)
This commit introduces MemoryContext class which manages expressions
that denote the base address and size of memory region dedicated to each
Bag.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
contrib/enco/core/src/CppGen/MemoryContext.cpp [new file with mode: 0644]
contrib/enco/core/src/CppGen/MemoryContext.h [new file with mode: 0644]

diff --git a/contrib/enco/core/src/CppGen/MemoryContext.cpp b/contrib/enco/core/src/CppGen/MemoryContext.cpp
new file mode 100644 (file)
index 0000000..ec0f94c
--- /dev/null
@@ -0,0 +1,9 @@
+#include "MemoryContext.h"
+
+namespace enco
+{
+
+void MemoryContext::base(const coco::Bag *bag, const std::string &exp) { _base[bag] = exp; }
+void MemoryContext::size(const coco::Bag *bag, const std::string &exp) { _size[bag] = exp; }
+
+} // namespace enco
diff --git a/contrib/enco/core/src/CppGen/MemoryContext.h b/contrib/enco/core/src/CppGen/MemoryContext.h
new file mode 100644 (file)
index 0000000..5b28b03
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef __ENCO_CPP_GEN_MEMORY_CONTEXT_H__
+#define __ENCO_CPP_GEN_MEMORY_CONTEXT_H__
+
+#include <coco/IR/Bag.h>
+
+#include <string>
+#include <map>
+
+namespace enco
+{
+
+/**
+ * @brief Record C/C++ expression that denotes the base and size of memory region
+ *        dedicated to each bag
+ */
+class MemoryContext
+{
+public:
+  void base(const coco::Bag *bag, const std::string &exp);
+  void size(const coco::Bag *bag, const std::string &exp);
+
+public:
+  const std::string &base(const coco::Bag *bag) const { return _base.at(bag); }
+  const std::string &size(const coco::Bag *bag) const { return _size.at(bag); }
+
+private:
+  std::map<const coco::Bag *, std::string> _base;
+  std::map<const coco::Bag *, std::string> _size;
+};
+
+} // namespace enco
+
+#endif // __ENCO_CPP_GEN_MEMORY_CONTEXT_H__