mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 09:29:26 +02:00
* when generating code for a pure assembler routine with LLVM, instantiate
a code and temp generator for the architectural target instead of for LLVM * write the code for pure assembler routines using a GNU-style external assembler writer for the target, with a decorator to wrap it in LLVM module-level assembly statements git-svn-id: trunk@31633 -
This commit is contained in:
parent
5c69d57674
commit
839482751d
@ -2165,7 +2165,7 @@ Implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function GetExternalAssemblerWithAsmInfoWriter(info: pasminfo; wr: TExternalAssemblerOutputFile): TExternalAssembler;
|
function GetExternalGnuAssemblerWithAsmInfoWriter(info: pasminfo; wr: TExternalAssemblerOutputFile): TExternalAssembler;
|
||||||
var
|
var
|
||||||
asmkind: tasm;
|
asmkind: tasm;
|
||||||
begin
|
begin
|
||||||
|
@ -1115,14 +1115,32 @@ implementation
|
|||||||
var
|
var
|
||||||
hal : tasmlisttype;
|
hal : tasmlisttype;
|
||||||
i: longint;
|
i: longint;
|
||||||
|
a: TExternalAssembler;
|
||||||
|
decorator: TLLVMModuleInlineAssemblyDecorator;
|
||||||
begin
|
begin
|
||||||
WriteExtraHeader;
|
WriteExtraHeader;
|
||||||
|
|
||||||
for hal:=low(TasmlistType) to high(TasmlistType) do
|
for hal:=low(TasmlistType) to high(TasmlistType) do
|
||||||
begin
|
begin
|
||||||
writer.AsmWriteLn(target_asm.comment+'Begin asmlist '+AsmlistTypeStr[hal]);
|
if not assigned(current_asmdata.asmlists[hal]) or
|
||||||
writetree(current_asmdata.asmlists[hal]);
|
current_asmdata.asmlists[hal].Empty then
|
||||||
writer.AsmWriteLn(target_asm.comment+'End asmlist '+AsmlistTypeStr[hal]);
|
continue;
|
||||||
|
writer.AsmWriteLn(asminfo^.comment+'Begin asmlist '+AsmlistTypeStr[hal]);
|
||||||
|
if hal<>al_pure_assembler then
|
||||||
|
writetree(current_asmdata.asmlists[hal])
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
{ write routines using the target-specific external assembler
|
||||||
|
writer, filtered using the LLVM module-level assembly
|
||||||
|
decorator }
|
||||||
|
decorator:=TLLVMModuleInlineAssemblyDecorator.Create;
|
||||||
|
writer.decorator:=decorator;
|
||||||
|
a:=GetExternalGnuAssemblerWithAsmInfoWriter(asminfo,writer);
|
||||||
|
a.WriteTree(current_asmdata.asmlists[hal]);
|
||||||
|
writer.decorator:=nil;
|
||||||
|
decorator.free;
|
||||||
|
end;
|
||||||
|
writer.AsmWriteLn(asminfo^.comment+'End asmlist '+AsmlistTypeStr[hal]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
writer.AsmLn;
|
writer.AsmLn;
|
||||||
|
@ -151,7 +151,8 @@ implementation
|
|||||||
aasmllvm,llvmbase,tgllvm,
|
aasmllvm,llvmbase,tgllvm,
|
||||||
symtable,symllvm,
|
symtable,symllvm,
|
||||||
paramgr,llvmpara,
|
paramgr,llvmpara,
|
||||||
procinfo,cpuinfo,cgobj,cgllvm,cghlcpu;
|
procinfo,cpuinfo,cgobj,cgllvm,cghlcpu,
|
||||||
|
cgcpu,hlcgcpu;
|
||||||
|
|
||||||
const
|
const
|
||||||
topcg2llvmop: array[topcg] of tllvmop =
|
topcg2llvmop: array[topcg] of tllvmop =
|
||||||
@ -1719,8 +1720,19 @@ implementation
|
|||||||
|
|
||||||
procedure create_hlcodegen;
|
procedure create_hlcodegen;
|
||||||
begin
|
begin
|
||||||
hlcg:=thlcgllvm.create;
|
if not assigned(current_procinfo) or
|
||||||
cgllvm.create_codegen
|
not(po_assembler in current_procinfo.procdef.procoptions) then
|
||||||
|
begin
|
||||||
|
tgobjclass:=ttgllvm;
|
||||||
|
hlcg:=thlcgllvm.create;
|
||||||
|
cgllvm.create_codegen
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
tgobjclass:=orgtgclass;
|
||||||
|
hlcgcpu.create_hlcodegen;
|
||||||
|
{ todo: handle/remove chlcgobj }
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
@ -68,6 +68,10 @@ unit tgllvm;
|
|||||||
procedure ungetiftemp(list: TAsmList; const ref: treference); override;
|
procedure ungetiftemp(list: TAsmList; const ref: treference); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
var
|
||||||
|
orgtgclass: ttgobjclass;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
@ -166,5 +170,6 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
orgtgclass:=tgobjclass;
|
||||||
tgobjclass:=ttgllvm;
|
tgobjclass:=ttgllvm;
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user