This is an archive of the discontinued LLVM Phabricator instance.

[llvm][AArch64] Generate getExtensionFeatures from the list of extensions
ClosedPublic

Authored by DavidSpickett on Apr 7 2022, 3:23 AM.

Details

Summary

This takes the AARCH64_ARCH_EXT_NAME in AArch64TargetParser.def and uses
it to generate all the "if bit is set add this feature name" code.

Which gives us a bunch that we were missing. I've updated testing
to include those and reordered them to match the order in the .def.

The final part of the test will catch any missing extensions if
we somehow manage to not generate an if block for them.

This has changed the order of cc1's "-target-feature" output so I've
updated some tests in clang to reflect that.

Diff Detail

Event Timeline

DavidSpickett created this revision.Apr 7 2022, 3:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 7 2022, 3:23 AM
DavidSpickett requested review of this revision.Apr 7 2022, 3:23 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptApr 7 2022, 3:23 AM

The background here is that I want to automate what I did in https://reviews.llvm.org/D121999 and thought I could do that by passing 0xf...f to getExtensionFeatures.

I thought there might be some reason to not list them all but considering that things like mte were missing I don't think there is. More likely that any time we were adding something like +mte we went through a different function in the target parser.

clang/test/Preprocessor/aarch64-target-features.c
288

Some of the ordering has changed and that means some tests look for new features. The CPU already had these features, the test just didn't check for them before and now they've been inserted into what it's looking for.

We could change all these to look for the exact feature set but to be conservative I stuck to re-ordering them and adding just enough to get them passing again.

llvm/lib/Support/AArch64TargetParser.cpp
69

This looks a bit strange but you can't do:

Features.push_back(FEATURE);

Because you get:

Features.push_back(nullptr);

Which calls a deleted constructor, and we don't want empty feature strings in any case.

So that's why I assign it to something so that the push_back line can still be compiled.

tmatheson accepted this revision.Apr 11 2022, 5:34 AM
tmatheson added inline comments.
llvm/unittests/Support/TargetParserTest.cpp
1475–1478

Does this need a similar test for NONE?

This revision is now accepted and ready to land.Apr 11 2022, 5:34 AM

Added check that NONE does not return any feature names.

Fix a spelling mistake.

This revision was landed with ongoing or failed builds.Apr 11 2022, 6:42 AM
This revision was automatically updated to reflect the committed changes.