Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions src/CodeGen_ARM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ Target complete_arm_target(Target t) {
t.set_feature(Target::ARMv84a);
}

auto add_implied_feature_if_supported = [](Target &t, Target::Feature super, Target::Feature implied) {
if (t.has_feature(super)) {
t.set_feature(implied);
}
};

constexpr int num_arm_v8_features = 10;
static const Target::Feature arm_v8_features[num_arm_v8_features] = {
Target::ARMv89a,
Expand All @@ -65,9 +71,26 @@ Target complete_arm_target(Target t) {
};

for (int i = 0; i < num_arm_v8_features - 1; i++) {
if (t.has_feature(arm_v8_features[i])) {
t.set_feature(arm_v8_features[i + 1]);
}
add_implied_feature_if_supported(t,
arm_v8_features[i],
arm_v8_features[i + 1]);
}

static const Target::Feature features_with_fp16[] = {
Target::SVE,
Target::SVE2,
};

for (const auto &f : features_with_fp16) {
add_implied_feature_if_supported(t, f, Target::ARMFp16);
}

static const Target::Feature features_with_dotprod[] = {
Target::SVE2,
};

for (const auto &f : features_with_dotprod) {
add_implied_feature_if_supported(t, f, Target::ARMDotProd);
}

return t;
Expand Down Expand Up @@ -1004,7 +1027,7 @@ void CodeGen_ARM::init_module() {
}

for (const ArmIntrinsic &intrin : intrinsic_defs) {
if (intrin.flags & ArmIntrinsic::RequireFp16 && !target.has_feature(Target::ARMFp16)) {
if ((intrin.flags & ArmIntrinsic::RequireFp16) && !target.has_feature(Target::ARMFp16)) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion test/correctness/simd_op_check_sve2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,7 @@ class SimdOpCheckArmSve : public SimdOpCheckTest {
};

bool is_float16_supported() const {
return (target.bits == 64) && target.has_feature(Target::ARMFp16);
return (target.bits == 64) && target.features_any_of({Target::ARMFp16, Target::SVE, Target::SVE2});
}

bool can_run_the_code;
Expand Down
2 changes: 1 addition & 1 deletion test/warning/emulated_float16.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ int main(int argc, char **argv) {

// Make sure target has no float16 native support
Target t = get_host_target();
for (auto &feature : {Target::F16C, Target::ARMFp16}) {
for (auto &feature : {Target::F16C, Target::ARMFp16, Target::SVE, Target::SVE2}) {
t = t.without_feature(feature);
}

Expand Down
Loading