changeset 215:abfad046e6de

*** empty log message ***
author kono
date Sat, 24 Apr 2004 15:31:15 +0900
parents 4f459364c334
children 941177f65d07
files mc-code-powerpc.c
diffstat 1 files changed, 85 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/mc-code-powerpc.c	Sat Apr 24 14:42:11 2004 +0900
+++ b/mc-code-powerpc.c	Sat Apr 24 15:31:15 2004 +0900
@@ -3429,20 +3429,26 @@
 
 int code_lconst_op_p(int op,int e)
 {
+    int v;
+    if (car(e)==LCONST) {
+	if (!(-32766<lcaddr(e)&&lcaddr(e)<32767)) return 0;
+	v = lcaddr(e);
+    } else if (car(e)==CONST) {
+	if (!(-32766<caddr(e)&&caddr(e)<32767)) return 0;
+	v = caddr(e);
+    }
+    
     switch(op) {
     case LSHIFT:
     case ULSHIFT:
     case RSHIFT:
     case URSHIFT:
-	return  (<lcaddr(e)&&lcaddr(e)<32767);
+	return  (0<v&&v<31);
     case ADD:
     case SUB:
-    case EOR: 
+	return 1;
     case BOR:
-	if (car(e)==LCONST)
-	    return  (-32766<lcaddr(e)&&lcaddr(e)<32767);
-	if (car(e)==CONST)
-	    return  (-32766<caddr(e)&&caddr(e)<32767);
+	return  (v>0);
     default:
 	return 0;
     }
@@ -3450,33 +3456,55 @@
 
 loprtc(int op,int e)
 {
-    char *crn = register_name(creg);
+    char *crn_h = lregister_name_high(creg);
+    char *crn_l = lregister_name_low(creg);
+    char *grn;
     int v;
+    int greg;
+
     if (car(e)==LCONST) v = lcaddr(e);
     else if (car(e)==CONST) v = caddr(e);
 
     switch(op) {
     case LSHIFT:
     case ULSHIFT:
-	printf("\tslwi %s,%s,%d\n",crn,crn,v);
+	greg = get_register();
+	grn = register_name(greg);
+	printf("\tsrwi %s,%s,%d\n",grn,crn_h,32-v);
+	printf("\tslwi %s,%s,%d\n",crn_l,crn_l,v);
+	printf("\tor %s,%s,%d\n",crn_l,grn,crn_l);
+	printf("\tslwi %s,%s,%d\n",crn_h,crn_h,v);
+	free_register(greg);
 	return;
     case RSHIFT:
-	printf("\tsrawi %s,%s,%d\n",crn,crn,v);
+	greg = get_register();
+	grn = register_name(greg);
+	printf("\tsrwi %s,%s,%d\n",grn,crn_l,v);
+	printf("\tinsrwi %s,%s,%d\n",grn,crn_h,v);
+	printf("\tsrawi %s,%s,%d\n",crn_h,crn_h,v);
+	printf("\tmr %s,%s\n",crn_l,grn);
+	free_register(greg);
 	return;
     case URSHIFT:
-	printf("\tsrwi %s,%s,%d\n",crn,crn,v);
+	greg = get_register();
+	grn = register_name(greg);
+	printf("\tslwi %s,%s,%d\n",grn,crn_l,32-v);
+	printf("\tsrwi %s,%s,%d\n",crn_l,crn_h,v);
+	printf("\tor %s,%s,%d\n",crn_h,grn,crn_h);
+	printf("\tsrwi %s,%s,%d\n",crn_l,crn_l,v);
+	free_register(greg);
+	return;
 	return;
     case ADD:
-	printf("\taddi %s,%s,lo16(%d)\n",crn,crn,v);
+	printf("\taddi %s,%s,lo16(%d)\n",crn_l,crn_l,v);
+	printf("\taddze %s,%s\n",crn_h,crn_h);
 	break;
     case SUB:
-	printf("\tsubi %s,%s,lo16(%d)\n",crn,crn,v);
-	break;
-    case EOR: 
-	printf("\txori %s,%s,lo16(%d)\n",crn,crn,v);
+	printf("\tsubi %s,%s,lo16(%d)\n",crn_l,crn_l,v);
+	printf("\taddme %s,%s\n",crn_h,crn_h);
 	break;
     case BOR:
-	printf("\tori %s,%s,lo16(%d)\n",crn,crn,v);
+	printf("\tori %s,%s,lo16(%d)\n",crn_l,crn_l,v);
 	break;
     default:
 	error(-1);
@@ -3505,110 +3533,124 @@
 void
 code_i2ll(int creg)
 {
-
+    char *crn,*crn_h,*crn_l;
+    int creg0;
+    crn = register_name(creg);
+    creg = use_lognlong(creg0=creg);
+    crn_h = lregister_name_high(creg);
+    crn_l = lregister_name_low(creg);
+    if (creg0!=regv_l(creg))
+	printf("\tmr %s,%s\n",crn_l,crn);
+    printf("\tsrawi %s,%s,31\n",crn_h,crn_l);
 }
 
 void
 code_i2ull(int creg)
 {
-
+    code_i2ll(creg);
 }
 
 void
 code_u2ll(int creg)
 {
-
+    int creg0;
+    char *crn,*crn_h,*crn_l;
+    crn = register_name(creg);
+    creg = use_lognlong(creg0=creg);
+    crn_h = lregister_name_high(creg);
+    crn_l = lregister_name_low(creg);
+    if (creg0!=regv_l(creg))
+	printf("\tmr %s,%s\n",crn_l,crn);
+    printf("\tli %s,0\n",crn_h);
 }
 
 void
 code_u2ull(int creg)
 {
-
+    code_u2ll(creg);
 }
 
 void
 code_ll2i(int creg)
 {
-
+    char *crn = lregister_name_low(creg);
+    creg = use_int(creg0=creg);
+    if (creg!=regv_l(creg0))
+	printf("\tmr %s,%s\n",crn,crn_l);
 }
 
 void
 code_ll2u(int creg)
 {
-
+    code_ll2i(creg);
 }
 
 void
 code_ull2i(int creg)
 {
-
+    code_ll2i(creg);
 }
 
 void
 code_ull2u(int creg)
 {
-
+    code_ll2i(creg);
 }
 
 #if FLOAT_CODE
 void
 code_d2ll(int creg)
 {
-
+    creg = use_longlong(creg0=creg);
+    // fixdfdi$stub
 }
 
 void
 code_d2ull(int creg)
 {
-
+    creg = use_longlong(creg0=creg);
+    // fixunsdfdi$stub
 }
 
 void
 code_f2ll(int creg)
 {
+    creg = use_longlong(creg0=creg);
+    // fixdfdi$stub
 
 }
 
 void
 code_f2ull(int creg)
 {
-
+    creg = use_longlong(creg0=creg);
+    // fixsfdi$stub
 }
 
 void
 code_ll2d(int creg)
 {
-
+    creg = use_double(creg0=creg);
+    // floatdidf$stub
 }
 
 void
 code_ll2f(int creg)
 {
-
+    creg = use_float(creg0=creg);
+    // floatdisf$stub
 }
 
 void
 code_ull2d(int creg)
 {
-
+    code_ll2d(creg);
 }
 
 void
 code_ull2f(int creg)
 {
-
-}
-
-void
-code_ull2ll(int creg)
-{
-
-}
-
-void
-code_ull2ull(int creg)
-{
-
+    code_ll2f(creg);
 }
 
 #endif