changeset 471:cfa4db8b18a5

mips float arg fix
author kono
date Tue, 08 Nov 2005 12:11:17 +0900
parents cc5ea30efe0c
children 834b5792bc5f
files Changes Makefile.mips mc-code-mips.c test/float.c
diffstat 4 files changed, 82 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/Changes	Sat Jul 30 21:38:28 2005 +0900
+++ b/Changes	Tue Nov 08 12:11:17 2005 +0900
@@ -7216,4 +7216,20 @@
 
 
 
-
+Mon Nov  7 20:30:26 JST 2005
+
+MIPS で、
+        jal fptodp
+で、呼出側の局所変数を壊すってのがまだあるらしい。
+
+じゃないみたい。
+
+> f50 では、引数は
+>        $f12,$f14,$6,$7
+> というように4つ乗るらしい。(こまったもんだ...)
+
+なんだけど、int との混在状況ではそうならないらしい。
+
+$4 が使われていると $f12 は使わずに $5 を使うという方針のようですね。
+
+
--- a/Makefile.mips	Sat Jul 30 21:38:28 2005 +0900
+++ b/Makefile.mips	Tue Nov 08 12:11:17 2005 +0900
@@ -15,7 +15,7 @@
 PRINTF= # printf.c
 CONVERTER=conv/c.o conv/null.o
 # conv/c2cbc.o conv/cbc2c.o
-COMPLIB = mc-parse.o mc-codegen.o mc-switch.o mc-macro.o mc-tree.o
+COMPLIB = mc-parse.o mc-codegen.o mc-switch.o mc-macro.o mc-tree.o mc-inline.o
 # CODE=mc-code-ia32.c
 CODE=mc-code-$(ARCH).c
 #
--- a/mc-code-mips.c	Sat Jul 30 21:38:28 2005 +0900
+++ b/mc-code-mips.c	Tue Nov 08 12:11:17 2005 +0900
@@ -29,6 +29,7 @@
 static void shift(char *op, int creg,int reg);
 static int push_struct(int e4,int t,int arg);
 static void register_usage(char *s);
+static int get_input_dregister_var0(int i,int reg_var,NMTBL *n,int is_code,int d);
 
 static int creg;
 
@@ -169,10 +170,10 @@
 #define lregister_name_low(i) reg_name[regv_l(i)]
 #define lregister_name_high(i) reg_name[regv_h(i)]
 
