Przeglądaj źródła

* made alloctemp more generic

git-svn-id: trunk@24023 -
Jonas Maebe 12 lat temu
rodzic
commit
477eeadaca
2 zmienionych plików z 10 dodań i 21 usunięć
  1. 3 3
      compiler/jvm/tgcpu.pas
  2. 7 18
      compiler/tgobj.pas

+ 3 - 3
compiler/jvm/tgcpu.pas

@@ -42,7 +42,7 @@ unit tgcpu;
         protected
          procedure getimplicitobjtemp(list: TAsmList; def: tdef; temptype: ttemptype; out ref: treference);
          function getifspecialtemp(list: TAsmList; def: tdef; forcesize: aint; temptype: ttemptype; out ref: treference): boolean;
-         function alloctemp(list: TAsmList; size, alignment: longint; temptype: ttemptype; def: tdef): longint; override;
+         procedure alloctemp(list: TAsmList; size, alignment: longint; temptype: ttemptype; def: tdef; out ref: treference); override;
         public
          procedure setfirsttemp(l : longint); override;
          procedure getlocal(list: TAsmList; size: longint; alignment: shortint; def: tdef; var ref: treference); override;
@@ -215,7 +215,7 @@ unit tgcpu;
       end;
 
 
-    function ttgjvm.alloctemp(list: TAsmList; size, alignment: longint; temptype: ttemptype; def: tdef): longint;
+    procedure ttgjvm.alloctemp(list: TAsmList; size, alignment: longint; temptype: ttemptype; def: tdef; out ref: treference);
       begin
         { the JVM only supports 1 slot (= 4 bytes in FPC) and 2 slot (= 8 bytes in
           FPC) temps on the stack. double and int64 are 2 slots, the rest is one slot.
@@ -227,7 +227,7 @@ unit tgcpu;
           internalerror(2010121401);
         { don't pass on "def", since we don't care if a slot is used again for a
           different type }
-        result:=inherited alloctemp(list, size shr 2, 1, temptype, nil);
+        inherited alloctemp(list, size shr 2, 1, temptype, nil,ref);
       end;
 
 

+ 7 - 18
compiler/tgobj.pas

@@ -59,8 +59,8 @@ unit tgobj;
        protected
           { contains all free temps using nextfree links }
           tempfreelist  : ptemprecord;
-          function alloctemp(list: TAsmList; size,alignment : longint; temptype : ttemptype; def:tdef) : longint; virtual;
-          procedure freetemp(list: TAsmList; pos:longint;temptypes:ttemptypeset);
+          procedure alloctemp(list: TAsmList; size,alignment : longint; temptype : ttemptype; def:tdef; out ref: treference); virtual;
+          procedure freetemp(list: TAsmList; pos:longint;temptypes:ttemptypeset);virtual;
           procedure gettempinternal(list: TAsmList; size, alignment : longint;temptype:ttemptype;def: tdef;out ref : treference);
        public
           { contains all temps }
@@ -107,7 +107,7 @@ unit tgobj;
 
              @param(ref reference to verify)
           }
-          function istemp(const ref : treference) : boolean;
+          function istemp(const ref : treference) : boolean; virtual;
           {# Frees a reference @var(ref) which was allocated in the volatile temporary memory space.
              The freed space can later be reallocated and reused. If this reference
              is not in the temporary memory, it is simply not freed.
@@ -236,7 +236,7 @@ implementation
       end;
 
 
-    function ttgobj.AllocTemp(list: TAsmList; size,alignment : longint; temptype : ttemptype;def : tdef) : longint;
+    procedure ttgobj.alloctemp(list: TAsmList; size,alignment : longint; temptype : ttemptype;def : tdef; out ref: treference);
       var
          tl,htl,
          bestslot,bestprev,
@@ -247,7 +247,6 @@ implementation
          fitatbegin,
          fitatend : boolean;
       begin
-         AllocTemp:=0;
          bestprev:=nil;
          bestslot:=nil;
          tl:=nil;
@@ -430,7 +429,7 @@ implementation
 {$else}
          list.concat(tai_tempalloc.alloc(tl^.pos,tl^.size));
 {$endif}
-         AllocTemp:=tl^.pos;
+         reference_reset_base(ref,current_procinfo.framepointer,tl^.pos,alignment);
       end;
 
 
@@ -543,12 +542,7 @@ implementation
         varalign : shortint;
       begin
         varalign:=used_align(alignment,current_settings.alignment.localalignmin,current_settings.alignment.localalignmax);
-        { can't use reference_reset_base, because that will let tgobj depend
-          on cgobj (PFV) }
-        fillchar(ref,sizeof(ref),0);
-        ref.base:=current_procinfo.framepointer;
-        ref.offset:=alloctemp(list,size,varalign,temptype,def);
-        ref.alignment:=varalign;
+        alloctemp(list,size,varalign,temptype,def,ref);
       end;
 
 
@@ -684,12 +678,7 @@ implementation
     procedure ttgobj.getlocal(list: TAsmList; size : longint; alignment : shortint; def:tdef;var ref : treference);
       begin
         alignment:=used_align(alignment,current_settings.alignment.localalignmin,current_settings.alignment.localalignmax);
-        { can't use reference_reset_base, because that will let tgobj depend
-          on cgobj (PFV) }
-        fillchar(ref,sizeof(ref),0);
-        ref.base:=current_procinfo.framepointer;
-        ref.offset:=alloctemp(list,size,alignment,tt_persistent,nil);
-        ref.alignment:=alignment;
+        alloctemp(list,size,alignment,tt_persistent,nil,ref);
       end;