Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for arm64e (Fixes #4490) #8330

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions python_bindings/src/halide/halide_/PyEnums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ void define_enums(py::module &m) {
.value("ARMv87a", Target::Feature::ARMv87a)
.value("ARMv88a", Target::Feature::ARMv88a)
.value("ARMv89a", Target::Feature::ARMv89a)
.value("ARM64e", Target::Feature::ARM64e)
.value("SanitizerCoverage", Target::Feature::SanitizerCoverage)
.value("ProfileByTimer", Target::Feature::ProfileByTimer)
.value("SPIRV", Target::Feature::SPIRV)
Expand Down
11 changes: 10 additions & 1 deletion src/CodeGen_ARM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ namespace {
//
// v8r has no relation to anything.
Target complete_arm_target(Target t) {
// If arm64e is set, assume at least arm8.3a
if (t.has_feature(Target::ARM64e)) {
t.set_feature(Target::ARMv83a);
}

constexpr int num_arm_v8_features = 10;
static const Target::Feature arm_v8_features[num_arm_v8_features] = {
Target::ARMv89a,
Expand Down Expand Up @@ -2473,7 +2478,11 @@ string CodeGen_ARM::mcpu_target() const {
}
} else {
if (target.os == Target::IOS) {
return "apple-a7";
if (target.has_feature(Target::ARM64e)) {
return "apple-a12";
} else {
return "apple-a7";
}
} else if (target.os == Target::OSX) {
return "apple-m1";
} else if (target.has_feature(Target::SVE2)) {
Expand Down
6 changes: 5 additions & 1 deletion src/LLVM_Runtime_Linker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,11 @@ llvm::Triple get_triple_for_target(const Target &target) {
} else {
user_assert(target.bits == 64) << "Target bits must be 32 or 64\n";
#ifdef WITH_AARCH64
triple.setArch(llvm::Triple::aarch64);
if (target.has_feature(Target::ARM64e)) {
triple.setArch(llvm::Triple::aarch64, llvm::Triple::AArch64SubArch_arm64e);
} else {
triple.setArch(llvm::Triple::aarch64);
}
#else
user_error << "AArch64 llvm target not enabled in this build of Halide\n";
#endif
Expand Down
5 changes: 4 additions & 1 deletion src/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,7 @@ const std::map<std::string, Target::Feature> feature_name_map = {
{"armv87a", Target::ARMv87a},
{"armv88a", Target::ARMv88a},
{"armv89a", Target::ARMv89a},
{"arm64e", Target::ARM64e},
{"sanitizer_coverage", Target::SanitizerCoverage},
{"profile_by_timer", Target::ProfileByTimer},
{"spirv", Target::SPIRV},
Expand Down Expand Up @@ -1504,7 +1505,7 @@ bool Target::get_runtime_compatible_target(const Target &other, Target &result)
// (c) must match across both targets; it is an error if one target has the feature and the other doesn't

// clang-format off
const std::array<Feature, 33> union_features = {{
const std::array<Feature, 34> union_features = {{
// These are true union features.
CUDA,
D3D12Compute,
Expand Down Expand Up @@ -1545,6 +1546,8 @@ bool Target::get_runtime_compatible_target(const Target &other, Target &result)
ARMv87a,
ARMv88a,
ARMv89a,

ARM64e,
}};
// clang-format on

Expand Down
1 change: 1 addition & 0 deletions src/Target.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ struct Target {
ARMv87a = halide_target_feature_armv87a,
ARMv88a = halide_target_feature_armv88a,
ARMv89a = halide_target_feature_armv89a,
ARM64e = halide_target_feature_arm64e,
SanitizerCoverage = halide_target_feature_sanitizer_coverage,
ProfileByTimer = halide_target_feature_profile_by_timer,
SPIRV = halide_target_feature_spirv,
Expand Down
1 change: 1 addition & 0 deletions src/runtime/HalideRuntime.h
Original file line number Diff line number Diff line change
Expand Up @@ -1444,6 +1444,7 @@ typedef enum halide_target_feature_t {
halide_target_feature_armv87a, ///< Enable ARMv8.7a instructions
halide_target_feature_armv88a, ///< Enable ARMv8.8a instructions
halide_target_feature_armv89a, ///< Enable ARMv8.9a instructions
halide_target_feature_arm64e, ///< Enable ARM64e (requires ARMv8.3a)
halide_target_feature_sanitizer_coverage, ///< Enable hooks for SanitizerCoverage support.
halide_target_feature_profile_by_timer, ///< Alternative to halide_target_feature_profile using timer interrupt for systems without threads or applicartions that need to avoid them.
halide_target_feature_spirv, ///< Enable SPIR-V code generation support.
Expand Down
1 change: 1 addition & 0 deletions test/correctness/cross_compilation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ int main(int argc, char **argv) {
"arm-64-ios-armv87a",
"arm-64-ios-armv88a",
"arm-64-ios-armv89a",
"arm-64-ios-arm64e",
"arm-64-linux",
"arm-64-noos-semihosting",
"arm-64-windows",
Expand Down
1 change: 1 addition & 0 deletions test/correctness/simd_op_check.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class SimdOpCheckTest {
Target::ARMv87a,
Target::ARMv88a,
Target::ARMv89a,
Target::ARM64e,
Target::AVX,
Target::AVX2,
Target::AVX512,
Expand Down
Loading