[llvm][Arm/AArch64] Format extension flags in CPU test failures
authorDavid Spickett <david.spickett@linaro.org>
Thu, 17 Dec 2020 10:52:37 +0000 (10:52 +0000)
committerDavid Spickett <david.spickett@linaro.org>
Tue, 22 Dec 2020 11:13:36 +0000 (11:13 +0000)
commit781a816d4cacbd0e73d36b12f82c87c0393b5a5b
tree5e5175c55923e5ae9b78f4ef3cda2996d9ce5652
parent4d59c8fdb955ea0d668b854f467e12bce05a8857
[llvm][Arm/AArch64] Format extension flags in CPU test failures

Previously you just two hex numbers you had to decode manually.
This change adds a predicate formatter for extension flags
to produce failure messages like:
```
[ RUN      ] AArch64CPUTests/AArch64CPUTestFixture.testAArch64CPU/2
<...>llvm/unittests/Support/TargetParserTest.cpp:862:
Failure
Expected extension flags: +fp-armv8, +crc, +crypto (0xe)
     Got extension flags: +fp-armv8, +neon, +crc, +crypto (0x1e)
[  FAILED  ] AArch64CPUTests/AArch64CPUTestFixture.testAArch64CPU/2,
where GetParam() = "cortex-a34", "armv8-a", <...>
```

From there you can take the feature name and map it back
to the enum in ARM/AArch64TargetParser.def.
(which isn't perfect but you've probably got both files
open if you're editing these tests)

Note that AEK_NONE is not meant to be user facing in the compiler
but here it is part of the tests. So failures may show an
extension "none" where the normal target parser wouldn't.

The formatter is implemented as a template on ARM::ISAKind
because the predicate formatters assume all parameters are used
for comparison.
(e.g. PRED_FORMAT3 is for comparing 3 values, not having 3
arguments in general)

Reviewed By: MarkMurrayARM

Differential Revision: https://reviews.llvm.org/D93448
llvm/unittests/Support/TargetParserTest.cpp