summaryrefslogtreecommitdiffstats
path: root/src/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/core/iwasm/fast-jit/jit_codegen.h
blob: 735cddab62479f213248671e444477a444150986 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
 * Copyright (C) 2021 Intel Corporation.  All rights reserved.
 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 */

#ifndef _JIT_CODEGEN_H_
#define _JIT_CODEGEN_H_

#include "bh_platform.h"
#include "jit_compiler.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
 * Initialize codegen module, such as instruction encoder.
 *
 * @return true if succeeded; false if failed.
 */
bool
jit_codegen_init();

/**
 * Destroy codegen module, such as instruction encoder.
 */
void
jit_codegen_destroy();

/**
 * Get hard register information of each kind.
 *
 * @return the JitHardRegInfo array of each kind
 */
const JitHardRegInfo *
jit_codegen_get_hreg_info();

/**
 * Get hard register by name.
 *
 * @param name the name of the hard register
 *
 * @return the hard register of the name
 */
JitReg
jit_codegen_get_hreg_by_name(const char *name);

/**
 * Generate native code for the given compilation context
 *
 * @param cc the compilation context that is ready to do codegen
 *
 * @return true if succeeds, false otherwise
 */
bool
jit_codegen_gen_native(JitCompContext *cc);

/**
 * lower unsupported operations to supported ones for the target.
 *
 * @param cc the compilation context that is ready to do codegen
 *
 * @return true if succeeds, false otherwise
 */
bool
jit_codegen_lower(JitCompContext *cc);

#if WASM_ENABLE_LAZY_JIT != 0 && WASM_ENABLE_JIT != 0
void *
jit_codegen_compile_call_to_llvm_jit(const WASMType *func_type);

void *
jit_codegen_compile_call_to_fast_jit(const WASMModule *module, uint32 func_idx);
#endif

/**
 * Dump native code in the given range to assembly.
 *
 * @param begin_addr begin address of the native code
 * @param end_addr end address of the native code
 */
void
jit_codegen_dump_native(void *begin_addr, void *end_addr);

int
jit_codegen_interp_jitted_glue(void *self, JitInterpSwitchInfo *info,
                               uint32 func_idx, void *pc);

#ifdef __cplusplus
}
#endif

#endif /* end of _JIT_CODEGEN_H_ */