浏览代码

* fixed Z80 stack and temp allocation, so it doesn't have any wasted bytes

git-svn-id: branches/z80@44906 -
nickysn 5 年之前
父节点
当前提交
d3e946b779
共有 4 个文件被更改,包括 71 次插入1 次删除
  1. 1 0
      .gitattributes
  2. 2 0
      compiler/z80/cpunode.pas
  3. 1 1
      compiler/z80/cpupi.pas
  4. 67 0
      compiler/z80/tgcpu.pas

+ 1 - 0
.gitattributes

@@ -1084,6 +1084,7 @@ compiler/z80/rz80sta.inc svneol=native#text/plain
 compiler/z80/rz80std.inc svneol=native#text/plain
 compiler/z80/rz80sup.inc svneol=native#text/plain
 compiler/z80/symcpu.pas svneol=native#text/plain
+compiler/z80/tgcpu.pas svneol=native#text/plain
 compiler/z80/z80ins.dat svneol=native#text/plain
 compiler/z80/z80nop.inc svneol=native#text/plain
 compiler/z80/z80op.inc svneol=native#text/plain

+ 2 - 0
compiler/z80/cpunode.pas

@@ -40,6 +40,8 @@ unit cpunode;
 //       ,nz80cnv
 //       ,nz80mem
 //       ,nz80util,
+       { these are not really nodes }
+       ,tgcpu
        { symtable }
        ,symcpu,
        aasmdef

+ 1 - 1
compiler/z80/cpupi.pas

@@ -55,7 +55,7 @@ unit cpupi;
     procedure tcpuprocinfo.set_first_temp_offset;
       begin
         if tg.direction = -1 then
-          tg.setfirsttemp(-1)
+          tg.setfirsttemp(0)
         else if not (po_nostackframe in procdef.procoptions) then
           tg.setfirsttemp(maxpushedparasize+1)
         else

+ 67 - 0
compiler/z80/tgcpu.pas

@@ -0,0 +1,67 @@
+{
+    Copyright (C) 1998-2000 by Florian Klaempfl
+
+    This unit handles the temporary variables stuff for Z80
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+{
+  This unit handles the temporary variables stuff for Z80.
+}
+unit tgcpu;
+
+{$i fpcdefs.inc}
+
+  interface
+
+    uses
+      tgobj,globtype,aasmdata,cgutils,symtype;
+
+    type
+
+      { ttgz80 }
+
+      ttgz80 = class(ttgobj)
+      public
+        procedure setfirsttemp(l: asizeint); override;
+      end;
+
+implementation
+
+uses
+  globals,
+  verbose,
+  cpubase,
+  cutils;
+
+{ ttgz80 }
+
+procedure ttgz80.setfirsttemp(l: asizeint);
+  begin
+    { this is a negative value normally }
+    if l*direction<0 then
+      internalerror(200204221);
+    firsttemp:=l;
+    lasttemp:=l;
+{$ifdef EXTDEBUG}
+    Comment(V_Note,'tgobj: (SetFirstTemp) set to '+tostr(l));
+{$endif}
+  end;
+
+begin
+  tgobjclass:=ttgz80;
+end.