Mercurial > hg > CbC > old > device
changeset 267:e7ab23c992e5
static double define fix
author | kono |
---|---|
date | Mon, 17 May 2004 11:41:51 +0900 |
parents | 86e315702d9e |
children | 3a368fc37559 |
files | .gdbinit.mips mc-code-mips.c mc-parse.c |
diffstat | 3 files changed, 59 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.gdbinit.mips Mon May 17 11:41:51 2004 +0900 @@ -0,0 +1,38 @@ +tb main +# run -s -ob00.s test/basic.c +# run -s -ob00.s mc-parse.c +run -s test/code-gen-all.c +define regs +printf "pc =%08x fp =%08x r2 =%08x r3 =%08x r4= %08x r5= %08x\n",$pc,$fp,$v0,$v1,$a0,$a1 +printf "r5 =%08x r6 =%08x r7 =%08x r8 =%08x r9 =%08x r10=%08x\n",$a2,$a3,$t0,$t1,$t2,$t3 +end +define fregs +printf "f0=%g f1=%g f2=%g f3=%g f4=%g f5=%g f6=%g\n",$f0,$f1,$f2,$f3,$f4,$f5,$f6 +printf "f10=%g f11=%g f12=%g f13=%g f14=%g f15=%g\n",$f10,$f11,$f12,$f13,$f14,$f15 +end +define allreg +printf "pc =%08x fp =%08x r2 =%08x r3 =%08x r4= %08x r5= %08x\n",$pc,$fp,$v0,$v1,$a0,$a1 +printf "r6=%08x r7=%08x r8=%08x r9=%08x r10=%08x\n",$a2,$a3,$t0,$t1,$t2 +printf "r11=%08x r12=%08x r14=%08x r15=%08x r16=%08x\n",$t3,$t4,$t5,$t6,$t7 +printf "r17=%08x r18=%08x r19=%08x r20=%08x r21=%08x\n",$s0,$s1,$s2,$s3,$s4 +printf "r22=%08x r23=%08x r24=%08x r25=%08x r26=%08x\n",$s5,$s6,$s7,$t8,$jp +printf "r27=%08x r28=%08x r29=%08x r30=%08x r31=%08x\n",$k0,$k1,$gp,$sp,$ra +printf "f0=%g f1=%g f2=%g f3=%g f4=%g f5=%g f6=%g\n",$f0,$f1,$f2,$f3,$f4,$f5,$f6 +printf "f10=%g f11=%g f12=%g f13=%g f14=%g f15=%g\n",$f10,$f11,$f12,$f13,$f14,$f15 +printf "f20=%g f21=%g f22=%g f23=%g f24=%g f25=%g\n",$f20,$f21,$f22,$f23,$f24,$f25 +end +define sh +regs +x/20i $pc-36 +end +define si +stepi +regs +x/1i $pc +end +define ni +nexti +regs +x/1i $pc +end +b errmsg
--- a/mc-code-mips.c Mon May 17 04:18:12 2004 +0900 +++ b/mc-code-mips.c Mon May 17 11:41:51 2004 +0900 @@ -2909,7 +2909,7 @@ } else if(car(e)==STRING) { if (car(n->ty)!=ARRAY || cadr(n->ty)!=CHAR) { l = fwdlabel(); - printf("\t.long L_%d\n",l); + printf("\t.long $L_%d\n",l); // printf(".cstring\n\t.align 2\n"); printf("$L_%d:\n",l); output_mode = RODATA_EMIT_MODE; @@ -2936,6 +2936,14 @@ } } +static void +comm(NMTBL *n) +{ + printf(".comm %s,%d,%d\n",n->nm,size(n->ty), + (n->ty==DOUBLE||n->ty==LONGLONG||n->ty==ULONGLONG)?8:4 + ); +} + void global_table(void) { @@ -2949,7 +2957,7 @@ data_mode(0); init=1; } - printf(".comm %s,%d\n",n->nm,size(n->ty)); + comm(n); } else if ((n->sc==STATIC) && n->dsp != -1) { /* n->dsp = -1 means initialized global */ if (init==0) { @@ -2957,7 +2965,7 @@ init=1; } printf(".local %s\n",n->nm); - printf(".comm %s,%d\n",n->nm,size(n->ty)); + comm(n); } } } @@ -2971,16 +2979,16 @@ /* static local variables */ for(n=ntable+GSYMS;n < &ntable[GSYMS+LSYMS];n++) { if (n->sc == GVAR) { - if (init==0) { - data_mode(0); - init=1; - } if (n->dsp != -1) { /* initialized static */ - printf(".local %s\n",n->nm); - printf(".comm %s,%d\n",n->nm,size(n->ty)); + if (init==0) { + data_mode(0); + init=1; + } + comm(n); } } } + text_mode(2); } void
--- a/mc-parse.c Mon May 17 04:18:12 2004 +0900 +++ b/mc-parse.c Mon May 17 11:41:51 2004 +0900 @@ -967,7 +967,8 @@ case STADECL: nsc = GVAR; ndsp = gpc; - n->dsp = ndsp; /* emit_data will override this */ + if (n->dsp!=-1) /* don't set dsp if initialzed static */ + n->dsp = ndsp; /* emit_data will override this */ if (stmode==EXTRN) nsc = EXTRN; else if (stmode==STATIC) @@ -984,6 +985,7 @@ *cheapp++ = 0; } if(sym==ASS) { + if (n->dsp==-1) error(-1); // already initialized conv->op_(sym); decl_data(type,n,0); emit_data_closing(n); @@ -3976,6 +3978,7 @@ if (nptr->sc == 0) { copy(nptr,name); nptr->sc=EMPTY; + nptr->dsp=0; } return nptr; }