From: Aleksey Demakov Date: Sat, 9 Sep 2006 05:21:03 +0000 (+0000) Subject: add _JIT_REGS_CLOBBER_STACK flag to be used for "only" rules X-Git-Tag: before.move.to.git~194 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=343fad4827d26f71bfc2d928f7cdc9ab98c963f4;p=francis%2Flibjit.git add _JIT_REGS_CLOBBER_STACK flag to be used for "only" rules --- diff --git a/ChangeLog b/ChangeLog index 082138c..0a4cfce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-09-09 Aleksey Demakov + + * 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 * jit/jit-interp.c (_jit_run_function): diff --git a/jit/jit-reg-alloc.c b/jit/jit-reg-alloc.c index 01328fb..a5608a4 100644 --- a/jit/jit-reg-alloc.c +++ b/jit/jit-reg-alloc.c @@ -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); + } } } diff --git a/jit/jit-reg-alloc.h b/jit/jit-reg-alloc.h index 2695e57..55f0323 100644 --- a/jit/jit-reg-alloc.h +++ b/jit/jit-reg-alloc.h @@ -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; diff --git a/tools/gen-rules-parser.y b/tools/gen-rules-parser.y index 95b48b0..3162210 100644 --- a/tools/gen-rules-parser.y +++ b/tools/gen-rules-parser.y @@ -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)