FreeRDP
Loading...
Searching...
No Matches
prim_shift_neon.c
1
19
20#include <freerdp/config.h>
21
22#include <freerdp/types.h>
23#include <freerdp/primitives.h>
24#include <winpr/sysinfo.h>
25
26#include "prim_internal.h"
27#include "prim_shift.h"
28
29#if defined(NEON_INTRINSICS_ENABLED)
30#include <arm_neon.h>
31
32static primitives_t* generic = nullptr;
33
34static pstatus_t neon_lShiftC_16s_inplace(INT16* WINPR_RESTRICT pSrcDst, UINT32 val, UINT32 ulen)
35{
36 INT16* dptr = pSrcDst;
37 size_t len = ulen;
38 if (val == 0)
39 return PRIMITIVES_SUCCESS;
40 if (val >= 16)
41 return -1;
42
43 const int16x8_t shift = vdupq_n_s16((INT16)val);
44
45 /* Use 2 128-bit NEON registers. */
46 size_t count = len >> 4;
47 len -= count << 4;
48 while (count--)
49 {
50 const int16x8_t v0 = vld1q_s16(dptr);
51 const int16x8_t v1 = vld1q_s16(dptr + 8);
52
53 vst1q_s16(dptr, vshlq_s16(v0, shift));
54 vst1q_s16(dptr + 8, vshlq_s16(v1, shift));
55
56 dptr += 16;
57 }
58 /* Finish off the remainder. */
59 if (len > 0)
60 return generic->lShiftC_16s_inplace(dptr, val, WINPR_ASSERTING_INT_CAST(uint32_t, len));
61
62 return PRIMITIVES_SUCCESS;
63}
64#endif
65
66/* ------------------------------------------------------------------------- */
67void primitives_init_shift_neon_int(primitives_t* WINPR_RESTRICT prims)
68{
69#if defined(NEON_INTRINSICS_ENABLED)
70 generic = primitives_get_generic();
71
72 WLog_VRB(PRIM_TAG, "NEON optimizations");
73 prims->lShiftC_16s_inplace = neon_lShiftC_16s_inplace;
74#else
75 WLog_VRB(PRIM_TAG, "undefined WITH_SIMD or neon intrinsics not available");
76 WINPR_UNUSED(prims);
77#endif
78}