SuperDex Physics C++ API
Loading...
Searching...
No Matches
arm_simd_inl.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19/**
20 This file contains Simd specializations for ARM CPUs with NEON support.
21*/
22
23#include "../../simd.h" // for IntelliSense
24
25#if MOCHI_USE_SIMD && MOCHI_ARCH_ARM_NEON
26
27#include <arm_neon.h>
28
29/***********************************************************************************************
30 Simd Specializations for ARM Architecture
31*/
32
33// NOTE: Order of these headers matters in some cases. Do not sort alphabetically.
34
35#include "arm_simd_tables_inl.h"
36
37#include "arm_simd_int_4_inl.h"
38
40
42
44
45/***********************************************************************************************
46 Simd Utilities for ARM Architecture
47*/
48
49namespace superdex {
50
51// clang-format off
52template<> MOCHI_FORCE_INLINE Simd<double, 2> StaticCast<Simd<double, 2>, Simd<int64_t, 2>>(Simd<int64_t, 2> const& a) { return vcvtq_f64_s64(a.raw); }
53template<> MOCHI_FORCE_INLINE Simd<int64_t, 2> StaticCast<Simd<int64_t, 2>, Simd<double, 2>>(Simd<double, 2> const& a) { return vcvtq_s64_f64(a.raw); }
54template<> MOCHI_FORCE_INLINE Simd<float, 4> StaticCast<Simd<float, 4>, Simd<int, 4>>(Simd<int, 4> const& a) { return vcvtq_f32_s32(a.raw); }
55template<> MOCHI_FORCE_INLINE Simd<int, 4> StaticCast<Simd<int, 4>, Simd<float, 4>>(Simd<float, 4> const& a) { return vcvtq_s32_f32(a.raw); }
56
57template<> MOCHI_FORCE_INLINE Simd<double, 2> ReinterpretCast<Simd<double, 2>, Simd<int64_t, 2>>(Simd<int64_t, 2> const& a) { return vreinterpretq_f64_s64(a.raw); }
58template<> MOCHI_FORCE_INLINE Simd<double, 2> ReinterpretCast<Simd<double, 2>, Simd<float, 4>>(Simd<float, 4> const& a) { return vreinterpretq_f64_f32(a.raw); }
59template<> MOCHI_FORCE_INLINE Simd<double, 2> ReinterpretCast<Simd<double, 2>, Simd<int, 4>>(Simd<int, 4> const& a) { return vreinterpretq_f64_s32(a.raw); }
60template<> MOCHI_FORCE_INLINE Simd<int64_t, 2> ReinterpretCast<Simd<int64_t, 2>, Simd<double, 2>>(Simd<double, 2> const& a) { return vreinterpretq_s64_f64(a.raw); }
61template<> MOCHI_FORCE_INLINE Simd<int64_t, 2> ReinterpretCast<Simd<int64_t, 2>, Simd<float, 4>>(Simd<float, 4> const& a) { return vreinterpretq_s64_f32(a.raw); }
62template<> MOCHI_FORCE_INLINE Simd<int64_t, 2> ReinterpretCast<Simd<int64_t, 2>, Simd<int, 4>>(Simd<int, 4> const& a) { return vreinterpretq_s64_s32(a.raw); }
63template<> MOCHI_FORCE_INLINE Simd<float, 4> ReinterpretCast<Simd<float, 4>, Simd<double, 2>>(Simd<double, 2> const& a) { return vreinterpretq_f32_f64(a.raw); }
64template<> MOCHI_FORCE_INLINE Simd<float, 4> ReinterpretCast<Simd<float, 4>, Simd<int64_t, 2>>(Simd<int64_t, 2> const& a) { return vreinterpretq_f32_s64(a.raw); }
65template<> MOCHI_FORCE_INLINE Simd<float, 4> ReinterpretCast<Simd<float, 4>, Simd<int, 4>>(Simd<int, 4> const& a) { return vreinterpretq_f32_s32(a.raw); }
66template<> MOCHI_FORCE_INLINE Simd<int, 4> ReinterpretCast<Simd<int, 4>, Simd<double, 2>>(Simd<double, 2> const& a) { return vreinterpretq_s32_f64(a.raw); }
67template<> MOCHI_FORCE_INLINE Simd<int, 4> ReinterpretCast<Simd<int, 4>, Simd<int64_t, 2>>(Simd<int64_t, 2> const& a) { return vreinterpretq_s32_s64(a.raw); }
68template<> MOCHI_FORCE_INLINE Simd<int, 4> ReinterpretCast<Simd<int, 4>, Simd<float, 4>>(Simd<float, 4> const& a) { return vreinterpretq_s32_f32(a.raw); }
69// clang-format on
70
71} // namespace superdex
72
73#endif // MOCHI_USE_SIMD && MOCHI_ARCH_ARM_NEON
#define MOCHI_FORCE_INLINE
constexpr To StaticCast(From const &a)
Definition basic_utils.h:79