Index: docs/UsersManual.rst =================================================================== --- docs/UsersManual.rst +++ docs/UsersManual.rst @@ -1188,7 +1188,8 @@ Generate code which only uses the general purpose registers. This option restricts the generated code to use general registers - only. This only applies to the AArch64 architecture. + only but does not restrict the assembler. This only applies to the + AArch64 architecture. .. option:: -mcompact-branches=[values] Index: lib/Driver/Tools.cpp =================================================================== --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -2623,9 +2623,33 @@ D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args); if (Args.getLastArg(options::OPT_mgeneral_regs_only)) { + // Find the last of each feature. + llvm::StringMap LastOpt; + for (unsigned I = 0, N = Features.size(); I < N; ++I) { + StringRef Name = Features[I]; + assert(Name[0] == '-' || Name[0] == '+'); + LastOpt[Name.drop_front(1)] = I; + } + + llvm::StringMap::iterator I = LastOpt.find("neon"); + if (I != LastOpt.end() && Features[I->second] == "+neon") + Features.push_back("+neonasm"); + + I = LastOpt.find("crypto"); + if (I != LastOpt.end() && Features[I->second] == "+crypto") + Features.push_back("+cryptoasm"); + + I = LastOpt.find("fp-armv8"); + if (I != LastOpt.end() && Features[I->second] == "+fp-armv8") + Features.push_back("+fp-armv8asm"); + + I = LastOpt.find("fullfp16"); + if (I != LastOpt.end() && Features[I->second] == "+fullfp16") + Features.push_back("+fullfp16asm"); + Features.push_back("-fp-armv8"); - Features.push_back("-crypto"); Features.push_back("-neon"); + Features.push_back("-crypto"); } // En/disable crc Index: test/Driver/aarch64-mgeneral_regs_only.c =================================================================== --- test/Driver/aarch64-mgeneral_regs_only.c +++ test/Driver/aarch64-mgeneral_regs_only.c @@ -4,6 +4,18 @@ // RUN: | FileCheck --check-prefix=CHECK-NO-FP %s // RUN: %clang -target arm64-linux-eabi -mgeneral-regs-only %s -### 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-NO-FP %s +// RUN: %clang -target aarch64-linux-eabi -mgeneral-regs-only -march=armv8.1a+crypto %s -### 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-FP %s + +// CHECK-NO-FP: "-target-feature" "+neonasm" +// CHECK-NO-FP-NOT: "-target-feature" "+fp-armv8asm" +// CHECK-NO-FP-NOT: "-target-feature" "+cryptoasm" // CHECK-NO-FP: "-target-feature" "-fp-armv8" -// CHECK-NO-FP: "-target-feature" "-crypto" // CHECK-NO-FP: "-target-feature" "-neon" +// CHECK-NO-FP: "-target-feature" "-crypto" + +// CHECK-FP: "-target-feature" "+neonasm" +// CHECK-FP: "-target-feature" "+cryptoasm" +// CHECK-FP: "-target-feature" "-fp-armv8" +// CHECK-FP: "-target-feature" "-neon" +// CHECK-FP: "-target-feature" "-crypto"