mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-28 11:27:10 +01:00
+ write the global procedures/functions in the llvm-mc assembler writer
git-svn-id: branches/wasm@46698 -
This commit is contained in:
parent
44d8dd2d43
commit
2d39ddf85e
@ -1548,6 +1548,18 @@ implementation
|
|||||||
end;
|
end;
|
||||||
writer.AsmLn;
|
writer.AsmLn;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$ifdef WASM}
|
||||||
|
ait_local:
|
||||||
|
begin
|
||||||
|
writer.AsmWriteLn(asminfo^.comment+'TODO: ait_local');
|
||||||
|
end;
|
||||||
|
ait_importexport:
|
||||||
|
begin
|
||||||
|
writer.AsmWriteLn(asminfo^.comment+'TODO: ait_importexport');
|
||||||
|
end;
|
||||||
|
{$endif WASM}
|
||||||
|
|
||||||
else
|
else
|
||||||
if not WriteComments(hp) then
|
if not WriteComments(hp) then
|
||||||
internalerror(2006012201);
|
internalerror(2006012201);
|
||||||
|
|||||||
@ -30,6 +30,7 @@ interface
|
|||||||
uses
|
uses
|
||||||
systems,
|
systems,
|
||||||
globtype,globals,
|
globtype,globals,
|
||||||
|
symbase,symdef,symtype,symconst,symcpu,
|
||||||
aasmbase,aasmtai,aasmdata,
|
aasmbase,aasmtai,aasmdata,
|
||||||
assemble,aggas;
|
assemble,aggas;
|
||||||
|
|
||||||
@ -39,9 +40,13 @@ interface
|
|||||||
|
|
||||||
TLLVMMachineCodePlaygroundAssembler=class(TGNUassembler)
|
TLLVMMachineCodePlaygroundAssembler=class(TGNUassembler)
|
||||||
protected
|
protected
|
||||||
|
procedure WriteProcDef(pd: tprocdef);
|
||||||
|
procedure WriteSymtableProcdefs(st: TSymtable);
|
||||||
|
|
||||||
function sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;override;
|
function sectionname(atype:TAsmSectiontype;const aname:string;aorder:TAsmSectionOrder):string;override;
|
||||||
public
|
public
|
||||||
constructor CreateWithWriter(info: pasminfo; wr: TExternalAssemblerOutputFile; freewriter, smart: boolean); override;
|
constructor CreateWithWriter(info: pasminfo; wr: TExternalAssemblerOutputFile; freewriter, smart: boolean); override;
|
||||||
|
procedure WriteAsmList;override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TWASM32InstrWriter }
|
{ TWASM32InstrWriter }
|
||||||
@ -54,12 +59,57 @@ implementation
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
cutils,
|
cutils,
|
||||||
finput,
|
fmodule,finput,
|
||||||
cpubase;
|
cpubase;
|
||||||
|
|
||||||
{ TLLVMMachineCodePlaygroundAssembler }
|
{ TLLVMMachineCodePlaygroundAssembler }
|
||||||
|
|
||||||
|
|
||||||
|
procedure TLLVMMachineCodePlaygroundAssembler.WriteProcDef(pd: tprocdef);
|
||||||
|
begin
|
||||||
|
if not assigned(tcpuprocdef(pd).exprasmlist) and
|
||||||
|
not(po_abstractmethod in pd.procoptions) and
|
||||||
|
(pd.proctypeoption in [potype_unitinit,potype_unitfinalize]) then
|
||||||
|
exit;
|
||||||
|
|
||||||
|
writer.AsmWriteLn(asminfo^.comment+'WriteProcDef('+pd.mangledname+')');
|
||||||
|
WriteTree(tcpuprocdef(pd).exprasmlist);
|
||||||
|
writer.AsmWriteLn(asminfo^.comment+'WriteProcDef('+pd.mangledname+') done');
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TLLVMMachineCodePlaygroundAssembler.WriteSymtableProcdefs(st: TSymtable);
|
||||||
|
var
|
||||||
|
i : longint;
|
||||||
|
def : tdef;
|
||||||
|
begin
|
||||||
|
if not assigned(st) then
|
||||||
|
exit;
|
||||||
|
for i:=0 to st.DefList.Count-1 do
|
||||||
|
begin
|
||||||
|
def:=tdef(st.DefList[i]);
|
||||||
|
case def.typ of
|
||||||
|
procdef :
|
||||||
|
begin
|
||||||
|
{ methods are also in the static/globalsymtable of the unit
|
||||||
|
-> make sure they are only written for the objectdefs that
|
||||||
|
own them }
|
||||||
|
if (not(st.symtabletype in [staticsymtable,globalsymtable]) or
|
||||||
|
(def.owner=st)) and
|
||||||
|
not(df_generic in def.defoptions) then
|
||||||
|
begin
|
||||||
|
WriteProcDef(tprocdef(def));
|
||||||
|
if assigned(tprocdef(def).localst) then
|
||||||
|
WriteSymtableProcdefs(tprocdef(def).localst);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
else
|
||||||
|
;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TLLVMMachineCodePlaygroundAssembler.sectionname(atype: TAsmSectiontype; const aname: string; aorder: TAsmSectionOrder): string;
|
function TLLVMMachineCodePlaygroundAssembler.sectionname(atype: TAsmSectiontype; const aname: string; aorder: TAsmSectionOrder): string;
|
||||||
begin
|
begin
|
||||||
Result:=inherited sectionname(atype, aname, aorder)+',"",@';
|
Result:=inherited sectionname(atype, aname, aorder)+',"",@';
|
||||||
@ -73,6 +123,15 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TLLVMMachineCodePlaygroundAssembler.WriteAsmList;
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
{ print all global procedures/functions }
|
||||||
|
WriteSymtableProcdefs(current_module.globalsymtable);
|
||||||
|
WriteSymtableProcdefs(current_module.localsymtable);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TWASM32InstrWriter }
|
{ TWASM32InstrWriter }
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user