Skip to content
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

[AArch64] Added feature dependencies for SME2p1 to TargetParser #81860

Merged
merged 5 commits into from
Feb 21, 2024

Conversation

Lukacma
Copy link
Contributor

@Lukacma Lukacma commented Feb 15, 2024

This patches adds missing target-feature dependencies for SME2.1

Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

Copy link

⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.
Please turn off Keep my email addresses private setting in your account.
See LLVM Discourse for more information.

@Lukacma
Copy link
Contributor Author

Lukacma commented Feb 15, 2024

Seems like I cannot add reviewers yet so I am tagging you for review @momchil-velikov @hassnaaHamdi @CarolineConcatto

@CarolineConcatto
Copy link
Contributor

Hi @Lukacma ,
It would be nice if you can add a test with clang cc1 to show what was the problem you are trying to fix.
Without this change clang cc1 does not see/understand the SVE type sizes

@Lukacma
Copy link
Contributor Author

Lukacma commented Feb 19, 2024

Hello @CarolineConcatto ,

Yes I was thinking about this but I couldn't find a good way to directly test this. Ideally we would have some sme2p1 tests, which just wouldn't work when cc1 would be used, but we don't have that as far as I can tell. I could create a dummy test, which wouldn't pass without this change but that felt little odd to me. Therefore, I wanted to check if there is better way to test this fix I might have missed.

@CarolineConcatto
Copy link
Contributor

Can it have a test for the sve types. Something like:

// RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu -target-feature +sme2p1  -S -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s
// RUN: %clang_cc1 -fclang-abi-compat=latest -triple aarch64-none-linux-gnu -target-feature +sme2p1 -S -disable-O0-optnone -Werror -Wall -o /dev/null %s

#include <arm_sme.h>
svuint8_t foo(svuint8_t a)  {
   return a;
}
svfloat16x2_t foo(svuint16x2_t a)  {
   return a;
}

@Lukacma
Copy link
Contributor Author

Lukacma commented Feb 20, 2024

Yes it could be like that. I was just wondering if there is not a better way than creating dummy programs and seeing if they compile. We have a test in aarch64-implied-sme-features.c which tests this nicely like this :

// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+sme %s -### 2>&1 | FileCheck %s --check-prefix=SME-IMPLY
// SME-IMPLY: "-target-feature" "+bf16"{{.*}} "-target-feature" "+sme"

Unfortunately this doesn't work with -cc1 and I was wondering if there is not a way to do something similiar for -cc1 that I am missing. If not I will create the dummy test.

@momchil-velikov
Copy link
Collaborator

Yes it could be like that. I was just wondering if there is not a better way than creating dummy programs and seeing if they compile. We have a test in aarch64-implied-sme-features.c which tests this nicely like this :

// RUN: %clang -target aarch64-linux-gnu -march=armv8-a+sme %s -### 2>&1 | FileCheck %s --check-prefix=SME-IMPLY
// SME-IMPLY: "-target-feature" "+bf16"{{.*}} "-target-feature" "+sme"

Unfortunately this doesn't work with -cc1 and I was wondering if there is not a way to do something similiar for -cc1 that I am missing. If not I will create the dummy test.

Add something like

// RUN: %clang_cc1  -triple aarch64-linux -target-feature +sme2p1 -S  -fsyntax-only -verify %s

#include <arm_sme.h>

void f(svfloat32_t x) {}

// expected-no-diagnostics

@llvmbot llvmbot added the clang Clang issues not falling into any other category label Feb 20, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Feb 20, 2024

@llvm/pr-subscribers-clang

Author: None (Lukacma)

Changes

This patches adds missing target-feature dependencies for SME2.1


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

2 Files Affected:

  • (added) clang/test/Sema/aarch64-sme2p1-diagnostics.c (+10)
  • (modified) llvm/include/llvm/TargetParser/AArch64TargetParser.h (+1-1)
diff --git a/clang/test/Sema/aarch64-sme2p1-diagnostics.c b/clang/test/Sema/aarch64-sme2p1-diagnostics.c
new file mode 100644
index 00000000000000..a0adb040385815
--- /dev/null
+++ b/clang/test/Sema/aarch64-sme2p1-diagnostics.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu  -target-feature +sme2p1 -fsyntax-only -verify %s
+
+// REQUIRES: aarch64-registered-target
+#include "arm_sme.h"
+
+svuint8x2_t  test_sme2p1(svuint8x2_t  x) {
+  // expected-no-diagnostics
+  return x;
+}
+
diff --git a/llvm/include/llvm/TargetParser/AArch64TargetParser.h b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
index ed9944bcef23d0..7376ac98a2b095 100644
--- a/llvm/include/llvm/TargetParser/AArch64TargetParser.h
+++ b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
@@ -273,7 +273,7 @@ inline constexpr ExtensionInfo Extensions[] = {
     {"sme-i16i64", AArch64::AEK_SMEI16I64, "+sme-i16i64", "-sme-i16i64", FEAT_SME_I64, "+sme,+sme-i16i64,+bf16", 570},
     {"sme", AArch64::AEK_SME, "+sme", "-sme", FEAT_SME, "+sme,+bf16", 430},
     {"sme2", AArch64::AEK_SME2, "+sme2", "-sme2", FEAT_SME2, "+sme2,+sme,+bf16", 580},
-    {"sme2p1", AArch64::AEK_SME2p1, "+sme2p1", "-sme2p1", FEAT_INIT, "", 0},
+    {"sme2p1", AArch64::AEK_SME2p1, "+sme2p1", "-sme2p1", FEAT_INIT, "+sme2p1,+sme2,+sme,+bf16", 0},
     {"ssbs", AArch64::AEK_SSBS, "+ssbs", "-ssbs", FEAT_SSBS, "", 490},
     {"ssbs2", AArch64::AEK_NONE, {}, {}, FEAT_SSBS2, "+ssbs", 500},
     {"sve-bf16", AArch64::AEK_NONE, {}, {}, FEAT_SVE_BF16, "+sve,+bf16,+fullfp16,+fp-armv8,+neon", 320},

@Lukacma
Copy link
Contributor Author

Lukacma commented Feb 20, 2024

Testcase added

Copy link
Contributor

@CarolineConcatto CarolineConcatto left a comment

Choose a reason for hiding this comment

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

Thank you @Lukacma

@Lukacma Lukacma merged commit 02e17ab into llvm:main Feb 21, 2024
3 of 4 checks passed
@Lukacma Lukacma deleted the clang-cc1-issue branch February 21, 2024 12:29
Copy link

@Lukacma Congratulations on having your first Pull Request (PR) merged into the LLVM Project!

Your changes will be combined with recent changes from other authors, then tested
by our build bots. If there is a problem with a build, you may recieve a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as
the builds can include changes from many authors. It is not uncommon for your
change to be included in a build that fails due to someone else's changes, or
infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail here.

If your change does cause a problem, it may be reverted, or you can revert it yourself.
This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants