2 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef __ONERT_COMPILER_BACKEND_MANAGER_H__
18 #define __ONERT_COMPILER_BACKEND_MANAGER_H__
23 #include "ir/Operands.h"
24 #include "backend/Backend.h"
25 #include "backend/controlflow/Backend.h"
35 using backend_create_t = backend::Backend *(*)();
36 using backend_destroy_t = void (*)(backend::Backend *);
37 using dlhandle_destroy_t = void (*)(void *);
39 static BackendManager &get();
42 backend::Backend *get(const std::string &key);
43 const backend::Backend *get(const std::string &key) const;
44 const backend::controlflow::Backend *getControlflow() const;
45 const std::vector<const backend::Backend *> getAll() const
47 std::vector<const backend::Backend *> v;
48 for (const auto &p : _gen_map)
49 v.emplace_back(p.second.get());
52 size_t num_backends() const { return _gen_map.size(); }
54 * @brief load backend plugin
56 * @param backend backend to be loaded
60 void loadBackend(const std::string &backend);
66 std::map<std::string, std::unique_ptr<void, dlhandle_destroy_t>> _handle_map;
67 std::map<std::string, std::unique_ptr<backend::Backend, backend_destroy_t>> _gen_map;
68 backend::controlflow::Backend *_controlflow{nullptr};
70 * @brief load controlflow backend
72 * @param backend backend to be loaded
76 void loadControlflowBackend();
79 } // namespace compiler
82 #endif // __ONERT_COMPILER_BACKEND_MANAGER_H__