14930cef6SMatthias Ringwald /******************************************************************************
24930cef6SMatthias Ringwald *
34930cef6SMatthias Ringwald * Copyright 2022 Google LLC
44930cef6SMatthias Ringwald *
54930cef6SMatthias Ringwald * Licensed under the Apache License, Version 2.0 (the "License");
64930cef6SMatthias Ringwald * you may not use this file except in compliance with the License.
74930cef6SMatthias Ringwald * You may obtain a copy of the License at:
84930cef6SMatthias Ringwald *
94930cef6SMatthias Ringwald * http://www.apache.org/licenses/LICENSE-2.0
104930cef6SMatthias Ringwald *
114930cef6SMatthias Ringwald * Unless required by applicable law or agreed to in writing, software
124930cef6SMatthias Ringwald * distributed under the License is distributed on an "AS IS" BASIS,
134930cef6SMatthias Ringwald * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
144930cef6SMatthias Ringwald * See the License for the specific language governing permissions and
154930cef6SMatthias Ringwald * limitations under the License.
164930cef6SMatthias Ringwald *
174930cef6SMatthias Ringwald ******************************************************************************/
184930cef6SMatthias Ringwald
194930cef6SMatthias Ringwald #if __ARM_FEATURE_SIMD32
204930cef6SMatthias Ringwald
214930cef6SMatthias Ringwald #include <arm_acle.h>
224930cef6SMatthias Ringwald
__pkhbt(int16x2_t a,int16x2_t b)23*4c4eb519SMatthias Ringwald static inline int16x2_t __pkhbt(int16x2_t a, int16x2_t b)
24*4c4eb519SMatthias Ringwald {
25*4c4eb519SMatthias Ringwald int16x2_t r;
26*4c4eb519SMatthias Ringwald __asm("pkhbt %0, %1, %2" : "=r" (r) : "r" (a), "r" (b));
27*4c4eb519SMatthias Ringwald return r;
28*4c4eb519SMatthias Ringwald }
29*4c4eb519SMatthias Ringwald
304930cef6SMatthias Ringwald #else
314930cef6SMatthias Ringwald
324930cef6SMatthias Ringwald #include <stdint.h>
334930cef6SMatthias Ringwald
344930cef6SMatthias Ringwald typedef int32_t int16x2_t;
354930cef6SMatthias Ringwald
364930cef6SMatthias Ringwald __attribute__((unused))
__pkhbt(int16x2_t a,int16x2_t b)374930cef6SMatthias Ringwald static int16x2_t __pkhbt(int16x2_t a, int16x2_t b)
384930cef6SMatthias Ringwald {
394930cef6SMatthias Ringwald uint32_t a_bot = (uint32_t)a & 0x0000ffffu;
404930cef6SMatthias Ringwald uint32_t b_top = (uint32_t)b & 0xffff0000u;
414930cef6SMatthias Ringwald
424930cef6SMatthias Ringwald return (int16x2_t)(a_bot | b_top);
434930cef6SMatthias Ringwald }
444930cef6SMatthias Ringwald
454930cef6SMatthias Ringwald __attribute__((unused))
__smlad(int16x2_t a,int16x2_t b,int32_t u)464930cef6SMatthias Ringwald static int32_t __smlad(int16x2_t a, int16x2_t b, int32_t u)
474930cef6SMatthias Ringwald {
484930cef6SMatthias Ringwald int16_t a_hi = a >> 16, a_lo = a & 0xffff;
494930cef6SMatthias Ringwald int16_t b_hi = b >> 16, b_lo = b & 0xffff;
504930cef6SMatthias Ringwald
514930cef6SMatthias Ringwald return u + (a_hi * b_hi) + (a_lo * b_lo);
524930cef6SMatthias Ringwald }
534930cef6SMatthias Ringwald
544930cef6SMatthias Ringwald __attribute__((unused))
__smlald(int16x2_t a,int16x2_t b,int64_t u)554930cef6SMatthias Ringwald static int64_t __smlald(int16x2_t a, int16x2_t b, int64_t u)
564930cef6SMatthias Ringwald {
574930cef6SMatthias Ringwald int16_t a_hi = a >> 16, a_lo = a & 0xffff;
584930cef6SMatthias Ringwald int16_t b_hi = b >> 16, b_lo = b & 0xffff;
594930cef6SMatthias Ringwald return u + (a_hi * b_hi) + (a_lo * b_lo);
604930cef6SMatthias Ringwald }
614930cef6SMatthias Ringwald
624930cef6SMatthias Ringwald __attribute__((unused))
__smlaldx(int16x2_t a,int16x2_t b,int64_t u)634930cef6SMatthias Ringwald static int64_t __smlaldx(int16x2_t a, int16x2_t b, int64_t u)
644930cef6SMatthias Ringwald {
654930cef6SMatthias Ringwald int16_t a_hi = a >> 16, a_lo = a & 0xffff;
664930cef6SMatthias Ringwald int16_t b_hi = b >> 16, b_lo = b & 0xffff;
674930cef6SMatthias Ringwald return u + (a_hi * b_lo) + (a_lo * b_hi);
684930cef6SMatthias Ringwald }
694930cef6SMatthias Ringwald
704930cef6SMatthias Ringwald #endif /* __ARM_FEATURE_SIMD32 */
71