diff options
author | Shengchen Kan <shengchen.kan@intel.com> | 2024-07-03 16:02:58 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-03 16:02:58 +0800 |
commit | 76c84e702bd9af7db2bb9373ba6de0508f1e57a9 (patch) | |
tree | 197fc869e2bc21c3b7f986e8b1d5e93fe099199e | |
parent | f3a02253e9daba0e5c11b94c090dfa9e2e9ad5db (diff) | |
download | llvm-76c84e702bd9af7db2bb9373ba6de0508f1e57a9.zip llvm-76c84e702bd9af7db2bb9373ba6de0508f1e57a9.tar.gz llvm-76c84e702bd9af7db2bb9373ba6de0508f1e57a9.tar.bz2 |
[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.
-rw-r--r-- | clang/include/clang/Driver/Options.td | 4 | ||||
-rw-r--r-- | flang/test/Driver/target-cpu-features.f90 | 12 |
2 files changed, 14 insertions, 2 deletions
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 1c2b8cf..1ede75d 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -6319,9 +6319,9 @@ def mno_gather : Flag<["-"], "mno-gather">, Group<m_Group>, def mno_scatter : Flag<["-"], "mno-scatter">, Group<m_Group>, HelpText<"Disable generation of scatter instructions in auto-vectorization(x86 only)">; def mapx_features_EQ : CommaJoined<["-"], "mapx-features=">, Group<m_x86_Features_Group>, - HelpText<"Enable features of APX">, Values<"egpr,push2pop2,ppx,ndd,ccmp,nf,cf,zu">; + 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">; + HelpText<"Disable features of APX">, Values<"egpr,push2pop2,ppx,ndd,ccmp,nf,cf,zu">, Visibility<[ClangOption, CLOption, FlangOption]>; // For stability, we only add a feature to -mapxf after it passes the validation of llvm-test-suite && cpu2017 on Intel SDE. def mapxf : Flag<["-"], "mapxf">, Alias<mapx_features_EQ>, AliasArgs<["egpr","push2pop2","ppx","ndd","ccmp","nf","cf"]>; def mno_apxf : Flag<["-"], "mno-apxf">, Alias<mno_apx_features_EQ>, AliasArgs<["egpr","push2pop2","ppx","ndd","ccmp","nf","cf"]>; diff --git a/flang/test/Driver/target-cpu-features.f90 b/flang/test/Driver/target-cpu-features.f90 index e78c351..0f19e4e 100644 --- a/flang/test/Driver/target-cpu-features.f90 +++ b/flang/test/Driver/target-cpu-features.f90 @@ -17,6 +17,12 @@ ! RUN: %flang --target=x86_64-linux-gnu -march=skylake -c %s -### 2>&1 \ ! RUN: | FileCheck %s -check-prefix=CHECK-SKYLAKE +! RUN: %flang --target=x86_64-linux-gnu -mapx-features=egpr -c %s -### 2>&1 \ +! RUN: | FileCheck %s -check-prefix=CHECK-APX + +! RUN: %flang --target=x86_64-linux-gnu -mno-apx-features=ccmp -c %s -### 2>&1 \ +! RUN: | FileCheck %s -check-prefix=CHECK-NO-APX + ! RUN: %flang --target=x86_64h-linux-gnu -c %s -### 2>&1 \ ! RUN: | FileCheck %s -check-prefix=CHECK-X86_64H @@ -51,6 +57,12 @@ ! CHECK-SKYLAKE: "-fc1" "-triple" "x86_64-unknown-linux-gnu" ! CHECK-SKYLAKE-SAME: "-target-cpu" "skylake" +! CHECK-APX: "-fc1" "-triple" "x86_64-unknown-linux-gnu" +! CHECK-APX-SAME: "-target-feature" "+egpr" + +! CHECK-NO-APX: "-fc1" "-triple" "x86_64-unknown-linux-gnu" +! CHECK-NO-APX-SAME: "-target-feature" "-ccmp" + ! CHECK-X86_64H: "-fc1" "-triple" "x86_64h-unknown-linux-gnu" ! CHECK-X86_64H-SAME: "-target-cpu" "x86-64" "-target-feature" "-rdrnd" "-target-feature" "-aes" "-target-feature" "-pclmul" "-target-feature" "-rtm" "-target-feature" "-fsgsbase" |