root / target-alpha / translate.c @ dd4239d6
History | View | Annotate | Download (74.7 kB)
1 | 4c9649a9 | j_mayer | /*
|
---|---|---|---|
2 | 4c9649a9 | j_mayer | * Alpha emulation cpu translation for qemu.
|
3 | 5fafdf24 | ths | *
|
4 | 4c9649a9 | j_mayer | * Copyright (c) 2007 Jocelyn Mayer
|
5 | 4c9649a9 | j_mayer | *
|
6 | 4c9649a9 | j_mayer | * This library is free software; you can redistribute it and/or
|
7 | 4c9649a9 | j_mayer | * modify it under the terms of the GNU Lesser General Public
|
8 | 4c9649a9 | j_mayer | * License as published by the Free Software Foundation; either
|
9 | 4c9649a9 | j_mayer | * version 2 of the License, or (at your option) any later version.
|
10 | 4c9649a9 | j_mayer | *
|
11 | 4c9649a9 | j_mayer | * This library is distributed in the hope that it will be useful,
|
12 | 4c9649a9 | j_mayer | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 4c9649a9 | j_mayer | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | 4c9649a9 | j_mayer | * Lesser General Public License for more details.
|
15 | 4c9649a9 | j_mayer | *
|
16 | 4c9649a9 | j_mayer | * You should have received a copy of the GNU Lesser General Public
|
17 | 8167ee88 | Blue Swirl | * License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
18 | 4c9649a9 | j_mayer | */
|
19 | 4c9649a9 | j_mayer | |
20 | 4c9649a9 | j_mayer | #include <stdint.h> |
21 | 4c9649a9 | j_mayer | #include <stdlib.h> |
22 | 4c9649a9 | j_mayer | #include <stdio.h> |
23 | 4c9649a9 | j_mayer | |
24 | 4c9649a9 | j_mayer | #include "cpu.h" |
25 | 4c9649a9 | j_mayer | #include "exec-all.h" |
26 | 4c9649a9 | j_mayer | #include "disas.h" |
27 | ae8ecd42 | aurel32 | #include "host-utils.h" |
28 | 57fec1fe | bellard | #include "tcg-op.h" |
29 | ca10f867 | aurel32 | #include "qemu-common.h" |
30 | 4c9649a9 | j_mayer | |
31 | a7812ae4 | pbrook | #include "helper.h" |
32 | a7812ae4 | pbrook | #define GEN_HELPER 1 |
33 | a7812ae4 | pbrook | #include "helper.h" |
34 | a7812ae4 | pbrook | |
35 | 55489a17 | aurel32 | /* #define DO_SINGLE_STEP */
|
36 | 4c9649a9 | j_mayer | #define ALPHA_DEBUG_DISAS
|
37 | 55489a17 | aurel32 | /* #define DO_TB_FLUSH */
|
38 | 4c9649a9 | j_mayer | |
39 | d12d51d5 | aliguori | |
40 | d12d51d5 | aliguori | #ifdef ALPHA_DEBUG_DISAS
|
41 | 93fcfe39 | aliguori | # define LOG_DISAS(...) qemu_log(__VA_ARGS__)
|
42 | d12d51d5 | aliguori | #else
|
43 | d12d51d5 | aliguori | # define LOG_DISAS(...) do { } while (0) |
44 | d12d51d5 | aliguori | #endif
|
45 | d12d51d5 | aliguori | |
46 | 4c9649a9 | j_mayer | typedef struct DisasContext DisasContext; |
47 | 4c9649a9 | j_mayer | struct DisasContext {
|
48 | 4c9649a9 | j_mayer | uint64_t pc; |
49 | 4c9649a9 | j_mayer | int mem_idx;
|
50 | 4c9649a9 | j_mayer | #if !defined (CONFIG_USER_ONLY)
|
51 | 4c9649a9 | j_mayer | int pal_mode;
|
52 | 4c9649a9 | j_mayer | #endif
|
53 | 8579095b | aurel32 | CPUAlphaState *env; |
54 | 4c9649a9 | j_mayer | uint32_t amask; |
55 | 4c9649a9 | j_mayer | }; |
56 | 4c9649a9 | j_mayer | |
57 | 3761035f | aurel32 | /* global register indexes */
|
58 | a7812ae4 | pbrook | static TCGv_ptr cpu_env;
|
59 | 496cb5b9 | aurel32 | static TCGv cpu_ir[31]; |
60 | f18cd223 | aurel32 | static TCGv cpu_fir[31]; |
61 | 496cb5b9 | aurel32 | static TCGv cpu_pc;
|
62 | f4ed8679 | aurel32 | static TCGv cpu_lock;
|
63 | 496cb5b9 | aurel32 | |
64 | 3761035f | aurel32 | /* register names */
|
65 | f18cd223 | aurel32 | static char cpu_reg_names[10*4+21*5 + 10*5+21*6]; |
66 | 2e70f6ef | pbrook | |
67 | 2e70f6ef | pbrook | #include "gen-icount.h" |
68 | 2e70f6ef | pbrook | |
69 | a5f1b965 | blueswir1 | static void alpha_translate_init(void) |
70 | 2e70f6ef | pbrook | { |
71 | 496cb5b9 | aurel32 | int i;
|
72 | 496cb5b9 | aurel32 | char *p;
|
73 | 2e70f6ef | pbrook | static int done_init = 0; |
74 | 496cb5b9 | aurel32 | |
75 | 2e70f6ef | pbrook | if (done_init)
|
76 | 2e70f6ef | pbrook | return;
|
77 | 496cb5b9 | aurel32 | |
78 | a7812ae4 | pbrook | cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env");
|
79 | 496cb5b9 | aurel32 | |
80 | 496cb5b9 | aurel32 | p = cpu_reg_names; |
81 | 496cb5b9 | aurel32 | for (i = 0; i < 31; i++) { |
82 | 496cb5b9 | aurel32 | sprintf(p, "ir%d", i);
|
83 | a7812ae4 | pbrook | cpu_ir[i] = tcg_global_mem_new_i64(TCG_AREG0, |
84 | a7812ae4 | pbrook | offsetof(CPUState, ir[i]), p); |
85 | 6ba8dcd7 | aurel32 | p += (i < 10) ? 4 : 5; |
86 | f18cd223 | aurel32 | |
87 | f18cd223 | aurel32 | sprintf(p, "fir%d", i);
|
88 | a7812ae4 | pbrook | cpu_fir[i] = tcg_global_mem_new_i64(TCG_AREG0, |
89 | a7812ae4 | pbrook | offsetof(CPUState, fir[i]), p); |
90 | f18cd223 | aurel32 | p += (i < 10) ? 5 : 6; |
91 | 496cb5b9 | aurel32 | } |
92 | 496cb5b9 | aurel32 | |
93 | a7812ae4 | pbrook | cpu_pc = tcg_global_mem_new_i64(TCG_AREG0, |
94 | a7812ae4 | pbrook | offsetof(CPUState, pc), "pc");
|
95 | 496cb5b9 | aurel32 | |
96 | a7812ae4 | pbrook | cpu_lock = tcg_global_mem_new_i64(TCG_AREG0, |
97 | a7812ae4 | pbrook | offsetof(CPUState, lock), "lock");
|
98 | f4ed8679 | aurel32 | |
99 | 496cb5b9 | aurel32 | /* register helpers */
|
100 | a7812ae4 | pbrook | #define GEN_HELPER 2 |
101 | 496cb5b9 | aurel32 | #include "helper.h" |
102 | 496cb5b9 | aurel32 | |
103 | 2e70f6ef | pbrook | done_init = 1;
|
104 | 2e70f6ef | pbrook | } |
105 | 2e70f6ef | pbrook | |
106 | 636aa200 | Blue Swirl | static inline void gen_excp(DisasContext *ctx, int exception, int error_code) |
107 | 4c9649a9 | j_mayer | { |
108 | a7812ae4 | pbrook | TCGv_i32 tmp1, tmp2; |
109 | 6ad02592 | aurel32 | |
110 | 496cb5b9 | aurel32 | tcg_gen_movi_i64(cpu_pc, ctx->pc); |
111 | 6ad02592 | aurel32 | tmp1 = tcg_const_i32(exception); |
112 | 6ad02592 | aurel32 | tmp2 = tcg_const_i32(error_code); |
113 | a7812ae4 | pbrook | gen_helper_excp(tmp1, tmp2); |
114 | a7812ae4 | pbrook | tcg_temp_free_i32(tmp2); |
115 | a7812ae4 | pbrook | tcg_temp_free_i32(tmp1); |
116 | 4c9649a9 | j_mayer | } |
117 | 4c9649a9 | j_mayer | |
118 | 636aa200 | Blue Swirl | static inline void gen_invalid(DisasContext *ctx) |
119 | 4c9649a9 | j_mayer | { |
120 | 4c9649a9 | j_mayer | gen_excp(ctx, EXCP_OPCDEC, 0);
|
121 | 4c9649a9 | j_mayer | } |
122 | 4c9649a9 | j_mayer | |
123 | 636aa200 | Blue Swirl | static inline void gen_qemu_ldf(TCGv t0, TCGv t1, int flags) |
124 | f18cd223 | aurel32 | { |
125 | a7812ae4 | pbrook | TCGv tmp = tcg_temp_new(); |
126 | a7812ae4 | pbrook | TCGv_i32 tmp32 = tcg_temp_new_i32(); |
127 | f18cd223 | aurel32 | tcg_gen_qemu_ld32u(tmp, t1, flags); |
128 | a7812ae4 | pbrook | tcg_gen_trunc_i64_i32(tmp32, tmp); |
129 | a7812ae4 | pbrook | gen_helper_memory_to_f(t0, tmp32); |
130 | a7812ae4 | pbrook | tcg_temp_free_i32(tmp32); |
131 | f18cd223 | aurel32 | tcg_temp_free(tmp); |
132 | f18cd223 | aurel32 | } |
133 | f18cd223 | aurel32 | |
134 | 636aa200 | Blue Swirl | static inline void gen_qemu_ldg(TCGv t0, TCGv t1, int flags) |
135 | f18cd223 | aurel32 | { |
136 | a7812ae4 | pbrook | TCGv tmp = tcg_temp_new(); |
137 | f18cd223 | aurel32 | tcg_gen_qemu_ld64(tmp, t1, flags); |
138 | a7812ae4 | pbrook | gen_helper_memory_to_g(t0, tmp); |
139 | f18cd223 | aurel32 | tcg_temp_free(tmp); |
140 | f18cd223 | aurel32 | } |
141 | f18cd223 | aurel32 | |
142 | 636aa200 | Blue Swirl | static inline void gen_qemu_lds(TCGv t0, TCGv t1, int flags) |
143 | f18cd223 | aurel32 | { |
144 | a7812ae4 | pbrook | TCGv tmp = tcg_temp_new(); |
145 | a7812ae4 | pbrook | TCGv_i32 tmp32 = tcg_temp_new_i32(); |
146 | f18cd223 | aurel32 | tcg_gen_qemu_ld32u(tmp, t1, flags); |
147 | a7812ae4 | pbrook | tcg_gen_trunc_i64_i32(tmp32, tmp); |
148 | a7812ae4 | pbrook | gen_helper_memory_to_s(t0, tmp32); |
149 | a7812ae4 | pbrook | tcg_temp_free_i32(tmp32); |
150 | f18cd223 | aurel32 | tcg_temp_free(tmp); |
151 | f18cd223 | aurel32 | } |
152 | f18cd223 | aurel32 | |
153 | 636aa200 | Blue Swirl | static inline void gen_qemu_ldl_l(TCGv t0, TCGv t1, int flags) |
154 | f4ed8679 | aurel32 | { |
155 | f4ed8679 | aurel32 | tcg_gen_mov_i64(cpu_lock, t1); |
156 | f4ed8679 | aurel32 | tcg_gen_qemu_ld32s(t0, t1, flags); |
157 | f4ed8679 | aurel32 | } |
158 | f4ed8679 | aurel32 | |
159 | 636aa200 | Blue Swirl | static inline void gen_qemu_ldq_l(TCGv t0, TCGv t1, int flags) |
160 | f4ed8679 | aurel32 | { |
161 | f4ed8679 | aurel32 | tcg_gen_mov_i64(cpu_lock, t1); |
162 | f4ed8679 | aurel32 | tcg_gen_qemu_ld64(t0, t1, flags); |
163 | f4ed8679 | aurel32 | } |
164 | f4ed8679 | aurel32 | |
165 | 636aa200 | Blue Swirl | static inline void gen_load_mem(DisasContext *ctx, |
166 | 636aa200 | Blue Swirl | void (*tcg_gen_qemu_load)(TCGv t0, TCGv t1,
|
167 | 636aa200 | Blue Swirl | int flags),
|
168 | 636aa200 | Blue Swirl | int ra, int rb, int32_t disp16, int fp, |
169 | 636aa200 | Blue Swirl | int clear)
|
170 | 023d8ca2 | aurel32 | { |
171 | 023d8ca2 | aurel32 | TCGv addr; |
172 | 023d8ca2 | aurel32 | |
173 | 023d8ca2 | aurel32 | if (unlikely(ra == 31)) |
174 | 023d8ca2 | aurel32 | return;
|
175 | 023d8ca2 | aurel32 | |
176 | a7812ae4 | pbrook | addr = tcg_temp_new(); |
177 | 023d8ca2 | aurel32 | if (rb != 31) { |
178 | 023d8ca2 | aurel32 | tcg_gen_addi_i64(addr, cpu_ir[rb], disp16); |
179 | 023d8ca2 | aurel32 | if (clear)
|
180 | 023d8ca2 | aurel32 | tcg_gen_andi_i64(addr, addr, ~0x7);
|
181 | 023d8ca2 | aurel32 | } else {
|
182 | 023d8ca2 | aurel32 | if (clear)
|
183 | 023d8ca2 | aurel32 | disp16 &= ~0x7;
|
184 | 023d8ca2 | aurel32 | tcg_gen_movi_i64(addr, disp16); |
185 | 023d8ca2 | aurel32 | } |
186 | f18cd223 | aurel32 | if (fp)
|
187 | f18cd223 | aurel32 | tcg_gen_qemu_load(cpu_fir[ra], addr, ctx->mem_idx); |
188 | f18cd223 | aurel32 | else
|
189 | f18cd223 | aurel32 | tcg_gen_qemu_load(cpu_ir[ra], addr, ctx->mem_idx); |
190 | 023d8ca2 | aurel32 | tcg_temp_free(addr); |
191 | 023d8ca2 | aurel32 | } |
192 | 023d8ca2 | aurel32 | |
193 | 636aa200 | Blue Swirl | static inline void gen_qemu_stf(TCGv t0, TCGv t1, int flags) |
194 | f18cd223 | aurel32 | { |
195 | a7812ae4 | pbrook | TCGv_i32 tmp32 = tcg_temp_new_i32(); |
196 | a7812ae4 | pbrook | TCGv tmp = tcg_temp_new(); |
197 | a7812ae4 | pbrook | gen_helper_f_to_memory(tmp32, t0); |
198 | a7812ae4 | pbrook | tcg_gen_extu_i32_i64(tmp, tmp32); |
199 | f18cd223 | aurel32 | tcg_gen_qemu_st32(tmp, t1, flags); |
200 | f18cd223 | aurel32 | tcg_temp_free(tmp); |
201 | a7812ae4 | pbrook | tcg_temp_free_i32(tmp32); |
202 | f18cd223 | aurel32 | } |
203 | f18cd223 | aurel32 | |
204 | 636aa200 | Blue Swirl | static inline void gen_qemu_stg(TCGv t0, TCGv t1, int flags) |
205 | f18cd223 | aurel32 | { |
206 | a7812ae4 | pbrook | TCGv tmp = tcg_temp_new(); |
207 | a7812ae4 | pbrook | gen_helper_g_to_memory(tmp, t0); |
208 | f18cd223 | aurel32 | tcg_gen_qemu_st64(tmp, t1, flags); |
209 | f18cd223 | aurel32 | tcg_temp_free(tmp); |
210 | f18cd223 | aurel32 | } |
211 | f18cd223 | aurel32 | |
212 | 636aa200 | Blue Swirl | static inline void gen_qemu_sts(TCGv t0, TCGv t1, int flags) |
213 | f18cd223 | aurel32 | { |
214 | a7812ae4 | pbrook | TCGv_i32 tmp32 = tcg_temp_new_i32(); |
215 | a7812ae4 | pbrook | TCGv tmp = tcg_temp_new(); |
216 | a7812ae4 | pbrook | gen_helper_s_to_memory(tmp32, t0); |
217 | a7812ae4 | pbrook | tcg_gen_extu_i32_i64(tmp, tmp32); |
218 | f18cd223 | aurel32 | tcg_gen_qemu_st32(tmp, t1, flags); |
219 | f18cd223 | aurel32 | tcg_temp_free(tmp); |
220 | a7812ae4 | pbrook | tcg_temp_free_i32(tmp32); |
221 | f18cd223 | aurel32 | } |
222 | f18cd223 | aurel32 | |
223 | 636aa200 | Blue Swirl | static inline void gen_qemu_stl_c(TCGv t0, TCGv t1, int flags) |
224 | f4ed8679 | aurel32 | { |
225 | f4ed8679 | aurel32 | int l1, l2;
|
226 | f4ed8679 | aurel32 | |
227 | f4ed8679 | aurel32 | l1 = gen_new_label(); |
228 | f4ed8679 | aurel32 | l2 = gen_new_label(); |
229 | f4ed8679 | aurel32 | tcg_gen_brcond_i64(TCG_COND_NE, cpu_lock, t1, l1); |
230 | f4ed8679 | aurel32 | tcg_gen_qemu_st32(t0, t1, flags); |
231 | 6223246a | aurel32 | tcg_gen_movi_i64(t0, 1);
|
232 | f4ed8679 | aurel32 | tcg_gen_br(l2); |
233 | f4ed8679 | aurel32 | gen_set_label(l1); |
234 | 6223246a | aurel32 | tcg_gen_movi_i64(t0, 0);
|
235 | f4ed8679 | aurel32 | gen_set_label(l2); |
236 | f4ed8679 | aurel32 | tcg_gen_movi_i64(cpu_lock, -1);
|
237 | f4ed8679 | aurel32 | } |
238 | f4ed8679 | aurel32 | |
239 | 636aa200 | Blue Swirl | static inline void gen_qemu_stq_c(TCGv t0, TCGv t1, int flags) |
240 | f4ed8679 | aurel32 | { |
241 | f4ed8679 | aurel32 | int l1, l2;
|
242 | f4ed8679 | aurel32 | |
243 | f4ed8679 | aurel32 | l1 = gen_new_label(); |
244 | f4ed8679 | aurel32 | l2 = gen_new_label(); |
245 | f4ed8679 | aurel32 | tcg_gen_brcond_i64(TCG_COND_NE, cpu_lock, t1, l1); |
246 | f4ed8679 | aurel32 | tcg_gen_qemu_st64(t0, t1, flags); |
247 | 6223246a | aurel32 | tcg_gen_movi_i64(t0, 1);
|
248 | f4ed8679 | aurel32 | tcg_gen_br(l2); |
249 | f4ed8679 | aurel32 | gen_set_label(l1); |
250 | 6223246a | aurel32 | tcg_gen_movi_i64(t0, 0);
|
251 | f4ed8679 | aurel32 | gen_set_label(l2); |
252 | f4ed8679 | aurel32 | tcg_gen_movi_i64(cpu_lock, -1);
|
253 | f4ed8679 | aurel32 | } |
254 | f4ed8679 | aurel32 | |
255 | 636aa200 | Blue Swirl | static inline void gen_store_mem(DisasContext *ctx, |
256 | 636aa200 | Blue Swirl | void (*tcg_gen_qemu_store)(TCGv t0, TCGv t1,
|
257 | 636aa200 | Blue Swirl | int flags),
|
258 | 636aa200 | Blue Swirl | int ra, int rb, int32_t disp16, int fp, |
259 | 636aa200 | Blue Swirl | int clear, int local) |
260 | 023d8ca2 | aurel32 | { |
261 | 9cd38c23 | aurel32 | TCGv addr; |
262 | 57a92c8e | aurel32 | if (local)
|
263 | a7812ae4 | pbrook | addr = tcg_temp_local_new(); |
264 | 57a92c8e | aurel32 | else
|
265 | a7812ae4 | pbrook | addr = tcg_temp_new(); |
266 | 023d8ca2 | aurel32 | if (rb != 31) { |
267 | 023d8ca2 | aurel32 | tcg_gen_addi_i64(addr, cpu_ir[rb], disp16); |
268 | 023d8ca2 | aurel32 | if (clear)
|
269 | 023d8ca2 | aurel32 | tcg_gen_andi_i64(addr, addr, ~0x7);
|
270 | 023d8ca2 | aurel32 | } else {
|
271 | 023d8ca2 | aurel32 | if (clear)
|
272 | 023d8ca2 | aurel32 | disp16 &= ~0x7;
|
273 | 023d8ca2 | aurel32 | tcg_gen_movi_i64(addr, disp16); |
274 | 023d8ca2 | aurel32 | } |
275 | f18cd223 | aurel32 | if (ra != 31) { |
276 | f18cd223 | aurel32 | if (fp)
|
277 | f18cd223 | aurel32 | tcg_gen_qemu_store(cpu_fir[ra], addr, ctx->mem_idx); |
278 | f18cd223 | aurel32 | else
|
279 | f18cd223 | aurel32 | tcg_gen_qemu_store(cpu_ir[ra], addr, ctx->mem_idx); |
280 | f18cd223 | aurel32 | } else {
|
281 | 57a92c8e | aurel32 | TCGv zero; |
282 | 57a92c8e | aurel32 | if (local)
|
283 | 57a92c8e | aurel32 | zero = tcg_const_local_i64(0);
|
284 | 57a92c8e | aurel32 | else
|
285 | 57a92c8e | aurel32 | zero = tcg_const_i64(0);
|
286 | 023d8ca2 | aurel32 | tcg_gen_qemu_store(zero, addr, ctx->mem_idx); |
287 | 023d8ca2 | aurel32 | tcg_temp_free(zero); |
288 | 023d8ca2 | aurel32 | } |
289 | 023d8ca2 | aurel32 | tcg_temp_free(addr); |
290 | 023d8ca2 | aurel32 | } |
291 | 023d8ca2 | aurel32 | |
292 | 636aa200 | Blue Swirl | static inline void gen_bcond(DisasContext *ctx, TCGCond cond, int ra, |
293 | 636aa200 | Blue Swirl | int32_t disp, int mask)
|
294 | 4c9649a9 | j_mayer | { |
295 | 9c29504e | aurel32 | int l1, l2;
|
296 | 9c29504e | aurel32 | |
297 | 9c29504e | aurel32 | l1 = gen_new_label(); |
298 | 9c29504e | aurel32 | l2 = gen_new_label(); |
299 | 9c29504e | aurel32 | if (likely(ra != 31)) { |
300 | 9c29504e | aurel32 | if (mask) {
|
301 | a7812ae4 | pbrook | TCGv tmp = tcg_temp_new(); |
302 | 9c29504e | aurel32 | tcg_gen_andi_i64(tmp, cpu_ir[ra], 1);
|
303 | 9c29504e | aurel32 | tcg_gen_brcondi_i64(cond, tmp, 0, l1);
|
304 | 9c29504e | aurel32 | tcg_temp_free(tmp); |
305 | 9c29504e | aurel32 | } else
|
306 | 9c29504e | aurel32 | tcg_gen_brcondi_i64(cond, cpu_ir[ra], 0, l1);
|
307 | 9c29504e | aurel32 | } else {
|
308 | 9c29504e | aurel32 | /* Very uncommon case - Do not bother to optimize. */
|
309 | 9c29504e | aurel32 | TCGv tmp = tcg_const_i64(0);
|
310 | 9c29504e | aurel32 | tcg_gen_brcondi_i64(cond, tmp, 0, l1);
|
311 | 9c29504e | aurel32 | tcg_temp_free(tmp); |
312 | 9c29504e | aurel32 | } |
313 | 9c29504e | aurel32 | tcg_gen_movi_i64(cpu_pc, ctx->pc); |
314 | 9c29504e | aurel32 | tcg_gen_br(l2); |
315 | 9c29504e | aurel32 | gen_set_label(l1); |
316 | a1516744 | aurel32 | tcg_gen_movi_i64(cpu_pc, ctx->pc + (int64_t)(disp << 2));
|
317 | 9c29504e | aurel32 | gen_set_label(l2); |
318 | 4c9649a9 | j_mayer | } |
319 | 4c9649a9 | j_mayer | |
320 | 636aa200 | Blue Swirl | static inline void gen_fbcond(DisasContext *ctx, int opc, int ra, |
321 | 636aa200 | Blue Swirl | int32_t disp16) |
322 | 4c9649a9 | j_mayer | { |
323 | f18cd223 | aurel32 | int l1, l2;
|
324 | f18cd223 | aurel32 | TCGv tmp; |
325 | a7812ae4 | pbrook | TCGv src; |
326 | f18cd223 | aurel32 | |
327 | f18cd223 | aurel32 | l1 = gen_new_label(); |
328 | f18cd223 | aurel32 | l2 = gen_new_label(); |
329 | f18cd223 | aurel32 | if (ra != 31) { |
330 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
331 | a7812ae4 | pbrook | src = cpu_fir[ra]; |
332 | f18cd223 | aurel32 | } else {
|
333 | f18cd223 | aurel32 | tmp = tcg_const_i64(0);
|
334 | a7812ae4 | pbrook | src = tmp; |
335 | a7812ae4 | pbrook | } |
336 | a7812ae4 | pbrook | switch (opc) {
|
337 | a7812ae4 | pbrook | case 0x31: /* FBEQ */ |
338 | a7812ae4 | pbrook | gen_helper_cmpfeq(tmp, src); |
339 | a7812ae4 | pbrook | break;
|
340 | a7812ae4 | pbrook | case 0x32: /* FBLT */ |
341 | a7812ae4 | pbrook | gen_helper_cmpflt(tmp, src); |
342 | a7812ae4 | pbrook | break;
|
343 | a7812ae4 | pbrook | case 0x33: /* FBLE */ |
344 | a7812ae4 | pbrook | gen_helper_cmpfle(tmp, src); |
345 | a7812ae4 | pbrook | break;
|
346 | a7812ae4 | pbrook | case 0x35: /* FBNE */ |
347 | a7812ae4 | pbrook | gen_helper_cmpfne(tmp, src); |
348 | a7812ae4 | pbrook | break;
|
349 | a7812ae4 | pbrook | case 0x36: /* FBGE */ |
350 | a7812ae4 | pbrook | gen_helper_cmpfge(tmp, src); |
351 | a7812ae4 | pbrook | break;
|
352 | a7812ae4 | pbrook | case 0x37: /* FBGT */ |
353 | a7812ae4 | pbrook | gen_helper_cmpfgt(tmp, src); |
354 | a7812ae4 | pbrook | break;
|
355 | a7812ae4 | pbrook | default:
|
356 | a7812ae4 | pbrook | abort(); |
357 | f18cd223 | aurel32 | } |
358 | f18cd223 | aurel32 | tcg_gen_brcondi_i64(TCG_COND_NE, tmp, 0, l1);
|
359 | f18cd223 | aurel32 | tcg_gen_movi_i64(cpu_pc, ctx->pc); |
360 | f18cd223 | aurel32 | tcg_gen_br(l2); |
361 | f18cd223 | aurel32 | gen_set_label(l1); |
362 | f18cd223 | aurel32 | tcg_gen_movi_i64(cpu_pc, ctx->pc + (int64_t)(disp16 << 2));
|
363 | f18cd223 | aurel32 | gen_set_label(l2); |
364 | 4c9649a9 | j_mayer | } |
365 | 4c9649a9 | j_mayer | |
366 | 636aa200 | Blue Swirl | static inline void gen_cmov(TCGCond inv_cond, int ra, int rb, int rc, |
367 | 636aa200 | Blue Swirl | int islit, uint8_t lit, int mask) |
368 | 4c9649a9 | j_mayer | { |
369 | 9c29504e | aurel32 | int l1;
|
370 | 9c29504e | aurel32 | |
371 | 9c29504e | aurel32 | if (unlikely(rc == 31)) |
372 | 9c29504e | aurel32 | return;
|
373 | 9c29504e | aurel32 | |
374 | 9c29504e | aurel32 | l1 = gen_new_label(); |
375 | 9c29504e | aurel32 | |
376 | 9c29504e | aurel32 | if (ra != 31) { |
377 | 9c29504e | aurel32 | if (mask) {
|
378 | a7812ae4 | pbrook | TCGv tmp = tcg_temp_new(); |
379 | 9c29504e | aurel32 | tcg_gen_andi_i64(tmp, cpu_ir[ra], 1);
|
380 | 9c29504e | aurel32 | tcg_gen_brcondi_i64(inv_cond, tmp, 0, l1);
|
381 | 9c29504e | aurel32 | tcg_temp_free(tmp); |
382 | 9c29504e | aurel32 | } else
|
383 | 9c29504e | aurel32 | tcg_gen_brcondi_i64(inv_cond, cpu_ir[ra], 0, l1);
|
384 | 9c29504e | aurel32 | } else {
|
385 | 9c29504e | aurel32 | /* Very uncommon case - Do not bother to optimize. */
|
386 | 9c29504e | aurel32 | TCGv tmp = tcg_const_i64(0);
|
387 | 9c29504e | aurel32 | tcg_gen_brcondi_i64(inv_cond, tmp, 0, l1);
|
388 | 9c29504e | aurel32 | tcg_temp_free(tmp); |
389 | 9c29504e | aurel32 | } |
390 | 9c29504e | aurel32 | |
391 | 4c9649a9 | j_mayer | if (islit)
|
392 | 9c29504e | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], lit); |
393 | 4c9649a9 | j_mayer | else
|
394 | dfaa8583 | aurel32 | tcg_gen_mov_i64(cpu_ir[rc], cpu_ir[rb]); |
395 | 9c29504e | aurel32 | gen_set_label(l1); |
396 | 4c9649a9 | j_mayer | } |
397 | 4c9649a9 | j_mayer | |
398 | a7812ae4 | pbrook | #define FARITH2(name) \
|
399 | 636aa200 | Blue Swirl | static inline void glue(gen_f, name)(int rb, int rc) \ |
400 | a7812ae4 | pbrook | { \ |
401 | a7812ae4 | pbrook | if (unlikely(rc == 31)) \ |
402 | a7812ae4 | pbrook | return; \
|
403 | a7812ae4 | pbrook | \ |
404 | a7812ae4 | pbrook | if (rb != 31) \ |
405 | a7812ae4 | pbrook | gen_helper_ ## name (cpu_fir[rc], cpu_fir[rb]); \ |
406 | a7812ae4 | pbrook | else { \
|
407 | a7812ae4 | pbrook | TCGv tmp = tcg_const_i64(0); \
|
408 | a7812ae4 | pbrook | gen_helper_ ## name (cpu_fir[rc], tmp); \ |
409 | a7812ae4 | pbrook | tcg_temp_free(tmp); \ |
410 | a7812ae4 | pbrook | } \ |
411 | 4c9649a9 | j_mayer | } |
412 | a7812ae4 | pbrook | FARITH2(sqrts) |
413 | a7812ae4 | pbrook | FARITH2(sqrtf) |
414 | a7812ae4 | pbrook | FARITH2(sqrtg) |
415 | a7812ae4 | pbrook | FARITH2(sqrtt) |
416 | a7812ae4 | pbrook | FARITH2(cvtgf) |
417 | a7812ae4 | pbrook | FARITH2(cvtgq) |
418 | a7812ae4 | pbrook | FARITH2(cvtqf) |
419 | a7812ae4 | pbrook | FARITH2(cvtqg) |
420 | a7812ae4 | pbrook | FARITH2(cvtst) |
421 | a7812ae4 | pbrook | FARITH2(cvtts) |
422 | a7812ae4 | pbrook | FARITH2(cvttq) |
423 | a7812ae4 | pbrook | FARITH2(cvtqs) |
424 | a7812ae4 | pbrook | FARITH2(cvtqt) |
425 | a7812ae4 | pbrook | FARITH2(cvtlq) |
426 | a7812ae4 | pbrook | FARITH2(cvtql) |
427 | a7812ae4 | pbrook | FARITH2(cvtqlv) |
428 | a7812ae4 | pbrook | FARITH2(cvtqlsv) |
429 | a7812ae4 | pbrook | |
430 | a7812ae4 | pbrook | #define FARITH3(name) \
|
431 | 636aa200 | Blue Swirl | static inline void glue(gen_f, name)(int ra, int rb, int rc) \ |
432 | a7812ae4 | pbrook | { \ |
433 | a7812ae4 | pbrook | if (unlikely(rc == 31)) \ |
434 | a7812ae4 | pbrook | return; \
|
435 | a7812ae4 | pbrook | \ |
436 | a7812ae4 | pbrook | if (ra != 31) { \ |
437 | a7812ae4 | pbrook | if (rb != 31) \ |
438 | a7812ae4 | pbrook | gen_helper_ ## name (cpu_fir[rc], cpu_fir[ra], cpu_fir[rb]); \ |
439 | a7812ae4 | pbrook | else { \
|
440 | a7812ae4 | pbrook | TCGv tmp = tcg_const_i64(0); \
|
441 | a7812ae4 | pbrook | gen_helper_ ## name (cpu_fir[rc], cpu_fir[ra], tmp); \ |
442 | a7812ae4 | pbrook | tcg_temp_free(tmp); \ |
443 | a7812ae4 | pbrook | } \ |
444 | a7812ae4 | pbrook | } else { \
|
445 | a7812ae4 | pbrook | TCGv tmp = tcg_const_i64(0); \
|
446 | a7812ae4 | pbrook | if (rb != 31) \ |
447 | a7812ae4 | pbrook | gen_helper_ ## name (cpu_fir[rc], tmp, cpu_fir[rb]); \ |
448 | a7812ae4 | pbrook | else \
|
449 | a7812ae4 | pbrook | gen_helper_ ## name (cpu_fir[rc], tmp, tmp); \ |
450 | a7812ae4 | pbrook | tcg_temp_free(tmp); \ |
451 | a7812ae4 | pbrook | } \ |
452 | 4c9649a9 | j_mayer | } |
453 | 4c9649a9 | j_mayer | |
454 | a7812ae4 | pbrook | FARITH3(addf) |
455 | a7812ae4 | pbrook | FARITH3(subf) |
456 | a7812ae4 | pbrook | FARITH3(mulf) |
457 | a7812ae4 | pbrook | FARITH3(divf) |
458 | a7812ae4 | pbrook | FARITH3(addg) |
459 | a7812ae4 | pbrook | FARITH3(subg) |
460 | a7812ae4 | pbrook | FARITH3(mulg) |
461 | a7812ae4 | pbrook | FARITH3(divg) |
462 | a7812ae4 | pbrook | FARITH3(cmpgeq) |
463 | a7812ae4 | pbrook | FARITH3(cmpglt) |
464 | a7812ae4 | pbrook | FARITH3(cmpgle) |
465 | a7812ae4 | pbrook | FARITH3(adds) |
466 | a7812ae4 | pbrook | FARITH3(subs) |
467 | a7812ae4 | pbrook | FARITH3(muls) |
468 | a7812ae4 | pbrook | FARITH3(divs) |
469 | a7812ae4 | pbrook | FARITH3(addt) |
470 | a7812ae4 | pbrook | FARITH3(subt) |
471 | a7812ae4 | pbrook | FARITH3(mult) |
472 | a7812ae4 | pbrook | FARITH3(divt) |
473 | a7812ae4 | pbrook | FARITH3(cmptun) |
474 | a7812ae4 | pbrook | FARITH3(cmpteq) |
475 | a7812ae4 | pbrook | FARITH3(cmptlt) |
476 | a7812ae4 | pbrook | FARITH3(cmptle) |
477 | a7812ae4 | pbrook | FARITH3(cpys) |
478 | a7812ae4 | pbrook | FARITH3(cpysn) |
479 | a7812ae4 | pbrook | FARITH3(cpyse) |
480 | a7812ae4 | pbrook | |
481 | a7812ae4 | pbrook | #define FCMOV(name) \
|
482 | 636aa200 | Blue Swirl | static inline void glue(gen_f, name)(int ra, int rb, int rc) \ |
483 | a7812ae4 | pbrook | { \ |
484 | a7812ae4 | pbrook | int l1; \
|
485 | a7812ae4 | pbrook | TCGv tmp; \ |
486 | a7812ae4 | pbrook | \ |
487 | a7812ae4 | pbrook | if (unlikely(rc == 31)) \ |
488 | a7812ae4 | pbrook | return; \
|
489 | a7812ae4 | pbrook | \ |
490 | a7812ae4 | pbrook | l1 = gen_new_label(); \ |
491 | a7812ae4 | pbrook | tmp = tcg_temp_new(); \ |
492 | a7812ae4 | pbrook | if (ra != 31) { \ |
493 | a7812ae4 | pbrook | tmp = tcg_temp_new(); \ |
494 | a7812ae4 | pbrook | gen_helper_ ## name (tmp, cpu_fir[ra]); \ |
495 | a7812ae4 | pbrook | } else { \
|
496 | a7812ae4 | pbrook | tmp = tcg_const_i64(0); \
|
497 | a7812ae4 | pbrook | gen_helper_ ## name (tmp, tmp); \ |
498 | a7812ae4 | pbrook | } \ |
499 | a7812ae4 | pbrook | tcg_gen_brcondi_i64(TCG_COND_EQ, tmp, 0, l1); \
|
500 | a7812ae4 | pbrook | if (rb != 31) \ |
501 | a7812ae4 | pbrook | tcg_gen_mov_i64(cpu_fir[rc], cpu_fir[ra]); \ |
502 | a7812ae4 | pbrook | else \
|
503 | a7812ae4 | pbrook | tcg_gen_movi_i64(cpu_fir[rc], 0); \
|
504 | a7812ae4 | pbrook | gen_set_label(l1); \ |
505 | 4c9649a9 | j_mayer | } |
506 | a7812ae4 | pbrook | FCMOV(cmpfeq) |
507 | a7812ae4 | pbrook | FCMOV(cmpfne) |
508 | a7812ae4 | pbrook | FCMOV(cmpflt) |
509 | a7812ae4 | pbrook | FCMOV(cmpfge) |
510 | a7812ae4 | pbrook | FCMOV(cmpfle) |
511 | a7812ae4 | pbrook | FCMOV(cmpfgt) |
512 | 4c9649a9 | j_mayer | |
513 | b3249f63 | aurel32 | /* EXTWH, EXTWH, EXTLH, EXTQH */
|
514 | 636aa200 | Blue Swirl | static inline void gen_ext_h(void(*tcg_gen_ext_i64)(TCGv t0, TCGv t1), |
515 | 636aa200 | Blue Swirl | int ra, int rb, int rc, int islit, uint8_t lit) |
516 | b3249f63 | aurel32 | { |
517 | b3249f63 | aurel32 | if (unlikely(rc == 31)) |
518 | b3249f63 | aurel32 | return;
|
519 | b3249f63 | aurel32 | |
520 | b3249f63 | aurel32 | if (ra != 31) { |
521 | dfaa8583 | aurel32 | if (islit) {
|
522 | dfaa8583 | aurel32 | if (lit != 0) |
523 | dfaa8583 | aurel32 | tcg_gen_shli_i64(cpu_ir[rc], cpu_ir[ra], 64 - ((lit & 7) * 8)); |
524 | dfaa8583 | aurel32 | else
|
525 | dfaa8583 | aurel32 | tcg_gen_mov_i64(cpu_ir[rc], cpu_ir[ra]); |
526 | fe2b269a | aurel32 | } else {
|
527 | dbf95805 | Vince Weaver | TCGv tmp1; |
528 | a7812ae4 | pbrook | tmp1 = tcg_temp_new(); |
529 | dbf95805 | Vince Weaver | |
530 | b3249f63 | aurel32 | tcg_gen_andi_i64(tmp1, cpu_ir[rb], 7);
|
531 | b3249f63 | aurel32 | tcg_gen_shli_i64(tmp1, tmp1, 3);
|
532 | dbf95805 | Vince Weaver | tcg_gen_neg_i64(tmp1, tmp1); |
533 | dbf95805 | Vince Weaver | tcg_gen_andi_i64(tmp1, tmp1, 0x3f);
|
534 | dfaa8583 | aurel32 | tcg_gen_shl_i64(cpu_ir[rc], cpu_ir[ra], tmp1); |
535 | dbf95805 | Vince Weaver | |
536 | b3249f63 | aurel32 | tcg_temp_free(tmp1); |
537 | dfaa8583 | aurel32 | } |
538 | dfaa8583 | aurel32 | if (tcg_gen_ext_i64)
|
539 | dfaa8583 | aurel32 | tcg_gen_ext_i64(cpu_ir[rc], cpu_ir[rc]); |
540 | b3249f63 | aurel32 | } else
|
541 | b3249f63 | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], 0);
|
542 | b3249f63 | aurel32 | } |
543 | b3249f63 | aurel32 | |
544 | b3249f63 | aurel32 | /* EXTBL, EXTWL, EXTWL, EXTLL, EXTQL */
|
545 | 636aa200 | Blue Swirl | static inline void gen_ext_l(void(*tcg_gen_ext_i64)(TCGv t0, TCGv t1), |
546 | 636aa200 | Blue Swirl | int ra, int rb, int rc, int islit, uint8_t lit) |
547 | b3249f63 | aurel32 | { |
548 | b3249f63 | aurel32 | if (unlikely(rc == 31)) |
549 | b3249f63 | aurel32 | return;
|
550 | b3249f63 | aurel32 | |
551 | b3249f63 | aurel32 | if (ra != 31) { |
552 | dfaa8583 | aurel32 | if (islit) {
|
553 | dfaa8583 | aurel32 | tcg_gen_shri_i64(cpu_ir[rc], cpu_ir[ra], (lit & 7) * 8); |
554 | dfaa8583 | aurel32 | } else {
|
555 | a7812ae4 | pbrook | TCGv tmp = tcg_temp_new(); |
556 | b3249f63 | aurel32 | tcg_gen_andi_i64(tmp, cpu_ir[rb], 7);
|
557 | b3249f63 | aurel32 | tcg_gen_shli_i64(tmp, tmp, 3);
|
558 | dfaa8583 | aurel32 | tcg_gen_shr_i64(cpu_ir[rc], cpu_ir[ra], tmp); |
559 | b3249f63 | aurel32 | tcg_temp_free(tmp); |
560 | fe2b269a | aurel32 | } |
561 | dfaa8583 | aurel32 | if (tcg_gen_ext_i64)
|
562 | dfaa8583 | aurel32 | tcg_gen_ext_i64(cpu_ir[rc], cpu_ir[rc]); |
563 | b3249f63 | aurel32 | } else
|
564 | b3249f63 | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], 0);
|
565 | b3249f63 | aurel32 | } |
566 | b3249f63 | aurel32 | |
567 | 04acd307 | aurel32 | /* Code to call arith3 helpers */
|
568 | a7812ae4 | pbrook | #define ARITH3(name) \
|
569 | 636aa200 | Blue Swirl | static inline void glue(gen_, name)(int ra, int rb, int rc, int islit,\ |
570 | 636aa200 | Blue Swirl | uint8_t lit) \ |
571 | a7812ae4 | pbrook | { \ |
572 | a7812ae4 | pbrook | if (unlikely(rc == 31)) \ |
573 | a7812ae4 | pbrook | return; \
|
574 | a7812ae4 | pbrook | \ |
575 | a7812ae4 | pbrook | if (ra != 31) { \ |
576 | a7812ae4 | pbrook | if (islit) { \
|
577 | a7812ae4 | pbrook | TCGv tmp = tcg_const_i64(lit); \ |
578 | a7812ae4 | pbrook | gen_helper_ ## name(cpu_ir[rc], cpu_ir[ra], tmp); \ |
579 | a7812ae4 | pbrook | tcg_temp_free(tmp); \ |
580 | a7812ae4 | pbrook | } else \
|
581 | a7812ae4 | pbrook | gen_helper_ ## name (cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]); \ |
582 | a7812ae4 | pbrook | } else { \
|
583 | a7812ae4 | pbrook | TCGv tmp1 = tcg_const_i64(0); \
|
584 | a7812ae4 | pbrook | if (islit) { \
|
585 | a7812ae4 | pbrook | TCGv tmp2 = tcg_const_i64(lit); \ |
586 | a7812ae4 | pbrook | gen_helper_ ## name (cpu_ir[rc], tmp1, tmp2); \ |
587 | a7812ae4 | pbrook | tcg_temp_free(tmp2); \ |
588 | a7812ae4 | pbrook | } else \
|
589 | a7812ae4 | pbrook | gen_helper_ ## name (cpu_ir[rc], tmp1, cpu_ir[rb]); \ |
590 | a7812ae4 | pbrook | tcg_temp_free(tmp1); \ |
591 | a7812ae4 | pbrook | } \ |
592 | b3249f63 | aurel32 | } |
593 | a7812ae4 | pbrook | ARITH3(cmpbge) |
594 | a7812ae4 | pbrook | ARITH3(addlv) |
595 | a7812ae4 | pbrook | ARITH3(sublv) |
596 | a7812ae4 | pbrook | ARITH3(addqv) |
597 | a7812ae4 | pbrook | ARITH3(subqv) |
598 | a7812ae4 | pbrook | ARITH3(mskbl) |
599 | a7812ae4 | pbrook | ARITH3(insbl) |
600 | a7812ae4 | pbrook | ARITH3(mskwl) |
601 | a7812ae4 | pbrook | ARITH3(inswl) |
602 | a7812ae4 | pbrook | ARITH3(mskll) |
603 | a7812ae4 | pbrook | ARITH3(insll) |
604 | a7812ae4 | pbrook | ARITH3(zap) |
605 | a7812ae4 | pbrook | ARITH3(zapnot) |
606 | a7812ae4 | pbrook | ARITH3(mskql) |
607 | a7812ae4 | pbrook | ARITH3(insql) |
608 | a7812ae4 | pbrook | ARITH3(mskwh) |
609 | a7812ae4 | pbrook | ARITH3(inswh) |
610 | a7812ae4 | pbrook | ARITH3(msklh) |
611 | a7812ae4 | pbrook | ARITH3(inslh) |
612 | a7812ae4 | pbrook | ARITH3(mskqh) |
613 | a7812ae4 | pbrook | ARITH3(insqh) |
614 | a7812ae4 | pbrook | ARITH3(umulh) |
615 | a7812ae4 | pbrook | ARITH3(mullv) |
616 | a7812ae4 | pbrook | ARITH3(mulqv) |
617 | b3249f63 | aurel32 | |
618 | 636aa200 | Blue Swirl | static inline void gen_cmp(TCGCond cond, int ra, int rb, int rc, int islit, |
619 | 636aa200 | Blue Swirl | uint8_t lit) |
620 | 01ff9cc8 | aurel32 | { |
621 | 01ff9cc8 | aurel32 | int l1, l2;
|
622 | 01ff9cc8 | aurel32 | TCGv tmp; |
623 | 01ff9cc8 | aurel32 | |
624 | 01ff9cc8 | aurel32 | if (unlikely(rc == 31)) |
625 | 01ff9cc8 | aurel32 | return;
|
626 | 01ff9cc8 | aurel32 | |
627 | 01ff9cc8 | aurel32 | l1 = gen_new_label(); |
628 | 01ff9cc8 | aurel32 | l2 = gen_new_label(); |
629 | 01ff9cc8 | aurel32 | |
630 | 01ff9cc8 | aurel32 | if (ra != 31) { |
631 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
632 | 01ff9cc8 | aurel32 | tcg_gen_mov_i64(tmp, cpu_ir[ra]); |
633 | 01ff9cc8 | aurel32 | } else
|
634 | 01ff9cc8 | aurel32 | tmp = tcg_const_i64(0);
|
635 | 01ff9cc8 | aurel32 | if (islit)
|
636 | 01ff9cc8 | aurel32 | tcg_gen_brcondi_i64(cond, tmp, lit, l1); |
637 | 01ff9cc8 | aurel32 | else
|
638 | dfaa8583 | aurel32 | tcg_gen_brcond_i64(cond, tmp, cpu_ir[rb], l1); |
639 | 01ff9cc8 | aurel32 | |
640 | 01ff9cc8 | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], 0);
|
641 | 01ff9cc8 | aurel32 | tcg_gen_br(l2); |
642 | 01ff9cc8 | aurel32 | gen_set_label(l1); |
643 | 01ff9cc8 | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], 1);
|
644 | 01ff9cc8 | aurel32 | gen_set_label(l2); |
645 | 01ff9cc8 | aurel32 | } |
646 | 01ff9cc8 | aurel32 | |
647 | 636aa200 | Blue Swirl | static inline int translate_one(DisasContext *ctx, uint32_t insn) |
648 | 4c9649a9 | j_mayer | { |
649 | 4c9649a9 | j_mayer | uint32_t palcode; |
650 | 4c9649a9 | j_mayer | int32_t disp21, disp16, disp12; |
651 | 4c9649a9 | j_mayer | uint16_t fn11, fn16; |
652 | 4c9649a9 | j_mayer | uint8_t opc, ra, rb, rc, sbz, fpfn, fn7, fn2, islit; |
653 | adf3c8b6 | aurel32 | uint8_t lit; |
654 | 4c9649a9 | j_mayer | int ret;
|
655 | 4c9649a9 | j_mayer | |
656 | 4c9649a9 | j_mayer | /* Decode all instruction fields */
|
657 | 4c9649a9 | j_mayer | opc = insn >> 26;
|
658 | 4c9649a9 | j_mayer | ra = (insn >> 21) & 0x1F; |
659 | 4c9649a9 | j_mayer | rb = (insn >> 16) & 0x1F; |
660 | 4c9649a9 | j_mayer | rc = insn & 0x1F;
|
661 | 4c9649a9 | j_mayer | sbz = (insn >> 13) & 0x07; |
662 | 4c9649a9 | j_mayer | islit = (insn >> 12) & 1; |
663 | dfaa8583 | aurel32 | if (rb == 31 && !islit) { |
664 | dfaa8583 | aurel32 | islit = 1;
|
665 | dfaa8583 | aurel32 | lit = 0;
|
666 | dfaa8583 | aurel32 | } else
|
667 | dfaa8583 | aurel32 | lit = (insn >> 13) & 0xFF; |
668 | 4c9649a9 | j_mayer | palcode = insn & 0x03FFFFFF;
|
669 | 4c9649a9 | j_mayer | disp21 = ((int32_t)((insn & 0x001FFFFF) << 11)) >> 11; |
670 | 4c9649a9 | j_mayer | disp16 = (int16_t)(insn & 0x0000FFFF);
|
671 | 4c9649a9 | j_mayer | disp12 = (int32_t)((insn & 0x00000FFF) << 20) >> 20; |
672 | 4c9649a9 | j_mayer | fn16 = insn & 0x0000FFFF;
|
673 | 4c9649a9 | j_mayer | fn11 = (insn >> 5) & 0x000007FF; |
674 | 4c9649a9 | j_mayer | fpfn = fn11 & 0x3F;
|
675 | 4c9649a9 | j_mayer | fn7 = (insn >> 5) & 0x0000007F; |
676 | 4c9649a9 | j_mayer | fn2 = (insn >> 5) & 0x00000003; |
677 | 4c9649a9 | j_mayer | ret = 0;
|
678 | d12d51d5 | aliguori | LOG_DISAS("opc %02x ra %d rb %d rc %d disp16 %04x\n",
|
679 | d12d51d5 | aliguori | opc, ra, rb, rc, disp16); |
680 | 4c9649a9 | j_mayer | switch (opc) {
|
681 | 4c9649a9 | j_mayer | case 0x00: |
682 | 4c9649a9 | j_mayer | /* CALL_PAL */
|
683 | 4c9649a9 | j_mayer | if (palcode >= 0x80 && palcode < 0xC0) { |
684 | 4c9649a9 | j_mayer | /* Unprivileged PAL call */
|
685 | 31a877f2 | aurel32 | gen_excp(ctx, EXCP_CALL_PAL + ((palcode & 0x3F) << 6), 0); |
686 | 4c9649a9 | j_mayer | #if !defined (CONFIG_USER_ONLY)
|
687 | 4c9649a9 | j_mayer | } else if (palcode < 0x40) { |
688 | 4c9649a9 | j_mayer | /* Privileged PAL code */
|
689 | 4c9649a9 | j_mayer | if (ctx->mem_idx & 1) |
690 | 4c9649a9 | j_mayer | goto invalid_opc;
|
691 | 4c9649a9 | j_mayer | else
|
692 | e79ab941 | aurel32 | gen_excp(ctx, EXCP_CALL_PALP + ((palcode & 0x3F) << 6), 0); |
693 | 4c9649a9 | j_mayer | #endif
|
694 | 4c9649a9 | j_mayer | } else {
|
695 | 4c9649a9 | j_mayer | /* Invalid PAL call */
|
696 | 4c9649a9 | j_mayer | goto invalid_opc;
|
697 | 4c9649a9 | j_mayer | } |
698 | 4c9649a9 | j_mayer | ret = 3;
|
699 | 4c9649a9 | j_mayer | break;
|
700 | 4c9649a9 | j_mayer | case 0x01: |
701 | 4c9649a9 | j_mayer | /* OPC01 */
|
702 | 4c9649a9 | j_mayer | goto invalid_opc;
|
703 | 4c9649a9 | j_mayer | case 0x02: |
704 | 4c9649a9 | j_mayer | /* OPC02 */
|
705 | 4c9649a9 | j_mayer | goto invalid_opc;
|
706 | 4c9649a9 | j_mayer | case 0x03: |
707 | 4c9649a9 | j_mayer | /* OPC03 */
|
708 | 4c9649a9 | j_mayer | goto invalid_opc;
|
709 | 4c9649a9 | j_mayer | case 0x04: |
710 | 4c9649a9 | j_mayer | /* OPC04 */
|
711 | 4c9649a9 | j_mayer | goto invalid_opc;
|
712 | 4c9649a9 | j_mayer | case 0x05: |
713 | 4c9649a9 | j_mayer | /* OPC05 */
|
714 | 4c9649a9 | j_mayer | goto invalid_opc;
|
715 | 4c9649a9 | j_mayer | case 0x06: |
716 | 4c9649a9 | j_mayer | /* OPC06 */
|
717 | 4c9649a9 | j_mayer | goto invalid_opc;
|
718 | 4c9649a9 | j_mayer | case 0x07: |
719 | 4c9649a9 | j_mayer | /* OPC07 */
|
720 | 4c9649a9 | j_mayer | goto invalid_opc;
|
721 | 4c9649a9 | j_mayer | case 0x08: |
722 | 4c9649a9 | j_mayer | /* LDA */
|
723 | 1ef4ef4e | aurel32 | if (likely(ra != 31)) { |
724 | 496cb5b9 | aurel32 | if (rb != 31) |
725 | 3761035f | aurel32 | tcg_gen_addi_i64(cpu_ir[ra], cpu_ir[rb], disp16); |
726 | 3761035f | aurel32 | else
|
727 | 3761035f | aurel32 | tcg_gen_movi_i64(cpu_ir[ra], disp16); |
728 | 496cb5b9 | aurel32 | } |
729 | 4c9649a9 | j_mayer | break;
|
730 | 4c9649a9 | j_mayer | case 0x09: |
731 | 4c9649a9 | j_mayer | /* LDAH */
|
732 | 1ef4ef4e | aurel32 | if (likely(ra != 31)) { |
733 | 496cb5b9 | aurel32 | if (rb != 31) |
734 | 3761035f | aurel32 | tcg_gen_addi_i64(cpu_ir[ra], cpu_ir[rb], disp16 << 16);
|
735 | 3761035f | aurel32 | else
|
736 | 3761035f | aurel32 | tcg_gen_movi_i64(cpu_ir[ra], disp16 << 16);
|
737 | 496cb5b9 | aurel32 | } |
738 | 4c9649a9 | j_mayer | break;
|
739 | 4c9649a9 | j_mayer | case 0x0A: |
740 | 4c9649a9 | j_mayer | /* LDBU */
|
741 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_BWX))
|
742 | 4c9649a9 | j_mayer | goto invalid_opc;
|
743 | f18cd223 | aurel32 | gen_load_mem(ctx, &tcg_gen_qemu_ld8u, ra, rb, disp16, 0, 0); |
744 | 4c9649a9 | j_mayer | break;
|
745 | 4c9649a9 | j_mayer | case 0x0B: |
746 | 4c9649a9 | j_mayer | /* LDQ_U */
|
747 | f18cd223 | aurel32 | gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 0, 1); |
748 | 4c9649a9 | j_mayer | break;
|
749 | 4c9649a9 | j_mayer | case 0x0C: |
750 | 4c9649a9 | j_mayer | /* LDWU */
|
751 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_BWX))
|
752 | 4c9649a9 | j_mayer | goto invalid_opc;
|
753 | 577d5e7f | aurel32 | gen_load_mem(ctx, &tcg_gen_qemu_ld16u, ra, rb, disp16, 0, 0); |
754 | 4c9649a9 | j_mayer | break;
|
755 | 4c9649a9 | j_mayer | case 0x0D: |
756 | 4c9649a9 | j_mayer | /* STW */
|
757 | 57a92c8e | aurel32 | gen_store_mem(ctx, &tcg_gen_qemu_st16, ra, rb, disp16, 0, 0, 0); |
758 | 4c9649a9 | j_mayer | break;
|
759 | 4c9649a9 | j_mayer | case 0x0E: |
760 | 4c9649a9 | j_mayer | /* STB */
|
761 | 57a92c8e | aurel32 | gen_store_mem(ctx, &tcg_gen_qemu_st8, ra, rb, disp16, 0, 0, 0); |
762 | 4c9649a9 | j_mayer | break;
|
763 | 4c9649a9 | j_mayer | case 0x0F: |
764 | 4c9649a9 | j_mayer | /* STQ_U */
|
765 | 57a92c8e | aurel32 | gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 0, 1, 0); |
766 | 4c9649a9 | j_mayer | break;
|
767 | 4c9649a9 | j_mayer | case 0x10: |
768 | 4c9649a9 | j_mayer | switch (fn7) {
|
769 | 4c9649a9 | j_mayer | case 0x00: |
770 | 4c9649a9 | j_mayer | /* ADDL */
|
771 | 30c7183b | aurel32 | if (likely(rc != 31)) { |
772 | 30c7183b | aurel32 | if (ra != 31) { |
773 | 30c7183b | aurel32 | if (islit) {
|
774 | 30c7183b | aurel32 | tcg_gen_addi_i64(cpu_ir[rc], cpu_ir[ra], lit); |
775 | 30c7183b | aurel32 | tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rc]); |
776 | dfaa8583 | aurel32 | } else {
|
777 | 30c7183b | aurel32 | tcg_gen_add_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]); |
778 | 30c7183b | aurel32 | tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rc]); |
779 | dfaa8583 | aurel32 | } |
780 | 30c7183b | aurel32 | } else {
|
781 | 30c7183b | aurel32 | if (islit)
|
782 | dfaa8583 | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], lit); |
783 | 30c7183b | aurel32 | else
|
784 | dfaa8583 | aurel32 | tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rb]); |
785 | 30c7183b | aurel32 | } |
786 | 30c7183b | aurel32 | } |
787 | 4c9649a9 | j_mayer | break;
|
788 | 4c9649a9 | j_mayer | case 0x02: |
789 | 4c9649a9 | j_mayer | /* S4ADDL */
|
790 | 30c7183b | aurel32 | if (likely(rc != 31)) { |
791 | 30c7183b | aurel32 | if (ra != 31) { |
792 | a7812ae4 | pbrook | TCGv tmp = tcg_temp_new(); |
793 | dfaa8583 | aurel32 | tcg_gen_shli_i64(tmp, cpu_ir[ra], 2);
|
794 | dfaa8583 | aurel32 | if (islit)
|
795 | dfaa8583 | aurel32 | tcg_gen_addi_i64(tmp, tmp, lit); |
796 | dfaa8583 | aurel32 | else
|
797 | dfaa8583 | aurel32 | tcg_gen_add_i64(tmp, tmp, cpu_ir[rb]); |
798 | dfaa8583 | aurel32 | tcg_gen_ext32s_i64(cpu_ir[rc], tmp); |
799 | dfaa8583 | aurel32 | tcg_temp_free(tmp); |
800 | 30c7183b | aurel32 | } else {
|
801 | 30c7183b | aurel32 | if (islit)
|
802 | 30c7183b | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], lit); |
803 | 30c7183b | aurel32 | else
|
804 | dfaa8583 | aurel32 | tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rb]); |
805 | 30c7183b | aurel32 | } |
806 | 30c7183b | aurel32 | } |
807 | 4c9649a9 | j_mayer | break;
|
808 | 4c9649a9 | j_mayer | case 0x09: |
809 | 4c9649a9 | j_mayer | /* SUBL */
|
810 | 30c7183b | aurel32 | if (likely(rc != 31)) { |
811 | 30c7183b | aurel32 | if (ra != 31) { |
812 | dfaa8583 | aurel32 | if (islit)
|
813 | 30c7183b | aurel32 | tcg_gen_subi_i64(cpu_ir[rc], cpu_ir[ra], lit); |
814 | dfaa8583 | aurel32 | else
|
815 | 30c7183b | aurel32 | tcg_gen_sub_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]); |
816 | dfaa8583 | aurel32 | tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rc]); |
817 | 30c7183b | aurel32 | } else {
|
818 | 30c7183b | aurel32 | if (islit)
|
819 | 30c7183b | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], -lit); |
820 | dfaa8583 | aurel32 | else {
|
821 | 30c7183b | aurel32 | tcg_gen_neg_i64(cpu_ir[rc], cpu_ir[rb]); |
822 | 30c7183b | aurel32 | tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rc]); |
823 | 30c7183b | aurel32 | } |
824 | 30c7183b | aurel32 | } |
825 | 4c9649a9 | j_mayer | break;
|
826 | 4c9649a9 | j_mayer | case 0x0B: |
827 | 4c9649a9 | j_mayer | /* S4SUBL */
|
828 | 30c7183b | aurel32 | if (likely(rc != 31)) { |
829 | 30c7183b | aurel32 | if (ra != 31) { |
830 | a7812ae4 | pbrook | TCGv tmp = tcg_temp_new(); |
831 | dfaa8583 | aurel32 | tcg_gen_shli_i64(tmp, cpu_ir[ra], 2);
|
832 | dfaa8583 | aurel32 | if (islit)
|
833 | dfaa8583 | aurel32 | tcg_gen_subi_i64(tmp, tmp, lit); |
834 | dfaa8583 | aurel32 | else
|
835 | dfaa8583 | aurel32 | tcg_gen_sub_i64(tmp, tmp, cpu_ir[rb]); |
836 | dfaa8583 | aurel32 | tcg_gen_ext32s_i64(cpu_ir[rc], tmp); |
837 | dfaa8583 | aurel32 | tcg_temp_free(tmp); |
838 | 30c7183b | aurel32 | } else {
|
839 | 30c7183b | aurel32 | if (islit)
|
840 | 30c7183b | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], -lit); |
841 | dfaa8583 | aurel32 | else {
|
842 | 30c7183b | aurel32 | tcg_gen_neg_i64(cpu_ir[rc], cpu_ir[rb]); |
843 | 30c7183b | aurel32 | tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rc]); |
844 | dfaa8583 | aurel32 | } |
845 | 30c7183b | aurel32 | } |
846 | 30c7183b | aurel32 | } |
847 | 4c9649a9 | j_mayer | break;
|
848 | 4c9649a9 | j_mayer | case 0x0F: |
849 | 4c9649a9 | j_mayer | /* CMPBGE */
|
850 | a7812ae4 | pbrook | gen_cmpbge(ra, rb, rc, islit, lit); |
851 | 4c9649a9 | j_mayer | break;
|
852 | 4c9649a9 | j_mayer | case 0x12: |
853 | 4c9649a9 | j_mayer | /* S8ADDL */
|
854 | 30c7183b | aurel32 | if (likely(rc != 31)) { |
855 | 30c7183b | aurel32 | if (ra != 31) { |
856 | a7812ae4 | pbrook | TCGv tmp = tcg_temp_new(); |
857 | dfaa8583 | aurel32 | tcg_gen_shli_i64(tmp, cpu_ir[ra], 3);
|
858 | dfaa8583 | aurel32 | if (islit)
|
859 | dfaa8583 | aurel32 | tcg_gen_addi_i64(tmp, tmp, lit); |
860 | dfaa8583 | aurel32 | else
|
861 | dfaa8583 | aurel32 | tcg_gen_add_i64(tmp, tmp, cpu_ir[rb]); |
862 | dfaa8583 | aurel32 | tcg_gen_ext32s_i64(cpu_ir[rc], tmp); |
863 | dfaa8583 | aurel32 | tcg_temp_free(tmp); |
864 | 30c7183b | aurel32 | } else {
|
865 | 30c7183b | aurel32 | if (islit)
|
866 | 30c7183b | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], lit); |
867 | 30c7183b | aurel32 | else
|
868 | dfaa8583 | aurel32 | tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rb]); |
869 | 30c7183b | aurel32 | } |
870 | 30c7183b | aurel32 | } |
871 | 4c9649a9 | j_mayer | break;
|
872 | 4c9649a9 | j_mayer | case 0x1B: |
873 | 4c9649a9 | j_mayer | /* S8SUBL */
|
874 | 30c7183b | aurel32 | if (likely(rc != 31)) { |
875 | 30c7183b | aurel32 | if (ra != 31) { |
876 | a7812ae4 | pbrook | TCGv tmp = tcg_temp_new(); |
877 | dfaa8583 | aurel32 | tcg_gen_shli_i64(tmp, cpu_ir[ra], 3);
|
878 | dfaa8583 | aurel32 | if (islit)
|
879 | dfaa8583 | aurel32 | tcg_gen_subi_i64(tmp, tmp, lit); |
880 | dfaa8583 | aurel32 | else
|
881 | dfaa8583 | aurel32 | tcg_gen_sub_i64(tmp, tmp, cpu_ir[rb]); |
882 | dfaa8583 | aurel32 | tcg_gen_ext32s_i64(cpu_ir[rc], tmp); |
883 | dfaa8583 | aurel32 | tcg_temp_free(tmp); |
884 | 30c7183b | aurel32 | } else {
|
885 | 30c7183b | aurel32 | if (islit)
|
886 | 30c7183b | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], -lit); |
887 | dfaa8583 | aurel32 | else
|
888 | 30c7183b | aurel32 | tcg_gen_neg_i64(cpu_ir[rc], cpu_ir[rb]); |
889 | 30c7183b | aurel32 | tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rc]); |
890 | dfaa8583 | aurel32 | } |
891 | 30c7183b | aurel32 | } |
892 | 30c7183b | aurel32 | } |
893 | 4c9649a9 | j_mayer | break;
|
894 | 4c9649a9 | j_mayer | case 0x1D: |
895 | 4c9649a9 | j_mayer | /* CMPULT */
|
896 | 01ff9cc8 | aurel32 | gen_cmp(TCG_COND_LTU, ra, rb, rc, islit, lit); |
897 | 4c9649a9 | j_mayer | break;
|
898 | 4c9649a9 | j_mayer | case 0x20: |
899 | 4c9649a9 | j_mayer | /* ADDQ */
|
900 | 30c7183b | aurel32 | if (likely(rc != 31)) { |
901 | 30c7183b | aurel32 | if (ra != 31) { |
902 | 30c7183b | aurel32 | if (islit)
|
903 | 30c7183b | aurel32 | tcg_gen_addi_i64(cpu_ir[rc], cpu_ir[ra], lit); |
904 | 30c7183b | aurel32 | else
|
905 | dfaa8583 | aurel32 | tcg_gen_add_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]); |
906 | 30c7183b | aurel32 | } else {
|
907 | 30c7183b | aurel32 | if (islit)
|
908 | 30c7183b | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], lit); |
909 | 30c7183b | aurel32 | else
|
910 | dfaa8583 | aurel32 | tcg_gen_mov_i64(cpu_ir[rc], cpu_ir[rb]); |
911 | 30c7183b | aurel32 | } |
912 | 30c7183b | aurel32 | } |
913 | 4c9649a9 | j_mayer | break;
|
914 | 4c9649a9 | j_mayer | case 0x22: |
915 | 4c9649a9 | j_mayer | /* S4ADDQ */
|
916 | 30c7183b | aurel32 | if (likely(rc != 31)) { |
917 | 30c7183b | aurel32 | if (ra != 31) { |
918 | a7812ae4 | pbrook | TCGv tmp = tcg_temp_new(); |
919 | dfaa8583 | aurel32 | tcg_gen_shli_i64(tmp, cpu_ir[ra], 2);
|
920 | dfaa8583 | aurel32 | if (islit)
|
921 | dfaa8583 | aurel32 | tcg_gen_addi_i64(cpu_ir[rc], tmp, lit); |
922 | dfaa8583 | aurel32 | else
|
923 | dfaa8583 | aurel32 | tcg_gen_add_i64(cpu_ir[rc], tmp, cpu_ir[rb]); |
924 | dfaa8583 | aurel32 | tcg_temp_free(tmp); |
925 | 30c7183b | aurel32 | } else {
|
926 | 30c7183b | aurel32 | if (islit)
|
927 | 30c7183b | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], lit); |
928 | 30c7183b | aurel32 | else
|
929 | dfaa8583 | aurel32 | tcg_gen_mov_i64(cpu_ir[rc], cpu_ir[rb]); |
930 | 30c7183b | aurel32 | } |
931 | 30c7183b | aurel32 | } |
932 | 4c9649a9 | j_mayer | break;
|
933 | 4c9649a9 | j_mayer | case 0x29: |
934 | 4c9649a9 | j_mayer | /* SUBQ */
|
935 | 30c7183b | aurel32 | if (likely(rc != 31)) { |
936 | 30c7183b | aurel32 | if (ra != 31) { |
937 | 30c7183b | aurel32 | if (islit)
|
938 | 30c7183b | aurel32 | tcg_gen_subi_i64(cpu_ir[rc], cpu_ir[ra], lit); |
939 | 30c7183b | aurel32 | else
|
940 | dfaa8583 | aurel32 | tcg_gen_sub_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]); |
941 | 30c7183b | aurel32 | } else {
|
942 | 30c7183b | aurel32 | if (islit)
|
943 | 30c7183b | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], -lit); |
944 | 30c7183b | aurel32 | else
|
945 | dfaa8583 | aurel32 | tcg_gen_neg_i64(cpu_ir[rc], cpu_ir[rb]); |
946 | 30c7183b | aurel32 | } |
947 | 30c7183b | aurel32 | } |
948 | 4c9649a9 | j_mayer | break;
|
949 | 4c9649a9 | j_mayer | case 0x2B: |
950 | 4c9649a9 | j_mayer | /* S4SUBQ */
|
951 | 30c7183b | aurel32 | if (likely(rc != 31)) { |
952 | 30c7183b | aurel32 | if (ra != 31) { |
953 | a7812ae4 | pbrook | TCGv tmp = tcg_temp_new(); |
954 | dfaa8583 | aurel32 | tcg_gen_shli_i64(tmp, cpu_ir[ra], 2);
|
955 | dfaa8583 | aurel32 | if (islit)
|
956 | dfaa8583 | aurel32 | tcg_gen_subi_i64(cpu_ir[rc], tmp, lit); |
957 | dfaa8583 | aurel32 | else
|
958 | dfaa8583 | aurel32 | tcg_gen_sub_i64(cpu_ir[rc], tmp, cpu_ir[rb]); |
959 | dfaa8583 | aurel32 | tcg_temp_free(tmp); |
960 | 30c7183b | aurel32 | } else {
|
961 | 30c7183b | aurel32 | if (islit)
|
962 | 30c7183b | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], -lit); |
963 | 30c7183b | aurel32 | else
|
964 | dfaa8583 | aurel32 | tcg_gen_neg_i64(cpu_ir[rc], cpu_ir[rb]); |
965 | 30c7183b | aurel32 | } |
966 | 30c7183b | aurel32 | } |
967 | 4c9649a9 | j_mayer | break;
|
968 | 4c9649a9 | j_mayer | case 0x2D: |
969 | 4c9649a9 | j_mayer | /* CMPEQ */
|
970 | 01ff9cc8 | aurel32 | gen_cmp(TCG_COND_EQ, ra, rb, rc, islit, lit); |
971 | 4c9649a9 | j_mayer | break;
|
972 | 4c9649a9 | j_mayer | case 0x32: |
973 | 4c9649a9 | j_mayer | /* S8ADDQ */
|
974 | 30c7183b | aurel32 | if (likely(rc != 31)) { |
975 | 30c7183b | aurel32 | if (ra != 31) { |
976 | a7812ae4 | pbrook | TCGv tmp = tcg_temp_new(); |
977 | dfaa8583 | aurel32 | tcg_gen_shli_i64(tmp, cpu_ir[ra], 3);
|
978 | dfaa8583 | aurel32 | if (islit)
|
979 | dfaa8583 | aurel32 | tcg_gen_addi_i64(cpu_ir[rc], tmp, lit); |
980 | dfaa8583 | aurel32 | else
|
981 | dfaa8583 | aurel32 | tcg_gen_add_i64(cpu_ir[rc], tmp, cpu_ir[rb]); |
982 | dfaa8583 | aurel32 | tcg_temp_free(tmp); |
983 | 30c7183b | aurel32 | } else {
|
984 | 30c7183b | aurel32 | if (islit)
|
985 | 30c7183b | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], lit); |
986 | 30c7183b | aurel32 | else
|
987 | dfaa8583 | aurel32 | tcg_gen_mov_i64(cpu_ir[rc], cpu_ir[rb]); |
988 | 30c7183b | aurel32 | } |
989 | 30c7183b | aurel32 | } |
990 | 4c9649a9 | j_mayer | break;
|
991 | 4c9649a9 | j_mayer | case 0x3B: |
992 | 4c9649a9 | j_mayer | /* S8SUBQ */
|
993 | 30c7183b | aurel32 | if (likely(rc != 31)) { |
994 | 30c7183b | aurel32 | if (ra != 31) { |
995 | a7812ae4 | pbrook | TCGv tmp = tcg_temp_new(); |
996 | dfaa8583 | aurel32 | tcg_gen_shli_i64(tmp, cpu_ir[ra], 3);
|
997 | dfaa8583 | aurel32 | if (islit)
|
998 | dfaa8583 | aurel32 | tcg_gen_subi_i64(cpu_ir[rc], tmp, lit); |
999 | dfaa8583 | aurel32 | else
|
1000 | dfaa8583 | aurel32 | tcg_gen_sub_i64(cpu_ir[rc], tmp, cpu_ir[rb]); |
1001 | dfaa8583 | aurel32 | tcg_temp_free(tmp); |
1002 | 30c7183b | aurel32 | } else {
|
1003 | 30c7183b | aurel32 | if (islit)
|
1004 | 30c7183b | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], -lit); |
1005 | 30c7183b | aurel32 | else
|
1006 | dfaa8583 | aurel32 | tcg_gen_neg_i64(cpu_ir[rc], cpu_ir[rb]); |
1007 | 30c7183b | aurel32 | } |
1008 | 30c7183b | aurel32 | } |
1009 | 4c9649a9 | j_mayer | break;
|
1010 | 4c9649a9 | j_mayer | case 0x3D: |
1011 | 4c9649a9 | j_mayer | /* CMPULE */
|
1012 | 01ff9cc8 | aurel32 | gen_cmp(TCG_COND_LEU, ra, rb, rc, islit, lit); |
1013 | 4c9649a9 | j_mayer | break;
|
1014 | 4c9649a9 | j_mayer | case 0x40: |
1015 | 4c9649a9 | j_mayer | /* ADDL/V */
|
1016 | a7812ae4 | pbrook | gen_addlv(ra, rb, rc, islit, lit); |
1017 | 4c9649a9 | j_mayer | break;
|
1018 | 4c9649a9 | j_mayer | case 0x49: |
1019 | 4c9649a9 | j_mayer | /* SUBL/V */
|
1020 | a7812ae4 | pbrook | gen_sublv(ra, rb, rc, islit, lit); |
1021 | 4c9649a9 | j_mayer | break;
|
1022 | 4c9649a9 | j_mayer | case 0x4D: |
1023 | 4c9649a9 | j_mayer | /* CMPLT */
|
1024 | 01ff9cc8 | aurel32 | gen_cmp(TCG_COND_LT, ra, rb, rc, islit, lit); |
1025 | 4c9649a9 | j_mayer | break;
|
1026 | 4c9649a9 | j_mayer | case 0x60: |
1027 | 4c9649a9 | j_mayer | /* ADDQ/V */
|
1028 | a7812ae4 | pbrook | gen_addqv(ra, rb, rc, islit, lit); |
1029 | 4c9649a9 | j_mayer | break;
|
1030 | 4c9649a9 | j_mayer | case 0x69: |
1031 | 4c9649a9 | j_mayer | /* SUBQ/V */
|
1032 | a7812ae4 | pbrook | gen_subqv(ra, rb, rc, islit, lit); |
1033 | 4c9649a9 | j_mayer | break;
|
1034 | 4c9649a9 | j_mayer | case 0x6D: |
1035 | 4c9649a9 | j_mayer | /* CMPLE */
|
1036 | 01ff9cc8 | aurel32 | gen_cmp(TCG_COND_LE, ra, rb, rc, islit, lit); |
1037 | 4c9649a9 | j_mayer | break;
|
1038 | 4c9649a9 | j_mayer | default:
|
1039 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1040 | 4c9649a9 | j_mayer | } |
1041 | 4c9649a9 | j_mayer | break;
|
1042 | 4c9649a9 | j_mayer | case 0x11: |
1043 | 4c9649a9 | j_mayer | switch (fn7) {
|
1044 | 4c9649a9 | j_mayer | case 0x00: |
1045 | 4c9649a9 | j_mayer | /* AND */
|
1046 | 30c7183b | aurel32 | if (likely(rc != 31)) { |
1047 | dfaa8583 | aurel32 | if (ra == 31) |
1048 | 30c7183b | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], 0);
|
1049 | 30c7183b | aurel32 | else if (islit) |
1050 | 30c7183b | aurel32 | tcg_gen_andi_i64(cpu_ir[rc], cpu_ir[ra], lit); |
1051 | 30c7183b | aurel32 | else
|
1052 | 30c7183b | aurel32 | tcg_gen_and_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]); |
1053 | 30c7183b | aurel32 | } |
1054 | 4c9649a9 | j_mayer | break;
|
1055 | 4c9649a9 | j_mayer | case 0x08: |
1056 | 4c9649a9 | j_mayer | /* BIC */
|
1057 | 30c7183b | aurel32 | if (likely(rc != 31)) { |
1058 | 30c7183b | aurel32 | if (ra != 31) { |
1059 | 30c7183b | aurel32 | if (islit)
|
1060 | 30c7183b | aurel32 | tcg_gen_andi_i64(cpu_ir[rc], cpu_ir[ra], ~lit); |
1061 | 1b581c44 | aurel32 | else
|
1062 | 1b581c44 | aurel32 | tcg_gen_andc_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]); |
1063 | 30c7183b | aurel32 | } else
|
1064 | 30c7183b | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], 0);
|
1065 | 30c7183b | aurel32 | } |
1066 | 4c9649a9 | j_mayer | break;
|
1067 | 4c9649a9 | j_mayer | case 0x14: |
1068 | 4c9649a9 | j_mayer | /* CMOVLBS */
|
1069 | fe2b269a | aurel32 | gen_cmov(TCG_COND_EQ, ra, rb, rc, islit, lit, 1);
|
1070 | 4c9649a9 | j_mayer | break;
|
1071 | 4c9649a9 | j_mayer | case 0x16: |
1072 | 4c9649a9 | j_mayer | /* CMOVLBC */
|
1073 | fe2b269a | aurel32 | gen_cmov(TCG_COND_NE, ra, rb, rc, islit, lit, 1);
|
1074 | 4c9649a9 | j_mayer | break;
|
1075 | 4c9649a9 | j_mayer | case 0x20: |
1076 | 4c9649a9 | j_mayer | /* BIS */
|
1077 | 30c7183b | aurel32 | if (likely(rc != 31)) { |
1078 | 30c7183b | aurel32 | if (ra != 31) { |
1079 | 30c7183b | aurel32 | if (islit)
|
1080 | 30c7183b | aurel32 | tcg_gen_ori_i64(cpu_ir[rc], cpu_ir[ra], lit); |
1081 | 8bb6e981 | aurel32 | else
|
1082 | 30c7183b | aurel32 | tcg_gen_or_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]); |
1083 | 4c9649a9 | j_mayer | } else {
|
1084 | 30c7183b | aurel32 | if (islit)
|
1085 | 30c7183b | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], lit); |
1086 | 30c7183b | aurel32 | else
|
1087 | dfaa8583 | aurel32 | tcg_gen_mov_i64(cpu_ir[rc], cpu_ir[rb]); |
1088 | 4c9649a9 | j_mayer | } |
1089 | 4c9649a9 | j_mayer | } |
1090 | 4c9649a9 | j_mayer | break;
|
1091 | 4c9649a9 | j_mayer | case 0x24: |
1092 | 4c9649a9 | j_mayer | /* CMOVEQ */
|
1093 | fe2b269a | aurel32 | gen_cmov(TCG_COND_NE, ra, rb, rc, islit, lit, 0);
|
1094 | 4c9649a9 | j_mayer | break;
|
1095 | 4c9649a9 | j_mayer | case 0x26: |
1096 | 4c9649a9 | j_mayer | /* CMOVNE */
|
1097 | fe2b269a | aurel32 | gen_cmov(TCG_COND_EQ, ra, rb, rc, islit, lit, 0);
|
1098 | 4c9649a9 | j_mayer | break;
|
1099 | 4c9649a9 | j_mayer | case 0x28: |
1100 | 4c9649a9 | j_mayer | /* ORNOT */
|
1101 | 30c7183b | aurel32 | if (likely(rc != 31)) { |
1102 | dfaa8583 | aurel32 | if (ra != 31) { |
1103 | 30c7183b | aurel32 | if (islit)
|
1104 | 30c7183b | aurel32 | tcg_gen_ori_i64(cpu_ir[rc], cpu_ir[ra], ~lit); |
1105 | 1b581c44 | aurel32 | else
|
1106 | 1b581c44 | aurel32 | tcg_gen_orc_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]); |
1107 | 30c7183b | aurel32 | } else {
|
1108 | 30c7183b | aurel32 | if (islit)
|
1109 | 30c7183b | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], ~lit); |
1110 | 30c7183b | aurel32 | else
|
1111 | 30c7183b | aurel32 | tcg_gen_not_i64(cpu_ir[rc], cpu_ir[rb]); |
1112 | 30c7183b | aurel32 | } |
1113 | 30c7183b | aurel32 | } |
1114 | 4c9649a9 | j_mayer | break;
|
1115 | 4c9649a9 | j_mayer | case 0x40: |
1116 | 4c9649a9 | j_mayer | /* XOR */
|
1117 | 30c7183b | aurel32 | if (likely(rc != 31)) { |
1118 | 30c7183b | aurel32 | if (ra != 31) { |
1119 | 30c7183b | aurel32 | if (islit)
|
1120 | 30c7183b | aurel32 | tcg_gen_xori_i64(cpu_ir[rc], cpu_ir[ra], lit); |
1121 | 30c7183b | aurel32 | else
|
1122 | dfaa8583 | aurel32 | tcg_gen_xor_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]); |
1123 | 30c7183b | aurel32 | } else {
|
1124 | 30c7183b | aurel32 | if (islit)
|
1125 | 30c7183b | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], lit); |
1126 | 30c7183b | aurel32 | else
|
1127 | dfaa8583 | aurel32 | tcg_gen_mov_i64(cpu_ir[rc], cpu_ir[rb]); |
1128 | 30c7183b | aurel32 | } |
1129 | 30c7183b | aurel32 | } |
1130 | 4c9649a9 | j_mayer | break;
|
1131 | 4c9649a9 | j_mayer | case 0x44: |
1132 | 4c9649a9 | j_mayer | /* CMOVLT */
|
1133 | fe2b269a | aurel32 | gen_cmov(TCG_COND_GE, ra, rb, rc, islit, lit, 0);
|
1134 | 4c9649a9 | j_mayer | break;
|
1135 | 4c9649a9 | j_mayer | case 0x46: |
1136 | 4c9649a9 | j_mayer | /* CMOVGE */
|
1137 | fe2b269a | aurel32 | gen_cmov(TCG_COND_LT, ra, rb, rc, islit, lit, 0);
|
1138 | 4c9649a9 | j_mayer | break;
|
1139 | 4c9649a9 | j_mayer | case 0x48: |
1140 | 4c9649a9 | j_mayer | /* EQV */
|
1141 | 30c7183b | aurel32 | if (likely(rc != 31)) { |
1142 | 30c7183b | aurel32 | if (ra != 31) { |
1143 | 30c7183b | aurel32 | if (islit)
|
1144 | 30c7183b | aurel32 | tcg_gen_xori_i64(cpu_ir[rc], cpu_ir[ra], ~lit); |
1145 | 1b581c44 | aurel32 | else
|
1146 | 1b581c44 | aurel32 | tcg_gen_eqv_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]); |
1147 | 30c7183b | aurel32 | } else {
|
1148 | 30c7183b | aurel32 | if (islit)
|
1149 | 30c7183b | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], ~lit); |
1150 | 30c7183b | aurel32 | else
|
1151 | dfaa8583 | aurel32 | tcg_gen_not_i64(cpu_ir[rc], cpu_ir[rb]); |
1152 | 30c7183b | aurel32 | } |
1153 | 30c7183b | aurel32 | } |
1154 | 4c9649a9 | j_mayer | break;
|
1155 | 4c9649a9 | j_mayer | case 0x61: |
1156 | 4c9649a9 | j_mayer | /* AMASK */
|
1157 | ae8ecd42 | aurel32 | if (likely(rc != 31)) { |
1158 | ae8ecd42 | aurel32 | if (islit)
|
1159 | 1a1f7dbc | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], lit); |
1160 | ae8ecd42 | aurel32 | else
|
1161 | 1a1f7dbc | aurel32 | tcg_gen_mov_i64(cpu_ir[rc], cpu_ir[rb]); |
1162 | 1a1f7dbc | aurel32 | switch (ctx->env->implver) {
|
1163 | 1a1f7dbc | aurel32 | case IMPLVER_2106x:
|
1164 | 1a1f7dbc | aurel32 | /* EV4, EV45, LCA, LCA45 & EV5 */
|
1165 | 1a1f7dbc | aurel32 | break;
|
1166 | 1a1f7dbc | aurel32 | case IMPLVER_21164:
|
1167 | 1a1f7dbc | aurel32 | case IMPLVER_21264:
|
1168 | 1a1f7dbc | aurel32 | case IMPLVER_21364:
|
1169 | 1a1f7dbc | aurel32 | tcg_gen_andi_i64(cpu_ir[rc], cpu_ir[rc], |
1170 | 1a1f7dbc | aurel32 | ~(uint64_t)ctx->amask); |
1171 | 1a1f7dbc | aurel32 | break;
|
1172 | 1a1f7dbc | aurel32 | } |
1173 | ae8ecd42 | aurel32 | } |
1174 | 4c9649a9 | j_mayer | break;
|
1175 | 4c9649a9 | j_mayer | case 0x64: |
1176 | 4c9649a9 | j_mayer | /* CMOVLE */
|
1177 | fe2b269a | aurel32 | gen_cmov(TCG_COND_GT, ra, rb, rc, islit, lit, 0);
|
1178 | 4c9649a9 | j_mayer | break;
|
1179 | 4c9649a9 | j_mayer | case 0x66: |
1180 | 4c9649a9 | j_mayer | /* CMOVGT */
|
1181 | fe2b269a | aurel32 | gen_cmov(TCG_COND_LE, ra, rb, rc, islit, lit, 0);
|
1182 | 4c9649a9 | j_mayer | break;
|
1183 | 4c9649a9 | j_mayer | case 0x6C: |
1184 | 4c9649a9 | j_mayer | /* IMPLVER */
|
1185 | 3761035f | aurel32 | if (rc != 31) |
1186 | 8579095b | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], ctx->env->implver); |
1187 | 4c9649a9 | j_mayer | break;
|
1188 | 4c9649a9 | j_mayer | default:
|
1189 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1190 | 4c9649a9 | j_mayer | } |
1191 | 4c9649a9 | j_mayer | break;
|
1192 | 4c9649a9 | j_mayer | case 0x12: |
1193 | 4c9649a9 | j_mayer | switch (fn7) {
|
1194 | 4c9649a9 | j_mayer | case 0x02: |
1195 | 4c9649a9 | j_mayer | /* MSKBL */
|
1196 | a7812ae4 | pbrook | gen_mskbl(ra, rb, rc, islit, lit); |
1197 | 4c9649a9 | j_mayer | break;
|
1198 | 4c9649a9 | j_mayer | case 0x06: |
1199 | 4c9649a9 | j_mayer | /* EXTBL */
|
1200 | b3249f63 | aurel32 | gen_ext_l(&tcg_gen_ext8u_i64, ra, rb, rc, islit, lit); |
1201 | 4c9649a9 | j_mayer | break;
|
1202 | 4c9649a9 | j_mayer | case 0x0B: |
1203 | 4c9649a9 | j_mayer | /* INSBL */
|
1204 | a7812ae4 | pbrook | gen_insbl(ra, rb, rc, islit, lit); |
1205 | 4c9649a9 | j_mayer | break;
|
1206 | 4c9649a9 | j_mayer | case 0x12: |
1207 | 4c9649a9 | j_mayer | /* MSKWL */
|
1208 | a7812ae4 | pbrook | gen_mskwl(ra, rb, rc, islit, lit); |
1209 | 4c9649a9 | j_mayer | break;
|
1210 | 4c9649a9 | j_mayer | case 0x16: |
1211 | 4c9649a9 | j_mayer | /* EXTWL */
|
1212 | b3249f63 | aurel32 | gen_ext_l(&tcg_gen_ext16u_i64, ra, rb, rc, islit, lit); |
1213 | 4c9649a9 | j_mayer | break;
|
1214 | 4c9649a9 | j_mayer | case 0x1B: |
1215 | 4c9649a9 | j_mayer | /* INSWL */
|
1216 | a7812ae4 | pbrook | gen_inswl(ra, rb, rc, islit, lit); |
1217 | 4c9649a9 | j_mayer | break;
|
1218 | 4c9649a9 | j_mayer | case 0x22: |
1219 | 4c9649a9 | j_mayer | /* MSKLL */
|
1220 | a7812ae4 | pbrook | gen_mskll(ra, rb, rc, islit, lit); |
1221 | 4c9649a9 | j_mayer | break;
|
1222 | 4c9649a9 | j_mayer | case 0x26: |
1223 | 4c9649a9 | j_mayer | /* EXTLL */
|
1224 | b3249f63 | aurel32 | gen_ext_l(&tcg_gen_ext32u_i64, ra, rb, rc, islit, lit); |
1225 | 4c9649a9 | j_mayer | break;
|
1226 | 4c9649a9 | j_mayer | case 0x2B: |
1227 | 4c9649a9 | j_mayer | /* INSLL */
|
1228 | a7812ae4 | pbrook | gen_insll(ra, rb, rc, islit, lit); |
1229 | 4c9649a9 | j_mayer | break;
|
1230 | 4c9649a9 | j_mayer | case 0x30: |
1231 | 4c9649a9 | j_mayer | /* ZAP */
|
1232 | a7812ae4 | pbrook | gen_zap(ra, rb, rc, islit, lit); |
1233 | 4c9649a9 | j_mayer | break;
|
1234 | 4c9649a9 | j_mayer | case 0x31: |
1235 | 4c9649a9 | j_mayer | /* ZAPNOT */
|
1236 | a7812ae4 | pbrook | gen_zapnot(ra, rb, rc, islit, lit); |
1237 | 4c9649a9 | j_mayer | break;
|
1238 | 4c9649a9 | j_mayer | case 0x32: |
1239 | 4c9649a9 | j_mayer | /* MSKQL */
|
1240 | a7812ae4 | pbrook | gen_mskql(ra, rb, rc, islit, lit); |
1241 | 4c9649a9 | j_mayer | break;
|
1242 | 4c9649a9 | j_mayer | case 0x34: |
1243 | 4c9649a9 | j_mayer | /* SRL */
|
1244 | 30c7183b | aurel32 | if (likely(rc != 31)) { |
1245 | 30c7183b | aurel32 | if (ra != 31) { |
1246 | 30c7183b | aurel32 | if (islit)
|
1247 | 30c7183b | aurel32 | tcg_gen_shri_i64(cpu_ir[rc], cpu_ir[ra], lit & 0x3f);
|
1248 | dfaa8583 | aurel32 | else {
|
1249 | a7812ae4 | pbrook | TCGv shift = tcg_temp_new(); |
1250 | 30c7183b | aurel32 | tcg_gen_andi_i64(shift, cpu_ir[rb], 0x3f);
|
1251 | 30c7183b | aurel32 | tcg_gen_shr_i64(cpu_ir[rc], cpu_ir[ra], shift); |
1252 | 30c7183b | aurel32 | tcg_temp_free(shift); |
1253 | dfaa8583 | aurel32 | } |
1254 | 30c7183b | aurel32 | } else
|
1255 | 30c7183b | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], 0);
|
1256 | 30c7183b | aurel32 | } |
1257 | 4c9649a9 | j_mayer | break;
|
1258 | 4c9649a9 | j_mayer | case 0x36: |
1259 | 4c9649a9 | j_mayer | /* EXTQL */
|
1260 | b3249f63 | aurel32 | gen_ext_l(NULL, ra, rb, rc, islit, lit);
|
1261 | 4c9649a9 | j_mayer | break;
|
1262 | 4c9649a9 | j_mayer | case 0x39: |
1263 | 4c9649a9 | j_mayer | /* SLL */
|
1264 | 30c7183b | aurel32 | if (likely(rc != 31)) { |
1265 | 30c7183b | aurel32 | if (ra != 31) { |
1266 | 30c7183b | aurel32 | if (islit)
|
1267 | 30c7183b | aurel32 | tcg_gen_shli_i64(cpu_ir[rc], cpu_ir[ra], lit & 0x3f);
|
1268 | dfaa8583 | aurel32 | else {
|
1269 | a7812ae4 | pbrook | TCGv shift = tcg_temp_new(); |
1270 | 30c7183b | aurel32 | tcg_gen_andi_i64(shift, cpu_ir[rb], 0x3f);
|
1271 | 30c7183b | aurel32 | tcg_gen_shl_i64(cpu_ir[rc], cpu_ir[ra], shift); |
1272 | 30c7183b | aurel32 | tcg_temp_free(shift); |
1273 | dfaa8583 | aurel32 | } |
1274 | 30c7183b | aurel32 | } else
|
1275 | 30c7183b | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], 0);
|
1276 | 30c7183b | aurel32 | } |
1277 | 4c9649a9 | j_mayer | break;
|
1278 | 4c9649a9 | j_mayer | case 0x3B: |
1279 | 4c9649a9 | j_mayer | /* INSQL */
|
1280 | a7812ae4 | pbrook | gen_insql(ra, rb, rc, islit, lit); |
1281 | 4c9649a9 | j_mayer | break;
|
1282 | 4c9649a9 | j_mayer | case 0x3C: |
1283 | 4c9649a9 | j_mayer | /* SRA */
|
1284 | 30c7183b | aurel32 | if (likely(rc != 31)) { |
1285 | 30c7183b | aurel32 | if (ra != 31) { |
1286 | 30c7183b | aurel32 | if (islit)
|
1287 | 30c7183b | aurel32 | tcg_gen_sari_i64(cpu_ir[rc], cpu_ir[ra], lit & 0x3f);
|
1288 | dfaa8583 | aurel32 | else {
|
1289 | a7812ae4 | pbrook | TCGv shift = tcg_temp_new(); |
1290 | 30c7183b | aurel32 | tcg_gen_andi_i64(shift, cpu_ir[rb], 0x3f);
|
1291 | 30c7183b | aurel32 | tcg_gen_sar_i64(cpu_ir[rc], cpu_ir[ra], shift); |
1292 | 30c7183b | aurel32 | tcg_temp_free(shift); |
1293 | dfaa8583 | aurel32 | } |
1294 | 30c7183b | aurel32 | } else
|
1295 | 30c7183b | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], 0);
|
1296 | 30c7183b | aurel32 | } |
1297 | 4c9649a9 | j_mayer | break;
|
1298 | 4c9649a9 | j_mayer | case 0x52: |
1299 | 4c9649a9 | j_mayer | /* MSKWH */
|
1300 | a7812ae4 | pbrook | gen_mskwh(ra, rb, rc, islit, lit); |
1301 | 4c9649a9 | j_mayer | break;
|
1302 | 4c9649a9 | j_mayer | case 0x57: |
1303 | 4c9649a9 | j_mayer | /* INSWH */
|
1304 | a7812ae4 | pbrook | gen_inswh(ra, rb, rc, islit, lit); |
1305 | 4c9649a9 | j_mayer | break;
|
1306 | 4c9649a9 | j_mayer | case 0x5A: |
1307 | 4c9649a9 | j_mayer | /* EXTWH */
|
1308 | b3249f63 | aurel32 | gen_ext_h(&tcg_gen_ext16u_i64, ra, rb, rc, islit, lit); |
1309 | 4c9649a9 | j_mayer | break;
|
1310 | 4c9649a9 | j_mayer | case 0x62: |
1311 | 4c9649a9 | j_mayer | /* MSKLH */
|
1312 | a7812ae4 | pbrook | gen_msklh(ra, rb, rc, islit, lit); |
1313 | 4c9649a9 | j_mayer | break;
|
1314 | 4c9649a9 | j_mayer | case 0x67: |
1315 | 4c9649a9 | j_mayer | /* INSLH */
|
1316 | a7812ae4 | pbrook | gen_inslh(ra, rb, rc, islit, lit); |
1317 | 4c9649a9 | j_mayer | break;
|
1318 | 4c9649a9 | j_mayer | case 0x6A: |
1319 | 4c9649a9 | j_mayer | /* EXTLH */
|
1320 | dbf95805 | Vince Weaver | gen_ext_h(&tcg_gen_ext32u_i64, ra, rb, rc, islit, lit); |
1321 | 4c9649a9 | j_mayer | break;
|
1322 | 4c9649a9 | j_mayer | case 0x72: |
1323 | 4c9649a9 | j_mayer | /* MSKQH */
|
1324 | a7812ae4 | pbrook | gen_mskqh(ra, rb, rc, islit, lit); |
1325 | 4c9649a9 | j_mayer | break;
|
1326 | 4c9649a9 | j_mayer | case 0x77: |
1327 | 4c9649a9 | j_mayer | /* INSQH */
|
1328 | a7812ae4 | pbrook | gen_insqh(ra, rb, rc, islit, lit); |
1329 | 4c9649a9 | j_mayer | break;
|
1330 | 4c9649a9 | j_mayer | case 0x7A: |
1331 | 4c9649a9 | j_mayer | /* EXTQH */
|
1332 | b3249f63 | aurel32 | gen_ext_h(NULL, ra, rb, rc, islit, lit);
|
1333 | 4c9649a9 | j_mayer | break;
|
1334 | 4c9649a9 | j_mayer | default:
|
1335 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1336 | 4c9649a9 | j_mayer | } |
1337 | 4c9649a9 | j_mayer | break;
|
1338 | 4c9649a9 | j_mayer | case 0x13: |
1339 | 4c9649a9 | j_mayer | switch (fn7) {
|
1340 | 4c9649a9 | j_mayer | case 0x00: |
1341 | 4c9649a9 | j_mayer | /* MULL */
|
1342 | 30c7183b | aurel32 | if (likely(rc != 31)) { |
1343 | dfaa8583 | aurel32 | if (ra == 31) |
1344 | 30c7183b | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], 0);
|
1345 | 30c7183b | aurel32 | else {
|
1346 | 30c7183b | aurel32 | if (islit)
|
1347 | 30c7183b | aurel32 | tcg_gen_muli_i64(cpu_ir[rc], cpu_ir[ra], lit); |
1348 | 30c7183b | aurel32 | else
|
1349 | 30c7183b | aurel32 | tcg_gen_mul_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]); |
1350 | 30c7183b | aurel32 | tcg_gen_ext32s_i64(cpu_ir[rc], cpu_ir[rc]); |
1351 | 30c7183b | aurel32 | } |
1352 | 30c7183b | aurel32 | } |
1353 | 4c9649a9 | j_mayer | break;
|
1354 | 4c9649a9 | j_mayer | case 0x20: |
1355 | 4c9649a9 | j_mayer | /* MULQ */
|
1356 | 30c7183b | aurel32 | if (likely(rc != 31)) { |
1357 | dfaa8583 | aurel32 | if (ra == 31) |
1358 | 30c7183b | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], 0);
|
1359 | 30c7183b | aurel32 | else if (islit) |
1360 | 30c7183b | aurel32 | tcg_gen_muli_i64(cpu_ir[rc], cpu_ir[ra], lit); |
1361 | 30c7183b | aurel32 | else
|
1362 | 30c7183b | aurel32 | tcg_gen_mul_i64(cpu_ir[rc], cpu_ir[ra], cpu_ir[rb]); |
1363 | 30c7183b | aurel32 | } |
1364 | 4c9649a9 | j_mayer | break;
|
1365 | 4c9649a9 | j_mayer | case 0x30: |
1366 | 4c9649a9 | j_mayer | /* UMULH */
|
1367 | a7812ae4 | pbrook | gen_umulh(ra, rb, rc, islit, lit); |
1368 | 4c9649a9 | j_mayer | break;
|
1369 | 4c9649a9 | j_mayer | case 0x40: |
1370 | 4c9649a9 | j_mayer | /* MULL/V */
|
1371 | a7812ae4 | pbrook | gen_mullv(ra, rb, rc, islit, lit); |
1372 | 4c9649a9 | j_mayer | break;
|
1373 | 4c9649a9 | j_mayer | case 0x60: |
1374 | 4c9649a9 | j_mayer | /* MULQ/V */
|
1375 | a7812ae4 | pbrook | gen_mulqv(ra, rb, rc, islit, lit); |
1376 | 4c9649a9 | j_mayer | break;
|
1377 | 4c9649a9 | j_mayer | default:
|
1378 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1379 | 4c9649a9 | j_mayer | } |
1380 | 4c9649a9 | j_mayer | break;
|
1381 | 4c9649a9 | j_mayer | case 0x14: |
1382 | 4c9649a9 | j_mayer | switch (fpfn) { /* f11 & 0x3F */ |
1383 | 4c9649a9 | j_mayer | case 0x04: |
1384 | 4c9649a9 | j_mayer | /* ITOFS */
|
1385 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_FIX))
|
1386 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1387 | f18cd223 | aurel32 | if (likely(rc != 31)) { |
1388 | f18cd223 | aurel32 | if (ra != 31) { |
1389 | a7812ae4 | pbrook | TCGv_i32 tmp = tcg_temp_new_i32(); |
1390 | f18cd223 | aurel32 | tcg_gen_trunc_i64_i32(tmp, cpu_ir[ra]); |
1391 | a7812ae4 | pbrook | gen_helper_memory_to_s(cpu_fir[rc], tmp); |
1392 | a7812ae4 | pbrook | tcg_temp_free_i32(tmp); |
1393 | f18cd223 | aurel32 | } else
|
1394 | f18cd223 | aurel32 | tcg_gen_movi_i64(cpu_fir[rc], 0);
|
1395 | f18cd223 | aurel32 | } |
1396 | 4c9649a9 | j_mayer | break;
|
1397 | 4c9649a9 | j_mayer | case 0x0A: |
1398 | 4c9649a9 | j_mayer | /* SQRTF */
|
1399 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_FIX))
|
1400 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1401 | a7812ae4 | pbrook | gen_fsqrtf(rb, rc); |
1402 | 4c9649a9 | j_mayer | break;
|
1403 | 4c9649a9 | j_mayer | case 0x0B: |
1404 | 4c9649a9 | j_mayer | /* SQRTS */
|
1405 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_FIX))
|
1406 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1407 | a7812ae4 | pbrook | gen_fsqrts(rb, rc); |
1408 | 4c9649a9 | j_mayer | break;
|
1409 | 4c9649a9 | j_mayer | case 0x14: |
1410 | 4c9649a9 | j_mayer | /* ITOFF */
|
1411 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_FIX))
|
1412 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1413 | f18cd223 | aurel32 | if (likely(rc != 31)) { |
1414 | f18cd223 | aurel32 | if (ra != 31) { |
1415 | a7812ae4 | pbrook | TCGv_i32 tmp = tcg_temp_new_i32(); |
1416 | f18cd223 | aurel32 | tcg_gen_trunc_i64_i32(tmp, cpu_ir[ra]); |
1417 | a7812ae4 | pbrook | gen_helper_memory_to_f(cpu_fir[rc], tmp); |
1418 | a7812ae4 | pbrook | tcg_temp_free_i32(tmp); |
1419 | f18cd223 | aurel32 | } else
|
1420 | f18cd223 | aurel32 | tcg_gen_movi_i64(cpu_fir[rc], 0);
|
1421 | f18cd223 | aurel32 | } |
1422 | 4c9649a9 | j_mayer | break;
|
1423 | 4c9649a9 | j_mayer | case 0x24: |
1424 | 4c9649a9 | j_mayer | /* ITOFT */
|
1425 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_FIX))
|
1426 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1427 | f18cd223 | aurel32 | if (likely(rc != 31)) { |
1428 | f18cd223 | aurel32 | if (ra != 31) |
1429 | f18cd223 | aurel32 | tcg_gen_mov_i64(cpu_fir[rc], cpu_ir[ra]); |
1430 | f18cd223 | aurel32 | else
|
1431 | f18cd223 | aurel32 | tcg_gen_movi_i64(cpu_fir[rc], 0);
|
1432 | f18cd223 | aurel32 | } |
1433 | 4c9649a9 | j_mayer | break;
|
1434 | 4c9649a9 | j_mayer | case 0x2A: |
1435 | 4c9649a9 | j_mayer | /* SQRTG */
|
1436 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_FIX))
|
1437 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1438 | a7812ae4 | pbrook | gen_fsqrtg(rb, rc); |
1439 | 4c9649a9 | j_mayer | break;
|
1440 | 4c9649a9 | j_mayer | case 0x02B: |
1441 | 4c9649a9 | j_mayer | /* SQRTT */
|
1442 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_FIX))
|
1443 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1444 | a7812ae4 | pbrook | gen_fsqrtt(rb, rc); |
1445 | 4c9649a9 | j_mayer | break;
|
1446 | 4c9649a9 | j_mayer | default:
|
1447 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1448 | 4c9649a9 | j_mayer | } |
1449 | 4c9649a9 | j_mayer | break;
|
1450 | 4c9649a9 | j_mayer | case 0x15: |
1451 | 4c9649a9 | j_mayer | /* VAX floating point */
|
1452 | 4c9649a9 | j_mayer | /* XXX: rounding mode and trap are ignored (!) */
|
1453 | 4c9649a9 | j_mayer | switch (fpfn) { /* f11 & 0x3F */ |
1454 | 4c9649a9 | j_mayer | case 0x00: |
1455 | 4c9649a9 | j_mayer | /* ADDF */
|
1456 | a7812ae4 | pbrook | gen_faddf(ra, rb, rc); |
1457 | 4c9649a9 | j_mayer | break;
|
1458 | 4c9649a9 | j_mayer | case 0x01: |
1459 | 4c9649a9 | j_mayer | /* SUBF */
|
1460 | a7812ae4 | pbrook | gen_fsubf(ra, rb, rc); |
1461 | 4c9649a9 | j_mayer | break;
|
1462 | 4c9649a9 | j_mayer | case 0x02: |
1463 | 4c9649a9 | j_mayer | /* MULF */
|
1464 | a7812ae4 | pbrook | gen_fmulf(ra, rb, rc); |
1465 | 4c9649a9 | j_mayer | break;
|
1466 | 4c9649a9 | j_mayer | case 0x03: |
1467 | 4c9649a9 | j_mayer | /* DIVF */
|
1468 | a7812ae4 | pbrook | gen_fdivf(ra, rb, rc); |
1469 | 4c9649a9 | j_mayer | break;
|
1470 | 4c9649a9 | j_mayer | case 0x1E: |
1471 | 4c9649a9 | j_mayer | /* CVTDG */
|
1472 | 4c9649a9 | j_mayer | #if 0 // TODO
|
1473 | a7812ae4 | pbrook | gen_fcvtdg(rb, rc);
|
1474 | 4c9649a9 | j_mayer | #else
|
1475 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1476 | 4c9649a9 | j_mayer | #endif
|
1477 | 4c9649a9 | j_mayer | break;
|
1478 | 4c9649a9 | j_mayer | case 0x20: |
1479 | 4c9649a9 | j_mayer | /* ADDG */
|
1480 | a7812ae4 | pbrook | gen_faddg(ra, rb, rc); |
1481 | 4c9649a9 | j_mayer | break;
|
1482 | 4c9649a9 | j_mayer | case 0x21: |
1483 | 4c9649a9 | j_mayer | /* SUBG */
|
1484 | a7812ae4 | pbrook | gen_fsubg(ra, rb, rc); |
1485 | 4c9649a9 | j_mayer | break;
|
1486 | 4c9649a9 | j_mayer | case 0x22: |
1487 | 4c9649a9 | j_mayer | /* MULG */
|
1488 | a7812ae4 | pbrook | gen_fmulg(ra, rb, rc); |
1489 | 4c9649a9 | j_mayer | break;
|
1490 | 4c9649a9 | j_mayer | case 0x23: |
1491 | 4c9649a9 | j_mayer | /* DIVG */
|
1492 | a7812ae4 | pbrook | gen_fdivg(ra, rb, rc); |
1493 | 4c9649a9 | j_mayer | break;
|
1494 | 4c9649a9 | j_mayer | case 0x25: |
1495 | 4c9649a9 | j_mayer | /* CMPGEQ */
|
1496 | a7812ae4 | pbrook | gen_fcmpgeq(ra, rb, rc); |
1497 | 4c9649a9 | j_mayer | break;
|
1498 | 4c9649a9 | j_mayer | case 0x26: |
1499 | 4c9649a9 | j_mayer | /* CMPGLT */
|
1500 | a7812ae4 | pbrook | gen_fcmpglt(ra, rb, rc); |
1501 | 4c9649a9 | j_mayer | break;
|
1502 | 4c9649a9 | j_mayer | case 0x27: |
1503 | 4c9649a9 | j_mayer | /* CMPGLE */
|
1504 | a7812ae4 | pbrook | gen_fcmpgle(ra, rb, rc); |
1505 | 4c9649a9 | j_mayer | break;
|
1506 | 4c9649a9 | j_mayer | case 0x2C: |
1507 | 4c9649a9 | j_mayer | /* CVTGF */
|
1508 | a7812ae4 | pbrook | gen_fcvtgf(rb, rc); |
1509 | 4c9649a9 | j_mayer | break;
|
1510 | 4c9649a9 | j_mayer | case 0x2D: |
1511 | 4c9649a9 | j_mayer | /* CVTGD */
|
1512 | 4c9649a9 | j_mayer | #if 0 // TODO
|
1513 | a7812ae4 | pbrook | gen_fcvtgd(rb, rc);
|
1514 | 4c9649a9 | j_mayer | #else
|
1515 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1516 | 4c9649a9 | j_mayer | #endif
|
1517 | 4c9649a9 | j_mayer | break;
|
1518 | 4c9649a9 | j_mayer | case 0x2F: |
1519 | 4c9649a9 | j_mayer | /* CVTGQ */
|
1520 | a7812ae4 | pbrook | gen_fcvtgq(rb, rc); |
1521 | 4c9649a9 | j_mayer | break;
|
1522 | 4c9649a9 | j_mayer | case 0x3C: |
1523 | 4c9649a9 | j_mayer | /* CVTQF */
|
1524 | a7812ae4 | pbrook | gen_fcvtqf(rb, rc); |
1525 | 4c9649a9 | j_mayer | break;
|
1526 | 4c9649a9 | j_mayer | case 0x3E: |
1527 | 4c9649a9 | j_mayer | /* CVTQG */
|
1528 | a7812ae4 | pbrook | gen_fcvtqg(rb, rc); |
1529 | 4c9649a9 | j_mayer | break;
|
1530 | 4c9649a9 | j_mayer | default:
|
1531 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1532 | 4c9649a9 | j_mayer | } |
1533 | 4c9649a9 | j_mayer | break;
|
1534 | 4c9649a9 | j_mayer | case 0x16: |
1535 | 4c9649a9 | j_mayer | /* IEEE floating-point */
|
1536 | 4c9649a9 | j_mayer | /* XXX: rounding mode and traps are ignored (!) */
|
1537 | 4c9649a9 | j_mayer | switch (fpfn) { /* f11 & 0x3F */ |
1538 | 4c9649a9 | j_mayer | case 0x00: |
1539 | 4c9649a9 | j_mayer | /* ADDS */
|
1540 | a7812ae4 | pbrook | gen_fadds(ra, rb, rc); |
1541 | 4c9649a9 | j_mayer | break;
|
1542 | 4c9649a9 | j_mayer | case 0x01: |
1543 | 4c9649a9 | j_mayer | /* SUBS */
|
1544 | a7812ae4 | pbrook | gen_fsubs(ra, rb, rc); |
1545 | 4c9649a9 | j_mayer | break;
|
1546 | 4c9649a9 | j_mayer | case 0x02: |
1547 | 4c9649a9 | j_mayer | /* MULS */
|
1548 | a7812ae4 | pbrook | gen_fmuls(ra, rb, rc); |
1549 | 4c9649a9 | j_mayer | break;
|
1550 | 4c9649a9 | j_mayer | case 0x03: |
1551 | 4c9649a9 | j_mayer | /* DIVS */
|
1552 | a7812ae4 | pbrook | gen_fdivs(ra, rb, rc); |
1553 | 4c9649a9 | j_mayer | break;
|
1554 | 4c9649a9 | j_mayer | case 0x20: |
1555 | 4c9649a9 | j_mayer | /* ADDT */
|
1556 | a7812ae4 | pbrook | gen_faddt(ra, rb, rc); |
1557 | 4c9649a9 | j_mayer | break;
|
1558 | 4c9649a9 | j_mayer | case 0x21: |
1559 | 4c9649a9 | j_mayer | /* SUBT */
|
1560 | a7812ae4 | pbrook | gen_fsubt(ra, rb, rc); |
1561 | 4c9649a9 | j_mayer | break;
|
1562 | 4c9649a9 | j_mayer | case 0x22: |
1563 | 4c9649a9 | j_mayer | /* MULT */
|
1564 | a7812ae4 | pbrook | gen_fmult(ra, rb, rc); |
1565 | 4c9649a9 | j_mayer | break;
|
1566 | 4c9649a9 | j_mayer | case 0x23: |
1567 | 4c9649a9 | j_mayer | /* DIVT */
|
1568 | a7812ae4 | pbrook | gen_fdivt(ra, rb, rc); |
1569 | 4c9649a9 | j_mayer | break;
|
1570 | 4c9649a9 | j_mayer | case 0x24: |
1571 | 4c9649a9 | j_mayer | /* CMPTUN */
|
1572 | a7812ae4 | pbrook | gen_fcmptun(ra, rb, rc); |
1573 | 4c9649a9 | j_mayer | break;
|
1574 | 4c9649a9 | j_mayer | case 0x25: |
1575 | 4c9649a9 | j_mayer | /* CMPTEQ */
|
1576 | a7812ae4 | pbrook | gen_fcmpteq(ra, rb, rc); |
1577 | 4c9649a9 | j_mayer | break;
|
1578 | 4c9649a9 | j_mayer | case 0x26: |
1579 | 4c9649a9 | j_mayer | /* CMPTLT */
|
1580 | a7812ae4 | pbrook | gen_fcmptlt(ra, rb, rc); |
1581 | 4c9649a9 | j_mayer | break;
|
1582 | 4c9649a9 | j_mayer | case 0x27: |
1583 | 4c9649a9 | j_mayer | /* CMPTLE */
|
1584 | a7812ae4 | pbrook | gen_fcmptle(ra, rb, rc); |
1585 | 4c9649a9 | j_mayer | break;
|
1586 | 4c9649a9 | j_mayer | case 0x2C: |
1587 | 4c9649a9 | j_mayer | /* XXX: incorrect */
|
1588 | a74b4d2c | aurel32 | if (fn11 == 0x2AC || fn11 == 0x6AC) { |
1589 | 4c9649a9 | j_mayer | /* CVTST */
|
1590 | a7812ae4 | pbrook | gen_fcvtst(rb, rc); |
1591 | 4c9649a9 | j_mayer | } else {
|
1592 | 4c9649a9 | j_mayer | /* CVTTS */
|
1593 | a7812ae4 | pbrook | gen_fcvtts(rb, rc); |
1594 | 4c9649a9 | j_mayer | } |
1595 | 4c9649a9 | j_mayer | break;
|
1596 | 4c9649a9 | j_mayer | case 0x2F: |
1597 | 4c9649a9 | j_mayer | /* CVTTQ */
|
1598 | a7812ae4 | pbrook | gen_fcvttq(rb, rc); |
1599 | 4c9649a9 | j_mayer | break;
|
1600 | 4c9649a9 | j_mayer | case 0x3C: |
1601 | 4c9649a9 | j_mayer | /* CVTQS */
|
1602 | a7812ae4 | pbrook | gen_fcvtqs(rb, rc); |
1603 | 4c9649a9 | j_mayer | break;
|
1604 | 4c9649a9 | j_mayer | case 0x3E: |
1605 | 4c9649a9 | j_mayer | /* CVTQT */
|
1606 | a7812ae4 | pbrook | gen_fcvtqt(rb, rc); |
1607 | 4c9649a9 | j_mayer | break;
|
1608 | 4c9649a9 | j_mayer | default:
|
1609 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1610 | 4c9649a9 | j_mayer | } |
1611 | 4c9649a9 | j_mayer | break;
|
1612 | 4c9649a9 | j_mayer | case 0x17: |
1613 | 4c9649a9 | j_mayer | switch (fn11) {
|
1614 | 4c9649a9 | j_mayer | case 0x010: |
1615 | 4c9649a9 | j_mayer | /* CVTLQ */
|
1616 | a7812ae4 | pbrook | gen_fcvtlq(rb, rc); |
1617 | 4c9649a9 | j_mayer | break;
|
1618 | 4c9649a9 | j_mayer | case 0x020: |
1619 | f18cd223 | aurel32 | if (likely(rc != 31)) { |
1620 | f18cd223 | aurel32 | if (ra == rb)
|
1621 | 4c9649a9 | j_mayer | /* FMOV */
|
1622 | f18cd223 | aurel32 | tcg_gen_mov_i64(cpu_fir[rc], cpu_fir[ra]); |
1623 | f18cd223 | aurel32 | else
|
1624 | f18cd223 | aurel32 | /* CPYS */
|
1625 | a7812ae4 | pbrook | gen_fcpys(ra, rb, rc); |
1626 | 4c9649a9 | j_mayer | } |
1627 | 4c9649a9 | j_mayer | break;
|
1628 | 4c9649a9 | j_mayer | case 0x021: |
1629 | 4c9649a9 | j_mayer | /* CPYSN */
|
1630 | a7812ae4 | pbrook | gen_fcpysn(ra, rb, rc); |
1631 | 4c9649a9 | j_mayer | break;
|
1632 | 4c9649a9 | j_mayer | case 0x022: |
1633 | 4c9649a9 | j_mayer | /* CPYSE */
|
1634 | a7812ae4 | pbrook | gen_fcpyse(ra, rb, rc); |
1635 | 4c9649a9 | j_mayer | break;
|
1636 | 4c9649a9 | j_mayer | case 0x024: |
1637 | 4c9649a9 | j_mayer | /* MT_FPCR */
|
1638 | f18cd223 | aurel32 | if (likely(ra != 31)) |
1639 | a7812ae4 | pbrook | gen_helper_store_fpcr(cpu_fir[ra]); |
1640 | f18cd223 | aurel32 | else {
|
1641 | f18cd223 | aurel32 | TCGv tmp = tcg_const_i64(0);
|
1642 | a7812ae4 | pbrook | gen_helper_store_fpcr(tmp); |
1643 | f18cd223 | aurel32 | tcg_temp_free(tmp); |
1644 | f18cd223 | aurel32 | } |
1645 | 4c9649a9 | j_mayer | break;
|
1646 | 4c9649a9 | j_mayer | case 0x025: |
1647 | 4c9649a9 | j_mayer | /* MF_FPCR */
|
1648 | f18cd223 | aurel32 | if (likely(ra != 31)) |
1649 | a7812ae4 | pbrook | gen_helper_load_fpcr(cpu_fir[ra]); |
1650 | 4c9649a9 | j_mayer | break;
|
1651 | 4c9649a9 | j_mayer | case 0x02A: |
1652 | 4c9649a9 | j_mayer | /* FCMOVEQ */
|
1653 | a7812ae4 | pbrook | gen_fcmpfeq(ra, rb, rc); |
1654 | 4c9649a9 | j_mayer | break;
|
1655 | 4c9649a9 | j_mayer | case 0x02B: |
1656 | 4c9649a9 | j_mayer | /* FCMOVNE */
|
1657 | a7812ae4 | pbrook | gen_fcmpfne(ra, rb, rc); |
1658 | 4c9649a9 | j_mayer | break;
|
1659 | 4c9649a9 | j_mayer | case 0x02C: |
1660 | 4c9649a9 | j_mayer | /* FCMOVLT */
|
1661 | a7812ae4 | pbrook | gen_fcmpflt(ra, rb, rc); |
1662 | 4c9649a9 | j_mayer | break;
|
1663 | 4c9649a9 | j_mayer | case 0x02D: |
1664 | 4c9649a9 | j_mayer | /* FCMOVGE */
|
1665 | a7812ae4 | pbrook | gen_fcmpfge(ra, rb, rc); |
1666 | 4c9649a9 | j_mayer | break;
|
1667 | 4c9649a9 | j_mayer | case 0x02E: |
1668 | 4c9649a9 | j_mayer | /* FCMOVLE */
|
1669 | a7812ae4 | pbrook | gen_fcmpfle(ra, rb, rc); |
1670 | 4c9649a9 | j_mayer | break;
|
1671 | 4c9649a9 | j_mayer | case 0x02F: |
1672 | 4c9649a9 | j_mayer | /* FCMOVGT */
|
1673 | a7812ae4 | pbrook | gen_fcmpfgt(ra, rb, rc); |
1674 | 4c9649a9 | j_mayer | break;
|
1675 | 4c9649a9 | j_mayer | case 0x030: |
1676 | 4c9649a9 | j_mayer | /* CVTQL */
|
1677 | a7812ae4 | pbrook | gen_fcvtql(rb, rc); |
1678 | 4c9649a9 | j_mayer | break;
|
1679 | 4c9649a9 | j_mayer | case 0x130: |
1680 | 4c9649a9 | j_mayer | /* CVTQL/V */
|
1681 | a7812ae4 | pbrook | gen_fcvtqlv(rb, rc); |
1682 | 4c9649a9 | j_mayer | break;
|
1683 | 4c9649a9 | j_mayer | case 0x530: |
1684 | 4c9649a9 | j_mayer | /* CVTQL/SV */
|
1685 | a7812ae4 | pbrook | gen_fcvtqlsv(rb, rc); |
1686 | 4c9649a9 | j_mayer | break;
|
1687 | 4c9649a9 | j_mayer | default:
|
1688 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1689 | 4c9649a9 | j_mayer | } |
1690 | 4c9649a9 | j_mayer | break;
|
1691 | 4c9649a9 | j_mayer | case 0x18: |
1692 | 4c9649a9 | j_mayer | switch ((uint16_t)disp16) {
|
1693 | 4c9649a9 | j_mayer | case 0x0000: |
1694 | 4c9649a9 | j_mayer | /* TRAPB */
|
1695 | 4c9649a9 | j_mayer | /* No-op. Just exit from the current tb */
|
1696 | 4c9649a9 | j_mayer | ret = 2;
|
1697 | 4c9649a9 | j_mayer | break;
|
1698 | 4c9649a9 | j_mayer | case 0x0400: |
1699 | 4c9649a9 | j_mayer | /* EXCB */
|
1700 | 4c9649a9 | j_mayer | /* No-op. Just exit from the current tb */
|
1701 | 4c9649a9 | j_mayer | ret = 2;
|
1702 | 4c9649a9 | j_mayer | break;
|
1703 | 4c9649a9 | j_mayer | case 0x4000: |
1704 | 4c9649a9 | j_mayer | /* MB */
|
1705 | 4c9649a9 | j_mayer | /* No-op */
|
1706 | 4c9649a9 | j_mayer | break;
|
1707 | 4c9649a9 | j_mayer | case 0x4400: |
1708 | 4c9649a9 | j_mayer | /* WMB */
|
1709 | 4c9649a9 | j_mayer | /* No-op */
|
1710 | 4c9649a9 | j_mayer | break;
|
1711 | 4c9649a9 | j_mayer | case 0x8000: |
1712 | 4c9649a9 | j_mayer | /* FETCH */
|
1713 | 4c9649a9 | j_mayer | /* No-op */
|
1714 | 4c9649a9 | j_mayer | break;
|
1715 | 4c9649a9 | j_mayer | case 0xA000: |
1716 | 4c9649a9 | j_mayer | /* FETCH_M */
|
1717 | 4c9649a9 | j_mayer | /* No-op */
|
1718 | 4c9649a9 | j_mayer | break;
|
1719 | 4c9649a9 | j_mayer | case 0xC000: |
1720 | 4c9649a9 | j_mayer | /* RPCC */
|
1721 | 3761035f | aurel32 | if (ra != 31) |
1722 | a7812ae4 | pbrook | gen_helper_load_pcc(cpu_ir[ra]); |
1723 | 4c9649a9 | j_mayer | break;
|
1724 | 4c9649a9 | j_mayer | case 0xE000: |
1725 | 4c9649a9 | j_mayer | /* RC */
|
1726 | 3761035f | aurel32 | if (ra != 31) |
1727 | a7812ae4 | pbrook | gen_helper_rc(cpu_ir[ra]); |
1728 | 4c9649a9 | j_mayer | break;
|
1729 | 4c9649a9 | j_mayer | case 0xE800: |
1730 | 4c9649a9 | j_mayer | /* ECB */
|
1731 | 4c9649a9 | j_mayer | break;
|
1732 | 4c9649a9 | j_mayer | case 0xF000: |
1733 | 4c9649a9 | j_mayer | /* RS */
|
1734 | 3761035f | aurel32 | if (ra != 31) |
1735 | a7812ae4 | pbrook | gen_helper_rs(cpu_ir[ra]); |
1736 | 4c9649a9 | j_mayer | break;
|
1737 | 4c9649a9 | j_mayer | case 0xF800: |
1738 | 4c9649a9 | j_mayer | /* WH64 */
|
1739 | 4c9649a9 | j_mayer | /* No-op */
|
1740 | 4c9649a9 | j_mayer | break;
|
1741 | 4c9649a9 | j_mayer | default:
|
1742 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1743 | 4c9649a9 | j_mayer | } |
1744 | 4c9649a9 | j_mayer | break;
|
1745 | 4c9649a9 | j_mayer | case 0x19: |
1746 | 4c9649a9 | j_mayer | /* HW_MFPR (PALcode) */
|
1747 | 4c9649a9 | j_mayer | #if defined (CONFIG_USER_ONLY)
|
1748 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1749 | 4c9649a9 | j_mayer | #else
|
1750 | 4c9649a9 | j_mayer | if (!ctx->pal_mode)
|
1751 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1752 | 8bb6e981 | aurel32 | if (ra != 31) { |
1753 | 8bb6e981 | aurel32 | TCGv tmp = tcg_const_i32(insn & 0xFF);
|
1754 | a7812ae4 | pbrook | gen_helper_mfpr(cpu_ir[ra], tmp, cpu_ir[ra]); |
1755 | 8bb6e981 | aurel32 | tcg_temp_free(tmp); |
1756 | 8bb6e981 | aurel32 | } |
1757 | 4c9649a9 | j_mayer | break;
|
1758 | 4c9649a9 | j_mayer | #endif
|
1759 | 4c9649a9 | j_mayer | case 0x1A: |
1760 | 3761035f | aurel32 | if (rb != 31) |
1761 | 3761035f | aurel32 | tcg_gen_andi_i64(cpu_pc, cpu_ir[rb], ~3);
|
1762 | 3761035f | aurel32 | else
|
1763 | 3761035f | aurel32 | tcg_gen_movi_i64(cpu_pc, 0);
|
1764 | 1304ca87 | aurel32 | if (ra != 31) |
1765 | 1304ca87 | aurel32 | tcg_gen_movi_i64(cpu_ir[ra], ctx->pc); |
1766 | 4c9649a9 | j_mayer | /* Those four jumps only differ by the branch prediction hint */
|
1767 | 4c9649a9 | j_mayer | switch (fn2) {
|
1768 | 4c9649a9 | j_mayer | case 0x0: |
1769 | 4c9649a9 | j_mayer | /* JMP */
|
1770 | 4c9649a9 | j_mayer | break;
|
1771 | 4c9649a9 | j_mayer | case 0x1: |
1772 | 4c9649a9 | j_mayer | /* JSR */
|
1773 | 4c9649a9 | j_mayer | break;
|
1774 | 4c9649a9 | j_mayer | case 0x2: |
1775 | 4c9649a9 | j_mayer | /* RET */
|
1776 | 4c9649a9 | j_mayer | break;
|
1777 | 4c9649a9 | j_mayer | case 0x3: |
1778 | 4c9649a9 | j_mayer | /* JSR_COROUTINE */
|
1779 | 4c9649a9 | j_mayer | break;
|
1780 | 4c9649a9 | j_mayer | } |
1781 | 4c9649a9 | j_mayer | ret = 1;
|
1782 | 4c9649a9 | j_mayer | break;
|
1783 | 4c9649a9 | j_mayer | case 0x1B: |
1784 | 4c9649a9 | j_mayer | /* HW_LD (PALcode) */
|
1785 | 4c9649a9 | j_mayer | #if defined (CONFIG_USER_ONLY)
|
1786 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1787 | 4c9649a9 | j_mayer | #else
|
1788 | 4c9649a9 | j_mayer | if (!ctx->pal_mode)
|
1789 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1790 | 8bb6e981 | aurel32 | if (ra != 31) { |
1791 | a7812ae4 | pbrook | TCGv addr = tcg_temp_new(); |
1792 | 8bb6e981 | aurel32 | if (rb != 31) |
1793 | 8bb6e981 | aurel32 | tcg_gen_addi_i64(addr, cpu_ir[rb], disp12); |
1794 | 8bb6e981 | aurel32 | else
|
1795 | 8bb6e981 | aurel32 | tcg_gen_movi_i64(addr, disp12); |
1796 | 8bb6e981 | aurel32 | switch ((insn >> 12) & 0xF) { |
1797 | 8bb6e981 | aurel32 | case 0x0: |
1798 | b5d51029 | aurel32 | /* Longword physical access (hw_ldl/p) */
|
1799 | a7812ae4 | pbrook | gen_helper_ldl_raw(cpu_ir[ra], addr); |
1800 | 8bb6e981 | aurel32 | break;
|
1801 | 8bb6e981 | aurel32 | case 0x1: |
1802 | b5d51029 | aurel32 | /* Quadword physical access (hw_ldq/p) */
|
1803 | a7812ae4 | pbrook | gen_helper_ldq_raw(cpu_ir[ra], addr); |
1804 | 8bb6e981 | aurel32 | break;
|
1805 | 8bb6e981 | aurel32 | case 0x2: |
1806 | b5d51029 | aurel32 | /* Longword physical access with lock (hw_ldl_l/p) */
|
1807 | a7812ae4 | pbrook | gen_helper_ldl_l_raw(cpu_ir[ra], addr); |
1808 | 8bb6e981 | aurel32 | break;
|
1809 | 8bb6e981 | aurel32 | case 0x3: |
1810 | b5d51029 | aurel32 | /* Quadword physical access with lock (hw_ldq_l/p) */
|
1811 | a7812ae4 | pbrook | gen_helper_ldq_l_raw(cpu_ir[ra], addr); |
1812 | 8bb6e981 | aurel32 | break;
|
1813 | 8bb6e981 | aurel32 | case 0x4: |
1814 | b5d51029 | aurel32 | /* Longword virtual PTE fetch (hw_ldl/v) */
|
1815 | b5d51029 | aurel32 | tcg_gen_qemu_ld32s(cpu_ir[ra], addr, 0);
|
1816 | 8bb6e981 | aurel32 | break;
|
1817 | 8bb6e981 | aurel32 | case 0x5: |
1818 | b5d51029 | aurel32 | /* Quadword virtual PTE fetch (hw_ldq/v) */
|
1819 | b5d51029 | aurel32 | tcg_gen_qemu_ld64(cpu_ir[ra], addr, 0);
|
1820 | 8bb6e981 | aurel32 | break;
|
1821 | 8bb6e981 | aurel32 | case 0x6: |
1822 | 8bb6e981 | aurel32 | /* Incpu_ir[ra]id */
|
1823 | b5d51029 | aurel32 | goto invalid_opc;
|
1824 | 8bb6e981 | aurel32 | case 0x7: |
1825 | 8bb6e981 | aurel32 | /* Incpu_ir[ra]id */
|
1826 | b5d51029 | aurel32 | goto invalid_opc;
|
1827 | 8bb6e981 | aurel32 | case 0x8: |
1828 | b5d51029 | aurel32 | /* Longword virtual access (hw_ldl) */
|
1829 | a7812ae4 | pbrook | gen_helper_st_virt_to_phys(addr, addr); |
1830 | a7812ae4 | pbrook | gen_helper_ldl_raw(cpu_ir[ra], addr); |
1831 | 8bb6e981 | aurel32 | break;
|
1832 | 8bb6e981 | aurel32 | case 0x9: |
1833 | b5d51029 | aurel32 | /* Quadword virtual access (hw_ldq) */
|
1834 | a7812ae4 | pbrook | gen_helper_st_virt_to_phys(addr, addr); |
1835 | a7812ae4 | pbrook | gen_helper_ldq_raw(cpu_ir[ra], addr); |
1836 | 8bb6e981 | aurel32 | break;
|
1837 | 8bb6e981 | aurel32 | case 0xA: |
1838 | b5d51029 | aurel32 | /* Longword virtual access with protection check (hw_ldl/w) */
|
1839 | b5d51029 | aurel32 | tcg_gen_qemu_ld32s(cpu_ir[ra], addr, 0);
|
1840 | 8bb6e981 | aurel32 | break;
|
1841 | 8bb6e981 | aurel32 | case 0xB: |
1842 | b5d51029 | aurel32 | /* Quadword virtual access with protection check (hw_ldq/w) */
|
1843 | b5d51029 | aurel32 | tcg_gen_qemu_ld64(cpu_ir[ra], addr, 0);
|
1844 | 8bb6e981 | aurel32 | break;
|
1845 | 8bb6e981 | aurel32 | case 0xC: |
1846 | b5d51029 | aurel32 | /* Longword virtual access with alt access mode (hw_ldl/a)*/
|
1847 | a7812ae4 | pbrook | gen_helper_set_alt_mode(); |
1848 | a7812ae4 | pbrook | gen_helper_st_virt_to_phys(addr, addr); |
1849 | a7812ae4 | pbrook | gen_helper_ldl_raw(cpu_ir[ra], addr); |
1850 | a7812ae4 | pbrook | gen_helper_restore_mode(); |
1851 | 8bb6e981 | aurel32 | break;
|
1852 | 8bb6e981 | aurel32 | case 0xD: |
1853 | b5d51029 | aurel32 | /* Quadword virtual access with alt access mode (hw_ldq/a) */
|
1854 | a7812ae4 | pbrook | gen_helper_set_alt_mode(); |
1855 | a7812ae4 | pbrook | gen_helper_st_virt_to_phys(addr, addr); |
1856 | a7812ae4 | pbrook | gen_helper_ldq_raw(cpu_ir[ra], addr); |
1857 | a7812ae4 | pbrook | gen_helper_restore_mode(); |
1858 | 8bb6e981 | aurel32 | break;
|
1859 | 8bb6e981 | aurel32 | case 0xE: |
1860 | 8bb6e981 | aurel32 | /* Longword virtual access with alternate access mode and
|
1861 | b5d51029 | aurel32 | * protection checks (hw_ldl/wa)
|
1862 | 8bb6e981 | aurel32 | */
|
1863 | a7812ae4 | pbrook | gen_helper_set_alt_mode(); |
1864 | a7812ae4 | pbrook | gen_helper_ldl_data(cpu_ir[ra], addr); |
1865 | a7812ae4 | pbrook | gen_helper_restore_mode(); |
1866 | 8bb6e981 | aurel32 | break;
|
1867 | 8bb6e981 | aurel32 | case 0xF: |
1868 | 8bb6e981 | aurel32 | /* Quadword virtual access with alternate access mode and
|
1869 | b5d51029 | aurel32 | * protection checks (hw_ldq/wa)
|
1870 | 8bb6e981 | aurel32 | */
|
1871 | a7812ae4 | pbrook | gen_helper_set_alt_mode(); |
1872 | a7812ae4 | pbrook | gen_helper_ldq_data(cpu_ir[ra], addr); |
1873 | a7812ae4 | pbrook | gen_helper_restore_mode(); |
1874 | 8bb6e981 | aurel32 | break;
|
1875 | 8bb6e981 | aurel32 | } |
1876 | 8bb6e981 | aurel32 | tcg_temp_free(addr); |
1877 | 4c9649a9 | j_mayer | } |
1878 | 4c9649a9 | j_mayer | break;
|
1879 | 4c9649a9 | j_mayer | #endif
|
1880 | 4c9649a9 | j_mayer | case 0x1C: |
1881 | 4c9649a9 | j_mayer | switch (fn7) {
|
1882 | 4c9649a9 | j_mayer | case 0x00: |
1883 | 4c9649a9 | j_mayer | /* SEXTB */
|
1884 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_BWX))
|
1885 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1886 | ae8ecd42 | aurel32 | if (likely(rc != 31)) { |
1887 | ae8ecd42 | aurel32 | if (islit)
|
1888 | ae8ecd42 | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], (int64_t)((int8_t)lit)); |
1889 | ae8ecd42 | aurel32 | else
|
1890 | dfaa8583 | aurel32 | tcg_gen_ext8s_i64(cpu_ir[rc], cpu_ir[rb]); |
1891 | ae8ecd42 | aurel32 | } |
1892 | 4c9649a9 | j_mayer | break;
|
1893 | 4c9649a9 | j_mayer | case 0x01: |
1894 | 4c9649a9 | j_mayer | /* SEXTW */
|
1895 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_BWX))
|
1896 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1897 | ae8ecd42 | aurel32 | if (likely(rc != 31)) { |
1898 | ae8ecd42 | aurel32 | if (islit)
|
1899 | ae8ecd42 | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], (int64_t)((int16_t)lit)); |
1900 | ae8ecd42 | aurel32 | else
|
1901 | dfaa8583 | aurel32 | tcg_gen_ext16s_i64(cpu_ir[rc], cpu_ir[rb]); |
1902 | ae8ecd42 | aurel32 | } |
1903 | 4c9649a9 | j_mayer | break;
|
1904 | 4c9649a9 | j_mayer | case 0x30: |
1905 | 4c9649a9 | j_mayer | /* CTPOP */
|
1906 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_CIX))
|
1907 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1908 | ae8ecd42 | aurel32 | if (likely(rc != 31)) { |
1909 | ae8ecd42 | aurel32 | if (islit)
|
1910 | ae8ecd42 | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], ctpop64(lit)); |
1911 | ae8ecd42 | aurel32 | else
|
1912 | a7812ae4 | pbrook | gen_helper_ctpop(cpu_ir[rc], cpu_ir[rb]); |
1913 | ae8ecd42 | aurel32 | } |
1914 | 4c9649a9 | j_mayer | break;
|
1915 | 4c9649a9 | j_mayer | case 0x31: |
1916 | 4c9649a9 | j_mayer | /* PERR */
|
1917 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_MVI))
|
1918 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1919 | 4c9649a9 | j_mayer | /* XXX: TODO */
|
1920 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1921 | 4c9649a9 | j_mayer | break;
|
1922 | 4c9649a9 | j_mayer | case 0x32: |
1923 | 4c9649a9 | j_mayer | /* CTLZ */
|
1924 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_CIX))
|
1925 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1926 | ae8ecd42 | aurel32 | if (likely(rc != 31)) { |
1927 | ae8ecd42 | aurel32 | if (islit)
|
1928 | ae8ecd42 | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], clz64(lit)); |
1929 | ae8ecd42 | aurel32 | else
|
1930 | a7812ae4 | pbrook | gen_helper_ctlz(cpu_ir[rc], cpu_ir[rb]); |
1931 | ae8ecd42 | aurel32 | } |
1932 | 4c9649a9 | j_mayer | break;
|
1933 | 4c9649a9 | j_mayer | case 0x33: |
1934 | 4c9649a9 | j_mayer | /* CTTZ */
|
1935 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_CIX))
|
1936 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1937 | ae8ecd42 | aurel32 | if (likely(rc != 31)) { |
1938 | ae8ecd42 | aurel32 | if (islit)
|
1939 | ae8ecd42 | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], ctz64(lit)); |
1940 | ae8ecd42 | aurel32 | else
|
1941 | a7812ae4 | pbrook | gen_helper_cttz(cpu_ir[rc], cpu_ir[rb]); |
1942 | ae8ecd42 | aurel32 | } |
1943 | 4c9649a9 | j_mayer | break;
|
1944 | 4c9649a9 | j_mayer | case 0x34: |
1945 | 4c9649a9 | j_mayer | /* UNPKBW */
|
1946 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_MVI))
|
1947 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1948 | 4c9649a9 | j_mayer | /* XXX: TODO */
|
1949 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1950 | 4c9649a9 | j_mayer | break;
|
1951 | 4c9649a9 | j_mayer | case 0x35: |
1952 | 4c9649a9 | j_mayer | /* UNPKWL */
|
1953 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_MVI))
|
1954 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1955 | 4c9649a9 | j_mayer | /* XXX: TODO */
|
1956 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1957 | 4c9649a9 | j_mayer | break;
|
1958 | 4c9649a9 | j_mayer | case 0x36: |
1959 | 4c9649a9 | j_mayer | /* PKWB */
|
1960 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_MVI))
|
1961 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1962 | 4c9649a9 | j_mayer | /* XXX: TODO */
|
1963 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1964 | 4c9649a9 | j_mayer | break;
|
1965 | 4c9649a9 | j_mayer | case 0x37: |
1966 | 4c9649a9 | j_mayer | /* PKLB */
|
1967 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_MVI))
|
1968 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1969 | 4c9649a9 | j_mayer | /* XXX: TODO */
|
1970 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1971 | 4c9649a9 | j_mayer | break;
|
1972 | 4c9649a9 | j_mayer | case 0x38: |
1973 | 4c9649a9 | j_mayer | /* MINSB8 */
|
1974 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_MVI))
|
1975 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1976 | 4c9649a9 | j_mayer | /* XXX: TODO */
|
1977 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1978 | 4c9649a9 | j_mayer | break;
|
1979 | 4c9649a9 | j_mayer | case 0x39: |
1980 | 4c9649a9 | j_mayer | /* MINSW4 */
|
1981 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_MVI))
|
1982 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1983 | 4c9649a9 | j_mayer | /* XXX: TODO */
|
1984 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1985 | 4c9649a9 | j_mayer | break;
|
1986 | 4c9649a9 | j_mayer | case 0x3A: |
1987 | 4c9649a9 | j_mayer | /* MINUB8 */
|
1988 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_MVI))
|
1989 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1990 | 4c9649a9 | j_mayer | /* XXX: TODO */
|
1991 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1992 | 4c9649a9 | j_mayer | break;
|
1993 | 4c9649a9 | j_mayer | case 0x3B: |
1994 | 4c9649a9 | j_mayer | /* MINUW4 */
|
1995 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_MVI))
|
1996 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1997 | 4c9649a9 | j_mayer | /* XXX: TODO */
|
1998 | 4c9649a9 | j_mayer | goto invalid_opc;
|
1999 | 4c9649a9 | j_mayer | break;
|
2000 | 4c9649a9 | j_mayer | case 0x3C: |
2001 | 4c9649a9 | j_mayer | /* MAXUB8 */
|
2002 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_MVI))
|
2003 | 4c9649a9 | j_mayer | goto invalid_opc;
|
2004 | 4c9649a9 | j_mayer | /* XXX: TODO */
|
2005 | 4c9649a9 | j_mayer | goto invalid_opc;
|
2006 | 4c9649a9 | j_mayer | break;
|
2007 | 4c9649a9 | j_mayer | case 0x3D: |
2008 | 4c9649a9 | j_mayer | /* MAXUW4 */
|
2009 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_MVI))
|
2010 | 4c9649a9 | j_mayer | goto invalid_opc;
|
2011 | 4c9649a9 | j_mayer | /* XXX: TODO */
|
2012 | 4c9649a9 | j_mayer | goto invalid_opc;
|
2013 | 4c9649a9 | j_mayer | break;
|
2014 | 4c9649a9 | j_mayer | case 0x3E: |
2015 | 4c9649a9 | j_mayer | /* MAXSB8 */
|
2016 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_MVI))
|
2017 | 4c9649a9 | j_mayer | goto invalid_opc;
|
2018 | 4c9649a9 | j_mayer | /* XXX: TODO */
|
2019 | 4c9649a9 | j_mayer | goto invalid_opc;
|
2020 | 4c9649a9 | j_mayer | break;
|
2021 | 4c9649a9 | j_mayer | case 0x3F: |
2022 | 4c9649a9 | j_mayer | /* MAXSW4 */
|
2023 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_MVI))
|
2024 | 4c9649a9 | j_mayer | goto invalid_opc;
|
2025 | 4c9649a9 | j_mayer | /* XXX: TODO */
|
2026 | 4c9649a9 | j_mayer | goto invalid_opc;
|
2027 | 4c9649a9 | j_mayer | break;
|
2028 | 4c9649a9 | j_mayer | case 0x70: |
2029 | 4c9649a9 | j_mayer | /* FTOIT */
|
2030 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_FIX))
|
2031 | 4c9649a9 | j_mayer | goto invalid_opc;
|
2032 | f18cd223 | aurel32 | if (likely(rc != 31)) { |
2033 | f18cd223 | aurel32 | if (ra != 31) |
2034 | f18cd223 | aurel32 | tcg_gen_mov_i64(cpu_ir[rc], cpu_fir[ra]); |
2035 | f18cd223 | aurel32 | else
|
2036 | f18cd223 | aurel32 | tcg_gen_movi_i64(cpu_ir[rc], 0);
|
2037 | f18cd223 | aurel32 | } |
2038 | 4c9649a9 | j_mayer | break;
|
2039 | 4c9649a9 | j_mayer | case 0x78: |
2040 | 4c9649a9 | j_mayer | /* FTOIS */
|
2041 | 4c9649a9 | j_mayer | if (!(ctx->amask & AMASK_FIX))
|
2042 | 4c9649a9 | j_mayer | goto invalid_opc;
|
2043 | f18cd223 | aurel32 | if (rc != 31) { |
2044 | a7812ae4 | pbrook | TCGv_i32 tmp1 = tcg_temp_new_i32(); |
2045 | f18cd223 | aurel32 | if (ra != 31) |
2046 | a7812ae4 | pbrook | gen_helper_s_to_memory(tmp1, cpu_fir[ra]); |
2047 | f18cd223 | aurel32 | else {
|
2048 | f18cd223 | aurel32 | TCGv tmp2 = tcg_const_i64(0);
|
2049 | a7812ae4 | pbrook | gen_helper_s_to_memory(tmp1, tmp2); |
2050 | f18cd223 | aurel32 | tcg_temp_free(tmp2); |
2051 | f18cd223 | aurel32 | } |
2052 | f18cd223 | aurel32 | tcg_gen_ext_i32_i64(cpu_ir[rc], tmp1); |
2053 | a7812ae4 | pbrook | tcg_temp_free_i32(tmp1); |
2054 | f18cd223 | aurel32 | } |
2055 | 4c9649a9 | j_mayer | break;
|
2056 | 4c9649a9 | j_mayer | default:
|
2057 | 4c9649a9 | j_mayer | goto invalid_opc;
|
2058 | 4c9649a9 | j_mayer | } |
2059 | 4c9649a9 | j_mayer | break;
|
2060 | 4c9649a9 | j_mayer | case 0x1D: |
2061 | 4c9649a9 | j_mayer | /* HW_MTPR (PALcode) */
|
2062 | 4c9649a9 | j_mayer | #if defined (CONFIG_USER_ONLY)
|
2063 | 4c9649a9 | j_mayer | goto invalid_opc;
|
2064 | 4c9649a9 | j_mayer | #else
|
2065 | 4c9649a9 | j_mayer | if (!ctx->pal_mode)
|
2066 | 4c9649a9 | j_mayer | goto invalid_opc;
|
2067 | 8bb6e981 | aurel32 | else {
|
2068 | 8bb6e981 | aurel32 | TCGv tmp1 = tcg_const_i32(insn & 0xFF);
|
2069 | 8bb6e981 | aurel32 | if (ra != 31) |
2070 | a7812ae4 | pbrook | gen_helper_mtpr(tmp1, cpu_ir[ra]); |
2071 | 8bb6e981 | aurel32 | else {
|
2072 | 8bb6e981 | aurel32 | TCGv tmp2 = tcg_const_i64(0);
|
2073 | a7812ae4 | pbrook | gen_helper_mtpr(tmp1, tmp2); |
2074 | 8bb6e981 | aurel32 | tcg_temp_free(tmp2); |
2075 | 8bb6e981 | aurel32 | } |
2076 | 8bb6e981 | aurel32 | tcg_temp_free(tmp1); |
2077 | 8bb6e981 | aurel32 | ret = 2;
|
2078 | 8bb6e981 | aurel32 | } |
2079 | 4c9649a9 | j_mayer | break;
|
2080 | 4c9649a9 | j_mayer | #endif
|
2081 | 4c9649a9 | j_mayer | case 0x1E: |
2082 | 4c9649a9 | j_mayer | /* HW_REI (PALcode) */
|
2083 | 4c9649a9 | j_mayer | #if defined (CONFIG_USER_ONLY)
|
2084 | 4c9649a9 | j_mayer | goto invalid_opc;
|
2085 | 4c9649a9 | j_mayer | #else
|
2086 | 4c9649a9 | j_mayer | if (!ctx->pal_mode)
|
2087 | 4c9649a9 | j_mayer | goto invalid_opc;
|
2088 | 4c9649a9 | j_mayer | if (rb == 31) { |
2089 | 4c9649a9 | j_mayer | /* "Old" alpha */
|
2090 | a7812ae4 | pbrook | gen_helper_hw_rei(); |
2091 | 4c9649a9 | j_mayer | } else {
|
2092 | 8bb6e981 | aurel32 | TCGv tmp; |
2093 | 8bb6e981 | aurel32 | |
2094 | 8bb6e981 | aurel32 | if (ra != 31) { |
2095 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
2096 | 8bb6e981 | aurel32 | tcg_gen_addi_i64(tmp, cpu_ir[rb], (((int64_t)insn << 51) >> 51)); |
2097 | 8bb6e981 | aurel32 | } else
|
2098 | 8bb6e981 | aurel32 | tmp = tcg_const_i64(((int64_t)insn << 51) >> 51); |
2099 | a7812ae4 | pbrook | gen_helper_hw_ret(tmp); |
2100 | 8bb6e981 | aurel32 | tcg_temp_free(tmp); |
2101 | 4c9649a9 | j_mayer | } |
2102 | 4c9649a9 | j_mayer | ret = 2;
|
2103 | 4c9649a9 | j_mayer | break;
|
2104 | 4c9649a9 | j_mayer | #endif
|
2105 | 4c9649a9 | j_mayer | case 0x1F: |
2106 | 4c9649a9 | j_mayer | /* HW_ST (PALcode) */
|
2107 | 4c9649a9 | j_mayer | #if defined (CONFIG_USER_ONLY)
|
2108 | 4c9649a9 | j_mayer | goto invalid_opc;
|
2109 | 4c9649a9 | j_mayer | #else
|
2110 | 4c9649a9 | j_mayer | if (!ctx->pal_mode)
|
2111 | 4c9649a9 | j_mayer | goto invalid_opc;
|
2112 | 8bb6e981 | aurel32 | else {
|
2113 | 8bb6e981 | aurel32 | TCGv addr, val; |
2114 | a7812ae4 | pbrook | addr = tcg_temp_new(); |
2115 | 8bb6e981 | aurel32 | if (rb != 31) |
2116 | 8bb6e981 | aurel32 | tcg_gen_addi_i64(addr, cpu_ir[rb], disp12); |
2117 | 8bb6e981 | aurel32 | else
|
2118 | 8bb6e981 | aurel32 | tcg_gen_movi_i64(addr, disp12); |
2119 | 8bb6e981 | aurel32 | if (ra != 31) |
2120 | 8bb6e981 | aurel32 | val = cpu_ir[ra]; |
2121 | 8bb6e981 | aurel32 | else {
|
2122 | a7812ae4 | pbrook | val = tcg_temp_new(); |
2123 | 8bb6e981 | aurel32 | tcg_gen_movi_i64(val, 0);
|
2124 | 8bb6e981 | aurel32 | } |
2125 | 8bb6e981 | aurel32 | switch ((insn >> 12) & 0xF) { |
2126 | 8bb6e981 | aurel32 | case 0x0: |
2127 | 8bb6e981 | aurel32 | /* Longword physical access */
|
2128 | a7812ae4 | pbrook | gen_helper_stl_raw(val, addr); |
2129 | 8bb6e981 | aurel32 | break;
|
2130 | 8bb6e981 | aurel32 | case 0x1: |
2131 | 8bb6e981 | aurel32 | /* Quadword physical access */
|
2132 | a7812ae4 | pbrook | gen_helper_stq_raw(val, addr); |
2133 | 8bb6e981 | aurel32 | break;
|
2134 | 8bb6e981 | aurel32 | case 0x2: |
2135 | 8bb6e981 | aurel32 | /* Longword physical access with lock */
|
2136 | a7812ae4 | pbrook | gen_helper_stl_c_raw(val, val, addr); |
2137 | 8bb6e981 | aurel32 | break;
|
2138 | 8bb6e981 | aurel32 | case 0x3: |
2139 | 8bb6e981 | aurel32 | /* Quadword physical access with lock */
|
2140 | a7812ae4 | pbrook | gen_helper_stq_c_raw(val, val, addr); |
2141 | 8bb6e981 | aurel32 | break;
|
2142 | 8bb6e981 | aurel32 | case 0x4: |
2143 | 8bb6e981 | aurel32 | /* Longword virtual access */
|
2144 | a7812ae4 | pbrook | gen_helper_st_virt_to_phys(addr, addr); |
2145 | a7812ae4 | pbrook | gen_helper_stl_raw(val, addr); |
2146 | 8bb6e981 | aurel32 | break;
|
2147 | 8bb6e981 | aurel32 | case 0x5: |
2148 | 8bb6e981 | aurel32 | /* Quadword virtual access */
|
2149 | a7812ae4 | pbrook | gen_helper_st_virt_to_phys(addr, addr); |
2150 | a7812ae4 | pbrook | gen_helper_stq_raw(val, addr); |
2151 | 8bb6e981 | aurel32 | break;
|
2152 | 8bb6e981 | aurel32 | case 0x6: |
2153 | 8bb6e981 | aurel32 | /* Invalid */
|
2154 | 8bb6e981 | aurel32 | goto invalid_opc;
|
2155 | 8bb6e981 | aurel32 | case 0x7: |
2156 | 8bb6e981 | aurel32 | /* Invalid */
|
2157 | 8bb6e981 | aurel32 | goto invalid_opc;
|
2158 | 8bb6e981 | aurel32 | case 0x8: |
2159 | 8bb6e981 | aurel32 | /* Invalid */
|
2160 | 8bb6e981 | aurel32 | goto invalid_opc;
|
2161 | 8bb6e981 | aurel32 | case 0x9: |
2162 | 8bb6e981 | aurel32 | /* Invalid */
|
2163 | 8bb6e981 | aurel32 | goto invalid_opc;
|
2164 | 8bb6e981 | aurel32 | case 0xA: |
2165 | 8bb6e981 | aurel32 | /* Invalid */
|
2166 | 8bb6e981 | aurel32 | goto invalid_opc;
|
2167 | 8bb6e981 | aurel32 | case 0xB: |
2168 | 8bb6e981 | aurel32 | /* Invalid */
|
2169 | 8bb6e981 | aurel32 | goto invalid_opc;
|
2170 | 8bb6e981 | aurel32 | case 0xC: |
2171 | 8bb6e981 | aurel32 | /* Longword virtual access with alternate access mode */
|
2172 | a7812ae4 | pbrook | gen_helper_set_alt_mode(); |
2173 | a7812ae4 | pbrook | gen_helper_st_virt_to_phys(addr, addr); |
2174 | a7812ae4 | pbrook | gen_helper_stl_raw(val, addr); |
2175 | a7812ae4 | pbrook | gen_helper_restore_mode(); |
2176 | 8bb6e981 | aurel32 | break;
|
2177 | 8bb6e981 | aurel32 | case 0xD: |
2178 | 8bb6e981 | aurel32 | /* Quadword virtual access with alternate access mode */
|
2179 | a7812ae4 | pbrook | gen_helper_set_alt_mode(); |
2180 | a7812ae4 | pbrook | gen_helper_st_virt_to_phys(addr, addr); |
2181 | a7812ae4 | pbrook | gen_helper_stl_raw(val, addr); |
2182 | a7812ae4 | pbrook | gen_helper_restore_mode(); |
2183 | 8bb6e981 | aurel32 | break;
|
2184 | 8bb6e981 | aurel32 | case 0xE: |
2185 | 8bb6e981 | aurel32 | /* Invalid */
|
2186 | 8bb6e981 | aurel32 | goto invalid_opc;
|
2187 | 8bb6e981 | aurel32 | case 0xF: |
2188 | 8bb6e981 | aurel32 | /* Invalid */
|
2189 | 8bb6e981 | aurel32 | goto invalid_opc;
|
2190 | 8bb6e981 | aurel32 | } |
2191 | 45d46ce8 | aurel32 | if (ra == 31) |
2192 | 8bb6e981 | aurel32 | tcg_temp_free(val); |
2193 | 8bb6e981 | aurel32 | tcg_temp_free(addr); |
2194 | 4c9649a9 | j_mayer | } |
2195 | 4c9649a9 | j_mayer | break;
|
2196 | 4c9649a9 | j_mayer | #endif
|
2197 | 4c9649a9 | j_mayer | case 0x20: |
2198 | 4c9649a9 | j_mayer | /* LDF */
|
2199 | f18cd223 | aurel32 | gen_load_mem(ctx, &gen_qemu_ldf, ra, rb, disp16, 1, 0); |
2200 | 4c9649a9 | j_mayer | break;
|
2201 | 4c9649a9 | j_mayer | case 0x21: |
2202 | 4c9649a9 | j_mayer | /* LDG */
|
2203 | f18cd223 | aurel32 | gen_load_mem(ctx, &gen_qemu_ldg, ra, rb, disp16, 1, 0); |
2204 | 4c9649a9 | j_mayer | break;
|
2205 | 4c9649a9 | j_mayer | case 0x22: |
2206 | 4c9649a9 | j_mayer | /* LDS */
|
2207 | f18cd223 | aurel32 | gen_load_mem(ctx, &gen_qemu_lds, ra, rb, disp16, 1, 0); |
2208 | 4c9649a9 | j_mayer | break;
|
2209 | 4c9649a9 | j_mayer | case 0x23: |
2210 | 4c9649a9 | j_mayer | /* LDT */
|
2211 | f18cd223 | aurel32 | gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 1, 0); |
2212 | 4c9649a9 | j_mayer | break;
|
2213 | 4c9649a9 | j_mayer | case 0x24: |
2214 | 4c9649a9 | j_mayer | /* STF */
|
2215 | 57a92c8e | aurel32 | gen_store_mem(ctx, &gen_qemu_stf, ra, rb, disp16, 1, 0, 0); |
2216 | 4c9649a9 | j_mayer | break;
|
2217 | 4c9649a9 | j_mayer | case 0x25: |
2218 | 4c9649a9 | j_mayer | /* STG */
|
2219 | 57a92c8e | aurel32 | gen_store_mem(ctx, &gen_qemu_stg, ra, rb, disp16, 1, 0, 0); |
2220 | 4c9649a9 | j_mayer | break;
|
2221 | 4c9649a9 | j_mayer | case 0x26: |
2222 | 4c9649a9 | j_mayer | /* STS */
|
2223 | 57a92c8e | aurel32 | gen_store_mem(ctx, &gen_qemu_sts, ra, rb, disp16, 1, 0, 0); |
2224 | 4c9649a9 | j_mayer | break;
|
2225 | 4c9649a9 | j_mayer | case 0x27: |
2226 | 4c9649a9 | j_mayer | /* STT */
|
2227 | 57a92c8e | aurel32 | gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 1, 0, 0); |
2228 | 4c9649a9 | j_mayer | break;
|
2229 | 4c9649a9 | j_mayer | case 0x28: |
2230 | 4c9649a9 | j_mayer | /* LDL */
|
2231 | f18cd223 | aurel32 | gen_load_mem(ctx, &tcg_gen_qemu_ld32s, ra, rb, disp16, 0, 0); |
2232 | 4c9649a9 | j_mayer | break;
|
2233 | 4c9649a9 | j_mayer | case 0x29: |
2234 | 4c9649a9 | j_mayer | /* LDQ */
|
2235 | f18cd223 | aurel32 | gen_load_mem(ctx, &tcg_gen_qemu_ld64, ra, rb, disp16, 0, 0); |
2236 | 4c9649a9 | j_mayer | break;
|
2237 | 4c9649a9 | j_mayer | case 0x2A: |
2238 | 4c9649a9 | j_mayer | /* LDL_L */
|
2239 | f4ed8679 | aurel32 | gen_load_mem(ctx, &gen_qemu_ldl_l, ra, rb, disp16, 0, 0); |
2240 | 4c9649a9 | j_mayer | break;
|
2241 | 4c9649a9 | j_mayer | case 0x2B: |
2242 | 4c9649a9 | j_mayer | /* LDQ_L */
|
2243 | f4ed8679 | aurel32 | gen_load_mem(ctx, &gen_qemu_ldq_l, ra, rb, disp16, 0, 0); |
2244 | 4c9649a9 | j_mayer | break;
|
2245 | 4c9649a9 | j_mayer | case 0x2C: |
2246 | 4c9649a9 | j_mayer | /* STL */
|
2247 | 57a92c8e | aurel32 | gen_store_mem(ctx, &tcg_gen_qemu_st32, ra, rb, disp16, 0, 0, 0); |
2248 | 4c9649a9 | j_mayer | break;
|
2249 | 4c9649a9 | j_mayer | case 0x2D: |
2250 | 4c9649a9 | j_mayer | /* STQ */
|
2251 | 57a92c8e | aurel32 | gen_store_mem(ctx, &tcg_gen_qemu_st64, ra, rb, disp16, 0, 0, 0); |
2252 | 4c9649a9 | j_mayer | break;
|
2253 | 4c9649a9 | j_mayer | case 0x2E: |
2254 | 4c9649a9 | j_mayer | /* STL_C */
|
2255 | 57a92c8e | aurel32 | gen_store_mem(ctx, &gen_qemu_stl_c, ra, rb, disp16, 0, 0, 1); |
2256 | 4c9649a9 | j_mayer | break;
|
2257 | 4c9649a9 | j_mayer | case 0x2F: |
2258 | 4c9649a9 | j_mayer | /* STQ_C */
|
2259 | 57a92c8e | aurel32 | gen_store_mem(ctx, &gen_qemu_stq_c, ra, rb, disp16, 0, 0, 1); |
2260 | 4c9649a9 | j_mayer | break;
|
2261 | 4c9649a9 | j_mayer | case 0x30: |
2262 | 4c9649a9 | j_mayer | /* BR */
|
2263 | 3761035f | aurel32 | if (ra != 31) |
2264 | 3761035f | aurel32 | tcg_gen_movi_i64(cpu_ir[ra], ctx->pc); |
2265 | 3761035f | aurel32 | tcg_gen_movi_i64(cpu_pc, ctx->pc + (int64_t)(disp21 << 2));
|
2266 | 4c9649a9 | j_mayer | ret = 1;
|
2267 | 4c9649a9 | j_mayer | break;
|
2268 | a7812ae4 | pbrook | case 0x31: /* FBEQ */ |
2269 | a7812ae4 | pbrook | case 0x32: /* FBLT */ |
2270 | a7812ae4 | pbrook | case 0x33: /* FBLE */ |
2271 | a7812ae4 | pbrook | gen_fbcond(ctx, opc, ra, disp16); |
2272 | 4c9649a9 | j_mayer | ret = 1;
|
2273 | 4c9649a9 | j_mayer | break;
|
2274 | 4c9649a9 | j_mayer | case 0x34: |
2275 | 4c9649a9 | j_mayer | /* BSR */
|
2276 | 3761035f | aurel32 | if (ra != 31) |
2277 | 3761035f | aurel32 | tcg_gen_movi_i64(cpu_ir[ra], ctx->pc); |
2278 | 3761035f | aurel32 | tcg_gen_movi_i64(cpu_pc, ctx->pc + (int64_t)(disp21 << 2));
|
2279 | 4c9649a9 | j_mayer | ret = 1;
|
2280 | 4c9649a9 | j_mayer | break;
|
2281 | a7812ae4 | pbrook | case 0x35: /* FBNE */ |
2282 | a7812ae4 | pbrook | case 0x36: /* FBGE */ |
2283 | a7812ae4 | pbrook | case 0x37: /* FBGT */ |
2284 | a7812ae4 | pbrook | gen_fbcond(ctx, opc, ra, disp16); |
2285 | 4c9649a9 | j_mayer | ret = 1;
|
2286 | 4c9649a9 | j_mayer | break;
|
2287 | 4c9649a9 | j_mayer | case 0x38: |
2288 | 4c9649a9 | j_mayer | /* BLBC */
|
2289 | a1516744 | aurel32 | gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 1);
|
2290 | 4c9649a9 | j_mayer | ret = 1;
|
2291 | 4c9649a9 | j_mayer | break;
|
2292 | 4c9649a9 | j_mayer | case 0x39: |
2293 | 4c9649a9 | j_mayer | /* BEQ */
|
2294 | a1516744 | aurel32 | gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 0);
|
2295 | 4c9649a9 | j_mayer | ret = 1;
|
2296 | 4c9649a9 | j_mayer | break;
|
2297 | 4c9649a9 | j_mayer | case 0x3A: |
2298 | 4c9649a9 | j_mayer | /* BLT */
|
2299 | a1516744 | aurel32 | gen_bcond(ctx, TCG_COND_LT, ra, disp21, 0);
|
2300 | 4c9649a9 | j_mayer | ret = 1;
|
2301 | 4c9649a9 | j_mayer | break;
|
2302 | 4c9649a9 | j_mayer | case 0x3B: |
2303 | 4c9649a9 | j_mayer | /* BLE */
|
2304 | a1516744 | aurel32 | gen_bcond(ctx, TCG_COND_LE, ra, disp21, 0);
|
2305 | 4c9649a9 | j_mayer | ret = 1;
|
2306 | 4c9649a9 | j_mayer | break;
|
2307 | 4c9649a9 | j_mayer | case 0x3C: |
2308 | 4c9649a9 | j_mayer | /* BLBS */
|
2309 | a1516744 | aurel32 | gen_bcond(ctx, TCG_COND_NE, ra, disp21, 1);
|
2310 | 4c9649a9 | j_mayer | ret = 1;
|
2311 | 4c9649a9 | j_mayer | break;
|
2312 | 4c9649a9 | j_mayer | case 0x3D: |
2313 | 4c9649a9 | j_mayer | /* BNE */
|
2314 | a1516744 | aurel32 | gen_bcond(ctx, TCG_COND_NE, ra, disp21, 0);
|
2315 | 4c9649a9 | j_mayer | ret = 1;
|
2316 | 4c9649a9 | j_mayer | break;
|
2317 | 4c9649a9 | j_mayer | case 0x3E: |
2318 | 4c9649a9 | j_mayer | /* BGE */
|
2319 | a1516744 | aurel32 | gen_bcond(ctx, TCG_COND_GE, ra, disp21, 0);
|
2320 | 4c9649a9 | j_mayer | ret = 1;
|
2321 | 4c9649a9 | j_mayer | break;
|
2322 | 4c9649a9 | j_mayer | case 0x3F: |
2323 | 4c9649a9 | j_mayer | /* BGT */
|
2324 | a1516744 | aurel32 | gen_bcond(ctx, TCG_COND_GT, ra, disp21, 0);
|
2325 | 4c9649a9 | j_mayer | ret = 1;
|
2326 | 4c9649a9 | j_mayer | break;
|
2327 | 4c9649a9 | j_mayer | invalid_opc:
|
2328 | 4c9649a9 | j_mayer | gen_invalid(ctx); |
2329 | 4c9649a9 | j_mayer | ret = 3;
|
2330 | 4c9649a9 | j_mayer | break;
|
2331 | 4c9649a9 | j_mayer | } |
2332 | 4c9649a9 | j_mayer | |
2333 | 4c9649a9 | j_mayer | return ret;
|
2334 | 4c9649a9 | j_mayer | } |
2335 | 4c9649a9 | j_mayer | |
2336 | 636aa200 | Blue Swirl | static inline void gen_intermediate_code_internal(CPUState *env, |
2337 | 636aa200 | Blue Swirl | TranslationBlock *tb, |
2338 | 636aa200 | Blue Swirl | int search_pc)
|
2339 | 4c9649a9 | j_mayer | { |
2340 | 4c9649a9 | j_mayer | #if defined ALPHA_DEBUG_DISAS
|
2341 | 4c9649a9 | j_mayer | static int insn_count; |
2342 | 4c9649a9 | j_mayer | #endif
|
2343 | 4c9649a9 | j_mayer | DisasContext ctx, *ctxp = &ctx; |
2344 | 4c9649a9 | j_mayer | target_ulong pc_start; |
2345 | 4c9649a9 | j_mayer | uint32_t insn; |
2346 | 4c9649a9 | j_mayer | uint16_t *gen_opc_end; |
2347 | a1d1bb31 | aliguori | CPUBreakpoint *bp; |
2348 | 4c9649a9 | j_mayer | int j, lj = -1; |
2349 | 4c9649a9 | j_mayer | int ret;
|
2350 | 2e70f6ef | pbrook | int num_insns;
|
2351 | 2e70f6ef | pbrook | int max_insns;
|
2352 | 4c9649a9 | j_mayer | |
2353 | 4c9649a9 | j_mayer | pc_start = tb->pc; |
2354 | 4c9649a9 | j_mayer | gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; |
2355 | 4c9649a9 | j_mayer | ctx.pc = pc_start; |
2356 | 4c9649a9 | j_mayer | ctx.amask = env->amask; |
2357 | 8579095b | aurel32 | ctx.env = env; |
2358 | 4c9649a9 | j_mayer | #if defined (CONFIG_USER_ONLY)
|
2359 | 4c9649a9 | j_mayer | ctx.mem_idx = 0;
|
2360 | 4c9649a9 | j_mayer | #else
|
2361 | 4c9649a9 | j_mayer | ctx.mem_idx = ((env->ps >> 3) & 3); |
2362 | 4c9649a9 | j_mayer | ctx.pal_mode = env->ipr[IPR_EXC_ADDR] & 1;
|
2363 | 4c9649a9 | j_mayer | #endif
|
2364 | 2e70f6ef | pbrook | num_insns = 0;
|
2365 | 2e70f6ef | pbrook | max_insns = tb->cflags & CF_COUNT_MASK; |
2366 | 2e70f6ef | pbrook | if (max_insns == 0) |
2367 | 2e70f6ef | pbrook | max_insns = CF_COUNT_MASK; |
2368 | 2e70f6ef | pbrook | |
2369 | 2e70f6ef | pbrook | gen_icount_start(); |
2370 | 4c9649a9 | j_mayer | for (ret = 0; ret == 0;) { |
2371 | 72cf2d4f | Blue Swirl | if (unlikely(!QTAILQ_EMPTY(&env->breakpoints))) {
|
2372 | 72cf2d4f | Blue Swirl | QTAILQ_FOREACH(bp, &env->breakpoints, entry) { |
2373 | a1d1bb31 | aliguori | if (bp->pc == ctx.pc) {
|
2374 | 4c9649a9 | j_mayer | gen_excp(&ctx, EXCP_DEBUG, 0);
|
2375 | 4c9649a9 | j_mayer | break;
|
2376 | 4c9649a9 | j_mayer | } |
2377 | 4c9649a9 | j_mayer | } |
2378 | 4c9649a9 | j_mayer | } |
2379 | 4c9649a9 | j_mayer | if (search_pc) {
|
2380 | 4c9649a9 | j_mayer | j = gen_opc_ptr - gen_opc_buf; |
2381 | 4c9649a9 | j_mayer | if (lj < j) {
|
2382 | 4c9649a9 | j_mayer | lj++; |
2383 | 4c9649a9 | j_mayer | while (lj < j)
|
2384 | 4c9649a9 | j_mayer | gen_opc_instr_start[lj++] = 0;
|
2385 | 4c9649a9 | j_mayer | } |
2386 | ed1dda53 | aurel32 | gen_opc_pc[lj] = ctx.pc; |
2387 | ed1dda53 | aurel32 | gen_opc_instr_start[lj] = 1;
|
2388 | ed1dda53 | aurel32 | gen_opc_icount[lj] = num_insns; |
2389 | 4c9649a9 | j_mayer | } |
2390 | 2e70f6ef | pbrook | if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) |
2391 | 2e70f6ef | pbrook | gen_io_start(); |
2392 | 4c9649a9 | j_mayer | #if defined ALPHA_DEBUG_DISAS
|
2393 | 4c9649a9 | j_mayer | insn_count++; |
2394 | d12d51d5 | aliguori | LOG_DISAS("pc " TARGET_FMT_lx " mem_idx %d\n", |
2395 | d12d51d5 | aliguori | ctx.pc, ctx.mem_idx); |
2396 | 4c9649a9 | j_mayer | #endif
|
2397 | 4c9649a9 | j_mayer | insn = ldl_code(ctx.pc); |
2398 | 4c9649a9 | j_mayer | #if defined ALPHA_DEBUG_DISAS
|
2399 | 4c9649a9 | j_mayer | insn_count++; |
2400 | d12d51d5 | aliguori | LOG_DISAS("opcode %08x %d\n", insn, insn_count);
|
2401 | 4c9649a9 | j_mayer | #endif
|
2402 | 2e70f6ef | pbrook | num_insns++; |
2403 | 4c9649a9 | j_mayer | ctx.pc += 4;
|
2404 | 4c9649a9 | j_mayer | ret = translate_one(ctxp, insn); |
2405 | 4c9649a9 | j_mayer | if (ret != 0) |
2406 | 4c9649a9 | j_mayer | break;
|
2407 | 4c9649a9 | j_mayer | /* if we reach a page boundary or are single stepping, stop
|
2408 | 4c9649a9 | j_mayer | * generation
|
2409 | 4c9649a9 | j_mayer | */
|
2410 | 19bf517b | aurel32 | if (env->singlestep_enabled) {
|
2411 | 19bf517b | aurel32 | gen_excp(&ctx, EXCP_DEBUG, 0);
|
2412 | 19bf517b | aurel32 | break;
|
2413 | 1b530a6d | aurel32 | } |
2414 | 19bf517b | aurel32 | |
2415 | 8fcc55f9 | aurel32 | if ((ctx.pc & (TARGET_PAGE_SIZE - 1)) == 0) |
2416 | 8fcc55f9 | aurel32 | break;
|
2417 | 8fcc55f9 | aurel32 | |
2418 | 8fcc55f9 | aurel32 | if (gen_opc_ptr >= gen_opc_end)
|
2419 | 8fcc55f9 | aurel32 | break;
|
2420 | 8fcc55f9 | aurel32 | |
2421 | 8fcc55f9 | aurel32 | if (num_insns >= max_insns)
|
2422 | 8fcc55f9 | aurel32 | break;
|
2423 | 8fcc55f9 | aurel32 | |
2424 | 1b530a6d | aurel32 | if (singlestep) {
|
2425 | 1b530a6d | aurel32 | break;
|
2426 | 1b530a6d | aurel32 | } |
2427 | 4c9649a9 | j_mayer | } |
2428 | 4c9649a9 | j_mayer | if (ret != 1 && ret != 3) { |
2429 | 496cb5b9 | aurel32 | tcg_gen_movi_i64(cpu_pc, ctx.pc); |
2430 | 4c9649a9 | j_mayer | } |
2431 | 4c9649a9 | j_mayer | #if defined (DO_TB_FLUSH)
|
2432 | a7812ae4 | pbrook | gen_helper_tb_flush(); |
2433 | 4c9649a9 | j_mayer | #endif
|
2434 | 2e70f6ef | pbrook | if (tb->cflags & CF_LAST_IO)
|
2435 | 2e70f6ef | pbrook | gen_io_end(); |
2436 | 4c9649a9 | j_mayer | /* Generate the return instruction */
|
2437 | 57fec1fe | bellard | tcg_gen_exit_tb(0);
|
2438 | 2e70f6ef | pbrook | gen_icount_end(tb, num_insns); |
2439 | 4c9649a9 | j_mayer | *gen_opc_ptr = INDEX_op_end; |
2440 | 4c9649a9 | j_mayer | if (search_pc) {
|
2441 | 4c9649a9 | j_mayer | j = gen_opc_ptr - gen_opc_buf; |
2442 | 4c9649a9 | j_mayer | lj++; |
2443 | 4c9649a9 | j_mayer | while (lj <= j)
|
2444 | 4c9649a9 | j_mayer | gen_opc_instr_start[lj++] = 0;
|
2445 | 4c9649a9 | j_mayer | } else {
|
2446 | 4c9649a9 | j_mayer | tb->size = ctx.pc - pc_start; |
2447 | 2e70f6ef | pbrook | tb->icount = num_insns; |
2448 | 4c9649a9 | j_mayer | } |
2449 | 4c9649a9 | j_mayer | #if defined ALPHA_DEBUG_DISAS
|
2450 | 93fcfe39 | aliguori | log_cpu_state_mask(CPU_LOG_TB_CPU, env, 0);
|
2451 | 8fec2b8c | aliguori | if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
|
2452 | 93fcfe39 | aliguori | qemu_log("IN: %s\n", lookup_symbol(pc_start));
|
2453 | 93fcfe39 | aliguori | log_target_disas(pc_start, ctx.pc - pc_start, 1);
|
2454 | 93fcfe39 | aliguori | qemu_log("\n");
|
2455 | 4c9649a9 | j_mayer | } |
2456 | 4c9649a9 | j_mayer | #endif
|
2457 | 4c9649a9 | j_mayer | } |
2458 | 4c9649a9 | j_mayer | |
2459 | 2cfc5f17 | ths | void gen_intermediate_code (CPUState *env, struct TranslationBlock *tb) |
2460 | 4c9649a9 | j_mayer | { |
2461 | 2cfc5f17 | ths | gen_intermediate_code_internal(env, tb, 0);
|
2462 | 4c9649a9 | j_mayer | } |
2463 | 4c9649a9 | j_mayer | |
2464 | 2cfc5f17 | ths | void gen_intermediate_code_pc (CPUState *env, struct TranslationBlock *tb) |
2465 | 4c9649a9 | j_mayer | { |
2466 | 2cfc5f17 | ths | gen_intermediate_code_internal(env, tb, 1);
|
2467 | 4c9649a9 | j_mayer | } |
2468 | 4c9649a9 | j_mayer | |
2469 | aaed909a | bellard | CPUAlphaState * cpu_alpha_init (const char *cpu_model) |
2470 | 4c9649a9 | j_mayer | { |
2471 | 4c9649a9 | j_mayer | CPUAlphaState *env; |
2472 | 4c9649a9 | j_mayer | uint64_t hwpcb; |
2473 | 4c9649a9 | j_mayer | |
2474 | 4c9649a9 | j_mayer | env = qemu_mallocz(sizeof(CPUAlphaState));
|
2475 | 4c9649a9 | j_mayer | cpu_exec_init(env); |
2476 | 2e70f6ef | pbrook | alpha_translate_init(); |
2477 | 4c9649a9 | j_mayer | tlb_flush(env, 1);
|
2478 | 4c9649a9 | j_mayer | /* XXX: should not be hardcoded */
|
2479 | 4c9649a9 | j_mayer | env->implver = IMPLVER_2106x; |
2480 | 4c9649a9 | j_mayer | env->ps = 0x1F00;
|
2481 | 4c9649a9 | j_mayer | #if defined (CONFIG_USER_ONLY)
|
2482 | 4c9649a9 | j_mayer | env->ps |= 1 << 3; |
2483 | 4c9649a9 | j_mayer | #endif
|
2484 | 4c9649a9 | j_mayer | pal_init(env); |
2485 | 4c9649a9 | j_mayer | /* Initialize IPR */
|
2486 | 4c9649a9 | j_mayer | hwpcb = env->ipr[IPR_PCBB]; |
2487 | 4c9649a9 | j_mayer | env->ipr[IPR_ASN] = 0;
|
2488 | 4c9649a9 | j_mayer | env->ipr[IPR_ASTEN] = 0;
|
2489 | 4c9649a9 | j_mayer | env->ipr[IPR_ASTSR] = 0;
|
2490 | 4c9649a9 | j_mayer | env->ipr[IPR_DATFX] = 0;
|
2491 | 4c9649a9 | j_mayer | /* XXX: fix this */
|
2492 | 4c9649a9 | j_mayer | // env->ipr[IPR_ESP] = ldq_raw(hwpcb + 8);
|
2493 | 4c9649a9 | j_mayer | // env->ipr[IPR_KSP] = ldq_raw(hwpcb + 0);
|
2494 | 4c9649a9 | j_mayer | // env->ipr[IPR_SSP] = ldq_raw(hwpcb + 16);
|
2495 | 4c9649a9 | j_mayer | // env->ipr[IPR_USP] = ldq_raw(hwpcb + 24);
|
2496 | 4c9649a9 | j_mayer | env->ipr[IPR_FEN] = 0;
|
2497 | 4c9649a9 | j_mayer | env->ipr[IPR_IPL] = 31;
|
2498 | 4c9649a9 | j_mayer | env->ipr[IPR_MCES] = 0;
|
2499 | 4c9649a9 | j_mayer | env->ipr[IPR_PERFMON] = 0; /* Implementation specific */ |
2500 | 4c9649a9 | j_mayer | // env->ipr[IPR_PTBR] = ldq_raw(hwpcb + 32);
|
2501 | 4c9649a9 | j_mayer | env->ipr[IPR_SISR] = 0;
|
2502 | 4c9649a9 | j_mayer | env->ipr[IPR_VIRBND] = -1ULL;
|
2503 | 4c9649a9 | j_mayer | |
2504 | 0bf46a40 | aliguori | qemu_init_vcpu(env); |
2505 | 4c9649a9 | j_mayer | return env;
|
2506 | 4c9649a9 | j_mayer | } |
2507 | aaed909a | bellard | |
2508 | d2856f1a | aurel32 | void gen_pc_load(CPUState *env, TranslationBlock *tb,
|
2509 | d2856f1a | aurel32 | unsigned long searched_pc, int pc_pos, void *puc) |
2510 | d2856f1a | aurel32 | { |
2511 | d2856f1a | aurel32 | env->pc = gen_opc_pc[pc_pos]; |
2512 | d2856f1a | aurel32 | } |