mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-20 11:49:25 +02:00
* skeleton to unify the RiscV paramgr
* first routines unified
This commit is contained in:
parent
74bad92e4d
commit
f32eaa1564
75
compiler/riscv/pararv.pas
Normal file
75
compiler/riscv/pararv.pas
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
{
|
||||||
|
Copyright (c) 2002 by Florian Klaempfl
|
||||||
|
|
||||||
|
RiscV specific calling conventions
|
||||||
|
|
||||||
|
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.
|
||||||
|
****************************************************************************
|
||||||
|
}
|
||||||
|
unit pararv;
|
||||||
|
|
||||||
|
{$I fpcdefs.inc}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
globtype,
|
||||||
|
cgutils,
|
||||||
|
paramgr;
|
||||||
|
|
||||||
|
type
|
||||||
|
trvparamanager = class(tparamanager)
|
||||||
|
function get_volatile_registers_int(calloption: tproccalloption): tcpuregisterset; override;
|
||||||
|
function get_volatile_registers_fpu(calloption: tproccalloption): tcpuregisterset; override;
|
||||||
|
|
||||||
|
function get_saved_registers_fpu(calloption: tproccalloption): tcpuregisterarray;override;
|
||||||
|
function get_saved_registers_int(calloption: tproccalloption): tcpuregisterarray;override;
|
||||||
|
end;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
uses
|
||||||
|
cpubase;
|
||||||
|
|
||||||
|
function trvparamanager.get_volatile_registers_int(calloption: tproccalloption): tcpuregisterset;
|
||||||
|
begin
|
||||||
|
result:=[RS_X0..RS_X31]-[RS_X2,RS_X8..RS_X9,RS_X18..RS_X27];
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function trvparamanager.get_volatile_registers_fpu(calloption: tproccalloption): tcpuregisterset;
|
||||||
|
begin
|
||||||
|
result:=[RS_F0..RS_F31]-[RS_F8..RS_F9,RS_F18..RS_F27];
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function trvparamanager.get_saved_registers_int(calloption : tproccalloption):tcpuregisterarray;
|
||||||
|
const
|
||||||
|
saved_regs: tcpuregisterarray = (RS_X2,RS_X8,RS_X9,RS_X18,RS_X19,RS_X20,RS_X21,RS_X22,RS_X23,RS_X24,RS_X26,RS_X26,RS_X27);
|
||||||
|
begin
|
||||||
|
result:=saved_regs;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function trvparamanager.get_saved_registers_fpu(calloption : tproccalloption):tcpuregisterarray;
|
||||||
|
const
|
||||||
|
saved_regs: tcpuregisterarray = (RS_F8,RS_F9,RS_F18,RS_F19,RS_F20,RS_F21,RS_F22,RS_F23,RS_F24,RS_F25,RS_F26,RS_F27);
|
||||||
|
begin
|
||||||
|
result:=saved_regs;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
@ -29,20 +29,17 @@ unit cpupara;
|
|||||||
aasmtai,aasmdata,
|
aasmtai,aasmdata,
|
||||||
cpubase,
|
cpubase,
|
||||||
symconst,symtype,symdef,symsym,
|
symconst,symtype,symdef,symsym,
|
||||||
paramgr,parabase,cgbase,cgutils;
|
paramgr,parabase,cgbase,cgutils,
|
||||||
|
pararv;
|
||||||
|
|
||||||
type
|
type
|
||||||
tcpuparamanager = class(tparamanager)
|
tcpuparamanager = class(trvparamanager)
|
||||||
function get_volatile_registers_int(calloption : tproccalloption):tcpuregisterset;override;
|
|
||||||
function get_volatile_registers_fpu(calloption : tproccalloption):tcpuregisterset;override;
|
|
||||||
function push_addr_param(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;override;
|
function push_addr_param(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;override;
|
||||||
|
|
||||||
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(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 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 get_saved_registers_int(calloption: tproccalloption): tcpuregisterarray;override;
|
|
||||||
function get_saved_registers_fpu(calloption: tproccalloption): tcpuregisterarray;override;
|
|
||||||
private
|
private
|
||||||
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);
|
||||||
function create_paraloc_info_intern(p : tabstractprocdef; side: tcallercallee; paras:tparalist;
|
function create_paraloc_info_intern(p : tabstractprocdef; side: tcallercallee; paras:tparalist;
|
||||||
@ -57,35 +54,6 @@ unit cpupara;
|
|||||||
defutil,symtable,
|
defutil,symtable,
|
||||||
procinfo,cpupi;
|
procinfo,cpupi;
|
||||||
|
|
||||||
|
|
||||||
function tcpuparamanager.get_volatile_registers_int(calloption : tproccalloption):tcpuregisterset;
|
|
||||||
begin
|
|
||||||
result:=[RS_X0..RS_X31]-[RS_X2,RS_X8..RS_X9,RS_X18..RS_X27];
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
function tcpuparamanager.get_volatile_registers_fpu(calloption : tproccalloption):tcpuregisterset;
|
|
||||||
begin
|
|
||||||
result:=[RS_F0..RS_F31]-[RS_F8..RS_F9,RS_F18..RS_F27];
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
function tcpuparamanager.get_saved_registers_int(calloption : tproccalloption):tcpuregisterarray;
|
|
||||||
const
|
|
||||||
saved_regs: tcpuregisterarray = (RS_X2,RS_X8,RS_X9,RS_X18,RS_X19,RS_X20,RS_X21,RS_X22,RS_X23,RS_X24,RS_X26,RS_X26,RS_X27);
|
|
||||||
begin
|
|
||||||
result:=saved_regs;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
function tcpuparamanager.get_saved_registers_fpu(calloption : tproccalloption):tcpuregisterarray;
|
|
||||||
const
|
|
||||||
saved_regs: tcpuregisterarray = (RS_F8,RS_F9,RS_F18,RS_F19,RS_F20,RS_F21,RS_F22,RS_F23,RS_F24,RS_F25,RS_F26,RS_F27);
|
|
||||||
begin
|
|
||||||
result:=saved_regs;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
procedure tcpuparamanager.getcgtempparaloc(list: TAsmList; pd : tabstractprocdef; nr : longint; var cgpara : tcgpara);
|
procedure tcpuparamanager.getcgtempparaloc(list: TAsmList; pd : tabstractprocdef; nr : longint; var cgpara : tcgpara);
|
||||||
var
|
var
|
||||||
paraloc : pcgparalocation;
|
paraloc : pcgparalocation;
|
||||||
|
@ -29,12 +29,11 @@ unit cpupara;
|
|||||||
aasmtai,aasmdata,
|
aasmtai,aasmdata,
|
||||||
cpubase,
|
cpubase,
|
||||||
symconst, symtype, symdef, symsym,
|
symconst, symtype, symdef, symsym,
|
||||||
paramgr, parabase, cgbase, cgutils;
|
paramgr, parabase, cgbase, cgutils,
|
||||||
|
pararv;
|
||||||
|
|
||||||
type
|
type
|
||||||
tcpuparamanager = class(tparamanager)
|
tcpuparamanager = class(trvparamanager)
|
||||||
function get_volatile_registers_int(calloption: tproccalloption): tcpuregisterset; override;
|
|
||||||
function get_volatile_registers_fpu(calloption: tproccalloption): tcpuregisterset; override;
|
|
||||||
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 ret_in_param(def: tdef; pd: tabstractprocdef): boolean; override;
|
function ret_in_param(def: tdef; pd: tabstractprocdef): boolean; override;
|
||||||
|
|
||||||
@ -43,8 +42,6 @@ unit cpupara;
|
|||||||
function create_varargs_paraloc_info(p: tabstractprocdef; side: tcallercallee; varargspara: tvarargsparalist): 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 get_saved_registers_fpu(calloption: tproccalloption): tcpuregisterarray;override;
|
|
||||||
function get_saved_registers_int(calloption: tproccalloption): tcpuregisterarray;override;
|
|
||||||
private
|
private
|
||||||
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);
|
||||||
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 create_paraloc_info_intern(p: tabstractprocdef; side: tcallercallee; paras: tparalist; var curintreg, curfloatreg, curmmreg: tsuperregister; var cur_stack_offset: aword; isVararg : boolean): longint;
|
||||||
@ -60,30 +57,6 @@ implementation
|
|||||||
defutil,symtable,symcpu,
|
defutil,symtable,symcpu,
|
||||||
procinfo, cpupi;
|
procinfo, cpupi;
|
||||||
|
|
||||||
function tcpuparamanager.get_volatile_registers_int(calloption: tproccalloption): tcpuregisterset;
|
|
||||||
begin
|
|
||||||
result:=[RS_X0..RS_X31]-[RS_X2,RS_X8..RS_X9,RS_X18..RS_X27];
|
|
||||||
end;
|
|
||||||
|
|
||||||
function tcpuparamanager.get_volatile_registers_fpu(calloption: tproccalloption): tcpuregisterset;
|
|
||||||
begin
|
|
||||||
result:=[RS_F0..RS_F31]-[RS_F8..RS_F9,RS_F18..RS_F27];
|
|
||||||
end;
|
|
||||||
|
|
||||||
function tcpuparamanager.get_saved_registers_int(calloption : tproccalloption):tcpuregisterarray;
|
|
||||||
const
|
|
||||||
saved_regs: tcpuregisterarray = (RS_X2,RS_X8,RS_X9,RS_X18,RS_X19,RS_X20,RS_X21,RS_X22,RS_X23,RS_X24,RS_X26,RS_X26,RS_X27);
|
|
||||||
begin
|
|
||||||
result:=saved_regs;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function tcpuparamanager.get_saved_registers_fpu(calloption : tproccalloption):tcpuregisterarray;
|
|
||||||
const
|
|
||||||
saved_regs: tcpuregisterarray = (RS_F8,RS_F9,RS_F18,RS_F19,RS_F20,RS_F21,RS_F22,RS_F23,RS_F24,RS_F25,RS_F26,RS_F27);
|
|
||||||
begin
|
|
||||||
result:=saved_regs;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure tcpuparamanager.getcgtempparaloc(list: TAsmList; pd : tabstractprocdef; nr: longint; var cgpara: tcgpara);
|
procedure tcpuparamanager.getcgtempparaloc(list: TAsmList; pd : tabstractprocdef; nr: longint; var cgpara: tcgpara);
|
||||||
var
|
var
|
||||||
paraloc: pcgparalocation;
|
paraloc: pcgparalocation;
|
||||||
@ -339,7 +312,7 @@ implementation
|
|||||||
else
|
else
|
||||||
paralen := tcgsize2size[def_cgsize(paradef)];
|
paralen := tcgsize2size[def_cgsize(paradef)];
|
||||||
|
|
||||||
if (paradef.typ=recorddef) and
|
if (paradef.typ=recorddef) and not(is_implicit_pointer_object_type(paradef)) and
|
||||||
tabstractrecordsymtable(tabstractrecorddef(paradef).symtable).has_single_field(tmpdef) and
|
tabstractrecordsymtable(tabstractrecorddef(paradef).symtable).has_single_field(tmpdef) and
|
||||||
(tmpdef.typ=floatdef) then
|
(tmpdef.typ=floatdef) then
|
||||||
begin
|
begin
|
||||||
|
@ -1645,11 +1645,11 @@ implementation
|
|||||||
else
|
else
|
||||||
exit;
|
exit;
|
||||||
offset := sym.fieldoffset;
|
offset := sym.fieldoffset;
|
||||||
if(def2.typ = def1.typ)then
|
if def2.typ = def1.typ then
|
||||||
cnt := 2
|
cnt := 2
|
||||||
else
|
else
|
||||||
cnt := 1;
|
cnt := 1;
|
||||||
if((offset = 0))then
|
if offset = 0 then
|
||||||
cnt := 0;
|
cnt := 0;
|
||||||
has_double_field := cnt;
|
has_double_field := cnt;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user