Browse Source

* fixed several issues with flags

florian 21 years ago
parent
commit
e7aba71412
4 changed files with 32 additions and 8 deletions
  1. 7 2
      compiler/arm/cgcpu.pas
  2. 5 2
      compiler/arm/cpubase.pas
  3. 5 2
      compiler/arm/narmadd.pas
  4. 15 2
      compiler/arm/narmcnv.pas

+ 7 - 2
compiler/arm/cgcpu.pas

@@ -37,6 +37,8 @@ unit cgcpu;
 
 
     type
     type
       tcgarm = class(tcg)
       tcgarm = class(tcg)
+        { true, if the next arithmetic operation should modify the flags }
+        setflags : boolean;
         procedure init_register_allocators;override;
         procedure init_register_allocators;override;
         procedure done_register_allocators;override;
         procedure done_register_allocators;override;
 
 
@@ -387,7 +389,7 @@ unit cgcpu;
                  end;
                  end;
              end;
              end;
            else
            else
-             list.concat(taicpu.op_reg_reg_reg(op_reg_reg_opcg2asmop[op],dst,src2,src1));
+             list.concat(setoppostfix(taicpu.op_reg_reg_reg(op_reg_reg_opcg2asmop[op],dst,src2,src1),toppostfix(ord(setflags)*ord(PF_S))));
          end;
          end;
        end;
        end;
 
 
@@ -1208,7 +1210,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.36  2004-01-22 02:22:47  florian
+  Revision 1.37  2004-01-22 20:13:18  florian
+    * fixed several issues with flags
+
+  Revision 1.36  2004/01/22 02:22:47  florian
     * op_const_reg_reg with OP_SAR fixed
     * op_const_reg_reg with OP_SAR fixed
 
 
   Revision 1.35  2004/01/22 01:47:15  florian
   Revision 1.35  2004/01/22 01:47:15  florian

+ 5 - 2
compiler/arm/cpubase.pas

@@ -509,7 +509,7 @@ unit cpubase;
     procedure inverse_flags(var f: TResFlags);
     procedure inverse_flags(var f: TResFlags);
       const
       const
         inv_flags: array[TResFlags] of TResFlags =
         inv_flags: array[TResFlags] of TResFlags =
-          (F_NE,F_NE,F_CC,F_CS,F_PL,F_MI,F_VC,F_VS,F_LS,F_HI,
+          (F_NE,F_EQ,F_CC,F_CS,F_PL,F_MI,F_VC,F_VS,F_LS,F_HI,
           F_LT,F_GE,F_LE,F_GT);
           F_LT,F_GE,F_LE,F_GT);
       begin
       begin
         f:=inv_flags[f];
         f:=inv_flags[f];
@@ -566,7 +566,10 @@ unit cpubase;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.23  2004-01-21 19:01:03  florian
+  Revision 1.24  2004-01-22 20:13:18  florian
+    * fixed several issues with flags
+
+  Revision 1.23  2004/01/21 19:01:03  florian
     * fixed handling of max. distance of pc relative symbols
     * fixed handling of max. distance of pc relative symbols
 
 
   Revision 1.22  2003/12/26 14:02:30  peter
   Revision 1.22  2003/12/26 14:02:30  peter

+ 5 - 2
compiler/arm/narmadd.pas

@@ -301,7 +301,7 @@ interface
                end;
                end;
           end
           end
         else
         else
-          exprasmlist.concat(taicpu.op_reg_reg(A_CMP,left.location.register,right.location.register));
+          exprasmlist.concat(taicpu.op_reg_reg(A_CMP,right.location.register,left.location.register));
 
 
         location_reset(location,LOC_FLAGS,OS_NO);
         location_reset(location,LOC_FLAGS,OS_NO);
         location.resflags:=getresflags(unsigned);
         location.resflags:=getresflags(unsigned);
@@ -314,7 +314,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.6  2004-01-22 01:47:15  florian
+  Revision 1.7  2004-01-22 20:13:18  florian
+    * fixed several issues with flags
+
+  Revision 1.6  2004/01/22 01:47:15  florian
     * improved register usage
     * improved register usage
     + implemented second_cmp64bit
     + implemented second_cmp64bit
 
 

+ 15 - 2
compiler/arm/narmcnv.pas

