OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgcc/] [soft-fp/] [op-8.h] - Blame information for rev 734

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 734 jeremybenn
/* Software floating-point emulation.
2
   Basic eight-word fraction declaration and manipulation.
3
   Copyright (C) 1997,1998,1999,2006 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) and
7
                  Peter Maydell (pmaydell@chiark.greenend.org.uk).
8
 
9
   The GNU C Library is free software; you can redistribute it and/or
10
   modify it under the terms of the GNU Lesser General Public
11
   License as published by the Free Software Foundation; either
12
   version 2.1 of the License, or (at your option) any later version.
13
 
14
   In addition to the permissions in the GNU Lesser General Public
15
   License, the Free Software Foundation gives you unlimited
16
   permission to link the compiled version of this file into
17
   combinations with other programs, and to distribute those
18
   combinations without any restriction coming from the use of this
19
   file.  (The Lesser General Public License restrictions do apply in
20
   other respects; for example, they cover modification of the file,
21
   and distribution when not linked into a combine executable.)
22
 
23
   The GNU C Library is distributed in the hope that it will be useful,
24
   but WITHOUT ANY WARRANTY; without even the implied warranty of
25
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
26
   Lesser General Public License for more details.
27
 
28
   You should have received a copy of the GNU Lesser General Public
29
   License along with the GNU C Library; if not, write to the Free
30
   Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
31
   MA 02110-1301, USA.  */
32
 
33
/* We need just a few things from here for op-4, if we ever need some
34
   other macros, they can be added. */
35
#define _FP_FRAC_DECL_8(X)      _FP_W_TYPE X##_f[8]
36
#define _FP_FRAC_HIGH_8(X)      (X##_f[7])
37
#define _FP_FRAC_LOW_8(X)       (X##_f[0])
38
#define _FP_FRAC_WORD_8(X,w)    (X##_f[w])
39
 
40
#define _FP_FRAC_SLL_8(X,N)                                             \
41
  do {                                                                  \
42
    _FP_I_TYPE _up, _down, _skip, _i;                                   \
43
    _skip = (N) / _FP_W_TYPE_SIZE;                                      \
44
    _up = (N) % _FP_W_TYPE_SIZE;                                        \
45
    _down = _FP_W_TYPE_SIZE - _up;                                      \
46
    if (!_up)                                                           \
47
      for (_i = 7; _i >= _skip; --_i)                                   \
48
        X##_f[_i] = X##_f[_i-_skip];                                    \
49
    else                                                                \
50
      {                                                                 \
51
        for (_i = 7; _i > _skip; --_i)                                  \
52
          X##_f[_i] = X##_f[_i-_skip] << _up                            \
53
                      | X##_f[_i-_skip-1] >> _down;                     \
54
        X##_f[_i--] = X##_f[0] << _up;                                  \
55
      }                                                                 \
56
    for (; _i >= 0; --_i)                                                \
57
      X##_f[_i] = 0;                                                    \
58
  } while (0)
59
 
60
#define _FP_FRAC_SRL_8(X,N)                                             \
61
  do {                                                                  \
62
    _FP_I_TYPE _up, _down, _skip, _i;                                   \
63
    _skip = (N) / _FP_W_TYPE_SIZE;                                      \
64
    _down = (N) % _FP_W_TYPE_SIZE;                                      \
65
    _up = _FP_W_TYPE_SIZE - _down;                                      \
66
    if (!_down)                                                         \
67
      for (_i = 0; _i <= 7-_skip; ++_i)                                  \
68
        X##_f[_i] = X##_f[_i+_skip];                                    \
69
    else                                                                \
70
      {                                                                 \
71
        for (_i = 0; _i < 7-_skip; ++_i)                         \
72
          X##_f[_i] = X##_f[_i+_skip] >> _down                          \
73
                      | X##_f[_i+_skip+1] << _up;                       \
74
        X##_f[_i++] = X##_f[7] >> _down;                                \
75
      }                                                                 \
76
    for (; _i < 8; ++_i)                                                \
77
      X##_f[_i] = 0;                                                    \
78
  } while (0)
79
 
80
 
81
/* Right shift with sticky-lsb.
82
 * What this actually means is that we do a standard right-shift,
83
 * but that if any of the bits that fall off the right hand side
84
 * were one then we always set the LSbit.
85
 */
86
#define _FP_FRAC_SRS_8(X,N,size)                                        \
87
  do {                                                                  \
88
    _FP_I_TYPE _up, _down, _skip, _i;                                   \
89
    _FP_W_TYPE _s;                                                      \
90
    _skip = (N) / _FP_W_TYPE_SIZE;                                      \
91
    _down = (N) % _FP_W_TYPE_SIZE;                                      \
92
    _up = _FP_W_TYPE_SIZE - _down;                                      \
93
    for (_s = _i = 0; _i < _skip; ++_i)                                  \
94
      _s |= X##_f[_i];                                                  \
95
    if (!_down)                                                         \
96
      for (_i = 0; _i <= 7-_skip; ++_i)                                  \
97
        X##_f[_i] = X##_f[_i+_skip];                                    \
98
    else                                                                \
99
      {                                                                 \
100
        _s |= X##_f[_i] << _up;                                         \
101
        for (_i = 0; _i < 7-_skip; ++_i)                         \
102
          X##_f[_i] = X##_f[_i+_skip] >> _down                          \
103
                      | X##_f[_i+_skip+1] << _up;                       \
104
        X##_f[_i++] = X##_f[7] >> _down;                                \
105
      }                                                                 \
106
    for (; _i < 8; ++_i)                                                \
107
      X##_f[_i] = 0;                                                    \
108
    /* don't fix the LSB until the very end when we're sure f[0] is stable */   \
109
    X##_f[0] |= (_s != 0);                                              \
110
  } while (0)
111
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.