This is an archive of the discontinued LLVM Phabricator instance.

[Clang][SVE] Properly enable/disable dependant SVE target features based upon +(no)sve.* options
ClosedPublic

Authored by bsmith on Nov 12 2021, 8:06 AM.

Diff Detail

Event Timeline

bsmith created this revision.Nov 12 2021, 8:06 AM
bsmith requested review of this revision.Nov 12 2021, 8:06 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptNov 12 2021, 8:06 AM
tschuett added inline comments.Nov 12 2021, 8:42 AM
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
66

This is almost an enum class.

enum class OptState { Unset, True, False };
llvm/unittests/Support/TargetParserTest.cpp
913

Has AEK_SVE2 been doubled up in this constant?

bsmith updated this revision to Diff 387212.Nov 15 2021, 4:20 AM
bsmith edited the summary of this revision. (Show Details)
  • Fix duplicate arch feature in unit test
  • Use enum class instead of plain enum with typedef
mgabka added inline comments.Nov 15 2021, 7:32 AM
clang/test/Driver/aarch64-implied-sve-features.c
29

Hi,
@bsmith could you at at least one test for +nosve2-sha3, +nosve2-aes and +nosve2-sm4?

sdesmalen added inline comments.Nov 16 2021, 9:56 AM
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
66

You can use Optional<bool> to avoid adding a new enum class.

68

does the order of the features matter?

+sve,+nosve => disables sve
+nosve,+sve => enables sve
+nosve,+sve2 => enables sve and sve2
bsmith added inline comments.Nov 16 2021, 9:59 AM
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
68

Yes it does, but I believe that is the desired behaviour.

sdesmalen added inline comments.Nov 16 2021, 10:04 AM
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
68

Doesn't your patch change this behaviour? The condition on line 147 no longer considers the original order of the flags.

bsmith updated this revision to Diff 387900.Nov 17 2021, 4:40 AM
  • Use more brute force approach to ensure ordering is accounted for
    • This massively simplifies things and removes what was becoming very confusing logic
  • Add tests for missing cases
sdesmalen added inline comments.Nov 17 2021, 6:21 AM
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
82–88

^^^ Are the above changes necessary? i.e. if only +sve2-sha3 is set as target feature, I thought LLVM automatically infers that it requires +sve and +sve2. Is that not the case?

bsmith added inline comments.Nov 17 2021, 7:15 AM
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
82–88

That is the case yes, however this code is to catch combinations, for example +sve2-bitperm+nosve2 needs to keep sve enabled, if +sve was never in the feature set this wouldn't be the case.

sdesmalen accepted this revision.Nov 17 2021, 7:18 AM

LGTM!

clang/lib/Driver/ToolChains/Arch/AArch64.cpp
82–88

That makes sense, thanks.

This revision is now accepted and ready to land.Nov 17 2021, 7:18 AM
Matt added a subscriber: Matt.Nov 17 2021, 12:05 PM
This revision was landed with ongoing or failed builds.Nov 18 2021, 7:52 AM
This revision was automatically updated to reflect the committed changes.

The tests in this are broken for windows, which I've fixed in 45e102a173680fd3c90def79a7f0766ed2786ff0.