changeset 411:32c1914308db

ENDIAN_L ENDIAN_D
author kono
date Tue, 19 Oct 2004 18:15:41 +0900
parents 5a3b1b65c6a8
children 6b3385124e5e
files mc-code-arm.c mc-code-ia32.c mc-code-mips.c mc-code-powerpc.c
diffstat 4 files changed, 109 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/mc-code-arm.c	Tue Oct 19 16:01:15 2004 +0900
+++ b/mc-code-arm.c	Tue Oct 19 18:15:41 2004 +0900
@@ -76,6 +76,8 @@
 #define SIZE_OF_DOUBLE  8
 #define SIZE_OF_LONGLONG  8
 #define ENDIAN  0
+#define ENDIAN_L  0
+#define ENDIAN_D  1
 
 static int  reg_sp;   /* REGister Stack-Pointer */
 static int reg_stack[MAX_MAX];  /* 実際のレジスタの領域 */
@@ -2737,7 +2739,7 @@
 {
     char *crn=register_name(creg);
     inc_inst(2);
-#if ENDIAN==0
+#if ENDIAN_L==0
     if (creg!=regv_l(reg)) {
 	printf("\tldr\t%s, [%s, #%d]\n",lregister_name_low(reg),crn,offset);
 	printf("\tldr\t%s, [%s, #%d]\n",lregister_name_high(reg),crn,offset+SIZE_OF_INT);
@@ -2787,7 +2789,7 @@
     crn_h = lregister_name_high(creg);
     crn_l = lregister_name_low(creg);
     inc_inst(2);
-#if ENDIAN==0
+#if ENDIAN_L==0
     printf("\tstr\t%s, [%s, #0]\n",crn_l,drn);
     printf("\tstr\t%s, [%s, #%d]\n",crn_h,drn,SIZE_OF_INT);
 #else
@@ -3530,7 +3532,7 @@
 #if LONGLONG_CODE
     long long ll = lcadr(e);
     data_mode(0);
-#if (ENDIAN==0)
+#if (ENDIAN_L==0)
 	printf("\t.long\t0x%x,0x%x\n",code_l1(ll),code_l2(ll));
 #else
 	printf("\t.long\t0x%x,0x%x\n",code_l2(ll),code_l1(ll));
@@ -3544,7 +3546,7 @@
 #if FLOAT_CODE
     double d = dcadr(e);
     data_mode(0);
-#if (ENDIAN==0)
+#if (ENDIAN_D==0)
 	printf("\t.long\t0x%x,0x%x\n",code_d1(d),code_d2(d));
 #else
 	printf("\t.long\t0x%x,0x%x\n",code_d2(d),code_d1(d));
@@ -3871,7 +3873,7 @@
 static void
 dconst(int l,int h,double value)
 {
-#if ENDIAN==0
+#if ENDIAN_D==0
     code_const(code_d1(value),l);
     code_const(code_d2(value),h);
 #else
@@ -3910,12 +3912,12 @@
 	} else if (value==-1 || value==-10) {
 	    printf("\t%s\t%s, #%d\n",d?"mnfd":"mnfs",frn,(int)-value);
 	} else if (d) {
-#if ENDIAN==0
+#if ENDIAN_D==0
+	    disp = search_double_const(DCONST,
+		code_d1(value),code_d2(value),&label);
+#else
 	    disp = search_double_const(DCONST,
 		code_d2(value),code_d1(value),&label);
-#else
-	    disp = search_double_const(DCONST,
-		code_d1(value),code_d2(value),&label);
 #endif
 	    printf("\tldfd\t%s, .L%d+%d\n",frn,label,disp);
 	} else {
@@ -4928,7 +4930,7 @@
     int r;
     use_longlong(creg);
     r = get_ptr_cache((NMTBL*)caddr(e2));
-#if ENDIAN==0
+#if ENDIAN_L==0
     code_ldf(cstore(0),lregister_name_low(creg),cadr(e2),r,"");
     code_ldf(cstore(0),lregister_name_high(creg),cadr(e2)+SIZE_OF_INT,r,"");
 #else
@@ -4948,7 +4950,7 @@
     crn_l = lregister_name_low(creg);
     lvar_intro(e2);
     inc_inst(2);
-#if ENDIAN==0
+#if ENDIAN_L==0
     printf("\tstr\t%s, ",crn_l);lvar(e2,"");
     printf("\tstr\t%s, ",crn_h);lvar(e2+SIZE_OF_INT,"");
 #else
@@ -4986,7 +4988,7 @@
 code_lconst(int e1,int creg)
 {
     use_longlong(creg);
-#if ENDIAN==0
+#if ENDIAN_L==0
     code_const(code_l1(lcadr(e1)),regv_l(creg));
     code_const(code_l2(lcadr(e1)),regv_h(creg));
 #else
@@ -5018,7 +5020,7 @@
     crn_h = lregister_name_high(creg);
     crn_l = lregister_name_low(creg);
     r = get_ptr_cache((NMTBL*)caddr(e1));
-#if ENDIAN==0
+#if ENDIAN_L==0
     code_ldf("ldr",crn_l,cadr(e1),r,"");
     code_ldf("ldr",crn_h,cadr(e1)+SIZE_OF_INT,r,"");
 #else
--- a/mc-code-ia32.c	Tue Oct 19 16:01:15 2004 +0900
+++ b/mc-code-ia32.c	Tue Oct 19 18:15:41 2004 +0900
@@ -25,6 +25,8 @@
 #define    SIZE_OF_DOUBLE  8
 #define    SIZE_OF_LONGLONG  8
 #define    ENDIAN  0
+#define    ENDIAN_L  0
+#define    ENDIAN_D  0
 
 #define SAVE_STACKS 1
 
@@ -2037,7 +2039,7 @@
 #if LONGLONG_CODE
     long long ll = lcadr(e);
     data_mode(0);
-#if (ENDIAN==0)
+#if (ENDIAN_L==0)
         printf("\t.long\t0x%x,0x%x\n",code_l1(ll),code_l2(ll));
 #else
         printf("\t.long\t0x%x,0x%x\n",code_l2(ll),code_l1(ll));
@@ -2051,7 +2053,7 @@
 #if FLOAT_CODE
     double d = dcadr(e);
     data_mode(0);
-#if (ENDIAN==0)
+#if (ENDIAN_D==0)
         printf("\t.long\t0x%x,0x%x\n",code_d1(d),code_d2(d));
 #else
         printf("\t.long\t0x%x,0x%x\n",code_d2(d),code_d1(d));
@@ -2259,7 +2261,9 @@
     printf(" \t.section\t.rodata\n\t.align 8\n");
     lb=fwdlabel();
     printf("_%d:\n",lb);
+#if ENDIAN_D==0
     printf("\t.long\t0x%x,0x%x\n",code_d1(value),code_d2(value));
+#endif
     if (output_mode==TEXT_EMIT_MODE) {
 	printf(".text\n");
     } else {
@@ -2708,8 +2712,10 @@
     // e1 = e2
     use_longlong(e2);
     rn = register_name(e1,0);
+#if ENDIAN_L==0
     printf("\tmovl %s,(%s)\n",l_eax(e2),rn);
     printf("\tmovl %s,4(%s)\n",l_edx(e2),rn);
+#endif
 }
 
 void code_lassign_gvar(int e1,int e2)
@@ -2717,6 +2723,7 @@
     char *n;
     n = ((NMTBL*)caddr(e1))->nm;
     use_longlong(e2);
+#if ENDIAN_L==0
     if (cadr(e1)) {
 	printf("\tmovl %s,%s+%d\n",l_eax(e2),n,cadr(e1));
 	printf("\tmovl %s,%s+%d\n",l_edx(e2),n,cadr(e1)+4);
@@ -2724,13 +2731,16 @@
 	printf("\tmovl %s,%s\n",l_eax(e2),n);
 	printf("\tmovl %s,%s+4\n",l_edx(e2),n);
     }
+#endif
 }
 
 void code_lassign_lvar(int e1,int e2)
 {
     use_longlong(e2);
+#if ENDIAN_L==0
     printf("\tmovl %s,%d(%%ebp)\n",l_eax(e2),lvar(e1));
     printf("\tmovl %s,%d(%%ebp)\n",l_edx(e2),lvar(e1)+4);
+#endif
 }
 
 void code_lassign_lregister(int e2,int reg)
@@ -2747,8 +2757,10 @@
 code_lconst(int e1,int creg)
 {
     use_longlong(creg);
+#if ENDIAN_L==0
     printf("\tmovl $%d,%s\n",code_l1(lcadr(e1)),l_eax(creg));
     printf("\tmovl $%d,%s\n",code_l2(lcadr(e1)),l_edx(creg));
+#endif
 }
 
 void code_lneg(int e1)
@@ -2764,6 +2776,7 @@
     char *n;
     n = ((NMTBL*)caddr(e1))->nm;
     use_longlong(e2);
+#if ENDIAN_L==0
     if (cadr(e1)) {
 	printf("\tmovl %s+%d,%s\n",n,cadr(e1),l_eax(e2));
 	printf("\tmovl %s+%d,%s\n",n,cadr(e1)+4,l_edx(e2));
@@ -2771,13 +2784,16 @@
 	printf("\tmovl %s,%s\n",n,l_eax(e2));
 	printf("\tmovl %s+4,%s\n",n,l_edx(e2));
     }
+#endif
 }
 
 void code_lrlvar(int e1,int e2)
 {
     use_longlong(e2);
+#if ENDIAN_L==0
     printf("\tmovl %d(%%ebp),%s\n",lvar(e1),l_eax(e2));
     printf("\tmovl %d(%%ebp),%s\n",lvar(e1)+4,l_edx(e2));
+#endif
 }
 
 #define check_lreg(reg) if (reg==REG_L) code_lassign_lregister(reg,REG_LCREG)
--- a/mc-code-mips.c	Tue Oct 19 16:01:15 2004 +0900
+++ b/mc-code-mips.c	Tue Oct 19 18:15:41 2004 +0900
@@ -62,6 +62,8 @@
 #define SIZE_OF_DOUBLE  8
 #define SIZE_OF_LONGLONG  8
 #define ENDIAN  0
+#define ENDIAN_L  0
+#define ENDIAN_D  0
 
 static int  reg_sp;   /* REGister Stack-Pointer */
 static int reg_stack[MAX_MAX];  /* 実際のレジスタの領域 */
@@ -826,7 +828,7 @@
 	    i = i+MIN_TMP_REG;
             if (i%2==1) i++;
 	}
-#if ENDIAN==0
+#if ENDIAN_L==0
 	regv_l(ll)=i;
 	regv_h(ll)=i+1;
 #else
@@ -2363,7 +2365,7 @@
 lload(int creg,int reg,int offset) 
 {
     char *crn=register_name(creg);
-#if ENDIAN==0
+#if ENDIAN_L==0
     if (creg!=regv_l(reg)) {
 	printf("\tlw %s,%d(%s)\n",lregister_name_low(reg),offset,crn);
 	printf("\tlw %s,%d(%s)\n",lregister_name_high(reg),offset+SIZE_OF_INT,crn);
@@ -2412,7 +2414,7 @@
     char *crn_l;
     crn_h = lregister_name_high(creg);
     crn_l = lregister_name_low(creg);
-#if ENDIAN==0
+#if ENDIAN_L==0
     printf("\tsw %s,0(%s)\n",crn_l,drn);
     printf("\tsw %s,%d(%s)\n",crn_h,SIZE_OF_INT,drn);
 #else
@@ -3292,7 +3294,7 @@
 #if LONGLONG_CODE
     long long ll = lcadr(e);
     data_mode(0);
-#if (ENDIAN==0)
+#if (ENDIAN_L==0)
 	printf("\t.long\t0x%x,0x%x\n",code_l1(ll),code_l2(ll));
 #else
 	printf("\t.long\t0x%x,0x%x\n",code_l2(ll),code_l1(ll));
@@ -3306,7 +3308,7 @@
 #if FLOAT_CODE
     double d = dcadr(e);
     data_mode(0);
-#if (ENDIAN==0)
+#if (ENDIAN_D==0)
 	printf("\t.long\t0x%x,0x%x\n",code_d1(d),code_d2(d));
 #else
 	printf("\t.long\t0x%x,0x%x\n",code_d2(d),code_d1(d));
@@ -3566,7 +3568,7 @@
 static void
 dconst(int l,int h,double value)
 {
-#if ENDIAN==0
+#if ENDIAN_D==0
 	printf("\tli %s,0x%x\n",register_name(l),code_d1(value));
 	printf("\tli %s,0x%x\n",register_name(h),code_d2(value));
 #else
@@ -4410,7 +4412,7 @@
     int r;
     use_longlong(creg);
     r = get_ptr_cache((NMTBL*)caddr(e2));
-#if ENDIAN==0
+#if ENDIAN_L==0
     code_ldf(cstore(0),lregister_name_low(creg),cadr(e2),r);
     code_ldf(cstore(0),lregister_name_high(creg),cadr(e2)+SIZE_OF_INT,r);
 #else
@@ -4429,7 +4431,7 @@
     crn_h = lregister_name_high(creg);
     crn_l = lregister_name_low(creg);
     lvar_intro(e2);
-#if ENDIAN==0
+#if ENDIAN_L==0
     printf("\tsw %s,",crn_l);lvar(e2);
     printf("\tsw %s,",crn_h);lvar(e2+SIZE_OF_INT);
 #else
@@ -4467,7 +4469,7 @@
 code_lconst(int e1,int creg)
 {
     use_longlong(creg);
-#if ENDIAN==0
+#if ENDIAN_L==0
     code_const(code_l1(lcadr(e1)),regv_l(creg));
     code_const(code_l2(lcadr(e1)),regv_h(creg));
 #else
@@ -4505,7 +4507,7 @@
     crn_h = lregister_name_high(creg);
     crn_l = lregister_name_low(creg);
     r = get_ptr_cache((NMTBL*)caddr(e1));
-#if ENDIAN==0
+#if ENDIAN_L==0
     code_ldf("lw",crn_l,cadr(e1),r);
     code_ldf("lw",crn_h,cadr(e1)+SIZE_OF_INT,r);
 #else
@@ -4523,8 +4525,13 @@
     crn_h = lregister_name_high(creg);
     crn_l = lregister_name_low(creg);
     lvar_intro(e1);
+#if ENDIAN_L==0
     printf("\tlw %s,",crn_l); lvar(e1);
     printf("\tlw %s,",crn_h); lvar(e1+SIZE_OF_INT);
+#else
+    printf("\tlw %s,",crn_h); lvar(e1);
+    printf("\tlw %s,",crn_l); lvar(e1+SIZE_OF_INT);
+#endif
 }
 
 
--- a/mc-code-powerpc.c	Tue Oct 19 16:01:15 2004 +0900
+++ b/mc-code-powerpc.c	Tue Oct 19 18:15:41 2004 +0900
@@ -62,6 +62,8 @@
 #define SIZE_OF_DOUBLE  8
 #define SIZE_OF_LONGLONG  8
 #define ENDIAN  1
+#define ENDIAN_L  1
+#define ENDIAN_D  1
 
 static int  reg_sp;   /* REGister Stack-Pointer */
 static int reg_stack[MAX_MAX];  /* 実際のレジスタの領域 */
@@ -746,8 +748,13 @@
 	    if (i<0||i>=MAX_INPUT_REGISTER_VAR) return 0;
 	    i = i+MIN_TMP_REG;
 	}
+#if ENDIAN_L==0
+	regv_l(ll)=i;
+	regv_h(ll)=i+1;
+#else
 	regv_h(ll)=i;
 	regv_l(ll)=i+1;
+#endif
     } else { error(-1); ll=LREG_OFFSET+2; }
     return list3(LREGISTER,ll,(int)n);
 }
@@ -2323,6 +2330,15 @@
     if (LARGE_OFFSET(offset)) {
 	printf("\taddis %s,%s,ha16(%d)\n",crn,crn,offset);
     }
+#if ENDIAN_L==0
+    if (creg!=regv_l(reg)) {
+	printf("\tlwz %s,lo16(%d)(%s)\n",lregister_name_low(reg),offset,crn);
+	printf("\tlwz %s,lo16(%d)(%s)\n",lregister_name_high(reg),offset+SIZE_OF_INT,crn);
+    } else {
+	printf("\tlwz %s,lo16(%d)(%s)\n",lregister_name_high(reg),offset+SIZE_OF_INT,crn);
+	printf("\tlwz %s,lo16(%d)(%s)\n",lregister_name_low(reg),offset,crn);
+    }
+#else
     if (creg!=regv_h(reg)) {
 	printf("\tlwz %s,lo16(%d)(%s)\n",lregister_name_high(reg),offset,crn);
 	printf("\tlwz %s,lo16(%d)(%s)\n",lregister_name_low(reg),offset+SIZE_OF_INT,crn);
@@ -2330,6 +2346,7 @@
 	printf("\tlwz %s,lo16(%d)(%s)\n",lregister_name_low(reg),offset+SIZE_OF_INT,crn);
 	printf("\tlwz %s,lo16(%d)(%s)\n",lregister_name_high(reg),offset,crn);
     }
+#endif
 }
 
 #if LONGLONG_CODE
