Skip to content

Commit

Permalink
[Driver][VE] Change to enable VPU flag by default
Browse files Browse the repository at this point in the history
Change to enable VPU flag for VE by default in order to support vector
intrinsics from clang.

Reviewed By: efocht, MaskRay

Differential Revision: https://reviews.llvm.org/D157813
  • Loading branch information
kaz7 committed Aug 31, 2023
1 parent 12da8ef commit b6ce860
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
9 changes: 9 additions & 0 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ def m_x86_Features_Group : OptionGroup<"<x86 features group>">,
DocName<"X86">;
def m_riscv_Features_Group : OptionGroup<"<riscv features group>">,
Group<m_Group>, DocName<"RISC-V">;
def m_ve_Features_Group : OptionGroup<"<ve features group>">,
Group<m_Group>, DocName<"VE">;

def m_libc_Group : OptionGroup<"<m libc group>">, Group<m_mips_Features_Group>,
Flags<[HelpHidden]>;
Expand Down Expand Up @@ -5845,6 +5847,13 @@ def mno_scatter : Flag<["-"], "mno-scatter">, Group<m_x86_Features_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<m_ve_Features_Group>,
HelpText<"Emit VPU instructions for VE">;
def mno_vevpu : Flag<["-"], "mno-vevpu">, Group<m_ve_Features_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.
Expand Down
7 changes: 6 additions & 1 deletion clang/lib/Driver/ToolChains/Arch/VE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ using namespace clang;
using namespace llvm::opt;

void ve::getVETargetFeatures(const Driver &D, const ArgList &Args,
std::vector<StringRef> &Features) {}
std::vector<StringRef> &Features) {
if (Args.hasFlag(options::OPT_mvevpu, options::OPT_mno_vevpu, true))
Features.push_back("+vpu");
else
Features.push_back("-vpu");
}
5 changes: 5 additions & 0 deletions clang/test/Driver/ve-features.c
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit b6ce860

Please sign in to comment.