From: Aleksey Demakov Date: Sun, 7 Oct 2007 14:16:50 +0000 (+0000) Subject: add jit_function_reserve_label function X-Git-Tag: before.move.to.git~135 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=e0f954a6728c4f239e199dd9af8a6ee1255e9f6b;p=francis%2Flibjit.git add jit_function_reserve_label function --- diff --git a/ChangeLog b/ChangeLog index 2554779..2c30f58 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,10 @@ * jit/jit-rules-x86.ins (JIT_OP_JUMP_TABLE): fix jump table code generation. + * include/jit/jit-function.h: + * jit/jit-function.c (jit_function_reserve_label): add new function + to create labels for jump tables. + 2007-06-11 Aleksey Demakov * jit/jit-insn.c (accumulate_relative_offset): remove. diff --git a/include/jit/jit-function.h b/include/jit/jit-function.h index b9d6db7..d2851bb 100644 --- a/include/jit/jit-function.h +++ b/include/jit/jit-function.h @@ -75,6 +75,7 @@ void jit_function_set_optimization_level unsigned int jit_function_get_optimization_level (jit_function_t func) JIT_NOTHROW; unsigned int jit_function_get_max_optimization_level(void) JIT_NOTHROW; +jit_label_t jit_function_reserve_label(jit_function_t func) JIT_NOTHROW; #ifdef __cplusplus }; diff --git a/jit/jit-function.c b/jit/jit-function.c index 0c0bcfb..b5afd9a 100644 --- a/jit/jit-function.c +++ b/jit/jit-function.c @@ -1635,3 +1635,23 @@ unsigned int jit_function_get_max_optimization_level(void) /* TODO - implement more than basic optimization */ return 0; } + +/*@ + * @deftypefun {jit_label_t} jit_function_reserve_label (jit_function_t func) + * Allocate a new label for later use within the function @code{func}. Most + * instructions that require a label could perform label allocation themselves. + * A separate label allocation could be useful to fill a jump table with + * identical entries. + * @end deftypefun +@*/ +jit_label_t +jit_function_reserve_label(jit_function_t func) +{ + /* Ensure that we have a function builder */ + if(!_jit_function_ensure_builder(func)) + { + return jit_label_undefined; + } + + return (func->builder->next_label)++; +}