blob: 495ddbb1af18209f2acd66981c54601a0b1c79e5 [file] [log] [blame]
Georgios Pinitas82833b82018-01-30 12:14:24 +00001/*
2 * Copyright (c) 2018 ARM Limited.
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#ifndef __ARM_COMPUTE_WRAPPER_TRAITS_H__
25#define __ARM_COMPUTE_WRAPPER_TRAITS_H__
26
27#include <arm_neon.h>
28
29namespace arm_compute
30{
31namespace wrapper
32{
33namespace traits
34{
35// *INDENT-OFF*
36// clang-format off
37
Georgios Pinitas57c033b2018-02-15 12:29:44 +000038/** 64-bit vector tag */
39struct vector_64_tag {};
40/** 128-bit vector tag */
41struct vector_128_tag {};
42
Georgios Pinitas82833b82018-01-30 12:14:24 +000043/** Create the appropriate NEON vector given its type and size */
44template <typename T, int S> struct neon_vector;
Alex Gildayc357c472018-03-21 13:54:09 +000045// Specializations
46#ifndef DOXYGEN_SKIP_THIS
Georgios Pinitas57c033b2018-02-15 12:29:44 +000047template <> struct neon_vector<uint8_t, 8>{ using type = uint8x8_t; using tag_type = vector_64_tag; };
48template <> struct neon_vector<int8_t, 8>{ using type = int8x8_t; using tag_type = vector_64_tag; };
49template <> struct neon_vector<uint8_t, 16>{ using type = uint8x16_t; using tag_type = vector_128_tag; };
50template <> struct neon_vector<int8_t, 16>{ using type = int8x16_t; using tag_type = vector_128_tag; };
51template <> struct neon_vector<uint16_t, 4>{ using type = uint16x4_t; using tag_type = vector_64_tag; };
52template <> struct neon_vector<int16_t, 4>{ using type = int16x4_t; using tag_type = vector_64_tag; };
53template <> struct neon_vector<uint16_t, 8>{ using type = uint16x8_t; using tag_type = vector_128_tag; };
54template <> struct neon_vector<int16_t, 8>{ using type = int16x8_t; using tag_type = vector_128_tag; };
55template <> struct neon_vector<uint32_t, 2>{ using type = uint32x2_t; using tag_type = vector_64_tag; };
56template <> struct neon_vector<int32_t, 2>{ using type = int32x2_t; using tag_type = vector_64_tag; };
57template <> struct neon_vector<uint32_t, 4>{ using type = uint32x4_t; using tag_type = vector_128_tag; };
58template <> struct neon_vector<int32_t, 4>{ using type = int32x4_t; using tag_type = vector_128_tag; };
59template <> struct neon_vector<uint64_t, 1>{ using type = uint64x1_t; using tag_type = vector_64_tag; };
60template <> struct neon_vector<int64_t, 1>{ using type = int64x1_t; using tag_type = vector_64_tag; };
61template <> struct neon_vector<uint64_t, 2>{ using type = uint64x2_t; using tag_type = vector_128_tag; };
62template <> struct neon_vector<int64_t, 2>{ using type = int64x2_t; using tag_type = vector_128_tag; };
63template <> struct neon_vector<float_t, 2>{ using type = float32x2_t; using tag_type = vector_64_tag; };
64template <> struct neon_vector<float_t, 4>{ using type = float32x4_t; using tag_type = vector_128_tag; };
Alex Gildayc357c472018-03-21 13:54:09 +000065#endif /* DOXYGEN_SKIP_THIS */
Georgios Pinitas57c033b2018-02-15 12:29:44 +000066
67/** Helper type template to get the type of a neon vector */
Georgios Pinitas82833b82018-01-30 12:14:24 +000068template <typename T, int S> using neon_vector_t = typename neon_vector<T, S>::type;
Georgios Pinitas57c033b2018-02-15 12:29:44 +000069/** Helper type template to get the tag type of a neon vector */
70template <typename T, int S> using neon_vector_tag_t = typename neon_vector<T, S>::tag_type;
Georgios Pinitas82833b82018-01-30 12:14:24 +000071// clang-format on
72// *INDENT-ON*
Georgios Pinitas57c033b2018-02-15 12:29:44 +000073} // namespace traits
74} // namespace wrapper
75} // namespace arm_compute
Georgios Pinitas82833b82018-01-30 12:14:24 +000076#endif /* __ARM_COMPUTE_WRAPPER_TRAITS_H__ */