--- /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 _NNC_ARTIFACT_GENERATOR_CPP_CODE_H_
+#define _NNC_ARTIFACT_GENERATOR_CPP_CODE_H_
+
+#include "IArtifactGenerator.h"
+
+#include <fstream>
+
+namespace nncc
+{
+namespace contrib
+{
+namespace backend
+{
+namespace soft
+{
+
+/**
+ * @brief The ACL C++ artifact source code producer.
+ */
+class ArtifactGeneratorCppCode : public IArtifactGenerator
+{
+public:
+ explicit ArtifactGeneratorCppCode(const std::string& name);
+
+ void visit(const ArtifactLiteral* node) override;
+ void visit(const ArtifactFunctionCall* node) override;
+ void visit(const ArtifactBlock* node) override;
+ void visit(const ArtifactFunction* node) override;
+ void visit(const ArtifactModule* node) override;
+
+private:
+ std::ofstream _out;
+};
+
+} // namespace soft
+} // namespace backend
+} // namespace contrib
+} // namespace nncc
+
+#endif //_NNC_ARTIFACT_GENERATOR_CPP_CODE_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.
+ */
+
+#ifndef _NNC_ARTIFACT_GENERATOR_CPP_DECL_H_
+#define _NNC_ARTIFACT_GENERATOR_CPP_DECL_H_
+
+#include "IArtifactGenerator.h"
+
+#include <fstream>
+
+namespace nncc
+{
+namespace contrib
+{
+namespace backend
+{
+namespace soft
+{
+
+/**
+ * @brief The ACL C++ artifact header file producer.
+ */
+class ArtifactGeneratorCppDecl : public IArtifactGenerator
+{
+public:
+ explicit ArtifactGeneratorCppDecl(const std::string& name);
+
+ void visit(const ArtifactLiteral* node) override;
+ void visit(const ArtifactFunctionCall* node) override;
+ void visit(const ArtifactBlock* node) override;
+ void visit(const ArtifactFunction* node) override;
+ void visit(const ArtifactModule* node) override;
+
+private:
+ std::ofstream _out;
+};
+
+} // namespace soft
+} // namespace backend
+} // namespace contrib
+} // namespace nncc
+
+#endif //_NNC_ARTIFACT_GENERATOR_CPP_DECL_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.
+ */
+
+#ifndef _NNC_ARTIFACT_MODEL_H_
+#define _NNC_ARTIFACT_MODEL_H_
+
+#include <string>
+#include <list>
+#include <ostream>
+
+#include "IArtifactGenerator.h"
+
+namespace nncc
+{
+namespace contrib
+{
+namespace backend
+{
+namespace soft
+{
+
+/**
+ * @todo FIXME: remove the identical accept() function implementations!
+ *
+ * @todo Get rid of the 'Artifact' prefix in the class names
+ * in this hierarchy, after anticipated namespace refactoring
+ * in the nnc project.
+ */
+
+/**
+ * @brief The base class of the whole artifact entities hierarchy.
+ */
+class ArtifactEntity
+{
+public:
+ virtual ~ArtifactEntity() = default;
+ /**
+ * @brief This is the core function of each artifact entity and
+ * is implemented by all concrete classes in the hierarchy.
+ */
+ virtual void accept(IArtifactGenerator* g) const = 0;
+
+protected:
+ ArtifactEntity() = default;
+};
+
+/**
+ * @brief Represents literals which should go to the artifact source code as is.
+ */
+class ArtifactLiteral : public ArtifactEntity
+{
+public:
+ explicit ArtifactLiteral(const std::string& value) : _value(value) {}
+
+ void accept(IArtifactGenerator* g) const override
+ {
+ g->visit(this);
+ }
+
+ const std::string& getValue() const { return _value; }
+
+private:
+ std::string _value;
+};
+
+class ArtifactIdentifier : public ArtifactEntity
+{
+public:
+ explicit ArtifactIdentifier(const std::string& id) : _id(id) {}
+ const std::string& getId() const { return _id; }
+
+private:
+ std::string _id;
+};
+
+/**
+ * @brief Represents an entity with semantics like C/C++ reference operator.
+ */
+class ArtifactRef : public ArtifactEntity
+{
+public:
+ explicit ArtifactRef(const ArtifactEntity& ref) : _ref(ref) {}
+
+ void accept(IArtifactGenerator* g) const override
+ {
+ g->visit(this);
+ }
+
+private:
+ const ArtifactEntity& _ref;
+};
+
+/**
+ * @brief Represents an entity with semantics like C/C++ dereference operator.
+ */
+class ArtifactDeref : public ArtifactEntity
+{
+public:
+ explicit ArtifactDeref(const ArtifactEntity& ref) : _ref(ref) {}
+
+ void accept(IArtifactGenerator* g) const override
+ {
+ g->visit(this);
+ }
+
+private:
+ const ArtifactEntity& _ref;
+};
+
+/**
+ * @brief Represents a variable.
+ */
+class ArtifactVariable : public ArtifactIdentifier
+{
+public:
+ ArtifactVariable(const std::string& typeName, const std::string& varName) : _typeName(typeName), ArtifactIdentifier(varName) {}
+
+ void accept(IArtifactGenerator* g) const override
+ {
+ g->visit(this);
+ }
+
+private:
+ const std::string& _typeName;
+};
+
+/**
+ * @brief Represents a class.
+ */
+class ArtifactClass : public ArtifactIdentifier
+{
+public:
+ explicit ArtifactClass(const std::string& className) : ArtifactIdentifier(className) {}
+
+ void accept(IArtifactGenerator* g) const override
+ {
+ g->visit(this);
+ }
+};
+
+/**
+ * @brief Represents a function call.
+ */
+class ArtifactFunctionCall : public ArtifactEntity
+{
+public:
+ ArtifactFunctionCall(const std::string& funcName, const std::list<ArtifactEntity*>& paramList) :
+ _funcName(funcName), _paramList(paramList) {}
+
+ void accept(IArtifactGenerator* g) const override
+ {
+ g->visit(this);
+ }
+
+ const std::string& getFuncName() const { return _funcName; }
+ const std::list<ArtifactEntity*> getParamList() const { return _paramList; }
+
+private:
+ std::string _funcName;
+ std::list<ArtifactEntity*> _paramList;
+};
+
+/**
+ * @brief Represents a block of instructions.
+ */
+class ArtifactBlock : public ArtifactEntity
+{
+public:
+ void accept(IArtifactGenerator* g) const override
+ {
+ g->visit(this);
+ }
+
+ void addStatement(ArtifactEntity* statement)
+ {
+ _statements.push_back(statement);
+ }
+
+ std::list<ArtifactEntity*> getStatements() const
+ {
+ return _statements;
+ }
+
+private:
+ std::list<ArtifactEntity*> _statements;
+};
+
+/**
+ * @brief Represents a function.
+ */
+class ArtifactFunction : public ArtifactIdentifier
+{
+public:
+ ArtifactFunction(const std::string& funcName, const std::list<ArtifactVariable*>& params, const std::string& retTypeName) :
+ ArtifactIdentifier(funcName), _params(params), _retTypeName(retTypeName) {}
+
+ void accept(IArtifactGenerator* g) const override
+ {
+ g->visit(this);
+ }
+
+ const std::list<ArtifactVariable*>& getParameters() const
+ {
+ return _params;
+ }
+
+ const std::string& getRetTypeName() const
+ {
+ return _retTypeName;
+ }
+
+ void AddStatement(ArtifactEntity* statement)
+ {
+ _body.addStatement(statement);
+ }
+
+private:
+ std::list<ArtifactVariable*> _params;
+ std::string _retTypeName;
+ ArtifactBlock _body;
+};
+
+/**
+ * @brief Class representing a module in the ACL C++ soft backend.
+ */
+class ArtifactModule
+{
+public:
+ explicit ArtifactModule(const std::string& name) : _name(name) {}
+
+ void accept(IArtifactGenerator* g) const
+ {
+ g->visit(this);
+ }
+
+private:
+ std::string _name;
+};
+
+} // namespace soft
+} // namespace backend
+} // namespace contrib
+} // namespace nncc
+
+#endif //_NNC_ARTIFACT_MODEL_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.
+ */
+
+#ifndef _NNC_ARTIFACT_GENERATOR_INTERFACE_H_
+#define _NNC_ARTIFACT_GENERATOR_INTERFACE_H_
+
+namespace nncc
+{
+namespace contrib
+{
+namespace backend
+{
+namespace soft
+{
+
+class ArtifactEntity;
+class ArtifactLiteral;
+class ArtifactFunctionCall;
+class ArtifactBlock;
+class ArtifactFunction;
+class ArtifactModule;
+
+/**
+ * @brief The interface of the artifact source code producer.
+ */
+class IArtifactGenerator
+{
+public:
+ virtual ~IArtifactGenerator() = default;
+
+ virtual void visit(const ArtifactEntity* node) = 0;
+ virtual void visit(const ArtifactLiteral* node) = 0;
+ virtual void visit(const ArtifactFunctionCall* node) = 0;
+ virtual void visit(const ArtifactBlock* node) = 0;
+ virtual void visit(const ArtifactFunction* node) = 0;
+ virtual void visit(const ArtifactModule* node) = 0;
+};
+
+} // namespace soft
+} // namespace backend
+} // namespace contrib
+} // namespace nncc
+
+#endif //_NNC_ARTIFACT_GENERATOR_INTERFACE_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 "passes/acl_soft_backend/ArtifactGeneratorCppCode.h"
+#include "passes/acl_soft_backend/ArtifactModel.h"
+
+using namespace std;
+using namespace nncc::contrib::backend::soft;
+
+ArtifactGeneratorCppCode::ArtifactGeneratorCppCode(const string& name)
+{
+}
+
+void ArtifactGeneratorCppCode::visit(const ArtifactLiteral* node)
+{
+ _out << node->getValue();
+}
+
+void ArtifactGeneratorCppCode::visit(const ArtifactFunctionCall* node)
+{
+ _out << node->getFuncName();
+ _out << "(";
+ bool addComma = false;
+
+ for (const auto* par : node->getParamList())
+ {
+ if (addComma)
+ _out << ", ";
+
+ par->accept(this);
+ addComma = true;
+ }
+
+ _out << ")";
+}
+
+void ArtifactGeneratorCppCode::visit(const ArtifactBlock* node)
+{
+ _out << "{" << endl;
+
+ for (const auto* st : node->getStatements())
+ {
+ st->accept(this);
+ _out << ";";
+ }
+
+ _out << "}" << endl;
+}
+
+void ArtifactGeneratorCppCode::visit(const ArtifactFunction* node)
+{
+
+}
+
+void ArtifactGeneratorCppCode::visit(const ArtifactModule* node)
+{
+
+}
--- /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 "passes/acl_soft_backend/ArtifactGeneratorCppDecl.h"
+#include "passes/acl_soft_backend/ArtifactModel.h"
+
+using namespace std;
+using namespace nncc::contrib::backend::soft;
+
+ArtifactGeneratorCppDecl::ArtifactGeneratorCppDecl(const string& name)
+{
+}
+
+void ArtifactGeneratorCppDecl::visit(const ArtifactLiteral* node)
+{
+}
+
+void ArtifactGeneratorCppDecl::visit(const ArtifactFunctionCall* node)
+{
+}
+
+void ArtifactGeneratorCppDecl::visit(const ArtifactBlock* node)
+{
+}
+
+void ArtifactGeneratorCppDecl::visit(const ArtifactFunction* node)
+{
+ _out << node->getRetTypeName() << " " << node->getId() << "(";
+
+ bool addComma = false;
+
+ for (const auto* par : node->getParameters())
+ {
+ if (addComma)
+ _out << ", ";
+
+ par->accept(this);
+ addComma = true;
+ }
+
+ _out << ");";
+}
+
+void ArtifactGeneratorCppDecl::visit(const ArtifactModule* node)
+{
+
+}
--- /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 "passes/acl_soft_backend/IArtifactGenerator.h"
+
+using namespace std;
+using namespace nncc::contrib::backend::soft;
-set(ACL_SOFT_BACKEND_CPP_SOURCES AclCPPGenerator.cpp)
+set(ACL_SOFT_BACKEND_CPP_SOURCES AclCPPGenerator.cpp ArtifactGeneratorCppCode.cpp ArtifactGeneratorCppDecl.cpp ArtifactModel.cpp)
add_nnc_library(acl_soft_backend_cpp SHARED ${ACL_SOFT_BACKEND_CPP_SOURCES})
target_include_directories(acl_soft_backend_cpp PRIVATE ${CMAKE_CURRENT_BINARY_DIR})