changeset 394:b96b46baa20f

*** empty log message ***
author kono
date Tue, 14 Sep 2004 15:49:57 +0900
parents fe5aceeb6e89
children f82993ed5ab9
files Changes mc-code-arm.c
diffstat 2 files changed, 46 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/Changes	Sun Sep 12 17:24:04 2004 +0900
+++ b/Changes	Tue Sep 14 15:49:57 2004 +0900
@@ -5975,3 +5975,11 @@
 もやりたいよね。
 
 それよりは、inline が先か。
+
+Tue Sep 14 14:36:15 JST 2004
+
+arm lvar のlarge offset をなんとかしないと。lvar intro
+でなくてもできるはずだよね。
+
+だけど、ptr cache と const list
+を一般的に一緒にできない? 両方ともconstだしねぇ。
--- a/mc-code-arm.c	Sun Sep 12 17:24:04 2004 +0900
+++ b/mc-code-arm.c	Tue Sep 14 15:49:57 2004 +0900
@@ -35,6 +35,7 @@
 static void register_usage(char *s);
 static void code_add(int reg,int offset,int r);
 static void const_list_table();
+static int search_const(int tag,int value,int *label);
 static char * cstore(int sz);
 static void code_int_lib(char *lib,int reg,int oreg); 
 #if FLOAT_CODE
@@ -51,8 +52,8 @@
 static int register_save_return_label;
 static int code_size_label ;
 
-// static int r1_offset_label;
-// static int lvar_offset_label;
+static int r1_offset_label;
+static int lvar_offset_label;
 static int    max_func_args = 0;
 
 
@@ -354,8 +355,8 @@
 printf("        @ args = %d, pretend = %d, frame = %d\n",
 	max_func_args,0,round16(-disp));
 printf("        @ frame_needed = 1, current_function_anonymous_args = 0\n");
-// printf("\t.set .L%d, %d\n",lvar_offset_label,lvar_offsetv);
-// printf("\t.set .L%d, %d\n",r1_offset_label,r1_offsetv);
+printf("\t.set .L%d, %d\n",lvar_offset_label,lvar_offsetv);
+printf("\t.set .L%d, %d\n",r1_offset_label,r1_offsetv);
 
 #if 0
 printf("# vars= %d, regs= %d/%d, args= %d, extra= %d\n",
@@ -392,19 +393,22 @@
         } else
             printf("[fp, #%d]%s\n",CODE_LVAR(l),cext);
     } else if (l<0) {  /* local variable */
-//        printf("[fp, #%d+.L%d]%s\n",FUNC_LVAR(l),lvar_offset_label,cext);
-        printf("[fp, #%d]%s\n",FUNC_LVAR(l),cext);
+        printf("[fp, #%d+.L%d]%s\n",FUNC_LVAR(l),lvar_offset_label,cext);
+//        printf("[fp, #%d]%s\n",FUNC_LVAR(l),cext);
     } else if (l>=ARG_LVAR_OFFSET) {  /* caller's arguments */
         printf("[sp, #%d]%s\n",CALLER_ARG(l-ARG_LVAR_OFFSET),cext);
     } else { /* callee's arguments */
-//        printf("[fp, #%d+.L%d]%s\n",CALLEE_ARG(l),r1_offset_label,cext);
-        printf("[fp, #%d]%s\n",CALLEE_ARG(l),cext);
+        printf("[fp, #%d+.L%d]%s\n",CALLEE_ARG(l),r1_offset_label,cext);
+//        printf("[fp, #%d]%s\n",CALLEE_ARG(l),cext);
     }
 }
 
 static void
 lvar_address(int l,int creg)
 {
+    int label,disp;
+    int tmp = -1;
+    char *trn;
     inc_inst(1);
     if (fnptr->sc==CODE) {
         if (l>=ARG_LVAR_OFFSET) {  /* caller's arguments */
@@ -412,17 +416,22 @@
         } else
 	    code_add(creg,CODE_LVAR(l),REG_fp);
     } else if (l<0) {  /* local variable */
-//        printf("\tsub\t%s, fp, #%d+.L%d\n",register_name(creg),
-//		FUNC_LVAR(l),lvar_offset_label);
-        printf("\tsub\t%s, fp, #%d\n",register_name(creg), FUNC_LVAR(l));
+//        printf("\tsub\t%s, fp, #%d\n",register_name(creg), FUNC_LVAR(l));
+	trn = register_name(tmp = get_register());
+	disp = search_const(LVAR,glist2(lvar_offset_label,FUNC_LVAR(l)),&label);
+        printf("\tldr\t%s, .L%d+%d\n",trn,label,disp);
+	printf("\tsub\t%s, fp, %s\n",register_name(creg),trn);
     } else if (l>=ARG_LVAR_OFFSET) {  /* caller's arguments */
 	code_add(creg,CALLER_ARG(l-ARG_LVAR_OFFSET),REG_sp);
     } else { /* callee's arguments */
 //        printf("\tsub\t%s, fp, #%d+.L%d\n",
 //		register_name(creg),CALLEE_ARG(l),r1_offset_label);
-        printf("\tsub\t%s, fp, #%d\n",
-		register_name(creg),CALLEE_ARG(l));
-    }
+	trn = register_name(tmp = get_register());
+	disp = search_const(LVAR,glist2(r1_offset_label,CALLEE_ARG(l)),&label);
+        printf("\tldr\t%s, .L%d+%d\n",trn,label,disp);
+	printf("\tsub\t%s, fp, %s\n",register_name(creg),trn);
+    }
+    if (tmp!=-1) free_register(tmp);
 }
 
 
