changeset 205:a50f90d0b63a

*** empty log message ***
author kono
date Thu, 15 Apr 2004 01:01:51 +0900 (2004-04-14)
parents 4c614334f3d0
children 4170cefb48f6
files .gdbinit Changes mc-code-ia32.c mc-code-mips.c mc-code-powerpc.c mc-code.h mc-codegen.c
diffstat 7 files changed, 189 insertions(+), 255 deletions(-) [+]
line wrap: on
line diff
--- a/.gdbinit	Tue Apr 13 12:26:56 2004 +0900
+++ b/.gdbinit	Thu Apr 15 01:01:51 2004 +0900
@@ -1,6 +1,6 @@
 tb main
 # run  -s -ob00.s mc-parse.c
-run -Itest/ test/code-gen-all.c
+run -s -Itest/ test/code-gen-all.c
 define regs 
 printf "pc =%08x lr =%08x r0 =%08x r1 =%08x r3= %08x r4= %08x\n",$pc,$lr,$r0,$r1,$r3,$r4
 printf "r10=%08x r11=%08x r12=%08x r13=%08x r14=%08x r15=%08x\n",$r10,$r11,$r12,$r13,$r14,$r15
--- a/Changes	Tue Apr 13 12:26:56 2004 +0900
+++ b/Changes	Thu Apr 15 01:01:51 2004 +0900
@@ -3886,3 +3886,44 @@
 ����ʤ��ơ�t>0 && (car(t)==STRUCT||car(t)==UNION)) {
 ����ʤ���?
 
+
+Wed Apr 14 14:26:04 JST 2004
+
+creg �ʤ�����ɡ�ľ�ܥ쥸�����������Τ��ȡ�ʣ���쥸������
+�Ȥä� double / long �򰷤��פäƤΤ���ꤺ�餤�������顢
+register �ѿ��������Τ������󤸤�ʤ�? �Ǥ⡢���������
+�ѹ���¿���ʤ뤱��...
+
+free_register �δط������뤫�顢��äѤꡢ�����Ѥ��ʤ���
+������͡�
+
+creg/freg ��ߤ᤿�Τϡ�MIPS�� float/double ����̤���
+ɬ�פ����뤿�ᡣ���λ��ˡ�creg ��¤�β�����٤����ä�
+�ߤ������͡�
+      creg = { ireg, freg, dreg }
+�ߤ����ˤ��Ƥ��ɤ��ä��櫓����
+
+�⤷�����ơ�regv �äƻȤäƤʤ���? (��������...)
+
+register �� list �ǻ���? ����ˤ����?
+      regs[0] = glist4(LREGISTER,use,r1,r2)
+      regs[0] = glist3(REGISTER,use,r1)
+�ߤ����ʴ���? ������... ������ϡ�
+      ireg_list
+      dreg_list
+      freg_list
+      lreg_list
+���ʡ��Ǥ���? �ճ��ˤ��ɤ�������ptr cache �Υ����ɤ⤢�뤷��
+
+�ޤ���conservative �ˤ�������
+
+lreg �ϡ��Ѷ�Ū�˲������ʤ��Ȥޤ������ɡ��ɤΥ����ߥ󥰤�?
+�Ȥ�������creg �⤽�Υ����ߥ󥰤Dz��������ɤ��󤸤�ʤ�?
+�ա���
+
+gexpr_init() �Υ����ߥ󥰤Dz������Ƥ⤤��������ɡ�������ȡ�
+gexpr_0 �Dz��äƤ���Ȥ��˲�������ʤ����ɡ�
+     g[long long hoge]
+�ߤ����ʾ��Ǥϡ�����Dz��������ߤ������?
+
+use_int �Ȥ��� lreg �ϲ��������ɤ��󤸤�ʤ�?
--- a/mc-code-ia32.c	Tue Apr 13 12:26:56 2004 +0900
+++ b/mc-code-ia32.c	Thu Apr 15 01:01:51 2004 +0900
@@ -109,20 +109,20 @@
 
 static int dreg; /* general temporal register */
 
-int ia32regs[REAL_MAX_REGISTER];
-int ia32regv[REAL_MAX_REGISTER];
-int ia32rname[REAL_MAX_REGISTER];
+static int ia32regs[REAL_MAX_REGISTER];
+static int ia32regv[REAL_MAX_REGISTER];
+static int ia32rname[REAL_MAX_REGISTER];
 
-int *regv  = ia32regv;
-int *regs  = ia32regs;
+static int *regv  = ia32regv;
+static int *regs  = ia32regs;
 static int *rname = ia32rname;
 
-int ia32fregs[1];
-int ia32fregv[1];
+static int ia32fregs[1];
+static int ia32fregv[1];
 
-int freg;
-int *fregv = ia32fregv;
-int *fregs = ia32fregs;
+static int freg;
+static int *fregv = ia32fregv;
+static int *fregs = ia32fregs;
 
 
 #define REG_EAX   0
@@ -231,11 +231,6 @@
 code_gexpr(int e){
 }
 
-int
-register_var(int r) {
-    return virtual(r+REG_ESI);
-}
-
 int 
 get_register(void)
 {    /* �Ȥ��Ƥ��ʤ��쥸������Ĵ�٤� */
@@ -285,6 +280,13 @@
     return list2(LVAR,new_lvar(size_of_longlong));
 }
 
+int 
+get_lregister()
+{
+    return -1;
+}
+
+
 int
 register_full(void)
 {
--- a/mc-code-mips.c	Tue Apr 13 12:26:56 2004 +0900
+++ b/mc-code-mips.c	Thu Apr 15 01:01:51 2004 +0900
@@ -101,21 +101,18 @@
 #define FREG_FREGISTER (MAX_TMP_FREG+FREG_OFFSET)
 #define DREG_DREGISTER (2+DREG_OFFSET)
 
-int powerpc_regs[REAL_MAX_REGISTER+REAL_MAX_FREGISTER+REAL_MAX_DREGISTER];
-int powerpc_regv[REAL_MAX_REGISTER+REAL_MAX_FREGISTER+REAL_MAX_DREGISTER];
-
-int dreg_pair0[REAL_MAX_DREGISTER] = {
+static int powerpc_regs[REAL_MAX_REGISTER+REAL_MAX_FREGISTER+REAL_MAX_DREGISTER];
+
+static int dreg_pair0[REAL_MAX_DREGISTER] = {
     0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30
 };
-int dreg_pair1[REAL_MAX_DREGISTER] = {
+static int dreg_pair1[REAL_MAX_DREGISTER] = {
     1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
 };
 
-int *regv  = powerpc_regv;
-int *regs  = powerpc_regs;
+static int *regs  = powerpc_regs;
 
 static int max_reg_var, max_freg_var;
-static int cond_reg=-1,cond_freg=-1,cond_dreg=-1;
 
 static char *reg_name[] = {
     "$0","$1","$2","$3","$4","$5","$6","$7","$8","$9",
@@ -321,7 +318,6 @@
 void
 code_lvar(int e2,int creg) {
     lvar_address(e2,creg);
-    regv[creg]=1;
 }
 
 void
@@ -332,8 +328,6 @@
 
 void
 gexpr_code_init(void){
-    regv[creg]=0;
-    regv[freg]=0;
 }
 
 void
@@ -361,7 +355,6 @@
             if ((reg = get_input_register_var(reg_var,n,is_code0))) {
                 n->sc = REGISTER;
                 n->dsp = cadr(reg);
-                regv[n->dsp]= 1;
                 regs[n->dsp]= INPUT_REG;
                 reg_var++;
                 cadddr(args)=size_of_int; /* why we need this? */
@@ -370,7 +363,6 @@
             if ((reg = get_input_dregister_var(freg_var,n,is_code0,0))) {
                 n->sc = FREGISTER;
                 n->dsp = cadr(reg);
-                regv[n->dsp]= 1;
                 regs[n->dsp]= INPUT_REG;
                 freg_var++;
                 cadddr(args)=size(type); /* why we need this? */
@@ -379,7 +371,6 @@
             if ((reg = get_input_dregister_var(reg_var,n,is_code0,1))) {
                 n->sc = DREGISTER;
                 n->dsp = cadr(reg);
-                regv[n->dsp]= 1;
                 regs[n->dsp]= INPUT_REG;
                 reg_var+=2;
                 cadddr(args)=size(type); /* why we need this? */
@@ -425,7 +416,6 @@
         reg =REG_VAR_BASE-i;
         if (! regs[reg]) {       /* �Ȥ��Ƥ��ʤ��ʤ� */
             regs[reg]=USING_REG; /* ���Υ쥸������Ȥ����Ȥ������ */
-            regv[reg]=0;
 	    if (i>max_reg_var) max_reg_var=i;
 	    return reg; 
         }
@@ -512,7 +502,6 @@
         reg =FREG_VAR_BASE-i+FREG_OFFSET;
         if (! regs[reg]) {       /* �Ȥ��Ƥ��ʤ��ʤ� */
             regs[reg]=USING_REG; /* ���Υ쥸������Ȥ����Ȥ������ */
-            regv[reg]=0;
 	    if (i>max_freg_var) max_freg_var=i;
 	    return reg; 
         }
@@ -546,6 +535,11 @@
 
 #if LONGLONG_CODE
 int
+get_lregister() {
+    return -1;
+}
+
+int
 get_lregister_var(NMTBL *n)
 {
     return list2(LVAR,new_lvar(size_of_double));
@@ -566,11 +560,11 @@
     if (i<0||MAX_FREGISTER+FREG_OFFSET+REAL_MAX_DREGISTER<i) error(-1);
     if (is_double_reg(i)) {
 	i0 = dreg_pair0[i-DREG_OFFSET];
-	regv[i0]=regs[i0]=0;
+	regs[i0]=0;
 	i1 = dreg_pair1[i-DREG_OFFSET];
-	regv[i1]=regs[i1]=0;
+	regs[i1]=0;
     }
-    regv[i]=regs[i]=0;
+    regs[i]=0;
 }
 
 int
@@ -631,10 +625,10 @@
     int i,count,fcount;
     fcount = count = 0;
     for(i=0;i<MAX_REGISTER;i++) {
-        if (! regs[i] && ! regv[i]) count++;
+        if (! regs[i]) count++;
     }
     for(i=0;i<MAX_FREGISTER;i++) {
-        if (! regs[i+FREG_OFFSET] && ! regv[i+FREG_OFFSET]) fcount++;
+        if (! regs[i+FREG_OFFSET]) fcount++;
     }
     printf("# free reg %d freg %d\n",count,fcount);
     return d?fcount:count;
@@ -656,9 +650,9 @@
 free_all_register(void)
 {
     int i;
-    for(i=0;i<MAX_REGISTER;i++) { regs[i]=0; regv[i]=0; }
-    for(i=0;i<MAX_FREGISTER;i++) { regs[i+FREG_OFFSET]=0; regv[i+FREG_OFFSET]=0; }
-    for(i=0;i<MAX_DREGISTER;i++) { regs[i+DREG_OFFSET]=0; regv[i+DREG_OFFSET]=0; }
+    for(i=0;i<MAX_REGISTER;i++) { regs[i]=0; }
+    for(i=0;i<MAX_FREGISTER;i++) { regs[i+FREG_OFFSET]=0; }
+    for(i=0;i<MAX_DREGISTER;i++) { regs[i+DREG_OFFSET]=0; }
     creg = get_register();
 #if FLOAT_CODE
     freg = get_dregister(0);
@@ -686,7 +680,6 @@
 register_name(ireg),fregister_name(freg),dregister_name0(dreg));
 #if 0
     printf("\n# regs:");
-    for(i=0;i<MAX_REGISTER;i++) { printf("%d",regv[i]); }
     printf(":");
     for(i=0;i<MAX_REGISTER;i++) { printf("%d",regs[i]); }
     printf("\n# freg:");
@@ -711,18 +704,6 @@
     while(dreg_sp > 0) {
 	free_register(dreg_stack[--dreg_sp]);
     }
-    if (cond_freg!=-1) { 
-	if(car(cond_freg)==FREGISTER) free_register(cadr(cond_freg)); 
-	cond_freg=-1; 
-    }
-    if (cond_dreg!=-1) { 
-	if(car(cond_dreg)==DREGISTER) free_register(cadr(cond_dreg)); 
-	cond_dreg=-1; 
-    }
-    if (cond_reg!=-1)  { 
-	if(car(cond_reg)==REGISTER) free_register(cadr(cond_reg)); 
-	cond_reg=-1;  
-    }
     cmpreg = -1;
     text_mode();
     gexpr_code_init();
@@ -742,12 +723,6 @@
 }
 
 int
-register_var(int r) {
-    return r;
-}
-
-
-int
 get_register_var(NMTBL *n)
 {
     int i;
@@ -755,7 +730,6 @@
 	if (! regs[REG_VAR_BASE-i]) {       /* �Ȥ��Ƥ��ʤ��ʤ� */
 	    /* ���Υ쥸������Ȥ����Ȥ������ */
 	    regs[REG_VAR_BASE-i]=USING_REG; 
-	    regv[REG_VAR_BASE-i]=0;
 	    if (i>max_reg_var) max_reg_var=i;
 	    /* ���ξ���ɽ���ֹ���֤� */
 	    return list3(REGISTER,REG_VAR_BASE-i,(int)n); 
@@ -778,9 +752,7 @@
 	    if (! regs[j=(DREG_VAR_BASE-i+DREG_OFFSET)]) {       /* �Ȥ��Ƥ��ʤ��ʤ� */
 		if (regs[dreg_pair0[j]] || regs[dreg_pair1[j]]) continue;
 		regs[DREG_VAR_BASE-i+DREG_OFFSET]=USING_REG; /*���Υ쥸������Ȥ����Ȥ������*/
-		regv[DREG_VAR_BASE-i+DREG_OFFSET]=0;
 		regs[dreg_pair0[j]] = regs[dreg_pair1[j]] = USING_REG;
-		regv[dreg_pair0[j]] = regv[dreg_pair1[j]] = 0;
 		if (dreg_pair1[j]>max_reg_var) max_reg_var=dreg_pair1[j];
 		/* ���ξ���ɽ���ֹ���֤� */
 		return list3(DREGISTER,DREG_VAR_BASE-i+DREG_OFFSET,(int)n); 
@@ -791,7 +763,6 @@
 	for(i=0;i<FREG_VAR_BASE-FREG_VAR_MIN;i++) {
 	    if (! regs[FREG_VAR_BASE-i+FREG_OFFSET]) {       /* �Ȥ��Ƥ��ʤ��ʤ� */
 		regs[FREG_VAR_BASE-i+FREG_OFFSET]=USING_REG; /*���Υ쥸������Ȥ����Ȥ������*/
-		regv[FREG_VAR_BASE-i+FREG_OFFSET]=0;
 		if (i>max_freg_var) max_freg_var=i;
 		/* ���ξ���ɽ���ֹ���֤� */
 		return list3(FREGISTER,FREG_VAR_BASE-i+FREG_OFFSET,(int)n); 
@@ -809,7 +780,6 @@
     new_reg = get_register();
     reg_stack[reg_sp++] = creg;     /* push ���뤫���˥쥸������Ȥ� */
     ireg = creg = new_reg;
-    regv[creg]=1;
 }
 
 int
@@ -822,7 +792,6 @@
         code_rlvar(REG_LVAR_OFFSET+xreg,reg);
 	free_lvar(REG_LVAR_OFFSET+xreg);
 	xreg = reg;
-	regv[creg]=1;
     }
     return xreg;
 }
@@ -836,20 +805,17 @@
 void
 code_gvar(int e1,int creg) {
     printf("\tla %s,%s\n",register_name(creg),((NMTBL*)cadr(e1))->nm);
-    regv[creg]=1;
 }
 
 void
 code_rgvar(int e1,int creg) {
     printf("\tlw %s,%s\n",register_name(creg),((NMTBL*)cadr(e1))->nm);
-    regv[creg]=1;
 }
 char *cload(int sign,int sz) { return sz==1?(sign?"lbu":"lb"):(sz==size_of_short?(sign?"lhu":"lh"):"lw");}
 char *cstore(int sz) { return sz==1?"sb":(sz==size_of_short)?"sh":"sw";}
 void
 code_crgvar(int e1,int creg,int sign,int sz){
     printf("\t%s %s,%s\n",cload(sign,sz),register_name(creg),((NMTBL*)cadr(e1))->nm);
-    regv[creg]=1;
 }
 
 
@@ -857,7 +823,6 @@
 code_register(int e2,int creg) {
     if (creg!=e2)
         printf("\tmove %s,%s\n",register_name(creg),register_name(e2));
-    regv[creg]=1;
 }
 
 
@@ -865,7 +830,6 @@
 code_rlvar(int e2,int reg) {
     printf("\tlw %s,",register_name(reg));
     lvar(e2);
-    regv[creg]=1;
 }
 
 
@@ -873,21 +837,18 @@
 code_crlvar(int e2,int reg,int sign,int sz) {
     printf("\t%s %s,",cload(sign,sz),register_name(reg));
     lvar(e2);
-    regv[reg]=1;
 }
 
 
 void
 code_fname(NMTBL *n,int creg) {
     printf("\tla %s,%s\n",register_name(creg),n->nm);
-    regv[creg]=1;
 }
 
 
 void
 code_const(int e2,int creg) {
     printf("\tli %s,%d\n",register_name(creg),e2);
-    regv[creg]=1;
 }
 
 
@@ -924,7 +885,6 @@
                 register_name(cadr(e2)),register_name(cadr(e2)), dir);
         if (cadr(reg)!=e2)
             printf("\tmove %s,%s\n",register_name(cadr(reg)),register_name(e2));
-        regv[reg]=1;
         return;
     } 
     g_expr(e2);
@@ -935,7 +895,7 @@
     printf("\taddu %s,%s,%d\n",drn,drn,dir);
     printf("\t%s %s,0(%s)\n",cstore(sz),drn,xrn);
     i=creg;creg=dreg;dreg=i;
-    regv[creg]=1; ireg=creg;
+    ireg=creg;
     free_register(dreg);
 }
 
@@ -948,7 +908,6 @@
         printf("\tmove %s,%s\n",register_name(reg),register_name(cadr(e2)));
         printf("\taddu %s,%s,%d\n", 
             register_name(cadr(e2)),register_name(cadr(e2)),dir);
-        regv[reg]=1;
         return;
     } 
     g_expr(e2);
@@ -963,7 +922,7 @@
     i=creg;creg=dreg;dreg=i; 
     free_register(nreg);
     free_register(dreg);
-    regv[creg]=1; ireg=creg;
+    ireg=creg;
 }
 
 
@@ -1035,7 +994,6 @@
 code_cmp_crgvar(int e1,int sz) {
     if (cmpreg==-1) cmpreg = get_register();
     code_crgvar(cadr(e1),cmpreg,1,sz);
-    regv[cmpreg]=1;
 }
 
 
@@ -1043,7 +1001,6 @@
 code_cmp_crlvar(int e2,int sz) {
     if (cmpreg==-1) cmpreg = get_register();
     code_crlvar(e2,cmpreg,1,sz);
-    regv[cmpreg]=1;
 }
 
 
@@ -1051,7 +1008,6 @@
 code_cmp_rgvar(int e1) {
     if (cmpreg==-1) cmpreg = get_register();
     code_rgvar(e1,cmpreg);
-    regv[cmpreg]=1;
 }
 
 
@@ -1059,7 +1015,6 @@
 code_cmp_rlvar(int e2) {
     if (cmpreg==-1) cmpreg = get_register();
     code_rlvar(e2,cmpreg);
-    regv[cmpreg]=1;
 }
 
 
@@ -1067,7 +1022,6 @@
 code_cmp_register(int e2) {
     cmpreg = e2;
     /* prevent cmpreg freeing */
-    regv[cmpreg]=2;
 }
 
 
@@ -1180,8 +1134,6 @@
         }
     }
     free_register(dreg);
-    regv[from]=regv[to]=regv[dreg]=0;
-    regv[creg]=1;
 }
 
 int
@@ -1467,15 +1419,11 @@
     }
     if (ret_type==DOUBLE) {
 	set_dreg(RET_DREGISTER,0);
-        regv[dreg]=1; regv[creg]=0;
     } else if (ret_type==FLOAT) {
 	set_freg(RET_FREGISTER,0);
-        regv[freg]=1; regv[creg]=0;
     } else if (ret_type==VOID) {
-        regv[freg]=0; regv[creg]=0;
     } else {
 	set_creg(RET_REGISTER,0);
-        regv[freg]=0; regv[creg]=1;
     }
     return ret_type;
 }
