gesamt: bessere taktik zum VAR sichern
authorBernhard Urban <lewurm@gmail.com>
Mon, 7 Jun 2010 18:55:55 +0000 (20:55 +0200)
committerBernhard Urban <lewurm@gmail.com>
Mon, 7 Jun 2010 18:55:55 +0000 (20:55 +0200)
gesamt/code.bfe
gesamt/parser.y

index 9390e228a9b5da702e34a1028f892d40fff046ac..14121c9cff5246867efc17004f3175f0975943f5 100644 (file)
@@ -187,15 +187,12 @@ void assign_var(struct treenode *bnode)
        printf("\tsub $%d, %%%s\n", KIDKID_VAL(0,1), KID_REG(1));
 }
 
-/* dirty...*/
-static short xchg_param[7] = {0};
 void make_call(struct treenode *bnode)
 {
        int j;
        printf("\t//params pushen\n");
        for(j = 0; j < bnode->soffset; j++) {
-               if(xchg_param[j] == 1)
-                       printf("\txchg %%%s, %d(%%rsp)\n", param_reg(j), j*8);
+               printf("\txchg %%%s, %d(%%rsp)\n", param_reg(j), j*8);
        }
        printf("\t//vars pushen\n");
        for(j = VARBEGIN; j > VARBEGIN - bnode->vars; j--) {
@@ -233,7 +230,6 @@ void make_call(struct treenode *bnode)
 void prep_arg(struct treenode *bnode, int moveit)
 {
        printf("\t//args-nr-> %i (%%%s) [moveit= %i]\n", bnode->soffset, param_reg(bnode->soffset), moveit);
-       xchg_param[bnode->soffset] = 1;
        if(moveit) { /* expr */
                if((BN_REG == (char *) NULL) || (bnode->kids[1] != TREENULL && bnode->kids[1]->op == O_ID && bnode->kids[1]->kids[0] == TREENULL && bnode->kids[1]->kids[1] == TREENULL)) {
                        if(bnode->kids[1]->name != (char *) NULL && strcmp(bnode->kids[1]->name,"this")!=0) {
@@ -241,7 +237,6 @@ void prep_arg(struct treenode *bnode, int moveit)
                                printf("\tpushq %%%s\n", KID_REG(1));
                        } else {
                                printf("\tpushq %%%s\n", param_reg(bnode->soffset));
-                               xchg_param[bnode->soffset] = 0;
                        }
                } else {
                        printf("\tpushq %%%s\n", BN_REG);
@@ -249,9 +244,6 @@ void prep_arg(struct treenode *bnode, int moveit)
        } else { /* just O_ID */
                KIDREG2PARM(0);
                printf("\tpushq %%%s\n", KID_REG(0));
-               if(strcmp(KID_REG(0), param_reg(bnode->soffset)) == 0) {
-                       xchg_param[bnode->soffset] = 0;
-               }
        }
 }
 
index c5271db0f981e3768803b8cc1611e1d1d25c27fa..55ca382b994419b602ab8326c0fcc4c85f066068 100644 (file)
@@ -562,7 +562,7 @@ Term:
            @i {
                        @Term.node@ = new_call(@IDENT.name@, new_arg(@Exprs.node@, new_nothing(), 0) /*this*/,
                                        TREENULL, @Term.gparamges@, @Term.vars_in@);
-                       @Term.node@->soffset = @Exprs.paramcount@;
+                       @Term.node@->soffset = MAX(@Exprs.paramcount@, @Term.gparamges@);
                }
                @i @Exprs.cnt@ = 1;
                @i @Term.imm@ = 0;
@@ -575,7 +575,7 @@ Term:
            @i {
                        @Term.node@ = new_call(@IDENT.name@, new_arg(@Exprs.node@, @Term.1.node@, 0) /*this*/,
                                        TREENULL, @Term.gparamges@, @Term.vars_in@);
-                       @Term.node@->soffset = @Exprs.paramcount@;
+                       @Term.node@->soffset = MAX(@Exprs.paramcount@, @Term.gparamges@);
                }
                @i @Exprs.cnt@ = 1;
                @i @Term.imm@ = 0;