changeset 747:d4bc10fe7362

i64 continue... (global table)
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 13 Nov 2010 10:47:47 +0900
parents f8ea174944f2
children c2c709727221
files mc-code-i64.c test/code-gen.c
diffstat 2 files changed, 105 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/mc-code-i64.c	Fri Nov 12 22:19:55 2010 +0900
+++ b/mc-code-i64.c	Sat Nov 13 10:47:47 2010 +0900
@@ -260,12 +260,12 @@
 
 int code_lassop_p = 1;
 
-#define MAX_REGISTER 14                /* intel386のレジスタを6つまで使う*/
-#define REAL_MAX_REGISTER (1+16)    /* intel386のレジスタが8つということ*/
-int MAX_REGISTER_VAR=6;    
-#define REAL_MAX_DREGISTER (1+16)    /* intel386のレジスタが8つということ*/
-
-int MAX_DREGISTER_VAR=8;
+#define MAX_REGISTER 14              /* intel64のレジスタを14まで使う*/
+#define REAL_MAX_REGISTER (1+16)     /* intel64のレジスタが16つということ*/
+int MAX_REGISTER_VAR=5;    
+#define REAL_MAX_DREGISTER (1+16)    /* intel64のxmmレジスタが16つということ*/
+
+int MAX_DREGISTER_VAR=0;             /* 保存される xmm register はない */
 
 #define MIN_TMP_FREG 6
 #define MAX_TMP_FREG 9
@@ -360,28 +360,29 @@
 //    2 (REG_VAR) register variable
 //    3 pointer cache (not used in ia32)
 
-#define FREG_OFFSET   18
 
 #define REG_ESP   0
 #define REG_EBP   1
 #define REG_EDI   2    // first argument register
 #define REG_ESI   3
-#define REG_EDX   4
-#define REG_ECX   5    // for strange reason (code_assop)
-#define REG_EAX   6
-#define REG_EBX   7
+#define REG_ECX   4    // for strange reason (code_assop)
+#define REG_EDX   5
+#define REG_EAX   8
+#define REG_EBX   11
+#define REG_R15   15
 #define is_int_reg(reg) (1<=reg&&reg<=MAX_REGISTER)
 #define is_float_reg(reg) (RET_FREGISTER<=reg&&reg<FREG_OFFSET+REAL_MAX_DREGISTER)
 
 //  return value register
-#define RET_FREGISTER   18
-#define RET_DREGISTER   18
+#define FREG_OFFSET   16
+#define RET_FREGISTER   16
+#define RET_DREGISTER   16
 #define RET_LREGISTER   REG_EAX
 #define RET_REGISTER    REG_EAX
 
 //  defalut current register
 #define CREG_REGISTER   REG_ECX
-#define FREG_FREGISTER  19
+#define FREG_FREGISTER  17
 
 static char *reg_name_l[] = {0,
     0,
@@ -392,14 +393,14 @@
     "%r8b",
     "%r9b",
     "%al",
-    "%bl",
     "%r10b",
     "%r11b",
+    "%bl",
     "%r12b",
     "%r13b",
     "%r14b",
     "%r15b",
-    "%r16b"};
+    "};
 static char *reg_name_w[] = {
     "%sp",
     "%bp",
@@ -410,14 +411,14 @@
     "%r8w",
     "%r9w",
     "%ax",
-    "%bx",
     "%r10w",
     "%r11w",
+    "%bx",
     "%r12w",
     "%r13w",
     "%r14w",
     "%r15w",
-    "%r16w"};
+    };
 
 static char *reg_name[] = {
     "%esp",
@@ -429,17 +430,17 @@
     "%r8d",
     "%r9d",
     "%eax",
-    "%ebx",
     "%r10d",
     "%r11d",
+    "%ebx",
     "%r12d",
     "%r13d",
     "%r14d",
     "%r15d",
-    "%r16d"};
-
-#define REG_VAR_BASE    (MAX_REGISTER)
-#define REG_VAR_MIN     (MAX_REGISTER-MAX_REGISTER_VAR)
+    };
+
+#define REG_VAR_BASE    (REG_R15)
+#define REG_VAR_MIN     (REG_R15-MAX_REGISTER_VAR)
 
 #define FREG_VAR_BASE    (RET_FREGISTER+15)
 #define FREG_VAR_MIN     (RET_FREGISTER+15-MAX_DREGISTER_VAR)
@@ -454,14 +455,13 @@
     "%r8",
     "%r9",
     "%rax",
-    "%rbx",
     "%r10",
     "%r11",
+    "%rbx",
     "%r12",
     "%r13",
     "%r14",
     "%r15",
-    "%r16",
 };
 
 static char *reg_name_d[] = {    
@@ -3140,8 +3140,60 @@
     }
 }
 
