From 133e272f018ecc0a88cdfc202ea51c1aa16d1413 Mon Sep 17 00:00:00 2001 From: Aleksey Demakov Date: Fri, 30 Oct 2009 22:32:09 +0600 Subject: [PATCH] add jit_function_labels_equal() function --- ChangeLog | 4 ++++ include/jit/jit-function.h | 1 + jit/jit-function.c | 31 ++++++++++++++++++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 9f78ab6..fa58561 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2009-10-30 Aleksey Demakov + * include/jit/jit-function.h, jit/jit-function.c + (jit_function_labels_equal): add function that checks if two labels + belong to the same basic block. + * jit/jit-reg-alloc.h, jit/jit-reg-alloc.c (_jit_regs_clear_all_outgoing): add function. * jit/jit-compile.c (compile_block): use _jit_regs_clear_all_outgoing diff --git a/include/jit/jit-function.h b/include/jit/jit-function.h index 708b77d..e24271a 100644 --- a/include/jit/jit-function.h +++ b/include/jit/jit-function.h @@ -79,6 +79,7 @@ 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; +int jit_function_labels_equal(jit_function_t func, jit_label_t label, jit_label_t label2); #ifdef __cplusplus }; diff --git a/jit/jit-function.c b/jit/jit-function.c index 8c92218..3cdc580 100644 --- a/jit/jit-function.c +++ b/jit/jit-function.c @@ -991,7 +991,7 @@ jit_function_get_max_optimization_level(void) /*@ * @deftypefun {jit_label_t} jit_function_reserve_label (jit_function_t @var{func}) - * Allocate a new label for later use within the function @var{func}. Most + * Allocate a new label for later use within the function @var{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. @@ -1008,3 +1008,32 @@ jit_function_reserve_label(jit_function_t func) return (func->builder->next_label)++; } + +/*@ + * @deftypefun {int} jit_function_labels_equal (jit_function_t @var{func}, jit_label_t @var{label}, jit_label_t @var{label2}) + * Check if labels @var{label} and @var{label2} defined within the function + * @var{func} are equal that is belong to the same basic block. Labels that + * are not associated with any block are never considered equal. + * @end deftypefun +@*/ +int +jit_function_labels_equal(jit_function_t func, jit_label_t label, jit_label_t label2) +{ + jit_block_t block, block2; + + if(func && func->builder + && label != jit_label_undefined + && label2 != jit_label_undefined + && label < func->builder->max_label_info + && label2 < func->builder->max_label_info) + { + block = func->builder->label_info[label].block; + if(block) + { + block2 = func->builder->label_info[label2].block; + return block == block2; + } + } + + return 0; +} -- 2.47.3