1 | /* |
2 | * Licensed to the Apache Software Foundation (ASF) under one |
3 | * or more contributor license agreements. See the NOTICE file |
4 | * distributed with this work for additional information |
5 | * regarding copyright ownership. The ASF licenses this file |
6 | * to you under the Apache License, Version 2.0 (the |
7 | * "License"); you may not use this file except in compliance |
8 | * with the License. You may obtain a copy of the License at |
9 | * |
10 | * http://www.apache.org/licenses/LICENSE-2.0 |
11 | * |
12 | * Unless required by applicable law or agreed to in writing, |
13 | * software distributed under the License is distributed on an |
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
15 | * KIND, either express or implied. See the License for the |
16 | * specific language governing permissions and limitations |
17 | * under the License. |
18 | */ |
19 | |
20 | #ifndef TVM_RUNTIME_HEXAGON_HEXAGON_MODULE_H_ |
21 | #define TVM_RUNTIME_HEXAGON_HEXAGON_MODULE_H_ |
22 | |
23 | #include <tvm/runtime/logging.h> |
24 | #include <tvm/runtime/module.h> |
25 | |
26 | #include <array> |
27 | #include <memory> |
28 | #include <set> |
29 | #include <string> |
30 | #include <unordered_map> |
31 | |
32 | #include "../meta_data.h" |
33 | |
34 | namespace tvm { |
35 | namespace runtime { |
36 | |
37 | /*! |
38 | * \brief Create a Hexagon module from data. |
39 | * \param data The module data. |
40 | * \param fmt The format of the data, can be "obj". |
41 | * \param fmap The function information map of each function. |
42 | * \param asm_str String with the generated assembly source. |
43 | * \param obj_str String with the object file data. |
44 | * \param ir_str String with the disassembled LLVM IR source. |
45 | * \param bc_str String with the bitcode LLVM IR. |
46 | */ |
47 | Module HexagonModuleCreate(std::string data, std::string fmt, |
48 | std::unordered_map<std::string, FunctionInfo> fmap, std::string asm_str, |
49 | std::string obj_str, std::string ir_str, std::string bc_str); |
50 | |
51 | /*! |
52 | \brief Module implementation for compiled Hexagon binaries. It is suitable |
53 | for managing cross-compiled Hexagon code on a host machine. |
54 | See docstring for HexagonModuleCreate for |
55 | construction parameter details. |
56 | */ |
57 | class HexagonModuleNode : public runtime::ModuleNode { |
58 | public: |
59 | HexagonModuleNode(std::string data, std::string fmt, |
60 | std::unordered_map<std::string, FunctionInfo> fmap, std::string asm_str, |
61 | std::string obj_str, std::string ir_str, std::string bc_str); |
62 | PackedFunc GetFunction(const std::string& name, const ObjectPtr<Object>& sptr_to_self) override; |
63 | std::string GetSource(const std::string& format) override; |
64 | const char* type_key() const final { return "hexagon" ; } |
65 | void SaveToFile(const std::string& file_name, const std::string& format) override; |
66 | void SaveToBinary(dmlc::Stream* stream) override; |
67 | |
68 | protected: |
69 | std::string data_; |
70 | std::string fmt_; |
71 | std::unordered_map<std::string, FunctionInfo> fmap_; |
72 | std::string asm_; |
73 | std::string obj_; |
74 | std::string ir_; |
75 | std::string bc_; |
76 | }; |
77 | |
78 | } // namespace runtime |
79 | } // namespace tvm |
80 | #endif // TVM_RUNTIME_HEXAGON_HEXAGON_MODULE_H_ |
81 | |