changeset 217:a4d3818f5353

*** empty log message ***
author kono
date Sat, 24 Apr 2004 21:44:50 +0900
parents 941177f65d07
children 2d64e82437d2
files mc-code-powerpc.c
diffstat 1 files changed, 126 insertions(+), 74 deletions(-) [+]
line wrap: on
line diff
--- a/mc-code-powerpc.c	Sat Apr 24 18:45:30 2004 +0900
+++ b/mc-code-powerpc.c	Sat Apr 24 21:44:50 2004 +0900
@@ -1450,9 +1450,16 @@
 }
 
 void
-set_lreg_operand(int oreg,int mode)
+set_lreg_operand(int reg,int mode)
 {
- wefwef wefwef
+    // save_stack,clear_ptr_cache is assmued    
+    if (!is_longlong_reg(reg)) { error(-1); return; }
+    if (mode) {
+	if (regv_l(reg)!=5)
+	    printf("\tmr r5,%s\n", lregister_name_low(reg));
+	if (regv_l(reg)!=6)
+	    printf("\tmr r6,%s\n", lregister_name_high(reg));
+    }
 }
 
 void
@@ -3302,67 +3309,146 @@
     printf("\tlwz %s,",crn_l); lvar(e1+size_of_int);
 }
 
-static int asld_lib_used=0;
-static char *asld_lib[] = {
-".data",
-/* ".literal8", */
-"        .align 3",
-"__u2dLC1:",
-"        blr",
-0
-};
-
-static int asld_lib_used=0;
-static char *asld_lib_lib[] = {
-};
-
 static int lumod_lib_used=0;
