aot_llvm.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #ifndef _AOT_LLVM_H_
  6. #define _AOT_LLVM_H_
  7. #include "aot.h"
  8. #include "llvm/Config/llvm-config.h"
  9. #include "llvm-c/Types.h"
  10. #include "llvm-c/Target.h"
  11. #include "llvm-c/Core.h"
  12. #include "llvm-c/Object.h"
  13. #include "llvm-c/OrcEE.h"
  14. #include "llvm-c/ExecutionEngine.h"
  15. #include "llvm-c/Analysis.h"
  16. #include "llvm-c/BitWriter.h"
  17. #if LLVM_VERSION_MAJOR < 17
  18. #include "llvm-c/Transforms/Utils.h"
  19. #include "llvm-c/Transforms/Scalar.h"
  20. #include "llvm-c/Transforms/Vectorize.h"
  21. #include "llvm-c/Transforms/PassManagerBuilder.h"
  22. #include "llvm-c/Initialization.h"
  23. #endif
  24. #include "llvm-c/Orc.h"
  25. #include "llvm-c/Error.h"
  26. #include "llvm-c/Support.h"
  27. #include "llvm-c/TargetMachine.h"
  28. #include "llvm-c/LLJIT.h"
  29. #if WASM_ENABLE_DEBUG_AOT != 0
  30. #include "llvm-c/DebugInfo.h"
  31. #endif
  32. #include "aot_orc_extra.h"
  33. #include "aot_comp_option.h"
  34. #if defined(_WIN32) || defined(_WIN32_)
  35. #include <io.h>
  36. #define access _access
  37. /* On windows there is no X_OK flag to check for executablity, only check for
  38. * existence */
  39. #ifdef X_OK
  40. #undef X_OK
  41. #endif
  42. #define X_OK 00
  43. #define unlink _unlink
  44. #endif
  45. #ifdef __cplusplus
  46. extern "C" {
  47. #endif
  48. #if LLVM_VERSION_MAJOR < 14
  49. #define LLVMBuildLoad2(builder, type, value, name) \
  50. LLVMBuildLoad(builder, value, name)
  51. #define LLVMBuildCall2(builder, type, func, args, num_args, name) \
  52. LLVMBuildCall(builder, func, args, num_args, name)
  53. #define LLVMBuildInBoundsGEP2(builder, type, ptr, indices, num_indices, name) \
  54. LLVMBuildInBoundsGEP(builder, ptr, indices, num_indices, name)
  55. #else
  56. /* Opaque pointer type */
  57. #define OPQ_PTR_TYPE INT8_PTR_TYPE
  58. #endif
  59. #ifndef NDEBUG
  60. #undef DEBUG_PASS
  61. #undef DUMP_MODULE
  62. // #define DEBUG_PASS
  63. // #define DUMP_MODULE
  64. #else
  65. #undef DEBUG_PASS
  66. #undef DUMP_MODULE
  67. #endif
  68. struct AOTValueSlot;
  69. /**
  70. * Value in the WASM operation stack, each stack element
  71. * is an LLVM value
  72. */
  73. typedef struct AOTValue {
  74. struct AOTValue *next;
  75. struct AOTValue *prev;
  76. LLVMValueRef value;
  77. uint64 const_value; /* valid if is_const is true */
  78. uint32 local_idx;
  79. /* VALUE_TYPE_I32/I64/F32/F64/VOID */
  80. uint8 type;
  81. bool is_local;
  82. bool is_const;
  83. } AOTValue;
  84. /**
  85. * Value stack, represents stack elements in a WASM block
  86. */
  87. typedef struct AOTValueStack {
  88. AOTValue *value_list_head;
  89. AOTValue *value_list_end;
  90. } AOTValueStack;
  91. /* Record information of a value slot of local variable or stack
  92. during translation */
  93. typedef struct AOTValueSlot {
  94. /* The LLVM value of this slot */
  95. LLVMValueRef value;
  96. /* The value type of this slot */
  97. uint8 type;
  98. /* The dirty bit of the value slot. It's set if the value in
  99. register is newer than the value in memory. */
  100. uint32 dirty : 1;
  101. /* Whether the new value in register is a reference, which is valid
  102. only when the dirty bit is set. */
  103. uint32 ref : 1;
  104. /* Committed reference flag:
  105. 0: uncommitted, 1: not-reference, 2: reference */
  106. uint32 committed_ref : 2;
  107. } AOTValueSlot;
  108. /* Frame information for translation */
  109. typedef struct AOTCompFrame {
  110. /* The current compilation context */
  111. struct AOTCompContext *comp_ctx;
  112. /* The current function context */
  113. struct AOTFuncContext *func_ctx;
  114. /* The current instruction pointer which is being compiled */
  115. const uint8 *frame_ip;
  116. /* Max local slot number */
  117. uint32 max_local_cell_num;
  118. /* Max operand stack slot number */
  119. uint32 max_stack_cell_num;
  120. /* Size of current AOTFrame/WASMInterpFrame */
  121. uint32 cur_frame_size;
  122. /* Stack top pointer */
  123. AOTValueSlot *sp;
  124. /* Local variables + stack operands */
  125. AOTValueSlot lp[1];
  126. } AOTCompFrame;
  127. typedef struct AOTBlock {
  128. struct AOTBlock *next;
  129. struct AOTBlock *prev;
  130. /* Block index */
  131. uint32 block_index;
  132. /* LABEL_TYPE_BLOCK/LOOP/IF/FUNCTION */
  133. uint32 label_type;
  134. /* Whether it is reachable */
  135. bool is_reachable;
  136. /* Whether skip translation of wasm else branch */
  137. bool skip_wasm_code_else;
  138. /* code of else opcode of this block, if it is a IF block */
  139. uint8 *wasm_code_else;
  140. /* code end of this block */
  141. uint8 *wasm_code_end;
  142. /* LLVM label points to code begin */
  143. LLVMBasicBlockRef llvm_entry_block;
  144. /* LLVM label points to code else */
  145. LLVMBasicBlockRef llvm_else_block;
  146. /* LLVM label points to code end */
  147. LLVMBasicBlockRef llvm_end_block;
  148. /* WASM operation stack */
  149. AOTValueStack value_stack;
  150. /* Param count/types/PHIs of this block */
  151. uint32 param_count;
  152. uint8 *param_types;
  153. LLVMValueRef *param_phis;
  154. LLVMValueRef *else_param_phis;
  155. /* Result count/types/PHIs of this block */
  156. uint32 result_count;
  157. uint8 *result_types;
  158. LLVMValueRef *result_phis;
  159. /* The begin frame stack pointer of this block */
  160. AOTValueSlot *frame_sp_begin;
  161. /* The max frame stack pointer that br/br_if/br_table/br_on_xxx
  162. opcodes ever reached when they jumped to the end this block */
  163. AOTValueSlot *frame_sp_max_reached;
  164. } AOTBlock;
  165. /**
  166. * Block stack, represents WASM block stack elements
  167. */
  168. typedef struct AOTBlockStack {
  169. AOTBlock *block_list_head;
  170. AOTBlock *block_list_end;
  171. /* Current block index of each block type */
  172. uint32 block_index[3];
  173. } AOTBlockStack;
  174. typedef struct AOTCheckedAddr {
  175. struct AOTCheckedAddr *next;
  176. uint32 local_idx;
  177. uint64 offset;
  178. uint32 bytes;
  179. } AOTCheckedAddr, *AOTCheckedAddrList;
  180. typedef struct AOTMemInfo {
  181. LLVMValueRef mem_base_addr;
  182. LLVMValueRef mem_data_size_addr;
  183. LLVMValueRef mem_cur_page_count_addr;
  184. LLVMValueRef mem_bound_check_1byte;
  185. LLVMValueRef mem_bound_check_2bytes;
  186. LLVMValueRef mem_bound_check_4bytes;
  187. LLVMValueRef mem_bound_check_8bytes;
  188. LLVMValueRef mem_bound_check_16bytes;
  189. } AOTMemInfo;
  190. typedef struct AOTFuncContext {
  191. AOTFunc *aot_func;
  192. LLVMValueRef func;
  193. LLVMValueRef precheck_func;
  194. LLVMTypeRef func_type;
  195. LLVMModuleRef module;
  196. AOTBlockStack block_stack;
  197. LLVMValueRef exec_env;
  198. LLVMValueRef aot_inst;
  199. LLVMValueRef argv_buf;
  200. LLVMValueRef native_stack_bound;
  201. LLVMValueRef native_stack_top_min_addr;
  202. LLVMValueRef aux_stack_bound;
  203. LLVMValueRef aux_stack_bottom;
  204. LLVMValueRef native_symbol;
  205. LLVMValueRef func_ptrs;
  206. AOTMemInfo *mem_info;
  207. LLVMValueRef cur_exception;
  208. LLVMValueRef cur_frame;
  209. LLVMValueRef cur_frame_ptr;
  210. LLVMValueRef wasm_stack_top_bound;
  211. LLVMValueRef wasm_stack_top_ptr;
  212. bool mem_space_unchanged;
  213. AOTCheckedAddrList checked_addr_list;
  214. /* The last accessed shared heap info */
  215. LLVMValueRef shared_heap_base_addr_adj;
  216. LLVMValueRef shared_heap_start_off;
  217. LLVMValueRef shared_heap_end_off;
  218. /* The start offset of the head of shared heap chain */
  219. LLVMValueRef shared_heap_head_start_off;
  220. LLVMBasicBlockRef got_exception_block;
  221. LLVMBasicBlockRef func_return_block;
  222. LLVMValueRef exception_id_phi;
  223. /* current ip when exception is thrown */
  224. LLVMValueRef exception_ip_phi;
  225. LLVMValueRef func_type_indexes;
  226. #if WASM_ENABLE_DEBUG_AOT != 0
  227. LLVMMetadataRef debug_func;
  228. #endif
  229. #if WASM_ENABLE_BRANCH_HINTS != 0
  230. struct WASMCompilationHint *function_hints;
  231. #endif
  232. unsigned int stack_consumption_for_func_call;
  233. LLVMValueRef locals[1];
  234. } AOTFuncContext;
  235. typedef struct AOTLLVMTypes {
  236. LLVMTypeRef int1_type;
  237. LLVMTypeRef int8_type;
  238. LLVMTypeRef int16_type;
  239. LLVMTypeRef int32_type;
  240. LLVMTypeRef int64_type;
  241. LLVMTypeRef intptr_t_type;
  242. LLVMTypeRef size_t_type;
  243. LLVMTypeRef float32_type;
  244. LLVMTypeRef float64_type;
  245. LLVMTypeRef void_type;
  246. LLVMTypeRef int8_ptr_type;
  247. LLVMTypeRef int8_pptr_type;
  248. LLVMTypeRef int16_ptr_type;
  249. LLVMTypeRef int32_ptr_type;
  250. LLVMTypeRef int64_ptr_type;
  251. LLVMTypeRef intptr_t_ptr_type;
  252. LLVMTypeRef float32_ptr_type;
  253. LLVMTypeRef float64_ptr_type;
  254. LLVMTypeRef v128_type;
  255. LLVMTypeRef v128_ptr_type;
  256. LLVMTypeRef i8x16_vec_type;
  257. LLVMTypeRef i16x8_vec_type;
  258. LLVMTypeRef i32x4_vec_type;
  259. LLVMTypeRef i64x2_vec_type;
  260. LLVMTypeRef f32x4_vec_type;
  261. LLVMTypeRef f64x2_vec_type;
  262. LLVMTypeRef int8_ptr_type_gs;
  263. LLVMTypeRef int16_ptr_type_gs;
  264. LLVMTypeRef int32_ptr_type_gs;
  265. LLVMTypeRef int64_ptr_type_gs;
  266. LLVMTypeRef float32_ptr_type_gs;
  267. LLVMTypeRef float64_ptr_type_gs;
  268. LLVMTypeRef v128_ptr_type_gs;
  269. LLVMTypeRef i1x2_vec_type;
  270. LLVMTypeRef meta_data_type;
  271. LLVMTypeRef funcref_type;
  272. LLVMTypeRef externref_type;
  273. LLVMTypeRef gc_ref_type;
  274. LLVMTypeRef gc_ref_ptr_type;
  275. } AOTLLVMTypes;
  276. typedef struct AOTLLVMConsts {
  277. LLVMValueRef i1_zero;
  278. LLVMValueRef i1_one;
  279. LLVMValueRef i8_zero;
  280. LLVMValueRef i8_one;
  281. LLVMValueRef i32_zero;
  282. LLVMValueRef i64_zero;
  283. LLVMValueRef f32_zero;
  284. LLVMValueRef f64_zero;
  285. LLVMValueRef i32_one;
  286. LLVMValueRef i32_two;
  287. LLVMValueRef i32_three;
  288. LLVMValueRef i32_four;
  289. LLVMValueRef i32_five;
  290. LLVMValueRef i32_six;
  291. LLVMValueRef i32_seven;
  292. LLVMValueRef i32_eight;
  293. LLVMValueRef i32_nine;
  294. LLVMValueRef i32_ten;
  295. LLVMValueRef i32_eleven;
  296. LLVMValueRef i32_twelve;
  297. LLVMValueRef i32_thirteen;
  298. LLVMValueRef i32_fourteen;
  299. LLVMValueRef i32_fifteen;
  300. LLVMValueRef i32_neg_one;
  301. LLVMValueRef i64_neg_one;
  302. LLVMValueRef i32_min;
  303. LLVMValueRef i64_min;
  304. LLVMValueRef i32_31;
  305. LLVMValueRef i32_32;
  306. LLVMValueRef i64_63;
  307. LLVMValueRef i64_64;
  308. LLVMValueRef i8x16_vec_zero;
  309. LLVMValueRef i16x8_vec_zero;
  310. LLVMValueRef i32x4_vec_zero;
  311. LLVMValueRef i64x2_vec_zero;
  312. LLVMValueRef f32x4_vec_zero;
  313. LLVMValueRef f64x2_vec_zero;
  314. LLVMValueRef i8x16_undef;
  315. LLVMValueRef i16x8_undef;
  316. LLVMValueRef i32x4_undef;
  317. LLVMValueRef i64x2_undef;
  318. LLVMValueRef f32x4_undef;
  319. LLVMValueRef f64x2_undef;
  320. LLVMValueRef i32x16_zero;
  321. LLVMValueRef i32x8_zero;
  322. LLVMValueRef i32x4_zero;
  323. LLVMValueRef i32x2_zero;
  324. LLVMValueRef gc_ref_null;
  325. LLVMValueRef i8_ptr_null;
  326. } AOTLLVMConsts;
  327. /**
  328. * Compiler context
  329. */
  330. typedef struct AOTCompContext {
  331. const AOTCompData *comp_data;
  332. /* LLVM variables required to emit LLVM IR */
  333. LLVMContextRef context;
  334. LLVMBuilderRef builder;
  335. #if WASM_ENABLE_DEBUG_AOT
  336. LLVMDIBuilderRef debug_builder;
  337. LLVMMetadataRef debug_file;
  338. LLVMMetadataRef debug_comp_unit;
  339. #endif
  340. LLVMTargetMachineRef target_machine;
  341. char *target_cpu;
  342. char target_arch[16];
  343. unsigned pointer_size;
  344. /* Hardware intrinsic compatibility flags */
  345. uint64 flags[8];
  346. /* required by JIT */
  347. LLVMOrcLLLazyJITRef orc_jit;
  348. LLVMOrcThreadSafeContextRef orc_thread_safe_context;
  349. LLVMModuleRef module;
  350. bool is_jit_mode;
  351. /* AOT indirect mode flag & symbol list */
  352. bool is_indirect_mode;
  353. bh_list native_symbols;
  354. /* Bulk memory feature */
  355. bool enable_bulk_memory;
  356. /* Boundary Check */
  357. bool enable_bound_check;
  358. /* Native stack boundary Check */
  359. bool enable_stack_bound_check;
  360. /* Native stack usage estimation */
  361. bool enable_stack_estimation;
  362. /* 128-bit SIMD */
  363. bool enable_simd;
  364. /* Auxiliary stack overflow/underflow check */
  365. bool enable_aux_stack_check;
  366. /* Generate auxiliary stack frame */
  367. AOTStackFrameType aux_stack_frame_type;
  368. /* Auxiliary call stack features */
  369. AOTCallStackFeatures call_stack_features;
  370. /* Function performance profiling */
  371. bool enable_perf_profiling;
  372. /* Memory usage profiling */
  373. bool enable_memory_profiling;
  374. /* Thread Manager */
  375. bool enable_thread_mgr;
  376. /* Tail Call */
  377. bool enable_tail_call;
  378. /* Reference Types */
  379. bool enable_ref_types;
  380. /* Disable LLVM built-in intrinsics */
  381. bool disable_llvm_intrinsics;
  382. /* Disable LLVM jump tables */
  383. bool disable_llvm_jump_tables;
  384. /* Disable LLVM link time optimization */
  385. bool disable_llvm_lto;
  386. /* Enable LLVM PGO (Profile-Guided Optimization) */
  387. bool enable_llvm_pgo;
  388. /* Enable extended constant expression */
  389. bool enable_extended_const;
  390. /* Treat unknown import function as wasm-c-api import function
  391. and allow to directly invoke it from AOT/JIT code */
  392. bool quick_invoke_c_api_import;
  393. /* Use profile file collected by LLVM PGO */
  394. char *use_prof_file;
  395. /* Enable to use segment register as the base addr
  396. of linear memory for load/store operations */
  397. bool enable_segue_i32_load;
  398. bool enable_segue_i64_load;
  399. bool enable_segue_f32_load;
  400. bool enable_segue_f64_load;
  401. bool enable_segue_v128_load;
  402. bool enable_segue_i32_store;
  403. bool enable_segue_i64_store;
  404. bool enable_segue_f32_store;
  405. bool enable_segue_f64_store;
  406. bool enable_segue_v128_store;
  407. /* Whether optimize the JITed code */
  408. bool optimize;
  409. bool emit_frame_pointer;
  410. /* Enable GC */
  411. bool enable_gc;
  412. bool enable_shared_heap;
  413. bool enable_shared_chain;
  414. uint32 opt_level;
  415. uint32 size_level;
  416. /* LLVM floating-point rounding mode metadata */
  417. LLVMValueRef fp_rounding_mode;
  418. /* LLVM floating-point exception behavior metadata */
  419. LLVMValueRef fp_exception_behavior;
  420. /* a global array to store stack sizes */
  421. LLVMTypeRef stack_sizes_type;
  422. LLVMValueRef stack_sizes;
  423. uint32 *jit_stack_sizes; /* for JIT */
  424. /* LLVM data types */
  425. AOTLLVMTypes basic_types;
  426. LLVMTypeRef exec_env_type;
  427. LLVMTypeRef aot_inst_type;
  428. /* LLVM const values */
  429. AOTLLVMConsts llvm_consts;
  430. /* Function contexts */
  431. AOTFuncContext **func_ctxes;
  432. uint32 func_ctx_count;
  433. char **custom_sections_wp;
  434. uint32 custom_sections_count;
  435. /* 3rd-party toolchains */
  436. /* External llc compiler, if specified, wamrc will emit the llvm-ir file and
  437. * invoke the llc compiler to generate object file.
  438. * This can be used when we want to benefit from the optimization of other
  439. * LLVM based toolchains */
  440. const char *external_llc_compiler;
  441. const char *llc_compiler_flags;
  442. /* External asm compiler, if specified, wamrc will emit the text-based
  443. * assembly file (.s) and invoke the llc compiler to generate object file.
  444. * This will be useful when the upstream LLVM doesn't support to emit object
  445. * file for some architecture (such as arc) */
  446. const char *external_asm_compiler;
  447. const char *asm_compiler_flags;
  448. const char *stack_usage_file;
  449. char stack_usage_temp_file[64];
  450. const char *llvm_passes;
  451. const char *builtin_intrinsics;
  452. /* Current frame information for translation */
  453. AOTCompFrame *aot_frame;
  454. } AOTCompContext;
  455. enum {
  456. AOT_FORMAT_FILE,
  457. AOT_OBJECT_FILE,
  458. AOT_LLVMIR_UNOPT_FILE,
  459. AOT_LLVMIR_OPT_FILE,
  460. };
  461. bool
  462. aot_compiler_init(void);
  463. void
  464. aot_compiler_destroy(void);
  465. AOTCompContext *
  466. aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option);
  467. void
  468. aot_destroy_comp_context(AOTCompContext *comp_ctx);
  469. int32
  470. aot_get_native_symbol_index(AOTCompContext *comp_ctx, const char *symbol);
  471. bool
  472. aot_compile_wasm(AOTCompContext *comp_ctx);
  473. uint8 *
  474. aot_emit_elf_file(AOTCompContext *comp_ctx, uint32 *p_elf_file_size);
  475. void
  476. aot_destroy_elf_file(uint8 *elf_file);
  477. void
  478. aot_value_stack_push(const AOTCompContext *comp_ctx, AOTValueStack *stack,
  479. AOTValue *value);
  480. AOTValue *
  481. aot_value_stack_pop(const AOTCompContext *comp_ctx, AOTValueStack *stack);
  482. void
  483. aot_value_stack_destroy(AOTCompContext *comp_ctx, AOTValueStack *stack);
  484. void
  485. aot_block_stack_push(AOTBlockStack *stack, AOTBlock *block);
  486. AOTBlock *
  487. aot_block_stack_pop(AOTBlockStack *stack);
  488. void
  489. aot_block_stack_destroy(AOTCompContext *comp_ctx, AOTBlockStack *stack);
  490. void
  491. aot_block_destroy(AOTCompContext *comp_ctx, AOTBlock *block);
  492. LLVMTypeRef
  493. wasm_type_to_llvm_type(const AOTCompContext *comp_ctx,
  494. const AOTLLVMTypes *llvm_types, uint8 wasm_type);
  495. bool
  496. aot_checked_addr_list_add(AOTFuncContext *func_ctx, uint32 local_idx,
  497. uint64 offset, uint32 bytes);
  498. void
  499. aot_checked_addr_list_del(AOTFuncContext *func_ctx, uint32 local_idx);
  500. bool
  501. aot_checked_addr_list_find(AOTFuncContext *func_ctx, uint32 local_idx,
  502. uint64 offset, uint32 bytes);
  503. void
  504. aot_checked_addr_list_destroy(AOTFuncContext *func_ctx);
  505. bool
  506. aot_build_zero_function_ret(const AOTCompContext *comp_ctx,
  507. AOTFuncContext *func_ctx, AOTFuncType *func_type);
  508. LLVMValueRef
  509. aot_call_llvm_intrinsic(const AOTCompContext *comp_ctx,
  510. const AOTFuncContext *func_ctx, const char *intrinsic,
  511. LLVMTypeRef ret_type, LLVMTypeRef *param_types,
  512. int param_count, ...);
  513. LLVMValueRef
  514. aot_call_llvm_intrinsic_v(const AOTCompContext *comp_ctx,
  515. const AOTFuncContext *func_ctx, const char *intrinsic,
  516. LLVMTypeRef ret_type, LLVMTypeRef *param_types,
  517. int param_count, va_list param_value_list);
  518. LLVMValueRef
  519. aot_get_func_from_table(const AOTCompContext *comp_ctx, LLVMValueRef base,
  520. LLVMTypeRef func_type, int32 index);
  521. LLVMValueRef
  522. aot_load_const_from_table(AOTCompContext *comp_ctx, LLVMValueRef base,
  523. const WASMValue *value, uint8 value_type);
  524. bool
  525. aot_check_simd_compatibility(const char *arch_c_str, const char *cpu_c_str);
  526. void
  527. aot_apply_llvm_new_pass_manager(AOTCompContext *comp_ctx, LLVMModuleRef module);
  528. void
  529. aot_handle_llvm_errmsg(const char *string, LLVMErrorRef err);
  530. char *
  531. aot_compress_aot_func_names(AOTCompContext *comp_ctx, uint32 *p_size);
  532. bool
  533. aot_set_cond_br_weights(AOTCompContext *comp_ctx, LLVMValueRef cond_br,
  534. int32 weights_true, int32 weights_false);
  535. bool
  536. aot_target_precheck_can_use_musttail(const AOTCompContext *comp_ctx);
  537. unsigned int
  538. aot_estimate_stack_usage_for_function_call(const AOTCompContext *comp_ctx,
  539. const AOTFuncType *callee_func_type);
  540. #ifdef __cplusplus
  541. } /* end of extern "C" */
  542. #endif
  543. #endif /* end of _AOT_LLVM_H_ */