Browse Source

* fixed unsigned comparisons after r18734 (comparison operator is now
used to determine the signedness of the comparison, not the types
of the arguments)

git-svn-id: branches/jvmbackend@18833 -

Jonas Maebe 14 years ago
parent
commit
3bf71d8d04
1 changed files with 25 additions and 13 deletions
  1. 25 13
      compiler/jvm/njvmadd.pas

+ 25 - 13
compiler/jvm/njvmadd.pas

@@ -39,9 +39,9 @@ interface
           function first_addstring: tnode; override;
           function first_addstring: tnode; override;
           function jvm_first_addset: tnode;
           function jvm_first_addset: tnode;
 
 
-          function cmpnode2signedtopcmp: TOpCmp;
+          function cmpnode2topcmp(unsigned: boolean): TOpCmp;
 
 
-          procedure second_generic_compare;
+          procedure second_generic_compare(unsigned: boolean);
 
 
           procedure pass_left_right;override;
           procedure pass_left_right;override;
           procedure second_addfloat;override;
           procedure second_addfloat;override;
@@ -383,13 +383,25 @@ interface
       end;
       end;
 
 
 
 
-    function tjvmaddnode.cmpnode2signedtopcmp: TOpCmp;
+    function tjvmaddnode.cmpnode2topcmp(unsigned: boolean): TOpCmp;
       begin
       begin
+        if not unsigned then
+          case nodetype of
+            gtn: result:=OC_GT;
+            gten: result:=OC_GTE;
+            ltn: result:=OC_LT;
+            lten: result:=OC_LTE;
+            equaln: result:=OC_EQ;
+            unequaln: result:=OC_NE;
+            else
+              internalerror(2011010412);
+          end
+        else
         case nodetype of
         case nodetype of
-          gtn: result:=OC_GT;
-          gten: result:=OC_GTE;
-          ltn: result:=OC_LT;
-          lten: result:=OC_LTE;
+          gtn: result:=OC_A;
+          gten: result:=OC_AE;
+          ltn: result:=OC_B;
+          lten: result:=OC_BE;
           equaln: result:=OC_EQ;
           equaln: result:=OC_EQ;
           unequaln: result:=OC_NE;
           unequaln: result:=OC_NE;
           else
           else
@@ -398,7 +410,7 @@ interface
       end;
       end;
 
 
 
 
-    procedure tjvmaddnode.second_generic_compare;
+    procedure tjvmaddnode.second_generic_compare(unsigned: boolean);
       var
       var
         cmpop: TOpCmp;
         cmpop: TOpCmp;
       begin
       begin
@@ -408,7 +420,7 @@ interface
         if (left.location.loc in [LOC_REGISTER,LOC_CREGISTER]) and
         if (left.location.loc in [LOC_REGISTER,LOC_CREGISTER]) and
            (right.location.loc in [LOC_REGISTER,LOC_CREGISTER]) then
            (right.location.loc in [LOC_REGISTER,LOC_CREGISTER]) then
           swapleftright;
           swapleftright;
-        cmpop:=cmpnode2signedtopcmp;
+        cmpop:=cmpnode2topcmp(unsigned);
         if (nf_swapped in flags) then
         if (nf_swapped in flags) then
           cmpop:=swap_opcmp(cmpop);
           cmpop:=swap_opcmp(cmpop);
         location_reset(location,LOC_JUMP,OS_NO);
         location_reset(location,LOC_JUMP,OS_NO);
@@ -515,7 +527,7 @@ interface
         if (left.location.loc in [LOC_FPUREGISTER,LOC_CFPUREGISTER]) and
         if (left.location.loc in [LOC_FPUREGISTER,LOC_CFPUREGISTER]) and
            (right.location.loc in [LOC_FPUREGISTER,LOC_CFPUREGISTER]) then
            (right.location.loc in [LOC_FPUREGISTER,LOC_CFPUREGISTER]) then
           swapleftright;
           swapleftright;
-        cmpop:=cmpnode2signedtopcmp;
+        cmpop:=cmpnode2topcmp(false);
         if (nf_swapped in flags) then
         if (nf_swapped in flags) then
           cmpop:=swap_opcmp(cmpop);
           cmpop:=swap_opcmp(cmpop);
         location_reset(location,LOC_JUMP,OS_NO);
         location_reset(location,LOC_JUMP,OS_NO);
@@ -546,13 +558,13 @@ interface
 
 
     procedure tjvmaddnode.second_cmpboolean;
     procedure tjvmaddnode.second_cmpboolean;
       begin
       begin
-        second_generic_compare;
+        second_generic_compare(true);
       end;
       end;
 
 
 
 
     procedure tjvmaddnode.second_cmp64bit;
     procedure tjvmaddnode.second_cmp64bit;
       begin
       begin
-        second_generic_compare;
+        second_generic_compare(not is_signed(left.resultdef));
       end;
       end;
 
 
 
 
@@ -564,7 +576,7 @@ interface
 
 
     procedure tjvmaddnode.second_cmpordinal;
     procedure tjvmaddnode.second_cmpordinal;
       begin
       begin
-        second_generic_compare;
+        second_generic_compare(not is_signed(left.resultdef));
       end;
       end;
 
 
 begin
 begin