changeset 389:68fb244e0e3c

mc-arm generates code-gen-all.s with no error, but assembler output contains errors.
author kono
date Fri, 03 Sep 2004 23:27:04 +0900
parents 245c6033683d
children 15cf97ce7db1
files .gdbinit Changes mc-code-arm.c mc-code-mips.c mc-parse.c mc.h
diffstat 6 files changed, 35 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/.gdbinit	Tue Aug 24 15:10:16 2004 +0900
+++ b/.gdbinit	Fri Sep 03 23:27:04 2004 +0900
@@ -1,11 +1,12 @@
 tb main
 # run  -s test/arg.c
 # run  -s mc-parse.c
+run  -s mc-codegen.c
 # run  -s nkf203/nkf.c
 # run  -s -ob01.s mc-switch.c
 # run  -s l.c
 # run  -s test/bitfield.c
-run -s test/code-gen-all.c
+# run -s test/code-gen-all.c
 define regs 
 printf "pc =%08x lr =%08x r0 =%08x r1 =%08x r3= %08x r4= %08x\n",$pc,$lr,$r0,$r1,$r3,$r4
 printf "r10=%08x r11=%08x r12=%08x r13=%08x r14=%08x r15=%08x\n",$r10,$r11,$r12,$r13,$r14,$r15
--- a/Changes	Tue Aug 24 15:10:16 2004 +0900
+++ b/Changes	Fri Sep 03 23:27:04 2004 +0900
@@ -5940,3 +5940,12 @@
 アドホックだね。(まぁねぇ)
 
 CONDのテストが入ってないなぁ。
+
+Tue Aug 24 15:39:27 JST 2004
+
+register 割当てが変。ほとんどをregister var に割り当てるように
+なっているけど、もっとtmpがないと計算できないよね。
+
+Thu Sep  2 20:46:56 JST 2004
+
+そういえば Input register をtmpに使わないのはなんで?
--- a/mc-code-arm.c	Tue Aug 24 15:10:16 2004 +0900
+++ b/mc-code-arm.c	Fri Sep 03 23:27:04 2004 +0900
@@ -83,9 +83,9 @@
 #define REG_fp   13
 #define REG_sp   14
 #define REG_VAR_BASE 11
-#define REG_VAR_MIN  4
-#define MIN_TMP_REG 12          /* only one tmp register? */
-#define MAX_TMP_REG 12
+#define REG_VAR_MIN  9
+#define MIN_TMP_REG 2          /* only one tmp register? */
+#define MAX_TMP_REG 8
 
 #define PTRC_REG 3              /* mark for pointer cache */
 
@@ -497,7 +497,7 @@
 void
 code_gexpr(int e){
      if (is_int_reg(creg) && creg!=ireg) error(-1);
-// register_usage("code_gexpr");
+//  register_usage("code_gexpr");
 }
 
 
@@ -620,7 +620,7 @@
         }
     }
     /* 空いている場所がないなら、エラー (いったい誰が使ってるの?) */
-    error(HPERR); return creg;
+    error(RGERR); return creg;
 }
 
 #if 0
@@ -672,7 +672,7 @@
         }
     }
     /* 空いている場所がないなら、エラー (いったい誰が使ってるの?) */
-    error(REG_ERR); return freg;
+    error(RGERR); return freg;
 }
 
 #if 0
@@ -692,13 +692,14 @@
 }
 #endif
 
+// static int lreg_count;
 int
 get_lregister0()
 {
     int i;
     for(i=LREG_OFFSET;i<REAL_MAX_LREGISTER+LREG_OFFSET;i++) {
 	if (regs[i]==0) {
-// printf("# get_lregister %d\n",i);
+// printf("# get_lregister %d (%d)\n",i,lreg_count++);
 	    return i;
 	}
     }
@@ -771,6 +772,7 @@
 // printf("# free_register %d\n",i);
     regs[i]=0;
     if (is_longlong_reg(i)) {
+// printf("# free lregister %d (%d)\n",i,lreg_count++);
 	regs[regv_l(i)]=0;
 	regs[regv_h(i)]=0;
 	//regv_l(i)=0;
@@ -2882,6 +2884,8 @@
 	printf("\tbeq\t.L%d\n",label); break;
     case LT:
 	printf("\tblt\t.L%d\n",label); break;
+    case GT:
+	printf("\tbgt\t.L%d\n",label); break;
     default: error(-1);
     }
     if (reg!=-1) free_register(reg);
@@ -5320,6 +5324,8 @@
     emit_pop_free(edx);
     if (edx0!=-1)
 	free_register(edx0);
+    if (reg!=lreg)
+	free_register(reg);
 }
 
 void
@@ -5394,7 +5400,7 @@
 
     char *trn = register_name(t=get_register());
 
-    code_add(t,csvalue,-min);
+    code_add(t,-min,csvalue);
     code_cmpdimm(max-min+1,t,dlabel,GT);
     switch(delta) {
     case 1: printf("\tldrls\tpc, [pc, %s, asl #2]\n",trn);
--- a/mc-code-mips.c	Tue Aug 24 15:10:16 2004 +0900
+++ b/mc-code-mips.c	Fri Sep 03 23:27:04 2004 +0900
@@ -5145,6 +5145,7 @@
     emit_pop_free(edx);
     if (edx0!=-1)
 	free_register(edx0);
+    if (reg!=lreg) free_register(reg);
 }
 
 void
--- a/mc-parse.c	Tue Aug 24 15:10:16 2004 +0900
+++ b/mc-parse.c	Fri Sep 03 23:27:04 2004 +0900
@@ -289,6 +289,7 @@
 	(n==LVERR) ? "Lvalue required" :
 	(n==UDERR) ? "Undeclared identifier" :
 	(n==OPTION) ? "Illegal option" :
+	(n==RGERR) ? "too many register usage (internal error)" :
 	(n==REG_ERR) ? "illegal register var" :
 	(n==INERR) ? "bad initialization" :
 	(n==CODE_ERR) ? "goto code is necessary" :
--- a/mc.h	Tue Aug 24 15:10:16 2004 +0900
+++ b/mc.h	Fri Sep 03 23:27:04 2004 +0900
@@ -409,13 +409,14 @@
 #define UDERR   18
 #define OPTION  19
 #define REG_ERR 20
-#define CODE_ERR        21
-#define MSERR   22
-#define BTERR   23
-#define HSERR   24
-#define NMERR   25
-#define MMERR   26
-#define INERR   27
+#define RGERR 21
+#define CODE_ERR        22
+#define MSERR   23
+#define BTERR   24
+#define HSERR   25
+#define NMERR   26
+#define MMERR   27
+#define INERR   28
 
 /* error number end */