diff mc-code-powerpc.c @ 231:f5efe15629d4

*** empty log message ***
author kono
date Wed, 28 Apr 2004 21:33:45 +0900
parents d60c6c31f63a
children 8a23c20ac92d
line wrap: on
line diff
--- a/mc-code-powerpc.c	Wed Apr 28 15:06:01 2004 +0900
+++ b/mc-code-powerpc.c	Wed Apr 28 21:33:45 2004 +0900
@@ -1142,7 +1142,6 @@
 void
 code_preinc(int e1,int e2,int dir,int sign,int sz,int reg) {
     char *xrn,*drn;
-    int dreg;
     if (car(e2)==REGISTER) {
 	use_int(reg);
 	printf("\taddi %s,%s,%d\n", 
@@ -1155,14 +1154,14 @@
     if (!is_int_reg(creg)) error(-1);
     xrn = register_name(creg);
     if (reg==USE_CREG) {
-	dreg=get_register(); if (!dreg) error(-1);
-	drn = register_name(dreg);
-	set_ireg(dreg,0);
+	reg=get_register(); if (!reg) error(-1);
+	drn = register_name(reg);
+	set_ireg(reg,0);
     } else {
 	drn = register_name(reg);
     }
     printf("\t%s %s,0(%s)\n",cload(sz),drn,xrn);
-    if (use) cext(sign,sz,dreg);
+    if (use) cext(sign,sz,reg);
     printf("\taddi %s,%s,%d\n",drn,drn,dir);
     printf("\t%s %s,0(%s)\n",cstore(sz),drn,xrn);
 }
@@ -1171,7 +1170,7 @@
 void
 code_postinc(int e1,int e2,int dir,int sign,int sz,int reg) {
     char *xrn,*crn,*nrn;
-    int dreg,nreg;
+    int nreg;
     if (car(e2)==REGISTER) {
 	use_int(reg);
 	printf("\tmr %s,%s\n",register_name(reg),register_name(cadr(e2)));
@@ -1185,9 +1184,9 @@
     nreg=get_register(); if (!nreg) error(-1);
     nrn = register_name(nreg);
     if (reg==USE_CREG) {
-	dreg=get_register(); if (!dreg) error(-1);
-	xrn = register_name(dreg);
-	set_ireg(dreg,0);
+	reg=get_register(); if (!reg) error(-1);
+	xrn = register_name(reg);
+	set_ireg(reg,0);
     } else {
 	xrn = register_name(reg);
     }
@@ -3205,20 +3204,20 @@
 void
 drexpr(int e1, int e2,int l1, int op,int cond)
 {
-    if (cond) {
+    if (!cond) {
 	switch(op) {
 	    case FOP+GT:
-		drexpr(e2,e1,l1,FOP+GE,0); break;
+		drexpr(e2,e1,l1,FOP+GE,1); break;
 	    case FOP+GE:
-		drexpr(e2,e1,l1,FOP+GT,0); break;
+		drexpr(e2,e1,l1,FOP+GT,1); break;
 	    case FOP+EQ:
 		op=FOP+NEQ; break;
 	    case FOP+NEQ:
 		op=FOP+EQ; break;
 	    case DOP+GT:
-		drexpr(e2,e1,l1,DOP+GE,0); break;
+		drexpr(e2,e1,l1,DOP+GE,1); break;
 	    case DOP+GE:
-		drexpr(e2,e1,l1,DOP+GT,0); break;
+		drexpr(e2,e1,l1,DOP+GT,1); break;
 	    case DOP+EQ:
 		op=DOP+NEQ; break;
 	    case DOP+NEQ:
@@ -3240,11 +3239,11 @@
 	    break;
 	case DOP+EQ:
 	case FOP+EQ:
-	    printf("\tbne\tcr0,L_%d\n",l1);
+	    printf("\tbeq\tcr0,L_%d\n",l1);
 	    break;
 	case DOP+NEQ:
 	case FOP+NEQ:
-	    printf("\tbeq\tcr0,L_%d\n",l1);
+	    printf("\tbne\tcr0,L_%d\n",l1);
 	    break;
     }
 }
@@ -3337,9 +3336,9 @@
     case LOP+LE:
     	pcond(code_gt(!cond),l1); break;
     case LOP+UGT:
-    	pcond(code_ugt(!cond),l1); break;
+    	pcond(code_ugt(cond),l1); break;
     case LOP+UGE:
-    	pcond(code_uge(!cond),l1); break;
+    	pcond(code_uge(cond),l1); break;
     default:
 	error(-1);
     }
@@ -3358,9 +3357,9 @@
     case LOP+LE:
     	pcond(code_gt(!cond),l1); break;
     case LOP+UGT:
-    	pcond(code_ugt(!cond),l1); break;
+    	pcond(code_ugt(cond),l1); break;
     case LOP+UGE:
-    	pcond(code_uge(!cond),l1); break;
+    	pcond(code_uge(cond),l1); break;
     default:
 	error(-1);
     }
@@ -3719,7 +3718,9 @@
     clear_ptr_cache();
     lsrd_lib_used = 1;
     set_lreg(RET_LREGISTER,1);
-    set_lreg_operand(oreg,1);
+    if (regv_l(oreg)!=5) {
+	printf("\tmr r5,%s\n", lregister_name_low(oreg));
+    }
     printf("\tbl lsrd__\n");
 }
 
@@ -3886,10 +3887,10 @@
     } else return 0;
     
     switch(op) {
-    case LSHIFT:
-    case ULSHIFT:
-    case RSHIFT:
-    case URSHIFT:
+    case LLSHIFT:
+    case LULSHIFT:
+    case LRSHIFT:
+    case LURSHIFT:
 	return  (0<v&&v<31);
     case LADD:
     case LSUB:
@@ -3923,10 +3924,10 @@
 	greg = get_register();
 	use_reg(greg);
 	grn = register_name(greg);
-	printf("\tsrwi %s,%s,%d\n",grn,crn_h,32-v);
+	printf("\tsrwi %s,%s,%d\n",grn,crn_l,32-v);
+	printf("\tslwi %s,%s,%d\n",crn_h,crn_h,v);
+	printf("\tor %s,%s,%s\n",crn_h,grn,crn_h);
 	printf("\tslwi %s,%s,%d\n",crn_l,crn_l,v);
-	printf("\tor %s,%s,%s\n",crn_l,grn,crn_l);
-	printf("\tslwi %s,%s,%d\n",crn_h,crn_h,v);
 	free_register(greg);
 	return;
     case LRSHIFT:
@@ -3934,7 +3935,7 @@
 	use_reg(greg);
 	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("\tinsrwi %s,%s,%d,0\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);
@@ -3943,19 +3944,20 @@
 	greg = get_register();
 	use_reg(greg);
 	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,%s\n",crn_h,grn,crn_h);
+	printf("\tslwi %s,%s,%d\n",grn,crn_h,32-v);
 	printf("\tsrwi %s,%s,%d\n",crn_l,crn_l,v);
+	printf("\tor %s,%s,%s\n",crn_l,grn,crn_l);
+	printf("\tsrwi %s,%s,%d\n",crn_h,crn_h,v);
 	free_register(greg);
 	return;
+    case LSUB:
+	v = -v;
     case LADD:
-	printf("\taddic %s,%s,lo16(%d)\n",crn_l,crn_l,v);
-	printf("\taddze %s,%s\n",crn_h,crn_h);
-	break;
-    case LSUB:
-	printf("\taddic %s,%s,lo16(-%d)\n",crn_l,crn_l,v);
-	printf("\taddme %s,%s\n",crn_h,crn_h);
+	printf("\taddic %s,%s,%d\n",crn_l,crn_l,v);
+	if (v<0)
+	    printf("\taddme %s,%s\n",crn_h,crn_h);
+	else
+	    printf("\taddze %s,%s\n",crn_h,crn_h);
 	break;
     case LBOR:
 	printf("\tori %s,%s,lo16(%d)\n",crn_l,crn_l,v);