jit_blocks 0.1.0
|
Builds a function acting as a big dynamic switch like below: More...
Data Structures | |
struct | jit_blocks_dynswitch_cond_t |
A condition for the dynamic switch. More... | |
Typedefs | |
typedef void(* | jit_blocks_dynswitch_func_ptr_t) (void *ctx, long val) |
The function pointer type called in each condition. | |
typedef struct jit_blocks_dynswitch_cond_t | jit_blocks_dynswitch_cond_t |
A condition for the dynamic switch. | |
typedef jit_blocks_dynswitch_func_ptr_t | jit_blocks_dynswitch_result_t |
The output function pointer type. | |
Functions | |
JIT_BLOCKS_EXPORT jit_blocks_dynswitch_result_t | jit_blocks_dynswitch_build (const jit_blocks_dynswitch_cond_t *conds, int num_conds, jit_blocks_dynswitch_func_ptr_t default_func, gcc_jit_result **out_res) |
Builds a function that performs a dynamic switch. | |
JIT_BLOCKS_EXPORT jit_blocks_dynswitch_result_t | jit_blocks_dynswitch_build_aux (const jit_blocks_dynswitch_cond_t *conds, int num_conds, jit_blocks_dynswitch_func_ptr_t default_func, gcc_jit_context *ctx, gcc_jit_result **out_res) |
Builds a function acting as a big dynamic switch like below:
Given the below construction call:
It generates the following function:
This could be used as an alternative to computed goto if the condition table is only known at run-time (e.g., build a dispatch() function of a dynamic base method that supports a dynamic dispatch table). Otherwise, computed goto might be a better choice.
typedef struct jit_blocks_dynswitch_cond_t jit_blocks_dynswitch_cond_t |
A condition for the dynamic switch.
typedef void(* jit_blocks_dynswitch_func_ptr_t) (void *ctx, long val) |
The function pointer type called in each condition.
The output function pointer type.
JIT_BLOCKS_EXPORT jit_blocks_dynswitch_result_t jit_blocks_dynswitch_build | ( | const jit_blocks_dynswitch_cond_t * | conds, |
int | num_conds, | ||
jit_blocks_dynswitch_func_ptr_t | default_func, | ||
gcc_jit_result ** | out_res | ||
) |
Builds a function that performs a dynamic switch.
It matches conds array in order and calls the corresponding function. If no match is found, it calls default_func.
JIT_BLOCKS_EXPORT jit_blocks_dynswitch_result_t jit_blocks_dynswitch_build_aux | ( | const jit_blocks_dynswitch_cond_t * | conds, |
int | num_conds, | ||
jit_blocks_dynswitch_func_ptr_t | default_func, | ||
gcc_jit_context * | ctx, | ||
gcc_jit_result ** | out_res | ||
) |