From 40ea449044e4c3959ca079fa503d20bf3aa514ab Mon Sep 17 00:00:00 2001 From: Andrew Adams Date: Tue, 5 Dec 2023 14:15:23 -0800 Subject: [PATCH] Add appropriate mattrs for arm-32 extensions (#7978) * Add appropriate mattrs for arm-32 extensions Fixes #7976 * Pull clauses out of if --- src/CodeGen_ARM.cpp | 46 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/src/CodeGen_ARM.cpp b/src/CodeGen_ARM.cpp index 826f3723e4bf..03678e5ef605 100644 --- a/src/CodeGen_ARM.cpp +++ b/src/CodeGen_ARM.cpp @@ -1647,19 +1647,34 @@ string CodeGen_ARM::mcpu_tune() const { } string CodeGen_ARM::mattrs() const { + string arch_flags; + string separator; + if (target.has_feature(Target::ARMFp16)) { + arch_flags += separator + "+fullfp16"; + separator = ","; + } + if (target.has_feature(Target::ARMv81a)) { + arch_flags += separator + "+v8.1a"; + separator = ","; + } + if (target.has_feature(Target::ARMDotProd)) { + arch_flags += separator + "+dotprod"; + separator = ","; + } if (target.bits == 32) { if (target.has_feature(Target::ARMv7s)) { - return "+neon"; + arch_flags += separator + "+neon"; + separator = ","; } if (!target.has_feature(Target::NoNEON)) { - return "+neon"; + arch_flags += separator + "+neon"; + separator = ","; } else { - return "-neon"; + arch_flags += separator + "-neon"; + separator = ","; } } else { // TODO: Should Halide's SVE flags be 64-bit only? - string arch_flags; - string separator; if (target.has_feature(Target::SVE2)) { arch_flags = "+sve2"; separator = ","; @@ -1667,28 +1682,11 @@ string CodeGen_ARM::mattrs() const { arch_flags = "+sve"; separator = ","; } - - if (target.has_feature(Target::ARMv81a)) { - arch_flags += separator + "+v8.1a"; - separator = ","; - } - - if (target.has_feature(Target::ARMDotProd)) { - arch_flags += separator + "+dotprod"; - separator = ","; - } - - if (target.has_feature(Target::ARMFp16)) { - arch_flags += separator + "+fullfp16"; - separator = ","; - } - if (target.os == Target::IOS || target.os == Target::OSX) { - return arch_flags + separator + "+reserve-x18"; - } else { - return arch_flags; + arch_flags += separator + "+reserve-x18"; } } + return arch_flags; } bool CodeGen_ARM::use_soft_float_abi() const {