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

« back to all changes in this revision

Viewing changes to debian/patches/ubuntu/arm64/0108-target-arm-A64-Add-1-source-32-to-32-and-64-to-64-FP.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 a3ca5aff47390abcb5c665cdea6248feb0246c72 Mon Sep 17 00:00:00 2001
 
2
From: Peter Maydell <peter.maydell@linaro.org>
 
3
Date: Tue, 7 Jan 2014 17:19:14 +0000
 
4
Subject: [PATCH 108/158] target-arm: A64: Add 1-source 32-to-32 and 64-to-64
 
5
 FP instructions
 
6
 
 
7
This patch adds support for those instructions in the  "Floating-point
 
8
data-processing (1 source)" group which are simple 32-bit-to-32-bit
 
9
or 64-bit-to-64-bit operations (ie everything except FCVT between
 
10
single/double/half precision).
 
11
 
 
12
We put the new round-to-int helpers in helper.c because they will
 
13
also be used by the new ARMv8 A32/T32 rounding instructions.
 
14
 
 
15
Signed-off-by: Alexander Graf <agraf@suse.de>
 
16
[WN: Commit message tweak, merged single and double precision patches,
 
17
 updated to new infrastructure.]
 
18
Signed-off-by: Will Newton <will.newton@linaro.org>
 
19
[PMM: reworked decode, split FCVT out into their own patch]
 
20
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
 
21
Reviewed-by: Richard Henderson <rth@twiddle.net>
 
22
---
 
23
 target-arm/helper.c        |  45 ++++++++++++++
 
24
 target-arm/helper.h        |   5 ++
 
25
 target-arm/translate-a64.c | 142 ++++++++++++++++++++++++++++++++++++++++++++-
 
26
 3 files changed, 191 insertions(+), 1 deletion(-)
 
27
 
 
28
diff --git a/target-arm/helper.c b/target-arm/helper.c
 
29
index 6206af7..b84b8a1 100644
 
30
--- a/target-arm/helper.c
 
31
+++ b/target-arm/helper.c
 
32
@@ -4388,3 +4388,48 @@ float64 VFP_HELPER(muladd, d)(float64 a, float64 b, float64 c, void *fpstp)
 
33
     float_status *fpst = fpstp;
 
34
     return float64_muladd(a, b, c, 0, fpst);
 
35
 }
 
36
+
 
37
+/* ARMv8 round to integral */
 
38
+float32 HELPER(rints_exact)(float32 x, void *fp_status)
 
39
+{
 
40
+    return float32_round_to_int(x, fp_status);
 
41
+}
 
42
+
 
43
+float64 HELPER(rintd_exact)(float64 x, void *fp_status)
 
44
+{
 
45
+    return float64_round_to_int(x, fp_status);
 
46
+}
 
47
+
 
48
+float32 HELPER(rints)(float32 x, void *fp_status)
 
49
+{
 
50
+    int old_flags = get_float_exception_flags(fp_status), new_flags;
 
51
+    float32 ret;
 
52
+
 
53
+    ret = float32_round_to_int(x, fp_status);
 
54
+
 
55
+    /* Suppress any inexact exceptions the conversion produced */
 
56
+    if (!(old_flags & float_flag_inexact)) {
 
57
+        new_flags = get_float_exception_flags(fp_status);
 
58
+        set_float_exception_flags(new_flags & ~float_flag_inexact, fp_status);
 
59
+    }
 
60
+
 
61
+    return ret;
 
62
+}
 
63
+
 
64
+float64 HELPER(rintd)(float64 x, void *fp_status)
 
65
+{
 
66
+    int old_flags = get_float_exception_flags(fp_status), new_flags;
 
67
+    float64 ret;
 
68
+
 
69
+    ret = float64_round_to_int(x, fp_status);
 
70
+
 
71
+    new_flags = get_float_exception_flags(fp_status);
 
72
+
 
73
+    /* Suppress any inexact exceptions the conversion produced */
 
74
+    if (!(old_flags & float_flag_inexact)) {
 
75
+        new_flags = get_float_exception_flags(fp_status);
 
76
+        set_float_exception_flags(new_flags & ~float_flag_inexact, fp_status);
 
77
+    }
 
78
+
 
79
+    return ret;
 
80
+}
 
81
diff --git a/target-arm/helper.h b/target-arm/helper.h
 
82
index 6dccf90..329b97f 100644
 
83
--- a/target-arm/helper.h
 