@@ -1564,12 +1512,10 @@
             dregister_name0(dreg),offset,crn);
         printf("\tlw %s,%d(%s)\n",
             dregister_name1(dreg),offset+size_of_int,crn);
-        regv[creg]=0; regv[dreg]=1;
 	creg = dreg;
         return DOUBLE;
     } else {
         printf("\tl.s %s,%d(%s)\n", fregister_name(freg),offset,crn);
-        regv[creg]=0; regv[freg]=1;
 	creg = freg;
         return FLOAT;
     }
@@ -1634,7 +1580,6 @@
     } else {
         printf("\tsw %s,0(%s)\n",crn,drn);
     }
-    regv[creg]=1;
 }
 
 
@@ -1647,7 +1592,6 @@
     creg = xreg;
     if (creg!=reg)
         printf("\tmove %s,%s\n",register_name(creg),register_name(reg));
-    regv[creg]=1;
 }
 
 
@@ -1657,9 +1601,8 @@
     int xreg;
     int edx = get_register(); if(!edx) error(-1);
     xrn = register_name(xreg = emit_pop(0));       /* pop e3 value */
-    regv[xreg]=regs[xreg]=1;
+    regs[xreg]=1;
     printf("# assop\n\tmr %s,%s\n",register_name(edx),register_name(creg));
