r227062 - Allows Clang to use LLVM's fixes-x18 option

Renato Golin renato.golin at linaro.org
Sun Jan 25 15:17:48 PST 2015


Author: rengolin
Date: Sun Jan 25 17:17:48 2015
New Revision: 227062

URL: http://llvm.org/viewvc/llvm-project?rev=227062&view=rev
Log:
Allows Clang to use LLVM's fixes-x18 option

This patch allows clang to have llvm reserve the x18
platform register on AArch64. FreeBSD will use this in the kernel for
per-cpu data but has no need to reserve this register in userland so
will need this flag to reserve it.

This uses llvm r226664 to allow this register to be reserved.

Patch by Andrew Turner.

Added:
    cfe/trunk/test/Driver/aarch64-fixed-x18.c
Modified:
    cfe/trunk/include/clang/Driver/Options.td
    cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=227062&r1=227061&r2=227062&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Sun Jan 25 17:17:48 2015
@@ -1218,6 +1218,8 @@ def mfix_cortex_a53_835769 : Flag<["-"],
 def mno_fix_cortex_a53_835769 : Flag<["-"], "mno-fix-cortex-a53-835769">,
   Group<m_aarch64_Features_Group>,
   HelpText<"Don't workaround Cortex-A53 erratum 835769 (AArch64 only)">;
+def ffixed_x18 : Flag<["-"], "ffixed-x18">, Group<m_aarch64_Features_Group>,
+  HelpText<"Reserve the x18 register (AArch64 only)">;
 
 def mvsx : Flag<["-"], "mvsx">, Group<m_ppc_Features_Group>;
 def mno_vsx : Flag<["-"], "mno-vsx">, Group<m_ppc_Features_Group>;

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=227062&r1=227061&r2=227062&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Sun Jan 25 17:17:48 2015
@@ -958,6 +958,11 @@ void Clang::AddAArch64TargetArgs(const A
     if (A->getOption().matches(options::OPT_mno_global_merge))
       CmdArgs.push_back("-mno-global-merge");
   }
+
+  if (Args.hasArg(options::OPT_ffixed_x18)) {
+    CmdArgs.push_back("-backend-option");
+    CmdArgs.push_back("-aarch64-reserve-x18");
+  }
 }
 
 // Get CPU and ABI names. They are not independent

Added: cfe/trunk/test/Driver/aarch64-fixed-x18.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/aarch64-fixed-x18.c?rev=227062&view=auto
==============================================================================
--- cfe/trunk/test/Driver/aarch64-fixed-x18.c (added)
+++ cfe/trunk/test/Driver/aarch64-fixed-x18.c Sun Jan 25 17:17:48 2015
@@ -0,0 +1,4 @@
+// RUN: %clang -target aarch64-none-gnu -ffixed-x18 -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-FIXED-X18 < %t %s
+
+// CHECK-FIXED-X18: "-backend-option" "-aarch64-reserve-x18"





More information about the cfe-commits mailing list