Explorar el Código

* basic sparc64 calling convention handling and stack frame handling fixed

git-svn-id: trunk@36518 -
florian hace 8 años
padre
commit
3c72115e30

+ 1 - 0
.gitattributes

@@ -689,6 +689,7 @@ compiler/sparc64/rsp64sri.inc svneol=native#text/pascal
 compiler/sparc64/rsp64stab.inc svneol=native#text/pascal
 compiler/sparc64/rsp64stab.inc svneol=native#text/pascal
 compiler/sparc64/rsp64std.inc svneol=native#text/pascal
 compiler/sparc64/rsp64std.inc svneol=native#text/pascal
 compiler/sparc64/rsp64sup.inc svneol=native#text/pascal
 compiler/sparc64/rsp64sup.inc svneol=native#text/pascal
+compiler/sparc64/tgcpu.pas svneol=native#text/plain
 compiler/sparcgen/aasmcpu.pas svneol=native#text/plain
 compiler/sparcgen/aasmcpu.pas svneol=native#text/plain
 compiler/sparcgen/aoptcpu.pas svneol=native#text/plain
 compiler/sparcgen/aoptcpu.pas svneol=native#text/plain
 compiler/sparcgen/aoptcpub.pas svneol=native#text/plain
 compiler/sparcgen/aoptcpub.pas svneol=native#text/plain

+ 2 - 0
compiler/sparc64/cpunode.pas

@@ -34,6 +34,8 @@ implementation
     ncpuadd,ncpucall,ncpumat,ncpuinln,ncpucnv,ncpuset,
     ncpuadd,ncpucall,ncpumat,ncpuinln,ncpucnv,ncpuset,
     { this not really a node }
     { this not really a node }
     rgcpu,
     rgcpu,
+    { this neither }
+    tgcpu,
     { symtable }
     { symtable }
     symcpu,
     symcpu,
     aasmdef;
     aasmdef;

+ 53 - 0
compiler/sparc64/tgcpu.pas

@@ -0,0 +1,53 @@
+{
+    Copyright (C) 1998-2000 by Florian Klaempfl
+
+    This unit handles the temporary variables stuff for sparc64
+
+    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 i8086.
+}
+unit tgcpu;
+
+{$i fpcdefs.inc}
+
+  interface
+
+    uses
+      tgobj,globtype,aasmdata,cgutils,symtype;
+
+    type
+      ttgsparc64 = class(ttgobj)
+      protected
+        procedure alloctemp(list: TAsmList; size: asizeint; alignment: shortint; temptype: ttemptype; def: tdef; fini: boolean; out ref: treference);override;
+      end;
+
+implementation
+
+uses
+  cpubase;
+
+procedure ttgsparc64.alloctemp(list: TAsmList; size: asizeint; alignment: shortint; temptype: ttemptype; def: tdef; fini: boolean; out ref: treference);
+  begin
+    inherited;
+    inc(ref.offset,STACK_BIAS);
+  end;
+
+begin
+  tgobjclass:=ttgsparc64;
+end.

+ 4 - 0
compiler/sparcgen/cpubase.pas

@@ -305,6 +305,10 @@ uses
       }
       }
       std_param_align = 4;  { for 32-bit version only }
       std_param_align = 4;  { for 32-bit version only }
 
 
