Back to index

glibc  2.9
fpu_control.h
Go to the documentation of this file.
00001 /* FPU control word bits.  Mips version.
00002    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2006, 2008
00003    Free Software Foundation, Inc.
00004    This file is part of the GNU C Library.
00005    Contributed by Olaf Flebbe and Ralf Baechle.
00006 
00007    The GNU C Library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Lesser General Public
00009    License as published by the Free Software Foundation; either
00010    version 2.1 of the License, or (at your option) any later version.
00011 
00012    The GNU C Library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Lesser General Public License for more details.
00016 
00017    You should have received a copy of the GNU Lesser General Public
00018    License along with the GNU C Library; if not, write to the Free
00019    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00020    02111-1307 USA.  */
00021 
00022 #ifndef _FPU_CONTROL_H
00023 #define _FPU_CONTROL_H
00024 
00025 /* MIPS FPU floating point control register bits.
00026  *
00027  * 31-25  -> floating point conditions code bits 7-1.  These bits are only
00028  *           available in MIPS IV.
00029  * 24     -> flush denormalized results to zero instead of
00030  *           causing unimplemented operation exception.  This bit is only
00031  *           available for MIPS III and newer.
00032  * 23     -> Condition bit
00033  * 22-18  -> reserved (read as 0, write with 0)
00034  * 17     -> cause bit for unimplemented operation
00035  * 16     -> cause bit for invalid exception
00036  * 15     -> cause bit for division by zero exception
00037  * 14     -> cause bit for overflow exception
00038  * 13     -> cause bit for underflow exception
00039  * 12     -> cause bit for inexact exception
00040  * 11     -> enable exception for invalid exception
00041  * 10     -> enable exception for division by zero exception
00042  *  9     -> enable exception for overflow exception
00043  *  8     -> enable exception for underflow exception
00044  *  7     -> enable exception for inexact exception
00045  *  6     -> flag invalid exception
00046  *  5     -> flag division by zero exception
00047  *  4     -> flag overflow exception
00048  *  3     -> flag underflow exception
00049  *  2     -> flag inexact exception
00050  *  1-0   -> rounding control
00051  *
00052  *
00053  * Rounding Control:
00054  * 00 - rounding to nearest (RN)
00055  * 01 - rounding toward zero (RZ)
00056  * 10 - rounding (up) toward plus infinity (RP)
00057  * 11 - rounding (down)toward minus infinity (RM)
00058  */
00059 
00060 #include <features.h>
00061 
00062 #ifdef __mips_soft_float
00063 
00064 #define _FPU_RESERVED 0xffffffff
00065 #define _FPU_DEFAULT  0x00000000
00066 typedef unsigned int fpu_control_t;
00067 #define _FPU_GETCW(cw) 0
00068 #define _FPU_SETCW(cw) do { } while (0)
00069 extern fpu_control_t __fpu_control;
00070 
00071 #else /* __mips_soft_float */
00072 
00073 /* masking of interrupts */
00074 #define _FPU_MASK_V     0x0800  /* Invalid operation */
00075 #define _FPU_MASK_Z     0x0400  /* Division by zero  */
00076 #define _FPU_MASK_O     0x0200  /* Overflow          */
00077 #define _FPU_MASK_U     0x0100  /* Underflow         */
00078 #define _FPU_MASK_I     0x0080  /* Inexact operation */
00079 
00080 /* flush denormalized numbers to zero */
00081 #define _FPU_FLUSH_TZ   0x1000000
00082 
00083 /* rounding control */
00084 #define _FPU_RC_NEAREST 0x0     /* RECOMMENDED */
00085 #define _FPU_RC_ZERO    0x1
00086 #define _FPU_RC_UP      0x2
00087 #define _FPU_RC_DOWN    0x3
00088 
00089 #define _FPU_RESERVED 0xfe3c0000  /* Reserved bits in cw */
00090 
00091 
00092 /* The fdlibm code requires strict IEEE double precision arithmetic,
00093    and no interrupts for exceptions, rounding to nearest.  */
00094 
00095 #define _FPU_DEFAULT  0x00000000
00096 
00097 /* IEEE:  same as above, but exceptions */
00098 #define _FPU_IEEE     0x00000F80
00099 
00100 /* Type of the control word.  */
00101 typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__SI__)));
00102 
00103 /* Macros for accessing the hardware control word.  */
00104 #define _FPU_GETCW(cw) __asm__ volatile ("cfc1 %0,$31" : "=r" (cw))
00105 #define _FPU_SETCW(cw) __asm__ volatile ("ctc1 %0,$31" : : "r" (cw))
00106 
00107 /* Default control word set at startup.  */
00108 extern fpu_control_t __fpu_control;
00109 
00110 #endif /* __mips_soft_float */
00111 
00112 #endif /* fpu_control.h */