35 #include <lal/LALConstants.h>
36 #include <lal/XLALError.h>
39 #define UNUSED __attribute__ ((unused))
50 #ifdef SINCOS_REAL4_ARG
53 #define SINCOS_TRIM_X(y,x) \
55 __asm FLD QWORD PTR x \
57 __asm FSUBR QWORD PTR x \
59 __asm FADDP ST(1),ST \
60 __asm FSTP QWORD PTR y \
64 #define SINCOS_TRIM_X(y,x) y = x - floor(x);
66 #define SINCOS_TRIM_X(y,x) y = x - rint(x) + 1.0;
72 #define SINCOS_TRIM_X(y,x) \
74 __asm FLD DWORD PTR x \
76 __asm FSUBR DWORD PTR x \
78 __asm FADDP ST(1),ST \
79 __asm FSTP DWORD PTR y \
83 #define SINCOS_TRIM_X(y,x) y = x - floorf(x);
85 #define SINCOS_TRIM_X(y,x) y = x - rintf(x) + 1.0;
97 #define SINCOS_ADDS 402653184.0
98 #define SINCOS_MASK1 0xFFFFFF
99 #define SINCOS_MASK2 0x003FFF
100 #define SINCOS_SHIFT 14
101 #define SINCOS_LUT_RES 1024
115 static UNUSED
union {
118 #ifdef __BIG_ENDIAN__
135 #define SINCOS_PROLOG
136 #define SINCOS_STEP1(x) sincosUX.asreal = x + SINCOS_ADDS;
137 #define SINCOS_STEP2 sincosI = sincosUX.as2int.intval & SINCOS_MASK1;
138 #define SINCOS_STEP3 sincosN = sincosUX.as2int.intval & SINCOS_MASK2;
139 #define SINCOS_STEP4 sincosI = sincosI >> SINCOS_SHIFT;
140 #define SINCOS_STEP5(s) *s = sincosLUTbase[sincosI] + sincosN * sincosLUTdiff[sincosI];
141 #define SINCOS_STEP6(c) *c = cosLUTbase[sincosI] + sincosN * cosLUTdiff[sincosI];
142 #define SINCOS_EPILOG(s,c,x)
151 #if defined(__x86_64__)
164 #ifdef SINCOS_REAL4_ARG
165 #define SINCOS_FLD "fld"
167 #define SINCOS_FLD "fldl"
171 #define SINCOS_TRIM_P0A(alpha) \
172 SINCOS_FLD " %[" #alpha "] \n\t"
\
173 "fistpll %[tmp] \n\t" \
177 #define SINCOS_TRIM_P0B(alpha) \
178 "fsubrp %%st,%%st(1) \n\t" \
179 "faddl %[" #alpha "] \n\t"
\
180 "faddl %[sincos_adds] \n\t" \
184 #define SINCOS_P0(alpha) \
185 SINCOS_FLD " %[" #alpha "] \n\t"
\
186 "faddl %[sincos_adds] \n\t" \
190 "mov %[tmp],"PAX" \n\t"
\
191 "mov "PAX","PDX" \n\t"
\
192 "and $0x3fff,"PAX" \n\t"
194 "mov "PAX",%[tmp] \n\t" \
195 "mov %[scd], "PAX" \n\t" \
196 "and $0xffffff,"PDX" \n\t"
198 "fildl %[tmp] \n\t" \
199 "sar $0xe,"PDX" \n\t"
202 "fmuls ("PAX","PDX",4) \n\t" \
203 "mov %[scb], "PDI" \n\t"
205 "fmuls ("PAX","PDX",4) \n\t" \
206 "mov %[scb], "PDI" \n\t"
207 #define SINCOS_P5(sin) \
208 "fadds ("PDI","PDX",4) \n\t"
\
209 "add $0x100,"PDX" \n\t"
\
210 "fstps %[" #sin "] \n\t"
211 #define SINCOS_P6(cos) \
212 "fmuls ("PAX","PDX",4) \n\t" \
213 "fadds ("PDI","PDX",4) \n\t" \
214 "fstps %[" #cos "] \n\t"
216 #define SINCOS_REGISTERS RAX,RDX,RDI,"st","st(1)","st(2)","cc"
static const UNUSED REAL4 * cosLUTbase
static UNUSED union @7 sincosUX
UNUSED REAL4 sincosLUTbase[SINCOS_LUT_RES+SINCOS_LUT_RES/4]
static UNUSED INT4 sincosN
UNUSED REAL4 sincosLUTdiff[SINCOS_LUT_RES+SINCOS_LUT_RES/4]
static const UNUSED REAL4 * cosLUTdiff
static UNUSED INT4 sincosI