@@ -1141,6 +1150,7 @@
 /*
      constant table
         glist3( tag, next, value )
+		LVAR       	glist2(label,offset)
 		GVAR       	nptr
 		CONST		value
 		LABEL		value
@@ -1174,6 +1184,10 @@
 	    case GVAR: case CONST: case LABEL:
 		if (caddr(p)!=value) continue;
 		return i;
+	    case LVAR:
+		if (car(caddr(p))!=car(value)) continue;
+		if (cadr(caddr(p))!=cadr(value)) continue;
+		return i;
 	    }
 	}
     }
@@ -1240,6 +1254,8 @@
 	    case DCONST: case LCONST:
 	    case CONST:	printf("\t.word\t%d\n",caddr(p)); break;
 	    case LABEL:	printf("\t.word\t.L%d\n",caddr(p)); break;
+	    case LVAR:	printf("\t.word\t.L%d+%d\n",
+		car(caddr(p)),cadr(caddr(p))); break;
 	    default: error(-1);
 	    }
 	}
@@ -1249,6 +1265,11 @@
 	prev_const_list_label=const_list_label;
 	const_list_label = 0;
     }
+    for(p = prev_const_list; p ; p = cadr(p)) {
+	if (car(p)==LVAR) {
+	    free_glist2(caddr(p));
+	}
+    }
     free_glist3_a(prev_const_list);
     prev_const_list=const_list;
     const_list = 0;
@@ -3064,7 +3085,7 @@
     printf("\t.globl\t%s\n",name);
     printf("\t.type\t%s,function\n",name);
     code_size_label = backdef();
-//    lvar_offset_label = fwdlabel();
+    lvar_offset_label = fwdlabel();
     max_func_args = 0;
 }
 
@@ -3098,8 +3119,8 @@
     
     max_func_args = 0;
 
-//    lvar_offset_label = fwdlabel();
-//    r1_offset_label = fwdlabel();
+    lvar_offset_label = fwdlabel();
+    r1_offset_label = fwdlabel();
     code_size_label = fwdlabel();
     printf("\t.type\t%s,function\n",name);
     if (stmode!=STATIC)