mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 05:04:06 +02:00
* continued unification of RiscV paramgr
This commit is contained in:
parent
6035058a21
commit
4bc9f64b70
@ -27,7 +27,7 @@ unit pararv;
|
|||||||
uses
|
uses
|
||||||
globtype,
|
globtype,
|
||||||
aasmdata,
|
aasmdata,
|
||||||
symtype,symdef,
|
symconst,symtype,symdef,
|
||||||
cgbase,cgutils,
|
cgbase,cgutils,
|
||||||
parabase,paramgr;
|
parabase,paramgr;
|
||||||
|
|
||||||
@ -41,6 +41,9 @@ unit pararv;
|
|||||||
|
|
||||||
procedure getcgtempparaloc(list: TAsmList; pd: tabstractprocdef; nr: longint; var cgpara: tcgpara);override;
|
procedure getcgtempparaloc(list: TAsmList; pd: tabstractprocdef; nr: longint; var cgpara: tcgpara);override;
|
||||||
|
|
||||||
|
function create_paraloc_info_intern(p: tabstractprocdef; side: tcallercallee; paras: tparalist; var curintreg, curfloatreg, curmmreg: tsuperregister; var cur_stack_offset: aword; isVararg : boolean): longint;virtual;abstract;
|
||||||
|
|
||||||
|
function create_varargs_paraloc_info(p: tabstractprocdef; side: tcallercallee; varargspara: tvarargsparalist): longint;override;
|
||||||
protected
|
protected
|
||||||
procedure init_values(var curintreg, curfloatreg, curmmreg: tsuperregister; var cur_stack_offset: aword);
|
procedure init_values(var curintreg, curfloatreg, curmmreg: tsuperregister; var cur_stack_offset: aword);
|
||||||
end;
|
end;
|
||||||
@ -53,7 +56,7 @@ implementation
|
|||||||
verbose,
|
verbose,
|
||||||
globals,
|
globals,
|
||||||
cpuinfo,
|
cpuinfo,
|
||||||
symconst,symsym,
|
symsym,
|
||||||
defutil,
|
defutil,
|
||||||
cpubase;
|
cpubase;
|
||||||
|
|
||||||
@ -204,6 +207,44 @@ implementation
|
|||||||
curmmreg := RS_NO;
|
curmmreg := RS_NO;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function trvparamanager.create_varargs_paraloc_info(p : tabstractprocdef; side: tcallercallee; varargspara:tvarargsparalist):longint;
|
||||||
|
var
|
||||||
|
cur_stack_offset: aword;
|
||||||
|
parasize, l: longint;
|
||||||
|
curintreg, firstfloatreg, curfloatreg, curmmreg: tsuperregister;
|
||||||
|
i : integer;
|
||||||
|
hp: tparavarsym;
|
||||||
|
paraloc: pcgparalocation;
|
||||||
|
begin
|
||||||
|
init_values(curintreg,curfloatreg,curmmreg,cur_stack_offset);
|
||||||
|
firstfloatreg:=curfloatreg;
|
||||||
|
|
||||||
|
result:=create_paraloc_info_intern(p,side,p.paras,curintreg,curfloatreg,curmmreg,cur_stack_offset,false);
|
||||||
|
if (p.proccalloption in cstylearrayofconst) then
|
||||||
|
{ just continue loading the parameters in the registers }
|
||||||
|
begin
|
||||||
|
if assigned(varargspara) then
|
||||||
|
begin
|
||||||
|
if side=callerside then
|
||||||
|
result:=create_paraloc_info_intern(p,side,varargspara,curintreg,curfloatreg,curmmreg,cur_stack_offset,true)
|
||||||
|
else
|
||||||
|
internalerror(2019021919);
|
||||||
|
if curfloatreg<>firstfloatreg then
|
||||||
|
include(varargspara.varargsinfo,va_uses_float_reg);
|
||||||
|
{ not sure if this applies to RiscV 32 as well ... }
|
||||||
|
{$ifdef RISCV64}
|
||||||
|
{ varargs routines have to reserve at least 64 bytes for the RiscV ABI }
|
||||||
|
if (result < 64) then
|
||||||
|
result := 64;
|
||||||
|
{$endif RISCV64}
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
internalerror(2019021912);
|
||||||
|
create_funcretloc_info(p,side);
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,11 +37,10 @@ unit cpupara;
|
|||||||
function push_addr_param(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;override;
|
function push_addr_param(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;override;
|
||||||
|
|
||||||
function create_paraloc_info(p : tabstractprocdef; side: tcallercallee):longint;override;
|
function create_paraloc_info(p : tabstractprocdef; side: tcallercallee):longint;override;
|
||||||
function create_varargs_paraloc_info(p : tabstractprocdef; side: tcallercallee; varargspara:tvarargsparalist):longint;override;
|
|
||||||
function get_funcretloc(p : tabstractprocdef; side: tcallercallee; forcetempdef: tdef): tcgpara;override;
|
function get_funcretloc(p : tabstractprocdef; side: tcallercallee; forcetempdef: tdef): tcgpara;override;
|
||||||
private
|
|
||||||
function create_paraloc_info_intern(p : tabstractprocdef; side: tcallercallee; paras:tparalist;
|
function create_paraloc_info_intern(p : tabstractprocdef; side: tcallercallee; paras:tparalist;
|
||||||
var curintreg, curfloatreg, curmmreg: tsuperregister; var cur_stack_offset: aword; varargsparas: boolean):longint;
|
var curintreg, curfloatreg, curmmreg: tsuperregister; var cur_stack_offset: aword; varargsparas: boolean):longint;override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -369,38 +368,6 @@ unit cpupara;
|
|||||||
result:=stack_offset;
|
result:=stack_offset;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function tcpuparamanager.create_varargs_paraloc_info(p : tabstractprocdef; side: tcallercallee; varargspara:tvarargsparalist):longint;
|
|
||||||
var
|
|
||||||
cur_stack_offset: aword;
|
|
||||||
parasize, l: longint;
|
|
||||||
curintreg, firstfloatreg, curfloatreg, curmmreg: tsuperregister;
|
|
||||||
i : integer;
|
|
||||||
hp: tparavarsym;
|
|
||||||
paraloc: pcgparalocation;
|
|
||||||
begin
|
|
||||||
init_values(curintreg,curfloatreg,curmmreg,cur_stack_offset);
|
|
||||||
firstfloatreg:=curfloatreg;
|
|
||||||
|
|
||||||
result:=create_paraloc_info_intern(p,side,p.paras,curintreg,curfloatreg,curmmreg,cur_stack_offset, false);
|
|
||||||
if (p.proccalloption in cstylearrayofconst) then
|
|
||||||
{ just continue loading the parameters in the registers }
|
|
||||||
begin
|
|
||||||
if assigned(varargspara) then
|
|
||||||
begin
|
|
||||||
if side=callerside then
|
|
||||||
result:=create_paraloc_info_intern(p,side,varargspara,curintreg,curfloatreg,curmmreg,cur_stack_offset,true)
|
|
||||||
else
|
|
||||||
internalerror(2019021919);
|
|
||||||
if curfloatreg<>firstfloatreg then
|
|
||||||
include(varargspara.varargsinfo,va_uses_float_reg);
|
|
||||||
end;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
internalerror(2019021912);
|
|
||||||
create_funcretloc_info(p,side);
|
|
||||||
end;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
paramanager:=tcpuparamanager.create;
|
paramanager:=tcpuparamanager.create;
|
||||||
end.
|
end.
|
||||||
|
@ -38,11 +38,10 @@ unit cpupara;
|
|||||||
function ret_in_param(def: tdef; pd: tabstractprocdef): boolean; override;
|
function ret_in_param(def: tdef; pd: tabstractprocdef): boolean; override;
|
||||||
|
|
||||||
function create_paraloc_info(p: tabstractprocdef; side: tcallercallee): longint; override;
|
function create_paraloc_info(p: tabstractprocdef; side: tcallercallee): longint; override;
|
||||||
function create_varargs_paraloc_info(p: tabstractprocdef; side: tcallercallee; varargspara: tvarargsparalist): longint; override;
|
|
||||||
function get_funcretloc(p : tabstractprocdef; side: tcallercallee; forcetempdef: tdef): tcgpara;override;
|
function get_funcretloc(p : tabstractprocdef; side: tcallercallee; forcetempdef: tdef): tcgpara;override;
|
||||||
|
|
||||||
|
function create_paraloc_info_intern(p: tabstractprocdef; side: tcallercallee; paras: tparalist; var curintreg, curfloatreg, curmmreg: tsuperregister; var cur_stack_offset: aword; isVararg : boolean): longint;override;
|
||||||
private
|
private
|
||||||
function create_paraloc_info_intern(p: tabstractprocdef; side: tcallercallee; paras: tparalist; var curintreg, curfloatreg, curmmreg: tsuperregister; var cur_stack_offset: aword; isVararg : boolean): longint;
|
|
||||||
function parseparaloc(p: tparavarsym; const s: string): boolean; override;
|
function parseparaloc(p: tparavarsym; const s: string): boolean; override;
|
||||||
procedure create_paraloc_for_def(var para: TCGPara; varspez: tvarspez; paradef: tdef; var nextfloatreg, nextintreg: tsuperregister; var stack_offset: aword; const isVararg, forceintmem: boolean; const side: tcallercallee; const p: tabstractprocdef);
|
procedure create_paraloc_for_def(var para: TCGPara; varspez: tvarspez; paradef: tdef; var nextfloatreg, nextintreg: tsuperregister; var stack_offset: aword; const isVararg, forceintmem: boolean; const side: tcallercallee; const p: tabstractprocdef);
|
||||||
end;
|
end;
|
||||||
@ -395,43 +394,6 @@ implementation
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function tcpuparamanager.create_varargs_paraloc_info(p: tabstractprocdef; side: tcallercallee;
|
|
||||||
varargspara: tvarargsparalist): longint;
|
|
||||||
var
|
|
||||||
cur_stack_offset: aword;
|
|
||||||
parasize, l: longint;
|
|
||||||
curintreg, firstfloatreg, curfloatreg, curmmreg: tsuperregister;
|
|
||||||
i: integer;
|
|
||||||
hp: tparavarsym;
|
|
||||||
paraloc: pcgparalocation;
|
|
||||||
begin
|
|
||||||
init_values(curintreg, curfloatreg, curmmreg, cur_stack_offset);
|
|
||||||
firstfloatreg := curfloatreg;
|
|
||||||
|
|
||||||
result := create_paraloc_info_intern(p, side, p.paras, curintreg,
|
|
||||||
curfloatreg, curmmreg, cur_stack_offset, false);
|
|
||||||
if (p.proccalloption in [pocall_cdecl, pocall_cppdecl, pocall_mwpascal]) then
|
|
||||||
begin
|
|
||||||
{ just continue loading the parameters in the registers }
|
|
||||||
if assigned(varargspara) then
|
|
||||||
begin
|
|
||||||
if side=callerside then
|
|
||||||
result := create_paraloc_info_intern(p, side, varargspara, curintreg,
|
|
||||||
curfloatreg, curmmreg, cur_stack_offset, true)
|
|
||||||
else
|
|
||||||
internalerror(2019021918);
|
|
||||||
if curfloatreg <> firstfloatreg then
|
|
||||||
include(varargspara.varargsinfo, va_uses_float_reg);
|
|
||||||
end;
|
|
||||||
{ varargs routines have to reserve at least 64 bytes for the RiscV ABI }
|
|
||||||
if (result < 64) then
|
|
||||||
result := 64;
|
|
||||||
end
|
|
||||||
else
|
|
||||||
internalerror(2019021913);
|
|
||||||
|
|
||||||
create_funcretloc_info(p, side);
|
|
||||||
end;
|
|
||||||
|
|
||||||
function tcpuparamanager.parseparaloc(p: tparavarsym; const s: string): boolean;
|
function tcpuparamanager.parseparaloc(p: tparavarsym; const s: string): boolean;
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user