Jelajahi Sumber

+ support for tt_regallocator/tt_freeregallocator temps; these will be used
by the JVM register allocator to store register values in, instead of
tt_noreuse (because almost all registers have to be mapped to temps,
no reusing these temps will blow up the stack frame a lot)
* documented the meaning of the tt_* values
* temp growing direction for jvm is also positive

git-svn-id: branches/jvmbackend@18284 -

Jonas Maebe 14 tahun lalu
induk
melakukan
d18cda2939
2 mengubah file dengan 28 tambahan dan 7 penghapusan
  1. 21 2
      compiler/globtype.pas
  2. 7 5
      compiler/tgobj.pas

+ 21 - 2
compiler/globtype.pas

@@ -326,8 +326,27 @@ interface
 
        { Temp types }
        ttemptype = (tt_none,
-                    tt_free,tt_normal,tt_persistent,
-                    tt_noreuse,tt_freenoreuse);
+                    { free temp location, can be reused for something else }
+                    tt_free,
+                    { temp location that will be freed when ttgobj.UnGetTemp/
+                      ttgobj.UnGetIfTemp is called on it }
+                    tt_normal,
+                    { temp location that will not be freed; if it has to be
+                      freed, first ttgobj.changetemptype() it to tt_normal,
+                      or call ttgobj.UnGetLocal() instead (for local variables,
+                      since they are also persistent temps) }
+                    tt_persistent,
+                    { temp location that can never be reused anymore, even
+                      after it has been freed }
+                    tt_noreuse,
+                    { freed version of the above }
+                    tt_freenoreuse,
+                    { temp location that has been allocated by the register
+                      allocator and that can be reallocated only by the
+                      register allocator }
+                    tt_regallocator,
+                    { freed version of the above }
+                    tt_freeregallocator);
        ttemptypeset = set of ttemptype;
 
        { calling convention for tprocdef and tprocvardef }

+ 7 - 5
compiler/tgobj.pas

@@ -125,20 +125,22 @@ implementation
 
 
     const
-      FreeTempTypes = [tt_free,tt_freenoreuse];
+      FreeTempTypes = [tt_free,tt_freenoreuse,tt_freeregallocator];
 
 {$ifdef EXTDEBUG}
       TempTypeStr : array[ttemptype] of string[18] = (
           '<none>',
           'free','normal','persistant',
-          'noreuse','freenoreuse'
+          'noreuse','freenoreuse',
+          'regallocator','freeregallocator'
       );
 {$endif EXTDEBUG}
 
       Used2Free : array[ttemptype] of ttemptype = (
         tt_none,
         tt_none,tt_free,tt_free,
-        tt_freenoreuse,tt_none
+        tt_freenoreuse,tt_none,
+        tt_freeregallocator,tt_none
       );
 
 
@@ -163,7 +165,7 @@ implementation
        tempfreelist:=nil;
        templist:=nil;
        { we could create a new child class for this but I don't if it is worth the effort (FK) }
-{$if defined(powerpc) or defined(powerpc64) or defined(avr)}
+{$if defined(powerpc) or defined(powerpc64) or defined(avr) or defined(jvm)}
        direction:=1;
 {$else}
        direction:=-1;
@@ -628,7 +630,7 @@ implementation
 
     procedure ttgobj.UnGetTemp(list: TAsmList; const ref : treference);
       begin
-        FreeTemp(list,ref.offset,[tt_normal,tt_noreuse,tt_persistent]);
+        FreeTemp(list,ref.offset,[tt_normal,tt_noreuse,tt_persistent,tt_regallocator]);
       end;