target/m68k: remove useless qregs array
[qemu/ar7.git] / target / xtensa / translate.c
blob944a157747cdd7300c22274f2b2bcb6511ce5931
1 /*
2 * Xtensa ISA:
3 * http://www.tensilica.com/products/literature-docs/documentation/xtensa-isa-databook.htm
5 * Copyright (c) 2011, Max Filippov, Open Source and Linux Lab.
6 * All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * * Neither the name of the Open Source and Linux Lab nor the
16 * names of its contributors may be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include "qemu/osdep.h"
33 #include "cpu.h"
34 #include "exec/exec-all.h"
35 #include "disas/disas.h"
36 #include "tcg/tcg-op.h"
37 #include "qemu/log.h"
38 #include "qemu/qemu-print.h"
39 #include "exec/cpu_ldst.h"
40 #include "hw/semihosting/semihost.h"
41 #include "exec/translator.h"
43 #include "exec/helper-proto.h"
44 #include "exec/helper-gen.h"
46 #include "trace-tcg.h"
47 #include "exec/log.h"
50 struct DisasContext {
51 DisasContextBase base;
52 const XtensaConfig *config;
53 uint32_t pc;
54 int cring;
55 int ring;
56 uint32_t lbeg_off;
57 uint32_t lend;
59 bool sar_5bit;
60 bool sar_m32_5bit;
61 bool sar_m32_allocated;
62 TCGv_i32 sar_m32;
64 unsigned window;
65 unsigned callinc;
66 bool cwoe;
68 bool debug;
69 bool icount;
70 TCGv_i32 next_icount;
72 unsigned cpenable;
74 uint32_t op_flags;
75 xtensa_insnbuf_word insnbuf[MAX_INSNBUF_LENGTH];
76 xtensa_insnbuf_word slotbuf[MAX_INSNBUF_LENGTH];
79 static TCGv_i32 cpu_pc;
80 static TCGv_i32 cpu_R[16];
81 static TCGv_i32 cpu_FR[16];
82 static TCGv_i64 cpu_FRD[16];
83 static TCGv_i32 cpu_MR[4];
84 static TCGv_i32 cpu_BR[16];
85 static TCGv_i32 cpu_BR4[4];
86 static TCGv_i32 cpu_BR8[2];
87 static TCGv_i32 cpu_SR[256];
88 static TCGv_i32 cpu_UR[256];
89 static TCGv_i32 cpu_windowbase_next;
90 static TCGv_i32 cpu_exclusive_addr;
91 static TCGv_i32 cpu_exclusive_val;
93 static GHashTable *xtensa_regfile_table;
95 #include "exec/gen-icount.h"
97 static char *sr_name[256];
98 static char *ur_name[256];
100 void xtensa_collect_sr_names(const XtensaConfig *config)
102 xtensa_isa isa = config->isa;
103 int n = xtensa_isa_num_sysregs(isa);
104 int i;
106 for (i = 0; i < n; ++i) {
107 int sr = xtensa_sysreg_number(isa, i);
109 if (sr >= 0 && sr < 256) {
110 const char *name = xtensa_sysreg_name(isa, i);
111 char **pname =
112 (xtensa_sysreg_is_user(isa, i) ? ur_name : sr_name) + sr;
114 if (*pname) {
115 if (strstr(*pname, name) == NULL) {
116 char *new_name =
117 malloc(strlen(*pname) + strlen(name) + 2);
119 strcpy(new_name, *pname);
120 strcat(new_name, "/");
121 strcat(new_name, name);
122 free(*pname);
123 *pname = new_name;
125 } else {
126 *pname = strdup(name);
132 void xtensa_translate_init(void)
134 static const char * const regnames[] = {
135 "ar0", "ar1", "ar2", "ar3",
136 "ar4", "ar5", "ar6", "ar7",
137 "ar8", "ar9", "ar10", "ar11",
138 "ar12", "ar13", "ar14", "ar15",
140 static const char * const fregnames[] = {
141 "f0", "f1", "f2", "f3",
142 "f4", "f5", "f6", "f7",
143 "f8", "f9", "f10", "f11",
144 "f12", "f13", "f14", "f15",
146 static const char * const mregnames[] = {
147 "m0", "m1", "m2", "m3",
149 static const char * const bregnames[] = {
150 "b0", "b1", "b2", "b3",
151 "b4", "b5", "b6", "b7",
152 "b8", "b9", "b10", "b11",
153 "b12", "b13", "b14", "b15",
155 int i;
157 cpu_pc = tcg_global_mem_new_i32(cpu_env,
158 offsetof(CPUXtensaState, pc), "pc");
160 for (i = 0; i < 16; i++) {
161 cpu_R[i] = tcg_global_mem_new_i32(cpu_env,
162 offsetof(CPUXtensaState, regs[i]),
163 regnames[i]);
166 for (i = 0; i < 16; i++) {
167 cpu_FR[i] = tcg_global_mem_new_i32(cpu_env,
168 offsetof(CPUXtensaState,
169 fregs[i].f32[FP_F32_LOW]),
170 fregnames[i]);
173 for (i = 0; i < 16; i++) {
174 cpu_FRD[i] = tcg_global_mem_new_i64(cpu_env,
175 offsetof(CPUXtensaState,
176 fregs[i].f64),
177 fregnames[i]);
180 for (i = 0; i < 4; i++) {
181 cpu_MR[i] = tcg_global_mem_new_i32(cpu_env,
182 offsetof(CPUXtensaState,
183 sregs[MR + i]),
184 mregnames[i]);
187 for (i = 0; i < 16; i++) {
188 cpu_BR[i] = tcg_global_mem_new_i32(cpu_env,
189 offsetof(CPUXtensaState,
190 sregs[BR]),
191 bregnames[i]);
192 if (i % 4 == 0) {
193 cpu_BR4[i / 4] = tcg_global_mem_new_i32(cpu_env,
194 offsetof(CPUXtensaState,
195 sregs[BR]),
196 bregnames[i]);
198 if (i % 8 == 0) {
199 cpu_BR8[i / 8] = tcg_global_mem_new_i32(cpu_env,
200 offsetof(CPUXtensaState,
201 sregs[BR]),
202 bregnames[i]);
206 for (i = 0; i < 256; ++i) {
207 if (sr_name[i]) {
208 cpu_SR[i] = tcg_global_mem_new_i32(cpu_env,
209 offsetof(CPUXtensaState,
210 sregs[i]),
211 sr_name[i]);
215 for (i = 0; i < 256; ++i) {
216 if (ur_name[i]) {
217 cpu_UR[i] = tcg_global_mem_new_i32(cpu_env,
218 offsetof(CPUXtensaState,
219 uregs[i]),
220 ur_name[i]);
224 cpu_windowbase_next =
225 tcg_global_mem_new_i32(cpu_env,
226 offsetof(CPUXtensaState, windowbase_next),
227 "windowbase_next");
228 cpu_exclusive_addr =
229 tcg_global_mem_new_i32(cpu_env,
230 offsetof(CPUXtensaState, exclusive_addr),
231 "exclusive_addr");
232 cpu_exclusive_val =
233 tcg_global_mem_new_i32(cpu_env,
234 offsetof(CPUXtensaState, exclusive_val),
235 "exclusive_val");
238 void **xtensa_get_regfile_by_name(const char *name, int entries, int bits)
240 char *geometry_name;
241 void **res;
243 if (xtensa_regfile_table == NULL) {
244 xtensa_regfile_table = g_hash_table_new(g_str_hash, g_str_equal);
246 * AR is special. Xtensa translator uses it as a current register
247 * window, but configuration overlays represent it as a complete
248 * physical register file.
250 g_hash_table_insert(xtensa_regfile_table,
251 (void *)"AR 16x32", (void *)cpu_R);
252 g_hash_table_insert(xtensa_regfile_table,
253 (void *)"AR 32x32", (void *)cpu_R);
254 g_hash_table_insert(xtensa_regfile_table,
255 (void *)"AR 64x32", (void *)cpu_R);
257 g_hash_table_insert(xtensa_regfile_table,
258 (void *)"MR 4x32", (void *)cpu_MR);
260 g_hash_table_insert(xtensa_regfile_table,
261 (void *)"FR 16x32", (void *)cpu_FR);
262 g_hash_table_insert(xtensa_regfile_table,
263 (void *)"FR 16x64", (void *)cpu_FRD);
265 g_hash_table_insert(xtensa_regfile_table,
266 (void *)"BR 16x1", (void *)cpu_BR);
267 g_hash_table_insert(xtensa_regfile_table,
268 (void *)"BR4 4x4", (void *)cpu_BR4);
269 g_hash_table_insert(xtensa_regfile_table,
270 (void *)"BR8 2x8", (void *)cpu_BR8);
273 geometry_name = g_strdup_printf("%s %dx%d", name, entries, bits);
274 res = (void **)g_hash_table_lookup(xtensa_regfile_table, geometry_name);
275 g_free(geometry_name);
276 return res;
279 static inline bool option_enabled(DisasContext *dc, int opt)
281 return xtensa_option_enabled(dc->config, opt);
284 static void init_sar_tracker(DisasContext *dc)
286 dc->sar_5bit = false;
287 dc->sar_m32_5bit = false;
288 dc->sar_m32_allocated = false;
291 static void reset_sar_tracker(DisasContext *dc)
293 if (dc->sar_m32_allocated) {
294 tcg_temp_free(dc->sar_m32);
298 static void gen_right_shift_sar(DisasContext *dc, TCGv_i32 sa)
300 tcg_gen_andi_i32(cpu_SR[SAR], sa, 0x1f);
301 if (dc->sar_m32_5bit) {
302 tcg_gen_discard_i32(dc->sar_m32);
304 dc->sar_5bit = true;
305 dc->sar_m32_5bit = false;
308 static void gen_left_shift_sar(DisasContext *dc, TCGv_i32 sa)
310 TCGv_i32 tmp = tcg_const_i32(32);
311 if (!dc->sar_m32_allocated) {
312 dc->sar_m32 = tcg_temp_local_new_i32();
313 dc->sar_m32_allocated = true;
315 tcg_gen_andi_i32(dc->sar_m32, sa, 0x1f);
316 tcg_gen_sub_i32(cpu_SR[SAR], tmp, dc->sar_m32);
317 dc->sar_5bit = false;
318 dc->sar_m32_5bit = true;
319 tcg_temp_free(tmp);
322 static void gen_exception(DisasContext *dc, int excp)
324 TCGv_i32 tmp = tcg_const_i32(excp);
325 gen_helper_exception(cpu_env, tmp);
326 tcg_temp_free(tmp);
329 static void gen_exception_cause(DisasContext *dc, uint32_t cause)
331 TCGv_i32 tpc = tcg_const_i32(dc->pc);
332 TCGv_i32 tcause = tcg_const_i32(cause);
333 gen_helper_exception_cause(cpu_env, tpc, tcause);
334 tcg_temp_free(tpc);
335 tcg_temp_free(tcause);
336 if (cause == ILLEGAL_INSTRUCTION_CAUSE ||
337 cause == SYSCALL_CAUSE) {
338 dc->base.is_jmp = DISAS_NORETURN;
342 static void gen_exception_cause_vaddr(DisasContext *dc, uint32_t cause,
343 TCGv_i32 vaddr)
345 TCGv_i32 tpc = tcg_const_i32(dc->pc);
346 TCGv_i32 tcause = tcg_const_i32(cause);
347 gen_helper_exception_cause_vaddr(cpu_env, tpc, tcause, vaddr);
348 tcg_temp_free(tpc);
349 tcg_temp_free(tcause);
352 static void gen_debug_exception(DisasContext *dc, uint32_t cause)
354 TCGv_i32 tpc = tcg_const_i32(dc->pc);
355 TCGv_i32 tcause = tcg_const_i32(cause);
356 gen_helper_debug_exception(cpu_env, tpc, tcause);
357 tcg_temp_free(tpc);
358 tcg_temp_free(tcause);
359 if (cause & (DEBUGCAUSE_IB | DEBUGCAUSE_BI | DEBUGCAUSE_BN)) {
360 dc->base.is_jmp = DISAS_NORETURN;
364 static bool gen_check_privilege(DisasContext *dc)
366 #ifndef CONFIG_USER_ONLY
367 if (!dc->cring) {
368 return true;
370 #endif
371 gen_exception_cause(dc, PRIVILEGED_CAUSE);
372 dc->base.is_jmp = DISAS_NORETURN;
373 return false;
376 static bool gen_check_cpenable(DisasContext *dc, uint32_t cp_mask)
378 cp_mask &= ~dc->cpenable;
380 if (option_enabled(dc, XTENSA_OPTION_COPROCESSOR) && cp_mask) {
381 gen_exception_cause(dc, COPROCESSOR0_DISABLED + ctz32(cp_mask));
382 dc->base.is_jmp = DISAS_NORETURN;
383 return false;
385 return true;
388 static int gen_postprocess(DisasContext *dc, int slot);
390 static void gen_jump_slot(DisasContext *dc, TCGv dest, int slot)
392 tcg_gen_mov_i32(cpu_pc, dest);
393 if (dc->icount) {
394 tcg_gen_mov_i32(cpu_SR[ICOUNT], dc->next_icount);
396 if (dc->base.singlestep_enabled) {
397 gen_exception(dc, EXCP_DEBUG);
398 } else {
399 if (dc->op_flags & XTENSA_OP_POSTPROCESS) {
400 slot = gen_postprocess(dc, slot);
402 if (slot >= 0) {
403 tcg_gen_goto_tb(slot);
404 tcg_gen_exit_tb(dc->base.tb, slot);
405 } else {
406 tcg_gen_exit_tb(NULL, 0);
409 dc->base.is_jmp = DISAS_NORETURN;
412 static void gen_jump(DisasContext *dc, TCGv dest)
414 gen_jump_slot(dc, dest, -1);
417 static int adjust_jump_slot(DisasContext *dc, uint32_t dest, int slot)
419 if (((dc->base.pc_first ^ dest) & TARGET_PAGE_MASK) != 0) {
420 return -1;
421 } else {
422 return slot;
426 static void gen_jumpi(DisasContext *dc, uint32_t dest, int slot)
428 TCGv_i32 tmp = tcg_const_i32(dest);
429 gen_jump_slot(dc, tmp, adjust_jump_slot(dc, dest, slot));
430 tcg_temp_free(tmp);
433 static void gen_callw_slot(DisasContext *dc, int callinc, TCGv_i32 dest,
434 int slot)
436 TCGv_i32 tcallinc = tcg_const_i32(callinc);
438 tcg_gen_deposit_i32(cpu_SR[PS], cpu_SR[PS],
439 tcallinc, PS_CALLINC_SHIFT, PS_CALLINC_LEN);
440 tcg_temp_free(tcallinc);
441 tcg_gen_movi_i32(cpu_R[callinc << 2],
442 (callinc << 30) | (dc->base.pc_next & 0x3fffffff));
443 gen_jump_slot(dc, dest, slot);
446 static bool gen_check_loop_end(DisasContext *dc, int slot)
448 if (dc->base.pc_next == dc->lend) {
449 TCGLabel *label = gen_new_label();
451 tcg_gen_brcondi_i32(TCG_COND_EQ, cpu_SR[LCOUNT], 0, label);
452 tcg_gen_subi_i32(cpu_SR[LCOUNT], cpu_SR[LCOUNT], 1);
453 if (dc->lbeg_off) {
454 gen_jumpi(dc, dc->base.pc_next - dc->lbeg_off, slot);
455 } else {
456 gen_jump(dc, cpu_SR[LBEG]);
458 gen_set_label(label);
459 gen_jumpi(dc, dc->base.pc_next, -1);
460 return true;
462 return false;
465 static void gen_jumpi_check_loop_end(DisasContext *dc, int slot)
467 if (!gen_check_loop_end(dc, slot)) {
468 gen_jumpi(dc, dc->base.pc_next, slot);
472 static void gen_brcond(DisasContext *dc, TCGCond cond,
473 TCGv_i32 t0, TCGv_i32 t1, uint32_t addr)
475 TCGLabel *label = gen_new_label();
477 tcg_gen_brcond_i32(cond, t0, t1, label);
478 gen_jumpi_check_loop_end(dc, 0);
479 gen_set_label(label);
480 gen_jumpi(dc, addr, 1);
483 static void gen_brcondi(DisasContext *dc, TCGCond cond,
484 TCGv_i32 t0, uint32_t t1, uint32_t addr)
486 TCGv_i32 tmp = tcg_const_i32(t1);
487 gen_brcond(dc, cond, t0, tmp, addr);
488 tcg_temp_free(tmp);
491 static uint32_t test_exceptions_sr(DisasContext *dc, const OpcodeArg arg[],
492 const uint32_t par[])
494 return xtensa_option_enabled(dc->config, par[1]) ? 0 : XTENSA_OP_ILL;
497 static uint32_t test_exceptions_ccompare(DisasContext *dc,
498 const OpcodeArg arg[],
499 const uint32_t par[])
501 unsigned n = par[0] - CCOMPARE;
503 if (n >= dc->config->nccompare) {
504 return XTENSA_OP_ILL;
506 return test_exceptions_sr(dc, arg, par);
509 static uint32_t test_exceptions_dbreak(DisasContext *dc, const OpcodeArg arg[],
510 const uint32_t par[])
512 unsigned n = MAX_NDBREAK;
514 if (par[0] >= DBREAKA && par[0] < DBREAKA + MAX_NDBREAK) {
515 n = par[0] - DBREAKA;
517 if (par[0] >= DBREAKC && par[0] < DBREAKC + MAX_NDBREAK) {
518 n = par[0] - DBREAKC;
520 if (n >= dc->config->ndbreak) {
521 return XTENSA_OP_ILL;
523 return test_exceptions_sr(dc, arg, par);
526 static uint32_t test_exceptions_ibreak(DisasContext *dc, const OpcodeArg arg[],
527 const uint32_t par[])
529 unsigned n = par[0] - IBREAKA;
531 if (n >= dc->config->nibreak) {
532 return XTENSA_OP_ILL;
534 return test_exceptions_sr(dc, arg, par);
537 static uint32_t test_exceptions_hpi(DisasContext *dc, const OpcodeArg arg[],
538 const uint32_t par[])
540 unsigned n = MAX_NLEVEL + 1;
542 if (par[0] >= EXCSAVE1 && par[0] < EXCSAVE1 + MAX_NLEVEL) {
543 n = par[0] - EXCSAVE1 + 1;
545 if (par[0] >= EPC1 && par[0] < EPC1 + MAX_NLEVEL) {
546 n = par[0] - EPC1 + 1;
548 if (par[0] >= EPS2 && par[0] < EPS2 + MAX_NLEVEL - 1) {
549 n = par[0] - EPS2 + 2;
551 if (n > dc->config->nlevel) {
552 return XTENSA_OP_ILL;
554 return test_exceptions_sr(dc, arg, par);
557 static void gen_load_store_alignment(DisasContext *dc, int shift,
558 TCGv_i32 addr, bool no_hw_alignment)
560 if (!option_enabled(dc, XTENSA_OPTION_UNALIGNED_EXCEPTION)) {
561 tcg_gen_andi_i32(addr, addr, ~0 << shift);
562 } else if (option_enabled(dc, XTENSA_OPTION_HW_ALIGNMENT) &&
563 no_hw_alignment) {
564 TCGLabel *label = gen_new_label();
565 TCGv_i32 tmp = tcg_temp_new_i32();
566 tcg_gen_andi_i32(tmp, addr, ~(~0 << shift));
567 tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, label);
568 gen_exception_cause_vaddr(dc, LOAD_STORE_ALIGNMENT_CAUSE, addr);
569 gen_set_label(label);
570 tcg_temp_free(tmp);
574 #ifndef CONFIG_USER_ONLY
575 static void gen_waiti(DisasContext *dc, uint32_t imm4)
577 TCGv_i32 pc = tcg_const_i32(dc->base.pc_next);
578 TCGv_i32 intlevel = tcg_const_i32(imm4);
580 if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
581 gen_io_start();
583 gen_helper_waiti(cpu_env, pc, intlevel);
584 tcg_temp_free(pc);
585 tcg_temp_free(intlevel);
587 #endif
589 static bool gen_window_check(DisasContext *dc, uint32_t mask)
591 unsigned r = 31 - clz32(mask);
593 if (r / 4 > dc->window) {
594 TCGv_i32 pc = tcg_const_i32(dc->pc);
595 TCGv_i32 w = tcg_const_i32(r / 4);
597 gen_helper_window_check(cpu_env, pc, w);
598 dc->base.is_jmp = DISAS_NORETURN;
599 return false;
601 return true;
604 static TCGv_i32 gen_mac16_m(TCGv_i32 v, bool hi, bool is_unsigned)
606 TCGv_i32 m = tcg_temp_new_i32();
608 if (hi) {
609 (is_unsigned ? tcg_gen_shri_i32 : tcg_gen_sari_i32)(m, v, 16);
610 } else {
611 (is_unsigned ? tcg_gen_ext16u_i32 : tcg_gen_ext16s_i32)(m, v);
613 return m;
616 static void gen_zero_check(DisasContext *dc, const OpcodeArg arg[])
618 TCGLabel *label = gen_new_label();
620 tcg_gen_brcondi_i32(TCG_COND_NE, arg[2].in, 0, label);
621 gen_exception_cause(dc, INTEGER_DIVIDE_BY_ZERO_CAUSE);
622 gen_set_label(label);
625 static inline unsigned xtensa_op0_insn_len(DisasContext *dc, uint8_t op0)
627 return xtensa_isa_length_from_chars(dc->config->isa, &op0);
630 static int gen_postprocess(DisasContext *dc, int slot)
632 uint32_t op_flags = dc->op_flags;
634 #ifndef CONFIG_USER_ONLY
635 if (op_flags & XTENSA_OP_CHECK_INTERRUPTS) {
636 if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
637 gen_io_start();
639 gen_helper_check_interrupts(cpu_env);
641 #endif
642 if (op_flags & XTENSA_OP_SYNC_REGISTER_WINDOW) {
643 gen_helper_sync_windowbase(cpu_env);
645 if (op_flags & XTENSA_OP_EXIT_TB_M1) {
646 slot = -1;
648 return slot;
651 struct opcode_arg_copy {
652 uint32_t resource;
653 void *temp;
654 OpcodeArg *arg;
657 struct opcode_arg_info {
658 uint32_t resource;
659 int index;
662 struct slot_prop {
663 XtensaOpcodeOps *ops;
664 OpcodeArg arg[MAX_OPCODE_ARGS];
665 struct opcode_arg_info in[MAX_OPCODE_ARGS];
666 struct opcode_arg_info out[MAX_OPCODE_ARGS];
667 unsigned n_in;
668 unsigned n_out;
669 uint32_t op_flags;
672 enum resource_type {
673 RES_REGFILE,
674 RES_STATE,
675 RES_MAX,
678 static uint32_t encode_resource(enum resource_type r, unsigned g, unsigned n)
680 assert(r < RES_MAX && g < 256 && n < 65536);
681 return (r << 24) | (g << 16) | n;
684 static enum resource_type get_resource_type(uint32_t resource)
686 return resource >> 24;
690 * a depends on b if b must be executed before a,
691 * because a's side effects will destroy b's inputs.
693 static bool op_depends_on(const struct slot_prop *a,
694 const struct slot_prop *b)
696 unsigned i = 0;
697 unsigned j = 0;
699 if (a->op_flags & XTENSA_OP_CONTROL_FLOW) {
700 return true;
702 if ((a->op_flags & XTENSA_OP_LOAD_STORE) <
703 (b->op_flags & XTENSA_OP_LOAD_STORE)) {
704 return true;
706 while (i < a->n_out && j < b->n_in) {
707 if (a->out[i].resource < b->in[j].resource) {
708 ++i;
709 } else if (a->out[i].resource > b->in[j].resource) {
710 ++j;
711 } else {
712 return true;
715 return false;
719 * Try to break a dependency on b, append temporary register copy records
720 * to the end of copy and update n_copy in case of success.
721 * This is not always possible: e.g. control flow must always be the last,
722 * load/store must be first and state dependencies are not supported yet.
724 static bool break_dependency(struct slot_prop *a,
725 struct slot_prop *b,
726 struct opcode_arg_copy *copy,
727 unsigned *n_copy)
729 unsigned i = 0;
730 unsigned j = 0;
731 unsigned n = *n_copy;
732 bool rv = false;
734 if (a->op_flags & XTENSA_OP_CONTROL_FLOW) {
735 return false;
737 if ((a->op_flags & XTENSA_OP_LOAD_STORE) <
738 (b->op_flags & XTENSA_OP_LOAD_STORE)) {
739 return false;
741 while (i < a->n_out && j < b->n_in) {
742 if (a->out[i].resource < b->in[j].resource) {
743 ++i;
744 } else if (a->out[i].resource > b->in[j].resource) {
745 ++j;
746 } else {
747 int index = b->in[j].index;
749 if (get_resource_type(a->out[i].resource) != RES_REGFILE ||
750 index < 0) {
751 return false;
753 copy[n].resource = b->in[j].resource;
754 copy[n].arg = b->arg + index;
755 ++n;
756 ++j;
757 rv = true;
760 *n_copy = n;
761 return rv;
765 * Calculate evaluation order for slot opcodes.
766 * Build opcode order graph and output its nodes in topological sort order.
767 * An edge a -> b in the graph means that opcode a must be followed by
768 * opcode b.
770 static bool tsort(struct slot_prop *slot,
771 struct slot_prop *sorted[],
772 unsigned n,
773 struct opcode_arg_copy *copy,
774 unsigned *n_copy)
776 struct tsnode {
777 unsigned n_in_edge;
778 unsigned n_out_edge;
779 unsigned out_edge[MAX_INSN_SLOTS];
780 } node[MAX_INSN_SLOTS];
782 unsigned in[MAX_INSN_SLOTS];
783 unsigned i, j;
784 unsigned n_in = 0;
785 unsigned n_out = 0;
786 unsigned n_edge = 0;
787 unsigned in_idx = 0;
788 unsigned node_idx = 0;
790 for (i = 0; i < n; ++i) {
791 node[i].n_in_edge = 0;
792 node[i].n_out_edge = 0;
795 for (i = 0; i < n; ++i) {
796 unsigned n_out_edge = 0;
798 for (j = 0; j < n; ++j) {
799 if (i != j && op_depends_on(slot + j, slot + i)) {
800 node[i].out_edge[n_out_edge] = j;
801 ++node[j].n_in_edge;
802 ++n_out_edge;
803 ++n_edge;
806 node[i].n_out_edge = n_out_edge;
809 for (i = 0; i < n; ++i) {
810 if (!node[i].n_in_edge) {
811 in[n_in] = i;
812 ++n_in;
816 again:
817 for (; in_idx < n_in; ++in_idx) {
818 i = in[in_idx];
819 sorted[n_out] = slot + i;
820 ++n_out;
821 for (j = 0; j < node[i].n_out_edge; ++j) {
822 --n_edge;
823 if (--node[node[i].out_edge[j]].n_in_edge == 0) {
824 in[n_in] = node[i].out_edge[j];
825 ++n_in;
829 if (n_edge) {
830 for (; node_idx < n; ++node_idx) {
831 struct tsnode *cnode = node + node_idx;
833 if (cnode->n_in_edge) {
834 for (j = 0; j < cnode->n_out_edge; ++j) {
835 unsigned k = cnode->out_edge[j];
837 if (break_dependency(slot + k, slot + node_idx,
838 copy, n_copy) &&
839 --node[k].n_in_edge == 0) {
840 in[n_in] = k;
841 ++n_in;
842 --n_edge;
843 cnode->out_edge[j] =
844 cnode->out_edge[cnode->n_out_edge - 1];
845 --cnode->n_out_edge;
846 goto again;
852 return n_edge == 0;
855 static void opcode_add_resource(struct slot_prop *op,
856 uint32_t resource, char direction,
857 int index)
859 switch (direction) {
860 case 'm':
861 case 'i':
862 assert(op->n_in < ARRAY_SIZE(op->in));
863 op->in[op->n_in].resource = resource;
864 op->in[op->n_in].index = index;
865 ++op->n_in;
866 /* fall through */
867 case 'o':
868 if (direction == 'm' || direction == 'o') {
869 assert(op->n_out < ARRAY_SIZE(op->out));
870 op->out[op->n_out].resource = resource;
871 op->out[op->n_out].index = index;
872 ++op->n_out;
874 break;
875 default:
876 g_assert_not_reached();
880 static int resource_compare(const void *a, const void *b)
882 const struct opcode_arg_info *pa = a;
883 const struct opcode_arg_info *pb = b;
885 return pa->resource < pb->resource ?
886 -1 : (pa->resource > pb->resource ? 1 : 0);
889 static int arg_copy_compare(const void *a, const void *b)
891 const struct opcode_arg_copy *pa = a;
892 const struct opcode_arg_copy *pb = b;
894 return pa->resource < pb->resource ?
895 -1 : (pa->resource > pb->resource ? 1 : 0);
898 static void disas_xtensa_insn(CPUXtensaState *env, DisasContext *dc)
900 xtensa_isa isa = dc->config->isa;
901 unsigned char b[MAX_INSN_LENGTH] = {translator_ldub(env, dc->pc)};
902 unsigned len = xtensa_op0_insn_len(dc, b[0]);
903 xtensa_format fmt;
904 int slot, slots;
905 unsigned i;
906 uint32_t op_flags = 0;
907 struct slot_prop slot_prop[MAX_INSN_SLOTS];
908 struct slot_prop *ordered[MAX_INSN_SLOTS];
909 struct opcode_arg_copy arg_copy[MAX_INSN_SLOTS * MAX_OPCODE_ARGS];
910 unsigned n_arg_copy = 0;
911 uint32_t debug_cause = 0;
912 uint32_t windowed_register = 0;
913 uint32_t coprocessor = 0;
915 if (len == XTENSA_UNDEFINED) {
916 qemu_log_mask(LOG_GUEST_ERROR,
917 "unknown instruction length (pc = %08x)\n",
918 dc->pc);
919 gen_exception_cause(dc, ILLEGAL_INSTRUCTION_CAUSE);
920 return;
923 dc->base.pc_next = dc->pc + len;
924 for (i = 1; i < len; ++i) {
925 b[i] = translator_ldub(env, dc->pc + i);
927 xtensa_insnbuf_from_chars(isa, dc->insnbuf, b, len);
928 fmt = xtensa_format_decode(isa, dc->insnbuf);
929 if (fmt == XTENSA_UNDEFINED) {
930 qemu_log_mask(LOG_GUEST_ERROR,
931 "unrecognized instruction format (pc = %08x)\n",
932 dc->pc);
933 gen_exception_cause(dc, ILLEGAL_INSTRUCTION_CAUSE);
934 return;
936 slots = xtensa_format_num_slots(isa, fmt);
937 for (slot = 0; slot < slots; ++slot) {
938 xtensa_opcode opc;
939 int opnd, vopnd, opnds;
940 OpcodeArg *arg = slot_prop[slot].arg;
941 XtensaOpcodeOps *ops;
943 xtensa_format_get_slot(isa, fmt, slot, dc->insnbuf, dc->slotbuf);
944 opc = xtensa_opcode_decode(isa, fmt, slot, dc->slotbuf);
945 if (opc == XTENSA_UNDEFINED) {
946 qemu_log_mask(LOG_GUEST_ERROR,
947 "unrecognized opcode in slot %d (pc = %08x)\n",
948 slot, dc->pc);
949 gen_exception_cause(dc, ILLEGAL_INSTRUCTION_CAUSE);
950 return;
952 opnds = xtensa_opcode_num_operands(isa, opc);
954 for (opnd = vopnd = 0; opnd < opnds; ++opnd) {
955 void **register_file = NULL;
956 xtensa_regfile rf;
958 if (xtensa_operand_is_register(isa, opc, opnd)) {
959 rf = xtensa_operand_regfile(isa, opc, opnd);
960 register_file = dc->config->regfile[rf];
962 if (rf == dc->config->a_regfile) {
963 uint32_t v;
965 xtensa_operand_get_field(isa, opc, opnd, fmt, slot,
966 dc->slotbuf, &v);
967 xtensa_operand_decode(isa, opc, opnd, &v);
968 windowed_register |= 1u << v;
971 if (xtensa_operand_is_visible(isa, opc, opnd)) {
972 uint32_t v;
974 xtensa_operand_get_field(isa, opc, opnd, fmt, slot,
975 dc->slotbuf, &v);
976 xtensa_operand_decode(isa, opc, opnd, &v);
977 arg[vopnd].raw_imm = v;
978 if (xtensa_operand_is_PCrelative(isa, opc, opnd)) {
979 xtensa_operand_undo_reloc(isa, opc, opnd, &v, dc->pc);
981 arg[vopnd].imm = v;
982 if (register_file) {
983 arg[vopnd].in = register_file[v];
984 arg[vopnd].out = register_file[v];
985 arg[vopnd].num_bits = xtensa_regfile_num_bits(isa, rf);
986 } else {
987 arg[vopnd].num_bits = 32;
989 ++vopnd;
992 ops = dc->config->opcode_ops[opc];
993 slot_prop[slot].ops = ops;
995 if (ops) {
996 op_flags |= ops->op_flags;
997 if (ops->test_exceptions) {
998 op_flags |= ops->test_exceptions(dc, arg, ops->par);
1000 } else {
1001 qemu_log_mask(LOG_UNIMP,
1002 "unimplemented opcode '%s' in slot %d (pc = %08x)\n",
1003 xtensa_opcode_name(isa, opc), slot, dc->pc);
1004 op_flags |= XTENSA_OP_ILL;
1006 if (op_flags & XTENSA_OP_ILL) {
1007 gen_exception_cause(dc, ILLEGAL_INSTRUCTION_CAUSE);
1008 return;
1010 if (op_flags & XTENSA_OP_DEBUG_BREAK) {
1011 debug_cause |= ops->par[0];
1013 if (ops->test_overflow) {
1014 windowed_register |= ops->test_overflow(dc, arg, ops->par);
1016 coprocessor |= ops->coprocessor;
1018 if (slots > 1) {
1019 slot_prop[slot].n_in = 0;
1020 slot_prop[slot].n_out = 0;
1021 slot_prop[slot].op_flags = ops->op_flags & XTENSA_OP_LOAD_STORE;
1023 opnds = xtensa_opcode_num_operands(isa, opc);
1025 for (opnd = vopnd = 0; opnd < opnds; ++opnd) {
1026 bool visible = xtensa_operand_is_visible(isa, opc, opnd);
1028 if (xtensa_operand_is_register(isa, opc, opnd)) {
1029 xtensa_regfile rf = xtensa_operand_regfile(isa, opc, opnd);
1030 uint32_t v = 0;
1032 xtensa_operand_get_field(isa, opc, opnd, fmt, slot,
1033 dc->slotbuf, &v);
1034 xtensa_operand_decode(isa, opc, opnd, &v);
1035 opcode_add_resource(slot_prop + slot,
1036 encode_resource(RES_REGFILE, rf, v),
1037 xtensa_operand_inout(isa, opc, opnd),
1038 visible ? vopnd : -1);
1040 if (visible) {
1041 ++vopnd;
1045 opnds = xtensa_opcode_num_stateOperands(isa, opc);
1047 for (opnd = 0; opnd < opnds; ++opnd) {
1048 xtensa_state state = xtensa_stateOperand_state(isa, opc, opnd);
1050 opcode_add_resource(slot_prop + slot,
1051 encode_resource(RES_STATE, 0, state),
1052 xtensa_stateOperand_inout(isa, opc, opnd),
1053 -1);
1055 if (xtensa_opcode_is_branch(isa, opc) ||
1056 xtensa_opcode_is_jump(isa, opc) ||
1057 xtensa_opcode_is_loop(isa, opc) ||
1058 xtensa_opcode_is_call(isa, opc)) {
1059 slot_prop[slot].op_flags |= XTENSA_OP_CONTROL_FLOW;
1062 qsort(slot_prop[slot].in, slot_prop[slot].n_in,
1063 sizeof(slot_prop[slot].in[0]), resource_compare);
1064 qsort(slot_prop[slot].out, slot_prop[slot].n_out,
1065 sizeof(slot_prop[slot].out[0]), resource_compare);
1069 if (slots > 1) {
1070 if (!tsort(slot_prop, ordered, slots, arg_copy, &n_arg_copy)) {
1071 qemu_log_mask(LOG_UNIMP,
1072 "Circular resource dependencies (pc = %08x)\n",
1073 dc->pc);
1074 gen_exception_cause(dc, ILLEGAL_INSTRUCTION_CAUSE);
1075 return;
1077 } else {
1078 ordered[0] = slot_prop + 0;
1081 if ((op_flags & XTENSA_OP_PRIVILEGED) &&
1082 !gen_check_privilege(dc)) {
1083 return;
1086 if (op_flags & XTENSA_OP_SYSCALL) {
1087 gen_exception_cause(dc, SYSCALL_CAUSE);
1088 return;
1091 if ((op_flags & XTENSA_OP_DEBUG_BREAK) && dc->debug) {
1092 gen_debug_exception(dc, debug_cause);
1093 return;
1096 if (windowed_register && !gen_window_check(dc, windowed_register)) {
1097 return;
1100 if (op_flags & XTENSA_OP_UNDERFLOW) {
1101 TCGv_i32 tmp = tcg_const_i32(dc->pc);
1103 gen_helper_test_underflow_retw(cpu_env, tmp);
1104 tcg_temp_free(tmp);
1107 if (op_flags & XTENSA_OP_ALLOCA) {
1108 TCGv_i32 tmp = tcg_const_i32(dc->pc);
1110 gen_helper_movsp(cpu_env, tmp);
1111 tcg_temp_free(tmp);
1114 if (coprocessor && !gen_check_cpenable(dc, coprocessor)) {
1115 return;
1118 if (n_arg_copy) {
1119 uint32_t resource;
1120 void *temp;
1121 unsigned j;
1123 qsort(arg_copy, n_arg_copy, sizeof(*arg_copy), arg_copy_compare);
1124 for (i = j = 0; i < n_arg_copy; ++i) {
1125 if (i == 0 || arg_copy[i].resource != resource) {
1126 resource = arg_copy[i].resource;
1127 if (arg_copy[i].arg->num_bits <= 32) {
1128 temp = tcg_temp_local_new_i32();
1129 tcg_gen_mov_i32(temp, arg_copy[i].arg->in);
1130 } else if (arg_copy[i].arg->num_bits <= 64) {
1131 temp = tcg_temp_local_new_i64();
1132 tcg_gen_mov_i64(temp, arg_copy[i].arg->in);
1133 } else {
1134 g_assert_not_reached();
1136 arg_copy[i].temp = temp;
1138 if (i != j) {
1139 arg_copy[j] = arg_copy[i];
1141 ++j;
1143 arg_copy[i].arg->in = temp;
1145 n_arg_copy = j;
1148 if (op_flags & XTENSA_OP_DIVIDE_BY_ZERO) {
1149 for (slot = 0; slot < slots; ++slot) {
1150 if (slot_prop[slot].ops->op_flags & XTENSA_OP_DIVIDE_BY_ZERO) {
1151 gen_zero_check(dc, slot_prop[slot].arg);
1156 dc->op_flags = op_flags;
1158 for (slot = 0; slot < slots; ++slot) {
1159 struct slot_prop *pslot = ordered[slot];
1160 XtensaOpcodeOps *ops = pslot->ops;
1162 ops->translate(dc, pslot->arg, ops->par);
1165 for (i = 0; i < n_arg_copy; ++i) {
1166 if (arg_copy[i].arg->num_bits <= 32) {
1167 tcg_temp_free_i32(arg_copy[i].temp);
1168 } else if (arg_copy[i].arg->num_bits <= 64) {
1169 tcg_temp_free_i64(arg_copy[i].temp);
1170 } else {
1171 g_assert_not_reached();
1175 if (dc->base.is_jmp == DISAS_NEXT) {
1176 gen_postprocess(dc, 0);
1177 dc->op_flags = 0;
1178 if (op_flags & XTENSA_OP_EXIT_TB_M1) {
1179 /* Change in mmu index, memory mapping or tb->flags; exit tb */
1180 gen_jumpi_check_loop_end(dc, -1);
1181 } else if (op_flags & XTENSA_OP_EXIT_TB_0) {
1182 gen_jumpi_check_loop_end(dc, 0);
1183 } else {
1184 gen_check_loop_end(dc, 0);
1187 dc->pc = dc->base.pc_next;
1190 static inline unsigned xtensa_insn_len(CPUXtensaState *env, DisasContext *dc)
1192 uint8_t b0 = cpu_ldub_code(env, dc->pc);
1193 return xtensa_op0_insn_len(dc, b0);
1196 static void gen_ibreak_check(CPUXtensaState *env, DisasContext *dc)
1198 unsigned i;
1200 for (i = 0; i < dc->config->nibreak; ++i) {
1201 if ((env->sregs[IBREAKENABLE] & (1 << i)) &&
1202 env->sregs[IBREAKA + i] == dc->pc) {
1203 gen_debug_exception(dc, DEBUGCAUSE_IB);
1204 break;
1209 static void xtensa_tr_init_disas_context(DisasContextBase *dcbase,
1210 CPUState *cpu)
1212 DisasContext *dc = container_of(dcbase, DisasContext, base);
1213 CPUXtensaState *env = cpu->env_ptr;
1214 uint32_t tb_flags = dc->base.tb->flags;
1216 dc->config = env->config;
1217 dc->pc = dc->base.pc_first;
1218 dc->ring = tb_flags & XTENSA_TBFLAG_RING_MASK;
1219 dc->cring = (tb_flags & XTENSA_TBFLAG_EXCM) ? 0 : dc->ring;
1220 dc->lbeg_off = (dc->base.tb->cs_base & XTENSA_CSBASE_LBEG_OFF_MASK) >>
1221 XTENSA_CSBASE_LBEG_OFF_SHIFT;
1222 dc->lend = (dc->base.tb->cs_base & XTENSA_CSBASE_LEND_MASK) +
1223 (dc->base.pc_first & TARGET_PAGE_MASK);
1224 dc->debug = tb_flags & XTENSA_TBFLAG_DEBUG;
1225 dc->icount = tb_flags & XTENSA_TBFLAG_ICOUNT;
1226 dc->cpenable = (tb_flags & XTENSA_TBFLAG_CPENABLE_MASK) >>
1227 XTENSA_TBFLAG_CPENABLE_SHIFT;
1228 dc->window = ((tb_flags & XTENSA_TBFLAG_WINDOW_MASK) >>
1229 XTENSA_TBFLAG_WINDOW_SHIFT);
1230 dc->cwoe = tb_flags & XTENSA_TBFLAG_CWOE;
1231 dc->callinc = ((tb_flags & XTENSA_TBFLAG_CALLINC_MASK) >>
1232 XTENSA_TBFLAG_CALLINC_SHIFT);
1233 init_sar_tracker(dc);
1236 static void xtensa_tr_tb_start(DisasContextBase *dcbase, CPUState *cpu)
1238 DisasContext *dc = container_of(dcbase, DisasContext, base);
1240 if (dc->icount) {
1241 dc->next_icount = tcg_temp_local_new_i32();
1245 static void xtensa_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu)
1247 tcg_gen_insn_start(dcbase->pc_next);
1250 static bool xtensa_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu,
1251 const CPUBreakpoint *bp)
1253 DisasContext *dc = container_of(dcbase, DisasContext, base);
1255 tcg_gen_movi_i32(cpu_pc, dc->base.pc_next);
1256 gen_exception(dc, EXCP_DEBUG);
1257 dc->base.is_jmp = DISAS_NORETURN;
1258 /* The address covered by the breakpoint must be included in
1259 [tb->pc, tb->pc + tb->size) in order to for it to be
1260 properly cleared -- thus we increment the PC here so that
1261 the logic setting tb->size below does the right thing. */
1262 dc->base.pc_next += 2;
1263 return true;
1266 static void xtensa_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
1268 DisasContext *dc = container_of(dcbase, DisasContext, base);
1269 CPUXtensaState *env = cpu->env_ptr;
1270 target_ulong page_start;
1272 /* These two conditions only apply to the first insn in the TB,
1273 but this is the first TranslateOps hook that allows exiting. */
1274 if ((tb_cflags(dc->base.tb) & CF_USE_ICOUNT)
1275 && (dc->base.tb->flags & XTENSA_TBFLAG_YIELD)) {
1276 gen_exception(dc, EXCP_YIELD);
1277 dc->base.is_jmp = DISAS_NORETURN;
1278 return;
1280 if (dc->base.tb->flags & XTENSA_TBFLAG_EXCEPTION) {
1281 gen_exception(dc, EXCP_DEBUG);
1282 dc->base.is_jmp = DISAS_NORETURN;
1283 return;
1286 if (dc->icount) {
1287 TCGLabel *label = gen_new_label();
1289 tcg_gen_addi_i32(dc->next_icount, cpu_SR[ICOUNT], 1);
1290 tcg_gen_brcondi_i32(TCG_COND_NE, dc->next_icount, 0, label);
1291 tcg_gen_mov_i32(dc->next_icount, cpu_SR[ICOUNT]);
1292 if (dc->debug) {
1293 gen_debug_exception(dc, DEBUGCAUSE_IC);
1295 gen_set_label(label);
1298 if (dc->debug) {
1299 gen_ibreak_check(env, dc);
1302 disas_xtensa_insn(env, dc);
1304 if (dc->icount) {
1305 tcg_gen_mov_i32(cpu_SR[ICOUNT], dc->next_icount);
1308 /* End the TB if the next insn will cross into the next page. */
1309 page_start = dc->base.pc_first & TARGET_PAGE_MASK;
1310 if (dc->base.is_jmp == DISAS_NEXT &&
1311 (dc->pc - page_start >= TARGET_PAGE_SIZE ||
1312 dc->pc - page_start + xtensa_insn_len(env, dc) > TARGET_PAGE_SIZE)) {
1313 dc->base.is_jmp = DISAS_TOO_MANY;
1317 static void xtensa_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)
1319 DisasContext *dc = container_of(dcbase, DisasContext, base);
1321 reset_sar_tracker(dc);
1322 if (dc->icount) {
1323 tcg_temp_free(dc->next_icount);
1326 switch (dc->base.is_jmp) {
1327 case DISAS_NORETURN:
1328 break;
1329 case DISAS_TOO_MANY:
1330 if (dc->base.singlestep_enabled) {
1331 tcg_gen_movi_i32(cpu_pc, dc->pc);
1332 gen_exception(dc, EXCP_DEBUG);
1333 } else {
1334 gen_jumpi(dc, dc->pc, 0);
1336 break;
1337 default:
1338 g_assert_not_reached();
1342 static void xtensa_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu)
1344 qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first));
1345 log_target_disas(cpu, dcbase->pc_first, dcbase->tb->size);
1348 static const TranslatorOps xtensa_translator_ops = {
1349 .init_disas_context = xtensa_tr_init_disas_context,
1350 .tb_start = xtensa_tr_tb_start,
1351 .insn_start = xtensa_tr_insn_start,
1352 .breakpoint_check = xtensa_tr_breakpoint_check,
1353 .translate_insn = xtensa_tr_translate_insn,
1354 .tb_stop = xtensa_tr_tb_stop,
1355 .disas_log = xtensa_tr_disas_log,
1358 void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns)
1360 DisasContext dc = {};
1361 translator_loop(&xtensa_translator_ops, &dc.base, cpu, tb, max_insns);
1364 void xtensa_cpu_dump_state(CPUState *cs, FILE *f, int flags)
1366 XtensaCPU *cpu = XTENSA_CPU(cs);
1367 CPUXtensaState *env = &cpu->env;
1368 xtensa_isa isa = env->config->isa;
1369 int i, j;
1371 qemu_fprintf(f, "PC=%08x\n\n", env->pc);
1373 for (i = j = 0; i < xtensa_isa_num_sysregs(isa); ++i) {
1374 const uint32_t *reg =
1375 xtensa_sysreg_is_user(isa, i) ? env->uregs : env->sregs;
1376 int regno = xtensa_sysreg_number(isa, i);
1378 if (regno >= 0) {
1379 qemu_fprintf(f, "%12s=%08x%c",
1380 xtensa_sysreg_name(isa, i),
1381 reg[regno],
1382 (j++ % 4) == 3 ? '\n' : ' ');
1386 qemu_fprintf(f, (j % 4) == 0 ? "\n" : "\n\n");
1388 for (i = 0; i < 16; ++i) {
1389 qemu_fprintf(f, " A%02d=%08x%c",
1390 i, env->regs[i], (i % 4) == 3 ? '\n' : ' ');
1393 xtensa_sync_phys_from_window(env);
1394 qemu_fprintf(f, "\n");
1396 for (i = 0; i < env->config->nareg; ++i) {
1397 qemu_fprintf(f, "AR%02d=%08x ", i, env->phys_regs[i]);
1398 if (i % 4 == 3) {
1399 bool ws = (env->sregs[WINDOW_START] & (1 << (i / 4))) != 0;
1400 bool cw = env->sregs[WINDOW_BASE] == i / 4;
1402 qemu_fprintf(f, "%c%c\n", ws ? '<' : ' ', cw ? '=' : ' ');
1406 if ((flags & CPU_DUMP_FPU) &&
1407 xtensa_option_enabled(env->config, XTENSA_OPTION_FP_COPROCESSOR)) {
1408 qemu_fprintf(f, "\n");
1410 for (i = 0; i < 16; ++i) {
1411 qemu_fprintf(f, "F%02d=%08x (%-+15.8e)%c", i,
1412 float32_val(env->fregs[i].f32[FP_F32_LOW]),
1413 *(float *)(env->fregs[i].f32 + FP_F32_LOW),
1414 (i % 2) == 1 ? '\n' : ' ');
1418 if ((flags & CPU_DUMP_FPU) &&
1419 xtensa_option_enabled(env->config, XTENSA_OPTION_DFP_COPROCESSOR) &&
1420 !xtensa_option_enabled(env->config, XTENSA_OPTION_DFPU_SINGLE_ONLY)) {
1421 qemu_fprintf(f, "\n");
1423 for (i = 0; i < 16; ++i) {
1424 qemu_fprintf(f, "F%02d=%016"PRIx64" (%-+24.16le)%c", i,
1425 float64_val(env->fregs[i].f64),
1426 *(double *)(&env->fregs[i].f64),
1427 (i % 2) == 1 ? '\n' : ' ');
1432 void restore_state_to_opc(CPUXtensaState *env, TranslationBlock *tb,
1433 target_ulong *data)
1435 env->pc = data[0];
1438 static void translate_abs(DisasContext *dc, const OpcodeArg arg[],
1439 const uint32_t par[])
1441 tcg_gen_abs_i32(arg[0].out, arg[1].in);
1444 static void translate_add(DisasContext *dc, const OpcodeArg arg[],
1445 const uint32_t par[])
1447 tcg_gen_add_i32(arg[0].out, arg[1].in, arg[2].in);
1450 static void translate_addi(DisasContext *dc, const OpcodeArg arg[],
1451 const uint32_t par[])
1453 tcg_gen_addi_i32(arg[0].out, arg[1].in, arg[2].imm);
1456 static void translate_addx(DisasContext *dc, const OpcodeArg arg[],
1457 const uint32_t par[])
1459 TCGv_i32 tmp = tcg_temp_new_i32();
1460 tcg_gen_shli_i32(tmp, arg[1].in, par[0]);
1461 tcg_gen_add_i32(arg[0].out, tmp, arg[2].in);
1462 tcg_temp_free(tmp);
1465 static void translate_all(DisasContext *dc, const OpcodeArg arg[],
1466 const uint32_t par[])
1468 uint32_t shift = par[1];
1469 TCGv_i32 mask = tcg_const_i32(((1 << shift) - 1) << arg[1].imm);
1470 TCGv_i32 tmp = tcg_temp_new_i32();
1472 tcg_gen_and_i32(tmp, arg[1].in, mask);
1473 if (par[0]) {
1474 tcg_gen_addi_i32(tmp, tmp, 1 << arg[1].imm);
1475 } else {
1476 tcg_gen_add_i32(tmp, tmp, mask);
1478 tcg_gen_shri_i32(tmp, tmp, arg[1].imm + shift);
1479 tcg_gen_deposit_i32(arg[0].out, arg[0].out,
1480 tmp, arg[0].imm, 1);
1481 tcg_temp_free(mask);
1482 tcg_temp_free(tmp);
1485 static void translate_and(DisasContext *dc, const OpcodeArg arg[],
1486 const uint32_t par[])
1488 tcg_gen_and_i32(arg[0].out, arg[1].in, arg[2].in);
1491 static void translate_ball(DisasContext *dc, const OpcodeArg arg[],
1492 const uint32_t par[])
1494 TCGv_i32 tmp = tcg_temp_new_i32();
1495 tcg_gen_and_i32(tmp, arg[0].in, arg[1].in);
1496 gen_brcond(dc, par[0], tmp, arg[1].in, arg[2].imm);
1497 tcg_temp_free(tmp);
1500 static void translate_bany(DisasContext *dc, const OpcodeArg arg[],
1501 const uint32_t par[])
1503 TCGv_i32 tmp = tcg_temp_new_i32();
1504 tcg_gen_and_i32(tmp, arg[0].in, arg[1].in);
1505 gen_brcondi(dc, par[0], tmp, 0, arg[2].imm);
1506 tcg_temp_free(tmp);
1509 static void translate_b(DisasContext *dc, const OpcodeArg arg[],
1510 const uint32_t par[])
1512 gen_brcond(dc, par[0], arg[0].in, arg[1].in, arg[2].imm);
1515 static void translate_bb(DisasContext *dc, const OpcodeArg arg[],
1516 const uint32_t par[])
1518 #ifdef TARGET_WORDS_BIGENDIAN
1519 TCGv_i32 bit = tcg_const_i32(0x80000000u);
1520 #else
1521 TCGv_i32 bit = tcg_const_i32(0x00000001u);
1522 #endif
1523 TCGv_i32 tmp = tcg_temp_new_i32();
1524 tcg_gen_andi_i32(tmp, arg[1].in, 0x1f);
1525 #ifdef TARGET_WORDS_BIGENDIAN
1526 tcg_gen_shr_i32(bit, bit, tmp);
1527 #else
1528 tcg_gen_shl_i32(bit, bit, tmp);
1529 #endif
1530 tcg_gen_and_i32(tmp, arg[0].in, bit);
1531 gen_brcondi(dc, par[0], tmp, 0, arg[2].imm);
1532 tcg_temp_free(tmp);
1533 tcg_temp_free(bit);
1536 static void translate_bbi(DisasContext *dc, const OpcodeArg arg[],
1537 const uint32_t par[])
1539 TCGv_i32 tmp = tcg_temp_new_i32();
1540 #ifdef TARGET_WORDS_BIGENDIAN
1541 tcg_gen_andi_i32(tmp, arg[0].in, 0x80000000u >> arg[1].imm);
1542 #else
1543 tcg_gen_andi_i32(tmp, arg[0].in, 0x00000001u << arg[1].imm);
1544 #endif
1545 gen_brcondi(dc, par[0], tmp, 0, arg[2].imm);
1546 tcg_temp_free(tmp);
1549 static void translate_bi(DisasContext *dc, const OpcodeArg arg[],
1550 const uint32_t par[])
1552 gen_brcondi(dc, par[0], arg[0].in, arg[1].imm, arg[2].imm);
1555 static void translate_bz(DisasContext *dc, const OpcodeArg arg[],
1556 const uint32_t par[])
1558 gen_brcondi(dc, par[0], arg[0].in, 0, arg[1].imm);
1561 enum {
1562 BOOLEAN_AND,
1563 BOOLEAN_ANDC,
1564 BOOLEAN_OR,
1565 BOOLEAN_ORC,
1566 BOOLEAN_XOR,
1569 static void translate_boolean(DisasContext *dc, const OpcodeArg arg[],
1570 const uint32_t par[])
1572 static void (* const op[])(TCGv_i32, TCGv_i32, TCGv_i32) = {
1573 [BOOLEAN_AND] = tcg_gen_and_i32,
1574 [BOOLEAN_ANDC] = tcg_gen_andc_i32,
1575 [BOOLEAN_OR] = tcg_gen_or_i32,
1576 [BOOLEAN_ORC] = tcg_gen_orc_i32,
1577 [BOOLEAN_XOR] = tcg_gen_xor_i32,
1580 TCGv_i32 tmp1 = tcg_temp_new_i32();
1581 TCGv_i32 tmp2 = tcg_temp_new_i32();
1583 tcg_gen_shri_i32(tmp1, arg[1].in, arg[1].imm);
1584 tcg_gen_shri_i32(tmp2, arg[2].in, arg[2].imm);
1585 op[par[0]](tmp1, tmp1, tmp2);
1586 tcg_gen_deposit_i32(arg[0].out, arg[0].out, tmp1, arg[0].imm, 1);
1587 tcg_temp_free(tmp1);
1588 tcg_temp_free(tmp2);
1591 static void translate_bp(DisasContext *dc, const OpcodeArg arg[],
1592 const uint32_t par[])
1594 TCGv_i32 tmp = tcg_temp_new_i32();
1596 tcg_gen_andi_i32(tmp, arg[0].in, 1 << arg[0].imm);
1597 gen_brcondi(dc, par[0], tmp, 0, arg[1].imm);
1598 tcg_temp_free(tmp);
1601 static void translate_call0(DisasContext *dc, const OpcodeArg arg[],
1602 const uint32_t par[])
1604 tcg_gen_movi_i32(cpu_R[0], dc->base.pc_next);
1605 gen_jumpi(dc, arg[0].imm, 0);
1608 static void translate_callw(DisasContext *dc, const OpcodeArg arg[],
1609 const uint32_t par[])
1611 TCGv_i32 tmp = tcg_const_i32(arg[0].imm);
1612 gen_callw_slot(dc, par[0], tmp, adjust_jump_slot(dc, arg[0].imm, 0));
1613 tcg_temp_free(tmp);
1616 static void translate_callx0(DisasContext *dc, const OpcodeArg arg[],
1617 const uint32_t par[])
1619 TCGv_i32 tmp = tcg_temp_new_i32();
1620 tcg_gen_mov_i32(tmp, arg[0].in);
1621 tcg_gen_movi_i32(cpu_R[0], dc->base.pc_next);
1622 gen_jump(dc, tmp);
1623 tcg_temp_free(tmp);
1626 static void translate_callxw(DisasContext *dc, const OpcodeArg arg[],
1627 const uint32_t par[])
1629 TCGv_i32 tmp = tcg_temp_new_i32();
1631 tcg_gen_mov_i32(tmp, arg[0].in);
1632 gen_callw_slot(dc, par[0], tmp, -1);
1633 tcg_temp_free(tmp);
1636 static void translate_clamps(DisasContext *dc, const OpcodeArg arg[],
1637 const uint32_t par[])
1639 TCGv_i32 tmp1 = tcg_const_i32(-1u << arg[2].imm);
1640 TCGv_i32 tmp2 = tcg_const_i32((1 << arg[2].imm) - 1);
1642 tcg_gen_smax_i32(tmp1, tmp1, arg[1].in);
1643 tcg_gen_smin_i32(arg[0].out, tmp1, tmp2);
1644 tcg_temp_free(tmp1);
1645 tcg_temp_free(tmp2);
1648 static void translate_clrb_expstate(DisasContext *dc, const OpcodeArg arg[],
1649 const uint32_t par[])
1651 /* TODO: GPIO32 may be a part of coprocessor */
1652 tcg_gen_andi_i32(cpu_UR[EXPSTATE], cpu_UR[EXPSTATE], ~(1u << arg[0].imm));
1655 static void translate_clrex(DisasContext *dc, const OpcodeArg arg[],
1656 const uint32_t par[])
1658 tcg_gen_movi_i32(cpu_exclusive_addr, -1);
1661 static void translate_const16(DisasContext *dc, const OpcodeArg arg[],
1662 const uint32_t par[])
1664 TCGv_i32 c = tcg_const_i32(arg[1].imm);
1666 tcg_gen_deposit_i32(arg[0].out, c, arg[0].in, 16, 16);
1667 tcg_temp_free(c);
1670 static void translate_dcache(DisasContext *dc, const OpcodeArg arg[],
1671 const uint32_t par[])
1673 TCGv_i32 addr = tcg_temp_new_i32();
1674 TCGv_i32 res = tcg_temp_new_i32();
1676 tcg_gen_addi_i32(addr, arg[0].in, arg[1].imm);
1677 tcg_gen_qemu_ld8u(res, addr, dc->cring);
1678 tcg_temp_free(addr);
1679 tcg_temp_free(res);
1682 static void translate_depbits(DisasContext *dc, const OpcodeArg arg[],
1683 const uint32_t par[])
1685 tcg_gen_deposit_i32(arg[1].out, arg[1].in, arg[0].in,
1686 arg[2].imm, arg[3].imm);
1689 static void translate_diwbuip(DisasContext *dc, const OpcodeArg arg[],
1690 const uint32_t par[])
1692 tcg_gen_addi_i32(arg[0].out, arg[0].in, dc->config->dcache_line_bytes);
1695 static uint32_t test_exceptions_entry(DisasContext *dc, const OpcodeArg arg[],
1696 const uint32_t par[])
1698 if (arg[0].imm > 3 || !dc->cwoe) {
1699 qemu_log_mask(LOG_GUEST_ERROR,
1700 "Illegal entry instruction(pc = %08x)\n", dc->pc);
1701 return XTENSA_OP_ILL;
1702 } else {
1703 return 0;
1707 static uint32_t test_overflow_entry(DisasContext *dc, const OpcodeArg arg[],
1708 const uint32_t par[])
1710 return 1 << (dc->callinc * 4);
1713 static void translate_entry(DisasContext *dc, const OpcodeArg arg[],
1714 const uint32_t par[])
1716 TCGv_i32 pc = tcg_const_i32(dc->pc);
1717 TCGv_i32 s = tcg_const_i32(arg[0].imm);
1718 TCGv_i32 imm = tcg_const_i32(arg[1].imm);
1719 gen_helper_entry(cpu_env, pc, s, imm);
1720 tcg_temp_free(imm);
1721 tcg_temp_free(s);
1722 tcg_temp_free(pc);
1725 static void translate_extui(DisasContext *dc, const OpcodeArg arg[],
1726 const uint32_t par[])
1728 int maskimm = (1 << arg[3].imm) - 1;
1730 TCGv_i32 tmp = tcg_temp_new_i32();
1731 tcg_gen_shri_i32(tmp, arg[1].in, arg[2].imm);
1732 tcg_gen_andi_i32(arg[0].out, tmp, maskimm);
1733 tcg_temp_free(tmp);
1736 static void translate_getex(DisasContext *dc, const OpcodeArg arg[],
1737 const uint32_t par[])
1739 TCGv_i32 tmp = tcg_temp_new_i32();
1741 tcg_gen_extract_i32(tmp, cpu_SR[ATOMCTL], 8, 1);
1742 tcg_gen_deposit_i32(cpu_SR[ATOMCTL], cpu_SR[ATOMCTL], arg[0].in, 8, 1);
1743 tcg_gen_mov_i32(arg[0].out, tmp);
1744 tcg_temp_free(tmp);
1747 static void translate_icache(DisasContext *dc, const OpcodeArg arg[],
1748 const uint32_t par[])
1750 #ifndef CONFIG_USER_ONLY
1751 TCGv_i32 addr = tcg_temp_new_i32();
1753 tcg_gen_movi_i32(cpu_pc, dc->pc);
1754 tcg_gen_addi_i32(addr, arg[0].in, arg[1].imm);
1755 gen_helper_itlb_hit_test(cpu_env, addr);
1756 tcg_temp_free(addr);
1757 #endif
1760 static void translate_itlb(DisasContext *dc, const OpcodeArg arg[],
1761 const uint32_t par[])
1763 #ifndef CONFIG_USER_ONLY
1764 TCGv_i32 dtlb = tcg_const_i32(par[0]);
1766 gen_helper_itlb(cpu_env, arg[0].in, dtlb);
1767 tcg_temp_free(dtlb);
1768 #endif
1771 static void translate_j(DisasContext *dc, const OpcodeArg arg[],
1772 const uint32_t par[])
1774 gen_jumpi(dc, arg[0].imm, 0);
1777 static void translate_jx(DisasContext *dc, const OpcodeArg arg[],
1778 const uint32_t par[])
1780 gen_jump(dc, arg[0].in);
1783 static void translate_l32e(DisasContext *dc, const OpcodeArg arg[],
1784 const uint32_t par[])
1786 TCGv_i32 addr = tcg_temp_new_i32();
1788 tcg_gen_addi_i32(addr, arg[1].in, arg[2].imm);
1789 gen_load_store_alignment(dc, 2, addr, false);
1790 tcg_gen_qemu_ld_tl(arg[0].out, addr, dc->ring, MO_TEUL);
1791 tcg_temp_free(addr);
1794 #ifdef CONFIG_USER_ONLY
1795 static void gen_check_exclusive(DisasContext *dc, TCGv_i32 addr, bool is_write)
1798 #else
1799 static void gen_check_exclusive(DisasContext *dc, TCGv_i32 addr, bool is_write)
1801 if (!option_enabled(dc, XTENSA_OPTION_MPU)) {
1802 TCGv_i32 tpc = tcg_const_i32(dc->pc);
1803 TCGv_i32 write = tcg_const_i32(is_write);
1805 gen_helper_check_exclusive(cpu_env, tpc, addr, write);
1806 tcg_temp_free(tpc);
1807 tcg_temp_free(write);
1810 #endif
1812 static void translate_l32ex(DisasContext *dc, const OpcodeArg arg[],
1813 const uint32_t par[])
1815 TCGv_i32 addr = tcg_temp_new_i32();
1817 tcg_gen_mov_i32(addr, arg[1].in);
1818 gen_load_store_alignment(dc, 2, addr, true);
1819 gen_check_exclusive(dc, addr, false);
1820 tcg_gen_qemu_ld_i32(arg[0].out, addr, dc->ring, MO_TEUL);
1821 tcg_gen_mov_i32(cpu_exclusive_addr, addr);
1822 tcg_gen_mov_i32(cpu_exclusive_val, arg[0].out);
1823 tcg_temp_free(addr);
1826 static void translate_ldst(DisasContext *dc, const OpcodeArg arg[],
1827 const uint32_t par[])
1829 TCGv_i32 addr = tcg_temp_new_i32();
1831 tcg_gen_addi_i32(addr, arg[1].in, arg[2].imm);
1832 if (par[0] & MO_SIZE) {
1833 gen_load_store_alignment(dc, par[0] & MO_SIZE, addr, par[1]);
1835 if (par[2]) {
1836 if (par[1]) {
1837 tcg_gen_mb(TCG_BAR_STRL | TCG_MO_ALL);
1839 tcg_gen_qemu_st_tl(arg[0].in, addr, dc->cring, par[0]);
1840 } else {
1841 tcg_gen_qemu_ld_tl(arg[0].out, addr, dc->cring, par[0]);
1842 if (par[1]) {
1843 tcg_gen_mb(TCG_BAR_LDAQ | TCG_MO_ALL);
1846 tcg_temp_free(addr);
1849 static void translate_l32r(DisasContext *dc, const OpcodeArg arg[],
1850 const uint32_t par[])
1852 TCGv_i32 tmp;
1854 if (dc->base.tb->flags & XTENSA_TBFLAG_LITBASE) {
1855 tmp = tcg_const_i32(arg[1].raw_imm - 1);
1856 tcg_gen_add_i32(tmp, cpu_SR[LITBASE], tmp);
1857 } else {
1858 tmp = tcg_const_i32(arg[1].imm);
1860 tcg_gen_qemu_ld32u(arg[0].out, tmp, dc->cring);
1861 tcg_temp_free(tmp);
1864 static void translate_loop(DisasContext *dc, const OpcodeArg arg[],
1865 const uint32_t par[])
1867 uint32_t lend = arg[1].imm;
1869 tcg_gen_subi_i32(cpu_SR[LCOUNT], arg[0].in, 1);
1870 tcg_gen_movi_i32(cpu_SR[LBEG], dc->base.pc_next);
1871 tcg_gen_movi_i32(cpu_SR[LEND], lend);
1873 if (par[0] != TCG_COND_NEVER) {
1874 TCGLabel *label = gen_new_label();
1875 tcg_gen_brcondi_i32(par[0], arg[0].in, 0, label);
1876 gen_jumpi(dc, lend, 1);
1877 gen_set_label(label);
1880 gen_jumpi(dc, dc->base.pc_next, 0);
1883 enum {
1884 MAC16_UMUL,
1885 MAC16_MUL,
1886 MAC16_MULA,
1887 MAC16_MULS,
1888 MAC16_NONE,
1891 enum {
1892 MAC16_LL,
1893 MAC16_HL,
1894 MAC16_LH,
1895 MAC16_HH,
1897 MAC16_HX = 0x1,
1898 MAC16_XH = 0x2,
1901 static void translate_mac16(DisasContext *dc, const OpcodeArg arg[],
1902 const uint32_t par[])
1904 int op = par[0];
1905 unsigned half = par[1];
1906 uint32_t ld_offset = par[2];
1907 unsigned off = ld_offset ? 2 : 0;
1908 TCGv_i32 vaddr = tcg_temp_new_i32();
1909 TCGv_i32 mem32 = tcg_temp_new_i32();
1911 if (ld_offset) {
1912 tcg_gen_addi_i32(vaddr, arg[1].in, ld_offset);
1913 gen_load_store_alignment(dc, 2, vaddr, false);
1914 tcg_gen_qemu_ld32u(mem32, vaddr, dc->cring);
1916 if (op != MAC16_NONE) {
1917 TCGv_i32 m1 = gen_mac16_m(arg[off].in,
1918 half & MAC16_HX, op == MAC16_UMUL);
1919 TCGv_i32 m2 = gen_mac16_m(arg[off + 1].in,
1920 half & MAC16_XH, op == MAC16_UMUL);
1922 if (op == MAC16_MUL || op == MAC16_UMUL) {
1923 tcg_gen_mul_i32(cpu_SR[ACCLO], m1, m2);
1924 if (op == MAC16_UMUL) {
1925 tcg_gen_movi_i32(cpu_SR[ACCHI], 0);
1926 } else {
1927 tcg_gen_sari_i32(cpu_SR[ACCHI], cpu_SR[ACCLO], 31);
1929 } else {
1930 TCGv_i32 lo = tcg_temp_new_i32();
1931 TCGv_i32 hi = tcg_temp_new_i32();
1933 tcg_gen_mul_i32(lo, m1, m2);
1934 tcg_gen_sari_i32(hi, lo, 31);
1935 if (op == MAC16_MULA) {
1936 tcg_gen_add2_i32(cpu_SR[ACCLO], cpu_SR[ACCHI],
1937 cpu_SR[ACCLO], cpu_SR[ACCHI],
1938 lo, hi);
1939 } else {
1940 tcg_gen_sub2_i32(cpu_SR[ACCLO], cpu_SR[ACCHI],
1941 cpu_SR[ACCLO], cpu_SR[ACCHI],
1942 lo, hi);
1944 tcg_gen_ext8s_i32(cpu_SR[ACCHI], cpu_SR[ACCHI]);
1946 tcg_temp_free_i32(lo);
1947 tcg_temp_free_i32(hi);
1949 tcg_temp_free(m1);
1950 tcg_temp_free(m2);
1952 if (ld_offset) {
1953 tcg_gen_mov_i32(arg[1].out, vaddr);
1954 tcg_gen_mov_i32(cpu_SR[MR + arg[0].imm], mem32);
1956 tcg_temp_free(vaddr);
1957 tcg_temp_free(mem32);
1960 static void translate_memw(DisasContext *dc, const OpcodeArg arg[],
1961 const uint32_t par[])
1963 tcg_gen_mb(TCG_BAR_SC | TCG_MO_ALL);
1966 static void translate_smin(DisasContext *dc, const OpcodeArg arg[],
1967 const uint32_t par[])
1969 tcg_gen_smin_i32(arg[0].out, arg[1].in, arg[2].in);
1972 static void translate_umin(DisasContext *dc, const OpcodeArg arg[],
1973 const uint32_t par[])
1975 tcg_gen_umin_i32(arg[0].out, arg[1].in, arg[2].in);
1978 static void translate_smax(DisasContext *dc, const OpcodeArg arg[],
1979 const uint32_t par[])
1981 tcg_gen_smax_i32(arg[0].out, arg[1].in, arg[2].in);
1984 static void translate_umax(DisasContext *dc, const OpcodeArg arg[],
1985 const uint32_t par[])
1987 tcg_gen_umax_i32(arg[0].out, arg[1].in, arg[2].in);
1990 static void translate_mov(DisasContext *dc, const OpcodeArg arg[],
1991 const uint32_t par[])
1993 tcg_gen_mov_i32(arg[0].out, arg[1].in);
1996 static void translate_movcond(DisasContext *dc, const OpcodeArg arg[],
1997 const uint32_t par[])
1999 TCGv_i32 zero = tcg_const_i32(0);
2001 tcg_gen_movcond_i32(par[0], arg[0].out,
2002 arg[2].in, zero, arg[1].in, arg[0].in);
2003 tcg_temp_free(zero);
2006 static void translate_movi(DisasContext *dc, const OpcodeArg arg[],
2007 const uint32_t par[])
2009 tcg_gen_movi_i32(arg[0].out, arg[1].imm);
2012 static void translate_movp(DisasContext *dc, const OpcodeArg arg[],
2013 const uint32_t par[])
2015 TCGv_i32 zero = tcg_const_i32(0);
2016 TCGv_i32 tmp = tcg_temp_new_i32();
2018 tcg_gen_andi_i32(tmp, arg[2].in, 1 << arg[2].imm);
2019 tcg_gen_movcond_i32(par[0],
2020 arg[0].out, tmp, zero,
2021 arg[1].in, arg[0].in);
2022 tcg_temp_free(tmp);
2023 tcg_temp_free(zero);
2026 static void translate_movsp(DisasContext *dc, const OpcodeArg arg[],
2027 const uint32_t par[])
2029 tcg_gen_mov_i32(arg[0].out, arg[1].in);
2032 static void translate_mul16(DisasContext *dc, const OpcodeArg arg[],
2033 const uint32_t par[])
2035 TCGv_i32 v1 = tcg_temp_new_i32();
2036 TCGv_i32 v2 = tcg_temp_new_i32();
2038 if (par[0]) {
2039 tcg_gen_ext16s_i32(v1, arg[1].in);
2040 tcg_gen_ext16s_i32(v2, arg[2].in);
2041 } else {
2042 tcg_gen_ext16u_i32(v1, arg[1].in);
2043 tcg_gen_ext16u_i32(v2, arg[2].in);
2045 tcg_gen_mul_i32(arg[0].out, v1, v2);
2046 tcg_temp_free(v2);
2047 tcg_temp_free(v1);
2050 static void translate_mull(DisasContext *dc, const OpcodeArg arg[],
2051 const uint32_t par[])
2053 tcg_gen_mul_i32(arg[0].out, arg[1].in, arg[2].in);
2056 static void translate_mulh(DisasContext *dc, const OpcodeArg arg[],
2057 const uint32_t par[])
2059 TCGv_i32 lo = tcg_temp_new();
2061 if (par[0]) {
2062 tcg_gen_muls2_i32(lo, arg[0].out, arg[1].in, arg[2].in);
2063 } else {
2064 tcg_gen_mulu2_i32(lo, arg[0].out, arg[1].in, arg[2].in);
2066 tcg_temp_free(lo);
2069 static void translate_neg(DisasContext *dc, const OpcodeArg arg[],
2070 const uint32_t par[])
2072 tcg_gen_neg_i32(arg[0].out, arg[1].in);
2075 static void translate_nop(DisasContext *dc, const OpcodeArg arg[],
2076 const uint32_t par[])
2080 static void translate_nsa(DisasContext *dc, const OpcodeArg arg[],
2081 const uint32_t par[])
2083 tcg_gen_clrsb_i32(arg[0].out, arg[1].in);
2086 static void translate_nsau(DisasContext *dc, const OpcodeArg arg[],
2087 const uint32_t par[])
2089 tcg_gen_clzi_i32(arg[0].out, arg[1].in, 32);
2092 static void translate_or(DisasContext *dc, const OpcodeArg arg[],
2093 const uint32_t par[])
2095 tcg_gen_or_i32(arg[0].out, arg[1].in, arg[2].in);
2098 static void translate_ptlb(DisasContext *dc, const OpcodeArg arg[],
2099 const uint32_t par[])
2101 #ifndef CONFIG_USER_ONLY
2102 TCGv_i32 dtlb = tcg_const_i32(par[0]);
2104 tcg_gen_movi_i32(cpu_pc, dc->pc);
2105 gen_helper_ptlb(arg[0].out, cpu_env, arg[1].in, dtlb);
2106 tcg_temp_free(dtlb);
2107 #endif
2110 static void translate_pptlb(DisasContext *dc, const OpcodeArg arg[],
2111 const uint32_t par[])
2113 #ifndef CONFIG_USER_ONLY
2114 tcg_gen_movi_i32(cpu_pc, dc->pc);
2115 gen_helper_pptlb(arg[0].out, cpu_env, arg[1].in);
2116 #endif
2119 static void translate_quos(DisasContext *dc, const OpcodeArg arg[],
2120 const uint32_t par[])
2122 TCGLabel *label1 = gen_new_label();
2123 TCGLabel *label2 = gen_new_label();
2125 tcg_gen_brcondi_i32(TCG_COND_NE, arg[1].in, 0x80000000,
2126 label1);
2127 tcg_gen_brcondi_i32(TCG_COND_NE, arg[2].in, 0xffffffff,
2128 label1);
2129 tcg_gen_movi_i32(arg[0].out,
2130 par[0] ? 0x80000000 : 0);
2131 tcg_gen_br(label2);
2132 gen_set_label(label1);
2133 if (par[0]) {
2134 tcg_gen_div_i32(arg[0].out,
2135 arg[1].in, arg[2].in);
2136 } else {
2137 tcg_gen_rem_i32(arg[0].out,
2138 arg[1].in, arg[2].in);
2140 gen_set_label(label2);
2143 static void translate_quou(DisasContext *dc, const OpcodeArg arg[],
2144 const uint32_t par[])
2146 tcg_gen_divu_i32(arg[0].out,
2147 arg[1].in, arg[2].in);
2150 static void translate_read_impwire(DisasContext *dc, const OpcodeArg arg[],
2151 const uint32_t par[])
2153 /* TODO: GPIO32 may be a part of coprocessor */
2154 tcg_gen_movi_i32(arg[0].out, 0);
2157 static void translate_remu(DisasContext *dc, const OpcodeArg arg[],
2158 const uint32_t par[])
2160 tcg_gen_remu_i32(arg[0].out,
2161 arg[1].in, arg[2].in);
2164 static void translate_rer(DisasContext *dc, const OpcodeArg arg[],
2165 const uint32_t par[])
2167 gen_helper_rer(arg[0].out, cpu_env, arg[1].in);
2170 static void translate_ret(DisasContext *dc, const OpcodeArg arg[],
2171 const uint32_t par[])
2173 gen_jump(dc, cpu_R[0]);
2176 static uint32_t test_exceptions_retw(DisasContext *dc, const OpcodeArg arg[],
2177 const uint32_t par[])
2179 if (!dc->cwoe) {
2180 qemu_log_mask(LOG_GUEST_ERROR,
2181 "Illegal retw instruction(pc = %08x)\n", dc->pc);
2182 return XTENSA_OP_ILL;
2183 } else {
2184 TCGv_i32 tmp = tcg_const_i32(dc->pc);
2186 gen_helper_test_ill_retw(cpu_env, tmp);
2187 tcg_temp_free(tmp);
2188 return 0;
2192 static void translate_retw(DisasContext *dc, const OpcodeArg arg[],
2193 const uint32_t par[])
2195 TCGv_i32 tmp = tcg_const_i32(1);
2196 tcg_gen_shl_i32(tmp, tmp, cpu_SR[WINDOW_BASE]);
2197 tcg_gen_andc_i32(cpu_SR[WINDOW_START],
2198 cpu_SR[WINDOW_START], tmp);
2199 tcg_gen_movi_i32(tmp, dc->pc);
2200 tcg_gen_deposit_i32(tmp, tmp, cpu_R[0], 0, 30);
2201 gen_helper_retw(cpu_env, cpu_R[0]);
2202 gen_jump(dc, tmp);
2203 tcg_temp_free(tmp);
2206 static void translate_rfde(DisasContext *dc, const OpcodeArg arg[],
2207 const uint32_t par[])
2209 gen_jump(dc, cpu_SR[dc->config->ndepc ? DEPC : EPC1]);
2212 static void translate_rfe(DisasContext *dc, const OpcodeArg arg[],
2213 const uint32_t par[])
2215 tcg_gen_andi_i32(cpu_SR[PS], cpu_SR[PS], ~PS_EXCM);
2216 gen_jump(dc, cpu_SR[EPC1]);
2219 static void translate_rfi(DisasContext *dc, const OpcodeArg arg[],
2220 const uint32_t par[])
2222 tcg_gen_mov_i32(cpu_SR[PS], cpu_SR[EPS2 + arg[0].imm - 2]);
2223 gen_jump(dc, cpu_SR[EPC1 + arg[0].imm - 1]);
2226 static void translate_rfw(DisasContext *dc, const OpcodeArg arg[],
2227 const uint32_t par[])
2229 TCGv_i32 tmp = tcg_const_i32(1);
2231 tcg_gen_andi_i32(cpu_SR[PS], cpu_SR[PS], ~PS_EXCM);
2232 tcg_gen_shl_i32(tmp, tmp, cpu_SR[WINDOW_BASE]);
2234 if (par[0]) {
2235 tcg_gen_andc_i32(cpu_SR[WINDOW_START],
2236 cpu_SR[WINDOW_START], tmp);
2237 } else {
2238 tcg_gen_or_i32(cpu_SR[WINDOW_START],
2239 cpu_SR[WINDOW_START], tmp);
2242 tcg_temp_free(tmp);
2243 gen_helper_restore_owb(cpu_env);
2244 gen_jump(dc, cpu_SR[EPC1]);
2247 static void translate_rotw(DisasContext *dc, const OpcodeArg arg[],
2248 const uint32_t par[])
2250 tcg_gen_addi_i32(cpu_windowbase_next, cpu_SR[WINDOW_BASE], arg[0].imm);
2253 static void translate_rsil(DisasContext *dc, const OpcodeArg arg[],
2254 const uint32_t par[])
2256 tcg_gen_mov_i32(arg[0].out, cpu_SR[PS]);
2257 tcg_gen_andi_i32(cpu_SR[PS], cpu_SR[PS], ~PS_INTLEVEL);
2258 tcg_gen_ori_i32(cpu_SR[PS], cpu_SR[PS], arg[1].imm);
2261 static void translate_rsr(DisasContext *dc, const OpcodeArg arg[],
2262 const uint32_t par[])
2264 if (sr_name[par[0]]) {
2265 tcg_gen_mov_i32(arg[0].out, cpu_SR[par[0]]);
2266 } else {
2267 tcg_gen_movi_i32(arg[0].out, 0);
2271 static void translate_rsr_ccount(DisasContext *dc, const OpcodeArg arg[],
2272 const uint32_t par[])
2274 #ifndef CONFIG_USER_ONLY
2275 if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
2276 gen_io_start();
2278 gen_helper_update_ccount(cpu_env);
2279 tcg_gen_mov_i32(arg[0].out, cpu_SR[par[0]]);
2280 #endif
2283 static void translate_rsr_ptevaddr(DisasContext *dc, const OpcodeArg arg[],
2284 const uint32_t par[])
2286 #ifndef CONFIG_USER_ONLY
2287 TCGv_i32 tmp = tcg_temp_new_i32();
2289 tcg_gen_shri_i32(tmp, cpu_SR[EXCVADDR], 10);
2290 tcg_gen_or_i32(tmp, tmp, cpu_SR[PTEVADDR]);
2291 tcg_gen_andi_i32(arg[0].out, tmp, 0xfffffffc);
2292 tcg_temp_free(tmp);
2293 #endif
2296 static void translate_rtlb(DisasContext *dc, const OpcodeArg arg[],
2297 const uint32_t par[])
2299 #ifndef CONFIG_USER_ONLY
2300 static void (* const helper[])(TCGv_i32 r, TCGv_env env, TCGv_i32 a1,
2301 TCGv_i32 a2) = {
2302 gen_helper_rtlb0,
2303 gen_helper_rtlb1,
2305 TCGv_i32 dtlb = tcg_const_i32(par[0]);
2307 helper[par[1]](arg[0].out, cpu_env, arg[1].in, dtlb);
2308 tcg_temp_free(dtlb);
2309 #endif
2312 static void translate_rptlb0(DisasContext *dc, const OpcodeArg arg[],
2313 const uint32_t par[])
2315 #ifndef CONFIG_USER_ONLY
2316 gen_helper_rptlb0(arg[0].out, cpu_env, arg[1].in);
2317 #endif
2320 static void translate_rptlb1(DisasContext *dc, const OpcodeArg arg[],
2321 const uint32_t par[])
2323 #ifndef CONFIG_USER_ONLY
2324 gen_helper_rptlb1(arg[0].out, cpu_env, arg[1].in);
2325 #endif
2328 static void translate_rur(DisasContext *dc, const OpcodeArg arg[],
2329 const uint32_t par[])
2331 tcg_gen_mov_i32(arg[0].out, cpu_UR[par[0]]);
2334 static void translate_setb_expstate(DisasContext *dc, const OpcodeArg arg[],
2335 const uint32_t par[])
2337 /* TODO: GPIO32 may be a part of coprocessor */
2338 tcg_gen_ori_i32(cpu_UR[EXPSTATE], cpu_UR[EXPSTATE], 1u << arg[0].imm);
2341 #ifdef CONFIG_USER_ONLY
2342 static void gen_check_atomctl(DisasContext *dc, TCGv_i32 addr)
2345 #else
2346 static void gen_check_atomctl(DisasContext *dc, TCGv_i32 addr)
2348 TCGv_i32 tpc = tcg_const_i32(dc->pc);
2350 gen_helper_check_atomctl(cpu_env, tpc, addr);
2351 tcg_temp_free(tpc);
2353 #endif
2355 static void translate_s32c1i(DisasContext *dc, const OpcodeArg arg[],
2356 const uint32_t par[])
2358 TCGv_i32 tmp = tcg_temp_local_new_i32();
2359 TCGv_i32 addr = tcg_temp_local_new_i32();
2361 tcg_gen_mov_i32(tmp, arg[0].in);
2362 tcg_gen_addi_i32(addr, arg[1].in, arg[2].imm);
2363 gen_load_store_alignment(dc, 2, addr, true);
2364 gen_check_atomctl(dc, addr);
2365 tcg_gen_atomic_cmpxchg_i32(arg[0].out, addr, cpu_SR[SCOMPARE1],
2366 tmp, dc->cring, MO_TEUL);
2367 tcg_temp_free(addr);
2368 tcg_temp_free(tmp);
2371 static void translate_s32e(DisasContext *dc, const OpcodeArg arg[],
2372 const uint32_t par[])
2374 TCGv_i32 addr = tcg_temp_new_i32();
2376 tcg_gen_addi_i32(addr, arg[1].in, arg[2].imm);
2377 gen_load_store_alignment(dc, 2, addr, false);
2378 tcg_gen_qemu_st_tl(arg[0].in, addr, dc->ring, MO_TEUL);
2379 tcg_temp_free(addr);
2382 static void translate_s32ex(DisasContext *dc, const OpcodeArg arg[],
2383 const uint32_t par[])
2385 TCGv_i32 prev = tcg_temp_new_i32();
2386 TCGv_i32 addr = tcg_temp_local_new_i32();
2387 TCGv_i32 res = tcg_temp_local_new_i32();
2388 TCGLabel *label = gen_new_label();
2390 tcg_gen_movi_i32(res, 0);
2391 tcg_gen_mov_i32(addr, arg[1].in);
2392 gen_load_store_alignment(dc, 2, addr, true);
2393 tcg_gen_brcond_i32(TCG_COND_NE, addr, cpu_exclusive_addr, label);
2394 gen_check_exclusive(dc, addr, true);
2395 tcg_gen_atomic_cmpxchg_i32(prev, cpu_exclusive_addr, cpu_exclusive_val,
2396 arg[0].in, dc->cring, MO_TEUL);
2397 tcg_gen_setcond_i32(TCG_COND_EQ, res, prev, cpu_exclusive_val);
2398 tcg_gen_movcond_i32(TCG_COND_EQ, cpu_exclusive_val,
2399 prev, cpu_exclusive_val, prev, cpu_exclusive_val);
2400 tcg_gen_movi_i32(cpu_exclusive_addr, -1);
2401 gen_set_label(label);
2402 tcg_gen_extract_i32(arg[0].out, cpu_SR[ATOMCTL], 8, 1);
2403 tcg_gen_deposit_i32(cpu_SR[ATOMCTL], cpu_SR[ATOMCTL], res, 8, 1);
2404 tcg_temp_free(prev);
2405 tcg_temp_free(addr);
2406 tcg_temp_free(res);
2409 static void translate_salt(DisasContext *dc, const OpcodeArg arg[],
2410 const uint32_t par[])
2412 tcg_gen_setcond_i32(par[0],
2413 arg[0].out,
2414 arg[1].in, arg[2].in);
2417 static void translate_sext(DisasContext *dc, const OpcodeArg arg[],
2418 const uint32_t par[])
2420 int shift = 31 - arg[2].imm;
2422 if (shift == 24) {
2423 tcg_gen_ext8s_i32(arg[0].out, arg[1].in);
2424 } else if (shift == 16) {
2425 tcg_gen_ext16s_i32(arg[0].out, arg[1].in);
2426 } else {
2427 TCGv_i32 tmp = tcg_temp_new_i32();
2428 tcg_gen_shli_i32(tmp, arg[1].in, shift);
2429 tcg_gen_sari_i32(arg[0].out, tmp, shift);
2430 tcg_temp_free(tmp);
2434 static uint32_t test_exceptions_simcall(DisasContext *dc,
2435 const OpcodeArg arg[],
2436 const uint32_t par[])
2438 #ifdef CONFIG_USER_ONLY
2439 bool ill = true;
2440 #else
2441 /* Between RE.2 and RE.3 simcall opcode's become nop for the hardware. */
2442 bool ill = dc->config->hw_version <= 250002 && !semihosting_enabled();
2443 #endif
2444 if (ill || !semihosting_enabled()) {
2445 qemu_log_mask(LOG_GUEST_ERROR, "SIMCALL but semihosting is disabled\n");
2447 return ill ? XTENSA_OP_ILL : 0;
2450 static void translate_simcall(DisasContext *dc, const OpcodeArg arg[],
2451 const uint32_t par[])
2453 #ifndef CONFIG_USER_ONLY
2454 if (semihosting_enabled()) {
2455 gen_helper_simcall(cpu_env);
2457 #endif
2461 * Note: 64 bit ops are used here solely because SAR values
2462 * have range 0..63
2464 #define gen_shift_reg(cmd, reg) do { \
2465 TCGv_i64 tmp = tcg_temp_new_i64(); \
2466 tcg_gen_extu_i32_i64(tmp, reg); \
2467 tcg_gen_##cmd##_i64(v, v, tmp); \
2468 tcg_gen_extrl_i64_i32(arg[0].out, v); \
2469 tcg_temp_free_i64(v); \
2470 tcg_temp_free_i64(tmp); \
2471 } while (0)
2473 #define gen_shift(cmd) gen_shift_reg(cmd, cpu_SR[SAR])
2475 static void translate_sll(DisasContext *dc, const OpcodeArg arg[],
2476 const uint32_t par[])
2478 if (dc->sar_m32_5bit) {
2479 tcg_gen_shl_i32(arg[0].out, arg[1].in, dc->sar_m32);
2480 } else {
2481 TCGv_i64 v = tcg_temp_new_i64();
2482 TCGv_i32 s = tcg_const_i32(32);
2483 tcg_gen_sub_i32(s, s, cpu_SR[SAR]);
2484 tcg_gen_andi_i32(s, s, 0x3f);
2485 tcg_gen_extu_i32_i64(v, arg[1].in);
2486 gen_shift_reg(shl, s);
2487 tcg_temp_free(s);
2491 static void translate_slli(DisasContext *dc, const OpcodeArg arg[],
2492 const uint32_t par[])
2494 if (arg[2].imm == 32) {
2495 qemu_log_mask(LOG_GUEST_ERROR, "slli a%d, a%d, 32 is undefined\n",
2496 arg[0].imm, arg[1].imm);
2498 tcg_gen_shli_i32(arg[0].out, arg[1].in, arg[2].imm & 0x1f);
2501 static void translate_sra(DisasContext *dc, const OpcodeArg arg[],
2502 const uint32_t par[])
2504 if (dc->sar_m32_5bit) {
2505 tcg_gen_sar_i32(arg[0].out, arg[1].in, cpu_SR[SAR]);
2506 } else {
2507 TCGv_i64 v = tcg_temp_new_i64();
2508 tcg_gen_ext_i32_i64(v, arg[1].in);
2509 gen_shift(sar);
2513 static void translate_srai(DisasContext *dc, const OpcodeArg arg[],
2514 const uint32_t par[])
2516 tcg_gen_sari_i32(arg[0].out, arg[1].in, arg[2].imm);
2519 static void translate_src(DisasContext *dc, const OpcodeArg arg[],
2520 const uint32_t par[])
2522 TCGv_i64 v = tcg_temp_new_i64();
2523 tcg_gen_concat_i32_i64(v, arg[2].in, arg[1].in);
2524 gen_shift(shr);
2527 static void translate_srl(DisasContext *dc, const OpcodeArg arg[],
2528 const uint32_t par[])
2530 if (dc->sar_m32_5bit) {
2531 tcg_gen_shr_i32(arg[0].out, arg[1].in, cpu_SR[SAR]);
2532 } else {
2533 TCGv_i64 v = tcg_temp_new_i64();
2534 tcg_gen_extu_i32_i64(v, arg[1].in);
2535 gen_shift(shr);
2539 #undef gen_shift
2540 #undef gen_shift_reg
2542 static void translate_srli(DisasContext *dc, const OpcodeArg arg[],
2543 const uint32_t par[])
2545 tcg_gen_shri_i32(arg[0].out, arg[1].in, arg[2].imm);
2548 static void translate_ssa8b(DisasContext *dc, const OpcodeArg arg[],
2549 const uint32_t par[])
2551 TCGv_i32 tmp = tcg_temp_new_i32();
2552 tcg_gen_shli_i32(tmp, arg[0].in, 3);
2553 gen_left_shift_sar(dc, tmp);
2554 tcg_temp_free(tmp);
2557 static void translate_ssa8l(DisasContext *dc, const OpcodeArg arg[],
2558 const uint32_t par[])
2560 TCGv_i32 tmp = tcg_temp_new_i32();
2561 tcg_gen_shli_i32(tmp, arg[0].in, 3);
2562 gen_right_shift_sar(dc, tmp);
2563 tcg_temp_free(tmp);
2566 static void translate_ssai(DisasContext *dc, const OpcodeArg arg[],
2567 const uint32_t par[])
2569 TCGv_i32 tmp = tcg_const_i32(arg[0].imm);
2570 gen_right_shift_sar(dc, tmp);
2571 tcg_temp_free(tmp);
2574 static void translate_ssl(DisasContext *dc, const OpcodeArg arg[],
2575 const uint32_t par[])
2577 gen_left_shift_sar(dc, arg[0].in);
2580 static void translate_ssr(DisasContext *dc, const OpcodeArg arg[],
2581 const uint32_t par[])
2583 gen_right_shift_sar(dc, arg[0].in);
2586 static void translate_sub(DisasContext *dc, const OpcodeArg arg[],
2587 const uint32_t par[])
2589 tcg_gen_sub_i32(arg[0].out, arg[1].in, arg[2].in);
2592 static void translate_subx(DisasContext *dc, const OpcodeArg arg[],
2593 const uint32_t par[])
2595 TCGv_i32 tmp = tcg_temp_new_i32();
2596 tcg_gen_shli_i32(tmp, arg[1].in, par[0]);
2597 tcg_gen_sub_i32(arg[0].out, tmp, arg[2].in);
2598 tcg_temp_free(tmp);
2601 static void translate_waiti(DisasContext *dc, const OpcodeArg arg[],
2602 const uint32_t par[])
2604 #ifndef CONFIG_USER_ONLY
2605 gen_waiti(dc, arg[0].imm);
2606 #endif
2609 static void translate_wtlb(DisasContext *dc, const OpcodeArg arg[],
2610 const uint32_t par[])
2612 #ifndef CONFIG_USER_ONLY
2613 TCGv_i32 dtlb = tcg_const_i32(par[0]);
2615 gen_helper_wtlb(cpu_env, arg[0].in, arg[1].in, dtlb);
2616 tcg_temp_free(dtlb);
2617 #endif
2620 static void translate_wptlb(DisasContext *dc, const OpcodeArg arg[],
2621 const uint32_t par[])
2623 #ifndef CONFIG_USER_ONLY
2624 gen_helper_wptlb(cpu_env, arg[0].in, arg[1].in);
2625 #endif
2628 static void translate_wer(DisasContext *dc, const OpcodeArg arg[],
2629 const uint32_t par[])
2631 gen_helper_wer(cpu_env, arg[0].in, arg[1].in);
2634 static void translate_wrmsk_expstate(DisasContext *dc, const OpcodeArg arg[],
2635 const uint32_t par[])
2637 /* TODO: GPIO32 may be a part of coprocessor */
2638 tcg_gen_and_i32(cpu_UR[EXPSTATE], arg[0].in, arg[1].in);
2641 static void translate_wsr(DisasContext *dc, const OpcodeArg arg[],
2642 const uint32_t par[])
2644 if (sr_name[par[0]]) {
2645 tcg_gen_mov_i32(cpu_SR[par[0]], arg[0].in);
2649 static void translate_wsr_mask(DisasContext *dc, const OpcodeArg arg[],
2650 const uint32_t par[])
2652 if (sr_name[par[0]]) {
2653 tcg_gen_andi_i32(cpu_SR[par[0]], arg[0].in, par[2]);
2657 static void translate_wsr_acchi(DisasContext *dc, const OpcodeArg arg[],
2658 const uint32_t par[])
2660 tcg_gen_ext8s_i32(cpu_SR[par[0]], arg[0].in);
2663 static void translate_wsr_ccompare(DisasContext *dc, const OpcodeArg arg[],
2664 const uint32_t par[])
2666 #ifndef CONFIG_USER_ONLY
2667 uint32_t id = par[0] - CCOMPARE;
2668 TCGv_i32 tmp = tcg_const_i32(id);
2670 assert(id < dc->config->nccompare);
2671 if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
2672 gen_io_start();
2674 tcg_gen_mov_i32(cpu_SR[par[0]], arg[0].in);
2675 gen_helper_update_ccompare(cpu_env, tmp);
2676 tcg_temp_free(tmp);
2677 #endif
2680 static void translate_wsr_ccount(DisasContext *dc, const OpcodeArg arg[],
2681 const uint32_t par[])
2683 #ifndef CONFIG_USER_ONLY
2684 if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
2685 gen_io_start();
2687 gen_helper_wsr_ccount(cpu_env, arg[0].in);
2688 #endif
2691 static void translate_wsr_dbreaka(DisasContext *dc, const OpcodeArg arg[],
2692 const uint32_t par[])
2694 #ifndef CONFIG_USER_ONLY
2695 unsigned id = par[0] - DBREAKA;
2696 TCGv_i32 tmp = tcg_const_i32(id);
2698 assert(id < dc->config->ndbreak);
2699 gen_helper_wsr_dbreaka(cpu_env, tmp, arg[0].in);
2700 tcg_temp_free(tmp);
2701 #endif
2704 static void translate_wsr_dbreakc(DisasContext *dc, const OpcodeArg arg[],
2705 const uint32_t par[])
2707 #ifndef CONFIG_USER_ONLY
2708 unsigned id = par[0] - DBREAKC;
2709 TCGv_i32 tmp = tcg_const_i32(id);
2711 assert(id < dc->config->ndbreak);
2712 gen_helper_wsr_dbreakc(cpu_env, tmp, arg[0].in);
2713 tcg_temp_free(tmp);
2714 #endif
2717 static void translate_wsr_ibreaka(DisasContext *dc, const OpcodeArg arg[],
2718 const uint32_t par[])
2720 #ifndef CONFIG_USER_ONLY
2721 unsigned id = par[0] - IBREAKA;
2722 TCGv_i32 tmp = tcg_const_i32(id);
2724 assert(id < dc->config->nibreak);
2725 gen_helper_wsr_ibreaka(cpu_env, tmp, arg[0].in);
2726 tcg_temp_free(tmp);
2727 #endif
2730 static void translate_wsr_ibreakenable(DisasContext *dc, const OpcodeArg arg[],
2731 const uint32_t par[])
2733 #ifndef CONFIG_USER_ONLY
2734 gen_helper_wsr_ibreakenable(cpu_env, arg[0].in);
2735 #endif
2738 static void translate_wsr_icount(DisasContext *dc, const OpcodeArg arg[],
2739 const uint32_t par[])
2741 #ifndef CONFIG_USER_ONLY
2742 if (dc->icount) {
2743 tcg_gen_mov_i32(dc->next_icount, arg[0].in);
2744 } else {
2745 tcg_gen_mov_i32(cpu_SR[par[0]], arg[0].in);
2747 #endif
2750 static void translate_wsr_intclear(DisasContext *dc, const OpcodeArg arg[],
2751 const uint32_t par[])
2753 #ifndef CONFIG_USER_ONLY
2754 gen_helper_intclear(cpu_env, arg[0].in);
2755 #endif
2758 static void translate_wsr_intset(DisasContext *dc, const OpcodeArg arg[],
2759 const uint32_t par[])
2761 #ifndef CONFIG_USER_ONLY
2762 gen_helper_intset(cpu_env, arg[0].in);
2763 #endif
2766 static void translate_wsr_memctl(DisasContext *dc, const OpcodeArg arg[],
2767 const uint32_t par[])
2769 #ifndef CONFIG_USER_ONLY
2770 gen_helper_wsr_memctl(cpu_env, arg[0].in);
2771 #endif
2774 static void translate_wsr_mpuenb(DisasContext *dc, const OpcodeArg arg[],
2775 const uint32_t par[])
2777 #ifndef CONFIG_USER_ONLY
2778 gen_helper_wsr_mpuenb(cpu_env, arg[0].in);
2779 #endif
2782 static void translate_wsr_ps(DisasContext *dc, const OpcodeArg arg[],
2783 const uint32_t par[])
2785 #ifndef CONFIG_USER_ONLY
2786 uint32_t mask = PS_WOE | PS_CALLINC | PS_OWB |
2787 PS_UM | PS_EXCM | PS_INTLEVEL;
2789 if (option_enabled(dc, XTENSA_OPTION_MMU) ||
2790 option_enabled(dc, XTENSA_OPTION_MPU)) {
2791 mask |= PS_RING;
2793 tcg_gen_andi_i32(cpu_SR[par[0]], arg[0].in, mask);
2794 #endif
2797 static void translate_wsr_rasid(DisasContext *dc, const OpcodeArg arg[],
2798 const uint32_t par[])
2800 #ifndef CONFIG_USER_ONLY
2801 gen_helper_wsr_rasid(cpu_env, arg[0].in);
2802 #endif
2805 static void translate_wsr_sar(DisasContext *dc, const OpcodeArg arg[],
2806 const uint32_t par[])
2808 tcg_gen_andi_i32(cpu_SR[par[0]], arg[0].in, 0x3f);
2809 if (dc->sar_m32_5bit) {
2810 tcg_gen_discard_i32(dc->sar_m32);
2812 dc->sar_5bit = false;
2813 dc->sar_m32_5bit = false;
2816 static void translate_wsr_windowbase(DisasContext *dc, const OpcodeArg arg[],
2817 const uint32_t par[])
2819 #ifndef CONFIG_USER_ONLY
2820 tcg_gen_mov_i32(cpu_windowbase_next, arg[0].in);
2821 #endif
2824 static void translate_wsr_windowstart(DisasContext *dc, const OpcodeArg arg[],
2825 const uint32_t par[])
2827 #ifndef CONFIG_USER_ONLY
2828 tcg_gen_andi_i32(cpu_SR[par[0]], arg[0].in,
2829 (1 << dc->config->nareg / 4) - 1);
2830 #endif
2833 static void translate_wur(DisasContext *dc, const OpcodeArg arg[],
2834 const uint32_t par[])
2836 tcg_gen_mov_i32(cpu_UR[par[0]], arg[0].in);
2839 static void translate_xor(DisasContext *dc, const OpcodeArg arg[],
2840 const uint32_t par[])
2842 tcg_gen_xor_i32(arg[0].out, arg[1].in, arg[2].in);
2845 static void translate_xsr(DisasContext *dc, const OpcodeArg arg[],
2846 const uint32_t par[])
2848 if (sr_name[par[0]]) {
2849 TCGv_i32 tmp = tcg_temp_new_i32();
2851 tcg_gen_mov_i32(tmp, arg[0].in);
2852 tcg_gen_mov_i32(arg[0].out, cpu_SR[par[0]]);
2853 tcg_gen_mov_i32(cpu_SR[par[0]], tmp);
2854 tcg_temp_free(tmp);
2855 } else {
2856 tcg_gen_movi_i32(arg[0].out, 0);
2860 static void translate_xsr_mask(DisasContext *dc, const OpcodeArg arg[],
2861 const uint32_t par[])
2863 if (sr_name[par[0]]) {
2864 TCGv_i32 tmp = tcg_temp_new_i32();
2866 tcg_gen_mov_i32(tmp, arg[0].in);
2867 tcg_gen_mov_i32(arg[0].out, cpu_SR[par[0]]);
2868 tcg_gen_andi_i32(cpu_SR[par[0]], tmp, par[2]);
2869 tcg_temp_free(tmp);
2870 } else {
2871 tcg_gen_movi_i32(arg[0].out, 0);
2875 static void translate_xsr_ccount(DisasContext *dc, const OpcodeArg arg[],
2876 const uint32_t par[])
2878 #ifndef CONFIG_USER_ONLY
2879 TCGv_i32 tmp = tcg_temp_new_i32();
2881 if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
2882 gen_io_start();
2885 gen_helper_update_ccount(cpu_env);
2886 tcg_gen_mov_i32(tmp, cpu_SR[par[0]]);
2887 gen_helper_wsr_ccount(cpu_env, arg[0].in);
2888 tcg_gen_mov_i32(arg[0].out, tmp);
2889 tcg_temp_free(tmp);
2891 #endif
2894 #define gen_translate_xsr(name) \
2895 static void translate_xsr_##name(DisasContext *dc, const OpcodeArg arg[], \
2896 const uint32_t par[]) \
2898 TCGv_i32 tmp = tcg_temp_new_i32(); \
2900 if (sr_name[par[0]]) { \
2901 tcg_gen_mov_i32(tmp, cpu_SR[par[0]]); \
2902 } else { \
2903 tcg_gen_movi_i32(tmp, 0); \
2905 translate_wsr_##name(dc, arg, par); \
2906 tcg_gen_mov_i32(arg[0].out, tmp); \
2907 tcg_temp_free(tmp); \
2910 gen_translate_xsr(acchi)
2911 gen_translate_xsr(ccompare)
2912 gen_translate_xsr(dbreaka)
2913 gen_translate_xsr(dbreakc)
2914 gen_translate_xsr(ibreaka)
2915 gen_translate_xsr(ibreakenable)
2916 gen_translate_xsr(icount)
2917 gen_translate_xsr(memctl)
2918 gen_translate_xsr(mpuenb)
2919 gen_translate_xsr(ps)
2920 gen_translate_xsr(rasid)
2921 gen_translate_xsr(sar)
2922 gen_translate_xsr(windowbase)
2923 gen_translate_xsr(windowstart)
2925 #undef gen_translate_xsr
2927 static const XtensaOpcodeOps core_ops[] = {
2929 .name = "abs",
2930 .translate = translate_abs,
2931 }, {
2932 .name = (const char * const[]) {
2933 "add", "add.n", NULL,
2935 .translate = translate_add,
2936 .op_flags = XTENSA_OP_NAME_ARRAY,
2937 }, {
2938 .name = (const char * const[]) {
2939 "addi", "addi.n", NULL,
2941 .translate = translate_addi,
2942 .op_flags = XTENSA_OP_NAME_ARRAY,
2943 }, {
2944 .name = "addmi",
2945 .translate = translate_addi,
2946 }, {
2947 .name = "addx2",
2948 .translate = translate_addx,
2949 .par = (const uint32_t[]){1},
2950 }, {
2951 .name = "addx4",
2952 .translate = translate_addx,
2953 .par = (const uint32_t[]){2},
2954 }, {
2955 .name = "addx8",
2956 .translate = translate_addx,
2957 .par = (const uint32_t[]){3},
2958 }, {
2959 .name = "all4",
2960 .translate = translate_all,
2961 .par = (const uint32_t[]){true, 4},
2962 }, {
2963 .name = "all8",
2964 .translate = translate_all,
2965 .par = (const uint32_t[]){true, 8},
2966 }, {
2967 .name = "and",
2968 .translate = translate_and,
2969 }, {
2970 .name = "andb",
2971 .translate = translate_boolean,
2972 .par = (const uint32_t[]){BOOLEAN_AND},
2973 }, {
2974 .name = "andbc",
2975 .translate = translate_boolean,
2976 .par = (const uint32_t[]){BOOLEAN_ANDC},
2977 }, {
2978 .name = "any4",
2979 .translate = translate_all,
2980 .par = (const uint32_t[]){false, 4},
2981 }, {
2982 .name = "any8",
2983 .translate = translate_all,
2984 .par = (const uint32_t[]){false, 8},
2985 }, {
2986 .name = (const char * const[]) {
2987 "ball", "ball.w15", "ball.w18", NULL,
2989 .translate = translate_ball,
2990 .par = (const uint32_t[]){TCG_COND_EQ},
2991 .op_flags = XTENSA_OP_NAME_ARRAY,
2992 }, {
2993 .name = (const char * const[]) {
2994 "bany", "bany.w15", "bany.w18", NULL,
2996 .translate = translate_bany,
2997 .par = (const uint32_t[]){TCG_COND_NE},
2998 .op_flags = XTENSA_OP_NAME_ARRAY,
2999 }, {
3000 .name = (const char * const[]) {
3001 "bbc", "bbc.w15", "bbc.w18", NULL,
3003 .translate = translate_bb,
3004 .par = (const uint32_t[]){TCG_COND_EQ},
3005 .op_flags = XTENSA_OP_NAME_ARRAY,
3006 }, {
3007 .name = (const char * const[]) {
3008 "bbci", "bbci.w15", "bbci.w18", NULL,
3010 .translate = translate_bbi,
3011 .par = (const uint32_t[]){TCG_COND_EQ},
3012 .op_flags = XTENSA_OP_NAME_ARRAY,
3013 }, {
3014 .name = (const char * const[]) {
3015 "bbs", "bbs.w15", "bbs.w18", NULL,
3017 .translate = translate_bb,
3018 .par = (const uint32_t[]){TCG_COND_NE},
3019 .op_flags = XTENSA_OP_NAME_ARRAY,
3020 }, {
3021 .name = (const char * const[]) {
3022 "bbsi", "bbsi.w15", "bbsi.w18", NULL,
3024 .translate = translate_bbi,
3025 .par = (const uint32_t[]){TCG_COND_NE},
3026 .op_flags = XTENSA_OP_NAME_ARRAY,
3027 }, {
3028 .name = (const char * const[]) {
3029 "beq", "beq.w15", "beq.w18", NULL,
3031 .translate = translate_b,
3032 .par = (const uint32_t[]){TCG_COND_EQ},
3033 .op_flags = XTENSA_OP_NAME_ARRAY,
3034 }, {
3035 .name = (const char * const[]) {
3036 "beqi", "beqi.w15", "beqi.w18", NULL,
3038 .translate = translate_bi,
3039 .par = (const uint32_t[]){TCG_COND_EQ},
3040 .op_flags = XTENSA_OP_NAME_ARRAY,
3041 }, {
3042 .name = (const char * const[]) {
3043 "beqz", "beqz.n", "beqz.w15", "beqz.w18", NULL,
3045 .translate = translate_bz,
3046 .par = (const uint32_t[]){TCG_COND_EQ},
3047 .op_flags = XTENSA_OP_NAME_ARRAY,
3048 }, {
3049 .name = "bf",
3050 .translate = translate_bp,
3051 .par = (const uint32_t[]){TCG_COND_EQ},
3052 }, {
3053 .name = (const char * const[]) {
3054 "bge", "bge.w15", "bge.w18", NULL,
3056 .translate = translate_b,
3057 .par = (const uint32_t[]){TCG_COND_GE},
3058 .op_flags = XTENSA_OP_NAME_ARRAY,
3059 }, {
3060 .name = (const char * const[]) {
3061 "bgei", "bgei.w15", "bgei.w18", NULL,
3063 .translate = translate_bi,
3064 .par = (const uint32_t[]){TCG_COND_GE},
3065 .op_flags = XTENSA_OP_NAME_ARRAY,
3066 }, {
3067 .name = (const char * const[]) {
3068 "bgeu", "bgeu.w15", "bgeu.w18", NULL,
3070 .translate = translate_b,
3071 .par = (const uint32_t[]){TCG_COND_GEU},
3072 .op_flags = XTENSA_OP_NAME_ARRAY,
3073 }, {
3074 .name = (const char * const[]) {
3075 "bgeui", "bgeui.w15", "bgeui.w18", NULL,
3077 .translate = translate_bi,
3078 .par = (const uint32_t[]){TCG_COND_GEU},
3079 .op_flags = XTENSA_OP_NAME_ARRAY,
3080 }, {
3081 .name = (const char * const[]) {
3082 "bgez", "bgez.w15", "bgez.w18", NULL,
3084 .translate = translate_bz,
3085 .par = (const uint32_t[]){TCG_COND_GE},
3086 .op_flags = XTENSA_OP_NAME_ARRAY,
3087 }, {
3088 .name = (const char * const[]) {
3089 "blt", "blt.w15", "blt.w18", NULL,
3091 .translate = translate_b,
3092 .par = (const uint32_t[]){TCG_COND_LT},
3093 .op_flags = XTENSA_OP_NAME_ARRAY,
3094 }, {
3095 .name = (const char * const[]) {
3096 "blti", "blti.w15", "blti.w18", NULL,
3098 .translate = translate_bi,
3099 .par = (const uint32_t[]){TCG_COND_LT},
3100 .op_flags = XTENSA_OP_NAME_ARRAY,
3101 }, {
3102 .name = (const char * const[]) {
3103 "bltu", "bltu.w15", "bltu.w18", NULL,
3105 .translate = translate_b,
3106 .par = (const uint32_t[]){TCG_COND_LTU},
3107 .op_flags = XTENSA_OP_NAME_ARRAY,
3108 }, {
3109 .name = (const char * const[]) {
3110 "bltui", "bltui.w15", "bltui.w18", NULL,
3112 .translate = translate_bi,
3113 .par = (const uint32_t[]){TCG_COND_LTU},
3114 .op_flags = XTENSA_OP_NAME_ARRAY,
3115 }, {
3116 .name = (const char * const[]) {
3117 "bltz", "bltz.w15", "bltz.w18", NULL,
3119 .translate = translate_bz,
3120 .par = (const uint32_t[]){TCG_COND_LT},
3121 .op_flags = XTENSA_OP_NAME_ARRAY,
3122 }, {
3123 .name = (const char * const[]) {
3124 "bnall", "bnall.w15", "bnall.w18", NULL,
3126 .translate = translate_ball,
3127 .par = (const uint32_t[]){TCG_COND_NE},
3128 .op_flags = XTENSA_OP_NAME_ARRAY,
3129 }, {
3130 .name = (const char * const[]) {
3131 "bne", "bne.w15", "bne.w18", NULL,
3133 .translate = translate_b,
3134 .par = (const uint32_t[]){TCG_COND_NE},
3135 .op_flags = XTENSA_OP_NAME_ARRAY,
3136 }, {
3137 .name = (const char * const[]) {
3138 "bnei", "bnei.w15", "bnei.w18", NULL,
3140 .translate = translate_bi,
3141 .par = (const uint32_t[]){TCG_COND_NE},
3142 .op_flags = XTENSA_OP_NAME_ARRAY,
3143 }, {
3144 .name = (const char * const[]) {
3145 "bnez", "bnez.n", "bnez.w15", "bnez.w18", NULL,
3147 .translate = translate_bz,
3148 .par = (const uint32_t[]){TCG_COND_NE},
3149 .op_flags = XTENSA_OP_NAME_ARRAY,
3150 }, {
3151 .name = (const char * const[]) {
3152 "bnone", "bnone.w15", "bnone.w18", NULL,
3154 .translate = translate_bany,
3155 .par = (const uint32_t[]){TCG_COND_EQ},
3156 .op_flags = XTENSA_OP_NAME_ARRAY,
3157 }, {
3158 .name = "break",
3159 .translate = translate_nop,
3160 .par = (const uint32_t[]){DEBUGCAUSE_BI},
3161 .op_flags = XTENSA_OP_DEBUG_BREAK,
3162 }, {
3163 .name = "break.n",
3164 .translate = translate_nop,
3165 .par = (const uint32_t[]){DEBUGCAUSE_BN},
3166 .op_flags = XTENSA_OP_DEBUG_BREAK,
3167 }, {
3168 .name = "bt",
3169 .translate = translate_bp,
3170 .par = (const uint32_t[]){TCG_COND_NE},
3171 }, {
3172 .name = "call0",
3173 .translate = translate_call0,
3174 }, {
3175 .name = "call12",
3176 .translate = translate_callw,
3177 .par = (const uint32_t[]){3},
3178 }, {
3179 .name = "call4",
3180 .translate = translate_callw,
3181 .par = (const uint32_t[]){1},
3182 }, {
3183 .name = "call8",
3184 .translate = translate_callw,
3185 .par = (const uint32_t[]){2},
3186 }, {
3187 .name = "callx0",
3188 .translate = translate_callx0,
3189 }, {
3190 .name = "callx12",
3191 .translate = translate_callxw,
3192 .par = (const uint32_t[]){3},
3193 }, {
3194 .name = "callx4",
3195 .translate = translate_callxw,
3196 .par = (const uint32_t[]){1},
3197 }, {
3198 .name = "callx8",
3199 .translate = translate_callxw,
3200 .par = (const uint32_t[]){2},
3201 }, {
3202 .name = "clamps",
3203 .translate = translate_clamps,
3204 }, {
3205 .name = "clrb_expstate",
3206 .translate = translate_clrb_expstate,
3207 }, {
3208 .name = "clrex",
3209 .translate = translate_clrex,
3210 }, {
3211 .name = "const16",
3212 .translate = translate_const16,
3213 }, {
3214 .name = "depbits",
3215 .translate = translate_depbits,
3216 }, {
3217 .name = "dhi",
3218 .translate = translate_dcache,
3219 .op_flags = XTENSA_OP_PRIVILEGED,
3220 }, {
3221 .name = "dhi.b",
3222 .translate = translate_nop,
3223 }, {
3224 .name = "dhu",
3225 .translate = translate_dcache,
3226 .op_flags = XTENSA_OP_PRIVILEGED,
3227 }, {
3228 .name = "dhwb",
3229 .translate = translate_dcache,
3230 }, {
3231 .name = "dhwb.b",
3232 .translate = translate_nop,
3233 }, {
3234 .name = "dhwbi",
3235 .translate = translate_dcache,
3236 }, {
3237 .name = "dhwbi.b",
3238 .translate = translate_nop,
3239 }, {
3240 .name = "dii",
3241 .translate = translate_nop,
3242 .op_flags = XTENSA_OP_PRIVILEGED,
3243 }, {
3244 .name = "diu",
3245 .translate = translate_nop,
3246 .op_flags = XTENSA_OP_PRIVILEGED,
3247 }, {
3248 .name = "diwb",
3249 .translate = translate_nop,
3250 .op_flags = XTENSA_OP_PRIVILEGED,
3251 }, {
3252 .name = "diwbi",
3253 .translate = translate_nop,
3254 .op_flags = XTENSA_OP_PRIVILEGED,
3255 }, {
3256 .name = "diwbui.p",
3257 .translate = translate_diwbuip,
3258 .op_flags = XTENSA_OP_PRIVILEGED,
3259 }, {
3260 .name = "dpfl",
3261 .translate = translate_dcache,
3262 .op_flags = XTENSA_OP_PRIVILEGED,
3263 }, {
3264 .name = "dpfm.b",
3265 .translate = translate_nop,
3266 }, {
3267 .name = "dpfm.bf",
3268 .translate = translate_nop,
3269 }, {
3270 .name = "dpfr",
3271 .translate = translate_nop,
3272 }, {
3273 .name = "dpfr.b",
3274 .translate = translate_nop,
3275 }, {
3276 .name = "dpfr.bf",
3277 .translate = translate_nop,
3278 }, {
3279 .name = "dpfro",
3280 .translate = translate_nop,
3281 }, {
3282 .name = "dpfw",
3283 .translate = translate_nop,
3284 }, {
3285 .name = "dpfw.b",
3286 .translate = translate_nop,
3287 }, {
3288 .name = "dpfw.bf",
3289 .translate = translate_nop,
3290 }, {
3291 .name = "dpfwo",
3292 .translate = translate_nop,
3293 }, {
3294 .name = "dsync",
3295 .translate = translate_nop,
3296 }, {
3297 .name = "entry",
3298 .translate = translate_entry,
3299 .test_exceptions = test_exceptions_entry,
3300 .test_overflow = test_overflow_entry,
3301 .op_flags = XTENSA_OP_EXIT_TB_M1 |
3302 XTENSA_OP_SYNC_REGISTER_WINDOW,
3303 }, {
3304 .name = "esync",
3305 .translate = translate_nop,
3306 }, {
3307 .name = "excw",
3308 .translate = translate_nop,
3309 }, {
3310 .name = "extui",
3311 .translate = translate_extui,
3312 }, {
3313 .name = "extw",
3314 .translate = translate_memw,
3315 }, {
3316 .name = "getex",
3317 .translate = translate_getex,
3318 }, {
3319 .name = "hwwdtlba",
3320 .op_flags = XTENSA_OP_ILL,
3321 }, {
3322 .name = "hwwitlba",
3323 .op_flags = XTENSA_OP_ILL,
3324 }, {
3325 .name = "idtlb",
3326 .translate = translate_itlb,
3327 .par = (const uint32_t[]){true},
3328 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_M1,
3329 }, {
3330 .name = "ihi",
3331 .translate = translate_icache,
3332 }, {
3333 .name = "ihu",
3334 .translate = translate_icache,
3335 .op_flags = XTENSA_OP_PRIVILEGED,
3336 }, {
3337 .name = "iii",
3338 .translate = translate_nop,
3339 .op_flags = XTENSA_OP_PRIVILEGED,
3340 }, {
3341 .name = "iitlb",
3342 .translate = translate_itlb,
3343 .par = (const uint32_t[]){false},
3344 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_M1,
3345 }, {
3346 .name = "iiu",
3347 .translate = translate_nop,
3348 .op_flags = XTENSA_OP_PRIVILEGED,
3349 }, {
3350 .name = (const char * const[]) {
3351 "ill", "ill.n", NULL,
3353 .op_flags = XTENSA_OP_ILL | XTENSA_OP_NAME_ARRAY,
3354 }, {
3355 .name = "ipf",
3356 .translate = translate_nop,
3357 }, {
3358 .name = "ipfl",
3359 .translate = translate_icache,
3360 .op_flags = XTENSA_OP_PRIVILEGED,
3361 }, {
3362 .name = "isync",
3363 .translate = translate_nop,
3364 }, {
3365 .name = "j",
3366 .translate = translate_j,
3367 }, {
3368 .name = "jx",
3369 .translate = translate_jx,
3370 }, {
3371 .name = "l16si",
3372 .translate = translate_ldst,
3373 .par = (const uint32_t[]){MO_TESW, false, false},
3374 .op_flags = XTENSA_OP_LOAD,
3375 }, {
3376 .name = "l16ui",
3377 .translate = translate_ldst,
3378 .par = (const uint32_t[]){MO_TEUW, false, false},
3379 .op_flags = XTENSA_OP_LOAD,
3380 }, {
3381 .name = "l32ai",
3382 .translate = translate_ldst,
3383 .par = (const uint32_t[]){MO_TEUL, true, false},
3384 .op_flags = XTENSA_OP_LOAD,
3385 }, {
3386 .name = "l32e",
3387 .translate = translate_l32e,
3388 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_LOAD,
3389 }, {
3390 .name = "l32ex",
3391 .translate = translate_l32ex,
3392 .op_flags = XTENSA_OP_LOAD,
3393 }, {
3394 .name = (const char * const[]) {
3395 "l32i", "l32i.n", NULL,
3397 .translate = translate_ldst,
3398 .par = (const uint32_t[]){MO_TEUL, false, false},
3399 .op_flags = XTENSA_OP_NAME_ARRAY | XTENSA_OP_LOAD,
3400 }, {
3401 .name = "l32r",
3402 .translate = translate_l32r,
3403 .op_flags = XTENSA_OP_LOAD,
3404 }, {
3405 .name = "l8ui",
3406 .translate = translate_ldst,
3407 .par = (const uint32_t[]){MO_UB, false, false},
3408 .op_flags = XTENSA_OP_LOAD,
3409 }, {
3410 .name = "lddec",
3411 .translate = translate_mac16,
3412 .par = (const uint32_t[]){MAC16_NONE, 0, -4},
3413 .op_flags = XTENSA_OP_LOAD,
3414 }, {
3415 .name = "ldinc",
3416 .translate = translate_mac16,
3417 .par = (const uint32_t[]){MAC16_NONE, 0, 4},
3418 .op_flags = XTENSA_OP_LOAD,
3419 }, {
3420 .name = "ldpte",
3421 .op_flags = XTENSA_OP_ILL,
3422 }, {
3423 .name = (const char * const[]) {
3424 "loop", "loop.w15", NULL,
3426 .translate = translate_loop,
3427 .par = (const uint32_t[]){TCG_COND_NEVER},
3428 .op_flags = XTENSA_OP_NAME_ARRAY,
3429 }, {
3430 .name = (const char * const[]) {
3431 "loopgtz", "loopgtz.w15", NULL,
3433 .translate = translate_loop,
3434 .par = (const uint32_t[]){TCG_COND_GT},
3435 .op_flags = XTENSA_OP_NAME_ARRAY,
3436 }, {
3437 .name = (const char * const[]) {
3438 "loopnez", "loopnez.w15", NULL,
3440 .translate = translate_loop,
3441 .par = (const uint32_t[]){TCG_COND_NE},
3442 .op_flags = XTENSA_OP_NAME_ARRAY,
3443 }, {
3444 .name = "max",
3445 .translate = translate_smax,
3446 }, {
3447 .name = "maxu",
3448 .translate = translate_umax,
3449 }, {
3450 .name = "memw",
3451 .translate = translate_memw,
3452 }, {
3453 .name = "min",
3454 .translate = translate_smin,
3455 }, {
3456 .name = "minu",
3457 .translate = translate_umin,
3458 }, {
3459 .name = (const char * const[]) {
3460 "mov", "mov.n", NULL,
3462 .translate = translate_mov,
3463 .op_flags = XTENSA_OP_NAME_ARRAY,
3464 }, {
3465 .name = "moveqz",
3466 .translate = translate_movcond,
3467 .par = (const uint32_t[]){TCG_COND_EQ},
3468 }, {
3469 .name = "movf",
3470 .translate = translate_movp,
3471 .par = (const uint32_t[]){TCG_COND_EQ},
3472 }, {
3473 .name = "movgez",
3474 .translate = translate_movcond,
3475 .par = (const uint32_t[]){TCG_COND_GE},
3476 }, {
3477 .name = "movi",
3478 .translate = translate_movi,
3479 }, {
3480 .name = "movi.n",
3481 .translate = translate_movi,
3482 }, {
3483 .name = "movltz",
3484 .translate = translate_movcond,
3485 .par = (const uint32_t[]){TCG_COND_LT},
3486 }, {
3487 .name = "movnez",
3488 .translate = translate_movcond,
3489 .par = (const uint32_t[]){TCG_COND_NE},
3490 }, {
3491 .name = "movsp",
3492 .translate = translate_movsp,
3493 .op_flags = XTENSA_OP_ALLOCA,
3494 }, {
3495 .name = "movt",
3496 .translate = translate_movp,
3497 .par = (const uint32_t[]){TCG_COND_NE},
3498 }, {
3499 .name = "mul.aa.hh",
3500 .translate = translate_mac16,
3501 .par = (const uint32_t[]){MAC16_MUL, MAC16_HH, 0},
3502 }, {
3503 .name = "mul.aa.hl",
3504 .translate = translate_mac16,
3505 .par = (const uint32_t[]){MAC16_MUL, MAC16_HL, 0},
3506 }, {
3507 .name = "mul.aa.lh",
3508 .translate = translate_mac16,
3509 .par = (const uint32_t[]){MAC16_MUL, MAC16_LH, 0},
3510 }, {
3511 .name = "mul.aa.ll",
3512 .translate = translate_mac16,
3513 .par = (const uint32_t[]){MAC16_MUL, MAC16_LL, 0},
3514 }, {
3515 .name = "mul.ad.hh",
3516 .translate = translate_mac16,
3517 .par = (const uint32_t[]){MAC16_MUL, MAC16_HH, 0},
3518 }, {
3519 .name = "mul.ad.hl",
3520 .translate = translate_mac16,
3521 .par = (const uint32_t[]){MAC16_MUL, MAC16_HL, 0},
3522 }, {
3523 .name = "mul.ad.lh",
3524 .translate = translate_mac16,
3525 .par = (const uint32_t[]){MAC16_MUL, MAC16_LH, 0},
3526 }, {
3527 .name = "mul.ad.ll",
3528 .translate = translate_mac16,
3529 .par = (const uint32_t[]){MAC16_MUL, MAC16_LL, 0},
3530 }, {
3531 .name = "mul.da.hh",
3532 .translate = translate_mac16,
3533 .par = (const uint32_t[]){MAC16_MUL, MAC16_HH, 0},
3534 }, {
3535 .name = "mul.da.hl",
3536 .translate = translate_mac16,
3537 .par = (const uint32_t[]){MAC16_MUL, MAC16_HL, 0},
3538 }, {
3539 .name = "mul.da.lh",
3540 .translate = translate_mac16,
3541 .par = (const uint32_t[]){MAC16_MUL, MAC16_LH, 0},
3542 }, {
3543 .name = "mul.da.ll",
3544 .translate = translate_mac16,
3545 .par = (const uint32_t[]){MAC16_MUL, MAC16_LL, 0},
3546 }, {
3547 .name = "mul.dd.hh",
3548 .translate = translate_mac16,
3549 .par = (const uint32_t[]){MAC16_MUL, MAC16_HH, 0},
3550 }, {
3551 .name = "mul.dd.hl",
3552 .translate = translate_mac16,
3553 .par = (const uint32_t[]){MAC16_MUL, MAC16_HL, 0},
3554 }, {
3555 .name = "mul.dd.lh",
3556 .translate = translate_mac16,
3557 .par = (const uint32_t[]){MAC16_MUL, MAC16_LH, 0},
3558 }, {
3559 .name = "mul.dd.ll",
3560 .translate = translate_mac16,
3561 .par = (const uint32_t[]){MAC16_MUL, MAC16_LL, 0},
3562 }, {
3563 .name = "mul16s",
3564 .translate = translate_mul16,
3565 .par = (const uint32_t[]){true},
3566 }, {
3567 .name = "mul16u",
3568 .translate = translate_mul16,
3569 .par = (const uint32_t[]){false},
3570 }, {
3571 .name = "mula.aa.hh",
3572 .translate = translate_mac16,
3573 .par = (const uint32_t[]){MAC16_MULA, MAC16_HH, 0},
3574 }, {
3575 .name = "mula.aa.hl",
3576 .translate = translate_mac16,
3577 .par = (const uint32_t[]){MAC16_MULA, MAC16_HL, 0},
3578 }, {
3579 .name = "mula.aa.lh",
3580 .translate = translate_mac16,
3581 .par = (const uint32_t[]){MAC16_MULA, MAC16_LH, 0},
3582 }, {
3583 .name = "mula.aa.ll",
3584 .translate = translate_mac16,
3585 .par = (const uint32_t[]){MAC16_MULA, MAC16_LL, 0},
3586 }, {
3587 .name = "mula.ad.hh",
3588 .translate = translate_mac16,
3589 .par = (const uint32_t[]){MAC16_MULA, MAC16_HH, 0},
3590 }, {
3591 .name = "mula.ad.hl",
3592 .translate = translate_mac16,
3593 .par = (const uint32_t[]){MAC16_MULA, MAC16_HL, 0},
3594 }, {
3595 .name = "mula.ad.lh",
3596 .translate = translate_mac16,
3597 .par = (const uint32_t[]){MAC16_MULA, MAC16_LH, 0},
3598 }, {
3599 .name = "mula.ad.ll",
3600 .translate = translate_mac16,
3601 .par = (const uint32_t[]){MAC16_MULA, MAC16_LL, 0},
3602 }, {
3603 .name = "mula.da.hh",
3604 .translate = translate_mac16,
3605 .par = (const uint32_t[]){MAC16_MULA, MAC16_HH, 0},
3606 }, {
3607 .name = "mula.da.hh.lddec",
3608 .translate = translate_mac16,
3609 .par = (const uint32_t[]){MAC16_MULA, MAC16_HH, -4},
3610 }, {
3611 .name = "mula.da.hh.ldinc",
3612 .translate = translate_mac16,
3613 .par = (const uint32_t[]){MAC16_MULA, MAC16_HH, 4},
3614 }, {
3615 .name = "mula.da.hl",
3616 .translate = translate_mac16,
3617 .par = (const uint32_t[]){MAC16_MULA, MAC16_HL, 0},
3618 }, {
3619 .name = "mula.da.hl.lddec",
3620 .translate = translate_mac16,
3621 .par = (const uint32_t[]){MAC16_MULA, MAC16_HL, -4},
3622 }, {
3623 .name = "mula.da.hl.ldinc",
3624 .translate = translate_mac16,
3625 .par = (const uint32_t[]){MAC16_MULA, MAC16_HL, 4},
3626 }, {
3627 .name = "mula.da.lh",
3628 .translate = translate_mac16,
3629 .par = (const uint32_t[]){MAC16_MULA, MAC16_LH, 0},
3630 }, {
3631 .name = "mula.da.lh.lddec",
3632 .translate = translate_mac16,
3633 .par = (const uint32_t[]){MAC16_MULA, MAC16_LH, -4},
3634 }, {
3635 .name = "mula.da.lh.ldinc",
3636 .translate = translate_mac16,
3637 .par = (const uint32_t[]){MAC16_MULA, MAC16_LH, 4},
3638 }, {
3639 .name = "mula.da.ll",
3640 .translate = translate_mac16,
3641 .par = (const uint32_t[]){MAC16_MULA, MAC16_LL, 0},
3642 }, {
3643 .name = "mula.da.ll.lddec",
3644 .translate = translate_mac16,
3645 .par = (const uint32_t[]){MAC16_MULA, MAC16_LL, -4},
3646 }, {
3647 .name = "mula.da.ll.ldinc",
3648 .translate = translate_mac16,
3649 .par = (const uint32_t[]){MAC16_MULA, MAC16_LL, 4},
3650 }, {
3651 .name = "mula.dd.hh",
3652 .translate = translate_mac16,
3653 .par = (const uint32_t[]){MAC16_MULA, MAC16_HH, 0},
3654 }, {
3655 .name = "mula.dd.hh.lddec",
3656 .translate = translate_mac16,
3657 .par = (const uint32_t[]){MAC16_MULA, MAC16_HH, -4},
3658 }, {
3659 .name = "mula.dd.hh.ldinc",
3660 .translate = translate_mac16,
3661 .par = (const uint32_t[]){MAC16_MULA, MAC16_HH, 4},
3662 }, {
3663 .name = "mula.dd.hl",
3664 .translate = translate_mac16,
3665 .par = (const uint32_t[]){MAC16_MULA, MAC16_HL, 0},
3666 }, {
3667 .name = "mula.dd.hl.lddec",
3668 .translate = translate_mac16,
3669 .par = (const uint32_t[]){MAC16_MULA, MAC16_HL, -4},
3670 }, {
3671 .name = "mula.dd.hl.ldinc",
3672 .translate = translate_mac16,
3673 .par = (const uint32_t[]){MAC16_MULA, MAC16_HL, 4},
3674 }, {
3675 .name = "mula.dd.lh",
3676 .translate = translate_mac16,
3677 .par = (const uint32_t[]){MAC16_MULA, MAC16_LH, 0},
3678 }, {
3679 .name = "mula.dd.lh.lddec",
3680 .translate = translate_mac16,
3681 .par = (const uint32_t[]){MAC16_MULA, MAC16_LH, -4},
3682 }, {
3683 .name = "mula.dd.lh.ldinc",
3684 .translate = translate_mac16,
3685 .par = (const uint32_t[]){MAC16_MULA, MAC16_LH, 4},
3686 }, {
3687 .name = "mula.dd.ll",
3688 .translate = translate_mac16,
3689 .par = (const uint32_t[]){MAC16_MULA, MAC16_LL, 0},
3690 }, {
3691 .name = "mula.dd.ll.lddec",
3692 .translate = translate_mac16,
3693 .par = (const uint32_t[]){MAC16_MULA, MAC16_LL, -4},
3694 }, {
3695 .name = "mula.dd.ll.ldinc",
3696 .translate = translate_mac16,
3697 .par = (const uint32_t[]){MAC16_MULA, MAC16_LL, 4},
3698 }, {
3699 .name = "mull",
3700 .translate = translate_mull,
3701 }, {
3702 .name = "muls.aa.hh",
3703 .translate = translate_mac16,
3704 .par = (const uint32_t[]){MAC16_MULS, MAC16_HH, 0},
3705 }, {
3706 .name = "muls.aa.hl",
3707 .translate = translate_mac16,
3708 .par = (const uint32_t[]){MAC16_MULS, MAC16_HL, 0},
3709 }, {
3710 .name = "muls.aa.lh",
3711 .translate = translate_mac16,
3712 .par = (const uint32_t[]){MAC16_MULS, MAC16_LH, 0},
3713 }, {
3714 .name = "muls.aa.ll",
3715 .translate = translate_mac16,
3716 .par = (const uint32_t[]){MAC16_MULS, MAC16_LL, 0},
3717 }, {
3718 .name = "muls.ad.hh",
3719 .translate = translate_mac16,
3720 .par = (const uint32_t[]){MAC16_MULS, MAC16_HH, 0},
3721 }, {
3722 .name = "muls.ad.hl",
3723 .translate = translate_mac16,
3724 .par = (const uint32_t[]){MAC16_MULS, MAC16_HL, 0},
3725 }, {
3726 .name = "muls.ad.lh",
3727 .translate = translate_mac16,
3728 .par = (const uint32_t[]){MAC16_MULS, MAC16_LH, 0},
3729 }, {
3730 .name = "muls.ad.ll",
3731 .translate = translate_mac16,
3732 .par = (const uint32_t[]){MAC16_MULS, MAC16_LL, 0},
3733 }, {
3734 .name = "muls.da.hh",
3735 .translate = translate_mac16,
3736 .par = (const uint32_t[]){MAC16_MULS, MAC16_HH, 0},
3737 }, {
3738 .name = "muls.da.hl",
3739 .translate = translate_mac16,
3740 .par = (const uint32_t[]){MAC16_MULS, MAC16_HL, 0},
3741 }, {
3742 .name = "muls.da.lh",
3743 .translate = translate_mac16,
3744 .par = (const uint32_t[]){MAC16_MULS, MAC16_LH, 0},
3745 }, {
3746 .name = "muls.da.ll",
3747 .translate = translate_mac16,
3748 .par = (const uint32_t[]){MAC16_MULS, MAC16_LL, 0},
3749 }, {
3750 .name = "muls.dd.hh",
3751 .translate = translate_mac16,
3752 .par = (const uint32_t[]){MAC16_MULS, MAC16_HH, 0},
3753 }, {
3754 .name = "muls.dd.hl",
3755 .translate = translate_mac16,
3756 .par = (const uint32_t[]){MAC16_MULS, MAC16_HL, 0},
3757 }, {
3758 .name = "muls.dd.lh",
3759 .translate = translate_mac16,
3760 .par = (const uint32_t[]){MAC16_MULS, MAC16_LH, 0},
3761 }, {
3762 .name = "muls.dd.ll",
3763 .translate = translate_mac16,
3764 .par = (const uint32_t[]){MAC16_MULS, MAC16_LL, 0},
3765 }, {
3766 .name = "mulsh",
3767 .translate = translate_mulh,
3768 .par = (const uint32_t[]){true},
3769 }, {
3770 .name = "muluh",
3771 .translate = translate_mulh,
3772 .par = (const uint32_t[]){false},
3773 }, {
3774 .name = "neg",
3775 .translate = translate_neg,
3776 }, {
3777 .name = (const char * const[]) {
3778 "nop", "nop.n", NULL,
3780 .translate = translate_nop,
3781 .op_flags = XTENSA_OP_NAME_ARRAY,
3782 }, {
3783 .name = "nsa",
3784 .translate = translate_nsa,
3785 }, {
3786 .name = "nsau",
3787 .translate = translate_nsau,
3788 }, {
3789 .name = "or",
3790 .translate = translate_or,
3791 }, {
3792 .name = "orb",
3793 .translate = translate_boolean,
3794 .par = (const uint32_t[]){BOOLEAN_OR},
3795 }, {
3796 .name = "orbc",
3797 .translate = translate_boolean,
3798 .par = (const uint32_t[]){BOOLEAN_ORC},
3799 }, {
3800 .name = "pdtlb",
3801 .translate = translate_ptlb,
3802 .par = (const uint32_t[]){true},
3803 .op_flags = XTENSA_OP_PRIVILEGED,
3804 }, {
3805 .name = "pfend.a",
3806 .translate = translate_nop,
3807 }, {
3808 .name = "pfend.o",
3809 .translate = translate_nop,
3810 }, {
3811 .name = "pfnxt.f",
3812 .translate = translate_nop,
3813 }, {
3814 .name = "pfwait.a",
3815 .translate = translate_nop,
3816 }, {
3817 .name = "pfwait.r",
3818 .translate = translate_nop,
3819 }, {
3820 .name = "pitlb",
3821 .translate = translate_ptlb,
3822 .par = (const uint32_t[]){false},
3823 .op_flags = XTENSA_OP_PRIVILEGED,
3824 }, {
3825 .name = "pptlb",
3826 .translate = translate_pptlb,
3827 .op_flags = XTENSA_OP_PRIVILEGED,
3828 }, {
3829 .name = "quos",
3830 .translate = translate_quos,
3831 .par = (const uint32_t[]){true},
3832 .op_flags = XTENSA_OP_DIVIDE_BY_ZERO,
3833 }, {
3834 .name = "quou",
3835 .translate = translate_quou,
3836 .op_flags = XTENSA_OP_DIVIDE_BY_ZERO,
3837 }, {
3838 .name = "rdtlb0",
3839 .translate = translate_rtlb,
3840 .par = (const uint32_t[]){true, 0},
3841 .op_flags = XTENSA_OP_PRIVILEGED,
3842 }, {
3843 .name = "rdtlb1",
3844 .translate = translate_rtlb,
3845 .par = (const uint32_t[]){true, 1},
3846 .op_flags = XTENSA_OP_PRIVILEGED,
3847 }, {
3848 .name = "read_impwire",
3849 .translate = translate_read_impwire,
3850 }, {
3851 .name = "rems",
3852 .translate = translate_quos,
3853 .par = (const uint32_t[]){false},
3854 .op_flags = XTENSA_OP_DIVIDE_BY_ZERO,
3855 }, {
3856 .name = "remu",
3857 .translate = translate_remu,
3858 .op_flags = XTENSA_OP_DIVIDE_BY_ZERO,
3859 }, {
3860 .name = "rer",
3861 .translate = translate_rer,
3862 .op_flags = XTENSA_OP_PRIVILEGED,
3863 }, {
3864 .name = (const char * const[]) {
3865 "ret", "ret.n", NULL,
3867 .translate = translate_ret,
3868 .op_flags = XTENSA_OP_NAME_ARRAY,
3869 }, {
3870 .name = (const char * const[]) {
3871 "retw", "retw.n", NULL,
3873 .translate = translate_retw,
3874 .test_exceptions = test_exceptions_retw,
3875 .op_flags = XTENSA_OP_UNDERFLOW | XTENSA_OP_NAME_ARRAY,
3876 }, {
3877 .name = "rfdd",
3878 .op_flags = XTENSA_OP_ILL,
3879 }, {
3880 .name = "rfde",
3881 .translate = translate_rfde,
3882 .op_flags = XTENSA_OP_PRIVILEGED,
3883 }, {
3884 .name = "rfdo",
3885 .op_flags = XTENSA_OP_ILL,
3886 }, {
3887 .name = "rfe",
3888 .translate = translate_rfe,
3889 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_CHECK_INTERRUPTS,
3890 }, {
3891 .name = "rfi",
3892 .translate = translate_rfi,
3893 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_CHECK_INTERRUPTS,
3894 }, {
3895 .name = "rfwo",
3896 .translate = translate_rfw,
3897 .par = (const uint32_t[]){true},
3898 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_CHECK_INTERRUPTS,
3899 }, {
3900 .name = "rfwu",
3901 .translate = translate_rfw,
3902 .par = (const uint32_t[]){false},
3903 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_CHECK_INTERRUPTS,
3904 }, {
3905 .name = "ritlb0",
3906 .translate = translate_rtlb,
3907 .par = (const uint32_t[]){false, 0},
3908 .op_flags = XTENSA_OP_PRIVILEGED,
3909 }, {
3910 .name = "ritlb1",
3911 .translate = translate_rtlb,
3912 .par = (const uint32_t[]){false, 1},
3913 .op_flags = XTENSA_OP_PRIVILEGED,
3914 }, {
3915 .name = "rptlb0",
3916 .translate = translate_rptlb0,
3917 .op_flags = XTENSA_OP_PRIVILEGED,
3918 }, {
3919 .name = "rptlb1",
3920 .translate = translate_rptlb1,
3921 .op_flags = XTENSA_OP_PRIVILEGED,
3922 }, {
3923 .name = "rotw",
3924 .translate = translate_rotw,
3925 .op_flags = XTENSA_OP_PRIVILEGED |
3926 XTENSA_OP_EXIT_TB_M1 |
3927 XTENSA_OP_SYNC_REGISTER_WINDOW,
3928 }, {
3929 .name = "rsil",
3930 .translate = translate_rsil,
3931 .op_flags =
3932 XTENSA_OP_PRIVILEGED |
3933 XTENSA_OP_EXIT_TB_0 |
3934 XTENSA_OP_CHECK_INTERRUPTS,
3935 }, {
3936 .name = "rsr.176",
3937 .translate = translate_rsr,
3938 .par = (const uint32_t[]){176},
3939 .op_flags = XTENSA_OP_PRIVILEGED,
3940 }, {
3941 .name = "rsr.208",
3942 .translate = translate_rsr,
3943 .par = (const uint32_t[]){208},
3944 .op_flags = XTENSA_OP_PRIVILEGED,
3945 }, {
3946 .name = "rsr.acchi",
3947 .translate = translate_rsr,
3948 .test_exceptions = test_exceptions_sr,
3949 .par = (const uint32_t[]){
3950 ACCHI,
3951 XTENSA_OPTION_MAC16,
3953 }, {
3954 .name = "rsr.acclo",
3955 .translate = translate_rsr,
3956 .test_exceptions = test_exceptions_sr,
3957 .par = (const uint32_t[]){
3958 ACCLO,
3959 XTENSA_OPTION_MAC16,
3961 }, {
3962 .name = "rsr.atomctl",
3963 .translate = translate_rsr,
3964 .test_exceptions = test_exceptions_sr,
3965 .par = (const uint32_t[]){
3966 ATOMCTL,
3967 XTENSA_OPTION_ATOMCTL,
3969 .op_flags = XTENSA_OP_PRIVILEGED,
3970 }, {
3971 .name = "rsr.br",
3972 .translate = translate_rsr,
3973 .test_exceptions = test_exceptions_sr,
3974 .par = (const uint32_t[]){
3976 XTENSA_OPTION_BOOLEAN,
3978 }, {
3979 .name = "rsr.cacheadrdis",
3980 .translate = translate_rsr,
3981 .test_exceptions = test_exceptions_sr,
3982 .par = (const uint32_t[]){
3983 CACHEADRDIS,
3984 XTENSA_OPTION_MPU,
3986 .op_flags = XTENSA_OP_PRIVILEGED,
3987 }, {
3988 .name = "rsr.cacheattr",
3989 .translate = translate_rsr,
3990 .test_exceptions = test_exceptions_sr,
3991 .par = (const uint32_t[]){
3992 CACHEATTR,
3993 XTENSA_OPTION_CACHEATTR,
3995 .op_flags = XTENSA_OP_PRIVILEGED,
3996 }, {
3997 .name = "rsr.ccompare0",
3998 .translate = translate_rsr,
3999 .test_exceptions = test_exceptions_ccompare,
4000 .par = (const uint32_t[]){
4001 CCOMPARE,
4002 XTENSA_OPTION_TIMER_INTERRUPT,
4004 .op_flags = XTENSA_OP_PRIVILEGED,
4005 }, {
4006 .name = "rsr.ccompare1",
4007 .translate = translate_rsr,
4008 .test_exceptions = test_exceptions_ccompare,
4009 .par = (const uint32_t[]){
4010 CCOMPARE + 1,
4011 XTENSA_OPTION_TIMER_INTERRUPT,
4013 .op_flags = XTENSA_OP_PRIVILEGED,
4014 }, {
4015 .name = "rsr.ccompare2",
4016 .translate = translate_rsr,
4017 .test_exceptions = test_exceptions_ccompare,
4018 .par = (const uint32_t[]){
4019 CCOMPARE + 2,
4020 XTENSA_OPTION_TIMER_INTERRUPT,
4022 .op_flags = XTENSA_OP_PRIVILEGED,
4023 }, {
4024 .name = "rsr.ccount",
4025 .translate = translate_rsr_ccount,
4026 .test_exceptions = test_exceptions_sr,
4027 .par = (const uint32_t[]){
4028 CCOUNT,
4029 XTENSA_OPTION_TIMER_INTERRUPT,
4031 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
4032 }, {
4033 .name = "rsr.configid0",
4034 .translate = translate_rsr,
4035 .par = (const uint32_t[]){CONFIGID0},
4036 .op_flags = XTENSA_OP_PRIVILEGED,
4037 }, {
4038 .name = "rsr.configid1",
4039 .translate = translate_rsr,
4040 .par = (const uint32_t[]){CONFIGID1},
4041 .op_flags = XTENSA_OP_PRIVILEGED,
4042 }, {
4043 .name = "rsr.cpenable",
4044 .translate = translate_rsr,
4045 .test_exceptions = test_exceptions_sr,
4046 .par = (const uint32_t[]){
4047 CPENABLE,
4048 XTENSA_OPTION_COPROCESSOR,
4050 .op_flags = XTENSA_OP_PRIVILEGED,
4051 }, {
4052 .name = "rsr.dbreaka0",
4053 .translate = translate_rsr,
4054 .test_exceptions = test_exceptions_dbreak,
4055 .par = (const uint32_t[]){
4056 DBREAKA,
4057 XTENSA_OPTION_DEBUG,
4059 .op_flags = XTENSA_OP_PRIVILEGED,
4060 }, {
4061 .name = "rsr.dbreaka1",
4062 .translate = translate_rsr,
4063 .test_exceptions = test_exceptions_dbreak,
4064 .par = (const uint32_t[]){
4065 DBREAKA + 1,
4066 XTENSA_OPTION_DEBUG,
4068 .op_flags = XTENSA_OP_PRIVILEGED,
4069 }, {
4070 .name = "rsr.dbreakc0",
4071 .translate = translate_rsr,
4072 .test_exceptions = test_exceptions_dbreak,
4073 .par = (const uint32_t[]){
4074 DBREAKC,
4075 XTENSA_OPTION_DEBUG,
4077 .op_flags = XTENSA_OP_PRIVILEGED,
4078 }, {
4079 .name = "rsr.dbreakc1",
4080 .translate = translate_rsr,
4081 .test_exceptions = test_exceptions_dbreak,
4082 .par = (const uint32_t[]){
4083 DBREAKC + 1,
4084 XTENSA_OPTION_DEBUG,
4086 .op_flags = XTENSA_OP_PRIVILEGED,
4087 }, {
4088 .name = "rsr.ddr",
4089 .translate = translate_rsr,
4090 .test_exceptions = test_exceptions_sr,
4091 .par = (const uint32_t[]){
4092 DDR,
4093 XTENSA_OPTION_DEBUG,
4095 .op_flags = XTENSA_OP_PRIVILEGED,
4096 }, {
4097 .name = "rsr.debugcause",
4098 .translate = translate_rsr,
4099 .test_exceptions = test_exceptions_sr,
4100 .par = (const uint32_t[]){
4101 DEBUGCAUSE,
4102 XTENSA_OPTION_DEBUG,
4104 .op_flags = XTENSA_OP_PRIVILEGED,
4105 }, {
4106 .name = "rsr.depc",
4107 .translate = translate_rsr,
4108 .test_exceptions = test_exceptions_sr,
4109 .par = (const uint32_t[]){
4110 DEPC,
4111 XTENSA_OPTION_EXCEPTION,
4113 .op_flags = XTENSA_OP_PRIVILEGED,
4114 }, {
4115 .name = "rsr.dtlbcfg",
4116 .translate = translate_rsr,
4117 .test_exceptions = test_exceptions_sr,
4118 .par = (const uint32_t[]){
4119 DTLBCFG,
4120 XTENSA_OPTION_MMU,
4122 .op_flags = XTENSA_OP_PRIVILEGED,
4123 }, {
4124 .name = "rsr.epc1",
4125 .translate = translate_rsr,
4126 .test_exceptions = test_exceptions_sr,
4127 .par = (const uint32_t[]){
4128 EPC1,
4129 XTENSA_OPTION_EXCEPTION,
4131 .op_flags = XTENSA_OP_PRIVILEGED,
4132 }, {
4133 .name = "rsr.epc2",
4134 .translate = translate_rsr,
4135 .test_exceptions = test_exceptions_hpi,
4136 .par = (const uint32_t[]){
4137 EPC1 + 1,
4138 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4140 .op_flags = XTENSA_OP_PRIVILEGED,
4141 }, {
4142 .name = "rsr.epc3",
4143 .translate = translate_rsr,
4144 .test_exceptions = test_exceptions_hpi,
4145 .par = (const uint32_t[]){
4146 EPC1 + 2,
4147 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4149 .op_flags = XTENSA_OP_PRIVILEGED,
4150 }, {
4151 .name = "rsr.epc4",
4152 .translate = translate_rsr,
4153 .test_exceptions = test_exceptions_hpi,
4154 .par = (const uint32_t[]){
4155 EPC1 + 3,
4156 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4158 .op_flags = XTENSA_OP_PRIVILEGED,
4159 }, {
4160 .name = "rsr.epc5",
4161 .translate = translate_rsr,
4162 .test_exceptions = test_exceptions_hpi,
4163 .par = (const uint32_t[]){
4164 EPC1 + 4,
4165 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4167 .op_flags = XTENSA_OP_PRIVILEGED,
4168 }, {
4169 .name = "rsr.epc6",
4170 .translate = translate_rsr,
4171 .test_exceptions = test_exceptions_hpi,
4172 .par = (const uint32_t[]){
4173 EPC1 + 5,
4174 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4176 .op_flags = XTENSA_OP_PRIVILEGED,
4177 }, {
4178 .name = "rsr.epc7",
4179 .translate = translate_rsr,
4180 .test_exceptions = test_exceptions_hpi,
4181 .par = (const uint32_t[]){
4182 EPC1 + 6,
4183 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4185 .op_flags = XTENSA_OP_PRIVILEGED,
4186 }, {
4187 .name = "rsr.eps2",
4188 .translate = translate_rsr,
4189 .test_exceptions = test_exceptions_hpi,
4190 .par = (const uint32_t[]){
4191 EPS2,
4192 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4194 .op_flags = XTENSA_OP_PRIVILEGED,
4195 }, {
4196 .name = "rsr.eps3",
4197 .translate = translate_rsr,
4198 .test_exceptions = test_exceptions_hpi,
4199 .par = (const uint32_t[]){
4200 EPS2 + 1,
4201 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4203 .op_flags = XTENSA_OP_PRIVILEGED,
4204 }, {
4205 .name = "rsr.eps4",
4206 .translate = translate_rsr,
4207 .test_exceptions = test_exceptions_hpi,
4208 .par = (const uint32_t[]){
4209 EPS2 + 2,
4210 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4212 .op_flags = XTENSA_OP_PRIVILEGED,
4213 }, {
4214 .name = "rsr.eps5",
4215 .translate = translate_rsr,
4216 .test_exceptions = test_exceptions_hpi,
4217 .par = (const uint32_t[]){
4218 EPS2 + 3,
4219 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4221 .op_flags = XTENSA_OP_PRIVILEGED,
4222 }, {
4223 .name = "rsr.eps6",
4224 .translate = translate_rsr,
4225 .test_exceptions = test_exceptions_hpi,
4226 .par = (const uint32_t[]){
4227 EPS2 + 4,
4228 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4230 .op_flags = XTENSA_OP_PRIVILEGED,
4231 }, {
4232 .name = "rsr.eps7",
4233 .translate = translate_rsr,
4234 .test_exceptions = test_exceptions_hpi,
4235 .par = (const uint32_t[]){
4236 EPS2 + 5,
4237 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4239 .op_flags = XTENSA_OP_PRIVILEGED,
4240 }, {
4241 .name = "rsr.eraccess",
4242 .translate = translate_rsr,
4243 .par = (const uint32_t[]){ERACCESS},
4244 .op_flags = XTENSA_OP_PRIVILEGED,
4245 }, {
4246 .name = "rsr.exccause",
4247 .translate = translate_rsr,
4248 .test_exceptions = test_exceptions_sr,
4249 .par = (const uint32_t[]){
4250 EXCCAUSE,
4251 XTENSA_OPTION_EXCEPTION,
4253 .op_flags = XTENSA_OP_PRIVILEGED,
4254 }, {
4255 .name = "rsr.excsave1",
4256 .translate = translate_rsr,
4257 .test_exceptions = test_exceptions_sr,
4258 .par = (const uint32_t[]){
4259 EXCSAVE1,
4260 XTENSA_OPTION_EXCEPTION,
4262 .op_flags = XTENSA_OP_PRIVILEGED,
4263 }, {
4264 .name = "rsr.excsave2",
4265 .translate = translate_rsr,
4266 .test_exceptions = test_exceptions_hpi,
4267 .par = (const uint32_t[]){
4268 EXCSAVE1 + 1,
4269 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4271 .op_flags = XTENSA_OP_PRIVILEGED,
4272 }, {
4273 .name = "rsr.excsave3",
4274 .translate = translate_rsr,
4275 .test_exceptions = test_exceptions_hpi,
4276 .par = (const uint32_t[]){
4277 EXCSAVE1 + 2,
4278 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4280 .op_flags = XTENSA_OP_PRIVILEGED,
4281 }, {
4282 .name = "rsr.excsave4",
4283 .translate = translate_rsr,
4284 .test_exceptions = test_exceptions_hpi,
4285 .par = (const uint32_t[]){
4286 EXCSAVE1 + 3,
4287 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4289 .op_flags = XTENSA_OP_PRIVILEGED,
4290 }, {
4291 .name = "rsr.excsave5",
4292 .translate = translate_rsr,
4293 .test_exceptions = test_exceptions_hpi,
4294 .par = (const uint32_t[]){
4295 EXCSAVE1 + 4,
4296 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4298 .op_flags = XTENSA_OP_PRIVILEGED,
4299 }, {
4300 .name = "rsr.excsave6",
4301 .translate = translate_rsr,
4302 .test_exceptions = test_exceptions_hpi,
4303 .par = (const uint32_t[]){
4304 EXCSAVE1 + 5,
4305 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4307 .op_flags = XTENSA_OP_PRIVILEGED,
4308 }, {
4309 .name = "rsr.excsave7",
4310 .translate = translate_rsr,
4311 .test_exceptions = test_exceptions_hpi,
4312 .par = (const uint32_t[]){
4313 EXCSAVE1 + 6,
4314 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4316 .op_flags = XTENSA_OP_PRIVILEGED,
4317 }, {
4318 .name = "rsr.excvaddr",
4319 .translate = translate_rsr,
4320 .test_exceptions = test_exceptions_sr,
4321 .par = (const uint32_t[]){
4322 EXCVADDR,
4323 XTENSA_OPTION_EXCEPTION,
4325 .op_flags = XTENSA_OP_PRIVILEGED,
4326 }, {
4327 .name = "rsr.ibreaka0",
4328 .translate = translate_rsr,
4329 .test_exceptions = test_exceptions_ibreak,
4330 .par = (const uint32_t[]){
4331 IBREAKA,
4332 XTENSA_OPTION_DEBUG,
4334 .op_flags = XTENSA_OP_PRIVILEGED,
4335 }, {
4336 .name = "rsr.ibreaka1",
4337 .translate = translate_rsr,
4338 .test_exceptions = test_exceptions_ibreak,
4339 .par = (const uint32_t[]){
4340 IBREAKA + 1,
4341 XTENSA_OPTION_DEBUG,
4343 .op_flags = XTENSA_OP_PRIVILEGED,
4344 }, {
4345 .name = "rsr.ibreakenable",
4346 .translate = translate_rsr,
4347 .test_exceptions = test_exceptions_sr,
4348 .par = (const uint32_t[]){
4349 IBREAKENABLE,
4350 XTENSA_OPTION_DEBUG,
4352 .op_flags = XTENSA_OP_PRIVILEGED,
4353 }, {
4354 .name = "rsr.icount",
4355 .translate = translate_rsr,
4356 .test_exceptions = test_exceptions_sr,
4357 .par = (const uint32_t[]){
4358 ICOUNT,
4359 XTENSA_OPTION_DEBUG,
4361 .op_flags = XTENSA_OP_PRIVILEGED,
4362 }, {
4363 .name = "rsr.icountlevel",
4364 .translate = translate_rsr,
4365 .test_exceptions = test_exceptions_sr,
4366 .par = (const uint32_t[]){
4367 ICOUNTLEVEL,
4368 XTENSA_OPTION_DEBUG,
4370 .op_flags = XTENSA_OP_PRIVILEGED,
4371 }, {
4372 .name = "rsr.intclear",
4373 .translate = translate_rsr,
4374 .test_exceptions = test_exceptions_sr,
4375 .par = (const uint32_t[]){
4376 INTCLEAR,
4377 XTENSA_OPTION_INTERRUPT,
4379 .op_flags = XTENSA_OP_PRIVILEGED,
4380 }, {
4381 .name = "rsr.intenable",
4382 .translate = translate_rsr,
4383 .test_exceptions = test_exceptions_sr,
4384 .par = (const uint32_t[]){
4385 INTENABLE,
4386 XTENSA_OPTION_INTERRUPT,
4388 .op_flags = XTENSA_OP_PRIVILEGED,
4389 }, {
4390 .name = "rsr.interrupt",
4391 .translate = translate_rsr_ccount,
4392 .test_exceptions = test_exceptions_sr,
4393 .par = (const uint32_t[]){
4394 INTSET,
4395 XTENSA_OPTION_INTERRUPT,
4397 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
4398 }, {
4399 .name = "rsr.intset",
4400 .translate = translate_rsr_ccount,
4401 .test_exceptions = test_exceptions_sr,
4402 .par = (const uint32_t[]){
4403 INTSET,
4404 XTENSA_OPTION_INTERRUPT,
4406 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
4407 }, {
4408 .name = "rsr.itlbcfg",
4409 .translate = translate_rsr,
4410 .test_exceptions = test_exceptions_sr,
4411 .par = (const uint32_t[]){
4412 ITLBCFG,
4413 XTENSA_OPTION_MMU,
4415 .op_flags = XTENSA_OP_PRIVILEGED,
4416 }, {
4417 .name = "rsr.lbeg",
4418 .translate = translate_rsr,
4419 .test_exceptions = test_exceptions_sr,
4420 .par = (const uint32_t[]){
4421 LBEG,
4422 XTENSA_OPTION_LOOP,
4424 }, {
4425 .name = "rsr.lcount",
4426 .translate = translate_rsr,
4427 .test_exceptions = test_exceptions_sr,
4428 .par = (const uint32_t[]){
4429 LCOUNT,
4430 XTENSA_OPTION_LOOP,
4432 }, {
4433 .name = "rsr.lend",
4434 .translate = translate_rsr,
4435 .test_exceptions = test_exceptions_sr,
4436 .par = (const uint32_t[]){
4437 LEND,
4438 XTENSA_OPTION_LOOP,
4440 }, {
4441 .name = "rsr.litbase",
4442 .translate = translate_rsr,
4443 .test_exceptions = test_exceptions_sr,
4444 .par = (const uint32_t[]){
4445 LITBASE,
4446 XTENSA_OPTION_EXTENDED_L32R,
4448 }, {
4449 .name = "rsr.m0",
4450 .translate = translate_rsr,
4451 .test_exceptions = test_exceptions_sr,
4452 .par = (const uint32_t[]){
4454 XTENSA_OPTION_MAC16,
4456 }, {
4457 .name = "rsr.m1",
4458 .translate = translate_rsr,
4459 .test_exceptions = test_exceptions_sr,
4460 .par = (const uint32_t[]){
4461 MR + 1,
4462 XTENSA_OPTION_MAC16,
4464 }, {
4465 .name = "rsr.m2",
4466 .translate = translate_rsr,
4467 .test_exceptions = test_exceptions_sr,
4468 .par = (const uint32_t[]){
4469 MR + 2,
4470 XTENSA_OPTION_MAC16,
4472 }, {
4473 .name = "rsr.m3",
4474 .translate = translate_rsr,
4475 .test_exceptions = test_exceptions_sr,
4476 .par = (const uint32_t[]){
4477 MR + 3,
4478 XTENSA_OPTION_MAC16,
4480 }, {
4481 .name = "rsr.memctl",
4482 .translate = translate_rsr,
4483 .par = (const uint32_t[]){MEMCTL},
4484 .op_flags = XTENSA_OP_PRIVILEGED,
4485 }, {
4486 .name = "rsr.mecr",
4487 .translate = translate_rsr,
4488 .test_exceptions = test_exceptions_sr,
4489 .par = (const uint32_t[]){
4490 MECR,
4491 XTENSA_OPTION_MEMORY_ECC_PARITY,
4493 .op_flags = XTENSA_OP_PRIVILEGED,
4494 }, {
4495 .name = "rsr.mepc",
4496 .translate = translate_rsr,
4497 .test_exceptions = test_exceptions_sr,
4498 .par = (const uint32_t[]){
4499 MEPC,
4500 XTENSA_OPTION_MEMORY_ECC_PARITY,
4502 .op_flags = XTENSA_OP_PRIVILEGED,
4503 }, {
4504 .name = "rsr.meps",
4505 .translate = translate_rsr,
4506 .test_exceptions = test_exceptions_sr,
4507 .par = (const uint32_t[]){
4508 MEPS,
4509 XTENSA_OPTION_MEMORY_ECC_PARITY,
4511 .op_flags = XTENSA_OP_PRIVILEGED,
4512 }, {
4513 .name = "rsr.mesave",
4514 .translate = translate_rsr,
4515 .test_exceptions = test_exceptions_sr,
4516 .par = (const uint32_t[]){
4517 MESAVE,
4518 XTENSA_OPTION_MEMORY_ECC_PARITY,
4520 .op_flags = XTENSA_OP_PRIVILEGED,
4521 }, {
4522 .name = "rsr.mesr",
4523 .translate = translate_rsr,
4524 .test_exceptions = test_exceptions_sr,
4525 .par = (const uint32_t[]){
4526 MESR,
4527 XTENSA_OPTION_MEMORY_ECC_PARITY,
4529 .op_flags = XTENSA_OP_PRIVILEGED,
4530 }, {
4531 .name = "rsr.mevaddr",
4532 .translate = translate_rsr,
4533 .test_exceptions = test_exceptions_sr,
4534 .par = (const uint32_t[]){
4535 MESR,
4536 XTENSA_OPTION_MEMORY_ECC_PARITY,
4538 .op_flags = XTENSA_OP_PRIVILEGED,
4539 }, {
4540 .name = "rsr.misc0",
4541 .translate = translate_rsr,
4542 .test_exceptions = test_exceptions_sr,
4543 .par = (const uint32_t[]){
4544 MISC,
4545 XTENSA_OPTION_MISC_SR,
4547 .op_flags = XTENSA_OP_PRIVILEGED,
4548 }, {
4549 .name = "rsr.misc1",
4550 .translate = translate_rsr,
4551 .test_exceptions = test_exceptions_sr,
4552 .par = (const uint32_t[]){
4553 MISC + 1,
4554 XTENSA_OPTION_MISC_SR,
4556 .op_flags = XTENSA_OP_PRIVILEGED,
4557 }, {
4558 .name = "rsr.misc2",
4559 .translate = translate_rsr,
4560 .test_exceptions = test_exceptions_sr,
4561 .par = (const uint32_t[]){
4562 MISC + 2,
4563 XTENSA_OPTION_MISC_SR,
4565 .op_flags = XTENSA_OP_PRIVILEGED,
4566 }, {
4567 .name = "rsr.misc3",
4568 .translate = translate_rsr,
4569 .test_exceptions = test_exceptions_sr,
4570 .par = (const uint32_t[]){
4571 MISC + 3,
4572 XTENSA_OPTION_MISC_SR,
4574 .op_flags = XTENSA_OP_PRIVILEGED,
4575 }, {
4576 .name = "rsr.mpucfg",
4577 .translate = translate_rsr,
4578 .test_exceptions = test_exceptions_sr,
4579 .par = (const uint32_t[]){
4580 MPUCFG,
4581 XTENSA_OPTION_MPU,
4583 .op_flags = XTENSA_OP_PRIVILEGED,
4584 }, {
4585 .name = "rsr.mpuenb",
4586 .translate = translate_rsr,
4587 .test_exceptions = test_exceptions_sr,
4588 .par = (const uint32_t[]){
4589 MPUENB,
4590 XTENSA_OPTION_MPU,
4592 .op_flags = XTENSA_OP_PRIVILEGED,
4593 }, {
4594 .name = "rsr.prefctl",
4595 .translate = translate_rsr,
4596 .par = (const uint32_t[]){PREFCTL},
4597 }, {
4598 .name = "rsr.prid",
4599 .translate = translate_rsr,
4600 .test_exceptions = test_exceptions_sr,
4601 .par = (const uint32_t[]){
4602 PRID,
4603 XTENSA_OPTION_PROCESSOR_ID,
4605 .op_flags = XTENSA_OP_PRIVILEGED,
4606 }, {
4607 .name = "rsr.ps",
4608 .translate = translate_rsr,
4609 .test_exceptions = test_exceptions_sr,
4610 .par = (const uint32_t[]){
4612 XTENSA_OPTION_EXCEPTION,
4614 .op_flags = XTENSA_OP_PRIVILEGED,
4615 }, {
4616 .name = "rsr.ptevaddr",
4617 .translate = translate_rsr_ptevaddr,
4618 .test_exceptions = test_exceptions_sr,
4619 .par = (const uint32_t[]){
4620 PTEVADDR,
4621 XTENSA_OPTION_MMU,
4623 .op_flags = XTENSA_OP_PRIVILEGED,
4624 }, {
4625 .name = "rsr.rasid",
4626 .translate = translate_rsr,
4627 .test_exceptions = test_exceptions_sr,
4628 .par = (const uint32_t[]){
4629 RASID,
4630 XTENSA_OPTION_MMU,
4632 .op_flags = XTENSA_OP_PRIVILEGED,
4633 }, {
4634 .name = "rsr.sar",
4635 .translate = translate_rsr,
4636 .par = (const uint32_t[]){SAR},
4637 }, {
4638 .name = "rsr.scompare1",
4639 .translate = translate_rsr,
4640 .test_exceptions = test_exceptions_sr,
4641 .par = (const uint32_t[]){
4642 SCOMPARE1,
4643 XTENSA_OPTION_CONDITIONAL_STORE,
4645 }, {
4646 .name = "rsr.vecbase",
4647 .translate = translate_rsr,
4648 .test_exceptions = test_exceptions_sr,
4649 .par = (const uint32_t[]){
4650 VECBASE,
4651 XTENSA_OPTION_RELOCATABLE_VECTOR,
4653 .op_flags = XTENSA_OP_PRIVILEGED,
4654 }, {
4655 .name = "rsr.windowbase",
4656 .translate = translate_rsr,
4657 .test_exceptions = test_exceptions_sr,
4658 .par = (const uint32_t[]){
4659 WINDOW_BASE,
4660 XTENSA_OPTION_WINDOWED_REGISTER,
4662 .op_flags = XTENSA_OP_PRIVILEGED,
4663 }, {
4664 .name = "rsr.windowstart",
4665 .translate = translate_rsr,
4666 .test_exceptions = test_exceptions_sr,
4667 .par = (const uint32_t[]){
4668 WINDOW_START,
4669 XTENSA_OPTION_WINDOWED_REGISTER,
4671 .op_flags = XTENSA_OP_PRIVILEGED,
4672 }, {
4673 .name = "rsync",
4674 .translate = translate_nop,
4675 }, {
4676 .name = "rur.expstate",
4677 .translate = translate_rur,
4678 .par = (const uint32_t[]){EXPSTATE},
4679 }, {
4680 .name = "rur.threadptr",
4681 .translate = translate_rur,
4682 .par = (const uint32_t[]){THREADPTR},
4683 }, {
4684 .name = "s16i",
4685 .translate = translate_ldst,
4686 .par = (const uint32_t[]){MO_TEUW, false, true},
4687 .op_flags = XTENSA_OP_STORE,
4688 }, {
4689 .name = "s32c1i",
4690 .translate = translate_s32c1i,
4691 .op_flags = XTENSA_OP_LOAD | XTENSA_OP_STORE,
4692 }, {
4693 .name = "s32e",
4694 .translate = translate_s32e,
4695 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_STORE,
4696 }, {
4697 .name = "s32ex",
4698 .translate = translate_s32ex,
4699 .op_flags = XTENSA_OP_LOAD | XTENSA_OP_STORE,
4700 }, {
4701 .name = (const char * const[]) {
4702 "s32i", "s32i.n", "s32nb", NULL,
4704 .translate = translate_ldst,
4705 .par = (const uint32_t[]){MO_TEUL, false, true},
4706 .op_flags = XTENSA_OP_NAME_ARRAY | XTENSA_OP_STORE,
4707 }, {
4708 .name = "s32ri",
4709 .translate = translate_ldst,
4710 .par = (const uint32_t[]){MO_TEUL, true, true},
4711 .op_flags = XTENSA_OP_STORE,
4712 }, {
4713 .name = "s8i",
4714 .translate = translate_ldst,
4715 .par = (const uint32_t[]){MO_UB, false, true},
4716 .op_flags = XTENSA_OP_STORE,
4717 }, {
4718 .name = "salt",
4719 .translate = translate_salt,
4720 .par = (const uint32_t[]){TCG_COND_LT},
4721 }, {
4722 .name = "saltu",
4723 .translate = translate_salt,
4724 .par = (const uint32_t[]){TCG_COND_LTU},
4725 }, {
4726 .name = "setb_expstate",
4727 .translate = translate_setb_expstate,
4728 }, {
4729 .name = "sext",
4730 .translate = translate_sext,
4731 }, {
4732 .name = "simcall",
4733 .translate = translate_simcall,
4734 .test_exceptions = test_exceptions_simcall,
4735 .op_flags = XTENSA_OP_PRIVILEGED,
4736 }, {
4737 .name = "sll",
4738 .translate = translate_sll,
4739 }, {
4740 .name = "slli",
4741 .translate = translate_slli,
4742 }, {
4743 .name = "sra",
4744 .translate = translate_sra,
4745 }, {
4746 .name = "srai",
4747 .translate = translate_srai,
4748 }, {
4749 .name = "src",
4750 .translate = translate_src,
4751 }, {
4752 .name = "srl",
4753 .translate = translate_srl,
4754 }, {
4755 .name = "srli",
4756 .translate = translate_srli,
4757 }, {
4758 .name = "ssa8b",
4759 .translate = translate_ssa8b,
4760 }, {
4761 .name = "ssa8l",
4762 .translate = translate_ssa8l,
4763 }, {
4764 .name = "ssai",
4765 .translate = translate_ssai,
4766 }, {
4767 .name = "ssl",
4768 .translate = translate_ssl,
4769 }, {
4770 .name = "ssr",
4771 .translate = translate_ssr,
4772 }, {
4773 .name = "sub",
4774 .translate = translate_sub,
4775 }, {
4776 .name = "subx2",
4777 .translate = translate_subx,
4778 .par = (const uint32_t[]){1},
4779 }, {
4780 .name = "subx4",
4781 .translate = translate_subx,
4782 .par = (const uint32_t[]){2},
4783 }, {
4784 .name = "subx8",
4785 .translate = translate_subx,
4786 .par = (const uint32_t[]){3},
4787 }, {
4788 .name = "syscall",
4789 .op_flags = XTENSA_OP_SYSCALL,
4790 }, {
4791 .name = "umul.aa.hh",
4792 .translate = translate_mac16,
4793 .par = (const uint32_t[]){MAC16_UMUL, MAC16_HH, 0},
4794 }, {
4795 .name = "umul.aa.hl",
4796 .translate = translate_mac16,
4797 .par = (const uint32_t[]){MAC16_UMUL, MAC16_HL, 0},
4798 }, {
4799 .name = "umul.aa.lh",
4800 .translate = translate_mac16,
4801 .par = (const uint32_t[]){MAC16_UMUL, MAC16_LH, 0},
4802 }, {
4803 .name = "umul.aa.ll",
4804 .translate = translate_mac16,
4805 .par = (const uint32_t[]){MAC16_UMUL, MAC16_LL, 0},
4806 }, {
4807 .name = "waiti",
4808 .translate = translate_waiti,
4809 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
4810 }, {
4811 .name = "wdtlb",
4812 .translate = translate_wtlb,
4813 .par = (const uint32_t[]){true},
4814 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_M1,
4815 }, {
4816 .name = "wer",
4817 .translate = translate_wer,
4818 .op_flags = XTENSA_OP_PRIVILEGED,
4819 }, {
4820 .name = "witlb",
4821 .translate = translate_wtlb,
4822 .par = (const uint32_t[]){false},
4823 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_M1,
4824 }, {
4825 .name = "wptlb",
4826 .translate = translate_wptlb,
4827 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_M1,
4828 }, {
4829 .name = "wrmsk_expstate",
4830 .translate = translate_wrmsk_expstate,
4831 }, {
4832 .name = "wsr.176",
4833 .op_flags = XTENSA_OP_ILL,
4834 }, {
4835 .name = "wsr.208",
4836 .op_flags = XTENSA_OP_ILL,
4837 }, {
4838 .name = "wsr.acchi",
4839 .translate = translate_wsr_acchi,
4840 .test_exceptions = test_exceptions_sr,
4841 .par = (const uint32_t[]){
4842 ACCHI,
4843 XTENSA_OPTION_MAC16,
4845 }, {
4846 .name = "wsr.acclo",
4847 .translate = translate_wsr,
4848 .test_exceptions = test_exceptions_sr,
4849 .par = (const uint32_t[]){
4850 ACCLO,
4851 XTENSA_OPTION_MAC16,
4853 }, {
4854 .name = "wsr.atomctl",
4855 .translate = translate_wsr_mask,
4856 .test_exceptions = test_exceptions_sr,
4857 .par = (const uint32_t[]){
4858 ATOMCTL,
4859 XTENSA_OPTION_ATOMCTL,
4860 0x3f,
4862 .op_flags = XTENSA_OP_PRIVILEGED,
4863 }, {
4864 .name = "wsr.br",
4865 .translate = translate_wsr_mask,
4866 .test_exceptions = test_exceptions_sr,
4867 .par = (const uint32_t[]){
4869 XTENSA_OPTION_BOOLEAN,
4870 0xffff,
4872 }, {
4873 .name = "wsr.cacheadrdis",
4874 .translate = translate_wsr_mask,
4875 .test_exceptions = test_exceptions_sr,
4876 .par = (const uint32_t[]){
4877 CACHEADRDIS,
4878 XTENSA_OPTION_MPU,
4879 0xff,
4881 .op_flags = XTENSA_OP_PRIVILEGED,
4882 }, {
4883 .name = "wsr.cacheattr",
4884 .translate = translate_wsr,
4885 .test_exceptions = test_exceptions_sr,
4886 .par = (const uint32_t[]){
4887 CACHEATTR,
4888 XTENSA_OPTION_CACHEATTR,
4890 .op_flags = XTENSA_OP_PRIVILEGED,
4891 }, {
4892 .name = "wsr.ccompare0",
4893 .translate = translate_wsr_ccompare,
4894 .test_exceptions = test_exceptions_ccompare,
4895 .par = (const uint32_t[]){
4896 CCOMPARE,
4897 XTENSA_OPTION_TIMER_INTERRUPT,
4899 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
4900 }, {
4901 .name = "wsr.ccompare1",
4902 .translate = translate_wsr_ccompare,
4903 .test_exceptions = test_exceptions_ccompare,
4904 .par = (const uint32_t[]){
4905 CCOMPARE + 1,
4906 XTENSA_OPTION_TIMER_INTERRUPT,
4908 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
4909 }, {
4910 .name = "wsr.ccompare2",
4911 .translate = translate_wsr_ccompare,
4912 .test_exceptions = test_exceptions_ccompare,
4913 .par = (const uint32_t[]){
4914 CCOMPARE + 2,
4915 XTENSA_OPTION_TIMER_INTERRUPT,
4917 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
4918 }, {
4919 .name = "wsr.ccount",
4920 .translate = translate_wsr_ccount,
4921 .test_exceptions = test_exceptions_sr,
4922 .par = (const uint32_t[]){
4923 CCOUNT,
4924 XTENSA_OPTION_TIMER_INTERRUPT,
4926 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
4927 }, {
4928 .name = "wsr.configid0",
4929 .op_flags = XTENSA_OP_ILL,
4930 }, {
4931 .name = "wsr.configid1",
4932 .op_flags = XTENSA_OP_ILL,
4933 }, {
4934 .name = "wsr.cpenable",
4935 .translate = translate_wsr_mask,
4936 .test_exceptions = test_exceptions_sr,
4937 .par = (const uint32_t[]){
4938 CPENABLE,
4939 XTENSA_OPTION_COPROCESSOR,
4940 0xff,
4942 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_M1,
4943 }, {
4944 .name = "wsr.dbreaka0",
4945 .translate = translate_wsr_dbreaka,
4946 .test_exceptions = test_exceptions_dbreak,
4947 .par = (const uint32_t[]){
4948 DBREAKA,
4949 XTENSA_OPTION_DEBUG,
4951 .op_flags = XTENSA_OP_PRIVILEGED,
4952 }, {
4953 .name = "wsr.dbreaka1",
4954 .translate = translate_wsr_dbreaka,
4955 .test_exceptions = test_exceptions_dbreak,
4956 .par = (const uint32_t[]){
4957 DBREAKA + 1,
4958 XTENSA_OPTION_DEBUG,
4960 .op_flags = XTENSA_OP_PRIVILEGED,
4961 }, {
4962 .name = "wsr.dbreakc0",
4963 .translate = translate_wsr_dbreakc,
4964 .test_exceptions = test_exceptions_dbreak,
4965 .par = (const uint32_t[]){
4966 DBREAKC,
4967 XTENSA_OPTION_DEBUG,
4969 .op_flags = XTENSA_OP_PRIVILEGED,
4970 }, {
4971 .name = "wsr.dbreakc1",
4972 .translate = translate_wsr_dbreakc,
4973 .test_exceptions = test_exceptions_dbreak,
4974 .par = (const uint32_t[]){
4975 DBREAKC + 1,
4976 XTENSA_OPTION_DEBUG,
4978 .op_flags = XTENSA_OP_PRIVILEGED,
4979 }, {
4980 .name = "wsr.ddr",
4981 .translate = translate_wsr,
4982 .test_exceptions = test_exceptions_sr,
4983 .par = (const uint32_t[]){
4984 DDR,
4985 XTENSA_OPTION_DEBUG,
4987 .op_flags = XTENSA_OP_PRIVILEGED,
4988 }, {
4989 .name = "wsr.debugcause",
4990 .op_flags = XTENSA_OP_ILL,
4991 }, {
4992 .name = "wsr.depc",
4993 .translate = translate_wsr,
4994 .test_exceptions = test_exceptions_sr,
4995 .par = (const uint32_t[]){
4996 DEPC,
4997 XTENSA_OPTION_EXCEPTION,
4999 .op_flags = XTENSA_OP_PRIVILEGED,
5000 }, {
5001 .name = "wsr.dtlbcfg",
5002 .translate = translate_wsr_mask,
5003 .test_exceptions = test_exceptions_sr,
5004 .par = (const uint32_t[]){
5005 DTLBCFG,
5006 XTENSA_OPTION_MMU,
5007 0x01130000,
5009 .op_flags = XTENSA_OP_PRIVILEGED,
5010 }, {
5011 .name = "wsr.epc1",
5012 .translate = translate_wsr,
5013 .test_exceptions = test_exceptions_sr,
5014 .par = (const uint32_t[]){
5015 EPC1,
5016 XTENSA_OPTION_EXCEPTION,
5018 .op_flags = XTENSA_OP_PRIVILEGED,
5019 }, {
5020 .name = "wsr.epc2",
5021 .translate = translate_wsr,
5022 .test_exceptions = test_exceptions_hpi,
5023 .par = (const uint32_t[]){
5024 EPC1 + 1,
5025 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5027 .op_flags = XTENSA_OP_PRIVILEGED,
5028 }, {
5029 .name = "wsr.epc3",
5030 .translate = translate_wsr,
5031 .test_exceptions = test_exceptions_hpi,
5032 .par = (const uint32_t[]){
5033 EPC1 + 2,
5034 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5036 .op_flags = XTENSA_OP_PRIVILEGED,
5037 }, {
5038 .name = "wsr.epc4",
5039 .translate = translate_wsr,
5040 .test_exceptions = test_exceptions_hpi,
5041 .par = (const uint32_t[]){
5042 EPC1 + 3,
5043 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5045 .op_flags = XTENSA_OP_PRIVILEGED,
5046 }, {
5047 .name = "wsr.epc5",
5048 .translate = translate_wsr,
5049 .test_exceptions = test_exceptions_hpi,
5050 .par = (const uint32_t[]){
5051 EPC1 + 4,
5052 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5054 .op_flags = XTENSA_OP_PRIVILEGED,
5055 }, {
5056 .name = "wsr.epc6",
5057 .translate = translate_wsr,
5058 .test_exceptions = test_exceptions_hpi,
5059 .par = (const uint32_t[]){
5060 EPC1 + 5,
5061 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5063 .op_flags = XTENSA_OP_PRIVILEGED,
5064 }, {
5065 .name = "wsr.epc7",
5066 .translate = translate_wsr,
5067 .test_exceptions = test_exceptions_hpi,
5068 .par = (const uint32_t[]){
5069 EPC1 + 6,
5070 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5072 .op_flags = XTENSA_OP_PRIVILEGED,
5073 }, {
5074 .name = "wsr.eps2",
5075 .translate = translate_wsr,
5076 .test_exceptions = test_exceptions_hpi,
5077 .par = (const uint32_t[]){
5078 EPS2,
5079 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5081 .op_flags = XTENSA_OP_PRIVILEGED,
5082 }, {
5083 .name = "wsr.eps3",
5084 .translate = translate_wsr,
5085 .test_exceptions = test_exceptions_hpi,
5086 .par = (const uint32_t[]){
5087 EPS2 + 1,
5088 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5090 .op_flags = XTENSA_OP_PRIVILEGED,
5091 }, {
5092 .name = "wsr.eps4",
5093 .translate = translate_wsr,
5094 .test_exceptions = test_exceptions_hpi,
5095 .par = (const uint32_t[]){
5096 EPS2 + 2,
5097 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5099 .op_flags = XTENSA_OP_PRIVILEGED,
5100 }, {
5101 .name = "wsr.eps5",
5102 .translate = translate_wsr,
5103 .test_exceptions = test_exceptions_hpi,
5104 .par = (const uint32_t[]){
5105 EPS2 + 3,
5106 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5108 .op_flags = XTENSA_OP_PRIVILEGED,
5109 }, {
5110 .name = "wsr.eps6",
5111 .translate = translate_wsr,
5112 .test_exceptions = test_exceptions_hpi,
5113 .par = (const uint32_t[]){
5114 EPS2 + 4,
5115 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5117 .op_flags = XTENSA_OP_PRIVILEGED,
5118 }, {
5119 .name = "wsr.eps7",
5120 .translate = translate_wsr,
5121 .test_exceptions = test_exceptions_hpi,
5122 .par = (const uint32_t[]){
5123 EPS2 + 5,
5124 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5126 .op_flags = XTENSA_OP_PRIVILEGED,
5127 }, {
5128 .name = "wsr.eraccess",
5129 .translate = translate_wsr_mask,
5130 .par = (const uint32_t[]){
5131 ERACCESS,
5133 0xffff,
5135 .op_flags = XTENSA_OP_PRIVILEGED,
5136 }, {
5137 .name = "wsr.exccause",
5138 .translate = translate_wsr,
5139 .test_exceptions = test_exceptions_sr,
5140 .par = (const uint32_t[]){
5141 EXCCAUSE,
5142 XTENSA_OPTION_EXCEPTION,
5144 .op_flags = XTENSA_OP_PRIVILEGED,
5145 }, {
5146 .name = "wsr.excsave1",
5147 .translate = translate_wsr,
5148 .test_exceptions = test_exceptions_sr,
5149 .par = (const uint32_t[]){
5150 EXCSAVE1,
5151 XTENSA_OPTION_EXCEPTION,
5153 .op_flags = XTENSA_OP_PRIVILEGED,
5154 }, {
5155 .name = "wsr.excsave2",
5156 .translate = translate_wsr,
5157 .test_exceptions = test_exceptions_hpi,
5158 .par = (const uint32_t[]){
5159 EXCSAVE1 + 1,
5160 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5162 .op_flags = XTENSA_OP_PRIVILEGED,
5163 }, {
5164 .name = "wsr.excsave3",
5165 .translate = translate_wsr,
5166 .test_exceptions = test_exceptions_hpi,
5167 .par = (const uint32_t[]){
5168 EXCSAVE1 + 2,
5169 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5171 .op_flags = XTENSA_OP_PRIVILEGED,
5172 }, {
5173 .name = "wsr.excsave4",
5174 .translate = translate_wsr,
5175 .test_exceptions = test_exceptions_hpi,
5176 .par = (const uint32_t[]){
5177 EXCSAVE1 + 3,
5178 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5180 .op_flags = XTENSA_OP_PRIVILEGED,
5181 }, {
5182 .name = "wsr.excsave5",
5183 .translate = translate_wsr,
5184 .test_exceptions = test_exceptions_hpi,
5185 .par = (const uint32_t[]){
5186 EXCSAVE1 + 4,
5187 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5189 .op_flags = XTENSA_OP_PRIVILEGED,
5190 }, {
5191 .name = "wsr.excsave6",
5192 .translate = translate_wsr,
5193 .test_exceptions = test_exceptions_hpi,
5194 .par = (const uint32_t[]){
5195 EXCSAVE1 + 5,
5196 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5198 .op_flags = XTENSA_OP_PRIVILEGED,
5199 }, {
5200 .name = "wsr.excsave7",
5201 .translate = translate_wsr,
5202 .test_exceptions = test_exceptions_hpi,
5203 .par = (const uint32_t[]){
5204 EXCSAVE1 + 6,
5205 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5207 .op_flags = XTENSA_OP_PRIVILEGED,
5208 }, {
5209 .name = "wsr.excvaddr",
5210 .translate = translate_wsr,
5211 .test_exceptions = test_exceptions_sr,
5212 .par = (const uint32_t[]){
5213 EXCVADDR,
5214 XTENSA_OPTION_EXCEPTION,
5216 .op_flags = XTENSA_OP_PRIVILEGED,
5217 }, {
5218 .name = "wsr.ibreaka0",
5219 .translate = translate_wsr_ibreaka,
5220 .test_exceptions = test_exceptions_ibreak,
5221 .par = (const uint32_t[]){
5222 IBREAKA,
5223 XTENSA_OPTION_DEBUG,
5225 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
5226 }, {
5227 .name = "wsr.ibreaka1",
5228 .translate = translate_wsr_ibreaka,
5229 .test_exceptions = test_exceptions_ibreak,
5230 .par = (const uint32_t[]){
5231 IBREAKA + 1,
5232 XTENSA_OPTION_DEBUG,
5234 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
5235 }, {
5236 .name = "wsr.ibreakenable",
5237 .translate = translate_wsr_ibreakenable,
5238 .test_exceptions = test_exceptions_sr,
5239 .par = (const uint32_t[]){
5240 IBREAKENABLE,
5241 XTENSA_OPTION_DEBUG,
5243 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
5244 }, {
5245 .name = "wsr.icount",
5246 .translate = translate_wsr_icount,
5247 .test_exceptions = test_exceptions_sr,
5248 .par = (const uint32_t[]){
5249 ICOUNT,
5250 XTENSA_OPTION_DEBUG,
5252 .op_flags = XTENSA_OP_PRIVILEGED,
5253 }, {
5254 .name = "wsr.icountlevel",
5255 .translate = translate_wsr_mask,
5256 .test_exceptions = test_exceptions_sr,
5257 .par = (const uint32_t[]){
5258 ICOUNTLEVEL,
5259 XTENSA_OPTION_DEBUG,
5260 0xf,
5262 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_M1,
5263 }, {
5264 .name = "wsr.intclear",
5265 .translate = translate_wsr_intclear,
5266 .test_exceptions = test_exceptions_sr,
5267 .par = (const uint32_t[]){
5268 INTCLEAR,
5269 XTENSA_OPTION_INTERRUPT,
5271 .op_flags =
5272 XTENSA_OP_PRIVILEGED |
5273 XTENSA_OP_EXIT_TB_0 |
5274 XTENSA_OP_CHECK_INTERRUPTS,
5275 }, {
5276 .name = "wsr.intenable",
5277 .translate = translate_wsr,
5278 .test_exceptions = test_exceptions_sr,
5279 .par = (const uint32_t[]){
5280 INTENABLE,
5281 XTENSA_OPTION_INTERRUPT,
5283 .op_flags =
5284 XTENSA_OP_PRIVILEGED |
5285 XTENSA_OP_EXIT_TB_0 |
5286 XTENSA_OP_CHECK_INTERRUPTS,
5287 }, {
5288 .name = "wsr.interrupt",
5289 .translate = translate_wsr,
5290 .test_exceptions = test_exceptions_sr,
5291 .par = (const uint32_t[]){
5292 INTSET,
5293 XTENSA_OPTION_INTERRUPT,
5295 .op_flags =
5296 XTENSA_OP_PRIVILEGED |
5297 XTENSA_OP_EXIT_TB_0 |
5298 XTENSA_OP_CHECK_INTERRUPTS,
5299 }, {
5300 .name = "wsr.intset",
5301 .translate = translate_wsr_intset,
5302 .test_exceptions = test_exceptions_sr,
5303 .par = (const uint32_t[]){
5304 INTSET,
5305 XTENSA_OPTION_INTERRUPT,
5307 .op_flags =
5308 XTENSA_OP_PRIVILEGED |
5309 XTENSA_OP_EXIT_TB_0 |
5310 XTENSA_OP_CHECK_INTERRUPTS,
5311 }, {
5312 .name = "wsr.itlbcfg",
5313 .translate = translate_wsr_mask,
5314 .test_exceptions = test_exceptions_sr,
5315 .par = (const uint32_t[]){
5316 ITLBCFG,
5317 XTENSA_OPTION_MMU,
5318 0x01130000,
5320 .op_flags = XTENSA_OP_PRIVILEGED,
5321 }, {
5322 .name = "wsr.lbeg",
5323 .translate = translate_wsr,
5324 .test_exceptions = test_exceptions_sr,
5325 .par = (const uint32_t[]){
5326 LBEG,
5327 XTENSA_OPTION_LOOP,
5329 .op_flags = XTENSA_OP_EXIT_TB_M1,
5330 }, {
5331 .name = "wsr.lcount",
5332 .translate = translate_wsr,
5333 .test_exceptions = test_exceptions_sr,
5334 .par = (const uint32_t[]){
5335 LCOUNT,
5336 XTENSA_OPTION_LOOP,
5338 }, {
5339 .name = "wsr.lend",
5340 .translate = translate_wsr,
5341 .test_exceptions = test_exceptions_sr,
5342 .par = (const uint32_t[]){
5343 LEND,
5344 XTENSA_OPTION_LOOP,
5346 .op_flags = XTENSA_OP_EXIT_TB_M1,
5347 }, {
5348 .name = "wsr.litbase",
5349 .translate = translate_wsr_mask,
5350 .test_exceptions = test_exceptions_sr,
5351 .par = (const uint32_t[]){
5352 LITBASE,
5353 XTENSA_OPTION_EXTENDED_L32R,
5354 0xfffff001,
5356 .op_flags = XTENSA_OP_EXIT_TB_M1,
5357 }, {
5358 .name = "wsr.m0",
5359 .translate = translate_wsr,
5360 .test_exceptions = test_exceptions_sr,
5361 .par = (const uint32_t[]){
5363 XTENSA_OPTION_MAC16,
5365 }, {
5366 .name = "wsr.m1",
5367 .translate = translate_wsr,
5368 .test_exceptions = test_exceptions_sr,
5369 .par = (const uint32_t[]){
5370 MR + 1,
5371 XTENSA_OPTION_MAC16,
5373 }, {
5374 .name = "wsr.m2",
5375 .translate = translate_wsr,
5376 .test_exceptions = test_exceptions_sr,
5377 .par = (const uint32_t[]){
5378 MR + 2,
5379 XTENSA_OPTION_MAC16,
5381 }, {
5382 .name = "wsr.m3",
5383 .translate = translate_wsr,
5384 .test_exceptions = test_exceptions_sr,
5385 .par = (const uint32_t[]){
5386 MR + 3,
5387 XTENSA_OPTION_MAC16,
5389 }, {
5390 .name = "wsr.memctl",
5391 .translate = translate_wsr_memctl,
5392 .par = (const uint32_t[]){MEMCTL},
5393 .op_flags = XTENSA_OP_PRIVILEGED,
5394 }, {
5395 .name = "wsr.mecr",
5396 .translate = translate_wsr,
5397 .test_exceptions = test_exceptions_sr,
5398 .par = (const uint32_t[]){
5399 MECR,
5400 XTENSA_OPTION_MEMORY_ECC_PARITY,
5402 .op_flags = XTENSA_OP_PRIVILEGED,
5403 }, {
5404 .name = "wsr.mepc",
5405 .translate = translate_wsr,
5406 .test_exceptions = test_exceptions_sr,
5407 .par = (const uint32_t[]){
5408 MEPC,
5409 XTENSA_OPTION_MEMORY_ECC_PARITY,
5411 .op_flags = XTENSA_OP_PRIVILEGED,
5412 }, {
5413 .name = "wsr.meps",
5414 .translate = translate_wsr,
5415 .test_exceptions = test_exceptions_sr,
5416 .par = (const uint32_t[]){
5417 MEPS,
5418 XTENSA_OPTION_MEMORY_ECC_PARITY,
5420 .op_flags = XTENSA_OP_PRIVILEGED,
5421 }, {
5422 .name = "wsr.mesave",
5423 .translate = translate_wsr,
5424 .test_exceptions = test_exceptions_sr,
5425 .par = (const uint32_t[]){
5426 MESAVE,
5427 XTENSA_OPTION_MEMORY_ECC_PARITY,
5429 .op_flags = XTENSA_OP_PRIVILEGED,
5430 }, {
5431 .name = "wsr.mesr",
5432 .translate = translate_wsr,
5433 .test_exceptions = test_exceptions_sr,
5434 .par = (const uint32_t[]){
5435 MESR,
5436 XTENSA_OPTION_MEMORY_ECC_PARITY,
5438 .op_flags = XTENSA_OP_PRIVILEGED,
5439 }, {
5440 .name = "wsr.mevaddr",
5441 .translate = translate_wsr,
5442 .test_exceptions = test_exceptions_sr,
5443 .par = (const uint32_t[]){
5444 MESR,
5445 XTENSA_OPTION_MEMORY_ECC_PARITY,
5447 .op_flags = XTENSA_OP_PRIVILEGED,
5448 }, {
5449 .name = "wsr.misc0",
5450 .translate = translate_wsr,
5451 .test_exceptions = test_exceptions_sr,
5452 .par = (const uint32_t[]){
5453 MISC,
5454 XTENSA_OPTION_MISC_SR,
5456 .op_flags = XTENSA_OP_PRIVILEGED,
5457 }, {
5458 .name = "wsr.misc1",
5459 .translate = translate_wsr,
5460 .test_exceptions = test_exceptions_sr,
5461 .par = (const uint32_t[]){
5462 MISC + 1,
5463 XTENSA_OPTION_MISC_SR,
5465 .op_flags = XTENSA_OP_PRIVILEGED,
5466 }, {
5467 .name = "wsr.misc2",
5468 .translate = translate_wsr,
5469 .test_exceptions = test_exceptions_sr,
5470 .par = (const uint32_t[]){
5471 MISC + 2,
5472 XTENSA_OPTION_MISC_SR,
5474 .op_flags = XTENSA_OP_PRIVILEGED,
5475 }, {
5476 .name = "wsr.misc3",
5477 .translate = translate_wsr,
5478 .test_exceptions = test_exceptions_sr,
5479 .par = (const uint32_t[]){
5480 MISC + 3,
5481 XTENSA_OPTION_MISC_SR,
5483 .op_flags = XTENSA_OP_PRIVILEGED,
5484 }, {
5485 .name = "wsr.mmid",
5486 .translate = translate_wsr,
5487 .test_exceptions = test_exceptions_sr,
5488 .par = (const uint32_t[]){
5489 MMID,
5490 XTENSA_OPTION_TRACE_PORT,
5492 .op_flags = XTENSA_OP_PRIVILEGED,
5493 }, {
5494 .name = "wsr.mpuenb",
5495 .translate = translate_wsr_mpuenb,
5496 .test_exceptions = test_exceptions_sr,
5497 .par = (const uint32_t[]){
5498 MPUENB,
5499 XTENSA_OPTION_MPU,
5501 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_M1,
5502 }, {
5503 .name = "wsr.prefctl",
5504 .translate = translate_wsr,
5505 .par = (const uint32_t[]){PREFCTL},
5506 }, {
5507 .name = "wsr.prid",
5508 .op_flags = XTENSA_OP_ILL,
5509 }, {
5510 .name = "wsr.ps",
5511 .translate = translate_wsr_ps,
5512 .test_exceptions = test_exceptions_sr,
5513 .par = (const uint32_t[]){
5515 XTENSA_OPTION_EXCEPTION,
5517 .op_flags =
5518 XTENSA_OP_PRIVILEGED |
5519 XTENSA_OP_EXIT_TB_M1 |
5520 XTENSA_OP_CHECK_INTERRUPTS,
5521 }, {
5522 .name = "wsr.ptevaddr",
5523 .translate = translate_wsr_mask,
5524 .test_exceptions = test_exceptions_sr,
5525 .par = (const uint32_t[]){
5526 PTEVADDR,
5527 XTENSA_OPTION_MMU,
5528 0xffc00000,
5530 .op_flags = XTENSA_OP_PRIVILEGED,
5531 }, {
5532 .name = "wsr.rasid",
5533 .translate = translate_wsr_rasid,
5534 .test_exceptions = test_exceptions_sr,
5535 .par = (const uint32_t[]){
5536 RASID,
5537 XTENSA_OPTION_MMU,
5539 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_M1,
5540 }, {
5541 .name = "wsr.sar",
5542 .translate = translate_wsr_sar,
5543 .par = (const uint32_t[]){SAR},
5544 }, {
5545 .name = "wsr.scompare1",
5546 .translate = translate_wsr,
5547 .test_exceptions = test_exceptions_sr,
5548 .par = (const uint32_t[]){
5549 SCOMPARE1,
5550 XTENSA_OPTION_CONDITIONAL_STORE,
5552 }, {
5553 .name = "wsr.vecbase",
5554 .translate = translate_wsr,
5555 .test_exceptions = test_exceptions_sr,
5556 .par = (const uint32_t[]){
5557 VECBASE,
5558 XTENSA_OPTION_RELOCATABLE_VECTOR,
5560 .op_flags = XTENSA_OP_PRIVILEGED,
5561 }, {
5562 .name = "wsr.windowbase",
5563 .translate = translate_wsr_windowbase,
5564 .test_exceptions = test_exceptions_sr,
5565 .par = (const uint32_t[]){
5566 WINDOW_BASE,
5567 XTENSA_OPTION_WINDOWED_REGISTER,
5569 .op_flags = XTENSA_OP_PRIVILEGED |
5570 XTENSA_OP_EXIT_TB_M1 |
5571 XTENSA_OP_SYNC_REGISTER_WINDOW,
5572 }, {
5573 .name = "wsr.windowstart",
5574 .translate = translate_wsr_windowstart,
5575 .test_exceptions = test_exceptions_sr,
5576 .par = (const uint32_t[]){
5577 WINDOW_START,
5578 XTENSA_OPTION_WINDOWED_REGISTER,
5580 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_M1,
5581 }, {
5582 .name = "wur.expstate",
5583 .translate = translate_wur,
5584 .par = (const uint32_t[]){EXPSTATE},
5585 }, {
5586 .name = "wur.threadptr",
5587 .translate = translate_wur,
5588 .par = (const uint32_t[]){THREADPTR},
5589 }, {
5590 .name = "xor",
5591 .translate = translate_xor,
5592 }, {
5593 .name = "xorb",
5594 .translate = translate_boolean,
5595 .par = (const uint32_t[]){BOOLEAN_XOR},
5596 }, {
5597 .name = "xsr.176",
5598 .op_flags = XTENSA_OP_ILL,
5599 }, {
5600 .name = "xsr.208",
5601 .op_flags = XTENSA_OP_ILL,
5602 }, {
5603 .name = "xsr.acchi",
5604 .translate = translate_xsr_acchi,
5605 .test_exceptions = test_exceptions_sr,
5606 .par = (const uint32_t[]){
5607 ACCHI,
5608 XTENSA_OPTION_MAC16,
5610 }, {
5611 .name = "xsr.acclo",
5612 .translate = translate_xsr,
5613 .test_exceptions = test_exceptions_sr,
5614 .par = (const uint32_t[]){
5615 ACCLO,
5616 XTENSA_OPTION_MAC16,
5618 }, {
5619 .name = "xsr.atomctl",
5620 .translate = translate_xsr_mask,
5621 .test_exceptions = test_exceptions_sr,
5622 .par = (const uint32_t[]){
5623 ATOMCTL,
5624 XTENSA_OPTION_ATOMCTL,
5625 0x3f,
5627 .op_flags = XTENSA_OP_PRIVILEGED,
5628 }, {
5629 .name = "xsr.br",
5630 .translate = translate_xsr_mask,
5631 .test_exceptions = test_exceptions_sr,
5632 .par = (const uint32_t[]){
5634 XTENSA_OPTION_BOOLEAN,
5635 0xffff,
5637 }, {
5638 .name = "xsr.cacheadrdis",
5639 .translate = translate_xsr_mask,
5640 .test_exceptions = test_exceptions_sr,
5641 .par = (const uint32_t[]){
5642 CACHEADRDIS,
5643 XTENSA_OPTION_MPU,
5644 0xff,
5646 .op_flags = XTENSA_OP_PRIVILEGED,
5647 }, {
5648 .name = "xsr.cacheattr",
5649 .translate = translate_xsr,
5650 .test_exceptions = test_exceptions_sr,
5651 .par = (const uint32_t[]){
5652 CACHEATTR,
5653 XTENSA_OPTION_CACHEATTR,
5655 .op_flags = XTENSA_OP_PRIVILEGED,
5656 }, {
5657 .name = "xsr.ccompare0",
5658 .translate = translate_xsr_ccompare,
5659 .test_exceptions = test_exceptions_ccompare,
5660 .par = (const uint32_t[]){
5661 CCOMPARE,
5662 XTENSA_OPTION_TIMER_INTERRUPT,
5664 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
5665 }, {
5666 .name = "xsr.ccompare1",
5667 .translate = translate_xsr_ccompare,
5668 .test_exceptions = test_exceptions_ccompare,
5669 .par = (const uint32_t[]){
5670 CCOMPARE + 1,
5671 XTENSA_OPTION_TIMER_INTERRUPT,
5673 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
5674 }, {
5675 .name = "xsr.ccompare2",
5676 .translate = translate_xsr_ccompare,
5677 .test_exceptions = test_exceptions_ccompare,
5678 .par = (const uint32_t[]){
5679 CCOMPARE + 2,
5680 XTENSA_OPTION_TIMER_INTERRUPT,
5682 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
5683 }, {
5684 .name = "xsr.ccount",
5685 .translate = translate_xsr_ccount,
5686 .test_exceptions = test_exceptions_sr,
5687 .par = (const uint32_t[]){
5688 CCOUNT,
5689 XTENSA_OPTION_TIMER_INTERRUPT,
5691 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
5692 }, {
5693 .name = "xsr.configid0",
5694 .op_flags = XTENSA_OP_ILL,
5695 }, {
5696 .name = "xsr.configid1",
5697 .op_flags = XTENSA_OP_ILL,
5698 }, {
5699 .name = "xsr.cpenable",
5700 .translate = translate_xsr_mask,
5701 .test_exceptions = test_exceptions_sr,
5702 .par = (const uint32_t[]){
5703 CPENABLE,
5704 XTENSA_OPTION_COPROCESSOR,
5705 0xff,
5707 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_M1,
5708 }, {
5709 .name = "xsr.dbreaka0",
5710 .translate = translate_xsr_dbreaka,
5711 .test_exceptions = test_exceptions_dbreak,
5712 .par = (const uint32_t[]){
5713 DBREAKA,
5714 XTENSA_OPTION_DEBUG,
5716 .op_flags = XTENSA_OP_PRIVILEGED,
5717 }, {
5718 .name = "xsr.dbreaka1",
5719 .translate = translate_xsr_dbreaka,
5720 .test_exceptions = test_exceptions_dbreak,
5721 .par = (const uint32_t[]){
5722 DBREAKA + 1,
5723 XTENSA_OPTION_DEBUG,
5725 .op_flags = XTENSA_OP_PRIVILEGED,
5726 }, {
5727 .name = "xsr.dbreakc0",
5728 .translate = translate_xsr_dbreakc,
5729 .test_exceptions = test_exceptions_dbreak,
5730 .par = (const uint32_t[]){
5731 DBREAKC,
5732 XTENSA_OPTION_DEBUG,
5734 .op_flags = XTENSA_OP_PRIVILEGED,
5735 }, {
5736 .name = "xsr.dbreakc1",
5737 .translate = translate_xsr_dbreakc,
5738 .test_exceptions = test_exceptions_dbreak,
5739 .par = (const uint32_t[]){
5740 DBREAKC + 1,
5741 XTENSA_OPTION_DEBUG,
5743 .op_flags = XTENSA_OP_PRIVILEGED,
5744 }, {
5745 .name = "xsr.ddr",
5746 .translate = translate_xsr,
5747 .test_exceptions = test_exceptions_sr,
5748 .par = (const uint32_t[]){
5749 DDR,
5750 XTENSA_OPTION_DEBUG,
5752 .op_flags = XTENSA_OP_PRIVILEGED,
5753 }, {
5754 .name = "xsr.debugcause",
5755 .op_flags = XTENSA_OP_ILL,
5756 }, {
5757 .name = "xsr.depc",
5758 .translate = translate_xsr,
5759 .test_exceptions = test_exceptions_sr,
5760 .par = (const uint32_t[]){
5761 DEPC,
5762 XTENSA_OPTION_EXCEPTION,
5764 .op_flags = XTENSA_OP_PRIVILEGED,
5765 }, {
5766 .name = "xsr.dtlbcfg",
5767 .translate = translate_xsr_mask,
5768 .test_exceptions = test_exceptions_sr,
5769 .par = (const uint32_t[]){
5770 DTLBCFG,
5771 XTENSA_OPTION_MMU,
5772 0x01130000,
5774 .op_flags = XTENSA_OP_PRIVILEGED,
5775 }, {
5776 .name = "xsr.epc1",
5777 .translate = translate_xsr,
5778 .test_exceptions = test_exceptions_sr,
5779 .par = (const uint32_t[]){
5780 EPC1,
5781 XTENSA_OPTION_EXCEPTION,
5783 .op_flags = XTENSA_OP_PRIVILEGED,
5784 }, {
5785 .name = "xsr.epc2",
5786 .translate = translate_xsr,
5787 .test_exceptions = test_exceptions_hpi,
5788 .par = (const uint32_t[]){
5789 EPC1 + 1,
5790 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5792 .op_flags = XTENSA_OP_PRIVILEGED,
5793 }, {
5794 .name = "xsr.epc3",
5795 .translate = translate_xsr,
5796 .test_exceptions = test_exceptions_hpi,
5797 .par = (const uint32_t[]){
5798 EPC1 + 2,
5799 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5801 .op_flags = XTENSA_OP_PRIVILEGED,
5802 }, {
5803 .name = "xsr.epc4",
5804 .translate = translate_xsr,
5805 .test_exceptions = test_exceptions_hpi,
5806 .par = (const uint32_t[]){
5807 EPC1 + 3,
5808 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5810 .op_flags = XTENSA_OP_PRIVILEGED,
5811 }, {
5812 .name = "xsr.epc5",
5813 .translate = translate_xsr,
5814 .test_exceptions = test_exceptions_hpi,
5815 .par = (const uint32_t[]){
5816 EPC1 + 4,
5817 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5819 .op_flags = XTENSA_OP_PRIVILEGED,
5820 }, {
5821 .name = "xsr.epc6",
5822 .translate = translate_xsr,
5823 .test_exceptions = test_exceptions_hpi,
5824 .par = (const uint32_t[]){
5825 EPC1 + 5,
5826 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5828 .op_flags = XTENSA_OP_PRIVILEGED,
5829 }, {
5830 .name = "xsr.epc7",
5831 .translate = translate_xsr,
5832 .test_exceptions = test_exceptions_hpi,
5833 .par = (const uint32_t[]){
5834 EPC1 + 6,
5835 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5837 .op_flags = XTENSA_OP_PRIVILEGED,
5838 }, {
5839 .name = "xsr.eps2",
5840 .translate = translate_xsr,
5841 .test_exceptions = test_exceptions_hpi,
5842 .par = (const uint32_t[]){
5843 EPS2,
5844 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5846 .op_flags = XTENSA_OP_PRIVILEGED,
5847 }, {
5848 .name = "xsr.eps3",
5849 .translate = translate_xsr,
5850 .test_exceptions = test_exceptions_hpi,
5851 .par = (const uint32_t[]){
5852 EPS2 + 1,
5853 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5855 .op_flags = XTENSA_OP_PRIVILEGED,
5856 }, {
5857 .name = "xsr.eps4",
5858 .translate = translate_xsr,
5859 .test_exceptions = test_exceptions_hpi,
5860 .par = (const uint32_t[]){
5861 EPS2 + 2,
5862 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5864 .op_flags = XTENSA_OP_PRIVILEGED,
5865 }, {
5866 .name = "xsr.eps5",
5867 .translate = translate_xsr,
5868 .test_exceptions = test_exceptions_hpi,
5869 .par = (const uint32_t[]){
5870 EPS2 + 3,
5871 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5873 .op_flags = XTENSA_OP_PRIVILEGED,
5874 }, {
5875 .name = "xsr.eps6",
5876 .translate = translate_xsr,
5877 .test_exceptions = test_exceptions_hpi,
5878 .par = (const uint32_t[]){
5879 EPS2 + 4,
5880 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5882 .op_flags = XTENSA_OP_PRIVILEGED,
5883 }, {
5884 .name = "xsr.eps7",
5885 .translate = translate_xsr,
5886 .test_exceptions = test_exceptions_hpi,
5887 .par = (const uint32_t[]){
5888 EPS2 + 5,
5889 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5891 .op_flags = XTENSA_OP_PRIVILEGED,
5892 }, {
5893 .name = "xsr.eraccess",
5894 .translate = translate_xsr_mask,
5895 .par = (const uint32_t[]){
5896 ERACCESS,
5898 0xffff,
5900 .op_flags = XTENSA_OP_PRIVILEGED,
5901 }, {
5902 .name = "xsr.exccause",
5903 .translate = translate_xsr,
5904 .test_exceptions = test_exceptions_sr,
5905 .par = (const uint32_t[]){
5906 EXCCAUSE,
5907 XTENSA_OPTION_EXCEPTION,
5909 .op_flags = XTENSA_OP_PRIVILEGED,
5910 }, {
5911 .name = "xsr.excsave1",
5912 .translate = translate_xsr,
5913 .test_exceptions = test_exceptions_sr,
5914 .par = (const uint32_t[]){
5915 EXCSAVE1,
5916 XTENSA_OPTION_EXCEPTION,
5918 .op_flags = XTENSA_OP_PRIVILEGED,
5919 }, {
5920 .name = "xsr.excsave2",
5921 .translate = translate_xsr,
5922 .test_exceptions = test_exceptions_hpi,
5923 .par = (const uint32_t[]){
5924 EXCSAVE1 + 1,
5925 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5927 .op_flags = XTENSA_OP_PRIVILEGED,
5928 }, {
5929 .name = "xsr.excsave3",
5930 .translate = translate_xsr,
5931 .test_exceptions = test_exceptions_hpi,
5932 .par = (const uint32_t[]){
5933 EXCSAVE1 + 2,
5934 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5936 .op_flags = XTENSA_OP_PRIVILEGED,
5937 }, {
5938 .name = "xsr.excsave4",
5939 .translate = translate_xsr,
5940 .test_exceptions = test_exceptions_hpi,
5941 .par = (const uint32_t[]){
5942 EXCSAVE1 + 3,
5943 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5945 .op_flags = XTENSA_OP_PRIVILEGED,
5946 }, {
5947 .name = "xsr.excsave5",
5948 .translate = translate_xsr,
5949 .test_exceptions = test_exceptions_hpi,
5950 .par = (const uint32_t[]){
5951 EXCSAVE1 + 4,
5952 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5954 .op_flags = XTENSA_OP_PRIVILEGED,
5955 }, {
5956 .name = "xsr.excsave6",
5957 .translate = translate_xsr,
5958 .test_exceptions = test_exceptions_hpi,
5959 .par = (const uint32_t[]){
5960 EXCSAVE1 + 5,
5961 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5963 .op_flags = XTENSA_OP_PRIVILEGED,
5964 }, {
5965 .name = "xsr.excsave7",
5966 .translate = translate_xsr,
5967 .test_exceptions = test_exceptions_hpi,
5968 .par = (const uint32_t[]){
5969 EXCSAVE1 + 6,
5970 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5972 .op_flags = XTENSA_OP_PRIVILEGED,
5973 }, {
5974 .name = "xsr.excvaddr",
5975 .translate = translate_xsr,
5976 .test_exceptions = test_exceptions_sr,
5977 .par = (const uint32_t[]){
5978 EXCVADDR,
5979 XTENSA_OPTION_EXCEPTION,
5981 .op_flags = XTENSA_OP_PRIVILEGED,
5982 }, {
5983 .name = "xsr.ibreaka0",
5984 .translate = translate_xsr_ibreaka,
5985 .test_exceptions = test_exceptions_ibreak,
5986 .par = (const uint32_t[]){
5987 IBREAKA,
5988 XTENSA_OPTION_DEBUG,
5990 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
5991 }, {
5992 .name = "xsr.ibreaka1",
5993 .translate = translate_xsr_ibreaka,
5994 .test_exceptions = test_exceptions_ibreak,
5995 .par = (const uint32_t[]){
5996 IBREAKA + 1,
5997 XTENSA_OPTION_DEBUG,
5999 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
6000 }, {
6001 .name = "xsr.ibreakenable",
6002 .translate = translate_xsr_ibreakenable,
6003 .test_exceptions = test_exceptions_sr,
6004 .par = (const uint32_t[]){
6005 IBREAKENABLE,
6006 XTENSA_OPTION_DEBUG,
6008 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
6009 }, {
6010 .name = "xsr.icount",
6011 .translate = translate_xsr_icount,
6012 .test_exceptions = test_exceptions_sr,
6013 .par = (const uint32_t[]){
6014 ICOUNT,
6015 XTENSA_OPTION_DEBUG,
6017 .op_flags = XTENSA_OP_PRIVILEGED,
6018 }, {
6019 .name = "xsr.icountlevel",
6020 .translate = translate_xsr_mask,
6021 .test_exceptions = test_exceptions_sr,
6022 .par = (const uint32_t[]){
6023 ICOUNTLEVEL,
6024 XTENSA_OPTION_DEBUG,
6025 0xf,
6027 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_M1,
6028 }, {
6029 .name = "xsr.intclear",
6030 .op_flags = XTENSA_OP_ILL,
6031 }, {
6032 .name = "xsr.intenable",
6033 .translate = translate_xsr,
6034 .test_exceptions = test_exceptions_sr,
6035 .par = (const uint32_t[]){
6036 INTENABLE,
6037 XTENSA_OPTION_INTERRUPT,
6039 .op_flags =
6040 XTENSA_OP_PRIVILEGED |
6041 XTENSA_OP_EXIT_TB_0 |
6042 XTENSA_OP_CHECK_INTERRUPTS,
6043 }, {
6044 .name = "xsr.interrupt",
6045 .op_flags = XTENSA_OP_ILL,
6046 }, {
6047 .name = "xsr.intset",
6048 .op_flags = XTENSA_OP_ILL,
6049 }, {
6050 .name = "xsr.itlbcfg",
6051 .translate = translate_xsr_mask,
6052 .test_exceptions = test_exceptions_sr,
6053 .par = (const uint32_t[]){
6054 ITLBCFG,
6055 XTENSA_OPTION_MMU,
6056 0x01130000,
6058 .op_flags = XTENSA_OP_PRIVILEGED,
6059 }, {
6060 .name = "xsr.lbeg",
6061 .translate = translate_xsr,
6062 .test_exceptions = test_exceptions_sr,
6063 .par = (const uint32_t[]){
6064 LBEG,
6065 XTENSA_OPTION_LOOP,
6067 .op_flags = XTENSA_OP_EXIT_TB_M1,
6068 }, {
6069 .name = "xsr.lcount",
6070 .translate = translate_xsr,
6071 .test_exceptions = test_exceptions_sr,
6072 .par = (const uint32_t[]){
6073 LCOUNT,
6074 XTENSA_OPTION_LOOP,
6076 }, {
6077 .name = "xsr.lend",
6078 .translate = translate_xsr,
6079 .test_exceptions = test_exceptions_sr,
6080 .par = (const uint32_t[]){
6081 LEND,
6082 XTENSA_OPTION_LOOP,
6084 .op_flags = XTENSA_OP_EXIT_TB_M1,
6085 }, {
6086 .name = "xsr.litbase",
6087 .translate = translate_xsr_mask,
6088 .test_exceptions = test_exceptions_sr,
6089 .par = (const uint32_t[]){
6090 LITBASE,
6091 XTENSA_OPTION_EXTENDED_L32R,
6092 0xfffff001,
6094 .op_flags = XTENSA_OP_EXIT_TB_M1,
6095 }, {
6096 .name = "xsr.m0",
6097 .translate = translate_xsr,
6098 .test_exceptions = test_exceptions_sr,
6099 .par = (const uint32_t[]){
6101 XTENSA_OPTION_MAC16,
6103 }, {
6104 .name = "xsr.m1",
6105 .translate = translate_xsr,
6106 .test_exceptions = test_exceptions_sr,
6107 .par = (const uint32_t[]){
6108 MR + 1,
6109 XTENSA_OPTION_MAC16,
6111 }, {
6112 .name = "xsr.m2",
6113 .translate = translate_xsr,
6114 .test_exceptions = test_exceptions_sr,
6115 .par = (const uint32_t[]){
6116 MR + 2,
6117 XTENSA_OPTION_MAC16,
6119 }, {
6120 .name = "xsr.m3",
6121 .translate = translate_xsr,
6122 .test_exceptions = test_exceptions_sr,
6123 .par = (const uint32_t[]){
6124 MR + 3,
6125 XTENSA_OPTION_MAC16,
6127 }, {
6128 .name = "xsr.memctl",
6129 .translate = translate_xsr_memctl,
6130 .par = (const uint32_t[]){MEMCTL},
6131 .op_flags = XTENSA_OP_PRIVILEGED,
6132 }, {
6133 .name = "xsr.mecr",
6134 .translate = translate_xsr,
6135 .test_exceptions = test_exceptions_sr,
6136 .par = (const uint32_t[]){
6137 MECR,
6138 XTENSA_OPTION_MEMORY_ECC_PARITY,
6140 .op_flags = XTENSA_OP_PRIVILEGED,
6141 }, {
6142 .name = "xsr.mepc",
6143 .translate = translate_xsr,
6144 .test_exceptions = test_exceptions_sr,
6145 .par = (const uint32_t[]){
6146 MEPC,
6147 XTENSA_OPTION_MEMORY_ECC_PARITY,
6149 .op_flags = XTENSA_OP_PRIVILEGED,
6150 }, {
6151 .name = "xsr.meps",
6152 .translate = translate_xsr,
6153 .test_exceptions = test_exceptions_sr,
6154 .par = (const uint32_t[]){
6155 MEPS,
6156 XTENSA_OPTION_MEMORY_ECC_PARITY,
6158 .op_flags = XTENSA_OP_PRIVILEGED,
6159 }, {
6160 .name = "xsr.mesave",
6161 .translate = translate_xsr,
6162 .test_exceptions = test_exceptions_sr,
6163 .par = (const uint32_t[]){
6164 MESAVE,
6165 XTENSA_OPTION_MEMORY_ECC_PARITY,
6167 .op_flags = XTENSA_OP_PRIVILEGED,
6168 }, {
6169 .name = "xsr.mesr",
6170 .translate = translate_xsr,
6171 .test_exceptions = test_exceptions_sr,
6172 .par = (const uint32_t[]){
6173 MESR,
6174 XTENSA_OPTION_MEMORY_ECC_PARITY,
6176 .op_flags = XTENSA_OP_PRIVILEGED,
6177 }, {
6178 .name = "xsr.mevaddr",
6179 .translate = translate_xsr,
6180 .test_exceptions = test_exceptions_sr,
6181 .par = (const uint32_t[]){
6182 MESR,
6183 XTENSA_OPTION_MEMORY_ECC_PARITY,
6185 .op_flags = XTENSA_OP_PRIVILEGED,
6186 }, {
6187 .name = "xsr.misc0",
6188 .translate = translate_xsr,
6189 .test_exceptions = test_exceptions_sr,
6190 .par = (const uint32_t[]){
6191 MISC,
6192 XTENSA_OPTION_MISC_SR,
6194 .op_flags = XTENSA_OP_PRIVILEGED,
6195 }, {
6196 .name = "xsr.misc1",
6197 .translate = translate_xsr,
6198 .test_exceptions = test_exceptions_sr,
6199 .par = (const uint32_t[]){
6200 MISC + 1,
6201 XTENSA_OPTION_MISC_SR,
6203 .op_flags = XTENSA_OP_PRIVILEGED,
6204 }, {
6205 .name = "xsr.misc2",
6206 .translate = translate_xsr,
6207 .test_exceptions = test_exceptions_sr,
6208 .par = (const uint32_t[]){
6209 MISC + 2,
6210 XTENSA_OPTION_MISC_SR,
6212 .op_flags = XTENSA_OP_PRIVILEGED,
6213 }, {
6214 .name = "xsr.misc3",
6215 .translate = translate_xsr,
6216 .test_exceptions = test_exceptions_sr,
6217 .par = (const uint32_t[]){
6218 MISC + 3,
6219 XTENSA_OPTION_MISC_SR,
6221 .op_flags = XTENSA_OP_PRIVILEGED,
6222 }, {
6223 .name = "xsr.mpuenb",
6224 .translate = translate_xsr_mpuenb,
6225 .test_exceptions = test_exceptions_sr,
6226 .par = (const uint32_t[]){
6227 MPUENB,
6228 XTENSA_OPTION_MPU,
6230 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_M1,
6231 }, {
6232 .name = "xsr.prefctl",
6233 .translate = translate_xsr,
6234 .par = (const uint32_t[]){PREFCTL},
6235 }, {
6236 .name = "xsr.prid",
6237 .op_flags = XTENSA_OP_ILL,
6238 }, {
6239 .name = "xsr.ps",
6240 .translate = translate_xsr_ps,
6241 .test_exceptions = test_exceptions_sr,
6242 .par = (const uint32_t[]){
6244 XTENSA_OPTION_EXCEPTION,
6246 .op_flags =
6247 XTENSA_OP_PRIVILEGED |
6248 XTENSA_OP_EXIT_TB_M1 |
6249 XTENSA_OP_CHECK_INTERRUPTS,
6250 }, {
6251 .name = "xsr.ptevaddr",
6252 .translate = translate_xsr_mask,
6253 .test_exceptions = test_exceptions_sr,
6254 .par = (const uint32_t[]){
6255 PTEVADDR,
6256 XTENSA_OPTION_MMU,
6257 0xffc00000,
6259 .op_flags = XTENSA_OP_PRIVILEGED,
6260 }, {
6261 .name = "xsr.rasid",
6262 .translate = translate_xsr_rasid,
6263 .test_exceptions = test_exceptions_sr,
6264 .par = (const uint32_t[]){
6265 RASID,
6266 XTENSA_OPTION_MMU,
6268 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_M1,
6269 }, {
6270 .name = "xsr.sar",
6271 .translate = translate_xsr_sar,
6272 .par = (const uint32_t[]){SAR},
6273 }, {
6274 .name = "xsr.scompare1",
6275 .translate = translate_xsr,
6276 .test_exceptions = test_exceptions_sr,
6277 .par = (const uint32_t[]){
6278 SCOMPARE1,
6279 XTENSA_OPTION_CONDITIONAL_STORE,
6281 }, {
6282 .name = "xsr.vecbase",
6283 .translate = translate_xsr,
6284 .test_exceptions = test_exceptions_sr,
6285 .par = (const uint32_t[]){
6286 VECBASE,
6287 XTENSA_OPTION_RELOCATABLE_VECTOR,
6289 .op_flags = XTENSA_OP_PRIVILEGED,
6290 }, {
6291 .name = "xsr.windowbase",
6292 .translate = translate_xsr_windowbase,
6293 .test_exceptions = test_exceptions_sr,
6294 .par = (const uint32_t[]){
6295 WINDOW_BASE,
6296 XTENSA_OPTION_WINDOWED_REGISTER,
6298 .op_flags = XTENSA_OP_PRIVILEGED |
6299 XTENSA_OP_EXIT_TB_M1 |
6300 XTENSA_OP_SYNC_REGISTER_WINDOW,
6301 }, {
6302 .name = "xsr.windowstart",
6303 .translate = translate_xsr_windowstart,
6304 .test_exceptions = test_exceptions_sr,
6305 .par = (const uint32_t[]){
6306 WINDOW_START,
6307 XTENSA_OPTION_WINDOWED_REGISTER,
6309 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_M1,
6313 const XtensaOpcodeTranslators xtensa_core_opcodes = {
6314 .num_opcodes = ARRAY_SIZE(core_ops),
6315 .opcode = core_ops,
6319 static inline void get_f32_o1_i3(const OpcodeArg *arg, OpcodeArg *arg32,
6320 int o0, int i0, int i1, int i2)
6322 if ((i0 >= 0 && arg[i0].num_bits == 64) ||
6323 (o0 >= 0 && arg[o0].num_bits == 64)) {
6324 if (o0 >= 0) {
6325 arg32[o0].out = tcg_temp_new_i32();
6327 if (i0 >= 0) {
6328 arg32[i0].in = tcg_temp_new_i32();
6329 tcg_gen_extrl_i64_i32(arg32[i0].in, arg[i0].in);
6331 if (i1 >= 0) {
6332 arg32[i1].in = tcg_temp_new_i32();
6333 tcg_gen_extrl_i64_i32(arg32[i1].in, arg[i1].in);
6335 if (i2 >= 0) {
6336 arg32[i2].in = tcg_temp_new_i32();
6337 tcg_gen_extrl_i64_i32(arg32[i2].in, arg[i2].in);
6339 } else {
6340 if (o0 >= 0) {
6341 arg32[o0].out = arg[o0].out;
6343 if (i0 >= 0) {
6344 arg32[i0].in = arg[i0].in;
6346 if (i1 >= 0) {
6347 arg32[i1].in = arg[i1].in;
6349 if (i2 >= 0) {
6350 arg32[i2].in = arg[i2].in;
6355 static inline void put_f32_o1_i3(const OpcodeArg *arg, const OpcodeArg *arg32,
6356 int o0, int i0, int i1, int i2)
6358 if ((i0 >= 0 && arg[i0].num_bits == 64) ||
6359 (o0 >= 0 && arg[o0].num_bits == 64)) {
6360 if (o0 >= 0) {
6361 tcg_gen_extu_i32_i64(arg[o0].out, arg32[o0].out);
6362 tcg_temp_free_i32(arg32[o0].out);
6364 if (i0 >= 0) {
6365 tcg_temp_free_i32(arg32[i0].in);
6367 if (i1 >= 0) {
6368 tcg_temp_free_i32(arg32[i1].in);
6370 if (i2 >= 0) {
6371 tcg_temp_free_i32(arg32[i2].in);
6376 static inline void get_f32_o1_i2(const OpcodeArg *arg, OpcodeArg *arg32,
6377 int o0, int i0, int i1)
6379 get_f32_o1_i3(arg, arg32, o0, i0, i1, -1);
6382 static inline void put_f32_o1_i2(const OpcodeArg *arg, const OpcodeArg *arg32,
6383 int o0, int i0, int i1)
6385 put_f32_o1_i3(arg, arg32, o0, i0, i1, -1);
6388 static inline void get_f32_o1_i1(const OpcodeArg *arg, OpcodeArg *arg32,
6389 int o0, int i0)
6391 get_f32_o1_i2(arg, arg32, o0, i0, -1);
6394 static inline void put_f32_o1_i1(const OpcodeArg *arg, const OpcodeArg *arg32,
6395 int o0, int i0)
6397 put_f32_o1_i2(arg, arg32, o0, i0, -1);
6400 static inline void get_f32_o1(const OpcodeArg *arg, OpcodeArg *arg32,
6401 int o0)
6403 get_f32_o1_i1(arg, arg32, o0, -1);
6406 static inline void put_f32_o1(const OpcodeArg *arg, const OpcodeArg *arg32,
6407 int o0)
6409 put_f32_o1_i1(arg, arg32, o0, -1);
6412 static inline void get_f32_i2(const OpcodeArg *arg, OpcodeArg *arg32,
6413 int i0, int i1)
6415 get_f32_o1_i2(arg, arg32, -1, i0, i1);
6418 static inline void put_f32_i2(const OpcodeArg *arg, const OpcodeArg *arg32,
6419 int i0, int i1)
6421 put_f32_o1_i2(arg, arg32, -1, i0, i1);
6424 static inline void get_f32_i1(const OpcodeArg *arg, OpcodeArg *arg32,
6425 int i0)
6427 get_f32_i2(arg, arg32, i0, -1);
6430 static inline void put_f32_i1(const OpcodeArg *arg, const OpcodeArg *arg32,
6431 int i0)
6433 put_f32_i2(arg, arg32, i0, -1);
6437 static void translate_abs_d(DisasContext *dc, const OpcodeArg arg[],
6438 const uint32_t par[])
6440 gen_helper_abs_d(arg[0].out, arg[1].in);
6443 static void translate_abs_s(DisasContext *dc, const OpcodeArg arg[],
6444 const uint32_t par[])
6446 OpcodeArg arg32[2];
6448 get_f32_o1_i1(arg, arg32, 0, 1);
6449 gen_helper_abs_s(arg32[0].out, arg32[1].in);
6450 put_f32_o1_i1(arg, arg32, 0, 1);
6453 static void translate_fpu2k_add_s(DisasContext *dc, const OpcodeArg arg[],
6454 const uint32_t par[])
6456 gen_helper_fpu2k_add_s(arg[0].out, cpu_env,
6457 arg[1].in, arg[2].in);
6460 enum {
6461 COMPARE_UN,
6462 COMPARE_OEQ,
6463 COMPARE_UEQ,
6464 COMPARE_OLT,
6465 COMPARE_ULT,
6466 COMPARE_OLE,
6467 COMPARE_ULE,
6470 static void translate_compare_d(DisasContext *dc, const OpcodeArg arg[],
6471 const uint32_t par[])
6473 static void (* const helper[])(TCGv_i32 res, TCGv_env env,
6474 TCGv_i64 s, TCGv_i64 t) = {
6475 [COMPARE_UN] = gen_helper_un_d,
6476 [COMPARE_OEQ] = gen_helper_oeq_d,
6477 [COMPARE_UEQ] = gen_helper_ueq_d,
6478 [COMPARE_OLT] = gen_helper_olt_d,
6479 [COMPARE_ULT] = gen_helper_ult_d,
6480 [COMPARE_OLE] = gen_helper_ole_d,
6481 [COMPARE_ULE] = gen_helper_ule_d,
6483 TCGv_i32 zero = tcg_const_i32(0);
6484 TCGv_i32 res = tcg_temp_new_i32();
6485 TCGv_i32 set_br = tcg_temp_new_i32();
6486 TCGv_i32 clr_br = tcg_temp_new_i32();
6488 tcg_gen_ori_i32(set_br, arg[0].in, 1 << arg[0].imm);
6489 tcg_gen_andi_i32(clr_br, arg[0].in, ~(1 << arg[0].imm));
6491 helper[par[0]](res, cpu_env, arg[1].in, arg[2].in);
6492 tcg_gen_movcond_i32(TCG_COND_NE,
6493 arg[0].out, res, zero,
6494 set_br, clr_br);
6495 tcg_temp_free(zero);
6496 tcg_temp_free(res);
6497 tcg_temp_free(set_br);
6498 tcg_temp_free(clr_br);
6501 static void translate_compare_s(DisasContext *dc, const OpcodeArg arg[],
6502 const uint32_t par[])
6504 static void (* const helper[])(TCGv_i32 res, TCGv_env env,
6505 TCGv_i32 s, TCGv_i32 t) = {
6506 [COMPARE_UN] = gen_helper_un_s,
6507 [COMPARE_OEQ] = gen_helper_oeq_s,
6508 [COMPARE_UEQ] = gen_helper_ueq_s,
6509 [COMPARE_OLT] = gen_helper_olt_s,
6510 [COMPARE_ULT] = gen_helper_ult_s,
6511 [COMPARE_OLE] = gen_helper_ole_s,
6512 [COMPARE_ULE] = gen_helper_ule_s,
6514 OpcodeArg arg32[3];
6515 TCGv_i32 zero = tcg_const_i32(0);
6516 TCGv_i32 res = tcg_temp_new_i32();
6517 TCGv_i32 set_br = tcg_temp_new_i32();
6518 TCGv_i32 clr_br = tcg_temp_new_i32();
6520 tcg_gen_ori_i32(set_br, arg[0].in, 1 << arg[0].imm);
6521 tcg_gen_andi_i32(clr_br, arg[0].in, ~(1 << arg[0].imm));
6523 get_f32_i2(arg, arg32, 1, 2);
6524 helper[par[0]](res, cpu_env, arg32[1].in, arg32[2].in);
6525 tcg_gen_movcond_i32(TCG_COND_NE,
6526 arg[0].out, res, zero,
6527 set_br, clr_br);
6528 put_f32_i2(arg, arg32, 1, 2);
6529 tcg_temp_free(zero);
6530 tcg_temp_free(res);
6531 tcg_temp_free(set_br);
6532 tcg_temp_free(clr_br);
6535 static void translate_const_d(DisasContext *dc, const OpcodeArg arg[],
6536 const uint32_t par[])
6538 static const uint64_t v[] = {
6539 UINT64_C(0x0000000000000000),
6540 UINT64_C(0x3ff0000000000000),
6541 UINT64_C(0x4000000000000000),
6542 UINT64_C(0x3fe0000000000000),
6545 tcg_gen_movi_i64(arg[0].out, v[arg[1].imm % ARRAY_SIZE(v)]);
6546 if (arg[1].imm >= ARRAY_SIZE(v)) {
6547 qemu_log_mask(LOG_GUEST_ERROR,
6548 "const.d f%d, #%d, immediate value is reserved\n",
6549 arg[0].imm, arg[1].imm);
6553 static void translate_const_s(DisasContext *dc, const OpcodeArg arg[],
6554 const uint32_t par[])
6556 static const uint32_t v[] = {
6557 0x00000000,
6558 0x3f800000,
6559 0x40000000,
6560 0x3f000000,
6563 if (arg[0].num_bits == 32) {
6564 tcg_gen_movi_i32(arg[0].out, v[arg[1].imm % ARRAY_SIZE(v)]);
6565 } else {
6566 tcg_gen_movi_i64(arg[0].out, v[arg[1].imm % ARRAY_SIZE(v)]);
6568 if (arg[1].imm >= ARRAY_SIZE(v)) {
6569 qemu_log_mask(LOG_GUEST_ERROR,
6570 "const.s f%d, #%d, immediate value is reserved\n",
6571 arg[0].imm, arg[1].imm);
6575 static void translate_float_d(DisasContext *dc, const OpcodeArg arg[],
6576 const uint32_t par[])
6578 TCGv_i32 scale = tcg_const_i32(-arg[2].imm);
6580 if (par[0]) {
6581 gen_helper_uitof_d(arg[0].out, cpu_env, arg[1].in, scale);
6582 } else {
6583 gen_helper_itof_d(arg[0].out, cpu_env, arg[1].in, scale);
6585 tcg_temp_free(scale);
6588 static void translate_float_s(DisasContext *dc, const OpcodeArg arg[],
6589 const uint32_t par[])
6591 TCGv_i32 scale = tcg_const_i32(-arg[2].imm);
6592 OpcodeArg arg32[1];
6594 get_f32_o1(arg, arg32, 0);
6595 if (par[0]) {
6596 gen_helper_uitof_s(arg32[0].out, cpu_env, arg[1].in, scale);
6597 } else {
6598 gen_helper_itof_s(arg32[0].out, cpu_env, arg[1].in, scale);
6600 put_f32_o1(arg, arg32, 0);
6601 tcg_temp_free(scale);
6604 static void translate_ftoi_d(DisasContext *dc, const OpcodeArg arg[],
6605 const uint32_t par[])
6607 TCGv_i32 rounding_mode = tcg_const_i32(par[0]);
6608 TCGv_i32 scale = tcg_const_i32(arg[2].imm);
6610 if (par[1]) {
6611 gen_helper_ftoui_d(arg[0].out, cpu_env, arg[1].in,
6612 rounding_mode, scale);
6613 } else {
6614 gen_helper_ftoi_d(arg[0].out, cpu_env, arg[1].in,
6615 rounding_mode, scale);
6617 tcg_temp_free(rounding_mode);
6618 tcg_temp_free(scale);
6621 static void translate_ftoi_s(DisasContext *dc, const OpcodeArg arg[],
6622 const uint32_t par[])
6624 TCGv_i32 rounding_mode = tcg_const_i32(par[0]);
6625 TCGv_i32 scale = tcg_const_i32(arg[2].imm);
6626 OpcodeArg arg32[2];
6628 get_f32_i1(arg, arg32, 1);
6629 if (par[1]) {
6630 gen_helper_ftoui_s(arg[0].out, cpu_env, arg32[1].in,
6631 rounding_mode, scale);
6632 } else {
6633 gen_helper_ftoi_s(arg[0].out, cpu_env, arg32[1].in,
6634 rounding_mode, scale);
6636 put_f32_i1(arg, arg32, 1);
6637 tcg_temp_free(rounding_mode);
6638 tcg_temp_free(scale);
6641 static void translate_ldsti(DisasContext *dc, const OpcodeArg arg[],
6642 const uint32_t par[])
6644 TCGv_i32 addr = tcg_temp_new_i32();
6646 tcg_gen_addi_i32(addr, arg[1].in, arg[2].imm);
6647 gen_load_store_alignment(dc, 2, addr, false);
6648 if (par[0]) {
6649 tcg_gen_qemu_st32(arg[0].in, addr, dc->cring);
6650 } else {
6651 tcg_gen_qemu_ld32u(arg[0].out, addr, dc->cring);
6653 if (par[1]) {
6654 tcg_gen_mov_i32(arg[1].out, addr);
6656 tcg_temp_free(addr);
6659 static void translate_ldstx(DisasContext *dc, const OpcodeArg arg[],
6660 const uint32_t par[])
6662 TCGv_i32 addr = tcg_temp_new_i32();
6664 tcg_gen_add_i32(addr, arg[1].in, arg[2].in);
6665 gen_load_store_alignment(dc, 2, addr, false);
6666 if (par[0]) {
6667 tcg_gen_qemu_st32(arg[0].in, addr, dc->cring);
6668 } else {
6669 tcg_gen_qemu_ld32u(arg[0].out, addr, dc->cring);
6671 if (par[1]) {
6672 tcg_gen_mov_i32(arg[1].out, addr);
6674 tcg_temp_free(addr);
6677 static void translate_fpu2k_madd_s(DisasContext *dc, const OpcodeArg arg[],
6678 const uint32_t par[])
6680 gen_helper_fpu2k_madd_s(arg[0].out, cpu_env,
6681 arg[0].in, arg[1].in, arg[2].in);
6684 static void translate_mov_d(DisasContext *dc, const OpcodeArg arg[],
6685 const uint32_t par[])
6687 tcg_gen_mov_i64(arg[0].out, arg[1].in);
6690 static void translate_mov_s(DisasContext *dc, const OpcodeArg arg[],
6691 const uint32_t par[])
6693 if (arg[0].num_bits == 32) {
6694 tcg_gen_mov_i32(arg[0].out, arg[1].in);
6695 } else {
6696 tcg_gen_mov_i64(arg[0].out, arg[1].in);
6700 static void translate_movcond_d(DisasContext *dc, const OpcodeArg arg[],
6701 const uint32_t par[])
6703 TCGv_i64 zero = tcg_const_i64(0);
6704 TCGv_i64 arg2 = tcg_temp_new_i64();
6706 tcg_gen_ext_i32_i64(arg2, arg[2].in);
6707 tcg_gen_movcond_i64(par[0], arg[0].out,
6708 arg2, zero,
6709 arg[1].in, arg[0].in);
6710 tcg_temp_free_i64(zero);
6711 tcg_temp_free_i64(arg2);
6714 static void translate_movcond_s(DisasContext *dc, const OpcodeArg arg[],
6715 const uint32_t par[])
6717 if (arg[0].num_bits == 32) {
6718 TCGv_i32 zero = tcg_const_i32(0);
6720 tcg_gen_movcond_i32(par[0], arg[0].out,
6721 arg[2].in, zero,
6722 arg[1].in, arg[0].in);
6723 tcg_temp_free(zero);
6724 } else {
6725 translate_movcond_d(dc, arg, par);
6729 static void translate_movp_d(DisasContext *dc, const OpcodeArg arg[],
6730 const uint32_t par[])
6732 TCGv_i64 zero = tcg_const_i64(0);
6733 TCGv_i32 tmp1 = tcg_temp_new_i32();
6734 TCGv_i64 tmp2 = tcg_temp_new_i64();
6736 tcg_gen_andi_i32(tmp1, arg[2].in, 1 << arg[2].imm);
6737 tcg_gen_extu_i32_i64(tmp2, tmp1);
6738 tcg_gen_movcond_i64(par[0],
6739 arg[0].out, tmp2, zero,
6740 arg[1].in, arg[0].in);
6741 tcg_temp_free_i64(zero);
6742 tcg_temp_free_i32(tmp1);
6743 tcg_temp_free_i64(tmp2);
6746 static void translate_movp_s(DisasContext *dc, const OpcodeArg arg[],
6747 const uint32_t par[])
6749 if (arg[0].num_bits == 32) {
6750 TCGv_i32 zero = tcg_const_i32(0);
6751 TCGv_i32 tmp = tcg_temp_new_i32();
6753 tcg_gen_andi_i32(tmp, arg[2].in, 1 << arg[2].imm);
6754 tcg_gen_movcond_i32(par[0],
6755 arg[0].out, tmp, zero,
6756 arg[1].in, arg[0].in);
6757 tcg_temp_free(tmp);
6758 tcg_temp_free(zero);
6759 } else {
6760 translate_movp_d(dc, arg, par);
6764 static void translate_fpu2k_mul_s(DisasContext *dc, const OpcodeArg arg[],
6765 const uint32_t par[])
6767 gen_helper_fpu2k_mul_s(arg[0].out, cpu_env,
6768 arg[1].in, arg[2].in);
6771 static void translate_fpu2k_msub_s(DisasContext *dc, const OpcodeArg arg[],
6772 const uint32_t par[])
6774 gen_helper_fpu2k_msub_s(arg[0].out, cpu_env,
6775 arg[0].in, arg[1].in, arg[2].in);
6778 static void translate_neg_d(DisasContext *dc, const OpcodeArg arg[],
6779 const uint32_t par[])
6781 gen_helper_neg_d(arg[0].out, arg[1].in);
6784 static void translate_neg_s(DisasContext *dc, const OpcodeArg arg[],
6785 const uint32_t par[])
6787 OpcodeArg arg32[2];
6789 get_f32_o1_i1(arg, arg32, 0, 1);
6790 gen_helper_neg_s(arg32[0].out, arg32[1].in);
6791 put_f32_o1_i1(arg, arg32, 0, 1);
6794 static void translate_rfr_d(DisasContext *dc, const OpcodeArg arg[],
6795 const uint32_t par[])
6797 tcg_gen_extrh_i64_i32(arg[0].out, arg[1].in);
6800 static void translate_rfr_s(DisasContext *dc, const OpcodeArg arg[],
6801 const uint32_t par[])
6803 if (arg[1].num_bits == 32) {
6804 tcg_gen_mov_i32(arg[0].out, arg[1].in);
6805 } else {
6806 tcg_gen_extrl_i64_i32(arg[0].out, arg[1].in);
6810 static void translate_fpu2k_sub_s(DisasContext *dc, const OpcodeArg arg[],
6811 const uint32_t par[])
6813 gen_helper_fpu2k_sub_s(arg[0].out, cpu_env,
6814 arg[1].in, arg[2].in);
6817 static void translate_wfr_d(DisasContext *dc, const OpcodeArg arg[],
6818 const uint32_t par[])
6820 tcg_gen_concat_i32_i64(arg[0].out, arg[2].in, arg[1].in);
6823 static void translate_wfr_s(DisasContext *dc, const OpcodeArg arg[],
6824 const uint32_t par[])
6826 if (arg[0].num_bits == 32) {
6827 tcg_gen_mov_i32(arg[0].out, arg[1].in);
6828 } else {
6829 tcg_gen_ext_i32_i64(arg[0].out, arg[1].in);
6833 static void translate_wur_fpu2k_fcr(DisasContext *dc, const OpcodeArg arg[],
6834 const uint32_t par[])
6836 gen_helper_wur_fpu2k_fcr(cpu_env, arg[0].in);
6839 static void translate_wur_fpu2k_fsr(DisasContext *dc, const OpcodeArg arg[],
6840 const uint32_t par[])
6842 tcg_gen_andi_i32(cpu_UR[par[0]], arg[0].in, 0xffffff80);
6845 static const XtensaOpcodeOps fpu2000_ops[] = {
6847 .name = "abs.s",
6848 .translate = translate_abs_s,
6849 .coprocessor = 0x1,
6850 }, {
6851 .name = "add.s",
6852 .translate = translate_fpu2k_add_s,
6853 .coprocessor = 0x1,
6854 }, {
6855 .name = "ceil.s",
6856 .translate = translate_ftoi_s,
6857 .par = (const uint32_t[]){float_round_up, false},
6858 .coprocessor = 0x1,
6859 }, {
6860 .name = "float.s",
6861 .translate = translate_float_s,
6862 .par = (const uint32_t[]){false},
6863 .coprocessor = 0x1,
6864 }, {
6865 .name = "floor.s",
6866 .translate = translate_ftoi_s,
6867 .par = (const uint32_t[]){float_round_down, false},
6868 .coprocessor = 0x1,
6869 }, {
6870 .name = "lsi",
6871 .translate = translate_ldsti,
6872 .par = (const uint32_t[]){false, false},
6873 .op_flags = XTENSA_OP_LOAD,
6874 .coprocessor = 0x1,
6875 }, {
6876 .name = "lsiu",
6877 .translate = translate_ldsti,
6878 .par = (const uint32_t[]){false, true},
6879 .op_flags = XTENSA_OP_LOAD,
6880 .coprocessor = 0x1,
6881 }, {
6882 .name = "lsx",
6883 .translate = translate_ldstx,
6884 .par = (const uint32_t[]){false, false},
6885 .op_flags = XTENSA_OP_LOAD,
6886 .coprocessor = 0x1,
6887 }, {
6888 .name = "lsxu",
6889 .translate = translate_ldstx,
6890 .par = (const uint32_t[]){false, true},
6891 .op_flags = XTENSA_OP_LOAD,
6892 .coprocessor = 0x1,
6893 }, {
6894 .name = "madd.s",
6895 .translate = translate_fpu2k_madd_s,
6896 .coprocessor = 0x1,
6897 }, {
6898 .name = "mov.s",
6899 .translate = translate_mov_s,
6900 .coprocessor = 0x1,
6901 }, {
6902 .name = "moveqz.s",
6903 .translate = translate_movcond_s,
6904 .par = (const uint32_t[]){TCG_COND_EQ},
6905 .coprocessor = 0x1,
6906 }, {
6907 .name = "movf.s",
6908 .translate = translate_movp_s,
6909 .par = (const uint32_t[]){TCG_COND_EQ},
6910 .coprocessor = 0x1,
6911 }, {
6912 .name = "movgez.s",
6913 .translate = translate_movcond_s,
6914 .par = (const uint32_t[]){TCG_COND_GE},
6915 .coprocessor = 0x1,
6916 }, {
6917 .name = "movltz.s",
6918 .translate = translate_movcond_s,
6919 .par = (const uint32_t[]){TCG_COND_LT},
6920 .coprocessor = 0x1,
6921 }, {
6922 .name = "movnez.s",
6923 .translate = translate_movcond_s,
6924 .par = (const uint32_t[]){TCG_COND_NE},
6925 .coprocessor = 0x1,
6926 }, {
6927 .name = "movt.s",
6928 .translate = translate_movp_s,
6929 .par = (const uint32_t[]){TCG_COND_NE},
6930 .coprocessor = 0x1,
6931 }, {
6932 .name = "msub.s",
6933 .translate = translate_fpu2k_msub_s,
6934 .coprocessor = 0x1,
6935 }, {
6936 .name = "mul.s",
6937 .translate = translate_fpu2k_mul_s,
6938 .coprocessor = 0x1,
6939 }, {
6940 .name = "neg.s",
6941 .translate = translate_neg_s,
6942 .coprocessor = 0x1,
6943 }, {
6944 .name = "oeq.s",
6945 .translate = translate_compare_s,
6946 .par = (const uint32_t[]){COMPARE_OEQ},
6947 .coprocessor = 0x1,
6948 }, {
6949 .name = "ole.s",
6950 .translate = translate_compare_s,
6951 .par = (const uint32_t[]){COMPARE_OLE},
6952 .coprocessor = 0x1,
6953 }, {
6954 .name = "olt.s",
6955 .translate = translate_compare_s,
6956 .par = (const uint32_t[]){COMPARE_OLT},
6957 .coprocessor = 0x1,
6958 }, {
6959 .name = "rfr",
6960 .translate = translate_rfr_s,
6961 .coprocessor = 0x1,
6962 }, {
6963 .name = "round.s",
6964 .translate = translate_ftoi_s,
6965 .par = (const uint32_t[]){float_round_nearest_even, false},
6966 .coprocessor = 0x1,
6967 }, {
6968 .name = "rur.fcr",
6969 .translate = translate_rur,
6970 .par = (const uint32_t[]){FCR},
6971 .coprocessor = 0x1,
6972 }, {
6973 .name = "rur.fsr",
6974 .translate = translate_rur,
6975 .par = (const uint32_t[]){FSR},
6976 .coprocessor = 0x1,
6977 }, {
6978 .name = "ssi",
6979 .translate = translate_ldsti,
6980 .par = (const uint32_t[]){true, false},
6981 .op_flags = XTENSA_OP_STORE,
6982 .coprocessor = 0x1,
6983 }, {
6984 .name = "ssiu",
6985 .translate = translate_ldsti,
6986 .par = (const uint32_t[]){true, true},
6987 .op_flags = XTENSA_OP_STORE,
6988 .coprocessor = 0x1,
6989 }, {
6990 .name = "ssx",
6991 .translate = translate_ldstx,
6992 .par = (const uint32_t[]){true, false},
6993 .op_flags = XTENSA_OP_STORE,
6994 .coprocessor = 0x1,
6995 }, {
6996 .name = "ssxu",
6997 .translate = translate_ldstx,
6998 .par = (const uint32_t[]){true, true},
6999 .op_flags = XTENSA_OP_STORE,
7000 .coprocessor = 0x1,
7001 }, {
7002 .name = "sub.s",
7003 .translate = translate_fpu2k_sub_s,
7004 .coprocessor = 0x1,
7005 }, {
7006 .name = "trunc.s",
7007 .translate = translate_ftoi_s,
7008 .par = (const uint32_t[]){float_round_to_zero, false},
7009 .coprocessor = 0x1,
7010 }, {
7011 .name = "ueq.s",
7012 .translate = translate_compare_s,
7013 .par = (const uint32_t[]){COMPARE_UEQ},
7014 .coprocessor = 0x1,
7015 }, {
7016 .name = "ufloat.s",
7017 .translate = translate_float_s,
7018 .par = (const uint32_t[]){true},
7019 .coprocessor = 0x1,
7020 }, {
7021 .name = "ule.s",
7022 .translate = translate_compare_s,
7023 .par = (const uint32_t[]){COMPARE_ULE},
7024 .coprocessor = 0x1,
7025 }, {
7026 .name = "ult.s",
7027 .translate = translate_compare_s,
7028 .par = (const uint32_t[]){COMPARE_ULT},
7029 .coprocessor = 0x1,
7030 }, {
7031 .name = "un.s",
7032 .translate = translate_compare_s,
7033 .par = (const uint32_t[]){COMPARE_UN},
7034 .coprocessor = 0x1,
7035 }, {
7036 .name = "utrunc.s",
7037 .translate = translate_ftoi_s,
7038 .par = (const uint32_t[]){float_round_to_zero, true},
7039 .coprocessor = 0x1,
7040 }, {
7041 .name = "wfr",
7042 .translate = translate_wfr_s,
7043 .coprocessor = 0x1,
7044 }, {
7045 .name = "wur.fcr",
7046 .translate = translate_wur_fpu2k_fcr,
7047 .par = (const uint32_t[]){FCR},
7048 .coprocessor = 0x1,
7049 }, {
7050 .name = "wur.fsr",
7051 .translate = translate_wur_fpu2k_fsr,
7052 .par = (const uint32_t[]){FSR},
7053 .coprocessor = 0x1,
7057 const XtensaOpcodeTranslators xtensa_fpu2000_opcodes = {
7058 .num_opcodes = ARRAY_SIZE(fpu2000_ops),
7059 .opcode = fpu2000_ops,
7062 static void translate_add_d(DisasContext *dc, const OpcodeArg arg[],
7063 const uint32_t par[])
7065 gen_helper_add_d(arg[0].out, cpu_env, arg[1].in, arg[2].in);
7068 static void translate_add_s(DisasContext *dc, const OpcodeArg arg[],
7069 const uint32_t par[])
7071 if (option_enabled(dc, XTENSA_OPTION_DFPU_SINGLE_ONLY)) {
7072 gen_helper_fpu2k_add_s(arg[0].out, cpu_env,
7073 arg[1].in, arg[2].in);
7074 } else {
7075 OpcodeArg arg32[3];
7077 get_f32_o1_i2(arg, arg32, 0, 1, 2);
7078 gen_helper_add_s(arg32[0].out, cpu_env, arg32[1].in, arg32[2].in);
7079 put_f32_o1_i2(arg, arg32, 0, 1, 2);
7083 static void translate_cvtd_s(DisasContext *dc, const OpcodeArg arg[],
7084 const uint32_t par[])
7086 TCGv_i32 v = tcg_temp_new_i32();
7088 tcg_gen_extrl_i64_i32(v, arg[1].in);
7089 gen_helper_cvtd_s(arg[0].out, cpu_env, v);
7090 tcg_temp_free_i32(v);
7093 static void translate_cvts_d(DisasContext *dc, const OpcodeArg arg[],
7094 const uint32_t par[])
7096 TCGv_i32 v = tcg_temp_new_i32();
7098 gen_helper_cvts_d(v, cpu_env, arg[1].in);
7099 tcg_gen_extu_i32_i64(arg[0].out, v);
7100 tcg_temp_free_i32(v);
7103 static void translate_ldsti_d(DisasContext *dc, const OpcodeArg arg[],
7104 const uint32_t par[])
7106 TCGv_i32 addr;
7108 if (par[1]) {
7109 addr = tcg_temp_new_i32();
7110 tcg_gen_addi_i32(addr, arg[1].in, arg[2].imm);
7111 } else {
7112 addr = arg[1].in;
7114 gen_load_store_alignment(dc, 3, addr, false);
7115 if (par[0]) {
7116 tcg_gen_qemu_st64(arg[0].in, addr, dc->cring);
7117 } else {
7118 tcg_gen_qemu_ld64(arg[0].out, addr, dc->cring);
7120 if (par[2]) {
7121 if (par[1]) {
7122 tcg_gen_mov_i32(arg[1].out, addr);
7123 } else {
7124 tcg_gen_addi_i32(arg[1].out, arg[1].in, arg[2].imm);
7127 if (par[1]) {
7128 tcg_temp_free(addr);
7132 static void translate_ldsti_s(DisasContext *dc, const OpcodeArg arg[],
7133 const uint32_t par[])
7135 TCGv_i32 addr;
7136 OpcodeArg arg32[1];
7138 if (par[1]) {
7139 addr = tcg_temp_new_i32();
7140 tcg_gen_addi_i32(addr, arg[1].in, arg[2].imm);
7141 } else {
7142 addr = arg[1].in;
7144 gen_load_store_alignment(dc, 2, addr, false);
7145 if (par[0]) {
7146 get_f32_i1(arg, arg32, 0);
7147 tcg_gen_qemu_st32(arg32[0].in, addr, dc->cring);
7148 put_f32_i1(arg, arg32, 0);
7149 } else {
7150 get_f32_o1(arg, arg32, 0);
7151 tcg_gen_qemu_ld32u(arg32[0].out, addr, dc->cring);
7152 put_f32_o1(arg, arg32, 0);
7154 if (par[2]) {
7155 if (par[1]) {
7156 tcg_gen_mov_i32(arg[1].out, addr);
7157 } else {
7158 tcg_gen_addi_i32(arg[1].out, arg[1].in, arg[2].imm);
7161 if (par[1]) {
7162 tcg_temp_free(addr);
7166 static void translate_ldstx_d(DisasContext *dc, const OpcodeArg arg[],
7167 const uint32_t par[])
7169 TCGv_i32 addr;
7171 if (par[1]) {
7172 addr = tcg_temp_new_i32();
7173 tcg_gen_add_i32(addr, arg[1].in, arg[2].in);
7174 } else {
7175 addr = arg[1].in;
7177 gen_load_store_alignment(dc, 3, addr, false);
7178 if (par[0]) {
7179 tcg_gen_qemu_st64(arg[0].in, addr, dc->cring);
7180 } else {
7181 tcg_gen_qemu_ld64(arg[0].out, addr, dc->cring);
7183 if (par[2]) {
7184 if (par[1]) {
7185 tcg_gen_mov_i32(arg[1].out, addr);
7186 } else {
7187 tcg_gen_add_i32(arg[1].out, arg[1].in, arg[2].in);
7190 if (par[1]) {
7191 tcg_temp_free(addr);
7195 static void translate_ldstx_s(DisasContext *dc, const OpcodeArg arg[],
7196 const uint32_t par[])
7198 TCGv_i32 addr;
7199 OpcodeArg arg32[1];
7201 if (par[1]) {
7202 addr = tcg_temp_new_i32();
7203 tcg_gen_add_i32(addr, arg[1].in, arg[2].in);
7204 } else {
7205 addr = arg[1].in;
7207 gen_load_store_alignment(dc, 2, addr, false);
7208 if (par[0]) {
7209 get_f32_i1(arg, arg32, 0);
7210 tcg_gen_qemu_st32(arg32[0].in, addr, dc->cring);
7211 put_f32_i1(arg, arg32, 0);
7212 } else {
7213 get_f32_o1(arg, arg32, 0);
7214 tcg_gen_qemu_ld32u(arg32[0].out, addr, dc->cring);
7215 put_f32_o1(arg, arg32, 0);
7217 if (par[2]) {
7218 if (par[1]) {
7219 tcg_gen_mov_i32(arg[1].out, addr);
7220 } else {
7221 tcg_gen_add_i32(arg[1].out, arg[1].in, arg[2].in);
7224 if (par[1]) {
7225 tcg_temp_free(addr);
7229 static void translate_madd_d(DisasContext *dc, const OpcodeArg arg[],
7230 const uint32_t par[])
7232 gen_helper_madd_d(arg[0].out, cpu_env,
7233 arg[0].in, arg[1].in, arg[2].in);
7236 static void translate_madd_s(DisasContext *dc, const OpcodeArg arg[],
7237 const uint32_t par[])
7239 if (option_enabled(dc, XTENSA_OPTION_DFPU_SINGLE_ONLY)) {
7240 gen_helper_fpu2k_madd_s(arg[0].out, cpu_env,
7241 arg[0].in, arg[1].in, arg[2].in);
7242 } else {
7243 OpcodeArg arg32[3];
7245 get_f32_o1_i3(arg, arg32, 0, 0, 1, 2);
7246 gen_helper_madd_s(arg32[0].out, cpu_env,
7247 arg32[0].in, arg32[1].in, arg32[2].in);
7248 put_f32_o1_i3(arg, arg32, 0, 0, 1, 2);
7252 static void translate_mul_d(DisasContext *dc, const OpcodeArg arg[],
7253 const uint32_t par[])
7255 gen_helper_mul_d(arg[0].out, cpu_env, arg[1].in, arg[2].in);
7258 static void translate_mul_s(DisasContext *dc, const OpcodeArg arg[],
7259 const uint32_t par[])
7261 if (option_enabled(dc, XTENSA_OPTION_DFPU_SINGLE_ONLY)) {
7262 gen_helper_fpu2k_mul_s(arg[0].out, cpu_env,
7263 arg[1].in, arg[2].in);
7264 } else {
7265 OpcodeArg arg32[3];
7267 get_f32_o1_i2(arg, arg32, 0, 1, 2);
7268 gen_helper_mul_s(arg32[0].out, cpu_env, arg32[1].in, arg32[2].in);
7269 put_f32_o1_i2(arg, arg32, 0, 1, 2);
7273 static void translate_msub_d(DisasContext *dc, const OpcodeArg arg[],
7274 const uint32_t par[])
7276 gen_helper_msub_d(arg[0].out, cpu_env,
7277 arg[0].in, arg[1].in, arg[2].in);
7280 static void translate_msub_s(DisasContext *dc, const OpcodeArg arg[],
7281 const uint32_t par[])
7283 if (option_enabled(dc, XTENSA_OPTION_DFPU_SINGLE_ONLY)) {
7284 gen_helper_fpu2k_msub_s(arg[0].out, cpu_env,
7285 arg[0].in, arg[1].in, arg[2].in);
7286 } else {
7287 OpcodeArg arg32[3];
7289 get_f32_o1_i3(arg, arg32, 0, 0, 1, 2);
7290 gen_helper_msub_s(arg32[0].out, cpu_env,
7291 arg32[0].in, arg32[1].in, arg32[2].in);
7292 put_f32_o1_i3(arg, arg32, 0, 0, 1, 2);
7296 static void translate_sub_d(DisasContext *dc, const OpcodeArg arg[],
7297 const uint32_t par[])
7299 gen_helper_sub_d(arg[0].out, cpu_env, arg[1].in, arg[2].in);
7302 static void translate_sub_s(DisasContext *dc, const OpcodeArg arg[],
7303 const uint32_t par[])
7305 if (option_enabled(dc, XTENSA_OPTION_DFPU_SINGLE_ONLY)) {
7306 gen_helper_fpu2k_sub_s(arg[0].out, cpu_env,
7307 arg[1].in, arg[2].in);
7308 } else {
7309 OpcodeArg arg32[3];
7311 get_f32_o1_i2(arg, arg32, 0, 1, 2);
7312 gen_helper_sub_s(arg32[0].out, cpu_env, arg32[1].in, arg32[2].in);
7313 put_f32_o1_i2(arg, arg32, 0, 1, 2);
7317 static void translate_mkdadj_d(DisasContext *dc, const OpcodeArg arg[],
7318 const uint32_t par[])
7320 gen_helper_mkdadj_d(arg[0].out, cpu_env, arg[0].in, arg[1].in);
7323 static void translate_mkdadj_s(DisasContext *dc, const OpcodeArg arg[],
7324 const uint32_t par[])
7326 OpcodeArg arg32[2];
7328 get_f32_o1_i2(arg, arg32, 0, 0, 1);
7329 gen_helper_mkdadj_s(arg32[0].out, cpu_env, arg32[0].in, arg32[1].in);
7330 put_f32_o1_i2(arg, arg32, 0, 0, 1);
7333 static void translate_mksadj_d(DisasContext *dc, const OpcodeArg arg[],
7334 const uint32_t par[])
7336 gen_helper_mksadj_d(arg[0].out, cpu_env, arg[1].in);
7339 static void translate_mksadj_s(DisasContext *dc, const OpcodeArg arg[],
7340 const uint32_t par[])
7342 OpcodeArg arg32[2];
7344 get_f32_o1_i1(arg, arg32, 0, 1);
7345 gen_helper_mksadj_s(arg32[0].out, cpu_env, arg32[1].in);
7346 put_f32_o1_i1(arg, arg32, 0, 1);
7349 static void translate_wur_fpu_fcr(DisasContext *dc, const OpcodeArg arg[],
7350 const uint32_t par[])
7352 gen_helper_wur_fpu_fcr(cpu_env, arg[0].in);
7355 static void translate_rur_fpu_fsr(DisasContext *dc, const OpcodeArg arg[],
7356 const uint32_t par[])
7358 gen_helper_rur_fpu_fsr(arg[0].out, cpu_env);
7361 static void translate_wur_fpu_fsr(DisasContext *dc, const OpcodeArg arg[],
7362 const uint32_t par[])
7364 gen_helper_wur_fpu_fsr(cpu_env, arg[0].in);
7367 static const XtensaOpcodeOps fpu_ops[] = {
7369 .name = "abs.d",
7370 .translate = translate_abs_d,
7371 .coprocessor = 0x1,
7372 }, {
7373 .name = "abs.s",
7374 .translate = translate_abs_s,
7375 .coprocessor = 0x1,
7376 }, {
7377 .name = "add.d",
7378 .translate = translate_add_d,
7379 .coprocessor = 0x1,
7380 }, {
7381 .name = "add.s",
7382 .translate = translate_add_s,
7383 .coprocessor = 0x1,
7384 }, {
7385 .name = "addexp.d",
7386 .translate = translate_nop,
7387 .coprocessor = 0x1,
7388 }, {
7389 .name = "addexp.s",
7390 .translate = translate_nop,
7391 .coprocessor = 0x1,
7392 }, {
7393 .name = "addexpm.d",
7394 .translate = translate_mov_s,
7395 .coprocessor = 0x1,
7396 }, {
7397 .name = "addexpm.s",
7398 .translate = translate_mov_s,
7399 .coprocessor = 0x1,
7400 }, {
7401 .name = "ceil.d",
7402 .translate = translate_ftoi_d,
7403 .par = (const uint32_t[]){float_round_up, false},
7404 .coprocessor = 0x1,
7405 }, {
7406 .name = "ceil.s",
7407 .translate = translate_ftoi_s,
7408 .par = (const uint32_t[]){float_round_up, false},
7409 .coprocessor = 0x1,
7410 }, {
7411 .name = "const.d",
7412 .translate = translate_const_d,
7413 .coprocessor = 0x1,
7414 }, {
7415 .name = "const.s",
7416 .translate = translate_const_s,
7417 .coprocessor = 0x1,
7418 }, {
7419 .name = "cvtd.s",
7420 .translate = translate_cvtd_s,
7421 .coprocessor = 0x1,
7422 }, {
7423 .name = "cvts.d",
7424 .translate = translate_cvts_d,
7425 .coprocessor = 0x1,
7426 }, {
7427 .name = "div0.d",
7428 .translate = translate_nop,
7429 .coprocessor = 0x1,
7430 }, {
7431 .name = "div0.s",
7432 .translate = translate_nop,
7433 .coprocessor = 0x1,
7434 }, {
7435 .name = "divn.d",
7436 .translate = translate_nop,
7437 .coprocessor = 0x1,
7438 }, {
7439 .name = "divn.s",
7440 .translate = translate_nop,
7441 .coprocessor = 0x1,
7442 }, {
7443 .name = "float.d",
7444 .translate = translate_float_d,
7445 .par = (const uint32_t[]){false},
7446 .coprocessor = 0x1,
7447 }, {
7448 .name = "float.s",
7449 .translate = translate_float_s,
7450 .par = (const uint32_t[]){false},
7451 .coprocessor = 0x1,
7452 }, {
7453 .name = "floor.d",
7454 .translate = translate_ftoi_d,
7455 .par = (const uint32_t[]){float_round_down, false},
7456 .coprocessor = 0x1,
7457 }, {
7458 .name = "floor.s",
7459 .translate = translate_ftoi_s,
7460 .par = (const uint32_t[]){float_round_down, false},
7461 .coprocessor = 0x1,
7462 }, {
7463 .name = "ldi",
7464 .translate = translate_ldsti_d,
7465 .par = (const uint32_t[]){false, true, false},
7466 .op_flags = XTENSA_OP_LOAD,
7467 .coprocessor = 0x1,
7468 }, {
7469 .name = "ldip",
7470 .translate = translate_ldsti_d,
7471 .par = (const uint32_t[]){false, false, true},
7472 .op_flags = XTENSA_OP_LOAD,
7473 .coprocessor = 0x1,
7474 }, {
7475 .name = "ldiu",
7476 .translate = translate_ldsti_d,
7477 .par = (const uint32_t[]){false, true, true},
7478 .op_flags = XTENSA_OP_LOAD,
7479 .coprocessor = 0x1,
7480 }, {
7481 .name = "ldx",
7482 .translate = translate_ldstx_d,
7483 .par = (const uint32_t[]){false, true, false},
7484 .op_flags = XTENSA_OP_LOAD,
7485 .coprocessor = 0x1,
7486 }, {
7487 .name = "ldxp",
7488 .translate = translate_ldstx_d,
7489 .par = (const uint32_t[]){false, false, true},
7490 .op_flags = XTENSA_OP_LOAD,
7491 .coprocessor = 0x1,
7492 }, {
7493 .name = "ldxu",
7494 .translate = translate_ldstx_d,
7495 .par = (const uint32_t[]){false, true, true},
7496 .op_flags = XTENSA_OP_LOAD,
7497 .coprocessor = 0x1,
7498 }, {
7499 .name = "lsi",
7500 .translate = translate_ldsti_s,
7501 .par = (const uint32_t[]){false, true, false},
7502 .op_flags = XTENSA_OP_LOAD,
7503 .coprocessor = 0x1,
7504 }, {
7505 .name = "lsip",
7506 .translate = translate_ldsti_s,
7507 .par = (const uint32_t[]){false, false, true},
7508 .op_flags = XTENSA_OP_LOAD,
7509 .coprocessor = 0x1,
7510 }, {
7511 .name = "lsiu",
7512 .translate = translate_ldsti_s,
7513 .par = (const uint32_t[]){false, true, true},
7514 .op_flags = XTENSA_OP_LOAD,
7515 .coprocessor = 0x1,
7516 }, {
7517 .name = "lsx",
7518 .translate = translate_ldstx_s,
7519 .par = (const uint32_t[]){false, true, false},
7520 .op_flags = XTENSA_OP_LOAD,
7521 .coprocessor = 0x1,
7522 }, {
7523 .name = "lsxp",
7524 .translate = translate_ldstx_s,
7525 .par = (const uint32_t[]){false, false, true},
7526 .op_flags = XTENSA_OP_LOAD,
7527 .coprocessor = 0x1,
7528 }, {
7529 .name = "lsxu",
7530 .translate = translate_ldstx_s,
7531 .par = (const uint32_t[]){false, true, true},
7532 .op_flags = XTENSA_OP_LOAD,
7533 .coprocessor = 0x1,
7534 }, {
7535 .name = "madd.d",
7536 .translate = translate_madd_d,
7537 .coprocessor = 0x1,
7538 }, {
7539 .name = "madd.s",
7540 .translate = translate_madd_s,
7541 .coprocessor = 0x1,
7542 }, {
7543 .name = "maddn.d",
7544 .translate = translate_nop,
7545 .coprocessor = 0x1,
7546 }, {
7547 .name = "maddn.s",
7548 .translate = translate_nop,
7549 .coprocessor = 0x1,
7550 }, {
7551 .name = "mkdadj.d",
7552 .translate = translate_mkdadj_d,
7553 .coprocessor = 0x1,
7554 }, {
7555 .name = "mkdadj.s",
7556 .translate = translate_mkdadj_s,
7557 .coprocessor = 0x1,
7558 }, {
7559 .name = "mksadj.d",
7560 .translate = translate_mksadj_d,
7561 .coprocessor = 0x1,
7562 }, {
7563 .name = "mksadj.s",
7564 .translate = translate_mksadj_s,
7565 .coprocessor = 0x1,
7566 }, {
7567 .name = "mov.d",
7568 .translate = translate_mov_d,
7569 .coprocessor = 0x1,
7570 }, {
7571 .name = "mov.s",
7572 .translate = translate_mov_s,
7573 .coprocessor = 0x1,
7574 }, {
7575 .name = "moveqz.d",
7576 .translate = translate_movcond_d,
7577 .par = (const uint32_t[]){TCG_COND_EQ},
7578 .coprocessor = 0x1,
7579 }, {
7580 .name = "moveqz.s",
7581 .translate = translate_movcond_s,
7582 .par = (const uint32_t[]){TCG_COND_EQ},
7583 .coprocessor = 0x1,
7584 }, {
7585 .name = "movf.d",
7586 .translate = translate_movp_d,
7587 .par = (const uint32_t[]){TCG_COND_EQ},
7588 .coprocessor = 0x1,
7589 }, {
7590 .name = "movf.s",
7591 .translate = translate_movp_s,
7592 .par = (const uint32_t[]){TCG_COND_EQ},
7593 .coprocessor = 0x1,
7594 }, {
7595 .name = "movgez.d",
7596 .translate = translate_movcond_d,
7597 .par = (const uint32_t[]){TCG_COND_GE},
7598 .coprocessor = 0x1,
7599 }, {
7600 .name = "movgez.s",
7601 .translate = translate_movcond_s,
7602 .par = (const uint32_t[]){TCG_COND_GE},
7603 .coprocessor = 0x1,
7604 }, {
7605 .name = "movltz.d",
7606 .translate = translate_movcond_d,
7607 .par = (const uint32_t[]){TCG_COND_LT},
7608 .coprocessor = 0x1,
7609 }, {
7610 .name = "movltz.s",
7611 .translate = translate_movcond_s,
7612 .par = (const uint32_t[]){TCG_COND_LT},
7613 .coprocessor = 0x1,
7614 }, {
7615 .name = "movnez.d",
7616 .translate = translate_movcond_d,
7617 .par = (const uint32_t[]){TCG_COND_NE},
7618 .coprocessor = 0x1,
7619 }, {
7620 .name = "movnez.s",
7621 .translate = translate_movcond_s,
7622 .par = (const uint32_t[]){TCG_COND_NE},
7623 .coprocessor = 0x1,
7624 }, {
7625 .name = "movt.d",
7626 .translate = translate_movp_d,
7627 .par = (const uint32_t[]){TCG_COND_NE},
7628 .coprocessor = 0x1,
7629 }, {
7630 .name = "movt.s",
7631 .translate = translate_movp_s,
7632 .par = (const uint32_t[]){TCG_COND_NE},
7633 .coprocessor = 0x1,
7634 }, {
7635 .name = "msub.d",
7636 .translate = translate_msub_d,
7637 .coprocessor = 0x1,
7638 }, {
7639 .name = "msub.s",
7640 .translate = translate_msub_s,
7641 .coprocessor = 0x1,
7642 }, {
7643 .name = "mul.d",
7644 .translate = translate_mul_d,
7645 .coprocessor = 0x1,
7646 }, {
7647 .name = "mul.s",
7648 .translate = translate_mul_s,
7649 .coprocessor = 0x1,
7650 }, {
7651 .name = "neg.d",
7652 .translate = translate_neg_d,
7653 .coprocessor = 0x1,
7654 }, {
7655 .name = "neg.s",
7656 .translate = translate_neg_s,
7657 .coprocessor = 0x1,
7658 }, {
7659 .name = "nexp01.d",
7660 .translate = translate_nop,
7661 .coprocessor = 0x1,
7662 }, {
7663 .name = "nexp01.s",
7664 .translate = translate_nop,
7665 .coprocessor = 0x1,
7666 }, {
7667 .name = "oeq.d",
7668 .translate = translate_compare_d,
7669 .par = (const uint32_t[]){COMPARE_OEQ},
7670 .coprocessor = 0x1,
7671 }, {
7672 .name = "oeq.s",
7673 .translate = translate_compare_s,
7674 .par = (const uint32_t[]){COMPARE_OEQ},
7675 .coprocessor = 0x1,
7676 }, {
7677 .name = "ole.d",
7678 .translate = translate_compare_d,
7679 .par = (const uint32_t[]){COMPARE_OLE},
7680 .coprocessor = 0x1,
7681 }, {
7682 .name = "ole.s",
7683 .translate = translate_compare_s,
7684 .par = (const uint32_t[]){COMPARE_OLE},
7685 .coprocessor = 0x1,
7686 }, {
7687 .name = "olt.d",
7688 .translate = translate_compare_d,
7689 .par = (const uint32_t[]){COMPARE_OLT},
7690 .coprocessor = 0x1,
7691 }, {
7692 .name = "olt.s",
7693 .translate = translate_compare_s,
7694 .par = (const uint32_t[]){COMPARE_OLT},
7695 .coprocessor = 0x1,
7696 }, {
7697 .name = "rfr",
7698 .translate = translate_rfr_s,
7699 .coprocessor = 0x1,
7700 }, {
7701 .name = "rfrd",
7702 .translate = translate_rfr_d,
7703 .coprocessor = 0x1,
7704 }, {
7705 .name = "round.d",
7706 .translate = translate_ftoi_d,
7707 .par = (const uint32_t[]){float_round_nearest_even, false},
7708 .coprocessor = 0x1,
7709 }, {
7710 .name = "round.s",
7711 .translate = translate_ftoi_s,
7712 .par = (const uint32_t[]){float_round_nearest_even, false},
7713 .coprocessor = 0x1,
7714 }, {
7715 .name = "rur.fcr",
7716 .translate = translate_rur,
7717 .par = (const uint32_t[]){FCR},
7718 .coprocessor = 0x1,
7719 }, {
7720 .name = "rur.fsr",
7721 .translate = translate_rur_fpu_fsr,
7722 .coprocessor = 0x1,
7723 }, {
7724 .name = "sdi",
7725 .translate = translate_ldsti_d,
7726 .par = (const uint32_t[]){true, true, false},
7727 .op_flags = XTENSA_OP_STORE,
7728 .coprocessor = 0x1,
7729 }, {
7730 .name = "sdip",
7731 .translate = translate_ldsti_d,
7732 .par = (const uint32_t[]){true, false, true},
7733 .op_flags = XTENSA_OP_STORE,
7734 .coprocessor = 0x1,
7735 }, {
7736 .name = "sdiu",
7737 .translate = translate_ldsti_d,
7738 .par = (const uint32_t[]){true, true, true},
7739 .op_flags = XTENSA_OP_STORE,
7740 .coprocessor = 0x1,
7741 }, {
7742 .name = "sdx",
7743 .translate = translate_ldstx_d,
7744 .par = (const uint32_t[]){true, true, false},
7745 .op_flags = XTENSA_OP_STORE,
7746 .coprocessor = 0x1,
7747 }, {
7748 .name = "sdxp",
7749 .translate = translate_ldstx_d,
7750 .par = (const uint32_t[]){true, false, true},
7751 .op_flags = XTENSA_OP_STORE,
7752 .coprocessor = 0x1,
7753 }, {
7754 .name = "sdxu",
7755 .translate = translate_ldstx_d,
7756 .par = (const uint32_t[]){true, true, true},
7757 .op_flags = XTENSA_OP_STORE,
7758 .coprocessor = 0x1,
7759 }, {
7760 .name = "sqrt0.d",
7761 .translate = translate_nop,
7762 .coprocessor = 0x1,
7763 }, {
7764 .name = "sqrt0.s",
7765 .translate = translate_nop,
7766 .coprocessor = 0x1,
7767 }, {
7768 .name = "ssi",
7769 .translate = translate_ldsti_s,
7770 .par = (const uint32_t[]){true, true, false},
7771 .op_flags = XTENSA_OP_STORE,
7772 .coprocessor = 0x1,
7773 }, {
7774 .name = "ssip",
7775 .translate = translate_ldsti_s,
7776 .par = (const uint32_t[]){true, false, true},
7777 .op_flags = XTENSA_OP_STORE,
7778 .coprocessor = 0x1,
7779 }, {
7780 .name = "ssiu",
7781 .translate = translate_ldsti_s,
7782 .par = (const uint32_t[]){true, true, true},
7783 .op_flags = XTENSA_OP_STORE,
7784 .coprocessor = 0x1,
7785 }, {
7786 .name = "ssx",
7787 .translate = translate_ldstx_s,
7788 .par = (const uint32_t[]){true, true, false},
7789 .op_flags = XTENSA_OP_STORE,
7790 .coprocessor = 0x1,
7791 }, {
7792 .name = "ssxp",
7793 .translate = translate_ldstx_s,
7794 .par = (const uint32_t[]){true, false, true},
7795 .op_flags = XTENSA_OP_STORE,
7796 .coprocessor = 0x1,
7797 }, {
7798 .name = "ssxu",
7799 .translate = translate_ldstx_s,
7800 .par = (const uint32_t[]){true, true, true},
7801 .op_flags = XTENSA_OP_STORE,
7802 .coprocessor = 0x1,
7803 }, {
7804 .name = "sub.d",
7805 .translate = translate_sub_d,
7806 .coprocessor = 0x1,
7807 }, {
7808 .name = "sub.s",
7809 .translate = translate_sub_s,
7810 .coprocessor = 0x1,
7811 }, {
7812 .name = "trunc.d",
7813 .translate = translate_ftoi_d,
7814 .par = (const uint32_t[]){float_round_to_zero, false},
7815 .coprocessor = 0x1,
7816 }, {
7817 .name = "trunc.s",
7818 .translate = translate_ftoi_s,
7819 .par = (const uint32_t[]){float_round_to_zero, false},
7820 .coprocessor = 0x1,
7821 }, {
7822 .name = "ueq.d",
7823 .translate = translate_compare_d,
7824 .par = (const uint32_t[]){COMPARE_UEQ},
7825 .coprocessor = 0x1,
7826 }, {
7827 .name = "ueq.s",
7828 .translate = translate_compare_s,
7829 .par = (const uint32_t[]){COMPARE_UEQ},
7830 .coprocessor = 0x1,
7831 }, {
7832 .name = "ufloat.d",
7833 .translate = translate_float_d,
7834 .par = (const uint32_t[]){true},
7835 .coprocessor = 0x1,
7836 }, {
7837 .name = "ufloat.s",
7838 .translate = translate_float_s,
7839 .par = (const uint32_t[]){true},
7840 .coprocessor = 0x1,
7841 }, {
7842 .name = "ule.d",
7843 .translate = translate_compare_d,
7844 .par = (const uint32_t[]){COMPARE_ULE},
7845 .coprocessor = 0x1,
7846 }, {
7847 .name = "ule.s",
7848 .translate = translate_compare_s,
7849 .par = (const uint32_t[]){COMPARE_ULE},
7850 .coprocessor = 0x1,
7851 }, {
7852 .name = "ult.d",
7853 .translate = translate_compare_d,
7854 .par = (const uint32_t[]){COMPARE_ULT},
7855 .coprocessor = 0x1,
7856 }, {
7857 .name = "ult.s",
7858 .translate = translate_compare_s,
7859 .par = (const uint32_t[]){COMPARE_ULT},
7860 .coprocessor = 0x1,
7861 }, {
7862 .name = "un.d",
7863 .translate = translate_compare_d,
7864 .par = (const uint32_t[]){COMPARE_UN},
7865 .coprocessor = 0x1,
7866 }, {
7867 .name = "un.s",
7868 .translate = translate_compare_s,
7869 .par = (const uint32_t[]){COMPARE_UN},
7870 .coprocessor = 0x1,
7871 }, {
7872 .name = "utrunc.d",
7873 .translate = translate_ftoi_d,
7874 .par = (const uint32_t[]){float_round_to_zero, true},
7875 .coprocessor = 0x1,
7876 }, {
7877 .name = "utrunc.s",
7878 .translate = translate_ftoi_s,
7879 .par = (const uint32_t[]){float_round_to_zero, true},
7880 .coprocessor = 0x1,
7881 }, {
7882 .name = "wfr",
7883 .translate = translate_wfr_s,
7884 .coprocessor = 0x1,
7885 }, {
7886 .name = "wfrd",
7887 .translate = translate_wfr_d,
7888 .coprocessor = 0x1,
7889 }, {
7890 .name = "wur.fcr",
7891 .translate = translate_wur_fpu_fcr,
7892 .par = (const uint32_t[]){FCR},
7893 .coprocessor = 0x1,
7894 }, {
7895 .name = "wur.fsr",
7896 .translate = translate_wur_fpu_fsr,
7897 .coprocessor = 0x1,
7901 const XtensaOpcodeTranslators xtensa_fpu_opcodes = {
7902 .num_opcodes = ARRAY_SIZE(fpu_ops),
7903 .opcode = fpu_ops,