mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-14 14:59:32 +02:00
arm: arm-aros syscall support
git-svn-id: trunk@34809 -
This commit is contained in:
parent
89c1b68b14
commit
657aa06360
@ -30,18 +30,73 @@ interface
|
||||
|
||||
type
|
||||
tarmcallnode = class(tcgcallnode)
|
||||
procedure gen_syscall_para(para: tcallparanode); override;
|
||||
procedure set_result_location(realresdef: tstoreddef);override;
|
||||
public
|
||||
procedure do_syscall;override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
verbose,globtype,globals,aasmdata,
|
||||
symconst,
|
||||
cgbase,cgutils,cpuinfo,
|
||||
ncgutil,tgobj,
|
||||
verbose,globtype,globals,aasmdata,aasmtai,
|
||||
symconst,symtype,symbase,symsym,symcpu,parabase,paramgr,
|
||||
cgbase,cgobj,cgutils,cpuinfo,cpubase,cutils,
|
||||
ncgutil,tgobj,nld,
|
||||
systems;
|
||||
|
||||
procedure tarmcallnode.gen_syscall_para(para: tcallparanode);
|
||||
begin
|
||||
{ lib parameter has no special type but proccalloptions must be a syscall }
|
||||
para.left:=cloadnode.create(tcpuprocdef(procdefinition).libsym,tcpuprocdef(procdefinition).libsym.owner);
|
||||
end;
|
||||
|
||||
procedure tarmcallnode.do_syscall;
|
||||
var
|
||||
tmpref: treference;
|
||||
libparaloc: pcgparalocation;
|
||||
hsym: tsym;
|
||||
begin
|
||||
case target_info.system of
|
||||
system_arm_aros:
|
||||
begin
|
||||
if (po_syscall_baselast in tprocdef(procdefinition).procoptions) then
|
||||
begin
|
||||
current_asmdata.CurrAsmList.concat(tai_comment.create(strpnew('AROS SysCall - BaseLast')));
|
||||
|
||||
cg.getcpuregister(current_asmdata.CurrAsmList,NR_R12);
|
||||
hsym:=tsym(procdefinition.parast.Find('syscalllib'));
|
||||
if not assigned(hsym) then
|
||||
internalerror(2016110605);
|
||||
libparaloc:=tparavarsym(hsym).paraloc[callerside].location;
|
||||
if not assigned(libparaloc) then
|
||||
internalerror(2016110604);
|
||||
|
||||
case libparaloc^.loc of
|
||||
LOC_REGISTER:
|
||||
reference_reset_base(tmpref,libparaloc^.register,-tprocdef(procdefinition).extnumber,sizeof(pint));
|
||||
LOC_REFERENCE:
|
||||
begin
|
||||
reference_reset_base(tmpref,libparaloc^.reference.index,libparaloc^.reference.offset,sizeof(pint));
|
||||
cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,tmpref,NR_R12);
|
||||
reference_reset_base(tmpref,NR_R12,-tprocdef(procdefinition).extnumber,sizeof(pint));
|
||||
end;
|
||||
else
|
||||
internalerror(2016110603);
|
||||
end;
|
||||
|
||||
cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,tmpref,NR_R12);
|
||||
cg.a_call_reg(current_asmdata.CurrAsmList,NR_R12);
|
||||
cg.ungetcpuregister(current_asmdata.CurrAsmList,NR_R12);
|
||||
exit;
|
||||
end;
|
||||
internalerror(2016110601);
|
||||
end;
|
||||
else
|
||||
internalerror(2016110602);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure tarmcallnode.set_result_location(realresdef: tstoreddef);
|
||||
begin
|
||||
if (realresdef.typ=floatdef) and
|
||||
@ -77,6 +132,8 @@ implementation
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
begin
|
||||
ccallnode:=tarmcallnode;
|
||||
end.
|
||||
|
@ -26,7 +26,7 @@ unit symcpu;
|
||||
interface
|
||||
|
||||
uses
|
||||
symtype,symdef,symsym,globtype;
|
||||
symtype,symdef,symsym,symconst,globtype;
|
||||
|
||||
type
|
||||
{ defs }
|
||||
@ -92,9 +92,18 @@ type
|
||||
|
||||
tcpuprocdef = class(tprocdef)
|
||||
{ the arm paramanager might need to know the total size of the stackframe
|
||||
to avoid cyclic unit dependencies or global variables, this infomatation is
|
||||
to avoid cyclic unit dependencies or global variables, this information is
|
||||
stored in total_stackframe_size }
|
||||
total_stackframe_size : aint;
|
||||
procedure ppuload_platform(ppufile: tcompilerppufile); override;
|
||||
procedure ppuwrite_platform(ppufile: tcompilerppufile); override;
|
||||
public
|
||||
{ library symbol for AROS }
|
||||
libsym : tsym;
|
||||
libsymderef : tderef;
|
||||
function getcopyas(newtyp: tdeftyp; copytyp: tproccopytyp): tstoreddef; override;
|
||||
procedure buildderef; override;
|
||||
procedure deref; override;
|
||||
end;
|
||||
tcpuprocdefclass = class of tcpuprocdef;
|
||||
|
||||
@ -178,6 +187,52 @@ const
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
{****************************************************************************
|
||||
tcpuprocdef
|
||||
****************************************************************************}
|
||||
|
||||
procedure tcpuprocdef.ppuload_platform(ppufile: tcompilerppufile);
|
||||
begin
|
||||
inherited;
|
||||
if po_syscall_has_libsym in procoptions then
|
||||
ppufile.getderef(libsymderef);
|
||||
end;
|
||||
|
||||
|
||||
procedure tcpuprocdef.ppuwrite_platform(ppufile: tcompilerppufile);
|
||||
begin
|
||||
inherited;
|
||||
if po_syscall_has_libsym in procoptions then
|
||||
ppufile.putderef(libsymderef);
|
||||
end;
|
||||
|
||||
|
||||
function tcpuprocdef.getcopyas(newtyp: tdeftyp; copytyp: tproccopytyp): tstoreddef;
|
||||
begin
|
||||
result:=inherited;
|
||||
if newtyp=procdef then
|
||||
tcpuprocdef(result).libsym:=libsym;
|
||||
end;
|
||||
|
||||
|
||||
procedure tcpuprocdef.buildderef;
|
||||
begin
|
||||
inherited;
|
||||
if po_syscall_has_libsym in procoptions then
|
||||
libsymderef.build(libsym);
|
||||
end;
|
||||
|
||||
|
||||
procedure tcpuprocdef.deref;
|
||||
begin
|
||||
inherited;
|
||||
if po_syscall_has_libsym in procoptions then
|
||||
libsym:=tsym(libsymderef.resolve)
|
||||
else
|
||||
libsym:=nil;
|
||||
end;
|
||||
|
||||
begin
|
||||
{ used tdef classes }
|
||||
cfiledef:=tcpufiledef;
|
||||
|
@ -119,6 +119,7 @@ implementation
|
||||
system_powerpc_amiga,
|
||||
system_powerpc_morphos,
|
||||
system_m68k_amiga,
|
||||
system_arm_aros,
|
||||
system_i386_aros,
|
||||
system_x86_64_aros:
|
||||
include(supported_calling_conventions,pocall_syscall);
|
||||
|
@ -2108,7 +2108,7 @@ procedure pd_syscall(pd:tabstractprocdef);
|
||||
internalerror(2016090101);
|
||||
end;
|
||||
|
||||
{$if defined(powerpc) or defined(m68k) or defined(i386) or defined(x86_64)}
|
||||
{$if defined(powerpc) or defined(m68k) or defined(i386) or defined(x86_64) or defined(arm)}
|
||||
const
|
||||
syscall_paranr: array[boolean] of aint =
|
||||
( paranr_syscall_lib_last, paranr_syscall_lib_first );
|
||||
@ -2119,12 +2119,12 @@ var
|
||||
v: Tconstexprint;
|
||||
vo: tvaroptions;
|
||||
paranr: aint;
|
||||
{$endif defined(powerpc) or defined(m68k) or defined(i386) or defined(x86_64)}
|
||||
{$endif defined(powerpc) or defined(m68k) or defined(i386) or defined(x86_64) or defined(arm)}
|
||||
begin
|
||||
if (pd.typ<>procdef) and (target_info.system <> system_powerpc_amiga) then
|
||||
internalerror(2003042614);
|
||||
tprocdef(pd).forwarddef:=false;
|
||||
{$if defined(powerpc) or defined(m68k) or defined(i386) or defined(x86_64)}
|
||||
{$if defined(powerpc) or defined(m68k) or defined(i386) or defined(x86_64) or defined(arm)}
|
||||
include_po_syscall;
|
||||
|
||||
if target_info.system = system_m68k_atari then
|
||||
@ -2173,7 +2173,7 @@ begin
|
||||
Tprocdef(pd).extnumber:=v.uvalue * sizeof(pint)
|
||||
else
|
||||
Tprocdef(pd).extnumber:=v.uvalue;
|
||||
{$endif defined(powerpc) or defined(m68k) or defined(i386) or defined(x86_64)}
|
||||
{$endif defined(powerpc) or defined(m68k) or defined(i386) or defined(x86_64) or defined(arm)}
|
||||
end;
|
||||
|
||||
|
||||
|
@ -43,7 +43,7 @@ type
|
||||
{$endif Test_Double_checksum}
|
||||
|
||||
const
|
||||
CurrentPPUVersion = 187;
|
||||
CurrentPPUVersion = 188;
|
||||
|
||||
{ unit flags }
|
||||
uf_init = $000001; { unit has initialization section }
|
||||
|
Loading…
Reference in New Issue
Block a user