diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index b8b02af9f35f0..3d73e24a4dc5a 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -199,6 +199,8 @@ def m_x86_Features_Group : OptionGroup<"">, 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]>; @@ -5845,6 +5847,13 @@ def mno_scatter : Flag<["-"], "mno-scatter">, Group, HelpText<"Disable generation of scatter instructions in auto-vectorization(x86 only)">; } // 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 index 97d74eb4e5efd..b19760898c647 100644 --- a/clang/lib/Driver/ToolChains/Arch/VE.cpp +++ b/clang/lib/Driver/ToolChains/Arch/VE.cpp @@ -18,4 +18,9 @@ using namespace clang; using namespace llvm::opt; void ve::getVETargetFeatures(const Driver &D, const ArgList &Args, - std::vector &Features) {} + std::vector &Features) { + if (Args.hasFlag(options::OPT_mvevpu, options::OPT_mno_vevpu, true)) + 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 index 0000000000000..5e233b0893a3c --- /dev/null +++ b/clang/test/Driver/ve-features.c @@ -0,0 +1,5 @@ +// RUN: %clang --target=ve-unknown-linux-gnu -### %s 2>&1 | FileCheck %s -check-prefix=DEFAULT +// RUN: %clang --target=ve-unknown-linux-gnu -### %s -mvevpu -mno-vevpu 2>&1 | FileCheck %s -check-prefix=NO-VEVPU + +// DEFAULT: "-target-feature" "+vpu" +// NO-VEVPU: "-target-feature" "-vpu"