From e0f954a6728c4f239e199dd9af8a6ee1255e9f6b Mon Sep 17 00:00:00 2001 From: Aleksey Demakov Date: Sun, 7 Oct 2007 14:16:50 +0000 Subject: [PATCH] add jit_function_reserve_label function --- ChangeLog | 4 ++++ include/jit/jit-function.h | 1 + jit/jit-function.c | 20 ++++++++++++++++++++ 3 files changed, 25 insertions(+) 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)++; +} -- 2.47.3