1 /******************************************************************************
2 *
3 * Copyright 2022 Google LLC
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 ******************************************************************************/
18
19 #if __ARM_FEATURE_SIMD32
20
21 #include <arm_acle.h>
22
23 #else
24 #define __ARM_FEATURE_SIMD32 1
25
26 #include <stdint.h>
27
28 typedef int32_t int16x2_t;
29
30 __attribute__((unused))
__pkhbt(int16x2_t a,int16x2_t b)31 static int16x2_t __pkhbt(int16x2_t a, int16x2_t b)
32 {
33 uint32_t a_bot = (uint32_t)a & 0x0000ffffu;
34 uint32_t b_top = (uint32_t)b & 0xffff0000u;
35
36 return (int16x2_t)(a_bot | b_top);
37 }
38
39 __attribute__((unused))
__smlad(int16x2_t a,int16x2_t b,int32_t u)40 static int32_t __smlad(int16x2_t a, int16x2_t b, int32_t u)
41 {
42 int16_t a_hi = a >> 16, a_lo = a & 0xffff;
43 int16_t b_hi = b >> 16, b_lo = b & 0xffff;
44
45 return u + (a_hi * b_hi) + (a_lo * b_lo);
46 }
47
48 __attribute__((unused))
__smlald(int16x2_t a,int16x2_t b,int64_t u)49 static int64_t __smlald(int16x2_t a, int16x2_t b, int64_t u)
50 {
51 int16_t a_hi = a >> 16, a_lo = a & 0xffff;
52 int16_t b_hi = b >> 16, b_lo = b & 0xffff;
53 return u + (a_hi * b_hi) + (a_lo * b_lo);
54 }
55
56 __attribute__((unused))
__smlaldx(int16x2_t a,int16x2_t b,int64_t u)57 static int64_t __smlaldx(int16x2_t a, int16x2_t b, int64_t u)
58 {
59 int16_t a_hi = a >> 16, a_lo = a & 0xffff;
60 int16_t b_hi = b >> 16, b_lo = b & 0xffff;
61 return u + (a_hi * b_lo) + (a_lo * b_hi);
62 }
63
64 #endif /* __ARM_FEATURE_SIMD32 */
65