]> git.unchartedbackwaters.co.uk Git - francis/libjit.git/commitdiff
add jit_function_labels_equal() function
authorAleksey Demakov <ademakov@gmail.com>
Fri, 30 Oct 2009 16:32:09 +0000 (22:32 +0600)
committerAleksey Demakov <ademakov@gmail.com>
Fri, 30 Oct 2009 16:32:09 +0000 (22:32 +0600)
ChangeLog
include/jit/jit-function.h
jit/jit-function.c

index 9f78ab630003352c51c1bb4bd14a14a48be3a93b..fa58561c6e0a694237c1f711fb9e648815e2929f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2009-10-30  Aleksey Demakov  <ademakov@gmail.com>
 
+       * 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
index 708b77d00d285253326d0bd2cf387c35f972c5c9..e24271a0dad229abba3a0f920f679bec848cbdca 100644 (file)
@@ -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
 };
index 8c9221859714d6e6a96366af544af4ba664115c6..3cdc580fcd07ec4d675244988d22f06a3a063ee0 100644 (file)
@@ -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;
+}