aboutsummaryrefslogtreecommitdiff
path: root/gcc/jit/libgccjit.h
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/jit/libgccjit.h')
-rw-r--r--gcc/jit/libgccjit.h82
1 files changed, 82 insertions, 0 deletions
diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h
index e33900c..32f2a5d 100644
--- a/gcc/jit/libgccjit.h
+++ b/gcc/jit/libgccjit.h
@@ -67,6 +67,7 @@ typedef struct gcc_jit_result gcc_jit_result;
+- gcc_jit_rvalue
+- gcc_jit_lvalue
+- gcc_jit_param
+ +- gcc_jit_case
*/
typedef struct gcc_jit_object gcc_jit_object;
@@ -131,6 +132,12 @@ typedef struct gcc_jit_lvalue gcc_jit_lvalue;
rvalue); use gcc_jit_param_as_lvalue to convert. */
typedef struct gcc_jit_param gcc_jit_param;
+/* A gcc_jit_case is for use when building multiway branches via
+ gcc_jit_block_end_with_switch and represents a range of integer
+ values (or an individual integer value) together with an associated
+ destination block. */
+typedef struct gcc_jit_case gcc_jit_case;
+
/* Acquire a JIT-compilation context. */
extern gcc_jit_context *
gcc_jit_context_acquire (void);
@@ -1097,6 +1104,81 @@ extern void
gcc_jit_block_end_with_void_return (gcc_jit_block *block,
gcc_jit_location *loc);
+/* Create a new gcc_jit_case instance for use in a switch statement.
+ min_value and max_value must be constants of integer type.
+
+ This API entrypoint was added in LIBGCCJIT_ABI_3; you can test for its
+ presence using
+ #ifdef LIBGCCJIT_HAVE_SWITCH_STATEMENTS
+*/
+extern gcc_jit_case *
+gcc_jit_context_new_case (gcc_jit_context *ctxt,
+ gcc_jit_rvalue *min_value,
+ gcc_jit_rvalue *max_value,
+ gcc_jit_block *dest_block);
+
+/* Upcasting from case to object.
+
+ This API entrypoint was added in LIBGCCJIT_ABI_3; you can test for its
+ presence using
+ #ifdef LIBGCCJIT_HAVE_SWITCH_STATEMENTS
+*/
+
+extern gcc_jit_object *
+gcc_jit_case_as_object (gcc_jit_case *case_);
+
+/* Terminate a block by adding evalation of an rvalue, then performing
+ a multiway branch.
+
+ This is roughly equivalent to this C code:
+
+ switch (expr)
+ {
+ default:
+ goto default_block;
+
+ case C0.min_value ... C0.max_value:
+ goto C0.dest_block;
+
+ case C1.min_value ... C1.max_value:
+ goto C1.dest_block;
+
+ ...etc...
+
+ case C[N - 1].min_value ... C[N - 1].max_value:
+ goto C[N - 1].dest_block;
+ }
+
+ block, expr, default_block and cases must all be non-NULL.
+
+ expr must be of the same integer type as all of the min_value
+ and max_value within the cases.
+
+ num_cases must be >= 0.
+
+ The ranges of the cases must not overlap (or have duplicate
+ values).
+
+ This API entrypoint was added in LIBGCCJIT_ABI_3; you can test for its
+ presence using
+ #ifdef LIBGCCJIT_HAVE_SWITCH_STATEMENTS
+*/
+
+extern void
+gcc_jit_block_end_with_switch (gcc_jit_block *block,
+ gcc_jit_location *loc,
+ gcc_jit_rvalue *expr,
+ gcc_jit_block *default_block,
+ int num_cases,
+ gcc_jit_case **cases);
+
+/* Pre-canned feature macro to indicate the presence of
+ gcc_jit_block_end_with_switch, gcc_jit_case_as_object, and
+ gcc_jit_context_new_case.
+
+ This can be tested for with #ifdef. */
+#define LIBGCCJIT_HAVE_SWITCH_STATEMENTS
+
/**********************************************************************
Nested contexts.
**********************************************************************/