changeset 101:05f197a4573a

*** empty log message ***
author kono
date Sat, 15 Mar 2003 15:13:27 +0900
parents a9e6f2a2946f
children 3cf2f8c120b9
files .gdbinit Changes mc-code-powerpc.c mc-parse.c mc.h
diffstat 5 files changed, 65 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/.gdbinit	Fri Mar 14 22:47:13 2003 +0900
+++ b/.gdbinit	Sat Mar 15 15:13:27 2003 +0900
@@ -13,4 +13,4 @@
 x/1i $eip
 end
 b errmsg
-r -s mc-parse.c
+r -s test/float.c
--- a/Changes	Fri Mar 14 22:47:13 2003 +0900
+++ b/Changes	Sat Mar 15 15:13:27 2003 +0900
@@ -2178,4 +2178,5 @@
       f%d に対して、"saveFP+%d",68-(31-f)*4
 かな?
 
-
+うーん、これで、全部書いた気がする。でも、ほとんど全部の
+関数にバグがあるだろうなぁ。一つ一つ取っていくしかないか。
--- a/mc-code-powerpc.c	Fri Mar 14 22:47:13 2003 +0900
+++ b/mc-code-powerpc.c	Sat Mar 15 15:13:27 2003 +0900
@@ -21,7 +21,6 @@
 static int data_alignment = 0;
 
 static int code_disp_label;
-static int func_disp_label;
 
 /*
                                            -16  -8 local2   <-- r30
@@ -120,9 +119,7 @@
 char * fload(int d);
 int code_d1(double d);
 int code_d2(double d);
-void code_save_registers();
 void code_save_stacks();
-void regist_extern_function();
 void clear_ptr_cache_reg(int r);
 int fregister_var(int r);
 int get_fregister_var(void);
@@ -328,13 +325,19 @@
     int i;
     if (chk) return;
     printf("# %d: %s:",lineno,s);
-    printf(" creg=%s ",register_name(creg));
+    printf(" creg=%s fgreg=%s\n# regs:",register_name(creg),fregister_name(freg));
+#if 0
+    for(i=0;i<MAX_REGISTER;i++) {
+	printf("%d",regv[i]);
+    }
+    printf(":");
+#endif
     for(i=0;i<MAX_REGISTER;i++) {
 	printf("%d",regs[i]);
     }
-    printf(":");
-    for(i=0;i<MAX_REGISTER;i++) {
-	printf("%d",regv[i]);
+    printf("\n# freg:");
+    for(i=0;i<MAX_FREGISTER;i++) {
+	printf("%d",fregs[i]);
     }
 #if 0
     printf(" regs_stack",register_name(creg),register_name(dreg));
@@ -637,6 +640,7 @@
 	return;
     } 
     g_expr(e2);
+    crn = register_name(creg);
     dreg=get_register(); if (!dreg) error(-1);
     xrn = register_name(dreg);
     nreg=get_register(); if (!nreg) error(-1);
@@ -948,7 +952,7 @@
 	    printf("\tmr r4,%s\n",trn);
 	    printf("\tmr r3,%s\n",frn);
 	    printf("\tbl L_%s$stub\n",bcopy);
-	    regist_extern_function(bcopy);
+	    extern_define(bcopy,0,FUNCTION);
 	    break;
 	}
     }
@@ -1016,7 +1020,6 @@
     char *jrn,*crn;
 
     code_save_stacks();
-    code_save_registers();
     /* now all input register vars are free */
     e2 = cadr(e1);
     reg_arg_list = nargs = reg_arg = freg_arg = 0;
@@ -1371,7 +1374,7 @@
     if (stmode!=STATIC)
 	printf(".globl %s\n",name);
     printf("\t.type\t%s,@function\n",name);
-    printf("%s:\n",name);
+    printf("_%s:\n",name);
     code_disp_label=fwdlabel();
     printf("\tla r30,-_%d(r1)\n",code_disp_label);
 }
@@ -1405,9 +1408,9 @@
     else
 	printf("\t.align 4\n");
     if (stmode!=STATIC)
-	printf(".globl %s\n",name);
+	printf(".globl _%s\n",name);
     printf("\t.type\t%s,@function\n",name);
-    printf("%s:\n",name);
+    printf("_%s:\n",name);
     code_setup=fwdlabel();
     printf("\tmflr r0\n");
     printf("\tbl _%d\n",code_setup);
@@ -1441,8 +1444,8 @@
     if (retcont) fwddef(retcont);
     fwddef(retlabel);
     printf("\tlwz r1,0(r1)\n");
