From 7b8df533cad8c9a84e4da9b60f26b5109daef638 Mon Sep 17 00:00:00 2001 From: Bernhard Urban Date: Wed, 9 Jun 2010 23:25:14 +0200 Subject: [PATCH] ppc: fixed stack fail und ein kleines clean up --- gesamt_ppc/chelper.c | 18 +++++------------- gesamt_ppc/chelper.h | 1 - gesamt_ppc/code.bfe | 4 ++-- gesamt_ppc/parser.y | 4 ++-- 4 files changed, 9 insertions(+), 18 deletions(-) diff --git a/gesamt_ppc/chelper.c b/gesamt_ppc/chelper.c index c8746eb..3f4776d 100644 --- a/gesamt_ppc/chelper.c +++ b/gesamt_ppc/chelper.c @@ -23,14 +23,10 @@ void func_header(char *s, int vars, int parms, int call) need_stack = (vars || parms) && call; if(need_stack) { -#if 0 - printf("\tenter $%d, $0\n", 8*(vars + parms + 2 /* fuer rax und r10 */)); -#else /* save the link register */ - printf("\tmflr 0; stw 0,8(1)\n"); + printf("\tmflr 0; stw 0,-8(1)\n"); /* create the stack */ - printf("\tstwu 1, -64(1)\n"); -#endif + printf("\tstwu 1, -80(1)\n"); } } @@ -42,14 +38,10 @@ char *get_func_name(void) void func_footer(void) { if(need_stack) { -#if 0 - printf("\tleave\n"); -#else /* remove stack frame */ - printf("\taddi 1,1,64\n"); + printf("\taddi 1,1,80\n"); /* restore link register */ - printf("\tlwz 0,8(1); mtlr 0\n"); -#endif + printf("\tlwz 0,-8(1); mtlr 0\n"); } printf("\tblr\n\n\n"); } @@ -92,7 +84,7 @@ char *reg_64to8l(char *s) char *param_reg(int num) { - char *regs[] = {"3", "4", "5", "6", "7", "8", "9"}; + char *regs[] = {"3", "4", "5", "6", "7", "8", "9", "10"}; return regs[num]; } diff --git a/gesamt_ppc/chelper.h b/gesamt_ppc/chelper.h index 004dcdb..5c8eb27 100644 --- a/gesamt_ppc/chelper.h +++ b/gesamt_ppc/chelper.h @@ -1,6 +1,5 @@ #ifndef __CHELPER_H #define __CHELPER_H -#define VARBEGIN 5 void func_header(char *s, int vars, int parms, int call); char *get_func_name(void); diff --git a/gesamt_ppc/code.bfe b/gesamt_ppc/code.bfe index ea56365..97dc269 100644 --- a/gesamt_ppc/code.bfe +++ b/gesamt_ppc/code.bfe @@ -223,7 +223,7 @@ void make_call(struct treenode *bnode) printf("\tmr %s,20\n", param_reg(j)); } printf("\t#vars pushen\n"); - for(j = VARBEGIN; j > VARBEGIN - bnode->vars; j--) { + for(j = bnode->soffset; j < bnode->soffset + bnode->vars; j++) { printf("\tstw %s,%d(1)\n", param_reg(j), j*4); } @@ -254,7 +254,7 @@ void make_call(struct treenode *bnode) } printf("\t#vars poppen\n"); - for(j = VARBEGIN+1 - bnode->vars; j < VARBEGIN+1; j++) { + for(j = bnode->soffset + bnode->vars - 1; j > bnode->soffset - 1; j--) { printf("\tlwz %s,%d(1)\n", param_reg(j), j*4); } diff --git a/gesamt_ppc/parser.y b/gesamt_ppc/parser.y index c0088d0..ab8d442 100644 --- a/gesamt_ppc/parser.y +++ b/gesamt_ppc/parser.y @@ -178,14 +178,14 @@ Statement: @{ /* tab_clone ist hier noetig, vgl. folgendes statement * > var x := x - 1; */ - @i @Statement.sout@ = tab_add_symbol(tab_clone(@Statement.sin@), @IDENT.name@, S_VAR, 1, VARBEGIN - @Statement.vars_in@, -1); + @i @Statement.sout@ = tab_add_symbol(tab_clone(@Statement.sin@), @IDENT.name@, S_VAR, 1, @Statement.gparamges@ + @Statement.vars_in@, -1); lblcountinout() @i @Statement.vars_out@ = @Statement.vars_in@ + 1; xxputsin(@Expr.s@,) - @i @Statement.node@ = new_node(O_ASSIGN, @Expr.node@, new_param(O_ID, @IDENT.name@, TREENULL, TREENULL, VARBEGIN - @Statement.vars_in@)); + @i @Statement.node@ = new_node(O_ASSIGN, @Expr.node@, new_param(O_ID, @IDENT.name@, TREENULL, TREENULL, @Statement.gparamges@ + @Statement.vars_in@)); @reg @Statement.node@->reg = @Expr.node@->reg = next_reg((char *)NULL, @Expr.gparamges@); @gen write_tree(@Statement.node@, 0); burm_label(@Statement.node@); burm_reduce(@Statement.node@, 1); -- 2.25.1