-    regv[edx]=1;
     ld_indexx(byte,0,edx,sign);
     tosop(op,xreg);
     crn = register_name(creg);
@@ -1667,7 +1610,6 @@
     printf("\t%s %s,0(%s)\n",cstore(byte),crn,drn);
     free_register(edx);
     emit_pop_free(xreg);
-    regv[creg]=1;
 }
 
 
@@ -1683,22 +1625,18 @@
 	dx = get_register(); if (dx<0) error(-1);
         code_rlvar(oreg+REG_LVAR_OFFSET,dx);
 	oreg = dx;
-        regv[oreg]=1;
     }
 
     switch(op) {
     case LSHIFT:
     case ULSHIFT:
 	shift("sll",oreg);
-	regv[creg]=1;
 	return;
     case RSHIFT:
 	shift("srl",oreg);
-	regv[creg]=1;
 	return;
     case URSHIFT:
 	shift("sra",oreg);
-	regv[creg]=1;
 	return;
     }
     orn = register_name(oreg);
@@ -1744,7 +1682,6 @@
 	error(-1);
     }
     if(oreg!=creg) free_register(oreg);
-    regv[creg]=1;
 }
 
 
@@ -1791,7 +1728,6 @@
     creg = use_int(creg);
     printf("\tli %s,%d\n",register_name(creg),e);
     cmpreg = csreg;
