mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-07 01:48:00 +02:00
AROS/x86_64: initial AROS/x86_64 support and implement syscalls for AROS/x86_64
git-svn-id: trunk@31169 -
This commit is contained in:
parent
09addc9e78
commit
7ca62febcd
@ -1802,13 +1802,13 @@ end;
|
||||
|
||||
|
||||
procedure pd_syscall(pd:tabstractprocdef);
|
||||
{$if defined(powerpc) or defined(m68k) or defined(i386)}
|
||||
{$if defined(powerpc) or defined(m68k) or defined(i386) or defined(x86_64)}
|
||||
var
|
||||
vs : tparavarsym;
|
||||
sym : tsym;
|
||||
symtable : TSymtable;
|
||||
v: Tconstexprint;
|
||||
{$endif defined(powerpc) or defined(m68k) or defined(i386)}
|
||||
{$endif defined(powerpc) or defined(m68k) or defined(i386) or defined(x86_64)}
|
||||
begin
|
||||
if (pd.typ<>procdef) and (target_info.system <> system_powerpc_amiga) then
|
||||
internalerror(2003042614);
|
||||
@ -1973,8 +1973,8 @@ begin
|
||||
Tprocdef(pd).extnumber:=v.uvalue;
|
||||
end;
|
||||
{$endif powerpc}
|
||||
{$ifdef i386}
|
||||
if target_info.system = system_i386_aros then
|
||||
{$if defined(i386) or defined(x86_64)}
|
||||
if target_info.system in [system_i386_aros,system_x86_64_aros] then
|
||||
begin
|
||||
include(pd.procoptions,po_syscall_sysvbase);
|
||||
|
||||
@ -2002,7 +2002,7 @@ begin
|
||||
if (v<low(Tprocdef(pd).extnumber)) or (v>high(Tprocdef(pd).extnumber)) then
|
||||
message(parser_e_range_check_error)
|
||||
else
|
||||
Tprocdef(pd).extnumber:=v.uvalue * 4; { sizeof Pointer for the target }
|
||||
Tprocdef(pd).extnumber:=v.uvalue * sizeof(pint);
|
||||
end;
|
||||
{$endif}
|
||||
end;
|
||||
|
@ -471,7 +471,7 @@ interface
|
||||
supported_targets : [system_x86_64_linux,system_x86_64_freebsd,
|
||||
system_x86_64_win64,system_x86_64_embedded,
|
||||
system_x86_64_openbsd,system_x86_64_netbsd,
|
||||
system_x86_64_dragonfly];
|
||||
system_x86_64_dragonfly,system_x86_64_aros];
|
||||
flags : [af_needar,af_smartlink_sections,af_supports_dwarf];
|
||||
labelprefix : '.L';
|
||||
comment : '# ';
|
||||
|
@ -676,7 +676,8 @@ implementation
|
||||
asmcmd : '';
|
||||
supported_targets : [system_x86_64_linux,system_x86_64_freebsd,
|
||||
system_x86_64_openbsd,system_x86_64_netbsd,
|
||||
system_x86_64_dragonfly,system_x86_64_solaris];
|
||||
system_x86_64_dragonfly,system_x86_64_solaris,
|
||||
system_x86_64_aros];
|
||||
flags : [af_outputbinary,af_smartlink_sections,af_supports_dwarf];
|
||||
labelprefix : '.L';
|
||||
comment : '';
|
||||
|
@ -49,6 +49,10 @@ implementation
|
||||
{$ifndef NOTARGETSUNOS}
|
||||
,t_sunos
|
||||
{$endif}
|
||||
{$ifndef NOTARGETAROS}
|
||||
,t_aros
|
||||
{$endif}
|
||||
|
||||
|
||||
{**************************************
|
||||
Assemblers
|
||||
|
@ -31,9 +31,12 @@ interface
|
||||
|
||||
type
|
||||
tx8664callnode = class(tx86callnode)
|
||||
protected
|
||||
protected
|
||||
procedure gen_syscall_para(para: tcallparanode); override;
|
||||
procedure extra_call_code;override;
|
||||
procedure set_result_location(realresdef: tstoreddef);override;
|
||||
public
|
||||
procedure do_syscall;override;
|
||||
end;
|
||||
|
||||
|
||||
@ -41,10 +44,53 @@ implementation
|
||||
|
||||
uses
|
||||
globtype,
|
||||
systems,
|
||||
systems,verbose,cutils,
|
||||
cpubase,cgbase,cgutils,cgobj,
|
||||
symsym,symcpu,nld,
|
||||
aasmtai,aasmdata,aasmcpu;
|
||||
|
||||
{ uses
|
||||
globtype,systems,
|
||||
cutils,verbose,globals,
|
||||
cgbase,cgutils,
|
||||
cpubase,paramgr,
|
||||
aasmtai,aasmdata,aasmcpu,
|
||||
nbas,nmem,nld,ncnv,
|
||||
symdef,symsym,symcpu,
|
||||
cga,cgobj,cpuinfo;}
|
||||
|
||||
|
||||
procedure tx8664callnode.do_syscall;
|
||||
var
|
||||
tmpref: treference;
|
||||
begin
|
||||
case target_info.system of
|
||||
system_x86_64_aros:
|
||||
begin
|
||||
// one syscall convention for AROS
|
||||
current_asmdata.CurrAsmList.concat(tai_comment.create(strpnew('AROS SysCall')));
|
||||
reference_reset(tmpref,sizeof(pint));
|
||||
tmpref.symbol:=current_asmdata.RefAsmSymbol(tstaticvarsym(tcpuprocdef(procdefinition).libsym).mangledname);
|
||||
cg.getcpuregister(current_asmdata.CurrAsmList,NR_RAX);
|
||||
cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,tmpref,NR_RAX);
|
||||
reference_reset_base(tmpref,NR_EAX,-tprocdef(procdefinition).extnumber,sizeof(pint));
|
||||
cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,tmpref,NR_RAX);
|
||||
cg.a_call_reg(current_asmdata.CurrAsmList,NR_RAX);
|
||||
cg.ungetcpuregister(current_asmdata.CurrAsmList,NR_RAX);
|
||||
end;
|
||||
else
|
||||
internalerror(2015062801);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure tx8664callnode.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 tx8664callnode.extra_call_code;
|
||||
var
|
||||
mmregs : aint;
|
||||
|
@ -26,7 +26,7 @@ unit symcpu;
|
||||
interface
|
||||
|
||||
uses
|
||||
symtype,symdef,symsym,symx86;
|
||||
symconst,symtype,symdef,symsym,symx86;
|
||||
|
||||
type
|
||||
{ defs }
|
||||
@ -91,6 +91,15 @@ type
|
||||
tcpuprocvardefclass = class of tcpuprocvardef;
|
||||
|
||||
tcpuprocdef = class(tprocdef)
|
||||
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;
|
||||
|
||||
@ -174,6 +183,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;
|
||||
|
Loading…
Reference in New Issue
Block a user