Coverage Report

Created: 2023-09-25 06:56

/src/FreeRDP/libfreerdp/primitives/prim_shift_opt.c
Line
Count
Source (jump to first uncovered line)
1
/* FreeRDP: A Remote Desktop Protocol Client
2
 * Shift operations.
3
 * vi:ts=4 sw=4:
4
 *
5
 * (c) Copyright 2012 Hewlett-Packard Development Company, L.P.
6
 * Licensed under the Apache License, Version 2.0 (the "License"); you may
7
 * not use this file except in compliance with the License. You may obtain
8
 * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
9
 * Unless required by applicable law or agreed to in writing, software
10
 * distributed under the License is distributed on an "AS IS" BASIS,
11
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12
 * or implied. See the License for the specific language governing
13
 * permissions and limitations under the License.
14
 */
15
16
#include <freerdp/config.h>
17
18
#include <freerdp/types.h>
19
#include <freerdp/primitives.h>
20
#include <winpr/sysinfo.h>
21
22
#ifdef WITH_SSE2
23
#include <emmintrin.h>
24
#include <pmmintrin.h>
25
#endif /* WITH_SSE2 */
26
27
#ifdef WITH_IPP
28
#include <ipps.h>
29
#endif /* WITH_IPP */
30
31
#include "prim_internal.h"
32
#include "prim_templates.h"
33
34
static primitives_t* generic = NULL;
35
36
#ifdef WITH_SSE2
37
#if !defined(WITH_IPP) || defined(ALL_PRIMITIVES_VERSIONS)
38
/* ------------------------------------------------------------------------- */
39
SSE3_SCD_ROUTINE(sse2_lShiftC_16s, INT16, generic->lShiftC_16s, _mm_slli_epi16,
40
                 *dptr++ = (INT16)((UINT16)*sptr++ << val))
41
/* ------------------------------------------------------------------------- */
42
SSE3_SCD_ROUTINE(sse2_rShiftC_16s, INT16, generic->rShiftC_16s, _mm_srai_epi16,
43
                 *dptr++ = *sptr++ >> val)
44
/* ------------------------------------------------------------------------- */
45
SSE3_SCD_ROUTINE(sse2_lShiftC_16u, UINT16, generic->lShiftC_16u, _mm_slli_epi16,
46
                 *dptr++ = (INT16)((UINT16)*sptr++ << val))
47
/* ------------------------------------------------------------------------- */
48
SSE3_SCD_ROUTINE(sse2_rShiftC_16u, UINT16, generic->rShiftC_16u, _mm_srli_epi16,
49
                 *dptr++ = *sptr++ >> val)
50
#endif /* !defined(WITH_IPP) || defined(ALL_PRIMITIVES_VERSIONS) */
51
#endif
52
53
/* Note: the IPP version will have to call ippLShiftC_16s or ippRShiftC_16s
54
 * depending on the sign of val.  To avoid using the deprecated inplace
55
 * routines, a wrapper can use the src for the dest.
56
 */
57
58
/* ------------------------------------------------------------------------- */
59
void primitives_init_shift_opt(primitives_t* WINPR_RESTRICT prims)
60
0
{
61
0
  generic = primitives_get_generic();
62
0
  primitives_init_shift(prims);
63
#if defined(WITH_IPP)
64
  prims->lShiftC_16s = ippsLShiftC_16s;
65
  prims->rShiftC_16s = ippsRShiftC_16s;
66
  prims->lShiftC_16u = ippsLShiftC_16u;
67
  prims->rShiftC_16u = ippsRShiftC_16u;
68
#elif defined(WITH_SSE2)
69
70
0
  if (IsProcessorFeaturePresent(PF_SSE2_INSTRUCTIONS_AVAILABLE) &&
71
0
      IsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE))
72
0
  {
73
0
    prims->lShiftC_16s = sse2_lShiftC_16s;
74
0
    prims->rShiftC_16s = sse2_rShiftC_16s;
75
0
    prims->lShiftC_16u = sse2_lShiftC_16u;
76
0
    prims->rShiftC_16u = sse2_rShiftC_16u;
77
0
  }
78
79
0
#endif
80
0
}