~ubuntu-branches/ubuntu/vivid/qemu/vivid

« back to all changes in this revision

Viewing changes to debian/patches/ubuntu/arm64/0101-softfloat-Add-support-for-ties-away-rounding.patch

  • Committer: Package Import Robot
  • Author(s): dann frazier
  • Date: 2014-02-11 15:41:53 UTC
  • Revision ID: package-import@ubuntu.com-20140211154153-2d001tf0ium08u81
Tags: 1.7.0+dfsg-3ubuntu2
* Backport changes to enable qemu-user-static support for aarch64
* debian/control: add ppc64el to Architectures
* debian/rules: only install qemu-system-aarch64 on arm64.
  Fixes a FTBFS  when built twice in a row on non-arm64 due to a stale
  debian/qemu-system-aarch64 directory

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From 0d80b9f0fd22f5da30c66bcb046ac0e5813f4c9a Mon Sep 17 00:00:00 2001
 
2
From: Peter Maydell <peter.maydell@linaro.org>
 
3
Date: Tue, 7 Jan 2014 17:19:12 +0000
 
4
Subject: [PATCH 101/158] softfloat: Add support for ties-away rounding
 
5
 
 
6
IEEE754-2008 specifies a new rounding mode:
 
7
 
 
8
"roundTiesToAway: the floating-point number nearest to the infinitely
 
9
precise result shall be delivered; if the two nearest floating-point
 
10
numbers bracketing an unrepresentable infinitely precise result are
 
11
equally near, the one with larger magnitude shall be delivered."
 
12
 
 
13
Implement this new mode (it is needed for ARM). The general principle
 
14
is that the required code is exactly like the ties-to-even code,
 
15
except that we do not need to do the "in case of exact tie clear LSB
 
16
to round-to-even", because the rounding operation naturally causes
 
17
the exact tie to round up in magnitude.
 
18
 
 
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
 
20
Reviewed-by: Richard Henderson <rth@twiddle.net>
 
21
---
 
22
 fpu/softfloat.c         | 54 +++++++++++++++++++++++++++++++++++++++++++++++++
 
23
 include/fpu/softfloat.h |  3 ++-
 
24
 2 files changed, 56 insertions(+), 1 deletion(-)
 
25
 
 
26
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
 
27
index 234b545..85c9095 100644
 
28
--- a/fpu/softfloat.c
 
29
+++ b/fpu/softfloat.c
 
30
@@ -111,6 +111,7 @@ static int32 roundAndPackInt32( flag zSign, uint64_t absZ STATUS_PARAM)
 
31
     roundNearestEven = ( roundingMode == float_round_nearest_even );
 
