blob: 20436714ef339600ab8b3160650d0eb8894bfe8d [file] [log] [blame]
giuros0192fd9432018-12-03 17:30:00 +00001/*
Omar Al Khatib605a9282022-11-01 17:01:24 +00002 * Copyright (c) 2018-2020, 2022 Arm Limited.
giuros0192fd9432018-12-03 17:30:00 +00003 *
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 */
Michalis Spyrouf4643372019-11-29 16:17:13 +000024#ifndef ARM_COMPUTE_WRAPPER_SUB_H
25#define ARM_COMPUTE_WRAPPER_SUB_H
giuros0192fd9432018-12-03 17:30:00 +000026
27#include <arm_neon.h>
28
29namespace arm_compute
30{
31namespace wrapper
32{
33#define VSUB_IMPL(stype, vtype, prefix, postfix) \
34 inline vtype vsub(const vtype &a, const vtype &b) \
35 { \
36 return prefix##_##postfix(a, b); \
37 }
38
39VSUB_IMPL(uint8x8_t, uint8x8_t, vsub, u8)
40VSUB_IMPL(int8x8_t, int8x8_t, vsub, s8)
41VSUB_IMPL(uint16x4_t, uint16x4_t, vsub, u16)
42VSUB_IMPL(int16x4_t, int16x4_t, vsub, s16)
43VSUB_IMPL(uint32x2_t, uint32x2_t, vsub, u32)
44VSUB_IMPL(int32x2_t, int32x2_t, vsub, s32)
45VSUB_IMPL(uint64x1_t, uint64x1_t, vsub, u64)
46VSUB_IMPL(int64x1_t, int64x1_t, vsub, s64)
47VSUB_IMPL(float32x2_t, float32x2_t, vsub, f32)
48#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
49VSUB_IMPL(float16x4_t, float16x4_t, vsub, f16)
50#endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
51
52VSUB_IMPL(uint8x16_t, uint8x16_t, vsubq, u8)
53VSUB_IMPL(int8x16_t, int8x16_t, vsubq, s8)
54VSUB_IMPL(uint16x8_t, uint16x8_t, vsubq, u16)
55VSUB_IMPL(int16x8_t, int16x8_t, vsubq, s16)
56VSUB_IMPL(uint32x4_t, uint32x4_t, vsubq, u32)
57VSUB_IMPL(int32x4_t, int32x4_t, vsubq, s32)
58VSUB_IMPL(uint64x2_t, uint64x2_t, vsubq, u64)
59VSUB_IMPL(int64x2_t, int64x2_t, vsubq, s64)
60VSUB_IMPL(float32x4_t, float32x4_t, vsubq, f32)
61#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
62VSUB_IMPL(float16x8_t, float16x8_t, vsubq, f16)
63#endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
64
Georgios Pinitas2cd7a372020-05-12 21:03:56 +010065#undef VSUB_IMPL
66
Michalis Spyrou5f390912020-05-13 00:12:08 +010067// VQSUB: Vector saturating sub (No notion of saturation for floating point)
Georgios Pinitas2cd7a372020-05-12 21:03:56 +010068#define VQSUB_IMPL(stype, vtype, prefix, postfix) \
69 inline vtype vqsub(const vtype &a, const vtype &b) \
70 { \
71 return prefix##_##postfix(a, b); \
72 }
73
74VQSUB_IMPL(uint8x8_t, uint8x8_t, vqsub, u8)
75VQSUB_IMPL(int8x8_t, int8x8_t, vqsub, s8)
76VQSUB_IMPL(uint16x4_t, uint16x4_t, vqsub, u16)
77VQSUB_IMPL(int16x4_t, int16x4_t, vqsub, s16)
78VQSUB_IMPL(uint32x2_t, uint32x2_t, vqsub, u32)
79VQSUB_IMPL(int32x2_t, int32x2_t, vqsub, s32)
80VQSUB_IMPL(uint64x1_t, uint64x1_t, vqsub, u64)
81VQSUB_IMPL(int64x1_t, int64x1_t, vqsub, s64)
Michalis Spyrou5f390912020-05-13 00:12:08 +010082VQSUB_IMPL(float32x2_t, float32x2_t, vsub, f32)
83#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
84VQSUB_IMPL(float16x4_t, float16x4_t, vsub, f16)
85#endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
Georgios Pinitas2cd7a372020-05-12 21:03:56 +010086
87VQSUB_IMPL(uint8x16_t, uint8x16_t, vqsubq, u8)
88VQSUB_IMPL(int8x16_t, int8x16_t, vqsubq, s8)
89VQSUB_IMPL(uint16x8_t, uint16x8_t, vqsubq, u16)
90VQSUB_IMPL(int16x8_t, int16x8_t, vqsubq, s16)
91VQSUB_IMPL(uint32x4_t, uint32x4_t, vqsubq, u32)
92VQSUB_IMPL(int32x4_t, int32x4_t, vqsubq, s32)
93VQSUB_IMPL(uint64x2_t, uint64x2_t, vqsubq, u64)
94VQSUB_IMPL(int64x2_t, int64x2_t, vqsubq, s64)
Michalis Spyrou5f390912020-05-13 00:12:08 +010095VQSUB_IMPL(float32x4_t, float32x4_t, vsubq, f32)
96#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
97VQSUB_IMPL(float16x8_t, float16x8_t, vsubq, f16)
98#endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
Georgios Pinitas2cd7a372020-05-12 21:03:56 +010099#undef VQSUB_IMPL
Michalis Spyrou5f390912020-05-13 00:12:08 +0100100
Omar Al Khatib605a9282022-11-01 17:01:24 +0000101#define VSUBL_IMPL(rtype, vtype, prefix, postfix) \
102 inline rtype vsubl(const vtype &a, const vtype &b) \
103 { \
104 return prefix##_##postfix(a, b); \
105 }
106
107VSUBL_IMPL(int16x8_t, int8x8_t, vsubl, s8)
108VSUBL_IMPL(int32x4_t, int16x4_t, vsubl, s16)
109VSUBL_IMPL(int64x2_t, int32x2_t, vsubl, s32)
110VSUBL_IMPL(uint16x8_t, uint8x8_t, vsubl, u8)
111VSUBL_IMPL(uint32x4_t, uint16x4_t, vsubl, u16)
112VSUBL_IMPL(uint64x2_t, uint32x2_t, vsubl, u32)
113
114#undef VSUB_IMPL
115
giuros0192fd9432018-12-03 17:30:00 +0000116} // namespace wrapper
117} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +0000118#endif /* ARM_COMPUTE_WRAPPER_SUB_H */