From 5b9056511d905e9f73eb8bcdb603b09516abd97a Mon Sep 17 00:00:00 2001 From: Aleksey Demakov Date: Mon, 3 Apr 2006 05:10:35 +0000 Subject: [PATCH] Add `reversible', `x87arith', `copy' keywords and fix bugs. --- ChangeLog | 6 +++ tools/gen-rules-parser.y | 89 +++++++++++++++++++++++++++++++-------- tools/gen-rules-scanner.l | 3 ++ 3 files changed, 80 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2413bdc..4ab7faf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-04-03 Aleksey Demakov + + * tools/gen-rules-scanner.l: + * tools/gen-rules-parser.y: add `reversible', `x87arith', + and `copy' keywords. Fix bugs. + 2006-03-23 Klaus Treichel * jit/jitc-except.c: Walk the stack to build the stack trace in diff --git a/tools/gen-rules-parser.y b/tools/gen-rules-parser.y index bdb5dd9..42b08ef 100644 --- a/tools/gen-rules-parser.y +++ b/tools/gen-rules-parser.y @@ -114,11 +114,14 @@ static int gensel_first_stack_reg = 8; /* st0 under x86 */ #define GENSEL_OPT_TERNARY 7 #define GENSEL_OPT_STACK 8 #define GENSEL_OPT_ONLY 9 -#define GENSEL_OPT_COMMUTATIVE 10 +#define GENSEL_OPT_COPY 10 +#define GENSEL_OPT_X87ARITH 11 +#define GENSEL_OPT_COMMUTATIVE 12 +#define GENSEL_OPT_REVERSIBLE 13 -#define GENSEL_OPT_MANUAL 11 -#define GENSEL_OPT_MORE_SPACE 12 -#define GENSEL_OPT_SPILL_BEFORE 13 +#define GENSEL_OPT_MANUAL 14 +#define GENSEL_OPT_MORE_SPACE 15 +#define GENSEL_OPT_SPILL_BEFORE 16 /* * Pattern values. @@ -840,7 +843,8 @@ static void gensel_output_clauses(gensel_clause_t clauses, gensel_option_t optio } printf("_JIT_REGS_TERNARY"); } - if(gensel_search_option(options, GENSEL_OPT_COMMUTATIVE)) + if(gensel_search_option(options, GENSEL_OPT_BINARY_BRANCH) + || gensel_search_option(options, GENSEL_OPT_UNARY_BRANCH)) { if(seen_option) { @@ -850,7 +854,19 @@ static void gensel_output_clauses(gensel_clause_t clauses, gensel_option_t optio { seen_option = 1; } - printf("_JIT_REGS_COMMUTATIVE"); + printf("_JIT_REGS_BRANCH"); + } + if(gensel_search_option(options, GENSEL_OPT_COPY)) + { + if(seen_option) + { + printf(" | "); + } + else + { + seen_option = 1; + } + printf("_JIT_REGS_COPY"); } if(gensel_search_option(options, GENSEL_OPT_STACK)) { @@ -864,8 +880,31 @@ static void gensel_output_clauses(gensel_clause_t clauses, gensel_option_t optio } printf("_JIT_REGS_STACK"); } -/* - if(gensel_search_option(options, GENSEL_OPT_)) + if(gensel_search_option(options, GENSEL_OPT_X87ARITH)) + { + if(seen_option) + { + printf(" | "); + } + else + { + seen_option = 1; + } + printf("_JIT_REGS_X87_ARITH"); + } + if(gensel_search_option(options, GENSEL_OPT_COMMUTATIVE)) + { + if(seen_option) + { + printf(" | "); + } + else + { + seen_option = 1; + } + printf("_JIT_REGS_COMMUTATIVE"); + } + if(gensel_search_option(options, GENSEL_OPT_REVERSIBLE)) { if(seen_option) { @@ -875,15 +914,23 @@ static void gensel_output_clauses(gensel_clause_t clauses, gensel_option_t optio { seen_option = 1; } - printf("_JIT_REGS_"); + printf("_JIT_REGS_REVERSIBLE"); } -*/ if(!seen_option) { printf("0"); } printf(");\n"); + if(!(gensel_search_option(options, GENSEL_OPT_TERNARY) + || gensel_search_option(options, GENSEL_OPT_BINARY_NOTE) + || gensel_search_option(options, GENSEL_OPT_BINARY_BRANCH) + || gensel_search_option(options, GENSEL_OPT_UNARY_NOTE) + || gensel_search_option(options, GENSEL_OPT_UNARY_BRANCH))) + { + printf("\t\t_jit_regs_set_dest(®s, insn, 0, -1, -1);\n"); + } + regs = 0; index = 0; pattern = clause->pattern; @@ -898,12 +945,12 @@ static void gensel_output_clauses(gensel_clause_t clauses, gensel_option_t optio printf("\t\t%s = _jit_regs_lookup(\"%s\")];\n", gensel_reg_names[regs], pattern->values->value); - printf("\t\t_jit_regs_set_%s(®s, insn, %s, -1);\n", + printf("\t\t_jit_regs_set_%s(®s, insn, 0, %s, -1);\n", args[index], gensel_reg_names[regs]); } else { - printf("\t\t_jit_regs_set_%s(®s, insn, -1, -1);\n", + printf("\t\t_jit_regs_set_%s(®s, insn, 0, -1, -1);\n", args[index]); } ++regs; @@ -922,7 +969,7 @@ static void gensel_output_clauses(gensel_clause_t clauses, gensel_option_t optio printf("\t\t%s = _jit_regs_lookup(\"%s\")];\n", gensel_other_reg_names[regs], pattern->values->next->value); - printf("\t\t_jit_regs_set_%s(®s, insn, %s, %s);\n", + printf("\t\t_jit_regs_set_%s(®s, insn, 0, %s, %s);\n", args[index], gensel_reg_names[regs], gensel_other_reg_names[regs]); @@ -932,13 +979,13 @@ static void gensel_output_clauses(gensel_clause_t clauses, gensel_option_t optio printf("\t\t%s = _jit_regs_lookup(\"%s\")];\n", gensel_reg_names[regs], pattern->values->value); - printf("\t\t_jit_regs_set_%s(®s, insn, %s, -1);\n", + printf("\t\t_jit_regs_set_%s(®s, insn, 0, %s, -1);\n", args[index], gensel_reg_names[regs]); } } else { - printf("\t\t_jit_regs_set_%s(®s, insn, -1, -1);\n", + printf("\t\t_jit_regs_set_%s(®s, insn, 0, -1, -1);\n", args[index]); } ++regs; @@ -1013,16 +1060,16 @@ static void gensel_output_clauses(gensel_clause_t clauses, gensel_option_t optio { case GENSEL_PATT_REG: case GENSEL_PATT_FREG: - printf("\t\t%s = _jit_reg_info[_jit_regs_%s(regs)].cpu_reg;\n", + printf("\t\t%s = _jit_reg_info[_jit_regs_%s(®s)].cpu_reg;\n", gensel_reg_names[regs], args[index]); ++regs; ++index; break; case GENSEL_PATT_LREG: - printf("\t\t%s = _jit_reg_info[_jit_regs_%s(regs)].cpu_reg;\n", + printf("\t\t%s = _jit_reg_info[_jit_regs_%s(®s)].cpu_reg;\n", gensel_reg_names[regs], args[index]); - printf("\t\t%s = _jit_reg_info[_jit_regs_%s_other(regs)].cpu_reg;\n", + printf("\t\t%s = _jit_reg_info[_jit_regs_%s_other(®s)].cpu_reg;\n", gensel_other_reg_names[regs], args[index]); ++regs; ++index; @@ -1202,7 +1249,10 @@ static void gensel_output_supported(void) %token K_TERNARY "`ternary'" %token K_STACK "`stack'" %token K_ONLY "`only'" +%token K_COPY "`copy'" +%token K_X87ARITH "`x87arith'" %token K_COMMUTATIVE "`commutative'" +%token K_REVERSIBLE "`reversible'" %token K_IF "`if'" %token K_CLOBBER "`clobber'" %token K_SCRATCH "`scratch'" @@ -1443,7 +1493,10 @@ OptionTag | K_TERNARY { $$ = GENSEL_OPT_TERNARY; } | K_STACK { $$ = GENSEL_OPT_STACK; } | K_ONLY { $$ = GENSEL_OPT_ONLY; } + | K_COPY { $$ = GENSEL_OPT_COPY; } + | K_X87ARITH { $$ = GENSEL_OPT_X87ARITH; } | K_COMMUTATIVE { $$ = GENSEL_OPT_COMMUTATIVE; } + | K_REVERSIBLE { $$ = GENSEL_OPT_REVERSIBLE; } /* deprecated: */ | K_MANUAL { $$ = GENSEL_OPT_MANUAL; } diff --git a/tools/gen-rules-scanner.l b/tools/gen-rules-scanner.l index 1213c98..7d5cda5 100644 --- a/tools/gen-rules-scanner.l +++ b/tools/gen-rules-scanner.l @@ -102,7 +102,10 @@ WHITE [ \t\v\r\f] "ternary" { RETURNTOK(K_TERNARY); } "stack" { RETURNTOK(K_STACK); } "only" { RETURNTOK(K_ONLY); } +"copy" { RETURNTOK(K_COPY); } +"x87arith" { RETURNTOK(K_X87ARITH); } "commutative" { RETURNTOK(K_COMMUTATIVE); } +"reversible" { RETURNTOK(K_REVERSIBLE); } "if" { RETURNTOK(K_IF); } "clobber" { RETURNTOK(K_CLOBBER); } "scratch" { RETURNTOK(K_SCRATCH); } -- 2.47.3