LLVM: separate as_clang_llvm_darwin

The Darwin local label prefix ('L') is different from that on most other
platforms ('.L). While LLVM generally handles that for us, for inline
assembly it's still FPC's job to adhere to the target conventions.
This commit is contained in:
Jonas Maebe 2022-05-14 22:31:12 +02:00
parent 481741c65b
commit 16cb409fbf
5 changed files with 28 additions and 6 deletions

View File

@ -785,7 +785,7 @@ Implementation
{$ifdef hasunix}
DoPipe:=(cs_asm_pipe in current_settings.globalswitches) and
(([cs_asm_extern,cs_asm_leave,cs_assemble_on_target] * current_settings.globalswitches) = []) and
((asminfo^.id in [as_gas,as_ggas,as_darwin,as_powerpc_xcoff,as_clang_gas,as_clang_llvm,as_solaris_as,as_clang_asdarwin]));
((asminfo^.id in [as_gas,as_ggas,as_darwin,as_powerpc_xcoff,as_clang_gas,as_clang_llvm,as_clang_llvm_darwin,as_solaris_as,as_clang_asdarwin]));
{$else hasunix}
DoPipe:=false;
{$endif}
@ -985,7 +985,7 @@ Implementation
begin
{$ifdef hasunix}
if DoPipe then
if not(asminfo^.id in [as_clang_gas,as_clang_asdarwin,as_clang_llvm]) then
if not(asminfo^.id in [as_clang_gas,as_clang_asdarwin,as_clang_llvm,as_clang_llvm_darwin]) then
Replace(result,'$ASM','')
else
Replace(result,'$ASM','-')

View File

@ -1753,7 +1753,7 @@ implementation
idtxt : 'CLANG-LLVM';
asmbin : 'clang';
asmcmd: '-x ir $OPT -target $TRIPLET -c -o $OBJ $ASM $EXTRAOPT';
supported_targets : [system_x86_64_linux,system_x86_64_darwin,system_aarch64_darwin,system_aarch64_linux,system_arm_linux];
supported_targets : [system_x86_64_linux,system_aarch64_linux,system_arm_linux];
flags : [af_smartlink_sections,af_llvm];
labelprefix : '.L';
labelmaxlen : -1;
@ -1761,6 +1761,21 @@ implementation
dollarsign: '$';
);
as_clang_llvm_darwin_info : tasminfo =
(
id : as_clang_llvm_darwin;
idtxt : 'CLANG-LLVM-DARWIN';
asmbin : 'clang';
asmcmd: '-x ir $OPT -target $TRIPLET -c -o $OBJ $ASM $EXTRAOPT';
supported_targets : [system_x86_64_darwin,system_aarch64_darwin];
flags : [af_smartlink_sections,af_llvm];
labelprefix : 'L';
labelmaxlen : -1;
comment : '; ';
dollarsign: '$';
);
begin
RegisterAssembler(as_clang_llvm_info,TLLVMClangAssember);
RegisterAssembler(as_clang_llvm_darwin_info,TLLVMClangAssember);
end.

View File

@ -4688,7 +4688,10 @@ begin
{ default to clang }
if (option.paratargetasm=as_none) then
begin
option.paratargetasm:=as_clang_llvm;
if not(target_info.system in systems_darwin) then
option.paratargetasm:=as_clang_llvm
else
option.paratargetasm:=as_clang_llvm_darwin;
end;
{$endif llvm}
{ maybe override assembler }
@ -4740,7 +4743,10 @@ begin
begin
Message(option_switch_bin_to_src_assembler);
{$ifdef llvm}
set_target_asm(as_clang_llvm);
if not(target_info.system in systems_darwin) then
set_target_asm(as_clang_llvm)
else
set_target_asm(as_clang_llvm_darwin);
{$else}
set_target_asm(target_info.assemextern);
{$endif}

View File

@ -274,6 +274,7 @@
,as_wasm32_llvm_mc { WebAssembly code assembled by llvm-mc (llvm machine code playground) }
,as_arm_vasm
,as_wasm32_wasm
,as_clang_llvm_darwin
);
tlink = (ld_none,

View File

@ -84,7 +84,7 @@ interface
pasminfo = ^tasminfo;
tasminfo = record
id : tasm;
idtxt : string[12];
idtxt : string[17];
asmbin : string[16];
asmcmd : string[121];
supported_targets : set of tsystem;