]> git.ipfire.org Git - thirdparty/glibc.git/blame - soft-fp/op-8.h
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / soft-fp / op-8.h
CommitLineData
d876f532
UD
1/* Software floating-point emulation.
2 Basic eight-word fraction declaration and manipulation.
688903eb 3 Copyright (C) 1997-2018 Free Software Foundation, Inc.
d876f532
UD
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).
41bdb6e2 8
d876f532 9 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
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.
d876f532 13
638a783c
RM
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
d876f532
UD
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
41bdb6e2 26 Lesser General Public License for more details.
d876f532 27
41bdb6e2 28 You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
29 License along with the GNU C Library; if not, see
30 <http://www.gnu.org/licenses/>. */
d876f532 31
a2f8be9c
JM
32#ifndef SOFT_FP_OP_8_H
33#define SOFT_FP_OP_8_H 1
34
d876f532 35/* We need just a few things from here for op-4, if we ever need some
c4fe3ea7 36 other macros, they can be added. */
d876f532
UD
37#define _FP_FRAC_DECL_8(X) _FP_W_TYPE X##_f[8]
38#define _FP_FRAC_HIGH_8(X) (X##_f[7])
39#define _FP_FRAC_LOW_8(X) (X##_f[0])
51ca9e29 40#define _FP_FRAC_WORD_8(X, w) (X##_f[w])
d876f532 41
3a6e9887
JM
42#define _FP_FRAC_SLL_8(X, N) \
43 do \
44 { \
45 _FP_I_TYPE _FP_FRAC_SLL_8_up, _FP_FRAC_SLL_8_down; \
46 _FP_I_TYPE _FP_FRAC_SLL_8_skip, _FP_FRAC_SLL_8_i; \
47 _FP_FRAC_SLL_8_skip = (N) / _FP_W_TYPE_SIZE; \
48 _FP_FRAC_SLL_8_up = (N) % _FP_W_TYPE_SIZE; \
49 _FP_FRAC_SLL_8_down = _FP_W_TYPE_SIZE - _FP_FRAC_SLL_8_up; \
50 if (!_FP_FRAC_SLL_8_up) \
51 for (_FP_FRAC_SLL_8_i = 7; \
52 _FP_FRAC_SLL_8_i >= _FP_FRAC_SLL_8_skip; \
53 --_FP_FRAC_SLL_8_i) \
54 X##_f[_FP_FRAC_SLL_8_i] \
55 = X##_f[_FP_FRAC_SLL_8_i-_FP_FRAC_SLL_8_skip]; \
56 else \
57 { \
58 for (_FP_FRAC_SLL_8_i = 7; \
59 _FP_FRAC_SLL_8_i > _FP_FRAC_SLL_8_skip; \
60 --_FP_FRAC_SLL_8_i) \
61 X##_f[_FP_FRAC_SLL_8_i] \
62 = ((X##_f[_FP_FRAC_SLL_8_i-_FP_FRAC_SLL_8_skip] \
63 << _FP_FRAC_SLL_8_up) \
64 | (X##_f[_FP_FRAC_SLL_8_i-_FP_FRAC_SLL_8_skip-1] \
65 >> _FP_FRAC_SLL_8_down)); \
66 X##_f[_FP_FRAC_SLL_8_i--] = X##_f[0] << _FP_FRAC_SLL_8_up; \
67 } \
68 for (; _FP_FRAC_SLL_8_i >= 0; --_FP_FRAC_SLL_8_i) \
69 X##_f[_FP_FRAC_SLL_8_i] = 0; \
70 } \
1e145589 71 while (0)
d876f532 72
3a6e9887
JM
73#define _FP_FRAC_SRL_8(X, N) \
74 do \
75 { \
76 _FP_I_TYPE _FP_FRAC_SRL_8_up, _FP_FRAC_SRL_8_down; \
77 _FP_I_TYPE _FP_FRAC_SRL_8_skip, _FP_FRAC_SRL_8_i; \
78 _FP_FRAC_SRL_8_skip = (N) / _FP_W_TYPE_SIZE; \
79 _FP_FRAC_SRL_8_down = (N) % _FP_W_TYPE_SIZE; \
80 _FP_FRAC_SRL_8_up = _FP_W_TYPE_SIZE - _FP_FRAC_SRL_8_down; \
81 if (!_FP_FRAC_SRL_8_down) \
82 for (_FP_FRAC_SRL_8_i = 0; \
83 _FP_FRAC_SRL_8_i <= 7-_FP_FRAC_SRL_8_skip; \
84 ++_FP_FRAC_SRL_8_i) \
85 X##_f[_FP_FRAC_SRL_8_i] \
86 = X##_f[_FP_FRAC_SRL_8_i+_FP_FRAC_SRL_8_skip]; \
87 else \
88 { \
89 for (_FP_FRAC_SRL_8_i = 0; \
90 _FP_FRAC_SRL_8_i < 7-_FP_FRAC_SRL_8_skip; \
91 ++_FP_FRAC_SRL_8_i) \
92 X##_f[_FP_FRAC_SRL_8_i] \
93 = ((X##_f[_FP_FRAC_SRL_8_i+_FP_FRAC_SRL_8_skip] \
94 >> _FP_FRAC_SRL_8_down) \
95 | (X##_f[_FP_FRAC_SRL_8_i+_FP_FRAC_SRL_8_skip+1] \
96 << _FP_FRAC_SRL_8_up)); \
97 X##_f[_FP_FRAC_SRL_8_i++] = X##_f[7] >> _FP_FRAC_SRL_8_down; \
98 } \
99 for (; _FP_FRAC_SRL_8_i < 8; ++_FP_FRAC_SRL_8_i) \
100 X##_f[_FP_FRAC_SRL_8_i] = 0; \
101 } \
1e145589 102 while (0)
d876f532
UD
103
104
9c84384c 105/* Right shift with sticky-lsb.
c4fe3ea7
JM
106 What this actually means is that we do a standard right-shift,
107 but that if any of the bits that fall off the right hand side
108 were one then we always set the LSbit. */
51ca9e29 109#define _FP_FRAC_SRS_8(X, N, size) \
1e145589
JM
110 do \
111 { \
3a6e9887
JM
112 _FP_I_TYPE _FP_FRAC_SRS_8_up, _FP_FRAC_SRS_8_down; \
113 _FP_I_TYPE _FP_FRAC_SRS_8_skip, _FP_FRAC_SRS_8_i; \
114 _FP_W_TYPE _FP_FRAC_SRS_8_s; \
115 _FP_FRAC_SRS_8_skip = (N) / _FP_W_TYPE_SIZE; \
116 _FP_FRAC_SRS_8_down = (N) % _FP_W_TYPE_SIZE; \
117 _FP_FRAC_SRS_8_up = _FP_W_TYPE_SIZE - _FP_FRAC_SRS_8_down; \
118 for (_FP_FRAC_SRS_8_s = _FP_FRAC_SRS_8_i = 0; \
119 _FP_FRAC_SRS_8_i < _FP_FRAC_SRS_8_skip; \
120 ++_FP_FRAC_SRS_8_i) \
121 _FP_FRAC_SRS_8_s |= X##_f[_FP_FRAC_SRS_8_i]; \
122 if (!_FP_FRAC_SRS_8_down) \
123 for (_FP_FRAC_SRS_8_i = 0; \
124 _FP_FRAC_SRS_8_i <= 7-_FP_FRAC_SRS_8_skip; \
125 ++_FP_FRAC_SRS_8_i) \
126 X##_f[_FP_FRAC_SRS_8_i] \
127 = X##_f[_FP_FRAC_SRS_8_i+_FP_FRAC_SRS_8_skip]; \
1e145589
JM
128 else \
129 { \
3a6e9887
JM
130 _FP_FRAC_SRS_8_s \
131 |= X##_f[_FP_FRAC_SRS_8_i] << _FP_FRAC_SRS_8_up; \
132 for (_FP_FRAC_SRS_8_i = 0; \
133 _FP_FRAC_SRS_8_i < 7-_FP_FRAC_SRS_8_skip; \
134 ++_FP_FRAC_SRS_8_i) \
135 X##_f[_FP_FRAC_SRS_8_i] \
136 = ((X##_f[_FP_FRAC_SRS_8_i+_FP_FRAC_SRS_8_skip] \
137 >> _FP_FRAC_SRS_8_down) \
138 | (X##_f[_FP_FRAC_SRS_8_i+_FP_FRAC_SRS_8_skip+1] \
139 << _FP_FRAC_SRS_8_up)); \
140 X##_f[_FP_FRAC_SRS_8_i++] = X##_f[7] >> _FP_FRAC_SRS_8_down; \
1e145589 141 } \
3a6e9887
JM
142 for (; _FP_FRAC_SRS_8_i < 8; ++_FP_FRAC_SRS_8_i) \
143 X##_f[_FP_FRAC_SRS_8_i] = 0; \
c4fe3ea7
JM
144 /* Don't fix the LSB until the very end when we're sure f[0] is \
145 stable. */ \
3a6e9887 146 X##_f[0] |= (_FP_FRAC_SRS_8_s != 0); \
1e145589
JM
147 } \
148 while (0)
a2f8be9c
JM
149
150#endif /* !SOFT_FP_OP_8_H */