-
-
+void
+exntern_entry(NMTBL *n) 
+{
+    printf(
+    ".globl _%s.eh\n"                             // name of this entry
+    "_%s.eh:\n"
+    "LSFDE%d:\n"
+    "        .set L$set$%d,LEFDE%d-LASFDE%d\n"    // size of this entry
+    "        .long L$set$%d\n"
+    "LASFDE%d:\n"
+    "        .long   LASFDE%d-EH_frame1\n"
+    "        .quad   LFB%d-.\n"                   //  function top
+    "        .set L$set$%d,LFE%d-LFB%d\n"         //  size of function
+    "        .quad L$set$%d\n"
+    "        .byte   0x0\n"
+    "        .byte   0x4\n"
+    "        .set L$set$%d,LCFI%d-LFB%d\n"        //  pushq %rbp
+    "        .long L$set$%d\n"
+    "        .byte   0xe\n"
+    "        .byte   0x10\n"
+    "        .byte   0x86\n"
+    "        .byte   0x2\n"
+    "        .byte   0x4\n"
+    "        .set L$set$%d,LCFI%d-LCFI%d\n"       //  movq %rsp, %rbp
+    "        .long L$set$%d\n"
+    "        .byte   0xd\n"
+    "        .byte   0x6\n",
+    );
+    printf(
+    "        .byte   0x4\n"
+    "        .set L$set$%d,LCFI%d-LCFI%d\n"       //  register variable save
+    "        .long L$set$%d\n"
+
+    );
+
+    printf(
+    "        .byte   0x83\n"
+
+    "        .byte   0x7\n"
+    "        .byte   0x8c\n"
+    "        .byte   0x6\n"
+    "        .byte   0x8d\n"
+    "        .byte   0x5\n"
+    "        .byte   0x8e\n"
+    "        .byte   0x4\n"
+    "        .byte   0x8f\n"
+    "        .byte   0x3\n"
+    );
+
+    printf(
+    "        .align 3\n"
+    "LEFDE%d:\n",);
+
+}
 
 
 
@@ -3199,33 +3251,38 @@
         if (n->sc == GVAR || 
 		((is_code(n) || is_function(n)) &&has_attr(n,FNAME)) ) {
             if (init==0) {
-	printf("\t.section __IMPORT,__pointers,non_lazy_symbol_pointers\n");
+printf(".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support\nEH_frame1:\n");
+printf(
+"        .set L$set$0,LECIE1-LSCIE1\n"
+"        .long L$set$0\n"
+"LSCIE1:\n"
+"        .long   0x0\n"
+"        .byte   0x1\n"
+"        .ascii \"zR\0\"\n"
+"        .byte   0x1\n"
+"        .byte   0x78\n"
+"        .byte   0x10\n"
+"        .byte   0x1\n"
+"        .byte   0x10\n"
+"        .byte   0xc\n"
+"        .byte   0x7\n"
+"        .byte   0x8\n"
+"        .byte   0x90\n"
+"        .byte   0x1\n"
+"        .align 3\n"
+"LECIE1:\n");
                 init=1;
             }
-	printf("L_%s$non_lazy_ptr:\n\t.indirect_symbol _%s\n\t.long\t0\n",
-				n->nm,n->nm);
+
 	}
     }
     for(n = global_list;n!=&null_nptr;n = n->next) {
         if (n->sc==EXTRN1) {
-	    if (!(is_code(n) || is_function(n))) {
-	printf("\t.section __IMPORT,__pointers,non_lazy_symbol_pointers\n");
-	printf("L_%s$non_lazy_ptr:\n\t.indirect_symbol _%s\n\t.long\t0\n",
-				n->nm,n->nm);
-	    }
-	    printf("\t.section __IMPORT,__jump_table,symbol_stubs,self_modifying_code+pure_instructions,5\n");
-	    printf("L_%s$stub:\n",n->nm);
-	    printf("\t.indirect_symbol _%s\n",n->nm);
-	    printf("\thlt ; hlt ; hlt ; hlt ; hlt\n");
+	    if ((is_code(n) || is_function(n))) {
+		exntern_entry(n) ;
         }
     }
     printf("	    .subsections_via_symbols\n");
-    printf("	    .section __TEXT,__textcoal_nt,coalesced,pure_instructions\n");
-    printf(".weak_definition        ___i686.get_pc_thunk.bx\n");
-    printf(".private_extern ___i686.get_pc_thunk.bx\n");
-    printf("___i686.get_pc_thunk.bx:\n");
-    printf("	    movl    (%%esp), %%ebx\n");
-    printf("	    ret\n");
 #endif
 }
 
--- a/test/code-gen.c	Fri Nov 12 22:19:55 2010 +0900
+++ b/test/code-gen.c	Sat Nov 13 10:47:47 2010 +0900
@@ -1581,6 +1581,9 @@
     f0 = 0.0; f1 = 0.2;
     d0 = 10; d1 = 10e10;
     printf("#1511:code_lvar float r %f %f %g %g\n",f0,f1,d0,d1);
+    f0 += f1;
+    d0 += d1;
+    printf("#1511:code_lvar float r %f %f %g %g\n",f0,f1,d0,d1);
 }
 
 // code_dassign_gvar(int e2,int freg,int d)