1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2011 Nexenta Systems, Inc. All rights reserved. 23 */ 24 /* 25 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 26 * Use is subject to license terms. 27 */ 28 29 .file "__reduction.s" 30 31 / 32 / After argument reduction which returns n: 33 / n mod 4 sin(x) cos(x) tan(x) 34 / ---------------------------------------------------------- 35 / 0 S C S/C 36 / 1 C -S -C/S 37 / 2 -S -C S/C 38 / 3 -C S -C/S 39 / ---------------------------------------------------------- 40 41 #include "libm.h" 42 #include "libm_protos.h" 43 #undef fabs 44 45 ENTRY(__reduction) 46 #ifndef PIC 47 movl 12(%esp),%eax / load the high part of arg 48 #else 49 movl 16(%esp),%eax / load the high part of arg 50 #endif 51 andl $0x7fffffff,%eax / clear sign 52 cmpl $0x3fe921fb,%eax / Is |x| < pi/4 (= 0x3fe921fb54...) ? 53 jbe .L0 54 cmpl $0x7ff00000,%eax / Is arg a NaN or an Inf ? 55 jb .L1 56 .L0: 57 #ifndef PIC 58 fldl 8(%esp) / push arg 59 #else 60 fldl 12(%esp) / push arg 61 #endif 62 fwait 63 movl $0,%eax / set n = 0 64 ret 65 .L1: 66 pushl %ebp 67 movl %esp,%ebp 68 subl $16,%esp 69 PIC_SETUP(1) 70 leal -16(%ebp),%eax / address of y[0] 71 pushl %eax 72 #ifndef PIC 73 pushl 16(%ebp) 74 pushl 12(%ebp) 75 #else 76 pushl 20(%ebp) 77 pushl 16(%ebp) 78 #endif 79 call PIC_F(__rem_pio2) / call __rem_pio2(x,&y) 80 fldl -8(%ebp) / y[1] 81 fldl -16(%ebp) / y[0], y[1] 82 faddp %st,%st(1) / y[0]+y[1] round-to-extended 83 addl $28,%esp / 16+4*3 84 andl $3,%eax 85 PIC_WRAPUP 86 leave 87 ret 88 .align 4 89 SET_SIZE(__reduction)