1
2 /* Copyright (c) 2013 Julien Pommier ( [email protected] )
3
4 Redistribution and use of the Software in source and binary forms,
5 with or without modification, is permitted provided that the
6 following conditions are met:
7
8 - Neither the names of NCAR's Computational and Information Systems
9 Laboratory, the University Corporation for Atmospheric Research,
10 nor the names of its sponsors or contributors may be used to
11 endorse or promote products derived from this Software without
12 specific prior written permission.
13
14 - Redistributions of source code must retain the above copyright
15 notices, this list of conditions, and the disclaimer below.
16
17 - Redistributions in binary form must reproduce the above copyright
18 notice, this list of conditions, and the disclaimer below in the
19 documentation and/or other materials provided with the
20 distribution.
21
22 THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE WARRANTIES OF
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT
26 HOLDERS BE LIABLE FOR ANY CLAIM, INDIRECT, INCIDENTAL, SPECIAL,
27 EXEMPLARY, OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
30 SOFTWARE.
31 */
32
33 #ifndef PF_ALTIVEC_FLT_H
34 #define PF_ALTIVEC_FLT_H
35
36 /*
37 Altivec support macros
38 */
39 #if !defined(PFFFT_SIMD_DISABLE) && (defined(__ppc__) || defined(__ppc64__))
40 #pragma message( __FILE__ ": ALTIVEC float macros are defined" )
41 typedef vector float v4sf;
42
43 # define SIMD_SZ 4
44
45 typedef union v4sf_union {
46 v4sf v;
47 float f[SIMD_SZ];
48 } v4sf_union;
49
50 # define VREQUIRES_ALIGN 1 /* not sure, if really required */
51 # define VARCH "ALTIVEC"
52 # define VZERO() ((vector float) vec_splat_u8(0))
53 # define VMUL(a,b) vec_madd(a,b, VZERO())
54 # define VADD(a,b) vec_add(a,b)
55 # define VMADD(a,b,c) vec_madd(a,b,c)
56 # define VSUB(a,b) vec_sub(a,b)
ld_ps1(const float * p)57 inline v4sf ld_ps1(const float *p) { v4sf v=vec_lde(0,p); return vec_splat(vec_perm(v, v, vec_lvsl(0, p)), 0); }
58 # define LD_PS1(p) ld_ps1(&p)
59 # define INTERLEAVE2(in1, in2, out1, out2) { v4sf tmp__ = vec_mergeh(in1, in2); out2 = vec_mergel(in1, in2); out1 = tmp__; }
60 # define UNINTERLEAVE2(in1, in2, out1, out2) { \
61 vector unsigned char vperm1 = (vector unsigned char)(0,1,2,3,8,9,10,11,16,17,18,19,24,25,26,27); \
62 vector unsigned char vperm2 = (vector unsigned char)(4,5,6,7,12,13,14,15,20,21,22,23,28,29,30,31); \
63 v4sf tmp__ = vec_perm(in1, in2, vperm1); out2 = vec_perm(in1, in2, vperm2); out1 = tmp__; \
64 }
65 # define VTRANSPOSE4(x0,x1,x2,x3) { \
66 v4sf y0 = vec_mergeh(x0, x2); \
67 v4sf y1 = vec_mergel(x0, x2); \
68 v4sf y2 = vec_mergeh(x1, x3); \
69 v4sf y3 = vec_mergel(x1, x3); \
70 x0 = vec_mergeh(y0, y2); \
71 x1 = vec_mergel(y0, y2); \
72 x2 = vec_mergeh(y1, y3); \
73 x3 = vec_mergel(y1, y3); \
74 }
75 # define VSWAPHL(a,b) vec_perm(a,b, (vector unsigned char)(16,17,18,19,20,21,22,23,8,9,10,11,12,13,14,15))
76 # define VALIGNED(ptr) ((((uintptr_t)(ptr)) & 0xF) == 0)
77
78 #endif
79
80 #endif /* PF_SSE1_FLT_H */
81
82