Skip to content

Commit

Permalink
Provide modeling and runtime detection of imm8 arm extension
Browse files Browse the repository at this point in the history
Some extra thoughts could be done on the way we model instruction set
extensions, I'm not happy with the way it's currently done.
  • Loading branch information
serge-sans-paille committed Feb 20, 2024
1 parent ead0742 commit 9da4b29
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 1 deletion.
17 changes: 17 additions & 0 deletions include/xsimd/arch/xsimd_imm8_neon64.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/***************************************************************************
* Copyright (c) Johan Mabille, Sylvain Corlay, Wolf Vollprecht and *
* Martin Renou *
* Copyright (c) QuantStack *
* Copyright (c) Serge Guelton *
* *
* Distributed under the terms of the BSD 3-Clause License. *
* *
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/

#ifndef XSIMD_IMM8_NEON64_HPP
#define XSIMD_IMM8_NEON64_HPP

#include "../types/xsimd_imm8_neon64_register.hpp"

#endif
2 changes: 1 addition & 1 deletion include/xsimd/config/xsimd_arch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ namespace xsimd

using all_sve_architectures = arch_list<detail::sve<512>, detail::sve<256>, detail::sve<128>>;
using all_rvv_architectures = arch_list<detail::rvv<512>, detail::rvv<256>, detail::rvv<128>>;
using all_arm_architectures = typename detail::join<all_sve_architectures, arch_list<neon64, neon>>::type;
using all_arm_architectures = typename detail::join<all_sve_architectures, arch_list<imm8<neon64>, neon64, neon>>::type;
using all_riscv_architectures = all_rvv_architectures;
using all_wasm_architectures = arch_list<wasm>;
using all_architectures = typename detail::join<all_riscv_architectures, all_wasm_architectures, all_arm_architectures, all_x86_architectures>::type;
Expand Down
4 changes: 4 additions & 0 deletions include/xsimd/config/xsimd_cpuid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ namespace xsimd
ARCH_FIELD_EX(avx512vnni<::xsimd::avx512vbmi>, avx512vnni_vbmi)
ARCH_FIELD(neon)
ARCH_FIELD(neon64)
ARCH_FIELD(imm8_neon64)
ARCH_FIELD(sve)
ARCH_FIELD(rvv)
ARCH_FIELD(wasm)
Expand All @@ -83,6 +84,9 @@ namespace xsimd
#if defined(__aarch64__) || defined(_M_ARM64)
neon = 1;
neon64 = 1;
#if defined(__linux__) && (!defined(__ANDROID_API__) || __ANDROID_API__ >= 18)
imm8_neon64 = bool(getauxval(AT_HWCAP2) & HWCAP2_I8MM);
#endif
#elif defined(__ARM_NEON) || defined(_M_ARM)

#if defined(__linux__) && (!defined(__ANDROID_API__) || __ANDROID_API__ >= 18)
Expand Down
46 changes: 46 additions & 0 deletions include/xsimd/types/xsimd_imm8_neon64_register.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/***************************************************************************
* Copyright (c) Johan Mabille, Sylvain Corlay, Wolf Vollprecht and *
* Martin Renou *
* Copyright (c) QuantStack *
* Copyright (c) Serge Guelton *
* *
* Distributed under the terms of the BSD 3-Clause License. *
* *
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/

#ifndef XSIMD_IMM8_NEON64_REGISTER_HPP
#define XSIMD_IMM8_NEON64_REGISTER_HPP

#include "./xsimd_neon64_register.hpp"

namespace xsimd
{
template <typename arch>
struct imm8;

/**
* @ingroup architectures
*
* Neon64 + imm8 instructions
*/
template <>
struct imm8<neon64> : neon64
{
static constexpr bool supported() noexcept { return XSIMD_WITH_IMM8_NEON64; }
static constexpr bool available() noexcept { return true; }
static constexpr unsigned version() noexcept { return generic::version(8, 2, 0); }
static constexpr char const* name() noexcept { return "imm8+neon64"; }
};

#if XSIMD_WITH_IMM8_NEON64
namespace types
{

XSIMD_DECLARE_SIMD_REGISTER_ALIAS(imm8<neon64>, neon64);

}
#endif

}
#endif

0 comments on commit 9da4b29

Please sign in to comment.