+{$ifdef SPARC64}
+      STACK_BIAS = 2047;
+{$endif SPARC64}
+
 
 
 {*****************************************************************************
 {*****************************************************************************
                             CPU Dependent Constants
                             CPU Dependent Constants

+ 16 - 2
compiler/sparcgen/hlcgcpu.pas

@@ -32,12 +32,17 @@ interface
     globtype,
     globtype,
     aasmdata,
     aasmdata,
     symdef,
     symdef,
-    hlcg2ll;
+    hlcg2ll,
+    cgutils,
+    tgobj;
 
 
   type
   type
     thlcgcpu = class(thlcg2ll)
     thlcgcpu = class(thlcg2ll)
      procedure g_intf_wrapper(list: TAsmList; procdef: tprocdef; const labelname: string; ioffset: longint);override;
      procedure g_intf_wrapper(list: TAsmList; procdef: tprocdef; const labelname: string; ioffset: longint);override;
      procedure a_jmp_external_name(list: TAsmList; const externalname: TSymStr);override;
      procedure a_jmp_external_name(list: TAsmList; const externalname: TSymStr);override;
+{$ifdef SPARC64}
+     procedure temp_to_ref(p: ptemprecord; out ref: treference);override;
+{$endif SPARC64}
     end;
     end;
 
 
   procedure create_hlcodegen;
   procedure create_hlcodegen;
@@ -49,7 +54,7 @@ implementation
     aasmbase,aasmtai,aasmcpu,
     aasmbase,aasmtai,aasmcpu,
     parabase,
     parabase,
     symconst,symtype,symsym,
     symconst,symtype,symsym,
-    cgbase,cgutils,cgobj,hlcgobj,cpubase,cgcpu;
+    cgbase,cgobj,hlcgobj,cpubase,cgcpu;
 
 
 
 
   procedure thlcgcpu.g_intf_wrapper(list: TAsmList; procdef: tprocdef; const labelname: string; ioffset: longint);
   procedure thlcgcpu.g_intf_wrapper(list: TAsmList; procdef: tprocdef; const labelname: string; ioffset: longint);
@@ -133,6 +138,15 @@ implementation
     end;
     end;
 
 
 
 
+{$ifdef SPARC64}
+  procedure thlcgcpu.temp_to_ref(p : ptemprecord; out ref : treference);
+    begin
+      inherited;
+      inc(ref.offset,STACK_BIAS);
+    end;
+{$endif SPARC64}
+
+
   procedure create_hlcodegen;
   procedure create_hlcodegen;
     begin
     begin
       hlcg:=thlcgcpu.create;
       hlcg:=thlcgcpu.create;

+ 12 - 3
compiler/sparcgen/sppara.pas

@@ -251,11 +251,18 @@ implementation
                 if vo_is_funcret in hp.varoptions then
                 if vo_is_funcret in hp.varoptions then
                   begin
                   begin
                     paraloc^.loc:=LOC_REFERENCE;
                     paraloc^.loc:=LOC_REFERENCE;
+{$ifdef SPARC64}
+                    paraloc^.reference.offset:=128;
+{$else SPARC64}
+                    paraloc^.reference.offset:=64;
+{$endif SPARC64}
                     if side=callerside then
                     if side=callerside then
                       paraloc^.reference.index:=NR_STACK_POINTER_REG
                       paraloc^.reference.index:=NR_STACK_POINTER_REG
                     else
                     else
                       paraloc^.reference.index:=NR_FRAME_POINTER_REG;
                       paraloc^.reference.index:=NR_FRAME_POINTER_REG;
-                    paraloc^.reference.offset:=64;
+{$ifdef SPARC64}
+                    inc(paraloc^.reference.offset,STACK_BIAS);
+{$endif SPARC64}
                   end
                   end
                 { In case of po_delphi_nested_cc, the parent frame pointer
                 { In case of po_delphi_nested_cc, the parent frame pointer
                   is always passed on the stack. }
                   is always passed on the stack. }
@@ -270,12 +277,14 @@ implementation
                 else
                 else
                   begin
                   begin
                     paraloc^.loc:=LOC_REFERENCE;
                     paraloc^.loc:=LOC_REFERENCE;
+                    paraloc^.reference.offset:=target_info.first_parm_offset+parasize;
                     if side=callerside then
                     if side=callerside then
                       paraloc^.reference.index:=NR_STACK_POINTER_REG
                       paraloc^.reference.index:=NR_STACK_POINTER_REG
                     else
                     else
                       paraloc^.reference.index:=NR_FRAME_POINTER_REG;
                       paraloc^.reference.index:=NR_FRAME_POINTER_REG;
-                    paraloc^.reference.offset:=target_info.first_parm_offset+parasize;
-
+{$ifdef SPARC64}
+                    inc(paraloc^.reference.offset,STACK_BIAS);
+{$endif SPARC64}
                     if (target_info.endian=endian_big) and
                     if (target_info.endian=endian_big) and
                        (paralen<tcgsize2size[OS_INT]) and
                        (paralen<tcgsize2size[OS_INT]) and
                        (paradef.typ<>recorddef) then
                        (paradef.typ<>recorddef) then

+ 1 - 1
compiler/systems/i_linux.pas

@@ -551,7 +551,7 @@ unit i_linux;
                 recordalignmax  : 16;
                 recordalignmax  : 16;
                 maxCrecordalign : 16
                 maxCrecordalign : 16
               );
               );
-            first_parm_offset : 92;
+            first_parm_offset : 176;
             stacksize    : 16*1024*1024;
             stacksize    : 16*1024*1024;
             stackalign   : 16;
             stackalign   : 16;
             abi : abi_default;
             abi : abi_default;