changeset 150:f8271009a314

MIPS continue
author kono
date Mon, 14 Jul 2003 14:05:20 +0900
parents 0f36fdbcba9b
children 81032a1b8a5d
files Changes Makefile mc-code-mips.c mc.h
diffstat 4 files changed, 50 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
--- a/Changes	Mon Jul 14 07:56:26 2003 +0900
+++ b/Changes	Mon Jul 14 14:05:20 2003 +0900
@@ -3127,3 +3127,11 @@
 いたら気まずくない? 
 
 regv は、register rename がなければいらないんじゃない?
+
+Mon Jul 14 10:54:46 JST 2003
+
+なんかなぁ... creg/ireg/freg/dreg は、あんまり良いアイデア
+では、なかったみたい。creg は、このうちのどれかでなくては
+ならないんだが、それを保証できない。
+
+前と同じで、creg を廃止して、ireg/freg/dreg/lreg とするか?
--- a/Makefile	Mon Jul 14 07:56:26 2003 +0900
+++ b/Makefile	Mon Jul 14 14:05:20 2003 +0900
@@ -70,7 +70,8 @@
 		mc-parse.c mc-tree.c mc.h \
 	    conv/c.c conv/c.h conv/c2cbc.c conv/c2cbc.h conv/cbc2c.c \
 	    conv/cbc2c.h conv/conv.h conv/convdef.h conv/null.c conv/null.h \
-                mc-code-powerpc.c
+                mc-code-powerpc.c \
+                mc-code-mips.c
 
 clean :
 	-rm -f mc mc-ia32 mc-powerpc mc-mips *.bak *.s *.o *.cc mc mc1 mc2 a.out *~ core* */*.o *.bak test/*.s test/*.cc test/*.o test/*.bak test/*~ conv/*.s conv/*.cc conv/*.o conv/*.bak conv/*~ *.out */*.out *.i */*.i
@@ -182,3 +183,9 @@
 mc-code-powerpc.o: /usr/include/machine/ansi.h /usr/include/ppc/ansi.h
 mc-code-powerpc.o: /usr/include/machine/endian.h /usr/include/ppc/endian.h
 mc-code-powerpc.o: conv/conv.h mc-code.h mc-codegen.h
+mc-code-mips.o: mc.h /usr/include/stdio.h /usr/include/sys/types.h
+mc-code-mips.o: /usr/include/sys/appleapiopts.h /usr/include/sys/cdefs.h
+mc-code-mips.o: /usr/include/machine/types.h /usr/include/ppc/types.h
+mc-code-mips.o: /usr/include/machine/ansi.h /usr/include/ppc/ansi.h
+mc-code-mips.o: /usr/include/machine/endian.h /usr/include/ppc/endian.h
+mc-code-mips.o: conv/conv.h mc-code.h mc-codegen.h
--- a/mc-code-mips.c	Mon Jul 14 07:56:26 2003 +0900
+++ b/mc-code-mips.c	Mon Jul 14 14:05:20 2003 +0900
@@ -630,7 +630,7 @@
     for(i=0;i<MAX_DREGISTER;i++) { regs[i+DREG_OFFSET]=0; regv[i+DREG_OFFSET]=0; }
     creg = get_register();
     freg = get_dregister(0);
-    dreg = -1;
+    dreg = DREG_DREGISTER;
     set_creg(CREG_REGISTER,0);
     set_freg(FREG_FREGISTER,0);
     set_dreg(DREG_DREGISTER,0);
@@ -646,7 +646,11 @@
     if (chk) return;
     if (!lsrc) return;
     printf("# %d: %s:",lineno,s);
-    printf(" creg=%s fgreg=%s",register_name(creg),fregister_name(freg));
+    printf(" creg=%s ireg=%s freg=%s dreg=%s",
+     is_int_reg(creg)?register_name(creg):
+     is_float_reg(creg)?fregister_name(creg):
+     is_double_reg(creg)?dregister_name0(creg):"bad",
+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]); }
@@ -897,7 +901,7 @@
     printf("\taddu %s,%s,%d\n",drn,drn,caddr(e1));
     printf("\tsw %s,0(%s)\n",drn,xrn);
     i=creg;creg=dreg;dreg=i;
-    regv[creg]=1;
+    regv[creg]=1; ireg=creg;
     free_register(dreg);
 }
 
@@ -925,7 +929,7 @@
     i=creg;creg=dreg;dreg=i; 
     free_register(nreg);
     free_register(dreg);
-    regv[creg]=1;
+    regv[creg]=1; ireg=creg;
 }
 
 
@@ -953,7 +957,7 @@
     i=creg;creg=nreg;nreg=i; 
     free_register(nreg);
     free_register(dreg);
-    regv[creg]=1;
+    regv[creg]=1; ireg=creg;
 }
 
 
@@ -981,7 +985,7 @@
     i=creg;creg=nreg;nreg=i; 
     free_register(nreg);
     free_register(dreg);
-    regv[creg]=1;
+    regv[creg]=1; ireg=creg;
 }
 
 
@@ -1010,7 +1014,7 @@
     i=creg;creg=nreg;nreg=i; 
     free_register(nreg);
     free_register(dreg);
-    regv[creg]=1;
+    regv[creg]=1; ireg=creg;
 }
 
 
@@ -1039,7 +1043,7 @@
     i=creg;creg=nreg;nreg=i; 
     free_register(nreg);
     free_register(dreg);
-    regv[creg]=1;
+    regv[creg]=1; ireg=creg;
 }
 
 
@@ -1068,6 +1072,7 @@
     char *xrn;
     int e2,e3;
     b_expr(e1,1,e2=fwdlabel(),1);  /* including > < ... */
+    creg = use_int(creg);
     xrn = register_name(creg);
     printf("\tli %s,0\n",xrn);
     jmp(e3=fwdlabel());
@@ -1078,31 +1083,31 @@
 
 char *
 code_gt(int cond) {
-    return (cond?"\tslt  %s,%s,%s\n\tbeq %s,$0,%s\n":
-                 "\tslt  %s,%s,%s\n\tbne %s,$0,%s\n");
+    return (cond?"\tslt  %s,%s,%s\n\tbeq %s,$0,L%d\n":
+                 "\tslt  %s,%s,%s\n\tbne %s,$0,L%d\n");
 }
 
 char *
 code_ugt(int cond) {
-    return (cond?"\tsltu %s,%s,%s\n\tbeq %s,$0,%s\n":
-                 "\tsltu %s,%s,%s\n\tbne %s,$0,%s\n");
+    return (cond?"\tsltu %s,%s,%s\n\tbeq %s,$0,L%d\n":
+                 "\tsltu %s,%s,%s\n\tbne %s,$0,L%d\n");
 }
 
 char *
 code_ge(int cond) {
-    return (cond?"\tslt  %s,%s,%s\n\txori %s,%s,0x1\n\tbeq %s,$0,%s\n":
-                 "\tslt  %s,%s,%s\n\txori %s,%s,0x1\n\tbne %s,$0,%s\n");
+    return (cond?"\tslt  %s,%s,%s\n\txori %s,%s,0x1\n\tbeq %s,$0,L%d\n":
+                 "\tslt  %s,%s,%s\n\txori %s,%s,0x1\n\tbne %s,$0,L%d\n");
 }
 
 char *
 code_uge(int cond) {
-    return (cond?"\tsltu %s,%s,%s\n\txori %s,%s,0x1\n\tbeq %s,$0,%s\n":
-                 "\tsltu %s,%s,%s\n\txori %s,%s,0x1\n\tbne %s,$0,%s\n");
+    return (cond?"\tsltu %s,%s,%s\n\txori %s,%s,0x1\n\tbeq %s,$0,L%d\n":
+                 "\tsltu %s,%s,%s\n\txori %s,%s,0x1\n\tbne %s,$0,L%d\n");
 }
 
 char *
 code_eq(int cond) {
-    return (cond?"\tbeq %s,%s,%s\n":"\tbne %s,%s,%s\n");
+    return (cond?"\tbeq %s,%s,L%d\n":"\tbne %s,%s,L%d\n");
 }
 
 void
