1 | #pragma once |
2 | |
3 | // Codegen for the hierarchical data structure (LLVM) |
4 | #include "taichi/runtime/program_impls/llvm/llvm_program.h" |
5 | #include "taichi/codegen/llvm/llvm_codegen_utils.h" |
6 | #include "taichi/struct/struct.h" |
7 | |
8 | namespace taichi::lang { |
9 | |
10 | class LlvmProgramImpl; |
11 | class StructCompilerLLVM : public StructCompiler, public LLVMModuleBuilder { |
12 | public: |
13 | StructCompilerLLVM(Arch arch, |
14 | const CompileConfig &config, |
15 | TaichiLLVMContext *tlctx, |
16 | std::unique_ptr<llvm::Module> &&module, |
17 | int snode_tree_id); |
18 | |
19 | StructCompilerLLVM(Arch arch, |
20 | LlvmProgramImpl *prog, |
21 | std::unique_ptr<llvm::Module> &&module, |
22 | int snode_tree_id); |
23 | |
24 | void generate_types(SNode &snode) override; |
25 | |
26 | void generate_child_accessors(SNode &snode) override; |
27 | |
28 | void run(SNode &node) override; |
29 | |
30 | llvm::Function *create_function(llvm::FunctionType *ft, |
31 | std::string func_name); |
32 | |
33 | void generate_refine_coordinates(SNode *snode); |
34 | |
35 | static std::string type_stub_name(SNode *snode); |
36 | |
37 | static llvm::Type *get_stub(llvm::Module *module, SNode *snode, uint32 index); |
38 | |
39 | static llvm::Type *get_llvm_node_type(llvm::Module *module, SNode *snode); |
40 | |
41 | static llvm::Type *get_llvm_body_type(llvm::Module *module, SNode *snode); |
42 | |
43 | static llvm::Type *get_llvm_aux_type(llvm::Module *module, SNode *snode); |
44 | |
45 | static llvm::Type *get_llvm_element_type(llvm::Module *module, SNode *snode); |
46 | |
47 | private: |
48 | Arch arch_; |
49 | const CompileConfig &config_; |
50 | TaichiLLVMContext *const tlctx_; |
51 | llvm::LLVMContext *const llvm_ctx_; |
52 | int snode_tree_id_; |
53 | }; |
54 | |
55 | } // namespace taichi::lang |
56 | |