diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -202,6 +202,8 @@ Group, Flags<[CoreOption]>, DocName<"X86">; def m_riscv_Features_Group : OptionGroup<"">, Group, DocName<"RISC-V">; +def m_ve_Features_Group : OptionGroup<"">, + Group, DocName<"VE">; def m_libc_Group : OptionGroup<"">, Group, Flags<[HelpHidden]>; @@ -5160,6 +5162,13 @@ def mno_vzeroupper : Flag<["-"], "mno-vzeroupper">, Group; } // let Flags = [TargetSpecific] +// VE feature flags +let Flags = [TargetSpecific] in { +def mvevpu : Flag<["-"], "mvevpu">, Group, + HelpText<"Emit VPU instructions for VE">; +def mno_vevpu : Flag<["-"], "mno-vevpu">, Group; +} // let Flags = [TargetSpecific] + // These are legacy user-facing driver-level option spellings. They are always // aliases for options that are spelled using the more common Unix / GNU flag // style of double-dash and equals-joined flags. diff --git a/clang/lib/Driver/ToolChains/Arch/VE.cpp b/clang/lib/Driver/ToolChains/Arch/VE.cpp --- a/clang/lib/Driver/ToolChains/Arch/VE.cpp +++ b/clang/lib/Driver/ToolChains/Arch/VE.cpp @@ -18,4 +18,11 @@ using namespace llvm::opt; void ve::getVETargetFeatures(const Driver &D, const ArgList &Args, - std::vector &Features) {} + std::vector &Features) { + if (auto *A = Args.getLastArg(options::OPT_mvevpu, options::OPT_mno_vevpu)) { + if (A->getOption().matches(options::OPT_mvevpu)) + Features.push_back("+vpu"); + else + Features.push_back("-vpu"); + } +} diff --git a/clang/test/Driver/ve-features.c b/clang/test/Driver/ve-features.c new file mode 100644 --- /dev/null +++ b/clang/test/Driver/ve-features.c @@ -0,0 +1,5 @@ +// RUN: %clang --target=ve-unknown-linux-gnu -### %s -mvevpu 2>&1 | FileCheck %s -check-prefix=VEVPU +// RUN: %clang --target=ve-unknown-linux-gnu -### %s -mno-vevpu 2>&1 | FileCheck %s -check-prefix=NO-VEVPU + +// VEVPU: "-target-feature" "+vpu" +// NO-VEVPU-NOT: "-target-feature" "+vpu"