/*1* Linux/PA-RISC Project (http://www.parisc-linux.org/)2*3* Floating-point emulation code4* Copyright (C) 2001 Hewlett-Packard (Paul Bame) <[email protected]>5*6* This program is free software; you can redistribute it and/or modify7* it under the terms of the GNU General Public License as published by8* the Free Software Foundation; either version 2, or (at your option)9* any later version.10*11* This program is distributed in the hope that it will be useful,12* but WITHOUT ANY WARRANTY; without even the implied warranty of13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14* GNU General Public License for more details.15*16* You should have received a copy of the GNU General Public License17* along with this program; if not, write to the Free Software18* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA19*/20/*21* BEGIN_DESC22*23* File:24* @(#) pa/fp/denormal.c $ Revision: $25*26* Purpose:27* <<please update with a synopsis of the functionality provided by this file>>28*29* External Interfaces:30* <<the following list was autogenerated, please review>>31* dbl_denormalize(dbl_opndp1,dbl_opndp2,inexactflag,rmode)32* sgl_denormalize(sgl_opnd,inexactflag,rmode)33*34* Internal Interfaces:35* <<please update>>36*37* Theory:38* <<please update with a overview of the operation of this file>>39*40* END_DESC41*/42434445#include "float.h"46#include "sgl_float.h"47#include "dbl_float.h"48#include "hppa.h"49#include <linux/kernel.h>50/* #include <machine/sys/mdep_private.h> */5152#undef Fpustatus_register53#define Fpustatus_register Fpu_register[0]5455void56sgl_denormalize(unsigned int *sgl_opnd, boolean *inexactflag, int rmode)57{58unsigned int opnd;59int sign, exponent;60boolean guardbit = FALSE, stickybit, inexact;6162opnd = *sgl_opnd;63stickybit = *inexactflag;64exponent = Sgl_exponent(opnd) - SGL_WRAP;65sign = Sgl_sign(opnd);66Sgl_denormalize(opnd,exponent,guardbit,stickybit,inexact);67if (inexact) {68switch (rmode) {69case ROUNDPLUS:70if (sign == 0) {71Sgl_increment(opnd);72}73break;74case ROUNDMINUS:75if (sign != 0) {76Sgl_increment(opnd);77}78break;79case ROUNDNEAREST:80if (guardbit && (stickybit ||81Sgl_isone_lowmantissa(opnd))) {82Sgl_increment(opnd);83}84break;85}86}87Sgl_set_sign(opnd,sign);88*sgl_opnd = opnd;89*inexactflag = inexact;90return;91}9293void94dbl_denormalize(unsigned int *dbl_opndp1,95unsigned int * dbl_opndp2,96boolean *inexactflag,97int rmode)98{99unsigned int opndp1, opndp2;100int sign, exponent;101boolean guardbit = FALSE, stickybit, inexact;102103opndp1 = *dbl_opndp1;104opndp2 = *dbl_opndp2;105stickybit = *inexactflag;106exponent = Dbl_exponent(opndp1) - DBL_WRAP;107sign = Dbl_sign(opndp1);108Dbl_denormalize(opndp1,opndp2,exponent,guardbit,stickybit,inexact);109if (inexact) {110switch (rmode) {111case ROUNDPLUS:112if (sign == 0) {113Dbl_increment(opndp1,opndp2);114}115break;116case ROUNDMINUS:117if (sign != 0) {118Dbl_increment(opndp1,opndp2);119}120break;121case ROUNDNEAREST:122if (guardbit && (stickybit ||123Dbl_isone_lowmantissap2(opndp2))) {124Dbl_increment(opndp1,opndp2);125}126break;127}128}129Dbl_set_sign(opndp1,sign);130*dbl_opndp1 = opndp1;131*dbl_opndp2 = opndp2;132*inexactflag = inexact;133return;134}135136137