Browse Source

* the boolean operators =;<>;xor with LOC_JUMP and LOC_FLAGS
operands fixed, small things for new ansistring management

florian 26 years ago
parent
commit
0596b2b719
3 changed files with 114 additions and 9 deletions
  1. 71 5
      compiler/cg386add.pas
  2. 36 3
      compiler/tcadd.pas
  3. 7 1
      compiler/temp_gen.pas

+ 71 - 5
compiler/cg386add.pas

@@ -65,7 +65,6 @@ implementation
          end;
          end;
       end;
       end;
 
 
-
     function getresflags(p : ptree;unsigned : boolean) : tresflags;
     function getresflags(p : ptree;unsigned : boolean) : tresflags;
 
 
       begin
       begin
@@ -589,7 +588,7 @@ implementation
          pushed,mboverflow,cmpop : boolean;
          pushed,mboverflow,cmpop : boolean;
          op,op2 : tasmop;
          op,op2 : tasmop;
          flags : tresflags;
          flags : tresflags;
-         otl,ofl : plabel;
+         otl,ofl,hl : plabel;
          power : longint;
          power : longint;
          opsize : topsize;
          opsize : topsize;
          hl4: plabel;
          hl4: plabel;
@@ -688,15 +687,78 @@ implementation
        equaln,xorn : begin
        equaln,xorn : begin
                        if p^.left^.treetype=ordconstn then
                        if p^.left^.treetype=ordconstn then
                         swaptree(p);
                         swaptree(p);
+                       if p^.left^.location.loc=LOC_JUMP then
+                         begin
+                            otl:=truelabel;
+                            getlabel(truelabel);
+                            ofl:=falselabel;
+                            getlabel(falselabel);
+                         end;
+
                        secondpass(p^.left);
                        secondpass(p^.left);
                        { if in flags then copy first to register, because the
                        { if in flags then copy first to register, because the
                          flags can be destroyed }
                          flags can be destroyed }
-                       if (p^.left^.location.loc=LOC_FLAGS) then
-                        locflags2reg(p^.left^.location,opsize);
+                       case p^.left^.location.loc of
+                          LOC_FLAGS:
+                            locflags2reg(p^.left^.location,opsize);
+                          LOC_JUMP:
+                            begin
+                               case opsize of
+                                  S_L : hregister:=getregister32;
+                                  S_W : hregister:=reg32toreg16(getregister32);
+                                  S_B : hregister:=reg32toreg8(getregister32);
+                               end;
+                               p^.left^.location.loc:=LOC_REGISTER;
+                               p^.left^.location.register:=hregister;
+                               emitlab(truelabel);
+                               truelabel:=otl;
+                               exprasmlist^.concat(new(pai386,op_const_reg(A_MOV,opsize,1,
+                                 hregister)));
+                               getlabel(hl);
+                               emitjmp(C_None,hl);
+                               emitlab(falselabel);
+                               falselabel:=ofl;
+                               exprasmlist^.concat(new(pai386,op_reg_reg(A_XOR,S_L,makereg32(hregister),
+                                 makereg32(hregister))));
+                               emitlab(hl);
+                            end;
+                       end;
                        set_location(p^.location,p^.left^.location);
                        set_location(p^.location,p^.left^.location);
                        pushed:=maybe_push(p^.right^.registers32,p);
                        pushed:=maybe_push(p^.right^.registers32,p);
+                       if p^.right^.location.loc=LOC_JUMP then
+                         begin
+                            otl:=truelabel;
+                            getlabel(truelabel);
+                            ofl:=falselabel;
+                            getlabel(falselabel);
+                         end;
                        secondpass(p^.right);
                        secondpass(p^.right);
                        if pushed then restore(p);
                        if pushed then restore(p);
+                       case p^.right^.location.loc of
+                          LOC_FLAGS:
+                            locflags2reg(p^.right^.location,opsize);
+                          LOC_JUMP:
+                            begin
+                               case opsize of
+                                  S_L : hregister:=getregister32;
+                                  S_W : hregister:=reg32toreg16(getregister32);
+                                  S_B : hregister:=reg32toreg8(getregister32);
+                               end;
+                               p^.right^.location.loc:=LOC_REGISTER;
+                               p^.right^.location.register:=hregister;
+                               emitlab(truelabel);
+                               truelabel:=otl;
+                               exprasmlist^.concat(new(pai386,op_const_reg(A_MOV,opsize,1,
+                                 hregister)));
+                               getlabel(hl);
+                               emitjmp(C_None,hl);
+                               emitlab(falselabel);
+                               falselabel:=ofl;
+                               exprasmlist^.concat(new(pai386,op_reg_reg(A_XOR,S_L,makereg32(hregister),
+                                 makereg32(hregister))));
+                               emitlab(hl);
+                            end;
+                       end;
                        goto do_normal;
                        goto do_normal;
                     end
                     end
              else
              else
