]> git.unchartedbackwaters.co.uk Git - francis/libjit.git/commitdiff
fix warning in jit/jit-rules-x86.c;
authorAleksey Demakov <ademakov@gmail.com>
Wed, 19 Apr 2006 14:33:21 +0000 (14:33 +0000)
committerAleksey Demakov <ademakov@gmail.com>
Wed, 19 Apr 2006 14:33:21 +0000 (14:33 +0000)
fix generation of scratch and clobber code;
add `any' keyword.

ChangeLog
jit/jit-rules-x86.c
tools/gen-rules-parser.y
tools/gen-rules-scanner.l

index 1e0815f81fceb9e1190a752a6efdcc719c251f0f..d3b8c9acac38ef92134932e0f8755fb13ffd94a0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2006-04-19  Aleksey Demakov  <ademakov@gmail.com>
+
+       * jit/jit-rules-x86.c (_jit_gen_load_value): fix compiler warning.
+
+       * tools/gen-rules-parser.y (gensel_output_clauses): fix generation
+       of clobber and scratch code.
+
+       * tools/gen-rules-scanner.l, tools/gen-rules-parser.y: add `any'
+       keyword.
+
 2006-04-18  Aleksey Demakov  <ademakov@gmail.com>
 
        * jit/jit-rules-x86.ins: add instruction selection rules for new
