# HG changeset patch # User kono # Date 1088215751 -32400 # Node ID ca34f02b2056123e1e55d748ab820d46f3ecc323 # Parent 0150de6a3244e19b91c350725abc2ea2a74c4ef8 ptr cache speed up diff -r 0150de6a3244 -r ca34f02b2056 mc-code-ia32.c --- a/mc-code-ia32.c Sat Jun 26 00:26:01 2004 +0900 +++ b/mc-code-ia32.c Sat Jun 26 11:09:11 2004 +0900 @@ -341,6 +341,18 @@ } } +extern void +use_ptr_cache(int r) +{ + error(-1); +} + +extern void +code_ptr_cache_def(int r,NMTBL *nptr) +{ + error(-1); +} + int get_input_register_var(int i,NMTBL *nptr,int is_code) { diff -r 0150de6a3244 -r ca34f02b2056 mc-code-mips.c --- a/mc-code-mips.c Sat Jun 26 00:26:01 2004 +0900 +++ b/mc-code-mips.c Sat Jun 26 11:09:11 2004 +0900 @@ -24,7 +24,6 @@ static void data_mode(char *name); static void text_mode(int alignment); -static void init_ptr_cache(); static void ld_indexx(int byte, int n, int xreg,int reg,int sign); static void local_table(void); static void shift(char *op, int creg,int reg); @@ -267,7 +266,6 @@ static void code_save_stacks(); static void code_save_input_registers(int dots); -static void clear_ptr_cache_reg(int r); static void set_ireg(int,int); static void set_dreg(int,int); static void set_freg(int,int); @@ -782,6 +780,12 @@ } } +extern void +use_ptr_cache(int r) +{ + regs[r]=PTRC_REG; +} + int get_input_dregister_var(int i,NMTBL *n,int is_code,int d) { @@ -1084,80 +1088,11 @@ return xreg; } -#define MAX_PTR_CACHE 10 - -int ptr_cache=0; - -void -init_ptr_cache() -{ - int i; - for(i=0;inm); - return r; } static char *cload(int sz,int sign) { diff -r 0150de6a3244 -r ca34f02b2056 mc-code-powerpc.c --- a/mc-code-powerpc.c Sat Jun 26 00:26:01 2004 +0900 +++ b/mc-code-powerpc.c Sat Jun 26 11:09:11 2004 +0900 @@ -32,12 +32,12 @@ static void data_mode(char *name); static void text_mode(); -static void init_ptr_cache(); static void ld_indexx(int byte, int n, int xreg,int reg,int sign); static void local_table(void); static void shift(char *op, int creg,int reg); static int struct_push(int e4,int t,int arg); + static int creg; static int output_mode = TEXT_EMIT_MODE; @@ -240,7 +240,6 @@ static void code_save_stacks(); static void code_save_input_registers(int dots); -static void clear_ptr_cache_reg(int r); static void set_ireg(int,int); static void set_freg(int,int); static void set_lreg(int,int); @@ -510,11 +509,8 @@ return i; /* その場所を表す番号を返す */ } /* PTR_CACHE をつぶす */ - for(i=MAX_TMP_REG;i>MIN_TMP_REG;i--) { - if (regs[i]==PTRC_REG) { - clear_ptr_cache_reg(i); - } else - continue; + if ((i=last_ptr_cache())) { + clear_ptr_cache_reg(i); regs[i]=USING_REG; /* そのレジスタを使うことを宣言し */ return i; /* その場所を表す番号を返す */ } @@ -701,6 +697,12 @@ } } +extern void +use_ptr_cache(int r) +{ + regs[r]=PTRC_REG; +} + int get_input_dregister_var(int i,NMTBL *n,int is_code,int d) { @@ -1017,78 +1019,10 @@ static int code_base; -#define MAX_PTR_CACHE 10 - -int ptr_cache=0; - -void -init_ptr_cache() -{ - int i; - for(i=0;isc==STATIC) { printf("\taddis %s,r31,ha16(_%s-L_%d)\n", rrn,nptr->nm,code_base); @@ -1100,7 +1034,6 @@ printf("\tlwz %s,lo16(L_%s$non_lazy_ptr-L_%d)(%s)\n", rrn,nptr->nm,code_base,rrn); } - return r; } static char *cload(int sz) { return sz==1?"lbz":sz==SIZE_OF_SHORT?"lhz":"lwz"; } @@ -2970,8 +2903,8 @@ emit_longlong(int e) { #if LONGLONG_CODE + long long d = lcadr(e); data_mode(0); - long long d = lcadr(e); printf("\t.long\t0x%x,0x%x\n",code_l2(d),code_l1(d)); #endif } @@ -2980,8 +2913,8 @@ emit_double(int e) { #if FLOAT_CODE + double d = dcadr(e); data_mode(0); - double d = dcadr(e); printf("\t.long\t0x%x,0x%x\n",code_d2(d),code_d1(d)); #endif } @@ -2990,8 +2923,8 @@ emit_float(int e) { #if FLOAT_CODE + float f = dcadr(e); data_mode(0); - float f = dcadr(e); printf("\t.long\t0x%x\n",*(int *)&f); #endif } diff -r 0150de6a3244 -r ca34f02b2056 mc-code.h --- a/mc-code.h Sat Jun 26 00:26:01 2004 +0900 +++ b/mc-code.h Sat Jun 26 11:09:11 2004 +0900 @@ -52,6 +52,9 @@ extern int get_input_register_var(int,NMTBL *,int); extern int get_input_dregister_var(int,NMTBL *,int,int); extern int get_input_lregister_var(int,NMTBL *,int); +extern void code_ptr_cache_def(int r,NMTBL *nptr); +extern void use_ptr_cache(int r); + extern void emit_push(); extern int emit_pop(int type); extern void gexpr_code_init(); diff -r 0150de6a3244 -r ca34f02b2056 mc-codegen.c --- a/mc-codegen.c Sat Jun 26 00:26:01 2004 +0900 +++ b/mc-codegen.c Sat Jun 26 11:09:11 2004 +0900 @@ -3531,4 +3531,107 @@ return mask; } +#define MAX_PTR_CACHE 10 + +static int ptr_cache=0; +static int ptr_cache_last=0; + +extern void +init_ptr_cache() +{ + int i; + for(i=0;i=0;i--) { bit=1; for(j=0;j<32;j++,bit<<=1) {