@@ -1970,7 +2032,11 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.50  1999-04-16 13:42:35  jonas
+  Revision 1.51  1999-04-16 20:44:34  florian
+    * the boolean operators =;<>;xor with LOC_JUMP and LOC_FLAGS
+      operands fixed, small things for new ansistring management
+
+  Revision 1.50  1999/04/16 13:42:35  jonas
     * more regalloc fixes (still not complete)
     * more regalloc fixes (still not complete)
 
 
   Revision 1.49  1999/04/16 11:44:24  peter
   Revision 1.49  1999/04/16 11:44:24  peter

+ 36 - 3
compiler/tcadd.pas

@@ -347,7 +347,11 @@ implementation
                   xorn:
                   xorn:
                     begin
                     begin
                       make_bool_equal_size(p);
                       make_bool_equal_size(p);
-                      calcregisters(p,1,0,0);
+                      if (p^.left^.location.loc in [LOC_JUMP,LOC_FLAGS]) and
+                        (p^.left^.location.loc in [LOC_JUMP,LOC_FLAGS]) then
+                        calcregisters(p,2,0,0)
+                      else
+                        calcregisters(p,1,0,0);
                     end;
                     end;
                   unequaln,
                   unequaln,
                   equaln:
                   equaln:
@@ -388,11 +392,36 @@ implementation
                           end;
                           end;
                          exit;
                          exit;
                        end;
                        end;
-                      calcregisters(p,1,0,0);
+                      if (p^.left^.location.loc in [LOC_JUMP,LOC_FLAGS]) and
+                        (p^.left^.location.loc in [LOC_JUMP,LOC_FLAGS]) then
+                        calcregisters(p,2,0,0)
+                      else
+                        calcregisters(p,1,0,0);
                     end;
                     end;
                 else
                 else
                   CGMessage(type_e_mismatch);
                   CGMessage(type_e_mismatch);
                 end;
                 end;
+
+                { these one can't be in flags! }
+                if p^.treetype in [xorn,unequaln,equaln] then
+                  begin
+                     if p^.left^.location.loc=LOC_FLAGS then
+                       begin
+                          p^.left:=gentypeconvnode(p^.left,porddef(p^.left^.resulttype));
+                          p^.left^.convtyp:=tc_bool_2_int;
+                          p^.left^.explizit:=true;
+                          firstpass(p^.left);
+                       end;
+                     if p^.right^.location.loc=LOC_FLAGS then
+                       begin
+                          p^.right:=gentypeconvnode(p^.right,porddef(p^.right^.resulttype));
+                          p^.right^.convtyp:=tc_bool_2_int;
+                          p^.right^.explizit:=true;
+                          firstpass(p^.right);
+                       end;
+                     { readjust registers }
+                     calcregisters(p,1,0,0);
+                  end;
                 convdone:=true;
                 convdone:=true;
               end
               end
              else
              else
@@ -1017,7 +1046,11 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.25  1999-04-15 09:01:34  peter
+  Revision 1.26  1999-04-16 20:44:37  florian
+    * the boolean operators =;<>;xor with LOC_JUMP and LOC_FLAGS
+      operands fixed, small things for new ansistring management
+
+  Revision 1.25  1999/04/15 09:01:34  peter
     * fixed set loading
     * fixed set loading
     * object inheritance support for browser
     * object inheritance support for browser
 
 

+ 7 - 1
compiler/temp_gen.pas

@@ -635,10 +635,16 @@ begin
    tmpfreelist:=nil;
    tmpfreelist:=nil;
    templist:=nil;
    templist:=nil;
    reftempslots:=nil;
    reftempslots:=nil;
+   { just to be sure }
+   tempansilist:=nil;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.18  1999-04-16 14:03:39  pierre
+  Revision 1.19  1999-04-16 20:44:38  florian
+    * the boolean operators =;<>;xor with LOC_JUMP and LOC_FLAGS
+      operands fixed, small things for new ansistring management
+
+  Revision 1.18  1999/04/16 14:03:39  pierre
    * added paitempalloc for tempansi
    * added paitempalloc for tempansi
 
 
   Revision 1.17  1999/04/16 11:49:45  peter
   Revision 1.17  1999/04/16 11:49:45  peter