Skip to content

Commit 76c84e7

Browse files
authored
[Driver][X86] Add flang visibility for -mapx-features= (#97525)
The default visibility of `m_x86_Features_Group` is `ClangOption, CLOption`. For x86, we expose `-march` to flang but not `-m<cpuid>`. `apxf` is special b/c it contains several independent features like `egpr, ndd, ppx, push2pop2, ccmp, nf, cf` and `zu`. Users may would like to turn on part of features in different cases 1. enable `ndd` only when writing a code-size sensitive library 2. disable `ccmp`, `cf` when building component has strong security request on caches Hence, we expose `-mapx-features=` to flang for Fortran users.
1 parent f3a0225 commit 76c84e7

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6319,9 +6319,9 @@ def mno_gather : Flag<["-"], "mno-gather">, Group<m_Group>,
63196319
def mno_scatter : Flag<["-"], "mno-scatter">, Group<m_Group>,
63206320
HelpText<"Disable generation of scatter instructions in auto-vectorization(x86 only)">;
63216321
def mapx_features_EQ : CommaJoined<["-"], "mapx-features=">, Group<m_x86_Features_Group>,
6322-
HelpText<"Enable features of APX">, Values<"egpr,push2pop2,ppx,ndd,ccmp,nf,cf,zu">;
6322+
HelpText<"Enable features of APX">, Values<"egpr,push2pop2,ppx,ndd,ccmp,nf,cf,zu">, Visibility<[ClangOption, CLOption, FlangOption]>;
63236323
def mno_apx_features_EQ : CommaJoined<["-"], "mno-apx-features=">, Group<m_x86_Features_Group>,
6324-
HelpText<"Disable features of APX">, Values<"egpr,push2pop2,ppx,ndd,ccmp,nf,cf,zu">;
6324+
HelpText<"Disable features of APX">, Values<"egpr,push2pop2,ppx,ndd,ccmp,nf,cf,zu">, Visibility<[ClangOption, CLOption, FlangOption]>;
63256325
// For stability, we only add a feature to -mapxf after it passes the validation of llvm-test-suite && cpu2017 on Intel SDE.
63266326
def mapxf : Flag<["-"], "mapxf">, Alias<mapx_features_EQ>, AliasArgs<["egpr","push2pop2","ppx","ndd","ccmp","nf","cf"]>;
63276327
def mno_apxf : Flag<["-"], "mno-apxf">, Alias<mno_apx_features_EQ>, AliasArgs<["egpr","push2pop2","ppx","ndd","ccmp","nf","cf"]>;

flang/test/Driver/target-cpu-features.f90

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
! RUN: %flang --target=x86_64-linux-gnu -march=skylake -c %s -### 2>&1 \
1818
! RUN: | FileCheck %s -check-prefix=CHECK-SKYLAKE
1919

20+
! RUN: %flang --target=x86_64-linux-gnu -mapx-features=egpr -c %s -### 2>&1 \
21+
! RUN: | FileCheck %s -check-prefix=CHECK-APX
22+
23+
! RUN: %flang --target=x86_64-linux-gnu -mno-apx-features=ccmp -c %s -### 2>&1 \
24+
! RUN: | FileCheck %s -check-prefix=CHECK-NO-APX
25+
2026
! RUN: %flang --target=x86_64h-linux-gnu -c %s -### 2>&1 \
2127
! RUN: | FileCheck %s -check-prefix=CHECK-X86_64H
2228

@@ -51,6 +57,12 @@
5157
! CHECK-SKYLAKE: "-fc1" "-triple" "x86_64-unknown-linux-gnu"
5258
! CHECK-SKYLAKE-SAME: "-target-cpu" "skylake"
5359

60+
! CHECK-APX: "-fc1" "-triple" "x86_64-unknown-linux-gnu"
61+
! CHECK-APX-SAME: "-target-feature" "+egpr"
62+
63+
! CHECK-NO-APX: "-fc1" "-triple" "x86_64-unknown-linux-gnu"
64+
! CHECK-NO-APX-SAME: "-target-feature" "-ccmp"
65+
5466
! CHECK-X86_64H: "-fc1" "-triple" "x86_64h-unknown-linux-gnu"
5567
! CHECK-X86_64H-SAME: "-target-cpu" "x86-64" "-target-feature" "-rdrnd" "-target-feature" "-aes" "-target-feature" "-pclmul" "-target-feature" "-rtm" "-target-feature" "-fsgsbase"
5668

0 commit comments

Comments
 (0)