-char *r(i) { return register_name(i); }
-char *f(i) { return fregister_name(i); }
-char *ll(i) { return lregister_name_low(i); }
-char *lh(i) { return lregister_name_high(i); }
+char *r(int i) { return register_name(i); }
+char *f(int i) { return fregister_name(i); }
+char *ll(int i) { return lregister_name_low(i); }
+char *lh(int i) { return lregister_name_high(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)
@@ -555,7 +556,7 @@
                 cadddr(args)=SIZE_OF_INT;
             }
         } else if (type==FLOAT) {
-            if ((reg = get_input_dregister_var(freg_var,n,is_code0,0))) {
+            if ((reg = get_input_dregister_var0(freg_var,reg_var,n,is_code0,0))) {
                 n->sc = FREGISTER;
                 n->dsp = cadr(reg);
                 regs[n->dsp]= INPUT_REG;
@@ -802,8 +803,8 @@
     regs[r]=PTRC_REG;
 }
 
-int
-get_input_dregister_var(int i,NMTBL *n,int is_code,int d)
+static int
+get_input_dregister_var0(int i,int reg_var,NMTBL *n,int is_code,int d)
 {
     int j;
     if (d) {
@@ -819,8 +820,13 @@
 	if(!(i<FREG_VAR_BASE-FREG_VAR_MIN)) return 0;
 	i = FREG_VAR_BASE-i+FREG_OFFSET;
     } else {
+	/* 
+	    f50(float,float,float...) => f12,f14,$6,$7
+	    test3(int,float,float,float...) => $4,$5,$6,$7
+	*/
 	if (i==0) i=12+FREG_OFFSET;
-	else if (i==1) i=14+FREG_OFFSET;
+	else if (i==1 && reg_var==0) i=14+FREG_OFFSET;
+	else if (i==1) return list3(REGISTER,5,(int)n);
 	else if (i==2) return list3(REGISTER,6,(int)n);
 	else if (i==3) return list3(REGISTER,7,(int)n);
 	else return 0;
@@ -829,6 +835,12 @@
 }
 
 int
+get_input_dregister_var(int i,NMTBL *n,int is_code,int d)
+{
+    return get_input_dregister_var0(i,0,n,is_code,d);
+}
+
+int
 get_input_lregister_var(int i,NMTBL *n,int is_code)
 {
     int ll;
@@ -1962,6 +1974,7 @@
     int t=caddr(e3);
     if(scalar(t)) {
 	nargs ++ ; reg_arg++;
+	freg_arg++;
     } else if (t==LONGLONG||t==ULONGLONG||t==DOUBLE) {
 	if (*preg_arg%2==1) reg_arg++;  // alignment
         if (*pnargs%2==1) nargs++;  // alignment
@@ -2009,7 +2022,7 @@
 	} else if (freg_arg>=MAX_INPUT_DREGISTER_VAR) {
 	    return list3(LVAR,caller_arg_offset_v(nargs),0);
 	} else
-	    return get_input_dregister_var(freg_arg,0,0,0);
+	    return get_input_dregister_var0(freg_arg,reg_arg,0,0,0);
     } else if (t==DOUBLE) {
         if (reg_arg%2==1) reg_arg++;  // alignment
         if (nargs%2==1) nargs++;  // alignment
--- a/test/float.c	Sat Jul 30 21:38:28 2005 +0900
+++ b/test/float.c	Tue Nov 08 12:11:17 2005 +0900
@@ -5,7 +5,7 @@
 
 extern double sin(double);
 // extern float fsin(float);
-double test2(double f,int i);
+double test9(double f,int i);
 
 float f = 0.3;
 double d = 0.3;
@@ -49,6 +49,38 @@
    return (float)u;
 }
 
+void
+test1(float id, float x,float y,float sx,float sy,int behav)
+{
+    printf("%f %f %f %f %f %d\n", id,x,y,sx,sy,behav);
+}
+
+void
+test2(int id, int x,float y,float sx,float sy,int behav)
+{
+    printf("%d %d %f %f %f %d\n", id,x,y,sx,sy,behav);
+}
+
+void
+test3(int id, float x,float y,float sx,float sy,int behav)
+{
+    printf("%d %f %f %f %f %d\n", id,x,y,sx,sy,behav);
+}
+
+void
+test4(int id, float x,int y,float sx,float sy,int behav)
+{
+    printf("%d %f %d %f %f %d\n", id,x,y,sx,sy,behav);
+}
+
+void
+test5(float id, int x,float y,int sx,float sy,int behav)
+{
+    printf("%f %d %f %d %f %d\n", id,x,y,sx,sy,behav);
+}
+
+
+
 int
 main(int ac,char *av[]) {
    double g;
@@ -58,6 +90,12 @@
 
    printf("#0058:%g\n",d00);
 
+    test1(1,2,3,10,11,4);
+    test2(1,2,3,10,11,4);
+    test3(1,2,3,10,11,4);
+    test4(1,2,3,10,11,4);
+    test5(1,2,3,10,11,4);
+
    g = 1.0;
    g = -g;
    printf("#0062:%d\ncond0 ",1);
@@ -116,7 +154,7 @@
    print(1.234e-10);
 
    test1();
-   printf("#0118:nested call: %g\n",test2(test2(test2(test2(-0.333,3),5),6),7));
+   printf("#0118:nested call: %g\n",test9(test9(test9(test9(-0.333,3),5),6),7));
    return 0;
 }
 
@@ -349,3 +387,5 @@
     h =  f-0.5;
     return h/3-(3.0-(g+3)*test2(f*0.5,i-1)/(h-1));
 }
+
+