https://github.com/fzou1 updated 
https://github.com/llvm/llvm-project/pull/140874

>From d683302d4768dfb5c618aa1b09553f3b22142aed Mon Sep 17 00:00:00 2001
From: Feng Zou <feng....@intel.com>
Date: Tue, 20 May 2025 22:10:07 +0800
Subject: [PATCH 1/2] [Driver][X86] Add -m[no-]apxf to m_x86_Features_Group

This is to expose these options to clang-cl on Windows.
And add help text for these options.
---
 clang/include/clang/Driver/Options.td |  9 +++--
 clang/test/Driver/cl-x86-flags.c      | 50 +++++++++++++++++++++++++++
 2 files changed, 57 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9a4253113488d..ead729342173b 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6679,8 +6679,13 @@ def mapx_features_EQ : CommaJoined<["-"], 
"mapx-features=">, Group<m_x86_Feature
     HelpText<"Enable features of APX">, 
Values<"egpr,push2pop2,ppx,ndd,ccmp,nf,cf,zu">,  Visibility<[ClangOption, 
CLOption, FlangOption]>;
 def mno_apx_features_EQ : CommaJoined<["-"], "mno-apx-features=">, 
Group<m_x86_Features_Group>,
     HelpText<"Disable features of APX">, 
Values<"egpr,push2pop2,ppx,ndd,ccmp,nf,cf,zu">, Visibility<[ClangOption, 
CLOption, FlangOption]>;
-def mapxf : Flag<["-"], "mapxf">, Alias<mapx_features_EQ>, 
AliasArgs<["egpr","push2pop2","ppx","ndd","ccmp","nf","cf","zu"]>;
-def mno_apxf : Flag<["-"], "mno-apxf">, Alias<mno_apx_features_EQ>, 
AliasArgs<["egpr","push2pop2","ppx","ndd","ccmp","nf","cf","zu"]>;
+def mapxf : Flag<["-"], "mapxf">, Alias<mapx_features_EQ>,
+            AliasArgs<["egpr","push2pop2","ppx","ndd","ccmp","nf","cf","zu"]>,
+            Group<m_x86_Features_Group>, HelpText<"Enable all features of 
APX">;
+def mno_apxf : Flag<["-"], "mno-apxf">, Alias<mno_apx_features_EQ>,
+               
AliasArgs<["egpr","push2pop2","ppx","ndd","ccmp","nf","cf","zu"]>,
+               Group<m_x86_Features_Group>,
+               HelpText<"Disable all features of APX">;
 def mapx_inline_asm_use_gpr32 : Flag<["-"], "mapx-inline-asm-use-gpr32">, 
Group<m_Group>,
                                 HelpText<"Enable use of GPR32 in inline 
assembly for APX">;
 } // let Flags = [TargetSpecific]
diff --git a/clang/test/Driver/cl-x86-flags.c b/clang/test/Driver/cl-x86-flags.c
index 51b16f0ce3546..23fe96d604604 100644
--- a/clang/test/Driver/cl-x86-flags.c
+++ b/clang/test/Driver/cl-x86-flags.c
@@ -135,3 +135,53 @@
 
 void f(void) {
 }
