Author: trong
Date: Wed Sep 12 16:45:04 2018
New Revision: 342100

URL: http://llvm.org/viewvc/llvm-project?rev=342100&view=rev
Log:
[AArch64] Support reserving x1-7 registers.

Summary: Reserving registers x1-7 is used to support CONFIG_ARM64_LSE_ATOMICS 
in Linux kernel. This change adds support for reserving registers x1 through x7.

Reviewers: javed.absar, efriedma, nickdesaulniers, srhines, phosek

Reviewed By: nickdesaulniers

Subscribers: manojgupta, jfb, cfe-commits, kristof.beyls

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

Added:
    cfe/trunk/test/Driver/aarch64-fixed-x-register.c
Removed:
    cfe/trunk/test/Driver/aarch64-fixed-x18.c
    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=342100&r1=342099&r2=342100&view=diff
==============================================================================
--- cfe/trunk/docs/ClangCommandLineReference.rst (original)
+++ cfe/trunk/docs/ClangCommandLineReference.rst Wed Sep 12 16:45:04 2018
@@ -2298,6 +2298,34 @@ The thread model to use, e.g. posix, sin
 
 AARCH64
 -------
+.. option:: -ffixed-x1
+
+Reserve the x1 register (AArch64 only)
+
+.. option:: -ffixed-x2
+
+Reserve the x2 register (AArch64 only)
+
+.. option:: -ffixed-x3
+
+Reserve the x3 register (AArch64 only)
+
+.. option:: -ffixed-x4
+
+Reserve the x4 register (AArch64 only)
+
+.. option:: -ffixed-x5
+
+Reserve the x5 register (AArch64 only)
+
+.. option:: -ffixed-x6
+
+Reserve the x6 register (AArch64 only)
+
+.. option:: -ffixed-x7
+
+Reserve the x7 register (AArch64 only)
+
 .. option:: -ffixed-x18
 
 Reserve the x18 register (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=342100&r1=342099&r2=342100&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Sep 12 16:45:04 2018
@@ -2050,10 +2050,9 @@ 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 ffixed_x20 : Flag<["-"], "ffixed-x20">, Group<m_aarch64_Features_Group>,
-  HelpText<"Reserve the x20 register (AArch64 only)">;
+foreach i = {1-7,18,20} in
+  def ffixed_x#i : Flag<["-"], "ffixed-x"#i>, Group<m_aarch64_Features_Group>,
+    HelpText<"Reserve the "#i#" register (AArch64 only)">;
 
 def msign_return_address : Joined<["-"], "msign-return-address=">,
   Flags<[CC1Option]>, Group<m_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=342100&r1=342099&r2=342100&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Arch/AArch64.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/AArch64.cpp Wed Sep 12 16:45:04 2018
@@ -198,6 +198,27 @@ void aarch64::getAArch64TargetFeatures(c
     if (A->getOption().matches(options::OPT_mno_unaligned_access))
       Features.push_back("+strict-align");
 
+  if (Args.hasArg(options::OPT_ffixed_x1))
+    Features.push_back("+reserve-x1");
+
+  if (Args.hasArg(options::OPT_ffixed_x2))
+    Features.push_back("+reserve-x2");
+
+  if (Args.hasArg(options::OPT_ffixed_x3))
+    Features.push_back("+reserve-x3");
+
+  if (Args.hasArg(options::OPT_ffixed_x4))
+    Features.push_back("+reserve-x4");
+
+  if (Args.hasArg(options::OPT_ffixed_x5))
+    Features.push_back("+reserve-x5");
+
+  if (Args.hasArg(options::OPT_ffixed_x6))
+    Features.push_back("+reserve-x6");
+
+  if (Args.hasArg(options::OPT_ffixed_x7))
+    Features.push_back("+reserve-x7");
+
   if (Args.hasArg(options::OPT_ffixed_x18))
     Features.push_back("+reserve-x18");
 

Added: cfe/trunk/test/Driver/aarch64-fixed-x-register.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/aarch64-fixed-x-register.c?rev=342100&view=auto
==============================================================================
--- cfe/trunk/test/Driver/aarch64-fixed-x-register.c (added)
+++ cfe/trunk/test/Driver/aarch64-fixed-x-register.c Wed Sep 12 16:45:04 2018
@@ -0,0 +1,71 @@
+// RUN: %clang -target aarch64-none-gnu -ffixed-x1 -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-FIXED-X1 < %t %s
+// CHECK-FIXED-X1: "-target-feature" "+reserve-x1"
+
+// RUN: %clang -target aarch64-none-gnu -ffixed-x2 -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-FIXED-X2 < %t %s
+// CHECK-FIXED-X2: "-target-feature" "+reserve-x2"
+
+// RUN: %clang -target aarch64-none-gnu -ffixed-x3 -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-FIXED-X3 < %t %s
+// CHECK-FIXED-X3: "-target-feature" "+reserve-x3"
+
+// RUN: %clang -target aarch64-none-gnu -ffixed-x4 -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-FIXED-X4 < %t %s
+// CHECK-FIXED-X4: "-target-feature" "+reserve-x4"
+
+// RUN: %clang -target aarch64-none-gnu -ffixed-x5 -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-FIXED-X5 < %t %s
+// CHECK-FIXED-X5: "-target-feature" "+reserve-x5"
+
+// RUN: %clang -target aarch64-none-gnu -ffixed-x6 -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-FIXED-X6 < %t %s
+// CHECK-FIXED-X6: "-target-feature" "+reserve-x6"
+
+// RUN: %clang -target aarch64-none-gnu -ffixed-x7 -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-FIXED-X7 < %t %s
+// CHECK-FIXED-X7: "-target-feature" "+reserve-x7"
+
+// RUN: %clang -target aarch64-none-gnu -ffixed-x18 -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-FIXED-X18 < %t %s
+// CHECK-FIXED-X18: "-target-feature" "+reserve-x18"
+
+// 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"
+
+// Test multiple of reserve-x# options together.
+// RUN: %clang -target aarch64-none-gnu \
+// RUN: -ffixed-x1 \
+// RUN: -ffixed-x2 \
+// RUN: -ffixed-x18 \
+// RUN: -### %s 2> %t
+// RUN: FileCheck \
+// RUN: --check-prefix=CHECK-FIXED-X1 \
+// RUN: --check-prefix=CHECK-FIXED-X2 \
+// RUN: --check-prefix=CHECK-FIXED-X18 \
+// RUN: < %t %s
+
+// Test all reserve-x# options together.
+// RUN: %clang -target aarch64-none-gnu \
+// RUN: -ffixed-x1 \
+// RUN: -ffixed-x2 \
+// RUN: -ffixed-x3 \
+// RUN: -ffixed-x4 \
+// RUN: -ffixed-x5 \
+// RUN: -ffixed-x6 \
+// RUN: -ffixed-x7 \
+// RUN: -ffixed-x18 \
+// RUN: -ffixed-x20 \
+// RUN: -### %s 2> %t
+// RUN: FileCheck \
+// RUN: --check-prefix=CHECK-FIXED-X1 \
+// RUN: --check-prefix=CHECK-FIXED-X2 \
+// RUN: --check-prefix=CHECK-FIXED-X3 \
+// RUN: --check-prefix=CHECK-FIXED-X4 \
+// RUN: --check-prefix=CHECK-FIXED-X5 \
+// RUN: --check-prefix=CHECK-FIXED-X6 \
+// RUN: --check-prefix=CHECK-FIXED-X7 \
+// RUN: --check-prefix=CHECK-FIXED-X18 \
+// RUN: --check-prefix=CHECK-FIXED-X20 \
+// RUN: < %t %s

Removed: cfe/trunk/test/Driver/aarch64-fixed-x18.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/aarch64-fixed-x18.c?rev=342099&view=auto
==============================================================================
--- cfe/trunk/test/Driver/aarch64-fixed-x18.c (original)
+++ cfe/trunk/test/Driver/aarch64-fixed-x18.c (removed)
@@ -1,4 +0,0 @@
-// RUN: %clang -target aarch64-none-gnu -ffixed-x18 -### %s 2> %t
-// RUN: FileCheck --check-prefix=CHECK-FIXED-X18 < %t %s
-
-// CHECK-FIXED-X18: "-target-feature" "+reserve-x18"

Removed: cfe/trunk/test/Driver/aarch64-fixed-x20.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/aarch64-fixed-x20.c?rev=342099&view=auto
==============================================================================
--- cfe/trunk/test/Driver/aarch64-fixed-x20.c (original)
+++ cfe/trunk/test/Driver/aarch64-fixed-x20.c (removed)
@@ -1,4 +0,0 @@
-// 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"


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to