Mercurial > hg > CbC > old > device
diff mc-nop-386.c @ 40:060d1e549fec
*** empty log message ***
author | kono |
---|---|
date | Wed, 12 Feb 2003 04:45:53 +0900 |
parents | c63c4fdeb9a7 |
children | 886ca1f2cf15 |
line wrap: on
line diff
--- a/mc-nop-386.c Tue Feb 11 22:36:51 2003 +0900 +++ b/mc-nop-386.c Wed Feb 12 04:45:53 2003 +0900 @@ -133,6 +133,7 @@ rname[dreg] spare real register regs[] virtual register usage + regv[] value in virtual register flag reg_name[rname[creg]] */ @@ -141,6 +142,7 @@ static int rname[MAX_MAX]; static int regs[MAX_MAX]; /* 使われているレジスタを示すフラグ */ static int reg_stack[MAX_MAX]; /* 実際のレジスタの領域 */ +static int regv[MAX_MAX]; /* 値が入っているかどうか */ void code_init(void) @@ -203,7 +205,7 @@ void free_register(int i) { /* いらなくなったレジスタを開放 */ - regs[i]=0; + regv[i]=regs[i]=0; } int @@ -230,6 +232,28 @@ return count; } +void +use_register_var(int i) { + regv[i]=1; +} + +static int creg_regvar = -1; +static int creg_regvar_back; +static int creg_back; + +void +creg_destroy() { + creg_back = creg; creg_regvar_back = creg_regvar; + if (creg_regvar>=0) + creg = creg_regvar; + creg_regvar=-1; +} + +void +creg_un_destroy() { + creg = creg_back; creg_regvar = creg_regvar_back; +} + void gexpr_init(void) @@ -239,16 +263,17 @@ } text_mode(); use_register(creg,REG_EAX,0); + /* use_register(dreg,REG_EDX,0); */ + creg_regvar = -1; } void emit_init(void) { int i; - for(i=0;i<REAL_MAX_REGISTER;i++) regs[i]=0; - for(i=0;i<REAL_MAX_REGISTER;i++) rname[i]=i; - creg = get_register(); - dreg = get_register(); + for(i=0;i<REAL_MAX_REGISTER;i++) { regs[i]=0; regv[i]=0;rname[i]=i;} + creg = get_register(); /* must be EAX */ + dreg = get_register(); /* must be EBX */ reg_sp = 0; text_mode(); } @@ -799,6 +824,13 @@ if(length%size_of_int) { length += size_of_int - (length%size_of_int); } + if (length==4) { + printf("\tpushl (%s)\n",register_name(creg,0)); return 1; + } + if (length==8) { + printf("\tpushl 4(%s)\n",register_name(creg,0)); + printf("\tpushl (%s)\n",register_name(creg,0)); return 2; + } /* I think, after g_expr, at least two registers are free */ printf("\tsubl $%d,%%esp\n",length); if (register_full()) {