index 3f7723a36e0d9b0030abc681fa5638773232acba..096fb4e79a1c04f1aa0f1e22138830499ed2251f 100644 (file)
@@ -1002,6 +1002,10 @@ _jit_gen_load_value(jit_gencode_t gen, int reg, int other_reg, jit_value_t value
                        {
                                other_src_reg = _jit_reg_info[src_reg].other_reg;
                        }
+                       else
+                       {
+                               other_src_reg = -1;
+                       }
                }
                else
                {
index b4dbf294f255b4321b5df7f08af6a2d7d3ca2e18..cbed85a5ca52dd5b2aee574227a3399be5ca3d3d 100644 (file)
@@ -140,6 +140,7 @@ static int gensel_first_stack_reg = 8;      /* st0 under x86 */
 #define        GENSEL_PATT_CLOBBER                     12
 #define        GENSEL_PATT_IF                          13
 #define        GENSEL_PATT_SPACE                       14
+#define GENSEL_PATT_ANY                                15
 
 /*
  * Register flags.
@@ -298,15 +299,13 @@ static void gensel_declare_regs(gensel_clause_t clauses, gensel_option_t options
        int other_regs_mask;
        int imms, max_imms;
        int have_local;
-       int scratch, max_scratch;
+       int scratch, others;
        int have_clobber;
-       int others;
 
        max_regs = 0;
        other_regs_mask = 0;
        max_imms = 0;
        have_local = 0;
-       max_scratch = 0;
        have_clobber = 0;
        while(clauses != 0)
        {
@@ -319,6 +318,10 @@ static void gensel_declare_regs(gensel_clause_t clauses, gensel_option_t options
                {
                        switch(pattern->option)
                        {
+                       case GENSEL_PATT_ANY:
+                               ++others;
+                               break;
+
                        case GENSEL_PATT_REG:
                        case GENSEL_PATT_FREG:
                                ++regs;
@@ -382,31 +385,24 @@ static void gensel_declare_regs(gensel_clause_t clauses, gensel_option_t options
                                clauses->linenum,
                                "too many scratch args in the pattern");
                }
-               if(max_regs < regs)
+               if(max_regs < (regs + scratch))
                {
-                       max_regs = regs;
+                       max_regs = regs + scratch;
                }
                if(max_imms < imms)
                {
                        max_imms = imms;
                }
-               if(max_scratch < scratch)
-               {
-                       max_scratch = scratch;
-               }
                clauses = clauses->next;
        }
-       switch(max_regs)
+       if(max_regs > 0)
        {
-       case 1:
-               printf("\tint reg;\n");
-               break;
-       case 2:
-               printf("\tint reg, reg2;\n");
-               break;
-       case 3:
-               printf("\tint reg, reg2, reg3;\n");
-               break;
+               printf("\tint reg");
+               for(scratch = 1; scratch < max_regs; scratch++)
+               {
+                       printf(", reg%d", scratch + 1);
+               }
+               printf(";\n");
        }
        if(other_regs_mask)
        {
@@ -425,13 +421,13 @@ static void gensel_declare_regs(gensel_clause_t clauses, gensel_option_t options
                        printf("\tint other_reg3;\n");
                        break;
                case 5:
-                       printf("\tint other_reg, othre_reg3;\n");
+                       printf("\tint other_reg, other_reg3;\n");
                        break;
                case 6:
-                       printf("\tint other_reg2, othre_reg3;\n");
+                       printf("\tint other_reg2, other_reg3;\n");
                        break;
                case 7:
-                       printf("\tint other_reg, other_reg2, othre_reg3;\n");
+                       printf("\tint other_reg, other_reg2, other_reg3;\n");
                        break;
                }
        }
@@ -447,17 +443,6 @@ static void gensel_declare_regs(gensel_clause_t clauses, gensel_option_t options
                printf("\tjit_nint imm_value, imm_value2, imm_value3;\n");
                break;
        }
-       for(scratch = 0; scratch < max_scratch; scratch++)
-       {
-               if((scratch + max_regs) == 0)
-               {
-                       printf("\tint reg;\n");
-               }
-               else
-               {
-                       printf("\tint reg%d;\n", scratch + max_regs + 1);
-               }
-       }
        if(have_local)
        {
                printf("\tjit_nint local_offset;\n");
@@ -490,6 +475,10 @@ gensel_build_index(gensel_option_t pattern, char *names[9], char *other_names[9]
        {
                switch(pattern->option)
                {
+               case GENSEL_PATT_ANY:
+                       ++index;
+                       break;
+
                case GENSEL_PATT_REG:
                case GENSEL_PATT_FREG:
                        names[index] = gensel_reg_names[regs];
@@ -541,7 +530,7 @@ gensel_build_index(gensel_option_t pattern, char *names[9], char *other_names[9]
  * Output the code.
  */
 static void
-gensel_output_code(gensel_option_t pattern, char *code)
+gensel_output_code(gensel_option_t pattern, char *code, int in_line)
 {
        char *names[9];
        char *other_names[9];
@@ -550,7 +539,10 @@ gensel_output_code(gensel_option_t pattern, char *code)
        gensel_build_index(pattern, names, other_names);
 
        /* Output the clause code */
-       printf("\t\t");
+       if(!in_line)
+       {
+               printf("\t\t");
+       }
        while(*code != '\0')
        {
                if(*code == '$' && code[1] >= '1' && code[1] <= '9')
@@ -577,7 +569,10 @@ gensel_output_code(gensel_option_t pattern, char *code)
                        ++code;
                }
        }
-       printf("\n");
+       if(!in_line)
+       {
+               printf("\n");
+       }
 }
 
 /*
@@ -589,7 +584,7 @@ gensel_output_clause_code(gensel_clause_t clause)
        /* Output the line number information from the original file */
        printf("#line %ld \"%s\"\n", clause->linenum, clause->filename);
 