-    regv[cmpreg]=2; /* prevent from freeing */
 }
 
 void
@@ -1859,10 +1795,7 @@
         cond?"ne":"eq",
 	register_name(creg),register_name(cmpreg),
 	l);
-    if (regv[cmpreg]==1) {
-        free_register(cmpreg); cmpreg = -1;
-    } 
-    regv[creg]=0;
+    free_register(cmpreg); cmpreg = -1;
 }
 
 void
@@ -2320,7 +2253,6 @@
 	    printf("\tfmr %s,%s\n",fregister_name(freg),fregister_name(e2));
 	}
     }
-    regv[freg]=1;
 }
 
 void code_dassign_gvar(int e2,int freg,int d)
@@ -2333,7 +2265,6 @@
     } else {
         printf("\ts.s %s,0(%s)\n",fregister_name(freg),n->nm);
     }
-    regv[freg]=1;
 }
 
 void code_dassign_lvar(int e2,int freg,int d)
@@ -2348,7 +2279,6 @@
         printf("\ts.s %s,",fregister_name(freg));
     }
     lvar(e2);
-    regv[freg]=1;
 }
 
 void code_dassign(int e2,int freg,int d)
@@ -2360,7 +2290,6 @@
     } else {
         printf("\ts.s %s,0(%s)\n",fregister_name(freg),register_name(e2));
     }
-    regv[freg]=1;
 }
 
 void
@@ -2412,7 +2341,6 @@
         frn = fregister_name(freg);
         printf("\tli.s %s,%g\n",frn,value);
     }
-    regv[freg]=1;
 }
 
 
@@ -2436,8 +2364,6 @@
     set_dreg(RET_DREGISTER,1);
     code_dpfunc("dptoli");
     set_creg(RET_REGISTER,0);
-    regv[freg]=0;
-    regv[creg]=1;
 }
 
 void code_i2d(int creg0)
@@ -2446,8 +2372,6 @@
     set_creg(RET_REGISTER,1);
     code_dpfunc("litodp");
     set_dreg(RET_DREGISTER,0);
-    regv[freg]=1;
-    regv[creg]=0;
 }
 
 void code_d2u(int freg0)
@@ -2456,7 +2380,6 @@
     set_dreg(RET_DREGISTER,1);
     code_dpfunc("dptoul");
     set_creg(RET_REGISTER,0);
-    regv[freg]=1;
 }
 
 void code_u2d(int creg0)
@@ -2465,7 +2388,6 @@
     set_creg(RET_REGISTER,1);
     code_dpfunc("ultodp");
     set_dreg(RET_DREGISTER,0);
-    regv[freg]=1;
 }
 
 void code_d2f(int freg) {
@@ -2513,7 +2435,6 @@
     } else {
         printf("\tl.s %s,%s\n",fregister_name(freg),name);
     }
-    regv[freg]=1;
 }
 
 
@@ -2525,7 +2446,6 @@
     } else {
         printf("\tl.s %s,",fregister_name(freg)); lvar(e2);
     }
-    regv[freg]=1;
 }
 
 void code_cmp_drgvar(int e2,int d)
@@ -2537,14 +2457,12 @@
 	set_dreg(RET_DREGISTER,1);
         code_drgvar(e2,d,RET_DREGISTER+2);
 	code_dpfunc("dcmp");
-	regv[dreg]=0;
     } else {
 	frn=fregister_name(freg);
         g=get_dregister(d);
         code_drgvar(e2,d,g);
         printf("\tfc.eq.s %s,%s\n",frn,fregister_name(g));
 	free_register(g);
-	regv[freg]=0;
     }
 }
 
@@ -2557,13 +2475,11 @@
 	set_dreg(RET_DREGISTER,1);
         code_drgvar(e2,d,RET_DREGISTER+2);
 	code_dpfunc("dcmp");
-	regv[dreg]=0;
     } else {
         g=get_dregister(d);
         code_drlvar(e2,d,g);
         printf("\tc.eq.s %s,%s\n",frn,fregister_name(g));
 	free_register(g);
-	regv[freg]=0;
     }
 }
 
@@ -2592,7 +2508,6 @@
 
 void dtosop(int op,int e1)
 { 
-    regv[freg]=1;
     switch(op) {
     case FADD: dtosop0("fadd",e1,0,0); return;
     case DADD: dtosop0("dpadd",e1,1,0); return;
@@ -2638,7 +2553,6 @@
         emit_dpop_free(xreg,d);
 	creg = freg;
     }
-    regv[creg]=1;
 }
 
 
@@ -2682,7 +2596,6 @@
         free_register(g);
 	creg = freg;
     }
-    regv[creg]=1;
 }
 
 void
@@ -2727,7 +2640,6 @@
         free_register(g);
 	creg = freg;
     }
-    regv[creg]=1;
 
 }
 
@@ -2774,7 +2686,7 @@
 	reg = get_dregister(d);
         code_drlvar(REG_LVAR_OFFSET+xreg,d,reg);
 	free_lvar(REG_LVAR_OFFSET+xreg);
-	regv[reg]=1; xreg=reg;
+	xreg=reg;
     }
     return xreg;
 }
@@ -2792,11 +2704,9 @@
     if (d) {
 	dreg_stack[dreg_sp++] = dreg;     /* push ���뤫���˥쥸������Ȥ� */
 	creg = dreg = new_reg;
-	regv[dreg]=1;
     } else {
 	freg_stack[freg_sp++] = freg;     /* push ���뤫���˥쥸������Ȥ� */
 	creg = freg = new_reg;
-	regv[freg]=1;
     }
 }
 
--- a/mc-code-powerpc.c	Tue Apr 13 12:26:56 2004 +0900
+++ b/mc-code-powerpc.c	Thu Apr 15 01:01:51 2004 +0900
@@ -33,7 +33,7 @@
 static int reg_save;
 static int freg_save;
 
-static int freg,ireg;
+static int freg,ireg,lreg;
 
 int size_of_int = 4;
 int size_of_short = 2;
@@ -42,13 +42,13 @@
 int size_of_longlong = 8;
 int endian = 1;
 
-int  reg_sp;   /* REGister Stack-Pointer */
-int reg_stack[MAX_MAX];  /* �ºݤΥ쥸�������ΰ� */
+static int  reg_sp;   /* REGister Stack-Pointer */
+static int reg_stack[MAX_MAX];  /* �ºݤΥ쥸�������ΰ� */
 
 /* floating point registers */
 
