mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-10-27 08:11:27 +01: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);
|
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
|
var
|
||||||
vs : tparavarsym;
|
vs : tparavarsym;
|
||||||
sym : tsym;
|
sym : tsym;
|
||||||
symtable : TSymtable;
|
symtable : TSymtable;
|
||||||
v: Tconstexprint;
|
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
|
begin
|
||||||
if (pd.typ<>procdef) and (target_info.system <> system_powerpc_amiga) then
|
if (pd.typ<>procdef) and (target_info.system <> system_powerpc_amiga) then
|
||||||
internalerror(2003042614);
|
internalerror(2003042614);
|
||||||
@ -1973,8 +1973,8 @@ begin
|
|||||||
Tprocdef(pd).extnumber:=v.uvalue;
|
Tprocdef(pd).extnumber:=v.uvalue;
|
||||||
end;
|
end;
|
||||||
{$endif powerpc}
|
{$endif powerpc}
|
||||||
{$ifdef i386}
|
{$if defined(i386) or defined(x86_64)}
|
||||||
if target_info.system = system_i386_aros then
|
if target_info.system in [system_i386_aros,system_x86_64_aros] then
|
||||||
begin
|
begin
|
||||||
include(pd.procoptions,po_syscall_sysvbase);
|
include(pd.procoptions,po_syscall_sysvbase);
|
||||||
|
|
||||||
@ -2002,7 +2002,7 @@ begin
|
|||||||
if (v<low(Tprocdef(pd).extnumber)) or (v>high(Tprocdef(pd).extnumber)) then
|
if (v<low(Tprocdef(pd).extnumber)) or (v>high(Tprocdef(pd).extnumber)) then
|
||||||
message(parser_e_range_check_error)
|
message(parser_e_range_check_error)
|
||||||
else
|
else
|
||||||
Tprocdef(pd).extnumber:=v.uvalue * 4; { sizeof Pointer for the target }
|
Tprocdef(pd).extnumber:=v.uvalue * sizeof(pint);
|
||||||
end;
|
end;
|
||||||
{$endif}
|
{$endif}
|
||||||
end;
|
end;
|
||||||
|
|||||||
@ -471,7 +471,7 @@ interface
|
|||||||
supported_targets : [system_x86_64_linux,system_x86_64_freebsd,
|
supported_targets : [system_x86_64_linux,system_x86_64_freebsd,
|
||||||
system_x86_64_win64,system_x86_64_embedded,
|
system_x86_64_win64,system_x86_64_embedded,
|
||||||
system_x86_64_openbsd,system_x86_64_netbsd,
|
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];
|
flags : [af_needar,af_smartlink_sections,af_supports_dwarf];
|
||||||
labelprefix : '.L';
|
labelprefix : '.L';
|
||||||
comment : '# ';
|
comment : '# ';
|
||||||
|
|||||||
@ -676,7 +676,8 @@ implementation
|
|||||||
asmcmd : '';
|
asmcmd : '';
|
||||||
supported_targets : [system_x86_64_linux,system_x86_64_freebsd,
|
supported_targets : [system_x86_64_linux,system_x86_64_freebsd,
|
||||||
system_x86_64_openbsd,system_x86_64_netbsd,
|
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];
|
flags : [af_outputbinary,af_smartlink_sections,af_supports_dwarf];
|
||||||
labelprefix : '.L';
|
labelprefix : '.L';
|
||||||
comment : '';
|
comment : '';
|
||||||
|
|||||||
@ -49,6 +49,10 @@ implementation
|
|||||||
{$ifndef NOTARGETSUNOS}
|
{$ifndef NOTARGETSUNOS}
|
||||||
,t_sunos
|
,t_sunos
|
||||||
{$endif}
|
{$endif}
|
||||||
|
{$ifndef NOTARGETAROS}
|
||||||
|
,t_aros
|
||||||
|
{$endif}
|
||||||
|
|
||||||
|
|
||||||
{**************************************
|
{**************************************
|
||||||
Assemblers
|
Assemblers
|
||||||
|
|||||||
@ -31,9 +31,12 @@ interface
|
|||||||
|
|
||||||
type
|
type
|
||||||
tx8664callnode = class(tx86callnode)
|
tx8664callnode = class(tx86callnode)
|
||||||
protected
|
protected
|
||||||
|
procedure gen_syscall_para(para: tcallparanode); override;
|
||||||
procedure extra_call_code;override;
|
procedure extra_call_code;override;
|
||||||
procedure set_result_location(realresdef: tstoreddef);override;
|
procedure set_result_location(realresdef: tstoreddef);override;
|
||||||
|
public
|
||||||
|
procedure do_syscall;override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -41,10 +44,53 @@ implementation
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
globtype,
|
globtype,
|
||||||
systems,
|
systems,verbose,cutils,
|
||||||
cpubase,cgbase,cgutils,cgobj,
|
cpubase,cgbase,cgutils,cgobj,
|
||||||
|
symsym,symcpu,nld,
|
||||||
aasmtai,aasmdata,aasmcpu;
|
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;
|
procedure tx8664callnode.extra_call_code;
|
||||||
var
|
var
|
||||||
mmregs : aint;
|
mmregs : aint;
|
||||||
|
|||||||
@ -26,7 +26,7 @@ unit symcpu;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
symtype,symdef,symsym,symx86;
|
symconst,symtype,symdef,symsym,symx86;
|
||||||
|
|
||||||
type
|
type
|
||||||
{ defs }
|
{ defs }
|
||||||
@ -91,6 +91,15 @@ type
|
|||||||
tcpuprocvardefclass = class of tcpuprocvardef;
|
tcpuprocvardefclass = class of tcpuprocvardef;
|
||||||
|
|
||||||
tcpuprocdef = class(tprocdef)
|
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;
|
end;
|
||||||
tcpuprocdefclass = class of tcpuprocdef;
|
tcpuprocdefclass = class of tcpuprocdef;
|
||||||
|
|
||||||
@ -174,6 +183,52 @@ const
|
|||||||
|
|
||||||
implementation
|
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
|
begin
|
||||||
{ used tdef classes }
|
{ used tdef classes }
|
||||||
cfiledef:=tcpufiledef;
|
cfiledef:=tcpufiledef;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user