* support for overriding the line ending character in external assembler

writer decorators (for LLVM function-level inline assembly: there
    newline has to be replaced by the character sequence '\0A')

git-svn-id: trunk@34854 -
This commit is contained in:
Jonas Maebe 2016-11-09 19:51:27 +00:00
parent 20a152d4e9
commit 646385e966
2 changed files with 22 additions and 9 deletions

View File

@ -68,6 +68,7 @@ interface
function LinePrefix: AnsiString; function LinePrefix: AnsiString;
function LinePostfix: AnsiString; function LinePostfix: AnsiString;
function LineFilter(const s: AnsiString): AnsiString; function LineFilter(const s: AnsiString): AnsiString;
function LineEnding(const deflineending: ShortString): ShortString;
end; end;
TExternalAssemblerOutputFile=class TExternalAssemblerOutputFile=class
@ -569,23 +570,28 @@ Implementation
Procedure TExternalAssemblerOutputFile.AsmLn; Procedure TExternalAssemblerOutputFile.AsmLn;
var var
newline: pshortstring; newline: pshortstring;
newlineres: shortstring;
index: longint;
begin begin
MaybeAddLinePostfix; MaybeAddLinePostfix;
if OutCnt>=AsmOutSize-2 then
AsmFlush;
if (cs_link_on_target in current_settings.globalswitches) then if (cs_link_on_target in current_settings.globalswitches) then
newline:=@target_info.newline newline:=@target_info.newline
else else
newline:=@source_info.newline; newline:=@source_info.newline;
OutBuf[OutCnt]:=newline^[1]; if assigned(decorator) then
inc(OutCnt);
inc(AsmSize);
if length(newline^)>1 then
begin begin
OutBuf[OutCnt]:=newline^[2]; newlineres:=decorator.LineEnding(newline^);
newline:=@newlineres;
end;
if OutCnt>=AsmOutSize-length(newline^) then
AsmFlush;
index:=1;
repeat
OutBuf[OutCnt]:=newline^[index];
inc(OutCnt); inc(OutCnt);
inc(AsmSize); inc(AsmSize);
end; inc(index);
until index>length(newline^);
end; end;

View File

@ -37,6 +37,7 @@ interface
function LinePrefix: AnsiString; function LinePrefix: AnsiString;
function LinePostfix: AnsiString; function LinePostfix: AnsiString;
function LineFilter(const s: AnsiString): AnsiString; function LineFilter(const s: AnsiString): AnsiString;
function LineEnding(const deflineending: ShortString): ShortString;
end; end;
TLLVMAssember=class(texternalassembler) TLLVMAssember=class(texternalassembler)
@ -176,6 +177,12 @@ implementation
end; end;
function TLLVMModuleInlineAssemblyDecorator.LineEnding(const deflineending: ShortString): ShortString;
begin
result:=deflineending
end;
{****************************************************************************} {****************************************************************************}
{ LLVM Instruction writer } { LLVM Instruction writer }
{****************************************************************************} {****************************************************************************}