@@ -65,7 +65,7 @@ implementation
       ncon,ncal,
       ncon,ncal,
       ncgutil,
       ncgutil,
       cpubase,aasmcpu,
       cpubase,aasmcpu,
-      rgobj,tgobj,cgobj;
+      rgobj,tgobj,cgobj,cgcpu;
 
 
 
 
 {*****************************************************************************
 {*****************************************************************************
@@ -158,13 +158,17 @@ implementation
                    href:=left.location.reference;
                    href:=left.location.reference;
                    inc(href.offset,4);
                    inc(href.offset,4);
                    cg.ungetregister(exprasmlist,hregister);
                    cg.ungetregister(exprasmlist,hregister);
+                   tcgarm(cg).setflags:=true;
                    cg.a_op_ref_reg(exprasmlist,OP_OR,OS_32,href,hregister);
                    cg.a_op_ref_reg(exprasmlist,OP_OR,OS_32,href,hregister);
+                   tcgarm(cg).setflags:=false;
                  end
                  end
                 else
                 else
                  begin
                  begin
                    location_force_reg(exprasmlist,left.location,left.location.size,true);
                    location_force_reg(exprasmlist,left.location,left.location.size,true);
                    location_release(exprasmlist,left.location);
                    location_release(exprasmlist,left.location);
+                   tcgarm(cg).setflags:=true;
                    cg.a_op_reg_reg(exprasmlist,OP_OR,left.location.size,left.location.register,left.location.register);
                    cg.a_op_reg_reg(exprasmlist,OP_OR,left.location.size,left.location.register,left.location.register);
+                   tcgarm(cg).setflags:=false;
                  end;
                  end;
               end;
               end;
             LOC_FLAGS :
             LOC_FLAGS :
@@ -179,12 +183,16 @@ implementation
                    cg.a_load_reg_reg(exprasmlist,OS_32,OS_32,left.location.registerlow,hregister);
                    cg.a_load_reg_reg(exprasmlist,OS_32,OS_32,left.location.registerlow,hregister);
                    cg.ungetregister(exprasmlist,hregister);
                    cg.ungetregister(exprasmlist,hregister);
                    location_release(exprasmlist,left.location);
                    location_release(exprasmlist,left.location);
+                   tcgarm(cg).setflags:=true;
                    cg.a_op_reg_reg(exprasmlist,OP_OR,OS_32,left.location.registerhigh,hregister);
                    cg.a_op_reg_reg(exprasmlist,OP_OR,OS_32,left.location.registerhigh,hregister);
+                   tcgarm(cg).setflags:=false;
                  end
                  end
                 else
                 else
                  begin
                  begin
                    location_release(exprasmlist,left.location);
                    location_release(exprasmlist,left.location);
+                   tcgarm(cg).setflags:=true;
                    cg.a_op_reg_reg(exprasmlist,OP_OR,left.location.size,left.location.register,left.location.register);
                    cg.a_op_reg_reg(exprasmlist,OP_OR,left.location.size,left.location.register,left.location.register);
+                   tcgarm(cg).setflags:=false;
                  end;
                  end;
               end;
               end;
             LOC_JUMP :
             LOC_JUMP :
@@ -198,7 +206,9 @@ implementation
                 cg.a_load_const_reg(exprasmlist,OS_INT,0,hregister);
                 cg.a_load_const_reg(exprasmlist,OS_INT,0,hregister);
                 cg.a_label(exprasmlist,hlabel);
                 cg.a_label(exprasmlist,hlabel);
                 cg.ungetregister(exprasmlist,hregister);
                 cg.ungetregister(exprasmlist,hregister);
+                tcgarm(cg).setflags:=true;
                 cg.a_op_reg_reg(exprasmlist,OP_OR,OS_INT,hregister,hregister);
                 cg.a_op_reg_reg(exprasmlist,OP_OR,OS_INT,hregister,hregister);
+                tcgarm(cg).setflags:=false;
               end;
               end;
             else
             else
               internalerror(200311301);
               internalerror(200311301);
@@ -217,7 +227,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.7  2003-11-30 19:35:29  florian
+  Revision 1.8  2004-01-22 20:13:18  florian
+    * fixed several issues with flags
+
+  Revision 1.7  2003/11/30 19:35:29  florian
     * fixed several arm related problems
     * fixed several arm related problems
 
 
   Revision 1.6  2003/11/04 22:30:15  florian
   Revision 1.6  2003/11/04 22:30:15  florian