@@ -3020,8 +3037,12 @@
 #if LONGLONG_CODE
     long long d = lcadr(e);
     data_mode(0);
+#if ENDIAN_L==0
+    printf("\t.long\t0x%x,0x%x\n",code_l1(d),code_l2(d));
+#else
     printf("\t.long\t0x%x,0x%x\n",code_l2(d),code_l1(d));
 #endif
+#endif
 }
 
 extern void
@@ -3030,8 +3051,12 @@
 #if FLOAT_CODE
     double d = dcadr(e);
     data_mode(0);
+#if ENDIAN_D==0
+    printf("\t.long\t0x%x,0x%x\n",code_d1(d),code_d2(d));
+#else
     printf("\t.long\t0x%x,0x%x\n",code_d2(d),code_d1(d));
 #endif
+#endif
 }
 
 extern void
@@ -3356,7 +3381,11 @@
     lb=fwdlabel();
     printf("L_%d:\n",lb);
     if (d) {
+#if ENDIAN_D==0
+	printf("\t.long\t0x%x,0x%x\n",code_d1(value),code_d2(value));
+#else
 	printf("\t.long\t0x%x,0x%x\n",code_d2(value),code_d1(value));
+#endif
     } else {
 	printf("\t.long\t0x%x\n",code_f(value));
     }
