/
vecLibTypes.h
203 lines (163 loc) · 8.65 KB
/
vecLibTypes.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/*
File: vecLib/vecLibTypes.h
Contains: Master include for vecLib framework
Version: vecLib-516.0
Copyright: © 2000-2014 by Apple Inc., all rights reserved.
Bugs?: For bug reports, consult the following page on
the World Wide Web:
http://developer.apple.com/bugreporter/
*/
#ifndef __VECLIBTYPES__
#define __VECLIBTYPES__
#include <Availability.h>
#if PRAGMA_ONCE
#pragma once
#endif
#pragma options align=power
#if defined(__ppc__) || defined(__ppc64__)
/*
The goal of the following preprocessor statements is to define the
preprocessor symbol _AltiVecPIMLanguageExtensionsAreEnabled if and only if
the AltiVec high-level language programming interface is enabled. We
designed the statements to accommodate some non-Apple compilers but cannot
assure behavior with non-Apple products.
Apple GCC version 3.3 and earlier versions defined the preprocessor symbol
__VEC__ if and only if the AltiVec programming interface were enabled.
Later versions define __VEC__ when the AltiVec instruction set is enabled
(and thus available for the compiler's assembly code generation) even if
the programming interface is not enabled (and thus not available at the
source code level). This occurs, for example, when -maltivec is specified
but neither -faltivec is specified nor <altivec.h> is included.
Due to this change, code that formerly used __VEC__ to select source code
with or without use of the AltiVec programming interface should now use
_AltiVecPIMLanguageExtensionsAreEnabled.
For more information about the interface, see AltiVec Technology
Programming Interface Manual (ALTIVECPIM/D 6/1999 Rev. 0, published by
Motorola Inc. [now Freescale, Inc.]).
*/
#if defined _ALTIVEC_H \
|| (defined __APPLE_CC__ && __APPLE_ALTIVEC__) \
|| (!defined __GNUC__ && defined __VEC__)
#define _AltiVecPIMLanguageExtensionsAreEnabled
#endif
#if defined _AltiVecPIMLanguageExtensionsAreEnabled
typedef __vector unsigned char vUInt8;
typedef __vector signed char vSInt8;
typedef __vector unsigned short vUInt16;
typedef __vector signed short vSInt16;
typedef __vector unsigned int vUInt32;
typedef __vector signed int vSInt32;
typedef __vector float vFloat;
typedef __vector bool int vBool32;
/*
* GCC allows us to create a vDouble type, even on AltiVec which has no double precision vector
* instructions (apart from boolean operations which are type agnostic). You can use standard
* operators: +-* etc. with the vDouble type. GCC will use scalar code on PowerPC to do the work.
* The type is provided for developers interested in writing shared Intel-PowerPC code.
*/
#if defined(__GNUC__) && ! defined( __XLC__ )
#if defined(__GNUC_MINOR__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ <= 3)) || (__GNUC__ < 3))
#else
#define __VECLIBTYPES_VDOUBLE__ 1
typedef double vDouble __attribute__ ((__vector_size__ (16)));
#endif
#endif
#endif /* defined _AltiVecPIMLanguageExtensionsAreEnabled */
#elif defined(__i386__) || defined(__x86_64__)
#ifdef __SSE__
#if defined(__GNUC__)
#include <xmmintrin.h>
typedef float vFloat __attribute__ ((__vector_size__ (16)));
#else /* not __GNUC__ */
#include <xmmintrin.h>
typedef __m128 vFloat;
#endif /* __GNUC__ */
#endif /* defined(__SSE__) */
#ifdef __SSE2__
#define __VECLIBTYPES_VDOUBLE__ 1
#if defined(__GNUC__)
#if defined(__GNUC_MINOR__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ <= 3)) || (__GNUC__ < 3))
#include <xmmintrin.h>
typedef __m128i vUInt8;
typedef __m128i vSInt8;
typedef __m128i vUInt16;
typedef __m128i vSInt16;
typedef __m128i vUInt32;
typedef __m128i vSInt32;
typedef __m128i vBool32;
typedef __m128i vUInt64;
typedef __m128i vSInt64;
typedef __m128d vDouble;
#else /* gcc-3.5 or later */
#include <emmintrin.h>
typedef unsigned char vUInt8 __attribute__ ((__vector_size__ (16)));
typedef char vSInt8 __attribute__ ((__vector_size__ (16)));
typedef unsigned short vUInt16 __attribute__ ((__vector_size__ (16)));
typedef short vSInt16 __attribute__ ((__vector_size__ (16)));
typedef unsigned int vUInt32 __attribute__ ((__vector_size__ (16)));
typedef int vSInt32 __attribute__ ((__vector_size__ (16)));
typedef unsigned int vBool32 __attribute__ ((__vector_size__ (16)));
typedef unsigned long long vUInt64 __attribute__ ((__vector_size__ (16)));
typedef long long vSInt64 __attribute__ ((__vector_size__ (16)));
typedef double vDouble __attribute__ ((__vector_size__ (16)));
#endif /* __GNUC__ <= 3.3 */
#else /* not __GNUC__ */
#include <emmintrin.h>
typedef __m128i vUInt8;
typedef __m128i vSInt8;
typedef __m128i vUInt16;
typedef __m128i vSInt16;
typedef __m128i vUInt32;
typedef __m128i vSInt32;
typedef __m128i vBool32;
typedef __m128i vUInt64;
typedef __m128i vSInt64;
typedef __m128d vDouble;
#endif /* __GNUC__ */
#endif /* defined(__SSE2__) */
#elif defined __arm__ && defined __ARM_NEON__
#if !defined ARM_NEON_GCC_COMPATIBILITY
#define ARM_NEON_GCC_COMPATIBILITY
#if \
defined __ARM_NEON_H && \
defined __GNUC__ && \
! defined __clang__ && \
! defined SQUELCH_VECLIB_WARNINGS_ABOUT_BROKEN_NEON_TYPES
/* GCC decided to make neon vector types using something other
than basic C types as the underlying element by default. This
prevents the below types from being used with the functions in
arm_neon.h. GCC did put in a workaround, however. Define
ARM_NEON_GCC_COMPATIBILITY before including arm_neon.h and then
everything will start working as designed. You are getting this
warning because some other header included arm_neon.h without
defining ARM_NEON_GCC_COMPATIBILITY before we arrived here.
#define SQUELCH_VECLIB_WARNINGS_ABOUT_BROKEN_NEON_TYPES to silence this warning
*/
#warning "arm_neon.h was included without #define ARM_NEON_GCC_COMPATIBILITY. Vector types defined in vecLibTypes.h, such as vUInt8, might not work with NEON intrinsics."
#endif
#endif /* !defined ARM_NEON_GCC_COMPATIBILITY */
#include <arm_neon.h>
typedef unsigned char vUInt8 __attribute__((__vector_size__(16), __aligned__(16)));
typedef signed char vSInt8 __attribute__((__vector_size__(16), __aligned__(16)));
typedef unsigned short vUInt16 __attribute__((__vector_size__(16), __aligned__(16)));
typedef signed short vSInt16 __attribute__((__vector_size__(16), __aligned__(16)));
typedef unsigned int vUInt32 __attribute__((__vector_size__(16), __aligned__(16)));
typedef signed int vSInt32 __attribute__((__vector_size__(16), __aligned__(16)));
typedef float vFloat __attribute__((__vector_size__(16), __aligned__(16)));
typedef double vDouble __attribute__((__vector_size__(16), __aligned__(16)));
typedef unsigned int vBool32 __attribute__((__vector_size__(16), __aligned__(16)));
#else
typedef unsigned char vUInt8 __attribute__((__vector_size__(16)));
typedef signed char vSInt8 __attribute__((__vector_size__(16)));
typedef unsigned short vUInt16 __attribute__((__vector_size__(16)));
typedef signed short vSInt16 __attribute__((__vector_size__(16)));
typedef unsigned int vUInt32 __attribute__((__vector_size__(16)));
typedef signed int vSInt32 __attribute__((__vector_size__(16)));
typedef long long vSInt64 __attribute__((__vector_size__(16)));
typedef unsigned long long vUInt64 __attribute__((__vector_size__(16)));
typedef float vFloat __attribute__((__vector_size__(16)));
typedef double vDouble __attribute__((__vector_size__(16)));
typedef unsigned int vBool32 __attribute__((__vector_size__(16)));
#endif
#pragma options align=reset
#endif /* __VECLIBTYPES__ */