changeset 270:0c6bf0e3e475

*** empty log message ***
author kono
date Wed, 19 May 2004 12:13:00 +0900
parents d9f4026de4e3
children e1a96bdbe527
files mc-code-mips.c
diffstat 1 files changed, 33 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/mc-code-mips.c	Wed May 19 09:56:53 2004 +0900
+++ b/mc-code-mips.c	Wed May 19 12:13:00 2004 +0900
@@ -8,6 +8,7 @@
 
 char *l_include_path[] = {
     "/usr/include/",
+    "/usr/lib/gcc-lib/mipsEEel-linux/2.95.2/include/",
     0
 };
 
@@ -100,7 +101,7 @@
 
 int MAX_INPUT_REGISTER_VAR = 4;
 int MAX_CODE_INPUT_REGISTER_VAR = 7-MIN_TMP_REG;
-int MAX_INPUT_DREGISTER_VAR = 2;
+int MAX_INPUT_DREGISTER_VAR = 4;
 int MAX_INPUT_FREGISTER_VAR = 4;
 int MAX_CODE_INPUT_DREGISTER_VAR = 14-MIN_TMP_FREG;
 int MAX_CODE_INPUT_FREGISTER_VAR = 14-MIN_TMP_FREG;
@@ -115,12 +116,13 @@
 
 #define RET_REGISTER 2
 #define RET_FREGISTER FREG_OFFSET
+#define FREGISTER_OPERAND  (FREG_OFFSET +12)
 
 #define RET_LREGISTER (LREG_OFFSET+REAL_MAX_LREGISTER)
 #define LREGISTER_OPERAND  (LREG_OFFSET +REAL_MAX_LREGISTER +1)
 #define LREGISTER_OPERAND_1  (LREG_OFFSET +REAL_MAX_LREGISTER +2)
-#define RET_LREGISTER_L 2    /* high word */
-#define RET_LREGISTER_H 3    /* low word */
+#define RET_LREGISTER_H 2    /* high word */
+#define RET_LREGISTER_L 3    /* low word */
 #define LREGISTER_OPERAND_H  4    /* high word */
 #define LREGISTER_OPERAND_L  5    /* low word */
 #define LREGISTER_OPERAND_1_H  6    /* high word */
@@ -397,8 +399,16 @@
 code_init(void)
 {
     int reg;
-    // macro_define("__BIG_ENDIAN__ 1\n");
     macro_define("__STDC__ 1\n");
+    macro_define("size_t int\n");
+    macro_define("__mips__ 1\n");
+    macro_define("__LITTLE_ENDIAN__ 1\n");
+    macro_define("__externsion__\n");
+    macro_define("__flexarr\n");
+    macro_define("__builtin_va_list int*\n");
+    macro_define("wchar_t int\n");
+    macro_define("__gnuc_va_list int*\n");
+
     init_ptr_cache();
     reg=RET_LREGISTER;
     regv_l(reg) = RET_LREGISTER_L;
@@ -1252,7 +1262,7 @@
 
 char *
 code_gt(int cond) {
-  return (cond?"eq":"ne");
+  return (cond?"ne":"eq");
 }
 
 char *
@@ -1262,7 +1272,7 @@
 
 char *
 code_ge(int cond) {
-  return code_gt(!cond);
+  return code_gt(cond);
 }
 
 char *
@@ -1810,6 +1820,12 @@
 	error(TYERR);
 	nargs ++ ;
     }
+    if (*preg_arg==0 && cadr(e3)) {  // MIPS oddy
+	t=caddr(cadr(e3));
+        if (t==LONGLONG||t==ULONGLONG||t==DOUBLE) {
+	    reg_arg++;
+	}
+    }
     *pnargs += nargs;
     *preg_arg += reg_arg;
     *pfreg_arg += freg_arg;
@@ -1829,6 +1845,7 @@
 	} else 
 	    return get_input_register_var(reg_arg,0,0);
     } else if (t==LONGLONG||t==ULONGLONG) {
+        if (reg_arg==1) reg_arg=2;  // MIPS oddy
 	if (mode==AS_SAVE) {
 	    return get_lregister_var(0);
 	} else if (reg_arg+1>=MAX_INPUT_REGISTER_VAR)  {
@@ -1843,12 +1860,13 @@
 	} else
 	    return get_input_dregister_var(freg_arg,0,0,0);
     } else if (t==DOUBLE) {
+        if (reg_arg==1) reg_arg=2;  // MIPS oddy
 	if (mode==AS_SAVE) {
 	    return get_dregister_var(0,1);
 	} else if (reg_arg+1>=MAX_INPUT_DREGISTER_VAR) {
 	    return list2(LVAR,caller_arg_offset_v(nargs));
 	} else
-	    return get_input_dregister_var(freg_arg,0,0,1);
+	    return get_input_dregister_var(reg_arg,0,0,1);
     } else if (t>=0&&(car(t)==STRUCT||car(t)==UNION)) {
 	if (mode==AS_SAVE) {
 	    return get_register_var(0);
@@ -2845,8 +2863,10 @@
 
 void
 code_set_return_register(int mode) {
-    if (cadr(fnptr->ty)==DOUBLE||cadr(fnptr->ty)==FLOAT) {
+    if (cadr(fnptr->ty)==FLOAT) {
 	set_freg(RET_FREGISTER,mode);
+    } else if (cadr(fnptr->ty)==DOUBLE) {
+	set_dreg(RET_DREGISTER,mode);
     } else if (cadr(fnptr->ty)==LONGLONG||cadr(fnptr->ty)==ULONGLONG) {
 	set_lreg(RET_LREGISTER,mode);
     } else if (cadr(fnptr->ty)==VOID) {
@@ -3194,8 +3214,8 @@
 
     use_float(d,freg);
     if (d) {
-	printf("\tli %s,0x%x\n",lregister_name_high(freg),code_d2(value));
-	printf("\tli %s,0x%x\n",lregister_name_low(freg),code_d1(value));
+	printf("\tli %s,0x%x\n",lregister_name_high(freg),code_d1(value));
+	printf("\tli %s,0x%x\n",lregister_name_low(freg),code_d2(value));
     } else {
         frn = fregister_name(freg);
         printf("\tli.s %s,%g\n",frn,value);
@@ -3283,7 +3303,7 @@
 
 void
 code_f2d(int reg) { 
-    set_freg(RET_FREGISTER,1);
+    set_freg(FREGISTER_OPERAND,1);
     code_save_stacks();
     clear_ptr_cache();
     extern_conv("fptodp");
@@ -4092,8 +4112,8 @@
 code_lconst(int e1,int creg)
 {
     use_longlong(creg);
-    code_const(code_l1(lcadr(e1)),regv_l(creg));
-    code_const(code_l2(lcadr(e1)),regv_h(creg));
+    code_const(code_l1(lcadr(e1)),regv_h(creg));
+    code_const(code_l2(lcadr(e1)),regv_l(creg));
 }
 
 void