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, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22/* 23 * Copyright (c) 1994-2000 by Sun Microsystems, Inc. 24 * All rights reserved. 25 */ 26 27#pragma ident "%Z%%M% %I% %E% SMI" 28 29 .file "%M%" 30 31#include <sys/asm_linkage.h> 32 33/* 34 * Versions of .mul .umul .div .udiv .rem .urem written using 35 * appropriate SPARC V8 instructions. 36 */ 37 38 ENTRY(.mul) 39 smul %o0, %o1, %o0 40 rd %y, %o1 41 sra %o0, 31, %o2 42 retl 43 cmp %o1, %o2 ! return with Z set if %y == (%o0 >> 31) 44 SET_SIZE(.mul) 45 46 ENTRY(.umul) 47 umul %o0, %o1, %o0 48 rd %y, %o1 49 retl 50 tst %o1 ! return with Z set if high order bits are zero 51 SET_SIZE(.umul) 52 53 ENTRY(.div) 54 sra %o0, 31, %o2 55 wr %g0, %o2, %y 56 nop 57 nop 58 nop 59 sdivcc %o0, %o1, %o0 60 bvs,a 1f 61 xnor %o0, %g0, %o0 ! Corbett Correction Factor 621: retl 63 nop 64 SET_SIZE(.div) 65 66 ENTRY(.udiv) 67 wr %g0, %g0, %y 68 nop 69 nop 70 retl 71 udiv %o0, %o1, %o0 72 SET_SIZE(.udiv) 73 74 ENTRY(.rem) 75 sra %o0, 31, %o4 76 wr %o4, %g0, %y 77 nop 78 nop 79 nop 80 sdivcc %o0, %o1, %o2 81 bvs,a 1f 82 xnor %o2, %g0, %o2 ! Corbett Correction Factor 831: smul %o2, %o1, %o2 84 retl 85 sub %o0, %o2, %o0 86 SET_SIZE(.rem) 87 88 ENTRY(.urem) 89 wr %g0, %g0, %y 90 nop 91 nop 92 nop 93 udiv %o0, %o1, %o2 94 umul %o2, %o1, %o2 95 retl 96 sub %o0, %o2, %o0 97 SET_SIZE(.urem) 98