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 44 ENTRY(__reduction) 45#ifndef PIC 46 movl 12(%esp),%eax / load the high part of arg 47#else 48 movl 16(%esp),%eax / load the high part of arg 49#endif 50 andl $0x7fffffff,%eax / clear sign 51 cmpl $0x3fe921fb,%eax / Is |x| < pi/4 (= 0x3fe921fb54...) ? 52 jbe .L0 53 cmpl $0x7ff00000,%eax / Is arg a NaN or an Inf ? 54 jb .L1 55.L0: 56#ifndef PIC 57 fldl 8(%esp) / push arg 58#else 59 fldl 12(%esp) / push arg 60#endif 61 fwait 62 movl $0,%eax / set n = 0 63 ret 64.L1: 65 pushl %ebp 66 movl %esp,%ebp 67 subl $16,%esp 68 PIC_SETUP(1) 69 leal -16(%ebp),%eax / address of y[0] 70 pushl %eax 71#ifndef PIC 72 pushl 16(%ebp) 73 pushl 12(%ebp) 74#else 75 pushl 20(%ebp) 76 pushl 16(%ebp) 77#endif 78 call PIC_F(__rem_pio2) / call __rem_pio2(x,&y) 79 fldl -8(%ebp) / y[1] 80 fldl -16(%ebp) / y[0], y[1] 81 faddp %st,%st(1) / y[0]+y[1] round-to-extended 82 addl $28,%esp / 16+4*3 83 andl $3,%eax 84 PIC_WRAPUP 85 leave 86 ret 87 .align 4 88 SET_SIZE(__reduction) 89