84
+++ b/target-arm/helper.h
 
85
@@ -171,6 +171,11 @@ DEF_HELPER_3(shr_cc, i32, env, i32, i32)
 
86
 DEF_HELPER_3(sar_cc, i32, env, i32, i32)
 
87
 DEF_HELPER_3(ror_cc, i32, env, i32, i32)
 
88
 
 
89
+DEF_HELPER_FLAGS_2(rints_exact, TCG_CALL_NO_RWG, f32, f32, ptr)
 
90
+DEF_HELPER_FLAGS_2(rintd_exact, TCG_CALL_NO_RWG, f64, f64, ptr)
 
91
+DEF_HELPER_FLAGS_2(rints, TCG_CALL_NO_RWG, f32, f32, ptr)
 
92
+DEF_HELPER_FLAGS_2(rintd, TCG_CALL_NO_RWG, f64, f64, ptr)
 
93
+
 
94
 /* neon_helper.c */
 
95
 DEF_HELPER_3(neon_qadd_u8, i32, env, i32, i32)
 
96
 DEF_HELPER_3(neon_qadd_s8, i32, env, i32, i32)
 
97
diff --git a/target-arm/translate-a64.c b/target-arm/translate-a64.c
 
98
index 9b23d37..345a47b 100644
 
99
--- a/target-arm/translate-a64.c
 
100
+++ b/target-arm/translate-a64.c
 
101
@@ -3386,6 +3386,118 @@ static void disas_fp_csel(DisasContext *s, uint32_t insn)
 
102
     }
 
103
 }
 
104
 
 
105
+/* C3.6.25 Floating-point data-processing (1 source) - single precision */
 
106
+static void handle_fp_1src_single(DisasContext *s, int opcode, int rd, int rn)
 
107
+{
 
108
+    TCGv_ptr fpst;
 
109
+    TCGv_i32 tcg_op;
 
110
+    TCGv_i32 tcg_res;
 
111
+
 
112
+    fpst = get_fpstatus_ptr();
 
113
+    tcg_op = read_fp_sreg(s, rn);
 
114
+    tcg_res = tcg_temp_new_i32();
 
115
+
 
116
+    switch (opcode) {
 
117
+    case 0x0: /* FMOV */
 
118
+        tcg_gen_mov_i32(tcg_res, tcg_op);
 
119
+        break;
 
120
+    case 0x1: /* FABS */
 
121
+        gen_helper_vfp_abss(tcg_res, tcg_op);
 
122
+        break;
 
123
+    case 0x2: /* FNEG */
 
124
+        gen_helper_vfp_negs(tcg_res, tcg_op);
 
125
+        break;
 
126
+    case 0x3: /* FSQRT */
 
127
+        gen_helper_vfp_sqrts(tcg_res, tcg_op, cpu_env);
 
128
+        break;
 
129
+    case 0x8: /* FRINTN */
 
130
+    case 0x9: /* FRINTP */
 
131
+    case 0xa: /* FRINTM */
 
132
+    case 0xb: /* FRINTZ */
 
133
+    case 0xc: /* FRINTA */
 
134
+    {
 
135
+        TCGv_i32 tcg_rmode = tcg_const_i32(arm_rmode_to_sf(opcode & 7));
 
136
+
 
137
+        gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
 
138
+        gen_helper_rints(tcg_res, tcg_op, fpst);
 
139
+
 
140
+        gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
 
141
+        tcg_temp_free_i32(tcg_rmode);
 
142
+        break;
 
143
+    }
 
144
+    case 0xe: /* FRINTX */
 
145
+        gen_helper_rints_exact(tcg_res, tcg_op, fpst);
 
146
+        break;
 
147
+    case 0xf: /* FRINTI */
 
148
+        gen_helper_rints(tcg_res, tcg_op, fpst);
 
149
+        break;
 
150
+    default:
 
151
+        abort();
 
152
+    }
 
153
+
 
154
+    write_fp_sreg(s, rd, tcg_res);
 
155
+
 
156
+    tcg_temp_free_ptr(fpst);
 
157
+    tcg_temp_free_i32(tcg_op);
 
158
+    tcg_temp_free_i32(tcg_res);
 
159
+}
 
160
+
 
161
+/* C3.6.25 Floating-point data-processing (1 source) - double precision */
 
162
+static void handle_fp_1src_double(DisasContext *s, int opcode, int rd, int rn)
 
