cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

quad.h (6633B)


      1/* Software floating-point emulation.
      2   Definitions for IEEE Quad Precision.
      3   Copyright (C) 1997,1998,1999 Free Software Foundation, Inc.
      4   This file is part of the GNU C Library.
      5   Contributed by Richard Henderson (rth@cygnus.com),
      6		  Jakub Jelinek (jj@ultra.linux.cz),
      7		  David S. Miller (davem@redhat.com) and
      8		  Peter Maydell (pmaydell@chiark.greenend.org.uk).
      9
     10   The GNU C Library is free software; you can redistribute it and/or
     11   modify it under the terms of the GNU Library General Public License as
     12   published by the Free Software Foundation; either version 2 of the
     13   License, or (at your option) any later version.
     14
     15   The GNU C Library is distributed in the hope that it will be useful,
     16   but WITHOUT ANY WARRANTY; without even the implied warranty of
     17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     18   Library General Public License for more details.
     19
     20   You should have received a copy of the GNU Library General Public
     21   License along with the GNU C Library; see the file COPYING.LIB.  If
     22   not, write to the Free Software Foundation, Inc.,
     23   59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
     24
     25#ifndef  __MATH_EMU_QUAD_H__
     26#define  __MATH_EMU_QUAD_H__
     27
     28#if _FP_W_TYPE_SIZE < 32
     29#error "Here's a nickel, kid. Go buy yourself a real computer."
     30#endif
     31
     32#if _FP_W_TYPE_SIZE < 64
     33#define _FP_FRACTBITS_Q         (4*_FP_W_TYPE_SIZE)
     34#else
     35#define _FP_FRACTBITS_Q		(2*_FP_W_TYPE_SIZE)
     36#endif
     37
     38#define _FP_FRACBITS_Q		113
     39#define _FP_FRACXBITS_Q		(_FP_FRACTBITS_Q - _FP_FRACBITS_Q)
     40#define _FP_WFRACBITS_Q		(_FP_WORKBITS + _FP_FRACBITS_Q)
     41#define _FP_WFRACXBITS_Q	(_FP_FRACTBITS_Q - _FP_WFRACBITS_Q)
     42#define _FP_EXPBITS_Q		15
     43#define _FP_EXPBIAS_Q		16383
     44#define _FP_EXPMAX_Q		32767
     45
     46#define _FP_QNANBIT_Q		\
     47	((_FP_W_TYPE)1 << (_FP_FRACBITS_Q-2) % _FP_W_TYPE_SIZE)
     48#define _FP_IMPLBIT_Q		\
     49	((_FP_W_TYPE)1 << (_FP_FRACBITS_Q-1) % _FP_W_TYPE_SIZE)
     50#define _FP_OVERFLOW_Q		\
     51	((_FP_W_TYPE)1 << (_FP_WFRACBITS_Q % _FP_W_TYPE_SIZE))
     52
     53#if _FP_W_TYPE_SIZE < 64
     54
     55union _FP_UNION_Q
     56{
     57   long double flt;
     58   struct 
     59   {
     60#if __BYTE_ORDER == __BIG_ENDIAN
     61      unsigned sign : 1;
     62      unsigned exp : _FP_EXPBITS_Q;
     63      unsigned long frac3 : _FP_FRACBITS_Q - (_FP_IMPLBIT_Q != 0)-(_FP_W_TYPE_SIZE * 3);
     64      unsigned long frac2 : _FP_W_TYPE_SIZE;
     65      unsigned long frac1 : _FP_W_TYPE_SIZE;
     66      unsigned long frac0 : _FP_W_TYPE_SIZE;
     67#else
     68      unsigned long frac0 : _FP_W_TYPE_SIZE;
     69      unsigned long frac1 : _FP_W_TYPE_SIZE;
     70      unsigned long frac2 : _FP_W_TYPE_SIZE;
     71      unsigned long frac3 : _FP_FRACBITS_Q - (_FP_IMPLBIT_Q != 0)-(_FP_W_TYPE_SIZE * 3);
     72      unsigned exp : _FP_EXPBITS_Q;
     73      unsigned sign : 1;
     74#endif /* not bigendian */
     75   } bits __attribute__((packed));
     76};
     77
     78
     79#define FP_DECL_Q(X)		_FP_DECL(4,X)
     80#define FP_UNPACK_RAW_Q(X,val)	_FP_UNPACK_RAW_4(Q,X,val)
     81#define FP_UNPACK_RAW_QP(X,val)	_FP_UNPACK_RAW_4_P(Q,X,val)
     82#define FP_PACK_RAW_Q(val,X)	_FP_PACK_RAW_4(Q,val,X)
     83#define FP_PACK_RAW_QP(val,X)		\
     84  do {					\
     85    if (!FP_INHIBIT_RESULTS)		\
     86      _FP_PACK_RAW_4_P(Q,val,X);	\
     87  } while (0)
     88
     89#define FP_UNPACK_Q(X,val)		\
     90  do {					\
     91    _FP_UNPACK_RAW_4(Q,X,val);		\
     92    _FP_UNPACK_CANONICAL(Q,4,X);	\
     93  } while (0)
     94
     95#define FP_UNPACK_QP(X,val)		\
     96  do {					\
     97    _FP_UNPACK_RAW_4_P(Q,X,val);	\
     98    _FP_UNPACK_CANONICAL(Q,4,X);	\
     99  } while (0)
    100
    101#define FP_PACK_Q(val,X)		\
    102  do {					\
    103    _FP_PACK_CANONICAL(Q,4,X);		\
    104    _FP_PACK_RAW_4(Q,val,X);		\
    105  } while (0)
    106
    107#define FP_PACK_QP(val,X)		\
    108  do {					\
    109    _FP_PACK_CANONICAL(Q,4,X);		\
    110    if (!FP_INHIBIT_RESULTS)		\
    111      _FP_PACK_RAW_4_P(Q,val,X);	\
    112  } while (0)
    113
    114#define FP_ISSIGNAN_Q(X)		_FP_ISSIGNAN(Q,4,X)
    115#define FP_NEG_Q(R,X)			_FP_NEG(Q,4,R,X)
    116#define FP_ADD_Q(R,X,Y)			_FP_ADD(Q,4,R,X,Y)
    117#define FP_SUB_Q(R,X,Y)			_FP_SUB(Q,4,R,X,Y)
    118#define FP_MUL_Q(R,X,Y)			_FP_MUL(Q,4,R,X,Y)
    119#define FP_DIV_Q(R,X,Y)			_FP_DIV(Q,4,R,X,Y)
    120#define FP_SQRT_Q(R,X)			_FP_SQRT(Q,4,R,X)
    121#define _FP_SQRT_MEAT_Q(R,S,T,X,Q)	_FP_SQRT_MEAT_4(R,S,T,X,Q)
    122
    123#define FP_CMP_Q(r,X,Y,un)	_FP_CMP(Q,4,r,X,Y,un)
    124#define FP_CMP_EQ_Q(r,X,Y)	_FP_CMP_EQ(Q,4,r,X,Y)
    125
    126#define FP_TO_INT_Q(r,X,rsz,rsg)	_FP_TO_INT(Q,4,r,X,rsz,rsg)
    127#define FP_TO_INT_ROUND_Q(r,X,rsz,rsg)	_FP_TO_INT_ROUND(Q,4,r,X,rsz,rsg)
    128#define FP_FROM_INT_Q(X,r,rs,rt)	_FP_FROM_INT(Q,4,X,r,rs,rt)
    129
    130#define _FP_FRAC_HIGH_Q(X)	_FP_FRAC_HIGH_4(X)
    131#define _FP_FRAC_HIGH_RAW_Q(X)	_FP_FRAC_HIGH_4(X)
    132
    133#else   /* not _FP_W_TYPE_SIZE < 64 */
    134union _FP_UNION_Q
    135{
    136  long double flt /* __attribute__((mode(TF))) */ ;
    137  struct {
    138#if __BYTE_ORDER == __BIG_ENDIAN
    139    unsigned sign  : 1;
    140    unsigned exp   : _FP_EXPBITS_Q;
    141    unsigned long frac1 : _FP_FRACBITS_Q-(_FP_IMPLBIT_Q != 0)-_FP_W_TYPE_SIZE;
    142    unsigned long frac0 : _FP_W_TYPE_SIZE;
    143#else
    144    unsigned long frac0 : _FP_W_TYPE_SIZE;
    145    unsigned long frac1 : _FP_FRACBITS_Q-(_FP_IMPLBIT_Q != 0)-_FP_W_TYPE_SIZE;
    146    unsigned exp   : _FP_EXPBITS_Q;
    147    unsigned sign  : 1;
    148#endif
    149  } bits;
    150};
    151
    152#define FP_DECL_Q(X)		_FP_DECL(2,X)
    153#define FP_UNPACK_RAW_Q(X,val)	_FP_UNPACK_RAW_2(Q,X,val)
    154#define FP_UNPACK_RAW_QP(X,val)	_FP_UNPACK_RAW_2_P(Q,X,val)
    155#define FP_PACK_RAW_Q(val,X)	_FP_PACK_RAW_2(Q,val,X)
    156#define FP_PACK_RAW_QP(val,X)		\
    157  do {					\
    158    if (!FP_INHIBIT_RESULTS)		\
    159      _FP_PACK_RAW_2_P(Q,val,X);	\
    160  } while (0)
    161
    162#define FP_UNPACK_Q(X,val)		\
    163  do {					\
    164    _FP_UNPACK_RAW_2(Q,X,val);		\
    165    _FP_UNPACK_CANONICAL(Q,2,X);	\
    166  } while (0)
    167
    168#define FP_UNPACK_QP(X,val)		\
    169  do {					\
    170    _FP_UNPACK_RAW_2_P(Q,X,val);	\
    171    _FP_UNPACK_CANONICAL(Q,2,X);	\
    172  } while (0)
    173
    174#define FP_PACK_Q(val,X)		\
    175  do {					\
    176    _FP_PACK_CANONICAL(Q,2,X);		\
    177    _FP_PACK_RAW_2(Q,val,X);		\
    178  } while (0)
    179
    180#define FP_PACK_QP(val,X)		\
    181  do {					\
    182    _FP_PACK_CANONICAL(Q,2,X);		\
    183    if (!FP_INHIBIT_RESULTS)		\
    184      _FP_PACK_RAW_2_P(Q,val,X);	\
    185  } while (0)
    186
    187#define FP_ISSIGNAN_Q(X)		_FP_ISSIGNAN(Q,2,X)
    188#define FP_NEG_Q(R,X)			_FP_NEG(Q,2,R,X)
    189#define FP_ADD_Q(R,X,Y)			_FP_ADD(Q,2,R,X,Y)
    190#define FP_SUB_Q(R,X,Y)			_FP_SUB(Q,2,R,X,Y)
    191#define FP_MUL_Q(R,X,Y)			_FP_MUL(Q,2,R,X,Y)
    192#define FP_DIV_Q(R,X,Y)			_FP_DIV(Q,2,R,X,Y)
    193#define FP_SQRT_Q(R,X)			_FP_SQRT(Q,2,R,X)
    194#define _FP_SQRT_MEAT_Q(R,S,T,X,Q)	_FP_SQRT_MEAT_2(R,S,T,X,Q)
    195
    196#define FP_CMP_Q(r,X,Y,un)	_FP_CMP(Q,2,r,X,Y,un)
    197#define FP_CMP_EQ_Q(r,X,Y)	_FP_CMP_EQ(Q,2,r,X,Y)
    198
    199#define FP_TO_INT_Q(r,X,rsz,rsg)	_FP_TO_INT(Q,2,r,X,rsz,rsg)
    200#define FP_TO_INT_ROUND_Q(r,X,rsz,rsg)	_FP_TO_INT_ROUND(Q,2,r,X,rsz,rsg)
    201#define FP_FROM_INT_Q(X,r,rs,rt)	_FP_FROM_INT(Q,2,X,r,rs,rt)
    202
    203#define _FP_FRAC_HIGH_Q(X)	_FP_FRAC_HIGH_2(X)
    204#define _FP_FRAC_HIGH_RAW_Q(X)	_FP_FRAC_HIGH_2(X)
    205
    206#endif /* not _FP_W_TYPE_SIZE < 64 */
    207
    208#endif /* __MATH_EMU_QUAD_H__ */