FreeRDP
prim_andor_sse3.c
1 /* FreeRDP: A Remote Desktop Protocol Client
2  * Optimized Logical 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 #include "prim_andor.h"
23 
24 #include "prim_internal.h"
25 #include "prim_templates.h"
26 
27 #if defined(SSE2_ENABLED)
28 #include <emmintrin.h>
29 #include <pmmintrin.h>
30 
31 static primitives_t* generic = NULL;
32 
33 /* ------------------------------------------------------------------------- */
34 SSE3_SCD_PRE_ROUTINE(sse3_andC_32u, UINT32, generic->andC_32u, _mm_and_si128,
35  *dptr++ = *sptr++ & val)
36 SSE3_SCD_PRE_ROUTINE(sse3_orC_32u, UINT32, generic->orC_32u, _mm_or_si128, *dptr++ = *sptr++ | val)
37 
38 #endif
39 
40 /* ------------------------------------------------------------------------- */
41 void primitives_init_andor_sse3(primitives_t* WINPR_RESTRICT prims)
42 {
43 #if defined(SSE2_ENABLED)
44  generic = primitives_get_generic();
45  primitives_init_andor(prims);
46 
47  if (IsProcessorFeaturePresent(PF_SSE2_INSTRUCTIONS_AVAILABLE) &&
48  IsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE))
49  {
50  WLog_VRB(PRIM_TAG, "SSE2/SSE3 optimizations");
51  prims->andC_32u = sse3_andC_32u;
52  prims->orC_32u = sse3_orC_32u;
53  }
54 
55 #else
56  WLog_VRB(PRIM_TAG, "undefined WITH_SSE2");
57  WINPR_UNUSED(prims);
58 #endif
59 }