Skip to content

Conversation

@folkertdev
Copy link
Contributor

fixes #146866

The issue discusses that it is unfortunate that command line flag parsing and assembly parsing don't share the infrastructure for recognizing features, which can lead to inconsistencies like here. I don't really see how I can combine them though, so for now this change will fix the immediate problem.

@llvmbot
Copy link
Member

llvmbot commented Nov 29, 2025

@llvm/pr-subscribers-backend-aarch64

Author: Folkert de Vries (folkertdev)

Changes

fixes #146866

The issue discusses that it is unfortunate that command line flag parsing and assembly parsing don't share the infrastructure for recognizing features, which can lead to inconsistencies like here. I don't really see how I can combine them though, so for now this change will fix the immediate problem.


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

2 Files Affected:

  • (modified) llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp (+1)
  • (modified) llvm/test/MC/AArch64/directive-arch_extension.s (+4)
diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
index 433cb0387c470..7116fd0ea3b6f 100644
--- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -3954,6 +3954,7 @@ static const struct Extension {
     {"poe2", {AArch64::FeatureS1POE2}},
     {"tev", {AArch64::FeatureTEV}},
     {"btie", {AArch64::FeatureBTIE}},
+    {"dit", {AArch64::FeatureDIT}},
 };
 
 static void setRequiredFeatureString(FeatureBitset FBS, std::string &Str) {
diff --git a/llvm/test/MC/AArch64/directive-arch_extension.s b/llvm/test/MC/AArch64/directive-arch_extension.s
index 3c754077572a1..f174e9d4d187e 100644
--- a/llvm/test/MC/AArch64/directive-arch_extension.s
+++ b/llvm/test/MC/AArch64/directive-arch_extension.s
@@ -197,3 +197,7 @@ fmmla v1.8h, v2.16b, v3.16b
 .arch_extension f8f32mm
 fmmla v1.4s, v2.16b, v3.16b
 // CHECK: fmmla v1.4s, v2.16b, v3.16b
+
+.arch_extension dit
+msr DIT, #1
+// CHECK: msr DIT, #1

@davemgreen
Copy link
Collaborator

GCC doesn't support this (https://gcc.godbolt.org/z/EcvKh4Tjv), but if there is a -march option then it sounds OK to add one. The other alternative is to remove the need for +dit, like GCC has it. See for example #163166. I believe there is the idea that sys-reg only extensions do not give an error, as you can only write the assembly where you know they are useful. I think either is fine, I'm not sure what others think and whether I've mis-remembered the idea of MSR sysregs.

jthackray
jthackray approved these changes Dec 1, 2025
Copy link
Collaborator

@efriedma-quic efriedma-quic left a comment

Choose a reason for hiding this comment

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

I think the set of extensions we support with march should be the same as the list here.

Going through the list, the following are missing:

brbe
bti
fcma
jscvt
pauth-lr
pmuv3
ssve-fexpa
wfxt

Maybe we can do them all in one batch?


I think this is worth fixing regardless of whether we require dit for the asm parser to parse msr DIT.

@folkertdev
Copy link
Contributor Author

I added all of those except for pmuv3, which is apparently called perfmon as a cli arg, but I could not find a test that fails when the feature is not enabled, it looks like it's just always on?

In general the names are not always consistent. I'm using the name that shows up in the error message when the feature is not present.

@efriedma-quic
Copy link
Collaborator

We shouldn't be exposing "complxnum" to users; it's the internal name which... I guess we picked before there was a standard name. If it's showing up in error messages, that's a bug in the diagnostic code.

@folkertdev
Copy link
Contributor Author

I fixed that one so fcma shows up in the error message, we'll see if that has knock-on consequences.

What about jscvt versus jsconv?

@github-actions
Copy link

github-actions bot commented Dec 2, 2025

🐧 Linux x64 Test Results

  • 186864 tests passed
  • 4918 tests skipped

✅ The build succeeded and all tests passed.

@folkertdev
Copy link
Contributor Author

Looks like the complxnum name is already visible to users also as a command line argument

https://github.com/llvm/llvm-project/blob/main/llvm/test/MC/AArch64/armv8.3a-complex_missing.s

So, can that just be changed?

@efriedma-quic
Copy link
Collaborator

Looks like the complxnum name is already visible to users also as a command line argument

-mattr is the LLVM internal notion of "attributes", not the architecture extension names defined by Arm. They mostly match, but not completely, for historical reasons.

So, can that just be changed?

It's fine if the diagnostics don't match the -mattr flag.

Copy link
Collaborator

@efriedma-quic efriedma-quic left a comment

Choose a reason for hiding this comment

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

Please make sure the commit message reflects the extended change. Otherwise LGTM, but maybe give a couple days if anyone has a second opinion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aarch64: dit target feature cannot be reliably en/disabled from assembly

5 participants