Переглянути джерело

* cs_regalloc renamed to cs_regvars to avoid confusion with register
allocator
* Some preventive changes to i386 spillinh code

daniel 22 роки тому
батько
коміт
42c320cb29

+ 7 - 2
compiler/globtype.pas

@@ -68,7 +68,7 @@ interface
          cs_load_objpas_unit,
          cs_load_gpc_unit,
          { optimizer }
-         cs_regalloc,cs_no_regalloc,cs_uncertainopts,cs_littlesize,
+         cs_regvars,cs_no_regalloc,cs_uncertainopts,cs_littlesize,
          cs_optimize,cs_fastoptimize,cs_slowoptimize,cs_align,
          { browser }
          cs_browser_log,
@@ -208,7 +208,12 @@ implementation
 end.
 {
   $Log$
-  Revision 1.38  2003-04-27 11:21:32  peter
+  Revision 1.39  2003-08-09 18:56:54  daniel
+    * cs_regalloc renamed to cs_regvars to avoid confusion with register
+      allocator
+    * Some preventive changes to i386 spillinh code
+
+  Revision 1.38  2003/04/27 11:21:32  peter
     * aktprocdef renamed to current_procdef
     * procinfo renamed to current_procinfo
     * procinfo will now be stored in current_module so it can be

+ 7 - 2
compiler/i386/ag386int.pas

@@ -48,7 +48,7 @@ interface
 
     const
       regname_count=45;
-      regname_count_bsstart=32;
+      regname_count_bsstart=32;   {Largest power of 2 out of regname_count.}
      
       intel_regname2regnum:array[0..regname_count-1] of regname2regnumrec=(
         (name:'ah';     number:NR_AH),
@@ -966,7 +966,12 @@ initialization
 end.
 {
   $Log$
-  Revision 1.34  2003-03-08 08:59:07  daniel
+  Revision 1.35  2003-08-09 18:56:54  daniel
+    * cs_regalloc renamed to cs_regvars to avoid confusion with register
+      allocator
+    * Some preventive changes to i386 spillinh code
+
+  Revision 1.34  2003/03/08 08:59:07  daniel
     + $define newra will enable new register allocator
     + getregisterint will return imaginary registers with $newra
     + -sr switch added, will skip register allocation so you can see

+ 11 - 2
compiler/i386/ag386nsm.pas

@@ -287,7 +287,11 @@ interface
               if o.reg.enum=R_INTREGISTER then
                 asmwrite(intel_regname(o.reg.number))
               else
-                asmwrite(int_nasmreg2str[o.reg.enum]);
+                begin
+                  if o.reg.enum>high(Toldregister) then
+                    internalerror(01010101);
+                  asmwrite(int_nasmreg2str[o.reg.enum]);
+                end;
             end;
           top_const :
             begin
@@ -925,7 +929,12 @@ initialization
 end.
 {
   $Log$
-  Revision 1.36  2003-07-06 15:31:21  daniel
+  Revision 1.37  2003-08-09 18:56:54  daniel
+    * cs_regalloc renamed to cs_regvars to avoid confusion with register
+      allocator
+    * Some preventive changes to i386 spillinh code
+
+  Revision 1.36  2003/07/06 15:31:21  daniel
     * Fixed register allocator. *Lots* of fixes.
 
   Revision 1.35  2003/06/03 13:01:59  daniel

+ 8 - 3
compiler/i386/cpuswtch.pas

@@ -54,7 +54,7 @@ begin
                  '-' :
                    begin
                      initglobalswitches:=initglobalswitches-[cs_optimize,cs_fastoptimize,cs_slowoptimize,cs_littlesize,
-                       cs_regalloc,cs_uncertainopts];
+                       cs_regvars,cs_uncertainopts];
                      FillChar(ParaAlignment,sizeof(ParaAlignment),0);
                    end;
                  'a' :
@@ -66,7 +66,7 @@ begin
                  'G' : initglobalswitches:=initglobalswitches-[cs_littlesize];
                  'r' :
                    begin
-                     initglobalswitches:=initglobalswitches+[cs_regalloc];
+                     initglobalswitches:=initglobalswitches+[cs_regvars];
                      Simplify_ppu:=false;
                    end;
                  'u' : initglobalswitches:=initglobalswitches+[cs_uncertainopts];
@@ -129,7 +129,12 @@ initialization
 end.
 {
   $Log$
-  Revision 1.9  2002-08-12 15:08:42  carl
+  Revision 1.10  2003-08-09 18:56:54  daniel
+    * cs_regalloc renamed to cs_regvars to avoid confusion with register
+      allocator
+    * Some preventive changes to i386 spillinh code
+
+  Revision 1.9  2002/08/12 15:08:42  carl
     + stab register indexes for powerpc (moved from gdb to cpubase)
     + tprocessor enumeration moved to cpuinfo
     + linker in target_info is now a class

+ 7 - 2
compiler/i386/popt386.pas

@@ -1952,7 +1952,7 @@ See test/tgadint64 in the test suite.
                 {   "cmpl $3,%eax; movzbl 8(%ebp),%ebx; je .Lxxx"           }
                 { so we can't safely replace the movzx then with xor/mov,   }
                 { since that would change the flags (JM)                    }
-                if not(cs_regalloc in aktglobalswitches) then
+                if not(cs_regvars in aktglobalswitches) then
                  Begin
                   If (Taicpu(p).oper[1].typ = top_reg) Then
                     If (Taicpu(p).oper[0].typ = top_reg)
@@ -2058,7 +2058,12 @@ End.
 
 {
   $Log$
-  Revision 1.47  2003-06-08 18:48:03  jonas
+  Revision 1.48  2003-08-09 18:56:54  daniel
+    * cs_regalloc renamed to cs_regvars to avoid confusion with register
+      allocator
+    * Some preventive changes to i386 spillinh code
+
+  Revision 1.47  2003/06/08 18:48:03  jonas
     * first small steps towards an oop optimizer
 
   Revision 1.46  2003/06/03 21:09:05  peter

+ 7 - 2
compiler/nbas.pas

@@ -384,7 +384,7 @@ implementation
          while assigned(hp) do
            begin
 (*
-              if cs_regalloc in aktglobalswitches then
+              if cs_regvars in aktglobalswitches then
                 begin
                    { node transformations }
 
@@ -852,7 +852,12 @@ begin
 end.
 {
   $Log$
-  Revision 1.58  2003-06-13 21:19:30  peter
+  Revision 1.59  2003-08-09 18:56:54  daniel
+    * cs_regalloc renamed to cs_regvars to avoid confusion with register
+      allocator
+    * Some preventive changes to i386 spillinh code
+
+  Revision 1.58  2003/06/13 21:19:30  peter
     * current_procdef removed, use current_procinfo.procdef instead
 
   Revision 1.57  2003/06/10 09:10:47  jonas

+ 13 - 8
compiler/ncgflw.pas

@@ -207,7 +207,7 @@ implementation
 {$ifdef i386}
          { save regvars loaded in the beginning so that we can restore them }
          { when processing the else-block                                   }
-         if cs_regalloc in aktglobalswitches then
+         if cs_regvars in aktglobalswitches then
            begin
              org_list := exprasmlist;
              exprasmlist := taasmoutput.create;
@@ -216,7 +216,7 @@ implementation
          maketojumpbool(exprasmlist,left,lr_dont_load_regvars);
 
 {$ifdef i386}
-         if cs_regalloc in aktglobalswitches then
+         if cs_regvars in aktglobalswitches then
            begin
              org_regvar_loaded_int := rg.regvar_loaded_int;
              org_regvar_loaded_other := rg.regvar_loaded_other;
@@ -235,7 +235,7 @@ implementation
 {$ifdef i386}
          { save current asmlist (previous instructions + then-block) and }
          { loaded regvar state and create new clean ones                 }
-         if cs_regalloc in aktglobalswitches then
+         if cs_regvars in aktglobalswitches then
            begin
              then_regvar_loaded_int := rg.regvar_loaded_int;
              then_regvar_loaded_other := rg.regvar_loaded_other;
@@ -253,7 +253,7 @@ implementation
                    objectlibrary.getlabel(hl);
                    { do go back to if line !! }
 {$ifdef i386}
-                   if not(cs_regalloc in aktglobalswitches) then
+                   if not(cs_regvars in aktglobalswitches) then
 {$endif i386}
                      aktfilepos:=exprasmList.getlasttaifilepos^
 {$ifdef i386}
@@ -271,7 +271,7 @@ implementation
 {$ifdef i386}
               { save current asmlist (previous instructions + else-block) }
               { and loaded regvar state and create a new clean list       }
-              if cs_regalloc in aktglobalswitches then
+              if cs_regvars in aktglobalswitches then
                 begin
                   else_regvar_loaded_int := rg.regvar_loaded_int;
                   else_regvar_loaded_other := rg.regvar_loaded_other;
@@ -285,7 +285,7 @@ implementation
          else
            begin
 {$ifdef i386}
-              if cs_regalloc in aktglobalswitches then
+              if cs_regvars in aktglobalswitches then
                 begin
                   else_regvar_loaded_int := rg.regvar_loaded_int;
                   else_regvar_loaded_other := rg.regvar_loaded_other;
@@ -301,7 +301,7 @@ implementation
            end;
 
 {$ifdef i386}
-         if cs_regalloc in aktglobalswitches then
+         if cs_regvars in aktglobalswitches then
            begin
              { add loads of regvars at the end of the then- and else-blocks  }
              { so that at the end of both blocks the same regvars are loaded }
@@ -1539,7 +1539,12 @@ begin
 end.
 {
   $Log$
-  Revision 1.73  2003-07-23 11:01:14  jonas
+  Revision 1.74  2003-08-09 18:56:54  daniel
+    * cs_regalloc renamed to cs_regvars to avoid confusion with register
+      allocator
+    * Some preventive changes to i386 spillinh code
+
+  Revision 1.73  2003/07/23 11:01:14  jonas
     * several rg.allocexplicitregistersint/rg.deallocexplicitregistersint
       pairs round calls to helpers
 

+ 7 - 2
compiler/ncgmem.pas

@@ -739,7 +739,7 @@ implementation
          else
          { not nodetype=ordconstn }
            begin
-              if (cs_regalloc in aktglobalswitches) and
+              if (cs_regvars in aktglobalswitches) and
                  { if we do range checking, we don't }
                  { need that fancy code (it would be }
                  { buggy)                            }
@@ -898,7 +898,12 @@ begin
 end.
 {
   $Log$
-  Revision 1.67  2003-07-23 11:01:14  jonas
+  Revision 1.68  2003-08-09 18:56:54  daniel
+    * cs_regalloc renamed to cs_regvars to avoid confusion with register
+      allocator
+    * Some preventive changes to i386 spillinh code
+
+  Revision 1.67  2003/07/23 11:01:14  jonas
     * several rg.allocexplicitregistersint/rg.deallocexplicitregistersint
       pairs round calls to helpers
 

+ 8 - 3
compiler/ncgutil.pas

@@ -250,10 +250,10 @@ implementation
                 internalerror(200301154);
               if t.reference.index.enum<>R_INTREGISTER then
                 internalerror(200301154);
-              if not(cs_regalloc in aktglobalswitches) or
+              if not(cs_regvars in aktglobalswitches) or
                  ((t.reference.base.number shr 8) in rg.usableregsint) then
                 exclude(regs,t.reference.base.number shr 8);
-              if not(cs_regalloc in aktglobalswitches) or
+              if not(cs_regvars in aktglobalswitches) or
                  ((t.reference.index.number shr 8) in rg.usableregsint) then
                 exclude(regs,t.reference.index.number shr 8);
             end;
@@ -2030,7 +2030,12 @@ implementation
 end.
 {
   $Log$
-  Revision 1.132  2003-08-03 14:09:50  daniel
+  Revision 1.133  2003-08-09 18:56:54  daniel
+    * cs_regalloc renamed to cs_regvars to avoid confusion with register
+      allocator
+    * Some preventive changes to i386 spillinh code
+
+  Revision 1.132  2003/08/03 14:09:50  daniel
     * Fixed a register allocator bug
     * Figured out why -dnewra generates superfluous "mov reg1,reg2"
       statements: changes in location_force. These moves are now no longer

+ 8 - 3
compiler/powerpc/cpuswtch.pas

@@ -54,7 +54,7 @@ begin
                  '-' :
                    begin
                      initglobalswitches:=initglobalswitches-[cs_optimize,cs_fastoptimize,cs_slowoptimize,cs_littlesize,
-                       cs_regalloc,cs_uncertainopts];
+                       cs_regvars,cs_uncertainopts];
                      FillChar(ParaAlignment,sizeof(ParaAlignment),0);
                    end;
                  'a' :
@@ -66,7 +66,7 @@ begin
                  'G' : initglobalswitches:=initglobalswitches-[cs_littlesize];
                  'r' :
                    begin
-                     initglobalswitches:=initglobalswitches+[cs_regalloc];
+                     initglobalswitches:=initglobalswitches+[cs_regvars];
                      Simplify_ppu:=false;
                    end;
                  'u' : initglobalswitches:=initglobalswitches+[cs_uncertainopts];
@@ -119,7 +119,12 @@ initialization
 end.
 {
   $Log$
-  Revision 1.8  2002-09-07 17:54:59  florian
+  Revision 1.9  2003-08-09 18:56:54  daniel
+    * cs_regalloc renamed to cs_regvars to avoid confusion with register
+      allocator
+    * Some preventive changes to i386 spillinh code
+
+  Revision 1.8  2002/09/07 17:54:59  florian
     * first part of PowerPC fixes
 
   Revision 1.7  2002/09/04 16:03:53  jonas

+ 9 - 4
compiler/regvars.pas

@@ -154,7 +154,7 @@ implementation
       { max. optimizations     }
       { only if no asm is used }
       { and no try statement   }
-      if (cs_regalloc in aktglobalswitches) and
+      if (cs_regvars in aktglobalswitches) and
 {$ifndef i386}
          { we have to store regvars back to memory in this case! }
          (tcgprocinfo(current_procinfo).nestedprocs.count = 0) and
@@ -468,7 +468,7 @@ implementation
       regvarinfo: pregvarinfo;
       r:Tregister;
     begin
-      if (cs_regalloc in aktglobalswitches) and
+      if (cs_regvars in aktglobalswitches) and
          not(pi_uses_asm in current_procinfo.flags) and
          not(pi_uses_exceptions in current_procinfo.flags) then
         begin
@@ -575,7 +575,7 @@ implementation
       { can happen when inlining assembler procedures (JM) }
       if not assigned(current_procinfo.procdef.regvarinfo) then
         exit;
-      if (cs_regalloc in aktglobalswitches) and
+      if (cs_regvars in aktglobalswitches) and
          not(pi_uses_asm in current_procinfo.flags) and
          not(pi_uses_exceptions in current_procinfo.flags) then
         with pregvarinfo(current_procinfo.procdef.regvarinfo)^ do
@@ -616,7 +616,12 @@ end.
 
 {
   $Log$
-  Revision 1.58  2003-07-02 22:18:04  peter
+  Revision 1.59  2003-08-09 18:56:54  daniel
+    * cs_regalloc renamed to cs_regvars to avoid confusion with register
+      allocator
+    * Some preventive changes to i386 spillinh code
+
+  Revision 1.58  2003/07/02 22:18:04  peter
     * paraloc splitted in callerparaloc,calleeparaloc
     * sparc calling convention updates
 

+ 8 - 3
compiler/rgobj.pas

@@ -992,7 +992,7 @@ unit rgobj;
     var r:Tsuperregister;
         hr: tregister;
     begin
-      if not(cs_regalloc in aktglobalswitches) then
+      if not(cs_regvars in aktglobalswitches) then
         exit;
       for r:=firstsaveintreg to lastsaveintreg do
         if (r in is_reg_var_int) and
@@ -1009,7 +1009,7 @@ unit rgobj;
       var
         r: Tregister;
       begin
-        if not(cs_regalloc in aktglobalswitches) then
+        if not(cs_regvars in aktglobalswitches) then
           exit;
         if firstsavefpureg <> R_NO then
           for r.enum := firstsavefpureg to lastsavefpureg do
@@ -2542,7 +2542,12 @@ end.
 
 {
   $Log$
-  Revision 1.62  2003-08-03 14:09:50  daniel
+  Revision 1.63  2003-08-09 18:56:54  daniel
+    * cs_regalloc renamed to cs_regvars to avoid confusion with register
+      allocator
+    * Some preventive changes to i386 spillinh code
+
+  Revision 1.62  2003/08/03 14:09:50  daniel
     * Fixed a register allocator bug
     * Figured out why -dnewra generates superfluous "mov reg1,reg2"
       statements: changes in location_force. These moves are now no longer

+ 8 - 3
compiler/sparc/cpuswtch.pas

@@ -54,7 +54,7 @@ begin
                  '-' :
                    begin
                      initglobalswitches:=initglobalswitches-[cs_optimize,cs_fastoptimize,cs_slowoptimize,cs_littlesize,
-                       cs_regalloc,cs_uncertainopts];
+                       cs_regvars,cs_uncertainopts];
                      FillChar(ParaAlignment,sizeof(ParaAlignment),0);
                    end;
                  'a' :
@@ -66,7 +66,7 @@ begin
                  'G' : initglobalswitches:=initglobalswitches-[cs_littlesize];
                  'r' :
                    begin
-                     initglobalswitches:=initglobalswitches+[cs_regalloc];
+                     initglobalswitches:=initglobalswitches+[cs_regvars];
                      Simplify_ppu:=false;
                    end;
                  'u' : initglobalswitches:=initglobalswitches+[cs_uncertainopts];
@@ -129,7 +129,12 @@ initialization
 end.
 {
   $Log$
-  Revision 1.3  2002-09-07 15:25:14  peter
+  Revision 1.4  2003-08-09 18:56:54  daniel
+    * cs_regalloc renamed to cs_regvars to avoid confusion with register
+      allocator
+    * Some preventive changes to i386 spillinh code
+
+  Revision 1.3  2002/09/07 15:25:14  peter
     * old logs removed and tabs fixed
 
   Revision 1.2  2002/08/23 10:08:28  mazen

+ 39 - 28
compiler/x86/aasmcpu.pas

@@ -2009,7 +2009,7 @@ implementation
      of the huge amount of situations you can have. The irregularity of the i386
      instruction set doesn't help either. (DM)}
 
-
+    
       function get_insert_pos(p:Tai;huntfor1,huntfor2,huntfor3:Tsuperregister):Tai;
 
       var back:Tsupregset;
@@ -2017,30 +2017,33 @@ implementation
       begin
         back:=unusedregsint;
         get_insert_pos:=p;
-        while (p<>nil) and (p.typ=ait_regalloc) do
+        while (p<>nil) and not (p.typ in [ait_instruction,ait_label]) do
           begin
-            {Rewind the register allocation.}
-            if Tai_regalloc(p).allocation then
-              include(unusedregsint,Tai_regalloc(p).reg.number shr 8)
-            else
+            if p.typ=ait_regalloc then
               begin
-                exclude(unusedregsint,Tai_regalloc(p).reg.number shr 8);
-                if Tai_regalloc(p).reg.number shr 8=huntfor1 then
-                  begin
-                    get_insert_pos:=Tai(p.previous);
-                    back:=unusedregsint;
-                  end;
-                if Tai_regalloc(p).reg.number shr 8=huntfor2 then
-                  begin
-                    get_insert_pos:=Tai(p.previous);
-                    back:=unusedregsint;
-                  end;
-                if Tai_regalloc(p).reg.number shr 8=huntfor3 then
+                {Rewind the register allocation.}
+                if Tai_regalloc(p).allocation then
+                  include(unusedregsint,Tai_regalloc(p).reg.number shr 8)
+                else
                   begin
-                    get_insert_pos:=Tai(p.previous);
-                    back:=unusedregsint;
-                  end;
-              end;
+                    exclude(unusedregsint,Tai_regalloc(p).reg.number shr 8);
+                    if Tai_regalloc(p).reg.number shr 8=huntfor1 then
+                      begin
+                        get_insert_pos:=Tai(p.previous);
+                        back:=unusedregsint;
+                      end;
+                    if Tai_regalloc(p).reg.number shr 8=huntfor2 then
+                      begin
+                        get_insert_pos:=Tai(p.previous);
+                        back:=unusedregsint;
+                      end;
+                    if Tai_regalloc(p).reg.number shr 8=huntfor3 then
+                      begin
+                        get_insert_pos:=Tai(p.previous);
+                        back:=unusedregsint;
+                      end;
+                end;
+            end {else writeln('!!!!'^g,byte(p.typ))};
             p:=Tai(p.previous);
           end;
         unusedregsint:=back;
@@ -2052,12 +2055,15 @@ implementation
         {Forward the register allocation again.}
         while (p<>self) do
           begin
-            if p.typ<>ait_regalloc then
+            if p.typ in [ait_instruction,ait_label] then
               internalerror(200305311);
-            if Tai_regalloc(p).allocation then
-              exclude(unusedregsint,Tai_regalloc(p).reg.number shr 8)
-            else
-              include(unusedregsint,Tai_regalloc(p).reg.number shr 8);
+            if p.typ=ait_regalloc then
+              begin
+              if Tai_regalloc(p).allocation then
+                exclude(unusedregsint,Tai_regalloc(p).reg.number shr 8)
+              else
+                include(unusedregsint,Tai_regalloc(p).reg.number shr 8);
+              end;
             p:=Tai(p.next);
           end;
       end;
@@ -2413,7 +2419,12 @@ implementation
 end.
 {
   $Log$
-  Revision 1.7  2003-07-06 15:31:21  daniel
+  Revision 1.8  2003-08-09 18:56:54  daniel
+    * cs_regalloc renamed to cs_regvars to avoid confusion with register
+      allocator
+    * Some preventive changes to i386 spillinh code
+
+  Revision 1.7  2003/07/06 15:31:21  daniel
     * Fixed register allocator. *Lots* of fixes.
 
   Revision 1.6  2003/06/14 14:53:50  jonas