@@ -4007,9 +4036,13 @@
     use_longlong(creg);
     crn_h = lregister_name_high(creg);
     crn_l = lregister_name_low(creg);
-
+#if ENDIAN_L==0
+    printf("\tstw %s,0(%s)\n",crn_l,drn);
+    printf("\tstw %s,%d(%s)\n",crn_h,SIZE_OF_INT,drn);
+#else
     printf("\tstw %s,0(%s)\n",crn_h,drn);
     printf("\tstw %s,%d(%s)\n",crn_l,SIZE_OF_INT,drn);
+#endif
 }
 
 void
@@ -4018,8 +4051,13 @@
     int r;
     use_longlong(creg);
     r = get_ptr_cache((NMTBL*)caddr(e2));
+#if ENDIAN_L==0
+    code_ldf(cstore(0),lregister_name_low(creg),cadr(e2),r);
+    code_ldf(cstore(0),lregister_name_high(creg),cadr(e2)+SIZE_OF_INT,r);
+#else
     code_ldf(cstore(0),lregister_name_high(creg),cadr(e2),r);
     code_ldf(cstore(0),lregister_name_low(creg),cadr(e2)+SIZE_OF_INT,r);
+#endif
 }
 
 void
@@ -4032,8 +4070,13 @@
     crn_h = lregister_name_high(creg);
     crn_l = lregister_name_low(creg);
     lvar_intro(e2);