163
+{
 
164
+    TCGv_ptr fpst;
 
165
+    TCGv_i64 tcg_op;
 
166
+    TCGv_i64 tcg_res;
 
167
+
 
168
+    fpst = get_fpstatus_ptr();
 
169
+    tcg_op = read_fp_dreg(s, rn);
 
170
+    tcg_res = tcg_temp_new_i64();
 
171
+
 
172
+    switch (opcode) {
 
173
+    case 0x0: /* FMOV */
 
174
+        tcg_gen_mov_i64(tcg_res, tcg_op);
 
175
+        break;
 
176
+    case 0x1: /* FABS */
 
177
+        gen_helper_vfp_absd(tcg_res, tcg_op);
 
178
+        break;
 
179
+    case 0x2: /* FNEG */
 
180
+        gen_helper_vfp_negd(tcg_res, tcg_op);
 
181
+        break;
 
182
+    case 0x3: /* FSQRT */
 
183
+        gen_helper_vfp_sqrtd(tcg_res, tcg_op, cpu_env);
 
184
+        break;
 
185
+    case 0x8: /* FRINTN */
 
186
+    case 0x9: /* FRINTP */
 
187
+    case 0xa: /* FRINTM */
 
188
+    case 0xb: /* FRINTZ */
 
189
+    case 0xc: /* FRINTA */
 
190
+    {
 
191
+        TCGv_i32 tcg_rmode = tcg_const_i32(arm_rmode_to_sf(opcode & 7));
 
192
+
 
193
+        gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
 
194
+        gen_helper_rintd(tcg_res, tcg_op, fpst);
 
195
+
 
196
+        gen_helper_set_rmode(tcg_rmode, tcg_rmode, cpu_env);
 
197
+        tcg_temp_free_i32(tcg_rmode);
 
198
+        break;
 
199
+    }
 
200
+    case 0xe: /* FRINTX */
 
201
+        gen_helper_rintd_exact(tcg_res, tcg_op, fpst);
 
202
+        break;
 
203
+    case 0xf: /* FRINTI */
 
204
+        gen_helper_rintd(tcg_res, tcg_op, fpst);
 
205
+        break;
 
206
+    default:
 
207
+        abort();
 
208
+    }
 
209
+
 
210
+    write_fp_dreg(s, rd, tcg_res);
 
211
+
 
212
+    tcg_temp_free_ptr(fpst);
 
213
+    tcg_temp_free_i64(tcg_op);
 
214
+    tcg_temp_free_i64(tcg_res);
 
215
+}
 
216
+
 
217
 /* C3.6.25 Floating point data-processing (1 source)
 
218
  *   31  30  29 28       24 23  22  21 20    15 14       10 9    5 4    0
 
219
  * +---+---+---+-----------+------+---+--------+-----------+------+------+
 
220
@@ -3394,7 +3506,35 @@ static void disas_fp_csel(DisasContext *s, uint32_t insn)
 
221
  */
 
222
 static void disas_fp_1src(DisasContext *s, uint32_t insn)
 
223
 {
 
224
-    unsupported_encoding(s, insn);
 
225
+    int type = extract32(insn, 22, 2);
 
226
+    int opcode = extract32(insn, 15, 6);
 
227
+    int rn = extract32(insn, 5, 5);
 
228
+    int rd = extract32(insn, 0, 5);
 
229
+
 
230
+    switch (opcode) {
 
231
+    case 0x4: case 0x5: case 0x7:
 
232
+        /* FCVT between half, single and double precision */
 
233
+        unsupported_encoding(s, insn);
 
234
+        break;
 
235
+    case 0x0 ... 0x3:
 
236
+    case 0x8 ... 0xc:
 
237
+    case 0xe ... 0xf:
 
238
+        /* 32-to-32 and 64-to-64 ops */
 
239
+        switch (type) {
 
240
+        case 0:
 
241
+            handle_fp_1src_single(s, opcode, rd, rn);
 
242
+            break;
 
243
+        case 1:
 
244
+            handle_fp_1src_double(s, opcode, rd, rn);
 
245
+            break;
 
246
+        default:
 
247
+            unallocated_encoding(s);
 
248
+        }
 
249
+        break;
 
250
+    default:
 
251
+        unallocated_encoding(s);
 
252
+        break;
 
253
+    }
 
254
 }
 
255
 
 
256
 /* C3.6.26 Floating-point data-processing (2 source) - single precision */
 
257
-- 
 
258
1.9.rc1
 
259