changeset 777:be917edcb671

i64 continue... minor fix code segment test start
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 18 Nov 2010 23:44:35 +0900
parents d32ae7119cf1
children a177c65f3e37
files .gdbinit Changes mc-code-i64.c mc-codegen.c
diffstat 4 files changed, 38 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/.gdbinit	Thu Nov 18 21:39:55 2010 +0900
+++ b/.gdbinit	Thu Nov 18 23:44:35 2010 +0900
@@ -26,8 +26,8 @@
 # r -s test/basic.c
 # r -s test/float.c
 # r -s test/strinit.c
-# r -s test/arg.c
+r -s test/arg.c
 # r -s test/putenemy.c
-r -s -DINLINE=inline test/code-gen-all.c
+# r -s -DINLINE=inline test/code-gen-all.c
 # r -s -DINLINE=inline test/strinit.c
 # r -s test/fact-a.c
--- a/Changes	Thu Nov 18 21:39:55 2010 +0900
+++ b/Changes	Thu Nov 18 23:44:35 2010 +0900
@@ -9821,6 +9821,8 @@
 
 clear するタイミングを prev_macro_end でおくらせる。
 
+mutual recursive macro の semantics が gcc とは異なるらしい。
+
 Sat Nov  8 15:06:22 JST 2008
 
 しばらくいじってないね。
@@ -9866,3 +9868,17 @@
 
 long double と vector 型を増やしたい...
 
+Thu Nov 18 23:41:39 JST 2010
+
+save_input_register をできるだけ送らせれば、code の mmx input register を
+使っても良い結果になるはず。code の先頭で、memory に store してしまうのでは、
+register にとる意味がない。
+
+Intel64 が mmx を save しないのは、そういう噂があったからだろうけど、
+ばかげた話だ。
+
+
+
+
+
+
--- a/mc-code-i64.c	Thu Nov 18 21:39:55 2010 +0900
+++ b/mc-code-i64.c	Thu Nov 18 23:44:35 2010 +0900
@@ -378,6 +378,7 @@
 #define REG_R10   9
 #define REG_EBX   11
 #define REG_R15   15
+#define REG_XMM0  16
 #define is_int_reg(reg) (1<=reg&&reg<=MAX_REGISTER)
 #define is_float_reg(reg) (RET_FREGISTER<=reg&&reg<FREG_OFFSET+REAL_MAX_DREGISTER)
 
@@ -582,7 +583,10 @@
 	r1_offsetv += 8;  
     }
     if (code_f) {
-	printf("\t.set _%d,%d\n",code_disp_label,r1_offsetv);
+	data_mode(0);
+	code_label(code_disp_label);
+	emit_longlong(round16(r1_offsetv));
+        code_disp_label = 0;
     } else {
 	//  +8 makes esp alignment 16
 	if (r1_offsetv-lvar_offsetv > 65000) error(-1);
@@ -959,17 +963,14 @@
 }
 
 /*
-    ESI,EDI are used as register variable
-    (both in integer and long long mode)
  */
 
 int 
 get_input_register_var(int i,NMTBL *nptr,int is_code)
 {
     if (is_code) {
-	if (i>=MAX_CODE_INPUT_REGISTER_VAR) return 0;
-	i += REG_EDI;
-	regs[i]=INPUT_REG;
+        if(!(i<REG_VAR_BASE-REG_VAR_MIN)) return 0;
+        i = REG_VAR_BASE-i;
 	return list3n(LREGISTER,i,nptr);
     } else {
 	if (i>=MAX_INPUT_REGISTER_VAR) return 0;
@@ -983,8 +984,9 @@
 get_input_dregister_var(int i,NMTBL *nptr,int is_code,int d)
 {
   if (is_code) {
-    if(!(i<MAX_INPUT_DREGISTER_VAR)) return 0;
-    i = FREG_OFFSET+i;
+    // if(!(i<MAX_INPUT_DREGISTER_VAR)) return 0;
+    // i = FREG_OFFSET+i;
+    return 0;
   } else {
     if(!(i<MAX_INPUT_DREGISTER_VAR)) return 0;
     i = FREG_OFFSET+i;
@@ -2900,7 +2902,8 @@
 code_enter1(int args)
 {
     code_disp_label=fwdlabel();
-    printf("\tlea -_%d(%%rbp),%%rsp\n",code_disp_label);
+    printf("\tmovq %%rbp,%%rsp\n");
+    printf("\tsubq  _%d(%%rip),%%rsp\n",code_disp_label);
 
     // printf("## args %d disp %d  code_disp_offset=%d\n",args,disp,code_disp_offset); 
 }
@@ -2973,20 +2976,17 @@
     int ty = cadr(fnptr->ty);
     fwddef(retcont);
     if (ty==FLOAT||ty==DOUBLE) {
-	printf("\tmovsd %d(%%rbp),%s\n",-SIZE_OF_DOUBLE,register_name(creg,0));
-	printf("\tmovq %s,%%rbp\n",reg_name_l[REG_ESI]);
-    } else if (ty==LONGLONG||ty==ULONGLONG) {
-	set_lreg(RET_LREGISTER,0);
-	printf("\tmovq %d(%%rbp),%%rbp\n",disp-SIZE_OF_LONGLONG);
+	set_freg(RET_DREGISTER,0);
+	printf("\tmovs%s %s,%s\n",ty==FLOAT?"s":"d",fregister_name(REG_XMM0),register_name(creg,0));
+	printf("\tmovq %s,%%rbp\n",register_name(REG_EDI,0));
     } else if (ty>0&&( car(ty)==STRUCT || car(ty)==UNION)) {
 	set_ireg(RET_REGISTER,0);
-	printf("\tmovq %d(%%rbp),%s\n",disp-SIZE_OF_LONGLONG,
-	    register_name(creg,0));
-	printf("\tmovq %s,%%rbp\n",reg_name_l[REG_EDI]);
+	printf("\tlea %d(%%rbp),%s\n",disp-SIZE_OF_LONGLONG, register_name(creg,0));
+	printf("\tmovq %s,%%rbp\n",register_name(REG_ESI,0));
     } else if (ty!=VOID) {
 	set_ireg(RET_REGISTER,0);
-	printf("\tmovq %s,%s\n",reg_name_l[REG_ESI],register_name(creg,0));
-	printf("\tmovq %s,%%rbp\n",reg_name_l[REG_EDI]);
+	printf("\tmovq %s,%s\n",register_name(REG_EDI,0),register_name(creg,0));
+	printf("\tmovq %s,%%rbp\n",register_name(REG_ESI,0));
     }
 }
 
--- a/mc-codegen.c	Thu Nov 18 21:39:55 2010 +0900
+++ b/mc-codegen.c	Thu Nov 18 23:44:35 2010 +0900
@@ -1903,7 +1903,7 @@
 	return;
     }
     /* e2 is register now */
-    if (car(e2)!=REGISTER||car(e2)!=REGISTER) error(-1);
+    if (car(e2)!=REGISTER && car(e2)!=LREGISTER) error(-1);
     reg = cadr(e2);
     switch(e5) {
     case CRGVAR: