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

2023-08-29 Thread Kazushi Marukawa via Phabricator via cfe-commits
kaz7 marked an inline comment as done.
kaz7 added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/VE.cpp:22
+ std::vector ) {
+  // Defaults.
+  bool EnableVPU = true;

MaskRay wrote:
> Delete the comment. The code speaks itself. 
> 
> ```
> if (Args.hasArg(options::OPT_mvevpu, options::OPT_mno_vevpu, true)
>   Features.push_back("+vpu");
> ```
Thanks.  I remove comments and simplify existing code.



Comment at: clang/test/Driver/ve-features.c:1
+// 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

MaskRay wrote:
> kaz7 wrote:
> > MaskRay wrote:
> > > `-target ` has been deprecated since Clang 3.4. Use `--target=`
> > I didn't know that.  Thank you!
> I think we typically spend just two RUN lines:
> 
> * one for the default
> * one for `-mvevpu -mno-vevpu`
> 
> The additional coverage for having 3 RUN lines is probably not useful.
Thank you for suggesting.  I consider what this patch should do and change the 
purpose to support VPU flag in the backend for VE.  As a result, Tests are two 
RUN lines.

- one for enable VPU
- one for disable VPU


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157813

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-08-29 Thread Kazushi Marukawa via Phabricator via cfe-commits
kaz7 updated this revision to Diff 554528.
kaz7 added a comment.

Change to not control backend default bahavior but support VPU flag in
the backend for VE.


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,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"
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,11 @@
 using namespace llvm::opt;
 
 void ve::getVETargetFeatures(const Driver , const ArgList ,
- std::vector ) {}
+ std::vector ) {
+  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");
+  }
+}
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ 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.


Index: clang/test/Driver/ve-features.c
===
--- /dev/null
+++ 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"
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,11 @@
 using namespace llvm::opt;
 
 void ve::getVETargetFeatures(const Driver , const ArgList ,
- std::vector ) {}
+ std::vector ) {
+  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");
+  }
+}
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ 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.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

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

2023-08-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> [VE][Clang] Change to enable VPU flag by default

For components like llvm/, clang/, we usually use a more specific tag. I'd pick 
`[Driver]` over `[Clang]`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157813

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-08-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Driver/ToolChains/Arch/VE.cpp:22
+ std::vector ) {
+  // Defaults.
+  bool EnableVPU = true;

Delete the comment. The code speaks itself. 

```
if (Args.hasArg(options::OPT_mvevpu, options::OPT_mno_vevpu, true)
  Features.push_back("+vpu");
```



Comment at: clang/test/Driver/ve-features.c:1
+// 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

kaz7 wrote:
> MaskRay wrote:
> > `-target ` has been deprecated since Clang 3.4. Use `--target=`
> I didn't know that.  Thank you!
I think we typically spend just two RUN lines:

* one for the default
* one for `-mvevpu -mno-vevpu`

The additional coverage for having 3 RUN lines is probably not useful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157813

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-08-28 Thread Kazushi Marukawa via Phabricator via cfe-commits
kaz7 added a comment.

Hi @MaskRay , thank you for reviewing this patch last time.  Is it possible to 
review updated this patch again?  Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157813

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-08-24 Thread Kazushi Marukawa via Phabricator via cfe-commits
kaz7 marked 3 inline comments as done.
kaz7 added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157813

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-08-15 Thread Kazushi Marukawa via Phabricator via cfe-commits
kaz7 marked 3 inline comments as done.
kaz7 added inline comments.



Comment at: clang/include/clang/Driver/Options.td:5166
+// VE feature flags
+let Flags = [TargetSpecific, CC1Option] in {
+def mvevpu : Flag<["-"], "mvevpu">, Group,

MaskRay wrote:
> Other feature group options  don't set CC1Option: we do not need them as CC1 
> options (e.g. `-Xclang -msse4`)
Thank you.  I was wondering which group options are required here.



Comment at: clang/include/clang/Driver/Options.td:5169
+  HelpText<"Emit VPU instructions for VE">;
+def mno_vevpu : Flag<["-"], "mno-vevpu">, Group,
+  HelpText<"Do not emit VPU instructions for VE">;

MaskRay wrote:
> In general, we just need documentation for the non-default option (let's say 
> `-mvevpu`). Documentation for the opposite `-mno-mvevpu` is just boilerplate 
> and not very useful.
I see.  Changed.



Comment at: clang/test/Driver/ve-features.c:1
+// 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

MaskRay wrote:
> `-target ` has been deprecated since Clang 3.4. Use `--target=`
I didn't know that.  Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157813

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-08-15 Thread Kazushi Marukawa via Phabricator via cfe-commits
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 , const ArgList ,
- std::vector ) {}
+ std::vector ) {
+  // 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, 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.


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 , const ArgList ,
- std::vector ) {}
+ std::vector ) {
+  // 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, 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 

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

2023-08-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/include/clang/Driver/Options.td:5169
+  HelpText<"Emit VPU instructions for VE">;
+def mno_vevpu : Flag<["-"], "mno-vevpu">, Group,
+  HelpText<"Do not emit VPU instructions for VE">;

In general, we just need documentation for the non-default option (let's say 
`-mvevpu`). Documentation for the opposite `-mno-mvevpu` is just boilerplate 
and not very useful.



Comment at: clang/test/Driver/ve-features.c:1
+// 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

`-target ` has been deprecated since Clang 3.4. Use `--target=`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157813

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-08-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/include/clang/Driver/Options.td:5166
+// VE feature flags
+let Flags = [TargetSpecific, CC1Option] in {
+def mvevpu : Flag<["-"], "mvevpu">, Group,

Other feature group options  don't set CC1Option: we do not need them as CC1 
options (e.g. `-Xclang -msse4`)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157813

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-08-14 Thread Kazushi Marukawa via Phabricator via cfe-commits
kaz7 added reviewers: MaskRay, jdoerfert, awarzynski.
kaz7 added a comment.

I randamly added reviewrs who review code related to feature flags and features 
group in clang.  I appreciate if some of you guys have a time to check this 
patch too.  Thank you so much.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157813

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-08-14 Thread Kazushi Marukawa via Phabricator via cfe-commits
kaz7 added a comment.

Thanks @efocht .  I appreciate if someone working on clang can review this 
patch too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157813

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-08-14 Thread Erich Focht via Phabricator via cfe-commits
efocht accepted this revision.
efocht added a comment.
This revision is now accepted and ready to land.

Looks good.
The default should be able to use intrinsics, hiding this only makes things 
complicated and gets users confused.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157813

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-08-13 Thread Kazushi Marukawa via Phabricator via cfe-commits
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 , const ArgList ,
- std::vector ) {}
+ std::vector ) {
+  // 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, 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,14 @@
 def mno_vzeroupper : Flag<["-"], "mno-vzeroupper">, 
Group;
 } // let Flags = [TargetSpecific]
 
+// VE feature flags
+let Flags = [TargetSpecific, CC1Option] in {
+def mvevpu : Flag<["-"], "mvevpu">, Group,
+  HelpText<"Emit VPU instructions for VE">;
+def mno_vevpu : Flag<["-"], "mno-vevpu">, 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.


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 , const ArgList ,
- std::vector ) {}
+ std::vector ) {
+  // 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, 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,14 @@
 def mno_vzeroupper :