mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-10 04:49:07 +02:00
* factored out setlocalloc and the code to set the initial paravarsym
location from ncgutil into hlcgobj, and override/implement it for llvm (use the symbolic parameter names) git-svn-id: branches/hlcgllvm@26052 -
This commit is contained in:
parent
aa5823a454
commit
d14ce7817f
@ -37,7 +37,7 @@ unit hlcgobj;
|
||||
cclasses,globtype,constexp,
|
||||
cpubase,cgbase,cgutils,parabase,
|
||||
aasmbase,aasmtai,aasmdata,aasmcpu,
|
||||
symconst,symtype,symdef,
|
||||
symconst,symbase,symtype,symsym,symdef,
|
||||
node
|
||||
;
|
||||
|
||||
@ -504,6 +504,10 @@ unit hlcgobj;
|
||||
{ generates the code for decrementing the reference count of parameters }
|
||||
procedure final_paras(p:TObject;arg:pointer);
|
||||
public
|
||||
{ helper called by gen_alloc_symtable }
|
||||
procedure varsym_set_localloc(list: TAsmList; vs:tabstractnormalvarsym); virtual;
|
||||
{ helper called by gen_alloc_symtable }
|
||||
procedure paravarsym_set_initialloc_to_paraloc(vs: tparavarsym); virtual;
|
||||
|
||||
procedure gen_load_para_value(list:TAsmList);virtual;
|
||||
protected
|
||||
@ -557,7 +561,7 @@ implementation
|
||||
globals,systems,
|
||||
fmodule,export,
|
||||
verbose,defutil,paramgr,
|
||||
symbase,symsym,symtable,
|
||||
symtable,
|
||||
ncon,nld,ncgrtti,pass_1,pass_2,
|
||||
cpuinfo,cgobj,tgobj,cutils,procinfo,
|
||||
ncgutil,ngenutil;
|
||||
@ -4026,6 +4030,29 @@ implementation
|
||||
current_procinfo:=old_current_procinfo;
|
||||
end;
|
||||
|
||||
procedure thlcgobj.varsym_set_localloc(list: TAsmList; vs: tabstractnormalvarsym);
|
||||
begin
|
||||
if cs_asm_source in current_settings.globalswitches then
|
||||
begin
|
||||
case vs.initialloc.loc of
|
||||
LOC_REFERENCE :
|
||||
begin
|
||||
if not assigned(vs.initialloc.reference.symbol) then
|
||||
list.concat(Tai_comment.Create(strpnew('Var '+vs.realname+' located at '+
|
||||
std_regname(vs.initialloc.reference.base)+tostr_with_plus(vs.initialloc.reference.offset))));
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
vs.localloc:=vs.initialloc;
|
||||
FillChar(vs.currentregloc,sizeof(vs.currentregloc),0);
|
||||
end;
|
||||
|
||||
procedure thlcgobj.paravarsym_set_initialloc_to_paraloc(vs: tparavarsym);
|
||||
begin
|
||||
reference_reset_base(vs.initialloc.reference,tparavarsym(vs).paraloc[calleeside].location^.reference.index,
|
||||
tparavarsym(vs).paraloc[calleeside].location^.reference.offset,tparavarsym(vs).paraloc[calleeside].alignment);
|
||||
end;
|
||||
|
||||
procedure thlcgobj.gen_entry_code(list: TAsmList);
|
||||
begin
|
||||
{ the actual profile code can clobber some registers,
|
||||
|
@ -99,7 +99,10 @@ uses
|
||||
procedure g_intf_wrapper(list: TAsmList; procdef: tprocdef; const labelname: string; ioffset: longint); override;
|
||||
procedure g_adjust_self_value(list: TAsmList; procdef: tprocdef; ioffset: aint); override;
|
||||
procedure g_local_unwind(list: TAsmList; l: TAsmLabel); override;
|
||||
protected
|
||||
|
||||
procedure varsym_set_localloc(list: TAsmList; vs: tabstractnormalvarsym); override;
|
||||
procedure paravarsym_set_initialloc_to_paraloc(vs: tparavarsym); override;
|
||||
protected
|
||||
{ def is the type of the data stored in memory pointed to by ref, not
|
||||
a pointer to this type }
|
||||
function make_simple_ref(list: TAsmList; const ref: treference; def: tdef): treference;
|
||||
@ -822,6 +825,38 @@ implementation
|
||||
end;
|
||||
|
||||
|
||||
procedure thlcgllvm.varsym_set_localloc(list: TAsmList; vs: tabstractnormalvarsym);
|
||||
begin
|
||||
if cs_asm_source in current_settings.globalswitches then
|
||||
begin
|
||||
case vs.initialloc.loc of
|
||||
LOC_REFERENCE :
|
||||
begin
|
||||
if assigned(vs.initialloc.reference.symbol) then
|
||||
list.concat(Tai_comment.Create(strpnew('Var '+vs.realname+' located at '+
|
||||
vs.initialloc.reference.symbol.name)))
|
||||
else
|
||||
list.concat(Tai_comment.Create(strpnew('Var '+vs.realname+' located at %tmp.'+
|
||||
tostr(getsupreg(vs.initialloc.reference.base)))));
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
vs.localloc:=vs.initialloc;
|
||||
FillChar(vs.currentregloc,sizeof(vs.currentregloc),0);
|
||||
end;
|
||||
|
||||
|
||||
procedure thlcgllvm.paravarsym_set_initialloc_to_paraloc(vs: tparavarsym);
|
||||
var
|
||||
parasym : tasmsymbol;
|
||||
begin
|
||||
parasym:=vs.paraloc[calleeside].location^.llvmloc;
|
||||
reference_reset_symbol(vs.initialloc.reference,parasym,0,vs.paraloc[calleeside].alignment);
|
||||
if vs.paraloc[calleeside].location^.llvmvalueloc then
|
||||
vs.initialloc.reference.refaddr:=addr_full;
|
||||
end;
|
||||
|
||||
|
||||
procedure create_hlcodegen;
|
||||
begin
|
||||
hlcg:=thlcgllvm.create;
|
||||
|
@ -150,7 +150,11 @@ implementation
|
||||
regvars,dbgbase,
|
||||
pass_1,pass_2,
|
||||
nbas,ncon,nld,nmem,nutils,ngenutil,
|
||||
tgobj,cgobj,cgcpu,hlcgobj,hlcgcpu
|
||||
tgobj,cgobj,hlcgobj,hlcgcpu
|
||||
{$ifdef llvm}
|
||||
{ override create_hlcodegen from hlcgcpu }
|
||||
, hlcgllvm
|
||||
{$endif}
|
||||
{$ifdef powerpc}
|
||||
, cpupi
|
||||
{$endif}
|
||||
@ -1504,23 +1508,6 @@ implementation
|
||||
|
||||
procedure gen_alloc_symtable(list:TAsmList;pd:tprocdef;st:TSymtable);
|
||||
|
||||
procedure setlocalloc(vs:tabstractnormalvarsym);
|
||||
begin
|
||||
if cs_asm_source in current_settings.globalswitches then
|
||||
begin
|
||||
case vs.initialloc.loc of
|
||||
LOC_REFERENCE :
|
||||
begin
|
||||
if not assigned(vs.initialloc.reference.symbol) then
|
||||
list.concat(Tai_comment.Create(strpnew('Var '+vs.realname+' located at '+
|
||||
std_regname(vs.initialloc.reference.base)+tostr_with_plus(vs.initialloc.reference.offset))));
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
vs.localloc:=vs.initialloc;
|
||||
FillChar(vs.currentregloc,sizeof(vs.currentregloc),0);
|
||||
end;
|
||||
|
||||
var
|
||||
i : longint;
|
||||
sym : tsym;
|
||||
@ -1544,7 +1531,7 @@ implementation
|
||||
vs.initialloc.loc:=tvarregable2tcgloc[vs.varregable];
|
||||
vs.initialloc.size:=def_cgsize(vs.vardef);
|
||||
gen_alloc_regvar(list,vs,true);
|
||||
setlocalloc(vs);
|
||||
hlcg.varsym_set_localloc(list,vs);
|
||||
end;
|
||||
end;
|
||||
paravarsym :
|
||||
@ -1575,21 +1562,20 @@ implementation
|
||||
begin
|
||||
vs.initialloc.loc:=LOC_REFERENCE;
|
||||
{ Reuse the parameter location for values to are at a single location on the stack }
|
||||
if paramanager.param_use_paraloc(tparavarsym(sym).paraloc[calleeside]) then
|
||||
if paramanager.param_use_paraloc(tparavarsym(vs).paraloc[calleeside]) then
|
||||
begin
|
||||
reference_reset_base(vs.initialloc.reference,tparavarsym(sym).paraloc[calleeside].location^.reference.index,
|
||||
tparavarsym(sym).paraloc[calleeside].location^.reference.offset,tparavarsym(sym).paraloc[calleeside].alignment);
|
||||
hlcg.paravarsym_set_initialloc_to_paraloc(tparavarsym(vs));
|
||||
end
|
||||
else
|
||||
begin
|
||||
if isaddr then
|
||||
tg.GetLocal(list,sizeof(pint),voidpointertype,vs.initialloc.reference)
|
||||
tg.GetLocal(list,sizeof(pint),getpointerdef(vs.vardef),vs.initialloc.reference)
|
||||
else
|
||||
tg.GetLocal(list,vs.getsize,tparavarsym(sym).paraloc[calleeside].alignment,vs.vardef,vs.initialloc.reference);
|
||||
tg.GetLocal(list,vs.getsize,tparavarsym(vs).paraloc[calleeside].alignment,vs.vardef,vs.initialloc.reference);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
setlocalloc(vs);
|
||||
hlcg.varsym_set_localloc(list,vs);
|
||||
end;
|
||||
localvarsym :
|
||||
begin
|
||||
@ -1629,7 +1615,7 @@ implementation
|
||||
vs.initialloc.loc:=LOC_REFERENCE;
|
||||
tg.GetLocal(list,vs.getsize,vs.vardef,vs.initialloc.reference);
|
||||
end;
|
||||
setlocalloc(vs);
|
||||
hlcg.varsym_set_localloc(list,vs);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user