From: Bernhard Urban Date: Sun, 6 Jun 2010 19:14:43 +0000 (+0200) Subject: gesamt: bugfix bei mehreren methodenaufrufen in einer Expr X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=uebersetzerbau-ss10.git;a=commitdiff_plain;h=2c41106ae4fd8e8b01f3e9c4ffe58f11263b318f gesamt: bugfix bei mehreren methodenaufrufen in einer Expr --- diff --git a/gesamt/chelper.c b/gesamt/chelper.c index 448b07b..25362dd 100644 --- a/gesamt/chelper.c +++ b/gesamt/chelper.c @@ -25,8 +25,8 @@ void func_header(char *s, int vars, int parms, int call) need_stack = (vars || parms) && call; if(need_stack) { printf("\tpushq %%rbp\n" - "\tmovq %%rsp, %%rbp\n", - "\tsubq $%d, %%rsp\n", 8*(vars+parms)); + "\tmovq %%rsp, %%rbp\n" + "\tsubq $%d, %%rsp\n", 8*(vars+parms+2 /* fuer rax und r10*/)); } } diff --git a/gesamt/code.bfe b/gesamt/code.bfe index 8e3dfde..9e85ee1 100644 --- a/gesamt/code.bfe +++ b/gesamt/code.bfe @@ -164,7 +164,9 @@ void gen_subspecial(struct treenode *bnode, short e) KIDKIDREG2PARM(1,0); if(e) { - printf("\tsubq $%d, %%%s\n", KIDKID_VAL(1,0), BN_REG); + if(KIDKID_VAL(1,0) != 0) { + printf("\tsubq $%d, %%%s\n", KIDKID_VAL(1,0), BN_REG); + } } else { printf("\tsubq %%%s, %%%s\n", KIDKID_REG(1,0), BN_REG); } @@ -189,7 +191,21 @@ void make_call(struct treenode *bnode) for(j = bnode->paramges; j < bnode->paramges + bnode->vars; j++) { printf("\tpushq %%%s\n", param_reg(j)); } + /* TODO: schoener machen... */ + if(strcmp(BN_REG, "rax")!=0) { + printf("\tpushq %%rax\n"); + if(strcmp(BN_REG, "r10")!=0) { + printf("\tpushq %%r10\n"); + } + } printf("\tcall %s\n", bnode->name); + if(strcmp(BN_REG, "rax")!=0) { + move("rax", BN_REG); + if(strcmp(BN_REG, "r10")!=0) { + printf("\tpopq %%r10\n"); + } + printf("\tpopq %%rax\n"); + } /* vars poppen */ for(j = bnode->paramges + bnode->vars - 1; j >= bnode->paramges; j--) {