/src/WasmEdge/include/llvm/compiler.h
Line | Count | Source |
1 | | // SPDX-License-Identifier: Apache-2.0 |
2 | | // SPDX-FileCopyrightText: 2019-2024 Second State INC |
3 | | |
4 | | //===-- wasmedge/llvm/compiler.h - Compiler class definition --------------===// |
5 | | // |
6 | | // Part of the WasmEdge Project. |
7 | | // |
8 | | //===----------------------------------------------------------------------===// |
9 | | /// |
10 | | /// \file |
11 | | /// This file is the definition class of Compiler class. |
12 | | /// |
13 | | //===----------------------------------------------------------------------===// |
14 | | #pragma once |
15 | | |
16 | | #include "ast/module.h" |
17 | | #include "common/configure.h" |
18 | | #include "common/errcode.h" |
19 | | #include "common/filesystem.h" |
20 | | #include "common/span.h" |
21 | | #include "llvm/data.h" |
22 | | |
23 | | #include <mutex> |
24 | | |
25 | | namespace WasmEdge::LLVM { |
26 | | |
27 | | /// Compiling Module into LLVM Module. |
28 | | class Compiler { |
29 | | public: |
30 | 2.14k | Compiler(const Configure &Conf) noexcept : Context(nullptr), Conf(Conf) {} |
31 | | |
32 | | Expect<void> checkConfigure() noexcept; |
33 | | |
34 | | Expect<Data> compile(const AST::Module &Module) noexcept; |
35 | | |
36 | | struct CompileContext; |
37 | | |
38 | | private: |
39 | | void compile(const AST::ImportSection &ImportSection) noexcept; |
40 | | void compile(const AST::ExportSection &ExportSection) noexcept; |
41 | | void compile(const AST::TypeSection &TypeSection) noexcept; |
42 | | void compile(const AST::GlobalSection &GlobalSection) noexcept; |
43 | | void compile(const AST::MemorySection &MemorySection, |
44 | | const AST::DataSection &DataSection) noexcept; |
45 | | void compile(const AST::TableSection &TableSection, |
46 | | const AST::ElementSection &ElementSection) noexcept; |
47 | | void compile(const AST::FunctionSection &FunctionSection, |
48 | | const AST::CodeSection &CodeSection) noexcept; |
49 | | |
50 | | std::mutex Mutex; |
51 | | CompileContext *Context; |
52 | | const Configure Conf; |
53 | | }; |
54 | | |
55 | | } // namespace WasmEdge::LLVM |