From 9d07e4948f751983de0fce9516d67b4be2f51a68 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Sun, 3 Feb 2019 21:09:54 +0000 Subject: [PATCH] * fix compilation of ARM compiler for LLVM git-svn-id: branches/debug_eh@41210 - --- compiler/Makefile | 6 +++--- compiler/Makefile.fpc | 6 +++--- compiler/arm/aasmcpu.pas | 6 +++--- compiler/arm/cpuinfo.pas | 15 +++++++++++++++ compiler/arm/cpunode.pas | 12 ++++++++---- compiler/fpcdefs.inc | 2 ++ compiler/llvm/agllvm.pas | 4 ++-- compiler/llvm/llvmbase.pas | 9 +++++++-- compiler/options.pas | 2 +- compiler/systems/i_linux.pas | 3 +++ 10 files changed, 47 insertions(+), 18 deletions(-) diff --git a/compiler/Makefile b/compiler/Makefile index 3216d7400c..59d7c610fa 100644 --- a/compiler/Makefile +++ b/compiler/Makefile @@ -513,11 +513,11 @@ endif endif override LOCALOPT+=-d$(CPC_TARGET) -dGDB -dBROWSERLOG ifdef LLVM -ifeq ($(findstring $(PPC_TARGET),x86_64 aarch64),) -$(error The $(PPC_TARGET) architecture is not (yet) support by the FPC/LLVM code generator) +ifeq ($(findstring $(PPC_TARGET),x86_64 aarch64 arm),) +$(error The $(PPC_TARGET) architecture is not (yet) supported by the FPC/LLVM code generator) endif ifeq ($(findstring $(OS_TARGET),darwin iphonesim linux),) -$(error The $(PPC_TARGET) target OS is not (yet) support by the FPC/LLVM code generator) +$(error The $(PPC_TARGET) target OS is not (yet) supported by the FPC/LLVM code generator) endif override LOCALOPT+=-dllvm -Fullvm endif diff --git a/compiler/Makefile.fpc b/compiler/Makefile.fpc index a27284c1af..4376fa415f 100644 --- a/compiler/Makefile.fpc +++ b/compiler/Makefile.fpc @@ -261,12 +261,12 @@ override LOCALOPT+=-d$(CPC_TARGET) -dGDB -dBROWSERLOG #include LLVM define/directory if requested ifdef LLVM -ifeq ($(findstring $(PPC_TARGET),x86_64 aarch64),) -$(error The $(PPC_TARGET) architecture is not (yet) support by the FPC/LLVM code generator) +ifeq ($(findstring $(PPC_TARGET),x86_64 aarch64 arm),) +$(error The $(PPC_TARGET) architecture is not (yet) supported by the FPC/LLVM code generator) endif ifeq ($(findstring $(OS_TARGET),darwin iphonesim linux),) -$(error The $(PPC_TARGET) target OS is not (yet) support by the FPC/LLVM code generator) +$(error The $(PPC_TARGET) target OS is not (yet) supported by the FPC/LLVM code generator) endif override LOCALOPT+=-dllvm -Fullvm diff --git a/compiler/arm/aasmcpu.pas b/compiler/arm/aasmcpu.pas index 75fec354c6..81c10250cc 100644 --- a/compiler/arm/aasmcpu.pas +++ b/compiler/arm/aasmcpu.pas @@ -198,7 +198,7 @@ uses roundingmode : troundingmode; procedure loadshifterop(opidx:longint;const so:tshifterop); procedure loadregset(opidx:longint; regsetregtype: tregistertype; regsetsubregtype: tsubregister; const s:tcpuregisterset; ausermode: boolean=false); - procedure loadconditioncode(opidx:longint;const cond:tasmcond); + procedure loadconditioncode(opidx:longint;const acond:tasmcond); procedure loadmodeflags(opidx:longint;const flags:tcpumodeflags); procedure loadspecialreg(opidx:longint;const areg:tregister; const aflags:tspecialregflags); procedure loadrealconst(opidx:longint;const _value:bestreal); @@ -386,14 +386,14 @@ implementation end; - procedure taicpu.loadconditioncode(opidx:longint;const cond:tasmcond); + procedure taicpu.loadconditioncode(opidx:longint;const acond:tasmcond); begin allocate_oper(opidx+1); with oper[opidx]^ do begin if typ<>top_conditioncode then clearop(opidx); - cc:=cond; + cc:=acond; typ:=top_conditioncode; end; end; diff --git a/compiler/arm/cpuinfo.pas b/compiler/arm/cpuinfo.pas index 8c65a365c0..e594901c0e 100644 --- a/compiler/arm/cpuinfo.pas +++ b/compiler/arm/cpuinfo.pas @@ -71,6 +71,21 @@ Type fpu_vfpv4 ); +Const + fputypestrllvm : array[tfputype] of string[13] = ('', + '', + '', + '', + '', + '', + 'fpu=vfpv2', + 'fpu=vfpv3', + 'fpu=vfpv3-d16', + 'fpu=vfpv4-s16', + 'fpu=vfpv4' + ); + +Type tcontrollertype = (ct_none, diff --git a/compiler/arm/cpunode.pas b/compiler/arm/cpunode.pas index 3995ce992d..c0a519ca9f 100644 --- a/compiler/arm/cpunode.pas +++ b/compiler/arm/cpunode.pas @@ -30,10 +30,14 @@ unit cpunode; uses { generic nodes } ncgbas,ncgld,ncgflw,ncgcnv,ncgmem,ncgcon,ncgcal,ncgset,ncginl,ncgopt,ncgmat,ncgobjc, + { symtable } + symcpu, + aasmdef, { to be able to only parts of the generic code, the processor specific nodes must be included after the generic one (FK) } +{$ifndef llvm} narmadd, narmcal, narmmat, @@ -42,10 +46,10 @@ unit cpunode; narmcnv, narmcon, narmset, - narmmem, - { symtable } - symcpu, - aasmdef + narmmem +{$else} + llvmnode +{$endif} ; diff --git a/compiler/fpcdefs.inc b/compiler/fpcdefs.inc index 9090bf4177..ee556b90ec 100644 --- a/compiler/fpcdefs.inc +++ b/compiler/fpcdefs.inc @@ -318,6 +318,8 @@ } {$ifdef llvm} {$undef SUPPORT_MMX} + {$undef cpuneedsmulhelper} + {$undef cpuneedsdivhelper} {$define cpuhighleveltarget} {$define cpucg64shiftsupport} {$define symansistr} diff --git a/compiler/llvm/agllvm.pas b/compiler/llvm/agllvm.pas index 062b3f99c9..95cb6920fc 100644 --- a/compiler/llvm/agllvm.pas +++ b/compiler/llvm/agllvm.pas @@ -1584,7 +1584,7 @@ implementation idtxt : 'LLVM-LLC'; asmbin : 'llc'; asmcmd: '$OPT -o $OBJ $ASM'; - supported_targets : [system_x86_64_linux,system_x86_64_darwin,system_aarch64_linux]; + supported_targets : [system_x86_64_linux,system_x86_64_darwin,system_aarch64_linux,system_arm_linux]; flags : [af_smartlink_sections]; labelprefix : 'L'; comment : '; '; @@ -1598,7 +1598,7 @@ implementation idtxt : 'LLVM-CLANG'; asmbin : 'clang'; asmcmd: '$OPT -c -o $OBJ $ASM'; - supported_targets : [system_x86_64_linux,system_x86_64_darwin,system_aarch64_linux]; + supported_targets : [system_x86_64_linux,system_x86_64_darwin,system_aarch64_linux,system_arm_linux]; flags : [af_smartlink_sections]; labelprefix : 'L'; comment : '; '; diff --git a/compiler/llvm/llvmbase.pas b/compiler/llvm/llvmbase.pas index 301f451bb7..858fb230a4 100644 --- a/compiler/llvm/llvmbase.pas +++ b/compiler/llvm/llvmbase.pas @@ -111,6 +111,7 @@ implementation systems; {$j-} +{$ifndef arm} const llvmsystemcpu: array[tsystemcpu] of ansistring = ('unknown', @@ -135,6 +136,7 @@ implementation 'riscv32', 'riscv64' ); +{$endif} function llvm_target_name: ansistring; begin @@ -154,7 +156,7 @@ implementation llvm_target_name:=llvm_target_name+'-ios'+iPhoneOSVersionMin; end else if target_info.system in (systems_linux+systems_android) then - llvm_target_name:=llvm_target_name+'-unknown-linux-gnu' + llvm_target_name:=llvm_target_name+'-unknown-linux' else if target_info.system in systems_windows then begin { WinCE isn't supported (yet) by llvm, but if/when added this is @@ -191,7 +193,10 @@ implementation llvm_target_name:=llvm_target_name+'-android' } else llvm_target_name:=llvm_target_name+'-gnueabi'; -{$endif FPC_ARM_HF} +{$else} + if target_info.system in systems_linux then + llvm_target_name:=llvm_target_name+'-gnu'; +{$endif} end; end. diff --git a/compiler/options.pas b/compiler/options.pas index ec8067a36d..980cd94299 100644 --- a/compiler/options.pas +++ b/compiler/options.pas @@ -4386,7 +4386,7 @@ begin end; {$endif defined(i386) or defined(x86_64)} -{$if defined(arm)} +{$if defined(arm) and not defined(llvm)} { it is determined during system unit compilation if clz is used for bsf or not, this is not perfect but the current implementation bsf/bsr does not allow another solution } diff --git a/compiler/systems/i_linux.pas b/compiler/systems/i_linux.pas index b4f6713463..fb34da7644 100644 --- a/compiler/systems/i_linux.pas +++ b/compiler/systems/i_linux.pas @@ -597,6 +597,9 @@ unit i_linux; {$ifdef tls_threadvars} tf_section_threadvars, {$endif tls_threadvars} +{$ifdef llvm} + tf_use_psabieh, +{$endif llvm} tf_smartlink_sections,tf_pic_uses_got, tf_has_winlike_resources]; cpu : cpu_arm;