+
+
+// RUN: not %clang_cl -### --target=i386 -mapx-features=ndd %s 2>&1 | 
FileCheck --check-prefix=NON-APX %s
+// RUN: not %clang_cl -### --target=i386 -mapxf %s 2>&1 | FileCheck 
--check-prefix=NON-APX %s
+// RUN: %clang_cl -### --target=i386 -mno-apxf %s 2>&1 > /dev/null
+// NON-APX:      error: unsupported option '-mapx-features=|-mapxf' for target 
'i386'
+// NON-APX-NOT:  error: {{.*}} -mapx-features=
+
+// RUN: %clang_cl -target x86_64-pc-windows -mapxf %s -### -o %t.o 2>&1 | 
FileCheck -check-prefix=APXF %s
+// RUN: %clang_cl -target x86_64-pc-windows -mno-apxf %s -### -o %t.o 2>&1 | 
FileCheck -check-prefix=NO-APXF %s
+// RUN: %clang_cl -target x86_64-pc-windows -mno-apxf -mapxf %s -### -o %t.o 
2>&1 | FileCheck -check-prefix=APXF %s
+// RUN: %clang_cl -target x86_64-pc-windows -mapxf -mno-apxf %s -### -o %t.o 
2>&1 | FileCheck -check-prefix=NO-APXF %s
+//
+// APXF: "-target-feature" "+egpr" "-target-feature" "+push2pop2" 
"-target-feature" "+ppx" "-target-feature" "+ndd" "-target-feature" "+ccmp" 
"-target-feature" "+nf" "-target-feature" "+cf" "-target-feature" "+zu"
+// NO-APXF: "-target-feature" "-egpr" "-target-feature" "-push2pop2" 
"-target-feature" "-ppx" "-target-feature" "-ndd" "-target-feature" "-ccmp" 
"-target-feature" "-nf" "-target-feature" "-cf" "-target-feature" "-zu"
+
+// RUN: %clang_cl -target x86_64-pc-windows -mapx-features=egpr %s -### -o 
%t.o 2>&1 | FileCheck -check-prefix=EGPR %s
+// RUN: %clang_cl -target x86_64-pc-windows -mapx-features=push2pop2 %s -### 
-o %t.o 2>&1 | FileCheck -check-prefix=PUSH2POP2 %s
+// RUN: %clang_cl -target x86_64-pc-windows -mapx-features=ppx %s -### -o %t.o 
2>&1 | FileCheck -check-prefix=PPX %s
+// RUN: %clang_cl -target x86_64-pc-windows -mapx-features=ndd %s -### -o %t.o 
2>&1 | FileCheck -check-prefix=NDD %s
+// RUN: %clang_cl -target x86_64-pc-windows -mapx-features=ccmp %s -### -o 
%t.o 2>&1 | FileCheck -check-prefix=CCMP %s
+// RUN: %clang_cl -target x86_64-pc-windows -mapx-features=nf %s -### -o %t.o 
2>&1 | FileCheck -check-prefix=NF %s
+// RUN: %clang_cl -target x86_64-pc-windows -mapx-features=cf %s -### -o %t.o 
2>&1 | FileCheck -check-prefix=CF %s
+// RUN: %clang_cl -target x86_64-pc-windows -mapx-features=zu %s -### -o %t.o 
2>&1 | FileCheck -check-prefix=ZU %s
+// EGPR: "-target-feature" "+egpr"
+// PUSH2POP2: "-target-feature" "+push2pop2"
+// PPX: "-target-feature" "+ppx"
+// NDD: "-target-feature" "+ndd"
+// CCMP: "-target-feature" "+ccmp"
+// NF: "-target-feature" "+nf"
+// CF: "-target-feature" "+cf"
+// ZU: "-target-feature" "+zu"
+
+// RUN: %clang_cl -target x86_64-pc-windows -mapx-features=egpr,ndd %s -### -o 
%t.o 2>&1 | FileCheck -check-prefix=EGPR-NDD %s
+// RUN: %clang_cl -target x86_64-pc-windows -mapx-features=egpr 
-mapx-features=ndd %s -### -o %t.o 2>&1 | FileCheck -check-prefix=EGPR-NDD %s
+// RUN: %clang_cl -target x86_64-pc-windows -mno-apx-features=egpr 
-mno-apx-features=ndd %s -### -o %t.o 2>&1 | FileCheck 
-check-prefix=NO-EGPR-NO-NDD %s
+// RUN: %clang_cl -target x86_64-pc-windows -mno-apx-features=egpr 
-mapx-features=egpr,ndd %s -### -o %t.o 2>&1 | FileCheck -check-prefix=EGPR-NDD 
%s
+// RUN: %clang_cl -target x86_64-pc-windows -mno-apx-features=egpr,ndd 
-mapx-features=egpr %s -### -o %t.o 2>&1 | FileCheck -check-prefix=EGPR-NO-NDD 
%s
+// RUN: %clang_cl -target x86_64-pc-windows -mapx-features=egpr,ndd 
-mno-apx-features=egpr %s -### -o %t.o 2>&1 | FileCheck 
-check-prefix=NO-EGPR-NDD %s
+// RUN: %clang_cl -target x86_64-pc-windows -mapx-features=egpr 
-mno-apx-features=egpr,ndd %s -### -o %t.o 2>&1 | FileCheck 
-check-prefix=NO-EGPR-NO-NDD %s
+//
+// EGPR-NDD: "-target-feature" "+egpr" "-target-feature" "+ndd"
+// EGPR-NO-NDD: "-target-feature" "-ndd" "-target-feature" "+egpr"
+// NO-EGPR-NDD: "-target-feature" "+ndd" "-target-feature" "-egpr"
+// NO-EGPR-NO-NDD: "-target-feature" "-egpr" "-target-feature" "-ndd"
+
+// RUN: not %clang_cl -target x86_64-pc-windows -mapx-features=egpr,foo,bar %s 
-### -o %t.o 2>&1 | FileCheck -check-prefix=ERROR %s
+//
+// ERROR: unsupported argument 'foo' to option '-mapx-features='
+// ERROR: unsupported argument 'bar' to option '-mapx-features='

>From c845e220783050532be14154d4ad8ba543f2ec69 Mon Sep 17 00:00:00 2001
From: Feng Zou <feng....@intel.com>
Date: Fri, 23 May 2025 10:31:03 +0800
Subject: [PATCH 2/2] Remove help text for m[no_]apxf.

---
 clang/include/clang/Driver/Options.td | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index ead729342173b..3f8ba71136099 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6681,11 +6681,10 @@ def mno_apx_features_EQ : CommaJoined<["-"], 
"mno-apx-features=">, Group<m_x86_F
     HelpText<"Disable features of APX">, 
Values<"egpr,push2pop2,ppx,ndd,ccmp,nf,cf,zu">, Visibility<[ClangOption, 
CLOption, FlangOption]>;
 def mapxf : Flag<["-"], "mapxf">, Alias<mapx_features_EQ>,
             AliasArgs<["egpr","push2pop2","ppx","ndd","ccmp","nf","cf","zu"]>,
-            Group<m_x86_Features_Group>, HelpText<"Enable all features of 
APX">;
+            Group<m_x86_Features_Group>;
 def mno_apxf : Flag<["-"], "mno-apxf">, Alias<mno_apx_features_EQ>,
                
AliasArgs<["egpr","push2pop2","ppx","ndd","ccmp","nf","cf","zu"]>,
-               Group<m_x86_Features_Group>,
-               HelpText<"Disable all features of APX">;
+               Group<m_x86_Features_Group>;
 def mapx_inline_asm_use_gpr32 : Flag<["-"], "mapx-inline-asm-use-gpr32">, 
Group<m_Group>,
                                 HelpText<"Enable use of GPR32 in inline 
assembly for APX">;
 } // let Flags = [TargetSpecific]

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

Reply via email to