]>
Commit | Line | Data |
---|---|---|
10ec5117 AG |
1 | /* |
2 | * S/390 translation | |
3 | * | |
4 | * Copyright (c) 2009 Ulrich Hecht | |
e023e832 | 5 | * Copyright (c) 2010 Alexander Graf |
10ec5117 AG |
6 | * |
7 | * This library is free software; you can redistribute it and/or | |
8 | * modify it under the terms of the GNU Lesser General Public | |
9 | * License as published by the Free Software Foundation; either | |
10 | * version 2 of the License, or (at your option) any later version. | |
11 | * | |
12 | * This library is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * Lesser General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU Lesser General Public | |
70539e18 | 18 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. |
10ec5117 | 19 | */ |
e023e832 | 20 | |
e023e832 AG |
21 | /* #define DEBUG_INLINE_BRANCHES */ |
22 | #define S390X_DEBUG_DISAS | |
23 | /* #define S390X_DEBUG_DISAS_VERBOSE */ | |
24 | ||
25 | #ifdef S390X_DEBUG_DISAS_VERBOSE | |
26 | # define LOG_DISAS(...) qemu_log(__VA_ARGS__) | |
27 | #else | |
28 | # define LOG_DISAS(...) do { } while (0) | |
29 | #endif | |
10ec5117 AG |
30 | |
31 | #include "cpu.h" | |
76cad711 | 32 | #include "disas/disas.h" |
10ec5117 | 33 | #include "tcg-op.h" |
1de7afc9 | 34 | #include "qemu/log.h" |
58a9e35b | 35 | #include "qemu/host-utils.h" |
10ec5117 | 36 | |
e023e832 AG |
37 | /* global register indexes */ |
38 | static TCGv_ptr cpu_env; | |
39 | ||
022c62cb | 40 | #include "exec/gen-icount.h" |
3208afbe | 41 | #include "helper.h" |
e023e832 | 42 | #define GEN_HELPER 1 |
3208afbe | 43 | #include "helper.h" |
e023e832 | 44 | |
ad044d09 RH |
45 | |
46 | /* Information that (most) every instruction needs to manipulate. */ | |
e023e832 | 47 | typedef struct DisasContext DisasContext; |
ad044d09 RH |
48 | typedef struct DisasInsn DisasInsn; |
49 | typedef struct DisasFields DisasFields; | |
50 | ||
e023e832 | 51 | struct DisasContext { |
e023e832 | 52 | struct TranslationBlock *tb; |
ad044d09 RH |
53 | const DisasInsn *insn; |
54 | DisasFields *fields; | |
55 | uint64_t pc, next_pc; | |
56 | enum cc_op cc_op; | |
57 | bool singlestep_enabled; | |
e023e832 AG |
58 | }; |
59 | ||
3fde06f5 RH |
60 | /* Information carried about a condition to be evaluated. */ |
61 | typedef struct { | |
62 | TCGCond cond:8; | |
63 | bool is_64; | |
64 | bool g1; | |
65 | bool g2; | |
66 | union { | |
67 | struct { TCGv_i64 a, b; } s64; | |
68 | struct { TCGv_i32 a, b; } s32; | |
69 | } u; | |
70 | } DisasCompare; | |
71 | ||
e023e832 AG |
72 | #define DISAS_EXCP 4 |
73 | ||
e023e832 AG |
74 | #ifdef DEBUG_INLINE_BRANCHES |
75 | static uint64_t inline_branch_hit[CC_OP_MAX]; | |
76 | static uint64_t inline_branch_miss[CC_OP_MAX]; | |
77 | #endif | |
78 | ||
4f3adfb2 | 79 | static uint64_t pc_to_link_info(DisasContext *s, uint64_t pc) |
e023e832 AG |
80 | { |
81 | if (!(s->tb->flags & FLAG_MASK_64)) { | |
82 | if (s->tb->flags & FLAG_MASK_32) { | |
83 | return pc | 0x80000000; | |
84 | } | |
85 | } | |
86 | return pc; | |
87 | } | |
88 | ||
a4e3ad19 | 89 | void cpu_dump_state(CPUS390XState *env, FILE *f, fprintf_function cpu_fprintf, |
10ec5117 AG |
90 | int flags) |
91 | { | |
92 | int i; | |
e023e832 | 93 | |
d885bdd4 RH |
94 | if (env->cc_op > 3) { |
95 | cpu_fprintf(f, "PSW=mask %016" PRIx64 " addr %016" PRIx64 " cc %15s\n", | |
96 | env->psw.mask, env->psw.addr, cc_name(env->cc_op)); | |
97 | } else { | |
98 | cpu_fprintf(f, "PSW=mask %016" PRIx64 " addr %016" PRIx64 " cc %02x\n", | |
99 | env->psw.mask, env->psw.addr, env->cc_op); | |
100 | } | |
101 | ||
10ec5117 | 102 | for (i = 0; i < 16; i++) { |
e023e832 | 103 | cpu_fprintf(f, "R%02d=%016" PRIx64, i, env->regs[i]); |
10ec5117 AG |
104 | if ((i % 4) == 3) { |
105 | cpu_fprintf(f, "\n"); | |
106 | } else { | |
107 | cpu_fprintf(f, " "); | |
108 | } | |
109 | } | |
e023e832 | 110 | |
10ec5117 | 111 | for (i = 0; i < 16; i++) { |
431253c2 | 112 | cpu_fprintf(f, "F%02d=%016" PRIx64, i, env->fregs[i].ll); |
10ec5117 AG |
113 | if ((i % 4) == 3) { |
114 | cpu_fprintf(f, "\n"); | |
115 | } else { | |
116 | cpu_fprintf(f, " "); | |
117 | } | |
118 | } | |
e023e832 | 119 | |
e023e832 AG |
120 | #ifndef CONFIG_USER_ONLY |
121 | for (i = 0; i < 16; i++) { | |
122 | cpu_fprintf(f, "C%02d=%016" PRIx64, i, env->cregs[i]); | |
123 | if ((i % 4) == 3) { | |
124 | cpu_fprintf(f, "\n"); | |
125 | } else { | |
126 | cpu_fprintf(f, " "); | |
127 | } | |
128 | } | |
129 | #endif | |
130 | ||
e023e832 AG |
131 | #ifdef DEBUG_INLINE_BRANCHES |
132 | for (i = 0; i < CC_OP_MAX; i++) { | |
133 | cpu_fprintf(f, " %15s = %10ld\t%10ld\n", cc_name(i), | |
134 | inline_branch_miss[i], inline_branch_hit[i]); | |
135 | } | |
136 | #endif | |
d885bdd4 RH |
137 | |
138 | cpu_fprintf(f, "\n"); | |
10ec5117 AG |
139 | } |
140 | ||
e023e832 AG |
141 | static TCGv_i64 psw_addr; |
142 | static TCGv_i64 psw_mask; | |
143 | ||
144 | static TCGv_i32 cc_op; | |
145 | static TCGv_i64 cc_src; | |
146 | static TCGv_i64 cc_dst; | |
147 | static TCGv_i64 cc_vr; | |
148 | ||
431253c2 | 149 | static char cpu_reg_names[32][4]; |
e023e832 | 150 | static TCGv_i64 regs[16]; |
431253c2 | 151 | static TCGv_i64 fregs[16]; |
e023e832 AG |
152 | |
153 | static uint8_t gen_opc_cc_op[OPC_BUF_SIZE]; | |
154 | ||
d5a43964 AG |
155 | void s390x_translate_init(void) |
156 | { | |
e023e832 | 157 | int i; |
e023e832 AG |
158 | |
159 | cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env"); | |
431253c2 RH |
160 | psw_addr = tcg_global_mem_new_i64(TCG_AREG0, |
161 | offsetof(CPUS390XState, psw.addr), | |
e023e832 | 162 | "psw_addr"); |
431253c2 RH |
163 | psw_mask = tcg_global_mem_new_i64(TCG_AREG0, |
164 | offsetof(CPUS390XState, psw.mask), | |
e023e832 AG |
165 | "psw_mask"); |
166 | ||
a4e3ad19 | 167 | cc_op = tcg_global_mem_new_i32(TCG_AREG0, offsetof(CPUS390XState, cc_op), |
e023e832 | 168 | "cc_op"); |
a4e3ad19 | 169 | cc_src = tcg_global_mem_new_i64(TCG_AREG0, offsetof(CPUS390XState, cc_src), |
e023e832 | 170 | "cc_src"); |
a4e3ad19 | 171 | cc_dst = tcg_global_mem_new_i64(TCG_AREG0, offsetof(CPUS390XState, cc_dst), |
e023e832 | 172 | "cc_dst"); |
a4e3ad19 | 173 | cc_vr = tcg_global_mem_new_i64(TCG_AREG0, offsetof(CPUS390XState, cc_vr), |
e023e832 AG |
174 | "cc_vr"); |
175 | ||
e023e832 | 176 | for (i = 0; i < 16; i++) { |
431253c2 | 177 | snprintf(cpu_reg_names[i], sizeof(cpu_reg_names[0]), "r%d", i); |
e023e832 | 178 | regs[i] = tcg_global_mem_new(TCG_AREG0, |
431253c2 RH |
179 | offsetof(CPUS390XState, regs[i]), |
180 | cpu_reg_names[i]); | |
181 | } | |
182 | ||
183 | for (i = 0; i < 16; i++) { | |
184 | snprintf(cpu_reg_names[i + 16], sizeof(cpu_reg_names[0]), "f%d", i); | |
185 | fregs[i] = tcg_global_mem_new(TCG_AREG0, | |
186 | offsetof(CPUS390XState, fregs[i].d), | |
187 | cpu_reg_names[i + 16]); | |
e023e832 | 188 | } |
7e68da2a RH |
189 | |
190 | /* register helpers */ | |
191 | #define GEN_HELPER 2 | |
192 | #include "helper.h" | |
d5a43964 AG |
193 | } |
194 | ||
4f3adfb2 | 195 | static TCGv_i64 load_reg(int reg) |
10ec5117 | 196 | { |
e023e832 AG |
197 | TCGv_i64 r = tcg_temp_new_i64(); |
198 | tcg_gen_mov_i64(r, regs[reg]); | |
199 | return r; | |
10ec5117 AG |
200 | } |
201 | ||
4f3adfb2 | 202 | static TCGv_i64 load_freg32_i64(int reg) |
d764a8d1 RH |
203 | { |
204 | TCGv_i64 r = tcg_temp_new_i64(); | |
205 | tcg_gen_shri_i64(r, fregs[reg], 32); | |
206 | return r; | |
207 | } | |
208 | ||
4f3adfb2 | 209 | static void store_reg(int reg, TCGv_i64 v) |
e023e832 AG |
210 | { |
211 | tcg_gen_mov_i64(regs[reg], v); | |
212 | } | |
213 | ||
4f3adfb2 | 214 | static void store_freg(int reg, TCGv_i64 v) |
e023e832 | 215 | { |
431253c2 | 216 | tcg_gen_mov_i64(fregs[reg], v); |
e023e832 AG |
217 | } |
218 | ||
4f3adfb2 | 219 | static void store_reg32_i64(int reg, TCGv_i64 v) |
e023e832 AG |
220 | { |
221 | /* 32 bit register writes keep the upper half */ | |
e023e832 | 222 | tcg_gen_deposit_i64(regs[reg], regs[reg], v, 0, 32); |
e023e832 AG |
223 | } |
224 | ||
4f3adfb2 | 225 | static void store_reg32h_i64(int reg, TCGv_i64 v) |
77f8d6c3 RH |
226 | { |
227 | tcg_gen_deposit_i64(regs[reg], regs[reg], v, 32, 32); | |
228 | } | |
229 | ||
4f3adfb2 | 230 | static void store_freg32_i64(int reg, TCGv_i64 v) |
d764a8d1 RH |
231 | { |
232 | tcg_gen_deposit_i64(fregs[reg], fregs[reg], v, 32, 32); | |
233 | } | |
234 | ||
4f3adfb2 | 235 | static void return_low128(TCGv_i64 dest) |
1ac5889f RH |
236 | { |
237 | tcg_gen_ld_i64(dest, cpu_env, offsetof(CPUS390XState, retxl)); | |
238 | } | |
239 | ||
4f3adfb2 | 240 | static void update_psw_addr(DisasContext *s) |
e023e832 AG |
241 | { |
242 | /* psw.addr */ | |
243 | tcg_gen_movi_i64(psw_addr, s->pc); | |
244 | } | |
245 | ||
7a6c7067 RH |
246 | static void update_cc_op(DisasContext *s) |
247 | { | |
248 | if (s->cc_op != CC_OP_DYNAMIC && s->cc_op != CC_OP_STATIC) { | |
249 | tcg_gen_movi_i32(cc_op, s->cc_op); | |
250 | } | |
251 | } | |
252 | ||
4f3adfb2 | 253 | static void potential_page_fault(DisasContext *s) |
e023e832 | 254 | { |
e023e832 | 255 | update_psw_addr(s); |
7a6c7067 | 256 | update_cc_op(s); |
e023e832 AG |
257 | } |
258 | ||
46ee3d84 | 259 | static inline uint64_t ld_code2(CPUS390XState *env, uint64_t pc) |
e023e832 | 260 | { |
46ee3d84 | 261 | return (uint64_t)cpu_lduw_code(env, pc); |
e023e832 AG |
262 | } |
263 | ||
46ee3d84 | 264 | static inline uint64_t ld_code4(CPUS390XState *env, uint64_t pc) |
e023e832 | 265 | { |
ad044d09 | 266 | return (uint64_t)(uint32_t)cpu_ldl_code(env, pc); |
e023e832 AG |
267 | } |
268 | ||
46ee3d84 | 269 | static inline uint64_t ld_code6(CPUS390XState *env, uint64_t pc) |
e023e832 | 270 | { |
ad044d09 | 271 | return (ld_code2(env, pc) << 32) | ld_code4(env, pc + 2); |
e023e832 AG |
272 | } |
273 | ||
4f3adfb2 | 274 | static int get_mem_index(DisasContext *s) |
e023e832 AG |
275 | { |
276 | switch (s->tb->flags & FLAG_MASK_ASC) { | |
277 | case PSW_ASC_PRIMARY >> 32: | |
278 | return 0; | |
279 | case PSW_ASC_SECONDARY >> 32: | |
280 | return 1; | |
281 | case PSW_ASC_HOME >> 32: | |
282 | return 2; | |
283 | default: | |
284 | tcg_abort(); | |
285 | break; | |
286 | } | |
287 | } | |
288 | ||
d5a103cd | 289 | static void gen_exception(int excp) |
e023e832 | 290 | { |
d5a103cd | 291 | TCGv_i32 tmp = tcg_const_i32(excp); |
089f5c06 | 292 | gen_helper_exception(cpu_env, tmp); |
e023e832 | 293 | tcg_temp_free_i32(tmp); |
e023e832 AG |
294 | } |
295 | ||
d5a103cd | 296 | static void gen_program_exception(DisasContext *s, int code) |
e023e832 AG |
297 | { |
298 | TCGv_i32 tmp; | |
299 | ||
d5a103cd | 300 | /* Remember what pgm exeption this was. */ |
e023e832 | 301 | tmp = tcg_const_i32(code); |
a4e3ad19 | 302 | tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUS390XState, int_pgm_code)); |
e023e832 AG |
303 | tcg_temp_free_i32(tmp); |
304 | ||
d5a103cd RH |
305 | tmp = tcg_const_i32(s->next_pc - s->pc); |
306 | tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUS390XState, int_pgm_ilen)); | |
e023e832 AG |
307 | tcg_temp_free_i32(tmp); |
308 | ||
d5a103cd RH |
309 | /* Advance past instruction. */ |
310 | s->pc = s->next_pc; | |
e023e832 AG |
311 | update_psw_addr(s); |
312 | ||
d5a103cd | 313 | /* Save off cc. */ |
7a6c7067 | 314 | update_cc_op(s); |
e023e832 | 315 | |
d5a103cd RH |
316 | /* Trigger exception. */ |
317 | gen_exception(EXCP_PGM); | |
e023e832 AG |
318 | } |
319 | ||
d5a103cd | 320 | static inline void gen_illegal_opcode(DisasContext *s) |
e023e832 | 321 | { |
d5a103cd | 322 | gen_program_exception(s, PGM_SPECIFICATION); |
e023e832 AG |
323 | } |
324 | ||
d5a103cd | 325 | static inline void check_privileged(DisasContext *s) |
e023e832 AG |
326 | { |
327 | if (s->tb->flags & (PSW_MASK_PSTATE >> 32)) { | |
d5a103cd | 328 | gen_program_exception(s, PGM_PRIVILEGED); |
e023e832 AG |
329 | } |
330 | } | |
331 | ||
e023e832 AG |
332 | static TCGv_i64 get_address(DisasContext *s, int x2, int b2, int d2) |
333 | { | |
334 | TCGv_i64 tmp; | |
335 | ||
336 | /* 31-bitify the immediate part; register contents are dealt with below */ | |
337 | if (!(s->tb->flags & FLAG_MASK_64)) { | |
338 | d2 &= 0x7fffffffUL; | |
339 | } | |
340 | ||
341 | if (x2) { | |
342 | if (d2) { | |
343 | tmp = tcg_const_i64(d2); | |
344 | tcg_gen_add_i64(tmp, tmp, regs[x2]); | |
345 | } else { | |
346 | tmp = load_reg(x2); | |
347 | } | |
348 | if (b2) { | |
349 | tcg_gen_add_i64(tmp, tmp, regs[b2]); | |
350 | } | |
351 | } else if (b2) { | |
352 | if (d2) { | |
353 | tmp = tcg_const_i64(d2); | |
354 | tcg_gen_add_i64(tmp, tmp, regs[b2]); | |
355 | } else { | |
356 | tmp = load_reg(b2); | |
357 | } | |
358 | } else { | |
359 | tmp = tcg_const_i64(d2); | |
360 | } | |
361 | ||
362 | /* 31-bit mode mask if there are values loaded from registers */ | |
363 | if (!(s->tb->flags & FLAG_MASK_64) && (x2 || b2)) { | |
364 | tcg_gen_andi_i64(tmp, tmp, 0x7fffffffUL); | |
365 | } | |
366 | ||
367 | return tmp; | |
368 | } | |
369 | ||
aa31bf60 | 370 | static inline void gen_op_movi_cc(DisasContext *s, uint32_t val) |
e023e832 AG |
371 | { |
372 | s->cc_op = CC_OP_CONST0 + val; | |
373 | } | |
374 | ||
375 | static void gen_op_update1_cc_i64(DisasContext *s, enum cc_op op, TCGv_i64 dst) | |
376 | { | |
377 | tcg_gen_discard_i64(cc_src); | |
378 | tcg_gen_mov_i64(cc_dst, dst); | |
379 | tcg_gen_discard_i64(cc_vr); | |
380 | s->cc_op = op; | |
381 | } | |
382 | ||
e023e832 AG |
383 | static void gen_op_update2_cc_i64(DisasContext *s, enum cc_op op, TCGv_i64 src, |
384 | TCGv_i64 dst) | |
385 | { | |
386 | tcg_gen_mov_i64(cc_src, src); | |
387 | tcg_gen_mov_i64(cc_dst, dst); | |
388 | tcg_gen_discard_i64(cc_vr); | |
389 | s->cc_op = op; | |
390 | } | |
391 | ||
e023e832 AG |
392 | static void gen_op_update3_cc_i64(DisasContext *s, enum cc_op op, TCGv_i64 src, |
393 | TCGv_i64 dst, TCGv_i64 vr) | |
394 | { | |
395 | tcg_gen_mov_i64(cc_src, src); | |
396 | tcg_gen_mov_i64(cc_dst, dst); | |
397 | tcg_gen_mov_i64(cc_vr, vr); | |
398 | s->cc_op = op; | |
399 | } | |
400 | ||
4f3adfb2 | 401 | static void set_cc_nz_u64(DisasContext *s, TCGv_i64 val) |
e023e832 AG |
402 | { |
403 | gen_op_update1_cc_i64(s, CC_OP_NZ, val); | |
404 | } | |
405 | ||
4f3adfb2 | 406 | static void gen_set_cc_nz_f32(DisasContext *s, TCGv_i64 val) |
68c8bd93 RH |
407 | { |
408 | gen_op_update1_cc_i64(s, CC_OP_NZ_F32, val); | |
409 | } | |
410 | ||
4f3adfb2 | 411 | static void gen_set_cc_nz_f64(DisasContext *s, TCGv_i64 val) |
68c8bd93 RH |
412 | { |
413 | gen_op_update1_cc_i64(s, CC_OP_NZ_F64, val); | |
414 | } | |
415 | ||
4f3adfb2 | 416 | static void gen_set_cc_nz_f128(DisasContext *s, TCGv_i64 vh, TCGv_i64 vl) |
68c8bd93 RH |
417 | { |
418 | gen_op_update2_cc_i64(s, CC_OP_NZ_F128, vh, vl); | |
419 | } | |
420 | ||
e023e832 | 421 | /* CC value is in env->cc_op */ |
4f3adfb2 | 422 | static void set_cc_static(DisasContext *s) |
e023e832 AG |
423 | { |
424 | tcg_gen_discard_i64(cc_src); | |
425 | tcg_gen_discard_i64(cc_dst); | |
426 | tcg_gen_discard_i64(cc_vr); | |
427 | s->cc_op = CC_OP_STATIC; | |
428 | } | |
429 | ||
e023e832 AG |
430 | /* calculates cc into cc_op */ |
431 | static void gen_op_calc_cc(DisasContext *s) | |
432 | { | |
7a6c7067 RH |
433 | TCGv_i32 local_cc_op; |
434 | TCGv_i64 dummy; | |
435 | ||
436 | TCGV_UNUSED_I32(local_cc_op); | |
437 | TCGV_UNUSED_I64(dummy); | |
438 | switch (s->cc_op) { | |
439 | default: | |
440 | dummy = tcg_const_i64(0); | |
441 | /* FALLTHRU */ | |
442 | case CC_OP_ADD_64: | |
443 | case CC_OP_ADDU_64: | |
444 | case CC_OP_ADDC_64: | |
445 | case CC_OP_SUB_64: | |
446 | case CC_OP_SUBU_64: | |
447 | case CC_OP_SUBB_64: | |
448 | case CC_OP_ADD_32: | |
449 | case CC_OP_ADDU_32: | |
450 | case CC_OP_ADDC_32: | |
451 | case CC_OP_SUB_32: | |
452 | case CC_OP_SUBU_32: | |
453 | case CC_OP_SUBB_32: | |
454 | local_cc_op = tcg_const_i32(s->cc_op); | |
455 | break; | |
456 | case CC_OP_CONST0: | |
457 | case CC_OP_CONST1: | |
458 | case CC_OP_CONST2: | |
459 | case CC_OP_CONST3: | |
460 | case CC_OP_STATIC: | |
461 | case CC_OP_DYNAMIC: | |
462 | break; | |
463 | } | |
e023e832 AG |
464 | |
465 | switch (s->cc_op) { | |
466 | case CC_OP_CONST0: | |
467 | case CC_OP_CONST1: | |
468 | case CC_OP_CONST2: | |
469 | case CC_OP_CONST3: | |
470 | /* s->cc_op is the cc value */ | |
471 | tcg_gen_movi_i32(cc_op, s->cc_op - CC_OP_CONST0); | |
472 | break; | |
473 | case CC_OP_STATIC: | |
474 | /* env->cc_op already is the cc value */ | |
475 | break; | |
476 | case CC_OP_NZ: | |
477 | case CC_OP_ABS_64: | |
478 | case CC_OP_NABS_64: | |
479 | case CC_OP_ABS_32: | |
480 | case CC_OP_NABS_32: | |
481 | case CC_OP_LTGT0_32: | |
482 | case CC_OP_LTGT0_64: | |
483 | case CC_OP_COMP_32: | |
484 | case CC_OP_COMP_64: | |
485 | case CC_OP_NZ_F32: | |
486 | case CC_OP_NZ_F64: | |
102bf2c6 | 487 | case CC_OP_FLOGR: |
e023e832 | 488 | /* 1 argument */ |
932385a3 | 489 | gen_helper_calc_cc(cc_op, cpu_env, local_cc_op, dummy, cc_dst, dummy); |
e023e832 AG |
490 | break; |
491 | case CC_OP_ICM: | |
492 | case CC_OP_LTGT_32: | |
493 | case CC_OP_LTGT_64: | |
494 | case CC_OP_LTUGTU_32: | |
495 | case CC_OP_LTUGTU_64: | |
496 | case CC_OP_TM_32: | |
497 | case CC_OP_TM_64: | |
cbe24bfa RH |
498 | case CC_OP_SLA_32: |
499 | case CC_OP_SLA_64: | |
587626f8 | 500 | case CC_OP_NZ_F128: |
e023e832 | 501 | /* 2 arguments */ |
932385a3 | 502 | gen_helper_calc_cc(cc_op, cpu_env, local_cc_op, cc_src, cc_dst, dummy); |
e023e832 AG |
503 | break; |
504 | case CC_OP_ADD_64: | |
505 | case CC_OP_ADDU_64: | |
4e4bb438 | 506 | case CC_OP_ADDC_64: |
e023e832 AG |
507 | case CC_OP_SUB_64: |
508 | case CC_OP_SUBU_64: | |
4e4bb438 | 509 | case CC_OP_SUBB_64: |
e023e832 AG |
510 | case CC_OP_ADD_32: |
511 | case CC_OP_ADDU_32: | |
4e4bb438 | 512 | case CC_OP_ADDC_32: |
e023e832 AG |
513 | case CC_OP_SUB_32: |
514 | case CC_OP_SUBU_32: | |
4e4bb438 | 515 | case CC_OP_SUBB_32: |
e023e832 | 516 | /* 3 arguments */ |
932385a3 | 517 | gen_helper_calc_cc(cc_op, cpu_env, local_cc_op, cc_src, cc_dst, cc_vr); |
e023e832 AG |
518 | break; |
519 | case CC_OP_DYNAMIC: | |
520 | /* unknown operation - assume 3 arguments and cc_op in env */ | |
932385a3 | 521 | gen_helper_calc_cc(cc_op, cpu_env, cc_op, cc_src, cc_dst, cc_vr); |
e023e832 AG |
522 | break; |
523 | default: | |
524 | tcg_abort(); | |
525 | } | |
526 | ||
7a6c7067 RH |
527 | if (!TCGV_IS_UNUSED_I32(local_cc_op)) { |
528 | tcg_temp_free_i32(local_cc_op); | |
529 | } | |
530 | if (!TCGV_IS_UNUSED_I64(dummy)) { | |
531 | tcg_temp_free_i64(dummy); | |
532 | } | |
e023e832 AG |
533 | |
534 | /* We now have cc in cc_op as constant */ | |
535 | set_cc_static(s); | |
536 | } | |
537 | ||
8ac33cdb | 538 | static int use_goto_tb(DisasContext *s, uint64_t dest) |
e023e832 | 539 | { |
8ac33cdb RH |
540 | /* NOTE: we handle the case where the TB spans two pages here */ |
541 | return (((dest & TARGET_PAGE_MASK) == (s->tb->pc & TARGET_PAGE_MASK) | |
542 | || (dest & TARGET_PAGE_MASK) == ((s->pc - 1) & TARGET_PAGE_MASK)) | |
543 | && !s->singlestep_enabled | |
544 | && !(s->tb->cflags & CF_LAST_IO)); | |
545 | } | |
e023e832 | 546 | |
4f3adfb2 | 547 | static void account_noninline_branch(DisasContext *s, int cc_op) |
e023e832 AG |
548 | { |
549 | #ifdef DEBUG_INLINE_BRANCHES | |
550 | inline_branch_miss[cc_op]++; | |
551 | #endif | |
552 | } | |
553 | ||
4f3adfb2 | 554 | static void account_inline_branch(DisasContext *s, int cc_op) |
e023e832 AG |
555 | { |
556 | #ifdef DEBUG_INLINE_BRANCHES | |
3fde06f5 | 557 | inline_branch_hit[cc_op]++; |
e023e832 AG |
558 | #endif |
559 | } | |
560 | ||
3fde06f5 RH |
561 | /* Table of mask values to comparison codes, given a comparison as input. |
562 | For a true comparison CC=3 will never be set, but we treat this | |
563 | conservatively for possible use when CC=3 indicates overflow. */ | |
564 | static const TCGCond ltgt_cond[16] = { | |
565 | TCG_COND_NEVER, TCG_COND_NEVER, /* | | | x */ | |
566 | TCG_COND_GT, TCG_COND_NEVER, /* | | GT | x */ | |
567 | TCG_COND_LT, TCG_COND_NEVER, /* | LT | | x */ | |
568 | TCG_COND_NE, TCG_COND_NEVER, /* | LT | GT | x */ | |
569 | TCG_COND_EQ, TCG_COND_NEVER, /* EQ | | | x */ | |
570 | TCG_COND_GE, TCG_COND_NEVER, /* EQ | | GT | x */ | |
571 | TCG_COND_LE, TCG_COND_NEVER, /* EQ | LT | | x */ | |
572 | TCG_COND_ALWAYS, TCG_COND_ALWAYS, /* EQ | LT | GT | x */ | |
573 | }; | |
574 | ||
575 | /* Table of mask values to comparison codes, given a logic op as input. | |
576 | For such, only CC=0 and CC=1 should be possible. */ | |
577 | static const TCGCond nz_cond[16] = { | |
578 | /* | | x | x */ | |
579 | TCG_COND_NEVER, TCG_COND_NEVER, TCG_COND_NEVER, TCG_COND_NEVER, | |
580 | /* | NE | x | x */ | |
581 | TCG_COND_NE, TCG_COND_NE, TCG_COND_NE, TCG_COND_NE, | |
582 | /* EQ | | x | x */ | |
583 | TCG_COND_EQ, TCG_COND_EQ, TCG_COND_EQ, TCG_COND_EQ, | |
584 | /* EQ | NE | x | x */ | |
585 | TCG_COND_ALWAYS, TCG_COND_ALWAYS, TCG_COND_ALWAYS, TCG_COND_ALWAYS, | |
586 | }; | |
587 | ||
588 | /* Interpret MASK in terms of S->CC_OP, and fill in C with all the | |
589 | details required to generate a TCG comparison. */ | |
590 | static void disas_jcc(DisasContext *s, DisasCompare *c, uint32_t mask) | |
e023e832 | 591 | { |
3fde06f5 RH |
592 | TCGCond cond; |
593 | enum cc_op old_cc_op = s->cc_op; | |
e023e832 | 594 | |
3fde06f5 RH |
595 | if (mask == 15 || mask == 0) { |
596 | c->cond = (mask ? TCG_COND_ALWAYS : TCG_COND_NEVER); | |
597 | c->u.s32.a = cc_op; | |
598 | c->u.s32.b = cc_op; | |
599 | c->g1 = c->g2 = true; | |
600 | c->is_64 = false; | |
601 | return; | |
602 | } | |
603 | ||
604 | /* Find the TCG condition for the mask + cc op. */ | |
605 | switch (old_cc_op) { | |
e023e832 | 606 | case CC_OP_LTGT0_32: |
e023e832 | 607 | case CC_OP_LTGT0_64: |
e023e832 | 608 | case CC_OP_LTGT_32: |
e023e832 | 609 | case CC_OP_LTGT_64: |
3fde06f5 RH |
610 | cond = ltgt_cond[mask]; |
611 | if (cond == TCG_COND_NEVER) { | |
e023e832 AG |
612 | goto do_dynamic; |
613 | } | |
3fde06f5 | 614 | account_inline_branch(s, old_cc_op); |
e023e832 | 615 | break; |
3fde06f5 | 616 | |
e023e832 | 617 | case CC_OP_LTUGTU_32: |
e023e832 | 618 | case CC_OP_LTUGTU_64: |
3fde06f5 RH |
619 | cond = tcg_unsigned_cond(ltgt_cond[mask]); |
620 | if (cond == TCG_COND_NEVER) { | |
e023e832 AG |
621 | goto do_dynamic; |
622 | } | |
3fde06f5 | 623 | account_inline_branch(s, old_cc_op); |
e023e832 | 624 | break; |
3fde06f5 | 625 | |
e023e832 | 626 | case CC_OP_NZ: |
3fde06f5 RH |
627 | cond = nz_cond[mask]; |
628 | if (cond == TCG_COND_NEVER) { | |
e023e832 AG |
629 | goto do_dynamic; |
630 | } | |
3fde06f5 | 631 | account_inline_branch(s, old_cc_op); |
e023e832 | 632 | break; |
e023e832 | 633 | |
3fde06f5 | 634 | case CC_OP_TM_32: |
e023e832 | 635 | case CC_OP_TM_64: |
e023e832 | 636 | switch (mask) { |
3fde06f5 RH |
637 | case 8: |
638 | cond = TCG_COND_EQ; | |
e023e832 | 639 | break; |
3fde06f5 RH |
640 | case 4 | 2 | 1: |
641 | cond = TCG_COND_NE; | |
e023e832 AG |
642 | break; |
643 | default: | |
644 | goto do_dynamic; | |
645 | } | |
3fde06f5 | 646 | account_inline_branch(s, old_cc_op); |
e023e832 | 647 | break; |
3fde06f5 | 648 | |
e023e832 AG |
649 | case CC_OP_ICM: |
650 | switch (mask) { | |
3fde06f5 RH |
651 | case 8: |
652 | cond = TCG_COND_EQ; | |
e023e832 | 653 | break; |
3fde06f5 RH |
654 | case 4 | 2 | 1: |
655 | case 4 | 2: | |
656 | cond = TCG_COND_NE; | |
e023e832 AG |
657 | break; |
658 | default: | |
659 | goto do_dynamic; | |
660 | } | |
3fde06f5 | 661 | account_inline_branch(s, old_cc_op); |
e023e832 | 662 | break; |
3fde06f5 | 663 | |
102bf2c6 RH |
664 | case CC_OP_FLOGR: |
665 | switch (mask & 0xa) { | |
666 | case 8: /* src == 0 -> no one bit found */ | |
667 | cond = TCG_COND_EQ; | |
668 | break; | |
669 | case 2: /* src != 0 -> one bit found */ | |
670 | cond = TCG_COND_NE; | |
671 | break; | |
672 | default: | |
673 | goto do_dynamic; | |
674 | } | |
675 | account_inline_branch(s, old_cc_op); | |
676 | break; | |
677 | ||
e023e832 | 678 | default: |
3fde06f5 RH |
679 | do_dynamic: |
680 | /* Calculate cc value. */ | |
e023e832 | 681 | gen_op_calc_cc(s); |
3fde06f5 | 682 | /* FALLTHRU */ |
e023e832 | 683 | |
3fde06f5 RH |
684 | case CC_OP_STATIC: |
685 | /* Jump based on CC. We'll load up the real cond below; | |
686 | the assignment here merely avoids a compiler warning. */ | |
e023e832 | 687 | account_noninline_branch(s, old_cc_op); |
3fde06f5 RH |
688 | old_cc_op = CC_OP_STATIC; |
689 | cond = TCG_COND_NEVER; | |
690 | break; | |
691 | } | |
e023e832 | 692 | |
3fde06f5 RH |
693 | /* Load up the arguments of the comparison. */ |
694 | c->is_64 = true; | |
695 | c->g1 = c->g2 = false; | |
696 | switch (old_cc_op) { | |
697 | case CC_OP_LTGT0_32: | |
698 | c->is_64 = false; | |
699 | c->u.s32.a = tcg_temp_new_i32(); | |
700 | tcg_gen_trunc_i64_i32(c->u.s32.a, cc_dst); | |
701 | c->u.s32.b = tcg_const_i32(0); | |
702 | break; | |
703 | case CC_OP_LTGT_32: | |
704 | case CC_OP_LTUGTU_32: | |
705 | c->is_64 = false; | |
706 | c->u.s32.a = tcg_temp_new_i32(); | |
707 | tcg_gen_trunc_i64_i32(c->u.s32.a, cc_src); | |
708 | c->u.s32.b = tcg_temp_new_i32(); | |
709 | tcg_gen_trunc_i64_i32(c->u.s32.b, cc_dst); | |
710 | break; | |
711 | ||
712 | case CC_OP_LTGT0_64: | |
713 | case CC_OP_NZ: | |
102bf2c6 | 714 | case CC_OP_FLOGR: |
3fde06f5 RH |
715 | c->u.s64.a = cc_dst; |
716 | c->u.s64.b = tcg_const_i64(0); | |
717 | c->g1 = true; | |
718 | break; | |
719 | case CC_OP_LTGT_64: | |
720 | case CC_OP_LTUGTU_64: | |
721 | c->u.s64.a = cc_src; | |
722 | c->u.s64.b = cc_dst; | |
723 | c->g1 = c->g2 = true; | |
724 | break; | |
725 | ||
726 | case CC_OP_TM_32: | |
727 | case CC_OP_TM_64: | |
58a9e35b | 728 | case CC_OP_ICM: |
3fde06f5 RH |
729 | c->u.s64.a = tcg_temp_new_i64(); |
730 | c->u.s64.b = tcg_const_i64(0); | |
731 | tcg_gen_and_i64(c->u.s64.a, cc_src, cc_dst); | |
732 | break; | |
733 | ||
734 | case CC_OP_STATIC: | |
735 | c->is_64 = false; | |
736 | c->u.s32.a = cc_op; | |
737 | c->g1 = true; | |
e023e832 | 738 | switch (mask) { |
e023e832 | 739 | case 0x8 | 0x4 | 0x2: /* cc != 3 */ |
3fde06f5 RH |
740 | cond = TCG_COND_NE; |
741 | c->u.s32.b = tcg_const_i32(3); | |
e023e832 AG |
742 | break; |
743 | case 0x8 | 0x4 | 0x1: /* cc != 2 */ | |
3fde06f5 RH |
744 | cond = TCG_COND_NE; |
745 | c->u.s32.b = tcg_const_i32(2); | |
e023e832 AG |
746 | break; |
747 | case 0x8 | 0x2 | 0x1: /* cc != 1 */ | |
3fde06f5 RH |
748 | cond = TCG_COND_NE; |
749 | c->u.s32.b = tcg_const_i32(1); | |
e023e832 | 750 | break; |
3fde06f5 RH |
751 | case 0x8 | 0x2: /* cc == 0 || cc == 2 => (cc & 1) == 0 */ |
752 | cond = TCG_COND_EQ; | |
753 | c->g1 = false; | |
754 | c->u.s32.a = tcg_temp_new_i32(); | |
755 | c->u.s32.b = tcg_const_i32(0); | |
756 | tcg_gen_andi_i32(c->u.s32.a, cc_op, 1); | |
e023e832 AG |
757 | break; |
758 | case 0x8 | 0x4: /* cc < 2 */ | |
3fde06f5 RH |
759 | cond = TCG_COND_LTU; |
760 | c->u.s32.b = tcg_const_i32(2); | |
e023e832 AG |
761 | break; |
762 | case 0x8: /* cc == 0 */ | |
3fde06f5 RH |
763 | cond = TCG_COND_EQ; |
764 | c->u.s32.b = tcg_const_i32(0); | |
e023e832 AG |
765 | break; |
766 | case 0x4 | 0x2 | 0x1: /* cc != 0 */ | |
3fde06f5 RH |
767 | cond = TCG_COND_NE; |
768 | c->u.s32.b = tcg_const_i32(0); | |
e023e832 | 769 | break; |
3fde06f5 RH |
770 | case 0x4 | 0x1: /* cc == 1 || cc == 3 => (cc & 1) != 0 */ |
771 | cond = TCG_COND_NE; | |
772 | c->g1 = false; | |
773 | c->u.s32.a = tcg_temp_new_i32(); | |
774 | c->u.s32.b = tcg_const_i32(0); | |
775 | tcg_gen_andi_i32(c->u.s32.a, cc_op, 1); | |
e023e832 AG |
776 | break; |
777 | case 0x4: /* cc == 1 */ | |
3fde06f5 RH |
778 | cond = TCG_COND_EQ; |
779 | c->u.s32.b = tcg_const_i32(1); | |
e023e832 AG |
780 | break; |
781 | case 0x2 | 0x1: /* cc > 1 */ | |
3fde06f5 RH |
782 | cond = TCG_COND_GTU; |
783 | c->u.s32.b = tcg_const_i32(1); | |
e023e832 AG |
784 | break; |
785 | case 0x2: /* cc == 2 */ | |
3fde06f5 RH |
786 | cond = TCG_COND_EQ; |
787 | c->u.s32.b = tcg_const_i32(2); | |
e023e832 AG |
788 | break; |
789 | case 0x1: /* cc == 3 */ | |
3fde06f5 RH |
790 | cond = TCG_COND_EQ; |
791 | c->u.s32.b = tcg_const_i32(3); | |
e023e832 | 792 | break; |
3fde06f5 RH |
793 | default: |
794 | /* CC is masked by something else: (8 >> cc) & mask. */ | |
795 | cond = TCG_COND_NE; | |
796 | c->g1 = false; | |
797 | c->u.s32.a = tcg_const_i32(8); | |
798 | c->u.s32.b = tcg_const_i32(0); | |
799 | tcg_gen_shr_i32(c->u.s32.a, c->u.s32.a, cc_op); | |
800 | tcg_gen_andi_i32(c->u.s32.a, c->u.s32.a, mask); | |
e023e832 AG |
801 | break; |
802 | } | |
803 | break; | |
3fde06f5 RH |
804 | |
805 | default: | |
806 | abort(); | |
e023e832 | 807 | } |
3fde06f5 RH |
808 | c->cond = cond; |
809 | } | |
810 | ||
811 | static void free_compare(DisasCompare *c) | |
812 | { | |
813 | if (!c->g1) { | |
814 | if (c->is_64) { | |
815 | tcg_temp_free_i64(c->u.s64.a); | |
816 | } else { | |
817 | tcg_temp_free_i32(c->u.s32.a); | |
818 | } | |
819 | } | |
820 | if (!c->g2) { | |
821 | if (c->is_64) { | |
822 | tcg_temp_free_i64(c->u.s64.b); | |
823 | } else { | |
824 | tcg_temp_free_i32(c->u.s32.b); | |
825 | } | |
826 | } | |
827 | } | |
828 | ||
ad044d09 RH |
829 | /* ====================================================================== */ |
830 | /* Define the insn format enumeration. */ | |
831 | #define F0(N) FMT_##N, | |
832 | #define F1(N, X1) F0(N) | |
833 | #define F2(N, X1, X2) F0(N) | |
834 | #define F3(N, X1, X2, X3) F0(N) | |
835 | #define F4(N, X1, X2, X3, X4) F0(N) | |
836 | #define F5(N, X1, X2, X3, X4, X5) F0(N) | |
837 | ||
838 | typedef enum { | |
839 | #include "insn-format.def" | |
840 | } DisasFormat; | |
841 | ||
842 | #undef F0 | |
843 | #undef F1 | |
844 | #undef F2 | |
845 | #undef F3 | |
846 | #undef F4 | |
847 | #undef F5 | |
848 | ||
849 | /* Define a structure to hold the decoded fields. We'll store each inside | |
850 | an array indexed by an enum. In order to conserve memory, we'll arrange | |
851 | for fields that do not exist at the same time to overlap, thus the "C" | |
852 | for compact. For checking purposes there is an "O" for original index | |
853 | as well that will be applied to availability bitmaps. */ | |
854 | ||
855 | enum DisasFieldIndexO { | |
856 | FLD_O_r1, | |
857 | FLD_O_r2, | |
858 | FLD_O_r3, | |
859 | FLD_O_m1, | |
860 | FLD_O_m3, | |
861 | FLD_O_m4, | |
862 | FLD_O_b1, | |
863 | FLD_O_b2, | |
864 | FLD_O_b4, | |
865 | FLD_O_d1, | |
866 | FLD_O_d2, | |
867 | FLD_O_d4, | |
868 | FLD_O_x2, | |
869 | FLD_O_l1, | |
870 | FLD_O_l2, | |
871 | FLD_O_i1, | |
872 | FLD_O_i2, | |
873 | FLD_O_i3, | |
874 | FLD_O_i4, | |
875 | FLD_O_i5 | |
876 | }; | |
877 | ||
878 | enum DisasFieldIndexC { | |
879 | FLD_C_r1 = 0, | |
880 | FLD_C_m1 = 0, | |
881 | FLD_C_b1 = 0, | |
882 | FLD_C_i1 = 0, | |
883 | ||
884 | FLD_C_r2 = 1, | |
885 | FLD_C_b2 = 1, | |
886 | FLD_C_i2 = 1, | |
887 | ||
888 | FLD_C_r3 = 2, | |
889 | FLD_C_m3 = 2, | |
890 | FLD_C_i3 = 2, | |
891 | ||
892 | FLD_C_m4 = 3, | |
893 | FLD_C_b4 = 3, | |
894 | FLD_C_i4 = 3, | |
895 | FLD_C_l1 = 3, | |
896 | ||
897 | FLD_C_i5 = 4, | |
898 | FLD_C_d1 = 4, | |
899 | ||
900 | FLD_C_d2 = 5, | |
901 | ||
902 | FLD_C_d4 = 6, | |
903 | FLD_C_x2 = 6, | |
904 | FLD_C_l2 = 6, | |
905 | ||
906 | NUM_C_FIELD = 7 | |
907 | }; | |
908 | ||
909 | struct DisasFields { | |
910 | unsigned op:8; | |
911 | unsigned op2:8; | |
912 | unsigned presentC:16; | |
913 | unsigned int presentO; | |
914 | int c[NUM_C_FIELD]; | |
915 | }; | |
916 | ||
917 | /* This is the way fields are to be accessed out of DisasFields. */ | |
918 | #define have_field(S, F) have_field1((S), FLD_O_##F) | |
919 | #define get_field(S, F) get_field1((S), FLD_O_##F, FLD_C_##F) | |
920 | ||
921 | static bool have_field1(const DisasFields *f, enum DisasFieldIndexO c) | |
922 | { | |
923 | return (f->presentO >> c) & 1; | |
924 | } | |
925 | ||
926 | static int get_field1(const DisasFields *f, enum DisasFieldIndexO o, | |
927 | enum DisasFieldIndexC c) | |
928 | { | |
929 | assert(have_field1(f, o)); | |
930 | return f->c[c]; | |
931 | } | |
932 | ||
933 | /* Describe the layout of each field in each format. */ | |
934 | typedef struct DisasField { | |
935 | unsigned int beg:8; | |
936 | unsigned int size:8; | |
937 | unsigned int type:2; | |
938 | unsigned int indexC:6; | |
939 | enum DisasFieldIndexO indexO:8; | |
940 | } DisasField; | |
941 | ||
942 | typedef struct DisasFormatInfo { | |
943 | DisasField op[NUM_C_FIELD]; | |
944 | } DisasFormatInfo; | |
945 | ||
946 | #define R(N, B) { B, 4, 0, FLD_C_r##N, FLD_O_r##N } | |
947 | #define M(N, B) { B, 4, 0, FLD_C_m##N, FLD_O_m##N } | |
948 | #define BD(N, BB, BD) { BB, 4, 0, FLD_C_b##N, FLD_O_b##N }, \ | |
949 | { BD, 12, 0, FLD_C_d##N, FLD_O_d##N } | |
950 | #define BXD(N) { 16, 4, 0, FLD_C_b##N, FLD_O_b##N }, \ | |
951 | { 12, 4, 0, FLD_C_x##N, FLD_O_x##N }, \ | |
952 | { 20, 12, 0, FLD_C_d##N, FLD_O_d##N } | |
953 | #define BDL(N) { 16, 4, 0, FLD_C_b##N, FLD_O_b##N }, \ | |
954 | { 20, 20, 2, FLD_C_d##N, FLD_O_d##N } | |
955 | #define BXDL(N) { 16, 4, 0, FLD_C_b##N, FLD_O_b##N }, \ | |
956 | { 12, 4, 0, FLD_C_x##N, FLD_O_x##N }, \ | |
957 | { 20, 20, 2, FLD_C_d##N, FLD_O_d##N } | |
958 | #define I(N, B, S) { B, S, 1, FLD_C_i##N, FLD_O_i##N } | |
959 | #define L(N, B, S) { B, S, 0, FLD_C_l##N, FLD_O_l##N } | |
960 | ||
961 | #define F0(N) { { } }, | |
962 | #define F1(N, X1) { { X1 } }, | |
963 | #define F2(N, X1, X2) { { X1, X2 } }, | |
964 | #define F3(N, X1, X2, X3) { { X1, X2, X3 } }, | |
965 | #define F4(N, X1, X2, X3, X4) { { X1, X2, X3, X4 } }, | |
966 | #define F5(N, X1, X2, X3, X4, X5) { { X1, X2, X3, X4, X5 } }, | |
967 | ||
968 | static const DisasFormatInfo format_info[] = { | |
969 | #include "insn-format.def" | |
970 | }; | |
971 | ||
972 | #undef F0 | |
973 | #undef F1 | |
974 | #undef F2 | |
975 | #undef F3 | |
976 | #undef F4 | |
977 | #undef F5 | |
978 | #undef R | |
979 | #undef M | |
980 | #undef BD | |
981 | #undef BXD | |
982 | #undef BDL | |
983 | #undef BXDL | |
984 | #undef I | |
985 | #undef L | |
986 | ||
987 | /* Generally, we'll extract operands into this structures, operate upon | |
988 | them, and store them back. See the "in1", "in2", "prep", "wout" sets | |
989 | of routines below for more details. */ | |
990 | typedef struct { | |
991 | bool g_out, g_out2, g_in1, g_in2; | |
992 | TCGv_i64 out, out2, in1, in2; | |
993 | TCGv_i64 addr1; | |
994 | } DisasOps; | |
995 | ||
996 | /* Return values from translate_one, indicating the state of the TB. */ | |
997 | typedef enum { | |
998 | /* Continue the TB. */ | |
999 | NO_EXIT, | |
1000 | /* We have emitted one or more goto_tb. No fixup required. */ | |
1001 | EXIT_GOTO_TB, | |
1002 | /* We are not using a goto_tb (for whatever reason), but have updated | |
1003 | the PC (for whatever reason), so there's no need to do it again on | |
1004 | exiting the TB. */ | |
1005 | EXIT_PC_UPDATED, | |
1006 | /* We are exiting the TB, but have neither emitted a goto_tb, nor | |
1007 | updated the PC for the next instruction to be executed. */ | |
1008 | EXIT_PC_STALE, | |
1009 | /* We are ending the TB with a noreturn function call, e.g. longjmp. | |
1010 | No following code will be executed. */ | |
1011 | EXIT_NORETURN, | |
1012 | } ExitStatus; | |
1013 | ||
1014 | typedef enum DisasFacility { | |
1015 | FAC_Z, /* zarch (default) */ | |
1016 | FAC_CASS, /* compare and swap and store */ | |
1017 | FAC_CASS2, /* compare and swap and store 2*/ | |
1018 | FAC_DFP, /* decimal floating point */ | |
1019 | FAC_DFPR, /* decimal floating point rounding */ | |
1020 | FAC_DO, /* distinct operands */ | |
1021 | FAC_EE, /* execute extensions */ | |
1022 | FAC_EI, /* extended immediate */ | |
1023 | FAC_FPE, /* floating point extension */ | |
1024 | FAC_FPSSH, /* floating point support sign handling */ | |
1025 | FAC_FPRGR, /* FPR-GR transfer */ | |
1026 | FAC_GIE, /* general instructions extension */ | |
1027 | FAC_HFP_MA, /* HFP multiply-and-add/subtract */ | |
1028 | FAC_HW, /* high-word */ | |
1029 | FAC_IEEEE_SIM, /* IEEE exception sumilation */ | |
1030 | FAC_LOC, /* load/store on condition */ | |
1031 | FAC_LD, /* long displacement */ | |
1032 | FAC_PC, /* population count */ | |
1033 | FAC_SCF, /* store clock fast */ | |
1034 | FAC_SFLE, /* store facility list extended */ | |
1035 | } DisasFacility; | |
1036 | ||
1037 | struct DisasInsn { | |
1038 | unsigned opc:16; | |
1039 | DisasFormat fmt:6; | |
1040 | DisasFacility fac:6; | |
1041 | ||
1042 | const char *name; | |
1043 | ||
1044 | void (*help_in1)(DisasContext *, DisasFields *, DisasOps *); | |
1045 | void (*help_in2)(DisasContext *, DisasFields *, DisasOps *); | |
1046 | void (*help_prep)(DisasContext *, DisasFields *, DisasOps *); | |
1047 | void (*help_wout)(DisasContext *, DisasFields *, DisasOps *); | |
1048 | void (*help_cout)(DisasContext *, DisasOps *); | |
1049 | ExitStatus (*help_op)(DisasContext *, DisasOps *); | |
1050 | ||
1051 | uint64_t data; | |
1052 | }; | |
1053 | ||
8ac33cdb RH |
1054 | /* ====================================================================== */ |
1055 | /* Miscelaneous helpers, used by several operations. */ | |
1056 | ||
cbe24bfa RH |
1057 | static void help_l2_shift(DisasContext *s, DisasFields *f, |
1058 | DisasOps *o, int mask) | |
1059 | { | |
1060 | int b2 = get_field(f, b2); | |
1061 | int d2 = get_field(f, d2); | |
1062 | ||
1063 | if (b2 == 0) { | |
1064 | o->in2 = tcg_const_i64(d2 & mask); | |
1065 | } else { | |
1066 | o->in2 = get_address(s, 0, b2, d2); | |
1067 | tcg_gen_andi_i64(o->in2, o->in2, mask); | |
1068 | } | |
1069 | } | |
1070 | ||
8ac33cdb RH |
1071 | static ExitStatus help_goto_direct(DisasContext *s, uint64_t dest) |
1072 | { | |
1073 | if (dest == s->next_pc) { | |
1074 | return NO_EXIT; | |
1075 | } | |
1076 | if (use_goto_tb(s, dest)) { | |
7a6c7067 | 1077 | update_cc_op(s); |
8ac33cdb RH |
1078 | tcg_gen_goto_tb(0); |
1079 | tcg_gen_movi_i64(psw_addr, dest); | |
1080 | tcg_gen_exit_tb((tcg_target_long)s->tb); | |
1081 | return EXIT_GOTO_TB; | |
1082 | } else { | |
1083 | tcg_gen_movi_i64(psw_addr, dest); | |
1084 | return EXIT_PC_UPDATED; | |
1085 | } | |
1086 | } | |
1087 | ||
7233f2ed RH |
1088 | static ExitStatus help_branch(DisasContext *s, DisasCompare *c, |
1089 | bool is_imm, int imm, TCGv_i64 cdest) | |
1090 | { | |
1091 | ExitStatus ret; | |
1092 | uint64_t dest = s->pc + 2 * imm; | |
1093 | int lab; | |
1094 | ||
1095 | /* Take care of the special cases first. */ | |
1096 | if (c->cond == TCG_COND_NEVER) { | |
1097 | ret = NO_EXIT; | |
1098 | goto egress; | |
1099 | } | |
1100 | if (is_imm) { | |
1101 | if (dest == s->next_pc) { | |
1102 | /* Branch to next. */ | |
1103 | ret = NO_EXIT; | |
1104 | goto egress; | |
1105 | } | |
1106 | if (c->cond == TCG_COND_ALWAYS) { | |
1107 | ret = help_goto_direct(s, dest); | |
1108 | goto egress; | |
1109 | } | |
1110 | } else { | |
1111 | if (TCGV_IS_UNUSED_I64(cdest)) { | |
1112 | /* E.g. bcr %r0 -> no branch. */ | |
1113 | ret = NO_EXIT; | |
1114 | goto egress; | |
1115 | } | |
1116 | if (c->cond == TCG_COND_ALWAYS) { | |
1117 | tcg_gen_mov_i64(psw_addr, cdest); | |
1118 | ret = EXIT_PC_UPDATED; | |
1119 | goto egress; | |
1120 | } | |
1121 | } | |
1122 | ||
1123 | if (use_goto_tb(s, s->next_pc)) { | |
1124 | if (is_imm && use_goto_tb(s, dest)) { | |
1125 | /* Both exits can use goto_tb. */ | |
7a6c7067 | 1126 | update_cc_op(s); |
7233f2ed RH |
1127 | |
1128 | lab = gen_new_label(); | |
1129 | if (c->is_64) { | |
1130 | tcg_gen_brcond_i64(c->cond, c->u.s64.a, c->u.s64.b, lab); | |
1131 | } else { | |
1132 | tcg_gen_brcond_i32(c->cond, c->u.s32.a, c->u.s32.b, lab); | |
1133 | } | |
1134 | ||
1135 | /* Branch not taken. */ | |
1136 | tcg_gen_goto_tb(0); | |
1137 | tcg_gen_movi_i64(psw_addr, s->next_pc); | |
1138 | tcg_gen_exit_tb((tcg_target_long)s->tb + 0); | |
1139 | ||
1140 | /* Branch taken. */ | |
1141 | gen_set_label(lab); | |
1142 | tcg_gen_goto_tb(1); | |
1143 | tcg_gen_movi_i64(psw_addr, dest); | |
1144 | tcg_gen_exit_tb((tcg_target_long)s->tb + 1); | |
1145 | ||
1146 | ret = EXIT_GOTO_TB; | |
1147 | } else { | |
1148 | /* Fallthru can use goto_tb, but taken branch cannot. */ | |
1149 | /* Store taken branch destination before the brcond. This | |
1150 | avoids having to allocate a new local temp to hold it. | |
1151 | We'll overwrite this in the not taken case anyway. */ | |
1152 | if (!is_imm) { | |
1153 | tcg_gen_mov_i64(psw_addr, cdest); | |
1154 | } | |
1155 | ||
1156 | lab = gen_new_label(); | |
1157 | if (c->is_64) { | |
1158 | tcg_gen_brcond_i64(c->cond, c->u.s64.a, c->u.s64.b, lab); | |
1159 | } else { | |
1160 | tcg_gen_brcond_i32(c->cond, c->u.s32.a, c->u.s32.b, lab); | |
1161 | } | |
1162 | ||
1163 | /* Branch not taken. */ | |
7a6c7067 | 1164 | update_cc_op(s); |
7233f2ed RH |
1165 | tcg_gen_goto_tb(0); |
1166 | tcg_gen_movi_i64(psw_addr, s->next_pc); | |
1167 | tcg_gen_exit_tb((tcg_target_long)s->tb + 0); | |
1168 | ||
1169 | gen_set_label(lab); | |
1170 | if (is_imm) { | |
1171 | tcg_gen_movi_i64(psw_addr, dest); | |
1172 | } | |
1173 | ret = EXIT_PC_UPDATED; | |
1174 | } | |
1175 | } else { | |
1176 | /* Fallthru cannot use goto_tb. This by itself is vanishingly rare. | |
1177 | Most commonly we're single-stepping or some other condition that | |
1178 | disables all use of goto_tb. Just update the PC and exit. */ | |
1179 | ||
1180 | TCGv_i64 next = tcg_const_i64(s->next_pc); | |
1181 | if (is_imm) { | |
1182 | cdest = tcg_const_i64(dest); | |
1183 | } | |
1184 | ||
1185 | if (c->is_64) { | |
1186 | tcg_gen_movcond_i64(c->cond, psw_addr, c->u.s64.a, c->u.s64.b, | |
1187 | cdest, next); | |
1188 | } else { | |
1189 | TCGv_i32 t0 = tcg_temp_new_i32(); | |
1190 | TCGv_i64 t1 = tcg_temp_new_i64(); | |
1191 | TCGv_i64 z = tcg_const_i64(0); | |
1192 | tcg_gen_setcond_i32(c->cond, t0, c->u.s32.a, c->u.s32.b); | |
1193 | tcg_gen_extu_i32_i64(t1, t0); | |
1194 | tcg_temp_free_i32(t0); | |
1195 | tcg_gen_movcond_i64(TCG_COND_NE, psw_addr, t1, z, cdest, next); | |
1196 | tcg_temp_free_i64(t1); | |
1197 | tcg_temp_free_i64(z); | |
1198 | } | |
1199 | ||
1200 | if (is_imm) { | |
1201 | tcg_temp_free_i64(cdest); | |
1202 | } | |
1203 | tcg_temp_free_i64(next); | |
1204 | ||
1205 | ret = EXIT_PC_UPDATED; | |
1206 | } | |
1207 | ||
1208 | egress: | |
1209 | free_compare(c); | |
1210 | return ret; | |
1211 | } | |
1212 | ||
ad044d09 RH |
1213 | /* ====================================================================== */ |
1214 | /* The operations. These perform the bulk of the work for any insn, | |
1215 | usually after the operands have been loaded and output initialized. */ | |
1216 | ||
b9bca3e5 RH |
1217 | static ExitStatus op_abs(DisasContext *s, DisasOps *o) |
1218 | { | |
1219 | gen_helper_abs_i64(o->out, o->in2); | |
1220 | return NO_EXIT; | |
1221 | } | |
1222 | ||
5d7fd045 RH |
1223 | static ExitStatus op_absf32(DisasContext *s, DisasOps *o) |
1224 | { | |
1225 | tcg_gen_andi_i64(o->out, o->in2, 0x7fffffffull); | |
1226 | return NO_EXIT; | |
1227 | } | |
1228 | ||
1229 | static ExitStatus op_absf64(DisasContext *s, DisasOps *o) | |
1230 | { | |
1231 | tcg_gen_andi_i64(o->out, o->in2, 0x7fffffffffffffffull); | |
1232 | return NO_EXIT; | |
1233 | } | |
1234 | ||
1235 | static ExitStatus op_absf128(DisasContext *s, DisasOps *o) | |
1236 | { | |
1237 | tcg_gen_andi_i64(o->out, o->in1, 0x7fffffffffffffffull); | |
1238 | tcg_gen_mov_i64(o->out2, o->in2); | |
1239 | return NO_EXIT; | |
1240 | } | |
1241 | ||
ad044d09 RH |
1242 | static ExitStatus op_add(DisasContext *s, DisasOps *o) |
1243 | { | |
1244 | tcg_gen_add_i64(o->out, o->in1, o->in2); | |
1245 | return NO_EXIT; | |
1246 | } | |
1247 | ||
4e4bb438 RH |
1248 | static ExitStatus op_addc(DisasContext *s, DisasOps *o) |
1249 | { | |
1250 | TCGv_i64 cc; | |
1251 | ||
1252 | tcg_gen_add_i64(o->out, o->in1, o->in2); | |
1253 | ||
1254 | /* XXX possible optimization point */ | |
1255 | gen_op_calc_cc(s); | |
1256 | cc = tcg_temp_new_i64(); | |
1257 | tcg_gen_extu_i32_i64(cc, cc_op); | |
1258 | tcg_gen_shri_i64(cc, cc, 1); | |
1259 | ||
1260 | tcg_gen_add_i64(o->out, o->out, cc); | |
1261 | tcg_temp_free_i64(cc); | |
1262 | return NO_EXIT; | |
1263 | } | |
1264 | ||
587626f8 RH |
1265 | static ExitStatus op_aeb(DisasContext *s, DisasOps *o) |
1266 | { | |
1267 | gen_helper_aeb(o->out, cpu_env, o->in1, o->in2); | |
1268 | return NO_EXIT; | |
1269 | } | |
1270 | ||
1271 | static ExitStatus op_adb(DisasContext *s, DisasOps *o) | |
1272 | { | |
1273 | gen_helper_adb(o->out, cpu_env, o->in1, o->in2); | |
1274 | return NO_EXIT; | |
1275 | } | |
1276 | ||
1277 | static ExitStatus op_axb(DisasContext *s, DisasOps *o) | |
1278 | { | |
1279 | gen_helper_axb(o->out, cpu_env, o->out, o->out2, o->in1, o->in2); | |
1280 | return_low128(o->out2); | |
1281 | return NO_EXIT; | |
1282 | } | |
1283 | ||
3bbfbd1f RH |
1284 | static ExitStatus op_and(DisasContext *s, DisasOps *o) |
1285 | { | |
1286 | tcg_gen_and_i64(o->out, o->in1, o->in2); | |
1287 | return NO_EXIT; | |
1288 | } | |
1289 | ||
facfc864 RH |
1290 | static ExitStatus op_andi(DisasContext *s, DisasOps *o) |
1291 | { | |
1292 | int shift = s->insn->data & 0xff; | |
1293 | int size = s->insn->data >> 8; | |
1294 | uint64_t mask = ((1ull << size) - 1) << shift; | |
1295 | ||
1296 | assert(!o->g_in2); | |
1297 | tcg_gen_shli_i64(o->in2, o->in2, shift); | |
1298 | tcg_gen_ori_i64(o->in2, o->in2, ~mask); | |
1299 | tcg_gen_and_i64(o->out, o->in1, o->in2); | |
1300 | ||
1301 | /* Produce the CC from only the bits manipulated. */ | |
1302 | tcg_gen_andi_i64(cc_dst, o->out, mask); | |
1303 | set_cc_nz_u64(s, cc_dst); | |
1304 | return NO_EXIT; | |
1305 | } | |
1306 | ||
8ac33cdb RH |
1307 | static ExitStatus op_bas(DisasContext *s, DisasOps *o) |
1308 | { | |
1309 | tcg_gen_movi_i64(o->out, pc_to_link_info(s, s->next_pc)); | |
1310 | if (!TCGV_IS_UNUSED_I64(o->in2)) { | |
1311 | tcg_gen_mov_i64(psw_addr, o->in2); | |
1312 | return EXIT_PC_UPDATED; | |
1313 | } else { | |
1314 | return NO_EXIT; | |
1315 | } | |
1316 | } | |
1317 | ||
1318 | static ExitStatus op_basi(DisasContext *s, DisasOps *o) | |
1319 | { | |
1320 | tcg_gen_movi_i64(o->out, pc_to_link_info(s, s->next_pc)); | |
1321 | return help_goto_direct(s, s->pc + 2 * get_field(s->fields, i2)); | |
1322 | } | |
1323 | ||
7233f2ed RH |
1324 | static ExitStatus op_bc(DisasContext *s, DisasOps *o) |
1325 | { | |
1326 | int m1 = get_field(s->fields, m1); | |
1327 | bool is_imm = have_field(s->fields, i2); | |
1328 | int imm = is_imm ? get_field(s->fields, i2) : 0; | |
1329 | DisasCompare c; | |
1330 | ||
1331 | disas_jcc(s, &c, m1); | |
1332 | return help_branch(s, &c, is_imm, imm, o->in2); | |
1333 | } | |
1334 | ||
c61aad69 RH |
1335 | static ExitStatus op_bct32(DisasContext *s, DisasOps *o) |
1336 | { | |
1337 | int r1 = get_field(s->fields, r1); | |
1338 | bool is_imm = have_field(s->fields, i2); | |
1339 | int imm = is_imm ? get_field(s->fields, i2) : 0; | |
1340 | DisasCompare c; | |
1341 | TCGv_i64 t; | |
1342 | ||
1343 | c.cond = TCG_COND_NE; | |
1344 | c.is_64 = false; | |
1345 | c.g1 = false; | |
1346 | c.g2 = false; | |
1347 | ||
1348 | t = tcg_temp_new_i64(); | |
1349 | tcg_gen_subi_i64(t, regs[r1], 1); | |
1350 | store_reg32_i64(r1, t); | |
1351 | c.u.s32.a = tcg_temp_new_i32(); | |
1352 | c.u.s32.b = tcg_const_i32(0); | |
1353 | tcg_gen_trunc_i64_i32(c.u.s32.a, t); | |
1354 | tcg_temp_free_i64(t); | |
1355 | ||
1356 | return help_branch(s, &c, is_imm, imm, o->in2); | |
1357 | } | |
1358 | ||
1359 | static ExitStatus op_bct64(DisasContext *s, DisasOps *o) | |
1360 | { | |
1361 | int r1 = get_field(s->fields, r1); | |
1362 | bool is_imm = have_field(s->fields, i2); | |
1363 | int imm = is_imm ? get_field(s->fields, i2) : 0; | |
1364 | DisasCompare c; | |
1365 | ||
1366 | c.cond = TCG_COND_NE; | |
1367 | c.is_64 = true; | |
1368 | c.g1 = true; | |
1369 | c.g2 = false; | |
1370 | ||
1371 | tcg_gen_subi_i64(regs[r1], regs[r1], 1); | |
1372 | c.u.s64.a = regs[r1]; | |
1373 | c.u.s64.b = tcg_const_i64(0); | |
1374 | ||
2cf5e350 RH |
1375 | return help_branch(s, &c, is_imm, imm, o->in2); |
1376 | } | |
1377 | ||
1378 | static ExitStatus op_bx32(DisasContext *s, DisasOps *o) | |
1379 | { | |
1380 | int r1 = get_field(s->fields, r1); | |
1381 | int r3 = get_field(s->fields, r3); | |
1382 | bool is_imm = have_field(s->fields, i2); | |
1383 | int imm = is_imm ? get_field(s->fields, i2) : 0; | |
1384 | DisasCompare c; | |
1385 | TCGv_i64 t; | |
1386 | ||
1387 | c.cond = (s->insn->data ? TCG_COND_LE : TCG_COND_GT); | |
1388 | c.is_64 = false; | |
1389 | c.g1 = false; | |
1390 | c.g2 = false; | |
1391 | ||
1392 | t = tcg_temp_new_i64(); | |
1393 | tcg_gen_add_i64(t, regs[r1], regs[r3]); | |
1394 | c.u.s32.a = tcg_temp_new_i32(); | |
1395 | c.u.s32.b = tcg_temp_new_i32(); | |
1396 | tcg_gen_trunc_i64_i32(c.u.s32.a, t); | |
1397 | tcg_gen_trunc_i64_i32(c.u.s32.b, regs[r3 | 1]); | |
1398 | store_reg32_i64(r1, t); | |
1399 | tcg_temp_free_i64(t); | |
1400 | ||
1401 | return help_branch(s, &c, is_imm, imm, o->in2); | |
1402 | } | |
1403 | ||
1404 | static ExitStatus op_bx64(DisasContext *s, DisasOps *o) | |
1405 | { | |
1406 | int r1 = get_field(s->fields, r1); | |
1407 | int r3 = get_field(s->fields, r3); | |
1408 | bool is_imm = have_field(s->fields, i2); | |
1409 | int imm = is_imm ? get_field(s->fields, i2) : 0; | |
1410 | DisasCompare c; | |
1411 | ||
1412 | c.cond = (s->insn->data ? TCG_COND_LE : TCG_COND_GT); | |
1413 | c.is_64 = true; | |
1414 | ||
1415 | if (r1 == (r3 | 1)) { | |
1416 | c.u.s64.b = load_reg(r3 | 1); | |
1417 | c.g2 = false; | |
1418 | } else { | |
1419 | c.u.s64.b = regs[r3 | 1]; | |
1420 | c.g2 = true; | |
1421 | } | |
1422 | ||
1423 | tcg_gen_add_i64(regs[r1], regs[r1], regs[r3]); | |
1424 | c.u.s64.a = regs[r1]; | |
1425 | c.g1 = true; | |
1426 | ||
c61aad69 RH |
1427 | return help_branch(s, &c, is_imm, imm, o->in2); |
1428 | } | |
1429 | ||
5550359f RH |
1430 | static ExitStatus op_cj(DisasContext *s, DisasOps *o) |
1431 | { | |
1432 | int imm, m3 = get_field(s->fields, m3); | |
1433 | bool is_imm; | |
1434 | DisasCompare c; | |
1435 | ||
1436 | /* Bit 3 of the m3 field is reserved and should be zero. | |
1437 | Choose to ignore it wrt the ltgt_cond table above. */ | |
1438 | c.cond = ltgt_cond[m3 & 14]; | |
1439 | if (s->insn->data) { | |
1440 | c.cond = tcg_unsigned_cond(c.cond); | |
1441 | } | |
1442 | c.is_64 = c.g1 = c.g2 = true; | |
1443 | c.u.s64.a = o->in1; | |
1444 | c.u.s64.b = o->in2; | |
1445 | ||
1446 | is_imm = have_field(s->fields, i4); | |
1447 | if (is_imm) { | |
1448 | imm = get_field(s->fields, i4); | |
1449 | } else { | |
1450 | imm = 0; | |
1451 | o->out = get_address(s, 0, get_field(s->fields, b4), | |
1452 | get_field(s->fields, d4)); | |
1453 | } | |
1454 | ||
1455 | return help_branch(s, &c, is_imm, imm, o->out); | |
1456 | } | |
1457 | ||
587626f8 RH |
1458 | static ExitStatus op_ceb(DisasContext *s, DisasOps *o) |
1459 | { | |
1460 | gen_helper_ceb(cc_op, cpu_env, o->in1, o->in2); | |
1461 | set_cc_static(s); | |
1462 | return NO_EXIT; | |
1463 | } | |
1464 | ||
1465 | static ExitStatus op_cdb(DisasContext *s, DisasOps *o) | |
1466 | { | |
1467 | gen_helper_cdb(cc_op, cpu_env, o->in1, o->in2); | |
1468 | set_cc_static(s); | |
1469 | return NO_EXIT; | |
1470 | } | |
1471 | ||
1472 | static ExitStatus op_cxb(DisasContext *s, DisasOps *o) | |
1473 | { | |
1474 | gen_helper_cxb(cc_op, cpu_env, o->out, o->out2, o->in1, o->in2); | |
1475 | set_cc_static(s); | |
1476 | return NO_EXIT; | |
1477 | } | |
1478 | ||
68c8bd93 RH |
1479 | static ExitStatus op_cfeb(DisasContext *s, DisasOps *o) |
1480 | { | |
1481 | TCGv_i32 m3 = tcg_const_i32(get_field(s->fields, m3)); | |
1482 | gen_helper_cfeb(o->out, cpu_env, o->in2, m3); | |
1483 | tcg_temp_free_i32(m3); | |
1484 | gen_set_cc_nz_f32(s, o->in2); | |
1485 | return NO_EXIT; | |
1486 | } | |
1487 | ||
1488 | static ExitStatus op_cfdb(DisasContext *s, DisasOps *o) | |
1489 | { | |
1490 | TCGv_i32 m3 = tcg_const_i32(get_field(s->fields, m3)); | |
1491 | gen_helper_cfdb(o->out, cpu_env, o->in2, m3); | |
1492 | tcg_temp_free_i32(m3); | |
1493 | gen_set_cc_nz_f64(s, o->in2); | |
1494 | return NO_EXIT; | |
1495 | } | |
1496 | ||
1497 | static ExitStatus op_cfxb(DisasContext *s, DisasOps *o) | |
1498 | { | |
1499 | TCGv_i32 m3 = tcg_const_i32(get_field(s->fields, m3)); | |
1500 | gen_helper_cfxb(o->out, cpu_env, o->in1, o->in2, m3); | |
1501 | tcg_temp_free_i32(m3); | |
1502 | gen_set_cc_nz_f128(s, o->in1, o->in2); | |
1503 | return NO_EXIT; | |
1504 | } | |
1505 | ||
1506 | static ExitStatus op_cgeb(DisasContext *s, DisasOps *o) | |
1507 | { | |
1508 | TCGv_i32 m3 = tcg_const_i32(get_field(s->fields, m3)); | |
1509 | gen_helper_cgeb(o->out, cpu_env, o->in2, m3); | |
1510 | tcg_temp_free_i32(m3); | |
1511 | gen_set_cc_nz_f32(s, o->in2); | |
1512 | return NO_EXIT; | |
1513 | } | |
1514 | ||
1515 | static ExitStatus op_cgdb(DisasContext *s, DisasOps *o) | |
1516 | { | |
1517 | TCGv_i32 m3 = tcg_const_i32(get_field(s->fields, m3)); | |
1518 | gen_helper_cgdb(o->out, cpu_env, o->in2, m3); | |
1519 | tcg_temp_free_i32(m3); | |
1520 | gen_set_cc_nz_f64(s, o->in2); | |
1521 | return NO_EXIT; | |
1522 | } | |
1523 | ||
1524 | static ExitStatus op_cgxb(DisasContext *s, DisasOps *o) | |
1525 | { | |
1526 | TCGv_i32 m3 = tcg_const_i32(get_field(s->fields, m3)); | |
1527 | gen_helper_cgxb(o->out, cpu_env, o->in1, o->in2, m3); | |
1528 | tcg_temp_free_i32(m3); | |
1529 | gen_set_cc_nz_f128(s, o->in1, o->in2); | |
1530 | return NO_EXIT; | |
1531 | } | |
1532 | ||
6ac1b45f RH |
1533 | static ExitStatus op_clfeb(DisasContext *s, DisasOps *o) |
1534 | { | |
1535 | TCGv_i32 m3 = tcg_const_i32(get_field(s->fields, m3)); | |
1536 | gen_helper_clfeb(o->out, cpu_env, o->in2, m3); | |
1537 | tcg_temp_free_i32(m3); | |
1538 | gen_set_cc_nz_f32(s, o->in2); | |
1539 | return NO_EXIT; | |
1540 | } | |
1541 | ||
1542 | static ExitStatus op_clfdb(DisasContext *s, DisasOps *o) | |
1543 | { | |
1544 | TCGv_i32 m3 = tcg_const_i32(get_field(s->fields, m3)); | |
1545 | gen_helper_clfdb(o->out, cpu_env, o->in2, m3); | |
1546 | tcg_temp_free_i32(m3); | |
1547 | gen_set_cc_nz_f64(s, o->in2); | |
1548 | return NO_EXIT; | |
1549 | } | |
1550 | ||
1551 | static ExitStatus op_clfxb(DisasContext *s, DisasOps *o) | |
1552 | { | |
1553 | TCGv_i32 m3 = tcg_const_i32(get_field(s->fields, m3)); | |
1554 | gen_helper_clfxb(o->out, cpu_env, o->in1, o->in2, m3); | |
1555 | tcg_temp_free_i32(m3); | |
1556 | gen_set_cc_nz_f128(s, o->in1, o->in2); | |
1557 | return NO_EXIT; | |
1558 | } | |
1559 | ||
1560 | static ExitStatus op_clgeb(DisasContext *s, DisasOps *o) | |
1561 | { | |
1562 | TCGv_i32 m3 = tcg_const_i32(get_field(s->fields, m3)); | |
1563 | gen_helper_clgeb(o->out, cpu_env, o->in2, m3); | |
1564 | tcg_temp_free_i32(m3); | |
1565 | gen_set_cc_nz_f32(s, o->in2); | |
1566 | return NO_EXIT; | |
1567 | } | |
1568 | ||
1569 | static ExitStatus op_clgdb(DisasContext *s, DisasOps *o) | |
1570 | { | |
1571 | TCGv_i32 m3 = tcg_const_i32(get_field(s->fields, m3)); | |
1572 | gen_helper_clgdb(o->out, cpu_env, o->in2, m3); | |
1573 | tcg_temp_free_i32(m3); | |
1574 | gen_set_cc_nz_f64(s, o->in2); | |
1575 | return NO_EXIT; | |
1576 | } | |
1577 | ||
1578 | static ExitStatus op_clgxb(DisasContext *s, DisasOps *o) | |
1579 | { | |
1580 | TCGv_i32 m3 = tcg_const_i32(get_field(s->fields, m3)); | |
1581 | gen_helper_clgxb(o->out, cpu_env, o->in1, o->in2, m3); | |
1582 | tcg_temp_free_i32(m3); | |
1583 | gen_set_cc_nz_f128(s, o->in1, o->in2); | |
1584 | return NO_EXIT; | |
1585 | } | |
1586 | ||
683bb9a8 RH |
1587 | static ExitStatus op_cegb(DisasContext *s, DisasOps *o) |
1588 | { | |
1589 | TCGv_i32 m3 = tcg_const_i32(get_field(s->fields, m3)); | |
1590 | gen_helper_cegb(o->out, cpu_env, o->in2, m3); | |
1591 | tcg_temp_free_i32(m3); | |
1592 | return NO_EXIT; | |
1593 | } | |
1594 | ||
1595 | static ExitStatus op_cdgb(DisasContext *s, DisasOps *o) | |
1596 | { | |
1597 | TCGv_i32 m3 = tcg_const_i32(get_field(s->fields, m3)); | |
1598 | gen_helper_cdgb(o->out, cpu_env, o->in2, m3); | |
1599 | tcg_temp_free_i32(m3); | |
1600 | return NO_EXIT; | |
1601 | } | |
1602 | ||
1603 | static ExitStatus op_cxgb(DisasContext *s, DisasOps *o) | |
1604 | { | |
1605 | TCGv_i32 m3 = tcg_const_i32(get_field(s->fields, m3)); | |
1606 | gen_helper_cxgb(o->out, cpu_env, o->in2, m3); | |
1607 | tcg_temp_free_i32(m3); | |
2112bf1b RH |
1608 | return_low128(o->out2); |
1609 | return NO_EXIT; | |
1610 | } | |
1611 | ||
1612 | static ExitStatus op_celgb(DisasContext *s, DisasOps *o) | |
1613 | { | |
1614 | TCGv_i32 m3 = tcg_const_i32(get_field(s->fields, m3)); | |
1615 | gen_helper_celgb(o->out, cpu_env, o->in2, m3); | |
1616 | tcg_temp_free_i32(m3); | |
1617 | return NO_EXIT; | |
1618 | } | |
1619 | ||
1620 | static ExitStatus op_cdlgb(DisasContext *s, DisasOps *o) | |
1621 | { | |
1622 | TCGv_i32 m3 = tcg_const_i32(get_field(s->fields, m3)); | |
1623 | gen_helper_cdlgb(o->out, cpu_env, o->in2, m3); | |
1624 | tcg_temp_free_i32(m3); | |
1625 | return NO_EXIT; | |
1626 | } | |
1627 | ||
1628 | static ExitStatus op_cxlgb(DisasContext *s, DisasOps *o) | |
1629 | { | |
1630 | TCGv_i32 m3 = tcg_const_i32(get_field(s->fields, m3)); | |
1631 | gen_helper_cxlgb(o->out, cpu_env, o->in2, m3); | |
1632 | tcg_temp_free_i32(m3); | |
683bb9a8 RH |
1633 | return_low128(o->out2); |
1634 | return NO_EXIT; | |
1635 | } | |
1636 | ||
374724f9 RH |
1637 | static ExitStatus op_cksm(DisasContext *s, DisasOps *o) |
1638 | { | |
1639 | int r2 = get_field(s->fields, r2); | |
1640 | TCGv_i64 len = tcg_temp_new_i64(); | |
1641 | ||
1642 | potential_page_fault(s); | |
1643 | gen_helper_cksm(len, cpu_env, o->in1, o->in2, regs[r2 + 1]); | |
1644 | set_cc_static(s); | |
1645 | return_low128(o->out); | |
1646 | ||
1647 | tcg_gen_add_i64(regs[r2], regs[r2], len); | |
1648 | tcg_gen_sub_i64(regs[r2 + 1], regs[r2 + 1], len); | |
1649 | tcg_temp_free_i64(len); | |
1650 | ||
1651 | return NO_EXIT; | |
1652 | } | |
1653 | ||
4f7403d5 RH |
1654 | static ExitStatus op_clc(DisasContext *s, DisasOps *o) |
1655 | { | |
1656 | int l = get_field(s->fields, l1); | |
1657 | TCGv_i32 vl; | |
1658 | ||
1659 | switch (l + 1) { | |
1660 | case 1: | |
1661 | tcg_gen_qemu_ld8u(cc_src, o->addr1, get_mem_index(s)); | |
1662 | tcg_gen_qemu_ld8u(cc_dst, o->in2, get_mem_index(s)); | |
1663 | break; | |
1664 | case 2: | |
1665 | tcg_gen_qemu_ld16u(cc_src, o->addr1, get_mem_index(s)); | |
1666 | tcg_gen_qemu_ld16u(cc_dst, o->in2, get_mem_index(s)); | |
1667 | break; | |
1668 | case 4: | |
1669 | tcg_gen_qemu_ld32u(cc_src, o->addr1, get_mem_index(s)); | |
1670 | tcg_gen_qemu_ld32u(cc_dst, o->in2, get_mem_index(s)); | |
1671 | break; | |
1672 | case 8: | |
1673 | tcg_gen_qemu_ld64(cc_src, o->addr1, get_mem_index(s)); | |
1674 | tcg_gen_qemu_ld64(cc_dst, o->in2, get_mem_index(s)); | |
1675 | break; | |
1676 | default: | |
1677 | potential_page_fault(s); | |
1678 | vl = tcg_const_i32(l); | |
1679 | gen_helper_clc(cc_op, cpu_env, vl, o->addr1, o->in2); | |
1680 | tcg_temp_free_i32(vl); | |
1681 | set_cc_static(s); | |
1682 | return NO_EXIT; | |
1683 | } | |
1684 | gen_op_update2_cc_i64(s, CC_OP_LTUGTU_64, cc_src, cc_dst); | |
1685 | return NO_EXIT; | |
1686 | } | |
1687 | ||
eb66e6a9 RH |
1688 | static ExitStatus op_clcle(DisasContext *s, DisasOps *o) |
1689 | { | |
1690 | TCGv_i32 r1 = tcg_const_i32(get_field(s->fields, r1)); | |
1691 | TCGv_i32 r3 = tcg_const_i32(get_field(s->fields, r3)); | |
1692 | potential_page_fault(s); | |
1693 | gen_helper_clcle(cc_op, cpu_env, r1, o->in2, r3); | |
1694 | tcg_temp_free_i32(r1); | |
1695 | tcg_temp_free_i32(r3); | |
1696 | set_cc_static(s); | |
1697 | return NO_EXIT; | |
1698 | } | |
1699 | ||
32a44d58 RH |
1700 | static ExitStatus op_clm(DisasContext *s, DisasOps *o) |
1701 | { | |
1702 | TCGv_i32 m3 = tcg_const_i32(get_field(s->fields, m3)); | |
1703 | TCGv_i32 t1 = tcg_temp_new_i32(); | |
1704 | tcg_gen_trunc_i64_i32(t1, o->in1); | |
1705 | potential_page_fault(s); | |
1706 | gen_helper_clm(cc_op, cpu_env, t1, m3, o->in2); | |
1707 | set_cc_static(s); | |
1708 | tcg_temp_free_i32(t1); | |
1709 | tcg_temp_free_i32(m3); | |
1710 | return NO_EXIT; | |
1711 | } | |
1712 | ||
aa31bf60 RH |
1713 | static ExitStatus op_clst(DisasContext *s, DisasOps *o) |
1714 | { | |
1715 | potential_page_fault(s); | |
1716 | gen_helper_clst(o->in1, cpu_env, regs[0], o->in1, o->in2); | |
1717 | set_cc_static(s); | |
1718 | return_low128(o->in2); | |
1719 | return NO_EXIT; | |
1720 | } | |
1721 | ||
2db014b5 RH |
1722 | static ExitStatus op_cps(DisasContext *s, DisasOps *o) |
1723 | { | |
1724 | TCGv_i64 t = tcg_temp_new_i64(); | |
1725 | tcg_gen_andi_i64(t, o->in1, 0x8000000000000000ull); | |
1726 | tcg_gen_andi_i64(o->out, o->in2, 0x7fffffffffffffffull); | |
1727 | tcg_gen_or_i64(o->out, o->out, t); | |
1728 | tcg_temp_free_i64(t); | |
1729 | return NO_EXIT; | |
1730 | } | |
1731 | ||
f3de39c4 RH |
1732 | static ExitStatus op_cs(DisasContext *s, DisasOps *o) |
1733 | { | |
1734 | int r3 = get_field(s->fields, r3); | |
1735 | potential_page_fault(s); | |
1736 | gen_helper_cs(o->out, cpu_env, o->in1, o->in2, regs[r3]); | |
1737 | set_cc_static(s); | |
1738 | return NO_EXIT; | |
1739 | } | |
1740 | ||
1741 | static ExitStatus op_csg(DisasContext *s, DisasOps *o) | |
1742 | { | |
1743 | int r3 = get_field(s->fields, r3); | |
1744 | potential_page_fault(s); | |
1745 | gen_helper_csg(o->out, cpu_env, o->in1, o->in2, regs[r3]); | |
1746 | set_cc_static(s); | |
1747 | return NO_EXIT; | |
1748 | } | |
1749 | ||
3d596f49 RH |
1750 | #ifndef CONFIG_USER_ONLY |
1751 | static ExitStatus op_csp(DisasContext *s, DisasOps *o) | |
1752 | { | |
1753 | TCGv_i32 r1 = tcg_const_i32(get_field(s->fields, r1)); | |
1754 | check_privileged(s); | |
1755 | gen_helper_csp(cc_op, cpu_env, r1, o->in2); | |
1756 | tcg_temp_free_i32(r1); | |
1757 | set_cc_static(s); | |
1758 | return NO_EXIT; | |
1759 | } | |
1760 | #endif | |
1761 | ||
f3de39c4 RH |
1762 | static ExitStatus op_cds(DisasContext *s, DisasOps *o) |
1763 | { | |
1764 | int r3 = get_field(s->fields, r3); | |
1765 | TCGv_i64 in3 = tcg_temp_new_i64(); | |
1766 | tcg_gen_deposit_i64(in3, regs[r3 + 1], regs[r3], 32, 32); | |
1767 | potential_page_fault(s); | |
1768 | gen_helper_csg(o->out, cpu_env, o->in1, o->in2, in3); | |
1769 | tcg_temp_free_i64(in3); | |
1770 | set_cc_static(s); | |
1771 | return NO_EXIT; | |
1772 | } | |
1773 | ||
1774 | static ExitStatus op_cdsg(DisasContext *s, DisasOps *o) | |
1775 | { | |
1776 | TCGv_i32 r1 = tcg_const_i32(get_field(s->fields, r1)); | |
1777 | TCGv_i32 r3 = tcg_const_i32(get_field(s->fields, r3)); | |
1778 | potential_page_fault(s); | |
1779 | /* XXX rewrite in tcg */ | |
1780 | gen_helper_cdsg(cc_op, cpu_env, r1, o->in2, r3); | |
1781 | set_cc_static(s); | |
1782 | return NO_EXIT; | |
1783 | } | |
1784 | ||
c49daa51 RH |
1785 | static ExitStatus op_cvd(DisasContext *s, DisasOps *o) |
1786 | { | |
1787 | TCGv_i64 t1 = tcg_temp_new_i64(); | |
1788 | TCGv_i32 t2 = tcg_temp_new_i32(); | |
1789 | tcg_gen_trunc_i64_i32(t2, o->in1); | |
1790 | gen_helper_cvd(t1, t2); | |
1791 | tcg_temp_free_i32(t2); | |
1792 | tcg_gen_qemu_st64(t1, o->in2, get_mem_index(s)); | |
1793 | tcg_temp_free_i64(t1); | |
1794 | return NO_EXIT; | |
1795 | } | |
1796 | ||
1c268751 RH |
1797 | static ExitStatus op_ct(DisasContext *s, DisasOps *o) |
1798 | { | |
1799 | int m3 = get_field(s->fields, m3); | |
1800 | int lab = gen_new_label(); | |
1801 | TCGv_i32 t; | |
1802 | TCGCond c; | |
1803 | ||
1804 | /* Bit 3 of the m3 field is reserved and should be zero. | |
1805 | Choose to ignore it wrt the ltgt_cond table above. */ | |
1806 | c = tcg_invert_cond(ltgt_cond[m3 & 14]); | |
1807 | if (s->insn->data) { | |
1808 | c = tcg_unsigned_cond(c); | |
1809 | } | |
1810 | tcg_gen_brcond_i64(c, o->in1, o->in2, lab); | |
1811 | ||
1812 | /* Set DXC to 0xff. */ | |
1813 | t = tcg_temp_new_i32(); | |
1814 | tcg_gen_ld_i32(t, cpu_env, offsetof(CPUS390XState, fpc)); | |
1815 | tcg_gen_ori_i32(t, t, 0xff00); | |
1816 | tcg_gen_st_i32(t, cpu_env, offsetof(CPUS390XState, fpc)); | |
1817 | tcg_temp_free_i32(t); | |
1818 | ||
1819 | /* Trap. */ | |
1820 | gen_program_exception(s, PGM_DATA); | |
1821 | ||
1822 | gen_set_label(lab); | |
1823 | return NO_EXIT; | |
1824 | } | |
1825 | ||
972e35b9 RH |
1826 | #ifndef CONFIG_USER_ONLY |
1827 | static ExitStatus op_diag(DisasContext *s, DisasOps *o) | |
1828 | { | |
1829 | TCGv_i32 tmp; | |
1830 | ||
1831 | check_privileged(s); | |
1832 | potential_page_fault(s); | |
1833 | ||
1834 | /* We pretend the format is RX_a so that D2 is the field we want. */ | |
1835 | tmp = tcg_const_i32(get_field(s->fields, d2) & 0xfff); | |
1836 | gen_helper_diag(regs[2], cpu_env, tmp, regs[2], regs[1]); | |
1837 | tcg_temp_free_i32(tmp); | |
1838 | return NO_EXIT; | |
1839 | } | |
1840 | #endif | |
1841 | ||
891452e5 RH |
1842 | static ExitStatus op_divs32(DisasContext *s, DisasOps *o) |
1843 | { | |
1844 | gen_helper_divs32(o->out2, cpu_env, o->in1, o->in2); | |
1845 | return_low128(o->out); | |
1846 | return NO_EXIT; | |
1847 | } | |
1848 | ||
1849 | static ExitStatus op_divu32(DisasContext *s, DisasOps *o) | |
1850 | { | |
1851 | gen_helper_divu32(o->out2, cpu_env, o->in1, o->in2); | |
1852 | return_low128(o->out); | |
1853 | return NO_EXIT; | |
1854 | } | |
1855 | ||
1856 | static ExitStatus op_divs64(DisasContext *s, DisasOps *o) | |
1857 | { | |
1858 | gen_helper_divs64(o->out2, cpu_env, o->in1, o->in2); | |
1859 | return_low128(o->out); | |
1860 | return NO_EXIT; | |
1861 | } | |
1862 | ||
1863 | static ExitStatus op_divu64(DisasContext *s, DisasOps *o) | |
1864 | { | |
1865 | gen_helper_divu64(o->out2, cpu_env, o->out, o->out2, o->in2); | |
1866 | return_low128(o->out); | |
1867 | return NO_EXIT; | |
1868 | } | |
1869 | ||
f08a5c31 RH |
1870 | static ExitStatus op_deb(DisasContext *s, DisasOps *o) |
1871 | { | |
1872 | gen_helper_deb(o->out, cpu_env, o->in1, o->in2); | |
1873 | return NO_EXIT; | |
1874 | } | |
1875 | ||
1876 | static ExitStatus op_ddb(DisasContext *s, DisasOps *o) | |
1877 | { | |
1878 | gen_helper_ddb(o->out, cpu_env, o->in1, o->in2); | |
1879 | return NO_EXIT; | |
1880 | } | |
1881 | ||
1882 | static ExitStatus op_dxb(DisasContext *s, DisasOps *o) | |
1883 | { | |
1884 | gen_helper_dxb(o->out, cpu_env, o->out, o->out2, o->in1, o->in2); | |
1885 | return_low128(o->out2); | |
1886 | return NO_EXIT; | |
1887 | } | |
1888 | ||
d62a4c97 RH |
1889 | static ExitStatus op_ear(DisasContext *s, DisasOps *o) |
1890 | { | |
1891 | int r2 = get_field(s->fields, r2); | |
1892 | tcg_gen_ld32u_i64(o->out, cpu_env, offsetof(CPUS390XState, aregs[r2])); | |
1893 | return NO_EXIT; | |
1894 | } | |
1895 | ||
ea20490f RH |
1896 | static ExitStatus op_efpc(DisasContext *s, DisasOps *o) |
1897 | { | |
1898 | tcg_gen_ld32u_i64(o->out, cpu_env, offsetof(CPUS390XState, fpc)); | |
1899 | return NO_EXIT; | |
1900 | } | |
1901 | ||
6e764e97 RH |
1902 | static ExitStatus op_ex(DisasContext *s, DisasOps *o) |
1903 | { | |
1904 | /* ??? Perhaps a better way to implement EXECUTE is to set a bit in | |
1905 | tb->flags, (ab)use the tb->cs_base field as the address of | |
1906 | the template in memory, and grab 8 bits of tb->flags/cflags for | |
1907 | the contents of the register. We would then recognize all this | |
1908 | in gen_intermediate_code_internal, generating code for exactly | |
1909 | one instruction. This new TB then gets executed normally. | |
1910 | ||
1911 | On the other hand, this seems to be mostly used for modifying | |
1912 | MVC inside of memcpy, which needs a helper call anyway. So | |
1913 | perhaps this doesn't bear thinking about any further. */ | |
1914 | ||
1915 | TCGv_i64 tmp; | |
1916 | ||
1917 | update_psw_addr(s); | |
7a6c7067 | 1918 | update_cc_op(s); |
6e764e97 RH |
1919 | |
1920 | tmp = tcg_const_i64(s->next_pc); | |
1921 | gen_helper_ex(cc_op, cpu_env, cc_op, o->in1, o->in2, tmp); | |
1922 | tcg_temp_free_i64(tmp); | |
1923 | ||
1924 | set_cc_static(s); | |
1925 | return NO_EXIT; | |
1926 | } | |
1927 | ||
102bf2c6 RH |
1928 | static ExitStatus op_flogr(DisasContext *s, DisasOps *o) |
1929 | { | |
1930 | /* We'll use the original input for cc computation, since we get to | |
1931 | compare that against 0, which ought to be better than comparing | |
1932 | the real output against 64. It also lets cc_dst be a convenient | |
1933 | temporary during our computation. */ | |
1934 | gen_op_update1_cc_i64(s, CC_OP_FLOGR, o->in2); | |
1935 | ||
1936 | /* R1 = IN ? CLZ(IN) : 64. */ | |
1937 | gen_helper_clz(o->out, o->in2); | |
1938 | ||
1939 | /* R1+1 = IN & ~(found bit). Note that we may attempt to shift this | |
1940 | value by 64, which is undefined. But since the shift is 64 iff the | |
1941 | input is zero, we still get the correct result after and'ing. */ | |
1942 | tcg_gen_movi_i64(o->out2, 0x8000000000000000ull); | |
1943 | tcg_gen_shr_i64(o->out2, o->out2, o->out); | |
1944 | tcg_gen_andc_i64(o->out2, cc_dst, o->out2); | |
1945 | return NO_EXIT; | |
1946 | } | |
1947 | ||
58a9e35b RH |
1948 | static ExitStatus op_icm(DisasContext *s, DisasOps *o) |
1949 | { | |
1950 | int m3 = get_field(s->fields, m3); | |
1951 | int pos, len, base = s->insn->data; | |
1952 | TCGv_i64 tmp = tcg_temp_new_i64(); | |
1953 | uint64_t ccm; | |
1954 | ||
1955 | switch (m3) { | |
1956 | case 0xf: | |
1957 | /* Effectively a 32-bit load. */ | |
1958 | tcg_gen_qemu_ld32u(tmp, o->in2, get_mem_index(s)); | |
1959 | len = 32; | |
1960 | goto one_insert; | |
1961 | ||
1962 | case 0xc: | |
1963 | case 0x6: | |
1964 | case 0x3: | |
1965 | /* Effectively a 16-bit load. */ | |
1966 | tcg_gen_qemu_ld16u(tmp, o->in2, get_mem_index(s)); | |
1967 | len = 16; | |
1968 | goto one_insert; | |
1969 | ||
1970 | case 0x8: | |
1971 | case 0x4: | |
1972 | case 0x2: | |
1973 | case 0x1: | |
1974 | /* Effectively an 8-bit load. */ | |
1975 | tcg_gen_qemu_ld8u(tmp, o->in2, get_mem_index(s)); | |
1976 | len = 8; | |
1977 | goto one_insert; | |
1978 | ||
1979 | one_insert: | |
1980 | pos = base + ctz32(m3) * 8; | |
1981 | tcg_gen_deposit_i64(o->out, o->out, tmp, pos, len); | |
1982 | ccm = ((1ull << len) - 1) << pos; | |
1983 | break; | |
1984 | ||
1985 | default: | |
1986 | /* This is going to be a sequence of loads and inserts. */ | |
1987 | pos = base + 32 - 8; | |
1988 | ccm = 0; | |
1989 | while (m3) { | |
1990 | if (m3 & 0x8) { | |
1991 | tcg_gen_qemu_ld8u(tmp, o->in2, get_mem_index(s)); | |
1992 | tcg_gen_addi_i64(o->in2, o->in2, 1); | |
1993 | tcg_gen_deposit_i64(o->out, o->out, tmp, pos, 8); | |
1994 | ccm |= 0xff << pos; | |
1995 | } | |
1996 | m3 = (m3 << 1) & 0xf; | |
1997 | pos -= 8; | |
1998 | } | |
1999 | break; | |
2000 | } | |
2001 | ||
2002 | tcg_gen_movi_i64(tmp, ccm); | |
2003 | gen_op_update2_cc_i64(s, CC_OP_ICM, tmp, o->out); | |
2004 | tcg_temp_free_i64(tmp); | |
2005 | return NO_EXIT; | |
2006 | } | |
2007 | ||
facfc864 RH |
2008 | static ExitStatus op_insi(DisasContext *s, DisasOps *o) |
2009 | { | |
2010 | int shift = s->insn->data & 0xff; | |
2011 | int size = s->insn->data >> 8; | |
2012 | tcg_gen_deposit_i64(o->out, o->in1, o->in2, shift, size); | |
2013 | return NO_EXIT; | |
2014 | } | |
2015 | ||
6e2704e7 RH |
2016 | static ExitStatus op_ipm(DisasContext *s, DisasOps *o) |
2017 | { | |
2018 | TCGv_i64 t1; | |
2019 | ||
2020 | gen_op_calc_cc(s); | |
2021 | tcg_gen_andi_i64(o->out, o->out, ~0xff000000ull); | |
2022 | ||
2023 | t1 = tcg_temp_new_i64(); | |
2024 | tcg_gen_shli_i64(t1, psw_mask, 20); | |
2025 | tcg_gen_shri_i64(t1, t1, 36); | |
2026 | tcg_gen_or_i64(o->out, o->out, t1); | |
2027 | ||
2028 | tcg_gen_extu_i32_i64(t1, cc_op); | |
2029 | tcg_gen_shli_i64(t1, t1, 28); | |
2030 | tcg_gen_or_i64(o->out, o->out, t1); | |
2031 | tcg_temp_free_i64(t1); | |
2032 | return NO_EXIT; | |
2033 | } | |
2034 | ||
cfef53e3 RH |
2035 | #ifndef CONFIG_USER_ONLY |
2036 | static ExitStatus op_ipte(DisasContext *s, DisasOps *o) | |
2037 | { | |
2038 | check_privileged(s); | |
2039 | gen_helper_ipte(cpu_env, o->in1, o->in2); | |
2040 | return NO_EXIT; | |
2041 | } | |
8026417c RH |
2042 | |
2043 | static ExitStatus op_iske(DisasContext *s, DisasOps *o) | |
2044 | { | |
2045 | check_privileged(s); | |
2046 | gen_helper_iske(o->out, cpu_env, o->in2); | |
2047 | return NO_EXIT; | |
2048 | } | |
cfef53e3 RH |
2049 | #endif |
2050 | ||
587626f8 RH |
2051 | static ExitStatus op_ldeb(DisasContext *s, DisasOps *o) |
2052 | { | |
2053 | gen_helper_ldeb(o->out, cpu_env, o->in2); | |
2054 | return NO_EXIT; | |
2055 | } | |
2056 | ||
2057 | static ExitStatus op_ledb(DisasContext *s, DisasOps *o) | |
2058 | { | |
2059 | gen_helper_ledb(o->out, cpu_env, o->in2); | |
2060 | return NO_EXIT; | |
2061 | } | |
2062 | ||
2063 | static ExitStatus op_ldxb(DisasContext *s, DisasOps *o) | |
2064 | { | |
2065 | gen_helper_ldxb(o->out, cpu_env, o->in1, o->in2); | |
2066 | return NO_EXIT; | |
2067 | } | |
2068 | ||
2069 | static ExitStatus op_lexb(DisasContext *s, DisasOps *o) | |
2070 | { | |
2071 | gen_helper_lexb(o->out, cpu_env, o->in1, o->in2); | |
2072 | return NO_EXIT; | |
2073 | } | |
2074 | ||
2075 | static ExitStatus op_lxdb(DisasContext *s, DisasOps *o) | |
2076 | { | |
2077 | gen_helper_lxdb(o->out, cpu_env, o->in2); | |
2078 | return_low128(o->out2); | |
2079 | return NO_EXIT; | |
2080 | } | |
2081 | ||
2082 | static ExitStatus op_lxeb(DisasContext *s, DisasOps *o) | |
2083 | { | |
2084 | gen_helper_lxeb(o->out, cpu_env, o->in2); | |
2085 | return_low128(o->out2); | |
2086 | return NO_EXIT; | |
2087 | } | |
2088 | ||
7691c23b RH |
2089 | static ExitStatus op_llgt(DisasContext *s, DisasOps *o) |
2090 | { | |
2091 | tcg_gen_andi_i64(o->out, o->in2, 0x7fffffff); | |
2092 | return NO_EXIT; | |
2093 | } | |
2094 | ||
c698d876 RH |
2095 | static ExitStatus op_ld8s(DisasContext *s, DisasOps *o) |
2096 | { | |
2097 | tcg_gen_qemu_ld8s(o->out, o->in2, get_mem_index(s)); | |
2098 | return NO_EXIT; | |
2099 | } | |
2100 | ||
2101 | static ExitStatus op_ld8u(DisasContext *s, DisasOps *o) | |
2102 | { | |
2103 | tcg_gen_qemu_ld8u(o->out, o->in2, get_mem_index(s)); | |
2104 | return NO_EXIT; | |
2105 | } | |
2106 | ||
2107 | static ExitStatus op_ld16s(DisasContext *s, DisasOps *o) | |
2108 | { | |
2109 | tcg_gen_qemu_ld16s(o->out, o->in2, get_mem_index(s)); | |
2110 | return NO_EXIT; | |
2111 | } | |
2112 | ||
2113 | static ExitStatus op_ld16u(DisasContext *s, DisasOps *o) | |
2114 | { | |
2115 | tcg_gen_qemu_ld16u(o->out, o->in2, get_mem_index(s)); | |
2116 | return NO_EXIT; | |
2117 | } | |
2118 | ||
22c37a08 RH |
2119 | static ExitStatus op_ld32s(DisasContext *s, DisasOps *o) |
2120 | { | |
2121 | tcg_gen_qemu_ld32s(o->out, o->in2, get_mem_index(s)); | |
2122 | return NO_EXIT; | |
2123 | } | |
2124 | ||
2125 | static ExitStatus op_ld32u(DisasContext *s, DisasOps *o) | |
2126 | { | |
2127 | tcg_gen_qemu_ld32u(o->out, o->in2, get_mem_index(s)); | |
2128 | return NO_EXIT; | |
2129 | } | |
2130 | ||
2131 | static ExitStatus op_ld64(DisasContext *s, DisasOps *o) | |
2132 | { | |
2133 | tcg_gen_qemu_ld64(o->out, o->in2, get_mem_index(s)); | |
2134 | return NO_EXIT; | |
2135 | } | |
2136 | ||
632086da RH |
2137 | static ExitStatus op_loc(DisasContext *s, DisasOps *o) |
2138 | { | |
2139 | DisasCompare c; | |
2140 | ||
2141 | disas_jcc(s, &c, get_field(s->fields, m3)); | |
2142 | ||
2143 | if (c.is_64) { | |
2144 | tcg_gen_movcond_i64(c.cond, o->out, c.u.s64.a, c.u.s64.b, | |
2145 | o->in2, o->in1); | |
2146 | free_compare(&c); | |
2147 | } else { | |
2148 | TCGv_i32 t32 = tcg_temp_new_i32(); | |
2149 | TCGv_i64 t, z; | |
2150 | ||
2151 | tcg_gen_setcond_i32(c.cond, t32, c.u.s32.a, c.u.s32.b); | |
2152 | free_compare(&c); | |
2153 | ||
2154 | t = tcg_temp_new_i64(); | |
2155 | tcg_gen_extu_i32_i64(t, t32); | |
2156 | tcg_temp_free_i32(t32); | |
2157 | ||
2158 | z = tcg_const_i64(0); | |
2159 | tcg_gen_movcond_i64(TCG_COND_NE, o->out, t, z, o->in2, o->in1); | |
2160 | tcg_temp_free_i64(t); | |
2161 | tcg_temp_free_i64(z); | |
2162 | } | |
2163 | ||
2164 | return NO_EXIT; | |
2165 | } | |
2166 | ||
8b5ff571 | 2167 | #ifndef CONFIG_USER_ONLY |
504488b8 RH |
2168 | static ExitStatus op_lctl(DisasContext *s, DisasOps *o) |
2169 | { | |
2170 | TCGv_i32 r1 = tcg_const_i32(get_field(s->fields, r1)); | |
2171 | TCGv_i32 r3 = tcg_const_i32(get_field(s->fields, r3)); | |
2172 | check_privileged(s); | |
2173 | potential_page_fault(s); | |
2174 | gen_helper_lctl(cpu_env, r1, o->in2, r3); | |
2175 | tcg_temp_free_i32(r1); | |
2176 | tcg_temp_free_i32(r3); | |
2177 | return NO_EXIT; | |
2178 | } | |
2179 | ||
3e398cf9 RH |
2180 | static ExitStatus op_lctlg(DisasContext *s, DisasOps *o) |
2181 | { | |
2182 | TCGv_i32 r1 = tcg_const_i32(get_field(s->fields, r1)); | |
2183 | TCGv_i32 r3 = tcg_const_i32(get_field(s->fields, r3)); | |
2184 | check_privileged(s); | |
2185 | potential_page_fault(s); | |
2186 | gen_helper_lctlg(cpu_env, r1, o->in2, r3); | |
2187 | tcg_temp_free_i32(r1); | |
2188 | tcg_temp_free_i32(r3); | |
2189 | return NO_EXIT; | |
2190 | } | |
d8fe4a9c RH |
2191 | static ExitStatus op_lra(DisasContext *s, DisasOps *o) |
2192 | { | |
2193 | check_privileged(s); | |
2194 | potential_page_fault(s); | |
2195 | gen_helper_lra(o->out, cpu_env, o->in2); | |
2196 | set_cc_static(s); | |
2197 | return NO_EXIT; | |
2198 | } | |
2199 | ||
8b5ff571 RH |
2200 | static ExitStatus op_lpsw(DisasContext *s, DisasOps *o) |
2201 | { | |
2202 | TCGv_i64 t1, t2; | |
2203 | ||
2204 | check_privileged(s); | |
2205 | ||
2206 | t1 = tcg_temp_new_i64(); | |
2207 | t2 = tcg_temp_new_i64(); | |
2208 | tcg_gen_qemu_ld32u(t1, o->in2, get_mem_index(s)); | |
2209 | tcg_gen_addi_i64(o->in2, o->in2, 4); | |
2210 | tcg_gen_qemu_ld32u(t2, o->in2, get_mem_index(s)); | |
2211 | /* Convert the 32-bit PSW_MASK into the 64-bit PSW_MASK. */ | |
2212 | tcg_gen_shli_i64(t1, t1, 32); | |
2213 | gen_helper_load_psw(cpu_env, t1, t2); | |
2214 | tcg_temp_free_i64(t1); | |
2215 | tcg_temp_free_i64(t2); | |
2216 | return EXIT_NORETURN; | |
2217 | } | |
7ab938d7 RH |
2218 | |
2219 | static ExitStatus op_lpswe(DisasContext *s, DisasOps *o) | |
2220 | { | |
2221 | TCGv_i64 t1, t2; | |
2222 | ||
2223 | check_privileged(s); | |
2224 | ||
2225 | t1 = tcg_temp_new_i64(); | |
2226 | t2 = tcg_temp_new_i64(); | |
2227 | tcg_gen_qemu_ld64(t1, o->in2, get_mem_index(s)); | |
2228 | tcg_gen_addi_i64(o->in2, o->in2, 8); | |
2229 | tcg_gen_qemu_ld64(t2, o->in2, get_mem_index(s)); | |
2230 | gen_helper_load_psw(cpu_env, t1, t2); | |
2231 | tcg_temp_free_i64(t1); | |
2232 | tcg_temp_free_i64(t2); | |
2233 | return EXIT_NORETURN; | |
2234 | } | |
8b5ff571 RH |
2235 | #endif |
2236 | ||
7df3e93a RH |
2237 | static ExitStatus op_lam(DisasContext *s, DisasOps *o) |
2238 | { | |
2239 | TCGv_i32 r1 = tcg_const_i32(get_field(s->fields, r1)); | |
2240 | TCGv_i32 r3 = tcg_const_i32(get_field(s->fields, r3)); | |
2241 | potential_page_fault(s); | |
2242 | gen_helper_lam(cpu_env, r1, o->in2, r3); | |
2243 | tcg_temp_free_i32(r1); | |
2244 | tcg_temp_free_i32(r3); | |
2245 | return NO_EXIT; | |
2246 | } | |
2247 | ||
77f8d6c3 RH |
2248 | static ExitStatus op_lm32(DisasContext *s, DisasOps *o) |
2249 | { | |
2250 | int r1 = get_field(s->fields, r1); | |
2251 | int r3 = get_field(s->fields, r3); | |
2252 | TCGv_i64 t = tcg_temp_new_i64(); | |
2253 | TCGv_i64 t4 = tcg_const_i64(4); | |
2254 | ||
2255 | while (1) { | |
2256 | tcg_gen_qemu_ld32u(t, o->in2, get_mem_index(s)); | |
2257 | store_reg32_i64(r1, t); | |
2258 | if (r1 == r3) { | |
2259 | break; | |
2260 | } | |
2261 | tcg_gen_add_i64(o->in2, o->in2, t4); | |
2262 | r1 = (r1 + 1) & 15; | |
2263 | } | |
2264 | ||
2265 | tcg_temp_free_i64(t); | |
2266 | tcg_temp_free_i64(t4); | |
2267 | return NO_EXIT; | |
2268 | } | |
2269 | ||
2270 | static ExitStatus op_lmh(DisasContext *s, DisasOps *o) | |
2271 | { | |
2272 | int r1 = get_field(s->fields, r1); | |
2273 | int r3 = get_field(s->fields, r3); | |
2274 | TCGv_i64 t = tcg_temp_new_i64(); | |
2275 | TCGv_i64 t4 = tcg_const_i64(4); | |
2276 | ||
2277 | while (1) { | |
2278 | tcg_gen_qemu_ld32u(t, o->in2, get_mem_index(s)); | |
2279 | store_reg32h_i64(r1, t); | |
2280 | if (r1 == r3) { | |
2281 | break; | |
2282 | } | |
2283 | tcg_gen_add_i64(o->in2, o->in2, t4); | |
2284 | r1 = (r1 + 1) & 15; | |
2285 | } | |
2286 | ||
2287 | tcg_temp_free_i64(t); | |
2288 | tcg_temp_free_i64(t4); | |
2289 | return NO_EXIT; | |
2290 | } | |
2291 | ||
2292 | static ExitStatus op_lm64(DisasContext *s, DisasOps *o) | |
2293 | { | |
2294 | int r1 = get_field(s->fields, r1); | |
2295 | int r3 = get_field(s->fields, r3); | |
2296 | TCGv_i64 t8 = tcg_const_i64(8); | |
2297 | ||
2298 | while (1) { | |
2299 | tcg_gen_qemu_ld64(regs[r1], o->in2, get_mem_index(s)); | |
2300 | if (r1 == r3) { | |
2301 | break; | |
2302 | } | |
2303 | tcg_gen_add_i64(o->in2, o->in2, t8); | |
2304 | r1 = (r1 + 1) & 15; | |
2305 | } | |
2306 | ||
2307 | tcg_temp_free_i64(t8); | |
2308 | return NO_EXIT; | |
2309 | } | |
2310 | ||
22c37a08 RH |
2311 | static ExitStatus op_mov2(DisasContext *s, DisasOps *o) |
2312 | { | |
2313 | o->out = o->in2; | |
2314 | o->g_out = o->g_in2; | |
2315 | TCGV_UNUSED_I64(o->in2); | |
2316 | o->g_in2 = false; | |
2317 | return NO_EXIT; | |
2318 | } | |
2319 | ||
d764a8d1 RH |
2320 | static ExitStatus op_movx(DisasContext *s, DisasOps *o) |
2321 | { | |
2322 | o->out = o->in1; | |
2323 | o->out2 = o->in2; | |
2324 | o->g_out = o->g_in1; | |
2325 | o->g_out2 = o->g_in2; | |
2326 | TCGV_UNUSED_I64(o->in1); | |
2327 | TCGV_UNUSED_I64(o->in2); | |
2328 | o->g_in1 = o->g_in2 = false; | |
2329 | return NO_EXIT; | |
2330 | } | |
2331 | ||
af9e5a04 RH |
2332 | static ExitStatus op_mvc(DisasContext *s, DisasOps *o) |
2333 | { | |
2334 | TCGv_i32 l = tcg_const_i32(get_field(s->fields, l1)); | |
2335 | potential_page_fault(s); | |
2336 | gen_helper_mvc(cpu_env, l, o->addr1, o->in2); | |
2337 | tcg_temp_free_i32(l); | |
2338 | return NO_EXIT; | |
2339 | } | |
2340 | ||
e1eaada9 RH |
2341 | static ExitStatus op_mvcl(DisasContext *s, DisasOps *o) |
2342 | { | |
2343 | TCGv_i32 r1 = tcg_const_i32(get_field(s->fields, r1)); | |
2344 | TCGv_i32 r2 = tcg_const_i32(get_field(s->fields, r2)); | |
2345 | potential_page_fault(s); | |
2346 | gen_helper_mvcl(cc_op, cpu_env, r1, r2); | |
2347 | tcg_temp_free_i32(r1); | |
2348 | tcg_temp_free_i32(r2); | |
2349 | set_cc_static(s); | |
2350 | return NO_EXIT; | |
2351 | } | |
2352 | ||
eb66e6a9 RH |
2353 | static ExitStatus op_mvcle(DisasContext *s, DisasOps *o) |
2354 | { | |
2355 | TCGv_i32 r1 = tcg_const_i32(get_field(s->fields, r1)); | |
2356 | TCGv_i32 r3 = tcg_const_i32(get_field(s->fields, r3)); | |
2357 | potential_page_fault(s); | |
2358 | gen_helper_mvcle(cc_op, cpu_env, r1, o->in2, r3); | |
2359 | tcg_temp_free_i32(r1); | |
2360 | tcg_temp_free_i32(r3); | |
2361 | set_cc_static(s); | |
2362 | return NO_EXIT; | |
2363 | } | |
2364 | ||
97c3ab61 RH |
2365 | #ifndef CONFIG_USER_ONLY |
2366 | static ExitStatus op_mvcp(DisasContext *s, DisasOps *o) | |
2367 | { | |
2368 | int r1 = get_field(s->fields, l1); | |
2369 | check_privileged(s); | |
2370 | potential_page_fault(s); | |
2371 | gen_helper_mvcp(cc_op, cpu_env, regs[r1], o->addr1, o->in2); | |
2372 | set_cc_static(s); | |
2373 | return NO_EXIT; | |
2374 | } | |
2375 | ||
2376 | static ExitStatus op_mvcs(DisasContext *s, DisasOps *o) | |
2377 | { | |
2378 | int r1 = get_field(s->fields, l1); | |
2379 | check_privileged(s); | |
2380 | potential_page_fault(s); | |
2381 | gen_helper_mvcs(cc_op, cpu_env, regs[r1], o->addr1, o->in2); | |
2382 | set_cc_static(s); | |
2383 | return NO_EXIT; | |
2384 | } | |
2385 | #endif | |
2386 | ||
ee6c38d5 RH |
2387 | static ExitStatus op_mvpg(DisasContext *s, DisasOps *o) |
2388 | { | |
2389 | potential_page_fault(s); | |
2390 | gen_helper_mvpg(cpu_env, regs[0], o->in1, o->in2); | |
2391 | set_cc_static(s); | |
2392 | return NO_EXIT; | |
2393 | } | |
2394 | ||
aa31bf60 RH |
2395 | static ExitStatus op_mvst(DisasContext *s, DisasOps *o) |
2396 | { | |
2397 | potential_page_fault(s); | |
2398 | gen_helper_mvst(o->in1, cpu_env, regs[0], o->in1, o->in2); | |
2399 | set_cc_static(s); | |
2400 | return_low128(o->in2); | |
2401 | return NO_EXIT; | |
2402 | } | |
2403 | ||
d1c04a2b RH |
2404 | static ExitStatus op_mul(DisasContext *s, DisasOps *o) |
2405 | { | |
2406 | tcg_gen_mul_i64(o->out, o->in1, o->in2); | |
2407 | return NO_EXIT; | |
2408 | } | |
2409 | ||
1ac5889f RH |
2410 | static ExitStatus op_mul128(DisasContext *s, DisasOps *o) |
2411 | { | |
2412 | gen_helper_mul128(o->out, cpu_env, o->in1, o->in2); | |
2413 | return_low128(o->out2); | |
2414 | return NO_EXIT; | |
2415 | } | |
2416 | ||
83b00736 RH |
2417 | static ExitStatus op_meeb(DisasContext *s, DisasOps *o) |
2418 | { | |
2419 | gen_helper_meeb(o->out, cpu_env, o->in1, o->in2); | |
2420 | return NO_EXIT; | |
2421 | } | |
2422 | ||
2423 | static ExitStatus op_mdeb(DisasContext *s, DisasOps *o) | |
2424 | { | |
2425 | gen_helper_mdeb(o->out, cpu_env, o->in1, o->in2); | |
2426 | return NO_EXIT; | |
2427 | } | |
2428 | ||
2429 | static ExitStatus op_mdb(DisasContext *s, DisasOps *o) | |
2430 | { | |
2431 | gen_helper_mdb(o->out, cpu_env, o->in1, o->in2); | |
2432 | return NO_EXIT; | |
2433 | } | |
2434 | ||
2435 | static ExitStatus op_mxb(DisasContext *s, DisasOps *o) | |
2436 | { | |
2437 | gen_helper_mxb(o->out, cpu_env, o->out, o->out2, o->in1, o->in2); | |
2438 | return_low128(o->out2); | |
2439 | return NO_EXIT; | |
2440 | } | |
2441 | ||
2442 | static ExitStatus op_mxdb(DisasContext *s, DisasOps *o) | |
2443 | { | |
2444 | gen_helper_mxdb(o->out, cpu_env, o->out, o->out2, o->in2); | |
2445 | return_low128(o->out2); | |
2446 | return NO_EXIT; | |
2447 | } | |
2448 | ||
722bfec3 RH |
2449 | static ExitStatus op_maeb(DisasContext *s, DisasOps *o) |
2450 | { | |
2451 | TCGv_i64 r3 = load_freg32_i64(get_field(s->fields, r3)); | |
2452 | gen_helper_maeb(o->out, cpu_env, o->in1, o->in2, r3); | |
2453 | tcg_temp_free_i64(r3); | |
2454 | return NO_EXIT; | |
2455 | } | |
2456 | ||
2457 | static ExitStatus op_madb(DisasContext *s, DisasOps *o) | |
2458 | { | |
2459 | int r3 = get_field(s->fields, r3); | |
2460 | gen_helper_madb(o->out, cpu_env, o->in1, o->in2, fregs[r3]); | |
2461 | return NO_EXIT; | |
2462 | } | |
2463 | ||
2464 | static ExitStatus op_mseb(DisasContext *s, DisasOps *o) | |
2465 | { | |
2466 | TCGv_i64 r3 = load_freg32_i64(get_field(s->fields, r3)); | |
2467 | gen_helper_mseb(o->out, cpu_env, o->in1, o->in2, r3); | |
2468 | tcg_temp_free_i64(r3); | |
2469 | return NO_EXIT; | |
2470 | } | |
2471 | ||
2472 | static ExitStatus op_msdb(DisasContext *s, DisasOps *o) | |
2473 | { | |
2474 | int r3 = get_field(s->fields, r3); | |
2475 | gen_helper_msdb(o->out, cpu_env, o->in1, o->in2, fregs[r3]); | |
2476 | return NO_EXIT; | |
2477 | } | |
2478 | ||
b9bca3e5 RH |
2479 | static ExitStatus op_nabs(DisasContext *s, DisasOps *o) |
2480 | { | |
2481 | gen_helper_nabs_i64(o->out, o->in2); | |
2482 | return NO_EXIT; | |
2483 | } | |
2484 | ||
5d7fd045 RH |
2485 | static ExitStatus op_nabsf32(DisasContext *s, DisasOps *o) |
2486 | { | |
2487 | tcg_gen_ori_i64(o->out, o->in2, 0x80000000ull); | |
2488 | return NO_EXIT; | |
2489 | } | |
2490 | ||
2491 | static ExitStatus op_nabsf64(DisasContext *s, DisasOps *o) | |
2492 | { | |
2493 | tcg_gen_ori_i64(o->out, o->in2, 0x8000000000000000ull); | |
2494 | return NO_EXIT; | |
2495 | } | |
2496 | ||
2497 | static ExitStatus op_nabsf128(DisasContext *s, DisasOps *o) | |
2498 | { | |
2499 | tcg_gen_ori_i64(o->out, o->in1, 0x8000000000000000ull); | |
2500 | tcg_gen_mov_i64(o->out2, o->in2); | |
2501 | return NO_EXIT; | |
2502 | } | |
2503 | ||
0a949039 RH |
2504 | static ExitStatus op_nc(DisasContext *s, DisasOps *o) |
2505 | { | |
2506 | TCGv_i32 l = tcg_const_i32(get_field(s->fields, l1)); | |
2507 | potential_page_fault(s); | |
2508 | gen_helper_nc(cc_op, cpu_env, l, o->addr1, o->in2); | |
2509 | tcg_temp_free_i32(l); | |
2510 | set_cc_static(s); | |
2511 | return NO_EXIT; | |
2512 | } | |
2513 | ||
b9bca3e5 RH |
2514 | static ExitStatus op_neg(DisasContext *s, DisasOps *o) |
2515 | { | |
2516 | tcg_gen_neg_i64(o->out, o->in2); | |
2517 | return NO_EXIT; | |
2518 | } | |
2519 | ||
5d7fd045 RH |
2520 | static ExitStatus op_negf32(DisasContext *s, DisasOps *o) |
2521 | { | |
2522 | tcg_gen_xori_i64(o->out, o->in2, 0x80000000ull); | |
2523 | return NO_EXIT; | |
2524 | } | |
2525 | ||
2526 | static ExitStatus op_negf64(DisasContext *s, DisasOps *o) | |
2527 | { | |
2528 | tcg_gen_xori_i64(o->out, o->in2, 0x8000000000000000ull); | |
2529 | return NO_EXIT; | |
2530 | } | |
2531 | ||
2532 | static ExitStatus op_negf128(DisasContext *s, DisasOps *o) | |
2533 | { | |
2534 | tcg_gen_xori_i64(o->out, o->in1, 0x8000000000000000ull); | |
2535 | tcg_gen_mov_i64(o->out2, o->in2); | |
2536 | return NO_EXIT; | |
2537 | } | |
2538 | ||
0a949039 RH |
2539 | static ExitStatus op_oc(DisasContext *s, DisasOps *o) |
2540 | { | |
2541 | TCGv_i32 l = tcg_const_i32(get_field(s->fields, l1)); | |
2542 | potential_page_fault(s); | |
2543 | gen_helper_oc(cc_op, cpu_env, l, o->addr1, o->in2); | |
2544 | tcg_temp_free_i32(l); | |
2545 | set_cc_static(s); | |
2546 | return NO_EXIT; | |
2547 | } | |
2548 | ||
3bbfbd1f RH |
2549 | static ExitStatus op_or(DisasContext *s, DisasOps *o) |
2550 | { | |
2551 | tcg_gen_or_i64(o->out, o->in1, o->in2); | |
2552 | return NO_EXIT; | |
2553 | } | |
2554 | ||
facfc864 RH |
2555 | static ExitStatus op_ori(DisasContext *s, DisasOps *o) |
2556 | { | |
2557 | int shift = s->insn->data & 0xff; | |
2558 | int size = s->insn->data >> 8; | |
2559 | uint64_t mask = ((1ull << size) - 1) << shift; | |
2560 | ||
2561 | assert(!o->g_in2); | |
2562 | tcg_gen_shli_i64(o->in2, o->in2, shift); | |
2563 | tcg_gen_or_i64(o->out, o->in1, o->in2); | |
2564 | ||
2565 | /* Produce the CC from only the bits manipulated. */ | |
2566 | tcg_gen_andi_i64(cc_dst, o->out, mask); | |
2567 | set_cc_nz_u64(s, cc_dst); | |
2568 | return NO_EXIT; | |
2569 | } | |
2570 | ||
99b4f24b RH |
2571 | static ExitStatus op_popcnt(DisasContext *s, DisasOps *o) |
2572 | { | |
2573 | gen_helper_popcnt(o->out, o->in2); | |
2574 | return NO_EXIT; | |
2575 | } | |
2576 | ||
0568d8aa RH |
2577 | #ifndef CONFIG_USER_ONLY |
2578 | static ExitStatus op_ptlb(DisasContext *s, DisasOps *o) | |
2579 | { | |
2580 | check_privileged(s); | |
2581 | gen_helper_ptlb(cpu_env); | |
2582 | return NO_EXIT; | |
2583 | } | |
2584 | #endif | |
2585 | ||
2d6a8698 RH |
2586 | static ExitStatus op_risbg(DisasContext *s, DisasOps *o) |
2587 | { | |
2588 | int i3 = get_field(s->fields, i3); | |
2589 | int i4 = get_field(s->fields, i4); | |
2590 | int i5 = get_field(s->fields, i5); | |
2591 | int do_zero = i4 & 0x80; | |
2592 | uint64_t mask, imask, pmask; | |
2593 | int pos, len, rot; | |
2594 | ||
2595 | /* Adjust the arguments for the specific insn. */ | |
2596 | switch (s->fields->op2) { | |
2597 | case 0x55: /* risbg */ | |
2598 | i3 &= 63; | |
2599 | i4 &= 63; | |
2600 | pmask = ~0; | |
2601 | break; | |
2602 | case 0x5d: /* risbhg */ | |
2603 | i3 &= 31; | |
2604 | i4 &= 31; | |
2605 | pmask = 0xffffffff00000000ull; | |
2606 | break; | |
2607 | case 0x51: /* risblg */ | |
2608 | i3 &= 31; | |
2609 | i4 &= 31; | |
2610 | pmask = 0x00000000ffffffffull; | |
2611 | break; | |
2612 | default: | |
2613 | abort(); | |
2614 | } | |
2615 | ||
2616 | /* MASK is the set of bits to be inserted from R2. | |
2617 | Take care for I3/I4 wraparound. */ | |
2618 | mask = pmask >> i3; | |
2619 | if (i3 <= i4) { | |
2620 | mask ^= pmask >> i4 >> 1; | |
2621 | } else { | |
2622 | mask |= ~(pmask >> i4 >> 1); | |
2623 | } | |
2624 | mask &= pmask; | |
2625 | ||
2626 | /* IMASK is the set of bits to be kept from R1. In the case of the high/low | |
2627 | insns, we need to keep the other half of the register. */ | |
2628 | imask = ~mask | ~pmask; | |
2629 | if (do_zero) { | |
2630 | if (s->fields->op2 == 0x55) { | |
2631 | imask = 0; | |
2632 | } else { | |
2633 | imask = ~pmask; | |
2634 | } | |
2635 | } | |
2636 | ||
2637 | /* In some cases we can implement this with deposit, which can be more | |
2638 | efficient on some hosts. */ | |
2639 | if (~mask == imask && i3 <= i4) { | |
2640 | if (s->fields->op2 == 0x5d) { | |
2641 | i3 += 32, i4 += 32; | |
2642 | } | |
2643 | /* Note that we rotate the bits to be inserted to the lsb, not to | |
2644 | the position as described in the PoO. */ | |
2645 | len = i4 - i3 + 1; | |
2646 | pos = 63 - i4; | |
2647 | rot = (i5 - pos) & 63; | |
2648 | } else { | |
2649 | pos = len = -1; | |
2650 | rot = i5 & 63; | |
2651 | } | |
2652 | ||
2653 | /* Rotate the input as necessary. */ | |
2654 | tcg_gen_rotli_i64(o->in2, o->in2, rot); | |
2655 | ||
2656 | /* Insert the selected bits into the output. */ | |
2657 | if (pos >= 0) { | |
2658 | tcg_gen_deposit_i64(o->out, o->out, o->in2, pos, len); | |
2659 | } else if (imask == 0) { | |
2660 | tcg_gen_andi_i64(o->out, o->in2, mask); | |
2661 | } else { | |
2662 | tcg_gen_andi_i64(o->in2, o->in2, mask); | |
2663 | tcg_gen_andi_i64(o->out, o->out, imask); | |
2664 | tcg_gen_or_i64(o->out, o->out, o->in2); | |
2665 | } | |
2666 | return NO_EXIT; | |
d6c6372e RH |
2667 | } |
2668 | ||
2669 | static ExitStatus op_rosbg(DisasContext *s, DisasOps *o) | |
2670 | { | |
2671 | int i3 = get_field(s->fields, i3); | |
2672 | int i4 = get_field(s->fields, i4); | |
2673 | int i5 = get_field(s->fields, i5); | |
2674 | uint64_t mask; | |
2675 | ||
2676 | /* If this is a test-only form, arrange to discard the result. */ | |
2677 | if (i3 & 0x80) { | |
2678 | o->out = tcg_temp_new_i64(); | |
2679 | o->g_out = false; | |
2680 | } | |
2681 | ||
2682 | i3 &= 63; | |
2683 | i4 &= 63; | |
2684 | i5 &= 63; | |
2685 | ||
2686 | /* MASK is the set of bits to be operated on from R2. | |
2687 | Take care for I3/I4 wraparound. */ | |
2688 | mask = ~0ull >> i3; | |
2689 | if (i3 <= i4) { | |
2690 | mask ^= ~0ull >> i4 >> 1; | |
2691 | } else { | |
2692 | mask |= ~(~0ull >> i4 >> 1); | |
2693 | } | |
2694 | ||
2695 | /* Rotate the input as necessary. */ | |
2696 | tcg_gen_rotli_i64(o->in2, o->in2, i5); | |
2697 | ||
2698 | /* Operate. */ | |
2699 | switch (s->fields->op2) { | |
2700 | case 0x55: /* AND */ | |
2701 | tcg_gen_ori_i64(o->in2, o->in2, ~mask); | |
2702 | tcg_gen_and_i64(o->out, o->out, o->in2); | |
2703 | break; | |
2704 | case 0x56: /* OR */ | |
2705 | tcg_gen_andi_i64(o->in2, o->in2, mask); | |
2706 | tcg_gen_or_i64(o->out, o->out, o->in2); | |
2707 | break; | |
2708 | case 0x57: /* XOR */ | |
2709 | tcg_gen_andi_i64(o->in2, o->in2, mask); | |
2710 | tcg_gen_xor_i64(o->out, o->out, o->in2); | |
2711 | break; | |
2712 | default: | |
2713 | abort(); | |
2714 | } | |
2715 | ||
2716 | /* Set the CC. */ | |
2717 | tcg_gen_andi_i64(cc_dst, o->out, mask); | |
2718 | set_cc_nz_u64(s, cc_dst); | |
2719 | return NO_EXIT; | |
2d6a8698 RH |
2720 | } |
2721 | ||
d54f5865 RH |
2722 | static ExitStatus op_rev16(DisasContext *s, DisasOps *o) |
2723 | { | |
2724 | tcg_gen_bswap16_i64(o->out, o->in2); | |
2725 | return NO_EXIT; | |
2726 | } | |
2727 | ||
2728 | static ExitStatus op_rev32(DisasContext *s, DisasOps *o) | |
2729 | { | |
2730 | tcg_gen_bswap32_i64(o->out, o->in2); | |
2731 | return NO_EXIT; | |
2732 | } | |
2733 | ||
2734 | static ExitStatus op_rev64(DisasContext *s, DisasOps *o) | |
2735 | { | |
2736 | tcg_gen_bswap64_i64(o->out, o->in2); | |
2737 | return NO_EXIT; | |
2738 | } | |
2739 | ||
cbe24bfa RH |
2740 | static ExitStatus op_rll32(DisasContext *s, DisasOps *o) |
2741 | { | |
2742 | TCGv_i32 t1 = tcg_temp_new_i32(); | |
2743 | TCGv_i32 t2 = tcg_temp_new_i32(); | |
2744 | TCGv_i32 to = tcg_temp_new_i32(); | |
2745 | tcg_gen_trunc_i64_i32(t1, o->in1); | |
2746 | tcg_gen_trunc_i64_i32(t2, o->in2); | |
2747 | tcg_gen_rotl_i32(to, t1, t2); | |
2748 | tcg_gen_extu_i32_i64(o->out, to); | |
2749 | tcg_temp_free_i32(t1); | |
2750 | tcg_temp_free_i32(t2); | |
2751 | tcg_temp_free_i32(to); | |
2752 | return NO_EXIT; | |
2753 | } | |
2754 | ||
2755 | static ExitStatus op_rll64(DisasContext *s, DisasOps *o) | |
2756 | { | |
2757 | tcg_gen_rotl_i64(o->out, o->in1, o->in2); | |
2758 | return NO_EXIT; | |
2759 | } | |
2760 | ||
5cc69c54 RH |
2761 | #ifndef CONFIG_USER_ONLY |
2762 | static ExitStatus op_rrbe(DisasContext *s, DisasOps *o) | |
2763 | { | |
2764 | check_privileged(s); | |
2765 | gen_helper_rrbe(cc_op, cpu_env, o->in2); | |
2766 | set_cc_static(s); | |
2767 | return NO_EXIT; | |
2768 | } | |
14244b21 RH |
2769 | |
2770 | static ExitStatus op_sacf(DisasContext *s, DisasOps *o) | |
2771 | { | |
2772 | check_privileged(s); | |
2773 | gen_helper_sacf(cpu_env, o->in2); | |
2774 | /* Addressing mode has changed, so end the block. */ | |
2775 | return EXIT_PC_STALE; | |
2776 | } | |
5cc69c54 RH |
2777 | #endif |
2778 | ||
d62a4c97 RH |
2779 | static ExitStatus op_sar(DisasContext *s, DisasOps *o) |
2780 | { | |
2781 | int r1 = get_field(s->fields, r1); | |
2782 | tcg_gen_st32_i64(o->in2, cpu_env, offsetof(CPUS390XState, aregs[r1])); | |
2783 | return NO_EXIT; | |
2784 | } | |
2785 | ||
1a800a2d RH |
2786 | static ExitStatus op_seb(DisasContext *s, DisasOps *o) |
2787 | { | |
2788 | gen_helper_seb(o->out, cpu_env, o->in1, o->in2); | |
2789 | return NO_EXIT; | |
2790 | } | |
2791 | ||
2792 | static ExitStatus op_sdb(DisasContext *s, DisasOps *o) | |
2793 | { | |
2794 | gen_helper_sdb(o->out, cpu_env, o->in1, o->in2); | |
2795 | return NO_EXIT; | |
2796 | } | |
2797 | ||
2798 | static ExitStatus op_sxb(DisasContext *s, DisasOps *o) | |
2799 | { | |
2800 | gen_helper_sxb(o->out, cpu_env, o->out, o->out2, o->in1, o->in2); | |
2801 | return_low128(o->out2); | |
2802 | return NO_EXIT; | |
2803 | } | |
2804 | ||
16d7b2a4 RH |
2805 | static ExitStatus op_sqeb(DisasContext *s, DisasOps *o) |
2806 | { | |
2807 | gen_helper_sqeb(o->out, cpu_env, o->in2); | |
2808 | return NO_EXIT; | |
2809 | } | |
2810 | ||
2811 | static ExitStatus op_sqdb(DisasContext *s, DisasOps *o) | |
2812 | { | |
2813 | gen_helper_sqdb(o->out, cpu_env, o->in2); | |
2814 | return NO_EXIT; | |
2815 | } | |
2816 | ||
2817 | static ExitStatus op_sqxb(DisasContext *s, DisasOps *o) | |
2818 | { | |
2819 | gen_helper_sqxb(o->out, cpu_env, o->in1, o->in2); | |
2820 | return_low128(o->out2); | |
2821 | return NO_EXIT; | |
2822 | } | |
2823 | ||
0c240015 | 2824 | #ifndef CONFIG_USER_ONLY |
dc458df9 RH |
2825 | static ExitStatus op_servc(DisasContext *s, DisasOps *o) |
2826 | { | |
2827 | check_privileged(s); | |
2828 | potential_page_fault(s); | |
2829 | gen_helper_servc(cc_op, cpu_env, o->in2, o->in1); | |
2830 | set_cc_static(s); | |
2831 | return NO_EXIT; | |
2832 | } | |
2833 | ||
0c240015 RH |
2834 | static ExitStatus op_sigp(DisasContext *s, DisasOps *o) |
2835 | { | |
2836 | TCGv_i32 r1 = tcg_const_i32(get_field(s->fields, r1)); | |
2837 | check_privileged(s); | |
2838 | potential_page_fault(s); | |
2839 | gen_helper_sigp(cc_op, cpu_env, o->in2, r1, o->in1); | |
2840 | tcg_temp_free_i32(r1); | |
2841 | return NO_EXIT; | |
2842 | } | |
2843 | #endif | |
2844 | ||
b92fa334 RH |
2845 | static ExitStatus op_soc(DisasContext *s, DisasOps *o) |
2846 | { | |
2847 | DisasCompare c; | |
2848 | TCGv_i64 a; | |
2849 | int lab, r1; | |
2850 | ||
2851 | disas_jcc(s, &c, get_field(s->fields, m3)); | |
2852 | ||
2853 | lab = gen_new_label(); | |
2854 | if (c.is_64) { | |
2855 | tcg_gen_brcond_i64(c.cond, c.u.s64.a, c.u.s64.b, lab); | |
2856 | } else { | |
2857 | tcg_gen_brcond_i32(c.cond, c.u.s32.a, c.u.s32.b, lab); | |
2858 | } | |
2859 | free_compare(&c); | |
2860 | ||
2861 | r1 = get_field(s->fields, r1); | |
2862 | a = get_address(s, 0, get_field(s->fields, b2), get_field(s->fields, d2)); | |
2863 | if (s->insn->data) { | |
2864 | tcg_gen_qemu_st64(regs[r1], a, get_mem_index(s)); | |
2865 | } else { | |
2866 | tcg_gen_qemu_st32(regs[r1], a, get_mem_index(s)); | |
2867 | } | |
2868 | tcg_temp_free_i64(a); | |
2869 | ||
2870 | gen_set_label(lab); | |
2871 | return NO_EXIT; | |
2872 | } | |
2873 | ||
cbe24bfa RH |
2874 | static ExitStatus op_sla(DisasContext *s, DisasOps *o) |
2875 | { | |
2876 | uint64_t sign = 1ull << s->insn->data; | |
2877 | enum cc_op cco = s->insn->data == 31 ? CC_OP_SLA_32 : CC_OP_SLA_64; | |
2878 | gen_op_update2_cc_i64(s, cco, o->in1, o->in2); | |
2879 | tcg_gen_shl_i64(o->out, o->in1, o->in2); | |
2880 | /* The arithmetic left shift is curious in that it does not affect | |
2881 | the sign bit. Copy that over from the source unchanged. */ | |
2882 | tcg_gen_andi_i64(o->out, o->out, ~sign); | |
2883 | tcg_gen_andi_i64(o->in1, o->in1, sign); | |
2884 | tcg_gen_or_i64(o->out, o->out, o->in1); | |
2885 | return NO_EXIT; | |
2886 | } | |
2887 | ||
2888 | static ExitStatus op_sll(DisasContext *s, DisasOps *o) | |
2889 | { | |
2890 | tcg_gen_shl_i64(o->out, o->in1, o->in2); | |
2891 | return NO_EXIT; | |
2892 | } | |
2893 | ||
2894 | static ExitStatus op_sra(DisasContext *s, DisasOps *o) | |
2895 | { | |
2896 | tcg_gen_sar_i64(o->out, o->in1, o->in2); | |
2897 | return NO_EXIT; | |
2898 | } | |
2899 | ||
2900 | static ExitStatus op_srl(DisasContext *s, DisasOps *o) | |
2901 | { | |
2902 | tcg_gen_shr_i64(o->out, o->in1, o->in2); | |
2903 | return NO_EXIT; | |
2904 | } | |
2905 | ||
8379bfdb RH |
2906 | static ExitStatus op_sfpc(DisasContext *s, DisasOps *o) |
2907 | { | |
2908 | gen_helper_sfpc(cpu_env, o->in2); | |
2909 | return NO_EXIT; | |
2910 | } | |
2911 | ||
7d30bb73 | 2912 | #ifndef CONFIG_USER_ONLY |
28d55556 RH |
2913 | static ExitStatus op_spka(DisasContext *s, DisasOps *o) |
2914 | { | |
2915 | check_privileged(s); | |
2916 | tcg_gen_shri_i64(o->in2, o->in2, 4); | |
2917 | tcg_gen_deposit_i64(psw_mask, psw_mask, o->in2, PSW_SHIFT_KEY - 4, 4); | |
2918 | return NO_EXIT; | |
2919 | } | |
2920 | ||
2bbde27f RH |
2921 | static ExitStatus op_sske(DisasContext *s, DisasOps *o) |
2922 | { | |
2923 | check_privileged(s); | |
2924 | gen_helper_sske(cpu_env, o->in1, o->in2); | |
2925 | return NO_EXIT; | |
2926 | } | |
2927 | ||
7d30bb73 RH |
2928 | static ExitStatus op_ssm(DisasContext *s, DisasOps *o) |
2929 | { | |
2930 | check_privileged(s); | |
2931 | tcg_gen_deposit_i64(psw_mask, psw_mask, o->in2, 56, 8); | |
2932 | return NO_EXIT; | |
2933 | } | |
145cdb40 | 2934 | |
411fea3d RH |
2935 | static ExitStatus op_stap(DisasContext *s, DisasOps *o) |
2936 | { | |
2937 | check_privileged(s); | |
2938 | /* ??? Surely cpu address != cpu number. In any case the previous | |
2939 | version of this stored more than the required half-word, so it | |
2940 | is unlikely this has ever been tested. */ | |
2941 | tcg_gen_ld32u_i64(o->out, cpu_env, offsetof(CPUS390XState, cpu_num)); | |
2942 | return NO_EXIT; | |
2943 | } | |
2944 | ||
434c91a5 RH |
2945 | static ExitStatus op_stck(DisasContext *s, DisasOps *o) |
2946 | { | |
2947 | gen_helper_stck(o->out, cpu_env); | |
2948 | /* ??? We don't implement clock states. */ | |
2949 | gen_op_movi_cc(s, 0); | |
2950 | return NO_EXIT; | |
39a5003c RH |
2951 | } |
2952 | ||
2953 | static ExitStatus op_stcke(DisasContext *s, DisasOps *o) | |
2954 | { | |
2955 | TCGv_i64 c1 = tcg_temp_new_i64(); | |
2956 | TCGv_i64 c2 = tcg_temp_new_i64(); | |
2957 | gen_helper_stck(c1, cpu_env); | |
2958 | /* Shift the 64-bit value into its place as a zero-extended | |
2959 | 104-bit value. Note that "bit positions 64-103 are always | |
2960 | non-zero so that they compare differently to STCK"; we set | |
2961 | the least significant bit to 1. */ | |
2962 | tcg_gen_shli_i64(c2, c1, 56); | |
2963 | tcg_gen_shri_i64(c1, c1, 8); | |
2964 | tcg_gen_ori_i64(c2, c2, 0x10000); | |
2965 | tcg_gen_qemu_st64(c1, o->in2, get_mem_index(s)); | |
2966 | tcg_gen_addi_i64(o->in2, o->in2, 8); | |
2967 | tcg_gen_qemu_st64(c2, o->in2, get_mem_index(s)); | |
2968 | tcg_temp_free_i64(c1); | |
2969 | tcg_temp_free_i64(c2); | |
2970 | /* ??? We don't implement clock states. */ | |
2971 | gen_op_movi_cc(s, 0); | |
2972 | return NO_EXIT; | |
434c91a5 RH |
2973 | } |
2974 | ||
dd3eb7b5 RH |
2975 | static ExitStatus op_sckc(DisasContext *s, DisasOps *o) |
2976 | { | |
2977 | check_privileged(s); | |
2978 | gen_helper_sckc(cpu_env, o->in2); | |
2979 | return NO_EXIT; | |
2980 | } | |
2981 | ||
2982 | static ExitStatus op_stckc(DisasContext *s, DisasOps *o) | |
2983 | { | |
2984 | check_privileged(s); | |
2985 | gen_helper_stckc(o->out, cpu_env); | |
2986 | return NO_EXIT; | |
2987 | } | |
2988 | ||
3e398cf9 RH |
2989 | static ExitStatus op_stctg(DisasContext *s, DisasOps *o) |
2990 | { | |
2991 | TCGv_i32 r1 = tcg_const_i32(get_field(s->fields, r1)); | |
2992 | TCGv_i32 r3 = tcg_const_i32(get_field(s->fields, r3)); | |
2993 | check_privileged(s); | |
2994 | potential_page_fault(s); | |
2995 | gen_helper_stctg(cpu_env, r1, o->in2, r3); | |
2996 | tcg_temp_free_i32(r1); | |
2997 | tcg_temp_free_i32(r3); | |
2998 | return NO_EXIT; | |
2999 | } | |
3000 | ||
504488b8 RH |
3001 | static ExitStatus op_stctl(DisasContext *s, DisasOps *o) |
3002 | { | |
3003 | TCGv_i32 r1 = tcg_const_i32(get_field(s->fields, r1)); | |
3004 | TCGv_i32 r3 = tcg_const_i32(get_field(s->fields, r3)); | |
3005 | check_privileged(s); | |
3006 | potential_page_fault(s); | |
3007 | gen_helper_stctl(cpu_env, r1, o->in2, r3); | |
3008 | tcg_temp_free_i32(r1); | |
3009 | tcg_temp_free_i32(r3); | |
3010 | return NO_EXIT; | |
3011 | } | |
3012 | ||
71bd6669 RH |
3013 | static ExitStatus op_stidp(DisasContext *s, DisasOps *o) |
3014 | { | |
3015 | check_privileged(s); | |
3016 | tcg_gen_ld32u_i64(o->out, cpu_env, offsetof(CPUS390XState, cpu_num)); | |
3017 | return NO_EXIT; | |
3018 | } | |
3019 | ||
c4f0a863 RH |
3020 | static ExitStatus op_spt(DisasContext *s, DisasOps *o) |
3021 | { | |
3022 | check_privileged(s); | |
3023 | gen_helper_spt(cpu_env, o->in2); | |
3024 | return NO_EXIT; | |
3025 | } | |
3026 | ||
fc778b55 RH |
3027 | static ExitStatus op_stfl(DisasContext *s, DisasOps *o) |
3028 | { | |
3029 | TCGv_i64 f, a; | |
3030 | /* We really ought to have more complete indication of facilities | |
3031 | that we implement. Address this when STFLE is implemented. */ | |
3032 | check_privileged(s); | |
3033 | f = tcg_const_i64(0xc0000000); | |
3034 | a = tcg_const_i64(200); | |
3035 | tcg_gen_qemu_st32(f, a, get_mem_index(s)); | |
3036 | tcg_temp_free_i64(f); | |
3037 | tcg_temp_free_i64(a); | |
3038 | return NO_EXIT; | |
3039 | } | |
3040 | ||
c4f0a863 RH |
3041 | static ExitStatus op_stpt(DisasContext *s, DisasOps *o) |
3042 | { | |
3043 | check_privileged(s); | |
3044 | gen_helper_stpt(o->out, cpu_env); | |
3045 | return NO_EXIT; | |
3046 | } | |
3047 | ||
d14b3e09 RH |
3048 | static ExitStatus op_stsi(DisasContext *s, DisasOps *o) |
3049 | { | |
3050 | check_privileged(s); | |
3051 | potential_page_fault(s); | |
3052 | gen_helper_stsi(cc_op, cpu_env, o->in2, regs[0], regs[1]); | |
3053 | set_cc_static(s); | |
3054 | return NO_EXIT; | |
3055 | } | |
3056 | ||
e805a0d3 RH |
3057 | static ExitStatus op_spx(DisasContext *s, DisasOps *o) |
3058 | { | |
3059 | check_privileged(s); | |
3060 | gen_helper_spx(cpu_env, o->in2); | |
3061 | return NO_EXIT; | |
3062 | } | |
3063 | ||
2c423fc0 RH |
3064 | static ExitStatus op_subchannel(DisasContext *s, DisasOps *o) |
3065 | { | |
3066 | check_privileged(s); | |
3067 | /* Not operational. */ | |
3068 | gen_op_movi_cc(s, 3); | |
3069 | return NO_EXIT; | |
3070 | } | |
3071 | ||
e805a0d3 RH |
3072 | static ExitStatus op_stpx(DisasContext *s, DisasOps *o) |
3073 | { | |
3074 | check_privileged(s); | |
3075 | tcg_gen_ld_i64(o->out, cpu_env, offsetof(CPUS390XState, psa)); | |
3076 | tcg_gen_andi_i64(o->out, o->out, 0x7fffe000); | |
3077 | return NO_EXIT; | |
3078 | } | |
3079 | ||
145cdb40 RH |
3080 | static ExitStatus op_stnosm(DisasContext *s, DisasOps *o) |
3081 | { | |
3082 | uint64_t i2 = get_field(s->fields, i2); | |
3083 | TCGv_i64 t; | |
3084 | ||
3085 | check_privileged(s); | |
3086 | ||
3087 | /* It is important to do what the instruction name says: STORE THEN. | |
3088 | If we let the output hook perform the store then if we fault and | |
3089 | restart, we'll have the wrong SYSTEM MASK in place. */ | |
3090 | t = tcg_temp_new_i64(); | |
3091 | tcg_gen_shri_i64(t, psw_mask, 56); | |
3092 | tcg_gen_qemu_st8(t, o->addr1, get_mem_index(s)); | |
3093 | tcg_temp_free_i64(t); | |
3094 | ||
3095 | if (s->fields->op == 0xac) { | |
3096 | tcg_gen_andi_i64(psw_mask, psw_mask, | |
3097 | (i2 << 56) | 0x00ffffffffffffffull); | |
3098 | } else { | |
3099 | tcg_gen_ori_i64(psw_mask, psw_mask, i2 << 56); | |
3100 | } | |
3101 | return NO_EXIT; | |
3102 | } | |
204504e2 RH |
3103 | |
3104 | static ExitStatus op_stura(DisasContext *s, DisasOps *o) | |
3105 | { | |
3106 | check_privileged(s); | |
3107 | potential_page_fault(s); | |
3108 | gen_helper_stura(cpu_env, o->in2, o->in1); | |
3109 | return NO_EXIT; | |
3110 | } | |
7d30bb73 RH |
3111 | #endif |
3112 | ||
2b280b97 RH |
3113 | static ExitStatus op_st8(DisasContext *s, DisasOps *o) |
3114 | { | |
3115 | tcg_gen_qemu_st8(o->in1, o->in2, get_mem_index(s)); | |
3116 | return NO_EXIT; | |
3117 | } | |
3118 | ||
3119 | static ExitStatus op_st16(DisasContext *s, DisasOps *o) | |
3120 | { | |
3121 | tcg_gen_qemu_st16(o->in1, o->in2, get_mem_index(s)); | |
3122 | return NO_EXIT; | |
3123 | } | |
3124 | ||
3125 | static ExitStatus op_st32(DisasContext *s, DisasOps *o) | |
3126 | { | |
3127 | tcg_gen_qemu_st32(o->in1, o->in2, get_mem_index(s)); | |
3128 | return NO_EXIT; | |
3129 | } | |
3130 | ||
3131 | static ExitStatus op_st64(DisasContext *s, DisasOps *o) | |
3132 | { | |
3133 | tcg_gen_qemu_st64(o->in1, o->in2, get_mem_index(s)); | |
3134 | return NO_EXIT; | |
3135 | } | |
3136 | ||
7df3e93a RH |
3137 | static ExitStatus op_stam(DisasContext *s, DisasOps *o) |
3138 | { | |
3139 | TCGv_i32 r1 = tcg_const_i32(get_field(s->fields, r1)); | |
3140 | TCGv_i32 r3 = tcg_const_i32(get_field(s->fields, r3)); | |
3141 | potential_page_fault(s); | |
3142 | gen_helper_stam(cpu_env, r1, o->in2, r3); | |
3143 | tcg_temp_free_i32(r1); | |
3144 | tcg_temp_free_i32(r3); | |
3145 | return NO_EXIT; | |
3146 | } | |
3147 | ||
2ae68059 RH |
3148 | static ExitStatus op_stcm(DisasContext *s, DisasOps *o) |
3149 | { | |
3150 | int m3 = get_field(s->fields, m3); | |
3151 | int pos, base = s->insn->data; | |
3152 | TCGv_i64 tmp = tcg_temp_new_i64(); | |
3153 | ||
3154 | pos = base + ctz32(m3) * 8; | |
3155 | switch (m3) { | |
3156 | case 0xf: | |
3157 | /* Effectively a 32-bit store. */ | |
3158 | tcg_gen_shri_i64(tmp, o->in1, pos); | |
3159 | tcg_gen_qemu_st32(tmp, o->in2, get_mem_index(s)); | |
3160 | break; | |
3161 | ||
3162 | case 0xc: | |
3163 | case 0x6: | |
3164 | case 0x3: | |
3165 | /* Effectively a 16-bit store. */ | |
3166 | tcg_gen_shri_i64(tmp, o->in1, pos); | |
3167 | tcg_gen_qemu_st16(tmp, o->in2, get_mem_index(s)); | |
3168 | break; | |
3169 | ||
3170 | case 0x8: | |
3171 | case 0x4: | |
3172 | case 0x2: | |
3173 | case 0x1: | |
3174 | /* Effectively an 8-bit store. */ | |
3175 | tcg_gen_shri_i64(tmp, o->in1, pos); | |
3176 | tcg_gen_qemu_st8(tmp, o->in2, get_mem_index(s)); | |
3177 | break; | |
3178 | ||
3179 | default: | |
3180 | /* This is going to be a sequence of shifts and stores. */ | |
3181 | pos = base + 32 - 8; | |
3182 | while (m3) { | |
3183 | if (m3 & 0x8) { | |
3184 | tcg_gen_shri_i64(tmp, o->in1, pos); | |
3185 | tcg_gen_qemu_st8(tmp, o->in2, get_mem_index(s)); | |
3186 | tcg_gen_addi_i64(o->in2, o->in2, 1); | |
3187 | } | |
3188 | m3 = (m3 << 1) & 0xf; | |
3189 | pos -= 8; | |
3190 | } | |
3191 | break; | |
3192 | } | |
3193 | tcg_temp_free_i64(tmp); | |
3194 | return NO_EXIT; | |
3195 | } | |
3196 | ||
77f8d6c3 RH |
3197 | static ExitStatus op_stm(DisasContext *s, DisasOps *o) |
3198 | { | |
3199 | int r1 = get_field(s->fields, r1); | |
3200 | int r3 = get_field(s->fields, r3); | |
3201 | int size = s->insn->data; | |
3202 | TCGv_i64 tsize = tcg_const_i64(size); | |
3203 | ||
3204 | while (1) { | |
3205 | if (size == 8) { | |
3206 | tcg_gen_qemu_st64(regs[r1], o->in2, get_mem_index(s)); | |
3207 | } else { | |
3208 | tcg_gen_qemu_st32(regs[r1], o->in2, get_mem_index(s)); | |
3209 | } | |
3210 | if (r1 == r3) { | |
3211 | break; | |
3212 | } | |
3213 | tcg_gen_add_i64(o->in2, o->in2, tsize); | |
3214 | r1 = (r1 + 1) & 15; | |
3215 | } | |
3216 | ||
3217 | tcg_temp_free_i64(tsize); | |
3218 | return NO_EXIT; | |
3219 | } | |
3220 | ||
3221 | static ExitStatus op_stmh(DisasContext *s, DisasOps *o) | |
3222 | { | |
3223 | int r1 = get_field(s->fields, r1); | |
3224 | int r3 = get_field(s->fields, r3); | |
3225 | TCGv_i64 t = tcg_temp_new_i64(); | |
3226 | TCGv_i64 t4 = tcg_const_i64(4); | |
3227 | TCGv_i64 t32 = tcg_const_i64(32); | |
3228 | ||
3229 | while (1) { | |
3230 | tcg_gen_shl_i64(t, regs[r1], t32); | |
3231 | tcg_gen_qemu_st32(t, o->in2, get_mem_index(s)); | |
3232 | if (r1 == r3) { | |
3233 | break; | |
3234 | } | |
3235 | tcg_gen_add_i64(o->in2, o->in2, t4); | |
3236 | r1 = (r1 + 1) & 15; | |
3237 | } | |
3238 | ||
3239 | tcg_temp_free_i64(t); | |
3240 | tcg_temp_free_i64(t4); | |
3241 | tcg_temp_free_i64(t32); | |
3242 | return NO_EXIT; | |
3243 | } | |
3244 | ||
4600c994 RH |
3245 | static ExitStatus op_srst(DisasContext *s, DisasOps *o) |
3246 | { | |
3247 | potential_page_fault(s); | |
3248 | gen_helper_srst(o->in1, cpu_env, regs[0], o->in1, o->in2); | |
3249 | set_cc_static(s); | |
3250 | return_low128(o->in2); | |
3251 | return NO_EXIT; | |
3252 | } | |
3253 | ||
ad044d09 RH |
3254 | static ExitStatus op_sub(DisasContext *s, DisasOps *o) |
3255 | { | |
3256 | tcg_gen_sub_i64(o->out, o->in1, o->in2); | |
3257 | return NO_EXIT; | |
3258 | } | |
3259 | ||
4e4bb438 RH |
3260 | static ExitStatus op_subb(DisasContext *s, DisasOps *o) |
3261 | { | |
3262 | TCGv_i64 cc; | |
3263 | ||
3264 | assert(!o->g_in2); | |
3265 | tcg_gen_not_i64(o->in2, o->in2); | |
3266 | tcg_gen_add_i64(o->out, o->in1, o->in2); | |
3267 | ||
3268 | /* XXX possible optimization point */ | |
3269 | gen_op_calc_cc(s); | |
3270 | cc = tcg_temp_new_i64(); | |
3271 | tcg_gen_extu_i32_i64(cc, cc_op); | |
3272 | tcg_gen_shri_i64(cc, cc, 1); | |
3273 | tcg_gen_add_i64(o->out, o->out, cc); | |
3274 | tcg_temp_free_i64(cc); | |
3275 | return NO_EXIT; | |
3276 | } | |
3277 | ||
b9836c1a RH |
3278 | static ExitStatus op_svc(DisasContext *s, DisasOps *o) |
3279 | { | |
3280 | TCGv_i32 t; | |
3281 | ||
3282 | update_psw_addr(s); | |
7a6c7067 | 3283 | update_cc_op(s); |
b9836c1a RH |
3284 | |
3285 | t = tcg_const_i32(get_field(s->fields, i1) & 0xff); | |
3286 | tcg_gen_st_i32(t, cpu_env, offsetof(CPUS390XState, int_svc_code)); | |
3287 | tcg_temp_free_i32(t); | |
3288 | ||
3289 | t = tcg_const_i32(s->next_pc - s->pc); | |
3290 | tcg_gen_st_i32(t, cpu_env, offsetof(CPUS390XState, int_svc_ilen)); | |
3291 | tcg_temp_free_i32(t); | |
3292 | ||
3293 | gen_exception(EXCP_SVC); | |
3294 | return EXIT_NORETURN; | |
3295 | } | |
3296 | ||
31aa97d1 RH |
3297 | static ExitStatus op_tceb(DisasContext *s, DisasOps *o) |
3298 | { | |
3299 | gen_helper_tceb(cc_op, o->in1, o->in2); | |
3300 | set_cc_static(s); | |
3301 | return NO_EXIT; | |
3302 | } | |
3303 | ||
3304 | static ExitStatus op_tcdb(DisasContext *s, DisasOps *o) | |
3305 | { | |
3306 | gen_helper_tcdb(cc_op, o->in1, o->in2); | |
3307 | set_cc_static(s); | |
3308 | return NO_EXIT; | |
3309 | } | |
3310 | ||
3311 | static ExitStatus op_tcxb(DisasContext *s, DisasOps *o) | |
3312 | { | |
3313 | gen_helper_tcxb(cc_op, o->out, o->out2, o->in2); | |
3314 | set_cc_static(s); | |
3315 | return NO_EXIT; | |
3316 | } | |
3317 | ||
112bf079 RH |
3318 | #ifndef CONFIG_USER_ONLY |
3319 | static ExitStatus op_tprot(DisasContext *s, DisasOps *o) | |
3320 | { | |
3321 | potential_page_fault(s); | |
3322 | gen_helper_tprot(cc_op, o->addr1, o->in2); | |
3323 | set_cc_static(s); | |
3324 | return NO_EXIT; | |
3325 | } | |
3326 | #endif | |
3327 | ||
0a949039 RH |
3328 | static ExitStatus op_tr(DisasContext *s, DisasOps *o) |
3329 | { | |
3330 | TCGv_i32 l = tcg_const_i32(get_field(s->fields, l1)); | |
3331 | potential_page_fault(s); | |
3332 | gen_helper_tr(cpu_env, l, o->addr1, o->in2); | |
3333 | tcg_temp_free_i32(l); | |
3334 | set_cc_static(s); | |
3335 | return NO_EXIT; | |
3336 | } | |
3337 | ||
3338 | static ExitStatus op_unpk(DisasContext *s, DisasOps *o) | |
3339 | { | |
3340 | TCGv_i32 l = tcg_const_i32(get_field(s->fields, l1)); | |
3341 | potential_page_fault(s); | |
3342 | gen_helper_unpk(cpu_env, l, o->addr1, o->in2); | |
3343 | tcg_temp_free_i32(l); | |
3344 | return NO_EXIT; | |
3345 | } | |
3346 | ||
3347 | static ExitStatus op_xc(DisasContext *s, DisasOps *o) | |
3348 | { | |
3349 | TCGv_i32 l = tcg_const_i32(get_field(s->fields, l1)); | |
3350 | potential_page_fault(s); | |
3351 | gen_helper_xc(cc_op, cpu_env, l, o->addr1, o->in2); | |
3352 | tcg_temp_free_i32(l); | |
3353 | set_cc_static(s); | |
3354 | return NO_EXIT; | |
3355 | } | |
3356 | ||
3bbfbd1f RH |
3357 | static ExitStatus op_xor(DisasContext *s, DisasOps *o) |
3358 | { | |
3359 | tcg_gen_xor_i64(o->out, o->in1, o->in2); | |
3360 | return NO_EXIT; | |
3361 | } | |
3362 | ||
facfc864 RH |
3363 | static ExitStatus op_xori(DisasContext *s, DisasOps *o) |
3364 | { | |
3365 | int shift = s->insn->data & 0xff; | |
3366 | int size = s->insn->data >> 8; | |
3367 | uint64_t mask = ((1ull << size) - 1) << shift; | |
3368 | ||
3369 | assert(!o->g_in2); | |
3370 | tcg_gen_shli_i64(o->in2, o->in2, shift); | |
3371 | tcg_gen_xor_i64(o->out, o->in1, o->in2); | |
3372 | ||
3373 | /* Produce the CC from only the bits manipulated. */ | |
3374 | tcg_gen_andi_i64(cc_dst, o->out, mask); | |
3375 | set_cc_nz_u64(s, cc_dst); | |
3376 | return NO_EXIT; | |
3377 | } | |
3378 | ||
24db8412 RH |
3379 | static ExitStatus op_zero(DisasContext *s, DisasOps *o) |
3380 | { | |
3381 | o->out = tcg_const_i64(0); | |
3382 | return NO_EXIT; | |
3383 | } | |
3384 | ||
3385 | static ExitStatus op_zero2(DisasContext *s, DisasOps *o) | |
3386 | { | |
3387 | o->out = tcg_const_i64(0); | |
3388 | o->out2 = o->out; | |
3389 | o->g_out2 = true; | |
3390 | return NO_EXIT; | |
3391 | } | |
3392 | ||
ad044d09 RH |
3393 | /* ====================================================================== */ |
3394 | /* The "Cc OUTput" generators. Given the generated output (and in some cases | |
3395 | the original inputs), update the various cc data structures in order to | |
3396 | be able to compute the new condition code. */ | |
3397 | ||
b9bca3e5 RH |
3398 | static void cout_abs32(DisasContext *s, DisasOps *o) |
3399 | { | |
3400 | gen_op_update1_cc_i64(s, CC_OP_ABS_32, o->out); | |
3401 | } | |
3402 | ||
3403 | static void cout_abs64(DisasContext *s, DisasOps *o) | |
3404 | { | |
3405 | gen_op_update1_cc_i64(s, CC_OP_ABS_64, o->out); | |
3406 | } | |
3407 | ||
ad044d09 RH |
3408 | static void cout_adds32(DisasContext *s, DisasOps *o) |
3409 | { | |
3410 | gen_op_update3_cc_i64(s, CC_OP_ADD_32, o->in1, o->in2, o->out); | |
3411 | } | |
3412 | ||
3413 | static void cout_adds64(DisasContext *s, DisasOps *o) | |
3414 | { | |
3415 | gen_op_update3_cc_i64(s, CC_OP_ADD_64, o->in1, o->in2, o->out); | |
3416 | } | |
3417 | ||
3418 | static void cout_addu32(DisasContext *s, DisasOps *o) | |
3419 | { | |
3420 | gen_op_update3_cc_i64(s, CC_OP_ADDU_32, o->in1, o->in2, o->out); | |
3421 | } | |
3422 | ||
3423 | static void cout_addu64(DisasContext *s, DisasOps *o) | |
3424 | { | |
3425 | gen_op_update3_cc_i64(s, CC_OP_ADDU_64, o->in1, o->in2, o->out); | |
3426 | } | |
3427 | ||
4e4bb438 RH |
3428 | static void cout_addc32(DisasContext *s, DisasOps *o) |
3429 | { | |
3430 | gen_op_update3_cc_i64(s, CC_OP_ADDC_32, o->in1, o->in2, o->out); | |
3431 | } | |
3432 | ||
3433 | static void cout_addc64(DisasContext *s, DisasOps *o) | |
3434 | { | |
3435 | gen_op_update3_cc_i64(s, CC_OP_ADDC_64, o->in1, o->in2, o->out); | |
3436 | } | |
3437 | ||
a7e836d5 RH |
3438 | static void cout_cmps32(DisasContext *s, DisasOps *o) |
3439 | { | |
3440 | gen_op_update2_cc_i64(s, CC_OP_LTGT_32, o->in1, o->in2); | |
3441 | } | |
3442 | ||
3443 | static void cout_cmps64(DisasContext *s, DisasOps *o) | |
3444 | { | |
3445 | gen_op_update2_cc_i64(s, CC_OP_LTGT_64, o->in1, o->in2); | |
3446 | } | |
3447 | ||
3448 | static void cout_cmpu32(DisasContext *s, DisasOps *o) | |
3449 | { | |
3450 | gen_op_update2_cc_i64(s, CC_OP_LTUGTU_32, o->in1, o->in2); | |
3451 | } | |
3452 | ||
3453 | static void cout_cmpu64(DisasContext *s, DisasOps *o) | |
3454 | { | |
3455 | gen_op_update2_cc_i64(s, CC_OP_LTUGTU_64, o->in1, o->in2); | |
3456 | } | |
3457 | ||
587626f8 RH |
3458 | static void cout_f32(DisasContext *s, DisasOps *o) |
3459 | { | |
3460 | gen_op_update1_cc_i64(s, CC_OP_NZ_F32, o->out); | |
3461 | } | |
3462 | ||
3463 | static void cout_f64(DisasContext *s, DisasOps *o) | |
3464 | { | |
3465 | gen_op_update1_cc_i64(s, CC_OP_NZ_F64, o->out); | |
3466 | } | |
3467 | ||
3468 | static void cout_f128(DisasContext *s, DisasOps *o) | |
3469 | { | |
3470 | gen_op_update2_cc_i64(s, CC_OP_NZ_F128, o->out, o->out2); | |
3471 | } | |
3472 | ||
b9bca3e5 RH |
3473 | static void cout_nabs32(DisasContext *s, DisasOps *o) |
3474 | { | |
3475 | gen_op_update1_cc_i64(s, CC_OP_NABS_32, o->out); | |
3476 | } | |
3477 | ||
3478 | static void cout_nabs64(DisasContext *s, DisasOps *o) | |
3479 | { | |
3480 | gen_op_update1_cc_i64(s, CC_OP_NABS_64, o->out); | |
3481 | } | |
3482 | ||
3483 | static void cout_neg32(DisasContext *s, DisasOps *o) | |
3484 | { | |
3485 | gen_op_update1_cc_i64(s, CC_OP_COMP_32, o->out); | |
3486 | } | |
3487 | ||
3488 | static void cout_neg64(DisasContext *s, DisasOps *o) | |
3489 | { | |
3490 | gen_op_update1_cc_i64(s, CC_OP_COMP_64, o->out); | |
3491 | } | |
3492 | ||
3bbfbd1f RH |
3493 | static void cout_nz32(DisasContext *s, DisasOps *o) |
3494 | { | |
3495 | tcg_gen_ext32u_i64(cc_dst, o->out); | |
3496 | gen_op_update1_cc_i64(s, CC_OP_NZ, cc_dst); | |
3497 | } | |
3498 | ||
3499 | static void cout_nz64(DisasContext *s, DisasOps *o) | |
3500 | { | |
3501 | gen_op_update1_cc_i64(s, CC_OP_NZ, o->out); | |
3502 | } | |
3503 | ||
11bf2d73 RH |
3504 | static void cout_s32(DisasContext *s, DisasOps *o) |
3505 | { | |
3506 | gen_op_update1_cc_i64(s, CC_OP_LTGT0_32, o->out); | |
3507 | } | |
3508 | ||
3509 | static void cout_s64(DisasContext *s, DisasOps *o) | |
3510 | { | |
3511 | gen_op_update1_cc_i64(s, CC_OP_LTGT0_64, o->out); | |
3512 | } | |
3513 | ||
ad044d09 RH |
3514 | static void cout_subs32(DisasContext *s, DisasOps *o) |
3515 | { | |
3516 | gen_op_update3_cc_i64(s, CC_OP_SUB_32, o->in1, o->in2, o->out); | |
3517 | } | |
3518 | ||
3519 | static void cout_subs64(DisasContext *s, DisasOps *o) | |
3520 | { | |
3521 | gen_op_update3_cc_i64(s, CC_OP_SUB_64, o->in1, o->in2, o->out); | |
3522 | } | |
3523 | ||
3524 | static void cout_subu32(DisasContext *s, DisasOps *o) | |
3525 | { | |
3526 | gen_op_update3_cc_i64(s, CC_OP_SUBU_32, o->in1, o->in2, o->out); | |
3527 | } | |
3528 | ||
3529 | static void cout_subu64(DisasContext *s, DisasOps *o) | |
3530 | { | |
3531 | gen_op_update3_cc_i64(s, CC_OP_SUBU_64, o->in1, o->in2, o->out); | |
3532 | } | |
3533 | ||
4e4bb438 RH |
3534 | static void cout_subb32(DisasContext *s, DisasOps *o) |
3535 | { | |
3536 | gen_op_update3_cc_i64(s, CC_OP_SUBB_32, o->in1, o->in2, o->out); | |
3537 | } | |
3538 | ||
3539 | static void cout_subb64(DisasContext *s, DisasOps *o) | |
3540 | { | |
3541 | gen_op_update3_cc_i64(s, CC_OP_SUBB_64, o->in1, o->in2, o->out); | |
3542 | } | |
3543 | ||
00d2dc19 RH |
3544 | static void cout_tm32(DisasContext *s, DisasOps *o) |
3545 | { | |
3546 | gen_op_update2_cc_i64(s, CC_OP_TM_32, o->in1, o->in2); | |
3547 | } | |
3548 | ||
3549 | static void cout_tm64(DisasContext *s, DisasOps *o) | |
3550 | { | |
3551 | gen_op_update2_cc_i64(s, CC_OP_TM_64, o->in1, o->in2); | |
3552 | } | |
3553 | ||
ad044d09 RH |
3554 | /* ====================================================================== */ |
3555 | /* The "PREPeration" generators. These initialize the DisasOps.OUT fields | |
3556 | with the TCG register to which we will write. Used in combination with | |
3557 | the "wout" generators, in some cases we need a new temporary, and in | |
3558 | some cases we can write to a TCG global. */ | |
3559 | ||
3560 | static void prep_new(DisasContext *s, DisasFields *f, DisasOps *o) | |
3561 | { | |
3562 | o->out = tcg_temp_new_i64(); | |
3563 | } | |
3564 | ||
891452e5 RH |
3565 | static void prep_new_P(DisasContext *s, DisasFields *f, DisasOps *o) |
3566 | { | |
3567 | o->out = tcg_temp_new_i64(); | |
3568 | o->out2 = tcg_temp_new_i64(); | |
3569 | } | |
3570 | ||
ad044d09 RH |
3571 | static void prep_r1(DisasContext *s, DisasFields *f, DisasOps *o) |
3572 | { | |
3573 | o->out = regs[get_field(f, r1)]; | |
3574 | o->g_out = true; | |
3575 | } | |
3576 | ||
1ac5889f RH |
3577 | static void prep_r1_P(DisasContext *s, DisasFields *f, DisasOps *o) |
3578 | { | |
3579 | /* ??? Specification exception: r1 must be even. */ | |
3580 | int r1 = get_field(f, r1); | |
3581 | o->out = regs[r1]; | |
3582 | o->out2 = regs[(r1 + 1) & 15]; | |
3583 | o->g_out = o->g_out2 = true; | |
3584 | } | |
3585 | ||
587626f8 RH |
3586 | static void prep_f1(DisasContext *s, DisasFields *f, DisasOps *o) |
3587 | { | |
3588 | o->out = fregs[get_field(f, r1)]; | |
3589 | o->g_out = true; | |
3590 | } | |
3591 | ||
3592 | static void prep_x1(DisasContext *s, DisasFields *f, DisasOps *o) | |
3593 | { | |
3594 | /* ??? Specification exception: r1 must be < 14. */ | |
3595 | int r1 = get_field(f, r1); | |
3596 | o->out = fregs[r1]; | |
3597 | o->out2 = fregs[(r1 + 2) & 15]; | |
3598 | o->g_out = o->g_out2 = true; | |
3599 | } | |
3600 | ||
ad044d09 RH |
3601 | /* ====================================================================== */ |
3602 | /* The "Write OUTput" generators. These generally perform some non-trivial | |
3603 | copy of data to TCG globals, or to main memory. The trivial cases are | |
3604 | generally handled by having a "prep" generator install the TCG global | |
3605 | as the destination of the operation. */ | |
3606 | ||
22c37a08 RH |
3607 | static void wout_r1(DisasContext *s, DisasFields *f, DisasOps *o) |
3608 | { | |
3609 | store_reg(get_field(f, r1), o->out); | |
3610 | } | |
3611 | ||
afdc70be RH |
3612 | static void wout_r1_8(DisasContext *s, DisasFields *f, DisasOps *o) |
3613 | { | |
3614 | int r1 = get_field(f, r1); | |
3615 | tcg_gen_deposit_i64(regs[r1], regs[r1], o->out, 0, 8); | |
3616 | } | |
3617 | ||
d54f5865 RH |
3618 | static void wout_r1_16(DisasContext *s, DisasFields *f, DisasOps *o) |
3619 | { | |
3620 | int r1 = get_field(f, r1); | |
3621 | tcg_gen_deposit_i64(regs[r1], regs[r1], o->out, 0, 16); | |
3622 | } | |
3623 | ||
ad044d09 RH |
3624 | static void wout_r1_32(DisasContext *s, DisasFields *f, DisasOps *o) |
3625 | { | |
3626 | store_reg32_i64(get_field(f, r1), o->out); | |
3627 | } | |
3628 | ||
891452e5 RH |
3629 | static void wout_r1_P32(DisasContext *s, DisasFields *f, DisasOps *o) |
3630 | { | |
3631 | /* ??? Specification exception: r1 must be even. */ | |
3632 | int r1 = get_field(f, r1); | |
3633 | store_reg32_i64(r1, o->out); | |
3634 | store_reg32_i64((r1 + 1) & 15, o->out2); | |
3635 | } | |
3636 | ||
d87aaf93 RH |
3637 | static void wout_r1_D32(DisasContext *s, DisasFields *f, DisasOps *o) |
3638 | { | |
3639 | /* ??? Specification exception: r1 must be even. */ | |
3640 | int r1 = get_field(f, r1); | |
3641 | store_reg32_i64((r1 + 1) & 15, o->out); | |
3642 | tcg_gen_shri_i64(o->out, o->out, 32); | |
3643 | store_reg32_i64(r1, o->out); | |
3644 | } | |
22c37a08 | 3645 | |
d764a8d1 RH |
3646 | static void wout_e1(DisasContext *s, DisasFields *f, DisasOps *o) |
3647 | { | |
3648 | store_freg32_i64(get_field(f, r1), o->out); | |
3649 | } | |
3650 | ||
3651 | static void wout_f1(DisasContext *s, DisasFields *f, DisasOps *o) | |
3652 | { | |
3653 | store_freg(get_field(f, r1), o->out); | |
3654 | } | |
3655 | ||
3656 | static void wout_x1(DisasContext *s, DisasFields *f, DisasOps *o) | |
3657 | { | |
587626f8 | 3658 | /* ??? Specification exception: r1 must be < 14. */ |
d764a8d1 RH |
3659 | int f1 = get_field(s->fields, r1); |
3660 | store_freg(f1, o->out); | |
3661 | store_freg((f1 + 2) & 15, o->out2); | |
3662 | } | |
3663 | ||
22c37a08 RH |
3664 | static void wout_cond_r1r2_32(DisasContext *s, DisasFields *f, DisasOps *o) |
3665 | { | |
3666 | if (get_field(f, r1) != get_field(f, r2)) { | |
3667 | store_reg32_i64(get_field(f, r1), o->out); | |
3668 | } | |
3669 | } | |
d87aaf93 | 3670 | |
d764a8d1 RH |
3671 | static void wout_cond_e1e2(DisasContext *s, DisasFields *f, DisasOps *o) |
3672 | { | |
3673 | if (get_field(f, r1) != get_field(f, r2)) { | |
3674 | store_freg32_i64(get_field(f, r1), o->out); | |
3675 | } | |
3676 | } | |
3677 | ||
6a04d76a RH |
3678 | static void wout_m1_8(DisasContext *s, DisasFields *f, DisasOps *o) |
3679 | { | |
3680 | tcg_gen_qemu_st8(o->out, o->addr1, get_mem_index(s)); | |
3681 | } | |
3682 | ||
3683 | static void wout_m1_16(DisasContext *s, DisasFields *f, DisasOps *o) | |
3684 | { | |
3685 | tcg_gen_qemu_st16(o->out, o->addr1, get_mem_index(s)); | |
3686 | } | |
3687 | ||
ad044d09 RH |
3688 | static void wout_m1_32(DisasContext *s, DisasFields *f, DisasOps *o) |
3689 | { | |
3690 | tcg_gen_qemu_st32(o->out, o->addr1, get_mem_index(s)); | |
3691 | } | |
3692 | ||
3693 | static void wout_m1_64(DisasContext *s, DisasFields *f, DisasOps *o) | |
3694 | { | |
3695 | tcg_gen_qemu_st64(o->out, o->addr1, get_mem_index(s)); | |
3696 | } | |
3697 | ||
ea20490f RH |
3698 | static void wout_m2_32(DisasContext *s, DisasFields *f, DisasOps *o) |
3699 | { | |
3700 | tcg_gen_qemu_st32(o->out, o->in2, get_mem_index(s)); | |
3701 | } | |
3702 | ||
ad044d09 RH |
3703 | /* ====================================================================== */ |
3704 | /* The "INput 1" generators. These load the first operand to an insn. */ | |
3705 | ||
3706 | static void in1_r1(DisasContext *s, DisasFields *f, DisasOps *o) | |
3707 | { | |
3708 | o->in1 = load_reg(get_field(f, r1)); | |
3709 | } | |
3710 | ||
d1c04a2b RH |
3711 | static void in1_r1_o(DisasContext *s, DisasFields *f, DisasOps *o) |
3712 | { | |
3713 | o->in1 = regs[get_field(f, r1)]; | |
3714 | o->g_in1 = true; | |
3715 | } | |
3716 | ||
cbe24bfa RH |
3717 | static void in1_r1_32s(DisasContext *s, DisasFields *f, DisasOps *o) |
3718 | { | |
3719 | o->in1 = tcg_temp_new_i64(); | |
3720 | tcg_gen_ext32s_i64(o->in1, regs[get_field(f, r1)]); | |
3721 | } | |
3722 | ||
3723 | static void in1_r1_32u(DisasContext *s, DisasFields *f, DisasOps *o) | |
3724 | { | |
3725 | o->in1 = tcg_temp_new_i64(); | |
3726 | tcg_gen_ext32u_i64(o->in1, regs[get_field(f, r1)]); | |
3727 | } | |
3728 | ||
32a44d58 RH |
3729 | static void in1_r1_sr32(DisasContext *s, DisasFields *f, DisasOps *o) |
3730 | { | |
3731 | o->in1 = tcg_temp_new_i64(); | |
3732 | tcg_gen_shri_i64(o->in1, regs[get_field(f, r1)], 32); | |
3733 | } | |
3734 | ||
1ac5889f RH |
3735 | static void in1_r1p1(DisasContext *s, DisasFields *f, DisasOps *o) |
3736 | { | |
3737 | /* ??? Specification exception: r1 must be even. */ | |
3738 | int r1 = get_field(f, r1); | |
3739 | o->in1 = load_reg((r1 + 1) & 15); | |
3740 | } | |
3741 | ||
d87aaf93 RH |
3742 | static void in1_r1p1_32s(DisasContext *s, DisasFields *f, DisasOps *o) |
3743 | { | |
3744 | /* ??? Specification exception: r1 must be even. */ | |
3745 | int r1 = get_field(f, r1); | |
3746 | o->in1 = tcg_temp_new_i64(); | |
3747 | tcg_gen_ext32s_i64(o->in1, regs[(r1 + 1) & 15]); | |
3748 | } | |
3749 | ||
3750 | static void in1_r1p1_32u(DisasContext *s, DisasFields *f, DisasOps *o) | |
3751 | { | |
3752 | /* ??? Specification exception: r1 must be even. */ | |
3753 | int r1 = get_field(f, r1); | |
3754 | o->in1 = tcg_temp_new_i64(); | |
3755 | tcg_gen_ext32u_i64(o->in1, regs[(r1 + 1) & 15]); | |
3756 | } | |
3757 | ||
891452e5 RH |
3758 | static void in1_r1_D32(DisasContext *s, DisasFields *f, DisasOps *o) |
3759 | { | |
3760 | /* ??? Specification exception: r1 must be even. */ | |
3761 | int r1 = get_field(f, r1); | |
3762 | o->in1 = tcg_temp_new_i64(); | |
3763 | tcg_gen_concat32_i64(o->in1, regs[r1 + 1], regs[r1]); | |
3764 | } | |
3765 | ||
ad044d09 RH |
3766 | static void in1_r2(DisasContext *s, DisasFields *f, DisasOps *o) |
3767 | { | |
3768 | o->in1 = load_reg(get_field(f, r2)); | |
3769 | } | |
3770 | ||
3771 | static void in1_r3(DisasContext *s, DisasFields *f, DisasOps *o) | |
3772 | { | |
3773 | o->in1 = load_reg(get_field(f, r3)); | |
3774 | } | |
3775 | ||
cbe24bfa RH |
3776 | static void in1_r3_o(DisasContext *s, DisasFields *f, DisasOps *o) |
3777 | { | |
3778 | o->in1 = regs[get_field(f, r3)]; | |
3779 | o->g_in1 = true; | |
3780 | } | |
3781 | ||
3782 | static void in1_r3_32s(DisasContext *s, DisasFields *f, DisasOps *o) | |
3783 | { | |
3784 | o->in1 = tcg_temp_new_i64(); | |
3785 | tcg_gen_ext32s_i64(o->in1, regs[get_field(f, r3)]); | |
3786 | } | |
3787 | ||
3788 | static void in1_r3_32u(DisasContext *s, DisasFields *f, DisasOps *o) | |
3789 | { | |
3790 | o->in1 = tcg_temp_new_i64(); | |
3791 | tcg_gen_ext32u_i64(o->in1, regs[get_field(f, r3)]); | |
3792 | } | |
3793 | ||
00574261 RH |
3794 | static void in1_e1(DisasContext *s, DisasFields *f, DisasOps *o) |
3795 | { | |
3796 | o->in1 = load_freg32_i64(get_field(f, r1)); | |
3797 | } | |
3798 | ||
3799 | static void in1_f1_o(DisasContext *s, DisasFields *f, DisasOps *o) | |
3800 | { | |
3801 | o->in1 = fregs[get_field(f, r1)]; | |
3802 | o->g_in1 = true; | |
3803 | } | |
3804 | ||
587626f8 RH |
3805 | static void in1_x1_o(DisasContext *s, DisasFields *f, DisasOps *o) |
3806 | { | |
3807 | /* ??? Specification exception: r1 must be < 14. */ | |
3808 | int r1 = get_field(f, r1); | |
3809 | o->out = fregs[r1]; | |
3810 | o->out2 = fregs[(r1 + 2) & 15]; | |
3811 | o->g_out = o->g_out2 = true; | |
3812 | } | |
3813 | ||
2db014b5 RH |
3814 | static void in1_f3_o(DisasContext *s, DisasFields *f, DisasOps *o) |
3815 | { | |
3816 | o->in1 = fregs[get_field(f, r3)]; | |
3817 | o->g_in1 = true; | |
3818 | } | |
3819 | ||
ad044d09 RH |
3820 | static void in1_la1(DisasContext *s, DisasFields *f, DisasOps *o) |
3821 | { | |
3822 | o->addr1 = get_address(s, 0, get_field(f, b1), get_field(f, d1)); | |
3823 | } | |
3824 | ||
e025e52a RH |
3825 | static void in1_la2(DisasContext *s, DisasFields *f, DisasOps *o) |
3826 | { | |
3827 | int x2 = have_field(f, x2) ? get_field(f, x2) : 0; | |
3828 | o->addr1 = get_address(s, x2, get_field(f, b2), get_field(f, d2)); | |
3829 | } | |
3830 | ||
a7e836d5 RH |
3831 | static void in1_m1_8u(DisasContext *s, DisasFields *f, DisasOps *o) |
3832 | { | |
3833 | in1_la1(s, f, o); | |
3834 | o->in1 = tcg_temp_new_i64(); | |
3835 | tcg_gen_qemu_ld8u(o->in1, o->addr1, get_mem_index(s)); | |
3836 | } | |
3837 | ||
3838 | static void in1_m1_16s(DisasContext *s, DisasFields *f, DisasOps *o) | |
3839 | { | |
3840 | in1_la1(s, f, o); | |
3841 | o->in1 = tcg_temp_new_i64(); | |
3842 | tcg_gen_qemu_ld16s(o->in1, o->addr1, get_mem_index(s)); | |
3843 | } | |
3844 | ||
3845 | static void in1_m1_16u(DisasContext *s, DisasFields *f, DisasOps *o) | |
3846 | { | |
3847 | in1_la1(s, f, o); | |
3848 | o->in1 = tcg_temp_new_i64(); | |
3849 | tcg_gen_qemu_ld16u(o->in1, o->addr1, get_mem_index(s)); | |
3850 | } | |
3851 | ||
ad044d09 RH |
3852 | static void in1_m1_32s(DisasContext *s, DisasFields *f, DisasOps *o) |
3853 | { | |
3854 | in1_la1(s, f, o); | |
3855 | o->in1 = tcg_temp_new_i64(); | |
3856 | tcg_gen_qemu_ld32s(o->in1, o->addr1, get_mem_index(s)); | |
3857 | } | |
3858 | ||
e272b3ac RH |
3859 | static void in1_m1_32u(DisasContext *s, DisasFields *f, DisasOps *o) |
3860 | { | |
3861 | in1_la1(s, f, o); | |
3862 | o->in1 = tcg_temp_new_i64(); | |
3863 | tcg_gen_qemu_ld32u(o->in1, o->addr1, get_mem_index(s)); | |
3864 | } | |
3865 | ||
ad044d09 RH |
3866 | static void in1_m1_64(DisasContext *s, DisasFields *f, DisasOps *o) |
3867 | { | |
3868 | in1_la1(s, f, o); | |
3869 | o->in1 = tcg_temp_new_i64(); | |
3870 | tcg_gen_qemu_ld64(o->in1, o->addr1, get_mem_index(s)); | |
3871 | } | |
3872 | ||
3873 | /* ====================================================================== */ | |
3874 | /* The "INput 2" generators. These load the second operand to an insn. */ | |
3875 | ||
e025e52a RH |
3876 | static void in2_r1_o(DisasContext *s, DisasFields *f, DisasOps *o) |
3877 | { | |
3878 | o->in2 = regs[get_field(f, r1)]; | |
3879 | o->g_in2 = true; | |
3880 | } | |
3881 | ||
3882 | static void in2_r1_16u(DisasContext *s, DisasFields *f, DisasOps *o) | |
3883 | { | |
3884 | o->in2 = tcg_temp_new_i64(); | |
3885 | tcg_gen_ext16u_i64(o->in2, regs[get_field(f, r1)]); | |
3886 | } | |
3887 | ||
3888 | static void in2_r1_32u(DisasContext *s, DisasFields *f, DisasOps *o) | |
3889 | { | |
3890 | o->in2 = tcg_temp_new_i64(); | |
3891 | tcg_gen_ext32u_i64(o->in2, regs[get_field(f, r1)]); | |
3892 | } | |
3893 | ||
ad044d09 RH |
3894 | static void in2_r2(DisasContext *s, DisasFields *f, DisasOps *o) |
3895 | { | |
3896 | o->in2 = load_reg(get_field(f, r2)); | |
3897 | } | |
3898 | ||
d1c04a2b RH |
3899 | static void in2_r2_o(DisasContext *s, DisasFields *f, DisasOps *o) |
3900 | { | |
3901 | o->in2 = regs[get_field(f, r2)]; | |
3902 | o->g_in2 = true; | |
3903 | } | |
3904 | ||
8ac33cdb RH |
3905 | static void in2_r2_nz(DisasContext *s, DisasFields *f, DisasOps *o) |
3906 | { | |
3907 | int r2 = get_field(f, r2); | |
3908 | if (r2 != 0) { | |
3909 | o->in2 = load_reg(r2); | |
3910 | } | |
3911 | } | |
3912 | ||
c698d876 RH |
3913 | static void in2_r2_8s(DisasContext *s, DisasFields *f, DisasOps *o) |
3914 | { | |
3915 | o->in2 = tcg_temp_new_i64(); | |
3916 | tcg_gen_ext8s_i64(o->in2, regs[get_field(f, r2)]); | |
3917 | } | |
3918 | ||
3919 | static void in2_r2_8u(DisasContext *s, DisasFields *f, DisasOps *o) | |
3920 | { | |
3921 | o->in2 = tcg_temp_new_i64(); | |
3922 | tcg_gen_ext8u_i64(o->in2, regs[get_field(f, r2)]); | |
3923 | } | |
3924 | ||
3925 | static void in2_r2_16s(DisasContext *s, DisasFields *f, DisasOps *o) | |
3926 | { | |
3927 | o->in2 = tcg_temp_new_i64(); | |
3928 | tcg_gen_ext16s_i64(o->in2, regs[get_field(f, r2)]); | |
3929 | } | |
3930 | ||
3931 | static void in2_r2_16u(DisasContext *s, DisasFields *f, DisasOps *o) | |
3932 | { | |
3933 | o->in2 = tcg_temp_new_i64(); | |
3934 | tcg_gen_ext16u_i64(o->in2, regs[get_field(f, r2)]); | |
3935 | } | |
3936 | ||
ad044d09 RH |
3937 | static void in2_r3(DisasContext *s, DisasFields *f, DisasOps *o) |
3938 | { | |
3939 | o->in2 = load_reg(get_field(f, r3)); | |
3940 | } | |
3941 | ||
3942 | static void in2_r2_32s(DisasContext *s, DisasFields *f, DisasOps *o) | |
3943 | { | |
3944 | o->in2 = tcg_temp_new_i64(); | |
3945 | tcg_gen_ext32s_i64(o->in2, regs[get_field(f, r2)]); | |
3946 | } | |
3947 | ||
3948 | static void in2_r2_32u(DisasContext *s, DisasFields *f, DisasOps *o) | |
3949 | { | |
3950 | o->in2 = tcg_temp_new_i64(); | |
3951 | tcg_gen_ext32u_i64(o->in2, regs[get_field(f, r2)]); | |
3952 | } | |
3953 | ||
d764a8d1 RH |
3954 | static void in2_e2(DisasContext *s, DisasFields *f, DisasOps *o) |
3955 | { | |
3956 | o->in2 = load_freg32_i64(get_field(f, r2)); | |
3957 | } | |
3958 | ||
3959 | static void in2_f2_o(DisasContext *s, DisasFields *f, DisasOps *o) | |
3960 | { | |
3961 | o->in2 = fregs[get_field(f, r2)]; | |
3962 | o->g_in2 = true; | |
3963 | } | |
3964 | ||
3965 | static void in2_x2_o(DisasContext *s, DisasFields *f, DisasOps *o) | |
3966 | { | |
587626f8 RH |
3967 | /* ??? Specification exception: r1 must be < 14. */ |
3968 | int r2 = get_field(f, r2); | |
3969 | o->in1 = fregs[r2]; | |
3970 | o->in2 = fregs[(r2 + 2) & 15]; | |
d764a8d1 RH |
3971 | o->g_in1 = o->g_in2 = true; |
3972 | } | |
3973 | ||
374724f9 RH |
3974 | static void in2_ra2(DisasContext *s, DisasFields *f, DisasOps *o) |
3975 | { | |
3976 | o->in2 = get_address(s, 0, get_field(f, r2), 0); | |
3977 | } | |
3978 | ||
ad044d09 RH |
3979 | static void in2_a2(DisasContext *s, DisasFields *f, DisasOps *o) |
3980 | { | |
3981 | int x2 = have_field(f, x2) ? get_field(f, x2) : 0; | |
3982 | o->in2 = get_address(s, x2, get_field(f, b2), get_field(f, d2)); | |
3983 | } | |
3984 | ||
a7e836d5 RH |
3985 | static void in2_ri2(DisasContext *s, DisasFields *f, DisasOps *o) |
3986 | { | |
3987 | o->in2 = tcg_const_i64(s->pc + (int64_t)get_field(f, i2) * 2); | |
3988 | } | |
3989 | ||
cbe24bfa RH |
3990 | static void in2_sh32(DisasContext *s, DisasFields *f, DisasOps *o) |
3991 | { | |
3992 | help_l2_shift(s, f, o, 31); | |
3993 | } | |
3994 | ||
3995 | static void in2_sh64(DisasContext *s, DisasFields *f, DisasOps *o) | |
3996 | { | |
3997 | help_l2_shift(s, f, o, 63); | |
3998 | } | |
3999 | ||
afdc70be RH |
4000 | static void in2_m2_8u(DisasContext *s, DisasFields *f, DisasOps *o) |
4001 | { | |
4002 | in2_a2(s, f, o); | |
4003 | tcg_gen_qemu_ld8u(o->in2, o->in2, get_mem_index(s)); | |
4004 | } | |
4005 | ||
d82287de RH |
4006 | static void in2_m2_16s(DisasContext *s, DisasFields *f, DisasOps *o) |
4007 | { | |
4008 | in2_a2(s, f, o); | |
4009 | tcg_gen_qemu_ld16s(o->in2, o->in2, get_mem_index(s)); | |
4010 | } | |
4011 | ||
d54f5865 RH |
4012 | static void in2_m2_16u(DisasContext *s, DisasFields *f, DisasOps *o) |
4013 | { | |
4014 | in2_a2(s, f, o); | |
4015 | tcg_gen_qemu_ld16u(o->in2, o->in2, get_mem_index(s)); | |
4016 | } | |
4017 | ||
ad044d09 RH |
4018 | static void in2_m2_32s(DisasContext *s, DisasFields *f, DisasOps *o) |
4019 | { | |
4020 | in2_a2(s, f, o); | |
4021 | tcg_gen_qemu_ld32s(o->in2, o->in2, get_mem_index(s)); | |
4022 | } | |
4023 | ||
4024 | static void in2_m2_32u(DisasContext *s, DisasFields *f, DisasOps *o) | |
4025 | { | |
4026 | in2_a2(s, f, o); | |
4027 | tcg_gen_qemu_ld32u(o->in2, o->in2, get_mem_index(s)); | |
4028 | } | |
4029 | ||
4030 | static void in2_m2_64(DisasContext *s, DisasFields *f, DisasOps *o) | |
4031 | { | |
4032 | in2_a2(s, f, o); | |
4033 | tcg_gen_qemu_ld64(o->in2, o->in2, get_mem_index(s)); | |
4034 | } | |
4035 | ||
a7e836d5 RH |
4036 | static void in2_mri2_16u(DisasContext *s, DisasFields *f, DisasOps *o) |
4037 | { | |
4038 | in2_ri2(s, f, o); | |
4039 | tcg_gen_qemu_ld16u(o->in2, o->in2, get_mem_index(s)); | |
4040 | } | |
4041 | ||
4042 | static void in2_mri2_32s(DisasContext *s, DisasFields *f, DisasOps *o) | |
4043 | { | |
4044 | in2_ri2(s, f, o); | |
4045 | tcg_gen_qemu_ld32s(o->in2, o->in2, get_mem_index(s)); | |
4046 | } | |
4047 | ||
4048 | static void in2_mri2_32u(DisasContext *s, DisasFields *f, DisasOps *o) | |
4049 | { | |
4050 | in2_ri2(s, f, o); | |
4051 | tcg_gen_qemu_ld32u(o->in2, o->in2, get_mem_index(s)); | |
4052 | } | |
4053 | ||
4054 | static void in2_mri2_64(DisasContext *s, DisasFields *f, DisasOps *o) | |
4055 | { | |
4056 | in2_ri2(s, f, o); | |
4057 | tcg_gen_qemu_ld64(o->in2, o->in2, get_mem_index(s)); | |
4058 | } | |
4059 | ||
ad044d09 RH |
4060 | static void in2_i2(DisasContext *s, DisasFields *f, DisasOps *o) |
4061 | { | |
4062 | o->in2 = tcg_const_i64(get_field(f, i2)); | |
4063 | } | |
4064 | ||
a7e836d5 RH |
4065 | static void in2_i2_8u(DisasContext *s, DisasFields *f, DisasOps *o) |
4066 | { | |
4067 | o->in2 = tcg_const_i64((uint8_t)get_field(f, i2)); | |
4068 | } | |
4069 | ||
4070 | static void in2_i2_16u(DisasContext *s, DisasFields *f, DisasOps *o) | |
4071 | { | |
4072 | o->in2 = tcg_const_i64((uint16_t)get_field(f, i2)); | |
4073 | } | |
4074 | ||
ad044d09 RH |
4075 | static void in2_i2_32u(DisasContext *s, DisasFields *f, DisasOps *o) |
4076 | { | |
4077 | o->in2 = tcg_const_i64((uint32_t)get_field(f, i2)); | |
4078 | } | |
4079 | ||
ade9dea4 RH |
4080 | static void in2_i2_16u_shl(DisasContext *s, DisasFields *f, DisasOps *o) |
4081 | { | |
4082 | uint64_t i2 = (uint16_t)get_field(f, i2); | |
4083 | o->in2 = tcg_const_i64(i2 << s->insn->data); | |
4084 | } | |
4085 | ||
4086 | static void in2_i2_32u_shl(DisasContext *s, DisasFields *f, DisasOps *o) | |
4087 | { | |
4088 | uint64_t i2 = (uint32_t)get_field(f, i2); | |
4089 | o->in2 = tcg_const_i64(i2 << s->insn->data); | |
4090 | } | |
4091 | ||
ad044d09 RH |
4092 | /* ====================================================================== */ |
4093 | ||
4094 | /* Find opc within the table of insns. This is formulated as a switch | |
4095 | statement so that (1) we get compile-time notice of cut-paste errors | |
4096 | for duplicated opcodes, and (2) the compiler generates the binary | |
4097 | search tree, rather than us having to post-process the table. */ | |
4098 | ||
4099 | #define C(OPC, NM, FT, FC, I1, I2, P, W, OP, CC) \ | |
4100 | D(OPC, NM, FT, FC, I1, I2, P, W, OP, CC, 0) | |
4101 | ||
4102 | #define D(OPC, NM, FT, FC, I1, I2, P, W, OP, CC, D) insn_ ## NM, | |
4103 | ||
4104 | enum DisasInsnEnum { | |
4105 | #include "insn-data.def" | |
4106 | }; | |
4107 | ||
4108 | #undef D | |
4109 | #define D(OPC, NM, FT, FC, I1, I2, P, W, OP, CC, D) { \ | |
4110 | .opc = OPC, \ | |
4111 | .fmt = FMT_##FT, \ | |
4112 | .fac = FAC_##FC, \ | |
4113 | .name = #NM, \ | |
4114 | .help_in1 = in1_##I1, \ | |
4115 | .help_in2 = in2_##I2, \ | |
4116 | .help_prep = prep_##P, \ | |
4117 | .help_wout = wout_##W, \ | |
4118 | .help_cout = cout_##CC, \ | |
4119 | .help_op = op_##OP, \ | |
4120 | .data = D \ | |
4121 | }, | |
4122 | ||
4123 | /* Allow 0 to be used for NULL in the table below. */ | |
4124 | #define in1_0 NULL | |
4125 | #define in2_0 NULL | |
4126 | #define prep_0 NULL | |
4127 | #define wout_0 NULL | |
4128 | #define cout_0 NULL | |
4129 | #define op_0 NULL | |
4130 | ||
4131 | static const DisasInsn insn_info[] = { | |
4132 | #include "insn-data.def" | |
4133 | }; | |
4134 | ||
4135 | #undef D | |
4136 | #define D(OPC, NM, FT, FC, I1, I2, P, W, OP, CC, D) \ | |
4137 | case OPC: return &insn_info[insn_ ## NM]; | |
4138 | ||
4139 | static const DisasInsn *lookup_opc(uint16_t opc) | |
4140 | { | |
4141 | switch (opc) { | |
4142 | #include "insn-data.def" | |
4143 | default: | |
4144 | return NULL; | |
4145 | } | |
4146 | } | |
4147 | ||
4148 | #undef D | |
4149 | #undef C | |
4150 | ||
4151 | /* Extract a field from the insn. The INSN should be left-aligned in | |
4152 | the uint64_t so that we can more easily utilize the big-bit-endian | |
4153 | definitions we extract from the Principals of Operation. */ | |
4154 | ||
4155 | static void extract_field(DisasFields *o, const DisasField *f, uint64_t insn) | |
4156 | { | |
4157 | uint32_t r, m; | |
4158 | ||
4159 | if (f->size == 0) { | |
4160 | return; | |
4161 | } | |
4162 | ||
4163 | /* Zero extract the field from the insn. */ | |
4164 | r = (insn << f->beg) >> (64 - f->size); | |
4165 | ||
4166 | /* Sign-extend, or un-swap the field as necessary. */ | |
4167 | switch (f->type) { | |
4168 | case 0: /* unsigned */ | |
4169 | break; | |
4170 | case 1: /* signed */ | |
4171 | assert(f->size <= 32); | |
4172 | m = 1u << (f->size - 1); | |
4173 | r = (r ^ m) - m; | |
4174 | break; | |
4175 | case 2: /* dl+dh split, signed 20 bit. */ | |
4176 | r = ((int8_t)r << 12) | (r >> 8); | |
4177 | break; | |
4178 | default: | |
4179 | abort(); | |
4180 | } | |
4181 | ||
4182 | /* Validate that the "compressed" encoding we selected above is valid. | |
4183 | I.e. we havn't make two different original fields overlap. */ | |
4184 | assert(((o->presentC >> f->indexC) & 1) == 0); | |
4185 | o->presentC |= 1 << f->indexC; | |
4186 | o->presentO |= 1 << f->indexO; | |
4187 | ||
4188 | o->c[f->indexC] = r; | |
4189 | } | |
4190 | ||
4191 | /* Lookup the insn at the current PC, extracting the operands into O and | |
4192 | returning the info struct for the insn. Returns NULL for invalid insn. */ | |
4193 | ||
4194 | static const DisasInsn *extract_insn(CPUS390XState *env, DisasContext *s, | |
4195 | DisasFields *f) | |
4196 | { | |
4197 | uint64_t insn, pc = s->pc; | |
d5a103cd | 4198 | int op, op2, ilen; |
ad044d09 RH |
4199 | const DisasInsn *info; |
4200 | ||
4201 | insn = ld_code2(env, pc); | |
4202 | op = (insn >> 8) & 0xff; | |
d5a103cd RH |
4203 | ilen = get_ilen(op); |
4204 | s->next_pc = s->pc + ilen; | |
4205 | ||
4206 | switch (ilen) { | |
4207 | case 2: | |
ad044d09 RH |
4208 | insn = insn << 48; |
4209 | break; | |
d5a103cd | 4210 | case 4: |
ad044d09 RH |
4211 | insn = ld_code4(env, pc) << 32; |
4212 | break; | |
d5a103cd | 4213 | case 6: |
ad044d09 RH |
4214 | insn = (insn << 48) | (ld_code4(env, pc + 2) << 16); |
4215 | break; | |
4216 | default: | |
4217 | abort(); | |
4218 | } | |
4219 | ||
4220 | /* We can't actually determine the insn format until we've looked up | |
4221 | the full insn opcode. Which we can't do without locating the | |
4222 | secondary opcode. Assume by default that OP2 is at bit 40; for | |
4223 | those smaller insns that don't actually have a secondary opcode | |
4224 | this will correctly result in OP2 = 0. */ | |
4225 | switch (op) { | |
4226 | case 0x01: /* E */ | |
4227 | case 0x80: /* S */ | |
4228 | case 0x82: /* S */ | |
4229 | case 0x93: /* S */ | |
4230 | case 0xb2: /* S, RRF, RRE */ | |
4231 | case 0xb3: /* RRE, RRD, RRF */ | |
4232 | case 0xb9: /* RRE, RRF */ | |
4233 | case 0xe5: /* SSE, SIL */ | |
4234 | op2 = (insn << 8) >> 56; | |
4235 | break; | |
4236 | case 0xa5: /* RI */ | |
4237 | case 0xa7: /* RI */ | |
4238 | case 0xc0: /* RIL */ | |
4239 | case 0xc2: /* RIL */ | |
4240 | case 0xc4: /* RIL */ | |
4241 | case 0xc6: /* RIL */ | |
4242 | case 0xc8: /* SSF */ | |
4243 | case 0xcc: /* RIL */ | |
4244 | op2 = (insn << 12) >> 60; | |
4245 | break; | |
4246 | case 0xd0 ... 0xdf: /* SS */ | |
4247 | case 0xe1: /* SS */ | |
4248 | case 0xe2: /* SS */ | |
4249 | case 0xe8: /* SS */ | |
4250 | case 0xe9: /* SS */ | |
4251 | case 0xea: /* SS */ | |
4252 | case 0xee ... 0xf3: /* SS */ | |
4253 | case 0xf8 ... 0xfd: /* SS */ | |
4254 | op2 = 0; | |
4255 | break; | |
4256 | default: | |
4257 | op2 = (insn << 40) >> 56; | |
4258 | break; | |
4259 | } | |
4260 | ||
4261 | memset(f, 0, sizeof(*f)); | |
4262 | f->op = op; | |
4263 | f->op2 = op2; | |
4264 | ||
4265 | /* Lookup the instruction. */ | |
4266 | info = lookup_opc(op << 8 | op2); | |
4267 | ||
4268 | /* If we found it, extract the operands. */ | |
4269 | if (info != NULL) { | |
4270 | DisasFormat fmt = info->fmt; | |
4271 | int i; | |
4272 | ||
4273 | for (i = 0; i < NUM_C_FIELD; ++i) { | |
4274 | extract_field(f, &format_info[fmt].op[i], insn); | |
4275 | } | |
4276 | } | |
4277 | return info; | |
4278 | } | |
4279 | ||
4280 | static ExitStatus translate_one(CPUS390XState *env, DisasContext *s) | |
4281 | { | |
4282 | const DisasInsn *insn; | |
4283 | ExitStatus ret = NO_EXIT; | |
4284 | DisasFields f; | |
4285 | DisasOps o; | |
4286 | ||
4f3adfb2 | 4287 | /* Search for the insn in the table. */ |
ad044d09 | 4288 | insn = extract_insn(env, s, &f); |
e023e832 | 4289 | |
4f3adfb2 | 4290 | /* Not found means unimplemented/illegal opcode. */ |
ad044d09 | 4291 | if (insn == NULL) { |
4f3adfb2 RH |
4292 | qemu_log_mask(LOG_UNIMP, "unimplemented opcode 0x%02x%02x\n", |
4293 | f.op, f.op2); | |
4294 | gen_illegal_opcode(s); | |
4295 | return EXIT_NORETURN; | |
ad044d09 RH |
4296 | } |
4297 | ||
4298 | /* Set up the strutures we use to communicate with the helpers. */ | |
4299 | s->insn = insn; | |
4300 | s->fields = &f; | |
4301 | o.g_out = o.g_out2 = o.g_in1 = o.g_in2 = false; | |
4302 | TCGV_UNUSED_I64(o.out); | |
4303 | TCGV_UNUSED_I64(o.out2); | |
4304 | TCGV_UNUSED_I64(o.in1); | |
4305 | TCGV_UNUSED_I64(o.in2); | |
4306 | TCGV_UNUSED_I64(o.addr1); | |
4307 | ||
4308 | /* Implement the instruction. */ | |
4309 | if (insn->help_in1) { | |
4310 | insn->help_in1(s, &f, &o); | |
4311 | } | |
4312 | if (insn->help_in2) { | |
4313 | insn->help_in2(s, &f, &o); | |
4314 | } | |
4315 | if (insn->help_prep) { | |
4316 | insn->help_prep(s, &f, &o); | |
4317 | } | |
4318 | if (insn->help_op) { | |
4319 | ret = insn->help_op(s, &o); | |
4320 | } | |
4321 | if (insn->help_wout) { | |
4322 | insn->help_wout(s, &f, &o); | |
4323 | } | |
4324 | if (insn->help_cout) { | |
4325 | insn->help_cout(s, &o); | |
4326 | } | |
4327 | ||
4328 | /* Free any temporaries created by the helpers. */ | |
4329 | if (!TCGV_IS_UNUSED_I64(o.out) && !o.g_out) { | |
4330 | tcg_temp_free_i64(o.out); | |
4331 | } | |
4332 | if (!TCGV_IS_UNUSED_I64(o.out2) && !o.g_out2) { | |
4333 | tcg_temp_free_i64(o.out2); | |
4334 | } | |
4335 | if (!TCGV_IS_UNUSED_I64(o.in1) && !o.g_in1) { | |
4336 | tcg_temp_free_i64(o.in1); | |
4337 | } | |
4338 | if (!TCGV_IS_UNUSED_I64(o.in2) && !o.g_in2) { | |
4339 | tcg_temp_free_i64(o.in2); | |
4340 | } | |
4341 | if (!TCGV_IS_UNUSED_I64(o.addr1)) { | |
4342 | tcg_temp_free_i64(o.addr1); | |
4343 | } | |
4344 | ||
4345 | /* Advance to the next instruction. */ | |
4346 | s->pc = s->next_pc; | |
4347 | return ret; | |
e023e832 AG |
4348 | } |
4349 | ||
a4e3ad19 | 4350 | static inline void gen_intermediate_code_internal(CPUS390XState *env, |
e023e832 AG |
4351 | TranslationBlock *tb, |
4352 | int search_pc) | |
4353 | { | |
4354 | DisasContext dc; | |
4355 | target_ulong pc_start; | |
4356 | uint64_t next_page_start; | |
4357 | uint16_t *gen_opc_end; | |
4358 | int j, lj = -1; | |
4359 | int num_insns, max_insns; | |
4360 | CPUBreakpoint *bp; | |
ad044d09 | 4361 | ExitStatus status; |
d5a103cd | 4362 | bool do_debug; |
e023e832 AG |
4363 | |
4364 | pc_start = tb->pc; | |
4365 | ||
4366 | /* 31-bit mode */ | |
4367 | if (!(tb->flags & FLAG_MASK_64)) { | |
4368 | pc_start &= 0x7fffffff; | |
4369 | } | |
4370 | ||
e023e832 | 4371 | dc.tb = tb; |
ad044d09 | 4372 | dc.pc = pc_start; |
e023e832 | 4373 | dc.cc_op = CC_OP_DYNAMIC; |
d5a103cd | 4374 | do_debug = dc.singlestep_enabled = env->singlestep_enabled; |
e023e832 | 4375 | |
92414b31 | 4376 | gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE; |
e023e832 AG |
4377 | |
4378 | next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; | |
4379 | ||
4380 | num_insns = 0; | |
4381 | max_insns = tb->cflags & CF_COUNT_MASK; | |
4382 | if (max_insns == 0) { | |
4383 | max_insns = CF_COUNT_MASK; | |
4384 | } | |
4385 | ||
4386 | gen_icount_start(); | |
4387 | ||
4388 | do { | |
e023e832 | 4389 | if (search_pc) { |
92414b31 | 4390 | j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; |
e023e832 AG |
4391 | if (lj < j) { |
4392 | lj++; | |
4393 | while (lj < j) { | |
ab1103de | 4394 | tcg_ctx.gen_opc_instr_start[lj++] = 0; |
e023e832 AG |
4395 | } |
4396 | } | |
25983cad | 4397 | tcg_ctx.gen_opc_pc[lj] = dc.pc; |
e023e832 | 4398 | gen_opc_cc_op[lj] = dc.cc_op; |
ab1103de | 4399 | tcg_ctx.gen_opc_instr_start[lj] = 1; |
c9c99c22 | 4400 | tcg_ctx.gen_opc_icount[lj] = num_insns; |
e023e832 | 4401 | } |
ad044d09 | 4402 | if (++num_insns == max_insns && (tb->cflags & CF_LAST_IO)) { |
e023e832 AG |
4403 | gen_io_start(); |
4404 | } | |
7193b5f6 RH |
4405 | |
4406 | if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) { | |
4407 | tcg_gen_debug_insn_start(dc.pc); | |
4408 | } | |
4409 | ||
d5a103cd RH |
4410 | status = NO_EXIT; |
4411 | if (unlikely(!QTAILQ_EMPTY(&env->breakpoints))) { | |
4412 | QTAILQ_FOREACH(bp, &env->breakpoints, entry) { | |
4413 | if (bp->pc == dc.pc) { | |
4414 | status = EXIT_PC_STALE; | |
4415 | do_debug = true; | |
4416 | break; | |
4417 | } | |
4418 | } | |
4419 | } | |
4420 | if (status == NO_EXIT) { | |
4421 | status = translate_one(env, &dc); | |
4422 | } | |
ad044d09 RH |
4423 | |
4424 | /* If we reach a page boundary, are single stepping, | |
4425 | or exhaust instruction count, stop generation. */ | |
4426 | if (status == NO_EXIT | |
4427 | && (dc.pc >= next_page_start | |
4428 | || tcg_ctx.gen_opc_ptr >= gen_opc_end | |
4429 | || num_insns >= max_insns | |
4430 | || singlestep | |
4431 | || env->singlestep_enabled)) { | |
4432 | status = EXIT_PC_STALE; | |
e023e832 | 4433 | } |
ad044d09 | 4434 | } while (status == NO_EXIT); |
e023e832 AG |
4435 | |
4436 | if (tb->cflags & CF_LAST_IO) { | |
4437 | gen_io_end(); | |
4438 | } | |
ad044d09 RH |
4439 | |
4440 | switch (status) { | |
4441 | case EXIT_GOTO_TB: | |
4442 | case EXIT_NORETURN: | |
4443 | break; | |
4444 | case EXIT_PC_STALE: | |
4445 | update_psw_addr(&dc); | |
4446 | /* FALLTHRU */ | |
4447 | case EXIT_PC_UPDATED: | |
7a6c7067 RH |
4448 | /* Next TB starts off with CC_OP_DYNAMIC, so make sure the |
4449 | cc op type is in env */ | |
4450 | update_cc_op(&dc); | |
4451 | /* Exit the TB, either by raising a debug exception or by return. */ | |
d5a103cd RH |
4452 | if (do_debug) { |
4453 | gen_exception(EXCP_DEBUG); | |
ad044d09 | 4454 | } else { |
ad044d09 RH |
4455 | tcg_gen_exit_tb(0); |
4456 | } | |
4457 | break; | |
4458 | default: | |
4459 | abort(); | |
e023e832 | 4460 | } |
ad044d09 | 4461 | |
e023e832 | 4462 | gen_icount_end(tb, num_insns); |
efd7f486 | 4463 | *tcg_ctx.gen_opc_ptr = INDEX_op_end; |
e023e832 | 4464 | if (search_pc) { |
92414b31 | 4465 | j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf; |
e023e832 AG |
4466 | lj++; |
4467 | while (lj <= j) { | |
ab1103de | 4468 | tcg_ctx.gen_opc_instr_start[lj++] = 0; |
e023e832 AG |
4469 | } |
4470 | } else { | |
4471 | tb->size = dc.pc - pc_start; | |
4472 | tb->icount = num_insns; | |
4473 | } | |
ad044d09 | 4474 | |
e023e832 | 4475 | #if defined(S390X_DEBUG_DISAS) |
e023e832 AG |
4476 | if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) { |
4477 | qemu_log("IN: %s\n", lookup_symbol(pc_start)); | |
f4359b9f | 4478 | log_target_disas(env, pc_start, dc.pc - pc_start, 1); |
e023e832 AG |
4479 | qemu_log("\n"); |
4480 | } | |
4481 | #endif | |
4482 | } | |
4483 | ||
a4e3ad19 | 4484 | void gen_intermediate_code (CPUS390XState *env, struct TranslationBlock *tb) |
e023e832 AG |
4485 | { |
4486 | gen_intermediate_code_internal(env, tb, 0); | |
4487 | } | |
4488 | ||
a4e3ad19 | 4489 | void gen_intermediate_code_pc (CPUS390XState *env, struct TranslationBlock *tb) |
e023e832 AG |
4490 | { |
4491 | gen_intermediate_code_internal(env, tb, 1); | |
4492 | } | |
4493 | ||
a4e3ad19 | 4494 | void restore_state_to_opc(CPUS390XState *env, TranslationBlock *tb, int pc_pos) |
e023e832 AG |
4495 | { |
4496 | int cc_op; | |
25983cad | 4497 | env->psw.addr = tcg_ctx.gen_opc_pc[pc_pos]; |
e023e832 AG |
4498 | cc_op = gen_opc_cc_op[pc_pos]; |
4499 | if ((cc_op != CC_OP_DYNAMIC) && (cc_op != CC_OP_STATIC)) { | |
4500 | env->cc_op = cc_op; | |
4501 | } | |
10ec5117 | 4502 | } |