From f4320ab08da5e4c927ef326c68d5081f5f2a2268 Mon Sep 17 00:00:00 2001 From: Hal Finkel Date: Thu, 28 Mar 2013 08:38:53 +0000 Subject: [PATCH] Add support for gcc-compatible -mmfcrf -mno-mfcrf PPC options gcc provides -mmfcrf and -mno-mfcrf for controlling what we call the mfocrf target feature. Also, PPC is now making use of the static function AddTargetFeature used by the Mips Driver code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178227 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Driver/Options.td | 2 ++ lib/Basic/Targets.cpp | 2 +- lib/Driver/Tools.cpp | 14 ++++++++++---- test/Driver/ppc-features.cpp | 6 ++++++ 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 9de13fb6fb..0a364bb56c 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -832,6 +832,8 @@ def mabi_EQ : Joined<["-"], "mabi=">, Group; def march_EQ : Joined<["-"], "march=">, Group; def maltivec : Flag<["-"], "maltivec">, Alias; def mno_altivec : Flag<["-"], "mno-altivec">, Alias; +def mmfcrf : Flag<["-"], "mmfcrf">, Group; +def mno_mfcrf : Flag<["-"], "mno-mfcrf">, Group; def mqpx : Flag<["-"], "mqpx">, Group; def mno_qpx : Flag<["-"], "mno-qpx">, Group; def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group; diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 09d8be682f..8dc9b20f4c 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -1029,7 +1029,7 @@ void PPCTargetInfo::getDefaultFeatures(llvm::StringMap &Features) const { bool PPCTargetInfo::setFeatureEnabled(llvm::StringMap &Features, StringRef Name, bool Enabled) const { - if (Name == "altivec" || Name == "qpx") { + if (Name == "altivec" || Name == "mfocrf" || Name == "qpx") { Features[Name] = Enabled; return true; } diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index fa3128bbd5..1c455eda4a 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -1097,11 +1097,17 @@ void Clang::AddPPCTargetArgs(const ArgList &Args, } // Allow override of the Altivec feature. - if (Args.hasFlag(options::OPT_fno_altivec, options::OPT_faltivec, false)) { - CmdArgs.push_back("-target-feature"); - CmdArgs.push_back("-altivec"); - } + AddTargetFeature(Args, CmdArgs, + options::OPT_faltivec, options::OPT_fno_altivec, + "altivec"); + + // Note that gcc calls this mfcrf and LLVM calls this mfocrf. + AddTargetFeature(Args, CmdArgs, + options::OPT_mmfcrf, options::OPT_mno_mfcrf, + "mfocrf"); + // It is really only possible to turn qpx off because turning qpx on is tied + // to using the a2q CPU. if (Args.hasFlag(options::OPT_mno_qpx, options::OPT_mqpx, false)) { CmdArgs.push_back("-target-feature"); CmdArgs.push_back("-qpx"); diff --git a/test/Driver/ppc-features.cpp b/test/Driver/ppc-features.cpp index 1918ed7d76..5140e85dd3 100644 --- a/test/Driver/ppc-features.cpp +++ b/test/Driver/ppc-features.cpp @@ -68,3 +68,9 @@ // RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-qpx -mqpx -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-QPX %s // CHECK-QPX-NOT: "-target-feature" "-qpx" +// RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-mfcrf -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOMFCRF %s +// CHECK-NOMFCRF: "-target-feature" "-mfocrf" + +// RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-mfcrf -mmfcrf -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-MFCRF %s +// CHECK-MFCRF: "-target-feature" "+mfocrf" + -- 2.40.0