]> granicus.if.org Git - clang/commitdiff
[AArch64] Support reserving x20 register
authorPetr Hosek <phosek@chromium.org>
Tue, 12 Jun 2018 20:00:50 +0000 (20:00 +0000)
committerPetr Hosek <phosek@chromium.org>
Tue, 12 Jun 2018 20:00:50 +0000 (20:00 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334531 91177308-0d34-0410-b5e6-96231b3b80d8

docs/ClangCommandLineReference.rst
include/clang/Driver/Options.td
lib/Driver/ToolChains/Arch/AArch64.cpp
test/Driver/aarch64-fixed-x20.c [new file with mode: 0644]

index 10fc831bdf8d05580994c2c20c8d618e0434056b..264729dd0f141548472bf5b6f504c1c011a373bb 100644 (file)
@@ -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)
index e5aaeb93defc7363796840f5e485598b209f7230..4c04d33466d8b66608a9df7d8870c6102088c17c 100644 (file)
@@ -2004,6 +2004,8 @@ def mno_fix_cortex_a53_835769 : Flag<["-"], "mno-fix-cortex-a53-835769">,
   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>;
index ad04aedd098eb78f0e79a1a510d4108986ca4af4..7bac69687a975a9a2f45f1c781c020898f60e276 100644 (file)
@@ -198,6 +198,9 @@ void aarch64::getAArch64TargetFeatures(const Driver &D, const ArgList &Args,
   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");
 }
diff --git a/test/Driver/aarch64-fixed-x20.c b/test/Driver/aarch64-fixed-x20.c
new file mode 100644 (file)
index 0000000..0be6397
--- /dev/null
@@ -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"