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