m68k: utilize cg.a_loadaddr_ref_cgpara in hlcgcpu, as m68k has an instruction for loading addresses directly to the stack (PEA), and the default implementation of hlcg.a_loadaddr_ref_cgpara doesn't use that code path

This commit is contained in:
Karoly Balogh 2022-03-23 11:06:18 +01:00
parent fba3da47c6
commit ed520548be
2 changed files with 18 additions and 3 deletions

View File

@ -413,11 +413,9 @@ unit cgcpu;
var
tmpref : treference;
begin
{ 68k always passes arguments on the stack }
if use_push(cgpara) then
begin
//list.concat(tai_comment.create(strpnew('a_loadaddr_ref_cgpara: PEA')));
cgpara.check_simple_location;
tmpref:=r;
fixref(list,tmpref,false);
list.concat(taicpu.op_ref(A_PEA,S_NO,tmpref));

View File

@ -34,6 +34,7 @@ interface
aasmbase, aasmdata,
cgbase, cgutils,
symconst,symtype,symdef,
parabase,
hlcg2ll;
type
@ -44,6 +45,8 @@ interface
procedure a_bit_set_const_ref(list: TAsmList; doset: boolean; destsize: tdef; bitnumber: tcgint; const ref: treference); override;
procedure g_intf_wrapper(list: TAsmList; procdef: tprocdef; const labelname: string; ioffset: longint);override;
procedure a_loadaddr_ref_cgpara(list: TAsmList; fromsize: tdef; const r: treference; const cgpara: TCGPara);override;
procedure gen_load_loc_function_result(list: TAsmList; vardef: tdef; const l: tlocation);override;
end;
@ -56,7 +59,7 @@ implementation
defutil,
hlcgobj,
cpuinfo, cgobj, cpubase, cgcpu,
parabase, procinfo;
paramgr, procinfo;
@ -241,6 +244,20 @@ implementation
List.concat(Tai_symbol_end.Createname(labelname));
end;
procedure thlcgcpu.a_loadaddr_ref_cgpara(list: TAsmList; fromsize: tdef; const r: treference; const cgpara: TCGPara);
begin
cgpara.check_simple_location;
if cgpara.location^.loc in [LOC_CREGISTER,LOC_REGISTER] then
begin
paramanager.allocparaloc(list,cgpara.location);
a_loadaddr_ref_reg(list,fromsize,cgpara.location^.def,r,cgpara.location^.register)
end
else
begin
paramanager.alloccgpara(list,cgpara);
cg.a_loadaddr_ref_cgpara(list,r,cgpara);
end;
end;
procedure thlcgcpu.gen_load_loc_function_result(list: TAsmList; vardef: tdef; const l: tlocation);
var