-    if (FREG_VAR_BASE-max_freg_var>0) {
-	if (REG_VAR_BASE-max_reg_var>0)
+    if (max_freg_var>0) {
+	if (max_reg_var>0)
 	    printf("\tlmw r%d,-%d(r1)\n",
 			REG_VAR_BASE-max_reg_var,reg_save_offset());
 	printf("\tb restFP+%d ; restore f%d-f31\n",
@@ -1451,7 +1454,7 @@
     } else {
 	printf("\tlwz r0,8(r1)\n");
 	printf("\tmtlr r0\n");
-	if (REG_VAR_BASE-max_reg_var>0)
+	if (max_reg_var>0)
 	    printf("\tlmw r%d,-%d(r1)\n",
 			REG_VAR_BASE-max_reg_var,reg_save_offset());
 	printf("\tblr\n");
@@ -1460,11 +1463,11 @@
     disp &= -size_of_int;
     fwddef(code_setup);
     fwddef(code_base);
-    if (REG_VAR_BASE-max_reg_var>0)
+    if (max_reg_var>0)
 	printf("\tstmw r%d,-%d(r1)\n",
 			REG_VAR_BASE-max_reg_var,reg_save_offset());
     printf("\tstwu r1,-%d(r1)\n",disp+disp_offset);
-    if (FREG_VAR_BASE-max_freg_var>0)
+    if (max_freg_var>0)
 	printf("\tb saveFP+%d ; save f%d-f31\n",
 			68-(31-FREG_VAR_BASE-max_freg_var)*4,
 			FREG_VAR_BASE-max_freg_var);
@@ -1978,7 +1981,7 @@
     r = get_ptr_cache((char*)caddr(e2));
     printf("\t%s %s,(%s)\n",fload(1),grn,register_name(r));
     printf("\tfcmpu cr0,%s,%s\n",frn,grn);
-    free_register(g);
+    free_fregister(g);
 }
 
 void code_cmp_drlvar(int e2)
@@ -1989,7 +1992,7 @@
     char *grn=fregister_name(g);
     printf("\t%s %s,%d(r1)\n",fload(1),grn,e2);
     printf("\tfcmpu cr0,%s,%s\n",frn,grn);
-    free_register(g);
+    free_fregister(g);
 }
 
 void dtosop(int op,int e1)
@@ -1999,20 +2002,20 @@
     char *grn=fregister_name(e1);
     switch(op) {
     case DADD: opn="fadd"; break;
-    case DSUB: opn="fadd"; break;
-    case DDIV: opn="fadd"; break;
-    case DMUL: opn="fadd"; break;
+    case DSUB: opn="fsub"; break;
+    case DDIV: opn="fdiv"; break;
+    case DMUL: opn="fmul"; break;
     case DCMP: 
 	printf("\tfcompu cr0,%s,%s\n",frn,grn);
-	free_register(e1);
-	break;
+	free_fregister(e1);
+	return;
     case DCMPGE: 
 	printf("\tfcompu cr7,%s,%s\n",frn,grn);
-	free_register(e1);
-	break;
+	free_fregister(e1);
+	return;
     }
     printf("\t%s %s,%s,%s\n",opn,frn,frn,grn);
-    free_register(e1);
+    free_fregister(e1);
 }
 
 void
@@ -2131,18 +2134,23 @@
 }
 
 void
-code_save_registers()
-{
-}
-
-void
 code_save_stacks()
 {
-}
-
-void
-regist_extern_function(int f)
-{
+    int i;
+    for(i=0;i<reg_sp;i++) {
+        if (reg_stack[i]>=0) {
+            code_assign_lvar(
+                lvar(reg_stack[i]=new_lvar(size_of_int)),1); 
+            reg_stack[i]= reg_stack[i]-REG_LVAR_OFFSET;
+        }
+    }
+    for(i=0;i<freg_sp;i++) {
+        if (freg_stack[i]>=0) {
+            code_dassign_lvar(
+                lvar(freg_stack[i]=new_lvar(size_of_double)),1); 
+            freg_stack[i]= freg_stack[i]-REG_LVAR_OFFSET;
+        }
+    }
 }
 
 void
--- a/mc-parse.c	Fri Mar 14 22:47:13 2003 +0900
+++ b/mc-parse.c	Sat Mar 15 15:13:27 2003 +0900
@@ -3387,6 +3387,22 @@
     return 1;
 }
 
+void
+extern_define(char *s,int dsp,int type)
+{
+    NMTBL *nptr0;
+    int i;
+
+    hash=0; name=namebuf; i=0;
+    while((name[i++] = *s)) {
+        hash=((7*hash) ^ *s++);
+    }
+    if (cheapp+i >= cheap+CHEAPSIZE) error(STRERR);
+    name[i++] = 0;
+    (nptr0 = gsearch())->sc = EXTRN;
+    nptr0->dsp = dsp; nptr0->ty=type;
+}
+
 static void
 macro_define(char *macro)
 {
--- a/mc.h	Fri Mar 14 22:47:13 2003 +0900
+++ b/mc.h	Sat Mar 15 15:13:27 2003 +0900
@@ -298,6 +298,7 @@
 
 extern Converter *conv;
 
+EXTERN void extern_define(char *s,int dsp,int type);
 EXTERN void error(int n);
 EXTERN int append4(int p,int a1,int a2,int a3);
 EXTERN int assign_expr(int e1,int e2,int t,int type);