]> git.gag.com Git - fw/sdcc/commitdiff
Added initial cseCostEstimation function, this I think will grow over a period of...
authorsandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 10 Nov 2001 06:42:23 +0000 (06:42 +0000)
committersandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 10 Nov 2001 06:42:23 +0000 (06:42 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1554 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/ds390/main.c
src/mcs51/main.c

index 17c9e482cbdde436a76921d85cd99008cebc19c4..b905d3cee1e61b1c7042f96887cf471490b2dcf8 100644 (file)
@@ -201,6 +201,31 @@ _ds390_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
   return TRUE;
 }
 
+/* Do CSE estimation */
+static bool cseCostEstimation (iCode *ic, iCode *pdic)
+{
+    operand *result = IC_RESULT(ic);
+    operand *right  = IC_RIGHT(ic);
+    operand *left   = IC_LEFT(ic);
+    sym_link *result_type = operandType(result);
+    sym_link *right_type  = (right ? operandType(right) : 0);
+    sym_link *left_type   = (left  ? operandType(left)  : 0);
+    
+    /* if it is a pointer then return ok for now */
+    if (IC_RESULT(ic) && IS_PTR(result_type)) return 1;
+    
+    /* if bitwise | add & subtract then no since mcs51 is pretty good at it 
+       so we will cse only if they are local (i.e. both ic & pdic belong to
+       the same basic block */
+    if (IS_BITWISE_OP(ic) || ic->op == '+' || ic->op == '-') {
+       /* then if they are the same Basic block then ok */
+       if (ic->eBBlockNum == pdic->eBBlockNum) return 1;
+       else return 0;
+    }
+       
+    /* for others it is cheaper to do the cse */
+    return 1;
+}
 /** $1 is always the basename.
     $2 is always the output file.
     $3 varies
@@ -296,5 +321,6 @@ PORT ds390_port =
   1,                           /* transform != to !(a == b) */
   0,                           /* leave == */
   TRUE,                         /* we support array initializers. */
+  cseCostEstimation,
   PORT_MAGIC
 };
index c20e80379dfb579915538e3bec0326f193a1e6e9..f4f5ba706afc4e60e2d569de521d28e1a587ca5c 100644 (file)
@@ -120,6 +120,32 @@ _mcs51_genIVT (FILE * of, symbol ** interrupts, int maxInterrupts)
   return FALSE;
 }
 
+/* Do CSE estimation */
+static bool cseCostEstimation (iCode *ic, iCode *pdic)
+{
+    operand *result = IC_RESULT(ic);
+    operand *right  = IC_RIGHT(ic);
+    operand *left   = IC_LEFT(ic);
+    sym_link *result_type = operandType(result);
+    sym_link *right_type  = (right ? operandType(right) : 0);
+    sym_link *left_type   = (left  ? operandType(left)  : 0);
+
+    /* if it is a pointer then return ok for now */
+    if (IC_RESULT(ic) && IS_PTR(result_type)) return 1;
+    
+    /* if bitwise | add & subtract then no since mcs51 is pretty good at it 
+       so we will cse only if they are local (i.e. both ic & pdic belong to
+       the same basic block */
+    if (IS_BITWISE_OP(ic) || ic->op == '+' || ic->op == '-') {
+       /* then if they are the same Basic block then ok */
+       if (ic->eBBlockNum == pdic->eBBlockNum) return 1;
+       else return 0;
+    }
+       
+    /* for others it is cheaper to do the cse */
+    return 1;
+}
+
 /** $1 is always the basename.
     $2 is always the output file.
     $3 varies
@@ -216,5 +242,6 @@ PORT mcs51_port =
   1,                           /* transform != to !(a == b) */
   0,                           /* leave == */
   FALSE,                        /* No array initializer support. */
+  cseCostEstimation,
   PORT_MAGIC
 };