Mercurial > hg > CbC > old > device
changeset 386:5b59949adc02
ARM continue... mc-parse.c compiler pass.
author | kono |
---|---|
date | Tue, 27 Jul 2004 13:52:33 +0900 |
parents | 875582d14b26 |
children | dc50ca364922 |
files | .gdbinit Changes mc-code-arm.c stdio.h |
diffstat | 4 files changed, 165 insertions(+), 103 deletions(-) [+] |
line wrap: on
line diff
--- a/.gdbinit Fri Jul 23 14:56:44 2004 +0900 +++ b/.gdbinit Tue Jul 27 13:52:33 2004 +0900 @@ -1,6 +1,6 @@ tb main # run -s test/arg.c -# run -s -ob00.s mc-parse.c +# run -s mc-parse.c # run -s nkf203/nkf.c # run -s -ob01.s mc-switch.c # run -s l.c
--- a/Changes Fri Jul 23 14:56:44 2004 +0900 +++ b/Changes Tue Jul 27 13:52:33 2004 +0900 @@ -5896,3 +5896,31 @@ Fri Jul 23 13:28:24 JST 2004 なんか頭が回らないな。 + +Sat Jul 24 19:27:55 JST 2004 + +うん。mc-arm で構文エラーがでるのは、なんかを壊しているから +なんだけど、それを直接にデバッグするのは、あんまり良い方法 +じゃないんだろう。この程度のエラーを自動的に見つけてくれるのが +欲しいよ。 + + +Tue Jul 27 13:45:21 JST 2004 + +.L183: + mov sl, r9 +.L178: + mov r9, sl +.L175: + mov sl, r9 +.L172: + mov r9, sl +.L169: + mov sl, r9 +.L166: + mov r8, sl +.L163: + +これねぇ。 + +まぁ、でも、なんとなく戻って来たか。
--- a/mc-code-arm.c Fri Jul 23 14:56:44 2004 +0900 +++ b/mc-code-arm.c Tue Jul 27 13:52:33 2004 +0900 @@ -14,6 +14,8 @@ char *l_include_path[]={ "/Developer/Zaurus-X-gcc/opt/Embedix/tools/arm-linux/include", + "/Developer/Zaurus-X-gcc/opt/Embedix/tools/arm-linux/include/linux", + "/usr/include", 0}; int data_alignment = 0; @@ -89,12 +91,12 @@ #define FREG_VAR_BASE 7 #define FREG_VAR_MIN 4 -#define MIN_TMP_FREG 0 -#define MAX_TMP_FREG 3 - -int MAX_REGISTER=16; /* ARMのレジスタを10個まで使う*/ +#define MIN_TMP_FREG 1 +#define MAX_TMP_FREG 4 + +int MAX_REGISTER=17; /* ARMのレジスタを10個まで使う*/ int MAX_FREGISTER=8; -#define REAL_MAX_REGISTER 16 /* ARMのレジスタが32ということ*/ +#define REAL_MAX_REGISTER 17 /* ARMのレジスタが32ということ*/ #define REAL_MAX_FREGISTER 8 /* ARMのレジスタが32ということ*/ #define REAL_MAX_LREGISTER 6 @@ -116,9 +118,9 @@ #define regv_h(i) regv_h0[(i)-LREG_OFFSET] #define regv_l(i) regv_l0[(i)-LREG_OFFSET] -#define RET_REGISTER 0 -#define REGISTER_OPERAND 0 -#define REGISTER_OPERAND_1 1 +#define RET_REGISTER 1 +#define REGISTER_OPERAND 1 +#define REGISTER_OPERAND_1 2 #define RET_FREGISTER FREG_OFFSET #define FREGISTER_OPERAND (FREG_OFFSET) #define FREGISTER_OPERAND_1 (FREG_OFFSET+1) @@ -126,12 +128,12 @@ #define RET_LREGISTER (LREG_OFFSET+REAL_MAX_LREGISTER) #define LREGISTER_OPERAND (LREG_OFFSET +REAL_MAX_LREGISTER +1) #define LREGISTER_OPERAND_1 (LREG_OFFSET +REAL_MAX_LREGISTER +2) -#define RET_LREGISTER_L 0 /* low word */ -#define RET_LREGISTER_H 1 /* high word */ -#define LREGISTER_OPERAND_L 0 /* low word */ -#define LREGISTER_OPERAND_H 1 /* high word */ -#define LREGISTER_OPERAND_1_L 2 /* low word */ -#define LREGISTER_OPERAND_1_H 3 /* high word */ +#define RET_LREGISTER_L 1 /* low word */ +#define RET_LREGISTER_H 2 /* high word */ +#define LREGISTER_OPERAND_L 1 /* low word */ +#define LREGISTER_OPERAND_H 2 /* high word */ +#define LREGISTER_OPERAND_1_L 3 /* low word */ +#define LREGISTER_OPERAND_1_H 4 /* high word */ #define RET_DREGISTER RET_LREGISTER #define DREGISTER_OPERAND LREGISTER_OPERAND @@ -157,7 +159,7 @@ static int max_reg_var, max_freg_var; -static char *reg_name[] = { +static char *reg_name[] = { "xx", "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "sl", "lr", "ip", "fp", "sp", "pc", "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7" @@ -569,18 +571,9 @@ regs[i]=USING_REG; /* そのレジスタを使うことを宣言し */ 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; - regs[i]=USING_REG; /* そのレジスタを使うことを宣言し */ - return i; /* その場所を表す番号を返す */ - } /* search register stack */ for(i=0;i<reg_sp;i++) { - if ((reg=reg_stack[i])>=0) { + if ((reg=reg_stack[i])>0) { code_assign_lvar( (j=new_lvar(SIZE_OF_INT)),reg,0); reg_stack[i]= j-REG_LVAR_OFFSET; @@ -590,7 +583,7 @@ #if LONGLONG_CODE||FLOAT_CODE /* search register stack */ for(i=0;i<lreg_sp;i++) { - if ((reg=lreg_stack[i])>=0) { + if ((reg=lreg_stack[i])>0) { code_lassign_lvar( (j=new_lvar(SIZE_OF_LONGLONG)),reg); lreg_stack[i]= j-REG_LVAR_OFFSET; @@ -607,6 +600,24 @@ return reg; /* その場所を表す番号を返す */ } } + /* PTR_CACHE をつぶす */ + for(i=MAX_TMP_REG;i>MIN_TMP_REG;i--) { + if (regs[i]==PTRC_REG) { + clear_ptr_cache_reg(i); + } else + continue; + regs[i]=USING_REG; /* そのレジスタを使うことを宣言し */ + return i; /* その場所を表す番号を返す */ + } + for(i=0;i<REG_VAR_BASE-REG_VAR_MIN;i++) { + reg =REG_VAR_BASE-i; + /* PTR_CACHE をつぶす */ + if (regs[reg]==PTRC_REG) { + clear_ptr_cache_reg(reg); + regs[reg]=0; + return reg; /* その場所を表す番号を返す */ + } + } /* 空いている場所がないなら、エラー (いったい誰が使ってるの?) */ error(HPERR); return creg; } @@ -964,11 +975,11 @@ if (lreg) printf(" lreg=%s,%s",lregister_name_high(lreg), lregister_name_low(lreg)); #if 1 - for(j=0,i=0;i<MAX_REGISTER;i++) if (regs[i]) j++; + for(j=0,i=1;i<MAX_REGISTER;i++) if (regs[i]) j++; if (j>USAGE_MAX) { // printf("\n# regs:01234567890123456789012"); printf("\n# regs:"); - for(i=0;i<MAX_REGISTER;i++) { printf("%d",regs[i]); } + for(i=1;i<MAX_REGISTER;i++) { printf("%d",regs[i]); } } if (reg_sp>0) { printf(" stack "); @@ -1017,7 +1028,6 @@ void gexpr_init(void) { - const_list_table(); while(reg_sp > 0) { error(-1); free_register(reg_stack[--reg_sp]); @@ -1136,6 +1146,8 @@ nth element has offset n * SIZE_OF_INT */ +#define CONST_TBL_COUNT 300 + static int search_const(int tag,int value,int *label) { @@ -1145,26 +1157,30 @@ i = 0; if(j==1) { if (!const_list_label) const_list_label = fwdlabel(); - list = const_list; *label = const_list_label; + *label = const_list_label; + if (const_list==0) { + const_list = glist3(tag,0,value); + return 0; + } else { + prev = list = const_list; + } } else { - list = prev_const_list; *label = prev_const_list_label; + prev = list = prev_const_list; *label = prev_const_list_label; } - for(p = list; p ;p=cadr(p),i+=SIZE_OF_INT) { + for(p = list; p ;prev=p,p=cadr(p),i+=SIZE_OF_INT) { if (car(p)!=tag) continue; switch(tag) { - case GVAR: - if (neqname(((char *)caddr(p)), - ((NMTBL *)value)->nm)) continue; - return i; - case CONST: case LABEL: + case GVAR: case CONST: case LABEL: if (caddr(p)!=value) continue; return i; } - prev = p; } } - cadr(p) = glist3(tag,0,value); - return i+SIZE_OF_INT; + cadr(prev) = glist3(tag,0,value); + if (i>CONST_TBL_COUNT) { + const_list_table(); + } + return i; } static int @@ -1176,11 +1192,17 @@ i = 0; if(j==1) { if (!const_list_label) const_list_label = fwdlabel(); - list = const_list; *label = const_list_label; + *label = const_list_label; + if (const_list==0) { + const_list = glist3(tag,glist3(tag,0,value2),value1); + return 0; + } else { + prev = list = const_list; + } } else { - list = prev_const_list; *label = prev_const_list_label; + prev =list = prev_const_list; *label = prev_const_list_label; } - for(p = list; p ;p=cadr(p),i+=SIZE_OF_INT) { + for(p = list; p ;prev=p,p=cadr(p),i+=SIZE_OF_INT) { if (car(p)!=tag) continue; switch(tag) { case DCONST: case LCONST: @@ -1193,39 +1215,44 @@ prev = p; } } - cadr(p) = glist3(tag,glist3(tag,0,value2),value1); - return i+SIZE_OF_INT*2; + cadr(prev) = glist3(tag,glist3(tag,0,value2),value1); + if (i>CONST_TBL_COUNT) { + const_list_table(); + } + return i; } static void const_list_table() { - int p,lb; - if (control) { - lb = fwdlabel(); - jmp(lb); - printf("\t.align\t2\n"); - } - fwddef(const_list_label); - for(p = const_list; p ; p = cadr(p)) { - switch(car(p)) { - case GVAR: printf("\t.word\t%s\n",((NMTBL *)caddr(p))->nm); break; - case CONST: printf("\t.word\t%d\n",caddr(p)); break; - case LABEL: printf("\t.word\t.L%d\n",caddr(p)); break; - default: error(-1); + int p,lb=0; + if (const_list) { + if (control) { + lb = fwdlabel(); + jmp(lb); + printf("\t.align\t2\n"); } - } - if (lb) { - fwddef(lb); + fwddef(const_list_label); + for(p = const_list; p ; p = cadr(p)) { + switch(car(p)) { + case GVAR: printf("\t.word\t%s\n",((NMTBL *)caddr(p))->nm); break; + case DCONST: case LCONST: + case CONST: printf("\t.word\t%d\n",caddr(p)); break; + case LABEL: printf("\t.word\t.L%d\n",caddr(p)); break; + default: error(-1); + } + } + if (lb) { + fwddef(lb); + } + prev_const_list_label=const_list_label; + const_list_label = 0; } free_glist3_a(prev_const_list); prev_const_list=const_list; - prev_const_list_label=const_list_label; const_list = 0; } -#define CONST_TBL_COUNT 300 - static void inc_inst(int count) { @@ -1259,6 +1286,11 @@ for(sign=1;sign>=-1;sign-=2) { int d; if (sign==1) { d = c; } else { d = mode==CMP?-c:~c; } + if (mask8(d,0)||d==0) { + min_stage=1; min_stage=1; msign = sign; + mim = d;mjm = 0;mkm = 0; + break; + } if (min_stage==1) break; for(i=24;i>=0;i-=2) { jm = km = 0; @@ -1293,8 +1325,8 @@ } } if (min_stage<=3) { - *p1 = im; *p2= jm; *p3 = km; - return sign; + *p1 = mim; *p2= mjm; *p3 = mkm; + return msign; } else return 0; } @@ -1303,7 +1335,7 @@ { int sign,p1,p2,p3; sign = make_const(c,&p1,&p2,&p3,mode); - return (p1&&!p2&&!p3)?sign:0; + return (p1==0||(p1&&!p2&&!p3))?sign:0; } @@ -1320,7 +1352,7 @@ if ((s=make_const(e2,&p1,&p2,&p3,0))) { add = s>0?"add":"sub"; mov = s>0?"mov":"mvn"; - if (p1) printf("\t%s\t%s, #%d\n",mov,crn,p1); + printf("\t%s\t%s, #%d\n",mov,crn,p1); if (p2) printf("\t%s\t%s, %s, #%d\n",add,crn,crn,p2); if (p3) printf("\t%s\t%s, %s, #%d\n",add,crn,crn,p3); } else { @@ -1345,11 +1377,11 @@ inc_inst(3); if (offset==0) { if(r!=reg) - printf("\tmov %s,%s\n",crn,rrn); + printf("\tmov\t%s, %s\n",crn,rrn); } if ((s=make_const(offset,&p1,&p2,&p3,0))) { add = s>0?"add":"sub"; - if (p1) printf("\t%s\t%s, %s, #%d\n",add,crn,rrn,p1); + printf("\t%s\t%s, %s, #%d\n",add,crn,rrn,p1); if (p2) printf("\t%s\t%s, %s, #%d\n",add,crn,rrn,p2); if (p3) printf("\t%s\t%s, %s, #%d\n",add,crn,rrn,p3); } else { @@ -1469,8 +1501,8 @@ { use_int(reg); inc_inst(2); - printf("bic %s, %s, #16711680\n",register_name(reg),register_name(reg)); - printf("bic %s, %s, #-16777216\n",register_name(reg),register_name(reg)); + printf("bic\t%s, %s, #16711680\n",register_name(reg),register_name(reg)); + printf("bic\t%s, %s, #-16777216\n",register_name(reg),register_name(reg)); } void @@ -1478,7 +1510,7 @@ use_int(reg); inc_inst(1); lvar_intro(e2); - printf("\t%s\t%s,",cload(sz,sign),register_name(reg)); + printf("\t%s\t%s, ",cload(sz,sign),register_name(reg)); lvar(e2,sz==1?" @ zero_extendqisi2":""); cext(sign,sz,reg); } @@ -1608,10 +1640,10 @@ inc_inst(1); #if R1SAVE use_int(creg); - printf("\tldr\t%s,[fp, #0]\n",register_name(creg)); + printf("\tldr\t%s, [fp, #0]\n",register_name(creg)); #else use_int(creg); - printf("\tmov\t%s,fp\n",register_name(creg)); + printf("\tmov\t%s, fp\n",register_name(creg)); #endif } @@ -1674,7 +1706,7 @@ crn = register_name(reg); lvar_intro(e2); inc_inst(1); - printf("\t%s\t%s,",cload(sz,0),crn); + printf("\t%s\t%s, ",cload(sz,0),crn); lvar(e2,sz==1?" @ zero_extendqisi2":""); cext(0,sz,reg); code_cmp_register(reg,label,cond); @@ -1696,7 +1728,7 @@ crn = register_name(reg); inc_inst(1); lvar_intro(e2); - printf("\tldr\t%s,",crn); + printf("\tldr\t%s, ",crn); lvar(e2,""); code_cmp_register(reg,label,cond); } @@ -1793,7 +1825,7 @@ code_const(length,2); /* overrap must be allowed */ inc_inst(1); - printf("\tbl %s\n",memmove); + printf("\tbl\t%s\n",memmove); extern_define(memmove,0,FUNCTION,1); fix=0; set_ireg(RET_REGISTER,0); @@ -2213,7 +2245,7 @@ } else { inc_inst(3); printf("\tmov\tlr, pc\n"); - printf("\tmov\tpc, %s\n",register_name(jmp)); + printf("\tmov\tpc, %s\n",register_name(cadr(jmp))); printf("\tldmea\tfp, {fp, sp, pc}\n"); } } @@ -2254,9 +2286,11 @@ jmp = get_register_var(0); if (!simple_arg(e2)) { e3=get_register_var(0); + reg_arg_list = list2(e3,reg_arg_list); g_expr_u(assign_expr0(e3,e2,INT,INT)); e2=e3; } + reg_arg_list = list2(jmp,reg_arg_list); arg_assign = list2(assign_expr0(jmp,e2,INT,INT),arg_assign); } /* First we execute complex argument to avoid interaction with @@ -2603,7 +2637,7 @@ crn=register_name(creg); inc_inst(1); lvar_intro(e2); - printf("\t%s\t%s,",cstore(byte),crn); + printf("\t%s\t%s, ",cstore(byte),crn); lvar(e2,""); } @@ -2626,7 +2660,7 @@ crn=register_name(creg); inc_inst(1); - printf("\t%s\t%s, [%s, #0]",cstore(byte),crn,drn); + printf("\t%s\t%s, [%s, #0]\n",cstore(byte),crn,drn); } @@ -2695,32 +2729,32 @@ switch(op) { case ADD: inc_inst(1); - printf("\tadd %s,%s,%s\n",crn,crn,orn); + printf("\tadd\t%s, %s, %s\n",crn,crn,orn); break; case SUB: inc_inst(1); - printf("\tsub %s,%s,%s\n",crn,crn,orn); + printf("\tsub\t%s, %s, %s\n",crn,crn,orn); break; case CMP: inc_inst(1); - printf("\tcmp %s,%s\n",crn,orn); + printf("\tcmp\t%s, %s\n",crn,orn); break; case BAND: inc_inst(1); - printf("\tand %s,%s,%s\n",crn,crn,orn); + printf("\tand\t%s, %s, %s\n",crn,crn,orn); break; case EOR: inc_inst(1); - printf("\teor %s,%s,%s\n",crn,crn,orn); + printf("\teor\t%s, %s, %s\n",crn,crn,orn); break; case BOR: inc_inst(1); - printf("\torr %s,%s,%s\n",crn,crn,orn); + printf("\torr\t%s, %s, %s\n",crn,crn,orn); break; case MUL: case UMUL: inc_inst(1); - printf("\tmul %s,%s,%s\n",crn,crn,orn); + printf("\tmul\t%s, %s, %s\n",crn,crn,orn); break; case DIV: code_int_lib("__divsi3",creg,oreg); break; @@ -3430,12 +3464,12 @@ { code_save_stacks(); clear_ptr_cache(); - if (reg!=REGISTER_OPERAND) code_dregister(REGISTER_OPERAND,reg,0); - if (oreg!=REGISTER_OPERAND_1) code_dregister(REGISTER_OPERAND_1,oreg,0); + if (reg!=REGISTER_OPERAND) code_register(REGISTER_OPERAND,reg); + if (oreg!=REGISTER_OPERAND_1) code_register(REGISTER_OPERAND_1,oreg); extern_conv(lib); set_ireg(RET_REGISTER,0); if (oreg!=RET_REGISTER) { - code_dregister(oreg,RET_REGISTER,0); + code_register(oreg,RET_REGISTER); } } @@ -3542,7 +3576,7 @@ use_float(d,freg); lvar_intro(e2); inc_inst(1); - printf("\t%s\t%s,",fstore(d),fregister_name(freg)); + printf("\t%s\t%s, ",fstore(d),fregister_name(freg)); lvar(e2,"@ float"); } } @@ -3748,14 +3782,14 @@ } else { // u = (d>2.1e9)?((int)(d-2.1e9)^2147483648):(int)d inc_inst(7); - if (!d) printf("\tmvfd %s, %s\n",frn,frn); + if (!d) printf("\tmvfd\t%s, %s\n",frn,frn); emit_dpush(1); code_dconst(dlist2(DCONST,2.147483648e9),USE_CREG,1); lrn = register_name(lreg = emit_dpop(d)); frn = register_name(freg); set_ireg(reg0=get_register(),0); crn = register_name(reg0); - printf("\tcmfe %s, %s\n",lrn,frn); + printf("\tcmfe\t%s, %s\n",lrn,frn); printf("\tbge\t1f\n"); printf("\tfixz\t%s, %s\n",crn,lrn); printf("\tb\t2f\n"); @@ -3940,7 +3974,7 @@ use_float(d,freg); lvar_intro(e2); inc_inst(1); - printf("\t%s\t%s,",fload(d),fregister_name(freg)); + printf("\t%s\t%s, ",fload(d),fregister_name(freg)); lvar(e2,d?"@ double":"@ float"); } } @@ -4514,7 +4548,7 @@ int emit_dpop(int d) { int xreg,reg; - if (d) { + if (!(arch_mode&UseFPP)) { return emit_lpop(); } xreg=pop_fregister(); @@ -4538,7 +4572,7 @@ emit_dpush(int d) { int new_reg; - if (d) { + if (!(arch_mode&UseFPP)) { emit_lpush(); return; } if (!is_float_reg(creg)) error(-1); @@ -5657,14 +5691,14 @@ // printf("# mask 0x%08x ~0x%08x\n",mask,~mask); inc_inst(4); code_const(~mask,tmp); - printf("\torr %s,%s,%s\n",trn,crn,trn); + printf("\torr\t%s, %s, %s\n",trn,crn,trn); /* do conjunction */ - printf("\tand %s,%s,%s\n",lrn,trn,lrn); + printf("\tand\t%s, %s, %s\n",lrn,trn,lrn); /* make or-mask */ code_const(mask,tmp); - printf("\tand %s,%s,%s\n",trn,crn,trn); + printf("\tand\t%s, %s, %s\n",trn,crn,trn); /* do disjunction */ - printf("\torr %s,%s,%s\n",crn,trn,lrn); + printf("\torr\t%s, %s, %s\n",crn,trn,lrn); } extern void