root / target-arm / iwmmxt_helper.c @ e8ee3c72
History | View | Annotate | Download (24.7 kB)
1 | e677137d | pbrook | /*
|
---|---|---|---|
2 | e677137d | pbrook | * iwMMXt micro operations for XScale.
|
3 | e677137d | pbrook | *
|
4 | e677137d | pbrook | * Copyright (c) 2007 OpenedHand, Ltd.
|
5 | e677137d | pbrook | * Written by Andrzej Zaborowski <andrew@openedhand.com>
|
6 | e677137d | pbrook | * Copyright (c) 2008 CodeSourcery
|
7 | e677137d | pbrook | *
|
8 | e677137d | pbrook | * This library is free software; you can redistribute it and/or
|
9 | e677137d | pbrook | * modify it under the terms of the GNU Lesser General Public
|
10 | e677137d | pbrook | * License as published by the Free Software Foundation; either
|
11 | e677137d | pbrook | * version 2 of the License, or (at your option) any later version.
|
12 | e677137d | pbrook | *
|
13 | e677137d | pbrook | * This library is distributed in the hope that it will be useful,
|
14 | e677137d | pbrook | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 | e677137d | pbrook | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
16 | e677137d | pbrook | * Lesser General Public License for more details.
|
17 | e677137d | pbrook | *
|
18 | e677137d | pbrook | * You should have received a copy of the GNU Lesser General Public
|
19 | e677137d | pbrook | * License along with this library; if not, write to the Free Software
|
20 | e677137d | pbrook | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
21 | e677137d | pbrook | */
|
22 | e677137d | pbrook | |
23 | e677137d | pbrook | #include <stdlib.h> |
24 | e677137d | pbrook | #include <stdio.h> |
25 | e677137d | pbrook | |
26 | e677137d | pbrook | #include "cpu.h" |
27 | e677137d | pbrook | #include "exec-all.h" |
28 | e677137d | pbrook | #include "helpers.h" |
29 | e677137d | pbrook | |
30 | e677137d | pbrook | /* iwMMXt macros extracted from GNU gdb. */
|
31 | e677137d | pbrook | |
32 | e677137d | pbrook | /* Set the SIMD wCASF flags for 8, 16, 32 or 64-bit operations. */
|
33 | e677137d | pbrook | #define SIMD8_SET( v, n, b) ((v != 0) << ((((b) + 1) * 4) + (n))) |
34 | e677137d | pbrook | #define SIMD16_SET(v, n, h) ((v != 0) << ((((h) + 1) * 8) + (n))) |
35 | e677137d | pbrook | #define SIMD32_SET(v, n, w) ((v != 0) << ((((w) + 1) * 16) + (n))) |
36 | e677137d | pbrook | #define SIMD64_SET(v, n) ((v != 0) << (32 + (n))) |
37 | e677137d | pbrook | /* Flags to pass as "n" above. */
|
38 | e677137d | pbrook | #define SIMD_NBIT -1 |
39 | e677137d | pbrook | #define SIMD_ZBIT -2 |
40 | e677137d | pbrook | #define SIMD_CBIT -3 |
41 | e677137d | pbrook | #define SIMD_VBIT -4 |
42 | e677137d | pbrook | /* Various status bit macros. */
|
43 | e677137d | pbrook | #define NBIT8(x) ((x) & 0x80) |
44 | e677137d | pbrook | #define NBIT16(x) ((x) & 0x8000) |
45 | e677137d | pbrook | #define NBIT32(x) ((x) & 0x80000000) |
46 | e677137d | pbrook | #define NBIT64(x) ((x) & 0x8000000000000000ULL) |
47 | e677137d | pbrook | #define ZBIT8(x) (((x) & 0xff) == 0) |
48 | e677137d | pbrook | #define ZBIT16(x) (((x) & 0xffff) == 0) |
49 | e677137d | pbrook | #define ZBIT32(x) (((x) & 0xffffffff) == 0) |
50 | e677137d | pbrook | #define ZBIT64(x) (x == 0) |
51 | e677137d | pbrook | /* Sign extension macros. */
|
52 | e677137d | pbrook | #define EXTEND8H(a) ((uint16_t) (int8_t) (a))
|
53 | e677137d | pbrook | #define EXTEND8(a) ((uint32_t) (int8_t) (a))
|
54 | e677137d | pbrook | #define EXTEND16(a) ((uint32_t) (int16_t) (a))
|
55 | e677137d | pbrook | #define EXTEND16S(a) ((int32_t) (int16_t) (a))
|
56 | e677137d | pbrook | #define EXTEND32(a) ((uint64_t) (int32_t) (a))
|
57 | e677137d | pbrook | |
58 | e677137d | pbrook | uint64_t HELPER(iwmmxt_maddsq)(uint64_t a, uint64_t b) |
59 | e677137d | pbrook | { |
60 | e677137d | pbrook | a = (( |
61 | e677137d | pbrook | EXTEND16S((a >> 0) & 0xffff) * EXTEND16S((b >> 0) & 0xffff) + |
62 | e677137d | pbrook | EXTEND16S((a >> 16) & 0xffff) * EXTEND16S((b >> 16) & 0xffff) |
63 | e677137d | pbrook | ) & 0xffffffff) | ((uint64_t) (
|
64 | e677137d | pbrook | EXTEND16S((a >> 32) & 0xffff) * EXTEND16S((b >> 32) & 0xffff) + |
65 | e677137d | pbrook | EXTEND16S((a >> 48) & 0xffff) * EXTEND16S((b >> 48) & 0xffff) |
66 | e677137d | pbrook | ) << 32);
|
67 | e677137d | pbrook | return a;
|
68 | e677137d | pbrook | } |
69 | e677137d | pbrook | |
70 | e677137d | pbrook | uint64_t HELPER(iwmmxt_madduq)(uint64_t a, uint64_t b) |
71 | e677137d | pbrook | { |
72 | e677137d | pbrook | a = (( |
73 | e677137d | pbrook | ((a >> 0) & 0xffff) * ((b >> 0) & 0xffff) + |
74 | e677137d | pbrook | ((a >> 16) & 0xffff) * ((b >> 16) & 0xffff) |
75 | e677137d | pbrook | ) & 0xffffffff) | ((
|
76 | e677137d | pbrook | ((a >> 32) & 0xffff) * ((b >> 32) & 0xffff) + |
77 | e677137d | pbrook | ((a >> 48) & 0xffff) * ((b >> 48) & 0xffff) |
78 | e677137d | pbrook | ) << 32);
|
79 | e677137d | pbrook | return a;
|
80 | e677137d | pbrook | } |
81 | e677137d | pbrook | |
82 | e677137d | pbrook | uint64_t HELPER(iwmmxt_sadb)(uint64_t a, uint64_t b) |
83 | e677137d | pbrook | { |
84 | e677137d | pbrook | #define abs(x) (((x) >= 0) ? x : -x) |
85 | e677137d | pbrook | #define SADB(SHR) abs((int) ((a >> SHR) & 0xff) - (int) ((b >> SHR) & 0xff)) |
86 | e677137d | pbrook | return
|
87 | e677137d | pbrook | SADB(0) + SADB(8) + SADB(16) + SADB(24) + |
88 | e677137d | pbrook | SADB(32) + SADB(40) + SADB(48) + SADB(56); |
89 | e677137d | pbrook | #undef SADB
|
90 | e677137d | pbrook | } |
91 | e677137d | pbrook | |
92 | e677137d | pbrook | uint64_t HELPER(iwmmxt_sadw)(uint64_t a, uint64_t b) |
93 | e677137d | pbrook | { |
94 | e677137d | pbrook | #define SADW(SHR) \
|
95 | e677137d | pbrook | abs((int) ((a >> SHR) & 0xffff) - (int) ((b >> SHR) & 0xffff)) |
96 | e677137d | pbrook | return SADW(0) + SADW(16) + SADW(32) + SADW(48); |
97 | e677137d | pbrook | #undef SADW
|
98 | e677137d | pbrook | } |
99 | e677137d | pbrook | |
100 | e677137d | pbrook | uint64_t HELPER(iwmmxt_mulslw)(uint64_t a, uint64_t b) |
101 | e677137d | pbrook | { |
102 | e677137d | pbrook | #define MULS(SHR) ((uint64_t) ((( \
|
103 | e677137d | pbrook | EXTEND16S((a >> SHR) & 0xffff) * EXTEND16S((b >> SHR) & 0xffff) \ |
104 | e677137d | pbrook | ) >> 0) & 0xffff) << SHR) |
105 | e677137d | pbrook | return MULS(0) | MULS(16) | MULS(32) | MULS(48); |
106 | e677137d | pbrook | #undef MULS
|
107 | e677137d | pbrook | } |
108 | e677137d | pbrook | |
109 | e677137d | pbrook | uint64_t HELPER(iwmmxt_mulshw)(uint64_t a, uint64_t b) |
110 | e677137d | pbrook | { |
111 | e677137d | pbrook | #define MULS(SHR) ((uint64_t) ((( \
|
112 | e677137d | pbrook | EXTEND16S((a >> SHR) & 0xffff) * EXTEND16S((b >> SHR) & 0xffff) \ |
113 | e677137d | pbrook | ) >> 16) & 0xffff) << SHR) |
114 | e677137d | pbrook | return MULS(0) | MULS(16) | MULS(32) | MULS(48); |
115 | e677137d | pbrook | #undef MULS
|
116 | e677137d | pbrook | } |
117 | e677137d | pbrook | |
118 | e677137d | pbrook | uint64_t HELPER(iwmmxt_mululw)(uint64_t a, uint64_t b) |
119 | e677137d | pbrook | { |
120 | e677137d | pbrook | #define MULU(SHR) ((uint64_t) ((( \
|
121 | e677137d | pbrook | ((a >> SHR) & 0xffff) * ((b >> SHR) & 0xffff) \ |
122 | e677137d | pbrook | ) >> 0) & 0xffff) << SHR) |
123 | e677137d | pbrook | return MULU(0) | MULU(16) | MULU(32) | MULU(48); |
124 | e677137d | pbrook | #undef MULU
|
125 | e677137d | pbrook | } |
126 | e677137d | pbrook | |
127 | e677137d | pbrook | uint64_t HELPER(iwmmxt_muluhw)(uint64_t a, uint64_t b) |
128 | e677137d | pbrook | { |
129 | e677137d | pbrook | #define MULU(SHR) ((uint64_t) ((( \
|
130 | e677137d | pbrook | ((a >> SHR) & 0xffff) * ((b >> SHR) & 0xffff) \ |
131 | e677137d | pbrook | ) >> 16) & 0xffff) << SHR) |
132 | e677137d | pbrook | return MULU(0) | MULU(16) | MULU(32) | MULU(48); |
133 | e677137d | pbrook | #undef MULU
|
134 | e677137d | pbrook | } |
135 | e677137d | pbrook | |
136 | e677137d | pbrook | uint64_t HELPER(iwmmxt_macsw)(uint64_t a, uint64_t b) |
137 | e677137d | pbrook | { |
138 | e677137d | pbrook | #define MACS(SHR) ( \
|
139 | e677137d | pbrook | EXTEND16((a >> SHR) & 0xffff) * EXTEND16S((b >> SHR) & 0xffff)) |
140 | e677137d | pbrook | return (int64_t) (MACS(0) + MACS(16) + MACS(32) + MACS(48)); |
141 | e677137d | pbrook | #undef MACS
|
142 | e677137d | pbrook | } |
143 | e677137d | pbrook | |
144 | e677137d | pbrook | uint64_t HELPER(iwmmxt_macuw)(uint64_t a, uint64_t b) |
145 | e677137d | pbrook | { |
146 | e677137d | pbrook | #define MACU(SHR) ( \
|
147 | e677137d | pbrook | (uint32_t) ((a >> SHR) & 0xffff) * \
|
148 | e677137d | pbrook | (uint32_t) ((b >> SHR) & 0xffff))
|
149 | e677137d | pbrook | return MACU(0) + MACU(16) + MACU(32) + MACU(48); |
150 | e677137d | pbrook | #undef MACU
|
151 | e677137d | pbrook | } |
152 | e677137d | pbrook | |
153 | e677137d | pbrook | #define NZBIT8(x, i) \
|
154 | e677137d | pbrook | SIMD8_SET(NBIT8((x) & 0xff), SIMD_NBIT, i) | \
|
155 | e677137d | pbrook | SIMD8_SET(ZBIT8((x) & 0xff), SIMD_ZBIT, i)
|
156 | e677137d | pbrook | #define NZBIT16(x, i) \
|
157 | e677137d | pbrook | SIMD16_SET(NBIT16((x) & 0xffff), SIMD_NBIT, i) | \
|
158 | e677137d | pbrook | SIMD16_SET(ZBIT16((x) & 0xffff), SIMD_ZBIT, i)
|
159 | e677137d | pbrook | #define NZBIT32(x, i) \
|
160 | e677137d | pbrook | SIMD32_SET(NBIT32((x) & 0xffffffff), SIMD_NBIT, i) | \
|
161 | e677137d | pbrook | SIMD32_SET(ZBIT32((x) & 0xffffffff), SIMD_ZBIT, i)
|
162 | e677137d | pbrook | #define NZBIT64(x) \
|
163 | e677137d | pbrook | SIMD64_SET(NBIT64(x), SIMD_NBIT) | \ |
164 | e677137d | pbrook | SIMD64_SET(ZBIT64(x), SIMD_ZBIT) |
165 | e677137d | pbrook | #define IWMMXT_OP_UNPACK(S, SH0, SH1, SH2, SH3) \
|
166 | e677137d | pbrook | uint64_t HELPER(glue(iwmmxt_unpack, glue(S, b)))(CPUState *env, \ |
167 | e677137d | pbrook | uint64_t a, uint64_t b) \ |
168 | e677137d | pbrook | { \ |
169 | e677137d | pbrook | a = \ |
170 | e677137d | pbrook | (((a >> SH0) & 0xff) << 0) | (((b >> SH0) & 0xff) << 8) | \ |
171 | e677137d | pbrook | (((a >> SH1) & 0xff) << 16) | (((b >> SH1) & 0xff) << 24) | \ |
172 | e677137d | pbrook | (((a >> SH2) & 0xff) << 32) | (((b >> SH2) & 0xff) << 40) | \ |
173 | e677137d | pbrook | (((a >> SH3) & 0xff) << 48) | (((b >> SH3) & 0xff) << 56); \ |
174 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
175 | e677137d | pbrook | NZBIT8(a >> 0, 0) | NZBIT8(a >> 8, 1) | \ |
176 | e677137d | pbrook | NZBIT8(a >> 16, 2) | NZBIT8(a >> 24, 3) | \ |
177 | e677137d | pbrook | NZBIT8(a >> 32, 4) | NZBIT8(a >> 40, 5) | \ |
178 | e677137d | pbrook | NZBIT8(a >> 48, 6) | NZBIT8(a >> 56, 7); \ |
179 | e677137d | pbrook | return a; \
|
180 | e677137d | pbrook | } \ |
181 | e677137d | pbrook | uint64_t HELPER(glue(iwmmxt_unpack, glue(S, w)))(CPUState *env, \ |
182 | e677137d | pbrook | uint64_t a, uint64_t b) \ |
183 | e677137d | pbrook | { \ |
184 | e677137d | pbrook | a = \ |
185 | e677137d | pbrook | (((a >> SH0) & 0xffff) << 0) | \ |
186 | e677137d | pbrook | (((b >> SH0) & 0xffff) << 16) | \ |
187 | e677137d | pbrook | (((a >> SH2) & 0xffff) << 32) | \ |
188 | e677137d | pbrook | (((b >> SH2) & 0xffff) << 48); \ |
189 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
190 | e677137d | pbrook | NZBIT8(a >> 0, 0) | NZBIT8(a >> 16, 1) | \ |
191 | e677137d | pbrook | NZBIT8(a >> 32, 2) | NZBIT8(a >> 48, 3); \ |
192 | e677137d | pbrook | return a; \
|
193 | e677137d | pbrook | } \ |
194 | e677137d | pbrook | uint64_t HELPER(glue(iwmmxt_unpack, glue(S, l)))(CPUState *env, \ |
195 | e677137d | pbrook | uint64_t a, uint64_t b) \ |
196 | e677137d | pbrook | { \ |
197 | e677137d | pbrook | a = \ |
198 | e677137d | pbrook | (((a >> SH0) & 0xffffffff) << 0) | \ |
199 | e677137d | pbrook | (((b >> SH0) & 0xffffffff) << 32); \ |
200 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
201 | e677137d | pbrook | NZBIT32(a >> 0, 0) | NZBIT32(a >> 32, 1); \ |
202 | e677137d | pbrook | return a; \
|
203 | e677137d | pbrook | } \ |
204 | e677137d | pbrook | uint64_t HELPER(glue(iwmmxt_unpack, glue(S, ub)))(CPUState *env, \ |
205 | e677137d | pbrook | uint64_t x) \ |
206 | e677137d | pbrook | { \ |
207 | e677137d | pbrook | x = \ |
208 | e677137d | pbrook | (((x >> SH0) & 0xff) << 0) | \ |
209 | e677137d | pbrook | (((x >> SH1) & 0xff) << 16) | \ |
210 | e677137d | pbrook | (((x >> SH2) & 0xff) << 32) | \ |
211 | e677137d | pbrook | (((x >> SH3) & 0xff) << 48); \ |
212 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
213 | e677137d | pbrook | NZBIT16(x >> 0, 0) | NZBIT16(x >> 16, 1) | \ |
214 | e677137d | pbrook | NZBIT16(x >> 32, 2) | NZBIT16(x >> 48, 3); \ |
215 | e677137d | pbrook | return x; \
|
216 | e677137d | pbrook | } \ |
217 | e677137d | pbrook | uint64_t HELPER(glue(iwmmxt_unpack, glue(S, uw)))(CPUState *env, \ |
218 | e677137d | pbrook | uint64_t x) \ |
219 | e677137d | pbrook | { \ |
220 | e677137d | pbrook | x = \ |
221 | e677137d | pbrook | (((x >> SH0) & 0xffff) << 0) | \ |
222 | e677137d | pbrook | (((x >> SH2) & 0xffff) << 32); \ |
223 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
224 | e677137d | pbrook | NZBIT32(x >> 0, 0) | NZBIT32(x >> 32, 1); \ |
225 | e677137d | pbrook | return x; \
|
226 | e677137d | pbrook | } \ |
227 | e677137d | pbrook | uint64_t HELPER(glue(iwmmxt_unpack, glue(S, ul)))(CPUState *env, \ |
228 | e677137d | pbrook | uint64_t x) \ |
229 | e677137d | pbrook | { \ |
230 | e677137d | pbrook | x = (((x >> SH0) & 0xffffffff) << 0); \ |
231 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = NZBIT64(x >> 0); \
|
232 | e677137d | pbrook | return x; \
|
233 | e677137d | pbrook | } \ |
234 | e677137d | pbrook | uint64_t HELPER(glue(iwmmxt_unpack, glue(S, sb)))(CPUState *env, \ |
235 | e677137d | pbrook | uint64_t x) \ |
236 | e677137d | pbrook | { \ |
237 | e677137d | pbrook | x = \ |
238 | e677137d | pbrook | ((uint64_t) EXTEND8H((x >> SH0) & 0xff) << 0) | \ |
239 | e677137d | pbrook | ((uint64_t) EXTEND8H((x >> SH1) & 0xff) << 16) | \ |
240 | e677137d | pbrook | ((uint64_t) EXTEND8H((x >> SH2) & 0xff) << 32) | \ |
241 | e677137d | pbrook | ((uint64_t) EXTEND8H((x >> SH3) & 0xff) << 48); \ |
242 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
243 | e677137d | pbrook | NZBIT16(x >> 0, 0) | NZBIT16(x >> 16, 1) | \ |
244 | e677137d | pbrook | NZBIT16(x >> 32, 2) | NZBIT16(x >> 48, 3); \ |
245 | e677137d | pbrook | return x; \
|
246 | e677137d | pbrook | } \ |
247 | e677137d | pbrook | uint64_t HELPER(glue(iwmmxt_unpack, glue(S, sw)))(CPUState *env, \ |
248 | e677137d | pbrook | uint64_t x) \ |
249 | e677137d | pbrook | { \ |
250 | e677137d | pbrook | x = \ |
251 | e677137d | pbrook | ((uint64_t) EXTEND16((x >> SH0) & 0xffff) << 0) | \ |
252 | e677137d | pbrook | ((uint64_t) EXTEND16((x >> SH2) & 0xffff) << 32); \ |
253 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
254 | e677137d | pbrook | NZBIT32(x >> 0, 0) | NZBIT32(x >> 32, 1); \ |
255 | e677137d | pbrook | return x; \
|
256 | e677137d | pbrook | } \ |
257 | e677137d | pbrook | uint64_t HELPER(glue(iwmmxt_unpack, glue(S, sl)))(CPUState *env, \ |
258 | e677137d | pbrook | uint64_t x) \ |
259 | e677137d | pbrook | { \ |
260 | e677137d | pbrook | x = EXTEND32((x >> SH0) & 0xffffffff); \
|
261 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = NZBIT64(x >> 0); \
|
262 | e677137d | pbrook | return x; \
|
263 | e677137d | pbrook | } |
264 | e677137d | pbrook | IWMMXT_OP_UNPACK(l, 0, 8, 16, 24) |
265 | e677137d | pbrook | IWMMXT_OP_UNPACK(h, 32, 40, 48, 56) |
266 | e677137d | pbrook | |
267 | e677137d | pbrook | #define IWMMXT_OP_CMP(SUFF, Tb, Tw, Tl, O) \
|
268 | e677137d | pbrook | uint64_t HELPER(glue(iwmmxt_, glue(SUFF, b)))(CPUState *env, \ |
269 | e677137d | pbrook | uint64_t a, uint64_t b) \ |
270 | e677137d | pbrook | { \ |
271 | e677137d | pbrook | a = \ |
272 | e677137d | pbrook | CMP(0, Tb, O, 0xff) | CMP(8, Tb, O, 0xff) | \ |
273 | e677137d | pbrook | CMP(16, Tb, O, 0xff) | CMP(24, Tb, O, 0xff) | \ |
274 | e677137d | pbrook | CMP(32, Tb, O, 0xff) | CMP(40, Tb, O, 0xff) | \ |
275 | e677137d | pbrook | CMP(48, Tb, O, 0xff) | CMP(56, Tb, O, 0xff); \ |
276 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
277 | e677137d | pbrook | NZBIT8(a >> 0, 0) | NZBIT8(a >> 8, 1) | \ |
278 | e677137d | pbrook | NZBIT8(a >> 16, 2) | NZBIT8(a >> 24, 3) | \ |
279 | e677137d | pbrook | NZBIT8(a >> 32, 4) | NZBIT8(a >> 40, 5) | \ |
280 | e677137d | pbrook | NZBIT8(a >> 48, 6) | NZBIT8(a >> 56, 7); \ |
281 | e677137d | pbrook | return a; \
|
282 | e677137d | pbrook | } \ |
283 | e677137d | pbrook | uint64_t HELPER(glue(iwmmxt_, glue(SUFF, w)))(CPUState *env, \ |
284 | e677137d | pbrook | uint64_t a, uint64_t b) \ |
285 | e677137d | pbrook | { \ |
286 | e677137d | pbrook | a = CMP(0, Tw, O, 0xffff) | CMP(16, Tw, O, 0xffff) | \ |
287 | e677137d | pbrook | CMP(32, Tw, O, 0xffff) | CMP(48, Tw, O, 0xffff); \ |
288 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
289 | e677137d | pbrook | NZBIT16(a >> 0, 0) | NZBIT16(a >> 16, 1) | \ |
290 | e677137d | pbrook | NZBIT16(a >> 32, 2) | NZBIT16(a >> 48, 3); \ |
291 | e677137d | pbrook | return a; \
|
292 | e677137d | pbrook | } \ |
293 | e677137d | pbrook | uint64_t HELPER(glue(iwmmxt_, glue(SUFF, l)))(CPUState *env, \ |
294 | e677137d | pbrook | uint64_t a, uint64_t b) \ |
295 | e677137d | pbrook | { \ |
296 | e677137d | pbrook | a = CMP(0, Tl, O, 0xffffffff) | \ |
297 | e677137d | pbrook | CMP(32, Tl, O, 0xffffffff); \ |
298 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
299 | e677137d | pbrook | NZBIT32(a >> 0, 0) | NZBIT32(a >> 32, 1); \ |
300 | e677137d | pbrook | return a; \
|
301 | e677137d | pbrook | } |
302 | e677137d | pbrook | #define CMP(SHR, TYPE, OPER, MASK) ((((TYPE) ((a >> SHR) & MASK) OPER \
|
303 | e677137d | pbrook | (TYPE) ((b >> SHR) & MASK)) ? (uint64_t) MASK : 0) << SHR)
|
304 | e677137d | pbrook | IWMMXT_OP_CMP(cmpeq, uint8_t, uint16_t, uint32_t, ==) |
305 | e677137d | pbrook | IWMMXT_OP_CMP(cmpgts, int8_t, int16_t, int32_t, >) |
306 | e677137d | pbrook | IWMMXT_OP_CMP(cmpgtu, uint8_t, uint16_t, uint32_t, >) |
307 | e677137d | pbrook | #undef CMP
|
308 | e677137d | pbrook | #define CMP(SHR, TYPE, OPER, MASK) ((((TYPE) ((a >> SHR) & MASK) OPER \
|
309 | e677137d | pbrook | (TYPE) ((b >> SHR) & MASK)) ? a : b) & ((uint64_t) MASK << SHR)) |
310 | e677137d | pbrook | IWMMXT_OP_CMP(mins, int8_t, int16_t, int32_t, <) |
311 | e677137d | pbrook | IWMMXT_OP_CMP(minu, uint8_t, uint16_t, uint32_t, <) |
312 | e677137d | pbrook | IWMMXT_OP_CMP(maxs, int8_t, int16_t, int32_t, >) |
313 | e677137d | pbrook | IWMMXT_OP_CMP(maxu, uint8_t, uint16_t, uint32_t, >) |
314 | e677137d | pbrook | #undef CMP
|
315 | e677137d | pbrook | #define CMP(SHR, TYPE, OPER, MASK) ((uint64_t) (((TYPE) ((a >> SHR) & MASK) \
|
316 | e677137d | pbrook | OPER (TYPE) ((b >> SHR) & MASK)) & MASK) << SHR) |
317 | e677137d | pbrook | IWMMXT_OP_CMP(subn, uint8_t, uint16_t, uint32_t, -) |
318 | e677137d | pbrook | IWMMXT_OP_CMP(addn, uint8_t, uint16_t, uint32_t, +) |
319 | e677137d | pbrook | #undef CMP
|
320 | e677137d | pbrook | /* TODO Signed- and Unsigned-Saturation */
|
321 | e677137d | pbrook | #define CMP(SHR, TYPE, OPER, MASK) ((uint64_t) (((TYPE) ((a >> SHR) & MASK) \
|
322 | e677137d | pbrook | OPER (TYPE) ((b >> SHR) & MASK)) & MASK) << SHR) |
323 | e677137d | pbrook | IWMMXT_OP_CMP(subu, uint8_t, uint16_t, uint32_t, -) |
324 | e677137d | pbrook | IWMMXT_OP_CMP(addu, uint8_t, uint16_t, uint32_t, +) |
325 | e677137d | pbrook | IWMMXT_OP_CMP(subs, int8_t, int16_t, int32_t, -) |
326 | e677137d | pbrook | IWMMXT_OP_CMP(adds, int8_t, int16_t, int32_t, +) |
327 | e677137d | pbrook | #undef CMP
|
328 | e677137d | pbrook | #undef IWMMXT_OP_CMP
|
329 | e677137d | pbrook | |
330 | e677137d | pbrook | #define AVGB(SHR) ((( \
|
331 | e677137d | pbrook | ((a >> SHR) & 0xff) + ((b >> SHR) & 0xff) + round) >> 1) << SHR) |
332 | e677137d | pbrook | #define IWMMXT_OP_AVGB(r) \
|
333 | e677137d | pbrook | uint64_t HELPER(iwmmxt_avgb##r)(CPUState *env, uint64_t a, uint64_t b) \ |
334 | e677137d | pbrook | { \ |
335 | e677137d | pbrook | const int round = r; \ |
336 | e677137d | pbrook | a = AVGB(0) | AVGB(8) | AVGB(16) | AVGB(24) | \ |
337 | e677137d | pbrook | AVGB(32) | AVGB(40) | AVGB(48) | AVGB(56); \ |
338 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
339 | e677137d | pbrook | SIMD8_SET(ZBIT8((a >> 0) & 0xff), SIMD_ZBIT, 0) | \ |
340 | e677137d | pbrook | SIMD8_SET(ZBIT8((a >> 8) & 0xff), SIMD_ZBIT, 1) | \ |
341 | e677137d | pbrook | SIMD8_SET(ZBIT8((a >> 16) & 0xff), SIMD_ZBIT, 2) | \ |
342 | e677137d | pbrook | SIMD8_SET(ZBIT8((a >> 24) & 0xff), SIMD_ZBIT, 3) | \ |
343 | e677137d | pbrook | SIMD8_SET(ZBIT8((a >> 32) & 0xff), SIMD_ZBIT, 4) | \ |
344 | e677137d | pbrook | SIMD8_SET(ZBIT8((a >> 40) & 0xff), SIMD_ZBIT, 5) | \ |
345 | e677137d | pbrook | SIMD8_SET(ZBIT8((a >> 48) & 0xff), SIMD_ZBIT, 6) | \ |
346 | e677137d | pbrook | SIMD8_SET(ZBIT8((a >> 56) & 0xff), SIMD_ZBIT, 7); \ |
347 | e677137d | pbrook | return a; \
|
348 | e677137d | pbrook | } |
349 | e677137d | pbrook | IWMMXT_OP_AVGB(0)
|
350 | e677137d | pbrook | IWMMXT_OP_AVGB(1)
|
351 | e677137d | pbrook | #undef IWMMXT_OP_AVGB
|
352 | e677137d | pbrook | #undef AVGB
|
353 | e677137d | pbrook | |
354 | e677137d | pbrook | #define AVGW(SHR) ((( \
|
355 | e677137d | pbrook | ((a >> SHR) & 0xffff) + ((b >> SHR) & 0xffff) + round) >> 1) << SHR) |
356 | e677137d | pbrook | #define IWMMXT_OP_AVGW(r) \
|
357 | e677137d | pbrook | uint64_t HELPER(iwmmxt_avgw##r)(CPUState *env, uint64_t a, uint64_t b) \ |
358 | e677137d | pbrook | { \ |
359 | e677137d | pbrook | const int round = r; \ |
360 | e677137d | pbrook | a = AVGW(0) | AVGW(16) | AVGW(32) | AVGW(48); \ |
361 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = \ |
362 | e677137d | pbrook | SIMD16_SET(ZBIT16((a >> 0) & 0xffff), SIMD_ZBIT, 0) | \ |
363 | e677137d | pbrook | SIMD16_SET(ZBIT16((a >> 16) & 0xffff), SIMD_ZBIT, 1) | \ |
364 | e677137d | pbrook | SIMD16_SET(ZBIT16((a >> 32) & 0xffff), SIMD_ZBIT, 2) | \ |
365 | e677137d | pbrook | SIMD16_SET(ZBIT16((a >> 48) & 0xffff), SIMD_ZBIT, 3); \ |
366 | e677137d | pbrook | return a; \
|
367 | e677137d | pbrook | } |
368 | e677137d | pbrook | IWMMXT_OP_AVGW(0)
|
369 | e677137d | pbrook | IWMMXT_OP_AVGW(1)
|
370 | e677137d | pbrook | #undef IWMMXT_OP_AVGW
|
371 | e677137d | pbrook | #undef AVGW
|
372 | e677137d | pbrook | |
373 | e677137d | pbrook | uint64_t HELPER(iwmmxt_msadb)(uint64_t a, uint64_t b) |
374 | e677137d | pbrook | { |
375 | e677137d | pbrook | a = ((((a >> 0 ) & 0xffff) * ((b >> 0) & 0xffff) + |
376 | e677137d | pbrook | ((a >> 16) & 0xffff) * ((b >> 16) & 0xffff)) & 0xffffffff) | |
377 | e677137d | pbrook | ((((a >> 32) & 0xffff) * ((b >> 32) & 0xffff) + |
378 | e677137d | pbrook | ((a >> 48) & 0xffff) * ((b >> 48) & 0xffff)) << 32); |
379 | e677137d | pbrook | return a;
|
380 | e677137d | pbrook | } |
381 | e677137d | pbrook | |
382 | e677137d | pbrook | uint64_t HELPER(iwmmxt_align)(uint64_t a, uint64_t b, uint32_t n) |
383 | e677137d | pbrook | { |
384 | e677137d | pbrook | a >>= n << 3;
|
385 | e677137d | pbrook | a |= b << (64 - (n << 3)); |
386 | e677137d | pbrook | return a;
|
387 | e677137d | pbrook | } |
388 | e677137d | pbrook | |
389 | e677137d | pbrook | uint64_t HELPER(iwmmxt_insr)(uint64_t x, uint32_t a, uint32_t b, uint32_t n) |
390 | e677137d | pbrook | { |
391 | e677137d | pbrook | x &= ~((uint64_t) b << n); |
392 | e677137d | pbrook | x |= (uint64_t) (a & b) << n; |
393 | e677137d | pbrook | return x;
|
394 | e677137d | pbrook | } |
395 | e677137d | pbrook | |
396 | e677137d | pbrook | uint32_t HELPER(iwmmxt_setpsr_nz)(uint64_t x) |
397 | e677137d | pbrook | { |
398 | e677137d | pbrook | return SIMD64_SET((x == 0), SIMD_ZBIT) | |
399 | e677137d | pbrook | SIMD64_SET((x & (1ULL << 63)), SIMD_NBIT); |
400 | e677137d | pbrook | } |
401 | e677137d | pbrook | |
402 | e677137d | pbrook | uint64_t HELPER(iwmmxt_bcstb)(uint32_t arg) |
403 | e677137d | pbrook | { |
404 | e677137d | pbrook | arg &= 0xff;
|
405 | e677137d | pbrook | return
|
406 | e677137d | pbrook | ((uint64_t) arg << 0 ) | ((uint64_t) arg << 8 ) | |
407 | e677137d | pbrook | ((uint64_t) arg << 16) | ((uint64_t) arg << 24) | |
408 | e677137d | pbrook | ((uint64_t) arg << 32) | ((uint64_t) arg << 40) | |
409 | e677137d | pbrook | ((uint64_t) arg << 48) | ((uint64_t) arg << 56); |
410 | e677137d | pbrook | } |
411 | e677137d | pbrook | |
412 | e677137d | pbrook | uint64_t HELPER(iwmmxt_bcstw)(uint32_t arg) |
413 | e677137d | pbrook | { |
414 | e677137d | pbrook | arg &= 0xffff;
|
415 | e677137d | pbrook | return
|
416 | e677137d | pbrook | ((uint64_t) arg << 0 ) | ((uint64_t) arg << 16) | |
417 | e677137d | pbrook | ((uint64_t) arg << 32) | ((uint64_t) arg << 48); |
418 | e677137d | pbrook | } |
419 | e677137d | pbrook | |
420 | e677137d | pbrook | uint64_t HELPER(iwmmxt_bcstl)(uint32_t arg) |
421 | e677137d | pbrook | { |
422 | e677137d | pbrook | return arg | ((uint64_t) arg << 32); |
423 | e677137d | pbrook | } |
424 | e677137d | pbrook | |
425 | e677137d | pbrook | uint64_t HELPER(iwmmxt_addcb)(uint64_t x) |
426 | e677137d | pbrook | { |
427 | e677137d | pbrook | return
|
428 | e677137d | pbrook | ((x >> 0) & 0xff) + ((x >> 8) & 0xff) + |
429 | e677137d | pbrook | ((x >> 16) & 0xff) + ((x >> 24) & 0xff) + |
430 | e677137d | pbrook | ((x >> 32) & 0xff) + ((x >> 40) & 0xff) + |
431 | e677137d | pbrook | ((x >> 48) & 0xff) + ((x >> 56) & 0xff); |
432 | e677137d | pbrook | } |
433 | e677137d | pbrook | |
434 | e677137d | pbrook | uint64_t HELPER(iwmmxt_addcw)(uint64_t x) |
435 | e677137d | pbrook | { |
436 | e677137d | pbrook | return
|
437 | e677137d | pbrook | ((x >> 0) & 0xffff) + ((x >> 16) & 0xffff) + |
438 | e677137d | pbrook | ((x >> 32) & 0xffff) + ((x >> 48) & 0xffff); |
439 | e677137d | pbrook | } |
440 | e677137d | pbrook | |
441 | e677137d | pbrook | uint64_t HELPER(iwmmxt_addcl)(uint64_t x) |
442 | e677137d | pbrook | { |
443 | e677137d | pbrook | return (x & 0xffffffff) + (x >> 32); |
444 | e677137d | pbrook | } |
445 | e677137d | pbrook | |
446 | e677137d | pbrook | uint32_t HELPER(iwmmxt_msbb)(uint64_t x) |
447 | e677137d | pbrook | { |
448 | e677137d | pbrook | return
|
449 | e677137d | pbrook | ((x >> 7) & 0x01) | ((x >> 14) & 0x02) | |
450 | e677137d | pbrook | ((x >> 21) & 0x04) | ((x >> 28) & 0x08) | |
451 | e677137d | pbrook | ((x >> 35) & 0x10) | ((x >> 42) & 0x20) | |
452 | e677137d | pbrook | ((x >> 49) & 0x40) | ((x >> 56) & 0x80); |
453 | e677137d | pbrook | } |
454 | e677137d | pbrook | |
455 | e677137d | pbrook | uint32_t HELPER(iwmmxt_msbw)(uint64_t x) |
456 | e677137d | pbrook | { |
457 | e677137d | pbrook | return
|
458 | e677137d | pbrook | ((x >> 15) & 0x01) | ((x >> 30) & 0x02) | |
459 | e677137d | pbrook | ((x >> 45) & 0x04) | ((x >> 52) & 0x08); |
460 | e677137d | pbrook | } |
461 | e677137d | pbrook | |
462 | e677137d | pbrook | uint32_t HELPER(iwmmxt_msbl)(uint64_t x) |
463 | e677137d | pbrook | { |
464 | e677137d | pbrook | return ((x >> 31) & 0x01) | ((x >> 62) & 0x02); |
465 | e677137d | pbrook | } |
466 | e677137d | pbrook | |
467 | e677137d | pbrook | /* FIXME: Split wCASF setting into a separate op to avoid env use. */
|
468 | e677137d | pbrook | uint64_t HELPER(iwmmxt_srlw)(CPUState *env, uint64_t x, uint32_t n) |
469 | e677137d | pbrook | { |
470 | e677137d | pbrook | x = (((x & (0xffffll << 0)) >> n) & (0xffffll << 0)) | |
471 | e677137d | pbrook | (((x & (0xffffll << 16)) >> n) & (0xffffll << 16)) | |
472 | e677137d | pbrook | (((x & (0xffffll << 32)) >> n) & (0xffffll << 32)) | |
473 | e677137d | pbrook | (((x & (0xffffll << 48)) >> n) & (0xffffll << 48)); |
474 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
475 | e677137d | pbrook | NZBIT16(x >> 0, 0) | NZBIT16(x >> 16, 1) | |
476 | e677137d | pbrook | NZBIT16(x >> 32, 2) | NZBIT16(x >> 48, 3); |
477 | e677137d | pbrook | return x;
|
478 | e677137d | pbrook | } |
479 | e677137d | pbrook | |
480 | e677137d | pbrook | uint64_t HELPER(iwmmxt_srll)(CPUState *env, uint64_t x, uint32_t n) |
481 | e677137d | pbrook | { |
482 | e677137d | pbrook | x = ((x & (0xffffffffll << 0)) >> n) | |
483 | e677137d | pbrook | ((x >> n) & (0xffffffffll << 32)); |
484 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
485 | e677137d | pbrook | NZBIT32(x >> 0, 0) | NZBIT32(x >> 32, 1); |
486 | e677137d | pbrook | return x;
|
487 | e677137d | pbrook | } |
488 | e677137d | pbrook | |
489 | e677137d | pbrook | uint64_t HELPER(iwmmxt_srlq)(CPUState *env, uint64_t x, uint32_t n) |
490 | e677137d | pbrook | { |
491 | e677137d | pbrook | x >>= n; |
492 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = NZBIT64(x); |
493 | e677137d | pbrook | return x;
|
494 | e677137d | pbrook | } |
495 | e677137d | pbrook | |
496 | e677137d | pbrook | uint64_t HELPER(iwmmxt_sllw)(CPUState *env, uint64_t x, uint32_t n) |
497 | e677137d | pbrook | { |
498 | e677137d | pbrook | x = (((x & (0xffffll << 0)) << n) & (0xffffll << 0)) | |
499 | e677137d | pbrook | (((x & (0xffffll << 16)) << n) & (0xffffll << 16)) | |
500 | e677137d | pbrook | (((x & (0xffffll << 32)) << n) & (0xffffll << 32)) | |
501 | e677137d | pbrook | (((x & (0xffffll << 48)) << n) & (0xffffll << 48)); |
502 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
503 | e677137d | pbrook | NZBIT16(x >> 0, 0) | NZBIT16(x >> 16, 1) | |
504 | e677137d | pbrook | NZBIT16(x >> 32, 2) | NZBIT16(x >> 48, 3); |
505 | e677137d | pbrook | return x;
|
506 | e677137d | pbrook | } |
507 | e677137d | pbrook | |
508 | e677137d | pbrook | uint64_t HELPER(iwmmxt_slll)(CPUState *env, uint64_t x, uint32_t n) |
509 | e677137d | pbrook | { |
510 | e677137d | pbrook | x = ((x << n) & (0xffffffffll << 0)) | |
511 | e677137d | pbrook | ((x & (0xffffffffll << 32)) << n); |
512 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
513 | e677137d | pbrook | NZBIT32(x >> 0, 0) | NZBIT32(x >> 32, 1); |
514 | e677137d | pbrook | return x;
|
515 | e677137d | pbrook | } |
516 | e677137d | pbrook | |
517 | e677137d | pbrook | uint64_t HELPER(iwmmxt_sllq)(CPUState *env, uint64_t x, uint32_t n) |
518 | e677137d | pbrook | { |
519 | e677137d | pbrook | x <<= n; |
520 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = NZBIT64(x); |
521 | e677137d | pbrook | return x;
|
522 | e677137d | pbrook | } |
523 | e677137d | pbrook | |
524 | e677137d | pbrook | uint64_t HELPER(iwmmxt_sraw)(CPUState *env, uint64_t x, uint32_t n) |
525 | e677137d | pbrook | { |
526 | e677137d | pbrook | x = ((uint64_t) ((EXTEND16(x >> 0) >> n) & 0xffff) << 0) | |
527 | e677137d | pbrook | ((uint64_t) ((EXTEND16(x >> 16) >> n) & 0xffff) << 16) | |
528 | e677137d | pbrook | ((uint64_t) ((EXTEND16(x >> 32) >> n) & 0xffff) << 32) | |
529 | e677137d | pbrook | ((uint64_t) ((EXTEND16(x >> 48) >> n) & 0xffff) << 48); |
530 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
531 | e677137d | pbrook | NZBIT16(x >> 0, 0) | NZBIT16(x >> 16, 1) | |
532 | e677137d | pbrook | NZBIT16(x >> 32, 2) | NZBIT16(x >> 48, 3); |
533 | e677137d | pbrook | return x;
|
534 | e677137d | pbrook | } |
535 | e677137d | pbrook | |
536 | e677137d | pbrook | uint64_t HELPER(iwmmxt_sral)(CPUState *env, uint64_t x, uint32_t n) |
537 | e677137d | pbrook | { |
538 | e677137d | pbrook | x = (((EXTEND32(x >> 0) >> n) & 0xffffffff) << 0) | |
539 | e677137d | pbrook | (((EXTEND32(x >> 32) >> n) & 0xffffffff) << 32); |
540 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
541 | e677137d | pbrook | NZBIT32(x >> 0, 0) | NZBIT32(x >> 32, 1); |
542 | e677137d | pbrook | return x;
|
543 | e677137d | pbrook | } |
544 | e677137d | pbrook | |
545 | e677137d | pbrook | uint64_t HELPER(iwmmxt_sraq)(CPUState *env, uint64_t x, uint32_t n) |
546 | e677137d | pbrook | { |
547 | e677137d | pbrook | x = (int64_t) x >> n; |
548 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = NZBIT64(x); |
549 | e677137d | pbrook | return x;
|
550 | e677137d | pbrook | } |
551 | e677137d | pbrook | |
552 | e677137d | pbrook | uint64_t HELPER(iwmmxt_rorw)(CPUState *env, uint64_t x, uint32_t n) |
553 | e677137d | pbrook | { |
554 | e677137d | pbrook | x = ((((x & (0xffffll << 0)) >> n) | |
555 | e677137d | pbrook | ((x & (0xffffll << 0)) << (16 - n))) & (0xffffll << 0)) | |
556 | e677137d | pbrook | ((((x & (0xffffll << 16)) >> n) | |
557 | e677137d | pbrook | ((x & (0xffffll << 16)) << (16 - n))) & (0xffffll << 16)) | |
558 | e677137d | pbrook | ((((x & (0xffffll << 32)) >> n) | |
559 | e677137d | pbrook | ((x & (0xffffll << 32)) << (16 - n))) & (0xffffll << 32)) | |
560 | e677137d | pbrook | ((((x & (0xffffll << 48)) >> n) | |
561 | e677137d | pbrook | ((x & (0xffffll << 48)) << (16 - n))) & (0xffffll << 48)); |
562 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
563 | e677137d | pbrook | NZBIT16(x >> 0, 0) | NZBIT16(x >> 16, 1) | |
564 | e677137d | pbrook | NZBIT16(x >> 32, 2) | NZBIT16(x >> 48, 3); |
565 | e677137d | pbrook | return x;
|
566 | e677137d | pbrook | } |
567 | e677137d | pbrook | |
568 | e677137d | pbrook | uint64_t HELPER(iwmmxt_rorl)(CPUState *env, uint64_t x, uint32_t n) |
569 | e677137d | pbrook | { |
570 | e677137d | pbrook | x = ((x & (0xffffffffll << 0)) >> n) | |
571 | e677137d | pbrook | ((x >> n) & (0xffffffffll << 32)) | |
572 | e677137d | pbrook | ((x << (32 - n)) & (0xffffffffll << 0)) | |
573 | e677137d | pbrook | ((x & (0xffffffffll << 32)) << (32 - n)); |
574 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
575 | e677137d | pbrook | NZBIT32(x >> 0, 0) | NZBIT32(x >> 32, 1); |
576 | e677137d | pbrook | return x;
|
577 | e677137d | pbrook | } |
578 | e677137d | pbrook | |
579 | e677137d | pbrook | uint64_t HELPER(iwmmxt_rorq)(CPUState *env, uint64_t x, uint32_t n) |
580 | e677137d | pbrook | { |
581 | e677137d | pbrook | x = (x >> n) | (x << (64 - n));
|
582 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = NZBIT64(x); |
583 | e677137d | pbrook | return x;
|
584 | e677137d | pbrook | } |
585 | e677137d | pbrook | |
586 | e677137d | pbrook | uint64_t HELPER(iwmmxt_shufh)(CPUState *env, uint64_t x, uint32_t n) |
587 | e677137d | pbrook | { |
588 | e677137d | pbrook | x = (((x >> ((n << 4) & 0x30)) & 0xffff) << 0) | |
589 | e677137d | pbrook | (((x >> ((n << 2) & 0x30)) & 0xffff) << 16) | |
590 | e677137d | pbrook | (((x >> ((n << 0) & 0x30)) & 0xffff) << 32) | |
591 | e677137d | pbrook | (((x >> ((n >> 2) & 0x30)) & 0xffff) << 48); |
592 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
593 | e677137d | pbrook | NZBIT16(x >> 0, 0) | NZBIT16(x >> 16, 1) | |
594 | e677137d | pbrook | NZBIT16(x >> 32, 2) | NZBIT16(x >> 48, 3); |
595 | e677137d | pbrook | return x;
|
596 | e677137d | pbrook | } |
597 | e677137d | pbrook | |
598 | e677137d | pbrook | /* TODO: Unsigned-Saturation */
|
599 | e677137d | pbrook | uint64_t HELPER(iwmmxt_packuw)(CPUState *env, uint64_t a, uint64_t b) |
600 | e677137d | pbrook | { |
601 | e677137d | pbrook | a = (((a >> 0) & 0xff) << 0) | (((a >> 16) & 0xff) << 8) | |
602 | e677137d | pbrook | (((a >> 32) & 0xff) << 16) | (((a >> 48) & 0xff) << 24) | |
603 | e677137d | pbrook | (((b >> 0) & 0xff) << 32) | (((b >> 16) & 0xff) << 40) | |
604 | e677137d | pbrook | (((b >> 32) & 0xff) << 48) | (((b >> 48) & 0xff) << 56); |
605 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
606 | e677137d | pbrook | NZBIT8(a >> 0, 0) | NZBIT8(a >> 8, 1) | |
607 | e677137d | pbrook | NZBIT8(a >> 16, 2) | NZBIT8(a >> 24, 3) | |
608 | e677137d | pbrook | NZBIT8(a >> 32, 4) | NZBIT8(a >> 40, 5) | |
609 | e677137d | pbrook | NZBIT8(a >> 48, 6) | NZBIT8(a >> 56, 7); |
610 | e677137d | pbrook | return a;
|
611 | e677137d | pbrook | } |
612 | e677137d | pbrook | |
613 | e677137d | pbrook | uint64_t HELPER(iwmmxt_packul)(CPUState *env, uint64_t a, uint64_t b) |
614 | e677137d | pbrook | { |
615 | e677137d | pbrook | a = (((a >> 0) & 0xffff) << 0) | (((a >> 32) & 0xffff) << 16) | |
616 | e677137d | pbrook | (((b >> 0) & 0xffff) << 32) | (((b >> 32) & 0xffff) << 48); |
617 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
618 | e677137d | pbrook | NZBIT16(a >> 0, 0) | NZBIT16(a >> 16, 1) | |
619 | e677137d | pbrook | NZBIT16(a >> 32, 2) | NZBIT16(a >> 48, 3); |
620 | e677137d | pbrook | return a;
|
621 | e677137d | pbrook | } |
622 | e677137d | pbrook | |
623 | e677137d | pbrook | uint64_t HELPER(iwmmxt_packuq)(CPUState *env, uint64_t a, uint64_t b) |
624 | e677137d | pbrook | { |
625 | e677137d | pbrook | a = (a & 0xffffffff) | ((b & 0xffffffff) << 32); |
626 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
627 | e677137d | pbrook | NZBIT32(a >> 0, 0) | NZBIT32(a >> 32, 1); |
628 | e677137d | pbrook | return a;
|
629 | e677137d | pbrook | } |
630 | e677137d | pbrook | |
631 | e677137d | pbrook | /* TODO: Signed-Saturation */
|
632 | e677137d | pbrook | uint64_t HELPER(iwmmxt_packsw)(CPUState *env, uint64_t a, uint64_t b) |
633 | e677137d | pbrook | { |
634 | e677137d | pbrook | a = (((a >> 0) & 0xff) << 0) | (((a >> 16) & 0xff) << 8) | |
635 | e677137d | pbrook | (((a >> 32) & 0xff) << 16) | (((a >> 48) & 0xff) << 24) | |
636 | e677137d | pbrook | (((b >> 0) & 0xff) << 32) | (((b >> 16) & 0xff) << 40) | |
637 | e677137d | pbrook | (((b >> 32) & 0xff) << 48) | (((b >> 48) & 0xff) << 56); |
638 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
639 | e677137d | pbrook | NZBIT8(a >> 0, 0) | NZBIT8(a >> 8, 1) | |
640 | e677137d | pbrook | NZBIT8(a >> 16, 2) | NZBIT8(a >> 24, 3) | |
641 | e677137d | pbrook | NZBIT8(a >> 32, 4) | NZBIT8(a >> 40, 5) | |
642 | e677137d | pbrook | NZBIT8(a >> 48, 6) | NZBIT8(a >> 56, 7); |
643 | e677137d | pbrook | return a;
|
644 | e677137d | pbrook | } |
645 | e677137d | pbrook | |
646 | e677137d | pbrook | uint64_t HELPER(iwmmxt_packsl)(CPUState *env, uint64_t a, uint64_t b) |
647 | e677137d | pbrook | { |
648 | e677137d | pbrook | a = (((a >> 0) & 0xffff) << 0) | (((a >> 32) & 0xffff) << 16) | |
649 | e677137d | pbrook | (((b >> 0) & 0xffff) << 32) | (((b >> 32) & 0xffff) << 48); |
650 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
651 | e677137d | pbrook | NZBIT16(a >> 0, 0) | NZBIT16(a >> 16, 1) | |
652 | e677137d | pbrook | NZBIT16(a >> 32, 2) | NZBIT16(a >> 48, 3); |
653 | e677137d | pbrook | return a;
|
654 | e677137d | pbrook | } |
655 | e677137d | pbrook | |
656 | e677137d | pbrook | uint64_t HELPER(iwmmxt_packsq)(CPUState *env, uint64_t a, uint64_t b) |
657 | e677137d | pbrook | { |
658 | e677137d | pbrook | a = (a & 0xffffffff) | ((b & 0xffffffff) << 32); |
659 | e677137d | pbrook | env->iwmmxt.cregs[ARM_IWMMXT_wCASF] = |
660 | e677137d | pbrook | NZBIT32(a >> 0, 0) | NZBIT32(a >> 32, 1); |
661 | e677137d | pbrook | return a;
|
662 | e677137d | pbrook | } |
663 | e677137d | pbrook | |
664 | e677137d | pbrook | uint64_t HELPER(iwmmxt_muladdsl)(uint64_t c, uint32_t a, uint32_t b) |
665 | e677137d | pbrook | { |
666 | e677137d | pbrook | return c + ((int32_t) EXTEND32(a) * (int32_t) EXTEND32(b));
|
667 | e677137d | pbrook | } |
668 | e677137d | pbrook | |
669 | e677137d | pbrook | uint64_t HELPER(iwmmxt_muladdsw)(uint64_t c, uint32_t a, uint32_t b) |
670 | e677137d | pbrook | { |
671 | e677137d | pbrook | c += EXTEND32(EXTEND16S((a >> 0) & 0xffff) * |
672 | e677137d | pbrook | EXTEND16S((b >> 0) & 0xffff)); |
673 | e677137d | pbrook | c += EXTEND32(EXTEND16S((a >> 16) & 0xffff) * |
674 | e677137d | pbrook | EXTEND16S((b >> 16) & 0xffff)); |
675 | e677137d | pbrook | return c;
|
676 | e677137d | pbrook | } |
677 | e677137d | pbrook | |
678 | e677137d | pbrook | uint64_t HELPER(iwmmxt_muladdswl)(uint64_t c, uint32_t a, uint32_t b) |
679 | e677137d | pbrook | { |
680 | e677137d | pbrook | return c + (EXTEND32(EXTEND16S(a & 0xffff) * |
681 | e677137d | pbrook | EXTEND16S(b & 0xffff)));
|
682 | e677137d | pbrook | } |