# HG changeset patch # User kono # Date 1082606146 -32400 # Node ID f21651f853449d0799a450daf12615af27c9e7ef # Parent 7bfc1435cdc6e5012a53ef8489b8c9349f3faabe *** empty log message *** diff -r 7bfc1435cdc6 -r f21651f85344 Changes --- a/Changes Wed Apr 21 17:40:29 2004 +0900 +++ b/Changes Thu Apr 22 12:55:46 2004 +0900 @@ -3941,3 +3941,9 @@ Wed Apr 21 17:32:40 JST 2004 unsigned のcosnt計算がおかしいんじゃない? + +Thu Apr 22 12:33:04 JST 2004 + +lrexpr は、codegen で、long の計算に置き換えた方がいい? +でも、それだと、64bit 演算をサポートしているCPUがうれしく +ないか。 diff -r 7bfc1435cdc6 -r f21651f85344 mc-code-powerpc.c --- a/mc-code-powerpc.c Wed Apr 21 17:40:29 2004 +0900 +++ b/mc-code-powerpc.c Thu Apr 22 12:55:46 2004 +0900 @@ -119,7 +119,7 @@ #define register_name(i) reg_name[i] #define fregister_name(i) reg_name[i] #define lregister_name_low(i) reg_name[regv_l(i)] -#define lregister_name_high(i) reg_name[regv_l(i)] +#define lregister_name_high(i) reg_name[regv_h(i)] #define is_int_reg(i) (0<=i&&iMIN_TMP_REG;i--) { @@ -497,6 +497,7 @@ error(HPERR); return creg; } +#if 0 int get_register(void) { @@ -504,6 +505,7 @@ printf("# get_register %d\n",i); return i; } +#endif int pop_register(void) @@ -513,7 +515,7 @@ #if FLOAT_CODE int -get_dregister0(int d) +get_dregister(int d) { /* 使われていないレジスタを調べる */ int i,reg; for(i=MAX_TMP_FREG+FREG_OFFSET;i>MIN_TMP_FREG+FREG_OFFSET;i--) { @@ -542,7 +544,7 @@ error(REG_ERR); return freg; } - +#if 0 int get_dregister(int d) { @@ -550,6 +552,7 @@ printf("# get_dregister %d\n",i); return i; } +#endif int pop_fregister(void) @@ -564,7 +567,7 @@ int i; for(i=LREG_OFFSET+1;i0;i--) { if(reg_stack[i-1]>=0) printf(" %s",register_name(reg_stack[i])); } printf("\n# freg:"); - for(i=0;i0;i--) { if(freg_stack[i-1]>=0) printf(" %s",fregister_name(freg_stack[i])); } printf("\n# lreg:"); - for(i=0;i0;i--) { if(lreg_stack[i-1]>=0) @@ -1446,7 +1447,7 @@ void use_reg(int arg) { -printf("# use reg %d\n",arg); +// printf("# use reg %d\n",arg); if (arg<0||arg> REAL_MAX_REGISTER+REAL_MAX_FREGISTER+ REAL_MAX_LREGISTER) error(-1); regs[arg]=USING_REG; @@ -1804,10 +1805,9 @@ char *crn; g_expr(e1); crn=register_name(creg); - if (!lreg) lreg = get_lregister(); + creg = use_longlong(creg); printf("\tlwz %s,%d(%s)\n",crn,offset,lregister_name_low(lreg)); printf("\tlwz %s,%d(%s)\n",crn,offset+size_of_int,lregister_name_high(lreg)); - creg = lreg; return us?ULONGLONG:LONGLONG; } #endif @@ -2293,7 +2293,7 @@ set_freg(reg,mode); } else if (type==LONGLONG||type==ULONGLONG) { set_lreg(reg,mode); - use_reg(reg); + // use_reg(reg); } else { set_ireg(reg,mode); } @@ -3066,18 +3066,85 @@ /* 64bit int part */ -void lrexpr(int e1, int e2,int l1, int op) +static +cond(char *s,int l1) +{ + printf("\tb%s cr0,L_%d\n",s,l1); +} + +void +lrexpr(int e1, int e2,int l1, int op) { + int creg_save; + int e3; + g_expr(e1); + emit_lpush(); + g_expr(e2); + e3 = emit_lpop(); + + creg = regv_h[creg_save = creg]; + tosop(CMP,regv_h[e3]); + switch(op) { + case LOP+GT: + cond(code_gt(1),l1); break; + case LOP+GE: + cond(code_ge(1),l1); break; + case LOP+EQ: + cond(code_eq(1),l1); break; + case LOP+NEQ: + cond(code_eq(0),l1); break; + case LOP+LT: + cond(code_ge(0),l1); break; + case LOP+LE: + cond(code_gt(0),l1); break; + case LOP+UGT: + cond(code_ugt(1),l1); break; + case LOP+UGE: + cond(code_uge(1),l1); break; + default: + error(-1); + } + creg = regv_l[creg_save]; + tosop(CMP,regv_l[e3]); + switch(op) { + case LOP+GT: + cond(code_gt(1),l1); break; + case LOP+GE: + cond(code_ge(1),l1); break; + case LOP+EQ: + cond(code_eq(1),l1); break; + case LOP+NEQ: + cond(code_eq(0),l1); break; + case LOP+LT: + cond(code_ge(0),l1); break; + case LOP+LE: + cond(code_gt(0),l1); break; + case LOP+UGT: + cond(code_ugt(1),l1); break; + case LOP+UGE: + cond(code_uge(1),l1); break; + default: + error(-1); + } + emit_lpop_free(e3); } int lpop_register() { - return 0; + return lreg_stack[--lreg_sp]; } int emit_lpop() { - return 0; + int xreg,reg; + xreg=lpop_register(); + if (xreg<= -REG_LVAR_OFFSET) { + reg = get_lregister(); + code_lrlvar(REG_LVAR_OFFSET+xreg,reg); + free_lvar(REG_LVAR_OFFSET+xreg); + xreg = reg; + } + return xreg; } void code_lregister(int e2,int reg) diff -r 7bfc1435cdc6 -r f21651f85344 mc-codegen.c --- a/mc-codegen.c Wed Apr 21 17:40:29 2004 +0900 +++ b/mc-codegen.c Thu Apr 22 12:55:46 2004 +0900 @@ -592,6 +592,16 @@ case LOP+LE: lrexpr(caddr(e1),cadr(e1),l1,LOP+GE); return; + case LOP+UGT: + case LOP+UGE: + lrexpr(cadr(e1),caddr(e1),l1,car(e1)); + return; + case LOP+ULT: + lrexpr(caddr(e1),cadr(e1),l1,LOP+UGT); + return; + case LOP+ULE: + lrexpr(caddr(e1),cadr(e1),l1,LOP+UGE); + return; #endif case LAND: b_expr(e2,0,cond?(l2=fwdlabel()):l1,0);