@@ -1299,7 +1304,7 @@
     if (!is_int_reg(reg)) error(-1);
     if (reg!=creg) {
 	if (reg!=ireg && mode) 
-            printf("\tmove %s,%s\n",register_name(reg),register_name(creg));
+            printf("\tmove %s,%s\n",register_name(reg),register_name(ireg));
 	free_register(creg);
 	creg = ireg = reg;
 	regs[creg]=1;
@@ -1431,7 +1436,7 @@
 int
 function(int e1)
 {
-    int e2,e3,e4,e5,nargs,t,r0,r1;
+    int e2,e3,e4,nargs,t;
     int arg,reg_arg,freg_arg,arg_assign;
     int dots;
     int reg_arg_list=0,ret_type,special_lvar;
@@ -1493,33 +1498,6 @@
 	    nargs ++ ; reg_arg++;
 	    continue;
 	} else if (t==DOUBLE||t==FLOAT) {
-	    if (reg_arg<MAX_INPUT_REGISTER_VAR) {
-		/* sigh... 
-                   printf requies floating value in integer registers
-                 */
-		if (car(e4)==DRLVAR) {
-		    special_lvar = cadr(e4);
-		    e5 = list2(LVAR,special_lvar);
-		} else {
-		    special_lvar = new_lvar(size_of_double);
-		    g_expr(assign_expr0(
-			(e5=list2(LVAR,special_lvar)),e4,DOUBLE,t));
-		    reg_arg_list = list2(e5,reg_arg_list);
-		    e4 = list2(DREGISTER,freg);
-		    /* freg should not change until XXX */
-		}
-		r0=get_input_register_var(reg_arg,0,0);
-		r1=get_input_register_var_1(reg_arg+1,0,0);
-		use_var(r0); /* protect from input register free */
-		use_var(r1); /* protect from input register free */
-		reg_arg_list = list2(r0,reg_arg_list);
-		reg_arg_list = list2(r1,reg_arg_list);
-		arg_assign = list2( assign_expr0(r0,e5,INT,INT), arg_assign);
-		arg_assign = list2( assign_expr0(r1,
-			list2(LVAR,special_lvar+size_of_int),
-			INT,INT), arg_assign);
-		reg_arg += 2;
-	    }
 	    if (freg_arg>=MAX_INPUT_DREGISTER_VAR) {
 		arg = list2(LVAR,caller_arg_offset_v(nargs));
 	    } else if (!simple_args(e3) && cadr(e3)) {
@@ -1840,6 +1818,7 @@
 {
     /* used in dosiwtch() */
     if(chk) return;
+    creg = use_int(creg);
     printf("\tli %s,%d\n",register_name(creg),e);
     cmpreg = csreg;
     regv[cmpreg]=2; /* prevent from freeing */
@@ -1882,7 +1861,7 @@
     g_expr(cadr(e1));
     emit_push();
     g_expr(caddr(e1));
-    cmpreg = pop_register();
+    cmpreg = emit_pop(0);
     crn = register_name(creg);
     drn = register_name(cmpreg);
 
@@ -1906,8 +1885,10 @@
 {
     if (chk) return;
     if (cmpreg==-1) error(-1);
-    printf("\tb%s %s,%s,L_%d\n",register_name(creg),register_name(cmpreg),
-        cond?"ne":"eq",l);
+    printf("\tb%s %s,%s,L_%d\n",
+        cond?"ne":"eq",
+	register_name(creg),register_name(cmpreg),
+	l);
     if (regv[cmpreg]==1) {
         free_register(cmpreg); cmpreg = -1;
     } 
@@ -2463,7 +2444,7 @@
     code_save_stacks();
     set_creg(RET_REGISTER,1);
     printf("\tjal litodp\n");
-    set_freg(RET_DREGISTER,0);
+    set_dreg(RET_DREGISTER,0);
     regv[freg]=1;
     regv[creg]=0;
 }
--- a/mc.h	Mon Jul 14 07:56:26 2003 +0900
+++ b/mc.h	Mon Jul 14 14:05:20 2003 +0900
@@ -60,9 +60,9 @@
 
 #define FLOAT	(-47)
 #define DOUBLE	(-48)
-#define DREGISTER       (REGISTER+DOP)
-#define FREGISTER       (REGISTER+FOP)
-#define LONGLONG	(-50)
+#define LONGLONG	(-49)
+#define FREGISTER       (-50)
+#define DREGISTER       (-51)
 
 #define EMPTY	(-99)