jit_blocks 0.1.0
Loading...
Searching...
No Matches
jit_blocks.h
Go to the documentation of this file.
1#pragma once
2#include <sys/types.h>
3// ---
4#include <libgccjit.h>
5#include <stdbool.h>
6
7#include "jit_blocks/jit_blocks_export.h"
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
19typedef gcc_jit_context* (*jit_blocks_context_builder_t)(void);
22JIT_BLOCKS_EXPORT jit_blocks_context_builder_t
24
29
37typedef int (*jit_blocks_divide_by_k_int_t)(int dividend);
38typedef long (*jit_blocks_divide_by_k_long_t)(long dividend);
39
40JIT_BLOCKS_EXPORT jit_blocks_divide_by_k_int_t
41jit_blocks_build_divide_by_k_int(int divisor, gcc_jit_result** out_res);
42
43JIT_BLOCKS_EXPORT jit_blocks_divide_by_k_int_t
45 gcc_jit_context* custom_context,
46 gcc_jit_result** out_res);
47
48JIT_BLOCKS_EXPORT jit_blocks_divide_by_k_long_t
49jit_blocks_build_divide_by_k_long(long divisor, gcc_jit_result** out_res);
50
51JIT_BLOCKS_EXPORT jit_blocks_divide_by_k_long_t
53 gcc_jit_context* custom_context,
54 gcc_jit_result** out_res);
84typedef void (*jit_blocks_funccalls_func_ptr_t)(void*);
85
86typedef void (*jit_blocks_funccalls_output_func_t)(void* arg);
87
90 int num_records,
91 gcc_jit_result** out_res);
92
95 int num_records,
96 gcc_jit_context* custom_context,
97 gcc_jit_result** out_res);
98
160
163 int initial_stack_capacity);
164
166JIT_BLOCKS_EXPORT void jit_blocks_expr_context_release(
168
171JIT_BLOCKS_EXPORT bool jit_blocks_expr_context_push(
172 jit_blocks_expr_context* ctx, double value);
173
177 double* out_value);
178
181
188
198JIT_BLOCKS_EXPORT void jit_blocks_expr_op_multiply(
204
207
211
215JIT_BLOCKS_EXPORT void jit_blocks_expr_pow(jit_blocks_expr_context* ctx);
216
230JIT_BLOCKS_EXPORT void jit_blocks_expr_ops_parse(
231 const char* ops[], int ops_cnt, jit_blocks_expr_func_t* out_funcs);
233
237
241 const jit_blocks_expr_func_t* ops, int num_ops, gcc_jit_result** out_res);
242
244JIT_BLOCKS_EXPORT jit_blocks_expr_func_t
246 int num_ops,
247 gcc_jit_context* ctx,
248 gcc_jit_result** out_res);
249
251
289
291
293typedef void (*jit_blocks_dynswitch_func_ptr_t)(void* ctx, long val);
294
300
303
308JIT_BLOCKS_EXPORT jit_blocks_dynswitch_result_t
310 int num_conds,
312 gcc_jit_result** out_res);
313
315JIT_BLOCKS_EXPORT jit_blocks_dynswitch_result_t
317 int num_conds,
319 gcc_jit_context* ctx,
320 gcc_jit_result** out_res);
321
323
324#ifdef __cplusplus
325} // extern "C"
326#endif
JIT_BLOCKS_EXPORT void jit_blocks_set_easy_context_builder(jit_blocks_context_builder_t builder)
Sets the global jit_blocks_context_builder_t used for all easy (aka non-aux) APIs.
gcc_jit_context *(* jit_blocks_context_builder_t)(void)
A jit_blocks_context_builder_t allocates a fresh gcc_jit_context, potentially sets some default optio...
Definition jit_blocks.h:19
JIT_BLOCKS_EXPORT jit_blocks_context_builder_t jit_blocks_get_easy_context_builder(void)
Returns the global jit_blocks_context_builder_t used for all easy (aka non-aux) APIs.
int(* jit_blocks_divide_by_k_int_t)(int dividend)
Definition jit_blocks.h:37
long(* jit_blocks_divide_by_k_long_t)(long dividend)
Definition jit_blocks.h:38
JIT_BLOCKS_EXPORT jit_blocks_divide_by_k_int_t jit_blocks_build_divide_by_k_int_aux(int divisor, gcc_jit_context *custom_context, gcc_jit_result **out_res)
JIT_BLOCKS_EXPORT jit_blocks_divide_by_k_long_t jit_blocks_build_divide_by_k_long_aux(long divisor, gcc_jit_context *custom_context, gcc_jit_result **out_res)
JIT_BLOCKS_EXPORT jit_blocks_divide_by_k_long_t jit_blocks_build_divide_by_k_long(long divisor, gcc_jit_result **out_res)
JIT_BLOCKS_EXPORT jit_blocks_divide_by_k_int_t jit_blocks_build_divide_by_k_int(int divisor, gcc_jit_result **out_res)
void(* jit_blocks_dynswitch_func_ptr_t)(void *ctx, long val)
The function pointer type called in each condition.
Definition jit_blocks.h:293
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_dynswitch_func_ptr_t jit_blocks_dynswitch_result_t
The output function pointer type.
Definition jit_blocks.h:302
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)
JIT_BLOCKS_EXPORT void jit_blocks_expr_op_abs(jit_blocks_expr_context *ctx)
Pops 1 double from the stack, converts it to its absolute value, and pushes the result back.
JIT_BLOCKS_EXPORT void jit_blocks_expr_pow(jit_blocks_expr_context *ctx)
Pops 2 doubles from the stack, computes the power of the first number to the second number,...
JIT_BLOCKS_EXPORT void jit_blocks_expr_op_divide(jit_blocks_expr_context *ctx)
Pops two doubles from the stack, divides the first by the second, and pushes the result back.
JIT_BLOCKS_EXPORT void jit_blocks_expr_op_multiply(jit_blocks_expr_context *ctx)
Pops two doubles from the stack, multiplies them, and pushes the result back.
JIT_BLOCKS_EXPORT void jit_blocks_expr_op_plus(jit_blocks_expr_context *ctx)
Pops two doubles from the stack, adds them, and pushes the result back.
JIT_BLOCKS_EXPORT void jit_blocks_expr_op_negate(jit_blocks_expr_context *ctx)
Pops a double from the stack, negates it, and pushes the result back.
JIT_BLOCKS_EXPORT void jit_blocks_expr_op_minus(jit_blocks_expr_context *ctx)
Pops two doubles from the stack, subtracts the second from the first, and pushes the result back.
JIT_BLOCKS_EXPORT void jit_blocks_expr_ops_parse(const char *ops[], int ops_cnt, jit_blocks_expr_func_t *out_funcs)
Parses arithmetic operations from the given string, and stores the parsed operations into out_funcs a...
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)
void(* jit_blocks_expr_func_t)(jit_blocks_expr_context *ctx)
Users could pass arbitrary functions to process the expression.
Definition jit_blocks.h:180
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 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,...
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 jit_blocks_funccalls_output_func_t jit_blocks_funccalls_build_aux(const jit_blocks_funccalls_func_ptr_t *records, int num_records, gcc_jit_context *custom_context, gcc_jit_result **out_res)
void(* jit_blocks_funccalls_func_ptr_t)(void *)
Definition jit_blocks.h:84
void(* jit_blocks_funccalls_output_func_t)(void *arg)
Definition jit_blocks.h:86
JIT_BLOCKS_EXPORT jit_blocks_funccalls_output_func_t jit_blocks_funccalls_build(const jit_blocks_funccalls_func_ptr_t *records, int num_records, gcc_jit_result **out_res)
A condition for the dynamic switch.
Definition jit_blocks.h:296
jit_blocks_dynswitch_func_ptr_t func
Definition jit_blocks.h:298
long val
Definition jit_blocks.h:297
Context of calculation.
Definition jit_blocks.h:155
int stack_size
Definition jit_blocks.h:157
int stack_capacity
Definition jit_blocks.h:158
double * stack
Definition jit_blocks.h:156