-static char *lumod_lib_lib[] = {
+static char *lumod_lib[] = {
 };
 
 static int lmod_lib_used=0;
-static char *lmod_lib_lib[] = {
+static char *lmod_lib[] = {
 };
 
 static int ludiv_lib_used=0;
-static char *ludiv_lib_lib[] = {
+static char *ludiv_lib[] = {
 };
 
 static int ldiv_lib_used=0;
-static char *ldiv_lib_lib[] = {
+static char *ldiv_lib[] = {
 };
 
 static int lsrd_lib_used=0;
-static char *lsrd_lib_lib[] = {
+static char *lsrd_lib[] = {
+".text",
+"        .align 2",
+"lsrd__:",
+"       mr.     r5,r5",
+"       beqlr",
+"       subfic  r2,r5,32",
+"      stw     r3,-32(r1)",
+"      stw     r4,-28(r1)",
+"      cmpwi   cr7,r2,0",
+"      bgt+    cr7,L__lsrd1",
+"      neg     r0,r2",
+"      lwz     r2,-32(r1)",
+"      li      r9,0",
+"      srw     r2,r2,r0",
+"      stw     r9,-48(r1)",
+"      b       L__lsrd2",
+"L__lsrd1:      lwz     r0,-32(r1)",
+"      slw     r9,r0,r2",
+"      lwz     r2,-28(r1)",
+"      srw     r0,r0,r5",
+"      srw     r2,r2,r5",
+"      stw     r0,-48(r1)",
+"      or      r2,r2,r9",
+"L__lsrd2:      stw     r2,-44(r1)",
+"      lwz     r3,-48(r1)",
+"      lwz     r4,-44(r1)",
+"      blr",
+};
+
+static int asld_lib_used=0;
+static char *asld_lib[] = {
+".text",
+"        .align 2",
+"asld__:",
+"       mr.     r5,r5",
+"       beqlr",
+"       subfic  r2,r5,32",
+"      stw     r3,-32(r1)",
+"      stw     r4,-28(r1)",
+"      cmpwi   cr7,r2,0",
+"      bgt+    cr7,L__asld1",
+"      neg     r0,r2",
+"      lwz     r2,-28(r1)",
+"      li      r9,0",
+"      slw     r2,r2,r0",
+"      stw     r9,-44(r1)",
+"      b       L__asld2",
+"L__asld1:      lwz     r0,-28(r1)",
+"      srw     r9,r0,r2",
+"      lwz     r2,-32(r1)",
+"      slw     r0,r0,r5",
+"      slw     r2,r2,r5",
+"      stw     r0,-44(r1)",
+"      or      r2,r2,r9",
+"L__asld2:      stw     r2,-48(r1)",
+"      lwz     r3,-48(r1)",
+"      lwz     r4,-44(r1)",
+"      blr",
 };
 
 static int asrd_lib_used=0;
-static char *asrd_lib_lib[] = {
+static char *asrd_lib[] = {
+".text",
+"        .align 2",
+"asrd__:",
+"       mr.     r5,r5",
+"       beqlr",
+"       subfic  r2,r5,32",
+"      stw     r3,-32(r1)",
+"      stw     r4,-28(r1)",
+"      cmpwi   cr7,r2,0",
+"      bgt+    cr7,L__asrd1",
+"      lwz     r0,-32(r1)",
+"      neg     r2,r2",
+"      sraw    r2,r0,r2",
+"      srawi   r0,r0,31",
+"      b       L__asrd2",
+"L__asrd1:      lwz     r0,-32(r1)",
+"      slw     r9,r0,r2",
+"      lwz     r2,-28(r1)",
+"      sraw    r0,r0,r5",
+"      srw     r2,r2,r5",
+"      or      r2,r2,r9",
+"L__asrd2:      stw     r0,-48(r1)",
+"      stw     r2,-44(r1)",
+"      lwz     r3,-48(r1)",
+"      lwz     r4,-44(r1)",
+"      blr",
 };
 
+static void
+extern_conv(char *conv)
+{
+    code_save_stacks();
+    clear_ptr_cache();
+    extern_define(conv,0,FUNCTION,1);
+    printf("\tbl L_%s$stub\n",conv);
+}
+
 #if FLOAT_CODE
-static int dl2ll_lib_used=0;
-static char *dl2ll_lib_lib[] = {
+static int d2ll_lib_used=0;
+static char *d2ll_lib[] = {
 };
 
 static int d2ull_lib_used=0;
-static char *d2ull_lib_lib[] = {
+static char *d2ull_lib[] = {
 };
 
 static int f2ll_lib_used=0;
-static char *f2ll_lib_lib[] = {
+static char *f2ll_lib[] = {
 };
 
 static int f2ull_lib_used=0;
-static char *f2ull_lib_lib[] = {
+static char *f2ull_lib[] = {
 };
 
 static int ll2d_lib_used=0;
-static char *ll2d_lib_lib[] = {
+static char *ll2d_lib[] = {
 };
 
 static int ll2f_lib_used=0;
-static char *ll2f_lib_lib[] = {
+static char *ll2f_lib[] = {
 };
 
 #endif
@@ -3403,45 +3489,33 @@
 static void
 code_ldiv_lib(int oreg) // ___divdi3$stub
 {
-    code_save_stacks();
-    clear_ptr_cache();
-    ldiv_lib_used = 1;
     set_lreg_operand(oreg,1);
     set_lreg(RET_LREGISTER,1);
-    printf("\tbl ldiv_\n");
+    extern_conv("__divdi3");
 }
 
 static void
 code_ludiv_lib(int oreg) // ___udivdi3$stub
 {
-    code_save_stacks();
-    clear_ptr_cache();
-    ludiv_lib_used = 1;
     set_lreg_operand(oreg,1);
     set_lreg(RET_LREGISTER,1);
-    printf("\tbl ludiv_\n");
+    extern_conv("__udivdi3");
 }
 
 static void
 code_lmod_lib(int oreg) // ___moddi3$stub
 {
-    code_save_stacks();
-    clear_ptr_cache();
-    lmod_lib_used = 1;
     set_lreg_operand(oreg,1);
     set_lreg(RET_LREGISTER,1);
-    printf("\tbl lmod_\n");
+    extern_conv("__moddi3");
 }
 
 static void
 code_lumod_lib(int oreg) // ___umoddi3$stub
 {
-    code_save_stacks();
-    clear_ptr_cache();
-    lumod_lib_used = 1;
     set_lreg_operand(oreg,1);
     set_lreg(RET_LREGISTER,1);
-    printf("\tbl lumod_\n");
+    extern_conv("__umoddi3");
 }
 
 void
@@ -3717,71 +3791,49 @@
 code_d2ll(int creg)
 {
     // fixdfdi$stub
-    code_save_stacks();
-    clear_ptr_cache();
-    dl2ll_lib_used = 1;
     set_freg(RET_DREGISTER,1);
-    printf("\tbl d2ll_\n");
+    extern_conv("_fixdfdi");
     set_lreg(RET_LREGISTER,0);
 }
 
 void
 code_d2ull(int creg)
 {
-    // fixunsdfdi$stub
-    code_save_stacks();
-    clear_ptr_cache();
-    d2ull_lib_used = 1;
     set_freg(RET_DREGISTER,1);
-    printf("\tbl d2ull\n");
+    extern_conv("_fixunsdfdi");
     set_lreg(RET_LREGISTER,0);
 }
 
 void
 code_f2ll(int creg)
 {
-    // fixdfdi$stub
-    code_save_stacks();
-    clear_ptr_cache();
-    f2ll_lib_used = 1;
     set_freg(RET_DREGISTER,1);
-    printf("\tbl f2ll\n");
+    extern_conv("_fixdfdi");
     set_lreg(RET_LREGISTER,0);
 }
 
 void
 code_f2ull(int creg)
 {
-    // fixsfdi$stub
-    code_save_stacks();
-    clear_ptr_cache();
-    f2ull_lib_used = 1;
     set_freg(RET_DREGISTER,1);
-    printf("\tbl f2ull\n");
+    extern_conv("_fixsfdi");
     set_lreg(RET_LREGISTER,0);
 }
 
 void
 code_ll2d(int creg)
 {
-    // floatdidf$stub
-    code_save_stacks();
-    clear_ptr_cache();
-    ll2d_lib_used = 1;
     set_lreg(RET_LREGISTER,1);
-    printf("\tbl ll2d\n");
+    extern_conv("_floatdidf");
     set_freg(RET_DREGISTER,0);
 }
 
+
 void
 code_ll2f(int creg)
 {
-    // floatdisf$stub
-    code_save_stacks();
-    clear_ptr_cache();
-    ll2f_lib_used = 1;
     set_lreg(RET_LREGISTER,1);
-    printf("\tbl ll2f\n");
+    extern_conv("_floatdisf");
     set_freg(RET_DREGISTER,0);
 }