]> git.unchartedbackwaters.co.uk Git - francis/libjit.git/commitdiff
add _JIT_REGS_CLOBBER_STACK flag to be used for "only" rules
authorAleksey Demakov <ademakov@gmail.com>
Sat, 9 Sep 2006 05:21:03 +0000 (05:21 +0000)
committerAleksey Demakov <ademakov@gmail.com>
Sat, 9 Sep 2006 05:21:03 +0000 (05:21 +0000)
ChangeLog
jit/jit-reg-alloc.c
jit/jit-reg-alloc.h
tools/gen-rules-parser.y

index 082138cc2c06461dbe41368ba2a30a2c1447a08f..0a4cfcedba5550458c7b8647cd6cea49362f7c3f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-09-09  Aleksey Demakov  <ademakov@gmail.com>
+
+       * jit/jit-reg-alloc.h, jit/jit-reg-alloc.c:
+       * tools/gen-rules-parser.y: add _JIT_REGS_CLOBBER_STACK flag and use
+       it in the code genearted for "only" rules instead of the explicit
+       stack top check followed by the _jit_regs_spill_all() call.
+
 2006-09-02  Aleksey Demakov  <ademakov@gmail.com>
 
        * jit/jit-interp.c (_jit_run_function): 
index 01328fb9d4ac3d0862e955f2378cc3c3548b392e..a5608a4bf96ca8c1e90216a3b046164b8fd61cba 100644 (file)
@@ -2801,9 +2801,9 @@ choose_input_order(jit_gencode_t gen, _jit_regs_t *regs)
        }
 
        if(regs->descs[2].value
-               && regs->descs[2].value->in_register
-               && regs->descs[2].value->reg == regs->descs[0].reg
-               && regs->descs[2].value != regs->descs[1].value)
+          && regs->descs[2].value->in_register
+          && regs->descs[2].value->reg == regs->descs[0].reg
+          && regs->descs[2].value != regs->descs[1].value)
        {
                if(regs->on_stack && regs->x87_arith)
                {
@@ -2832,10 +2832,9 @@ choose_input_order(jit_gencode_t gen, _jit_regs_t *regs)
        }
 
        /* Choose between pop and no-pop instructions. */
-       if(regs->on_stack && regs->x87_arith
-          && !regs->no_pop && !regs->clobber_all
-          && regs->descs[1].value
-          && regs->descs[2].value)
+       if(regs->on_stack && regs->x87_arith && !regs->no_pop
+          && !regs->clobber_all && !regs->clobber_stack
+          && regs->descs[1].value && regs->descs[2].value)
        {
                /* Determine if we might want to keep either of input values
                   in registers after the instruction completion. */
@@ -3971,6 +3970,7 @@ _jit_regs_init(jit_gencode_t gen, _jit_regs_t *regs, int flags)
        int index;
 
        regs->clobber_all = (flags & _JIT_REGS_CLOBBER_ALL) != 0;
+       regs->clobber_stack = (flags & _JIT_REGS_CLOBBER_STACK) != 0;
        regs->ternary = (flags & _JIT_REGS_TERNARY) != 0;
        regs->branch = (flags & _JIT_REGS_BRANCH) != 0;
        regs->copy = (flags & _JIT_REGS_COPY) != 0;
@@ -3998,7 +3998,7 @@ _jit_regs_init(jit_gencode_t gen, _jit_regs_t *regs, int flags)
 
        /* Set clobber flags. */
        regs->clobber = jit_regused_init;
-       if(regs->clobber_all)
+       if(regs->clobber_all || regs->clobber_stack)
        {
                for(index = 0; index < JIT_NUM_REGS; index++)
                {
@@ -4007,7 +4007,10 @@ _jit_regs_init(jit_gencode_t gen, _jit_regs_t *regs, int flags)
                        {
                                continue;
                        }
-                       jit_reg_set_used(regs->clobber, index);
+                       if(regs->clobber_all || IS_STACK_REG(index))
+                       {
+                               jit_reg_set_used(regs->clobber, index);
+                       }
                }
        }
 
index 2695e57114dc31f09f8421c1b64a459a11372fc1..55f0323a480077dbd67f6a4aa6150397d6d60c25 100644 (file)
@@ -86,6 +86,7 @@ void _jit_regs_get_reg_pair(jit_gencode_t gen, int not_this1, int not_this2,
 #define _JIT_REGS_COMMUTATIVE          0x0040
 #define _JIT_REGS_REVERSIBLE           0x0080
 #define _JIT_REGS_FREE_DEST            0x0100
+#define _JIT_REGS_CLOBBER_STACK                0x0200
 
 /*
  * Flags for _jit_regs_init_dest(), _jit_regs_init_value1(), and
@@ -140,6 +141,7 @@ typedef struct
 typedef struct
 {
        unsigned        clobber_all : 1;
+       unsigned        clobber_stack : 1;
        unsigned        ternary : 1;
        unsigned        branch : 1;
        unsigned        copy : 1;
index 95b48b0fe48f5e33563d2432916c4499314d7524..31622100c2a9219c4498e532b00d607ef4bf29e4 100644 (file)
@@ -87,11 +87,6 @@ static int gensel_new_inst_type = 0;
 static int gensel_reserve_space = 32;
 static int gensel_reserve_more_space = 128;
 
-/*
- * First register in a stack arrangement.
- */
-static int gensel_first_stack_reg = 8; /* st0 under x86 */
-
 /*
  * Maximal number of input values in a pattern.
  */
@@ -1133,17 +1128,6 @@ static void gensel_output_clauses(gensel_clause_t clauses, gensel_option_t optio
                        printf("\telse\n\t{\n");
                }
 
-               if(gensel_search_option(options, GENSEL_OPT_STACK)
-                  && gensel_search_option(options, GENSEL_OPT_ONLY))
-               {
-                       printf("\t\tif(!_jit_regs_is_top(gen, insn->value1) ||\n");
-                       printf("\t\t   _jit_regs_num_used(gen, %d) != 1)\n",
-                              gensel_first_stack_reg);
-                       printf("\t\t{\n");
-                       printf("\t\t\t_jit_regs_spill_all(gen);\n");
-                       printf("\t\t}\n");
-               }
-
                if(gensel_search_option(options, GENSEL_OPT_BINARY_BRANCH)
                   || gensel_search_option(options, GENSEL_OPT_UNARY_BRANCH))
                {
@@ -1228,6 +1212,18 @@ static void gensel_output_clauses(gensel_clause_t clauses, gensel_option_t optio
                                }
                                printf("_JIT_REGS_STACK");
                        }
+                       if(gensel_search_option(options, GENSEL_OPT_ONLY))
+                       {
+                               if(seen_option)
+                               {
+                                       printf(" | ");
+                               }
+                               else
+                               {
+                                       seen_option = 1;
+                               }
+                               printf("_JIT_REGS_CLOBBER_STACK");
+                       }
                        if(gensel_search_option(options, GENSEL_OPT_X87ARITH))
                        {
                                if(seen_option)