This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][AsmParser] Arch directives should set implied features.
ClosedPublic

Authored by sdesmalen on Feb 21 2022, 9:35 AM.

Details

Summary

When assembling for example an SVE instruction with the .arch +sve2 directive,
+sve should be implied by setting +sve2, similar to what would happen if
one would pass the mattr=+sve2 flag on the command-line.

The AsmParser doesn't set the implied features, meaning that the SVE
instruction does not assemble. This patch fixes that.

Note that the same does not hold when disabling a feature. For example,
+nosve2 does not imply +nosve.

Diff Detail

Event Timeline

sdesmalen created this revision.Feb 21 2022, 9:35 AM
sdesmalen requested review of this revision.Feb 21 2022, 9:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 21 2022, 9:35 AM
c-rhodes added inline comments.
llvm/test/MC/AArch64/SVE/directive-arch_extension-negative.s
12 ↗(On Diff #410327)

SVE is never enabled so I don't think this is doing what you intended, plus this instruction will be in the output for both pass/fail? I'm not sure it makes sense to mix positive/negative tests like this. As an aside, I'm not sure what my original intention was with this test but it would make sense to enable the feature before disabling it to verify nosve is doing what it's supposed to.

llvm/test/MC/AArch64/SVE/directive-arch_extension.s
7–12

unlike .arch, .arch_extension doesn't clear any previously selected architecture extensions, probably best to disable SVE with .arch_extension nosve first.

llvm/test/MC/AArch64/SVE/directive-cpu-negative.s
3

enable SVE before disabling it?

9–13

I think this belongs in the positive test.

sdesmalen updated this revision to Diff 410476.Feb 22 2022, 1:27 AM
sdesmalen marked 4 inline comments as done.

Addressed @c-rhodes' comments.

llvm/test/MC/AArch64/SVE/directive-arch_extension-negative.s
12 ↗(On Diff #410327)

Good point!

llvm/test/MC/AArch64/SVE/directive-arch_extension.s
7–12

Good point!

llvm/test/MC/AArch64/SVE/directive-cpu-negative.s
3

Good suggestion, this actually exposed a bug in the existing implementation of .cpu directive!
https://godbolt.org/z/MndP97soh

c-rhodes accepted this revision.Feb 22 2022, 12:19 PM
This revision is now accepted and ready to land.Feb 22 2022, 12:19 PM
This revision was landed with ongoing or failed builds.Feb 24 2022, 1:16 AM
This revision was automatically updated to reflect the committed changes.