Skip to content

Commit

Permalink
[Target] Make key=arm_cpu --> key=arm_cpu,cpu on AArch64 (apache#…
Browse files Browse the repository at this point in the history
…13775)

* arm cpu is cpu

* init commit

* fix test
  • Loading branch information
AndrewZhaoLuo authored Jan 13, 2023
1 parent bd3d93b commit 5878f60
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/target/parsers/aprofile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,17 @@ static TargetFeatures GetFeatures(TargetJSON target) {
}

static Array<String> MergeKeys(Optional<Array<String>> existing_keys) {
const String kExtraKey = "arm_cpu";
const Array<String> kExtraKeys = {"arm_cpu", "cpu"};

if (!existing_keys) {
return {kExtraKey};
return kExtraKeys;
}

Array<String> keys = existing_keys.value();
if (std::find(keys.begin(), keys.end(), kExtraKey) == keys.end()) {
keys.push_back(kExtraKey);
for (String key : kExtraKeys) {
if (std::find(keys.begin(), keys.end(), key) == keys.end()) {
keys.push_back(key);
}
}
return keys;
}
Expand Down
3 changes: 2 additions & 1 deletion tests/cpp/target/parsers/aprofile_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ static TargetFeatures ParseTargetWithAttrs(String mcpu, String mtriple, Array<St
TEST(AProfileParser, ParseTargetKeys) {
TargetJSON target = ParseTarget({});
Array<String> keys = Downcast<Array<String>>(target.at("keys"));
ASSERT_EQ(keys.size(), 1);
ASSERT_EQ(keys.size(), 2);
ASSERT_EQ(keys[0], "arm_cpu");
ASSERT_EQ(keys[1], "cpu");
}

TEST(AProfileParser, ParseTargetWithExistingKeys) {
Expand Down

0 comments on commit 5878f60

Please sign in to comment.