changeset 630:557b2a266f75

Intel continue...
author kono
date Tue, 10 Oct 2006 23:26:06 +0900
parents d3067773659c
children 76242dc0bbc9
files .gdbinit.i386mac Changes mc-code-ia32.c
diffstat 3 files changed, 37 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.gdbinit.i386mac	Tue Oct 10 23:26:06 2006 +0900
@@ -0,0 +1,17 @@
+tb main
+define regs 
+call (void)printf("eax=%08x ebx=%08x ecx=%08x edx=%08x\nesi=%08x edi=%08x ebp=%08x esp=%08x eip=%08x\n",$eax,$ebx,$ecx,$edx,$esi,$edi,$ebp,$esp,$eip)
+end
+define si
+stepi
+regs
+x/1i $eip
+end
+define ni
+nexti
+regs
+x/1i $eip
+end
+b errmsg
+r -s test/code-gen-all.c
+# r -s mc-code-powerpc.c
--- a/Changes	Tue Oct 10 22:35:28 2006 +0900
+++ b/Changes	Tue Oct 10 23:26:06 2006 +0900
@@ -8917,5 +8917,9 @@
 ってことは、defined  されたかどうかの attribute があった
 方がいいね。
 
-
-
+あぁ、なんか「関数呼び出す引数の分だけ、スタックを取っておいて、
+関数呼び出し時にスタックを調整するようなことはしない」
+なのか。
+
+
+
--- a/mc-code-ia32.c	Tue Oct 10 22:35:28 2006 +0900
+++ b/mc-code-ia32.c	Tue Oct 10 23:26:06 2006 +0900
@@ -1356,7 +1356,7 @@
 	text_mode(0);
     }
 #ifdef __APPLE__
-    printf("\tmovl _%d-%d(%%ebx),%s\n",lb,
+    printf("\tmovl _%d-_%d(%%ebx),%s\n",lb,
 	    goffset_label,
 	    register_name(creg,0));
 #else
@@ -2530,13 +2530,9 @@
 				n->nm,n->nm);
 	}
     }