+#if ENDIAN_L==0
+    printf("\tstw %s,",crn_l);lvar(e2);
+    printf("\tstw %s,",crn_h);lvar(e2+SIZE_OF_INT);
+#else
     printf("\tstw %s,",crn_h);lvar(e2);
     printf("\tstw %s,",crn_l);lvar(e2+SIZE_OF_INT);
+#endif
 }
 
 void
@@ -4065,8 +4108,13 @@
 code_lconst(int e1,int creg)
 {
     use_longlong(creg);
+#if ENDIAN_L==0
+    code_const(code_l1(lcadr(e1)),regv_h(creg));
+    code_const(code_l2(lcadr(e1)),regv_l(creg));
+#else
     code_const(code_l1(lcadr(e1)),regv_l(creg));
     code_const(code_l2(lcadr(e1)),regv_h(creg));
+#endif
 }
 
 void
@@ -4089,8 +4137,13 @@
     crn_h = lregister_name_high(creg);
     crn_l = lregister_name_low(creg);
     r = get_ptr_cache((NMTBL*)caddr(e1));
+#if ENDIAN_L==0
+    code_ldf(cload(0),crn_l,cadr(e1),r);
+    code_ldf(cload(0),crn_h,cadr(e1)+SIZE_OF_INT,r);
+#else
     code_ldf(cload(0),crn_h,cadr(e1),r);
     code_ldf(cload(0),crn_l,cadr(e1)+SIZE_OF_INT,r);
+#endif
 }
 
 void
@@ -4102,8 +4155,13 @@
     crn_h = lregister_name_high(creg);
     crn_l = lregister_name_low(creg);
     lvar_intro(e1);
+#if ENDIAN_L==0
+    printf("\tlwz %s,",crn_l); lvar(e1);
+    printf("\tlwz %s,",crn_h); lvar(e1+SIZE_OF_INT);
+#else
     printf("\tlwz %s,",crn_h); lvar(e1);
     printf("\tlwz %s,",crn_l); lvar(e1+SIZE_OF_INT);
+#endif
 }
 
 #if 0