Skip to content

[Driver][X86] Add flang visibility for -mapx-features= #97525

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 3, 2024

Conversation

KanRobert
Copy link
Contributor

@KanRobert KanRobert commented Jul 3, 2024

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.

@llvmbot llvmbot added clang Clang issues not falling into any other category flang:driver flang Flang issues not falling into any other category labels Jul 3, 2024
@llvmbot
Copy link
Member

llvmbot commented Jul 3, 2024

@llvm/pr-subscribers-flang-driver

@llvm/pr-subscribers-clang

Author: Shengchen Kan (KanRobert)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/97525.diff

2 Files Affected:

  • (modified) clang/include/clang/Driver/Options.td (+1-1)
  • (modified) flang/test/Driver/target-cpu-features.f90 (+6)
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 1c2b8cfeef6ce..e1e6a6e3a0fcd 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6319,7 +6319,7 @@ 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">;
 // For stability, we only add a feature to -mapxf after it passes the validation of llvm-test-suite && cpu2017 on Intel SDE.
diff --git a/flang/test/Driver/target-cpu-features.f90 b/flang/test/Driver/target-cpu-features.f90
index e78c3516db45a..2728fb90afa41 100644
--- a/flang/test/Driver/target-cpu-features.f90
+++ b/flang/test/Driver/target-cpu-features.f90
@@ -17,6 +17,9 @@
 ! 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_64h-linux-gnu -c %s -### 2>&1 \
 ! RUN: | FileCheck %s -check-prefix=CHECK-X86_64H
 
@@ -51,6 +54,9 @@
 ! 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-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"
 

@KanRobert KanRobert requested a review from phoebewang July 3, 2024 06:27
Copy link
Contributor

@phoebewang phoebewang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@KanRobert
Copy link
Contributor Author

Also, AArch64 also exposes the tuning flag msve-vector-bits= to flang.

@KanRobert KanRobert merged commit 76c84e7 into llvm:main Jul 3, 2024
5 of 6 checks passed
lravenclaw pushed a commit to lravenclaw/llvm-project that referenced this pull request Jul 3, 2024
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.
kbluck pushed a commit to kbluck/llvm-project that referenced this pull request Jul 6, 2024
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category flang:driver flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants