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

« back to all changes in this revision

Viewing changes to target-arm/neon_helper.c

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2014-02-25 22:31:43 UTC
  • mfrom: (1.8.5)
  • Revision ID: package-import@ubuntu.com-20140225223143-odhqxfc60wxrjl15
Tags: 2.0.0~rc1+dfsg-0ubuntu1
* Merge 2.0.0-rc1
* debian/rules: consolidate ppc filter entries.
* Move qemu-system-arch64 into qemu-system-arm
* debian/patches/define-trusty-machine-type.patch: define a trusty machine
  type, currently the same as pc-i440fx-2.0, to put is in a better position
  to enable live migrations from trusty onward.  (LP: #1294823)
* debian/control: build-dep on libfdt >= 1.4.0  (LP: #1295072)
* Merge latest upstream git to commit dc9528f
* Debian/rules:
  - remove -enable-uname-release=2.6.32
  - don't make the aarch64 target Ubuntu-specific.
* Remove patches which are now upstream:
  - fix-smb-security-share.patch
  - slirp-smb-redirect-port-445-too.patch 
  - linux-user-Implement-sendmmsg-syscall.patch (better version is upstream)
  - signal-added-a-wrapper-for-sigprocmask-function.patch
  - ubuntu/signal-sigsegv-protection-on-do_sigprocmask.patch
  - ubuntu/Don-t-block-SIGSEGV-at-more-places.patch
  - ubuntu/ppc-force-cpu-threads-count-to-be-power-of-2.patch
* add link for /usr/share/qemu/bios-256k.bin
* Remove all linaro patches.
* Remove all arm64/ patches.  Many but not all are upstream.
* Remove CVE-2013-4377.patch which is upstream.
* debian/control-in: don't make qemu-system-aarch64 ubuntu-specific

Show diffs side-by-side

added added

removed removed

Lines of Context:
236
236
    return res;
237
237
}
238
238
 
 
239
/* Unsigned saturating accumulate of signed value
 
240
 *
 
241
 * Op1/Rn is treated as signed
 
242
 * Op2/Rd is treated as unsigned
 
243
 *
 
244
 * Explicit casting is used to ensure the correct sign extension of
 
245
 * inputs. The result is treated as a unsigned value and saturated as such.
 
246
 *
 
247
 * We use a macro for the 8/16 bit cases which expects signed integers of va,
 
248
 * vb, and vr for interim calculation and an unsigned 32 bit result value r.
 
249
 */
 
250
 
 
251
#define USATACC(bits, shift) \
 
252
    do { \
 
253
        va = sextract32(a, shift, bits);                                \
 
254
        vb = extract32(b, shift, bits);                                 \
 
255
        vr = va + vb;                                                   \
 
256
        if (vr > UINT##bits##_MAX) {                                    \
 
257
            SET_QC();                                                   \
 
258
            vr = UINT##bits##_MAX;                                      \
 
259
        } else if (vr < 0) {                                            \
 
260
            SET_QC();                                                   \
 
261
            vr = 0;                                                     \
 
262
        }                                                               \
 
263
        r = deposit32(r, shift, bits, vr);                              \
 
264
   } while (0)
 
265
 
 
266
uint32_t HELPER(neon_uqadd_s8)(CPUARMState *env, uint32_t a, uint32_t b)
 
267
{
 
268
    int16_t va, vb, vr;
 
269
    uint32_t r = 0;
 
270
 
 
271
    USATACC(8, 0);
 
272
    USATACC(8, 8);
 
273
    USATACC(8, 16);
 
274
    USATACC(8, 24);
 
275
    return r;
 
276
}
 
277
 
 
278
uint32_t HELPER(neon_uqadd_s16)(CPUARMState *env, uint32_t a, uint32_t b)
 
279
{
 
280
    int32_t va, vb, vr;
 
281
    uint64_t r = 0;
 
282
 
 
283
    USATACC(16, 0);
 
284
    USATACC(16, 16);
 
285
    return r;
 
286
}
 
287
 
 
288
#undef USATACC
 
289
 
 
290
uint32_t HELPER(neon_uqadd_s32)(CPUARMState *env, uint32_t a, uint32_t b)
 
291
{
 
292
    int64_t va = (int32_t)a;
 
293
    int64_t vb = (uint32_t)b;
 
294
    int64_t vr = va + vb;
 
295
    if (vr > UINT32_MAX) {
 
296
        SET_QC();
 
297
        vr = UINT32_MAX;
 
298
    } else if (vr < 0) {
 
299
        SET_QC();
 
300
        vr = 0;
 
301
    }
 
302
    return vr;
 
303
}
 
304
 
 
305
uint64_t HELPER(neon_uqadd_s64)(CPUARMState *env, uint64_t a, uint64_t b)
 
306
{
 
307
    uint64_t res;
 
308
    res = a + b;
 
309
    /* We only need to look at the pattern of SIGN bits to detect
 
310
     * +ve/-ve saturation
 
311
     */
 
312
    if (~a & b & ~res & SIGNBIT64) {
 
313
        SET_QC();
 
314
        res = UINT64_MAX;
 
315
    } else if (a & ~b & res & SIGNBIT64) {
 
316
        SET_QC();
 
317
        res = 0;
 
318
    }
 
319
    return res;
 
320
}
 
321
 
 
322
/* Signed saturating accumulate of unsigned value
 
323
 *
 
324
 * Op1/Rn is treated as unsigned
 
325
 * Op2/Rd is treated as signed
 
326
 *
 
327
 * The result is treated as a signed value and saturated as such
 
328
 *
 
329
 * We use a macro for the 8/16 bit cases which expects signed integers of va,
 
330
 * vb, and vr for interim calculation and an unsigned 32 bit result value r.
 
331
 */
 
332
 
 
333
#define SSATACC(bits, shift) \
 
334
    do { \
 
335
        va = extract32(a, shift, bits);                                 \
 
336
        vb = sextract32(b, shift, bits);                                \
 
337
        vr = va + vb;                                                   \
 
338
        if (vr > INT##bits##_MAX) {                                     \
 
339
            SET_QC();                                                   \
 
340
            vr = INT##bits##_MAX;                                       \
 
341
        } else if (vr < INT##bits##_MIN) {                              \
 
342
            SET_QC();                                                   \
 
343
            vr = INT##bits##_MIN;                                       \
 
344
        }                                                               \
 
345
        r = deposit32(r, shift, bits, vr);                              \
 
346
    } while (0)
 
347
 
 
348
uint32_t HELPER(neon_sqadd_u8)(CPUARMState *env, uint32_t a, uint32_t b)
 
349
{
 
350
    int16_t va, vb, vr;
 
351
    uint32_t r = 0;
 
352
 
 
353
    SSATACC(8, 0);
 
354
    SSATACC(8, 8);
 
355
    SSATACC(8, 16);
 
356
    SSATACC(8, 24);
 
357
    return r;
 
358
}
 
359
 
 
360
uint32_t HELPER(neon_sqadd_u16)(CPUARMState *env, uint32_t a, uint32_t b)
 
361
{
 
362
    int32_t va, vb, vr;
 
363
    uint32_t r = 0;
 
364
 
 
365
    SSATACC(16, 0);
 
366
    SSATACC(16, 16);
 
367
 
 
368
    return r;
 
369
}
 
370
 
 
371
#undef SSATACC
 
372
 
 
373
uint32_t HELPER(neon_sqadd_u32)(CPUARMState *env, uint32_t a, uint32_t b)
 
374
{
 
375
    int64_t res;
 
376
    int64_t op1 = (uint32_t)a;
 
377
    int64_t op2 = (int32_t)b;
 
378
    res = op1 + op2;
 
379
    if (res > INT32_MAX) {
 
380
        SET_QC();
 
381
        res = INT32_MAX;
 
382
    } else if (res < INT32_MIN) {
 
383
        SET_QC();
 
384
        res = INT32_MIN;
 
385
    }
 
386
    return res;
 
387
}
 
388
 
 
389
uint64_t HELPER(neon_sqadd_u64)(CPUARMState *env, uint64_t a, uint64_t b)
 
390
{
 
391
    uint64_t res;
 
392
    res = a + b;
 
393
    /* We only need to look at the pattern of SIGN bits to detect an overflow */
 
394
    if (((a & res)
 
395
         | (~b & res)
 
396
         | (a & ~b)) & SIGNBIT64) {
 
397
        SET_QC();
 
398
        res = INT64_MAX;
 
399
    }
 
400
    return res;
 
401
}
 
402
 
 
403
 
239
404
#define NEON_USAT(dest, src1, src2, type) do { \
240
405
    uint32_t tmp = (uint32_t)src1 - (uint32_t)src2; \
241
406
    if (tmp != (type)tmp) { \
1776
1941
    return x;
1777
1942
}
1778
1943
 
 
1944
uint64_t HELPER(neon_qabs_s64)(CPUARMState *env, uint64_t x)
 
1945
{
 
1946
    if (x == SIGNBIT64) {
 
1947
        SET_QC();
 
1948
        x = ~SIGNBIT64;
 
1949
    } else if ((int64_t)x < 0) {
 
1950
        x = -x;
 
1951
    }
 
1952
    return x;
 
1953
}
 
1954
 
 
1955
uint64_t HELPER(neon_qneg_s64)(CPUARMState *env, uint64_t x)
 
1956
{
 
1957
    if (x == SIGNBIT64) {
 
1958
        SET_QC();
 
1959
        x = ~SIGNBIT64;
 
1960
    } else {
 
1961
        x = -x;
 
1962
    }
 
1963
    return x;
 
1964
}
 
1965
 
1779
1966
/* NEON Float helpers.  */
1780
1967
uint32_t HELPER(neon_abd_f32)(uint32_t a, uint32_t b, void *fpstp)
1781
1968
{
1823
2010
    return -float32_lt(f1, f0, fpst);
1824
2011
}
1825
2012
 
 
2013
uint64_t HELPER(neon_acge_f64)(uint64_t a, uint64_t b, void *fpstp)
 
2014
{
 
2015
    float_status *fpst = fpstp;
 
2016
    float64 f0 = float64_abs(make_float64(a));
 
2017
    float64 f1 = float64_abs(make_float64(b));
 
2018
    return -float64_le(f1, f0, fpst);
 
2019
}
 
2020
 
 
2021
uint64_t HELPER(neon_acgt_f64)(uint64_t a, uint64_t b, void *fpstp)
 
2022
{
 
2023
    float_status *fpst = fpstp;
 
2024
    float64 f0 = float64_abs(make_float64(a));
 
2025
    float64 f1 = float64_abs(make_float64(b));
 
2026
    return -float64_lt(f1, f0, fpst);
 
2027
}
 
2028
 
1826
2029
#define ELEM(V, N, SIZE) (((V) >> ((N) * (SIZE))) & ((1ull << (SIZE)) - 1))
1827
2030
 
1828
2031
void HELPER(neon_qunzip8)(CPUARMState *env, uint32_t rd, uint32_t rm)