root / target-m68k / translate.c @ 8d0eb050
History | View | Annotate | Download (79 kB)
1 | e6e5906b | pbrook | /*
|
---|---|---|---|
2 | e6e5906b | pbrook | * m68k translation
|
3 | 5fafdf24 | ths | *
|
4 | 0633879f | pbrook | * Copyright (c) 2005-2007 CodeSourcery
|
5 | e6e5906b | pbrook | * Written by Paul Brook
|
6 | e6e5906b | pbrook | *
|
7 | e6e5906b | pbrook | * This library is free software; you can redistribute it and/or
|
8 | e6e5906b | pbrook | * modify it under the terms of the GNU Lesser General Public
|
9 | e6e5906b | pbrook | * License as published by the Free Software Foundation; either
|
10 | e6e5906b | pbrook | * version 2 of the License, or (at your option) any later version.
|
11 | e6e5906b | pbrook | *
|
12 | e6e5906b | pbrook | * This library is distributed in the hope that it will be useful,
|
13 | e6e5906b | pbrook | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 | e6e5906b | pbrook | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15 | e6e5906b | pbrook | * General Public License for more details.
|
16 | e6e5906b | pbrook | *
|
17 | e6e5906b | pbrook | * You should have received a copy of the GNU Lesser General Public
|
18 | 8167ee88 | Blue Swirl | * License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
19 | e6e5906b | pbrook | */
|
20 | e6e5906b | pbrook | #include <stdarg.h> |
21 | e6e5906b | pbrook | #include <stdlib.h> |
22 | e6e5906b | pbrook | #include <stdio.h> |
23 | e6e5906b | pbrook | #include <string.h> |
24 | e6e5906b | pbrook | #include <inttypes.h> |
25 | e6e5906b | pbrook | |
26 | e6e5906b | pbrook | #include "config.h" |
27 | e6e5906b | pbrook | #include "cpu.h" |
28 | e6e5906b | pbrook | #include "exec-all.h" |
29 | e6e5906b | pbrook | #include "disas.h" |
30 | 57fec1fe | bellard | #include "tcg-op.h" |
31 | 79383c9c | blueswir1 | #include "qemu-log.h" |
32 | e1f3808e | pbrook | |
33 | a7812ae4 | pbrook | #include "helpers.h" |
34 | e1f3808e | pbrook | #define GEN_HELPER 1 |
35 | e1f3808e | pbrook | #include "helpers.h" |
36 | e6e5906b | pbrook | |
37 | 0633879f | pbrook | //#define DEBUG_DISPATCH 1
|
38 | 0633879f | pbrook | |
39 | 815a6742 | pbrook | /* Fake floating point. */
|
40 | 815a6742 | pbrook | #define tcg_gen_mov_f64 tcg_gen_mov_i64
|
41 | 815a6742 | pbrook | #define tcg_gen_qemu_ldf64 tcg_gen_qemu_ld64
|
42 | 815a6742 | pbrook | #define tcg_gen_qemu_stf64 tcg_gen_qemu_st64
|
43 | 815a6742 | pbrook | |
44 | e1f3808e | pbrook | #define DEFO32(name, offset) static TCGv QREG_##name; |
45 | a7812ae4 | pbrook | #define DEFO64(name, offset) static TCGv_i64 QREG_##name; |
46 | a7812ae4 | pbrook | #define DEFF64(name, offset) static TCGv_i64 QREG_##name; |
47 | e1f3808e | pbrook | #include "qregs.def" |
48 | e1f3808e | pbrook | #undef DEFO32
|
49 | e1f3808e | pbrook | #undef DEFO64
|
50 | e1f3808e | pbrook | #undef DEFF64
|
51 | e1f3808e | pbrook | |
52 | a7812ae4 | pbrook | static TCGv_ptr cpu_env;
|
53 | e1f3808e | pbrook | |
54 | e1f3808e | pbrook | static char cpu_reg_names[3*8*3 + 5*4]; |
55 | e1f3808e | pbrook | static TCGv cpu_dregs[8]; |
56 | e1f3808e | pbrook | static TCGv cpu_aregs[8]; |
57 | a7812ae4 | pbrook | static TCGv_i64 cpu_fregs[8]; |
58 | a7812ae4 | pbrook | static TCGv_i64 cpu_macc[4]; |
59 | e1f3808e | pbrook | |
60 | e1f3808e | pbrook | #define DREG(insn, pos) cpu_dregs[((insn) >> (pos)) & 7] |
61 | e1f3808e | pbrook | #define AREG(insn, pos) cpu_aregs[((insn) >> (pos)) & 7] |
62 | e1f3808e | pbrook | #define FREG(insn, pos) cpu_fregs[((insn) >> (pos)) & 7] |
63 | e1f3808e | pbrook | #define MACREG(acc) cpu_macc[acc]
|
64 | e1f3808e | pbrook | #define QREG_SP cpu_aregs[7] |
65 | e1f3808e | pbrook | |
66 | e1f3808e | pbrook | static TCGv NULL_QREG;
|
67 | a7812ae4 | pbrook | #define IS_NULL_QREG(t) (TCGV_EQUAL(t, NULL_QREG))
|
68 | e1f3808e | pbrook | /* Used to distinguish stores from bad addressing modes. */
|
69 | e1f3808e | pbrook | static TCGv store_dummy;
|
70 | e1f3808e | pbrook | |
71 | 2e70f6ef | pbrook | #include "gen-icount.h" |
72 | 2e70f6ef | pbrook | |
73 | e1f3808e | pbrook | void m68k_tcg_init(void) |
74 | e1f3808e | pbrook | { |
75 | e1f3808e | pbrook | char *p;
|
76 | e1f3808e | pbrook | int i;
|
77 | e1f3808e | pbrook | |
78 | a7812ae4 | pbrook | #define DEFO32(name, offset) QREG_##name = tcg_global_mem_new_i32(TCG_AREG0, offsetof(CPUState, offset), #name); |
79 | a7812ae4 | pbrook | #define DEFO64(name, offset) QREG_##name = tcg_global_mem_new_i64(TCG_AREG0, offsetof(CPUState, offset), #name); |
80 | e1f3808e | pbrook | #define DEFF64(name, offset) DEFO64(name, offset)
|
81 | e1f3808e | pbrook | #include "qregs.def" |
82 | e1f3808e | pbrook | #undef DEFO32
|
83 | e1f3808e | pbrook | #undef DEFO64
|
84 | e1f3808e | pbrook | #undef DEFF64
|
85 | e1f3808e | pbrook | |
86 | a7812ae4 | pbrook | cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env");
|
87 | e1f3808e | pbrook | |
88 | e1f3808e | pbrook | p = cpu_reg_names; |
89 | e1f3808e | pbrook | for (i = 0; i < 8; i++) { |
90 | e1f3808e | pbrook | sprintf(p, "D%d", i);
|
91 | a7812ae4 | pbrook | cpu_dregs[i] = tcg_global_mem_new(TCG_AREG0, |
92 | e1f3808e | pbrook | offsetof(CPUM68KState, dregs[i]), p); |
93 | e1f3808e | pbrook | p += 3;
|
94 | e1f3808e | pbrook | sprintf(p, "A%d", i);
|
95 | a7812ae4 | pbrook | cpu_aregs[i] = tcg_global_mem_new(TCG_AREG0, |
96 | e1f3808e | pbrook | offsetof(CPUM68KState, aregs[i]), p); |
97 | e1f3808e | pbrook | p += 3;
|
98 | e1f3808e | pbrook | sprintf(p, "F%d", i);
|
99 | a7812ae4 | pbrook | cpu_fregs[i] = tcg_global_mem_new_i64(TCG_AREG0, |
100 | e1f3808e | pbrook | offsetof(CPUM68KState, fregs[i]), p); |
101 | e1f3808e | pbrook | p += 3;
|
102 | e1f3808e | pbrook | } |
103 | e1f3808e | pbrook | for (i = 0; i < 4; i++) { |
104 | e1f3808e | pbrook | sprintf(p, "ACC%d", i);
|
105 | a7812ae4 | pbrook | cpu_macc[i] = tcg_global_mem_new_i64(TCG_AREG0, |
106 | e1f3808e | pbrook | offsetof(CPUM68KState, macc[i]), p); |
107 | e1f3808e | pbrook | p += 5;
|
108 | e1f3808e | pbrook | } |
109 | e1f3808e | pbrook | |
110 | a7812ae4 | pbrook | NULL_QREG = tcg_global_mem_new(TCG_AREG0, -4, "NULL"); |
111 | a7812ae4 | pbrook | store_dummy = tcg_global_mem_new(TCG_AREG0, -8, "NULL"); |
112 | e1f3808e | pbrook | |
113 | a7812ae4 | pbrook | #define GEN_HELPER 2 |
114 | e1f3808e | pbrook | #include "helpers.h" |
115 | e1f3808e | pbrook | } |
116 | e1f3808e | pbrook | |
117 | e6e5906b | pbrook | static inline void qemu_assert(int cond, const char *msg) |
118 | e6e5906b | pbrook | { |
119 | e6e5906b | pbrook | if (!cond) {
|
120 | e6e5906b | pbrook | fprintf (stderr, "badness: %s\n", msg);
|
121 | e6e5906b | pbrook | abort(); |
122 | e6e5906b | pbrook | } |
123 | e6e5906b | pbrook | } |
124 | e6e5906b | pbrook | |
125 | e6e5906b | pbrook | /* internal defines */
|
126 | e6e5906b | pbrook | typedef struct DisasContext { |
127 | e6dbd3b3 | pbrook | CPUM68KState *env; |
128 | 510ff0b7 | pbrook | target_ulong insn_pc; /* Start of the current instruction. */
|
129 | e6e5906b | pbrook | target_ulong pc; |
130 | e6e5906b | pbrook | int is_jmp;
|
131 | e6e5906b | pbrook | int cc_op;
|
132 | 0633879f | pbrook | int user;
|
133 | e6e5906b | pbrook | uint32_t fpcr; |
134 | e6e5906b | pbrook | struct TranslationBlock *tb;
|
135 | e6e5906b | pbrook | int singlestep_enabled;
|
136 | c9bac22c | pbrook | int is_mem;
|
137 | a7812ae4 | pbrook | TCGv_i64 mactmp; |
138 | a7812ae4 | pbrook | int done_mac;
|
139 | e6e5906b | pbrook | } DisasContext; |
140 | e6e5906b | pbrook | |
141 | e6e5906b | pbrook | #define DISAS_JUMP_NEXT 4 |
142 | e6e5906b | pbrook | |
143 | 0633879f | pbrook | #if defined(CONFIG_USER_ONLY)
|
144 | 0633879f | pbrook | #define IS_USER(s) 1 |
145 | 0633879f | pbrook | #else
|
146 | 0633879f | pbrook | #define IS_USER(s) s->user
|
147 | 0633879f | pbrook | #endif
|
148 | 0633879f | pbrook | |
149 | e6e5906b | pbrook | /* XXX: move that elsewhere */
|
150 | e6e5906b | pbrook | /* ??? Fix exceptions. */
|
151 | e6e5906b | pbrook | static void *gen_throws_exception; |
152 | e6e5906b | pbrook | #define gen_last_qop NULL |
153 | e6e5906b | pbrook | |
154 | e6e5906b | pbrook | #define OS_BYTE 0 |
155 | e6e5906b | pbrook | #define OS_WORD 1 |
156 | e6e5906b | pbrook | #define OS_LONG 2 |
157 | e6e5906b | pbrook | #define OS_SINGLE 4 |
158 | e6e5906b | pbrook | #define OS_DOUBLE 5 |
159 | e6e5906b | pbrook | |
160 | e6e5906b | pbrook | typedef void (*disas_proc)(DisasContext *, uint16_t); |
161 | e6e5906b | pbrook | |
162 | 0633879f | pbrook | #ifdef DEBUG_DISPATCH
|
163 | 0633879f | pbrook | #define DISAS_INSN(name) \
|
164 | 0633879f | pbrook | static void real_disas_##name (DisasContext *s, uint16_t insn); \ |
165 | 0633879f | pbrook | static void disas_##name (DisasContext *s, uint16_t insn) { \ |
166 | 93fcfe39 | aliguori | qemu_log("Dispatch " #name "\n"); \ |
167 | 0633879f | pbrook | real_disas_##name(s, insn); } \ |
168 | 0633879f | pbrook | static void real_disas_##name (DisasContext *s, uint16_t insn) |
169 | 0633879f | pbrook | #else
|
170 | e6e5906b | pbrook | #define DISAS_INSN(name) \
|
171 | e6e5906b | pbrook | static void disas_##name (DisasContext *s, uint16_t insn) |
172 | 0633879f | pbrook | #endif
|
173 | e6e5906b | pbrook | |
174 | e1f3808e | pbrook | /* FIXME: Remove this. */
|
175 | e1f3808e | pbrook | #define gen_im32(val) tcg_const_i32(val)
|
176 | e1f3808e | pbrook | |
177 | e6e5906b | pbrook | /* Generate a load from the specified address. Narrow values are
|
178 | e6e5906b | pbrook | sign extended to full register width. */
|
179 | e1f3808e | pbrook | static inline TCGv gen_load(DisasContext * s, int opsize, TCGv addr, int sign) |
180 | e6e5906b | pbrook | { |
181 | e1f3808e | pbrook | TCGv tmp; |
182 | e1f3808e | pbrook | int index = IS_USER(s);
|
183 | c9bac22c | pbrook | s->is_mem = 1;
|
184 | a7812ae4 | pbrook | tmp = tcg_temp_new_i32(); |
185 | e6e5906b | pbrook | switch(opsize) {
|
186 | e6e5906b | pbrook | case OS_BYTE:
|
187 | e6e5906b | pbrook | if (sign)
|
188 | e1f3808e | pbrook | tcg_gen_qemu_ld8s(tmp, addr, index); |
189 | e6e5906b | pbrook | else
|
190 | e1f3808e | pbrook | tcg_gen_qemu_ld8u(tmp, addr, index); |
191 | e6e5906b | pbrook | break;
|
192 | e6e5906b | pbrook | case OS_WORD:
|
193 | e6e5906b | pbrook | if (sign)
|
194 | e1f3808e | pbrook | tcg_gen_qemu_ld16s(tmp, addr, index); |
195 | e6e5906b | pbrook | else
|
196 | e1f3808e | pbrook | tcg_gen_qemu_ld16u(tmp, addr, index); |
197 | e6e5906b | pbrook | break;
|
198 | e6e5906b | pbrook | case OS_LONG:
|
199 | e6e5906b | pbrook | case OS_SINGLE:
|
200 | a7812ae4 | pbrook | tcg_gen_qemu_ld32u(tmp, addr, index); |
201 | e6e5906b | pbrook | break;
|
202 | e6e5906b | pbrook | default:
|
203 | e6e5906b | pbrook | qemu_assert(0, "bad load size"); |
204 | e6e5906b | pbrook | } |
205 | e6e5906b | pbrook | gen_throws_exception = gen_last_qop; |
206 | e6e5906b | pbrook | return tmp;
|
207 | e6e5906b | pbrook | } |
208 | e6e5906b | pbrook | |
209 | a7812ae4 | pbrook | static inline TCGv_i64 gen_load64(DisasContext * s, TCGv addr) |
210 | a7812ae4 | pbrook | { |
211 | a7812ae4 | pbrook | TCGv_i64 tmp; |
212 | a7812ae4 | pbrook | int index = IS_USER(s);
|
213 | a7812ae4 | pbrook | s->is_mem = 1;
|
214 | a7812ae4 | pbrook | tmp = tcg_temp_new_i64(); |
215 | a7812ae4 | pbrook | tcg_gen_qemu_ldf64(tmp, addr, index); |
216 | a7812ae4 | pbrook | gen_throws_exception = gen_last_qop; |
217 | a7812ae4 | pbrook | return tmp;
|
218 | a7812ae4 | pbrook | } |
219 | a7812ae4 | pbrook | |
220 | e6e5906b | pbrook | /* Generate a store. */
|
221 | e1f3808e | pbrook | static inline void gen_store(DisasContext *s, int opsize, TCGv addr, TCGv val) |
222 | e6e5906b | pbrook | { |
223 | e1f3808e | pbrook | int index = IS_USER(s);
|
224 | c9bac22c | pbrook | s->is_mem = 1;
|
225 | e6e5906b | pbrook | switch(opsize) {
|
226 | e6e5906b | pbrook | case OS_BYTE:
|
227 | e1f3808e | pbrook | tcg_gen_qemu_st8(val, addr, index); |
228 | e6e5906b | pbrook | break;
|
229 | e6e5906b | pbrook | case OS_WORD:
|
230 | e1f3808e | pbrook | tcg_gen_qemu_st16(val, addr, index); |
231 | e6e5906b | pbrook | break;
|
232 | e6e5906b | pbrook | case OS_LONG:
|
233 | e6e5906b | pbrook | case OS_SINGLE:
|
234 | a7812ae4 | pbrook | tcg_gen_qemu_st32(val, addr, index); |
235 | e6e5906b | pbrook | break;
|
236 | e6e5906b | pbrook | default:
|
237 | e6e5906b | pbrook | qemu_assert(0, "bad store size"); |
238 | e6e5906b | pbrook | } |
239 | e6e5906b | pbrook | gen_throws_exception = gen_last_qop; |
240 | e6e5906b | pbrook | } |
241 | e6e5906b | pbrook | |
242 | a7812ae4 | pbrook | static inline void gen_store64(DisasContext *s, TCGv addr, TCGv_i64 val) |
243 | a7812ae4 | pbrook | { |
244 | a7812ae4 | pbrook | int index = IS_USER(s);
|
245 | a7812ae4 | pbrook | s->is_mem = 1;
|
246 | a7812ae4 | pbrook | tcg_gen_qemu_stf64(val, addr, index); |
247 | a7812ae4 | pbrook | gen_throws_exception = gen_last_qop; |
248 | a7812ae4 | pbrook | } |
249 | a7812ae4 | pbrook | |
250 | e1f3808e | pbrook | typedef enum { |
251 | e1f3808e | pbrook | EA_STORE, |
252 | e1f3808e | pbrook | EA_LOADU, |
253 | e1f3808e | pbrook | EA_LOADS |
254 | e1f3808e | pbrook | } ea_what; |
255 | e1f3808e | pbrook | |
256 | e6e5906b | pbrook | /* Generate an unsigned load if VAL is 0 a signed load if val is -1,
|
257 | e6e5906b | pbrook | otherwise generate a store. */
|
258 | e1f3808e | pbrook | static TCGv gen_ldst(DisasContext *s, int opsize, TCGv addr, TCGv val, |
259 | e1f3808e | pbrook | ea_what what) |
260 | e6e5906b | pbrook | { |
261 | e1f3808e | pbrook | if (what == EA_STORE) {
|
262 | 0633879f | pbrook | gen_store(s, opsize, addr, val); |
263 | e1f3808e | pbrook | return store_dummy;
|
264 | e6e5906b | pbrook | } else {
|
265 | e1f3808e | pbrook | return gen_load(s, opsize, addr, what == EA_LOADS);
|
266 | e6e5906b | pbrook | } |
267 | e6e5906b | pbrook | } |
268 | e6e5906b | pbrook | |
269 | e6dbd3b3 | pbrook | /* Read a 32-bit immediate constant. */
|
270 | e6dbd3b3 | pbrook | static inline uint32_t read_im32(DisasContext *s) |
271 | e6dbd3b3 | pbrook | { |
272 | e6dbd3b3 | pbrook | uint32_t im; |
273 | e6dbd3b3 | pbrook | im = ((uint32_t)lduw_code(s->pc)) << 16;
|
274 | e6dbd3b3 | pbrook | s->pc += 2;
|
275 | e6dbd3b3 | pbrook | im |= lduw_code(s->pc); |
276 | e6dbd3b3 | pbrook | s->pc += 2;
|
277 | e6dbd3b3 | pbrook | return im;
|
278 | e6dbd3b3 | pbrook | } |
279 | e6dbd3b3 | pbrook | |
280 | e6dbd3b3 | pbrook | /* Calculate and address index. */
|
281 | e1f3808e | pbrook | static TCGv gen_addr_index(uint16_t ext, TCGv tmp)
|
282 | e6dbd3b3 | pbrook | { |
283 | e1f3808e | pbrook | TCGv add; |
284 | e6dbd3b3 | pbrook | int scale;
|
285 | e6dbd3b3 | pbrook | |
286 | e6dbd3b3 | pbrook | add = (ext & 0x8000) ? AREG(ext, 12) : DREG(ext, 12); |
287 | e6dbd3b3 | pbrook | if ((ext & 0x800) == 0) { |
288 | e1f3808e | pbrook | tcg_gen_ext16s_i32(tmp, add); |
289 | e6dbd3b3 | pbrook | add = tmp; |
290 | e6dbd3b3 | pbrook | } |
291 | e6dbd3b3 | pbrook | scale = (ext >> 9) & 3; |
292 | e6dbd3b3 | pbrook | if (scale != 0) { |
293 | e1f3808e | pbrook | tcg_gen_shli_i32(tmp, add, scale); |
294 | e6dbd3b3 | pbrook | add = tmp; |
295 | e6dbd3b3 | pbrook | } |
296 | e6dbd3b3 | pbrook | return add;
|
297 | e6dbd3b3 | pbrook | } |
298 | e6dbd3b3 | pbrook | |
299 | e1f3808e | pbrook | /* Handle a base + index + displacement effective addresss.
|
300 | e1f3808e | pbrook | A NULL_QREG base means pc-relative. */
|
301 | e1f3808e | pbrook | static TCGv gen_lea_indexed(DisasContext *s, int opsize, TCGv base) |
302 | e6e5906b | pbrook | { |
303 | e6e5906b | pbrook | uint32_t offset; |
304 | e6e5906b | pbrook | uint16_t ext; |
305 | e1f3808e | pbrook | TCGv add; |
306 | e1f3808e | pbrook | TCGv tmp; |
307 | e6dbd3b3 | pbrook | uint32_t bd, od; |
308 | e6e5906b | pbrook | |
309 | e6e5906b | pbrook | offset = s->pc; |
310 | 0633879f | pbrook | ext = lduw_code(s->pc); |
311 | e6e5906b | pbrook | s->pc += 2;
|
312 | e6dbd3b3 | pbrook | |
313 | e6dbd3b3 | pbrook | if ((ext & 0x800) == 0 && !m68k_feature(s->env, M68K_FEATURE_WORD_INDEX)) |
314 | e1f3808e | pbrook | return NULL_QREG;
|
315 | e6dbd3b3 | pbrook | |
316 | e6dbd3b3 | pbrook | if (ext & 0x100) { |
317 | e6dbd3b3 | pbrook | /* full extension word format */
|
318 | e6dbd3b3 | pbrook | if (!m68k_feature(s->env, M68K_FEATURE_EXT_FULL))
|
319 | e1f3808e | pbrook | return NULL_QREG;
|
320 | e6dbd3b3 | pbrook | |
321 | e6dbd3b3 | pbrook | if ((ext & 0x30) > 0x10) { |
322 | e6dbd3b3 | pbrook | /* base displacement */
|
323 | e6dbd3b3 | pbrook | if ((ext & 0x30) == 0x20) { |
324 | e6dbd3b3 | pbrook | bd = (int16_t)lduw_code(s->pc); |
325 | e6dbd3b3 | pbrook | s->pc += 2;
|
326 | e6dbd3b3 | pbrook | } else {
|
327 | e6dbd3b3 | pbrook | bd = read_im32(s); |
328 | e6dbd3b3 | pbrook | } |
329 | e6dbd3b3 | pbrook | } else {
|
330 | e6dbd3b3 | pbrook | bd = 0;
|
331 | e6dbd3b3 | pbrook | } |
332 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
333 | e6dbd3b3 | pbrook | if ((ext & 0x44) == 0) { |
334 | e6dbd3b3 | pbrook | /* pre-index */
|
335 | e6dbd3b3 | pbrook | add = gen_addr_index(ext, tmp); |
336 | e6dbd3b3 | pbrook | } else {
|
337 | e1f3808e | pbrook | add = NULL_QREG; |
338 | e6dbd3b3 | pbrook | } |
339 | e6dbd3b3 | pbrook | if ((ext & 0x80) == 0) { |
340 | e6dbd3b3 | pbrook | /* base not suppressed */
|
341 | e1f3808e | pbrook | if (IS_NULL_QREG(base)) {
|
342 | e6dbd3b3 | pbrook | base = gen_im32(offset + bd); |
343 | e6dbd3b3 | pbrook | bd = 0;
|
344 | e6dbd3b3 | pbrook | } |
345 | e1f3808e | pbrook | if (!IS_NULL_QREG(add)) {
|
346 | e1f3808e | pbrook | tcg_gen_add_i32(tmp, add, base); |
347 | e6dbd3b3 | pbrook | add = tmp; |
348 | e6dbd3b3 | pbrook | } else {
|
349 | e6dbd3b3 | pbrook | add = base; |
350 | e6dbd3b3 | pbrook | } |
351 | e6dbd3b3 | pbrook | } |
352 | e1f3808e | pbrook | if (!IS_NULL_QREG(add)) {
|
353 | e6dbd3b3 | pbrook | if (bd != 0) { |
354 | e1f3808e | pbrook | tcg_gen_addi_i32(tmp, add, bd); |
355 | e6dbd3b3 | pbrook | add = tmp; |
356 | e6dbd3b3 | pbrook | } |
357 | e6dbd3b3 | pbrook | } else {
|
358 | e6dbd3b3 | pbrook | add = gen_im32(bd); |
359 | e6dbd3b3 | pbrook | } |
360 | e6dbd3b3 | pbrook | if ((ext & 3) != 0) { |
361 | e6dbd3b3 | pbrook | /* memory indirect */
|
362 | e6dbd3b3 | pbrook | base = gen_load(s, OS_LONG, add, 0);
|
363 | e6dbd3b3 | pbrook | if ((ext & 0x44) == 4) { |
364 | e6dbd3b3 | pbrook | add = gen_addr_index(ext, tmp); |
365 | e1f3808e | pbrook | tcg_gen_add_i32(tmp, add, base); |
366 | e6dbd3b3 | pbrook | add = tmp; |
367 | e6dbd3b3 | pbrook | } else {
|
368 | e6dbd3b3 | pbrook | add = base; |
369 | e6dbd3b3 | pbrook | } |
370 | e6dbd3b3 | pbrook | if ((ext & 3) > 1) { |
371 | e6dbd3b3 | pbrook | /* outer displacement */
|
372 | e6dbd3b3 | pbrook | if ((ext & 3) == 2) { |
373 | e6dbd3b3 | pbrook | od = (int16_t)lduw_code(s->pc); |
374 | e6dbd3b3 | pbrook | s->pc += 2;
|
375 | e6dbd3b3 | pbrook | } else {
|
376 | e6dbd3b3 | pbrook | od = read_im32(s); |
377 | e6dbd3b3 | pbrook | } |
378 | e6dbd3b3 | pbrook | } else {
|
379 | e6dbd3b3 | pbrook | od = 0;
|
380 | e6dbd3b3 | pbrook | } |
381 | e6dbd3b3 | pbrook | if (od != 0) { |
382 | e1f3808e | pbrook | tcg_gen_addi_i32(tmp, add, od); |
383 | e6dbd3b3 | pbrook | add = tmp; |
384 | e6dbd3b3 | pbrook | } |
385 | e6dbd3b3 | pbrook | } |
386 | e6e5906b | pbrook | } else {
|
387 | e6dbd3b3 | pbrook | /* brief extension word format */
|
388 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
389 | e6dbd3b3 | pbrook | add = gen_addr_index(ext, tmp); |
390 | e1f3808e | pbrook | if (!IS_NULL_QREG(base)) {
|
391 | e1f3808e | pbrook | tcg_gen_add_i32(tmp, add, base); |
392 | e6dbd3b3 | pbrook | if ((int8_t)ext)
|
393 | e1f3808e | pbrook | tcg_gen_addi_i32(tmp, tmp, (int8_t)ext); |
394 | e6dbd3b3 | pbrook | } else {
|
395 | e1f3808e | pbrook | tcg_gen_addi_i32(tmp, add, offset + (int8_t)ext); |
396 | e6dbd3b3 | pbrook | } |
397 | e6dbd3b3 | pbrook | add = tmp; |
398 | e6e5906b | pbrook | } |
399 | e6dbd3b3 | pbrook | return add;
|
400 | e6e5906b | pbrook | } |
401 | e6e5906b | pbrook | |
402 | e6e5906b | pbrook | /* Update the CPU env CC_OP state. */
|
403 | e6e5906b | pbrook | static inline void gen_flush_cc_op(DisasContext *s) |
404 | e6e5906b | pbrook | { |
405 | e6e5906b | pbrook | if (s->cc_op != CC_OP_DYNAMIC)
|
406 | e1f3808e | pbrook | tcg_gen_movi_i32(QREG_CC_OP, s->cc_op); |
407 | e6e5906b | pbrook | } |
408 | e6e5906b | pbrook | |
409 | e6e5906b | pbrook | /* Evaluate all the CC flags. */
|
410 | e6e5906b | pbrook | static inline void gen_flush_flags(DisasContext *s) |
411 | e6e5906b | pbrook | { |
412 | e6e5906b | pbrook | if (s->cc_op == CC_OP_FLAGS)
|
413 | e6e5906b | pbrook | return;
|
414 | 0cf5c677 | pbrook | gen_flush_cc_op(s); |
415 | e1f3808e | pbrook | gen_helper_flush_flags(cpu_env, QREG_CC_OP); |
416 | e6e5906b | pbrook | s->cc_op = CC_OP_FLAGS; |
417 | e6e5906b | pbrook | } |
418 | e6e5906b | pbrook | |
419 | e1f3808e | pbrook | static void gen_logic_cc(DisasContext *s, TCGv val) |
420 | e1f3808e | pbrook | { |
421 | e1f3808e | pbrook | tcg_gen_mov_i32(QREG_CC_DEST, val); |
422 | e1f3808e | pbrook | s->cc_op = CC_OP_LOGIC; |
423 | e1f3808e | pbrook | } |
424 | e1f3808e | pbrook | |
425 | e1f3808e | pbrook | static void gen_update_cc_add(TCGv dest, TCGv src) |
426 | e1f3808e | pbrook | { |
427 | e1f3808e | pbrook | tcg_gen_mov_i32(QREG_CC_DEST, dest); |
428 | e1f3808e | pbrook | tcg_gen_mov_i32(QREG_CC_SRC, src); |
429 | e1f3808e | pbrook | } |
430 | e1f3808e | pbrook | |
431 | e6e5906b | pbrook | static inline int opsize_bytes(int opsize) |
432 | e6e5906b | pbrook | { |
433 | e6e5906b | pbrook | switch (opsize) {
|
434 | e6e5906b | pbrook | case OS_BYTE: return 1; |
435 | e6e5906b | pbrook | case OS_WORD: return 2; |
436 | e6e5906b | pbrook | case OS_LONG: return 4; |
437 | e6e5906b | pbrook | case OS_SINGLE: return 4; |
438 | e6e5906b | pbrook | case OS_DOUBLE: return 8; |
439 | e6e5906b | pbrook | default:
|
440 | e6e5906b | pbrook | qemu_assert(0, "bad operand size"); |
441 | 1ed1a787 | blueswir1 | return 0; |
442 | e6e5906b | pbrook | } |
443 | e6e5906b | pbrook | } |
444 | e6e5906b | pbrook | |
445 | e6e5906b | pbrook | /* Assign value to a register. If the width is less than the register width
|
446 | e6e5906b | pbrook | only the low part of the register is set. */
|
447 | e1f3808e | pbrook | static void gen_partset_reg(int opsize, TCGv reg, TCGv val) |
448 | e6e5906b | pbrook | { |
449 | e1f3808e | pbrook | TCGv tmp; |
450 | e6e5906b | pbrook | switch (opsize) {
|
451 | e6e5906b | pbrook | case OS_BYTE:
|
452 | e1f3808e | pbrook | tcg_gen_andi_i32(reg, reg, 0xffffff00);
|
453 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
454 | e1f3808e | pbrook | tcg_gen_ext8u_i32(tmp, val); |
455 | e1f3808e | pbrook | tcg_gen_or_i32(reg, reg, tmp); |
456 | e6e5906b | pbrook | break;
|
457 | e6e5906b | pbrook | case OS_WORD:
|
458 | e1f3808e | pbrook | tcg_gen_andi_i32(reg, reg, 0xffff0000);
|
459 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
460 | e1f3808e | pbrook | tcg_gen_ext16u_i32(tmp, val); |
461 | e1f3808e | pbrook | tcg_gen_or_i32(reg, reg, tmp); |
462 | e6e5906b | pbrook | break;
|
463 | e6e5906b | pbrook | case OS_LONG:
|
464 | e6e5906b | pbrook | case OS_SINGLE:
|
465 | a7812ae4 | pbrook | tcg_gen_mov_i32(reg, val); |
466 | e6e5906b | pbrook | break;
|
467 | e6e5906b | pbrook | default:
|
468 | e6e5906b | pbrook | qemu_assert(0, "Bad operand size"); |
469 | e6e5906b | pbrook | break;
|
470 | e6e5906b | pbrook | } |
471 | e6e5906b | pbrook | } |
472 | e6e5906b | pbrook | |
473 | e6e5906b | pbrook | /* Sign or zero extend a value. */
|
474 | e1f3808e | pbrook | static inline TCGv gen_extend(TCGv val, int opsize, int sign) |
475 | e6e5906b | pbrook | { |
476 | e1f3808e | pbrook | TCGv tmp; |
477 | e6e5906b | pbrook | |
478 | e6e5906b | pbrook | switch (opsize) {
|
479 | e6e5906b | pbrook | case OS_BYTE:
|
480 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
481 | e6e5906b | pbrook | if (sign)
|
482 | e1f3808e | pbrook | tcg_gen_ext8s_i32(tmp, val); |
483 | e6e5906b | pbrook | else
|
484 | e1f3808e | pbrook | tcg_gen_ext8u_i32(tmp, val); |
485 | e6e5906b | pbrook | break;
|
486 | e6e5906b | pbrook | case OS_WORD:
|
487 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
488 | e6e5906b | pbrook | if (sign)
|
489 | e1f3808e | pbrook | tcg_gen_ext16s_i32(tmp, val); |
490 | e6e5906b | pbrook | else
|
491 | e1f3808e | pbrook | tcg_gen_ext16u_i32(tmp, val); |
492 | e6e5906b | pbrook | break;
|
493 | e6e5906b | pbrook | case OS_LONG:
|
494 | e6e5906b | pbrook | case OS_SINGLE:
|
495 | a7812ae4 | pbrook | tmp = val; |
496 | e6e5906b | pbrook | break;
|
497 | e6e5906b | pbrook | default:
|
498 | e6e5906b | pbrook | qemu_assert(0, "Bad operand size"); |
499 | e6e5906b | pbrook | } |
500 | e6e5906b | pbrook | return tmp;
|
501 | e6e5906b | pbrook | } |
502 | e6e5906b | pbrook | |
503 | e6e5906b | pbrook | /* Generate code for an "effective address". Does not adjust the base
|
504 | 1addc7c5 | aurel32 | register for autoincrement addressing modes. */
|
505 | e1f3808e | pbrook | static TCGv gen_lea(DisasContext *s, uint16_t insn, int opsize) |
506 | e6e5906b | pbrook | { |
507 | e1f3808e | pbrook | TCGv reg; |
508 | e1f3808e | pbrook | TCGv tmp; |
509 | e6e5906b | pbrook | uint16_t ext; |
510 | e6e5906b | pbrook | uint32_t offset; |
511 | e6e5906b | pbrook | |
512 | e6e5906b | pbrook | switch ((insn >> 3) & 7) { |
513 | e6e5906b | pbrook | case 0: /* Data register direct. */ |
514 | e6e5906b | pbrook | case 1: /* Address register direct. */ |
515 | e1f3808e | pbrook | return NULL_QREG;
|
516 | e6e5906b | pbrook | case 2: /* Indirect register */ |
517 | e6e5906b | pbrook | case 3: /* Indirect postincrement. */ |
518 | e1f3808e | pbrook | return AREG(insn, 0); |
519 | e6e5906b | pbrook | case 4: /* Indirect predecrememnt. */ |
520 | e1f3808e | pbrook | reg = AREG(insn, 0);
|
521 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
522 | e1f3808e | pbrook | tcg_gen_subi_i32(tmp, reg, opsize_bytes(opsize)); |
523 | e6e5906b | pbrook | return tmp;
|
524 | e6e5906b | pbrook | case 5: /* Indirect displacement. */ |
525 | e1f3808e | pbrook | reg = AREG(insn, 0);
|
526 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
527 | 0633879f | pbrook | ext = lduw_code(s->pc); |
528 | e6e5906b | pbrook | s->pc += 2;
|
529 | e1f3808e | pbrook | tcg_gen_addi_i32(tmp, reg, (int16_t)ext); |
530 | e6e5906b | pbrook | return tmp;
|
531 | e6e5906b | pbrook | case 6: /* Indirect index + displacement. */ |
532 | e1f3808e | pbrook | reg = AREG(insn, 0);
|
533 | e6e5906b | pbrook | return gen_lea_indexed(s, opsize, reg);
|
534 | e6e5906b | pbrook | case 7: /* Other */ |
535 | e1f3808e | pbrook | switch (insn & 7) { |
536 | e6e5906b | pbrook | case 0: /* Absolute short. */ |
537 | 0633879f | pbrook | offset = ldsw_code(s->pc); |
538 | e6e5906b | pbrook | s->pc += 2;
|
539 | e6e5906b | pbrook | return gen_im32(offset);
|
540 | e6e5906b | pbrook | case 1: /* Absolute long. */ |
541 | e6e5906b | pbrook | offset = read_im32(s); |
542 | e6e5906b | pbrook | return gen_im32(offset);
|
543 | e6e5906b | pbrook | case 2: /* pc displacement */ |
544 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
545 | e6e5906b | pbrook | offset = s->pc; |
546 | 0633879f | pbrook | offset += ldsw_code(s->pc); |
547 | e6e5906b | pbrook | s->pc += 2;
|
548 | e6e5906b | pbrook | return gen_im32(offset);
|
549 | e6e5906b | pbrook | case 3: /* pc index+displacement. */ |
550 | e1f3808e | pbrook | return gen_lea_indexed(s, opsize, NULL_QREG);
|
551 | e6e5906b | pbrook | case 4: /* Immediate. */ |
552 | e6e5906b | pbrook | default:
|
553 | e1f3808e | pbrook | return NULL_QREG;
|
554 | e6e5906b | pbrook | } |
555 | e6e5906b | pbrook | } |
556 | e6e5906b | pbrook | /* Should never happen. */
|
557 | e1f3808e | pbrook | return NULL_QREG;
|
558 | e6e5906b | pbrook | } |
559 | e6e5906b | pbrook | |
560 | e6e5906b | pbrook | /* Helper function for gen_ea. Reuse the computed address between the
|
561 | e6e5906b | pbrook | for read/write operands. */
|
562 | e1f3808e | pbrook | static inline TCGv gen_ea_once(DisasContext *s, uint16_t insn, int opsize, |
563 | e1f3808e | pbrook | TCGv val, TCGv *addrp, ea_what what) |
564 | e6e5906b | pbrook | { |
565 | e1f3808e | pbrook | TCGv tmp; |
566 | e6e5906b | pbrook | |
567 | e1f3808e | pbrook | if (addrp && what == EA_STORE) {
|
568 | e6e5906b | pbrook | tmp = *addrp; |
569 | e6e5906b | pbrook | } else {
|
570 | e6e5906b | pbrook | tmp = gen_lea(s, insn, opsize); |
571 | e1f3808e | pbrook | if (IS_NULL_QREG(tmp))
|
572 | e1f3808e | pbrook | return tmp;
|
573 | e6e5906b | pbrook | if (addrp)
|
574 | e6e5906b | pbrook | *addrp = tmp; |
575 | e6e5906b | pbrook | } |
576 | e1f3808e | pbrook | return gen_ldst(s, opsize, tmp, val, what);
|
577 | e6e5906b | pbrook | } |
578 | e6e5906b | pbrook | |
579 | e6e5906b | pbrook | /* Generate code to load/store a value ito/from an EA. If VAL > 0 this is
|
580 | e6e5906b | pbrook | a write otherwise it is a read (0 == sign extend, -1 == zero extend).
|
581 | e6e5906b | pbrook | ADDRP is non-null for readwrite operands. */
|
582 | e1f3808e | pbrook | static TCGv gen_ea(DisasContext *s, uint16_t insn, int opsize, TCGv val, |
583 | e1f3808e | pbrook | TCGv *addrp, ea_what what) |
584 | e6e5906b | pbrook | { |
585 | e1f3808e | pbrook | TCGv reg; |
586 | e1f3808e | pbrook | TCGv result; |
587 | e6e5906b | pbrook | uint32_t offset; |
588 | e6e5906b | pbrook | |
589 | e6e5906b | pbrook | switch ((insn >> 3) & 7) { |
590 | e6e5906b | pbrook | case 0: /* Data register direct. */ |
591 | e1f3808e | pbrook | reg = DREG(insn, 0);
|
592 | e1f3808e | pbrook | if (what == EA_STORE) {
|
593 | e6e5906b | pbrook | gen_partset_reg(opsize, reg, val); |
594 | e1f3808e | pbrook | return store_dummy;
|
595 | e6e5906b | pbrook | } else {
|
596 | e1f3808e | pbrook | return gen_extend(reg, opsize, what == EA_LOADS);
|
597 | e6e5906b | pbrook | } |
598 | e6e5906b | pbrook | case 1: /* Address register direct. */ |
599 | e1f3808e | pbrook | reg = AREG(insn, 0);
|
600 | e1f3808e | pbrook | if (what == EA_STORE) {
|
601 | e1f3808e | pbrook | tcg_gen_mov_i32(reg, val); |
602 | e1f3808e | pbrook | return store_dummy;
|
603 | e6e5906b | pbrook | } else {
|
604 | e1f3808e | pbrook | return gen_extend(reg, opsize, what == EA_LOADS);
|
605 | e6e5906b | pbrook | } |
606 | e6e5906b | pbrook | case 2: /* Indirect register */ |
607 | e1f3808e | pbrook | reg = AREG(insn, 0);
|
608 | e1f3808e | pbrook | return gen_ldst(s, opsize, reg, val, what);
|
609 | e6e5906b | pbrook | case 3: /* Indirect postincrement. */ |
610 | e1f3808e | pbrook | reg = AREG(insn, 0);
|
611 | e1f3808e | pbrook | result = gen_ldst(s, opsize, reg, val, what); |
612 | e6e5906b | pbrook | /* ??? This is not exception safe. The instruction may still
|
613 | e6e5906b | pbrook | fault after this point. */
|
614 | e1f3808e | pbrook | if (what == EA_STORE || !addrp)
|
615 | e1f3808e | pbrook | tcg_gen_addi_i32(reg, reg, opsize_bytes(opsize)); |
616 | e6e5906b | pbrook | return result;
|
617 | e6e5906b | pbrook | case 4: /* Indirect predecrememnt. */ |
618 | e6e5906b | pbrook | { |
619 | e1f3808e | pbrook | TCGv tmp; |
620 | e1f3808e | pbrook | if (addrp && what == EA_STORE) {
|
621 | e6e5906b | pbrook | tmp = *addrp; |
622 | e6e5906b | pbrook | } else {
|
623 | e6e5906b | pbrook | tmp = gen_lea(s, insn, opsize); |
624 | e1f3808e | pbrook | if (IS_NULL_QREG(tmp))
|
625 | e1f3808e | pbrook | return tmp;
|
626 | e6e5906b | pbrook | if (addrp)
|
627 | e6e5906b | pbrook | *addrp = tmp; |
628 | e6e5906b | pbrook | } |
629 | e1f3808e | pbrook | result = gen_ldst(s, opsize, tmp, val, what); |
630 | e6e5906b | pbrook | /* ??? This is not exception safe. The instruction may still
|
631 | e6e5906b | pbrook | fault after this point. */
|
632 | e1f3808e | pbrook | if (what == EA_STORE || !addrp) {
|
633 | e1f3808e | pbrook | reg = AREG(insn, 0);
|
634 | e1f3808e | pbrook | tcg_gen_mov_i32(reg, tmp); |
635 | e6e5906b | pbrook | } |
636 | e6e5906b | pbrook | } |
637 | e6e5906b | pbrook | return result;
|
638 | e6e5906b | pbrook | case 5: /* Indirect displacement. */ |
639 | e6e5906b | pbrook | case 6: /* Indirect index + displacement. */ |
640 | e1f3808e | pbrook | return gen_ea_once(s, insn, opsize, val, addrp, what);
|
641 | e6e5906b | pbrook | case 7: /* Other */ |
642 | e1f3808e | pbrook | switch (insn & 7) { |
643 | e6e5906b | pbrook | case 0: /* Absolute short. */ |
644 | e6e5906b | pbrook | case 1: /* Absolute long. */ |
645 | e6e5906b | pbrook | case 2: /* pc displacement */ |
646 | e6e5906b | pbrook | case 3: /* pc index+displacement. */ |
647 | e1f3808e | pbrook | return gen_ea_once(s, insn, opsize, val, addrp, what);
|
648 | e6e5906b | pbrook | case 4: /* Immediate. */ |
649 | e6e5906b | pbrook | /* Sign extend values for consistency. */
|
650 | e6e5906b | pbrook | switch (opsize) {
|
651 | e6e5906b | pbrook | case OS_BYTE:
|
652 | e1f3808e | pbrook | if (what == EA_LOADS)
|
653 | 0633879f | pbrook | offset = ldsb_code(s->pc + 1);
|
654 | e6e5906b | pbrook | else
|
655 | 0633879f | pbrook | offset = ldub_code(s->pc + 1);
|
656 | e6e5906b | pbrook | s->pc += 2;
|
657 | e6e5906b | pbrook | break;
|
658 | e6e5906b | pbrook | case OS_WORD:
|
659 | e1f3808e | pbrook | if (what == EA_LOADS)
|
660 | 0633879f | pbrook | offset = ldsw_code(s->pc); |
661 | e6e5906b | pbrook | else
|
662 | 0633879f | pbrook | offset = lduw_code(s->pc); |
663 | e6e5906b | pbrook | s->pc += 2;
|
664 | e6e5906b | pbrook | break;
|
665 | e6e5906b | pbrook | case OS_LONG:
|
666 | e6e5906b | pbrook | offset = read_im32(s); |
667 | e6e5906b | pbrook | break;
|
668 | e6e5906b | pbrook | default:
|
669 | e6e5906b | pbrook | qemu_assert(0, "Bad immediate operand"); |
670 | e6e5906b | pbrook | } |
671 | e1f3808e | pbrook | return tcg_const_i32(offset);
|
672 | e6e5906b | pbrook | default:
|
673 | e1f3808e | pbrook | return NULL_QREG;
|
674 | e6e5906b | pbrook | } |
675 | e6e5906b | pbrook | } |
676 | e6e5906b | pbrook | /* Should never happen. */
|
677 | e1f3808e | pbrook | return NULL_QREG;
|
678 | e6e5906b | pbrook | } |
679 | e6e5906b | pbrook | |
680 | e1f3808e | pbrook | /* This generates a conditional branch, clobbering all temporaries. */
|
681 | e6e5906b | pbrook | static void gen_jmpcc(DisasContext *s, int cond, int l1) |
682 | e6e5906b | pbrook | { |
683 | e1f3808e | pbrook | TCGv tmp; |
684 | e6e5906b | pbrook | |
685 | e1f3808e | pbrook | /* TODO: Optimize compare/branch pairs rather than always flushing
|
686 | e1f3808e | pbrook | flag state to CC_OP_FLAGS. */
|
687 | e6e5906b | pbrook | gen_flush_flags(s); |
688 | e6e5906b | pbrook | switch (cond) {
|
689 | e6e5906b | pbrook | case 0: /* T */ |
690 | e1f3808e | pbrook | tcg_gen_br(l1); |
691 | e6e5906b | pbrook | break;
|
692 | e6e5906b | pbrook | case 1: /* F */ |
693 | e6e5906b | pbrook | break;
|
694 | e6e5906b | pbrook | case 2: /* HI (!C && !Z) */ |
695 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
696 | e1f3808e | pbrook | tcg_gen_andi_i32(tmp, QREG_CC_DEST, CCF_C | CCF_Z); |
697 | e1f3808e | pbrook | tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, l1);
|
698 | e6e5906b | pbrook | break;
|
699 | e6e5906b | pbrook | case 3: /* LS (C || Z) */ |
700 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
701 | e1f3808e | pbrook | tcg_gen_andi_i32(tmp, QREG_CC_DEST, CCF_C | CCF_Z); |
702 | e1f3808e | pbrook | tcg_gen_brcondi_i32(TCG_COND_NE, tmp, 0, l1);
|
703 | e6e5906b | pbrook | break;
|
704 | e6e5906b | pbrook | case 4: /* CC (!C) */ |
705 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
706 | e1f3808e | pbrook | tcg_gen_andi_i32(tmp, QREG_CC_DEST, CCF_C); |
707 | e1f3808e | pbrook | tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, l1);
|
708 | e6e5906b | pbrook | break;
|
709 | e6e5906b | pbrook | case 5: /* CS (C) */ |
710 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
711 | e1f3808e | pbrook | tcg_gen_andi_i32(tmp, QREG_CC_DEST, CCF_C); |
712 | e1f3808e | pbrook | tcg_gen_brcondi_i32(TCG_COND_NE, tmp, 0, l1);
|
713 | e6e5906b | pbrook | break;
|
714 | e6e5906b | pbrook | case 6: /* NE (!Z) */ |
715 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
716 | e1f3808e | pbrook | tcg_gen_andi_i32(tmp, QREG_CC_DEST, CCF_Z); |
717 | e1f3808e | pbrook | tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, l1);
|
718 | e6e5906b | pbrook | break;
|
719 | e6e5906b | pbrook | case 7: /* EQ (Z) */ |
720 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
721 | e1f3808e | pbrook | tcg_gen_andi_i32(tmp, QREG_CC_DEST, CCF_Z); |
722 | e1f3808e | pbrook | tcg_gen_brcondi_i32(TCG_COND_NE, tmp, 0, l1);
|
723 | e6e5906b | pbrook | break;
|
724 | e6e5906b | pbrook | case 8: /* VC (!V) */ |
725 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
726 | e1f3808e | pbrook | tcg_gen_andi_i32(tmp, QREG_CC_DEST, CCF_V); |
727 | e1f3808e | pbrook | tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, l1);
|
728 | e6e5906b | pbrook | break;
|
729 | e6e5906b | pbrook | case 9: /* VS (V) */ |
730 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
731 | e1f3808e | pbrook | tcg_gen_andi_i32(tmp, QREG_CC_DEST, CCF_V); |
732 | e1f3808e | pbrook | tcg_gen_brcondi_i32(TCG_COND_NE, tmp, 0, l1);
|
733 | e6e5906b | pbrook | break;
|
734 | e6e5906b | pbrook | case 10: /* PL (!N) */ |
735 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
736 | e1f3808e | pbrook | tcg_gen_andi_i32(tmp, QREG_CC_DEST, CCF_N); |
737 | e1f3808e | pbrook | tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, l1);
|
738 | e6e5906b | pbrook | break;
|
739 | e6e5906b | pbrook | case 11: /* MI (N) */ |
740 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
741 | e1f3808e | pbrook | tcg_gen_andi_i32(tmp, QREG_CC_DEST, CCF_N); |
742 | e1f3808e | pbrook | tcg_gen_brcondi_i32(TCG_COND_NE, tmp, 0, l1);
|
743 | e6e5906b | pbrook | break;
|
744 | e6e5906b | pbrook | case 12: /* GE (!(N ^ V)) */ |
745 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
746 | e1f3808e | pbrook | assert(CCF_V == (CCF_N >> 2));
|
747 | e1f3808e | pbrook | tcg_gen_shri_i32(tmp, QREG_CC_DEST, 2);
|
748 | e1f3808e | pbrook | tcg_gen_xor_i32(tmp, tmp, QREG_CC_DEST); |
749 | e1f3808e | pbrook | tcg_gen_andi_i32(tmp, tmp, CCF_V); |
750 | e1f3808e | pbrook | tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, l1);
|
751 | e6e5906b | pbrook | break;
|
752 | e6e5906b | pbrook | case 13: /* LT (N ^ V) */ |
753 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
754 | e1f3808e | pbrook | assert(CCF_V == (CCF_N >> 2));
|
755 | e1f3808e | pbrook | tcg_gen_shri_i32(tmp, QREG_CC_DEST, 2);
|
756 | e1f3808e | pbrook | tcg_gen_xor_i32(tmp, tmp, QREG_CC_DEST); |
757 | e1f3808e | pbrook | tcg_gen_andi_i32(tmp, tmp, CCF_V); |
758 | e1f3808e | pbrook | tcg_gen_brcondi_i32(TCG_COND_NE, tmp, 0, l1);
|
759 | e6e5906b | pbrook | break;
|
760 | e6e5906b | pbrook | case 14: /* GT (!(Z || (N ^ V))) */ |
761 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
762 | e1f3808e | pbrook | assert(CCF_V == (CCF_N >> 2));
|
763 | e1f3808e | pbrook | tcg_gen_andi_i32(tmp, QREG_CC_DEST, CCF_N); |
764 | e1f3808e | pbrook | tcg_gen_shri_i32(tmp, tmp, 2);
|
765 | e1f3808e | pbrook | tcg_gen_xor_i32(tmp, tmp, QREG_CC_DEST); |
766 | e1f3808e | pbrook | tcg_gen_andi_i32(tmp, tmp, CCF_V | CCF_Z); |
767 | e1f3808e | pbrook | tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, l1);
|
768 | e6e5906b | pbrook | break;
|
769 | e6e5906b | pbrook | case 15: /* LE (Z || (N ^ V)) */ |
770 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
771 | e1f3808e | pbrook | assert(CCF_V == (CCF_N >> 2));
|
772 | e1f3808e | pbrook | tcg_gen_andi_i32(tmp, QREG_CC_DEST, CCF_N); |
773 | e1f3808e | pbrook | tcg_gen_shri_i32(tmp, tmp, 2);
|
774 | e1f3808e | pbrook | tcg_gen_xor_i32(tmp, tmp, QREG_CC_DEST); |
775 | e1f3808e | pbrook | tcg_gen_andi_i32(tmp, tmp, CCF_V | CCF_Z); |
776 | e1f3808e | pbrook | tcg_gen_brcondi_i32(TCG_COND_NE, tmp, 0, l1);
|
777 | e6e5906b | pbrook | break;
|
778 | e6e5906b | pbrook | default:
|
779 | e6e5906b | pbrook | /* Should ever happen. */
|
780 | e6e5906b | pbrook | abort(); |
781 | e6e5906b | pbrook | } |
782 | e6e5906b | pbrook | } |
783 | e6e5906b | pbrook | |
784 | e6e5906b | pbrook | DISAS_INSN(scc) |
785 | e6e5906b | pbrook | { |
786 | e6e5906b | pbrook | int l1;
|
787 | e6e5906b | pbrook | int cond;
|
788 | e1f3808e | pbrook | TCGv reg; |
789 | e6e5906b | pbrook | |
790 | e6e5906b | pbrook | l1 = gen_new_label(); |
791 | e6e5906b | pbrook | cond = (insn >> 8) & 0xf; |
792 | e6e5906b | pbrook | reg = DREG(insn, 0);
|
793 | e1f3808e | pbrook | tcg_gen_andi_i32(reg, reg, 0xffffff00);
|
794 | e1f3808e | pbrook | /* This is safe because we modify the reg directly, with no other values
|
795 | e1f3808e | pbrook | live. */
|
796 | e6e5906b | pbrook | gen_jmpcc(s, cond ^ 1, l1);
|
797 | e1f3808e | pbrook | tcg_gen_ori_i32(reg, reg, 0xff);
|
798 | e6e5906b | pbrook | gen_set_label(l1); |
799 | e6e5906b | pbrook | } |
800 | e6e5906b | pbrook | |
801 | 0633879f | pbrook | /* Force a TB lookup after an instruction that changes the CPU state. */
|
802 | 0633879f | pbrook | static void gen_lookup_tb(DisasContext *s) |
803 | 0633879f | pbrook | { |
804 | 0633879f | pbrook | gen_flush_cc_op(s); |
805 | e1f3808e | pbrook | tcg_gen_movi_i32(QREG_PC, s->pc); |
806 | 0633879f | pbrook | s->is_jmp = DISAS_UPDATE; |
807 | 0633879f | pbrook | } |
808 | 0633879f | pbrook | |
809 | e1f3808e | pbrook | /* Generate a jump to an immediate address. */
|
810 | e1f3808e | pbrook | static void gen_jmp_im(DisasContext *s, uint32_t dest) |
811 | e1f3808e | pbrook | { |
812 | e1f3808e | pbrook | gen_flush_cc_op(s); |
813 | e1f3808e | pbrook | tcg_gen_movi_i32(QREG_PC, dest); |
814 | e1f3808e | pbrook | s->is_jmp = DISAS_JUMP; |
815 | e1f3808e | pbrook | } |
816 | e1f3808e | pbrook | |
817 | e1f3808e | pbrook | /* Generate a jump to the address in qreg DEST. */
|
818 | e1f3808e | pbrook | static void gen_jmp(DisasContext *s, TCGv dest) |
819 | e6e5906b | pbrook | { |
820 | e6e5906b | pbrook | gen_flush_cc_op(s); |
821 | e1f3808e | pbrook | tcg_gen_mov_i32(QREG_PC, dest); |
822 | e6e5906b | pbrook | s->is_jmp = DISAS_JUMP; |
823 | e6e5906b | pbrook | } |
824 | e6e5906b | pbrook | |
825 | e6e5906b | pbrook | static void gen_exception(DisasContext *s, uint32_t where, int nr) |
826 | e6e5906b | pbrook | { |
827 | e6e5906b | pbrook | gen_flush_cc_op(s); |
828 | e1f3808e | pbrook | gen_jmp_im(s, where); |
829 | e1f3808e | pbrook | gen_helper_raise_exception(tcg_const_i32(nr)); |
830 | e6e5906b | pbrook | } |
831 | e6e5906b | pbrook | |
832 | 510ff0b7 | pbrook | static inline void gen_addr_fault(DisasContext *s) |
833 | 510ff0b7 | pbrook | { |
834 | 510ff0b7 | pbrook | gen_exception(s, s->insn_pc, EXCP_ADDRESS); |
835 | 510ff0b7 | pbrook | } |
836 | 510ff0b7 | pbrook | |
837 | e1f3808e | pbrook | #define SRC_EA(result, opsize, op_sign, addrp) do { \ |
838 | e1f3808e | pbrook | result = gen_ea(s, insn, opsize, NULL_QREG, addrp, op_sign ? EA_LOADS : EA_LOADU); \ |
839 | e1f3808e | pbrook | if (IS_NULL_QREG(result)) { \
|
840 | 510ff0b7 | pbrook | gen_addr_fault(s); \ |
841 | 510ff0b7 | pbrook | return; \
|
842 | 510ff0b7 | pbrook | } \ |
843 | 510ff0b7 | pbrook | } while (0) |
844 | 510ff0b7 | pbrook | |
845 | 510ff0b7 | pbrook | #define DEST_EA(insn, opsize, val, addrp) do { \ |
846 | e1f3808e | pbrook | TCGv ea_result = gen_ea(s, insn, opsize, val, addrp, EA_STORE); \ |
847 | e1f3808e | pbrook | if (IS_NULL_QREG(ea_result)) { \
|
848 | 510ff0b7 | pbrook | gen_addr_fault(s); \ |
849 | 510ff0b7 | pbrook | return; \
|
850 | 510ff0b7 | pbrook | } \ |
851 | 510ff0b7 | pbrook | } while (0) |
852 | 510ff0b7 | pbrook | |
853 | e6e5906b | pbrook | /* Generate a jump to an immediate address. */
|
854 | e6e5906b | pbrook | static void gen_jmp_tb(DisasContext *s, int n, uint32_t dest) |
855 | e6e5906b | pbrook | { |
856 | e6e5906b | pbrook | TranslationBlock *tb; |
857 | e6e5906b | pbrook | |
858 | e6e5906b | pbrook | tb = s->tb; |
859 | 551bd27f | ths | if (unlikely(s->singlestep_enabled)) {
|
860 | e6e5906b | pbrook | gen_exception(s, dest, EXCP_DEBUG); |
861 | e6e5906b | pbrook | } else if ((tb->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK) || |
862 | e6e5906b | pbrook | (s->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK)) { |
863 | 57fec1fe | bellard | tcg_gen_goto_tb(n); |
864 | e1f3808e | pbrook | tcg_gen_movi_i32(QREG_PC, dest); |
865 | 57fec1fe | bellard | tcg_gen_exit_tb((long)tb + n);
|
866 | e6e5906b | pbrook | } else {
|
867 | e1f3808e | pbrook | gen_jmp_im(s, dest); |
868 | 57fec1fe | bellard | tcg_gen_exit_tb(0);
|
869 | e6e5906b | pbrook | } |
870 | e6e5906b | pbrook | s->is_jmp = DISAS_TB_JUMP; |
871 | e6e5906b | pbrook | } |
872 | e6e5906b | pbrook | |
873 | e6e5906b | pbrook | DISAS_INSN(undef_mac) |
874 | e6e5906b | pbrook | { |
875 | e6e5906b | pbrook | gen_exception(s, s->pc - 2, EXCP_LINEA);
|
876 | e6e5906b | pbrook | } |
877 | e6e5906b | pbrook | |
878 | e6e5906b | pbrook | DISAS_INSN(undef_fpu) |
879 | e6e5906b | pbrook | { |
880 | e6e5906b | pbrook | gen_exception(s, s->pc - 2, EXCP_LINEF);
|
881 | e6e5906b | pbrook | } |
882 | e6e5906b | pbrook | |
883 | e6e5906b | pbrook | DISAS_INSN(undef) |
884 | e6e5906b | pbrook | { |
885 | e6e5906b | pbrook | gen_exception(s, s->pc - 2, EXCP_UNSUPPORTED);
|
886 | e6e5906b | pbrook | cpu_abort(cpu_single_env, "Illegal instruction: %04x @ %08x",
|
887 | e6e5906b | pbrook | insn, s->pc - 2);
|
888 | e6e5906b | pbrook | } |
889 | e6e5906b | pbrook | |
890 | e6e5906b | pbrook | DISAS_INSN(mulw) |
891 | e6e5906b | pbrook | { |
892 | e1f3808e | pbrook | TCGv reg; |
893 | e1f3808e | pbrook | TCGv tmp; |
894 | e1f3808e | pbrook | TCGv src; |
895 | e6e5906b | pbrook | int sign;
|
896 | e6e5906b | pbrook | |
897 | e6e5906b | pbrook | sign = (insn & 0x100) != 0; |
898 | e6e5906b | pbrook | reg = DREG(insn, 9);
|
899 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
900 | e6e5906b | pbrook | if (sign)
|
901 | e1f3808e | pbrook | tcg_gen_ext16s_i32(tmp, reg); |
902 | e6e5906b | pbrook | else
|
903 | e1f3808e | pbrook | tcg_gen_ext16u_i32(tmp, reg); |
904 | e1f3808e | pbrook | SRC_EA(src, OS_WORD, sign, NULL);
|
905 | e1f3808e | pbrook | tcg_gen_mul_i32(tmp, tmp, src); |
906 | e1f3808e | pbrook | tcg_gen_mov_i32(reg, tmp); |
907 | e6e5906b | pbrook | /* Unlike m68k, coldfire always clears the overflow bit. */
|
908 | e6e5906b | pbrook | gen_logic_cc(s, tmp); |
909 | e6e5906b | pbrook | } |
910 | e6e5906b | pbrook | |
911 | e6e5906b | pbrook | DISAS_INSN(divw) |
912 | e6e5906b | pbrook | { |
913 | e1f3808e | pbrook | TCGv reg; |
914 | e1f3808e | pbrook | TCGv tmp; |
915 | e1f3808e | pbrook | TCGv src; |
916 | e6e5906b | pbrook | int sign;
|
917 | e6e5906b | pbrook | |
918 | e6e5906b | pbrook | sign = (insn & 0x100) != 0; |
919 | e6e5906b | pbrook | reg = DREG(insn, 9);
|
920 | e6e5906b | pbrook | if (sign) {
|
921 | e1f3808e | pbrook | tcg_gen_ext16s_i32(QREG_DIV1, reg); |
922 | e6e5906b | pbrook | } else {
|
923 | e1f3808e | pbrook | tcg_gen_ext16u_i32(QREG_DIV1, reg); |
924 | e6e5906b | pbrook | } |
925 | e1f3808e | pbrook | SRC_EA(src, OS_WORD, sign, NULL);
|
926 | e1f3808e | pbrook | tcg_gen_mov_i32(QREG_DIV2, src); |
927 | e6e5906b | pbrook | if (sign) {
|
928 | e1f3808e | pbrook | gen_helper_divs(cpu_env, tcg_const_i32(1));
|
929 | e6e5906b | pbrook | } else {
|
930 | e1f3808e | pbrook | gen_helper_divu(cpu_env, tcg_const_i32(1));
|
931 | e6e5906b | pbrook | } |
932 | e6e5906b | pbrook | |
933 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
934 | a7812ae4 | pbrook | src = tcg_temp_new(); |
935 | e1f3808e | pbrook | tcg_gen_ext16u_i32(tmp, QREG_DIV1); |
936 | e1f3808e | pbrook | tcg_gen_shli_i32(src, QREG_DIV2, 16);
|
937 | e1f3808e | pbrook | tcg_gen_or_i32(reg, tmp, src); |
938 | e6e5906b | pbrook | s->cc_op = CC_OP_FLAGS; |
939 | e6e5906b | pbrook | } |
940 | e6e5906b | pbrook | |
941 | e6e5906b | pbrook | DISAS_INSN(divl) |
942 | e6e5906b | pbrook | { |
943 | e1f3808e | pbrook | TCGv num; |
944 | e1f3808e | pbrook | TCGv den; |
945 | e1f3808e | pbrook | TCGv reg; |
946 | e6e5906b | pbrook | uint16_t ext; |
947 | e6e5906b | pbrook | |
948 | 0633879f | pbrook | ext = lduw_code(s->pc); |
949 | e6e5906b | pbrook | s->pc += 2;
|
950 | e6e5906b | pbrook | if (ext & 0x87f8) { |
951 | e6e5906b | pbrook | gen_exception(s, s->pc - 4, EXCP_UNSUPPORTED);
|
952 | e6e5906b | pbrook | return;
|
953 | e6e5906b | pbrook | } |
954 | e6e5906b | pbrook | num = DREG(ext, 12);
|
955 | e6e5906b | pbrook | reg = DREG(ext, 0);
|
956 | e1f3808e | pbrook | tcg_gen_mov_i32(QREG_DIV1, num); |
957 | 510ff0b7 | pbrook | SRC_EA(den, OS_LONG, 0, NULL); |
958 | e1f3808e | pbrook | tcg_gen_mov_i32(QREG_DIV2, den); |
959 | e6e5906b | pbrook | if (ext & 0x0800) { |
960 | e1f3808e | pbrook | gen_helper_divs(cpu_env, tcg_const_i32(0));
|
961 | e6e5906b | pbrook | } else {
|
962 | e1f3808e | pbrook | gen_helper_divu(cpu_env, tcg_const_i32(0));
|
963 | e6e5906b | pbrook | } |
964 | e1f3808e | pbrook | if ((ext & 7) == ((ext >> 12) & 7)) { |
965 | e6e5906b | pbrook | /* div */
|
966 | e1f3808e | pbrook | tcg_gen_mov_i32 (reg, QREG_DIV1); |
967 | e6e5906b | pbrook | } else {
|
968 | e6e5906b | pbrook | /* rem */
|
969 | e1f3808e | pbrook | tcg_gen_mov_i32 (reg, QREG_DIV2); |
970 | e6e5906b | pbrook | } |
971 | e6e5906b | pbrook | s->cc_op = CC_OP_FLAGS; |
972 | e6e5906b | pbrook | } |
973 | e6e5906b | pbrook | |
974 | e6e5906b | pbrook | DISAS_INSN(addsub) |
975 | e6e5906b | pbrook | { |
976 | e1f3808e | pbrook | TCGv reg; |
977 | e1f3808e | pbrook | TCGv dest; |
978 | e1f3808e | pbrook | TCGv src; |
979 | e1f3808e | pbrook | TCGv tmp; |
980 | e1f3808e | pbrook | TCGv addr; |
981 | e6e5906b | pbrook | int add;
|
982 | e6e5906b | pbrook | |
983 | e6e5906b | pbrook | add = (insn & 0x4000) != 0; |
984 | e6e5906b | pbrook | reg = DREG(insn, 9);
|
985 | a7812ae4 | pbrook | dest = tcg_temp_new(); |
986 | e6e5906b | pbrook | if (insn & 0x100) { |
987 | 510ff0b7 | pbrook | SRC_EA(tmp, OS_LONG, 0, &addr);
|
988 | e6e5906b | pbrook | src = reg; |
989 | e6e5906b | pbrook | } else {
|
990 | e6e5906b | pbrook | tmp = reg; |
991 | 510ff0b7 | pbrook | SRC_EA(src, OS_LONG, 0, NULL); |
992 | e6e5906b | pbrook | } |
993 | e6e5906b | pbrook | if (add) {
|
994 | e1f3808e | pbrook | tcg_gen_add_i32(dest, tmp, src); |
995 | e1f3808e | pbrook | gen_helper_xflag_lt(QREG_CC_X, dest, src); |
996 | e6e5906b | pbrook | s->cc_op = CC_OP_ADD; |
997 | e6e5906b | pbrook | } else {
|
998 | e1f3808e | pbrook | gen_helper_xflag_lt(QREG_CC_X, tmp, src); |
999 | e1f3808e | pbrook | tcg_gen_sub_i32(dest, tmp, src); |
1000 | e6e5906b | pbrook | s->cc_op = CC_OP_SUB; |
1001 | e6e5906b | pbrook | } |
1002 | e1f3808e | pbrook | gen_update_cc_add(dest, src); |
1003 | e6e5906b | pbrook | if (insn & 0x100) { |
1004 | 510ff0b7 | pbrook | DEST_EA(insn, OS_LONG, dest, &addr); |
1005 | e6e5906b | pbrook | } else {
|
1006 | e1f3808e | pbrook | tcg_gen_mov_i32(reg, dest); |
1007 | e6e5906b | pbrook | } |
1008 | e6e5906b | pbrook | } |
1009 | e6e5906b | pbrook | |
1010 | e6e5906b | pbrook | |
1011 | e6e5906b | pbrook | /* Reverse the order of the bits in REG. */
|
1012 | e6e5906b | pbrook | DISAS_INSN(bitrev) |
1013 | e6e5906b | pbrook | { |
1014 | e1f3808e | pbrook | TCGv reg; |
1015 | e6e5906b | pbrook | reg = DREG(insn, 0);
|
1016 | e1f3808e | pbrook | gen_helper_bitrev(reg, reg); |
1017 | e6e5906b | pbrook | } |
1018 | e6e5906b | pbrook | |
1019 | e6e5906b | pbrook | DISAS_INSN(bitop_reg) |
1020 | e6e5906b | pbrook | { |
1021 | e6e5906b | pbrook | int opsize;
|
1022 | e6e5906b | pbrook | int op;
|
1023 | e1f3808e | pbrook | TCGv src1; |
1024 | e1f3808e | pbrook | TCGv src2; |
1025 | e1f3808e | pbrook | TCGv tmp; |
1026 | e1f3808e | pbrook | TCGv addr; |
1027 | e1f3808e | pbrook | TCGv dest; |
1028 | e6e5906b | pbrook | |
1029 | e6e5906b | pbrook | if ((insn & 0x38) != 0) |
1030 | e6e5906b | pbrook | opsize = OS_BYTE; |
1031 | e6e5906b | pbrook | else
|
1032 | e6e5906b | pbrook | opsize = OS_LONG; |
1033 | e6e5906b | pbrook | op = (insn >> 6) & 3; |
1034 | 510ff0b7 | pbrook | SRC_EA(src1, opsize, 0, op ? &addr: NULL); |
1035 | e6e5906b | pbrook | src2 = DREG(insn, 9);
|
1036 | a7812ae4 | pbrook | dest = tcg_temp_new(); |
1037 | e6e5906b | pbrook | |
1038 | e6e5906b | pbrook | gen_flush_flags(s); |
1039 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
1040 | e6e5906b | pbrook | if (opsize == OS_BYTE)
|
1041 | e1f3808e | pbrook | tcg_gen_andi_i32(tmp, src2, 7);
|
1042 | e6e5906b | pbrook | else
|
1043 | e1f3808e | pbrook | tcg_gen_andi_i32(tmp, src2, 31);
|
1044 | e6e5906b | pbrook | src2 = tmp; |
1045 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
1046 | e1f3808e | pbrook | tcg_gen_shr_i32(tmp, src1, src2); |
1047 | e1f3808e | pbrook | tcg_gen_andi_i32(tmp, tmp, 1);
|
1048 | e1f3808e | pbrook | tcg_gen_shli_i32(tmp, tmp, 2);
|
1049 | e1f3808e | pbrook | /* Clear CCF_Z if bit set. */
|
1050 | e1f3808e | pbrook | tcg_gen_ori_i32(QREG_CC_DEST, QREG_CC_DEST, CCF_Z); |
1051 | e1f3808e | pbrook | tcg_gen_xor_i32(QREG_CC_DEST, QREG_CC_DEST, tmp); |
1052 | e1f3808e | pbrook | |
1053 | e1f3808e | pbrook | tcg_gen_shl_i32(tmp, tcg_const_i32(1), src2);
|
1054 | e6e5906b | pbrook | switch (op) {
|
1055 | e6e5906b | pbrook | case 1: /* bchg */ |
1056 | e1f3808e | pbrook | tcg_gen_xor_i32(dest, src1, tmp); |
1057 | e6e5906b | pbrook | break;
|
1058 | e6e5906b | pbrook | case 2: /* bclr */ |
1059 | e1f3808e | pbrook | tcg_gen_not_i32(tmp, tmp); |
1060 | e1f3808e | pbrook | tcg_gen_and_i32(dest, src1, tmp); |
1061 | e6e5906b | pbrook | break;
|
1062 | e6e5906b | pbrook | case 3: /* bset */ |
1063 | e1f3808e | pbrook | tcg_gen_or_i32(dest, src1, tmp); |
1064 | e6e5906b | pbrook | break;
|
1065 | e6e5906b | pbrook | default: /* btst */ |
1066 | e6e5906b | pbrook | break;
|
1067 | e6e5906b | pbrook | } |
1068 | e6e5906b | pbrook | if (op)
|
1069 | 510ff0b7 | pbrook | DEST_EA(insn, opsize, dest, &addr); |
1070 | e6e5906b | pbrook | } |
1071 | e6e5906b | pbrook | |
1072 | e6e5906b | pbrook | DISAS_INSN(sats) |
1073 | e6e5906b | pbrook | { |
1074 | e1f3808e | pbrook | TCGv reg; |
1075 | e6e5906b | pbrook | reg = DREG(insn, 0);
|
1076 | e6e5906b | pbrook | gen_flush_flags(s); |
1077 | e1f3808e | pbrook | gen_helper_sats(reg, reg, QREG_CC_DEST); |
1078 | e1f3808e | pbrook | gen_logic_cc(s, reg); |
1079 | e6e5906b | pbrook | } |
1080 | e6e5906b | pbrook | |
1081 | e1f3808e | pbrook | static void gen_push(DisasContext *s, TCGv val) |
1082 | e6e5906b | pbrook | { |
1083 | e1f3808e | pbrook | TCGv tmp; |
1084 | e6e5906b | pbrook | |
1085 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
1086 | e1f3808e | pbrook | tcg_gen_subi_i32(tmp, QREG_SP, 4);
|
1087 | 0633879f | pbrook | gen_store(s, OS_LONG, tmp, val); |
1088 | e1f3808e | pbrook | tcg_gen_mov_i32(QREG_SP, tmp); |
1089 | e6e5906b | pbrook | } |
1090 | e6e5906b | pbrook | |
1091 | e6e5906b | pbrook | DISAS_INSN(movem) |
1092 | e6e5906b | pbrook | { |
1093 | e1f3808e | pbrook | TCGv addr; |
1094 | e6e5906b | pbrook | int i;
|
1095 | e6e5906b | pbrook | uint16_t mask; |
1096 | e1f3808e | pbrook | TCGv reg; |
1097 | e1f3808e | pbrook | TCGv tmp; |
1098 | e6e5906b | pbrook | int is_load;
|
1099 | e6e5906b | pbrook | |
1100 | 0633879f | pbrook | mask = lduw_code(s->pc); |
1101 | e6e5906b | pbrook | s->pc += 2;
|
1102 | e6e5906b | pbrook | tmp = gen_lea(s, insn, OS_LONG); |
1103 | e1f3808e | pbrook | if (IS_NULL_QREG(tmp)) {
|
1104 | 510ff0b7 | pbrook | gen_addr_fault(s); |
1105 | 510ff0b7 | pbrook | return;
|
1106 | 510ff0b7 | pbrook | } |
1107 | a7812ae4 | pbrook | addr = tcg_temp_new(); |
1108 | e1f3808e | pbrook | tcg_gen_mov_i32(addr, tmp); |
1109 | e6e5906b | pbrook | is_load = ((insn & 0x0400) != 0); |
1110 | e6e5906b | pbrook | for (i = 0; i < 16; i++, mask >>= 1) { |
1111 | e6e5906b | pbrook | if (mask & 1) { |
1112 | e6e5906b | pbrook | if (i < 8) |
1113 | e6e5906b | pbrook | reg = DREG(i, 0);
|
1114 | e6e5906b | pbrook | else
|
1115 | e6e5906b | pbrook | reg = AREG(i, 0);
|
1116 | e6e5906b | pbrook | if (is_load) {
|
1117 | 0633879f | pbrook | tmp = gen_load(s, OS_LONG, addr, 0);
|
1118 | e1f3808e | pbrook | tcg_gen_mov_i32(reg, tmp); |
1119 | e6e5906b | pbrook | } else {
|
1120 | 0633879f | pbrook | gen_store(s, OS_LONG, addr, reg); |
1121 | e6e5906b | pbrook | } |
1122 | e6e5906b | pbrook | if (mask != 1) |
1123 | e1f3808e | pbrook | tcg_gen_addi_i32(addr, addr, 4);
|
1124 | e6e5906b | pbrook | } |
1125 | e6e5906b | pbrook | } |
1126 | e6e5906b | pbrook | } |
1127 | e6e5906b | pbrook | |
1128 | e6e5906b | pbrook | DISAS_INSN(bitop_im) |
1129 | e6e5906b | pbrook | { |
1130 | e6e5906b | pbrook | int opsize;
|
1131 | e6e5906b | pbrook | int op;
|
1132 | e1f3808e | pbrook | TCGv src1; |
1133 | e6e5906b | pbrook | uint32_t mask; |
1134 | e6e5906b | pbrook | int bitnum;
|
1135 | e1f3808e | pbrook | TCGv tmp; |
1136 | e1f3808e | pbrook | TCGv addr; |
1137 | e6e5906b | pbrook | |
1138 | e6e5906b | pbrook | if ((insn & 0x38) != 0) |
1139 | e6e5906b | pbrook | opsize = OS_BYTE; |
1140 | e6e5906b | pbrook | else
|
1141 | e6e5906b | pbrook | opsize = OS_LONG; |
1142 | e6e5906b | pbrook | op = (insn >> 6) & 3; |
1143 | e6e5906b | pbrook | |
1144 | 0633879f | pbrook | bitnum = lduw_code(s->pc); |
1145 | e6e5906b | pbrook | s->pc += 2;
|
1146 | e6e5906b | pbrook | if (bitnum & 0xff00) { |
1147 | e6e5906b | pbrook | disas_undef(s, insn); |
1148 | e6e5906b | pbrook | return;
|
1149 | e6e5906b | pbrook | } |
1150 | e6e5906b | pbrook | |
1151 | 510ff0b7 | pbrook | SRC_EA(src1, opsize, 0, op ? &addr: NULL); |
1152 | e6e5906b | pbrook | |
1153 | e6e5906b | pbrook | gen_flush_flags(s); |
1154 | e6e5906b | pbrook | if (opsize == OS_BYTE)
|
1155 | e6e5906b | pbrook | bitnum &= 7;
|
1156 | e6e5906b | pbrook | else
|
1157 | e6e5906b | pbrook | bitnum &= 31;
|
1158 | e6e5906b | pbrook | mask = 1 << bitnum;
|
1159 | e6e5906b | pbrook | |
1160 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
1161 | e1f3808e | pbrook | assert (CCF_Z == (1 << 2)); |
1162 | e1f3808e | pbrook | if (bitnum > 2) |
1163 | e1f3808e | pbrook | tcg_gen_shri_i32(tmp, src1, bitnum - 2);
|
1164 | e1f3808e | pbrook | else if (bitnum < 2) |
1165 | e1f3808e | pbrook | tcg_gen_shli_i32(tmp, src1, 2 - bitnum);
|
1166 | e6e5906b | pbrook | else
|
1167 | e1f3808e | pbrook | tcg_gen_mov_i32(tmp, src1); |
1168 | e1f3808e | pbrook | tcg_gen_andi_i32(tmp, tmp, CCF_Z); |
1169 | e1f3808e | pbrook | /* Clear CCF_Z if bit set. */
|
1170 | e1f3808e | pbrook | tcg_gen_ori_i32(QREG_CC_DEST, QREG_CC_DEST, CCF_Z); |
1171 | e1f3808e | pbrook | tcg_gen_xor_i32(QREG_CC_DEST, QREG_CC_DEST, tmp); |
1172 | e1f3808e | pbrook | if (op) {
|
1173 | e1f3808e | pbrook | switch (op) {
|
1174 | e1f3808e | pbrook | case 1: /* bchg */ |
1175 | e1f3808e | pbrook | tcg_gen_xori_i32(tmp, src1, mask); |
1176 | e1f3808e | pbrook | break;
|
1177 | e1f3808e | pbrook | case 2: /* bclr */ |
1178 | e1f3808e | pbrook | tcg_gen_andi_i32(tmp, src1, ~mask); |
1179 | e1f3808e | pbrook | break;
|
1180 | e1f3808e | pbrook | case 3: /* bset */ |
1181 | e1f3808e | pbrook | tcg_gen_ori_i32(tmp, src1, mask); |
1182 | e1f3808e | pbrook | break;
|
1183 | e1f3808e | pbrook | default: /* btst */ |
1184 | e1f3808e | pbrook | break;
|
1185 | e1f3808e | pbrook | } |
1186 | e1f3808e | pbrook | DEST_EA(insn, opsize, tmp, &addr); |
1187 | e6e5906b | pbrook | } |
1188 | e6e5906b | pbrook | } |
1189 | e6e5906b | pbrook | |
1190 | e6e5906b | pbrook | DISAS_INSN(arith_im) |
1191 | e6e5906b | pbrook | { |
1192 | e6e5906b | pbrook | int op;
|
1193 | e1f3808e | pbrook | uint32_t im; |
1194 | e1f3808e | pbrook | TCGv src1; |
1195 | e1f3808e | pbrook | TCGv dest; |
1196 | e1f3808e | pbrook | TCGv addr; |
1197 | e6e5906b | pbrook | |
1198 | e6e5906b | pbrook | op = (insn >> 9) & 7; |
1199 | 510ff0b7 | pbrook | SRC_EA(src1, OS_LONG, 0, (op == 6) ? NULL : &addr); |
1200 | e1f3808e | pbrook | im = read_im32(s); |
1201 | a7812ae4 | pbrook | dest = tcg_temp_new(); |
1202 | e6e5906b | pbrook | switch (op) {
|
1203 | e6e5906b | pbrook | case 0: /* ori */ |
1204 | e1f3808e | pbrook | tcg_gen_ori_i32(dest, src1, im); |
1205 | e6e5906b | pbrook | gen_logic_cc(s, dest); |
1206 | e6e5906b | pbrook | break;
|
1207 | e6e5906b | pbrook | case 1: /* andi */ |
1208 | e1f3808e | pbrook | tcg_gen_andi_i32(dest, src1, im); |
1209 | e6e5906b | pbrook | gen_logic_cc(s, dest); |
1210 | e6e5906b | pbrook | break;
|
1211 | e6e5906b | pbrook | case 2: /* subi */ |
1212 | e1f3808e | pbrook | tcg_gen_mov_i32(dest, src1); |
1213 | e1f3808e | pbrook | gen_helper_xflag_lt(QREG_CC_X, dest, gen_im32(im)); |
1214 | e1f3808e | pbrook | tcg_gen_subi_i32(dest, dest, im); |
1215 | e1f3808e | pbrook | gen_update_cc_add(dest, gen_im32(im)); |
1216 | e6e5906b | pbrook | s->cc_op = CC_OP_SUB; |
1217 | e6e5906b | pbrook | break;
|
1218 | e6e5906b | pbrook | case 3: /* addi */ |
1219 | e1f3808e | pbrook | tcg_gen_mov_i32(dest, src1); |
1220 | e1f3808e | pbrook | tcg_gen_addi_i32(dest, dest, im); |
1221 | e1f3808e | pbrook | gen_update_cc_add(dest, gen_im32(im)); |
1222 | e1f3808e | pbrook | gen_helper_xflag_lt(QREG_CC_X, dest, gen_im32(im)); |
1223 | e6e5906b | pbrook | s->cc_op = CC_OP_ADD; |
1224 | e6e5906b | pbrook | break;
|
1225 | e6e5906b | pbrook | case 5: /* eori */ |
1226 | e1f3808e | pbrook | tcg_gen_xori_i32(dest, src1, im); |
1227 | e6e5906b | pbrook | gen_logic_cc(s, dest); |
1228 | e6e5906b | pbrook | break;
|
1229 | e6e5906b | pbrook | case 6: /* cmpi */ |
1230 | e1f3808e | pbrook | tcg_gen_mov_i32(dest, src1); |
1231 | e1f3808e | pbrook | tcg_gen_subi_i32(dest, dest, im); |
1232 | e1f3808e | pbrook | gen_update_cc_add(dest, gen_im32(im)); |
1233 | e6e5906b | pbrook | s->cc_op = CC_OP_SUB; |
1234 | e6e5906b | pbrook | break;
|
1235 | e6e5906b | pbrook | default:
|
1236 | e6e5906b | pbrook | abort(); |
1237 | e6e5906b | pbrook | } |
1238 | e6e5906b | pbrook | if (op != 6) { |
1239 | 510ff0b7 | pbrook | DEST_EA(insn, OS_LONG, dest, &addr); |
1240 | e6e5906b | pbrook | } |
1241 | e6e5906b | pbrook | } |
1242 | e6e5906b | pbrook | |
1243 | e6e5906b | pbrook | DISAS_INSN(byterev) |
1244 | e6e5906b | pbrook | { |
1245 | e1f3808e | pbrook | TCGv reg; |
1246 | e6e5906b | pbrook | |
1247 | e6e5906b | pbrook | reg = DREG(insn, 0);
|
1248 | 66896cb8 | aurel32 | tcg_gen_bswap32_i32(reg, reg); |
1249 | e6e5906b | pbrook | } |
1250 | e6e5906b | pbrook | |
1251 | e6e5906b | pbrook | DISAS_INSN(move) |
1252 | e6e5906b | pbrook | { |
1253 | e1f3808e | pbrook | TCGv src; |
1254 | e1f3808e | pbrook | TCGv dest; |
1255 | e6e5906b | pbrook | int op;
|
1256 | e6e5906b | pbrook | int opsize;
|
1257 | e6e5906b | pbrook | |
1258 | e6e5906b | pbrook | switch (insn >> 12) { |
1259 | e6e5906b | pbrook | case 1: /* move.b */ |
1260 | e6e5906b | pbrook | opsize = OS_BYTE; |
1261 | e6e5906b | pbrook | break;
|
1262 | e6e5906b | pbrook | case 2: /* move.l */ |
1263 | e6e5906b | pbrook | opsize = OS_LONG; |
1264 | e6e5906b | pbrook | break;
|
1265 | e6e5906b | pbrook | case 3: /* move.w */ |
1266 | e6e5906b | pbrook | opsize = OS_WORD; |
1267 | e6e5906b | pbrook | break;
|
1268 | e6e5906b | pbrook | default:
|
1269 | e6e5906b | pbrook | abort(); |
1270 | e6e5906b | pbrook | } |
1271 | e1f3808e | pbrook | SRC_EA(src, opsize, 1, NULL); |
1272 | e6e5906b | pbrook | op = (insn >> 6) & 7; |
1273 | e6e5906b | pbrook | if (op == 1) { |
1274 | e6e5906b | pbrook | /* movea */
|
1275 | e6e5906b | pbrook | /* The value will already have been sign extended. */
|
1276 | e6e5906b | pbrook | dest = AREG(insn, 9);
|
1277 | e1f3808e | pbrook | tcg_gen_mov_i32(dest, src); |
1278 | e6e5906b | pbrook | } else {
|
1279 | e6e5906b | pbrook | /* normal move */
|
1280 | e6e5906b | pbrook | uint16_t dest_ea; |
1281 | e6e5906b | pbrook | dest_ea = ((insn >> 9) & 7) | (op << 3); |
1282 | 510ff0b7 | pbrook | DEST_EA(dest_ea, opsize, src, NULL);
|
1283 | e6e5906b | pbrook | /* This will be correct because loads sign extend. */
|
1284 | e6e5906b | pbrook | gen_logic_cc(s, src); |
1285 | e6e5906b | pbrook | } |
1286 | e6e5906b | pbrook | } |
1287 | e6e5906b | pbrook | |
1288 | e6e5906b | pbrook | DISAS_INSN(negx) |
1289 | e6e5906b | pbrook | { |
1290 | e1f3808e | pbrook | TCGv reg; |
1291 | e6e5906b | pbrook | |
1292 | e6e5906b | pbrook | gen_flush_flags(s); |
1293 | e6e5906b | pbrook | reg = DREG(insn, 0);
|
1294 | e1f3808e | pbrook | gen_helper_subx_cc(reg, cpu_env, tcg_const_i32(0), reg);
|
1295 | e6e5906b | pbrook | } |
1296 | e6e5906b | pbrook | |
1297 | e6e5906b | pbrook | DISAS_INSN(lea) |
1298 | e6e5906b | pbrook | { |
1299 | e1f3808e | pbrook | TCGv reg; |
1300 | e1f3808e | pbrook | TCGv tmp; |
1301 | e6e5906b | pbrook | |
1302 | e6e5906b | pbrook | reg = AREG(insn, 9);
|
1303 | e6e5906b | pbrook | tmp = gen_lea(s, insn, OS_LONG); |
1304 | e1f3808e | pbrook | if (IS_NULL_QREG(tmp)) {
|
1305 | 510ff0b7 | pbrook | gen_addr_fault(s); |
1306 | 510ff0b7 | pbrook | return;
|
1307 | 510ff0b7 | pbrook | } |
1308 | e1f3808e | pbrook | tcg_gen_mov_i32(reg, tmp); |
1309 | e6e5906b | pbrook | } |
1310 | e6e5906b | pbrook | |
1311 | e6e5906b | pbrook | DISAS_INSN(clr) |
1312 | e6e5906b | pbrook | { |
1313 | e6e5906b | pbrook | int opsize;
|
1314 | e6e5906b | pbrook | |
1315 | e6e5906b | pbrook | switch ((insn >> 6) & 3) { |
1316 | e6e5906b | pbrook | case 0: /* clr.b */ |
1317 | e6e5906b | pbrook | opsize = OS_BYTE; |
1318 | e6e5906b | pbrook | break;
|
1319 | e6e5906b | pbrook | case 1: /* clr.w */ |
1320 | e6e5906b | pbrook | opsize = OS_WORD; |
1321 | e6e5906b | pbrook | break;
|
1322 | e6e5906b | pbrook | case 2: /* clr.l */ |
1323 | e6e5906b | pbrook | opsize = OS_LONG; |
1324 | e6e5906b | pbrook | break;
|
1325 | e6e5906b | pbrook | default:
|
1326 | e6e5906b | pbrook | abort(); |
1327 | e6e5906b | pbrook | } |
1328 | 510ff0b7 | pbrook | DEST_EA(insn, opsize, gen_im32(0), NULL); |
1329 | e6e5906b | pbrook | gen_logic_cc(s, gen_im32(0));
|
1330 | e6e5906b | pbrook | } |
1331 | e6e5906b | pbrook | |
1332 | e1f3808e | pbrook | static TCGv gen_get_ccr(DisasContext *s)
|
1333 | e6e5906b | pbrook | { |
1334 | e1f3808e | pbrook | TCGv dest; |
1335 | e6e5906b | pbrook | |
1336 | e6e5906b | pbrook | gen_flush_flags(s); |
1337 | a7812ae4 | pbrook | dest = tcg_temp_new(); |
1338 | e1f3808e | pbrook | tcg_gen_shli_i32(dest, QREG_CC_X, 4);
|
1339 | e1f3808e | pbrook | tcg_gen_or_i32(dest, dest, QREG_CC_DEST); |
1340 | 0633879f | pbrook | return dest;
|
1341 | 0633879f | pbrook | } |
1342 | 0633879f | pbrook | |
1343 | 0633879f | pbrook | DISAS_INSN(move_from_ccr) |
1344 | 0633879f | pbrook | { |
1345 | e1f3808e | pbrook | TCGv reg; |
1346 | e1f3808e | pbrook | TCGv ccr; |
1347 | 0633879f | pbrook | |
1348 | 0633879f | pbrook | ccr = gen_get_ccr(s); |
1349 | e6e5906b | pbrook | reg = DREG(insn, 0);
|
1350 | 0633879f | pbrook | gen_partset_reg(OS_WORD, reg, ccr); |
1351 | e6e5906b | pbrook | } |
1352 | e6e5906b | pbrook | |
1353 | e6e5906b | pbrook | DISAS_INSN(neg) |
1354 | e6e5906b | pbrook | { |
1355 | e1f3808e | pbrook | TCGv reg; |
1356 | e1f3808e | pbrook | TCGv src1; |
1357 | e6e5906b | pbrook | |
1358 | e6e5906b | pbrook | reg = DREG(insn, 0);
|
1359 | a7812ae4 | pbrook | src1 = tcg_temp_new(); |
1360 | e1f3808e | pbrook | tcg_gen_mov_i32(src1, reg); |
1361 | e1f3808e | pbrook | tcg_gen_neg_i32(reg, src1); |
1362 | e6e5906b | pbrook | s->cc_op = CC_OP_SUB; |
1363 | e1f3808e | pbrook | gen_update_cc_add(reg, src1); |
1364 | e1f3808e | pbrook | gen_helper_xflag_lt(QREG_CC_X, tcg_const_i32(0), src1);
|
1365 | e6e5906b | pbrook | s->cc_op = CC_OP_SUB; |
1366 | e6e5906b | pbrook | } |
1367 | e6e5906b | pbrook | |
1368 | 0633879f | pbrook | static void gen_set_sr_im(DisasContext *s, uint16_t val, int ccr_only) |
1369 | 0633879f | pbrook | { |
1370 | e1f3808e | pbrook | tcg_gen_movi_i32(QREG_CC_DEST, val & 0xf);
|
1371 | e1f3808e | pbrook | tcg_gen_movi_i32(QREG_CC_X, (val & 0x10) >> 4); |
1372 | 0633879f | pbrook | if (!ccr_only) {
|
1373 | e1f3808e | pbrook | gen_helper_set_sr(cpu_env, tcg_const_i32(val & 0xff00));
|
1374 | 0633879f | pbrook | } |
1375 | 0633879f | pbrook | } |
1376 | 0633879f | pbrook | |
1377 | 0633879f | pbrook | static void gen_set_sr(DisasContext *s, uint16_t insn, int ccr_only) |
1378 | e6e5906b | pbrook | { |
1379 | e1f3808e | pbrook | TCGv tmp; |
1380 | e1f3808e | pbrook | TCGv reg; |
1381 | e6e5906b | pbrook | |
1382 | e6e5906b | pbrook | s->cc_op = CC_OP_FLAGS; |
1383 | e6e5906b | pbrook | if ((insn & 0x38) == 0) |
1384 | e6e5906b | pbrook | { |
1385 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
1386 | e6e5906b | pbrook | reg = DREG(insn, 0);
|
1387 | e1f3808e | pbrook | tcg_gen_andi_i32(QREG_CC_DEST, reg, 0xf);
|
1388 | e1f3808e | pbrook | tcg_gen_shri_i32(tmp, reg, 4);
|
1389 | e1f3808e | pbrook | tcg_gen_andi_i32(QREG_CC_X, tmp, 1);
|
1390 | 0633879f | pbrook | if (!ccr_only) {
|
1391 | e1f3808e | pbrook | gen_helper_set_sr(cpu_env, reg); |
1392 | 0633879f | pbrook | } |
1393 | e6e5906b | pbrook | } |
1394 | 0633879f | pbrook | else if ((insn & 0x3f) == 0x3c) |
1395 | e6e5906b | pbrook | { |
1396 | 0633879f | pbrook | uint16_t val; |
1397 | 0633879f | pbrook | val = lduw_code(s->pc); |
1398 | e6e5906b | pbrook | s->pc += 2;
|
1399 | 0633879f | pbrook | gen_set_sr_im(s, val, ccr_only); |
1400 | e6e5906b | pbrook | } |
1401 | e6e5906b | pbrook | else
|
1402 | e6e5906b | pbrook | disas_undef(s, insn); |
1403 | e6e5906b | pbrook | } |
1404 | e6e5906b | pbrook | |
1405 | 0633879f | pbrook | DISAS_INSN(move_to_ccr) |
1406 | 0633879f | pbrook | { |
1407 | 0633879f | pbrook | gen_set_sr(s, insn, 1);
|
1408 | 0633879f | pbrook | } |
1409 | 0633879f | pbrook | |
1410 | e6e5906b | pbrook | DISAS_INSN(not) |
1411 | e6e5906b | pbrook | { |
1412 | e1f3808e | pbrook | TCGv reg; |
1413 | e6e5906b | pbrook | |
1414 | e6e5906b | pbrook | reg = DREG(insn, 0);
|
1415 | e1f3808e | pbrook | tcg_gen_not_i32(reg, reg); |
1416 | e6e5906b | pbrook | gen_logic_cc(s, reg); |
1417 | e6e5906b | pbrook | } |
1418 | e6e5906b | pbrook | |
1419 | e6e5906b | pbrook | DISAS_INSN(swap) |
1420 | e6e5906b | pbrook | { |
1421 | e1f3808e | pbrook | TCGv src1; |
1422 | e1f3808e | pbrook | TCGv src2; |
1423 | e1f3808e | pbrook | TCGv reg; |
1424 | e6e5906b | pbrook | |
1425 | a7812ae4 | pbrook | src1 = tcg_temp_new(); |
1426 | a7812ae4 | pbrook | src2 = tcg_temp_new(); |
1427 | e6e5906b | pbrook | reg = DREG(insn, 0);
|
1428 | e1f3808e | pbrook | tcg_gen_shli_i32(src1, reg, 16);
|
1429 | e1f3808e | pbrook | tcg_gen_shri_i32(src2, reg, 16);
|
1430 | e1f3808e | pbrook | tcg_gen_or_i32(reg, src1, src2); |
1431 | e1f3808e | pbrook | gen_logic_cc(s, reg); |
1432 | e6e5906b | pbrook | } |
1433 | e6e5906b | pbrook | |
1434 | e6e5906b | pbrook | DISAS_INSN(pea) |
1435 | e6e5906b | pbrook | { |
1436 | e1f3808e | pbrook | TCGv tmp; |
1437 | e6e5906b | pbrook | |
1438 | e6e5906b | pbrook | tmp = gen_lea(s, insn, OS_LONG); |
1439 | e1f3808e | pbrook | if (IS_NULL_QREG(tmp)) {
|
1440 | 510ff0b7 | pbrook | gen_addr_fault(s); |
1441 | 510ff0b7 | pbrook | return;
|
1442 | 510ff0b7 | pbrook | } |
1443 | 0633879f | pbrook | gen_push(s, tmp); |
1444 | e6e5906b | pbrook | } |
1445 | e6e5906b | pbrook | |
1446 | e6e5906b | pbrook | DISAS_INSN(ext) |
1447 | e6e5906b | pbrook | { |
1448 | e6e5906b | pbrook | int op;
|
1449 | e1f3808e | pbrook | TCGv reg; |
1450 | e1f3808e | pbrook | TCGv tmp; |
1451 | e6e5906b | pbrook | |
1452 | e6e5906b | pbrook | reg = DREG(insn, 0);
|
1453 | e6e5906b | pbrook | op = (insn >> 6) & 7; |
1454 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
1455 | e6e5906b | pbrook | if (op == 3) |
1456 | e1f3808e | pbrook | tcg_gen_ext16s_i32(tmp, reg); |
1457 | e6e5906b | pbrook | else
|
1458 | e1f3808e | pbrook | tcg_gen_ext8s_i32(tmp, reg); |
1459 | e6e5906b | pbrook | if (op == 2) |
1460 | e6e5906b | pbrook | gen_partset_reg(OS_WORD, reg, tmp); |
1461 | e6e5906b | pbrook | else
|
1462 | e1f3808e | pbrook | tcg_gen_mov_i32(reg, tmp); |
1463 | e6e5906b | pbrook | gen_logic_cc(s, tmp); |
1464 | e6e5906b | pbrook | } |
1465 | e6e5906b | pbrook | |
1466 | e6e5906b | pbrook | DISAS_INSN(tst) |
1467 | e6e5906b | pbrook | { |
1468 | e6e5906b | pbrook | int opsize;
|
1469 | e1f3808e | pbrook | TCGv tmp; |
1470 | e6e5906b | pbrook | |
1471 | e6e5906b | pbrook | switch ((insn >> 6) & 3) { |
1472 | e6e5906b | pbrook | case 0: /* tst.b */ |
1473 | e6e5906b | pbrook | opsize = OS_BYTE; |
1474 | e6e5906b | pbrook | break;
|
1475 | e6e5906b | pbrook | case 1: /* tst.w */ |
1476 | e6e5906b | pbrook | opsize = OS_WORD; |
1477 | e6e5906b | pbrook | break;
|
1478 | e6e5906b | pbrook | case 2: /* tst.l */ |
1479 | e6e5906b | pbrook | opsize = OS_LONG; |
1480 | e6e5906b | pbrook | break;
|
1481 | e6e5906b | pbrook | default:
|
1482 | e6e5906b | pbrook | abort(); |
1483 | e6e5906b | pbrook | } |
1484 | e1f3808e | pbrook | SRC_EA(tmp, opsize, 1, NULL); |
1485 | e6e5906b | pbrook | gen_logic_cc(s, tmp); |
1486 | e6e5906b | pbrook | } |
1487 | e6e5906b | pbrook | |
1488 | e6e5906b | pbrook | DISAS_INSN(pulse) |
1489 | e6e5906b | pbrook | { |
1490 | e6e5906b | pbrook | /* Implemented as a NOP. */
|
1491 | e6e5906b | pbrook | } |
1492 | e6e5906b | pbrook | |
1493 | e6e5906b | pbrook | DISAS_INSN(illegal) |
1494 | e6e5906b | pbrook | { |
1495 | e6e5906b | pbrook | gen_exception(s, s->pc - 2, EXCP_ILLEGAL);
|
1496 | e6e5906b | pbrook | } |
1497 | e6e5906b | pbrook | |
1498 | e6e5906b | pbrook | /* ??? This should be atomic. */
|
1499 | e6e5906b | pbrook | DISAS_INSN(tas) |
1500 | e6e5906b | pbrook | { |
1501 | e1f3808e | pbrook | TCGv dest; |
1502 | e1f3808e | pbrook | TCGv src1; |
1503 | e1f3808e | pbrook | TCGv addr; |
1504 | e6e5906b | pbrook | |
1505 | a7812ae4 | pbrook | dest = tcg_temp_new(); |
1506 | e1f3808e | pbrook | SRC_EA(src1, OS_BYTE, 1, &addr);
|
1507 | e6e5906b | pbrook | gen_logic_cc(s, src1); |
1508 | e1f3808e | pbrook | tcg_gen_ori_i32(dest, src1, 0x80);
|
1509 | 510ff0b7 | pbrook | DEST_EA(insn, OS_BYTE, dest, &addr); |
1510 | e6e5906b | pbrook | } |
1511 | e6e5906b | pbrook | |
1512 | e6e5906b | pbrook | DISAS_INSN(mull) |
1513 | e6e5906b | pbrook | { |
1514 | e6e5906b | pbrook | uint16_t ext; |
1515 | e1f3808e | pbrook | TCGv reg; |
1516 | e1f3808e | pbrook | TCGv src1; |
1517 | e1f3808e | pbrook | TCGv dest; |
1518 | e6e5906b | pbrook | |
1519 | e6e5906b | pbrook | /* The upper 32 bits of the product are discarded, so
|
1520 | e6e5906b | pbrook | muls.l and mulu.l are functionally equivalent. */
|
1521 | 0633879f | pbrook | ext = lduw_code(s->pc); |
1522 | e6e5906b | pbrook | s->pc += 2;
|
1523 | e6e5906b | pbrook | if (ext & 0x87ff) { |
1524 | e6e5906b | pbrook | gen_exception(s, s->pc - 4, EXCP_UNSUPPORTED);
|
1525 | e6e5906b | pbrook | return;
|
1526 | e6e5906b | pbrook | } |
1527 | e6e5906b | pbrook | reg = DREG(ext, 12);
|
1528 | 510ff0b7 | pbrook | SRC_EA(src1, OS_LONG, 0, NULL); |
1529 | a7812ae4 | pbrook | dest = tcg_temp_new(); |
1530 | e1f3808e | pbrook | tcg_gen_mul_i32(dest, src1, reg); |
1531 | e1f3808e | pbrook | tcg_gen_mov_i32(reg, dest); |
1532 | e6e5906b | pbrook | /* Unlike m68k, coldfire always clears the overflow bit. */
|
1533 | e6e5906b | pbrook | gen_logic_cc(s, dest); |
1534 | e6e5906b | pbrook | } |
1535 | e6e5906b | pbrook | |
1536 | e6e5906b | pbrook | DISAS_INSN(link) |
1537 | e6e5906b | pbrook | { |
1538 | e6e5906b | pbrook | int16_t offset; |
1539 | e1f3808e | pbrook | TCGv reg; |
1540 | e1f3808e | pbrook | TCGv tmp; |
1541 | e6e5906b | pbrook | |
1542 | 0633879f | pbrook | offset = ldsw_code(s->pc); |
1543 | e6e5906b | pbrook | s->pc += 2;
|
1544 | e6e5906b | pbrook | reg = AREG(insn, 0);
|
1545 | a7812ae4 | pbrook | tmp = tcg_temp_new(); |
1546 | e1f3808e | pbrook | tcg_gen_subi_i32(tmp, QREG_SP, 4);
|
1547 | 0633879f | pbrook | gen_store(s, OS_LONG, tmp, reg); |
1548 | e1f3808e | pbrook | if ((insn & 7) != 7) |
1549 | e1f3808e | pbrook | tcg_gen_mov_i32(reg, tmp); |
1550 | e1f3808e | pbrook | tcg_gen_addi_i32(QREG_SP, tmp, offset); |
1551 | e6e5906b | pbrook | } |
1552 | e6e5906b | pbrook | |
1553 | e6e5906b | pbrook | DISAS_INSN(unlk) |
1554 | e6e5906b | pbrook | { |
1555 | e1f3808e | pbrook | TCGv src; |
1556 | e1f3808e | pbrook | TCGv reg; |
1557 | e1f3808e | pbrook | TCGv tmp; |
1558 | e6e5906b | pbrook | |
1559 | a7812ae4 | pbrook | src = tcg_temp_new(); |
1560 | e6e5906b | pbrook | reg = AREG(insn, 0);
|
1561 | e1f3808e | pbrook | tcg_gen_mov_i32(src, reg); |
1562 | 0633879f | pbrook | tmp = gen_load(s, OS_LONG, src, 0);
|
1563 | e1f3808e | pbrook | tcg_gen_mov_i32(reg, tmp); |
1564 | e1f3808e | pbrook | tcg_gen_addi_i32(QREG_SP, src, 4);
|
1565 | e6e5906b | pbrook | } |
1566 | e6e5906b | pbrook | |
1567 | e6e5906b | pbrook | DISAS_INSN(nop) |
1568 | e6e5906b | pbrook | { |
1569 | e6e5906b | pbrook | } |
1570 | e6e5906b | pbrook | |
1571 | e6e5906b | pbrook | DISAS_INSN(rts) |
1572 | e6e5906b | pbrook | { |
1573 | e1f3808e | pbrook | TCGv tmp; |
1574 | e6e5906b | pbrook | |
1575 | 0633879f | pbrook | tmp = gen_load(s, OS_LONG, QREG_SP, 0);
|
1576 | e1f3808e | pbrook | tcg_gen_addi_i32(QREG_SP, QREG_SP, 4);
|
1577 | e6e5906b | pbrook | gen_jmp(s, tmp); |
1578 | e6e5906b | pbrook | } |
1579 | e6e5906b | pbrook | |
1580 | e6e5906b | pbrook | DISAS_INSN(jump) |
1581 | e6e5906b | pbrook | { |
1582 | e1f3808e | pbrook | TCGv tmp; |
1583 | e6e5906b | pbrook | |
1584 | e6e5906b | pbrook | /* Load the target address first to ensure correct exception
|
1585 | e6e5906b | pbrook | behavior. */
|
1586 | e6e5906b | pbrook | tmp = gen_lea(s, insn, OS_LONG); |
1587 | e1f3808e | pbrook | if (IS_NULL_QREG(tmp)) {
|
1588 | 510ff0b7 | pbrook | gen_addr_fault(s); |
1589 | 510ff0b7 | pbrook | return;
|
1590 | 510ff0b7 | pbrook | } |
1591 | e6e5906b | pbrook | if ((insn & 0x40) == 0) { |
1592 | e6e5906b | pbrook | /* jsr */
|
1593 | 0633879f | pbrook | gen_push(s, gen_im32(s->pc)); |
1594 | e6e5906b | pbrook | } |
1595 | e6e5906b | pbrook | gen_jmp(s, tmp); |
1596 | e6e5906b | pbrook | } |
1597 | e6e5906b | pbrook | |
1598 | e6e5906b | pbrook | DISAS_INSN(addsubq) |
1599 | e6e5906b | pbrook | { |
1600 | e1f3808e | pbrook | TCGv src1; |
1601 | e1f3808e | pbrook | TCGv src2; |
1602 | e1f3808e | pbrook | TCGv dest; |
1603 | e6e5906b | pbrook | int val;
|
1604 | e1f3808e | pbrook | TCGv addr; |
1605 | e6e5906b | pbrook | |
1606 | 510ff0b7 | pbrook | SRC_EA(src1, OS_LONG, 0, &addr);
|
1607 | e6e5906b | pbrook | val = (insn >> 9) & 7; |
1608 | e6e5906b | pbrook | if (val == 0) |
1609 | e6e5906b | pbrook | val = 8;
|
1610 | a7812ae4 | pbrook | dest = tcg_temp_new(); |
1611 | e1f3808e | pbrook | tcg_gen_mov_i32(dest, src1); |
1612 | e6e5906b | pbrook | if ((insn & 0x38) == 0x08) { |
1613 | e6e5906b | pbrook | /* Don't update condition codes if the destination is an
|
1614 | e6e5906b | pbrook | address register. */
|
1615 | e6e5906b | pbrook | if (insn & 0x0100) { |
1616 | e1f3808e | pbrook | tcg_gen_subi_i32(dest, dest, val); |
1617 | e6e5906b | pbrook | } else {
|
1618 | e1f3808e | pbrook | tcg_gen_addi_i32(dest, dest, val); |
1619 | e6e5906b | pbrook | } |
1620 | e6e5906b | pbrook | } else {
|
1621 | e1f3808e | pbrook | src2 = gen_im32(val); |
1622 | e6e5906b | pbrook | if (insn & 0x0100) { |
1623 | e1f3808e | pbrook | gen_helper_xflag_lt(QREG_CC_X, dest, src2); |
1624 | e1f3808e | pbrook | tcg_gen_subi_i32(dest, dest, val); |
1625 | e6e5906b | pbrook | s->cc_op = CC_OP_SUB; |
1626 | e6e5906b | pbrook | } else {
|
1627 | e1f3808e | pbrook | tcg_gen_addi_i32(dest, dest, val); |
1628 | e1f3808e | pbrook | gen_helper_xflag_lt(QREG_CC_X, dest, src2); |
1629 | e6e5906b | pbrook | s->cc_op = CC_OP_ADD; |
1630 | e6e5906b | pbrook | } |
1631 | e1f3808e | pbrook | gen_update_cc_add(dest, src2); |
1632 | e6e5906b | pbrook | } |
1633 | 510ff0b7 | pbrook | DEST_EA(insn, OS_LONG, dest, &addr); |
1634 | e6e5906b | pbrook | } |
1635 | e6e5906b | pbrook | |
1636 | e6e5906b | pbrook | DISAS_INSN(tpf) |
1637 | e6e5906b | pbrook | { |
1638 | e6e5906b | pbrook | switch (insn & 7) { |
1639 | e6e5906b | pbrook | case 2: /* One extension word. */ |
1640 | e6e5906b | pbrook | s->pc += 2;
|
1641 | e6e5906b | pbrook | break;
|
1642 | e6e5906b | pbrook | case 3: /* Two extension words. */ |
1643 | e6e5906b | pbrook | s->pc += 4;
|
1644 | e6e5906b | pbrook | break;
|
1645 | e6e5906b | pbrook | case 4: /* No extension words. */ |
1646 | e6e5906b | pbrook | break;
|
1647 | e6e5906b | pbrook | default:
|
1648 | e6e5906b | pbrook | disas_undef(s, insn); |
1649 | e6e5906b | pbrook | } |
1650 | e6e5906b | pbrook | } |
1651 | e6e5906b | pbrook | |
1652 | e6e5906b | pbrook | DISAS_INSN(branch) |
1653 | e6e5906b | pbrook | { |
1654 | e6e5906b | pbrook | int32_t offset; |
1655 | e6e5906b | pbrook | uint32_t base; |
1656 | e6e5906b | pbrook | int op;
|
1657 | e6e5906b | pbrook | int l1;
|
1658 | 3b46e624 | ths | |
1659 | e6e5906b | pbrook | base = s->pc; |
1660 | e6e5906b | pbrook | op = (insn >> 8) & 0xf; |
1661 | e6e5906b | pbrook | offset = (int8_t)insn; |
1662 | e6e5906b | pbrook | if (offset == 0) { |
1663 | 0633879f | pbrook | offset = ldsw_code(s->pc); |
1664 | e6e5906b | pbrook | s->pc += 2;
|
1665 | e6e5906b | pbrook | } else if (offset == -1) { |
1666 | e6e5906b | pbrook | offset = read_im32(s); |
1667 | e6e5906b | pbrook | } |
1668 | e6e5906b | pbrook | if (op == 1) { |
1669 | e6e5906b | pbrook | /* bsr */
|
1670 | 0633879f | pbrook | gen_push(s, gen_im32(s->pc)); |
1671 | e6e5906b | pbrook | } |
1672 | e6e5906b | pbrook | gen_flush_cc_op(s); |
1673 | e6e5906b | pbrook | if (op > 1) { |
1674 | e6e5906b | pbrook | /* Bcc */
|
1675 | e6e5906b | pbrook | l1 = gen_new_label(); |
1676 | e6e5906b | pbrook | gen_jmpcc(s, ((insn >> 8) & 0xf) ^ 1, l1); |
1677 | e6e5906b | pbrook | gen_jmp_tb(s, 1, base + offset);
|
1678 | e6e5906b | pbrook | gen_set_label(l1); |
1679 | e6e5906b | pbrook | gen_jmp_tb(s, 0, s->pc);
|
1680 | e6e5906b | pbrook | } else {
|
1681 | e6e5906b | pbrook | /* Unconditional branch. */
|
1682 | e6e5906b | pbrook | gen_jmp_tb(s, 0, base + offset);
|
1683 | e6e5906b | pbrook | } |
1684 | e6e5906b | pbrook | } |
1685 | e6e5906b | pbrook | |
1686 | e6e5906b | pbrook | DISAS_INSN(moveq) |
1687 | e6e5906b | pbrook | { |
1688 | e1f3808e | pbrook | uint32_t val; |
1689 | e6e5906b | pbrook | |
1690 | e1f3808e | pbrook | val = (int8_t)insn; |
1691 | e1f3808e | pbrook | tcg_gen_movi_i32(DREG(insn, 9), val);
|
1692 | e1f3808e | pbrook | gen_logic_cc(s, tcg_const_i32(val)); |
1693 | e6e5906b | pbrook | } |
1694 | e6e5906b | pbrook | |
1695 | e6e5906b | pbrook | DISAS_INSN(mvzs) |
1696 | e6e5906b | pbrook | { |
1697 | e6e5906b | pbrook | int opsize;
|
1698 | e1f3808e | pbrook | TCGv src; |
1699 | e1f3808e | pbrook | TCGv reg; |
1700 | e6e5906b | pbrook | |
1701 | e6e5906b | pbrook | if (insn & 0x40) |
1702 | e6e5906b | pbrook | opsize = OS_WORD; |
1703 | e6e5906b | pbrook | else
|
1704 | e6e5906b | pbrook | opsize = OS_BYTE; |
1705 | 9507fb52 | pbrook | SRC_EA(src, opsize, (insn & 0x80) == 0, NULL); |
1706 | e6e5906b | pbrook | reg = DREG(insn, 9);
|
1707 | e1f3808e | pbrook | tcg_gen_mov_i32(reg, src); |
1708 | e6e5906b | pbrook | gen_logic_cc(s, src); |
1709 | e6e5906b | pbrook | } |
1710 | e6e5906b | pbrook | |
1711 | e6e5906b | pbrook | DISAS_INSN(or) |
1712 | e6e5906b | pbrook | { |
1713 | e1f3808e | pbrook | TCGv reg; |
1714 | e1f3808e | pbrook | TCGv dest; |
1715 | e1f3808e | pbrook | TCGv src; |
1716 | e1f3808e | pbrook | TCGv addr; |
1717 | e6e5906b | pbrook | |
1718 | e6e5906b | pbrook | reg = DREG(insn, 9);
|
1719 | a7812ae4 | pbrook | dest = tcg_temp_new(); |
1720 | e6e5906b | pbrook | if (insn & 0x100) { |
1721 | 510ff0b7 | pbrook | SRC_EA(src, OS_LONG, 0, &addr);
|
1722 | e1f3808e | pbrook | tcg_gen_or_i32(dest, src, reg); |
1723 | 510ff0b7 | pbrook | DEST_EA(insn, OS_LONG, dest, &addr); |
1724 | e6e5906b | pbrook | } else {
|
1725 | 510ff0b7 | pbrook | SRC_EA(src, OS_LONG, 0, NULL); |
1726 | e1f3808e | pbrook | tcg_gen_or_i32(dest, src, reg); |
1727 | e1f3808e | pbrook | tcg_gen_mov_i32(reg, dest); |
1728 | e6e5906b | pbrook | } |
1729 | e6e5906b | pbrook | gen_logic_cc(s, dest); |
1730 | e6e5906b | pbrook | } |
1731 | e6e5906b | pbrook | |
1732 | e6e5906b | pbrook | DISAS_INSN(suba) |
1733 | e6e5906b | pbrook | { |
1734 | e1f3808e | pbrook | TCGv src; |
1735 | e1f3808e | pbrook | TCGv reg; |
1736 | e6e5906b | pbrook | |
1737 | 510ff0b7 | pbrook | SRC_EA(src, OS_LONG, 0, NULL); |
1738 | e6e5906b | pbrook | reg = AREG(insn, 9);
|
1739 | e1f3808e | pbrook | tcg_gen_sub_i32(reg, reg, src); |
1740 | e6e5906b | pbrook | } |
1741 | e6e5906b | pbrook | |
1742 | e6e5906b | pbrook | DISAS_INSN(subx) |
1743 | e6e5906b | pbrook | { |
1744 | e1f3808e | pbrook | TCGv reg; |
1745 | e1f3808e | pbrook | TCGv src; |
1746 | e6e5906b | pbrook | |
1747 | e6e5906b | pbrook | gen_flush_flags(s); |
1748 | e6e5906b | pbrook | reg = DREG(insn, 9);
|
1749 | e6e5906b | pbrook | src = DREG(insn, 0);
|
1750 | e1f3808e | pbrook | gen_helper_subx_cc(reg, cpu_env, reg, src); |
1751 | e6e5906b | pbrook | } |
1752 | e6e5906b | pbrook | |
1753 | e6e5906b | pbrook | DISAS_INSN(mov3q) |
1754 | e6e5906b | pbrook | { |
1755 | e1f3808e | pbrook | TCGv src; |
1756 | e6e5906b | pbrook | int val;
|
1757 | e6e5906b | pbrook | |
1758 | e6e5906b | pbrook | val = (insn >> 9) & 7; |
1759 | e6e5906b | pbrook | if (val == 0) |
1760 | e6e5906b | pbrook | val = -1;
|
1761 | e6e5906b | pbrook | src = gen_im32(val); |
1762 | e6e5906b | pbrook | gen_logic_cc(s, src); |
1763 | 510ff0b7 | pbrook | DEST_EA(insn, OS_LONG, src, NULL);
|
1764 | e6e5906b | pbrook | } |
1765 | e6e5906b | pbrook | |
1766 | e6e5906b | pbrook | DISAS_INSN(cmp) |
1767 | e6e5906b | pbrook | { |
1768 | e6e5906b | pbrook | int op;
|
1769 | e1f3808e | pbrook | TCGv src; |
1770 | e1f3808e | pbrook | TCGv reg; |
1771 | e1f3808e | pbrook | TCGv dest; |
1772 | e6e5906b | pbrook | int opsize;
|
1773 | e6e5906b | pbrook | |
1774 | e6e5906b | pbrook | op = (insn >> 6) & 3; |
1775 | e6e5906b | pbrook | switch (op) {
|
1776 | e6e5906b | pbrook | case 0: /* cmp.b */ |
1777 | e6e5906b | pbrook | opsize = OS_BYTE; |
1778 | e6e5906b | pbrook | s->cc_op = CC_OP_CMPB; |
1779 | e6e5906b | pbrook | break;
|
1780 | e6e5906b | pbrook | case 1: /* cmp.w */ |
1781 | e6e5906b | pbrook | opsize = OS_WORD; |
1782 | e6e5906b | pbrook | s->cc_op = CC_OP_CMPW; |
1783 | e6e5906b | pbrook | break;
|
1784 | e6e5906b | pbrook | case 2: /* cmp.l */ |
1785 | e6e5906b | pbrook | opsize = OS_LONG; |
1786 | e6e5906b | pbrook | s->cc_op = CC_OP_SUB; |
1787 | e6e5906b | pbrook | break;
|
1788 | e6e5906b | pbrook | default:
|
1789 | e6e5906b | pbrook | abort(); |
1790 | e6e5906b | pbrook | } |
1791 | e1f3808e | pbrook | SRC_EA(src, opsize, 1, NULL); |
1792 | e6e5906b | pbrook | reg = DREG(insn, 9);
|
1793 | a7812ae4 | pbrook | dest = tcg_temp_new(); |
1794 | e1f3808e | pbrook | tcg_gen_sub_i32(dest, reg, src); |
1795 | e1f3808e | pbrook | gen_update_cc_add(dest, src); |
1796 | e6e5906b | pbrook | } |
1797 | e6e5906b | pbrook | |
1798 | e6e5906b | pbrook | DISAS_INSN(cmpa) |
1799 | e6e5906b | pbrook | { |
1800 | e6e5906b | pbrook | int opsize;
|
1801 | e1f3808e | pbrook | TCGv src; |
1802 | e1f3808e | pbrook | TCGv reg; |
1803 | e1f3808e | pbrook | TCGv dest; |
1804 | e6e5906b | pbrook | |
1805 | e6e5906b | pbrook | if (insn & 0x100) { |
1806 | e6e5906b | pbrook | opsize = OS_LONG; |
1807 | e6e5906b | pbrook | } else {
|
1808 | e6e5906b | pbrook | opsize = OS_WORD; |
1809 | e6e5906b | pbrook | } |
1810 | e1f3808e | pbrook | SRC_EA(src, opsize, 1, NULL); |
1811 | e6e5906b | pbrook | reg = AREG(insn, 9);
|
1812 | a7812ae4 | pbrook | dest = tcg_temp_new(); |
1813 | e1f3808e | pbrook | tcg_gen_sub_i32(dest, reg, src); |
1814 | e1f3808e | pbrook | gen_update_cc_add(dest, src); |
1815 | e6e5906b | pbrook | s->cc_op = CC_OP_SUB; |
1816 | e6e5906b | pbrook | } |
1817 | e6e5906b | pbrook | |
1818 | e6e5906b | pbrook | DISAS_INSN(eor) |
1819 | e6e5906b | pbrook | { |
1820 | e1f3808e | pbrook | TCGv src; |
1821 | e1f3808e | pbrook | TCGv reg; |
1822 | e1f3808e | pbrook | TCGv dest; |
1823 | e1f3808e | pbrook | TCGv addr; |
1824 | e6e5906b | pbrook | |
1825 | 510ff0b7 | pbrook | SRC_EA(src, OS_LONG, 0, &addr);
|
1826 | e6e5906b | pbrook | reg = DREG(insn, 9);
|
1827 | a7812ae4 | pbrook | dest = tcg_temp_new(); |
1828 | e1f3808e | pbrook | tcg_gen_xor_i32(dest, src, reg); |
1829 | e6e5906b | pbrook | gen_logic_cc(s, dest); |
1830 | 510ff0b7 | pbrook | DEST_EA(insn, OS_LONG, dest, &addr); |
1831 | e6e5906b | pbrook | } |
1832 | e6e5906b | pbrook | |
1833 | e6e5906b | pbrook | DISAS_INSN(and) |
1834 | e6e5906b | pbrook | { |
1835 | e1f3808e | pbrook | TCGv src; |
1836 | e1f3808e | pbrook | TCGv reg; |
1837 | e1f3808e | pbrook | TCGv dest; |
1838 | e1f3808e | pbrook | TCGv addr; |
1839 | e6e5906b | pbrook | |
1840 | e6e5906b | pbrook | reg = DREG(insn, 9);
|
1841 | a7812ae4 | pbrook | dest = tcg_temp_new(); |
1842 | e6e5906b | pbrook | if (insn & 0x100) { |
1843 | 510ff0b7 | pbrook | SRC_EA(src, OS_LONG, 0, &addr);
|
1844 | e1f3808e | pbrook | tcg_gen_and_i32(dest, src, reg); |
1845 | 510ff0b7 | pbrook | DEST_EA(insn, OS_LONG, dest, &addr); |
1846 | e6e5906b | pbrook | } else {
|
1847 | 510ff0b7 | pbrook | SRC_EA(src, OS_LONG, 0, NULL); |
1848 | e1f3808e | pbrook | tcg_gen_and_i32(dest, src, reg); |
1849 | e1f3808e | pbrook | tcg_gen_mov_i32(reg, dest); |
1850 | e6e5906b | pbrook | } |
1851 | e6e5906b | pbrook | gen_logic_cc(s, dest); |
1852 | e6e5906b | pbrook | } |
1853 | e6e5906b | pbrook | |
1854 | e6e5906b | pbrook | DISAS_INSN(adda) |
1855 | e6e5906b | pbrook | { |
1856 | e1f3808e | pbrook | TCGv src; |
1857 | e1f3808e | pbrook | TCGv reg; |
1858 | e6e5906b | pbrook | |
1859 | 510ff0b7 | pbrook | SRC_EA(src, OS_LONG, 0, NULL); |
1860 | e6e5906b | pbrook | reg = AREG(insn, 9);
|
1861 | e1f3808e | pbrook | tcg_gen_add_i32(reg, reg, src); |
1862 | e6e5906b | pbrook | } |
1863 | e6e5906b | pbrook | |
1864 | e6e5906b | pbrook | DISAS_INSN(addx) |
1865 | e6e5906b | pbrook | { |
1866 | e1f3808e | pbrook | TCGv reg; |
1867 | e1f3808e | pbrook | TCGv src; |
1868 | e6e5906b | pbrook | |
1869 | e6e5906b | pbrook | gen_flush_flags(s); |
1870 | e6e5906b | pbrook | reg = DREG(insn, 9);
|
1871 | e6e5906b | pbrook | src = DREG(insn, 0);
|
1872 | e1f3808e | pbrook | gen_helper_addx_cc(reg, cpu_env, reg, src); |
1873 | e6e5906b | pbrook | s->cc_op = CC_OP_FLAGS; |
1874 | e6e5906b | pbrook | } |
1875 | e6e5906b | pbrook | |
1876 | e1f3808e | pbrook | /* TODO: This could be implemented without helper functions. */
|
1877 | e6e5906b | pbrook | DISAS_INSN(shift_im) |
1878 | e6e5906b | pbrook | { |
1879 | e1f3808e | pbrook | TCGv reg; |
1880 | e6e5906b | pbrook | int tmp;
|
1881 | e1f3808e | pbrook | TCGv shift; |
1882 | e6e5906b | pbrook | |
1883 | e6e5906b | pbrook | reg = DREG(insn, 0);
|
1884 | e6e5906b | pbrook | tmp = (insn >> 9) & 7; |
1885 | e6e5906b | pbrook | if (tmp == 0) |
1886 | e1f3808e | pbrook | tmp = 8;
|
1887 | e1f3808e | pbrook | shift = gen_im32(tmp); |
1888 | e1f3808e | pbrook | /* No need to flush flags becuse we know we will set C flag. */
|
1889 | e6e5906b | pbrook | if (insn & 0x100) { |
1890 | e1f3808e | pbrook | gen_helper_shl_cc(reg, cpu_env, reg, shift); |
1891 | e6e5906b | pbrook | } else {
|
1892 | e6e5906b | pbrook | if (insn & 8) { |
1893 | e1f3808e | pbrook | gen_helper_shr_cc(reg, cpu_env, reg, shift); |
1894 | e6e5906b | pbrook | } else {
|
1895 | e1f3808e | pbrook | gen_helper_sar_cc(reg, cpu_env, reg, shift); |
1896 | e6e5906b | pbrook | } |
1897 | e6e5906b | pbrook | } |
1898 | e1f3808e | pbrook | s->cc_op = CC_OP_SHIFT; |
1899 | e6e5906b | pbrook | } |
1900 | e6e5906b | pbrook | |
1901 | e6e5906b | pbrook | DISAS_INSN(shift_reg) |
1902 | e6e5906b | pbrook | { |
1903 | e1f3808e | pbrook | TCGv reg; |
1904 | e1f3808e | pbrook | TCGv shift; |
1905 | e6e5906b | pbrook | |
1906 | e6e5906b | pbrook | reg = DREG(insn, 0);
|
1907 | e1f3808e | pbrook | shift = DREG(insn, 9);
|
1908 | e1f3808e | pbrook | /* Shift by zero leaves C flag unmodified. */
|
1909 | e1f3808e | pbrook | gen_flush_flags(s); |
1910 | e6e5906b | pbrook | if (insn & 0x100) { |
1911 | e1f3808e | pbrook | gen_helper_shl_cc(reg, cpu_env, reg, shift); |
1912 | e6e5906b | pbrook | } else {
|
1913 | e6e5906b | pbrook | if (insn & 8) { |
1914 | e1f3808e | pbrook | gen_helper_shr_cc(reg, cpu_env, reg, shift); |
1915 | e6e5906b | pbrook | } else {
|
1916 | e1f3808e | pbrook | gen_helper_sar_cc(reg, cpu_env, reg, shift); |
1917 | e6e5906b | pbrook | } |
1918 | e6e5906b | pbrook | } |
1919 | e1f3808e | pbrook | s->cc_op = CC_OP_SHIFT; |
1920 | e6e5906b | pbrook | } |
1921 | e6e5906b | pbrook | |
1922 | e6e5906b | pbrook | DISAS_INSN(ff1) |
1923 | e6e5906b | pbrook | { |
1924 | e1f3808e | pbrook | TCGv reg; |
1925 | 821f7e76 | pbrook | reg = DREG(insn, 0);
|
1926 | 821f7e76 | pbrook | gen_logic_cc(s, reg); |
1927 | e1f3808e | pbrook | gen_helper_ff1(reg, reg); |
1928 | e6e5906b | pbrook | } |
1929 | e6e5906b | pbrook | |
1930 | e1f3808e | pbrook | static TCGv gen_get_sr(DisasContext *s)
|
1931 | 0633879f | pbrook | { |
1932 | e1f3808e | pbrook | TCGv ccr; |
1933 | e1f3808e | pbrook | TCGv sr; |
1934 | 0633879f | pbrook | |
1935 | 0633879f | pbrook | ccr = gen_get_ccr(s); |
1936 | a7812ae4 | pbrook | sr = tcg_temp_new(); |
1937 | e1f3808e | pbrook | tcg_gen_andi_i32(sr, QREG_SR, 0xffe0);
|
1938 | e1f3808e | pbrook | tcg_gen_or_i32(sr, sr, ccr); |
1939 | 0633879f | pbrook | return sr;
|
1940 | 0633879f | pbrook | } |
1941 | 0633879f | pbrook | |
1942 | e6e5906b | pbrook | DISAS_INSN(strldsr) |
1943 | e6e5906b | pbrook | { |
1944 | e6e5906b | pbrook | uint16_t ext; |
1945 | e6e5906b | pbrook | uint32_t addr; |
1946 | e6e5906b | pbrook | |
1947 | e6e5906b | pbrook | addr = s->pc - 2;
|
1948 | 0633879f | pbrook | ext = lduw_code(s->pc); |
1949 | e6e5906b | pbrook | s->pc += 2;
|
1950 | 0633879f | pbrook | if (ext != 0x46FC) { |
1951 | e6e5906b | pbrook | gen_exception(s, addr, EXCP_UNSUPPORTED); |
1952 | 0633879f | pbrook | return;
|
1953 | 0633879f | pbrook | } |
1954 | 0633879f | pbrook | ext = lduw_code(s->pc); |
1955 | 0633879f | pbrook | s->pc += 2;
|
1956 | 0633879f | pbrook | if (IS_USER(s) || (ext & SR_S) == 0) { |
1957 | e6e5906b | pbrook | gen_exception(s, addr, EXCP_PRIVILEGE); |
1958 | 0633879f | pbrook | return;
|
1959 | 0633879f | pbrook | } |
1960 | 0633879f | pbrook | gen_push(s, gen_get_sr(s)); |
1961 | 0633879f | pbrook | gen_set_sr_im(s, ext, 0);
|
1962 | e6e5906b | pbrook | } |
1963 | e6e5906b | pbrook | |
1964 | e6e5906b | pbrook | DISAS_INSN(move_from_sr) |
1965 | e6e5906b | pbrook | { |
1966 | e1f3808e | pbrook | TCGv reg; |
1967 | e1f3808e | pbrook | TCGv sr; |
1968 | 0633879f | pbrook | |
1969 | 0633879f | pbrook | if (IS_USER(s)) {
|
1970 | 0633879f | pbrook | gen_exception(s, s->pc - 2, EXCP_PRIVILEGE);
|
1971 | 0633879f | pbrook | return;
|
1972 | 0633879f | pbrook | } |
1973 | 0633879f | pbrook | sr = gen_get_sr(s); |
1974 | 0633879f | pbrook | reg = DREG(insn, 0);
|
1975 | 0633879f | pbrook | gen_partset_reg(OS_WORD, reg, sr); |
1976 | e6e5906b | pbrook | } |
1977 | e6e5906b | pbrook | |
1978 | e6e5906b | pbrook | DISAS_INSN(move_to_sr) |
1979 | e6e5906b | pbrook | { |
1980 | 0633879f | pbrook | if (IS_USER(s)) {
|
1981 | 0633879f | pbrook | gen_exception(s, s->pc - 2, EXCP_PRIVILEGE);
|
1982 | 0633879f | pbrook | return;
|
1983 | 0633879f | pbrook | } |
1984 | 0633879f | pbrook | gen_set_sr(s, insn, 0);
|
1985 | 0633879f | pbrook | gen_lookup_tb(s); |
1986 | e6e5906b | pbrook | } |
1987 | e6e5906b | pbrook | |
1988 | e6e5906b | pbrook | DISAS_INSN(move_from_usp) |
1989 | e6e5906b | pbrook | { |
1990 | 0633879f | pbrook | if (IS_USER(s)) {
|
1991 | 0633879f | pbrook | gen_exception(s, s->pc - 2, EXCP_PRIVILEGE);
|
1992 | 0633879f | pbrook | return;
|
1993 | 0633879f | pbrook | } |
1994 | 0633879f | pbrook | /* TODO: Implement USP. */
|
1995 | 0633879f | pbrook | gen_exception(s, s->pc - 2, EXCP_ILLEGAL);
|
1996 | e6e5906b | pbrook | } |
1997 | e6e5906b | pbrook | |
1998 | e6e5906b | pbrook | DISAS_INSN(move_to_usp) |
1999 | e6e5906b | pbrook | { |
2000 | 0633879f | pbrook | if (IS_USER(s)) {
|
2001 | 0633879f | pbrook | gen_exception(s, s->pc - 2, EXCP_PRIVILEGE);
|
2002 | 0633879f | pbrook | return;
|
2003 | 0633879f | pbrook | } |
2004 | 0633879f | pbrook | /* TODO: Implement USP. */
|
2005 | 0633879f | pbrook | gen_exception(s, s->pc - 2, EXCP_ILLEGAL);
|
2006 | e6e5906b | pbrook | } |
2007 | e6e5906b | pbrook | |
2008 | e6e5906b | pbrook | DISAS_INSN(halt) |
2009 | e6e5906b | pbrook | { |
2010 | e1f3808e | pbrook | gen_exception(s, s->pc, EXCP_HALT_INSN); |
2011 | e6e5906b | pbrook | } |
2012 | e6e5906b | pbrook | |
2013 | e6e5906b | pbrook | DISAS_INSN(stop) |
2014 | e6e5906b | pbrook | { |
2015 | 0633879f | pbrook | uint16_t ext; |
2016 | 0633879f | pbrook | |
2017 | 0633879f | pbrook | if (IS_USER(s)) {
|
2018 | 0633879f | pbrook | gen_exception(s, s->pc - 2, EXCP_PRIVILEGE);
|
2019 | 0633879f | pbrook | return;
|
2020 | 0633879f | pbrook | } |
2021 | 0633879f | pbrook | |
2022 | 0633879f | pbrook | ext = lduw_code(s->pc); |
2023 | 0633879f | pbrook | s->pc += 2;
|
2024 | 0633879f | pbrook | |
2025 | 0633879f | pbrook | gen_set_sr_im(s, ext, 0);
|
2026 | e1f3808e | pbrook | tcg_gen_movi_i32(QREG_HALTED, 1);
|
2027 | e1f3808e | pbrook | gen_exception(s, s->pc, EXCP_HLT); |
2028 | e6e5906b | pbrook | } |
2029 | e6e5906b | pbrook | |
2030 | e6e5906b | pbrook | DISAS_INSN(rte) |
2031 | e6e5906b | pbrook | { |
2032 | 0633879f | pbrook | if (IS_USER(s)) {
|
2033 | 0633879f | pbrook | gen_exception(s, s->pc - 2, EXCP_PRIVILEGE);
|
2034 | 0633879f | pbrook | return;
|
2035 | 0633879f | pbrook | } |
2036 | 0633879f | pbrook | gen_exception(s, s->pc - 2, EXCP_RTE);
|
2037 | e6e5906b | pbrook | } |
2038 | e6e5906b | pbrook | |
2039 | e6e5906b | pbrook | DISAS_INSN(movec) |
2040 | e6e5906b | pbrook | { |
2041 | 0633879f | pbrook | uint16_t ext; |
2042 | e1f3808e | pbrook | TCGv reg; |
2043 | 0633879f | pbrook | |
2044 | 0633879f | pbrook | if (IS_USER(s)) {
|
2045 | 0633879f | pbrook | gen_exception(s, s->pc - 2, EXCP_PRIVILEGE);
|
2046 | 0633879f | pbrook | return;
|
2047 | 0633879f | pbrook | } |
2048 | 0633879f | pbrook | |
2049 | 0633879f | pbrook | ext = lduw_code(s->pc); |
2050 | 0633879f | pbrook | s->pc += 2;
|
2051 | 0633879f | pbrook | |
2052 | 0633879f | pbrook | if (ext & 0x8000) { |
2053 | 0633879f | pbrook | reg = AREG(ext, 12);
|
2054 | 0633879f | pbrook | } else {
|
2055 | 0633879f | pbrook | reg = DREG(ext, 12);
|
2056 | 0633879f | pbrook | } |
2057 | e1f3808e | pbrook | gen_helper_movec(cpu_env, tcg_const_i32(ext & 0xfff), reg);
|
2058 | 0633879f | pbrook | gen_lookup_tb(s); |
2059 | e6e5906b | pbrook | } |
2060 | e6e5906b | pbrook | |
2061 | e6e5906b | pbrook | DISAS_INSN(intouch) |
2062 | e6e5906b | pbrook | { |
2063 | 0633879f | pbrook | if (IS_USER(s)) {
|
2064 | 0633879f | pbrook | gen_exception(s, s->pc - 2, EXCP_PRIVILEGE);
|
2065 | 0633879f | pbrook | return;
|
2066 | 0633879f | pbrook | } |
2067 | 0633879f | pbrook | /* ICache fetch. Implement as no-op. */
|
2068 | e6e5906b | pbrook | } |
2069 | e6e5906b | pbrook | |
2070 | e6e5906b | pbrook | DISAS_INSN(cpushl) |
2071 | e6e5906b | pbrook | { |
2072 | 0633879f | pbrook | if (IS_USER(s)) {
|
2073 | 0633879f | pbrook | gen_exception(s, s->pc - 2, EXCP_PRIVILEGE);
|
2074 | 0633879f | pbrook | return;
|
2075 | 0633879f | pbrook | } |
2076 | 0633879f | pbrook | /* Cache push/invalidate. Implement as no-op. */
|
2077 | e6e5906b | pbrook | } |
2078 | e6e5906b | pbrook | |
2079 | e6e5906b | pbrook | DISAS_INSN(wddata) |
2080 | e6e5906b | pbrook | { |
2081 | e6e5906b | pbrook | gen_exception(s, s->pc - 2, EXCP_PRIVILEGE);
|
2082 | e6e5906b | pbrook | } |
2083 | e6e5906b | pbrook | |
2084 | e6e5906b | pbrook | DISAS_INSN(wdebug) |
2085 | e6e5906b | pbrook | { |
2086 | 0633879f | pbrook | if (IS_USER(s)) {
|
2087 | 0633879f | pbrook | gen_exception(s, s->pc - 2, EXCP_PRIVILEGE);
|
2088 | 0633879f | pbrook | return;
|
2089 | 0633879f | pbrook | } |
2090 | 0633879f | pbrook | /* TODO: Implement wdebug. */
|
2091 | 0633879f | pbrook | qemu_assert(0, "WDEBUG not implemented"); |
2092 | e6e5906b | pbrook | } |
2093 | e6e5906b | pbrook | |
2094 | e6e5906b | pbrook | DISAS_INSN(trap) |
2095 | e6e5906b | pbrook | { |
2096 | e6e5906b | pbrook | gen_exception(s, s->pc - 2, EXCP_TRAP0 + (insn & 0xf)); |
2097 | e6e5906b | pbrook | } |
2098 | e6e5906b | pbrook | |
2099 | e6e5906b | pbrook | /* ??? FP exceptions are not implemented. Most exceptions are deferred until
|
2100 | e6e5906b | pbrook | immediately before the next FP instruction is executed. */
|
2101 | e6e5906b | pbrook | DISAS_INSN(fpu) |
2102 | e6e5906b | pbrook | { |
2103 | e6e5906b | pbrook | uint16_t ext; |
2104 | a7812ae4 | pbrook | int32_t offset; |
2105 | e6e5906b | pbrook | int opmode;
|
2106 | a7812ae4 | pbrook | TCGv_i64 src; |
2107 | a7812ae4 | pbrook | TCGv_i64 dest; |
2108 | a7812ae4 | pbrook | TCGv_i64 res; |
2109 | a7812ae4 | pbrook | TCGv tmp32; |
2110 | e6e5906b | pbrook | int round;
|
2111 | a7812ae4 | pbrook | int set_dest;
|
2112 | e6e5906b | pbrook | int opsize;
|
2113 | e6e5906b | pbrook | |
2114 | 0633879f | pbrook | ext = lduw_code(s->pc); |
2115 | e6e5906b | pbrook | s->pc += 2;
|
2116 | e6e5906b | pbrook | opmode = ext & 0x7f;
|
2117 | e6e5906b | pbrook | switch ((ext >> 13) & 7) { |
2118 | e6e5906b | pbrook | case 0: case 2: |
2119 | e6e5906b | pbrook | break;
|
2120 | e6e5906b | pbrook | case 1: |
2121 | e6e5906b | pbrook | goto undef;
|
2122 | e6e5906b | pbrook | case 3: /* fmove out */ |
2123 | e6e5906b | pbrook | src = FREG(ext, 7);
|
2124 | a7812ae4 | pbrook | tmp32 = tcg_temp_new_i32(); |
2125 | e6e5906b | pbrook | /* fmove */
|
2126 | e6e5906b | pbrook | /* ??? TODO: Proper behavior on overflow. */
|
2127 | e6e5906b | pbrook | switch ((ext >> 10) & 7) { |
2128 | e6e5906b | pbrook | case 0: |
2129 | e6e5906b | pbrook | opsize = OS_LONG; |
2130 | a7812ae4 | pbrook | gen_helper_f64_to_i32(tmp32, cpu_env, src); |
2131 | e6e5906b | pbrook | break;
|
2132 | e6e5906b | pbrook | case 1: |
2133 | e6e5906b | pbrook | opsize = OS_SINGLE; |
2134 | a7812ae4 | pbrook | gen_helper_f64_to_f32(tmp32, cpu_env, src); |
2135 | e6e5906b | pbrook | break;
|
2136 | e6e5906b | pbrook | case 4: |
2137 | e6e5906b | pbrook | opsize = OS_WORD; |
2138 | a7812ae4 | pbrook | gen_helper_f64_to_i32(tmp32, cpu_env, src); |
2139 | e6e5906b | pbrook | break;
|
2140 | a7812ae4 | pbrook | case 5: /* OS_DOUBLE */ |
2141 | a7812ae4 | pbrook | tcg_gen_mov_i32(tmp32, AREG(insn, 0));
|
2142 | c59b97aa | pbrook | switch ((insn >> 3) & 7) { |
2143 | a7812ae4 | pbrook | case 2: |
2144 | a7812ae4 | pbrook | case 3: |
2145 | 243ee8f7 | pbrook | break;
|
2146 | a7812ae4 | pbrook | case 4: |
2147 | a7812ae4 | pbrook | tcg_gen_addi_i32(tmp32, tmp32, -8);
|
2148 | a7812ae4 | pbrook | break;
|
2149 | a7812ae4 | pbrook | case 5: |
2150 | a7812ae4 | pbrook | offset = ldsw_code(s->pc); |
2151 | a7812ae4 | pbrook | s->pc += 2;
|
2152 | a7812ae4 | pbrook | tcg_gen_addi_i32(tmp32, tmp32, offset); |
2153 | a7812ae4 | pbrook | break;
|
2154 | a7812ae4 | pbrook | default:
|
2155 | a7812ae4 | pbrook | goto undef;
|
2156 | a7812ae4 | pbrook | } |
2157 | a7812ae4 | pbrook | gen_store64(s, tmp32, src); |
2158 | c59b97aa | pbrook | switch ((insn >> 3) & 7) { |
2159 | a7812ae4 | pbrook | case 3: |
2160 | a7812ae4 | pbrook | tcg_gen_addi_i32(tmp32, tmp32, 8);
|
2161 | a7812ae4 | pbrook | tcg_gen_mov_i32(AREG(insn, 0), tmp32);
|
2162 | a7812ae4 | pbrook | break;
|
2163 | a7812ae4 | pbrook | case 4: |
2164 | a7812ae4 | pbrook | tcg_gen_mov_i32(AREG(insn, 0), tmp32);
|
2165 | a7812ae4 | pbrook | break;
|
2166 | a7812ae4 | pbrook | } |
2167 | a7812ae4 | pbrook | tcg_temp_free_i32(tmp32); |
2168 | a7812ae4 | pbrook | return;
|
2169 | e6e5906b | pbrook | case 6: |
2170 | e6e5906b | pbrook | opsize = OS_BYTE; |
2171 | a7812ae4 | pbrook | gen_helper_f64_to_i32(tmp32, cpu_env, src); |
2172 | e6e5906b | pbrook | break;
|
2173 | e6e5906b | pbrook | default:
|
2174 | e6e5906b | pbrook | goto undef;
|
2175 | e6e5906b | pbrook | } |
2176 | a7812ae4 | pbrook | DEST_EA(insn, opsize, tmp32, NULL);
|
2177 | a7812ae4 | pbrook | tcg_temp_free_i32(tmp32); |
2178 | e6e5906b | pbrook | return;
|
2179 | e6e5906b | pbrook | case 4: /* fmove to control register. */ |
2180 | e6e5906b | pbrook | switch ((ext >> 10) & 7) { |
2181 | e6e5906b | pbrook | case 4: /* FPCR */ |
2182 | e6e5906b | pbrook | /* Not implemented. Ignore writes. */
|
2183 | e6e5906b | pbrook | break;
|
2184 | e6e5906b | pbrook | case 1: /* FPIAR */ |
2185 | e6e5906b | pbrook | case 2: /* FPSR */ |
2186 | e6e5906b | pbrook | default:
|
2187 | e6e5906b | pbrook | cpu_abort(NULL, "Unimplemented: fmove to control %d", |
2188 | e6e5906b | pbrook | (ext >> 10) & 7); |
2189 | e6e5906b | pbrook | } |
2190 | e6e5906b | pbrook | break;
|
2191 | e6e5906b | pbrook | case 5: /* fmove from control register. */ |
2192 | e6e5906b | pbrook | switch ((ext >> 10) & 7) { |
2193 | e6e5906b | pbrook | case 4: /* FPCR */ |
2194 | e6e5906b | pbrook | /* Not implemented. Always return zero. */
|
2195 | a7812ae4 | pbrook | tmp32 = gen_im32(0);
|
2196 | e6e5906b | pbrook | break;
|
2197 | e6e5906b | pbrook | case 1: /* FPIAR */ |
2198 | e6e5906b | pbrook | case 2: /* FPSR */ |
2199 | e6e5906b | pbrook | default:
|
2200 | e6e5906b | pbrook | cpu_abort(NULL, "Unimplemented: fmove from control %d", |
2201 | e6e5906b | pbrook | (ext >> 10) & 7); |
2202 | e6e5906b | pbrook | goto undef;
|
2203 | e6e5906b | pbrook | } |
2204 | a7812ae4 | pbrook | DEST_EA(insn, OS_LONG, tmp32, NULL);
|
2205 | e6e5906b | pbrook | break;
|
2206 | 5fafdf24 | ths | case 6: /* fmovem */ |
2207 | e6e5906b | pbrook | case 7: |
2208 | e6e5906b | pbrook | { |
2209 | e1f3808e | pbrook | TCGv addr; |
2210 | e1f3808e | pbrook | uint16_t mask; |
2211 | e1f3808e | pbrook | int i;
|
2212 | e1f3808e | pbrook | if ((ext & 0x1f00) != 0x1000 || (ext & 0xff) == 0) |
2213 | e1f3808e | pbrook | goto undef;
|
2214 | a7812ae4 | pbrook | tmp32 = gen_lea(s, insn, OS_LONG); |
2215 | a7812ae4 | pbrook | if (IS_NULL_QREG(tmp32)) {
|
2216 | e1f3808e | pbrook | gen_addr_fault(s); |
2217 | e1f3808e | pbrook | return;
|
2218 | e1f3808e | pbrook | } |
2219 | a7812ae4 | pbrook | addr = tcg_temp_new_i32(); |
2220 | a7812ae4 | pbrook | tcg_gen_mov_i32(addr, tmp32); |
2221 | e1f3808e | pbrook | mask = 0x80;
|
2222 | e1f3808e | pbrook | for (i = 0; i < 8; i++) { |
2223 | e1f3808e | pbrook | if (ext & mask) {
|
2224 | e1f3808e | pbrook | s->is_mem = 1;
|
2225 | e1f3808e | pbrook | dest = FREG(i, 0);
|
2226 | e1f3808e | pbrook | if (ext & (1 << 13)) { |
2227 | e1f3808e | pbrook | /* store */
|
2228 | e1f3808e | pbrook | tcg_gen_qemu_stf64(dest, addr, IS_USER(s)); |
2229 | e1f3808e | pbrook | } else {
|
2230 | e1f3808e | pbrook | /* load */
|
2231 | e1f3808e | pbrook | tcg_gen_qemu_ldf64(dest, addr, IS_USER(s)); |
2232 | e1f3808e | pbrook | } |
2233 | e1f3808e | pbrook | if (ext & (mask - 1)) |
2234 | e1f3808e | pbrook | tcg_gen_addi_i32(addr, addr, 8);
|
2235 | e6e5906b | pbrook | } |
2236 | e1f3808e | pbrook | mask >>= 1;
|
2237 | e6e5906b | pbrook | } |
2238 | 18307f26 | pbrook | tcg_temp_free_i32(addr); |
2239 | e6e5906b | pbrook | } |
2240 | e6e5906b | pbrook | return;
|
2241 | e6e5906b | pbrook | } |
2242 | e6e5906b | pbrook | if (ext & (1 << 14)) { |
2243 | e6e5906b | pbrook | /* Source effective address. */
|
2244 | e6e5906b | pbrook | switch ((ext >> 10) & 7) { |
2245 | e6e5906b | pbrook | case 0: opsize = OS_LONG; break; |
2246 | e6e5906b | pbrook | case 1: opsize = OS_SINGLE; break; |
2247 | e6e5906b | pbrook | case 4: opsize = OS_WORD; break; |
2248 | e6e5906b | pbrook | case 5: opsize = OS_DOUBLE; break; |
2249 | e6e5906b | pbrook | case 6: opsize = OS_BYTE; break; |
2250 | e6e5906b | pbrook | default:
|
2251 | e6e5906b | pbrook | goto undef;
|
2252 | e6e5906b | pbrook | } |
2253 | e6e5906b | pbrook | if (opsize == OS_DOUBLE) {
|
2254 | a7812ae4 | pbrook | tmp32 = tcg_temp_new_i32(); |
2255 | a7812ae4 | pbrook | tcg_gen_mov_i32(tmp32, AREG(insn, 0));
|
2256 | c59b97aa | pbrook | switch ((insn >> 3) & 7) { |
2257 | a7812ae4 | pbrook | case 2: |
2258 | a7812ae4 | pbrook | case 3: |
2259 | 243ee8f7 | pbrook | break;
|
2260 | a7812ae4 | pbrook | case 4: |
2261 | a7812ae4 | pbrook | tcg_gen_addi_i32(tmp32, tmp32, -8);
|
2262 | a7812ae4 | pbrook | break;
|
2263 | a7812ae4 | pbrook | case 5: |
2264 | a7812ae4 | pbrook | offset = ldsw_code(s->pc); |
2265 | a7812ae4 | pbrook | s->pc += 2;
|
2266 | a7812ae4 | pbrook | tcg_gen_addi_i32(tmp32, tmp32, offset); |
2267 | a7812ae4 | pbrook | break;
|
2268 | a7812ae4 | pbrook | case 7: |
2269 | a7812ae4 | pbrook | offset = ldsw_code(s->pc); |
2270 | a7812ae4 | pbrook | offset += s->pc - 2;
|
2271 | a7812ae4 | pbrook | s->pc += 2;
|
2272 | a7812ae4 | pbrook | tcg_gen_addi_i32(tmp32, tmp32, offset); |
2273 | a7812ae4 | pbrook | break;
|
2274 | a7812ae4 | pbrook | default:
|
2275 | a7812ae4 | pbrook | goto undef;
|
2276 | a7812ae4 | pbrook | } |
2277 | a7812ae4 | pbrook | src = gen_load64(s, tmp32); |
2278 | c59b97aa | pbrook | switch ((insn >> 3) & 7) { |
2279 | a7812ae4 | pbrook | case 3: |
2280 | a7812ae4 | pbrook | tcg_gen_addi_i32(tmp32, tmp32, 8);
|
2281 | a7812ae4 | pbrook | tcg_gen_mov_i32(AREG(insn, 0), tmp32);
|
2282 | a7812ae4 | pbrook | break;
|
2283 | a7812ae4 | pbrook | case 4: |
2284 | a7812ae4 | pbrook | tcg_gen_mov_i32(AREG(insn, 0), tmp32);
|
2285 | a7812ae4 | pbrook | break;
|
2286 | a7812ae4 | pbrook | } |
2287 | a7812ae4 | pbrook | tcg_temp_free_i32(tmp32); |
2288 | e6e5906b | pbrook | } else {
|
2289 | a7812ae4 | pbrook | SRC_EA(tmp32, opsize, 1, NULL); |
2290 | a7812ae4 | pbrook | src = tcg_temp_new_i64(); |
2291 | e6e5906b | pbrook | switch (opsize) {
|
2292 | e6e5906b | pbrook | case OS_LONG:
|
2293 | e6e5906b | pbrook | case OS_WORD:
|
2294 | e6e5906b | pbrook | case OS_BYTE:
|
2295 | a7812ae4 | pbrook | gen_helper_i32_to_f64(src, cpu_env, tmp32); |
2296 | e6e5906b | pbrook | break;
|
2297 | e6e5906b | pbrook | case OS_SINGLE:
|
2298 | a7812ae4 | pbrook | gen_helper_f32_to_f64(src, cpu_env, tmp32); |
2299 | e6e5906b | pbrook | break;
|
2300 | e6e5906b | pbrook | } |
2301 | e6e5906b | pbrook | } |
2302 | e6e5906b | pbrook | } else {
|
2303 | e6e5906b | pbrook | /* Source register. */
|
2304 | e6e5906b | pbrook | src = FREG(ext, 10);
|
2305 | e6e5906b | pbrook | } |
2306 | e6e5906b | pbrook | dest = FREG(ext, 7);
|
2307 | a7812ae4 | pbrook | res = tcg_temp_new_i64(); |
2308 | e6e5906b | pbrook | if (opmode != 0x3a) |
2309 | e1f3808e | pbrook | tcg_gen_mov_f64(res, dest); |
2310 | e6e5906b | pbrook | round = 1;
|
2311 | a7812ae4 | pbrook | set_dest = 1;
|
2312 | e6e5906b | pbrook | switch (opmode) {
|
2313 | e6e5906b | pbrook | case 0: case 0x40: case 0x44: /* fmove */ |
2314 | e1f3808e | pbrook | tcg_gen_mov_f64(res, src); |
2315 | e6e5906b | pbrook | break;
|
2316 | e6e5906b | pbrook | case 1: /* fint */ |
2317 | e1f3808e | pbrook | gen_helper_iround_f64(res, cpu_env, src); |
2318 | e6e5906b | pbrook | round = 0;
|
2319 | e6e5906b | pbrook | break;
|
2320 | e6e5906b | pbrook | case 3: /* fintrz */ |
2321 | e1f3808e | pbrook | gen_helper_itrunc_f64(res, cpu_env, src); |
2322 | e6e5906b | pbrook | round = 0;
|
2323 | e6e5906b | pbrook | break;
|
2324 | e6e5906b | pbrook | case 4: case 0x41: case 0x45: /* fsqrt */ |
2325 | e1f3808e | pbrook | gen_helper_sqrt_f64(res, cpu_env, src); |
2326 | e6e5906b | pbrook | break;
|
2327 | e6e5906b | pbrook | case 0x18: case 0x58: case 0x5c: /* fabs */ |
2328 | e1f3808e | pbrook | gen_helper_abs_f64(res, src); |
2329 | e6e5906b | pbrook | break;
|
2330 | e6e5906b | pbrook | case 0x1a: case 0x5a: case 0x5e: /* fneg */ |
2331 | e1f3808e | pbrook | gen_helper_chs_f64(res, src); |
2332 | e6e5906b | pbrook | break;
|
2333 | e6e5906b | pbrook | case 0x20: case 0x60: case 0x64: /* fdiv */ |
2334 | e1f3808e | pbrook | gen_helper_div_f64(res, cpu_env, res, src); |
2335 | e6e5906b | pbrook | break;
|
2336 | e6e5906b | pbrook | case 0x22: case 0x62: case 0x66: /* fadd */ |
2337 | e1f3808e | pbrook | gen_helper_add_f64(res, cpu_env, res, src); |
2338 | e6e5906b | pbrook | break;
|
2339 | e6e5906b | pbrook | case 0x23: case 0x63: case 0x67: /* fmul */ |
2340 | e1f3808e | pbrook | gen_helper_mul_f64(res, cpu_env, res, src); |
2341 | e6e5906b | pbrook | break;
|
2342 | e6e5906b | pbrook | case 0x28: case 0x68: case 0x6c: /* fsub */ |
2343 | e1f3808e | pbrook | gen_helper_sub_f64(res, cpu_env, res, src); |
2344 | e6e5906b | pbrook | break;
|
2345 | e6e5906b | pbrook | case 0x38: /* fcmp */ |
2346 | e1f3808e | pbrook | gen_helper_sub_cmp_f64(res, cpu_env, res, src); |
2347 | a7812ae4 | pbrook | set_dest = 0;
|
2348 | e6e5906b | pbrook | round = 0;
|
2349 | e6e5906b | pbrook | break;
|
2350 | e6e5906b | pbrook | case 0x3a: /* ftst */ |
2351 | e1f3808e | pbrook | tcg_gen_mov_f64(res, src); |
2352 | a7812ae4 | pbrook | set_dest = 0;
|
2353 | e6e5906b | pbrook | round = 0;
|
2354 | e6e5906b | pbrook | break;
|
2355 | e6e5906b | pbrook | default:
|
2356 | e6e5906b | pbrook | goto undef;
|
2357 | e6e5906b | pbrook | } |
2358 | a7812ae4 | pbrook | if (ext & (1 << 14)) { |
2359 | a7812ae4 | pbrook | tcg_temp_free_i64(src); |
2360 | a7812ae4 | pbrook | } |
2361 | e6e5906b | pbrook | if (round) {
|
2362 | e6e5906b | pbrook | if (opmode & 0x40) { |
2363 | e6e5906b | pbrook | if ((opmode & 0x4) != 0) |
2364 | e6e5906b | pbrook | round = 0;
|
2365 | e6e5906b | pbrook | } else if ((s->fpcr & M68K_FPCR_PREC) == 0) { |
2366 | e6e5906b | pbrook | round = 0;
|
2367 | e6e5906b | pbrook | } |
2368 | e6e5906b | pbrook | } |
2369 | e6e5906b | pbrook | if (round) {
|
2370 | a7812ae4 | pbrook | TCGv tmp = tcg_temp_new_i32(); |
2371 | e1f3808e | pbrook | gen_helper_f64_to_f32(tmp, cpu_env, res); |
2372 | e1f3808e | pbrook | gen_helper_f32_to_f64(res, cpu_env, tmp); |
2373 | a7812ae4 | pbrook | tcg_temp_free_i32(tmp); |
2374 | 5fafdf24 | ths | } |
2375 | e1f3808e | pbrook | tcg_gen_mov_f64(QREG_FP_RESULT, res); |
2376 | a7812ae4 | pbrook | if (set_dest) {
|
2377 | e1f3808e | pbrook | tcg_gen_mov_f64(dest, res); |
2378 | e6e5906b | pbrook | } |
2379 | a7812ae4 | pbrook | tcg_temp_free_i64(res); |
2380 | e6e5906b | pbrook | return;
|
2381 | e6e5906b | pbrook | undef:
|
2382 | a7812ae4 | pbrook | /* FIXME: Is this right for offset addressing modes? */
|
2383 | e6e5906b | pbrook | s->pc -= 2;
|
2384 | e6e5906b | pbrook | disas_undef_fpu(s, insn); |
2385 | e6e5906b | pbrook | } |
2386 | e6e5906b | pbrook | |
2387 | e6e5906b | pbrook | DISAS_INSN(fbcc) |
2388 | e6e5906b | pbrook | { |
2389 | e6e5906b | pbrook | uint32_t offset; |
2390 | e6e5906b | pbrook | uint32_t addr; |
2391 | e1f3808e | pbrook | TCGv flag; |
2392 | e6e5906b | pbrook | int l1;
|
2393 | e6e5906b | pbrook | |
2394 | e6e5906b | pbrook | addr = s->pc; |
2395 | 0633879f | pbrook | offset = ldsw_code(s->pc); |
2396 | e6e5906b | pbrook | s->pc += 2;
|
2397 | e6e5906b | pbrook | if (insn & (1 << 6)) { |
2398 | 0633879f | pbrook | offset = (offset << 16) | lduw_code(s->pc);
|
2399 | e6e5906b | pbrook | s->pc += 2;
|
2400 | e6e5906b | pbrook | } |
2401 | e6e5906b | pbrook | |
2402 | e6e5906b | pbrook | l1 = gen_new_label(); |
2403 | e6e5906b | pbrook | /* TODO: Raise BSUN exception. */
|
2404 | a7812ae4 | pbrook | flag = tcg_temp_new(); |
2405 | e1f3808e | pbrook | gen_helper_compare_f64(flag, cpu_env, QREG_FP_RESULT); |
2406 | e6e5906b | pbrook | /* Jump to l1 if condition is true. */
|
2407 | e6e5906b | pbrook | switch (insn & 0xf) { |
2408 | e6e5906b | pbrook | case 0: /* f */ |
2409 | e6e5906b | pbrook | break;
|
2410 | e6e5906b | pbrook | case 1: /* eq (=0) */ |
2411 | e1f3808e | pbrook | tcg_gen_brcond_i32(TCG_COND_EQ, flag, tcg_const_i32(0), l1);
|
2412 | e6e5906b | pbrook | break;
|
2413 | e6e5906b | pbrook | case 2: /* ogt (=1) */ |
2414 | e1f3808e | pbrook | tcg_gen_brcond_i32(TCG_COND_EQ, flag, tcg_const_i32(1), l1);
|
2415 | e6e5906b | pbrook | break;
|
2416 | e6e5906b | pbrook | case 3: /* oge (=0 or =1) */ |
2417 | e1f3808e | pbrook | tcg_gen_brcond_i32(TCG_COND_LEU, flag, tcg_const_i32(1), l1);
|
2418 | e6e5906b | pbrook | break;
|
2419 | e6e5906b | pbrook | case 4: /* olt (=-1) */ |
2420 | e1f3808e | pbrook | tcg_gen_brcond_i32(TCG_COND_LT, flag, tcg_const_i32(0), l1);
|
2421 | e6e5906b | pbrook | break;
|
2422 | e6e5906b | pbrook | case 5: /* ole (=-1 or =0) */ |
2423 | e1f3808e | pbrook | tcg_gen_brcond_i32(TCG_COND_LE, flag, tcg_const_i32(0), l1);
|
2424 | e6e5906b | pbrook | break;
|
2425 | e6e5906b | pbrook | case 6: /* ogl (=-1 or =1) */ |
2426 | e1f3808e | pbrook | tcg_gen_andi_i32(flag, flag, 1);
|
2427 | e1f3808e | pbrook | tcg_gen_brcond_i32(TCG_COND_NE, flag, tcg_const_i32(0), l1);
|
2428 | e6e5906b | pbrook | break;
|
2429 | e6e5906b | pbrook | case 7: /* or (=2) */ |
2430 | e1f3808e | pbrook | tcg_gen_brcond_i32(TCG_COND_EQ, flag, tcg_const_i32(2), l1);
|
2431 | e6e5906b | pbrook | break;
|
2432 | e6e5906b | pbrook | case 8: /* un (<2) */ |
2433 | e1f3808e | pbrook | tcg_gen_brcond_i32(TCG_COND_LT, flag, tcg_const_i32(2), l1);
|
2434 | e6e5906b | pbrook | break;
|
2435 | e6e5906b | pbrook | case 9: /* ueq (=0 or =2) */ |
2436 | e1f3808e | pbrook | tcg_gen_andi_i32(flag, flag, 1);
|
2437 | e1f3808e | pbrook | tcg_gen_brcond_i32(TCG_COND_EQ, flag, tcg_const_i32(0), l1);
|
2438 | e6e5906b | pbrook | break;
|
2439 | e6e5906b | pbrook | case 10: /* ugt (>0) */ |
2440 | e1f3808e | pbrook | tcg_gen_brcond_i32(TCG_COND_GT, flag, tcg_const_i32(0), l1);
|
2441 | e6e5906b | pbrook | break;
|
2442 | e6e5906b | pbrook | case 11: /* uge (>=0) */ |
2443 | e1f3808e | pbrook | tcg_gen_brcond_i32(TCG_COND_GE, flag, tcg_const_i32(0), l1);
|
2444 | e6e5906b | pbrook | break;
|
2445 | e6e5906b | pbrook | case 12: /* ult (=-1 or =2) */ |
2446 | e1f3808e | pbrook | tcg_gen_brcond_i32(TCG_COND_GEU, flag, tcg_const_i32(2), l1);
|
2447 | e6e5906b | pbrook | break;
|
2448 | e6e5906b | pbrook | case 13: /* ule (!=1) */ |
2449 | e1f3808e | pbrook | tcg_gen_brcond_i32(TCG_COND_NE, flag, tcg_const_i32(1), l1);
|
2450 | e6e5906b | pbrook | break;
|
2451 | e6e5906b | pbrook | case 14: /* ne (!=0) */ |
2452 | e1f3808e | pbrook | tcg_gen_brcond_i32(TCG_COND_NE, flag, tcg_const_i32(0), l1);
|
2453 | e6e5906b | pbrook | break;
|
2454 | e6e5906b | pbrook | case 15: /* t */ |
2455 | e1f3808e | pbrook | tcg_gen_br(l1); |
2456 | e6e5906b | pbrook | break;
|
2457 | e6e5906b | pbrook | } |
2458 | e6e5906b | pbrook | gen_jmp_tb(s, 0, s->pc);
|
2459 | e6e5906b | pbrook | gen_set_label(l1); |
2460 | e6e5906b | pbrook | gen_jmp_tb(s, 1, addr + offset);
|
2461 | e6e5906b | pbrook | } |
2462 | e6e5906b | pbrook | |
2463 | 0633879f | pbrook | DISAS_INSN(frestore) |
2464 | 0633879f | pbrook | { |
2465 | 0633879f | pbrook | /* TODO: Implement frestore. */
|
2466 | 0633879f | pbrook | qemu_assert(0, "FRESTORE not implemented"); |
2467 | 0633879f | pbrook | } |
2468 | 0633879f | pbrook | |
2469 | 0633879f | pbrook | DISAS_INSN(fsave) |
2470 | 0633879f | pbrook | { |
2471 | 0633879f | pbrook | /* TODO: Implement fsave. */
|
2472 | 0633879f | pbrook | qemu_assert(0, "FSAVE not implemented"); |
2473 | 0633879f | pbrook | } |
2474 | 0633879f | pbrook | |
2475 | e1f3808e | pbrook | static inline TCGv gen_mac_extract_word(DisasContext *s, TCGv val, int upper) |
2476 | acf930aa | pbrook | { |
2477 | a7812ae4 | pbrook | TCGv tmp = tcg_temp_new(); |
2478 | acf930aa | pbrook | if (s->env->macsr & MACSR_FI) {
|
2479 | acf930aa | pbrook | if (upper)
|
2480 | e1f3808e | pbrook | tcg_gen_andi_i32(tmp, val, 0xffff0000);
|
2481 | acf930aa | pbrook | else
|
2482 | e1f3808e | pbrook | tcg_gen_shli_i32(tmp, val, 16);
|
2483 | acf930aa | pbrook | } else if (s->env->macsr & MACSR_SU) { |
2484 | acf930aa | pbrook | if (upper)
|
2485 | e1f3808e | pbrook | tcg_gen_sari_i32(tmp, val, 16);
|
2486 | acf930aa | pbrook | else
|
2487 | e1f3808e | pbrook | tcg_gen_ext16s_i32(tmp, val); |
2488 | acf930aa | pbrook | } else {
|
2489 | acf930aa | pbrook | if (upper)
|
2490 | e1f3808e | pbrook | tcg_gen_shri_i32(tmp, val, 16);
|
2491 | acf930aa | pbrook | else
|
2492 | e1f3808e | pbrook | tcg_gen_ext16u_i32(tmp, val); |
2493 | acf930aa | pbrook | } |
2494 | acf930aa | pbrook | return tmp;
|
2495 | acf930aa | pbrook | } |
2496 | acf930aa | pbrook | |
2497 | e1f3808e | pbrook | static void gen_mac_clear_flags(void) |
2498 | e1f3808e | pbrook | { |
2499 | e1f3808e | pbrook | tcg_gen_andi_i32(QREG_MACSR, QREG_MACSR, |
2500 | e1f3808e | pbrook | ~(MACSR_V | MACSR_Z | MACSR_N | MACSR_EV)); |
2501 | e1f3808e | pbrook | } |
2502 | e1f3808e | pbrook | |
2503 | acf930aa | pbrook | DISAS_INSN(mac) |
2504 | acf930aa | pbrook | { |
2505 | e1f3808e | pbrook | TCGv rx; |
2506 | e1f3808e | pbrook | TCGv ry; |
2507 | acf930aa | pbrook | uint16_t ext; |
2508 | acf930aa | pbrook | int acc;
|
2509 | e1f3808e | pbrook | TCGv tmp; |
2510 | e1f3808e | pbrook | TCGv addr; |
2511 | e1f3808e | pbrook | TCGv loadval; |
2512 | acf930aa | pbrook | int dual;
|
2513 | e1f3808e | pbrook | TCGv saved_flags; |
2514 | e1f3808e | pbrook | |
2515 | a7812ae4 | pbrook | if (!s->done_mac) {
|
2516 | a7812ae4 | pbrook | s->mactmp = tcg_temp_new_i64(); |
2517 | a7812ae4 | pbrook | s->done_mac = 1;
|
2518 | a7812ae4 | pbrook | } |
2519 | acf930aa | pbrook | |
2520 | acf930aa | pbrook | ext = lduw_code(s->pc); |
2521 | acf930aa | pbrook | s->pc += 2;
|
2522 | acf930aa | pbrook | |
2523 | acf930aa | pbrook | acc = ((insn >> 7) & 1) | ((ext >> 3) & 2); |
2524 | acf930aa | pbrook | dual = ((insn & 0x30) != 0 && (ext & 3) != 0); |
2525 | d315c888 | pbrook | if (dual && !m68k_feature(s->env, M68K_FEATURE_CF_EMAC_B)) {
|
2526 | d315c888 | pbrook | disas_undef(s, insn); |
2527 | d315c888 | pbrook | return;
|
2528 | d315c888 | pbrook | } |
2529 | acf930aa | pbrook | if (insn & 0x30) { |
2530 | acf930aa | pbrook | /* MAC with load. */
|
2531 | acf930aa | pbrook | tmp = gen_lea(s, insn, OS_LONG); |
2532 | a7812ae4 | pbrook | addr = tcg_temp_new(); |
2533 | e1f3808e | pbrook | tcg_gen_and_i32(addr, tmp, QREG_MAC_MASK); |
2534 | acf930aa | pbrook | /* Load the value now to ensure correct exception behavior.
|
2535 | acf930aa | pbrook | Perform writeback after reading the MAC inputs. */
|
2536 | acf930aa | pbrook | loadval = gen_load(s, OS_LONG, addr, 0);
|
2537 | acf930aa | pbrook | |
2538 | acf930aa | pbrook | acc ^= 1;
|
2539 | acf930aa | pbrook | rx = (ext & 0x8000) ? AREG(ext, 12) : DREG(insn, 12); |
2540 | acf930aa | pbrook | ry = (ext & 8) ? AREG(ext, 0) : DREG(ext, 0); |
2541 | acf930aa | pbrook | } else {
|
2542 | e1f3808e | pbrook | loadval = addr = NULL_QREG; |
2543 | acf930aa | pbrook | rx = (insn & 0x40) ? AREG(insn, 9) : DREG(insn, 9); |
2544 | acf930aa | pbrook | ry = (insn & 8) ? AREG(insn, 0) : DREG(insn, 0); |
2545 | acf930aa | pbrook | } |
2546 | acf930aa | pbrook | |
2547 | e1f3808e | pbrook | gen_mac_clear_flags(); |
2548 | e1f3808e | pbrook | #if 0
|
2549 | acf930aa | pbrook | l1 = -1;
|
2550 | e1f3808e | pbrook | /* Disabled because conditional branches clobber temporary vars. */
|
2551 | acf930aa | pbrook | if ((s->env->macsr & MACSR_OMC) != 0 && !dual) {
|
2552 | acf930aa | pbrook | /* Skip the multiply if we know we will ignore it. */
|
2553 | acf930aa | pbrook | l1 = gen_new_label();
|
2554 | a7812ae4 | pbrook | tmp = tcg_temp_new();
|
2555 | e1f3808e | pbrook | tcg_gen_andi_i32(tmp, QREG_MACSR, 1 << (acc + 8));
|
2556 | acf930aa | pbrook | gen_op_jmp_nz32(tmp, l1);
|
2557 | acf930aa | pbrook | }
|
2558 | e1f3808e | pbrook | #endif
|
2559 | acf930aa | pbrook | |
2560 | acf930aa | pbrook | if ((ext & 0x0800) == 0) { |
2561 | acf930aa | pbrook | /* Word. */
|
2562 | acf930aa | pbrook | rx = gen_mac_extract_word(s, rx, (ext & 0x80) != 0); |
2563 | acf930aa | pbrook | ry = gen_mac_extract_word(s, ry, (ext & 0x40) != 0); |
2564 | acf930aa | pbrook | } |
2565 | acf930aa | pbrook | if (s->env->macsr & MACSR_FI) {
|
2566 | e1f3808e | pbrook | gen_helper_macmulf(s->mactmp, cpu_env, rx, ry); |
2567 | acf930aa | pbrook | } else {
|
2568 | acf930aa | pbrook | if (s->env->macsr & MACSR_SU)
|
2569 | e1f3808e | pbrook | gen_helper_macmuls(s->mactmp, cpu_env, rx, ry); |
2570 | acf930aa | pbrook | else
|
2571 | e1f3808e | pbrook | gen_helper_macmulu(s->mactmp, cpu_env, rx, ry); |
2572 | acf930aa | pbrook | switch ((ext >> 9) & 3) { |
2573 | acf930aa | pbrook | case 1: |
2574 | e1f3808e | pbrook | tcg_gen_shli_i64(s->mactmp, s->mactmp, 1);
|
2575 | acf930aa | pbrook | break;
|
2576 | acf930aa | pbrook | case 3: |
2577 | e1f3808e | pbrook | tcg_gen_shri_i64(s->mactmp, s->mactmp, 1);
|
2578 | acf930aa | pbrook | break;
|
2579 | acf930aa | pbrook | } |
2580 | acf930aa | pbrook | } |
2581 | acf930aa | pbrook | |
2582 | acf930aa | pbrook | if (dual) {
|
2583 | acf930aa | pbrook | /* Save the overflow flag from the multiply. */
|
2584 | a7812ae4 | pbrook | saved_flags = tcg_temp_new(); |
2585 | e1f3808e | pbrook | tcg_gen_mov_i32(saved_flags, QREG_MACSR); |
2586 | e1f3808e | pbrook | } else {
|
2587 | e1f3808e | pbrook | saved_flags = NULL_QREG; |
2588 | acf930aa | pbrook | } |
2589 | acf930aa | pbrook | |
2590 | e1f3808e | pbrook | #if 0
|
2591 | e1f3808e | pbrook | /* Disabled because conditional branches clobber temporary vars. */
|
2592 | acf930aa | pbrook | if ((s->env->macsr & MACSR_OMC) != 0 && dual) {
|
2593 | acf930aa | pbrook | /* Skip the accumulate if the value is already saturated. */
|
2594 | acf930aa | pbrook | l1 = gen_new_label();
|
2595 | a7812ae4 | pbrook | tmp = tcg_temp_new();
|
2596 | acf930aa | pbrook | gen_op_and32(tmp, QREG_MACSR, gen_im32(MACSR_PAV0 << acc));
|
2597 | acf930aa | pbrook | gen_op_jmp_nz32(tmp, l1);
|
2598 | acf930aa | pbrook | }
|
2599 | e1f3808e | pbrook | #endif
|
2600 | acf930aa | pbrook | |
2601 | acf930aa | pbrook | if (insn & 0x100) |
2602 | e1f3808e | pbrook | tcg_gen_sub_i64(MACREG(acc), MACREG(acc), s->mactmp); |
2603 | acf930aa | pbrook | else
|
2604 | e1f3808e | pbrook | tcg_gen_add_i64(MACREG(acc), MACREG(acc), s->mactmp); |
2605 | acf930aa | pbrook | |
2606 | acf930aa | pbrook | if (s->env->macsr & MACSR_FI)
|
2607 | e1f3808e | pbrook | gen_helper_macsatf(cpu_env, tcg_const_i32(acc)); |
2608 | acf930aa | pbrook | else if (s->env->macsr & MACSR_SU) |
2609 | e1f3808e | pbrook | gen_helper_macsats(cpu_env, tcg_const_i32(acc)); |
2610 | acf930aa | pbrook | else
|
2611 | e1f3808e | pbrook | gen_helper_macsatu(cpu_env, tcg_const_i32(acc)); |
2612 | acf930aa | pbrook | |
2613 | e1f3808e | pbrook | #if 0
|
2614 | e1f3808e | pbrook | /* Disabled because conditional branches clobber temporary vars. */
|
2615 | acf930aa | pbrook | if (l1 != -1)
|
2616 | acf930aa | pbrook | gen_set_label(l1);
|
2617 | e1f3808e | pbrook | #endif
|
2618 | acf930aa | pbrook | |
2619 | acf930aa | pbrook | if (dual) {
|
2620 | acf930aa | pbrook | /* Dual accumulate variant. */
|
2621 | acf930aa | pbrook | acc = (ext >> 2) & 3; |
2622 | acf930aa | pbrook | /* Restore the overflow flag from the multiplier. */
|
2623 | e1f3808e | pbrook | tcg_gen_mov_i32(QREG_MACSR, saved_flags); |
2624 | e1f3808e | pbrook | #if 0
|
2625 | e1f3808e | pbrook | /* Disabled because conditional branches clobber temporary vars. */
|
2626 | acf930aa | pbrook | if ((s->env->macsr & MACSR_OMC) != 0) {
|
2627 | acf930aa | pbrook | /* Skip the accumulate if the value is already saturated. */
|
2628 | acf930aa | pbrook | l1 = gen_new_label();
|
2629 | a7812ae4 | pbrook | tmp = tcg_temp_new();
|
2630 | acf930aa | pbrook | gen_op_and32(tmp, QREG_MACSR, gen_im32(MACSR_PAV0 << acc));
|
2631 | acf930aa | pbrook | gen_op_jmp_nz32(tmp, l1);
|
2632 | acf930aa | pbrook | }
|
2633 | e1f3808e | pbrook | #endif
|
2634 | acf930aa | pbrook | if (ext & 2) |
2635 | e1f3808e | pbrook | tcg_gen_sub_i64(MACREG(acc), MACREG(acc), s->mactmp); |
2636 | acf930aa | pbrook | else
|
2637 | e1f3808e | pbrook | tcg_gen_add_i64(MACREG(acc), MACREG(acc), s->mactmp); |
2638 | acf930aa | pbrook | if (s->env->macsr & MACSR_FI)
|
2639 | e1f3808e | pbrook | gen_helper_macsatf(cpu_env, tcg_const_i32(acc)); |
2640 | acf930aa | pbrook | else if (s->env->macsr & MACSR_SU) |
2641 | e1f3808e | pbrook | gen_helper_macsats(cpu_env, tcg_const_i32(acc)); |
2642 | acf930aa | pbrook | else
|
2643 | e1f3808e | pbrook | gen_helper_macsatu(cpu_env, tcg_const_i32(acc)); |
2644 | e1f3808e | pbrook | #if 0
|
2645 | e1f3808e | pbrook | /* Disabled because conditional branches clobber temporary vars. */
|
2646 | acf930aa | pbrook | if (l1 != -1)
|
2647 | acf930aa | pbrook | gen_set_label(l1);
|
2648 | e1f3808e | pbrook | #endif
|
2649 | acf930aa | pbrook | } |
2650 | e1f3808e | pbrook | gen_helper_mac_set_flags(cpu_env, tcg_const_i32(acc)); |
2651 | acf930aa | pbrook | |
2652 | acf930aa | pbrook | if (insn & 0x30) { |
2653 | e1f3808e | pbrook | TCGv rw; |
2654 | acf930aa | pbrook | rw = (insn & 0x40) ? AREG(insn, 9) : DREG(insn, 9); |
2655 | e1f3808e | pbrook | tcg_gen_mov_i32(rw, loadval); |
2656 | acf930aa | pbrook | /* FIXME: Should address writeback happen with the masked or
|
2657 | acf930aa | pbrook | unmasked value? */
|
2658 | acf930aa | pbrook | switch ((insn >> 3) & 7) { |
2659 | acf930aa | pbrook | case 3: /* Post-increment. */ |
2660 | e1f3808e | pbrook | tcg_gen_addi_i32(AREG(insn, 0), addr, 4); |
2661 | acf930aa | pbrook | break;
|
2662 | acf930aa | pbrook | case 4: /* Pre-decrement. */ |
2663 | e1f3808e | pbrook | tcg_gen_mov_i32(AREG(insn, 0), addr);
|
2664 | acf930aa | pbrook | } |
2665 | acf930aa | pbrook | } |
2666 | acf930aa | pbrook | } |
2667 | acf930aa | pbrook | |
2668 | acf930aa | pbrook | DISAS_INSN(from_mac) |
2669 | acf930aa | pbrook | { |
2670 | e1f3808e | pbrook | TCGv rx; |
2671 | a7812ae4 | pbrook | TCGv_i64 acc; |
2672 | e1f3808e | pbrook | int accnum;
|
2673 | acf930aa | pbrook | |
2674 | acf930aa | pbrook | rx = (insn & 8) ? AREG(insn, 0) : DREG(insn, 0); |
2675 | e1f3808e | pbrook | accnum = (insn >> 9) & 3; |
2676 | e1f3808e | pbrook | acc = MACREG(accnum); |
2677 | acf930aa | pbrook | if (s->env->macsr & MACSR_FI) {
|
2678 | a7812ae4 | pbrook | gen_helper_get_macf(rx, cpu_env, acc); |
2679 | acf930aa | pbrook | } else if ((s->env->macsr & MACSR_OMC) == 0) { |
2680 | e1f3808e | pbrook | tcg_gen_trunc_i64_i32(rx, acc); |
2681 | acf930aa | pbrook | } else if (s->env->macsr & MACSR_SU) { |
2682 | e1f3808e | pbrook | gen_helper_get_macs(rx, acc); |
2683 | acf930aa | pbrook | } else {
|
2684 | e1f3808e | pbrook | gen_helper_get_macu(rx, acc); |
2685 | e1f3808e | pbrook | } |
2686 | e1f3808e | pbrook | if (insn & 0x40) { |
2687 | e1f3808e | pbrook | tcg_gen_movi_i64(acc, 0);
|
2688 | e1f3808e | pbrook | tcg_gen_andi_i32(QREG_MACSR, QREG_MACSR, ~(MACSR_PAV0 << accnum)); |
2689 | acf930aa | pbrook | } |
2690 | acf930aa | pbrook | } |
2691 | acf930aa | pbrook | |
2692 | acf930aa | pbrook | DISAS_INSN(move_mac) |
2693 | acf930aa | pbrook | { |
2694 | e1f3808e | pbrook | /* FIXME: This can be done without a helper. */
|
2695 | acf930aa | pbrook | int src;
|
2696 | e1f3808e | pbrook | TCGv dest; |
2697 | acf930aa | pbrook | src = insn & 3;
|
2698 | e1f3808e | pbrook | dest = tcg_const_i32((insn >> 9) & 3); |
2699 | e1f3808e | pbrook | gen_helper_mac_move(cpu_env, dest, tcg_const_i32(src)); |
2700 | e1f3808e | pbrook | gen_mac_clear_flags(); |
2701 | e1f3808e | pbrook | gen_helper_mac_set_flags(cpu_env, dest); |
2702 | acf930aa | pbrook | } |
2703 | acf930aa | pbrook | |
2704 | acf930aa | pbrook | DISAS_INSN(from_macsr) |
2705 | acf930aa | pbrook | { |
2706 | e1f3808e | pbrook | TCGv reg; |
2707 | acf930aa | pbrook | |
2708 | acf930aa | pbrook | reg = (insn & 8) ? AREG(insn, 0) : DREG(insn, 0); |
2709 | e1f3808e | pbrook | tcg_gen_mov_i32(reg, QREG_MACSR); |
2710 | acf930aa | pbrook | } |
2711 | acf930aa | pbrook | |
2712 | acf930aa | pbrook | DISAS_INSN(from_mask) |
2713 | acf930aa | pbrook | { |
2714 | e1f3808e | pbrook | TCGv reg; |
2715 | acf930aa | pbrook | reg = (insn & 8) ? AREG(insn, 0) : DREG(insn, 0); |
2716 | e1f3808e | pbrook | tcg_gen_mov_i32(reg, QREG_MAC_MASK); |
2717 | acf930aa | pbrook | } |
2718 | acf930aa | pbrook | |
2719 | acf930aa | pbrook | DISAS_INSN(from_mext) |
2720 | acf930aa | pbrook | { |
2721 | e1f3808e | pbrook | TCGv reg; |
2722 | e1f3808e | pbrook | TCGv acc; |
2723 | acf930aa | pbrook | reg = (insn & 8) ? AREG(insn, 0) : DREG(insn, 0); |
2724 | e1f3808e | pbrook | acc = tcg_const_i32((insn & 0x400) ? 2 : 0); |
2725 | acf930aa | pbrook | if (s->env->macsr & MACSR_FI)
|
2726 | e1f3808e | pbrook | gen_helper_get_mac_extf(reg, cpu_env, acc); |
2727 | acf930aa | pbrook | else
|
2728 | e1f3808e | pbrook | gen_helper_get_mac_exti(reg, cpu_env, acc); |
2729 | acf930aa | pbrook | } |
2730 | acf930aa | pbrook | |
2731 | acf930aa | pbrook | DISAS_INSN(macsr_to_ccr) |
2732 | acf930aa | pbrook | { |
2733 | e1f3808e | pbrook | tcg_gen_movi_i32(QREG_CC_X, 0);
|
2734 | e1f3808e | pbrook | tcg_gen_andi_i32(QREG_CC_DEST, QREG_MACSR, 0xf);
|
2735 | acf930aa | pbrook | s->cc_op = CC_OP_FLAGS; |
2736 | acf930aa | pbrook | } |
2737 | acf930aa | pbrook | |
2738 | acf930aa | pbrook | DISAS_INSN(to_mac) |
2739 | acf930aa | pbrook | { |
2740 | a7812ae4 | pbrook | TCGv_i64 acc; |
2741 | e1f3808e | pbrook | TCGv val; |
2742 | e1f3808e | pbrook | int accnum;
|
2743 | e1f3808e | pbrook | accnum = (insn >> 9) & 3; |
2744 | e1f3808e | pbrook | acc = MACREG(accnum); |
2745 | acf930aa | pbrook | SRC_EA(val, OS_LONG, 0, NULL); |
2746 | acf930aa | pbrook | if (s->env->macsr & MACSR_FI) {
|
2747 | e1f3808e | pbrook | tcg_gen_ext_i32_i64(acc, val); |
2748 | e1f3808e | pbrook | tcg_gen_shli_i64(acc, acc, 8);
|
2749 | acf930aa | pbrook | } else if (s->env->macsr & MACSR_SU) { |
2750 | e1f3808e | pbrook | tcg_gen_ext_i32_i64(acc, val); |
2751 | acf930aa | pbrook | } else {
|
2752 | e1f3808e | pbrook | tcg_gen_extu_i32_i64(acc, val); |
2753 | acf930aa | pbrook | } |
2754 | e1f3808e | pbrook | tcg_gen_andi_i32(QREG_MACSR, QREG_MACSR, ~(MACSR_PAV0 << accnum)); |
2755 | e1f3808e | pbrook | gen_mac_clear_flags(); |
2756 | e1f3808e | pbrook | gen_helper_mac_set_flags(cpu_env, tcg_const_i32(accnum)); |
2757 | acf930aa | pbrook | } |
2758 | acf930aa | pbrook | |
2759 | acf930aa | pbrook | DISAS_INSN(to_macsr) |
2760 | acf930aa | pbrook | { |
2761 | e1f3808e | pbrook | TCGv val; |
2762 | acf930aa | pbrook | SRC_EA(val, OS_LONG, 0, NULL); |
2763 | e1f3808e | pbrook | gen_helper_set_macsr(cpu_env, val); |
2764 | acf930aa | pbrook | gen_lookup_tb(s); |
2765 | acf930aa | pbrook | } |
2766 | acf930aa | pbrook | |
2767 | acf930aa | pbrook | DISAS_INSN(to_mask) |
2768 | acf930aa | pbrook | { |
2769 | e1f3808e | pbrook | TCGv val; |
2770 | acf930aa | pbrook | SRC_EA(val, OS_LONG, 0, NULL); |
2771 | e1f3808e | pbrook | tcg_gen_ori_i32(QREG_MAC_MASK, val, 0xffff0000);
|
2772 | acf930aa | pbrook | } |
2773 | acf930aa | pbrook | |
2774 | acf930aa | pbrook | DISAS_INSN(to_mext) |
2775 | acf930aa | pbrook | { |
2776 | e1f3808e | pbrook | TCGv val; |
2777 | e1f3808e | pbrook | TCGv acc; |
2778 | acf930aa | pbrook | SRC_EA(val, OS_LONG, 0, NULL); |
2779 | e1f3808e | pbrook | acc = tcg_const_i32((insn & 0x400) ? 2 : 0); |
2780 | acf930aa | pbrook | if (s->env->macsr & MACSR_FI)
|
2781 | e1f3808e | pbrook | gen_helper_set_mac_extf(cpu_env, val, acc); |
2782 | acf930aa | pbrook | else if (s->env->macsr & MACSR_SU) |
2783 | e1f3808e | pbrook | gen_helper_set_mac_exts(cpu_env, val, acc); |
2784 | acf930aa | pbrook | else
|
2785 | e1f3808e | pbrook | gen_helper_set_mac_extu(cpu_env, val, acc); |
2786 | acf930aa | pbrook | } |
2787 | acf930aa | pbrook | |
2788 | e6e5906b | pbrook | static disas_proc opcode_table[65536]; |
2789 | e6e5906b | pbrook | |
2790 | e6e5906b | pbrook | static void |
2791 | e6e5906b | pbrook | register_opcode (disas_proc proc, uint16_t opcode, uint16_t mask) |
2792 | e6e5906b | pbrook | { |
2793 | e6e5906b | pbrook | int i;
|
2794 | e6e5906b | pbrook | int from;
|
2795 | e6e5906b | pbrook | int to;
|
2796 | e6e5906b | pbrook | |
2797 | e6e5906b | pbrook | /* Sanity check. All set bits must be included in the mask. */
|
2798 | 5fc4adf6 | pbrook | if (opcode & ~mask) {
|
2799 | 5fc4adf6 | pbrook | fprintf(stderr, |
2800 | 5fc4adf6 | pbrook | "qemu internal error: bogus opcode definition %04x/%04x\n",
|
2801 | 5fc4adf6 | pbrook | opcode, mask); |
2802 | e6e5906b | pbrook | abort(); |
2803 | 5fc4adf6 | pbrook | } |
2804 | e6e5906b | pbrook | /* This could probably be cleverer. For now just optimize the case where
|
2805 | e6e5906b | pbrook | the top bits are known. */
|
2806 | e6e5906b | pbrook | /* Find the first zero bit in the mask. */
|
2807 | e6e5906b | pbrook | i = 0x8000;
|
2808 | e6e5906b | pbrook | while ((i & mask) != 0) |
2809 | e6e5906b | pbrook | i >>= 1;
|
2810 | e6e5906b | pbrook | /* Iterate over all combinations of this and lower bits. */
|
2811 | e6e5906b | pbrook | if (i == 0) |
2812 | e6e5906b | pbrook | i = 1;
|
2813 | e6e5906b | pbrook | else
|
2814 | e6e5906b | pbrook | i <<= 1;
|
2815 | e6e5906b | pbrook | from = opcode & ~(i - 1);
|
2816 | e6e5906b | pbrook | to = from + i; |
2817 | 0633879f | pbrook | for (i = from; i < to; i++) {
|
2818 | e6e5906b | pbrook | if ((i & mask) == opcode)
|
2819 | e6e5906b | pbrook | opcode_table[i] = proc; |
2820 | 0633879f | pbrook | } |
2821 | e6e5906b | pbrook | } |
2822 | e6e5906b | pbrook | |
2823 | e6e5906b | pbrook | /* Register m68k opcode handlers. Order is important.
|
2824 | e6e5906b | pbrook | Later insn override earlier ones. */
|
2825 | 0402f767 | pbrook | void register_m68k_insns (CPUM68KState *env)
|
2826 | e6e5906b | pbrook | { |
2827 | d315c888 | pbrook | #define INSN(name, opcode, mask, feature) do { \ |
2828 | 0402f767 | pbrook | if (m68k_feature(env, M68K_FEATURE_##feature)) \ |
2829 | d315c888 | pbrook | register_opcode(disas_##name, 0x##opcode, 0x##mask); \ |
2830 | d315c888 | pbrook | } while(0) |
2831 | 0402f767 | pbrook | INSN(undef, 0000, 0000, CF_ISA_A); |
2832 | 0402f767 | pbrook | INSN(arith_im, 0080, fff8, CF_ISA_A);
|
2833 | d315c888 | pbrook | INSN(bitrev, 00c0, fff8, CF_ISA_APLUSC);
|
2834 | 0402f767 | pbrook | INSN(bitop_reg, 0100, f1c0, CF_ISA_A);
|
2835 | 0402f767 | pbrook | INSN(bitop_reg, 0140, f1c0, CF_ISA_A);
|
2836 | 0402f767 | pbrook | INSN(bitop_reg, 0180, f1c0, CF_ISA_A);
|
2837 | 0402f767 | pbrook | INSN(bitop_reg, 01c0, f1c0, CF_ISA_A);
|
2838 | 0402f767 | pbrook | INSN(arith_im, 0280, fff8, CF_ISA_A);
|
2839 | d315c888 | pbrook | INSN(byterev, 02c0, fff8, CF_ISA_APLUSC);
|
2840 | 0402f767 | pbrook | INSN(arith_im, 0480, fff8, CF_ISA_A);
|
2841 | d315c888 | pbrook | INSN(ff1, 04c0, fff8, CF_ISA_APLUSC);
|
2842 | 0402f767 | pbrook | INSN(arith_im, 0680, fff8, CF_ISA_A);
|
2843 | 0402f767 | pbrook | INSN(bitop_im, 0800, ffc0, CF_ISA_A);
|
2844 | 0402f767 | pbrook | INSN(bitop_im, 0840, ffc0, CF_ISA_A);
|
2845 | 0402f767 | pbrook | INSN(bitop_im, 0880, ffc0, CF_ISA_A);
|
2846 | 0402f767 | pbrook | INSN(bitop_im, 08c0, ffc0, CF_ISA_A);
|
2847 | 0402f767 | pbrook | INSN(arith_im, 0a80, fff8, CF_ISA_A);
|
2848 | 0402f767 | pbrook | INSN(arith_im, 0c00, ff38, CF_ISA_A);
|
2849 | 0402f767 | pbrook | INSN(move, 1000, f000, CF_ISA_A);
|
2850 | 0402f767 | pbrook | INSN(move, 2000, f000, CF_ISA_A);
|
2851 | 0402f767 | pbrook | INSN(move, 3000, f000, CF_ISA_A);
|
2852 | d315c888 | pbrook | INSN(strldsr, 40e7, ffff, CF_ISA_APLUSC); |
2853 | 0402f767 | pbrook | INSN(negx, 4080, fff8, CF_ISA_A);
|
2854 | 0402f767 | pbrook | INSN(move_from_sr, 40c0, fff8, CF_ISA_A);
|
2855 | 0402f767 | pbrook | INSN(lea, 41c0, f1c0, CF_ISA_A);
|
2856 | 0402f767 | pbrook | INSN(clr, 4200, ff00, CF_ISA_A);
|
2857 | 0402f767 | pbrook | INSN(undef, 42c0, ffc0, CF_ISA_A);
|
2858 | 0402f767 | pbrook | INSN(move_from_ccr, 42c0, fff8, CF_ISA_A);
|
2859 | 0402f767 | pbrook | INSN(neg, 4480, fff8, CF_ISA_A);
|
2860 | 0402f767 | pbrook | INSN(move_to_ccr, 44c0, ffc0, CF_ISA_A);
|
2861 | 0402f767 | pbrook | INSN(not, 4680, fff8, CF_ISA_A);
|
2862 | 0402f767 | pbrook | INSN(move_to_sr, 46c0, ffc0, CF_ISA_A);
|
2863 | 0402f767 | pbrook | INSN(pea, 4840, ffc0, CF_ISA_A);
|
2864 | 0402f767 | pbrook | INSN(swap, 4840, fff8, CF_ISA_A);
|
2865 | 0402f767 | pbrook | INSN(movem, 48c0, fbc0, CF_ISA_A);
|
2866 | 0402f767 | pbrook | INSN(ext, 4880, fff8, CF_ISA_A);
|
2867 | 0402f767 | pbrook | INSN(ext, 48c0, fff8, CF_ISA_A);
|
2868 | 0402f767 | pbrook | INSN(ext, 49c0, fff8, CF_ISA_A);
|
2869 | 0402f767 | pbrook | INSN(tst, 4a00, ff00, CF_ISA_A);
|
2870 | 0402f767 | pbrook | INSN(tas, 4ac0, ffc0, CF_ISA_B);
|
2871 | 0402f767 | pbrook | INSN(halt, 4ac8, ffff, CF_ISA_A);
|
2872 | 0402f767 | pbrook | INSN(pulse, 4acc, ffff, CF_ISA_A);
|
2873 | 0402f767 | pbrook | INSN(illegal, 4afc, ffff, CF_ISA_A);
|
2874 | 0402f767 | pbrook | INSN(mull, 4c00, ffc0, CF_ISA_A);
|
2875 | 0402f767 | pbrook | INSN(divl, 4c40, ffc0, CF_ISA_A);
|
2876 | 0402f767 | pbrook | INSN(sats, 4c80, fff8, CF_ISA_B);
|
2877 | 0402f767 | pbrook | INSN(trap, 4e40, fff0, CF_ISA_A);
|
2878 | 0402f767 | pbrook | INSN(link, 4e50, fff8, CF_ISA_A);
|
2879 | 0402f767 | pbrook | INSN(unlk, 4e58, fff8, CF_ISA_A);
|
2880 | 20dcee94 | pbrook | INSN(move_to_usp, 4e60, fff8, USP);
|
2881 | 20dcee94 | pbrook | INSN(move_from_usp, 4e68, fff8, USP);
|
2882 | 0402f767 | pbrook | INSN(nop, 4e71, ffff, CF_ISA_A);
|
2883 | 0402f767 | pbrook | INSN(stop, 4e72, ffff, CF_ISA_A);
|
2884 | 0402f767 | pbrook | INSN(rte, 4e73, ffff, CF_ISA_A);
|
2885 | 0402f767 | pbrook | INSN(rts, 4e75, ffff, CF_ISA_A);
|
2886 | 0402f767 | pbrook | INSN(movec, 4e7b, ffff, CF_ISA_A);
|
2887 | 0402f767 | pbrook | INSN(jump, 4e80, ffc0, CF_ISA_A);
|
2888 | 0402f767 | pbrook | INSN(jump, 4ec0, ffc0, CF_ISA_A);
|
2889 | 0402f767 | pbrook | INSN(addsubq, 5180, f1c0, CF_ISA_A);
|
2890 | 0402f767 | pbrook | INSN(scc, 50c0, f0f8, CF_ISA_A);
|
2891 | 0402f767 | pbrook | INSN(addsubq, 5080, f1c0, CF_ISA_A);
|
2892 | 0402f767 | pbrook | INSN(tpf, 51f8, fff8, CF_ISA_A); |
2893 | d315c888 | pbrook | |
2894 | d315c888 | pbrook | /* Branch instructions. */
|
2895 | 0402f767 | pbrook | INSN(branch, 6000, f000, CF_ISA_A);
|
2896 | d315c888 | pbrook | /* Disable long branch instructions, then add back the ones we want. */
|
2897 | d315c888 | pbrook | INSN(undef, 60ff, f0ff, CF_ISA_A); /* All long branches. */ |
2898 | d315c888 | pbrook | INSN(branch, 60ff, f0ff, CF_ISA_B); |
2899 | d315c888 | pbrook | INSN(undef, 60ff, ffff, CF_ISA_B); /* bra.l */ |
2900 | d315c888 | pbrook | INSN(branch, 60ff, ffff, BRAL); |
2901 | d315c888 | pbrook | |
2902 | 0402f767 | pbrook | INSN(moveq, 7000, f100, CF_ISA_A);
|
2903 | 0402f767 | pbrook | INSN(mvzs, 7100, f100, CF_ISA_B);
|
2904 | 0402f767 | pbrook | INSN(or, 8000, f000, CF_ISA_A);
|
2905 | 0402f767 | pbrook | INSN(divw, 80c0, f0c0, CF_ISA_A);
|
2906 | 0402f767 | pbrook | INSN(addsub, 9000, f000, CF_ISA_A);
|
2907 | 0402f767 | pbrook | INSN(subx, 9180, f1f8, CF_ISA_A);
|
2908 | 0402f767 | pbrook | INSN(suba, 91c0, f1c0, CF_ISA_A);
|
2909 | acf930aa | pbrook | |
2910 | 0402f767 | pbrook | INSN(undef_mac, a000, f000, CF_ISA_A); |
2911 | acf930aa | pbrook | INSN(mac, a000, f100, CF_EMAC); |
2912 | acf930aa | pbrook | INSN(from_mac, a180, f9b0, CF_EMAC); |
2913 | acf930aa | pbrook | INSN(move_mac, a110, f9fc, CF_EMAC); |
2914 | acf930aa | pbrook | INSN(from_macsr,a980, f9f0, CF_EMAC); |
2915 | acf930aa | pbrook | INSN(from_mask, ad80, fff0, CF_EMAC); |
2916 | acf930aa | pbrook | INSN(from_mext, ab80, fbf0, CF_EMAC); |
2917 | acf930aa | pbrook | INSN(macsr_to_ccr, a9c0, ffff, CF_EMAC); |
2918 | acf930aa | pbrook | INSN(to_mac, a100, f9c0, CF_EMAC); |
2919 | acf930aa | pbrook | INSN(to_macsr, a900, ffc0, CF_EMAC); |
2920 | acf930aa | pbrook | INSN(to_mext, ab00, fbc0, CF_EMAC); |
2921 | acf930aa | pbrook | INSN(to_mask, ad00, ffc0, CF_EMAC); |
2922 | acf930aa | pbrook | |
2923 | 0402f767 | pbrook | INSN(mov3q, a140, f1c0, CF_ISA_B); |
2924 | 0402f767 | pbrook | INSN(cmp, b000, f1c0, CF_ISA_B); /* cmp.b */
|
2925 | 0402f767 | pbrook | INSN(cmp, b040, f1c0, CF_ISA_B); /* cmp.w */
|
2926 | 0402f767 | pbrook | INSN(cmpa, b0c0, f1c0, CF_ISA_B); /* cmpa.w */
|
2927 | 0402f767 | pbrook | INSN(cmp, b080, f1c0, CF_ISA_A); |
2928 | 0402f767 | pbrook | INSN(cmpa, b1c0, f1c0, CF_ISA_A); |
2929 | 0402f767 | pbrook | INSN(eor, b180, f1c0, CF_ISA_A); |
2930 | 0402f767 | pbrook | INSN(and, c000, f000, CF_ISA_A); |
2931 | 0402f767 | pbrook | INSN(mulw, c0c0, f0c0, CF_ISA_A); |
2932 | 0402f767 | pbrook | INSN(addsub, d000, f000, CF_ISA_A); |
2933 | 0402f767 | pbrook | INSN(addx, d180, f1f8, CF_ISA_A); |
2934 | 0402f767 | pbrook | INSN(adda, d1c0, f1c0, CF_ISA_A); |
2935 | 0402f767 | pbrook | INSN(shift_im, e080, f0f0, CF_ISA_A); |
2936 | 0402f767 | pbrook | INSN(shift_reg, e0a0, f0f0, CF_ISA_A); |
2937 | 0402f767 | pbrook | INSN(undef_fpu, f000, f000, CF_ISA_A); |
2938 | e6e5906b | pbrook | INSN(fpu, f200, ffc0, CF_FPU); |
2939 | e6e5906b | pbrook | INSN(fbcc, f280, ffc0, CF_FPU); |
2940 | 0633879f | pbrook | INSN(frestore, f340, ffc0, CF_FPU); |
2941 | 0633879f | pbrook | INSN(fsave, f340, ffc0, CF_FPU); |
2942 | 0402f767 | pbrook | INSN(intouch, f340, ffc0, CF_ISA_A); |
2943 | 0402f767 | pbrook | INSN(cpushl, f428, ff38, CF_ISA_A); |
2944 | 0402f767 | pbrook | INSN(wddata, fb00, ff00, CF_ISA_A); |
2945 | 0402f767 | pbrook | INSN(wdebug, fbc0, ffc0, CF_ISA_A); |
2946 | e6e5906b | pbrook | #undef INSN
|
2947 | e6e5906b | pbrook | } |
2948 | e6e5906b | pbrook | |
2949 | e6e5906b | pbrook | /* ??? Some of this implementation is not exception safe. We should always
|
2950 | e6e5906b | pbrook | write back the result to memory before setting the condition codes. */
|
2951 | e6e5906b | pbrook | static void disas_m68k_insn(CPUState * env, DisasContext *s) |
2952 | e6e5906b | pbrook | { |
2953 | e6e5906b | pbrook | uint16_t insn; |
2954 | e6e5906b | pbrook | |
2955 | 0633879f | pbrook | insn = lduw_code(s->pc); |
2956 | e6e5906b | pbrook | s->pc += 2;
|
2957 | e6e5906b | pbrook | |
2958 | e6e5906b | pbrook | opcode_table[insn](s, insn); |
2959 | e6e5906b | pbrook | } |
2960 | e6e5906b | pbrook | |
2961 | e6e5906b | pbrook | /* generate intermediate code for basic block 'tb'. */
|
2962 | 2cfc5f17 | ths | static inline void |
2963 | 820e00f2 | ths | gen_intermediate_code_internal(CPUState *env, TranslationBlock *tb, |
2964 | 820e00f2 | ths | int search_pc)
|
2965 | e6e5906b | pbrook | { |
2966 | e6e5906b | pbrook | DisasContext dc1, *dc = &dc1; |
2967 | e6e5906b | pbrook | uint16_t *gen_opc_end; |
2968 | a1d1bb31 | aliguori | CPUBreakpoint *bp; |
2969 | e6e5906b | pbrook | int j, lj;
|
2970 | e6e5906b | pbrook | target_ulong pc_start; |
2971 | e6e5906b | pbrook | int pc_offset;
|
2972 | e6e5906b | pbrook | int last_cc_op;
|
2973 | 2e70f6ef | pbrook | int num_insns;
|
2974 | 2e70f6ef | pbrook | int max_insns;
|
2975 | e6e5906b | pbrook | |
2976 | e6e5906b | pbrook | /* generate intermediate code */
|
2977 | e6e5906b | pbrook | pc_start = tb->pc; |
2978 | 3b46e624 | ths | |
2979 | e6e5906b | pbrook | dc->tb = tb; |
2980 | e6e5906b | pbrook | |
2981 | e6e5906b | pbrook | gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; |
2982 | e6e5906b | pbrook | |
2983 | e6dbd3b3 | pbrook | dc->env = env; |
2984 | e6e5906b | pbrook | dc->is_jmp = DISAS_NEXT; |
2985 | e6e5906b | pbrook | dc->pc = pc_start; |
2986 | e6e5906b | pbrook | dc->cc_op = CC_OP_DYNAMIC; |
2987 | e6e5906b | pbrook | dc->singlestep_enabled = env->singlestep_enabled; |
2988 | e6e5906b | pbrook | dc->fpcr = env->fpcr; |
2989 | 0633879f | pbrook | dc->user = (env->sr & SR_S) == 0;
|
2990 | c9bac22c | pbrook | dc->is_mem = 0;
|
2991 | a7812ae4 | pbrook | dc->done_mac = 0;
|
2992 | e6e5906b | pbrook | lj = -1;
|
2993 | 2e70f6ef | pbrook | num_insns = 0;
|
2994 | 2e70f6ef | pbrook | max_insns = tb->cflags & CF_COUNT_MASK; |
2995 | 2e70f6ef | pbrook | if (max_insns == 0) |
2996 | 2e70f6ef | pbrook | max_insns = CF_COUNT_MASK; |
2997 | 2e70f6ef | pbrook | |
2998 | 2e70f6ef | pbrook | gen_icount_start(); |
2999 | e6e5906b | pbrook | do {
|
3000 | e6e5906b | pbrook | pc_offset = dc->pc - pc_start; |
3001 | e6e5906b | pbrook | gen_throws_exception = NULL;
|
3002 | 72cf2d4f | Blue Swirl | if (unlikely(!QTAILQ_EMPTY(&env->breakpoints))) {
|
3003 | 72cf2d4f | Blue Swirl | QTAILQ_FOREACH(bp, &env->breakpoints, entry) { |
3004 | a1d1bb31 | aliguori | if (bp->pc == dc->pc) {
|
3005 | e6e5906b | pbrook | gen_exception(dc, dc->pc, EXCP_DEBUG); |
3006 | e6e5906b | pbrook | dc->is_jmp = DISAS_JUMP; |
3007 | e6e5906b | pbrook | break;
|
3008 | e6e5906b | pbrook | } |
3009 | e6e5906b | pbrook | } |
3010 | e6e5906b | pbrook | if (dc->is_jmp)
|
3011 | e6e5906b | pbrook | break;
|
3012 | e6e5906b | pbrook | } |
3013 | e6e5906b | pbrook | if (search_pc) {
|
3014 | e6e5906b | pbrook | j = gen_opc_ptr - gen_opc_buf; |
3015 | e6e5906b | pbrook | if (lj < j) {
|
3016 | e6e5906b | pbrook | lj++; |
3017 | e6e5906b | pbrook | while (lj < j)
|
3018 | e6e5906b | pbrook | gen_opc_instr_start[lj++] = 0;
|
3019 | e6e5906b | pbrook | } |
3020 | e6e5906b | pbrook | gen_opc_pc[lj] = dc->pc; |
3021 | e6e5906b | pbrook | gen_opc_instr_start[lj] = 1;
|
3022 | 2e70f6ef | pbrook | gen_opc_icount[lj] = num_insns; |
3023 | e6e5906b | pbrook | } |
3024 | 2e70f6ef | pbrook | if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO)) |
3025 | 2e70f6ef | pbrook | gen_io_start(); |
3026 | e6e5906b | pbrook | last_cc_op = dc->cc_op; |
3027 | 510ff0b7 | pbrook | dc->insn_pc = dc->pc; |
3028 | e6e5906b | pbrook | disas_m68k_insn(env, dc); |
3029 | 2e70f6ef | pbrook | num_insns++; |
3030 | e6e5906b | pbrook | } while (!dc->is_jmp && gen_opc_ptr < gen_opc_end &&
|
3031 | e6e5906b | pbrook | !env->singlestep_enabled && |
3032 | 1b530a6d | aurel32 | !singlestep && |
3033 | 2e70f6ef | pbrook | (pc_offset) < (TARGET_PAGE_SIZE - 32) &&
|
3034 | 2e70f6ef | pbrook | num_insns < max_insns); |
3035 | e6e5906b | pbrook | |
3036 | 2e70f6ef | pbrook | if (tb->cflags & CF_LAST_IO)
|
3037 | 2e70f6ef | pbrook | gen_io_end(); |
3038 | 551bd27f | ths | if (unlikely(env->singlestep_enabled)) {
|
3039 | e6e5906b | pbrook | /* Make sure the pc is updated, and raise a debug exception. */
|
3040 | e6e5906b | pbrook | if (!dc->is_jmp) {
|
3041 | e6e5906b | pbrook | gen_flush_cc_op(dc); |
3042 | e1f3808e | pbrook | tcg_gen_movi_i32(QREG_PC, dc->pc); |
3043 | e6e5906b | pbrook | } |
3044 | e1f3808e | pbrook | gen_helper_raise_exception(tcg_const_i32(EXCP_DEBUG)); |
3045 | e6e5906b | pbrook | } else {
|
3046 | e6e5906b | pbrook | switch(dc->is_jmp) {
|
3047 | e6e5906b | pbrook | case DISAS_NEXT:
|
3048 | e6e5906b | pbrook | gen_flush_cc_op(dc); |
3049 | e6e5906b | pbrook | gen_jmp_tb(dc, 0, dc->pc);
|
3050 | e6e5906b | pbrook | break;
|
3051 | e6e5906b | pbrook | default:
|
3052 | e6e5906b | pbrook | case DISAS_JUMP:
|
3053 | e6e5906b | pbrook | case DISAS_UPDATE:
|
3054 | e6e5906b | pbrook | gen_flush_cc_op(dc); |
3055 | e6e5906b | pbrook | /* indicate that the hash table must be used to find the next TB */
|
3056 | 57fec1fe | bellard | tcg_gen_exit_tb(0);
|
3057 | e6e5906b | pbrook | break;
|
3058 | e6e5906b | pbrook | case DISAS_TB_JUMP:
|
3059 | e6e5906b | pbrook | /* nothing more to generate */
|
3060 | e6e5906b | pbrook | break;
|
3061 | e6e5906b | pbrook | } |
3062 | e6e5906b | pbrook | } |
3063 | 2e70f6ef | pbrook | gen_icount_end(tb, num_insns); |
3064 | e6e5906b | pbrook | *gen_opc_ptr = INDEX_op_end; |
3065 | e6e5906b | pbrook | |
3066 | e6e5906b | pbrook | #ifdef DEBUG_DISAS
|
3067 | 8fec2b8c | aliguori | if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
|
3068 | 93fcfe39 | aliguori | qemu_log("----------------\n");
|
3069 | 93fcfe39 | aliguori | qemu_log("IN: %s\n", lookup_symbol(pc_start));
|
3070 | 93fcfe39 | aliguori | log_target_disas(pc_start, dc->pc - pc_start, 0);
|
3071 | 93fcfe39 | aliguori | qemu_log("\n");
|
3072 | e6e5906b | pbrook | } |
3073 | e6e5906b | pbrook | #endif
|
3074 | e6e5906b | pbrook | if (search_pc) {
|
3075 | e6e5906b | pbrook | j = gen_opc_ptr - gen_opc_buf; |
3076 | e6e5906b | pbrook | lj++; |
3077 | e6e5906b | pbrook | while (lj <= j)
|
3078 | e6e5906b | pbrook | gen_opc_instr_start[lj++] = 0;
|
3079 | e6e5906b | pbrook | } else {
|
3080 | e6e5906b | pbrook | tb->size = dc->pc - pc_start; |
3081 | 2e70f6ef | pbrook | tb->icount = num_insns; |
3082 | e6e5906b | pbrook | } |
3083 | e6e5906b | pbrook | |
3084 | e6e5906b | pbrook | //optimize_flags();
|
3085 | e6e5906b | pbrook | //expand_target_qops();
|
3086 | e6e5906b | pbrook | } |
3087 | e6e5906b | pbrook | |
3088 | 2cfc5f17 | ths | void gen_intermediate_code(CPUState *env, TranslationBlock *tb)
|
3089 | e6e5906b | pbrook | { |
3090 | 2cfc5f17 | ths | gen_intermediate_code_internal(env, tb, 0);
|
3091 | e6e5906b | pbrook | } |
3092 | e6e5906b | pbrook | |
3093 | 2cfc5f17 | ths | void gen_intermediate_code_pc(CPUState *env, TranslationBlock *tb)
|
3094 | e6e5906b | pbrook | { |
3095 | 2cfc5f17 | ths | gen_intermediate_code_internal(env, tb, 1);
|
3096 | e6e5906b | pbrook | } |
3097 | e6e5906b | pbrook | |
3098 | 5fafdf24 | ths | void cpu_dump_state(CPUState *env, FILE *f,
|
3099 | e6e5906b | pbrook | int (*cpu_fprintf)(FILE *f, const char *fmt, ...), |
3100 | e6e5906b | pbrook | int flags)
|
3101 | e6e5906b | pbrook | { |
3102 | e6e5906b | pbrook | int i;
|
3103 | e6e5906b | pbrook | uint16_t sr; |
3104 | e6e5906b | pbrook | CPU_DoubleU u; |
3105 | e6e5906b | pbrook | for (i = 0; i < 8; i++) |
3106 | e6e5906b | pbrook | { |
3107 | e6e5906b | pbrook | u.d = env->fregs[i]; |
3108 | e6e5906b | pbrook | cpu_fprintf (f, "D%d = %08x A%d = %08x F%d = %08x%08x (%12g)\n",
|
3109 | e6e5906b | pbrook | i, env->dregs[i], i, env->aregs[i], |
3110 | 8fc7cc58 | pbrook | i, u.l.upper, u.l.lower, *(double *)&u.d);
|
3111 | e6e5906b | pbrook | } |
3112 | e6e5906b | pbrook | cpu_fprintf (f, "PC = %08x ", env->pc);
|
3113 | e6e5906b | pbrook | sr = env->sr; |
3114 | e6e5906b | pbrook | cpu_fprintf (f, "SR = %04x %c%c%c%c%c ", sr, (sr & 0x10) ? 'X' : '-', |
3115 | e6e5906b | pbrook | (sr & CCF_N) ? 'N' : '-', (sr & CCF_Z) ? 'Z' : '-', |
3116 | e6e5906b | pbrook | (sr & CCF_V) ? 'V' : '-', (sr & CCF_C) ? 'C' : '-'); |
3117 | 8fc7cc58 | pbrook | cpu_fprintf (f, "FPRESULT = %12g\n", *(double *)&env->fp_result); |
3118 | e6e5906b | pbrook | } |
3119 | e6e5906b | pbrook | |
3120 | d2856f1a | aurel32 | void gen_pc_load(CPUState *env, TranslationBlock *tb,
|
3121 | d2856f1a | aurel32 | unsigned long searched_pc, int pc_pos, void *puc) |
3122 | d2856f1a | aurel32 | { |
3123 | d2856f1a | aurel32 | env->pc = gen_opc_pc[pc_pos]; |
3124 | d2856f1a | aurel32 | } |