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

Kazushi Marukawa via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 15 20:51:39 PDT 2023


kaz7 updated this revision to Diff 550588.
kaz7 added a comment.

Update to follow suggestions.  Thank you.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157813/new/

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,13 @@
 def mno_vzeroupper : Flag<["-"], "mno-vzeroupper">, Group<m_x86_Features_Group>;
 } // 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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157813.550588.patch
Type: text/x-patch
Size: 2680 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230816/0579ca9b/attachment.bin>


More information about the cfe-commits mailing list