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

View File

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