[PATCH] D157813: [VE][Clang] Change to enable VPU flag by default

Kazushi Marukawa via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Aug 13 09:52:57 PDT 2023


kaz7 created this revision.
kaz7 added a reviewer: efocht.
kaz7 added projects: clang, VE.
Herald added a project: All.
kaz7 requested review of this revision.
Herald added subscribers: cfe-commits, wangpc, MaskRay.

Change to enable VPU flag for VE by default in order to support vector
intrinsics from clang.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157813

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/VE.cpp
  clang/test/Driver/ve-features.c


Index: clang/test/Driver/ve-features.c
===================================================================
--- /dev/null
+++ clang/test/Driver/ve-features.c
@@ -0,0 +1,7 @@
+// 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
+// RUN: %clang -target ve-unknown-linux-gnu -### %s 2>&1 | FileCheck %s -check-prefix=DEFAULT
+
+// VEVPU: "-target-feature" "+vpu"
+// NO-VEVPU-NOT: "-target-feature" "+vpu"
+// DEFAULT: "-target-feature" "+vpu"
Index: clang/lib/Driver/ToolChains/Arch/VE.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Arch/VE.cpp
+++ clang/lib/Driver/ToolChains/Arch/VE.cpp
@@ -18,4 +18,17 @@
 using namespace llvm::opt;
 
 void ve::getVETargetFeatures(const Driver &D, const ArgList &Args,
-                             std::vector<StringRef> &Features) {}
+                             std::vector<StringRef> &Features) {
+  // Defaults.
+  bool EnableVPU = true;
+
+  // Whether to enable VPU registers and isel.
+  if (auto *A = Args.getLastArg(options::OPT_mvevpu, options::OPT_mno_vevpu)) {
+    if (A->getOption().matches(options::OPT_mno_vevpu))
+      EnableVPU = false;
+  }
+
+  // VVP
+  if (EnableVPU)
+    Features.push_back("+vpu");
+}
Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -202,6 +202,8 @@
                            Group<m_Group>, Flags<[CoreOption]>, 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]>;
@@ -5160,6 +5162,14 @@
 def mno_vzeroupper : Flag<["-"], "mno-vzeroupper">, Group<m_x86_Features_Group>;
 } // let Flags = [TargetSpecific]
 
+// VE feature flags
+let Flags = [TargetSpecific, CC1Option] 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>,
+  HelpText<"Do not emit VPU instructions for VE">;
+} // let Flags = [TargetSpecific, CC1Option]
+
 // 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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157813.549713.patch
Type: text/x-patch
Size: 2751 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230813/5c303a49/attachment.bin>


More information about the cfe-commits mailing list