Преглед изворни кода

* don't change sign for unsigned shl/shr operations
* cleanup for u32bit

peter пре 21 година
родитељ
комит
c25228226d
2 измењених фајлова са 37 додато и 42 уклоњено
  1. 21 32
      compiler/nadd.pas
  2. 16 10
      compiler/nmat.pas

+ 21 - 32
compiler/nadd.pas

@@ -772,44 +772,29 @@ implementation
                    end
                    end
                  else
                  else
                    begin
                    begin
-                     if is_signed(ld) and
-                        { then rd = u32bit }
-                        { convert positive constants to u32bit }
-                        not(is_constintnode(left) and
-                            (tordconstnode(left).value >= 0)) then
+                     { convert positive constants to u32bit }
+                     if (torddef(ld).typ<>u32bit) and
+                        is_constintnode(left) and
+                        (tordconstnode(left).value >= 0) then
+                       inserttypeconv(left,u32inttype);
+                     if (torddef(rd).typ<>u32bit) and
+                        is_constintnode(right) and
+                        (tordconstnode(right).value >= 0) then
+                       inserttypeconv(right,u32inttype);
+                     { when one of the operand is signed perform
+                       the operation in 64bit }
+                     if is_signed(ld) or is_signed(rd) then
                        begin
                        begin
-                         { perform the operation in 64bit }
                          CGMessage(type_w_mixed_signed_unsigned);
                          CGMessage(type_w_mixed_signed_unsigned);
                          inserttypeconv(left,s64inttype);
                          inserttypeconv(left,s64inttype);
                          inserttypeconv(right,s64inttype);
                          inserttypeconv(right,s64inttype);
                        end
                        end
                      else
                      else
                        begin
                        begin
-                         if is_signed(ld) and
-                            not(is_constintnode(left) and
-                                (tordconstnode(left).value >= 0)) then
-                           CGMessage(type_w_mixed_signed_unsigned2);
-                         inserttypeconv(left,u32inttype);
-
-                         if is_signed(rd) and
-                            { then ld = u32bit }
-                            { convert positive constants to u32bit }
-                            not(is_constintnode(right) and
-                                (tordconstnode(right).value >= 0)) then
-                           begin
-                             { perform the operation in 64bit }
-                             CGMessage(type_w_mixed_signed_unsigned);
-                             inserttypeconv(left,s64inttype);
-                             inserttypeconv(right,s64inttype);
-                           end
-                         else
-                           begin
-                             if is_signed(rd) and
-                                not(is_constintnode(right) and
-                                    (tordconstnode(right).value >= 0)) then
-                               CGMessage(type_w_mixed_signed_unsigned2);
-                             inserttypeconv(right,u32inttype);
-                           end;
+                         if (torddef(ld).typ<>u32bit) then
+                           inserttypeconv(left,u32inttype);
+                         if (torddef(rd).typ<>u32bit) then
+                           inserttypeconv(right,u32inttype);
                        end;
                        end;
                    end;
                    end;
                end
                end
@@ -1952,7 +1937,11 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.117  2004-04-29 19:56:37  daniel
+  Revision 1.118  2004-05-19 23:29:26  peter
+    * don't change sign for unsigned shl/shr operations
+    * cleanup for u32bit
+
+  Revision 1.117  2004/04/29 19:56:37  daniel
     * Prepare compiler infrastructure for multiple ansistring types
     * Prepare compiler infrastructure for multiple ansistring types
 
 
   Revision 1.116  2004/04/18 07:52:43  florian
   Revision 1.116  2004/04/18 07:52:43  florian

+ 16 - 10
compiler/nmat.pas

@@ -171,11 +171,10 @@ implementation
          if (rd.typ in [u32bit,u64bit]) and
          if (rd.typ in [u32bit,u64bit]) and
             is_constintnode(left) and
             is_constintnode(left) and
             (tordconstnode(left).value >= 0) then
             (tordconstnode(left).value >= 0) then
-           inserttypeconv(left,right.resulttype)
-         else
-          if (ld.typ in [u32bit,u64bit]) and
-             is_constintnode(right) and
-             (tordconstnode(right).value >= 0) then
+           inserttypeconv(left,right.resulttype);
+         if (ld.typ in [u32bit,u64bit]) and
+            is_constintnode(right) and
+            (tordconstnode(right).value >= 0) then
            inserttypeconv(right,left.resulttype);
            inserttypeconv(right,left.resulttype);
 
 
          { when there is one currency value, everything is done
          { when there is one currency value, everything is done
@@ -454,13 +453,16 @@ implementation
               exit;
               exit;
            end;
            end;
 
 
+         { expand to cpu wordsize, but don't change sign. For
+           32bit ignore 64bit since that has it's own code }
 {$ifndef cpu64bit}
 {$ifndef cpu64bit}
-         { 64 bit ints have their own shift handling }
          if not is_64bit(left.resulttype.def) then
          if not is_64bit(left.resulttype.def) then
-{$endif cpu64bit}
+{$endif}
            begin
            begin
-             if torddef(left.resulttype.def).typ<>torddef(uinttype.def).typ then
-               inserttypeconv(left,sinttype);
+             if is_signed(left.resulttype.def) then
+               inserttypeconv(left,sinttype)
+             else
+               inserttypeconv(left,uinttype);
            end;
            end;
 
 
          inserttypeconv(right,sinttype);
          inserttypeconv(right,sinttype);
@@ -852,7 +854,11 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.61  2004-03-29 14:44:10  peter
+  Revision 1.62  2004-05-19 23:29:25  peter
+    * don't change sign for unsigned shl/shr operations
+    * cleanup for u32bit
+
+  Revision 1.61  2004/03/29 14:44:10  peter
     * fixes to previous constant integer commit
     * fixes to previous constant integer commit
 
 
   Revision 1.60  2004/03/23 22:34:49  peter
   Revision 1.60  2004/03/23 22:34:49  peter