-       gensel_output_code(clause->pattern, clause->code);
+       gensel_output_code(clause->pattern, clause->code, 0);
 }
 
 /*
@@ -614,7 +609,7 @@ static void gensel_output_clause(gensel_clause_t clause, gensel_option_t options
                if(space && space->values && space->values->value)
                {
                        printf("(");
-                       gensel_output_code(clause->pattern, space->values->value);
+                       gensel_output_code(clause->pattern, space->values->value, 1);
                        printf(")");
                }
                else
@@ -742,10 +737,14 @@ static void gensel_output_clauses(gensel_clause_t clauses, gensel_option_t optio
                        index = 0;
                        seen_option = 0;
                        pattern = clause->pattern;
-                       while(pattern && index < MAX_INPUT)
+                       while(pattern)
                        {
                                switch(pattern->option)
                                {
+                               case GENSEL_PATT_ANY:
+                                       ++index;
+                                       break;
+
                                case GENSEL_PATT_REG:
                                case GENSEL_PATT_LREG:
                                case GENSEL_PATT_FREG:
@@ -849,7 +848,7 @@ static void gensel_output_clauses(gensel_clause_t clauses, gensel_option_t optio
                                                printf(" && ");
                                        }
                                        printf("(");
-                                       gensel_output_code(clause->pattern, pattern->values->value);
+                                       gensel_output_code(clause->pattern, pattern->values->value, 1);
                                        printf(")");
                                        seen_option = 1;
                                        break;
@@ -1027,10 +1026,14 @@ static void gensel_output_clauses(gensel_clause_t clauses, gensel_option_t optio
                regs = 0;
                index = 0;
                pattern = clause->pattern;
-               while(pattern && index < MAX_INPUT)
+               while(pattern)
                {
                        switch(pattern->option)
                        {
+                       case GENSEL_PATT_ANY:
+                               ++index;
+                               break;
+
                        case GENSEL_PATT_REG:
                        case GENSEL_PATT_FREG:
                                if(pattern->values && pattern->values->value)
@@ -1110,8 +1113,9 @@ 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_scratch(&regs, clobber);\n");
+                                                      values->value);
+                                               printf("\t\t_jit_regs_set_scratch(&regs, %s);\n",
+                                                      gensel_reg_names[regs]);
                                        }
                                        else
                                        {
@@ -1129,8 +1133,8 @@ static void gensel_output_clauses(gensel_clause_t clauses, gensel_option_t optio
                                {
                                        if(values->value && strcmp(values->value, "*") != 0)
                                        {
-                                               printf("\t\tclobber = _jit_regs_lookup(\"%s\")];\n",
-                                                      pattern->values->value);
+                                               printf("\t\tclobber = _jit_regs_lookup(\"%s\");\n",
+                                                      values->value);
                                                printf("\t\t_jit_regs_set_clobber(&regs, clobber);\n");
                                        }
                                        values = values->next;
@@ -1157,10 +1161,14 @@ static void gensel_output_clauses(gensel_clause_t clauses, gensel_option_t optio
                index = 0;
                scratch = 0;
                pattern = clause->pattern;
-               while(pattern && index < MAX_INPUT)
+               while(pattern)
                {
                        switch(pattern->option)
                        {
+                       case GENSEL_PATT_ANY:
+                               ++index;
+                               break;
+
                        case GENSEL_PATT_REG:
                        case GENSEL_PATT_FREG:
                                printf("\t\t%s = _jit_reg_info[_jit_regs_%s(&regs)].cpu_reg;\n",
@@ -1329,6 +1337,7 @@ static void gensel_output_supported(void)
 %token CODE_BLOCK              "a code block"
 %token LITERAL                 "literal string"
 %token K_PTR                   "`->'"
+%token K_ANY                   "any variable"
 %token K_REG                   "word register"
 %token K_LREG                  "long register"
 %token K_FREG                  "float register"
@@ -1624,6 +1633,7 @@ InputTag
        | K_IMMS16                      { $$ = GENSEL_PATT_IMMS16; }
        | K_IMMU16                      { $$ = GENSEL_PATT_IMMU16; }
        | K_LOCAL                       { $$ = GENSEL_PATT_LOCAL; }
+       | K_ANY                         { $$ = GENSEL_PATT_ANY; }
        ;
 
 RegTag
index 7d5cda51edfdc67060c04761b7f78e303aa4bd16..346a8f388757ea4ba12e946022fd521720b5a0ef 100644 (file)
@@ -83,6 +83,7 @@ WHITE                 [ \t\v\r\f]
 %%
 
 "->"                   { RETURNTOK(K_PTR); }
+"any"                  { RETURNTOK(K_ANY); }
 "reg"                  { RETURNTOK(K_REG); }
 "lreg"                 { RETURNTOK(K_LREG); }
 "freg"                 { RETURNTOK(K_FREG); }