-int  freg_sp;  /* floating point REGister Stack-Pointer */
-int freg_stack[MAX_MAX]; /* �ºݤΥ쥸�������ΰ� */
+static int  freg_sp;  /* floating point REGister Stack-Pointer */
+static int freg_stack[MAX_MAX]; /* �ºݤΥ쥸�������ΰ� */
 
 #define REG_fp   1
 #define REG_sp   30
@@ -66,6 +66,8 @@
 
 #define RET_REGISTER 3
 #define RET_FREGISTER (1+FREG_OFFSET)
+#define RET_LREGISTER_L 4    /* low word */
+#define RET_LREGISTER_H 3    /* high word */
 
 int MAX_REGISTER=30;             /* PowerPC�Υ쥸������10�ĤޤǻȤ�*/
 int MAX_FREGISTER=31;
@@ -84,14 +86,11 @@
 #define CREG_REGISTER  MAX_TMP_REG
 #define FREG_FREGISTER (MAX_TMP_FREG+FREG_OFFSET)
 
-int powerpc_regs[REAL_MAX_REGISTER+REAL_MAX_FREGISTER];
-int powerpc_regv[REAL_MAX_REGISTER+REAL_MAX_FREGISTER];
-
-int *regv  = powerpc_regv;
-int *regs  = powerpc_regs;
+static int powerpc_regs[REAL_MAX_REGISTER+REAL_MAX_FREGISTER];
+
+static int *regs  = powerpc_regs;
 
 static int max_reg_var, max_freg_var;
-static int cond_reg=-1,cond_freg=-1;
 
 static char *reg_name[] = {
     "r0","r1","r2","r3","r4","r5","r6","r7","r8","r9",
@@ -104,16 +103,27 @@
     "f30","f31"
 }; 
 
-#define register_name(i)  reg_name[i]
-#define fregister_name(i) reg_name[i]
-
-#define is_int_reg(i)  (0<=i&&i<REAL_MAX_REGISTER)
-#define is_float_reg(i)  (REAL_MAX_REGISTER<=i&&i<REAL_MAX_FREGISTER+REAL_MAX_REGISTER)
+#define register_name(i)  reg_name[cadr(i)]
+#define fregister_name(i) reg_name[cadr(i)]
+#define lregister_name_low(i) reg_name[cadr(i)]
+#define lregister_name_high(i) reg_name[caddr(i)]
+
+#define is_int_reg_0(i)  (0<=i&&i<REAL_MAX_REGISTER)
+#define is_float_reg_0(i)  (REAL_MAX_REGISTER<=i&&i<REAL_MAX_FREGISTER+REAL_MAX_REGISTER)
+
+#define is_int_reg(i)  (car(i)==REGISTER)
+#define is_float_reg(i)  (car(i)==DREGISTER)
+#define is_longlong_reg(i)  (car(i)==LREGISTER)
 
 
 int use_int(int i) { 
-    if (!is_int_reg(i)) i = ireg;
-    if (!regs[i]) regs[i]=1;
+    if (lreg) {
+	free_register(lreg); lreg = 0;
+    }
+    if (!is_int_reg(i)) {
+	if (!ireg) ireg = get_register();
+	i = lreg;
+    }
     return i;
 }
 
@@ -130,6 +140,13 @@
 }
 
 int use_longlong(int i) {
+    if (ireg) {
+	free_register(ireg); ireg = 0;
+    }
+    if (!is_longlong_reg(i)) {
+	if (!lreg) lreg = get_lregister();
+	i = lreg;
+    }
     return i;
 }
 
@@ -303,7 +320,6 @@
     lvar_intro(e2);
     printf("\tla %s,",register_name(creg));
     lvar(e2);
-    regv[creg]=1;
 }
 
 void
@@ -326,17 +342,17 @@
 	new_reg = get_register();
 	old_reg = creg;
 	ireg = creg = new_reg;
+	free_register(old_reg);
+	free_register(dm);
     } else if (is_float_reg(creg)) {
 	dm = get_dregister(1);
 	new_reg = get_dregister(1);
 	old_reg = creg;
 	freg = creg = new_reg;
+	free_register(old_reg);
+	free_register(dm);
     }
-    free_register(old_reg);
-    free_register(dm);
 #endif
-    regv[creg]=0;
-    regv[freg]=0;
 }
 
 void
@@ -363,29 +379,35 @@
         if (scalar(type)) {
             if ((reg = get_input_register_var(reg_var,n,is_code0))) {
                 n->sc = REGISTER;
-                n->dsp = cadr(reg);
-                regv[n->dsp]= 1;
-                regs[n->dsp]= INPUT_REG;
+                n->dsp = reg;
+                regs[cadr(n->dsp)]= INPUT_REG;
                 reg_var++;
-                cadddr(args)=size_of_int; /* why we need this? */
+                cadddr(args)=size_of_int;
             }
         } else if (type==FLOAT) {
             if ((reg = get_input_dregister_var(freg_var,n,is_code0,0))) {
                 n->sc = DREGISTER;
-                n->dsp = cadr(reg);
-                regv[n->dsp]= 1;
-                regs[n->dsp]= INPUT_REG;
+                n->dsp = reg;
+                regs[cadr(n->dsp)]= INPUT_REG;
                 freg_var++;
-                cadddr(args)=size(type); /* why we need this? */
+                cadddr(args)=size(type);
             }
         } else if (type==DOUBLE) {
             if ((reg = get_input_dregister_var(freg_var,n,is_code0,1))) {
                 n->sc = DREGISTER;
-                n->dsp = cadr(reg);
-                regv[n->dsp]= 1;
-                regs[n->dsp]= INPUT_REG;
+                n->dsp = reg;
+                regs[cadr(n->dsp)]= INPUT_REG;
                 freg_var++;
-                cadddr(args)=size(type); /* why we need this? */
+                cadddr(args)=size(type);
+            }
+        } else if (type==LONGLONG||type==ULONGLONG) {
+            if ((reg = get_input_lregister_var(reg_var,n,is_code0))) {
+                n->sc = LREGISTER;
+                n->dsp = reg;
+                regs[cadr(n->dsp)]= INPUT_REG;
+                regs[caddr(n->dsp)]= INPUT_REG;
+                reg_var+=2;
+                cadddr(args)=size(type);
             }
         }
         args = cadr(args);
@@ -401,7 +423,7 @@
     for(i=MAX_TMP_REG;i>MIN_TMP_REG;i--) {
 	if (regs[i]) continue;  /* �Ȥ��Ƥ��� */
 	regs[i]=USING_REG;      /* ���Υ쥸������Ȥ����Ȥ������ */
-	return i;               /* ���ξ���ɽ���ֹ���֤� */
+	return glist2(REGISTER,i);   /* ���ξ���ɽ���ֹ���֤� */
     }
     /* PTR_CACHE ��Ĥ֤� */
     for(i=MAX_TMP_REG;i>MIN_TMP_REG;i--) {
@@ -410,7 +432,7 @@
 	} else 
 	    continue;
 	regs[i]=USING_REG;      /* ���Υ쥸������Ȥ����Ȥ������ */
-	return i;               /* ���ξ���ɽ���ֹ���֤� */
+	return glist2(REGISTER,i);   /* ���ξ���ɽ���ֹ���֤� */
     }
     /* search register stack */
     for(i=0;i<reg_sp;i++) {
@@ -425,9 +447,8 @@
         reg =REG_VAR_BASE-i;
         if (! regs[reg]) {       /* �Ȥ��Ƥ��ʤ��ʤ� */
             regs[reg]=USING_REG; /* ���Υ쥸������Ȥ����Ȥ������ */
-            regv[reg]=0;
 	    if (i>max_reg_var) max_reg_var=i;
-	    return reg; 
+	    return glist2(REGISTER,reg);   /* ���ξ���ɽ���ֹ���֤� */
         }
     }
     /* �����Ƥ����꤬�ʤ��ʤ顢���顼 (���ä���ï���ȤäƤ��?) */
