Browse Source

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.
Jonas Maebe 3 years ago
parent
commit
16cb409fbf
5 changed files with 28 additions and 6 deletions
  1. 2 2
      compiler/assemble.pas
  2. 16 1
      compiler/llvm/agllvm.pas
  3. 8 2
      compiler/options.pas
  4. 1 0
      compiler/systems.inc
  5. 1 1
      compiler/systems.pas

+ 2 - 2
compiler/assemble.pas

@@ -785,7 +785,7 @@ Implementation
 {$ifdef hasunix}
 {$ifdef hasunix}
         DoPipe:=(cs_asm_pipe in current_settings.globalswitches) and
         DoPipe:=(cs_asm_pipe in current_settings.globalswitches) and
                 (([cs_asm_extern,cs_asm_leave,cs_assemble_on_target] * 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}
 {$else hasunix}
         DoPipe:=false;
         DoPipe:=false;
 {$endif}
 {$endif}
@@ -985,7 +985,7 @@ Implementation
          begin
          begin
 {$ifdef hasunix}
 {$ifdef hasunix}
           if DoPipe then
           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','')
               Replace(result,'$ASM','')
             else
             else
               Replace(result,'$ASM','-')
               Replace(result,'$ASM','-')

+ 16 - 1
compiler/llvm/agllvm.pas

@@ -1753,7 +1753,7 @@ implementation
           idtxt  : 'CLANG-LLVM';
           idtxt  : 'CLANG-LLVM';
           asmbin : 'clang';
           asmbin : 'clang';
           asmcmd: '-x ir $OPT -target $TRIPLET -c -o $OBJ $ASM $EXTRAOPT';
           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];
           flags : [af_smartlink_sections,af_llvm];
           labelprefix : '.L';
           labelprefix : '.L';
           labelmaxlen : -1;
           labelmaxlen : -1;
@@ -1761,6 +1761,21 @@ implementation
           dollarsign: '$';
           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
 begin
   RegisterAssembler(as_clang_llvm_info,TLLVMClangAssember);
   RegisterAssembler(as_clang_llvm_info,TLLVMClangAssember);
+  RegisterAssembler(as_clang_llvm_darwin_info,TLLVMClangAssember);
 end.
 end.

+ 8 - 2
compiler/options.pas

@@ -4688,7 +4688,10 @@ begin
   { default to clang }
   { default to clang }
   if (option.paratargetasm=as_none) then
   if (option.paratargetasm=as_none) then
     begin
     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;
     end;
 {$endif llvm}
 {$endif llvm}
   { maybe override assembler }
   { maybe override assembler }
@@ -4740,7 +4743,10 @@ begin
    begin
    begin
      Message(option_switch_bin_to_src_assembler);
      Message(option_switch_bin_to_src_assembler);
 {$ifdef llvm}
 {$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}
 {$else}
      set_target_asm(target_info.assemextern);
      set_target_asm(target_info.assemextern);
 {$endif}
 {$endif}

+ 1 - 0
compiler/systems.inc

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

+ 1 - 1
compiler/systems.pas

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