OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libm/] [machine/] [spu/] [headers/] [sincosd2.h] - Blame information for rev 825

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/* --------------------------------------------------------------  */
2
/* (C)Copyright 2007,2008,                                         */
3
/* International Business Machines Corporation                     */
4
/* All Rights Reserved.                                            */
5
/*                                                                 */
6
/* Redistribution and use in source and binary forms, with or      */
7
/* without modification, are permitted provided that the           */
8
/* following conditions are met:                                   */
9
/*                                                                 */
10
/* - Redistributions of source code must retain the above copyright*/
11
/*   notice, this list of conditions and the following disclaimer. */
12
/*                                                                 */
13
/* - Redistributions in binary form must reproduce the above       */
14
/*   copyright notice, this list of conditions and the following   */
15
/*   disclaimer in the documentation and/or other materials        */
16
/*   provided with the distribution.                               */
17
/*                                                                 */
18
/* - Neither the name of IBM Corporation nor the names of its      */
19
/*   contributors may be used to endorse or promote products       */
20
/*   derived from this software without specific prior written     */
21
/*   permission.                                                   */
22
/*                                                                 */
23
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND          */
24
/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,     */
25
/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF        */
26
/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE        */
27
/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR            */
28
/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    */
29
/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT    */
30
/* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;    */
31
/* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)        */
32
/* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN       */
33
/* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR    */
34
/* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,  */
35
/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              */
36
/* --------------------------------------------------------------  */
37
/* PROLOG END TAG zYx                                              */
38
#ifdef __SPU__
39
#ifndef _SINCOSD2_H_
40
#define _SINCOSD2_H_    1
41
 
42
#include <spu_intrinsics.h>
43
 
44
#include "cos_sin.h"
45
 
46
/*
47
 * FUNCTION
48
 *  void _sincosd2(vector double x, vector double *sx, vector double *cx)
49
 *
50
 * DESCRIPTION
51
 *      The _sincosd2 function computes the sine and cosine of a vector of
52
 *      angles (expressed in radians) to an accuracy of a double precision
53
 *      floating point.
54
 *
55
 *
56
 */
57
 
58
static __inline void _sincosd2(vector double angle,
59
                               vector double *sinx,
60
                               vector double *cosx)
61
{
62
    vec_int4    octant;
63
    vec_ullong2 select;
64
    vec_double2 cos, sin;
65
    vec_double2 toggle_sign;
66
 
67
    /* Range reduce the input angle x into the range -PI/4 to PI/4
68
     * by performing simple modulus.
69
     */
70
    MOD_PI_OVER_FOUR(angle, octant);
71
 
72
    /* Compute the cosine and sine of the range reduced input.
73
     */
74
    COMPUTE_COS_SIN(angle, cos, sin);
75
 
76
    /*
77
     * See the comments for the sind2 and cosd2 functions for an
78
     * explanation of the following steps.
79
     */
80
    octant = spu_shuffle(octant, octant, ((vec_uchar16) { 0,1,2,3, 0,1,2,3, 8,9,10,11, 8,9,10,11 }));
81
    select = (vec_ullong2)spu_cmpeq(spu_and(octant, 2), 0);
82
 
83
    toggle_sign = (vec_double2)spu_sl(spu_and(spu_add(octant, 2), 4), ((vec_uint4) { 29,32,29,32 }));
84
    *cosx = spu_xor(spu_sel(sin, cos, select), toggle_sign);
85
 
86
    toggle_sign = (vec_double2)spu_sl(spu_and(octant, 4), ((vec_uint4) { 29,32,29,32 }));
87
    *sinx = spu_xor(spu_sel(cos, sin, select), toggle_sign);
88
 
89
    return;
90
}
91
 
92
#endif /* _SINCOSD2_H_ */
93
#endif /* __SPU__ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.