@@ -448,7 +469,7 @@
     for(i=MAX_TMP_FREG+FREG_OFFSET;i>MIN_TMP_FREG+FREG_OFFSET;i--) {
 	if (regs[i]) continue;    /* �Ȥ��Ƥ��� */
 	regs[i]=USING_REG;      /* ���Υ쥸������Ȥ����Ȥ������ */
-	return i;               /* ���ξ���ɽ���ֹ���֤� */
+	return glist2(DREGISTER,i);   /* ���ξ���ɽ���ֹ���֤� */
     }
     /* search register stack */
     for(i=0;i<freg_sp;i++) {
@@ -463,9 +484,8 @@
         reg =FREG_VAR_BASE-i+FREG_OFFSET;
         if (! regs[reg]) {       /* �Ȥ��Ƥ��ʤ��ʤ� */
             regs[reg]=USING_REG; /* ���Υ쥸������Ȥ����Ȥ������ */
-            regv[reg]=0;
 	    if (i>max_freg_var) max_freg_var=i;
-	    return reg; 
+	    return glist2(DREGISTER,reg);   /* ���ξ���ɽ���ֹ���֤� */
         }
     }
     /* �����Ƥ����꤬�ʤ��ʤ顢���顼 (���ä���ï���ȤäƤ��?) */
@@ -481,6 +501,16 @@
 
 #if LONGLONG_CODE
 int
+get_lregister()
+{
+    int h,l,h0,l0;
+    h = get_register(); h0 = cadr(h);
+    l = get_register(); l0 = cadr(l);
+    free_glist2(h); free_glist2(l);
+    return glist3(LREGISTER,l0,h0);
+}
+
+int
 get_lregister_var(NMTBL *n)
 {
     return list2(LVAR,new_lvar(size_of_longlong));
@@ -497,7 +527,7 @@
 void 
 free_register(int i) {    /* ����ʤ��ʤä��쥸�������� */
     if (i<0||MAX_FREGISTER+FREG_OFFSET<i) error(-1);
-    regv[i]=regs[i]=0;
+    regs[i]=0;
 }
 
 int
@@ -510,7 +540,20 @@
 	if (i<0||i>=MAX_INPUT_DREGISTER_VAR) return 0;
 	i = i+MIN_TMP_FREG+FREG_OFFSET;
     }
-    return list3(DREGISTER,i,(int)n);
+    return list3(DREGISTER,glist2(DREGISTER,i),(int)n);
+}
+
+int
+get_input_lregister_var(int i,NMTBL *n,int is_code)
+{
+    if (is_code) {
+	if(!(i<REG_VAR_BASE-REG_VAR_MIN)) return 0;
+	i = REG_VAR_BASE-i;
+    } else {
+	if (i<0||i>=MAX_INPUT_REGISTER_VAR) return 0;
+	i = i+MIN_TMP_REG;
+    }
+    return list3(LREGISTER,glist3(LREGISTER,i+1,i),(int)n);
 }
 
 int
@@ -523,7 +566,7 @@
 	if (i<0||i>=MAX_INPUT_REGISTER_VAR) return 0;
 	i = i+MIN_TMP_REG;
     }
-    return list3(REGISTER,i,(int)n);
+    return list3(REGISTER,glist2(REGISTER,i),(int)n);
 }
 
 /* double register case? */
@@ -538,7 +581,7 @@
 	if (i<0||i>=MAX_INPUT_REGISTER_VAR+1) return 0;
 	i = i+MIN_TMP_REG;
     }
-    return list3(REGISTER,i,(int)n);
+    return list3(REGISTER,glist2(REGISTER,i),(int)n);
 }
 
 int
@@ -547,16 +590,17 @@
     int i,count,fcount;
     fcount = count = 0;
     for(i=0;i<MAX_REGISTER;i++) {
-        if (! regs[i] && ! regv[i]) count++;
+        if (! regs[i]) count++;
     }
     for(i=0;i<MAX_FREGISTER;i++) {
-        if (! regs[i+FREG_OFFSET] && ! regv[i+FREG_OFFSET]) fcount++;
+        if (! regs[i+FREG_OFFSET]) fcount++;
     }
     printf("# free reg %d freg %d\n",count,fcount);
     return d?fcount:count;
 }
 
-int
+#if 0
+static int
 register_full(void)
 {
     int i;
@@ -567,13 +611,14 @@
     }
     return 1;    
 }
+#endif
 
 void
 free_all_register(void)
 {
     int i;
-    for(i=0;i<MAX_REGISTER;i++) { regs[i]=0; regv[i]=0; }
-    for(i=0;i<MAX_FREGISTER;i++) { regs[i+FREG_OFFSET]=0; regv[i+FREG_OFFSET]=0; }
+    for(i=0;i<MAX_REGISTER;i++) { regs[i]=0; }
+    for(i=0;i<MAX_FREGISTER;i++) { regs[i+FREG_OFFSET]=0; }
 #if FLOAT_CODE
     freg = get_dregister(1);
     set_freg(FREG_FREGISTER,0);
@@ -595,8 +640,6 @@
     printf(" creg=%s fgreg=%s",register_name(creg),fregister_name(freg));
 #if 0
     printf("\n# regs:");
-    for(i=0;i<MAX_REGISTER;i++) { printf("%d",regv[i]); }
-    printf(":");
     for(i=0;i<MAX_REGISTER;i++) { printf("%d",regs[i]); }
     printf("\n# freg:");
     for(i=0;i<MAX_FREGISTER;i++) { printf("%d",regs[i+FREG_OFFSET]); }
@@ -617,15 +660,6 @@
     while(freg_sp > 0) {
 	free_register(freg_stack[--freg_sp]);
     }
-    if (cond_freg!=-1) { 
-	if(car(cond_freg)==DREGISTER) free_register(cadr(cond_freg)); 
-	else if(car(cond_freg)==FREGISTER) free_register(cadr(cond_freg)); 
-	cond_freg=-1; 
-    }
-    if (cond_reg!=-1)  { 
-	if(car(cond_reg)==REGISTER) free_register(cadr(cond_reg)); 
-	cond_reg=-1;  
-    }
     text_mode();
     gexpr_code_init();
     register_usage("gexpr_init");
@@ -642,11 +676,6 @@
     text_mode();
 }
 
-int
-register_var(int r) {
-    return r;
-}
-
 
 int
 get_register_var(NMTBL *n)
