]> git.proxmox.com Git - mirror_qemu.git/blame - target-tilegx/simd_helper.c
sPAPR: Introduce rtas_ldq()
[mirror_qemu.git] / target-tilegx / simd_helper.c
CommitLineData
461aa678
RH
1/*
2 * QEMU TILE-Gx helpers
3 *
4 * Copyright (c) 2015 Chen Gang
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see
18 * <http://www.gnu.org/licenses/lgpl-2.1.html>
19 */
20
21#include "cpu.h"
22#include "qemu-common.h"
23#include "exec/helper-proto.h"
24
25
26uint64_t helper_v1shl(uint64_t a, uint64_t b)
27{
28 uint64_t m;
29
30 b &= 7;
31 m = 0x0101010101010101ULL * (0xff >> b);
32 return (a & m) << b;
33}
34
35uint64_t helper_v1shru(uint64_t a, uint64_t b)
36{
37 uint64_t m;
38
39 b &= 7;
40 m = 0x0101010101010101ULL * ((0xff << b) & 0xff);
41 return (a & m) >> b;
42}
43
44uint64_t helper_v1shrs(uint64_t a, uint64_t b)
45{
46 uint64_t r = 0;
47 int i;
48
49 b &= 7;
50 for (i = 0; i < 64; i += 8) {
51 int64_t ae = (int8_t)(a >> i);
52 r |= ((ae >> b) & 0xff) << i;
53 }
54 return r;
55}