Browse Source

* improved allocation rules for integer register variables

florian 25 years ago
parent
commit
f3ed1eaf5c
1 changed files with 15 additions and 4 deletions
  1. 15 4
      compiler/pass_2.pas

+ 15 - 4
compiler/pass_2.pas

@@ -461,7 +461,7 @@ implementation
       end;
       end;
 
 
     var
     var
-       { the array ranges are oveestimated !!!  }
+       { the array ranges are overestimated !!!  }
        { max(maxvarregs,maxfpuvarregs) would be }
        { max(maxvarregs,maxfpuvarregs) would be }
        { enough                                 }
        { enough                                 }
        regvars : array[1..maxvarregs+maxfpuvarregs] of pvarsym;
        regvars : array[1..maxvarregs+maxfpuvarregs] of pvarsym;
@@ -487,7 +487,7 @@ implementation
               { walk through all momentary register variables }
               { walk through all momentary register variables }
               for i:=1 to maxvarregs do
               for i:=1 to maxvarregs do
                 begin
                 begin
-                   if (regvars[i]=nil) or ((j>regvars_refs[i]) and (j>0)) then
+                   if ((regvars[i]=nil) or (j>regvars_refs[i])) and (j>0) then
                      begin
                      begin
                         for k:=maxvarregs-1 downto i do
                         for k:=maxvarregs-1 downto i do
                           begin
                           begin
@@ -525,7 +525,7 @@ implementation
               { walk through all momentary register variables }
               { walk through all momentary register variables }
               for i:=1 to maxfpuvarregs do
               for i:=1 to maxfpuvarregs do
                 begin
                 begin
-                   if (regvars[i]=nil) or ((j>regvars_refs[i]) and (j>0)) then
+                   if ((regvars[i]=nil) or (j>regvars_refs[i])) and (j>0) then
                      begin
                      begin
                         for k:=maxfpuvarregs-1 downto i do
                         for k:=maxfpuvarregs-1 downto i do
                           begin
                           begin
@@ -544,6 +544,12 @@ implementation
            end;
            end;
       end;
       end;
 
 
+    procedure clearrefs(p : pnamedindexobject);
+
+      begin
+         if (psym(p)^.typ=varsym) then
+           pvarsym(p)^.refs:=0;
+      end;
 
 
     procedure generatecode(var p : ptree);
     procedure generatecode(var p : ptree);
       var
       var
@@ -565,6 +571,8 @@ implementation
          clearregistercount;
          clearregistercount;
          use_esp_stackframe:=false;
          use_esp_stackframe:=false;
          aktexceptblock:=nil;
          aktexceptblock:=nil;
+         symtablestack^.foreach(@clearrefs);
+         symtablestack^.next^.foreach(@clearrefs);
          if not(do_firstpass(p)) then
          if not(do_firstpass(p)) then
            begin
            begin
               { max. optimizations     }
               { max. optimizations     }
@@ -835,7 +843,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.60  2000-03-19 08:17:36  peter
+  Revision 1.61  2000-03-26 10:50:04  florian
+    * improved allocation rules for integer register variables
+
+  Revision 1.60  2000/03/19 08:17:36  peter
     * tp7 fix
     * tp7 fix
 
 
   Revision 1.59  2000/03/01 00:01:14  pierre
   Revision 1.59  2000/03/01 00:01:14  pierre