@@ -656,7 +685,6 @@
 	if (! regs[REG_VAR_BASE-i]) {       /* �Ȥ��Ƥ��ʤ��ʤ� */
 	    /* ���Υ쥸������Ȥ����Ȥ������ */
 	    regs[REG_VAR_BASE-i]=USING_REG; 
-	    regv[REG_VAR_BASE-i]=0;
 	    if (i>max_reg_var) max_reg_var=i;
 	    /* ���ξ���ɽ���ֹ���֤� */
 	    return list3(REGISTER,REG_VAR_BASE-i,(int)n); 
@@ -677,7 +705,6 @@
     for(i=0;i<FREG_VAR_BASE-FREG_VAR_MIN;i++) {
         if (! regs[FREG_VAR_BASE-i+FREG_OFFSET]) {       /* �Ȥ��Ƥ��ʤ��ʤ� */
             regs[FREG_VAR_BASE-i+FREG_OFFSET]=USING_REG; /*���Υ쥸������Ȥ����Ȥ������*/
-            regv[FREG_VAR_BASE-i+FREG_OFFSET]=0;
 	    if (i>max_freg_var) max_freg_var=i;
 	    /* ���ξ���ɽ���ֹ���֤� */
 	    return list3(DREGISTER,FREG_VAR_BASE-i+FREG_OFFSET,(int)n); 
@@ -694,7 +721,6 @@
     new_reg = get_register();
     reg_stack[reg_sp++] = creg;     /* push ���뤫���˥쥸������Ȥ� */
     ireg = creg = new_reg;
-    regv[creg]=1;
 }
 
 int
@@ -707,7 +733,6 @@
         code_rlvar(REG_LVAR_OFFSET+xreg,reg);
 	free_lvar(REG_LVAR_OFFSET+xreg);
 	xreg = reg;
-	regv[creg]=1;
     }
     return xreg;
 }
@@ -839,7 +864,6 @@
     r = get_ptr_cache((NMTBL*)cadr(e1));
     if(r!=creg)
 	printf("\tmr %s,%s\n",register_name(creg),register_name(r));
-    regv[creg]=1;
     return;
 }
 
@@ -848,7 +872,6 @@
     if (!is_int_reg(creg)) error(-1);
     printf("\tlwz %s,0(%s)\n",register_name(creg),
                              register_name(get_ptr_cache((NMTBL*)cadr(e1))));
-    regv[creg]=1;
 }
 
 void
@@ -858,7 +881,6 @@
                              register_name(get_ptr_cache((NMTBL*)cadr(e1))));
     if (sign)
 	printf("\t%s %s,%s\n",cext(sz),crn,crn);
-    regv[creg]=1;
 }
 
 
@@ -867,7 +889,6 @@
 code_register(int e2,int creg) {
     if (creg!=e2)
 	printf("\tmr %s,%s\n",register_name(creg),register_name(e2));
-    regv[creg]=1;
 }
 
 
@@ -877,7 +898,6 @@
     if (!is_int_reg(reg)) error(-1);
     printf("\tlwz %s,",register_name(reg));
     lvar(e2);
-    regv[creg]=1;
 }
 
 void
@@ -887,7 +907,6 @@
     lvar(e2);
     if (sign)
 	printf("\t%s %s,%s\n",cext(sz),register_name(reg),register_name(reg));
-    regv[creg]=1;
 }
 
 
@@ -900,7 +919,6 @@
     r = get_ptr_cache(n);
     if(r!=creg)
 	printf("\tmr %s,%s\n",register_name(creg),register_name(r));
-    regv[creg]=1;
     return;
 }
 
@@ -914,7 +932,6 @@
 	printf("\tlis %s,ha16(%d)\n",crn,e2);
 	printf("\taddi %s,%s,lo16(%d)\n",crn,crn,e2);
     }
-    regv[creg]=1;
 }
 
 
@@ -946,7 +963,6 @@
 		register_name(cadr(e2)),register_name(cadr(e2)), dir);
 	if (cadr(reg)!=e2)
 	    printf("\tmr %s,%s\n",register_name(cadr(reg)),register_name(e2));
-	regv[reg]=1;
 	return;
     } 
     g_expr(e2);
@@ -959,7 +975,7 @@
     printf("\taddi %s,%s,%d\n",drn,drn,dir);
     printf("\t%s %s,0(%s)\n",cstore(sz),drn,xrn);
     i=creg;creg=dreg;dreg=i;
-    regv[creg]=1; ireg=creg;
+    ireg=creg;
     free_register(dreg);
 }
 
@@ -972,7 +988,6 @@
 	printf("\tmr %s,%s\n",register_name(reg),register_name(cadr(e2)));
 	printf("\taddi %s,%s,%d\n", 
 	    register_name(cadr(e2)),register_name(cadr(e2)),dir);
-	regv[reg]=1;
 	return;
     } 
     g_expr(e2);
@@ -989,7 +1004,7 @@
     i=creg;creg=dreg;dreg=i; 
     free_register(nreg);
     free_register(dreg);
-    regv[creg]=1; ireg=creg;
+    ireg=creg;
 }
 
 
@@ -1060,7 +1075,6 @@
     r = get_ptr_cache((NMTBL*)cadr(e1));
     printf("\t%s %s,0(%s)\n",cload(sz),crn,register_name(r));
     printf("\tcmpwi cr0,%s,0\n",crn);
-    regv[creg]=0;
 }
 
 
@@ -1071,7 +1085,6 @@
     printf("\t%s %s,",cload(sz),crn);
     lvar(e2);
     code_cmp_register(creg);
-    regv[creg]=0;
 }
 
 
@@ -1083,7 +1096,6 @@
     r = get_ptr_cache((NMTBL*)cadr(e1));
     printf("\tlwz %s,0(%s)\n",crn,register_name(r));
     code_cmp_register(creg);
-    regv[creg]=0;
 }
 
 
@@ -1094,7 +1106,6 @@
     printf("\tlwz %s,",crn);
     lvar(e2);
     code_cmp_register(creg);
-    regv[creg]=0;
 }
 
 
@@ -1216,8 +1227,6 @@
 	}
     }
     free_register(dreg);
-    regv[from]=regv[to]=regv[dreg]=0;
-    regv[creg]=1;
 }
 
 int
@@ -1516,12 +1525,9 @@
     }
     if (ret_type==DOUBLE||ret_type==FLOAT) {
 	set_freg(RET_FREGISTER,0);
-        regv[freg]=1; regv[creg]=0;
     } else if (ret_type==VOID) {
-        regv[freg]=0; regv[creg]=0;
     } else {
 	set_creg(RET_REGISTER,0);
-        regv[freg]=0; regv[creg]=1;
     }
     return ret_type;
 }
@@ -1610,7 +1616,6 @@
     crn=register_name(creg);
     printf("\t%s %s,%d(%s)\n",fload(d),
 	fregister_name(freg),offset,crn);
-    regv[creg]=0; regv[freg]=1;
     creg = freg;
     return DOUBLE;
 }
@@ -1677,7 +1682,6 @@
     } else {
 	printf("\tstw %s,0(%s)\n",crn,drn);
     }
-    regv[creg]=1;
 }
 
 
@@ -1690,7 +1694,6 @@
     creg = xreg;
     if (creg!=reg)
 	printf("\tmr %s,%s\n",register_name(creg),register_name(reg));
-    regv[creg]=1;
 }
 
 
@@ -1700,9 +1703,7 @@
     int xreg;
     int edx = get_register(); if(!edx) error(-1);
     xrn = register_name(xreg = emit_pop(0));       /* pop e3 value */
-    regv[xreg]=regs[xreg]=1;
     printf("# assop\n\tmr %s,%s\n",register_name(edx),register_name(creg));
-    regv[edx]=1;
     ld_indexx(byte,0,edx,sign);
     tosop(op,xreg);
     crn = register_name(creg);
@@ -1716,7 +1717,6 @@
     }
     free_register(edx);
     emit_pop_free(xreg);
-    regv[creg]=1;
 }
 
 
@@ -1732,22 +1732,18 @@
 	dx = get_register(); if (dx<0) error(-1);
         code_rlvar(oreg+REG_LVAR_OFFSET,dx);
 	oreg = dx;
