Browse Source

* fixed bool-bool conversion

peter 26 years ago
parent
commit
7e2211d2d9
3 changed files with 34 additions and 13 deletions
  1. 12 6
      compiler/cg386cnv.pas
  2. 5 2
      compiler/htypechk.pas
  3. 17 5
      compiler/tccnv.pas

+ 12 - 6
compiler/cg386cnv.pas

@@ -915,6 +915,7 @@ implementation
       var
       var
         hregister : tregister;
         hregister : tregister;
         flags     : tresflags;
         flags     : tresflags;
+        opsize    : topsize;
       begin
       begin
          clear_location(pto^.location);
          clear_location(pto^.location);
          { byte(boolean) or word(wordbool) or longint(longbool) must
          { byte(boolean) or word(wordbool) or longint(longbool) must
@@ -928,13 +929,14 @@ implementation
            end;
            end;
          pto^.location.loc:=LOC_REGISTER;
          pto^.location.loc:=LOC_REGISTER;
          del_reference(pfrom^.location.reference);
          del_reference(pfrom^.location.reference);
+         opsize:=def_opsize(pfrom^.resulttype);
          case pfrom^.location.loc of
          case pfrom^.location.loc of
             LOC_MEM,LOC_REFERENCE :
             LOC_MEM,LOC_REFERENCE :
               begin
               begin
-                hregister:=getregister32;
-                exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,S_L,
+                hregister:=def_getreg(pfrom^.resulttype);
+                exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,opsize,
                   newreference(pfrom^.location.reference),hregister)));
                   newreference(pfrom^.location.reference),hregister)));
-                exprasmlist^.concat(new(pai386,op_reg_reg(A_OR,S_L,hregister,hregister)));
+                exprasmlist^.concat(new(pai386,op_reg_reg(A_OR,opsize,hregister,hregister)));
                 flags:=F_NE;
                 flags:=F_NE;
               end;
               end;
             LOC_FLAGS :
             LOC_FLAGS :
@@ -945,7 +947,7 @@ implementation
             LOC_REGISTER,LOC_CREGISTER :
             LOC_REGISTER,LOC_CREGISTER :
               begin
               begin
                 hregister:=pfrom^.location.register;
                 hregister:=pfrom^.location.register;
-                exprasmlist^.concat(new(pai386,op_reg_reg(A_OR,S_L,hregister,hregister)));
+                exprasmlist^.concat(new(pai386,op_reg_reg(A_OR,opsize,hregister,hregister)));
                 flags:=F_NE;
                 flags:=F_NE;
               end;
               end;
             else
             else
@@ -1103,8 +1105,9 @@ implementation
            second_array_to_pointer,
            second_array_to_pointer,
            second_pointer_to_array,
            second_pointer_to_array,
            second_int_to_int,
            second_int_to_int,
-           second_bool_to_int,
            second_int_to_bool,
            second_int_to_bool,
+           second_bool_to_int, { bool_to_bool }
+           second_bool_to_int,
            second_real_to_real,
            second_real_to_real,
            second_int_to_real,
            second_int_to_real,
            second_int_to_fix,
            second_int_to_fix,
@@ -1257,7 +1260,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.62  1999-04-13 18:51:47  florian
+  Revision 1.63  1999-04-15 08:56:25  peter
+    * fixed bool-bool conversion
+
+  Revision 1.62  1999/04/13 18:51:47  florian
     * esi wasn't reloaded after a call to the esi helper procedure, fixed
     * esi wasn't reloaded after a call to the esi helper procedure, fixed
 
 
   Revision 1.61  1999/03/05 16:14:20  peter
   Revision 1.61  1999/03/05 16:14:20  peter

+ 5 - 2
compiler/htypechk.pas

@@ -89,7 +89,7 @@ implementation
          ((tc_not_possible,tc_not_possible,tc_not_possible,tc_not_possible),
          ((tc_not_possible,tc_not_possible,tc_not_possible,tc_not_possible),
           (tc_not_possible,tc_equal,tc_not_possible,tc_not_possible),
           (tc_not_possible,tc_equal,tc_not_possible,tc_not_possible),
           (tc_not_possible,tc_not_possible,tc_int_2_int,tc_int_2_bool),
           (tc_not_possible,tc_not_possible,tc_int_2_int,tc_int_2_bool),
-          (tc_not_possible,tc_not_possible,tc_bool_2_int,tc_int_2_bool));
+          (tc_not_possible,tc_not_possible,tc_bool_2_int,tc_bool_2_bool));
 
 
       var
       var
          b : byte;
          b : byte;
@@ -650,7 +650,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.19  1999-03-24 23:17:02  peter
+  Revision 1.20  1999-04-15 08:56:27  peter
+    * fixed bool-bool conversion
+
+  Revision 1.19  1999/03/24 23:17:02  peter
     * fixed bugs 212,222,225,227,229,231,233
     * fixed bugs 212,222,225,227,229,231,233
 
 
   Revision 1.18  1999/03/06 17:25:19  peter
   Revision 1.18  1999/03/06 17:25:19  peter

+ 17 - 5
compiler/tccnv.pas

@@ -474,11 +474,19 @@ implementation
             (p^.left^.location.loc in [LOC_REFERENCE,LOC_MEM,LOC_CREGISTER]) then
             (p^.left^.location.loc in [LOC_REFERENCE,LOC_MEM,LOC_CREGISTER]) then
            exit;
            exit;
          p^.location.loc:=LOC_REGISTER;
          p^.location.loc:=LOC_REGISTER;
-         p^.left:=gentypeconvnode(p^.left,s32bitdef);
          { need if bool to bool !!
          { need if bool to bool !!
-           not very nice !! }
+           not very nice !!
+         p^.left:=gentypeconvnode(p^.left,s32bitdef);
          p^.left^.explizit:=true;
          p^.left^.explizit:=true;
-         firstpass(p^.left);
+         firstpass(p^.left);  }
+         if p^.registers32<1 then
+           p^.registers32:=1;
+      end;
+
+
+    procedure first_bool_to_bool(var p : ptree);
+      begin
+         p^.location.loc:=LOC_REGISTER;
          if p^.registers32<1 then
          if p^.registers32<1 then
            p^.registers32:=1;
            p^.registers32:=1;
       end;
       end;
@@ -555,8 +563,9 @@ implementation
          first_array_to_pointer,
          first_array_to_pointer,
          first_pointer_to_array,
          first_pointer_to_array,
          first_int_to_int,
          first_int_to_int,
-         first_bool_to_int,
          first_int_to_bool,
          first_int_to_bool,
+         first_bool_to_bool,
+         first_bool_to_int,
          first_real_to_real,
          first_real_to_real,
          first_int_to_real,
          first_int_to_real,
          first_int_to_fix,
          first_int_to_fix,
@@ -927,7 +936,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.22  1999-04-08 09:47:31  pierre
+  Revision 1.23  1999-04-15 08:56:24  peter
+    * fixed bool-bool conversion
+
+  Revision 1.22  1999/04/08 09:47:31  pierre
    * warn if uninitilized local vars are used in IS or AS statements
    * warn if uninitilized local vars are used in IS or AS statements
 
 
   Revision 1.21  1999/03/06 17:25:20  peter
   Revision 1.21  1999/03/06 17:25:20  peter