|
Packit |
6c4009 |
/* FPU control word bits. Mips version.
|
|
Packit |
6c4009 |
Copyright (C) 1996-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
Contributed by Olaf Flebbe and Ralf Baechle.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License along with the GNU C Library. If not, see
|
|
Packit |
6c4009 |
<http://www.gnu.org/licenses/>. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#ifndef _FPU_CONTROL_H
|
|
Packit |
6c4009 |
#define _FPU_CONTROL_H
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* MIPS FPU floating point control register bits.
|
|
Packit |
6c4009 |
*
|
|
Packit |
6c4009 |
* 31-25 -> floating point conditions code bits 7-1. These bits are only
|
|
Packit |
6c4009 |
* available in MIPS IV.
|
|
Packit |
6c4009 |
* 24 -> flush denormalized results to zero instead of
|
|
Packit |
6c4009 |
* causing unimplemented operation exception. This bit is only
|
|
Packit |
6c4009 |
* available for MIPS III and newer.
|
|
Packit |
6c4009 |
* 23 -> Condition bit
|
|
Packit |
6c4009 |
* 22-21 -> reserved for architecture implementers
|
|
Packit |
6c4009 |
* 20 -> reserved (read as 0, write with 0)
|
|
Packit |
6c4009 |
* 19 -> IEEE 754-2008 non-arithmetic ABS.fmt and NEG.fmt enable
|
|
Packit |
6c4009 |
* 18 -> IEEE 754-2008 recommended NaN encoding enable
|
|
Packit |
6c4009 |
* 17 -> cause bit for unimplemented operation
|
|
Packit |
6c4009 |
* 16 -> cause bit for invalid exception
|
|
Packit |
6c4009 |
* 15 -> cause bit for division by zero exception
|
|
Packit |
6c4009 |
* 14 -> cause bit for overflow exception
|
|
Packit |
6c4009 |
* 13 -> cause bit for underflow exception
|
|
Packit |
6c4009 |
* 12 -> cause bit for inexact exception
|
|
Packit |
6c4009 |
* 11 -> enable exception for invalid exception
|
|
Packit |
6c4009 |
* 10 -> enable exception for division by zero exception
|
|
Packit |
6c4009 |
* 9 -> enable exception for overflow exception
|
|
Packit |
6c4009 |
* 8 -> enable exception for underflow exception
|
|
Packit |
6c4009 |
* 7 -> enable exception for inexact exception
|
|
Packit |
6c4009 |
* 6 -> flag invalid exception
|
|
Packit |
6c4009 |
* 5 -> flag division by zero exception
|
|
Packit |
6c4009 |
* 4 -> flag overflow exception
|
|
Packit |
6c4009 |
* 3 -> flag underflow exception
|
|
Packit |
6c4009 |
* 2 -> flag inexact exception
|
|
Packit |
6c4009 |
* 1-0 -> rounding control
|
|
Packit |
6c4009 |
*
|
|
Packit |
6c4009 |
*
|
|
Packit |
6c4009 |
* Rounding Control:
|
|
Packit |
6c4009 |
* 00 - rounding to nearest (RN)
|
|
Packit |
6c4009 |
* 01 - rounding toward zero (RZ)
|
|
Packit |
6c4009 |
* 10 - rounding (up) toward plus infinity (RP)
|
|
Packit |
6c4009 |
* 11 - rounding (down)toward minus infinity (RM)
|
|
Packit |
6c4009 |
*/
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <features.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#ifdef __mips_soft_float
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#define _FPU_RESERVED 0xffffffff
|
|
Packit |
6c4009 |
#define _FPU_DEFAULT 0x00000000
|
|
Packit |
6c4009 |
typedef unsigned int fpu_control_t;
|
|
Packit |
6c4009 |
#define _FPU_GETCW(cw) (cw) = 0
|
|
Packit |
6c4009 |
#define _FPU_SETCW(cw) (void) (cw)
|
|
Packit |
6c4009 |
extern fpu_control_t __fpu_control;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#else /* __mips_soft_float */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Masks for interrupts. */
|
|
Packit |
6c4009 |
#define _FPU_MASK_V 0x0800 /* Invalid operation */
|
|
Packit |
6c4009 |
#define _FPU_MASK_Z 0x0400 /* Division by zero */
|
|
Packit |
6c4009 |
#define _FPU_MASK_O 0x0200 /* Overflow */
|
|
Packit |
6c4009 |
#define _FPU_MASK_U 0x0100 /* Underflow */
|
|
Packit |
6c4009 |
#define _FPU_MASK_I 0x0080 /* Inexact operation */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Flush denormalized numbers to zero. */
|
|
Packit |
6c4009 |
#define _FPU_FLUSH_TZ 0x1000000
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* IEEE 754-2008 compliance control. */
|
|
Packit |
6c4009 |
#define _FPU_ABS2008 0x80000
|
|
Packit |
6c4009 |
#define _FPU_NAN2008 0x40000
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Rounding control. */
|
|
Packit |
6c4009 |
#define _FPU_RC_NEAREST 0x0 /* RECOMMENDED */
|
|
Packit |
6c4009 |
#define _FPU_RC_ZERO 0x1
|
|
Packit |
6c4009 |
#define _FPU_RC_UP 0x2
|
|
Packit |
6c4009 |
#define _FPU_RC_DOWN 0x3
|
|
Packit |
6c4009 |
/* Mask for rounding control. */
|
|
Packit |
6c4009 |
#define _FPU_RC_MASK 0x3
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#define _FPU_RESERVED 0xfe8c0000 /* Reserved bits in cw, incl ABS/NAN2008. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* The fdlibm code requires strict IEEE double precision arithmetic,
|
|
Packit |
6c4009 |
and no interrupts for exceptions, rounding to nearest. */
|
|
Packit |
6c4009 |
#ifdef __mips_nan2008
|
|
Packit |
6c4009 |
# define _FPU_DEFAULT 0x000C0000
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
# define _FPU_DEFAULT 0x00000000
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* IEEE: same as above, but exceptions. */
|
|
Packit |
6c4009 |
#ifdef __mips_nan2008
|
|
Packit |
6c4009 |
# define _FPU_IEEE 0x000C0F80
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
# define _FPU_IEEE 0x00000F80
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Type of the control word. */
|
|
Packit |
6c4009 |
typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__SI__)));
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Macros for accessing the hardware control word. */
|
|
Packit |
6c4009 |
extern fpu_control_t __mips_fpu_getcw (void) __THROW;
|
|
Packit |
6c4009 |
extern void __mips_fpu_setcw (fpu_control_t) __THROW;
|
|
Packit |
6c4009 |
#ifdef __mips16
|
|
Packit |
6c4009 |
# define _FPU_GETCW(cw) do { (cw) = __mips_fpu_getcw (); } while (0)
|
|
Packit |
6c4009 |
# define _FPU_SETCW(cw) __mips_fpu_setcw (cw)
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
# define _FPU_GETCW(cw) __asm__ volatile ("cfc1 %0,$31" : "=r" (cw))
|
|
Packit |
6c4009 |
# define _FPU_SETCW(cw) __asm__ volatile ("ctc1 %0,$31" : : "r" (cw))
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Default control word set at startup. */
|
|
Packit |
6c4009 |
extern fpu_control_t __fpu_control;
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#endif /* __mips_soft_float */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#endif /* fpu_control.h */
|