jit_blocks 0.1.0
|
Creates a stack-based expression evaluation function. More...
Modules | |
Predefined arithmetic operations | |
expr engine has special support for these operations by inlining, leading to much faster execution. | |
Data Structures | |
struct | jit_blocks_expr_context |
Context of calculation. More... | |
Typedefs | |
typedef struct jit_blocks_expr_context | jit_blocks_expr_context |
Context of calculation. | |
typedef void(* | jit_blocks_expr_func_t) (jit_blocks_expr_context *ctx) |
Users could pass arbitrary functions to process the expression. | |
Functions | |
JIT_BLOCKS_EXPORT jit_blocks_expr_context * | jit_blocks_expr_context_new (int initial_stack_capacity) |
Creates a new context with the given initial stack capacity. | |
JIT_BLOCKS_EXPORT void | jit_blocks_expr_context_release (jit_blocks_expr_context *ctx) |
Destroys the context and frees all associated resources. | |
JIT_BLOCKS_EXPORT bool | jit_blocks_expr_context_push (jit_blocks_expr_context *ctx, double value) |
Pushes a double onto the stack. | |
JIT_BLOCKS_EXPORT bool | jit_blocks_expr_context_pop (jit_blocks_expr_context *ctx, double *out_value) |
Pops a double from the stack. | |
JIT_BLOCKS_EXPORT jit_blocks_expr_func_t | jit_blocks_expr_build (const jit_blocks_expr_func_t *ops, int num_ops, gcc_jit_result **out_res) |
Creates a function that performs the given arithmetic operations on the initial_ctx stack, and pushes the result back onto the stack. | |
JIT_BLOCKS_EXPORT jit_blocks_expr_func_t | jit_blocks_expr_build_aux (const jit_blocks_expr_func_t *ops, int num_ops, gcc_jit_context *ctx, gcc_jit_result **out_res) |
Creates a stack-based expression evaluation function.
Users could pass an array of jit_blocks_expr_func_t to jit_blocks_expr_build to create a function that accepts a jit_blocks_expr_context (which is essentially a stack of doubles),
Then, users could call jit_blocks_expr_context_new to create a context, push doubles into the context via jit_blocks_expr_context_push (Operands evaluated first should be pushed last so that they could popped out during calculation first). After users build a successful jit_blocks_expr_context, they can call the generation function and extract result from the stack via jit_blocks_expr_context_pop.
Example usage:
jit_blocks_expr_op_*
functions are predefined operators and got specially handled for faster calculation. See Predefined arithmetic operations for more details.
typedef struct jit_blocks_expr_context jit_blocks_expr_context |
Context of calculation.
Under the hood it's a fixed capacity stack for doubles. Users should use jit_blocks_expr_context_new to create one.
typedef void(* jit_blocks_expr_func_t) (jit_blocks_expr_context *ctx) |
Users could pass arbitrary functions to process the expression.
JIT_BLOCKS_EXPORT jit_blocks_expr_func_t jit_blocks_expr_build | ( | const jit_blocks_expr_func_t * | ops, |
int | num_ops, | ||
gcc_jit_result ** | out_res | ||
) |
Creates a function that performs the given arithmetic operations on the initial_ctx stack, and pushes the result back onto the stack.
JIT_BLOCKS_EXPORT jit_blocks_expr_func_t jit_blocks_expr_build_aux | ( | const jit_blocks_expr_func_t * | ops, |
int | num_ops, | ||
gcc_jit_context * | ctx, | ||
gcc_jit_result ** | out_res | ||
) |
JIT_BLOCKS_EXPORT jit_blocks_expr_context * jit_blocks_expr_context_new | ( | int | initial_stack_capacity | ) |
Creates a new context with the given initial stack capacity.
JIT_BLOCKS_EXPORT bool jit_blocks_expr_context_pop | ( | jit_blocks_expr_context * | ctx, |
double * | out_value | ||
) |
Pops a double from the stack.
JIT_BLOCKS_EXPORT bool jit_blocks_expr_context_push | ( | jit_blocks_expr_context * | ctx, |
double | value | ||
) |
Pushes a double onto the stack.
JIT_BLOCKS_EXPORT void jit_blocks_expr_context_release | ( | jit_blocks_expr_context * | ctx | ) |
Destroys the context and frees all associated resources.