1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

[ARM][TargetParser] Improve handling of dependencies between target features

The patch at https://reviews.llvm.org/D64048 added "negative"
dependency handling in `ARM::appendArchExtFeatures`: feature "noX"
removes all features, which imply "X".

This patch adds the "positive" handling: feature "X" adds all the
feature strings implied by "X".

(This patch also comes from the suggestion here
https://reviews.llvm.org/D72633#inline-658582)

Differential Revision: https://reviews.llvm.org/D72762
This commit is contained in:
Momchil Velikov 2020-02-05 15:19:03 +00:00
parent 16edf004ac
commit ad184987b8
2 changed files with 28 additions and 4 deletions

View File

@ -498,10 +498,13 @@ bool ARM::appendArchExtFeatures(
return false;
for (const auto AE : ARCHExtNames) {
if (Negated && (AE.ID & ID) == ID && AE.NegFeature)
Features.push_back(AE.NegFeature);
else if (AE.ID == ID && AE.Feature)
Features.push_back(AE.Feature);
if (Negated) {
if ((AE.ID & ID) == ID && AE.NegFeature)
Features.push_back(AE.NegFeature);
} else {
if ((AE.ID & ID) == AE.ID && AE.Feature)
Features.push_back(AE.Feature);
}
}
if (CPU == "")

View File

@ -637,6 +637,27 @@ TEST(TargetParserTest, ARMArchExtFeature) {
}
}
static bool
testArchExtDependency(const char *ArchExt,
const std::initializer_list<const char *> &Expected) {
std::vector<StringRef> Features;
if (!ARM::appendArchExtFeatures("", ARM::ArchKind::ARMV8_1MMainline, ArchExt,
Features))
return false;
return llvm::all_of(Expected, [&](StringRef Ext) {
return llvm::is_contained(Features, Ext);
});
}
TEST(TargetParserTest, ARMArchExtDependencies) {
EXPECT_TRUE(testArchExtDependency("mve", {"+mve", "+dsp"}));
EXPECT_TRUE(testArchExtDependency("mve.fp", {"+mve.fp", "+mve", "+dsp"}));
EXPECT_TRUE(testArchExtDependency("nodsp", {"-dsp", "-mve", "-mve.fp"}));
EXPECT_TRUE(testArchExtDependency("nomve", {"-mve", "-mve.fp"}));
}
TEST(TargetParserTest, ARMparseHWDiv) {
const char *hwdiv[] = {"thumb", "arm", "arm,thumb", "thumb,arm"};