From d5e59fc9df4cc7136e07c830ed08343a80a83b8e Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Wed, 16 Oct 2013 20:40:08 +0000 Subject: [PATCH] Rework ppc options handling into a features group. This should have no functional behavior. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192838 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Driver/Options.td | 29 ++++++++++++++------------ lib/Driver/Tools.cpp | 37 ++++++++++++++++++++------------- test/Driver/ppc-features.cpp | 1 - 3 files changed, 39 insertions(+), 28 deletions(-) diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 6cb024933b..22c4cdca44 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -72,6 +72,7 @@ def m_Group : OptionGroup<"">, Group; def m_x86_Features_Group : OptionGroup<"">, Group; def m_hexagon_Features_Group : OptionGroup<"">, Group; def m_arm_Features_Group : OptionGroup<"">, Group; +def m_ppc_Features_Group : OptionGroup<"">, Group; def opencl_Group : OptionGroup<"">; def u_Group : OptionGroup<"">; @@ -337,9 +338,6 @@ def fPIE : Flag<["-"], "fPIE">, Group; def fno_PIE : Flag<["-"], "fno-PIE">, Group; def faccess_control : Flag<["-"], "faccess-control">, Group; def fallow_unsupported : Flag<["-"], "fallow-unsupported">, Group; -def faltivec : Flag<["-"], "faltivec">, Group, Flags<[CC1Option]>, - HelpText<"Enable AltiVec vector initializer syntax">; -def fno_altivec : Flag<["-"], "fno-altivec">, Group, Flags<[CC1Option]>; def fapple_kext : Flag<["-"], "fapple-kext">, Group, Flags<[CC1Option]>, HelpText<"Use Apple's kernel extensions ABI">; def fapple_pragma_pack : Flag<["-"], "fapple-pragma-pack">, Group, Flags<[CC1Option]>, @@ -935,16 +933,6 @@ def m3dnow : Flag<["-"], "m3dnow">, Group; def m64 : Flag<["-"], "m64">, Group, Flags<[DriverOption, CoreOption]>; 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 mfprnd : Flag<["-"], "mfprnd">, Group; -def mno_fprnd : Flag<["-"], "mno-fprnd">, Group; -def mmfcrf : Flag<["-"], "mmfcrf">, Group; -def mno_mfcrf : Flag<["-"], "mno-mfcrf">, Group; -def mpopcntd : Flag<["-"], "mpopcntd">, Group; -def mno_popcntd : Flag<["-"], "mno-popcntd">, Group; -def mqpx : Flag<["-"], "mqpx">, Group; -def mno_qpx : Flag<["-"], "mno-qpx">, Group; def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group; def mconstant_cfstrings : Flag<["-"], "mconstant-cfstrings">, Group; def mcpu_EQ : Joined<["-"], "mcpu=">, Group; @@ -1029,6 +1017,21 @@ def marm : Flag<["-"], "marm">, Alias; def ffixed_r9 : Flag<["-"], "ffixed-r9">, Group, HelpText<"Reserve the r9 register (ARM only)">; +def mfprnd : Flag<["-"], "mfprnd">, Group; +def mno_fprnd : Flag<["-"], "mno-fprnd">, Group; +def mmfcrf : Flag<["-"], "mmfcrf">, Group; +def mno_mfcrf : Flag<["-"], "mno-mfcrf">, Group; +def mpopcntd : Flag<["-"], "mpopcntd">, Group; +def mno_popcntd : Flag<["-"], "mno-popcntd">, Group; +def mqpx : Flag<["-"], "mqpx">, Group; +def mno_qpx : Flag<["-"], "mno-qpx">, Group; + +def faltivec : Flag<["-"], "faltivec">, Group, Flags<[CC1Option]>, + HelpText<"Enable AltiVec vector initializer syntax">; +def fno_altivec : Flag<["-"], "fno-altivec">, Group, Flags<[CC1Option]>; +def maltivec : Flag<["-"], "maltivec">, Alias; +def mno_altivec : Flag<["-"], "mno-altivec">, Alias; + def mno_warn_nonportable_cfstrings : Flag<["-"], "mno-warn-nonportable-cfstrings">, Group; def mno_omit_leaf_frame_pointer : Flag<["-"], "mno-omit-leaf-frame-pointer">, Group; def momit_leaf_frame_pointer : Flag<["-"], "momit-leaf-frame-pointer">, Group, diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 91228dca16..68a5fe8f9a 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -1112,24 +1112,33 @@ static std::string getPPCTargetCPU(const ArgList &Args) { static void getPPCTargetFeatures(const ArgList &Args, std::vector &Features) { - // Allow override of the Altivec feature. - AddTargetFeature(Args, Features, options::OPT_faltivec, - options::OPT_fno_altivec, "altivec"); + for (arg_iterator it = Args.filtered_begin(options::OPT_m_ppc_Features_Group), + ie = Args.filtered_end(); + it != ie; ++it) { + StringRef Name = (*it)->getOption().getName(); + (*it)->claim(); - AddTargetFeature(Args, Features, options::OPT_mfprnd, options::OPT_mno_fprnd, - "fprnd"); + // Skip over "-m". + assert(Name.startswith("m") && "Invalid feature name."); + Name = Name.substr(1); - // Note that gcc calls this mfcrf and LLVM calls this mfocrf. - AddTargetFeature(Args, Features, options::OPT_mmfcrf, options::OPT_mno_mfcrf, - "mfocrf"); + bool IsNegative = Name.startswith("no-"); + if (IsNegative) + Name = Name.substr(3); + + // Note that gcc calls this mfcrf and LLVM calls this mfocrf so we + // pass the correct option to the backend while calling the frontend + // option the same. + // TODO: Change the LLVM backend option maybe? + if (Name == "mfcrf") + Name = "mfocrf"; - AddTargetFeature(Args, Features, options::OPT_mpopcntd, - options::OPT_mno_popcntd, "popcntd"); + Features.push_back(Args.MakeArgString((IsNegative ? "-" : "+") + Name)); + } - // 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)) - Features.push_back("-qpx"); + // Altivec is a bit weird, allow overriding of the Altivec feature here. + AddTargetFeature(Args, Features, options::OPT_faltivec, + options::OPT_fno_altivec, "altivec"); } /// Get the (LLVM) name of the R600 gpu we are targeting. diff --git a/test/Driver/ppc-features.cpp b/test/Driver/ppc-features.cpp index b030998ad6..7544c64ad6 100644 --- a/test/Driver/ppc-features.cpp +++ b/test/Driver/ppc-features.cpp @@ -85,4 +85,3 @@ // RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-fprnd -mfprnd -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-FPRND %s // CHECK-FPRND: "-target-feature" "+fprnd" - -- 2.40.0