[PATCH] D48581: [AArch64] Support reserving x1-7 registers.
trong updated this revision to Diff 165132. trong added a comment. Added test cases for combination of -ffixed flags. https://reviews.llvm.org/D48581 Files: docs/ClangCommandLineReference.rst include/clang/Driver/Options.td lib/Driver/ToolChains/Arch/AArch64.cpp test/Driver/aarch64-fixed-x-register.c test/Driver/aarch64-fixed-x18.c test/Driver/aarch64-fixed-x20.c Index: test/Driver/aarch64-fixed-x20.c === --- test/Driver/aarch64-fixed-x20.c +++ /dev/null @@ -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" Index: test/Driver/aarch64-fixed-x18.c === --- test/Driver/aarch64-fixed-x18.c +++ /dev/null @@ -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" Index: test/Driver/aarch64-fixed-x-register.c === --- /dev/null +++ test/Driver/aarch64-fixed-x-register.c @@ -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 Index: lib/Driver/ToolChains/Arch/AArch64.cpp === --- lib/Driver/ToolChains/Arch/AArch64.cpp +++ lib/Driver/ToolChains/Arch/AArch64.cpp @@ -198,6 +198,27 @@ 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"); Index: include/clang/Driver/Op
[PATCH] D48581: [AArch64] Support reserving x1-7 registers.
This revision was automatically updated to reflect the committed changes. Closed by commit rL342100: [AArch64] Support reserving x1-7 registers. (authored by trong, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D48581?vs=165132&id=165179#toc Repository: rL LLVM https://reviews.llvm.org/D48581 Files: cfe/trunk/docs/ClangCommandLineReference.rst cfe/trunk/include/clang/Driver/Options.td cfe/trunk/lib/Driver/ToolChains/Arch/AArch64.cpp cfe/trunk/test/Driver/aarch64-fixed-x-register.c cfe/trunk/test/Driver/aarch64-fixed-x18.c cfe/trunk/test/Driver/aarch64-fixed-x20.c Index: cfe/trunk/docs/ClangCommandLineReference.rst === --- cfe/trunk/docs/ClangCommandLineReference.rst +++ cfe/trunk/docs/ClangCommandLineReference.rst @@ -2298,6 +2298,34 @@ 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) Index: cfe/trunk/include/clang/Driver/Options.td === --- cfe/trunk/include/clang/Driver/Options.td +++ cfe/trunk/include/clang/Driver/Options.td @@ -2050,10 +2050,9 @@ def mno_fix_cortex_a53_835769 : Flag<["-"], "mno-fix-cortex-a53-835769">, Group, HelpText<"Don't workaround Cortex-A53 erratum 835769 (AArch64 only)">; -def ffixed_x18 : Flag<["-"], "ffixed-x18">, Group, - HelpText<"Reserve the x18 register (AArch64 only)">; -def ffixed_x20 : Flag<["-"], "ffixed-x20">, Group, - HelpText<"Reserve the x20 register (AArch64 only)">; +foreach i = {1-7,18,20} in + def ffixed_x#i : Flag<["-"], "ffixed-x"#i>, Group, +HelpText<"Reserve the "#i#" register (AArch64 only)">; def msign_return_address : Joined<["-"], "msign-return-address=">, Flags<[CC1Option]>, Group, Index: cfe/trunk/test/Driver/aarch64-fixed-x-register.c === --- cfe/trunk/test/Driver/aarch64-fixed-x-register.c +++ cfe/trunk/test/Driver/aarch64-fixed-x-register.c @@ -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 \ +//
[PATCH] D52399: [AArch64] Support adding X[8-15, 18] registers as CSRs.
trong created this revision. trong added reviewers: srhines, nickdesaulniers. Herald added a reviewer: javed.absar. Herald added subscribers: jfb, kristof.beyls. Making X[8-15,18] registers call-saved is used to support CONFIG_ARM64_LSE_ATOMICS in Linux kernel. Signed-off-by: Tri Vo Repository: rC Clang https://reviews.llvm.org/D52399 Files: docs/ClangCommandLineReference.rst include/clang/Driver/Options.td lib/Driver/ToolChains/Arch/AArch64.cpp test/Driver/aarch64-call-saved-x-register.c Index: test/Driver/aarch64-call-saved-x-register.c === --- /dev/null +++ test/Driver/aarch64-call-saved-x-register.c @@ -0,0 +1,58 @@ +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x8 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X8 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x9 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X9 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x10 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X10 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x11 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X11 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x12 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X12 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x13 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X13 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x14 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X14 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x15 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X15 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x18 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X18 %s + +// Test all call-saved-x# options together. +// RUN: %clang -target aarch64-none-gnu \ +// RUN: -fcall-saved-x8 \ +// RUN: -fcall-saved-x9 \ +// RUN: -fcall-saved-x10 \ +// RUN: -fcall-saved-x11 \ +// RUN: -fcall-saved-x12 \ +// RUN: -fcall-saved-x13 \ +// RUN: -fcall-saved-x14 \ +// RUN: -fcall-saved-x15 \ +// RUN: -fcall-saved-x18 \ +// RUN: -### %s 2>&1 | FileCheck %s \ +// RUN: --check-prefix=CHECK-CALL-SAVED-X8 \ +// RUN: --check-prefix=CHECK-CALL-SAVED-X9 \ +// RUN: --check-prefix=CHECK-CALL-SAVED-X10 \ +// RUN: --check-prefix=CHECK-CALL-SAVED-X11 \ +// RUN: --check-prefix=CHECK-CALL-SAVED-X12 \ +// RUN: --check-prefix=CHECK-CALL-SAVED-X13 \ +// RUN: --check-prefix=CHECK-CALL-SAVED-X14 \ +// RUN: --check-prefix=CHECK-CALL-SAVED-X15 \ +// RUN: --check-prefix=CHECK-CALL-SAVED-X18 + +// CHECK-CALL-SAVED-X8: "-target-feature" "+call-saved-x8" +// CHECK-CALL-SAVED-X9: "-target-feature" "+call-saved-x9" +// CHECK-CALL-SAVED-X10: "-target-feature" "+call-saved-x10" +// CHECK-CALL-SAVED-X11: "-target-feature" "+call-saved-x11" +// CHECK-CALL-SAVED-X12: "-target-feature" "+call-saved-x12" +// CHECK-CALL-SAVED-X13: "-target-feature" "+call-saved-x13" +// CHECK-CALL-SAVED-X14: "-target-feature" "+call-saved-x14" +// CHECK-CALL-SAVED-X15: "-target-feature" "+call-saved-x15" +// CHECK-CALL-SAVED-X18: "-target-feature" "+call-saved-x18" Index: lib/Driver/ToolChains/Arch/AArch64.cpp === --- lib/Driver/ToolChains/Arch/AArch64.cpp +++ lib/Driver/ToolChains/Arch/AArch64.cpp @@ -225,6 +225,33 @@ if (Args.hasArg(options::OPT_ffixed_x20)) Features.push_back("+reserve-x20"); + if (Args.hasArg(options::OPT_fcall_saved_x8)) +Features.push_back("+call-saved-x8"); + + if (Args.hasArg(options::OPT_fcall_saved_x9)) +Features.push_back("+call-saved-x9"); + + if (Args.hasArg(options::OPT_fcall_saved_x10)) +Features.push_back("+call-saved-x10"); + + if (Args.hasArg(options::OPT_fcall_saved_x11)) +Features.push_back("+call-saved-x11"); + + if (Args.hasArg(options::OPT_fcall_saved_x12)) +Features.push_back("+call-saved-x12"); + + if (Args.hasArg(options::OPT_fcall_saved_x13)) +Features.push_back("+call-saved-x13"); + + if (Args.hasArg(options::OPT_fcall_saved_x14)) +Features.push_back("+call-saved-x14"); + + if (Args.hasArg(options::OPT_fcall_saved_x15)) +Features.push_back("+call-saved-x15"); + + if (Args.hasArg(options::OPT_fcall_saved_x18)) +Features.push_back("+call-saved-x18"); + if (Args.hasArg(options::OPT_mno_neg_immediates)) Features.push_back("+no-neg-immediates"); } Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -2054,6 +2054,10 @@ def ffixed_x#i : Flag<["-"], "ffixed-x"#i>, Group, HelpText<"Reserve the "#i#" register (AArch64 only)">; +foreach i = {8-15,18} in + def fcall_saved_x#i : Flag<["-"], "fcall-saved-x"#i>, Group, +HelpText<"Make the x"#
[PATCH] D52399: [AArch64] Support adding X[8-15, 18] registers as CSRs.
trong updated this revision to Diff 166722. trong added a comment. - Added test case for using -fcall-saved-x18 and -ffixed-x18 together. Repository: rC Clang https://reviews.llvm.org/D52399 Files: docs/ClangCommandLineReference.rst include/clang/Driver/Options.td lib/Driver/ToolChains/Arch/AArch64.cpp test/Driver/aarch64-call-saved-x-register.c test/Driver/aarch64-fixed-call-saved-x-register.c Index: test/Driver/aarch64-fixed-call-saved-x-register.c === --- /dev/null +++ test/Driver/aarch64-fixed-call-saved-x-register.c @@ -0,0 +1,8 @@ +// Check that -ffixed and -fcall-saved flags work correctly together. +// RUN: %clang -target aarch64-none-gnu \ +// RUN: -ffixed-x18 \ +// RUN: -fcall-saved-x18 \ +// RUN: -### %s 2>&1 | FileCheck %s + +// CHECK: "-target-feature" "+reserve-x18" +// CHECK: "-target-feature" "+call-saved-x18" Index: test/Driver/aarch64-call-saved-x-register.c === --- /dev/null +++ test/Driver/aarch64-call-saved-x-register.c @@ -0,0 +1,58 @@ +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x8 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X8 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x9 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X9 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x10 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X10 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x11 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X11 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x12 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X12 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x13 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X13 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x14 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X14 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x15 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X15 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x18 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X18 %s + +// Test all call-saved-x# options together. +// RUN: %clang -target aarch64-none-gnu \ +// RUN: -fcall-saved-x8 \ +// RUN: -fcall-saved-x9 \ +// RUN: -fcall-saved-x10 \ +// RUN: -fcall-saved-x11 \ +// RUN: -fcall-saved-x12 \ +// RUN: -fcall-saved-x13 \ +// RUN: -fcall-saved-x14 \ +// RUN: -fcall-saved-x15 \ +// RUN: -fcall-saved-x18 \ +// RUN: -### %s 2>&1 | FileCheck %s \ +// RUN: --check-prefix=CHECK-CALL-SAVED-X8 \ +// RUN: --check-prefix=CHECK-CALL-SAVED-X9 \ +// RUN: --check-prefix=CHECK-CALL-SAVED-X10 \ +// RUN: --check-prefix=CHECK-CALL-SAVED-X11 \ +// RUN: --check-prefix=CHECK-CALL-SAVED-X12 \ +// RUN: --check-prefix=CHECK-CALL-SAVED-X13 \ +// RUN: --check-prefix=CHECK-CALL-SAVED-X14 \ +// RUN: --check-prefix=CHECK-CALL-SAVED-X15 \ +// RUN: --check-prefix=CHECK-CALL-SAVED-X18 + +// CHECK-CALL-SAVED-X8: "-target-feature" "+call-saved-x8" +// CHECK-CALL-SAVED-X9: "-target-feature" "+call-saved-x9" +// CHECK-CALL-SAVED-X10: "-target-feature" "+call-saved-x10" +// CHECK-CALL-SAVED-X11: "-target-feature" "+call-saved-x11" +// CHECK-CALL-SAVED-X12: "-target-feature" "+call-saved-x12" +// CHECK-CALL-SAVED-X13: "-target-feature" "+call-saved-x13" +// CHECK-CALL-SAVED-X14: "-target-feature" "+call-saved-x14" +// CHECK-CALL-SAVED-X15: "-target-feature" "+call-saved-x15" +// CHECK-CALL-SAVED-X18: "-target-feature" "+call-saved-x18" Index: lib/Driver/ToolChains/Arch/AArch64.cpp === --- lib/Driver/ToolChains/Arch/AArch64.cpp +++ lib/Driver/ToolChains/Arch/AArch64.cpp @@ -225,6 +225,33 @@ if (Args.hasArg(options::OPT_ffixed_x20)) Features.push_back("+reserve-x20"); + if (Args.hasArg(options::OPT_fcall_saved_x8)) +Features.push_back("+call-saved-x8"); + + if (Args.hasArg(options::OPT_fcall_saved_x9)) +Features.push_back("+call-saved-x9"); + + if (Args.hasArg(options::OPT_fcall_saved_x10)) +Features.push_back("+call-saved-x10"); + + if (Args.hasArg(options::OPT_fcall_saved_x11)) +Features.push_back("+call-saved-x11"); + + if (Args.hasArg(options::OPT_fcall_saved_x12)) +Features.push_back("+call-saved-x12"); + + if (Args.hasArg(options::OPT_fcall_saved_x13)) +Features.push_back("+call-saved-x13"); + + if (Args.hasArg(options::OPT_fcall_saved_x14)) +Features.push_back("+call-saved-x14"); + + if (Args.hasArg(options::OPT_fcall_saved_x15)) +Features.push_back("+call-saved-x15"); + + if (Args.hasArg(options::OPT_fcall_saved_x18)) +Features.push_back("+call-saved-x18"); + if (Args.hasArg(options::OPT_mno_neg_immediates)) Features.push_back("+no-neg-immediates"); } Index: include/clang/Drive
[PATCH] D52399: [AArch64] Support adding X[8-15, 18] registers as CSRs.
This revision was automatically updated to reflect the committed changes. Closed by commit rL342990: [AArch64] Support adding X[8-15,18] registers as CSRs. (authored by trong, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM https://reviews.llvm.org/D52399 Files: cfe/trunk/docs/ClangCommandLineReference.rst cfe/trunk/include/clang/Driver/Options.td cfe/trunk/lib/Driver/ToolChains/Arch/AArch64.cpp cfe/trunk/test/Driver/aarch64-call-saved-x-register.c cfe/trunk/test/Driver/aarch64-fixed-call-saved-x-register.c Index: cfe/trunk/docs/ClangCommandLineReference.rst === --- cfe/trunk/docs/ClangCommandLineReference.rst +++ cfe/trunk/docs/ClangCommandLineReference.rst @@ -2334,6 +2334,42 @@ Reserve the x20 register (AArch64 only) +.. option:: -fcall-saved-x8 + +Make the x8 register call-saved (AArch64 only) + +.. option:: -fcall-saved-x9 + +Make the x9 register call-saved (AArch64 only) + +.. option:: -fcall-saved-x10 + +Make the x10 register call-saved (AArch64 only) + +.. option:: -fcall-saved-x11 + +Make the x11 register call-saved (AArch64 only) + +.. option:: -fcall-saved-x12 + +Make the x12 register call-saved (AArch64 only) + +.. option:: -fcall-saved-x13 + +Make the x13 register call-saved (AArch64 only) + +.. option:: -fcall-saved-x14 + +Make the x14 register call-saved (AArch64 only) + +.. option:: -fcall-saved-x15 + +Make the x15 register call-saved (AArch64 only) + +.. option:: -fcall-saved-x18 + +Make the x18 register call-saved (AArch64 only) + .. option:: -mfix-cortex-a53-835769, -mno-fix-cortex-a53-835769 Workaround Cortex-A53 erratum 835769 (AArch64 only) Index: cfe/trunk/include/clang/Driver/Options.td === --- cfe/trunk/include/clang/Driver/Options.td +++ cfe/trunk/include/clang/Driver/Options.td @@ -2054,6 +2054,10 @@ def ffixed_x#i : Flag<["-"], "ffixed-x"#i>, Group, HelpText<"Reserve the "#i#" register (AArch64 only)">; +foreach i = {8-15,18} in + def fcall_saved_x#i : Flag<["-"], "fcall-saved-x"#i>, Group, +HelpText<"Make the x"#i#" register call-saved (AArch64 only)">; + def msign_return_address : Joined<["-"], "msign-return-address=">, Flags<[CC1Option]>, Group, HelpText<"Select return address signing scope">, Values<"none,all,non-leaf">; Index: cfe/trunk/test/Driver/aarch64-fixed-call-saved-x-register.c === --- cfe/trunk/test/Driver/aarch64-fixed-call-saved-x-register.c +++ cfe/trunk/test/Driver/aarch64-fixed-call-saved-x-register.c @@ -0,0 +1,8 @@ +// Check that -ffixed and -fcall-saved flags work correctly together. +// RUN: %clang -target aarch64-none-gnu \ +// RUN: -ffixed-x18 \ +// RUN: -fcall-saved-x18 \ +// RUN: -### %s 2>&1 | FileCheck %s + +// CHECK: "-target-feature" "+reserve-x18" +// CHECK: "-target-feature" "+call-saved-x18" Index: cfe/trunk/test/Driver/aarch64-call-saved-x-register.c === --- cfe/trunk/test/Driver/aarch64-call-saved-x-register.c +++ cfe/trunk/test/Driver/aarch64-call-saved-x-register.c @@ -0,0 +1,58 @@ +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x8 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X8 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x9 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X9 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x10 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X10 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x11 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X11 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x12 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X12 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x13 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X13 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x14 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X14 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x15 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X15 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x18 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X18 %s + +// Test all call-saved-x# options together. +// RUN: %clang -target aarch64-none-gnu \ +// RUN: -fcall-saved-x8 \ +// RUN: -fcall-saved-x9 \ +// RUN: -fcall-saved-x10 \ +// RUN: -fcall-saved-x11 \ +// RUN: -fcall-saved-x12 \ +// RUN: -fcall-saved-x13 \ +// RUN: -fcall-saved-x14 \ +// RUN: -fcall-saved-x15 \ +// RUN: -fcall-saved-x18 \ +// RUN: -### %s 2>&1 | FileCheck %s \ +// RUN: --check-prefix=CHECK-CALL-SAVED-X8 \ +// RUN: --check-prefix=CHECK-CALL-SAVED-X9 \ +// RUN: --check-prefix=CHECK-CALL-SAVED-X10 \ +// RUN: --check-pre
[PATCH] D52399: [AArch64] Support adding X[8-15, 18] registers as CSRs.
This revision was automatically updated to reflect the committed changes. Closed by commit rC342990: [AArch64] Support adding X[8-15,18] registers as CSRs. (authored by trong, committed by ). Changed prior to commit: https://reviews.llvm.org/D52399?vs=166722&id=166940#toc Repository: rC Clang https://reviews.llvm.org/D52399 Files: docs/ClangCommandLineReference.rst include/clang/Driver/Options.td lib/Driver/ToolChains/Arch/AArch64.cpp test/Driver/aarch64-call-saved-x-register.c test/Driver/aarch64-fixed-call-saved-x-register.c Index: docs/ClangCommandLineReference.rst === --- docs/ClangCommandLineReference.rst +++ docs/ClangCommandLineReference.rst @@ -2334,6 +2334,42 @@ Reserve the x20 register (AArch64 only) +.. option:: -fcall-saved-x8 + +Make the x8 register call-saved (AArch64 only) + +.. option:: -fcall-saved-x9 + +Make the x9 register call-saved (AArch64 only) + +.. option:: -fcall-saved-x10 + +Make the x10 register call-saved (AArch64 only) + +.. option:: -fcall-saved-x11 + +Make the x11 register call-saved (AArch64 only) + +.. option:: -fcall-saved-x12 + +Make the x12 register call-saved (AArch64 only) + +.. option:: -fcall-saved-x13 + +Make the x13 register call-saved (AArch64 only) + +.. option:: -fcall-saved-x14 + +Make the x14 register call-saved (AArch64 only) + +.. option:: -fcall-saved-x15 + +Make the x15 register call-saved (AArch64 only) + +.. option:: -fcall-saved-x18 + +Make the x18 register call-saved (AArch64 only) + .. option:: -mfix-cortex-a53-835769, -mno-fix-cortex-a53-835769 Workaround Cortex-A53 erratum 835769 (AArch64 only) Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -2054,6 +2054,10 @@ def ffixed_x#i : Flag<["-"], "ffixed-x"#i>, Group, HelpText<"Reserve the "#i#" register (AArch64 only)">; +foreach i = {8-15,18} in + def fcall_saved_x#i : Flag<["-"], "fcall-saved-x"#i>, Group, +HelpText<"Make the x"#i#" register call-saved (AArch64 only)">; + def msign_return_address : Joined<["-"], "msign-return-address=">, Flags<[CC1Option]>, Group, HelpText<"Select return address signing scope">, Values<"none,all,non-leaf">; Index: test/Driver/aarch64-call-saved-x-register.c === --- test/Driver/aarch64-call-saved-x-register.c +++ test/Driver/aarch64-call-saved-x-register.c @@ -0,0 +1,58 @@ +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x8 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X8 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x9 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X9 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x10 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X10 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x11 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X11 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x12 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X12 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x13 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X13 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x14 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X14 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x15 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X15 %s + +// RUN: %clang -target aarch64-none-gnu -fcall-saved-x18 -### %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-CALL-SAVED-X18 %s + +// Test all call-saved-x# options together. +// RUN: %clang -target aarch64-none-gnu \ +// RUN: -fcall-saved-x8 \ +// RUN: -fcall-saved-x9 \ +// RUN: -fcall-saved-x10 \ +// RUN: -fcall-saved-x11 \ +// RUN: -fcall-saved-x12 \ +// RUN: -fcall-saved-x13 \ +// RUN: -fcall-saved-x14 \ +// RUN: -fcall-saved-x15 \ +// RUN: -fcall-saved-x18 \ +// RUN: -### %s 2>&1 | FileCheck %s \ +// RUN: --check-prefix=CHECK-CALL-SAVED-X8 \ +// RUN: --check-prefix=CHECK-CALL-SAVED-X9 \ +// RUN: --check-prefix=CHECK-CALL-SAVED-X10 \ +// RUN: --check-prefix=CHECK-CALL-SAVED-X11 \ +// RUN: --check-prefix=CHECK-CALL-SAVED-X12 \ +// RUN: --check-prefix=CHECK-CALL-SAVED-X13 \ +// RUN: --check-prefix=CHECK-CALL-SAVED-X14 \ +// RUN: --check-prefix=CHECK-CALL-SAVED-X15 \ +// RUN: --check-prefix=CHECK-CALL-SAVED-X18 + +// CHECK-CALL-SAVED-X8: "-target-feature" "+call-saved-x8" +// CHECK-CALL-SAVED-X9: "-target-feature" "+call-saved-x9" +// CHECK-CALL-SAVED-X10: "-target-feature" "+call-saved-x10" +// CHECK-CALL-SAVED-X11: "-target-feature" "+call-saved-x11" +// CHECK-CALL-SAVED-X12: "-target-feature" "+call-saved-x12" +// CHECK-CALL-SAVED-X13: "-target-feature" "+call-saved-x13" +// CHECK-CALL-SAVED-X14: "-target-featur
[PATCH] D56305: [AArch64] Support reserving arbitrary general purpose registers
trong added inline comments. Herald added a project: LLVM. Comment at: clang/lib/Driver/ToolChains/Arch/AArch64.cpp:318 + if (Args.hasArg(options::OPT_ffixed_x0)) +Features.push_back("+reserve-x0"); phosek wrote: > trong wrote: > > What happens (should happen) if we reserve x0 and compile a function with a > > return value? > Clang throws `error: AArch64 doesn't support function calls if any of the > argument registers is reserved.` as for any other argument register. Yes, if x0 is reserved, it can't be used to pass arguments. But what happens if x0 is used to return a value? For example: ``` int foo() { return 1; } ``` It would be helpful if compiling `foo()` with x0 reserved threw an error. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D56305/new/ https://reviews.llvm.org/D56305 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D56305: [AArch64] Support reserving arbitrary general purpose registers
trong accepted this revision. trong added inline comments. This revision is now accepted and ready to land. Comment at: clang/lib/Driver/ToolChains/Arch/AArch64.cpp:318 + if (Args.hasArg(options::OPT_ffixed_x0)) +Features.push_back("+reserve-x0"); trong wrote: > phosek wrote: > > trong wrote: > > > What happens (should happen) if we reserve x0 and compile a function with > > > a return value? > > Clang throws `error: AArch64 doesn't support function calls if any of the > > argument registers is reserved.` as for any other argument register. > Yes, if x0 is reserved, it can't be used to pass arguments. But what happens > if x0 is used to return a value? For example: > ``` > int foo() { > return 1; > } > ``` > It would be helpful if compiling `foo()` with x0 reserved threw an error. OTOH, [[ https://godbolt.org/z/jWW09Y | gcc ]] doesn't complain, so maybe we're OK here. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D56305/new/ https://reviews.llvm.org/D56305 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits