added conditional transformation
authorsandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 1 Oct 2000 02:04:05 +0000 (02:04 +0000)
committersandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 1 Oct 2000 02:04:05 +0000 (02:04 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@437 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCC.y
src/port.h

index 5775b3259a6ac96d5a6a1e7c8a66d479b65b1d49..ab463d4b8debca1c1d618ec91fcf6ae1868e5ff5 100644 (file)
@@ -31,6 +31,7 @@
 #include "SDCCval.h"
 #include "SDCCmem.h"
 #include "SDCCast.h"
+#include "port.h"
 
 extern int yyerror (char *);
 extern FILE    *yyin;
@@ -287,41 +288,40 @@ shift_expr
 
 relational_expr
    : shift_expr
-   | relational_expr '<' shift_expr    { $$ = newNode('<',$1,$3); }
-   | relational_expr '>' shift_expr    { $$ = newNode('>',$1,$3); }
+   | relational_expr '<' shift_expr    { 
+       $$ = (port->lt_nge ? 
+             newNode('!',newNode(GE_OP,$1,$3),NULL) :
+             newNode('<', $1,$3));
+   }
+   | relational_expr '>' shift_expr    { 
+          $$ = (port->gt_nle ? 
+                newNode('!',newNode(LE_OP,$1,$3),NULL) :
+                newNode('>',$1,$3));
+   }
    | relational_expr LE_OP shift_expr  { 
-       /* $$ = newNode(LE_OP,$1,$3); */
-       /* getting 8051 specific here : will change
-         LE_OP operation to "not greater than" i.e.
-         ( a <= b ) === ( ! ( a > b )) */
-       $$ = newNode('!', 
-                   newNode('>', $1 , $3 ),
-                   NULL);
+          $$ = (port->le_ngt ? 
+                newNode('!', newNode('>', $1 , $3 ), NULL) :
+                newNode(LE_OP,$1,$3));
    }
    | relational_expr GE_OP shift_expr  { 
-       /* $$ = newNode(GE_OP,$1,$3) ; */
-       /* getting 8051 specific here : will change
-         GE_OP operation to "not less than" i.e.
-         ( a >= b ) === ( ! ( a < b )) */
-       $$ = newNode('!',
-                   newNode('<', $1 , $3 ),
-                   NULL);
+          $$ = (port->ge_nlt ? 
+                newNode('!', newNode('<', $1 , $3 ), NULL) :
+                newNode(GE_OP,$1,$3));
    }
    ;
 
 equality_expr
    : relational_expr
-   | equality_expr EQ_OP relational_expr  { $$ = newNode(EQ_OP,$1,$3);}
-   | equality_expr NE_OP relational_expr  
-          { 
-              /* $$ = newNode(NE_OP,$1,$3); */
-             /* NE_OP changed :            
-                expr1 != expr2 is equivalent to
-                (! expr1 == expr2) */
-             $$ = newNode('!',
-                          newNode(EQ_OP,$1,$3),
-                          NULL);
-         }       
+   | equality_expr EQ_OP relational_expr  { 
+    $$ = (port->eq_nne ? 
+         newNode('!',newNode(NE_OP,$1,$3),NULL) : 
+         newNode(EQ_OP,$1,$3));
+   }
+   | equality_expr NE_OP relational_expr { 
+       $$ = (port->ne_neq ? 
+            newNode('!', newNode(EQ_OP,$1,$3), NULL) : 
+            newNode(NE_OP,$1,$3));
+   }       
    ;
 
 and_expr
index 2247a7e9d02ebeab1db097ef69269f848b80c954..b98eee5351aedee42d9601bed17d4b20eaa4eb35 100644 (file)
@@ -129,7 +129,7 @@ typedef struct {
        options are parsed. */
     void (*setDefaultOptions)(void);
     /** Does the dirty work. */
-    void (*assignRegisters)(eBBlock **, int);
+    void (*assignRegisters)(struct eBBlock **, int);
     
     /** Returns the register name of a symbol.
        Used so that 'regs' can be an incomplete type. */
@@ -161,6 +161,14 @@ typedef struct {
     /** If TRUE, then tprintf and !dw will be used for some initalisers
      */
     bool use_dw_for_init;
+
+    /* condition transformations */
+    bool lt_nge ;     /* transform (a < b)  to !(a >= b)  */
+    bool gt_nle ;     /* transform (a > b)  to !(a <= b)  */
+    bool le_ngt ;     /* transform (a <= b) to !(a > b)   */
+    bool ge_nlt ;     /* transform (a >= b) to !(a < b)   */
+    bool ne_neq ;     /* transform a != b --> ! (a == b)  */
+    bool eq_nne ;     /* transform a == b --> ! (a != b)  */
 } PORT;
 
 extern PORT *port;