#include "Transforms/GlobalDataGeneration.h"
-#include "CppGen/Global.h"
#include "CppGen/MemoryContext.h"
#include "CppGen/Host.h"
+++ /dev/null
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "Global.h"
-
-#include <cassert>
-
-namespace enco
-{
-
-GlobalOffset Global::constant(const std::string &s)
-{
- auto const base = reinterpret_cast<const uint8_t *>(s.c_str());
- auto const size = s.size() + 1 /* NUL */;
- return constant(base, size);
-}
-
-template <> GlobalOffset Global::constant(const std::vector<uint32_t> &values)
-{
- auto const base = reinterpret_cast<const uint8_t *>(values.data());
- auto const size = sizeof(uint32_t) * values.size();
- return constant(base, size);
-}
-
-GlobalOffset Global::constant(const uint8_t *base, uint32_t size)
-{
- auto pos = _os.tellp();
- assert(pos != -1);
-
- _os.write(reinterpret_cast<const char *>(base), size);
-
- return static_cast<GlobalOffset>(pos);
-}
-
-} // namespace enco
+++ /dev/null
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __ENCO_GLOBAL_H__
-#define __ENCO_GLOBAL_H__
-
-#include <cstdint>
-#include <string>
-#include <vector>
-#include <ostream>
-
-namespace enco
-{
-
-using GlobalOffset = uint32_t;
-
-/**
- * @brief Manage global variable declarations
- */
-class Global
-{
-public:
- Global(std::ostream &os) : _os(os)
- {
- // DO NOTHING
- }
-
-public:
- // @brief Create a global constant string (const char *) literal, and return variable name
- GlobalOffset constant(const std::string &value);
-
- // @brief Create a global constant array variable of type T
- template <typename T> GlobalOffset constant(const std::vector<T> &values);
-
- // @brief Create a global constant array variable of byte (uint8_t) type
- GlobalOffset constant(const uint8_t *base, uint32_t size);
-
-private:
- uint32_t _offset = 0;
- std::ostream &_os;
-};
-
-} // namespace enco
-
-#endif // __ENCO_GLOBAL_H__
+++ /dev/null
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "Global.h"
-
-#include <set>
-
-#include <gtest/gtest.h>
-
-// TODO Rewrite this test
-#if 0
-TEST(GLOBAL, distinct_id)
-{
- enco::Global global;
-
- std::set<std::string> ids;
-
- ids.insert(global.constant("Hello"));
- ids.insert(global.constant("Nice to meet you"));
-
- ASSERT_EQ(ids.size(), 2);
-}
-#endif
namespace
{
+/**
+ * @brief Manage global variable declarations
+ */
+class Global
+{
+public:
+ Global(std::ostream &os) : _os(os)
+ {
+ // DO NOTHING
+ }
+
+public:
+ // @brief Create a global constant string (const char *) literal, and return variable name
+ enco::GlobalOffset constant(const std::string &value);
+
+ // @brief Create a global constant array variable of type T
+ template <typename T> enco::GlobalOffset constant(const std::vector<T> &values);
+
+ // @brief Create a global constant array variable of byte (uint8_t) type
+ enco::GlobalOffset constant(const uint8_t *base, uint32_t size);
+
+private:
+ uint32_t _offset = 0;
+ std::ostream &_os;
+};
+
+enco::GlobalOffset Global::constant(const std::string &s)
+{
+ auto const base = reinterpret_cast<const uint8_t *>(s.c_str());
+ auto const size = s.size() + 1 /* NUL */;
+ return constant(base, size);
+}
+
+template <> enco::GlobalOffset Global::constant(const std::vector<uint32_t> &values)
+{
+ auto const base = reinterpret_cast<const uint8_t *>(values.data());
+ auto const size = sizeof(uint32_t) * values.size();
+ return constant(base, size);
+}
+
+enco::GlobalOffset Global::constant(const uint8_t *base, uint32_t size)
+{
+ auto pos = _os.tellp();
+ assert(pos != -1);
+
+ _os.write(reinterpret_cast<const char *>(base), size);
+
+ return static_cast<enco::GlobalOffset>(pos);
+}
+
+} // namespace
+
+namespace
+{
+
std::map<const ann::Operand *, enco::GlobalOffset> data_offset_ctx;
std::map<const coco::Arg *, enco::GlobalOffset> name_offset_ctx;
std::map<const coco::Arg *, enco::GlobalOffset> dims_offset_ctx;
#ifndef __ENCO_TRANSFORM_GLOBAL_DATA_GENERATION_H__
#define __ENCO_TRANSFORM_GLOBAL_DATA_GENERATION_H__
-#include "CppGen/Global.h"
#include "Code.h"
+#include <ostream>
+
namespace enco
{
+using GlobalOffset = uint32_t;
+
struct GlobalData
{
static GlobalOffset data_offset(const ann::Operand *);