Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging
[qemu/ar7.git] / tests / tcg / mips / include / wrappers_mips64r6.h
blobd1e5edb632ed482873412ff1ab13534eb7fa9a42
1 /*
2 * Header file for wrappers around MIPS64R6 instructions assembler
3 * invocations
5 * Copyright (C) 2019 Wave Computing, Inc.
6 * Copyright (C) 2019 Aleksandar Markovic <amarkovic@wavecomp.com>
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 #ifndef WRAPPERS_MIPS64R6_H
24 #define WRAPPERS_MIPS64R6_H
27 #define DO_MIPS64R6__RD__RS(suffix, mnemonic) \
28 static inline void do_mips64r6_##suffix(const void *input, \
29 void *output) \
30 { \
31 __asm__ volatile ( \
32 "ld $t1, 0(%0)\n\t" \
33 #mnemonic " $t0, $t1\n\t" \
34 "sd $t0, 0(%1)\n\t" \
35 : \
36 : "r" (input), "r" (output) \
37 : "t0", "t1", "memory" \
38 ); \
41 DO_MIPS64R6__RD__RS(CLO, clo)
42 DO_MIPS64R6__RD__RS(CLZ, clz)
43 DO_MIPS64R6__RD__RS(DCLO, dclo)
44 DO_MIPS64R6__RD__RS(DCLZ, dclz)
46 DO_MIPS64R6__RD__RS(BITSWAP, bitswap)
47 DO_MIPS64R6__RD__RS(DBITSWAP, dbitswap)
50 #define DO_MIPS64R6__RD__RS_RT(suffix, mnemonic) \
51 static inline void do_mips64r6_##suffix(const void *input1, \
52 const void *input2, \
53 void *output) \
54 { \
55 __asm__ volatile ( \
56 "ld $t1, 0(%0)\n\t" \
57 "ld $t2, 0(%1)\n\t" \
58 #mnemonic " $t0, $t1, $t2\n\t" \
59 "sd $t0, 0(%2)\n\t" \
60 : \
61 : "r" (input1), "r" (input2), "r" (output) \
62 : "t0", "t1", "memory" \
63 ); \
66 DO_MIPS64R6__RD__RS_RT(SLLV, sllv)
67 DO_MIPS64R6__RD__RS_RT(SRLV, srlv)
68 DO_MIPS64R6__RD__RS_RT(SRAV, srav)
69 DO_MIPS64R6__RD__RS_RT(DSLLV, dsllv)
70 DO_MIPS64R6__RD__RS_RT(DSRLV, dsrlv)
71 DO_MIPS64R6__RD__RS_RT(DSRAV, dsrav)
73 DO_MIPS64R6__RD__RS_RT(MUL, mul)
74 DO_MIPS64R6__RD__RS_RT(MUH, muh)
75 DO_MIPS64R6__RD__RS_RT(MULU, mulu)
76 DO_MIPS64R6__RD__RS_RT(MUHU, muhu)
77 DO_MIPS64R6__RD__RS_RT(DMUL, dmul)
78 DO_MIPS64R6__RD__RS_RT(DMUH, dmuh)
79 DO_MIPS64R6__RD__RS_RT(DMULU, dmulu)
80 DO_MIPS64R6__RD__RS_RT(DMUHU, dmuhu)
83 #endif