32
     switch (roundingMode) {
 
33
     case float_round_nearest_even:
 
34
+    case float_round_ties_away:
 
35
         roundIncrement = 0x40;
 
36
         break;
 
37
     case float_round_to_zero:
 
38
@@ -161,6 +162,7 @@ static int64 roundAndPackInt64( flag zSign, uint64_t absZ0, uint64_t absZ1 STATU
 
39
     roundNearestEven = ( roundingMode == float_round_nearest_even );
 
40
     switch (roundingMode) {
 
41
     case float_round_nearest_even:
 
42
+    case float_round_ties_away:
 
43
         increment = ((int64_t) absZ1 < 0);
 
44
         break;
 
45
     case float_round_to_zero:
 
46
@@ -214,6 +216,7 @@ static int64 roundAndPackUint64(flag zSign, uint64_t absZ0,
 
47
     roundNearestEven = (roundingMode == float_round_nearest_even);
 
48
     switch (roundingMode) {
 
49
     case float_round_nearest_even:
 
50
+    case float_round_ties_away:
 
51
         increment = ((int64_t)absZ1 < 0);
 
52
         break;
 
53
     case float_round_to_zero:
 
54
@@ -366,6 +369,7 @@ static float32 roundAndPackFloat32(flag zSign, int_fast16_t zExp, uint32_t zSig
 
55
     roundNearestEven = ( roundingMode == float_round_nearest_even );
 
56
     switch (roundingMode) {
 
57
     case float_round_nearest_even:
 
58
+    case float_round_ties_away:
 
59
         roundIncrement = 0x40;
 
60
         break;
 
61
     case float_round_to_zero:
 
62
@@ -550,6 +554,7 @@ static float64 roundAndPackFloat64(flag zSign, int_fast16_t zExp, uint64_t zSig
 
63
     roundNearestEven = ( roundingMode == float_round_nearest_even );
 
64
     switch (roundingMode) {
 
65
     case float_round_nearest_even:
 
66
+    case float_round_ties_away:
 
67
         roundIncrement = 0x200;
 
68
         break;
 
69
     case float_round_to_zero:
 
70
@@ -734,6 +739,7 @@ static floatx80
 
71
     zSig0 |= ( zSig1 != 0 );
 
72
     switch (roundingMode) {
 
73
     case float_round_nearest_even:
 
74
+    case float_round_ties_away:
 
75
         break;
 
76
     case float_round_to_zero:
 
77
         roundIncrement = 0;
 
78
@@ -794,6 +800,7 @@ static floatx80
 
79
  precision80:
 
80
     switch (roundingMode) {
 
81
     case float_round_nearest_even:
 
82
+    case float_round_ties_away:
 
83
         increment = ((int64_t)zSig1 < 0);
 
84
         break;
 
85
     case float_round_to_zero:
 
86
@@ -838,6 +845,7 @@ static floatx80
 
87
             if ( zSig1 ) STATUS(float_exception_flags) |= float_flag_inexact;
 
88
             switch (roundingMode) {
 
89
             case float_round_nearest_even:
 
90
+            case float_round_ties_away:
 
91
                 increment = ((int64_t)zSig1 < 0);
 
92
                 break;
 
93
             case float_round_to_zero:
 
94
@@ -1052,6 +1060,7 @@ static float128
 
95
     roundNearestEven = ( roundingMode == float_round_nearest_even );
 
96
     switch (roundingMode) {
 
97
     case float_round_nearest_even:
 
98
+    case float_round_ties_away:
 
99
         increment = ((int64_t)zSig2 < 0);
 
100
         break;
 
101
     case float_round_to_zero:
 
102
@@ -1114,6 +1123,7 @@ static float128
 
103
             if ( isTiny && zSig2 ) float_raise( float_flag_underflow STATUS_VAR);
 
104
             switch (roundingMode) {
 
105
             case float_round_nearest_even:
 
106
+            case float_round_ties_away:
 
107
                 increment = ((int64_t)zSig2 < 0);
 
108
                 break;
 
109
             case float_round_to_zero:
 
110
@@ -1785,6 +1795,11 @@ float32 float32_round_to_int( float32 a STATUS_PARAM)
 
111
                 return packFloat32( aSign, 0x7F, 0 );
 
112
             }
 
113
             break;
 
114
+        case float_round_ties_away:
 
115
+            if (aExp == 0x7E) {
 
116
+                return packFloat32(aSign, 0x7F, 0);
 
117
+            }
 
118
+            break;
 
119
          case float_round_down:
 
120
             return make_float32(aSign ? 0xBF800000 : 0);
 
121
          case float_round_up:
 
122
@@ -1803,6 +1818,9 @@ float32 float32_round_to_int( float32 a STATUS_PARAM)
 
123
             z &= ~lastBitMask;
 
124
         }
 
125
         break;
 
126
+    case float_round_ties_away:
 
127
+        z += lastBitMask >> 1;
 
128
+        break;
 
129
     case float_round_to_zero:
 
130
         break;
 
131
     case float_round_up:
 
132
@@ -3183,6 +3201,9 @@ static float32 roundAndPackFloat16(flag zSign, int_fast16_t zExp,
 
133
             increment = zSig & (increment << 1);
 
134
         }
 
135
         break;
 
136
+    case float_round_ties_away:
 
137
+        increment = (mask + 1) >> 1;
 
138
+        break;
 
139
     case float_round_up:
 
140
         increment = zSign ? 0 : mask;
 
141
         break;
 
142
@@ -3487,6 +3508,11 @@ float64 float64_round_to_int( float64 a STATUS_PARAM )
 
143
                 return packFloat64( aSign, 0x3FF, 0 );
 
144
             }
 
145
             break;
 
146
+        case float_round_ties_away:
 
147
+            if (aExp == 0x3FE) {
 
148
+                return packFloat64(aSign, 0x3ff, 0);
 
149
+            }
 
150
+            break;
 
151
          case float_round_down:
 
152
             return make_float64(aSign ? LIT64( 0xBFF0000000000000 ) : 0);
 
153
          case float_round_up:
 
154
@@ -3506,6 +3532,9 @@ float64 float64_round_to_int( float64 a STATUS_PARAM )
 
155
             z &= ~lastBitMask;
 
156
         }
 
157
         break;
 
158
+    case float_round_ties_away:
 
159
+        z += lastBitMask >> 1;
 
160
+        break;
 
161
     case float_round_to_zero:
 
162
         break;
 
163
     case float_round_up:
 
164
@@ -4771,6 +4800,11 @@ floatx80 floatx80_round_to_int( floatx80 a STATUS_PARAM )
 
165
                     packFloatx80( aSign, 0x3FFF, LIT64( 0x8000000000000000 ) );
 
166
             }
 
167
             break;
 
168
+        case float_round_ties_away:
 
169
+            if (aExp == 0x3FFE) {
 
170
+                return packFloatx80(aSign, 0x3FFF, LIT64(0x8000000000000000));
 
171
+            }
 
172
+            break;
 
173
          case float_round_down:
 
174
             return
 
175
                   aSign ?
 
176
@@ -4794,6 +4828,9 @@ floatx80 floatx80_round_to_int( floatx80 a STATUS_PARAM )
 
177
             z.low &= ~lastBitMask;
 
178
         }
 
179
         break;
 
180
+    case float_round_ties_away:
 
181
+        z.low += lastBitMask >> 1;
 
182
+        break;
 
183
     case float_round_to_zero:
 
184
         break;
 
185
     case float_round_up:
 
186
@@ -5862,6 +5899,15 @@ float128 float128_round_to_int( float128 a STATUS_PARAM )
 
187
                 }
 
188
             }
 
189
             break;
 
190
+        case float_round_ties_away:
 
191
+            if (lastBitMask) {
 
192
+                add128(z.high, z.low, 0, lastBitMask >> 1, &z.high, &z.low);
 
193
+            } else {
 
194
+                if ((int64_t) z.low < 0) {
 
195
+                    ++z.high;
 
196
+                }
 
197
+            }
 
198
+            break;
 
199
         case float_round_to_zero:
 
200
             break;
 
201
         case float_round_up:
 
202
@@ -5893,6 +5939,11 @@ float128 float128_round_to_int( float128 a STATUS_PARAM )
 
203
                     return packFloat128( aSign, 0x3FFF, 0, 0 );
 
204
                 }
 
205
                 break;
 
206
+            case float_round_ties_away:
 
207
+                if (aExp == 0x3FFE) {
 
208
+                    return packFloat128(aSign, 0x3FFF, 0, 0);
 
209
+                }
 
210
+                break;
 
211
              case float_round_down:
 
212
                 return
 
213
                       aSign ? packFloat128( 1, 0x3FFF, 0, 0 )
 
214
@@ -5916,6 +5967,9 @@ float128 float128_round_to_int( float128 a STATUS_PARAM )
 
215
                 z.high &= ~ lastBitMask;
 
216
             }
 
217
             break;
 
218
+        case float_round_ties_away:
 
219
+            z.high += lastBitMask>>1;
 
220
+            break;
 
221
         case float_round_to_zero:
 
222
             break;
 
223
         case float_round_up:
 
224
diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
 
225
index 83d324a..806ae13 100644
 
226
--- a/include/fpu/softfloat.h
 
227
+++ b/include/fpu/softfloat.h
 
228
@@ -152,7 +152,8 @@ enum {
 
229
     float_round_nearest_even = 0,
 
230
     float_round_down         = 1,
 
231
     float_round_up           = 2,
 
232
-    float_round_to_zero      = 3
 
233
+    float_round_to_zero      = 3,
 
234
+    float_round_ties_away    = 4,
 
235
 };
 
236
 
 
237
 /*----------------------------------------------------------------------------
 
238
-- 
 
239
1.9.rc1
 
240