-    init=0;
     for(n = global_list;n!=&null_nptr;n = n->next) {
         if (n->sc==EXTRN1) {
-            if(init==0) {
 	    printf("\t.section __IMPORT,__jump_table,symbol_stubs,self_modifying_code+pure_instructions,5\n");
-                init=1;
-            }
 	    printf("L_%s$stub:\n",n->nm);
 	    printf("\t.indirect_symbol _%s\n",n->nm);
 	    printf("\thlt ; hlt ; hlt ; hlt ; hlt\n");
@@ -2643,16 +2639,11 @@
 void code_dassign_gvar(int e2,int freg,int d)
 { 
 #ifdef __APPLE__
-    int dreg;
-    dreg = get_register();
-    printf("\tmovl _%s-%d(%%ebx),%s\n",((NMTBL*)caddr(e2))->nm,
-	    goffset_label,
-	    register_name(dreg,0));
+    int r = get_ptr_cache((NMTBL*)caddr(e2));
     if (cadr(e2)) 
-	printf("\t%s %d(%s)\n",fstore(d),cadr(e2),register_name(dreg,0));
+	printf("\t%s %d(%s)\n",fstore(d),cadr(e2),register_name(r,0));
     else
-	printf("\t%s (%s)\n",fstore(d),register_name(dreg,0));
-    free_register(dreg);
+	printf("\t%s (%s)\n",fstore(d),register_name(r,0));
 #else
     if (cadr(e2)) 
 	printf("\t%s %s+%d\n",fstore(d),((NMTBL*)caddr(e2))->nm,cadr(e2));
@@ -2803,16 +2794,11 @@
 void code_drgvar(int e2,int d,int freg)
 { 
 #ifdef __APPLE__
-    int dreg;
-    dreg = get_register();
-    printf("\tmovl _%s-%d(%%ebx),%s\n",((NMTBL*)caddr(e2))->nm,
-	    goffset_label,
-	    register_name(dreg,0));
+    int r = get_ptr_cache((NMTBL*)caddr(e2));
     if (cadr(e2))
-	printf("\t%s %d(%s)\n",fload(d),cadr(e2),register_name(dreg,0));
+	printf("\t%s %d(%s)\n",fload(d),cadr(e2),register_name(r,0));
     else
-	printf("\t%s (%s)\n",fload(d),register_name(dreg,0));
-    free_register(dreg);
+	printf("\t%s (%s)\n",fload(d),register_name(r,0));
 #else
     if (cadr(e2))
 	printf("\t%s %s+%d\n",fload(d),((NMTBL*)caddr(e2))->nm,cadr(e2));
@@ -2830,16 +2816,11 @@
 void code_cmp_drgvar(int e2,int reg,int d,int label,int cond)
 { 
 #ifdef __APPLE__
-    int dreg;
-    dreg = get_register();
-    printf("\tmovl _%s-%d(%%ebx),%s\n",((NMTBL*)caddr(e2))->nm,
-	    goffset_label,
-	    register_name(dreg,0));
+    int r = get_ptr_cache((NMTBL*)caddr(e2));
     if (cadr(e2))
-	printf("\tfcomp %d(%s)\n",cadr(e2),register_name(dreg,0));
+	printf("\tfcomp %d(%s)\n",cadr(e2),register_name(r,0));
     else
-	printf("\tfcomp (%s)\n",register_name(dreg,0));
-    free_register(dreg);
+	printf("\tfcomp (%s)\n",register_name(r,0));
 #else
     if (cadr(e2))
 	printf("\tfcomp %s+%d\n",((NMTBL*)caddr(e2))->nm,cadr(e2));
@@ -3805,7 +3786,7 @@
     printf("\tja\t_%d\n",dlabel);
     if (delta==1)  {
 #ifdef __APPLE__
-	printf("\tmovl\t_%d-%d(%%ebx,%s,4)\n",l,goffset_label,crn);
+	printf("\tmovl\t_%d-_%d(%%ebx,%s,4)\n",l,goffset_label,crn);
 	printf("\tjmp\t*%s\n",crn);
 #else
 	printf("\tjmp\t*_%d(,%s,4)\n",l,crn);
@@ -3821,7 +3802,7 @@
 	printf("\tandl\t%%eax,%%edx\n");
 	printf("\tjne\t_%d\n",dlabel);
 #ifdef __APPLE__
-	printf("\tmovl\t_%d-%d(%%ebx,%s,2)\n",l,goffset_label,crn);
+	printf("\tmovl\t_%d-_%d(%%ebx,%s,2)\n",l,goffset_label,crn);
 	printf("\tjmp\t*%s\n",crn);
 #else
 	printf("\tjmp\t*_%d(,%%eax,2)\n",l); break;
@@ -3831,7 +3812,7 @@
 	printf("\tandl\t%%eax,%%edx\n");
 	printf("\tjne\t_%d\n",dlabel);
 #ifdef __APPLE__
-	printf("\tmovl\t_%d-%d(%%ebx,%s)\n",l,goffset_label,crn);
+	printf("\tmovl\t_%d-_%d(%%ebx,%s)\n",l,goffset_label,crn);
 	printf("\tjmp\t*%s\n",crn);
 #else
 	printf("\tjmp\t*_%d(%%eax)\n",l); break;
@@ -3842,7 +3823,7 @@
 	printf("\tandl\t%%edx,%%edx\n");
 	printf("\tjne\t_%d\n",dlabel);
 #ifdef __APPLE__
-	printf("\tmovl\t_%d-%d(%%ebx,%s,4)\n",l,goffset_label,crn);
+	printf("\tmovl\t_%d-_%d(%%ebx,%s,4)\n",l,goffset_label,crn);
 	printf("\tjmp\t*%s\n",crn);
 #else
 	printf("\tjmp\t*_%d(,%%eax,4)\n",l); break;