r334531 - [AArch64] Support reserving x20 register

Petr Hosek via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 12 13:00:50 PDT 2018


Author: phosek
Date: Tue Jun 12 13:00:50 2018
New Revision: 334531

URL: http://llvm.org/viewvc/llvm-project?rev=334531&view=rev
Log:
[AArch64] Support reserving x20 register

Register x20 is a callee-saved register which may be used for other
purposes in certain contexts, for example to hold special variables
within the kernel. This change adds support for reserving this register
both to frontend and backend to make this register usable for these
purposes.

Differential Revision: https://reviews.llvm.org/D46552

Added:
    cfe/trunk/test/Driver/aarch64-fixed-x20.c
Modified:
    cfe/trunk/docs/ClangCommandLineReference.rst
    cfe/trunk/include/clang/Driver/Options.td
    cfe/trunk/lib/Driver/ToolChains/Arch/AArch64.cpp

Modified: cfe/trunk/docs/ClangCommandLineReference.rst
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangCommandLineReference.rst?rev=334531&r1=334530&r2=334531&view=diff
==============================================================================
--- cfe/trunk/docs/ClangCommandLineReference.rst (original)
+++ cfe/trunk/docs/ClangCommandLineReference.rst Tue Jun 12 13:00:50 2018
@@ -2296,6 +2296,10 @@ AARCH64
 
 Reserve the x18 register (AArch64 only)
 
+.. option:: -ffixed-x20
+
+Reserve the x20 register (AArch64 only)
+
 .. option:: -mfix-cortex-a53-835769, -mno-fix-cortex-a53-835769
 
 Workaround Cortex-A53 erratum 835769 (AArch64 only)

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=334531&r1=334530&r2=334531&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Jun 12 13:00:50 2018
@@ -2004,6 +2004,8 @@ def mno_fix_cortex_a53_835769 : Flag<["-
   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 ffixed_x20 : Flag<["-"], "ffixed-x20">, Group<m_aarch64_Features_Group>,
+  HelpText<"Reserve the x20 register (AArch64 only)">;
 
 def msimd128 : Flag<["-"], "msimd128">, Group<m_wasm_Features_Group>;
 def mno_simd128 : Flag<["-"], "mno-simd128">, Group<m_wasm_Features_Group>;

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/AArch64.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/AArch64.cpp?rev=334531&r1=334530&r2=334531&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Arch/AArch64.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/AArch64.cpp Tue Jun 12 13:00:50 2018
@@ -198,6 +198,9 @@ void aarch64::getAArch64TargetFeatures(c
   if (Args.hasArg(options::OPT_ffixed_x18))
     Features.push_back("+reserve-x18");
 
+  if (Args.hasArg(options::OPT_ffixed_x20))
+    Features.push_back("+reserve-x20");
+
   if (Args.hasArg(options::OPT_mno_neg_immediates))
     Features.push_back("+no-neg-immediates");
 }

Added: cfe/trunk/test/Driver/aarch64-fixed-x20.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/aarch64-fixed-x20.c?rev=334531&view=auto
==============================================================================
--- cfe/trunk/test/Driver/aarch64-fixed-x20.c (added)
+++ cfe/trunk/test/Driver/aarch64-fixed-x20.c Tue Jun 12 13:00:50 2018
@@ -0,0 +1,4 @@
+// RUN: %clang -target aarch64-none-gnu -ffixed-x20 -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-FIXED-X20 < %t %s
+
+// CHECK-FIXED-X20: "-target-feature" "+reserve-x20"




More information about the cfe-commits mailing list