1 | // x86 backend implementation |
2 | |
3 | #pragma once |
4 | |
5 | #include <memory> |
6 | |
7 | #include "taichi/codegen/codegen.h" |
8 | #include "taichi/codegen/llvm/codegen_llvm.h" |
9 | |
10 | namespace taichi::lang { |
11 | |
12 | class KernelCodeGenCPU : public KernelCodeGen { |
13 | public: |
14 | explicit KernelCodeGenCPU(const CompileConfig &compile_config, |
15 | Kernel *kernel, |
16 | TaichiLLVMContext &tlctx) |
17 | : KernelCodeGen(compile_config, kernel, tlctx) { |
18 | } |
19 | |
20 | // TODO: Stop defining this macro guards in the headers |
21 | #ifdef TI_WITH_LLVM |
22 | bool supports_offline_cache() const override { |
23 | return true; |
24 | } |
25 | LLVMCompiledTask compile_task( |
26 | const CompileConfig &config, |
27 | std::unique_ptr<llvm::Module> &&module = nullptr, |
28 | OffloadedStmt *stmt = nullptr) override; |
29 | |
30 | #endif // TI_WITH_LLVM |
31 | |
32 | FunctionType compile_to_function() override; |
33 | }; |
34 | |
35 | #ifdef TI_WITH_LLVM |
36 | |
37 | class CPUModuleToFunctionConverter : public ModuleToFunctionConverter { |
38 | public: |
39 | explicit CPUModuleToFunctionConverter(TaichiLLVMContext *tlctx, |
40 | LlvmRuntimeExecutor *executor) |
41 | : ModuleToFunctionConverter(tlctx, executor) { |
42 | } |
43 | |
44 | using ModuleToFunctionConverter::convert; |
45 | |
46 | FunctionType convert(const std::string &kernel_name, |
47 | const std::vector<LlvmLaunchArgInfo> &args, |
48 | LLVMCompiledKernel data) const override; |
49 | }; |
50 | |
51 | #endif |
52 | |
53 | } // namespace taichi::lang |
54 | |