From 3c72115e3078c07fc1c490935c2dc360b87e846d Mon Sep 17 00:00:00 2001 From: florian Date: Sun, 18 Jun 2017 15:49:21 +0000 Subject: [PATCH] * basic sparc64 calling convention handling and stack frame handling fixed git-svn-id: trunk@36518 - --- .gitattributes | 1 + compiler/sparc64/cpunode.pas | 2 ++ compiler/sparc64/tgcpu.pas | 53 +++++++++++++++++++++++++++++++++++ compiler/sparcgen/cpubase.pas | 4 +++ compiler/sparcgen/hlcgcpu.pas | 18 ++++++++++-- compiler/sparcgen/sppara.pas | 15 ++++++++-- compiler/systems/i_linux.pas | 2 +- 7 files changed, 89 insertions(+), 6 deletions(-) create mode 100644 compiler/sparc64/tgcpu.pas diff --git a/.gitattributes b/.gitattributes index 76e859960e..037068806c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -689,6 +689,7 @@ compiler/sparc64/rsp64sri.inc svneol=native#text/pascal compiler/sparc64/rsp64stab.inc svneol=native#text/pascal compiler/sparc64/rsp64std.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/aoptcpu.pas svneol=native#text/plain compiler/sparcgen/aoptcpub.pas svneol=native#text/plain diff --git a/compiler/sparc64/cpunode.pas b/compiler/sparc64/cpunode.pas index 734802ee9c..95573136d0 100644 --- a/compiler/sparc64/cpunode.pas +++ b/compiler/sparc64/cpunode.pas @@ -34,6 +34,8 @@ implementation ncpuadd,ncpucall,ncpumat,ncpuinln,ncpucnv,ncpuset, { this not really a node } rgcpu, + { this neither } + tgcpu, { symtable } symcpu, aasmdef; diff --git a/compiler/sparc64/tgcpu.pas b/compiler/sparc64/tgcpu.pas new file mode 100644 index 0000000000..61f7893108 --- /dev/null +++ b/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. diff --git a/compiler/sparcgen/cpubase.pas b/compiler/sparcgen/cpubase.pas index 71daf4f095..d544806071 100644 --- a/compiler/sparcgen/cpubase.pas +++ b/compiler/sparcgen/cpubase.pas @@ -305,6 +305,10 @@ uses } std_param_align = 4; { for 32-bit version only } +{$ifdef SPARC64} + STACK_BIAS = 2047; +{$endif SPARC64} + {***************************************************************************** CPU Dependent Constants diff --git a/compiler/sparcgen/hlcgcpu.pas b/compiler/sparcgen/hlcgcpu.pas index 5f3967004a..b9a4590b0b 100644 --- a/compiler/sparcgen/hlcgcpu.pas +++ b/compiler/sparcgen/hlcgcpu.pas @@ -32,12 +32,17 @@ interface globtype, aasmdata, symdef, - hlcg2ll; + hlcg2ll, + cgutils, + tgobj; type thlcgcpu = class(thlcg2ll) 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; +{$ifdef SPARC64} + procedure temp_to_ref(p: ptemprecord; out ref: treference);override; +{$endif SPARC64} end; procedure create_hlcodegen; @@ -49,7 +54,7 @@ implementation aasmbase,aasmtai,aasmcpu, parabase, 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); @@ -133,6 +138,15 @@ implementation 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; begin hlcg:=thlcgcpu.create; diff --git a/compiler/sparcgen/sppara.pas b/compiler/sparcgen/sppara.pas index a39d60e3dc..de21e8daee 100644 --- a/compiler/sparcgen/sppara.pas +++ b/compiler/sparcgen/sppara.pas @@ -251,11 +251,18 @@ implementation if vo_is_funcret in hp.varoptions then begin paraloc^.loc:=LOC_REFERENCE; +{$ifdef SPARC64} + paraloc^.reference.offset:=128; +{$else SPARC64} + paraloc^.reference.offset:=64; +{$endif SPARC64} if side=callerside then paraloc^.reference.index:=NR_STACK_POINTER_REG else paraloc^.reference.index:=NR_FRAME_POINTER_REG; - paraloc^.reference.offset:=64; +{$ifdef SPARC64} + inc(paraloc^.reference.offset,STACK_BIAS); +{$endif SPARC64} end { In case of po_delphi_nested_cc, the parent frame pointer is always passed on the stack. } @@ -270,12 +277,14 @@ implementation else begin paraloc^.loc:=LOC_REFERENCE; + paraloc^.reference.offset:=target_info.first_parm_offset+parasize; if side=callerside then paraloc^.reference.index:=NR_STACK_POINTER_REG else 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 (paralenrecorddef) then diff --git a/compiler/systems/i_linux.pas b/compiler/systems/i_linux.pas index 79ed6be105..b6c8f8272f 100644 --- a/compiler/systems/i_linux.pas +++ b/compiler/systems/i_linux.pas @@ -551,7 +551,7 @@ unit i_linux; recordalignmax : 16; maxCrecordalign : 16 ); - first_parm_offset : 92; + first_parm_offset : 176; stacksize : 16*1024*1024; stackalign : 16; abi : abi_default;