-        regv[oreg]=1;
     }
 
     switch(op) {
     case LSHIFT:
     case ULSHIFT:
 	shift("slw",oreg);
-	regv[creg]=1;
 	return;
     case RSHIFT:
 	shift("sraw",oreg);
-	regv[creg]=1;
 	return;
     case URSHIFT:
 	shift("srw",oreg);
-	regv[creg]=1;
 	return;
     }
     orn = register_name(oreg);
@@ -1803,7 +1799,6 @@
 	error(-1);
     }
     if(oreg!=creg) free_register(oreg);
-    regv[creg]=1;
 }
 
 int 
@@ -2408,7 +2403,6 @@
 	if (is_int_reg(e2)) error(-1);
 	printf("\tfmr %s,%s\n",fregister_name(freg),fregister_name(e2));
     }
-    regv[freg]=1;
 }
 
 void code_dassign_gvar(int e2,int freg,int d)
@@ -2417,7 +2411,6 @@
     r = get_ptr_cache((NMTBL*)cadr(e2));
     if (!is_float_reg(freg)) error(-1);
     printf("\t%s %s,0(%s)\n",fstore(d),fregister_name(freg),register_name(r));
-    regv[freg]=1;
 }
 
 void code_dassign_lvar(int e2,int freg,int d)
@@ -2426,14 +2419,12 @@
     if (!is_float_reg(freg)) error(-1);
     printf("\t%s %s,",fstore(d),fregister_name(freg));
     lvar(e2);
-    regv[freg]=1;
 }
 
 void code_dassign(int e2,int freg,int d)
 { 
     if (!is_float_reg(freg)) error(-1);
     printf("\t%s %s,0(%s)\n",fstore(d),fregister_name(freg),register_name(e2));
-    regv[freg]=1;
 }
 
 void
@@ -2512,7 +2503,6 @@
 	printf("\tlfs %s,0(%s)\n",frn,rrn);
     }
     free_register(r);
-    regv[freg]=1;
 }
 
 
@@ -2541,7 +2531,6 @@
     printf("\tstfd  %s,",frn); lvar(e2);
     lvar_intro(e2+size_of_double-size_of_int);
     printf("\tlwz %s,",crn); lvar(e2+size_of_double-size_of_int);
-    regv[creg]=1;
 }
 
 static int i2d_lib_used=0;
@@ -2580,7 +2569,6 @@
     set_creg(RET_REGISTER,1);
     printf("\tbl i2d_\n");
     set_freg(RET_FREGISTER,0);
-    regv[freg]=1;
 }
 
 static int d2u_lib_used=0;
@@ -2627,7 +2615,6 @@
     set_freg(RET_FREGISTER,1);
     printf("\tbl d2u_\n");
     set_creg(RET_REGISTER,0);
-    regv[freg]=1;
 }
 
 static int u2d_lib_used=0;
@@ -2665,7 +2652,6 @@
     set_creg(RET_REGISTER,1);
     printf("\tbl u2d_\n");
     set_freg(FREG_FREGISTER,0);
-    regv[freg]=1;
 }
 
 void code_d2f(int freg) { }
@@ -2680,7 +2666,6 @@
     int r;
     r = get_ptr_cache((NMTBL*)cadr(e2));
     printf("\t%s %s,0(%s)\n",fload(d),fregister_name(freg),register_name(r));
-    regv[freg]=1;
 }
 
 
@@ -2688,7 +2673,6 @@
 { 
     lvar_intro(e2);
     printf("\t%s %s,",fload(d),fregister_name(freg)); lvar(e2);
-    regv[freg]=1;
 }
 
 void code_cmp_drgvar(int e2,int d)
@@ -2701,7 +2685,6 @@
     printf("\t%s %s,0(%s)\n",fload(1),grn,register_name(r));
     printf("\tfcmpu cr0,%s,%s\n",frn,grn);
     free_register(g);
-    regv[freg]=0;
 }
 
 void code_cmp_drlvar(int e2,int d)
@@ -2714,7 +2697,6 @@
     printf("\t%s %s,",fload(1),grn); lvar(e2);
     printf("\tfcmpu cr0,%s,%s\n",frn,grn);
     free_register(g);
-    regv[freg]=0;
 }
 
 void dtosop(int op,int e1)
@@ -2722,7 +2704,6 @@
     char *opn="";
     char *frn=fregister_name(freg);
     char *grn=fregister_name(e1);
-    regv[freg]=1;
     switch(op) {
     case FADD:
     case DADD: opn="fadd"; break;
@@ -2746,7 +2727,6 @@
 	error(-1); return;
     }
     printf("\t%s %s,%s,%s\n",opn,frn,frn,grn);
-    regv[freg]=1;
     free_register(e1);
 }
 
@@ -2762,7 +2742,6 @@
     dtosop(op,xreg);
     printf("\t%s %s,0(%s)\n",fstore(d),frn,crn);
     emit_dpop_free(xreg,d);
-    regv[freg]=1;
 }
 
 
@@ -2795,8 +2774,6 @@
     if (!is_float_reg(freg)) error(-1);
     printf("\t%s %s,0(%s)\n",fstore(d),frn,crn);
     free_register(g);
-    regv[freg]=1;
-    regv[ireg]=0;
     creg = freg;
 }
 
@@ -2829,8 +2806,6 @@
     if (!is_float_reg(freg)) error(-1);
     printf("\t%s %s,0(%s)\n",fstore(d),grn,crn);
     free_register(g);
-    regv[freg]=1;
-    regv[ireg]=0;
     creg = freg;
 }
 
@@ -2867,7 +2842,7 @@
 	reg = get_dregister(d);
         code_drlvar(REG_LVAR_OFFSET+xreg,1,reg);
 	free_lvar(REG_LVAR_OFFSET+xreg);
-	regv[reg]=1; xreg=reg;
+	xreg=reg;
     }
     return xreg;
 }
@@ -2884,7 +2859,6 @@
     new_reg = get_dregister(1);
     freg_stack[freg_sp++] = freg;     /* push ���뤫���˥쥸������Ȥ� */
     creg = freg = new_reg;
-    regv[freg]=1;
 }
 
 #endif
--- a/mc-code.h	Tue Apr 13 12:26:56 2004 +0900
+++ b/mc-code.h	Thu Apr 15 01:01:51 2004 +0900
@@ -29,7 +29,6 @@
 
 extern void code_init();
 extern void gexpr_code_init(void);
-extern int register_var(int r);
 extern int get_register_var(NMTBL *n);
 extern int get_dregister_var(NMTBL *n,int d);
 extern int get_lregister_var(NMTBL *n);
@@ -204,6 +203,7 @@
 
 extern int get_register(void);
 extern int get_dregister(int);
+extern int get_lregister(void);
 extern void free_register(int i) ;
 extern int pop_register(void);
 extern void emit_pop_free(int xreg);
--- a/mc-codegen.c	Tue Apr 13 12:26:56 2004 +0900
+++ b/mc-codegen.c	Thu Apr 15 01:01:51 2004 +0900
@@ -841,6 +841,13 @@
 	g_expr_u(assign_expr0(e1,s,ty,ty));
 	*target = append4(*target,t,ty,e1);
 #endif
+#if LONGLONG_CODE
+    } else if (sz==size_of_longlong && (e1=get_lregister())!=-1) {
+	e1=list3(LREGISTER,e1,0);
+	*use=list3(t,*use,e1);
+	g_expr_u(assign_expr0(e1,s,ty,ty));
+	*target = append4(*target,t,ty,e1);
+#endif
     } else {
 	g_expr_u(assign_expr0((e1=list2(LVAR,new_lvar(sz))),s,ty,ty));
 	*target = append4(*target,t,ty,e1);