mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-14 13:41:31 +00:00
core/iwasm/compilation: constify a bit (#2223)
Just to make the code a bit easier to read.
This commit is contained in:
parent
d692878484
commit
670567f8b3
|
@ -112,7 +112,7 @@ static bool
|
||||||
compile_global(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
compile_global(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||||
uint32 global_idx, bool is_set, bool is_aux_stack)
|
uint32 global_idx, bool is_set, bool is_aux_stack)
|
||||||
{
|
{
|
||||||
AOTCompData *comp_data = comp_ctx->comp_data;
|
const AOTCompData *comp_data = comp_ctx->comp_data;
|
||||||
uint32 import_global_count = comp_data->import_global_count;
|
uint32 import_global_count = comp_data->import_global_count;
|
||||||
uint32 global_base_offset;
|
uint32 global_base_offset;
|
||||||
uint32 global_offset;
|
uint32 global_offset;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LLVMTypeRef
|
LLVMTypeRef
|
||||||
wasm_type_to_llvm_type(AOTLLVMTypes *llvm_types, uint8 wasm_type)
|
wasm_type_to_llvm_type(const AOTLLVMTypes *llvm_types, uint8 wasm_type)
|
||||||
{
|
{
|
||||||
switch (wasm_type) {
|
switch (wasm_type) {
|
||||||
case VALUE_TYPE_I32:
|
case VALUE_TYPE_I32:
|
||||||
|
@ -42,8 +42,8 @@ wasm_type_to_llvm_type(AOTLLVMTypes *llvm_types, uint8 wasm_type)
|
||||||
* Add LLVM function
|
* Add LLVM function
|
||||||
*/
|
*/
|
||||||
static LLVMValueRef
|
static LLVMValueRef
|
||||||
aot_add_llvm_func(AOTCompContext *comp_ctx, LLVMModuleRef module,
|
aot_add_llvm_func(const AOTCompContext *comp_ctx, LLVMModuleRef module,
|
||||||
AOTFuncType *aot_func_type, uint32 func_index,
|
const AOTFuncType *aot_func_type, uint32 func_index,
|
||||||
LLVMTypeRef *p_func_type)
|
LLVMTypeRef *p_func_type)
|
||||||
{
|
{
|
||||||
LLVMValueRef func = NULL;
|
LLVMValueRef func = NULL;
|
||||||
|
@ -177,8 +177,9 @@ free_block_memory(AOTBlock *block)
|
||||||
* Create first AOTBlock, or function block for the function
|
* Create first AOTBlock, or function block for the function
|
||||||
*/
|
*/
|
||||||
static AOTBlock *
|
static AOTBlock *
|
||||||
aot_create_func_block(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
aot_create_func_block(const AOTCompContext *comp_ctx,
|
||||||
AOTFunc *func, AOTFuncType *aot_func_type)
|
const AOTFuncContext *func_ctx, const AOTFunc *func,
|
||||||
|
const AOTFuncType *aot_func_type)
|
||||||
{
|
{
|
||||||
AOTBlock *aot_block;
|
AOTBlock *aot_block;
|
||||||
uint32 param_count = aot_func_type->param_count,
|
uint32 param_count = aot_func_type->param_count,
|
||||||
|
@ -266,7 +267,8 @@ create_argv_buf(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
create_native_stack_bound(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
create_native_stack_bound(const AOTCompContext *comp_ctx,
|
||||||
|
AOTFuncContext *func_ctx)
|
||||||
{
|
{
|
||||||
LLVMValueRef stack_bound_offset = I32_FOUR, stack_bound_addr;
|
LLVMValueRef stack_bound_offset = I32_FOUR, stack_bound_addr;
|
||||||
|
|
||||||
|
@ -288,7 +290,8 @@ create_native_stack_bound(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
create_native_stack_top_min(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
create_native_stack_top_min(const AOTCompContext *comp_ctx,
|
||||||
|
AOTFuncContext *func_ctx)
|
||||||
{
|
{
|
||||||
LLVMValueRef offset = I32_NINE;
|
LLVMValueRef offset = I32_NINE;
|
||||||
|
|
||||||
|
@ -303,7 +306,7 @@ create_native_stack_top_min(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
create_aux_stack_info(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
create_aux_stack_info(const AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||||
{
|
{
|
||||||
LLVMValueRef aux_stack_bound_offset = I32_SIX, aux_stack_bound_addr;
|
LLVMValueRef aux_stack_bound_offset = I32_SIX, aux_stack_bound_addr;
|
||||||
LLVMValueRef aux_stack_bottom_offset = I32_SEVEN, aux_stack_bottom_addr;
|
LLVMValueRef aux_stack_bottom_offset = I32_SEVEN, aux_stack_bottom_addr;
|
||||||
|
@ -355,7 +358,7 @@ create_aux_stack_info(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
create_native_symbol(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
create_native_symbol(const AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||||
{
|
{
|
||||||
LLVMValueRef native_symbol_offset = I32_EIGHT, native_symbol_addr;
|
LLVMValueRef native_symbol_offset = I32_EIGHT, native_symbol_addr;
|
||||||
|
|
||||||
|
@ -384,8 +387,9 @@ create_native_symbol(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
create_local_variables(AOTCompData *comp_data, AOTCompContext *comp_ctx,
|
create_local_variables(const AOTCompData *comp_data,
|
||||||
AOTFuncContext *func_ctx, AOTFunc *func)
|
const AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||||
|
const AOTFunc *func)
|
||||||
{
|
{
|
||||||
AOTFuncType *aot_func_type = comp_data->func_types[func->func_type_index];
|
AOTFuncType *aot_func_type = comp_data->func_types[func->func_type_index];
|
||||||
char local_name[32];
|
char local_name[32];
|
||||||
|
@ -475,7 +479,7 @@ create_local_variables(AOTCompData *comp_data, AOTCompContext *comp_ctx,
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
create_memory_info(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
create_memory_info(const AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||||
LLVMTypeRef int8_ptr_type, uint32 func_index)
|
LLVMTypeRef int8_ptr_type, uint32 func_index)
|
||||||
{
|
{
|
||||||
LLVMValueRef offset, mem_info_base;
|
LLVMValueRef offset, mem_info_base;
|
||||||
|
@ -807,7 +811,7 @@ create_memory_info(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
create_cur_exception(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
create_cur_exception(const AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||||
{
|
{
|
||||||
LLVMValueRef offset;
|
LLVMValueRef offset;
|
||||||
|
|
||||||
|
@ -823,7 +827,8 @@ create_cur_exception(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
create_func_type_indexes(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
create_func_type_indexes(const AOTCompContext *comp_ctx,
|
||||||
|
AOTFuncContext *func_ctx)
|
||||||
{
|
{
|
||||||
LLVMValueRef offset, func_type_indexes_ptr;
|
LLVMValueRef offset, func_type_indexes_ptr;
|
||||||
LLVMTypeRef int32_ptr_type;
|
LLVMTypeRef int32_ptr_type;
|
||||||
|
@ -861,7 +866,7 @@ create_func_type_indexes(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
create_func_ptrs(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
create_func_ptrs(const AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||||
{
|
{
|
||||||
LLVMValueRef offset;
|
LLVMValueRef offset;
|
||||||
|
|
||||||
|
@ -903,7 +908,7 @@ create_func_ptrs(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
|
||||||
* Create function compiler context
|
* Create function compiler context
|
||||||
*/
|
*/
|
||||||
static AOTFuncContext *
|
static AOTFuncContext *
|
||||||
aot_create_func_context(AOTCompData *comp_data, AOTCompContext *comp_ctx,
|
aot_create_func_context(const AOTCompData *comp_data, AOTCompContext *comp_ctx,
|
||||||
AOTFunc *func, uint32 func_index)
|
AOTFunc *func, uint32 func_index)
|
||||||
{
|
{
|
||||||
AOTFuncContext *func_ctx;
|
AOTFuncContext *func_ctx;
|
||||||
|
@ -1059,7 +1064,7 @@ aot_destroy_func_contexts(AOTFuncContext **func_ctxes, uint32 count)
|
||||||
* Create function compiler contexts
|
* Create function compiler contexts
|
||||||
*/
|
*/
|
||||||
static AOTFuncContext **
|
static AOTFuncContext **
|
||||||
aot_create_func_contexts(AOTCompData *comp_data, AOTCompContext *comp_ctx)
|
aot_create_func_contexts(const AOTCompData *comp_data, AOTCompContext *comp_ctx)
|
||||||
{
|
{
|
||||||
AOTFuncContext **func_ctxes;
|
AOTFuncContext **func_ctxes;
|
||||||
uint64 size;
|
uint64 size;
|
||||||
|
@ -1536,7 +1541,7 @@ aot_compiler_destroy(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
AOTCompContext *
|
AOTCompContext *
|
||||||
aot_create_comp_context(AOTCompData *comp_data, aot_comp_option_t option)
|
aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
|
||||||
{
|
{
|
||||||
AOTCompContext *comp_ctx, *ret = NULL;
|
AOTCompContext *comp_ctx, *ret = NULL;
|
||||||
LLVMTargetRef target;
|
LLVMTargetRef target;
|
||||||
|
|
|
@ -275,7 +275,7 @@ typedef struct AOTLLVMConsts {
|
||||||
* Compiler context
|
* Compiler context
|
||||||
*/
|
*/
|
||||||
typedef struct AOTCompContext {
|
typedef struct AOTCompContext {
|
||||||
AOTCompData *comp_data;
|
const AOTCompData *comp_data;
|
||||||
|
|
||||||
/* LLVM variables required to emit LLVM IR */
|
/* LLVM variables required to emit LLVM IR */
|
||||||
LLVMContextRef context;
|
LLVMContextRef context;
|
||||||
|
@ -425,7 +425,7 @@ void
|
||||||
aot_compiler_destroy(void);
|
aot_compiler_destroy(void);
|
||||||
|
|
||||||
AOTCompContext *
|
AOTCompContext *
|
||||||
aot_create_comp_context(AOTCompData *comp_data, aot_comp_option_t option);
|
aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option);
|
||||||
|
|
||||||
void
|
void
|
||||||
aot_destroy_comp_context(AOTCompContext *comp_ctx);
|
aot_destroy_comp_context(AOTCompContext *comp_ctx);
|
||||||
|
@ -464,7 +464,7 @@ void
|
||||||
aot_block_destroy(AOTBlock *block);
|
aot_block_destroy(AOTBlock *block);
|
||||||
|
|
||||||
LLVMTypeRef
|
LLVMTypeRef
|
||||||
wasm_type_to_llvm_type(AOTLLVMTypes *llvm_types, uint8 wasm_type);
|
wasm_type_to_llvm_type(const AOTLLVMTypes *llvm_types, uint8 wasm_type);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
aot_checked_addr_list_add(AOTFuncContext *func_ctx, uint32 local_idx,
|
aot_checked_addr_list_add(AOTFuncContext *func_ctx, uint32 local_idx,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user