3 * http://www.tensilica.com/products/literature-docs/documentation/xtensa-isa-databook.htm
5 * Copyright (c) 2011, Max Filippov, Open Source and Linux Lab.
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"
34 #include "exec/exec-all.h"
35 #include "disas/disas.h"
36 #include "tcg/tcg-op.h"
38 #include "qemu/qemu-print.h"
39 #include "exec/cpu_ldst.h"
40 #include "semihosting/semihost.h"
41 #include "exec/translator.h"
43 #include "exec/helper-proto.h"
44 #include "exec/helper-gen.h"
50 DisasContextBase base
;
51 const XtensaConfig
*config
;
60 bool sar_m32_allocated
;
74 xtensa_insnbuf_word insnbuf
[MAX_INSNBUF_LENGTH
];
75 xtensa_insnbuf_word slotbuf
[MAX_INSNBUF_LENGTH
];
78 static TCGv_i32 cpu_pc
;
79 static TCGv_i32 cpu_R
[16];
80 static TCGv_i32 cpu_FR
[16];
81 static TCGv_i64 cpu_FRD
[16];
82 static TCGv_i32 cpu_MR
[4];
83 static TCGv_i32 cpu_BR
[16];
84 static TCGv_i32 cpu_BR4
[4];
85 static TCGv_i32 cpu_BR8
[2];
86 static TCGv_i32 cpu_SR
[256];
87 static TCGv_i32 cpu_UR
[256];
88 static TCGv_i32 cpu_windowbase_next
;
89 static TCGv_i32 cpu_exclusive_addr
;
90 static TCGv_i32 cpu_exclusive_val
;
92 static GHashTable
*xtensa_regfile_table
;
94 #include "exec/gen-icount.h"
96 static char *sr_name
[256];
97 static char *ur_name
[256];
99 void xtensa_collect_sr_names(const XtensaConfig
*config
)
101 xtensa_isa isa
= config
->isa
;
102 int n
= xtensa_isa_num_sysregs(isa
);
105 for (i
= 0; i
< n
; ++i
) {
106 int sr
= xtensa_sysreg_number(isa
, i
);
108 if (sr
>= 0 && sr
< 256) {
109 const char *name
= xtensa_sysreg_name(isa
, i
);
111 (xtensa_sysreg_is_user(isa
, i
) ? ur_name
: sr_name
) + sr
;
114 if (strstr(*pname
, name
) == NULL
) {
116 malloc(strlen(*pname
) + strlen(name
) + 2);
118 strcpy(new_name
, *pname
);
119 strcat(new_name
, "/");
120 strcat(new_name
, name
);
125 *pname
= strdup(name
);
131 void xtensa_translate_init(void)
133 static const char * const regnames
[] = {
134 "ar0", "ar1", "ar2", "ar3",
135 "ar4", "ar5", "ar6", "ar7",
136 "ar8", "ar9", "ar10", "ar11",
137 "ar12", "ar13", "ar14", "ar15",
139 static const char * const fregnames
[] = {
140 "f0", "f1", "f2", "f3",
141 "f4", "f5", "f6", "f7",
142 "f8", "f9", "f10", "f11",
143 "f12", "f13", "f14", "f15",
145 static const char * const mregnames
[] = {
146 "m0", "m1", "m2", "m3",
148 static const char * const bregnames
[] = {
149 "b0", "b1", "b2", "b3",
150 "b4", "b5", "b6", "b7",
151 "b8", "b9", "b10", "b11",
152 "b12", "b13", "b14", "b15",
156 cpu_pc
= tcg_global_mem_new_i32(cpu_env
,
157 offsetof(CPUXtensaState
, pc
), "pc");
159 for (i
= 0; i
< 16; i
++) {
160 cpu_R
[i
] = tcg_global_mem_new_i32(cpu_env
,
161 offsetof(CPUXtensaState
, regs
[i
]),
165 for (i
= 0; i
< 16; i
++) {
166 cpu_FR
[i
] = tcg_global_mem_new_i32(cpu_env
,
167 offsetof(CPUXtensaState
,
168 fregs
[i
].f32
[FP_F32_LOW
]),
172 for (i
= 0; i
< 16; i
++) {
173 cpu_FRD
[i
] = tcg_global_mem_new_i64(cpu_env
,
174 offsetof(CPUXtensaState
,
179 for (i
= 0; i
< 4; i
++) {
180 cpu_MR
[i
] = tcg_global_mem_new_i32(cpu_env
,
181 offsetof(CPUXtensaState
,
186 for (i
= 0; i
< 16; i
++) {
187 cpu_BR
[i
] = tcg_global_mem_new_i32(cpu_env
,
188 offsetof(CPUXtensaState
,
192 cpu_BR4
[i
/ 4] = tcg_global_mem_new_i32(cpu_env
,
193 offsetof(CPUXtensaState
,
198 cpu_BR8
[i
/ 8] = tcg_global_mem_new_i32(cpu_env
,
199 offsetof(CPUXtensaState
,
205 for (i
= 0; i
< 256; ++i
) {
207 cpu_SR
[i
] = tcg_global_mem_new_i32(cpu_env
,
208 offsetof(CPUXtensaState
,
214 for (i
= 0; i
< 256; ++i
) {
216 cpu_UR
[i
] = tcg_global_mem_new_i32(cpu_env
,
217 offsetof(CPUXtensaState
,
223 cpu_windowbase_next
=
224 tcg_global_mem_new_i32(cpu_env
,
225 offsetof(CPUXtensaState
, windowbase_next
),
228 tcg_global_mem_new_i32(cpu_env
,
229 offsetof(CPUXtensaState
, exclusive_addr
),
232 tcg_global_mem_new_i32(cpu_env
,
233 offsetof(CPUXtensaState
, exclusive_val
),
237 void **xtensa_get_regfile_by_name(const char *name
, int entries
, int bits
)
242 if (xtensa_regfile_table
== NULL
) {
243 xtensa_regfile_table
= g_hash_table_new(g_str_hash
, g_str_equal
);
245 * AR is special. Xtensa translator uses it as a current register
246 * window, but configuration overlays represent it as a complete
247 * physical register file.
249 g_hash_table_insert(xtensa_regfile_table
,
250 (void *)"AR 16x32", (void *)cpu_R
);
251 g_hash_table_insert(xtensa_regfile_table
,
252 (void *)"AR 32x32", (void *)cpu_R
);
253 g_hash_table_insert(xtensa_regfile_table
,
254 (void *)"AR 64x32", (void *)cpu_R
);
256 g_hash_table_insert(xtensa_regfile_table
,
257 (void *)"MR 4x32", (void *)cpu_MR
);
259 g_hash_table_insert(xtensa_regfile_table
,
260 (void *)"FR 16x32", (void *)cpu_FR
);
261 g_hash_table_insert(xtensa_regfile_table
,
262 (void *)"FR 16x64", (void *)cpu_FRD
);
264 g_hash_table_insert(xtensa_regfile_table
,
265 (void *)"BR 16x1", (void *)cpu_BR
);
266 g_hash_table_insert(xtensa_regfile_table
,
267 (void *)"BR4 4x4", (void *)cpu_BR4
);
268 g_hash_table_insert(xtensa_regfile_table
,
269 (void *)"BR8 2x8", (void *)cpu_BR8
);
272 geometry_name
= g_strdup_printf("%s %dx%d", name
, entries
, bits
);
273 res
= (void **)g_hash_table_lookup(xtensa_regfile_table
, geometry_name
);
274 g_free(geometry_name
);
278 static inline bool option_enabled(DisasContext
*dc
, int opt
)
280 return xtensa_option_enabled(dc
->config
, opt
);
283 static void init_sar_tracker(DisasContext
*dc
)
285 dc
->sar_5bit
= false;
286 dc
->sar_m32_5bit
= false;
287 dc
->sar_m32_allocated
= false;
290 static void reset_sar_tracker(DisasContext
*dc
)
292 if (dc
->sar_m32_allocated
) {
293 tcg_temp_free(dc
->sar_m32
);
297 static void gen_right_shift_sar(DisasContext
*dc
, TCGv_i32 sa
)
299 tcg_gen_andi_i32(cpu_SR
[SAR
], sa
, 0x1f);
300 if (dc
->sar_m32_5bit
) {
301 tcg_gen_discard_i32(dc
->sar_m32
);
304 dc
->sar_m32_5bit
= false;
307 static void gen_left_shift_sar(DisasContext
*dc
, TCGv_i32 sa
)
309 TCGv_i32 tmp
= tcg_const_i32(32);
310 if (!dc
->sar_m32_allocated
) {
311 dc
->sar_m32
= tcg_temp_local_new_i32();
312 dc
->sar_m32_allocated
= true;
314 tcg_gen_andi_i32(dc
->sar_m32
, sa
, 0x1f);
315 tcg_gen_sub_i32(cpu_SR
[SAR
], tmp
, dc
->sar_m32
);
316 dc
->sar_5bit
= false;
317 dc
->sar_m32_5bit
= true;
321 static void gen_exception(DisasContext
*dc
, int excp
)
323 TCGv_i32 tmp
= tcg_const_i32(excp
);
324 gen_helper_exception(cpu_env
, tmp
);
328 static void gen_exception_cause(DisasContext
*dc
, uint32_t cause
)
330 TCGv_i32 tpc
= tcg_const_i32(dc
->pc
);
331 TCGv_i32 tcause
= tcg_const_i32(cause
);
332 gen_helper_exception_cause(cpu_env
, tpc
, tcause
);
334 tcg_temp_free(tcause
);
335 if (cause
== ILLEGAL_INSTRUCTION_CAUSE
||
336 cause
== SYSCALL_CAUSE
) {
337 dc
->base
.is_jmp
= DISAS_NORETURN
;
341 static void gen_debug_exception(DisasContext
*dc
, uint32_t cause
)
343 TCGv_i32 tpc
= tcg_const_i32(dc
->pc
);
344 TCGv_i32 tcause
= tcg_const_i32(cause
);
345 gen_helper_debug_exception(cpu_env
, tpc
, tcause
);
347 tcg_temp_free(tcause
);
348 if (cause
& (DEBUGCAUSE_IB
| DEBUGCAUSE_BI
| DEBUGCAUSE_BN
)) {
349 dc
->base
.is_jmp
= DISAS_NORETURN
;
353 static bool gen_check_privilege(DisasContext
*dc
)
355 #ifndef CONFIG_USER_ONLY
360 gen_exception_cause(dc
, PRIVILEGED_CAUSE
);
361 dc
->base
.is_jmp
= DISAS_NORETURN
;
365 static bool gen_check_cpenable(DisasContext
*dc
, uint32_t cp_mask
)
367 cp_mask
&= ~dc
->cpenable
;
369 if (option_enabled(dc
, XTENSA_OPTION_COPROCESSOR
) && cp_mask
) {
370 gen_exception_cause(dc
, COPROCESSOR0_DISABLED
+ ctz32(cp_mask
));
371 dc
->base
.is_jmp
= DISAS_NORETURN
;
377 static int gen_postprocess(DisasContext
*dc
, int slot
);
379 static void gen_jump_slot(DisasContext
*dc
, TCGv dest
, int slot
)
381 tcg_gen_mov_i32(cpu_pc
, dest
);
383 tcg_gen_mov_i32(cpu_SR
[ICOUNT
], dc
->next_icount
);
385 if (dc
->base
.singlestep_enabled
) {
386 gen_exception(dc
, EXCP_DEBUG
);
388 if (dc
->op_flags
& XTENSA_OP_POSTPROCESS
) {
389 slot
= gen_postprocess(dc
, slot
);
392 tcg_gen_goto_tb(slot
);
393 tcg_gen_exit_tb(dc
->base
.tb
, slot
);
395 tcg_gen_exit_tb(NULL
, 0);
398 dc
->base
.is_jmp
= DISAS_NORETURN
;
401 static void gen_jump(DisasContext
*dc
, TCGv dest
)
403 gen_jump_slot(dc
, dest
, -1);
406 static int adjust_jump_slot(DisasContext
*dc
, uint32_t dest
, int slot
)
408 if (((dc
->base
.pc_first
^ dest
) & TARGET_PAGE_MASK
) != 0) {
415 static void gen_jumpi(DisasContext
*dc
, uint32_t dest
, int slot
)
417 TCGv_i32 tmp
= tcg_const_i32(dest
);
418 gen_jump_slot(dc
, tmp
, adjust_jump_slot(dc
, dest
, slot
));
422 static void gen_callw_slot(DisasContext
*dc
, int callinc
, TCGv_i32 dest
,
425 TCGv_i32 tcallinc
= tcg_const_i32(callinc
);
427 tcg_gen_deposit_i32(cpu_SR
[PS
], cpu_SR
[PS
],
428 tcallinc
, PS_CALLINC_SHIFT
, PS_CALLINC_LEN
);
429 tcg_temp_free(tcallinc
);
430 tcg_gen_movi_i32(cpu_R
[callinc
<< 2],
431 (callinc
<< 30) | (dc
->base
.pc_next
& 0x3fffffff));
432 gen_jump_slot(dc
, dest
, slot
);
435 static bool gen_check_loop_end(DisasContext
*dc
, int slot
)
437 if (dc
->base
.pc_next
== dc
->lend
) {
438 TCGLabel
*label
= gen_new_label();
440 tcg_gen_brcondi_i32(TCG_COND_EQ
, cpu_SR
[LCOUNT
], 0, label
);
441 tcg_gen_subi_i32(cpu_SR
[LCOUNT
], cpu_SR
[LCOUNT
], 1);
443 gen_jumpi(dc
, dc
->base
.pc_next
- dc
->lbeg_off
, slot
);
445 gen_jump(dc
, cpu_SR
[LBEG
]);
447 gen_set_label(label
);
448 gen_jumpi(dc
, dc
->base
.pc_next
, -1);
454 static void gen_jumpi_check_loop_end(DisasContext
*dc
, int slot
)
456 if (!gen_check_loop_end(dc
, slot
)) {
457 gen_jumpi(dc
, dc
->base
.pc_next
, slot
);
461 static void gen_brcond(DisasContext
*dc
, TCGCond cond
,
462 TCGv_i32 t0
, TCGv_i32 t1
, uint32_t addr
)
464 TCGLabel
*label
= gen_new_label();
466 tcg_gen_brcond_i32(cond
, t0
, t1
, label
);
467 gen_jumpi_check_loop_end(dc
, 0);
468 gen_set_label(label
);
469 gen_jumpi(dc
, addr
, 1);
472 static void gen_brcondi(DisasContext
*dc
, TCGCond cond
,
473 TCGv_i32 t0
, uint32_t t1
, uint32_t addr
)
475 TCGv_i32 tmp
= tcg_const_i32(t1
);
476 gen_brcond(dc
, cond
, t0
, tmp
, addr
);
480 static uint32_t test_exceptions_sr(DisasContext
*dc
, const OpcodeArg arg
[],
481 const uint32_t par
[])
483 return xtensa_option_enabled(dc
->config
, par
[1]) ? 0 : XTENSA_OP_ILL
;
486 static uint32_t test_exceptions_ccompare(DisasContext
*dc
,
487 const OpcodeArg arg
[],
488 const uint32_t par
[])
490 unsigned n
= par
[0] - CCOMPARE
;
492 if (n
>= dc
->config
->nccompare
) {
493 return XTENSA_OP_ILL
;
495 return test_exceptions_sr(dc
, arg
, par
);
498 static uint32_t test_exceptions_dbreak(DisasContext
*dc
, const OpcodeArg arg
[],
499 const uint32_t par
[])
501 unsigned n
= MAX_NDBREAK
;
503 if (par
[0] >= DBREAKA
&& par
[0] < DBREAKA
+ MAX_NDBREAK
) {
504 n
= par
[0] - DBREAKA
;
506 if (par
[0] >= DBREAKC
&& par
[0] < DBREAKC
+ MAX_NDBREAK
) {
507 n
= par
[0] - DBREAKC
;
509 if (n
>= dc
->config
->ndbreak
) {
510 return XTENSA_OP_ILL
;
512 return test_exceptions_sr(dc
, arg
, par
);
515 static uint32_t test_exceptions_ibreak(DisasContext
*dc
, const OpcodeArg arg
[],
516 const uint32_t par
[])
518 unsigned n
= par
[0] - IBREAKA
;
520 if (n
>= dc
->config
->nibreak
) {
521 return XTENSA_OP_ILL
;
523 return test_exceptions_sr(dc
, arg
, par
);
526 static uint32_t test_exceptions_hpi(DisasContext
*dc
, const OpcodeArg arg
[],
527 const uint32_t par
[])
529 unsigned n
= MAX_NLEVEL
+ 1;
531 if (par
[0] >= EXCSAVE1
&& par
[0] < EXCSAVE1
+ MAX_NLEVEL
) {
532 n
= par
[0] - EXCSAVE1
+ 1;
534 if (par
[0] >= EPC1
&& par
[0] < EPC1
+ MAX_NLEVEL
) {
535 n
= par
[0] - EPC1
+ 1;
537 if (par
[0] >= EPS2
&& par
[0] < EPS2
+ MAX_NLEVEL
- 1) {
538 n
= par
[0] - EPS2
+ 2;
540 if (n
> dc
->config
->nlevel
) {
541 return XTENSA_OP_ILL
;
543 return test_exceptions_sr(dc
, arg
, par
);
546 static MemOp
gen_load_store_alignment(DisasContext
*dc
, MemOp mop
,
549 if ((mop
& MO_SIZE
) == MO_8
) {
552 if ((mop
& MO_AMASK
) == MO_UNALN
&&
553 !option_enabled(dc
, XTENSA_OPTION_HW_ALIGNMENT
)) {
556 if (!option_enabled(dc
, XTENSA_OPTION_UNALIGNED_EXCEPTION
)) {
557 tcg_gen_andi_i32(addr
, addr
, ~0 << get_alignment_bits(mop
));
562 #ifndef CONFIG_USER_ONLY
563 static void gen_waiti(DisasContext
*dc
, uint32_t imm4
)
565 TCGv_i32 pc
= tcg_const_i32(dc
->base
.pc_next
);
566 TCGv_i32 intlevel
= tcg_const_i32(imm4
);
568 if (tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
) {
571 gen_helper_waiti(cpu_env
, pc
, intlevel
);
573 tcg_temp_free(intlevel
);
577 static bool gen_window_check(DisasContext
*dc
, uint32_t mask
)
579 unsigned r
= 31 - clz32(mask
);
581 if (r
/ 4 > dc
->window
) {
582 TCGv_i32 pc
= tcg_const_i32(dc
->pc
);
583 TCGv_i32 w
= tcg_const_i32(r
/ 4);
585 gen_helper_window_check(cpu_env
, pc
, w
);
586 dc
->base
.is_jmp
= DISAS_NORETURN
;
592 static TCGv_i32
gen_mac16_m(TCGv_i32 v
, bool hi
, bool is_unsigned
)
594 TCGv_i32 m
= tcg_temp_new_i32();
597 (is_unsigned
? tcg_gen_shri_i32
: tcg_gen_sari_i32
)(m
, v
, 16);
599 (is_unsigned
? tcg_gen_ext16u_i32
: tcg_gen_ext16s_i32
)(m
, v
);
604 static void gen_zero_check(DisasContext
*dc
, const OpcodeArg arg
[])
606 TCGLabel
*label
= gen_new_label();
608 tcg_gen_brcondi_i32(TCG_COND_NE
, arg
[2].in
, 0, label
);
609 gen_exception_cause(dc
, INTEGER_DIVIDE_BY_ZERO_CAUSE
);
610 gen_set_label(label
);
613 static inline unsigned xtensa_op0_insn_len(DisasContext
*dc
, uint8_t op0
)
615 return xtensa_isa_length_from_chars(dc
->config
->isa
, &op0
);
618 static int gen_postprocess(DisasContext
*dc
, int slot
)
620 uint32_t op_flags
= dc
->op_flags
;
622 #ifndef CONFIG_USER_ONLY
623 if (op_flags
& XTENSA_OP_CHECK_INTERRUPTS
) {
624 if (tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
) {
627 gen_helper_check_interrupts(cpu_env
);
630 if (op_flags
& XTENSA_OP_SYNC_REGISTER_WINDOW
) {
631 gen_helper_sync_windowbase(cpu_env
);
633 if (op_flags
& XTENSA_OP_EXIT_TB_M1
) {
639 struct opcode_arg_copy
{
645 struct opcode_arg_info
{
651 XtensaOpcodeOps
*ops
;
652 OpcodeArg arg
[MAX_OPCODE_ARGS
];
653 struct opcode_arg_info in
[MAX_OPCODE_ARGS
];
654 struct opcode_arg_info out
[MAX_OPCODE_ARGS
];
666 static uint32_t encode_resource(enum resource_type r
, unsigned g
, unsigned n
)
668 assert(r
< RES_MAX
&& g
< 256 && n
< 65536);
669 return (r
<< 24) | (g
<< 16) | n
;
672 static enum resource_type
get_resource_type(uint32_t resource
)
674 return resource
>> 24;
678 * a depends on b if b must be executed before a,
679 * because a's side effects will destroy b's inputs.
681 static bool op_depends_on(const struct slot_prop
*a
,
682 const struct slot_prop
*b
)
687 if (a
->op_flags
& XTENSA_OP_CONTROL_FLOW
) {
690 if ((a
->op_flags
& XTENSA_OP_LOAD_STORE
) <
691 (b
->op_flags
& XTENSA_OP_LOAD_STORE
)) {
694 while (i
< a
->n_out
&& j
< b
->n_in
) {
695 if (a
->out
[i
].resource
< b
->in
[j
].resource
) {
697 } else if (a
->out
[i
].resource
> b
->in
[j
].resource
) {
707 * Try to break a dependency on b, append temporary register copy records
708 * to the end of copy and update n_copy in case of success.
709 * This is not always possible: e.g. control flow must always be the last,
710 * load/store must be first and state dependencies are not supported yet.
712 static bool break_dependency(struct slot_prop
*a
,
714 struct opcode_arg_copy
*copy
,
719 unsigned n
= *n_copy
;
722 if (a
->op_flags
& XTENSA_OP_CONTROL_FLOW
) {
725 if ((a
->op_flags
& XTENSA_OP_LOAD_STORE
) <
726 (b
->op_flags
& XTENSA_OP_LOAD_STORE
)) {
729 while (i
< a
->n_out
&& j
< b
->n_in
) {
730 if (a
->out
[i
].resource
< b
->in
[j
].resource
) {
732 } else if (a
->out
[i
].resource
> b
->in
[j
].resource
) {
735 int index
= b
->in
[j
].index
;
737 if (get_resource_type(a
->out
[i
].resource
) != RES_REGFILE
||
741 copy
[n
].resource
= b
->in
[j
].resource
;
742 copy
[n
].arg
= b
->arg
+ index
;
753 * Calculate evaluation order for slot opcodes.
754 * Build opcode order graph and output its nodes in topological sort order.
755 * An edge a -> b in the graph means that opcode a must be followed by
758 static bool tsort(struct slot_prop
*slot
,
759 struct slot_prop
*sorted
[],
761 struct opcode_arg_copy
*copy
,
767 unsigned out_edge
[MAX_INSN_SLOTS
];
768 } node
[MAX_INSN_SLOTS
];
770 unsigned in
[MAX_INSN_SLOTS
];
776 unsigned node_idx
= 0;
778 for (i
= 0; i
< n
; ++i
) {
779 node
[i
].n_in_edge
= 0;
780 node
[i
].n_out_edge
= 0;
783 for (i
= 0; i
< n
; ++i
) {
784 unsigned n_out_edge
= 0;
786 for (j
= 0; j
< n
; ++j
) {
787 if (i
!= j
&& op_depends_on(slot
+ j
, slot
+ i
)) {
788 node
[i
].out_edge
[n_out_edge
] = j
;
794 node
[i
].n_out_edge
= n_out_edge
;
797 for (i
= 0; i
< n
; ++i
) {
798 if (!node
[i
].n_in_edge
) {
805 for (; in_idx
< n_in
; ++in_idx
) {
807 sorted
[n_out
] = slot
+ i
;
809 for (j
= 0; j
< node
[i
].n_out_edge
; ++j
) {
811 if (--node
[node
[i
].out_edge
[j
]].n_in_edge
== 0) {
812 in
[n_in
] = node
[i
].out_edge
[j
];
818 for (; node_idx
< n
; ++node_idx
) {
819 struct tsnode
*cnode
= node
+ node_idx
;
821 if (cnode
->n_in_edge
) {
822 for (j
= 0; j
< cnode
->n_out_edge
; ++j
) {
823 unsigned k
= cnode
->out_edge
[j
];
825 if (break_dependency(slot
+ k
, slot
+ node_idx
,
827 --node
[k
].n_in_edge
== 0) {
832 cnode
->out_edge
[cnode
->n_out_edge
- 1];
843 static void opcode_add_resource(struct slot_prop
*op
,
844 uint32_t resource
, char direction
,
850 assert(op
->n_in
< ARRAY_SIZE(op
->in
));
851 op
->in
[op
->n_in
].resource
= resource
;
852 op
->in
[op
->n_in
].index
= index
;
856 if (direction
== 'm' || direction
== 'o') {
857 assert(op
->n_out
< ARRAY_SIZE(op
->out
));
858 op
->out
[op
->n_out
].resource
= resource
;
859 op
->out
[op
->n_out
].index
= index
;
864 g_assert_not_reached();
868 static int resource_compare(const void *a
, const void *b
)
870 const struct opcode_arg_info
*pa
= a
;
871 const struct opcode_arg_info
*pb
= b
;
873 return pa
->resource
< pb
->resource
?
874 -1 : (pa
->resource
> pb
->resource
? 1 : 0);
877 static int arg_copy_compare(const void *a
, const void *b
)
879 const struct opcode_arg_copy
*pa
= a
;
880 const struct opcode_arg_copy
*pb
= b
;
882 return pa
->resource
< pb
->resource
?
883 -1 : (pa
->resource
> pb
->resource
? 1 : 0);
886 static void disas_xtensa_insn(CPUXtensaState
*env
, DisasContext
*dc
)
888 xtensa_isa isa
= dc
->config
->isa
;
889 unsigned char b
[MAX_INSN_LENGTH
] = {translator_ldub(env
, dc
->pc
)};
890 unsigned len
= xtensa_op0_insn_len(dc
, b
[0]);
894 uint32_t op_flags
= 0;
895 struct slot_prop slot_prop
[MAX_INSN_SLOTS
];
896 struct slot_prop
*ordered
[MAX_INSN_SLOTS
];
897 struct opcode_arg_copy arg_copy
[MAX_INSN_SLOTS
* MAX_OPCODE_ARGS
];
898 unsigned n_arg_copy
= 0;
899 uint32_t debug_cause
= 0;
900 uint32_t windowed_register
= 0;
901 uint32_t coprocessor
= 0;
903 if (len
== XTENSA_UNDEFINED
) {
904 qemu_log_mask(LOG_GUEST_ERROR
,
905 "unknown instruction length (pc = %08x)\n",
907 gen_exception_cause(dc
, ILLEGAL_INSTRUCTION_CAUSE
);
908 dc
->base
.pc_next
= dc
->pc
+ 1;
912 dc
->base
.pc_next
= dc
->pc
+ len
;
913 for (i
= 1; i
< len
; ++i
) {
914 b
[i
] = translator_ldub(env
, dc
->pc
+ i
);
916 xtensa_insnbuf_from_chars(isa
, dc
->insnbuf
, b
, len
);
917 fmt
= xtensa_format_decode(isa
, dc
->insnbuf
);
918 if (fmt
== XTENSA_UNDEFINED
) {
919 qemu_log_mask(LOG_GUEST_ERROR
,
920 "unrecognized instruction format (pc = %08x)\n",
922 gen_exception_cause(dc
, ILLEGAL_INSTRUCTION_CAUSE
);
925 slots
= xtensa_format_num_slots(isa
, fmt
);
926 for (slot
= 0; slot
< slots
; ++slot
) {
928 int opnd
, vopnd
, opnds
;
929 OpcodeArg
*arg
= slot_prop
[slot
].arg
;
930 XtensaOpcodeOps
*ops
;
932 xtensa_format_get_slot(isa
, fmt
, slot
, dc
->insnbuf
, dc
->slotbuf
);
933 opc
= xtensa_opcode_decode(isa
, fmt
, slot
, dc
->slotbuf
);
934 if (opc
== XTENSA_UNDEFINED
) {
935 qemu_log_mask(LOG_GUEST_ERROR
,
936 "unrecognized opcode in slot %d (pc = %08x)\n",
938 gen_exception_cause(dc
, ILLEGAL_INSTRUCTION_CAUSE
);
941 opnds
= xtensa_opcode_num_operands(isa
, opc
);
943 for (opnd
= vopnd
= 0; opnd
< opnds
; ++opnd
) {
944 void **register_file
= NULL
;
947 if (xtensa_operand_is_register(isa
, opc
, opnd
)) {
948 rf
= xtensa_operand_regfile(isa
, opc
, opnd
);
949 register_file
= dc
->config
->regfile
[rf
];
951 if (rf
== dc
->config
->a_regfile
) {
954 xtensa_operand_get_field(isa
, opc
, opnd
, fmt
, slot
,
956 xtensa_operand_decode(isa
, opc
, opnd
, &v
);
957 windowed_register
|= 1u << v
;
960 if (xtensa_operand_is_visible(isa
, opc
, opnd
)) {
963 xtensa_operand_get_field(isa
, opc
, opnd
, fmt
, slot
,
965 xtensa_operand_decode(isa
, opc
, opnd
, &v
);
966 arg
[vopnd
].raw_imm
= v
;
967 if (xtensa_operand_is_PCrelative(isa
, opc
, opnd
)) {
968 xtensa_operand_undo_reloc(isa
, opc
, opnd
, &v
, dc
->pc
);
972 arg
[vopnd
].in
= register_file
[v
];
973 arg
[vopnd
].out
= register_file
[v
];
974 arg
[vopnd
].num_bits
= xtensa_regfile_num_bits(isa
, rf
);
976 arg
[vopnd
].num_bits
= 32;
981 ops
= dc
->config
->opcode_ops
[opc
];
982 slot_prop
[slot
].ops
= ops
;
985 op_flags
|= ops
->op_flags
;
986 if (ops
->test_exceptions
) {
987 op_flags
|= ops
->test_exceptions(dc
, arg
, ops
->par
);
990 qemu_log_mask(LOG_UNIMP
,
991 "unimplemented opcode '%s' in slot %d (pc = %08x)\n",
992 xtensa_opcode_name(isa
, opc
), slot
, dc
->pc
);
993 op_flags
|= XTENSA_OP_ILL
;
995 if (op_flags
& XTENSA_OP_ILL
) {
996 gen_exception_cause(dc
, ILLEGAL_INSTRUCTION_CAUSE
);
999 if (op_flags
& XTENSA_OP_DEBUG_BREAK
) {
1000 debug_cause
|= ops
->par
[0];
1002 if (ops
->test_overflow
) {
1003 windowed_register
|= ops
->test_overflow(dc
, arg
, ops
->par
);
1005 coprocessor
|= ops
->coprocessor
;
1008 slot_prop
[slot
].n_in
= 0;
1009 slot_prop
[slot
].n_out
= 0;
1010 slot_prop
[slot
].op_flags
= ops
->op_flags
& XTENSA_OP_LOAD_STORE
;
1012 opnds
= xtensa_opcode_num_operands(isa
, opc
);
1014 for (opnd
= vopnd
= 0; opnd
< opnds
; ++opnd
) {
1015 bool visible
= xtensa_operand_is_visible(isa
, opc
, opnd
);
1017 if (xtensa_operand_is_register(isa
, opc
, opnd
)) {
1018 xtensa_regfile rf
= xtensa_operand_regfile(isa
, opc
, opnd
);
1021 xtensa_operand_get_field(isa
, opc
, opnd
, fmt
, slot
,
1023 xtensa_operand_decode(isa
, opc
, opnd
, &v
);
1024 opcode_add_resource(slot_prop
+ slot
,
1025 encode_resource(RES_REGFILE
, rf
, v
),
1026 xtensa_operand_inout(isa
, opc
, opnd
),
1027 visible
? vopnd
: -1);
1034 opnds
= xtensa_opcode_num_stateOperands(isa
, opc
);
1036 for (opnd
= 0; opnd
< opnds
; ++opnd
) {
1037 xtensa_state state
= xtensa_stateOperand_state(isa
, opc
, opnd
);
1039 opcode_add_resource(slot_prop
+ slot
,
1040 encode_resource(RES_STATE
, 0, state
),
1041 xtensa_stateOperand_inout(isa
, opc
, opnd
),
1044 if (xtensa_opcode_is_branch(isa
, opc
) ||
1045 xtensa_opcode_is_jump(isa
, opc
) ||
1046 xtensa_opcode_is_loop(isa
, opc
) ||
1047 xtensa_opcode_is_call(isa
, opc
)) {
1048 slot_prop
[slot
].op_flags
|= XTENSA_OP_CONTROL_FLOW
;
1051 qsort(slot_prop
[slot
].in
, slot_prop
[slot
].n_in
,
1052 sizeof(slot_prop
[slot
].in
[0]), resource_compare
);
1053 qsort(slot_prop
[slot
].out
, slot_prop
[slot
].n_out
,
1054 sizeof(slot_prop
[slot
].out
[0]), resource_compare
);
1059 if (!tsort(slot_prop
, ordered
, slots
, arg_copy
, &n_arg_copy
)) {
1060 qemu_log_mask(LOG_UNIMP
,
1061 "Circular resource dependencies (pc = %08x)\n",
1063 gen_exception_cause(dc
, ILLEGAL_INSTRUCTION_CAUSE
);
1067 ordered
[0] = slot_prop
+ 0;
1070 if ((op_flags
& XTENSA_OP_PRIVILEGED
) &&
1071 !gen_check_privilege(dc
)) {
1075 if (op_flags
& XTENSA_OP_SYSCALL
) {
1076 gen_exception_cause(dc
, SYSCALL_CAUSE
);
1080 if ((op_flags
& XTENSA_OP_DEBUG_BREAK
) && dc
->debug
) {
1081 gen_debug_exception(dc
, debug_cause
);
1085 if (windowed_register
&& !gen_window_check(dc
, windowed_register
)) {
1089 if (op_flags
& XTENSA_OP_UNDERFLOW
) {
1090 TCGv_i32 tmp
= tcg_const_i32(dc
->pc
);
1092 gen_helper_test_underflow_retw(cpu_env
, tmp
);
1096 if (op_flags
& XTENSA_OP_ALLOCA
) {
1097 TCGv_i32 tmp
= tcg_const_i32(dc
->pc
);
1099 gen_helper_movsp(cpu_env
, tmp
);
1103 if (coprocessor
&& !gen_check_cpenable(dc
, coprocessor
)) {
1112 qsort(arg_copy
, n_arg_copy
, sizeof(*arg_copy
), arg_copy_compare
);
1113 for (i
= j
= 0; i
< n_arg_copy
; ++i
) {
1114 if (i
== 0 || arg_copy
[i
].resource
!= resource
) {
1115 resource
= arg_copy
[i
].resource
;
1116 if (arg_copy
[i
].arg
->num_bits
<= 32) {
1117 temp
= tcg_temp_local_new_i32();
1118 tcg_gen_mov_i32(temp
, arg_copy
[i
].arg
->in
);
1119 } else if (arg_copy
[i
].arg
->num_bits
<= 64) {
1120 temp
= tcg_temp_local_new_i64();
1121 tcg_gen_mov_i64(temp
, arg_copy
[i
].arg
->in
);
1123 g_assert_not_reached();
1125 arg_copy
[i
].temp
= temp
;
1128 arg_copy
[j
] = arg_copy
[i
];
1132 arg_copy
[i
].arg
->in
= temp
;
1137 if (op_flags
& XTENSA_OP_DIVIDE_BY_ZERO
) {
1138 for (slot
= 0; slot
< slots
; ++slot
) {
1139 if (slot_prop
[slot
].ops
->op_flags
& XTENSA_OP_DIVIDE_BY_ZERO
) {
1140 gen_zero_check(dc
, slot_prop
[slot
].arg
);
1145 dc
->op_flags
= op_flags
;
1147 for (slot
= 0; slot
< slots
; ++slot
) {
1148 struct slot_prop
*pslot
= ordered
[slot
];
1149 XtensaOpcodeOps
*ops
= pslot
->ops
;
1151 ops
->translate(dc
, pslot
->arg
, ops
->par
);
1154 for (i
= 0; i
< n_arg_copy
; ++i
) {
1155 if (arg_copy
[i
].arg
->num_bits
<= 32) {
1156 tcg_temp_free_i32(arg_copy
[i
].temp
);
1157 } else if (arg_copy
[i
].arg
->num_bits
<= 64) {
1158 tcg_temp_free_i64(arg_copy
[i
].temp
);
1160 g_assert_not_reached();
1164 if (dc
->base
.is_jmp
== DISAS_NEXT
) {
1165 gen_postprocess(dc
, 0);
1167 if (op_flags
& XTENSA_OP_EXIT_TB_M1
) {
1168 /* Change in mmu index, memory mapping or tb->flags; exit tb */
1169 gen_jumpi_check_loop_end(dc
, -1);
1170 } else if (op_flags
& XTENSA_OP_EXIT_TB_0
) {
1171 gen_jumpi_check_loop_end(dc
, 0);
1173 gen_check_loop_end(dc
, 0);
1176 dc
->pc
= dc
->base
.pc_next
;
1179 static inline unsigned xtensa_insn_len(CPUXtensaState
*env
, DisasContext
*dc
)
1181 uint8_t b0
= cpu_ldub_code(env
, dc
->pc
);
1182 return xtensa_op0_insn_len(dc
, b0
);
1185 static void gen_ibreak_check(CPUXtensaState
*env
, DisasContext
*dc
)
1189 for (i
= 0; i
< dc
->config
->nibreak
; ++i
) {
1190 if ((env
->sregs
[IBREAKENABLE
] & (1 << i
)) &&
1191 env
->sregs
[IBREAKA
+ i
] == dc
->pc
) {
1192 gen_debug_exception(dc
, DEBUGCAUSE_IB
);
1198 static void xtensa_tr_init_disas_context(DisasContextBase
*dcbase
,
1201 DisasContext
*dc
= container_of(dcbase
, DisasContext
, base
);
1202 CPUXtensaState
*env
= cpu
->env_ptr
;
1203 uint32_t tb_flags
= dc
->base
.tb
->flags
;
1205 dc
->config
= env
->config
;
1206 dc
->pc
= dc
->base
.pc_first
;
1207 dc
->ring
= tb_flags
& XTENSA_TBFLAG_RING_MASK
;
1208 dc
->cring
= (tb_flags
& XTENSA_TBFLAG_EXCM
) ? 0 : dc
->ring
;
1209 dc
->lbeg_off
= (dc
->base
.tb
->cs_base
& XTENSA_CSBASE_LBEG_OFF_MASK
) >>
1210 XTENSA_CSBASE_LBEG_OFF_SHIFT
;
1211 dc
->lend
= (dc
->base
.tb
->cs_base
& XTENSA_CSBASE_LEND_MASK
) +
1212 (dc
->base
.pc_first
& TARGET_PAGE_MASK
);
1213 dc
->debug
= tb_flags
& XTENSA_TBFLAG_DEBUG
;
1214 dc
->icount
= tb_flags
& XTENSA_TBFLAG_ICOUNT
;
1215 dc
->cpenable
= (tb_flags
& XTENSA_TBFLAG_CPENABLE_MASK
) >>
1216 XTENSA_TBFLAG_CPENABLE_SHIFT
;
1217 dc
->window
= ((tb_flags
& XTENSA_TBFLAG_WINDOW_MASK
) >>
1218 XTENSA_TBFLAG_WINDOW_SHIFT
);
1219 dc
->cwoe
= tb_flags
& XTENSA_TBFLAG_CWOE
;
1220 dc
->callinc
= ((tb_flags
& XTENSA_TBFLAG_CALLINC_MASK
) >>
1221 XTENSA_TBFLAG_CALLINC_SHIFT
);
1222 init_sar_tracker(dc
);
1225 static void xtensa_tr_tb_start(DisasContextBase
*dcbase
, CPUState
*cpu
)
1227 DisasContext
*dc
= container_of(dcbase
, DisasContext
, base
);
1230 dc
->next_icount
= tcg_temp_local_new_i32();
1234 static void xtensa_tr_insn_start(DisasContextBase
*dcbase
, CPUState
*cpu
)
1236 tcg_gen_insn_start(dcbase
->pc_next
);
1239 static bool xtensa_tr_breakpoint_check(DisasContextBase
*dcbase
, CPUState
*cpu
,
1240 const CPUBreakpoint
*bp
)
1242 DisasContext
*dc
= container_of(dcbase
, DisasContext
, base
);
1244 tcg_gen_movi_i32(cpu_pc
, dc
->base
.pc_next
);
1245 gen_exception(dc
, EXCP_DEBUG
);
1246 dc
->base
.is_jmp
= DISAS_NORETURN
;
1247 /* The address covered by the breakpoint must be included in
1248 [tb->pc, tb->pc + tb->size) in order to for it to be
1249 properly cleared -- thus we increment the PC here so that
1250 the logic setting tb->size below does the right thing. */
1251 dc
->base
.pc_next
+= 2;
1255 static void xtensa_tr_translate_insn(DisasContextBase
*dcbase
, CPUState
*cpu
)
1257 DisasContext
*dc
= container_of(dcbase
, DisasContext
, base
);
1258 CPUXtensaState
*env
= cpu
->env_ptr
;
1259 target_ulong page_start
;
1261 /* These two conditions only apply to the first insn in the TB,
1262 but this is the first TranslateOps hook that allows exiting. */
1263 if ((tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
)
1264 && (dc
->base
.tb
->flags
& XTENSA_TBFLAG_YIELD
)) {
1265 gen_exception(dc
, EXCP_YIELD
);
1266 dc
->base
.pc_next
= dc
->pc
+ 1;
1267 dc
->base
.is_jmp
= DISAS_NORETURN
;
1272 TCGLabel
*label
= gen_new_label();
1274 tcg_gen_addi_i32(dc
->next_icount
, cpu_SR
[ICOUNT
], 1);
1275 tcg_gen_brcondi_i32(TCG_COND_NE
, dc
->next_icount
, 0, label
);
1276 tcg_gen_mov_i32(dc
->next_icount
, cpu_SR
[ICOUNT
]);
1278 gen_debug_exception(dc
, DEBUGCAUSE_IC
);
1280 gen_set_label(label
);
1284 gen_ibreak_check(env
, dc
);
1287 disas_xtensa_insn(env
, dc
);
1290 tcg_gen_mov_i32(cpu_SR
[ICOUNT
], dc
->next_icount
);
1293 /* End the TB if the next insn will cross into the next page. */
1294 page_start
= dc
->base
.pc_first
& TARGET_PAGE_MASK
;
1295 if (dc
->base
.is_jmp
== DISAS_NEXT
&&
1296 (dc
->pc
- page_start
>= TARGET_PAGE_SIZE
||
1297 dc
->pc
- page_start
+ xtensa_insn_len(env
, dc
) > TARGET_PAGE_SIZE
)) {
1298 dc
->base
.is_jmp
= DISAS_TOO_MANY
;
1302 static void xtensa_tr_tb_stop(DisasContextBase
*dcbase
, CPUState
*cpu
)
1304 DisasContext
*dc
= container_of(dcbase
, DisasContext
, base
);
1306 reset_sar_tracker(dc
);
1308 tcg_temp_free(dc
->next_icount
);
1311 switch (dc
->base
.is_jmp
) {
1312 case DISAS_NORETURN
:
1314 case DISAS_TOO_MANY
:
1315 if (dc
->base
.singlestep_enabled
) {
1316 tcg_gen_movi_i32(cpu_pc
, dc
->pc
);
1317 gen_exception(dc
, EXCP_DEBUG
);
1319 gen_jumpi(dc
, dc
->pc
, 0);
1323 g_assert_not_reached();
1327 static void xtensa_tr_disas_log(const DisasContextBase
*dcbase
, CPUState
*cpu
)
1329 qemu_log("IN: %s\n", lookup_symbol(dcbase
->pc_first
));
1330 log_target_disas(cpu
, dcbase
->pc_first
, dcbase
->tb
->size
);
1333 static const TranslatorOps xtensa_translator_ops
= {
1334 .init_disas_context
= xtensa_tr_init_disas_context
,
1335 .tb_start
= xtensa_tr_tb_start
,
1336 .insn_start
= xtensa_tr_insn_start
,
1337 .breakpoint_check
= xtensa_tr_breakpoint_check
,
1338 .translate_insn
= xtensa_tr_translate_insn
,
1339 .tb_stop
= xtensa_tr_tb_stop
,
1340 .disas_log
= xtensa_tr_disas_log
,
1343 void gen_intermediate_code(CPUState
*cpu
, TranslationBlock
*tb
, int max_insns
)
1345 DisasContext dc
= {};
1346 translator_loop(&xtensa_translator_ops
, &dc
.base
, cpu
, tb
, max_insns
);
1349 void xtensa_cpu_dump_state(CPUState
*cs
, FILE *f
, int flags
)
1351 XtensaCPU
*cpu
= XTENSA_CPU(cs
);
1352 CPUXtensaState
*env
= &cpu
->env
;
1353 xtensa_isa isa
= env
->config
->isa
;
1356 qemu_fprintf(f
, "PC=%08x\n\n", env
->pc
);
1358 for (i
= j
= 0; i
< xtensa_isa_num_sysregs(isa
); ++i
) {
1359 const uint32_t *reg
=
1360 xtensa_sysreg_is_user(isa
, i
) ? env
->uregs
: env
->sregs
;
1361 int regno
= xtensa_sysreg_number(isa
, i
);
1364 qemu_fprintf(f
, "%12s=%08x%c",
1365 xtensa_sysreg_name(isa
, i
),
1367 (j
++ % 4) == 3 ? '\n' : ' ');
1371 qemu_fprintf(f
, (j
% 4) == 0 ? "\n" : "\n\n");
1373 for (i
= 0; i
< 16; ++i
) {
1374 qemu_fprintf(f
, " A%02d=%08x%c",
1375 i
, env
->regs
[i
], (i
% 4) == 3 ? '\n' : ' ');
1378 xtensa_sync_phys_from_window(env
);
1379 qemu_fprintf(f
, "\n");
1381 for (i
= 0; i
< env
->config
->nareg
; ++i
) {
1382 qemu_fprintf(f
, "AR%02d=%08x ", i
, env
->phys_regs
[i
]);
1384 bool ws
= (env
->sregs
[WINDOW_START
] & (1 << (i
/ 4))) != 0;
1385 bool cw
= env
->sregs
[WINDOW_BASE
] == i
/ 4;
1387 qemu_fprintf(f
, "%c%c\n", ws
? '<' : ' ', cw
? '=' : ' ');
1391 if ((flags
& CPU_DUMP_FPU
) &&
1392 xtensa_option_enabled(env
->config
, XTENSA_OPTION_FP_COPROCESSOR
)) {
1393 qemu_fprintf(f
, "\n");
1395 for (i
= 0; i
< 16; ++i
) {
1396 qemu_fprintf(f
, "F%02d=%08x (%-+15.8e)%c", i
,
1397 float32_val(env
->fregs
[i
].f32
[FP_F32_LOW
]),
1398 *(float *)(env
->fregs
[i
].f32
+ FP_F32_LOW
),
1399 (i
% 2) == 1 ? '\n' : ' ');
1403 if ((flags
& CPU_DUMP_FPU
) &&
1404 xtensa_option_enabled(env
->config
, XTENSA_OPTION_DFP_COPROCESSOR
) &&
1405 !xtensa_option_enabled(env
->config
, XTENSA_OPTION_DFPU_SINGLE_ONLY
)) {
1406 qemu_fprintf(f
, "\n");
1408 for (i
= 0; i
< 16; ++i
) {
1409 qemu_fprintf(f
, "F%02d=%016"PRIx64
" (%-+24.16le)%c", i
,
1410 float64_val(env
->fregs
[i
].f64
),
1411 *(double *)(&env
->fregs
[i
].f64
),
1412 (i
% 2) == 1 ? '\n' : ' ');
1417 void restore_state_to_opc(CPUXtensaState
*env
, TranslationBlock
*tb
,
1423 static void translate_abs(DisasContext
*dc
, const OpcodeArg arg
[],
1424 const uint32_t par
[])
1426 tcg_gen_abs_i32(arg
[0].out
, arg
[1].in
);
1429 static void translate_add(DisasContext
*dc
, const OpcodeArg arg
[],
1430 const uint32_t par
[])
1432 tcg_gen_add_i32(arg
[0].out
, arg
[1].in
, arg
[2].in
);
1435 static void translate_addi(DisasContext
*dc
, const OpcodeArg arg
[],
1436 const uint32_t par
[])
1438 tcg_gen_addi_i32(arg
[0].out
, arg
[1].in
, arg
[2].imm
);
1441 static void translate_addx(DisasContext
*dc
, const OpcodeArg arg
[],
1442 const uint32_t par
[])
1444 TCGv_i32 tmp
= tcg_temp_new_i32();
1445 tcg_gen_shli_i32(tmp
, arg
[1].in
, par
[0]);
1446 tcg_gen_add_i32(arg
[0].out
, tmp
, arg
[2].in
);
1450 static void translate_all(DisasContext
*dc
, const OpcodeArg arg
[],
1451 const uint32_t par
[])
1453 uint32_t shift
= par
[1];
1454 TCGv_i32 mask
= tcg_const_i32(((1 << shift
) - 1) << arg
[1].imm
);
1455 TCGv_i32 tmp
= tcg_temp_new_i32();
1457 tcg_gen_and_i32(tmp
, arg
[1].in
, mask
);
1459 tcg_gen_addi_i32(tmp
, tmp
, 1 << arg
[1].imm
);
1461 tcg_gen_add_i32(tmp
, tmp
, mask
);
1463 tcg_gen_shri_i32(tmp
, tmp
, arg
[1].imm
+ shift
);
1464 tcg_gen_deposit_i32(arg
[0].out
, arg
[0].out
,
1465 tmp
, arg
[0].imm
, 1);
1466 tcg_temp_free(mask
);
1470 static void translate_and(DisasContext
*dc
, const OpcodeArg arg
[],
1471 const uint32_t par
[])
1473 tcg_gen_and_i32(arg
[0].out
, arg
[1].in
, arg
[2].in
);
1476 static void translate_ball(DisasContext
*dc
, const OpcodeArg arg
[],
1477 const uint32_t par
[])
1479 TCGv_i32 tmp
= tcg_temp_new_i32();
1480 tcg_gen_and_i32(tmp
, arg
[0].in
, arg
[1].in
);
1481 gen_brcond(dc
, par
[0], tmp
, arg
[1].in
, arg
[2].imm
);
1485 static void translate_bany(DisasContext
*dc
, const OpcodeArg arg
[],
1486 const uint32_t par
[])
1488 TCGv_i32 tmp
= tcg_temp_new_i32();
1489 tcg_gen_and_i32(tmp
, arg
[0].in
, arg
[1].in
);
1490 gen_brcondi(dc
, par
[0], tmp
, 0, arg
[2].imm
);
1494 static void translate_b(DisasContext
*dc
, const OpcodeArg arg
[],
1495 const uint32_t par
[])
1497 gen_brcond(dc
, par
[0], arg
[0].in
, arg
[1].in
, arg
[2].imm
);
1500 static void translate_bb(DisasContext
*dc
, const OpcodeArg arg
[],
1501 const uint32_t par
[])
1503 #ifdef TARGET_WORDS_BIGENDIAN
1504 TCGv_i32 bit
= tcg_const_i32(0x80000000u
);
1506 TCGv_i32 bit
= tcg_const_i32(0x00000001u
);
1508 TCGv_i32 tmp
= tcg_temp_new_i32();
1509 tcg_gen_andi_i32(tmp
, arg
[1].in
, 0x1f);
1510 #ifdef TARGET_WORDS_BIGENDIAN
1511 tcg_gen_shr_i32(bit
, bit
, tmp
);
1513 tcg_gen_shl_i32(bit
, bit
, tmp
);
1515 tcg_gen_and_i32(tmp
, arg
[0].in
, bit
);
1516 gen_brcondi(dc
, par
[0], tmp
, 0, arg
[2].imm
);
1521 static void translate_bbi(DisasContext
*dc
, const OpcodeArg arg
[],
1522 const uint32_t par
[])
1524 TCGv_i32 tmp
= tcg_temp_new_i32();
1525 #ifdef TARGET_WORDS_BIGENDIAN
1526 tcg_gen_andi_i32(tmp
, arg
[0].in
, 0x80000000u
>> arg
[1].imm
);
1528 tcg_gen_andi_i32(tmp
, arg
[0].in
, 0x00000001u
<< arg
[1].imm
);
1530 gen_brcondi(dc
, par
[0], tmp
, 0, arg
[2].imm
);
1534 static void translate_bi(DisasContext
*dc
, const OpcodeArg arg
[],
1535 const uint32_t par
[])
1537 gen_brcondi(dc
, par
[0], arg
[0].in
, arg
[1].imm
, arg
[2].imm
);
1540 static void translate_bz(DisasContext
*dc
, const OpcodeArg arg
[],
1541 const uint32_t par
[])
1543 gen_brcondi(dc
, par
[0], arg
[0].in
, 0, arg
[1].imm
);
1554 static void translate_boolean(DisasContext
*dc
, const OpcodeArg arg
[],
1555 const uint32_t par
[])
1557 static void (* const op
[])(TCGv_i32
, TCGv_i32
, TCGv_i32
) = {
1558 [BOOLEAN_AND
] = tcg_gen_and_i32
,
1559 [BOOLEAN_ANDC
] = tcg_gen_andc_i32
,
1560 [BOOLEAN_OR
] = tcg_gen_or_i32
,
1561 [BOOLEAN_ORC
] = tcg_gen_orc_i32
,
1562 [BOOLEAN_XOR
] = tcg_gen_xor_i32
,
1565 TCGv_i32 tmp1
= tcg_temp_new_i32();
1566 TCGv_i32 tmp2
= tcg_temp_new_i32();
1568 tcg_gen_shri_i32(tmp1
, arg
[1].in
, arg
[1].imm
);
1569 tcg_gen_shri_i32(tmp2
, arg
[2].in
, arg
[2].imm
);
1570 op
[par
[0]](tmp1
, tmp1
, tmp2
);
1571 tcg_gen_deposit_i32(arg
[0].out
, arg
[0].out
, tmp1
, arg
[0].imm
, 1);
1572 tcg_temp_free(tmp1
);
1573 tcg_temp_free(tmp2
);
1576 static void translate_bp(DisasContext
*dc
, const OpcodeArg arg
[],
1577 const uint32_t par
[])
1579 TCGv_i32 tmp
= tcg_temp_new_i32();
1581 tcg_gen_andi_i32(tmp
, arg
[0].in
, 1 << arg
[0].imm
);
1582 gen_brcondi(dc
, par
[0], tmp
, 0, arg
[1].imm
);
1586 static void translate_call0(DisasContext
*dc
, const OpcodeArg arg
[],
1587 const uint32_t par
[])
1589 tcg_gen_movi_i32(cpu_R
[0], dc
->base
.pc_next
);
1590 gen_jumpi(dc
, arg
[0].imm
, 0);
1593 static void translate_callw(DisasContext
*dc
, const OpcodeArg arg
[],
1594 const uint32_t par
[])
1596 TCGv_i32 tmp
= tcg_const_i32(arg
[0].imm
);
1597 gen_callw_slot(dc
, par
[0], tmp
, adjust_jump_slot(dc
, arg
[0].imm
, 0));
1601 static void translate_callx0(DisasContext
*dc
, const OpcodeArg arg
[],
1602 const uint32_t par
[])
1604 TCGv_i32 tmp
= tcg_temp_new_i32();
1605 tcg_gen_mov_i32(tmp
, arg
[0].in
);
1606 tcg_gen_movi_i32(cpu_R
[0], dc
->base
.pc_next
);
1611 static void translate_callxw(DisasContext
*dc
, const OpcodeArg arg
[],
1612 const uint32_t par
[])
1614 TCGv_i32 tmp
= tcg_temp_new_i32();
1616 tcg_gen_mov_i32(tmp
, arg
[0].in
);
1617 gen_callw_slot(dc
, par
[0], tmp
, -1);
1621 static void translate_clamps(DisasContext
*dc
, const OpcodeArg arg
[],
1622 const uint32_t par
[])
1624 TCGv_i32 tmp1
= tcg_const_i32(-1u << arg
[2].imm
);
1625 TCGv_i32 tmp2
= tcg_const_i32((1 << arg
[2].imm
) - 1);
1627 tcg_gen_smax_i32(tmp1
, tmp1
, arg
[1].in
);
1628 tcg_gen_smin_i32(arg
[0].out
, tmp1
, tmp2
);
1629 tcg_temp_free(tmp1
);
1630 tcg_temp_free(tmp2
);
1633 static void translate_clrb_expstate(DisasContext
*dc
, const OpcodeArg arg
[],
1634 const uint32_t par
[])
1636 /* TODO: GPIO32 may be a part of coprocessor */
1637 tcg_gen_andi_i32(cpu_UR
[EXPSTATE
], cpu_UR
[EXPSTATE
], ~(1u << arg
[0].imm
));
1640 static void translate_clrex(DisasContext
*dc
, const OpcodeArg arg
[],
1641 const uint32_t par
[])
1643 tcg_gen_movi_i32(cpu_exclusive_addr
, -1);
1646 static void translate_const16(DisasContext
*dc
, const OpcodeArg arg
[],
1647 const uint32_t par
[])
1649 TCGv_i32 c
= tcg_const_i32(arg
[1].imm
);
1651 tcg_gen_deposit_i32(arg
[0].out
, c
, arg
[0].in
, 16, 16);
1655 static void translate_dcache(DisasContext
*dc
, const OpcodeArg arg
[],
1656 const uint32_t par
[])
1658 TCGv_i32 addr
= tcg_temp_new_i32();
1659 TCGv_i32 res
= tcg_temp_new_i32();
1661 tcg_gen_addi_i32(addr
, arg
[0].in
, arg
[1].imm
);
1662 tcg_gen_qemu_ld8u(res
, addr
, dc
->cring
);
1663 tcg_temp_free(addr
);
1667 static void translate_depbits(DisasContext
*dc
, const OpcodeArg arg
[],
1668 const uint32_t par
[])
1670 tcg_gen_deposit_i32(arg
[1].out
, arg
[1].in
, arg
[0].in
,
1671 arg
[2].imm
, arg
[3].imm
);
1674 static void translate_diwbuip(DisasContext
*dc
, const OpcodeArg arg
[],
1675 const uint32_t par
[])
1677 tcg_gen_addi_i32(arg
[0].out
, arg
[0].in
, dc
->config
->dcache_line_bytes
);
1680 static uint32_t test_exceptions_entry(DisasContext
*dc
, const OpcodeArg arg
[],
1681 const uint32_t par
[])
1683 if (arg
[0].imm
> 3 || !dc
->cwoe
) {
1684 qemu_log_mask(LOG_GUEST_ERROR
,
1685 "Illegal entry instruction(pc = %08x)\n", dc
->pc
);
1686 return XTENSA_OP_ILL
;
1692 static uint32_t test_overflow_entry(DisasContext
*dc
, const OpcodeArg arg
[],
1693 const uint32_t par
[])
1695 return 1 << (dc
->callinc
* 4);
1698 static void translate_entry(DisasContext
*dc
, const OpcodeArg arg
[],
1699 const uint32_t par
[])
1701 TCGv_i32 pc
= tcg_const_i32(dc
->pc
);
1702 TCGv_i32 s
= tcg_const_i32(arg
[0].imm
);
1703 TCGv_i32 imm
= tcg_const_i32(arg
[1].imm
);
1704 gen_helper_entry(cpu_env
, pc
, s
, imm
);
1710 static void translate_extui(DisasContext
*dc
, const OpcodeArg arg
[],
1711 const uint32_t par
[])
1713 int maskimm
= (1 << arg
[3].imm
) - 1;
1715 TCGv_i32 tmp
= tcg_temp_new_i32();
1716 tcg_gen_shri_i32(tmp
, arg
[1].in
, arg
[2].imm
);
1717 tcg_gen_andi_i32(arg
[0].out
, tmp
, maskimm
);
1721 static void translate_getex(DisasContext
*dc
, const OpcodeArg arg
[],
1722 const uint32_t par
[])
1724 TCGv_i32 tmp
= tcg_temp_new_i32();
1726 tcg_gen_extract_i32(tmp
, cpu_SR
[ATOMCTL
], 8, 1);
1727 tcg_gen_deposit_i32(cpu_SR
[ATOMCTL
], cpu_SR
[ATOMCTL
], arg
[0].in
, 8, 1);
1728 tcg_gen_mov_i32(arg
[0].out
, tmp
);
1732 static void translate_icache(DisasContext
*dc
, const OpcodeArg arg
[],
1733 const uint32_t par
[])
1735 #ifndef CONFIG_USER_ONLY
1736 TCGv_i32 addr
= tcg_temp_new_i32();
1738 tcg_gen_movi_i32(cpu_pc
, dc
->pc
);
1739 tcg_gen_addi_i32(addr
, arg
[0].in
, arg
[1].imm
);
1740 gen_helper_itlb_hit_test(cpu_env
, addr
);
1741 tcg_temp_free(addr
);
1745 static void translate_itlb(DisasContext
*dc
, const OpcodeArg arg
[],
1746 const uint32_t par
[])
1748 #ifndef CONFIG_USER_ONLY
1749 TCGv_i32 dtlb
= tcg_const_i32(par
[0]);
1751 gen_helper_itlb(cpu_env
, arg
[0].in
, dtlb
);
1752 tcg_temp_free(dtlb
);
1756 static void translate_j(DisasContext
*dc
, const OpcodeArg arg
[],
1757 const uint32_t par
[])
1759 gen_jumpi(dc
, arg
[0].imm
, 0);
1762 static void translate_jx(DisasContext
*dc
, const OpcodeArg arg
[],
1763 const uint32_t par
[])
1765 gen_jump(dc
, arg
[0].in
);
1768 static void translate_l32e(DisasContext
*dc
, const OpcodeArg arg
[],
1769 const uint32_t par
[])
1771 TCGv_i32 addr
= tcg_temp_new_i32();
1774 tcg_gen_addi_i32(addr
, arg
[1].in
, arg
[2].imm
);
1775 mop
= gen_load_store_alignment(dc
, MO_TEUL
, addr
);
1776 tcg_gen_qemu_ld_tl(arg
[0].out
, addr
, dc
->ring
, mop
);
1777 tcg_temp_free(addr
);
1780 #ifdef CONFIG_USER_ONLY
1781 static void gen_check_exclusive(DisasContext
*dc
, TCGv_i32 addr
, bool is_write
)
1785 static void gen_check_exclusive(DisasContext
*dc
, TCGv_i32 addr
, bool is_write
)
1787 if (!option_enabled(dc
, XTENSA_OPTION_MPU
)) {
1788 TCGv_i32 tpc
= tcg_const_i32(dc
->pc
);
1789 TCGv_i32 write
= tcg_const_i32(is_write
);
1791 gen_helper_check_exclusive(cpu_env
, tpc
, addr
, write
);
1793 tcg_temp_free(write
);
1798 static void translate_l32ex(DisasContext
*dc
, const OpcodeArg arg
[],
1799 const uint32_t par
[])
1801 TCGv_i32 addr
= tcg_temp_new_i32();
1804 tcg_gen_mov_i32(addr
, arg
[1].in
);
1805 mop
= gen_load_store_alignment(dc
, MO_TEUL
| MO_ALIGN
, addr
);
1806 gen_check_exclusive(dc
, addr
, false);
1807 tcg_gen_qemu_ld_i32(arg
[0].out
, addr
, dc
->cring
, mop
);
1808 tcg_gen_mov_i32(cpu_exclusive_addr
, addr
);
1809 tcg_gen_mov_i32(cpu_exclusive_val
, arg
[0].out
);
1810 tcg_temp_free(addr
);
1813 static void translate_ldst(DisasContext
*dc
, const OpcodeArg arg
[],
1814 const uint32_t par
[])
1816 TCGv_i32 addr
= tcg_temp_new_i32();
1819 tcg_gen_addi_i32(addr
, arg
[1].in
, arg
[2].imm
);
1820 mop
= gen_load_store_alignment(dc
, par
[0], addr
);
1824 tcg_gen_mb(TCG_BAR_STRL
| TCG_MO_ALL
);
1826 tcg_gen_qemu_st_tl(arg
[0].in
, addr
, dc
->cring
, mop
);
1828 tcg_gen_qemu_ld_tl(arg
[0].out
, addr
, dc
->cring
, mop
);
1830 tcg_gen_mb(TCG_BAR_LDAQ
| TCG_MO_ALL
);
1833 tcg_temp_free(addr
);
1836 static void translate_l32r(DisasContext
*dc
, const OpcodeArg arg
[],
1837 const uint32_t par
[])
1841 if (dc
->base
.tb
->flags
& XTENSA_TBFLAG_LITBASE
) {
1842 tmp
= tcg_const_i32(arg
[1].raw_imm
- 1);
1843 tcg_gen_add_i32(tmp
, cpu_SR
[LITBASE
], tmp
);
1845 tmp
= tcg_const_i32(arg
[1].imm
);
1847 tcg_gen_qemu_ld32u(arg
[0].out
, tmp
, dc
->cring
);
1851 static void translate_loop(DisasContext
*dc
, const OpcodeArg arg
[],
1852 const uint32_t par
[])
1854 uint32_t lend
= arg
[1].imm
;
1856 tcg_gen_subi_i32(cpu_SR
[LCOUNT
], arg
[0].in
, 1);
1857 tcg_gen_movi_i32(cpu_SR
[LBEG
], dc
->base
.pc_next
);
1858 tcg_gen_movi_i32(cpu_SR
[LEND
], lend
);
1860 if (par
[0] != TCG_COND_NEVER
) {
1861 TCGLabel
*label
= gen_new_label();
1862 tcg_gen_brcondi_i32(par
[0], arg
[0].in
, 0, label
);
1863 gen_jumpi(dc
, lend
, 1);
1864 gen_set_label(label
);
1867 gen_jumpi(dc
, dc
->base
.pc_next
, 0);
1888 static void translate_mac16(DisasContext
*dc
, const OpcodeArg arg
[],
1889 const uint32_t par
[])
1892 unsigned half
= par
[1];
1893 uint32_t ld_offset
= par
[2];
1894 unsigned off
= ld_offset
? 2 : 0;
1895 TCGv_i32 vaddr
= tcg_temp_new_i32();
1896 TCGv_i32 mem32
= tcg_temp_new_i32();
1901 tcg_gen_addi_i32(vaddr
, arg
[1].in
, ld_offset
);
1902 mop
= gen_load_store_alignment(dc
, MO_TEUL
, vaddr
);
1903 tcg_gen_qemu_ld_tl(mem32
, vaddr
, dc
->cring
, mop
);
1905 if (op
!= MAC16_NONE
) {
1906 TCGv_i32 m1
= gen_mac16_m(arg
[off
].in
,
1907 half
& MAC16_HX
, op
== MAC16_UMUL
);
1908 TCGv_i32 m2
= gen_mac16_m(arg
[off
+ 1].in
,
1909 half
& MAC16_XH
, op
== MAC16_UMUL
);
1911 if (op
== MAC16_MUL
|| op
== MAC16_UMUL
) {
1912 tcg_gen_mul_i32(cpu_SR
[ACCLO
], m1
, m2
);
1913 if (op
== MAC16_UMUL
) {
1914 tcg_gen_movi_i32(cpu_SR
[ACCHI
], 0);
1916 tcg_gen_sari_i32(cpu_SR
[ACCHI
], cpu_SR
[ACCLO
], 31);
1919 TCGv_i32 lo
= tcg_temp_new_i32();
1920 TCGv_i32 hi
= tcg_temp_new_i32();
1922 tcg_gen_mul_i32(lo
, m1
, m2
);
1923 tcg_gen_sari_i32(hi
, lo
, 31);
1924 if (op
== MAC16_MULA
) {
1925 tcg_gen_add2_i32(cpu_SR
[ACCLO
], cpu_SR
[ACCHI
],
1926 cpu_SR
[ACCLO
], cpu_SR
[ACCHI
],
1929 tcg_gen_sub2_i32(cpu_SR
[ACCLO
], cpu_SR
[ACCHI
],
1930 cpu_SR
[ACCLO
], cpu_SR
[ACCHI
],
1933 tcg_gen_ext8s_i32(cpu_SR
[ACCHI
], cpu_SR
[ACCHI
]);
1935 tcg_temp_free_i32(lo
);
1936 tcg_temp_free_i32(hi
);
1942 tcg_gen_mov_i32(arg
[1].out
, vaddr
);
1943 tcg_gen_mov_i32(cpu_SR
[MR
+ arg
[0].imm
], mem32
);
1945 tcg_temp_free(vaddr
);
1946 tcg_temp_free(mem32
);
1949 static void translate_memw(DisasContext
*dc
, const OpcodeArg arg
[],
1950 const uint32_t par
[])
1952 tcg_gen_mb(TCG_BAR_SC
| TCG_MO_ALL
);
1955 static void translate_smin(DisasContext
*dc
, const OpcodeArg arg
[],
1956 const uint32_t par
[])
1958 tcg_gen_smin_i32(arg
[0].out
, arg
[1].in
, arg
[2].in
);
1961 static void translate_umin(DisasContext
*dc
, const OpcodeArg arg
[],
1962 const uint32_t par
[])
1964 tcg_gen_umin_i32(arg
[0].out
, arg
[1].in
, arg
[2].in
);
1967 static void translate_smax(DisasContext
*dc
, const OpcodeArg arg
[],
1968 const uint32_t par
[])
1970 tcg_gen_smax_i32(arg
[0].out
, arg
[1].in
, arg
[2].in
);
1973 static void translate_umax(DisasContext
*dc
, const OpcodeArg arg
[],
1974 const uint32_t par
[])
1976 tcg_gen_umax_i32(arg
[0].out
, arg
[1].in
, arg
[2].in
);
1979 static void translate_mov(DisasContext
*dc
, const OpcodeArg arg
[],
1980 const uint32_t par
[])
1982 tcg_gen_mov_i32(arg
[0].out
, arg
[1].in
);
1985 static void translate_movcond(DisasContext
*dc
, const OpcodeArg arg
[],
1986 const uint32_t par
[])
1988 TCGv_i32 zero
= tcg_const_i32(0);
1990 tcg_gen_movcond_i32(par
[0], arg
[0].out
,
1991 arg
[2].in
, zero
, arg
[1].in
, arg
[0].in
);
1992 tcg_temp_free(zero
);
1995 static void translate_movi(DisasContext
*dc
, const OpcodeArg arg
[],
1996 const uint32_t par
[])
1998 tcg_gen_movi_i32(arg
[0].out
, arg
[1].imm
);
2001 static void translate_movp(DisasContext
*dc
, const OpcodeArg arg
[],
2002 const uint32_t par
[])
2004 TCGv_i32 zero
= tcg_const_i32(0);
2005 TCGv_i32 tmp
= tcg_temp_new_i32();
2007 tcg_gen_andi_i32(tmp
, arg
[2].in
, 1 << arg
[2].imm
);
2008 tcg_gen_movcond_i32(par
[0],
2009 arg
[0].out
, tmp
, zero
,
2010 arg
[1].in
, arg
[0].in
);
2012 tcg_temp_free(zero
);
2015 static void translate_movsp(DisasContext
*dc
, const OpcodeArg arg
[],
2016 const uint32_t par
[])
2018 tcg_gen_mov_i32(arg
[0].out
, arg
[1].in
);
2021 static void translate_mul16(DisasContext
*dc
, const OpcodeArg arg
[],
2022 const uint32_t par
[])
2024 TCGv_i32 v1
= tcg_temp_new_i32();
2025 TCGv_i32 v2
= tcg_temp_new_i32();
2028 tcg_gen_ext16s_i32(v1
, arg
[1].in
);
2029 tcg_gen_ext16s_i32(v2
, arg
[2].in
);
2031 tcg_gen_ext16u_i32(v1
, arg
[1].in
);
2032 tcg_gen_ext16u_i32(v2
, arg
[2].in
);
2034 tcg_gen_mul_i32(arg
[0].out
, v1
, v2
);
2039 static void translate_mull(DisasContext
*dc
, const OpcodeArg arg
[],
2040 const uint32_t par
[])
2042 tcg_gen_mul_i32(arg
[0].out
, arg
[1].in
, arg
[2].in
);
2045 static void translate_mulh(DisasContext
*dc
, const OpcodeArg arg
[],
2046 const uint32_t par
[])
2048 TCGv_i32 lo
= tcg_temp_new();
2051 tcg_gen_muls2_i32(lo
, arg
[0].out
, arg
[1].in
, arg
[2].in
);
2053 tcg_gen_mulu2_i32(lo
, arg
[0].out
, arg
[1].in
, arg
[2].in
);
2058 static void translate_neg(DisasContext
*dc
, const OpcodeArg arg
[],
2059 const uint32_t par
[])
2061 tcg_gen_neg_i32(arg
[0].out
, arg
[1].in
);
2064 static void translate_nop(DisasContext
*dc
, const OpcodeArg arg
[],
2065 const uint32_t par
[])
2069 static void translate_nsa(DisasContext
*dc
, const OpcodeArg arg
[],
2070 const uint32_t par
[])
2072 tcg_gen_clrsb_i32(arg
[0].out
, arg
[1].in
);
2075 static void translate_nsau(DisasContext
*dc
, const OpcodeArg arg
[],
2076 const uint32_t par
[])
2078 tcg_gen_clzi_i32(arg
[0].out
, arg
[1].in
, 32);
2081 static void translate_or(DisasContext
*dc
, const OpcodeArg arg
[],
2082 const uint32_t par
[])
2084 tcg_gen_or_i32(arg
[0].out
, arg
[1].in
, arg
[2].in
);
2087 static void translate_ptlb(DisasContext
*dc
, const OpcodeArg arg
[],
2088 const uint32_t par
[])
2090 #ifndef CONFIG_USER_ONLY
2091 TCGv_i32 dtlb
= tcg_const_i32(par
[0]);
2093 tcg_gen_movi_i32(cpu_pc
, dc
->pc
);
2094 gen_helper_ptlb(arg
[0].out
, cpu_env
, arg
[1].in
, dtlb
);
2095 tcg_temp_free(dtlb
);
2099 static void translate_pptlb(DisasContext
*dc
, const OpcodeArg arg
[],
2100 const uint32_t par
[])
2102 #ifndef CONFIG_USER_ONLY
2103 tcg_gen_movi_i32(cpu_pc
, dc
->pc
);
2104 gen_helper_pptlb(arg
[0].out
, cpu_env
, arg
[1].in
);
2108 static void translate_quos(DisasContext
*dc
, const OpcodeArg arg
[],
2109 const uint32_t par
[])
2111 TCGLabel
*label1
= gen_new_label();
2112 TCGLabel
*label2
= gen_new_label();
2114 tcg_gen_brcondi_i32(TCG_COND_NE
, arg
[1].in
, 0x80000000,
2116 tcg_gen_brcondi_i32(TCG_COND_NE
, arg
[2].in
, 0xffffffff,
2118 tcg_gen_movi_i32(arg
[0].out
,
2119 par
[0] ? 0x80000000 : 0);
2121 gen_set_label(label1
);
2123 tcg_gen_div_i32(arg
[0].out
,
2124 arg
[1].in
, arg
[2].in
);
2126 tcg_gen_rem_i32(arg
[0].out
,
2127 arg
[1].in
, arg
[2].in
);
2129 gen_set_label(label2
);
2132 static void translate_quou(DisasContext
*dc
, const OpcodeArg arg
[],
2133 const uint32_t par
[])
2135 tcg_gen_divu_i32(arg
[0].out
,
2136 arg
[1].in
, arg
[2].in
);
2139 static void translate_read_impwire(DisasContext
*dc
, const OpcodeArg arg
[],
2140 const uint32_t par
[])
2142 /* TODO: GPIO32 may be a part of coprocessor */
2143 tcg_gen_movi_i32(arg
[0].out
, 0);
2146 static void translate_remu(DisasContext
*dc
, const OpcodeArg arg
[],
2147 const uint32_t par
[])
2149 tcg_gen_remu_i32(arg
[0].out
,
2150 arg
[1].in
, arg
[2].in
);
2153 static void translate_rer(DisasContext
*dc
, const OpcodeArg arg
[],
2154 const uint32_t par
[])
2156 gen_helper_rer(arg
[0].out
, cpu_env
, arg
[1].in
);
2159 static void translate_ret(DisasContext
*dc
, const OpcodeArg arg
[],
2160 const uint32_t par
[])
2162 gen_jump(dc
, cpu_R
[0]);
2165 static uint32_t test_exceptions_retw(DisasContext
*dc
, const OpcodeArg arg
[],
2166 const uint32_t par
[])
2169 qemu_log_mask(LOG_GUEST_ERROR
,
2170 "Illegal retw instruction(pc = %08x)\n", dc
->pc
);
2171 return XTENSA_OP_ILL
;
2173 TCGv_i32 tmp
= tcg_const_i32(dc
->pc
);
2175 gen_helper_test_ill_retw(cpu_env
, tmp
);
2181 static void translate_retw(DisasContext
*dc
, const OpcodeArg arg
[],
2182 const uint32_t par
[])
2184 TCGv_i32 tmp
= tcg_const_i32(1);
2185 tcg_gen_shl_i32(tmp
, tmp
, cpu_SR
[WINDOW_BASE
]);
2186 tcg_gen_andc_i32(cpu_SR
[WINDOW_START
],
2187 cpu_SR
[WINDOW_START
], tmp
);
2188 tcg_gen_movi_i32(tmp
, dc
->pc
);
2189 tcg_gen_deposit_i32(tmp
, tmp
, cpu_R
[0], 0, 30);
2190 gen_helper_retw(cpu_env
, cpu_R
[0]);
2195 static void translate_rfde(DisasContext
*dc
, const OpcodeArg arg
[],
2196 const uint32_t par
[])
2198 gen_jump(dc
, cpu_SR
[dc
->config
->ndepc
? DEPC
: EPC1
]);
2201 static void translate_rfe(DisasContext
*dc
, const OpcodeArg arg
[],
2202 const uint32_t par
[])
2204 tcg_gen_andi_i32(cpu_SR
[PS
], cpu_SR
[PS
], ~PS_EXCM
);
2205 gen_jump(dc
, cpu_SR
[EPC1
]);
2208 static void translate_rfi(DisasContext
*dc
, const OpcodeArg arg
[],
2209 const uint32_t par
[])
2211 tcg_gen_mov_i32(cpu_SR
[PS
], cpu_SR
[EPS2
+ arg
[0].imm
- 2]);
2212 gen_jump(dc
, cpu_SR
[EPC1
+ arg
[0].imm
- 1]);
2215 static void translate_rfw(DisasContext
*dc
, const OpcodeArg arg
[],
2216 const uint32_t par
[])
2218 TCGv_i32 tmp
= tcg_const_i32(1);
2220 tcg_gen_andi_i32(cpu_SR
[PS
], cpu_SR
[PS
], ~PS_EXCM
);
2221 tcg_gen_shl_i32(tmp
, tmp
, cpu_SR
[WINDOW_BASE
]);
2224 tcg_gen_andc_i32(cpu_SR
[WINDOW_START
],
2225 cpu_SR
[WINDOW_START
], tmp
);
2227 tcg_gen_or_i32(cpu_SR
[WINDOW_START
],
2228 cpu_SR
[WINDOW_START
], tmp
);
2232 gen_helper_restore_owb(cpu_env
);
2233 gen_jump(dc
, cpu_SR
[EPC1
]);
2236 static void translate_rotw(DisasContext
*dc
, const OpcodeArg arg
[],
2237 const uint32_t par
[])
2239 tcg_gen_addi_i32(cpu_windowbase_next
, cpu_SR
[WINDOW_BASE
], arg
[0].imm
);
2242 static void translate_rsil(DisasContext
*dc
, const OpcodeArg arg
[],
2243 const uint32_t par
[])
2245 tcg_gen_mov_i32(arg
[0].out
, cpu_SR
[PS
]);
2246 tcg_gen_andi_i32(cpu_SR
[PS
], cpu_SR
[PS
], ~PS_INTLEVEL
);
2247 tcg_gen_ori_i32(cpu_SR
[PS
], cpu_SR
[PS
], arg
[1].imm
);
2250 static void translate_rsr(DisasContext
*dc
, const OpcodeArg arg
[],
2251 const uint32_t par
[])
2253 if (sr_name
[par
[0]]) {
2254 tcg_gen_mov_i32(arg
[0].out
, cpu_SR
[par
[0]]);
2256 tcg_gen_movi_i32(arg
[0].out
, 0);
2260 static void translate_rsr_ccount(DisasContext
*dc
, const OpcodeArg arg
[],
2261 const uint32_t par
[])
2263 #ifndef CONFIG_USER_ONLY
2264 if (tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
) {
2267 gen_helper_update_ccount(cpu_env
);
2268 tcg_gen_mov_i32(arg
[0].out
, cpu_SR
[par
[0]]);
2272 static void translate_rsr_ptevaddr(DisasContext
*dc
, const OpcodeArg arg
[],
2273 const uint32_t par
[])
2275 #ifndef CONFIG_USER_ONLY
2276 TCGv_i32 tmp
= tcg_temp_new_i32();
2278 tcg_gen_shri_i32(tmp
, cpu_SR
[EXCVADDR
], 10);
2279 tcg_gen_or_i32(tmp
, tmp
, cpu_SR
[PTEVADDR
]);
2280 tcg_gen_andi_i32(arg
[0].out
, tmp
, 0xfffffffc);
2285 static void translate_rtlb(DisasContext
*dc
, const OpcodeArg arg
[],
2286 const uint32_t par
[])
2288 #ifndef CONFIG_USER_ONLY
2289 static void (* const helper
[])(TCGv_i32 r
, TCGv_env env
, TCGv_i32 a1
,
2294 TCGv_i32 dtlb
= tcg_const_i32(par
[0]);
2296 helper
[par
[1]](arg
[0].out
, cpu_env
, arg
[1].in
, dtlb
);
2297 tcg_temp_free(dtlb
);
2301 static void translate_rptlb0(DisasContext
*dc
, const OpcodeArg arg
[],
2302 const uint32_t par
[])
2304 #ifndef CONFIG_USER_ONLY
2305 gen_helper_rptlb0(arg
[0].out
, cpu_env
, arg
[1].in
);
2309 static void translate_rptlb1(DisasContext
*dc
, const OpcodeArg arg
[],
2310 const uint32_t par
[])
2312 #ifndef CONFIG_USER_ONLY
2313 gen_helper_rptlb1(arg
[0].out
, cpu_env
, arg
[1].in
);
2317 static void translate_rur(DisasContext
*dc
, const OpcodeArg arg
[],
2318 const uint32_t par
[])
2320 tcg_gen_mov_i32(arg
[0].out
, cpu_UR
[par
[0]]);
2323 static void translate_setb_expstate(DisasContext
*dc
, const OpcodeArg arg
[],
2324 const uint32_t par
[])
2326 /* TODO: GPIO32 may be a part of coprocessor */
2327 tcg_gen_ori_i32(cpu_UR
[EXPSTATE
], cpu_UR
[EXPSTATE
], 1u << arg
[0].imm
);
2330 #ifdef CONFIG_USER_ONLY
2331 static void gen_check_atomctl(DisasContext
*dc
, TCGv_i32 addr
)
2335 static void gen_check_atomctl(DisasContext
*dc
, TCGv_i32 addr
)
2337 TCGv_i32 tpc
= tcg_const_i32(dc
->pc
);
2339 gen_helper_check_atomctl(cpu_env
, tpc
, addr
);
2344 static void translate_s32c1i(DisasContext
*dc
, const OpcodeArg arg
[],
2345 const uint32_t par
[])
2347 TCGv_i32 tmp
= tcg_temp_local_new_i32();
2348 TCGv_i32 addr
= tcg_temp_local_new_i32();
2351 tcg_gen_mov_i32(tmp
, arg
[0].in
);
2352 tcg_gen_addi_i32(addr
, arg
[1].in
, arg
[2].imm
);
2353 mop
= gen_load_store_alignment(dc
, MO_TEUL
| MO_ALIGN
, addr
);
2354 gen_check_atomctl(dc
, addr
);
2355 tcg_gen_atomic_cmpxchg_i32(arg
[0].out
, addr
, cpu_SR
[SCOMPARE1
],
2356 tmp
, dc
->cring
, mop
);
2357 tcg_temp_free(addr
);
2361 static void translate_s32e(DisasContext
*dc
, const OpcodeArg arg
[],
2362 const uint32_t par
[])
2364 TCGv_i32 addr
= tcg_temp_new_i32();
2367 tcg_gen_addi_i32(addr
, arg
[1].in
, arg
[2].imm
);
2368 mop
= gen_load_store_alignment(dc
, MO_TEUL
, addr
);
2369 tcg_gen_qemu_st_tl(arg
[0].in
, addr
, dc
->ring
, mop
);
2370 tcg_temp_free(addr
);
2373 static void translate_s32ex(DisasContext
*dc
, const OpcodeArg arg
[],
2374 const uint32_t par
[])
2376 TCGv_i32 prev
= tcg_temp_new_i32();
2377 TCGv_i32 addr
= tcg_temp_local_new_i32();
2378 TCGv_i32 res
= tcg_temp_local_new_i32();
2379 TCGLabel
*label
= gen_new_label();
2382 tcg_gen_movi_i32(res
, 0);
2383 tcg_gen_mov_i32(addr
, arg
[1].in
);
2384 mop
= gen_load_store_alignment(dc
, MO_TEUL
| MO_ALIGN
, addr
);
2385 tcg_gen_brcond_i32(TCG_COND_NE
, addr
, cpu_exclusive_addr
, label
);
2386 gen_check_exclusive(dc
, addr
, true);
2387 tcg_gen_atomic_cmpxchg_i32(prev
, cpu_exclusive_addr
, cpu_exclusive_val
,
2388 arg
[0].in
, dc
->cring
, mop
);
2389 tcg_gen_setcond_i32(TCG_COND_EQ
, res
, prev
, cpu_exclusive_val
);
2390 tcg_gen_movcond_i32(TCG_COND_EQ
, cpu_exclusive_val
,
2391 prev
, cpu_exclusive_val
, prev
, cpu_exclusive_val
);
2392 tcg_gen_movi_i32(cpu_exclusive_addr
, -1);
2393 gen_set_label(label
);
2394 tcg_gen_extract_i32(arg
[0].out
, cpu_SR
[ATOMCTL
], 8, 1);
2395 tcg_gen_deposit_i32(cpu_SR
[ATOMCTL
], cpu_SR
[ATOMCTL
], res
, 8, 1);
2396 tcg_temp_free(prev
);
2397 tcg_temp_free(addr
);
2401 static void translate_salt(DisasContext
*dc
, const OpcodeArg arg
[],
2402 const uint32_t par
[])
2404 tcg_gen_setcond_i32(par
[0],
2406 arg
[1].in
, arg
[2].in
);
2409 static void translate_sext(DisasContext
*dc
, const OpcodeArg arg
[],
2410 const uint32_t par
[])
2412 int shift
= 31 - arg
[2].imm
;
2415 tcg_gen_ext8s_i32(arg
[0].out
, arg
[1].in
);
2416 } else if (shift
== 16) {
2417 tcg_gen_ext16s_i32(arg
[0].out
, arg
[1].in
);
2419 TCGv_i32 tmp
= tcg_temp_new_i32();
2420 tcg_gen_shli_i32(tmp
, arg
[1].in
, shift
);
2421 tcg_gen_sari_i32(arg
[0].out
, tmp
, shift
);
2426 static uint32_t test_exceptions_simcall(DisasContext
*dc
,
2427 const OpcodeArg arg
[],
2428 const uint32_t par
[])
2430 #ifdef CONFIG_USER_ONLY
2433 /* Between RE.2 and RE.3 simcall opcode's become nop for the hardware. */
2434 bool ill
= dc
->config
->hw_version
<= 250002 && !semihosting_enabled();
2436 if (ill
|| !semihosting_enabled()) {
2437 qemu_log_mask(LOG_GUEST_ERROR
, "SIMCALL but semihosting is disabled\n");
2439 return ill
? XTENSA_OP_ILL
: 0;
2442 static void translate_simcall(DisasContext
*dc
, const OpcodeArg arg
[],
2443 const uint32_t par
[])
2445 #ifndef CONFIG_USER_ONLY
2446 if (semihosting_enabled()) {
2447 gen_helper_simcall(cpu_env
);
2453 * Note: 64 bit ops are used here solely because SAR values
2456 #define gen_shift_reg(cmd, reg) do { \
2457 TCGv_i64 tmp = tcg_temp_new_i64(); \
2458 tcg_gen_extu_i32_i64(tmp, reg); \
2459 tcg_gen_##cmd##_i64(v, v, tmp); \
2460 tcg_gen_extrl_i64_i32(arg[0].out, v); \
2461 tcg_temp_free_i64(v); \
2462 tcg_temp_free_i64(tmp); \
2465 #define gen_shift(cmd) gen_shift_reg(cmd, cpu_SR[SAR])
2467 static void translate_sll(DisasContext
*dc
, const OpcodeArg arg
[],
2468 const uint32_t par
[])
2470 if (dc
->sar_m32_5bit
) {
2471 tcg_gen_shl_i32(arg
[0].out
, arg
[1].in
, dc
->sar_m32
);
2473 TCGv_i64 v
= tcg_temp_new_i64();
2474 TCGv_i32 s
= tcg_const_i32(32);
2475 tcg_gen_sub_i32(s
, s
, cpu_SR
[SAR
]);
2476 tcg_gen_andi_i32(s
, s
, 0x3f);
2477 tcg_gen_extu_i32_i64(v
, arg
[1].in
);
2478 gen_shift_reg(shl
, s
);
2483 static void translate_slli(DisasContext
*dc
, const OpcodeArg arg
[],
2484 const uint32_t par
[])
2486 if (arg
[2].imm
== 32) {
2487 qemu_log_mask(LOG_GUEST_ERROR
, "slli a%d, a%d, 32 is undefined\n",
2488 arg
[0].imm
, arg
[1].imm
);
2490 tcg_gen_shli_i32(arg
[0].out
, arg
[1].in
, arg
[2].imm
& 0x1f);
2493 static void translate_sra(DisasContext
*dc
, const OpcodeArg arg
[],
2494 const uint32_t par
[])
2496 if (dc
->sar_m32_5bit
) {
2497 tcg_gen_sar_i32(arg
[0].out
, arg
[1].in
, cpu_SR
[SAR
]);
2499 TCGv_i64 v
= tcg_temp_new_i64();
2500 tcg_gen_ext_i32_i64(v
, arg
[1].in
);
2505 static void translate_srai(DisasContext
*dc
, const OpcodeArg arg
[],
2506 const uint32_t par
[])
2508 tcg_gen_sari_i32(arg
[0].out
, arg
[1].in
, arg
[2].imm
);
2511 static void translate_src(DisasContext
*dc
, const OpcodeArg arg
[],
2512 const uint32_t par
[])
2514 TCGv_i64 v
= tcg_temp_new_i64();
2515 tcg_gen_concat_i32_i64(v
, arg
[2].in
, arg
[1].in
);
2519 static void translate_srl(DisasContext
*dc
, const OpcodeArg arg
[],
2520 const uint32_t par
[])
2522 if (dc
->sar_m32_5bit
) {
2523 tcg_gen_shr_i32(arg
[0].out
, arg
[1].in
, cpu_SR
[SAR
]);
2525 TCGv_i64 v
= tcg_temp_new_i64();
2526 tcg_gen_extu_i32_i64(v
, arg
[1].in
);
2532 #undef gen_shift_reg
2534 static void translate_srli(DisasContext
*dc
, const OpcodeArg arg
[],
2535 const uint32_t par
[])
2537 tcg_gen_shri_i32(arg
[0].out
, arg
[1].in
, arg
[2].imm
);
2540 static void translate_ssa8b(DisasContext
*dc
, const OpcodeArg arg
[],
2541 const uint32_t par
[])
2543 TCGv_i32 tmp
= tcg_temp_new_i32();
2544 tcg_gen_shli_i32(tmp
, arg
[0].in
, 3);
2545 gen_left_shift_sar(dc
, tmp
);
2549 static void translate_ssa8l(DisasContext
*dc
, const OpcodeArg arg
[],
2550 const uint32_t par
[])
2552 TCGv_i32 tmp
= tcg_temp_new_i32();
2553 tcg_gen_shli_i32(tmp
, arg
[0].in
, 3);
2554 gen_right_shift_sar(dc
, tmp
);
2558 static void translate_ssai(DisasContext
*dc
, const OpcodeArg arg
[],
2559 const uint32_t par
[])
2561 TCGv_i32 tmp
= tcg_const_i32(arg
[0].imm
);
2562 gen_right_shift_sar(dc
, tmp
);
2566 static void translate_ssl(DisasContext
*dc
, const OpcodeArg arg
[],
2567 const uint32_t par
[])
2569 gen_left_shift_sar(dc
, arg
[0].in
);
2572 static void translate_ssr(DisasContext
*dc
, const OpcodeArg arg
[],
2573 const uint32_t par
[])
2575 gen_right_shift_sar(dc
, arg
[0].in
);
2578 static void translate_sub(DisasContext
*dc
, const OpcodeArg arg
[],
2579 const uint32_t par
[])
2581 tcg_gen_sub_i32(arg
[0].out
, arg
[1].in
, arg
[2].in
);
2584 static void translate_subx(DisasContext
*dc
, const OpcodeArg arg
[],
2585 const uint32_t par
[])
2587 TCGv_i32 tmp
= tcg_temp_new_i32();
2588 tcg_gen_shli_i32(tmp
, arg
[1].in
, par
[0]);
2589 tcg_gen_sub_i32(arg
[0].out
, tmp
, arg
[2].in
);
2593 static void translate_waiti(DisasContext
*dc
, const OpcodeArg arg
[],
2594 const uint32_t par
[])
2596 #ifndef CONFIG_USER_ONLY
2597 gen_waiti(dc
, arg
[0].imm
);
2601 static void translate_wtlb(DisasContext
*dc
, const OpcodeArg arg
[],
2602 const uint32_t par
[])
2604 #ifndef CONFIG_USER_ONLY
2605 TCGv_i32 dtlb
= tcg_const_i32(par
[0]);
2607 gen_helper_wtlb(cpu_env
, arg
[0].in
, arg
[1].in
, dtlb
);
2608 tcg_temp_free(dtlb
);
2612 static void translate_wptlb(DisasContext
*dc
, const OpcodeArg arg
[],
2613 const uint32_t par
[])
2615 #ifndef CONFIG_USER_ONLY
2616 gen_helper_wptlb(cpu_env
, arg
[0].in
, arg
[1].in
);
2620 static void translate_wer(DisasContext
*dc
, const OpcodeArg arg
[],
2621 const uint32_t par
[])
2623 gen_helper_wer(cpu_env
, arg
[0].in
, arg
[1].in
);
2626 static void translate_wrmsk_expstate(DisasContext
*dc
, const OpcodeArg arg
[],
2627 const uint32_t par
[])
2629 /* TODO: GPIO32 may be a part of coprocessor */
2630 tcg_gen_and_i32(cpu_UR
[EXPSTATE
], arg
[0].in
, arg
[1].in
);
2633 static void translate_wsr(DisasContext
*dc
, const OpcodeArg arg
[],
2634 const uint32_t par
[])
2636 if (sr_name
[par
[0]]) {
2637 tcg_gen_mov_i32(cpu_SR
[par
[0]], arg
[0].in
);
2641 static void translate_wsr_mask(DisasContext
*dc
, const OpcodeArg arg
[],
2642 const uint32_t par
[])
2644 if (sr_name
[par
[0]]) {
2645 tcg_gen_andi_i32(cpu_SR
[par
[0]], arg
[0].in
, par
[2]);
2649 static void translate_wsr_acchi(DisasContext
*dc
, const OpcodeArg arg
[],
2650 const uint32_t par
[])
2652 tcg_gen_ext8s_i32(cpu_SR
[par
[0]], arg
[0].in
);
2655 static void translate_wsr_ccompare(DisasContext
*dc
, const OpcodeArg arg
[],
2656 const uint32_t par
[])
2658 #ifndef CONFIG_USER_ONLY
2659 uint32_t id
= par
[0] - CCOMPARE
;
2660 TCGv_i32 tmp
= tcg_const_i32(id
);
2662 assert(id
< dc
->config
->nccompare
);
2663 if (tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
) {
2666 tcg_gen_mov_i32(cpu_SR
[par
[0]], arg
[0].in
);
2667 gen_helper_update_ccompare(cpu_env
, tmp
);
2672 static void translate_wsr_ccount(DisasContext
*dc
, const OpcodeArg arg
[],
2673 const uint32_t par
[])
2675 #ifndef CONFIG_USER_ONLY
2676 if (tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
) {
2679 gen_helper_wsr_ccount(cpu_env
, arg
[0].in
);
2683 static void translate_wsr_dbreaka(DisasContext
*dc
, const OpcodeArg arg
[],
2684 const uint32_t par
[])
2686 #ifndef CONFIG_USER_ONLY
2687 unsigned id
= par
[0] - DBREAKA
;
2688 TCGv_i32 tmp
= tcg_const_i32(id
);
2690 assert(id
< dc
->config
->ndbreak
);
2691 gen_helper_wsr_dbreaka(cpu_env
, tmp
, arg
[0].in
);
2696 static void translate_wsr_dbreakc(DisasContext
*dc
, const OpcodeArg arg
[],
2697 const uint32_t par
[])
2699 #ifndef CONFIG_USER_ONLY
2700 unsigned id
= par
[0] - DBREAKC
;
2701 TCGv_i32 tmp
= tcg_const_i32(id
);
2703 assert(id
< dc
->config
->ndbreak
);
2704 gen_helper_wsr_dbreakc(cpu_env
, tmp
, arg
[0].in
);
2709 static void translate_wsr_ibreaka(DisasContext
*dc
, const OpcodeArg arg
[],
2710 const uint32_t par
[])
2712 #ifndef CONFIG_USER_ONLY
2713 unsigned id
= par
[0] - IBREAKA
;
2714 TCGv_i32 tmp
= tcg_const_i32(id
);
2716 assert(id
< dc
->config
->nibreak
);
2717 gen_helper_wsr_ibreaka(cpu_env
, tmp
, arg
[0].in
);
2722 static void translate_wsr_ibreakenable(DisasContext
*dc
, const OpcodeArg arg
[],
2723 const uint32_t par
[])
2725 #ifndef CONFIG_USER_ONLY
2726 gen_helper_wsr_ibreakenable(cpu_env
, arg
[0].in
);
2730 static void translate_wsr_icount(DisasContext
*dc
, const OpcodeArg arg
[],
2731 const uint32_t par
[])
2733 #ifndef CONFIG_USER_ONLY
2735 tcg_gen_mov_i32(dc
->next_icount
, arg
[0].in
);
2737 tcg_gen_mov_i32(cpu_SR
[par
[0]], arg
[0].in
);
2742 static void translate_wsr_intclear(DisasContext
*dc
, const OpcodeArg arg
[],
2743 const uint32_t par
[])
2745 #ifndef CONFIG_USER_ONLY
2746 gen_helper_intclear(cpu_env
, arg
[0].in
);
2750 static void translate_wsr_intset(DisasContext
*dc
, const OpcodeArg arg
[],
2751 const uint32_t par
[])
2753 #ifndef CONFIG_USER_ONLY
2754 gen_helper_intset(cpu_env
, arg
[0].in
);
2758 static void translate_wsr_memctl(DisasContext
*dc
, const OpcodeArg arg
[],
2759 const uint32_t par
[])
2761 #ifndef CONFIG_USER_ONLY
2762 gen_helper_wsr_memctl(cpu_env
, arg
[0].in
);
2766 static void translate_wsr_mpuenb(DisasContext
*dc
, const OpcodeArg arg
[],
2767 const uint32_t par
[])
2769 #ifndef CONFIG_USER_ONLY
2770 gen_helper_wsr_mpuenb(cpu_env
, arg
[0].in
);
2774 static void translate_wsr_ps(DisasContext
*dc
, const OpcodeArg arg
[],
2775 const uint32_t par
[])
2777 #ifndef CONFIG_USER_ONLY
2778 uint32_t mask
= PS_WOE
| PS_CALLINC
| PS_OWB
|
2779 PS_UM
| PS_EXCM
| PS_INTLEVEL
;
2781 if (option_enabled(dc
, XTENSA_OPTION_MMU
) ||
2782 option_enabled(dc
, XTENSA_OPTION_MPU
)) {
2785 tcg_gen_andi_i32(cpu_SR
[par
[0]], arg
[0].in
, mask
);
2789 static void translate_wsr_rasid(DisasContext
*dc
, const OpcodeArg arg
[],
2790 const uint32_t par
[])
2792 #ifndef CONFIG_USER_ONLY
2793 gen_helper_wsr_rasid(cpu_env
, arg
[0].in
);
2797 static void translate_wsr_sar(DisasContext
*dc
, const OpcodeArg arg
[],
2798 const uint32_t par
[])
2800 tcg_gen_andi_i32(cpu_SR
[par
[0]], arg
[0].in
, 0x3f);
2801 if (dc
->sar_m32_5bit
) {
2802 tcg_gen_discard_i32(dc
->sar_m32
);
2804 dc
->sar_5bit
= false;
2805 dc
->sar_m32_5bit
= false;
2808 static void translate_wsr_windowbase(DisasContext
*dc
, const OpcodeArg arg
[],
2809 const uint32_t par
[])
2811 #ifndef CONFIG_USER_ONLY
2812 tcg_gen_mov_i32(cpu_windowbase_next
, arg
[0].in
);
2816 static void translate_wsr_windowstart(DisasContext
*dc
, const OpcodeArg arg
[],
2817 const uint32_t par
[])
2819 #ifndef CONFIG_USER_ONLY
2820 tcg_gen_andi_i32(cpu_SR
[par
[0]], arg
[0].in
,
2821 (1 << dc
->config
->nareg
/ 4) - 1);
2825 static void translate_wur(DisasContext
*dc
, const OpcodeArg arg
[],
2826 const uint32_t par
[])
2828 tcg_gen_mov_i32(cpu_UR
[par
[0]], arg
[0].in
);
2831 static void translate_xor(DisasContext
*dc
, const OpcodeArg arg
[],
2832 const uint32_t par
[])
2834 tcg_gen_xor_i32(arg
[0].out
, arg
[1].in
, arg
[2].in
);
2837 static void translate_xsr(DisasContext
*dc
, const OpcodeArg arg
[],
2838 const uint32_t par
[])
2840 if (sr_name
[par
[0]]) {
2841 TCGv_i32 tmp
= tcg_temp_new_i32();
2843 tcg_gen_mov_i32(tmp
, arg
[0].in
);
2844 tcg_gen_mov_i32(arg
[0].out
, cpu_SR
[par
[0]]);
2845 tcg_gen_mov_i32(cpu_SR
[par
[0]], tmp
);
2848 tcg_gen_movi_i32(arg
[0].out
, 0);
2852 static void translate_xsr_mask(DisasContext
*dc
, const OpcodeArg arg
[],
2853 const uint32_t par
[])
2855 if (sr_name
[par
[0]]) {
2856 TCGv_i32 tmp
= tcg_temp_new_i32();
2858 tcg_gen_mov_i32(tmp
, arg
[0].in
);
2859 tcg_gen_mov_i32(arg
[0].out
, cpu_SR
[par
[0]]);
2860 tcg_gen_andi_i32(cpu_SR
[par
[0]], tmp
, par
[2]);
2863 tcg_gen_movi_i32(arg
[0].out
, 0);
2867 static void translate_xsr_ccount(DisasContext
*dc
, const OpcodeArg arg
[],
2868 const uint32_t par
[])
2870 #ifndef CONFIG_USER_ONLY
2871 TCGv_i32 tmp
= tcg_temp_new_i32();
2873 if (tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
) {
2877 gen_helper_update_ccount(cpu_env
);
2878 tcg_gen_mov_i32(tmp
, cpu_SR
[par
[0]]);
2879 gen_helper_wsr_ccount(cpu_env
, arg
[0].in
);
2880 tcg_gen_mov_i32(arg
[0].out
, tmp
);
2886 #define gen_translate_xsr(name) \
2887 static void translate_xsr_##name(DisasContext *dc, const OpcodeArg arg[], \
2888 const uint32_t par[]) \
2890 TCGv_i32 tmp = tcg_temp_new_i32(); \
2892 if (sr_name[par[0]]) { \
2893 tcg_gen_mov_i32(tmp, cpu_SR[par[0]]); \
2895 tcg_gen_movi_i32(tmp, 0); \
2897 translate_wsr_##name(dc, arg, par); \
2898 tcg_gen_mov_i32(arg[0].out, tmp); \
2899 tcg_temp_free(tmp); \
2902 gen_translate_xsr(acchi
)
2903 gen_translate_xsr(ccompare
)
2904 gen_translate_xsr(dbreaka
)
2905 gen_translate_xsr(dbreakc
)
2906 gen_translate_xsr(ibreaka
)
2907 gen_translate_xsr(ibreakenable
)
2908 gen_translate_xsr(icount
)
2909 gen_translate_xsr(memctl
)
2910 gen_translate_xsr(mpuenb
)
2911 gen_translate_xsr(ps
)
2912 gen_translate_xsr(rasid
)
2913 gen_translate_xsr(sar
)
2914 gen_translate_xsr(windowbase
)
2915 gen_translate_xsr(windowstart
)
2917 #undef gen_translate_xsr
2919 static const XtensaOpcodeOps core_ops
[] = {
2922 .translate
= translate_abs
,
2924 .name
= (const char * const[]) {
2925 "add", "add.n", NULL
,
2927 .translate
= translate_add
,
2928 .op_flags
= XTENSA_OP_NAME_ARRAY
,
2930 .name
= (const char * const[]) {
2931 "addi", "addi.n", NULL
,
2933 .translate
= translate_addi
,
2934 .op_flags
= XTENSA_OP_NAME_ARRAY
,
2937 .translate
= translate_addi
,
2940 .translate
= translate_addx
,
2941 .par
= (const uint32_t[]){1},
2944 .translate
= translate_addx
,
2945 .par
= (const uint32_t[]){2},
2948 .translate
= translate_addx
,
2949 .par
= (const uint32_t[]){3},
2952 .translate
= translate_all
,
2953 .par
= (const uint32_t[]){true, 4},
2956 .translate
= translate_all
,
2957 .par
= (const uint32_t[]){true, 8},
2960 .translate
= translate_and
,
2963 .translate
= translate_boolean
,
2964 .par
= (const uint32_t[]){BOOLEAN_AND
},
2967 .translate
= translate_boolean
,
2968 .par
= (const uint32_t[]){BOOLEAN_ANDC
},
2971 .translate
= translate_all
,
2972 .par
= (const uint32_t[]){false, 4},
2975 .translate
= translate_all
,
2976 .par
= (const uint32_t[]){false, 8},
2978 .name
= (const char * const[]) {
2979 "ball", "ball.w15", "ball.w18", NULL
,
2981 .translate
= translate_ball
,
2982 .par
= (const uint32_t[]){TCG_COND_EQ
},
2983 .op_flags
= XTENSA_OP_NAME_ARRAY
,
2985 .name
= (const char * const[]) {
2986 "bany", "bany.w15", "bany.w18", NULL
,
2988 .translate
= translate_bany
,
2989 .par
= (const uint32_t[]){TCG_COND_NE
},
2990 .op_flags
= XTENSA_OP_NAME_ARRAY
,
2992 .name
= (const char * const[]) {
2993 "bbc", "bbc.w15", "bbc.w18", NULL
,
2995 .translate
= translate_bb
,
2996 .par
= (const uint32_t[]){TCG_COND_EQ
},
2997 .op_flags
= XTENSA_OP_NAME_ARRAY
,
2999 .name
= (const char * const[]) {
3000 "bbci", "bbci.w15", "bbci.w18", NULL
,
3002 .translate
= translate_bbi
,
3003 .par
= (const uint32_t[]){TCG_COND_EQ
},
3004 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3006 .name
= (const char * const[]) {
3007 "bbs", "bbs.w15", "bbs.w18", NULL
,
3009 .translate
= translate_bb
,
3010 .par
= (const uint32_t[]){TCG_COND_NE
},
3011 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3013 .name
= (const char * const[]) {
3014 "bbsi", "bbsi.w15", "bbsi.w18", NULL
,
3016 .translate
= translate_bbi
,
3017 .par
= (const uint32_t[]){TCG_COND_NE
},
3018 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3020 .name
= (const char * const[]) {
3021 "beq", "beq.w15", "beq.w18", NULL
,
3023 .translate
= translate_b
,
3024 .par
= (const uint32_t[]){TCG_COND_EQ
},
3025 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3027 .name
= (const char * const[]) {
3028 "beqi", "beqi.w15", "beqi.w18", NULL
,
3030 .translate
= translate_bi
,
3031 .par
= (const uint32_t[]){TCG_COND_EQ
},
3032 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3034 .name
= (const char * const[]) {
3035 "beqz", "beqz.n", "beqz.w15", "beqz.w18", NULL
,
3037 .translate
= translate_bz
,
3038 .par
= (const uint32_t[]){TCG_COND_EQ
},
3039 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3042 .translate
= translate_bp
,
3043 .par
= (const uint32_t[]){TCG_COND_EQ
},
3045 .name
= (const char * const[]) {
3046 "bge", "bge.w15", "bge.w18", NULL
,
3048 .translate
= translate_b
,
3049 .par
= (const uint32_t[]){TCG_COND_GE
},
3050 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3052 .name
= (const char * const[]) {
3053 "bgei", "bgei.w15", "bgei.w18", NULL
,
3055 .translate
= translate_bi
,
3056 .par
= (const uint32_t[]){TCG_COND_GE
},
3057 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3059 .name
= (const char * const[]) {
3060 "bgeu", "bgeu.w15", "bgeu.w18", NULL
,
3062 .translate
= translate_b
,
3063 .par
= (const uint32_t[]){TCG_COND_GEU
},
3064 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3066 .name
= (const char * const[]) {
3067 "bgeui", "bgeui.w15", "bgeui.w18", NULL
,
3069 .translate
= translate_bi
,
3070 .par
= (const uint32_t[]){TCG_COND_GEU
},
3071 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3073 .name
= (const char * const[]) {
3074 "bgez", "bgez.w15", "bgez.w18", NULL
,
3076 .translate
= translate_bz
,
3077 .par
= (const uint32_t[]){TCG_COND_GE
},
3078 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3080 .name
= (const char * const[]) {
3081 "blt", "blt.w15", "blt.w18", NULL
,
3083 .translate
= translate_b
,
3084 .par
= (const uint32_t[]){TCG_COND_LT
},
3085 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3087 .name
= (const char * const[]) {
3088 "blti", "blti.w15", "blti.w18", NULL
,
3090 .translate
= translate_bi
,
3091 .par
= (const uint32_t[]){TCG_COND_LT
},
3092 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3094 .name
= (const char * const[]) {
3095 "bltu", "bltu.w15", "bltu.w18", NULL
,
3097 .translate
= translate_b
,
3098 .par
= (const uint32_t[]){TCG_COND_LTU
},
3099 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3101 .name
= (const char * const[]) {
3102 "bltui", "bltui.w15", "bltui.w18", NULL
,
3104 .translate
= translate_bi
,
3105 .par
= (const uint32_t[]){TCG_COND_LTU
},
3106 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3108 .name
= (const char * const[]) {
3109 "bltz", "bltz.w15", "bltz.w18", NULL
,
3111 .translate
= translate_bz
,
3112 .par
= (const uint32_t[]){TCG_COND_LT
},
3113 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3115 .name
= (const char * const[]) {
3116 "bnall", "bnall.w15", "bnall.w18", NULL
,
3118 .translate
= translate_ball
,
3119 .par
= (const uint32_t[]){TCG_COND_NE
},
3120 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3122 .name
= (const char * const[]) {
3123 "bne", "bne.w15", "bne.w18", NULL
,
3125 .translate
= translate_b
,
3126 .par
= (const uint32_t[]){TCG_COND_NE
},
3127 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3129 .name
= (const char * const[]) {
3130 "bnei", "bnei.w15", "bnei.w18", NULL
,
3132 .translate
= translate_bi
,
3133 .par
= (const uint32_t[]){TCG_COND_NE
},
3134 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3136 .name
= (const char * const[]) {
3137 "bnez", "bnez.n", "bnez.w15", "bnez.w18", NULL
,
3139 .translate
= translate_bz
,
3140 .par
= (const uint32_t[]){TCG_COND_NE
},
3141 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3143 .name
= (const char * const[]) {
3144 "bnone", "bnone.w15", "bnone.w18", NULL
,
3146 .translate
= translate_bany
,
3147 .par
= (const uint32_t[]){TCG_COND_EQ
},
3148 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3151 .translate
= translate_nop
,
3152 .par
= (const uint32_t[]){DEBUGCAUSE_BI
},
3153 .op_flags
= XTENSA_OP_DEBUG_BREAK
,
3156 .translate
= translate_nop
,
3157 .par
= (const uint32_t[]){DEBUGCAUSE_BN
},
3158 .op_flags
= XTENSA_OP_DEBUG_BREAK
,
3161 .translate
= translate_bp
,
3162 .par
= (const uint32_t[]){TCG_COND_NE
},
3165 .translate
= translate_call0
,
3168 .translate
= translate_callw
,
3169 .par
= (const uint32_t[]){3},
3172 .translate
= translate_callw
,
3173 .par
= (const uint32_t[]){1},
3176 .translate
= translate_callw
,
3177 .par
= (const uint32_t[]){2},
3180 .translate
= translate_callx0
,
3183 .translate
= translate_callxw
,
3184 .par
= (const uint32_t[]){3},
3187 .translate
= translate_callxw
,
3188 .par
= (const uint32_t[]){1},
3191 .translate
= translate_callxw
,
3192 .par
= (const uint32_t[]){2},
3195 .translate
= translate_clamps
,
3197 .name
= "clrb_expstate",
3198 .translate
= translate_clrb_expstate
,
3201 .translate
= translate_clrex
,
3204 .translate
= translate_const16
,
3207 .translate
= translate_depbits
,
3210 .translate
= translate_dcache
,
3211 .op_flags
= XTENSA_OP_PRIVILEGED
,
3214 .translate
= translate_nop
,
3217 .translate
= translate_dcache
,
3218 .op_flags
= XTENSA_OP_PRIVILEGED
,
3221 .translate
= translate_dcache
,
3224 .translate
= translate_nop
,
3227 .translate
= translate_dcache
,
3230 .translate
= translate_nop
,
3233 .translate
= translate_nop
,
3234 .op_flags
= XTENSA_OP_PRIVILEGED
,
3237 .translate
= translate_nop
,
3238 .op_flags
= XTENSA_OP_PRIVILEGED
,
3241 .translate
= translate_nop
,
3242 .op_flags
= XTENSA_OP_PRIVILEGED
,
3245 .translate
= translate_nop
,
3246 .op_flags
= XTENSA_OP_PRIVILEGED
,
3249 .translate
= translate_diwbuip
,
3250 .op_flags
= XTENSA_OP_PRIVILEGED
,
3253 .translate
= translate_dcache
,
3254 .op_flags
= XTENSA_OP_PRIVILEGED
,
3257 .translate
= translate_nop
,
3260 .translate
= translate_nop
,
3263 .translate
= translate_nop
,
3266 .translate
= translate_nop
,
3269 .translate
= translate_nop
,
3272 .translate
= translate_nop
,
3275 .translate
= translate_nop
,
3278 .translate
= translate_nop
,
3281 .translate
= translate_nop
,
3284 .translate
= translate_nop
,
3287 .translate
= translate_nop
,
3290 .translate
= translate_entry
,
3291 .test_exceptions
= test_exceptions_entry
,
3292 .test_overflow
= test_overflow_entry
,
3293 .op_flags
= XTENSA_OP_EXIT_TB_M1
|
3294 XTENSA_OP_SYNC_REGISTER_WINDOW
,
3297 .translate
= translate_nop
,
3300 .translate
= translate_nop
,
3303 .translate
= translate_extui
,
3306 .translate
= translate_memw
,
3309 .translate
= translate_getex
,
3312 .op_flags
= XTENSA_OP_ILL
,
3315 .op_flags
= XTENSA_OP_ILL
,
3318 .translate
= translate_itlb
,
3319 .par
= (const uint32_t[]){true},
3320 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
3323 .translate
= translate_icache
,
3326 .translate
= translate_icache
,
3327 .op_flags
= XTENSA_OP_PRIVILEGED
,
3330 .translate
= translate_nop
,
3331 .op_flags
= XTENSA_OP_PRIVILEGED
,
3334 .translate
= translate_itlb
,
3335 .par
= (const uint32_t[]){false},
3336 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
3339 .translate
= translate_nop
,
3340 .op_flags
= XTENSA_OP_PRIVILEGED
,
3342 .name
= (const char * const[]) {
3343 "ill", "ill.n", NULL
,
3345 .op_flags
= XTENSA_OP_ILL
| XTENSA_OP_NAME_ARRAY
,
3348 .translate
= translate_nop
,
3351 .translate
= translate_icache
,
3352 .op_flags
= XTENSA_OP_PRIVILEGED
,
3355 .translate
= translate_nop
,
3358 .translate
= translate_j
,
3361 .translate
= translate_jx
,
3364 .translate
= translate_ldst
,
3365 .par
= (const uint32_t[]){MO_TESW
, false, false},
3366 .op_flags
= XTENSA_OP_LOAD
,
3369 .translate
= translate_ldst
,
3370 .par
= (const uint32_t[]){MO_TEUW
, false, false},
3371 .op_flags
= XTENSA_OP_LOAD
,
3374 .translate
= translate_ldst
,
3375 .par
= (const uint32_t[]){MO_TEUL
| MO_ALIGN
, true, false},
3376 .op_flags
= XTENSA_OP_LOAD
,
3379 .translate
= translate_l32e
,
3380 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_LOAD
,
3383 .translate
= translate_l32ex
,
3384 .op_flags
= XTENSA_OP_LOAD
,
3386 .name
= (const char * const[]) {
3387 "l32i", "l32i.n", NULL
,
3389 .translate
= translate_ldst
,
3390 .par
= (const uint32_t[]){MO_TEUL
, false, false},
3391 .op_flags
= XTENSA_OP_NAME_ARRAY
| XTENSA_OP_LOAD
,
3394 .translate
= translate_l32r
,
3395 .op_flags
= XTENSA_OP_LOAD
,
3398 .translate
= translate_ldst
,
3399 .par
= (const uint32_t[]){MO_UB
, false, false},
3400 .op_flags
= XTENSA_OP_LOAD
,
3403 .translate
= translate_mac16
,
3404 .par
= (const uint32_t[]){MAC16_NONE
, 0, -4},
3405 .op_flags
= XTENSA_OP_LOAD
,
3408 .translate
= translate_mac16
,
3409 .par
= (const uint32_t[]){MAC16_NONE
, 0, 4},
3410 .op_flags
= XTENSA_OP_LOAD
,
3413 .op_flags
= XTENSA_OP_ILL
,
3415 .name
= (const char * const[]) {
3416 "loop", "loop.w15", NULL
,
3418 .translate
= translate_loop
,
3419 .par
= (const uint32_t[]){TCG_COND_NEVER
},
3420 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3422 .name
= (const char * const[]) {
3423 "loopgtz", "loopgtz.w15", NULL
,
3425 .translate
= translate_loop
,
3426 .par
= (const uint32_t[]){TCG_COND_GT
},
3427 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3429 .name
= (const char * const[]) {
3430 "loopnez", "loopnez.w15", NULL
,
3432 .translate
= translate_loop
,
3433 .par
= (const uint32_t[]){TCG_COND_NE
},
3434 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3437 .translate
= translate_smax
,
3440 .translate
= translate_umax
,
3443 .translate
= translate_memw
,
3446 .translate
= translate_smin
,
3449 .translate
= translate_umin
,
3451 .name
= (const char * const[]) {
3452 "mov", "mov.n", NULL
,
3454 .translate
= translate_mov
,
3455 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3458 .translate
= translate_movcond
,
3459 .par
= (const uint32_t[]){TCG_COND_EQ
},
3462 .translate
= translate_movp
,
3463 .par
= (const uint32_t[]){TCG_COND_EQ
},
3466 .translate
= translate_movcond
,
3467 .par
= (const uint32_t[]){TCG_COND_GE
},
3470 .translate
= translate_movi
,
3473 .translate
= translate_movi
,
3476 .translate
= translate_movcond
,
3477 .par
= (const uint32_t[]){TCG_COND_LT
},
3480 .translate
= translate_movcond
,
3481 .par
= (const uint32_t[]){TCG_COND_NE
},
3484 .translate
= translate_movsp
,
3485 .op_flags
= XTENSA_OP_ALLOCA
,
3488 .translate
= translate_movp
,
3489 .par
= (const uint32_t[]){TCG_COND_NE
},
3491 .name
= "mul.aa.hh",
3492 .translate
= translate_mac16
,
3493 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_HH
, 0},
3495 .name
= "mul.aa.hl",
3496 .translate
= translate_mac16
,
3497 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_HL
, 0},
3499 .name
= "mul.aa.lh",
3500 .translate
= translate_mac16
,
3501 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_LH
, 0},
3503 .name
= "mul.aa.ll",
3504 .translate
= translate_mac16
,
3505 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_LL
, 0},
3507 .name
= "mul.ad.hh",
3508 .translate
= translate_mac16
,
3509 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_HH
, 0},
3511 .name
= "mul.ad.hl",
3512 .translate
= translate_mac16
,
3513 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_HL
, 0},
3515 .name
= "mul.ad.lh",
3516 .translate
= translate_mac16
,
3517 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_LH
, 0},
3519 .name
= "mul.ad.ll",
3520 .translate
= translate_mac16
,
3521 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_LL
, 0},
3523 .name
= "mul.da.hh",
3524 .translate
= translate_mac16
,
3525 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_HH
, 0},
3527 .name
= "mul.da.hl",
3528 .translate
= translate_mac16
,
3529 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_HL
, 0},
3531 .name
= "mul.da.lh",
3532 .translate
= translate_mac16
,
3533 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_LH
, 0},
3535 .name
= "mul.da.ll",
3536 .translate
= translate_mac16
,
3537 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_LL
, 0},
3539 .name
= "mul.dd.hh",
3540 .translate
= translate_mac16
,
3541 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_HH
, 0},
3543 .name
= "mul.dd.hl",
3544 .translate
= translate_mac16
,
3545 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_HL
, 0},
3547 .name
= "mul.dd.lh",
3548 .translate
= translate_mac16
,
3549 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_LH
, 0},
3551 .name
= "mul.dd.ll",
3552 .translate
= translate_mac16
,
3553 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_LL
, 0},
3556 .translate
= translate_mul16
,
3557 .par
= (const uint32_t[]){true},
3560 .translate
= translate_mul16
,
3561 .par
= (const uint32_t[]){false},
3563 .name
= "mula.aa.hh",
3564 .translate
= translate_mac16
,
3565 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HH
, 0},
3567 .name
= "mula.aa.hl",
3568 .translate
= translate_mac16
,
3569 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HL
, 0},
3571 .name
= "mula.aa.lh",
3572 .translate
= translate_mac16
,
3573 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LH
, 0},
3575 .name
= "mula.aa.ll",
3576 .translate
= translate_mac16
,
3577 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LL
, 0},
3579 .name
= "mula.ad.hh",
3580 .translate
= translate_mac16
,
3581 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HH
, 0},
3583 .name
= "mula.ad.hl",
3584 .translate
= translate_mac16
,
3585 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HL
, 0},
3587 .name
= "mula.ad.lh",
3588 .translate
= translate_mac16
,
3589 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LH
, 0},
3591 .name
= "mula.ad.ll",
3592 .translate
= translate_mac16
,
3593 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LL
, 0},
3595 .name
= "mula.da.hh",
3596 .translate
= translate_mac16
,
3597 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HH
, 0},
3599 .name
= "mula.da.hh.lddec",
3600 .translate
= translate_mac16
,
3601 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HH
, -4},
3603 .name
= "mula.da.hh.ldinc",
3604 .translate
= translate_mac16
,
3605 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HH
, 4},
3607 .name
= "mula.da.hl",
3608 .translate
= translate_mac16
,
3609 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HL
, 0},
3611 .name
= "mula.da.hl.lddec",
3612 .translate
= translate_mac16
,
3613 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HL
, -4},
3615 .name
= "mula.da.hl.ldinc",
3616 .translate
= translate_mac16
,
3617 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HL
, 4},
3619 .name
= "mula.da.lh",
3620 .translate
= translate_mac16
,
3621 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LH
, 0},
3623 .name
= "mula.da.lh.lddec",
3624 .translate
= translate_mac16
,
3625 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LH
, -4},
3627 .name
= "mula.da.lh.ldinc",
3628 .translate
= translate_mac16
,
3629 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LH
, 4},
3631 .name
= "mula.da.ll",
3632 .translate
= translate_mac16
,
3633 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LL
, 0},
3635 .name
= "mula.da.ll.lddec",
3636 .translate
= translate_mac16
,
3637 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LL
, -4},
3639 .name
= "mula.da.ll.ldinc",
3640 .translate
= translate_mac16
,
3641 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LL
, 4},
3643 .name
= "mula.dd.hh",
3644 .translate
= translate_mac16
,
3645 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HH
, 0},
3647 .name
= "mula.dd.hh.lddec",
3648 .translate
= translate_mac16
,
3649 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HH
, -4},
3651 .name
= "mula.dd.hh.ldinc",
3652 .translate
= translate_mac16
,
3653 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HH
, 4},
3655 .name
= "mula.dd.hl",
3656 .translate
= translate_mac16
,
3657 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HL
, 0},
3659 .name
= "mula.dd.hl.lddec",
3660 .translate
= translate_mac16
,
3661 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HL
, -4},
3663 .name
= "mula.dd.hl.ldinc",
3664 .translate
= translate_mac16
,
3665 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HL
, 4},
3667 .name
= "mula.dd.lh",
3668 .translate
= translate_mac16
,
3669 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LH
, 0},
3671 .name
= "mula.dd.lh.lddec",
3672 .translate
= translate_mac16
,
3673 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LH
, -4},
3675 .name
= "mula.dd.lh.ldinc",
3676 .translate
= translate_mac16
,
3677 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LH
, 4},
3679 .name
= "mula.dd.ll",
3680 .translate
= translate_mac16
,
3681 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LL
, 0},
3683 .name
= "mula.dd.ll.lddec",
3684 .translate
= translate_mac16
,
3685 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LL
, -4},
3687 .name
= "mula.dd.ll.ldinc",
3688 .translate
= translate_mac16
,
3689 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LL
, 4},
3692 .translate
= translate_mull
,
3694 .name
= "muls.aa.hh",
3695 .translate
= translate_mac16
,
3696 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_HH
, 0},
3698 .name
= "muls.aa.hl",
3699 .translate
= translate_mac16
,
3700 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_HL
, 0},
3702 .name
= "muls.aa.lh",
3703 .translate
= translate_mac16
,
3704 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_LH
, 0},
3706 .name
= "muls.aa.ll",
3707 .translate
= translate_mac16
,
3708 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_LL
, 0},
3710 .name
= "muls.ad.hh",
3711 .translate
= translate_mac16
,
3712 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_HH
, 0},
3714 .name
= "muls.ad.hl",
3715 .translate
= translate_mac16
,
3716 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_HL
, 0},
3718 .name
= "muls.ad.lh",
3719 .translate
= translate_mac16
,
3720 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_LH
, 0},
3722 .name
= "muls.ad.ll",
3723 .translate
= translate_mac16
,
3724 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_LL
, 0},
3726 .name
= "muls.da.hh",
3727 .translate
= translate_mac16
,
3728 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_HH
, 0},
3730 .name
= "muls.da.hl",
3731 .translate
= translate_mac16
,
3732 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_HL
, 0},
3734 .name
= "muls.da.lh",
3735 .translate
= translate_mac16
,
3736 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_LH
, 0},
3738 .name
= "muls.da.ll",
3739 .translate
= translate_mac16
,
3740 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_LL
, 0},
3742 .name
= "muls.dd.hh",
3743 .translate
= translate_mac16
,
3744 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_HH
, 0},
3746 .name
= "muls.dd.hl",
3747 .translate
= translate_mac16
,
3748 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_HL
, 0},
3750 .name
= "muls.dd.lh",
3751 .translate
= translate_mac16
,
3752 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_LH
, 0},
3754 .name
= "muls.dd.ll",
3755 .translate
= translate_mac16
,
3756 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_LL
, 0},
3759 .translate
= translate_mulh
,
3760 .par
= (const uint32_t[]){true},
3763 .translate
= translate_mulh
,
3764 .par
= (const uint32_t[]){false},
3767 .translate
= translate_neg
,
3769 .name
= (const char * const[]) {
3770 "nop", "nop.n", NULL
,
3772 .translate
= translate_nop
,
3773 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3776 .translate
= translate_nsa
,
3779 .translate
= translate_nsau
,
3782 .translate
= translate_or
,
3785 .translate
= translate_boolean
,
3786 .par
= (const uint32_t[]){BOOLEAN_OR
},
3789 .translate
= translate_boolean
,
3790 .par
= (const uint32_t[]){BOOLEAN_ORC
},
3793 .translate
= translate_ptlb
,
3794 .par
= (const uint32_t[]){true},
3795 .op_flags
= XTENSA_OP_PRIVILEGED
,
3798 .translate
= translate_nop
,
3801 .translate
= translate_nop
,
3804 .translate
= translate_nop
,
3807 .translate
= translate_nop
,
3810 .translate
= translate_nop
,
3813 .translate
= translate_ptlb
,
3814 .par
= (const uint32_t[]){false},
3815 .op_flags
= XTENSA_OP_PRIVILEGED
,
3818 .translate
= translate_pptlb
,
3819 .op_flags
= XTENSA_OP_PRIVILEGED
,
3822 .translate
= translate_quos
,
3823 .par
= (const uint32_t[]){true},
3824 .op_flags
= XTENSA_OP_DIVIDE_BY_ZERO
,
3827 .translate
= translate_quou
,
3828 .op_flags
= XTENSA_OP_DIVIDE_BY_ZERO
,
3831 .translate
= translate_rtlb
,
3832 .par
= (const uint32_t[]){true, 0},
3833 .op_flags
= XTENSA_OP_PRIVILEGED
,
3836 .translate
= translate_rtlb
,
3837 .par
= (const uint32_t[]){true, 1},
3838 .op_flags
= XTENSA_OP_PRIVILEGED
,
3840 .name
= "read_impwire",
3841 .translate
= translate_read_impwire
,
3844 .translate
= translate_quos
,
3845 .par
= (const uint32_t[]){false},
3846 .op_flags
= XTENSA_OP_DIVIDE_BY_ZERO
,
3849 .translate
= translate_remu
,
3850 .op_flags
= XTENSA_OP_DIVIDE_BY_ZERO
,
3853 .translate
= translate_rer
,
3854 .op_flags
= XTENSA_OP_PRIVILEGED
,
3856 .name
= (const char * const[]) {
3857 "ret", "ret.n", NULL
,
3859 .translate
= translate_ret
,
3860 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3862 .name
= (const char * const[]) {
3863 "retw", "retw.n", NULL
,
3865 .translate
= translate_retw
,
3866 .test_exceptions
= test_exceptions_retw
,
3867 .op_flags
= XTENSA_OP_UNDERFLOW
| XTENSA_OP_NAME_ARRAY
,
3870 .op_flags
= XTENSA_OP_ILL
,
3873 .translate
= translate_rfde
,
3874 .op_flags
= XTENSA_OP_PRIVILEGED
,
3877 .op_flags
= XTENSA_OP_ILL
,
3880 .translate
= translate_rfe
,
3881 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_CHECK_INTERRUPTS
,
3884 .translate
= translate_rfi
,
3885 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_CHECK_INTERRUPTS
,
3888 .translate
= translate_rfw
,
3889 .par
= (const uint32_t[]){true},
3890 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_CHECK_INTERRUPTS
,
3893 .translate
= translate_rfw
,
3894 .par
= (const uint32_t[]){false},
3895 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_CHECK_INTERRUPTS
,
3898 .translate
= translate_rtlb
,
3899 .par
= (const uint32_t[]){false, 0},
3900 .op_flags
= XTENSA_OP_PRIVILEGED
,
3903 .translate
= translate_rtlb
,
3904 .par
= (const uint32_t[]){false, 1},
3905 .op_flags
= XTENSA_OP_PRIVILEGED
,
3908 .translate
= translate_rptlb0
,
3909 .op_flags
= XTENSA_OP_PRIVILEGED
,
3912 .translate
= translate_rptlb1
,
3913 .op_flags
= XTENSA_OP_PRIVILEGED
,
3916 .translate
= translate_rotw
,
3917 .op_flags
= XTENSA_OP_PRIVILEGED
|
3918 XTENSA_OP_EXIT_TB_M1
|
3919 XTENSA_OP_SYNC_REGISTER_WINDOW
,
3922 .translate
= translate_rsil
,
3924 XTENSA_OP_PRIVILEGED
|
3925 XTENSA_OP_EXIT_TB_0
|
3926 XTENSA_OP_CHECK_INTERRUPTS
,
3929 .translate
= translate_rsr
,
3930 .par
= (const uint32_t[]){176},
3931 .op_flags
= XTENSA_OP_PRIVILEGED
,
3934 .translate
= translate_rsr
,
3935 .par
= (const uint32_t[]){208},
3936 .op_flags
= XTENSA_OP_PRIVILEGED
,
3938 .name
= "rsr.acchi",
3939 .translate
= translate_rsr
,
3940 .test_exceptions
= test_exceptions_sr
,
3941 .par
= (const uint32_t[]){
3943 XTENSA_OPTION_MAC16
,
3946 .name
= "rsr.acclo",
3947 .translate
= translate_rsr
,
3948 .test_exceptions
= test_exceptions_sr
,
3949 .par
= (const uint32_t[]){
3951 XTENSA_OPTION_MAC16
,
3954 .name
= "rsr.atomctl",
3955 .translate
= translate_rsr
,
3956 .test_exceptions
= test_exceptions_sr
,
3957 .par
= (const uint32_t[]){
3959 XTENSA_OPTION_ATOMCTL
,
3961 .op_flags
= XTENSA_OP_PRIVILEGED
,
3964 .translate
= translate_rsr
,
3965 .test_exceptions
= test_exceptions_sr
,
3966 .par
= (const uint32_t[]){
3968 XTENSA_OPTION_BOOLEAN
,
3971 .name
= "rsr.cacheadrdis",
3972 .translate
= translate_rsr
,
3973 .test_exceptions
= test_exceptions_sr
,
3974 .par
= (const uint32_t[]){
3978 .op_flags
= XTENSA_OP_PRIVILEGED
,
3980 .name
= "rsr.cacheattr",
3981 .translate
= translate_rsr
,
3982 .test_exceptions
= test_exceptions_sr
,
3983 .par
= (const uint32_t[]){
3985 XTENSA_OPTION_CACHEATTR
,
3987 .op_flags
= XTENSA_OP_PRIVILEGED
,
3989 .name
= "rsr.ccompare0",
3990 .translate
= translate_rsr
,
3991 .test_exceptions
= test_exceptions_ccompare
,
3992 .par
= (const uint32_t[]){
3994 XTENSA_OPTION_TIMER_INTERRUPT
,
3996 .op_flags
= XTENSA_OP_PRIVILEGED
,
3998 .name
= "rsr.ccompare1",
3999 .translate
= translate_rsr
,
4000 .test_exceptions
= test_exceptions_ccompare
,
4001 .par
= (const uint32_t[]){
4003 XTENSA_OPTION_TIMER_INTERRUPT
,
4005 .op_flags
= XTENSA_OP_PRIVILEGED
,
4007 .name
= "rsr.ccompare2",
4008 .translate
= translate_rsr
,
4009 .test_exceptions
= test_exceptions_ccompare
,
4010 .par
= (const uint32_t[]){
4012 XTENSA_OPTION_TIMER_INTERRUPT
,
4014 .op_flags
= XTENSA_OP_PRIVILEGED
,
4016 .name
= "rsr.ccount",
4017 .translate
= translate_rsr_ccount
,
4018 .test_exceptions
= test_exceptions_sr
,
4019 .par
= (const uint32_t[]){
4021 XTENSA_OPTION_TIMER_INTERRUPT
,
4023 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
4025 .name
= "rsr.configid0",
4026 .translate
= translate_rsr
,
4027 .par
= (const uint32_t[]){CONFIGID0
},
4028 .op_flags
= XTENSA_OP_PRIVILEGED
,
4030 .name
= "rsr.configid1",
4031 .translate
= translate_rsr
,
4032 .par
= (const uint32_t[]){CONFIGID1
},
4033 .op_flags
= XTENSA_OP_PRIVILEGED
,
4035 .name
= "rsr.cpenable",
4036 .translate
= translate_rsr
,
4037 .test_exceptions
= test_exceptions_sr
,
4038 .par
= (const uint32_t[]){
4040 XTENSA_OPTION_COPROCESSOR
,
4042 .op_flags
= XTENSA_OP_PRIVILEGED
,
4044 .name
= "rsr.dbreaka0",
4045 .translate
= translate_rsr
,
4046 .test_exceptions
= test_exceptions_dbreak
,
4047 .par
= (const uint32_t[]){
4049 XTENSA_OPTION_DEBUG
,
4051 .op_flags
= XTENSA_OP_PRIVILEGED
,
4053 .name
= "rsr.dbreaka1",
4054 .translate
= translate_rsr
,
4055 .test_exceptions
= test_exceptions_dbreak
,
4056 .par
= (const uint32_t[]){
4058 XTENSA_OPTION_DEBUG
,
4060 .op_flags
= XTENSA_OP_PRIVILEGED
,
4062 .name
= "rsr.dbreakc0",
4063 .translate
= translate_rsr
,
4064 .test_exceptions
= test_exceptions_dbreak
,
4065 .par
= (const uint32_t[]){
4067 XTENSA_OPTION_DEBUG
,
4069 .op_flags
= XTENSA_OP_PRIVILEGED
,
4071 .name
= "rsr.dbreakc1",
4072 .translate
= translate_rsr
,
4073 .test_exceptions
= test_exceptions_dbreak
,
4074 .par
= (const uint32_t[]){
4076 XTENSA_OPTION_DEBUG
,
4078 .op_flags
= XTENSA_OP_PRIVILEGED
,
4081 .translate
= translate_rsr
,
4082 .test_exceptions
= test_exceptions_sr
,
4083 .par
= (const uint32_t[]){
4085 XTENSA_OPTION_DEBUG
,
4087 .op_flags
= XTENSA_OP_PRIVILEGED
,
4089 .name
= "rsr.debugcause",
4090 .translate
= translate_rsr
,
4091 .test_exceptions
= test_exceptions_sr
,
4092 .par
= (const uint32_t[]){
4094 XTENSA_OPTION_DEBUG
,
4096 .op_flags
= XTENSA_OP_PRIVILEGED
,
4099 .translate
= translate_rsr
,
4100 .test_exceptions
= test_exceptions_sr
,
4101 .par
= (const uint32_t[]){
4103 XTENSA_OPTION_EXCEPTION
,
4105 .op_flags
= XTENSA_OP_PRIVILEGED
,
4107 .name
= "rsr.dtlbcfg",
4108 .translate
= translate_rsr
,
4109 .test_exceptions
= test_exceptions_sr
,
4110 .par
= (const uint32_t[]){
4114 .op_flags
= XTENSA_OP_PRIVILEGED
,
4117 .translate
= translate_rsr
,
4118 .test_exceptions
= test_exceptions_sr
,
4119 .par
= (const uint32_t[]){
4121 XTENSA_OPTION_EXCEPTION
,
4123 .op_flags
= XTENSA_OP_PRIVILEGED
,
4126 .translate
= translate_rsr
,
4127 .test_exceptions
= test_exceptions_hpi
,
4128 .par
= (const uint32_t[]){
4130 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4132 .op_flags
= XTENSA_OP_PRIVILEGED
,
4135 .translate
= translate_rsr
,
4136 .test_exceptions
= test_exceptions_hpi
,
4137 .par
= (const uint32_t[]){
4139 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4141 .op_flags
= XTENSA_OP_PRIVILEGED
,
4144 .translate
= translate_rsr
,
4145 .test_exceptions
= test_exceptions_hpi
,
4146 .par
= (const uint32_t[]){
4148 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4150 .op_flags
= XTENSA_OP_PRIVILEGED
,
4153 .translate
= translate_rsr
,
4154 .test_exceptions
= test_exceptions_hpi
,
4155 .par
= (const uint32_t[]){
4157 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4159 .op_flags
= XTENSA_OP_PRIVILEGED
,
4162 .translate
= translate_rsr
,
4163 .test_exceptions
= test_exceptions_hpi
,
4164 .par
= (const uint32_t[]){
4166 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4168 .op_flags
= XTENSA_OP_PRIVILEGED
,
4171 .translate
= translate_rsr
,
4172 .test_exceptions
= test_exceptions_hpi
,
4173 .par
= (const uint32_t[]){
4175 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4177 .op_flags
= XTENSA_OP_PRIVILEGED
,
4180 .translate
= translate_rsr
,
4181 .test_exceptions
= test_exceptions_hpi
,
4182 .par
= (const uint32_t[]){
4184 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4186 .op_flags
= XTENSA_OP_PRIVILEGED
,
4189 .translate
= translate_rsr
,
4190 .test_exceptions
= test_exceptions_hpi
,
4191 .par
= (const uint32_t[]){
4193 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4195 .op_flags
= XTENSA_OP_PRIVILEGED
,
4198 .translate
= translate_rsr
,
4199 .test_exceptions
= test_exceptions_hpi
,
4200 .par
= (const uint32_t[]){
4202 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4204 .op_flags
= XTENSA_OP_PRIVILEGED
,
4207 .translate
= translate_rsr
,
4208 .test_exceptions
= test_exceptions_hpi
,
4209 .par
= (const uint32_t[]){
4211 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4213 .op_flags
= XTENSA_OP_PRIVILEGED
,
4216 .translate
= translate_rsr
,
4217 .test_exceptions
= test_exceptions_hpi
,
4218 .par
= (const uint32_t[]){
4220 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4222 .op_flags
= XTENSA_OP_PRIVILEGED
,
4225 .translate
= translate_rsr
,
4226 .test_exceptions
= test_exceptions_hpi
,
4227 .par
= (const uint32_t[]){
4229 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4231 .op_flags
= XTENSA_OP_PRIVILEGED
,
4233 .name
= "rsr.eraccess",
4234 .translate
= translate_rsr
,
4235 .par
= (const uint32_t[]){ERACCESS
},
4236 .op_flags
= XTENSA_OP_PRIVILEGED
,
4238 .name
= "rsr.exccause",
4239 .translate
= translate_rsr
,
4240 .test_exceptions
= test_exceptions_sr
,
4241 .par
= (const uint32_t[]){
4243 XTENSA_OPTION_EXCEPTION
,
4245 .op_flags
= XTENSA_OP_PRIVILEGED
,
4247 .name
= "rsr.excsave1",
4248 .translate
= translate_rsr
,
4249 .test_exceptions
= test_exceptions_sr
,
4250 .par
= (const uint32_t[]){
4252 XTENSA_OPTION_EXCEPTION
,
4254 .op_flags
= XTENSA_OP_PRIVILEGED
,
4256 .name
= "rsr.excsave2",
4257 .translate
= translate_rsr
,
4258 .test_exceptions
= test_exceptions_hpi
,
4259 .par
= (const uint32_t[]){
4261 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4263 .op_flags
= XTENSA_OP_PRIVILEGED
,
4265 .name
= "rsr.excsave3",
4266 .translate
= translate_rsr
,
4267 .test_exceptions
= test_exceptions_hpi
,
4268 .par
= (const uint32_t[]){
4270 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4272 .op_flags
= XTENSA_OP_PRIVILEGED
,
4274 .name
= "rsr.excsave4",
4275 .translate
= translate_rsr
,
4276 .test_exceptions
= test_exceptions_hpi
,
4277 .par
= (const uint32_t[]){
4279 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4281 .op_flags
= XTENSA_OP_PRIVILEGED
,
4283 .name
= "rsr.excsave5",
4284 .translate
= translate_rsr
,
4285 .test_exceptions
= test_exceptions_hpi
,
4286 .par
= (const uint32_t[]){
4288 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4290 .op_flags
= XTENSA_OP_PRIVILEGED
,
4292 .name
= "rsr.excsave6",
4293 .translate
= translate_rsr
,
4294 .test_exceptions
= test_exceptions_hpi
,
4295 .par
= (const uint32_t[]){
4297 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4299 .op_flags
= XTENSA_OP_PRIVILEGED
,
4301 .name
= "rsr.excsave7",
4302 .translate
= translate_rsr
,
4303 .test_exceptions
= test_exceptions_hpi
,
4304 .par
= (const uint32_t[]){
4306 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4308 .op_flags
= XTENSA_OP_PRIVILEGED
,
4310 .name
= "rsr.excvaddr",
4311 .translate
= translate_rsr
,
4312 .test_exceptions
= test_exceptions_sr
,
4313 .par
= (const uint32_t[]){
4315 XTENSA_OPTION_EXCEPTION
,
4317 .op_flags
= XTENSA_OP_PRIVILEGED
,
4319 .name
= "rsr.ibreaka0",
4320 .translate
= translate_rsr
,
4321 .test_exceptions
= test_exceptions_ibreak
,
4322 .par
= (const uint32_t[]){
4324 XTENSA_OPTION_DEBUG
,
4326 .op_flags
= XTENSA_OP_PRIVILEGED
,
4328 .name
= "rsr.ibreaka1",
4329 .translate
= translate_rsr
,
4330 .test_exceptions
= test_exceptions_ibreak
,
4331 .par
= (const uint32_t[]){
4333 XTENSA_OPTION_DEBUG
,
4335 .op_flags
= XTENSA_OP_PRIVILEGED
,
4337 .name
= "rsr.ibreakenable",
4338 .translate
= translate_rsr
,
4339 .test_exceptions
= test_exceptions_sr
,
4340 .par
= (const uint32_t[]){
4342 XTENSA_OPTION_DEBUG
,
4344 .op_flags
= XTENSA_OP_PRIVILEGED
,
4346 .name
= "rsr.icount",
4347 .translate
= translate_rsr
,
4348 .test_exceptions
= test_exceptions_sr
,
4349 .par
= (const uint32_t[]){
4351 XTENSA_OPTION_DEBUG
,
4353 .op_flags
= XTENSA_OP_PRIVILEGED
,
4355 .name
= "rsr.icountlevel",
4356 .translate
= translate_rsr
,
4357 .test_exceptions
= test_exceptions_sr
,
4358 .par
= (const uint32_t[]){
4360 XTENSA_OPTION_DEBUG
,
4362 .op_flags
= XTENSA_OP_PRIVILEGED
,
4364 .name
= "rsr.intclear",
4365 .translate
= translate_rsr
,
4366 .test_exceptions
= test_exceptions_sr
,
4367 .par
= (const uint32_t[]){
4369 XTENSA_OPTION_INTERRUPT
,
4371 .op_flags
= XTENSA_OP_PRIVILEGED
,
4373 .name
= "rsr.intenable",
4374 .translate
= translate_rsr
,
4375 .test_exceptions
= test_exceptions_sr
,
4376 .par
= (const uint32_t[]){
4378 XTENSA_OPTION_INTERRUPT
,
4380 .op_flags
= XTENSA_OP_PRIVILEGED
,
4382 .name
= "rsr.interrupt",
4383 .translate
= translate_rsr_ccount
,
4384 .test_exceptions
= test_exceptions_sr
,
4385 .par
= (const uint32_t[]){
4387 XTENSA_OPTION_INTERRUPT
,
4389 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
4391 .name
= "rsr.intset",
4392 .translate
= translate_rsr_ccount
,
4393 .test_exceptions
= test_exceptions_sr
,
4394 .par
= (const uint32_t[]){
4396 XTENSA_OPTION_INTERRUPT
,
4398 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
4400 .name
= "rsr.itlbcfg",
4401 .translate
= translate_rsr
,
4402 .test_exceptions
= test_exceptions_sr
,
4403 .par
= (const uint32_t[]){
4407 .op_flags
= XTENSA_OP_PRIVILEGED
,
4410 .translate
= translate_rsr
,
4411 .test_exceptions
= test_exceptions_sr
,
4412 .par
= (const uint32_t[]){
4417 .name
= "rsr.lcount",
4418 .translate
= translate_rsr
,
4419 .test_exceptions
= test_exceptions_sr
,
4420 .par
= (const uint32_t[]){
4426 .translate
= translate_rsr
,
4427 .test_exceptions
= test_exceptions_sr
,
4428 .par
= (const uint32_t[]){
4433 .name
= "rsr.litbase",
4434 .translate
= translate_rsr
,
4435 .test_exceptions
= test_exceptions_sr
,
4436 .par
= (const uint32_t[]){
4438 XTENSA_OPTION_EXTENDED_L32R
,
4442 .translate
= translate_rsr
,
4443 .test_exceptions
= test_exceptions_sr
,
4444 .par
= (const uint32_t[]){
4446 XTENSA_OPTION_MAC16
,
4450 .translate
= translate_rsr
,
4451 .test_exceptions
= test_exceptions_sr
,
4452 .par
= (const uint32_t[]){
4454 XTENSA_OPTION_MAC16
,
4458 .translate
= translate_rsr
,
4459 .test_exceptions
= test_exceptions_sr
,
4460 .par
= (const uint32_t[]){
4462 XTENSA_OPTION_MAC16
,
4466 .translate
= translate_rsr
,
4467 .test_exceptions
= test_exceptions_sr
,
4468 .par
= (const uint32_t[]){
4470 XTENSA_OPTION_MAC16
,
4473 .name
= "rsr.memctl",
4474 .translate
= translate_rsr
,
4475 .par
= (const uint32_t[]){MEMCTL
},
4476 .op_flags
= XTENSA_OP_PRIVILEGED
,
4479 .translate
= translate_rsr
,
4480 .test_exceptions
= test_exceptions_sr
,
4481 .par
= (const uint32_t[]){
4483 XTENSA_OPTION_MEMORY_ECC_PARITY
,
4485 .op_flags
= XTENSA_OP_PRIVILEGED
,
4488 .translate
= translate_rsr
,
4489 .test_exceptions
= test_exceptions_sr
,
4490 .par
= (const uint32_t[]){
4492 XTENSA_OPTION_MEMORY_ECC_PARITY
,
4494 .op_flags
= XTENSA_OP_PRIVILEGED
,
4497 .translate
= translate_rsr
,
4498 .test_exceptions
= test_exceptions_sr
,
4499 .par
= (const uint32_t[]){
4501 XTENSA_OPTION_MEMORY_ECC_PARITY
,
4503 .op_flags
= XTENSA_OP_PRIVILEGED
,
4505 .name
= "rsr.mesave",
4506 .translate
= translate_rsr
,
4507 .test_exceptions
= test_exceptions_sr
,
4508 .par
= (const uint32_t[]){
4510 XTENSA_OPTION_MEMORY_ECC_PARITY
,
4512 .op_flags
= XTENSA_OP_PRIVILEGED
,
4515 .translate
= translate_rsr
,
4516 .test_exceptions
= test_exceptions_sr
,
4517 .par
= (const uint32_t[]){
4519 XTENSA_OPTION_MEMORY_ECC_PARITY
,
4521 .op_flags
= XTENSA_OP_PRIVILEGED
,
4523 .name
= "rsr.mevaddr",
4524 .translate
= translate_rsr
,
4525 .test_exceptions
= test_exceptions_sr
,
4526 .par
= (const uint32_t[]){
4528 XTENSA_OPTION_MEMORY_ECC_PARITY
,
4530 .op_flags
= XTENSA_OP_PRIVILEGED
,
4532 .name
= "rsr.misc0",
4533 .translate
= translate_rsr
,
4534 .test_exceptions
= test_exceptions_sr
,
4535 .par
= (const uint32_t[]){
4537 XTENSA_OPTION_MISC_SR
,
4539 .op_flags
= XTENSA_OP_PRIVILEGED
,
4541 .name
= "rsr.misc1",
4542 .translate
= translate_rsr
,
4543 .test_exceptions
= test_exceptions_sr
,
4544 .par
= (const uint32_t[]){
4546 XTENSA_OPTION_MISC_SR
,
4548 .op_flags
= XTENSA_OP_PRIVILEGED
,
4550 .name
= "rsr.misc2",
4551 .translate
= translate_rsr
,
4552 .test_exceptions
= test_exceptions_sr
,
4553 .par
= (const uint32_t[]){
4555 XTENSA_OPTION_MISC_SR
,
4557 .op_flags
= XTENSA_OP_PRIVILEGED
,
4559 .name
= "rsr.misc3",
4560 .translate
= translate_rsr
,
4561 .test_exceptions
= test_exceptions_sr
,
4562 .par
= (const uint32_t[]){
4564 XTENSA_OPTION_MISC_SR
,
4566 .op_flags
= XTENSA_OP_PRIVILEGED
,
4568 .name
= "rsr.mpucfg",
4569 .translate
= translate_rsr
,
4570 .test_exceptions
= test_exceptions_sr
,
4571 .par
= (const uint32_t[]){
4575 .op_flags
= XTENSA_OP_PRIVILEGED
,
4577 .name
= "rsr.mpuenb",
4578 .translate
= translate_rsr
,
4579 .test_exceptions
= test_exceptions_sr
,
4580 .par
= (const uint32_t[]){
4584 .op_flags
= XTENSA_OP_PRIVILEGED
,
4586 .name
= "rsr.prefctl",
4587 .translate
= translate_rsr
,
4588 .par
= (const uint32_t[]){PREFCTL
},
4591 .translate
= translate_rsr
,
4592 .test_exceptions
= test_exceptions_sr
,
4593 .par
= (const uint32_t[]){
4595 XTENSA_OPTION_PROCESSOR_ID
,
4597 .op_flags
= XTENSA_OP_PRIVILEGED
,
4600 .translate
= translate_rsr
,
4601 .test_exceptions
= test_exceptions_sr
,
4602 .par
= (const uint32_t[]){
4604 XTENSA_OPTION_EXCEPTION
,
4606 .op_flags
= XTENSA_OP_PRIVILEGED
,
4608 .name
= "rsr.ptevaddr",
4609 .translate
= translate_rsr_ptevaddr
,
4610 .test_exceptions
= test_exceptions_sr
,
4611 .par
= (const uint32_t[]){
4615 .op_flags
= XTENSA_OP_PRIVILEGED
,
4617 .name
= "rsr.rasid",
4618 .translate
= translate_rsr
,
4619 .test_exceptions
= test_exceptions_sr
,
4620 .par
= (const uint32_t[]){
4624 .op_flags
= XTENSA_OP_PRIVILEGED
,
4627 .translate
= translate_rsr
,
4628 .par
= (const uint32_t[]){SAR
},
4630 .name
= "rsr.scompare1",
4631 .translate
= translate_rsr
,
4632 .test_exceptions
= test_exceptions_sr
,
4633 .par
= (const uint32_t[]){
4635 XTENSA_OPTION_CONDITIONAL_STORE
,
4638 .name
= "rsr.vecbase",
4639 .translate
= translate_rsr
,
4640 .test_exceptions
= test_exceptions_sr
,
4641 .par
= (const uint32_t[]){
4643 XTENSA_OPTION_RELOCATABLE_VECTOR
,
4645 .op_flags
= XTENSA_OP_PRIVILEGED
,
4647 .name
= "rsr.windowbase",
4648 .translate
= translate_rsr
,
4649 .test_exceptions
= test_exceptions_sr
,
4650 .par
= (const uint32_t[]){
4652 XTENSA_OPTION_WINDOWED_REGISTER
,
4654 .op_flags
= XTENSA_OP_PRIVILEGED
,
4656 .name
= "rsr.windowstart",
4657 .translate
= translate_rsr
,
4658 .test_exceptions
= test_exceptions_sr
,
4659 .par
= (const uint32_t[]){
4661 XTENSA_OPTION_WINDOWED_REGISTER
,
4663 .op_flags
= XTENSA_OP_PRIVILEGED
,
4666 .translate
= translate_nop
,
4668 .name
= "rur.expstate",
4669 .translate
= translate_rur
,
4670 .par
= (const uint32_t[]){EXPSTATE
},
4672 .name
= "rur.threadptr",
4673 .translate
= translate_rur
,
4674 .par
= (const uint32_t[]){THREADPTR
},
4677 .translate
= translate_ldst
,
4678 .par
= (const uint32_t[]){MO_TEUW
, false, true},
4679 .op_flags
= XTENSA_OP_STORE
,
4682 .translate
= translate_s32c1i
,
4683 .op_flags
= XTENSA_OP_LOAD
| XTENSA_OP_STORE
,
4686 .translate
= translate_s32e
,
4687 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_STORE
,
4690 .translate
= translate_s32ex
,
4691 .op_flags
= XTENSA_OP_LOAD
| XTENSA_OP_STORE
,
4693 .name
= (const char * const[]) {
4694 "s32i", "s32i.n", "s32nb", NULL
,
4696 .translate
= translate_ldst
,
4697 .par
= (const uint32_t[]){MO_TEUL
, false, true},
4698 .op_flags
= XTENSA_OP_NAME_ARRAY
| XTENSA_OP_STORE
,
4701 .translate
= translate_ldst
,
4702 .par
= (const uint32_t[]){MO_TEUL
| MO_ALIGN
, true, true},
4703 .op_flags
= XTENSA_OP_STORE
,
4706 .translate
= translate_ldst
,
4707 .par
= (const uint32_t[]){MO_UB
, false, true},
4708 .op_flags
= XTENSA_OP_STORE
,
4711 .translate
= translate_salt
,
4712 .par
= (const uint32_t[]){TCG_COND_LT
},
4715 .translate
= translate_salt
,
4716 .par
= (const uint32_t[]){TCG_COND_LTU
},
4718 .name
= "setb_expstate",
4719 .translate
= translate_setb_expstate
,
4722 .translate
= translate_sext
,
4725 .translate
= translate_simcall
,
4726 .test_exceptions
= test_exceptions_simcall
,
4727 .op_flags
= XTENSA_OP_PRIVILEGED
,
4730 .translate
= translate_sll
,
4733 .translate
= translate_slli
,
4736 .translate
= translate_sra
,
4739 .translate
= translate_srai
,
4742 .translate
= translate_src
,
4745 .translate
= translate_srl
,
4748 .translate
= translate_srli
,
4751 .translate
= translate_ssa8b
,
4754 .translate
= translate_ssa8l
,
4757 .translate
= translate_ssai
,
4760 .translate
= translate_ssl
,
4763 .translate
= translate_ssr
,
4766 .translate
= translate_sub
,
4769 .translate
= translate_subx
,
4770 .par
= (const uint32_t[]){1},
4773 .translate
= translate_subx
,
4774 .par
= (const uint32_t[]){2},
4777 .translate
= translate_subx
,
4778 .par
= (const uint32_t[]){3},
4781 .op_flags
= XTENSA_OP_SYSCALL
,
4783 .name
= "umul.aa.hh",
4784 .translate
= translate_mac16
,
4785 .par
= (const uint32_t[]){MAC16_UMUL
, MAC16_HH
, 0},
4787 .name
= "umul.aa.hl",
4788 .translate
= translate_mac16
,
4789 .par
= (const uint32_t[]){MAC16_UMUL
, MAC16_HL
, 0},
4791 .name
= "umul.aa.lh",
4792 .translate
= translate_mac16
,
4793 .par
= (const uint32_t[]){MAC16_UMUL
, MAC16_LH
, 0},
4795 .name
= "umul.aa.ll",
4796 .translate
= translate_mac16
,
4797 .par
= (const uint32_t[]){MAC16_UMUL
, MAC16_LL
, 0},
4800 .translate
= translate_waiti
,
4801 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
4804 .translate
= translate_wtlb
,
4805 .par
= (const uint32_t[]){true},
4806 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
4809 .translate
= translate_wer
,
4810 .op_flags
= XTENSA_OP_PRIVILEGED
,
4813 .translate
= translate_wtlb
,
4814 .par
= (const uint32_t[]){false},
4815 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
4818 .translate
= translate_wptlb
,
4819 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
4821 .name
= "wrmsk_expstate",
4822 .translate
= translate_wrmsk_expstate
,
4825 .op_flags
= XTENSA_OP_ILL
,
4828 .op_flags
= XTENSA_OP_ILL
,
4830 .name
= "wsr.acchi",
4831 .translate
= translate_wsr_acchi
,
4832 .test_exceptions
= test_exceptions_sr
,
4833 .par
= (const uint32_t[]){
4835 XTENSA_OPTION_MAC16
,
4838 .name
= "wsr.acclo",
4839 .translate
= translate_wsr
,
4840 .test_exceptions
= test_exceptions_sr
,
4841 .par
= (const uint32_t[]){
4843 XTENSA_OPTION_MAC16
,
4846 .name
= "wsr.atomctl",
4847 .translate
= translate_wsr_mask
,
4848 .test_exceptions
= test_exceptions_sr
,
4849 .par
= (const uint32_t[]){
4851 XTENSA_OPTION_ATOMCTL
,
4854 .op_flags
= XTENSA_OP_PRIVILEGED
,
4857 .translate
= translate_wsr_mask
,
4858 .test_exceptions
= test_exceptions_sr
,
4859 .par
= (const uint32_t[]){
4861 XTENSA_OPTION_BOOLEAN
,
4865 .name
= "wsr.cacheadrdis",
4866 .translate
= translate_wsr_mask
,
4867 .test_exceptions
= test_exceptions_sr
,
4868 .par
= (const uint32_t[]){
4873 .op_flags
= XTENSA_OP_PRIVILEGED
,
4875 .name
= "wsr.cacheattr",
4876 .translate
= translate_wsr
,
4877 .test_exceptions
= test_exceptions_sr
,
4878 .par
= (const uint32_t[]){
4880 XTENSA_OPTION_CACHEATTR
,
4882 .op_flags
= XTENSA_OP_PRIVILEGED
,
4884 .name
= "wsr.ccompare0",
4885 .translate
= translate_wsr_ccompare
,
4886 .test_exceptions
= test_exceptions_ccompare
,
4887 .par
= (const uint32_t[]){
4889 XTENSA_OPTION_TIMER_INTERRUPT
,
4891 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
4893 .name
= "wsr.ccompare1",
4894 .translate
= translate_wsr_ccompare
,
4895 .test_exceptions
= test_exceptions_ccompare
,
4896 .par
= (const uint32_t[]){
4898 XTENSA_OPTION_TIMER_INTERRUPT
,
4900 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
4902 .name
= "wsr.ccompare2",
4903 .translate
= translate_wsr_ccompare
,
4904 .test_exceptions
= test_exceptions_ccompare
,
4905 .par
= (const uint32_t[]){
4907 XTENSA_OPTION_TIMER_INTERRUPT
,
4909 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
4911 .name
= "wsr.ccount",
4912 .translate
= translate_wsr_ccount
,
4913 .test_exceptions
= test_exceptions_sr
,
4914 .par
= (const uint32_t[]){
4916 XTENSA_OPTION_TIMER_INTERRUPT
,
4918 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
4920 .name
= "wsr.configid0",
4921 .op_flags
= XTENSA_OP_ILL
,
4923 .name
= "wsr.configid1",
4924 .op_flags
= XTENSA_OP_ILL
,
4926 .name
= "wsr.cpenable",
4927 .translate
= translate_wsr_mask
,
4928 .test_exceptions
= test_exceptions_sr
,
4929 .par
= (const uint32_t[]){
4931 XTENSA_OPTION_COPROCESSOR
,
4934 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
4936 .name
= "wsr.dbreaka0",
4937 .translate
= translate_wsr_dbreaka
,
4938 .test_exceptions
= test_exceptions_dbreak
,
4939 .par
= (const uint32_t[]){
4941 XTENSA_OPTION_DEBUG
,
4943 .op_flags
= XTENSA_OP_PRIVILEGED
,
4945 .name
= "wsr.dbreaka1",
4946 .translate
= translate_wsr_dbreaka
,
4947 .test_exceptions
= test_exceptions_dbreak
,
4948 .par
= (const uint32_t[]){
4950 XTENSA_OPTION_DEBUG
,
4952 .op_flags
= XTENSA_OP_PRIVILEGED
,
4954 .name
= "wsr.dbreakc0",
4955 .translate
= translate_wsr_dbreakc
,
4956 .test_exceptions
= test_exceptions_dbreak
,
4957 .par
= (const uint32_t[]){
4959 XTENSA_OPTION_DEBUG
,
4961 .op_flags
= XTENSA_OP_PRIVILEGED
,
4963 .name
= "wsr.dbreakc1",
4964 .translate
= translate_wsr_dbreakc
,
4965 .test_exceptions
= test_exceptions_dbreak
,
4966 .par
= (const uint32_t[]){
4968 XTENSA_OPTION_DEBUG
,
4970 .op_flags
= XTENSA_OP_PRIVILEGED
,
4973 .translate
= translate_wsr
,
4974 .test_exceptions
= test_exceptions_sr
,
4975 .par
= (const uint32_t[]){
4977 XTENSA_OPTION_DEBUG
,
4979 .op_flags
= XTENSA_OP_PRIVILEGED
,
4981 .name
= "wsr.debugcause",
4982 .op_flags
= XTENSA_OP_ILL
,
4985 .translate
= translate_wsr
,
4986 .test_exceptions
= test_exceptions_sr
,
4987 .par
= (const uint32_t[]){
4989 XTENSA_OPTION_EXCEPTION
,
4991 .op_flags
= XTENSA_OP_PRIVILEGED
,
4993 .name
= "wsr.dtlbcfg",
4994 .translate
= translate_wsr_mask
,
4995 .test_exceptions
= test_exceptions_sr
,
4996 .par
= (const uint32_t[]){
5001 .op_flags
= XTENSA_OP_PRIVILEGED
,
5004 .translate
= translate_wsr
,
5005 .test_exceptions
= test_exceptions_sr
,
5006 .par
= (const uint32_t[]){
5008 XTENSA_OPTION_EXCEPTION
,
5010 .op_flags
= XTENSA_OP_PRIVILEGED
,
5013 .translate
= translate_wsr
,
5014 .test_exceptions
= test_exceptions_hpi
,
5015 .par
= (const uint32_t[]){
5017 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5019 .op_flags
= XTENSA_OP_PRIVILEGED
,
5022 .translate
= translate_wsr
,
5023 .test_exceptions
= test_exceptions_hpi
,
5024 .par
= (const uint32_t[]){
5026 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5028 .op_flags
= XTENSA_OP_PRIVILEGED
,
5031 .translate
= translate_wsr
,
5032 .test_exceptions
= test_exceptions_hpi
,
5033 .par
= (const uint32_t[]){
5035 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5037 .op_flags
= XTENSA_OP_PRIVILEGED
,
5040 .translate
= translate_wsr
,
5041 .test_exceptions
= test_exceptions_hpi
,
5042 .par
= (const uint32_t[]){
5044 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5046 .op_flags
= XTENSA_OP_PRIVILEGED
,
5049 .translate
= translate_wsr
,
5050 .test_exceptions
= test_exceptions_hpi
,
5051 .par
= (const uint32_t[]){
5053 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5055 .op_flags
= XTENSA_OP_PRIVILEGED
,
5058 .translate
= translate_wsr
,
5059 .test_exceptions
= test_exceptions_hpi
,
5060 .par
= (const uint32_t[]){
5062 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5064 .op_flags
= XTENSA_OP_PRIVILEGED
,
5067 .translate
= translate_wsr
,
5068 .test_exceptions
= test_exceptions_hpi
,
5069 .par
= (const uint32_t[]){
5071 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5073 .op_flags
= XTENSA_OP_PRIVILEGED
,
5076 .translate
= translate_wsr
,
5077 .test_exceptions
= test_exceptions_hpi
,
5078 .par
= (const uint32_t[]){
5080 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5082 .op_flags
= XTENSA_OP_PRIVILEGED
,
5085 .translate
= translate_wsr
,
5086 .test_exceptions
= test_exceptions_hpi
,
5087 .par
= (const uint32_t[]){
5089 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5091 .op_flags
= XTENSA_OP_PRIVILEGED
,
5094 .translate
= translate_wsr
,
5095 .test_exceptions
= test_exceptions_hpi
,
5096 .par
= (const uint32_t[]){
5098 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5100 .op_flags
= XTENSA_OP_PRIVILEGED
,
5103 .translate
= translate_wsr
,
5104 .test_exceptions
= test_exceptions_hpi
,
5105 .par
= (const uint32_t[]){
5107 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5109 .op_flags
= XTENSA_OP_PRIVILEGED
,
5112 .translate
= translate_wsr
,
5113 .test_exceptions
= test_exceptions_hpi
,
5114 .par
= (const uint32_t[]){
5116 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5118 .op_flags
= XTENSA_OP_PRIVILEGED
,
5120 .name
= "wsr.eraccess",
5121 .translate
= translate_wsr_mask
,
5122 .par
= (const uint32_t[]){
5127 .op_flags
= XTENSA_OP_PRIVILEGED
,
5129 .name
= "wsr.exccause",
5130 .translate
= translate_wsr
,
5131 .test_exceptions
= test_exceptions_sr
,
5132 .par
= (const uint32_t[]){
5134 XTENSA_OPTION_EXCEPTION
,
5136 .op_flags
= XTENSA_OP_PRIVILEGED
,
5138 .name
= "wsr.excsave1",
5139 .translate
= translate_wsr
,
5140 .test_exceptions
= test_exceptions_sr
,
5141 .par
= (const uint32_t[]){
5143 XTENSA_OPTION_EXCEPTION
,
5145 .op_flags
= XTENSA_OP_PRIVILEGED
,
5147 .name
= "wsr.excsave2",
5148 .translate
= translate_wsr
,
5149 .test_exceptions
= test_exceptions_hpi
,
5150 .par
= (const uint32_t[]){
5152 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5154 .op_flags
= XTENSA_OP_PRIVILEGED
,
5156 .name
= "wsr.excsave3",
5157 .translate
= translate_wsr
,
5158 .test_exceptions
= test_exceptions_hpi
,
5159 .par
= (const uint32_t[]){
5161 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5163 .op_flags
= XTENSA_OP_PRIVILEGED
,
5165 .name
= "wsr.excsave4",
5166 .translate
= translate_wsr
,
5167 .test_exceptions
= test_exceptions_hpi
,
5168 .par
= (const uint32_t[]){
5170 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5172 .op_flags
= XTENSA_OP_PRIVILEGED
,
5174 .name
= "wsr.excsave5",
5175 .translate
= translate_wsr
,
5176 .test_exceptions
= test_exceptions_hpi
,
5177 .par
= (const uint32_t[]){
5179 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5181 .op_flags
= XTENSA_OP_PRIVILEGED
,
5183 .name
= "wsr.excsave6",
5184 .translate
= translate_wsr
,
5185 .test_exceptions
= test_exceptions_hpi
,
5186 .par
= (const uint32_t[]){
5188 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5190 .op_flags
= XTENSA_OP_PRIVILEGED
,
5192 .name
= "wsr.excsave7",
5193 .translate
= translate_wsr
,
5194 .test_exceptions
= test_exceptions_hpi
,
5195 .par
= (const uint32_t[]){
5197 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5199 .op_flags
= XTENSA_OP_PRIVILEGED
,
5201 .name
= "wsr.excvaddr",
5202 .translate
= translate_wsr
,
5203 .test_exceptions
= test_exceptions_sr
,
5204 .par
= (const uint32_t[]){
5206 XTENSA_OPTION_EXCEPTION
,
5208 .op_flags
= XTENSA_OP_PRIVILEGED
,
5210 .name
= "wsr.ibreaka0",
5211 .translate
= translate_wsr_ibreaka
,
5212 .test_exceptions
= test_exceptions_ibreak
,
5213 .par
= (const uint32_t[]){
5215 XTENSA_OPTION_DEBUG
,
5217 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
5219 .name
= "wsr.ibreaka1",
5220 .translate
= translate_wsr_ibreaka
,
5221 .test_exceptions
= test_exceptions_ibreak
,
5222 .par
= (const uint32_t[]){
5224 XTENSA_OPTION_DEBUG
,
5226 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
5228 .name
= "wsr.ibreakenable",
5229 .translate
= translate_wsr_ibreakenable
,
5230 .test_exceptions
= test_exceptions_sr
,
5231 .par
= (const uint32_t[]){
5233 XTENSA_OPTION_DEBUG
,
5235 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
5237 .name
= "wsr.icount",
5238 .translate
= translate_wsr_icount
,
5239 .test_exceptions
= test_exceptions_sr
,
5240 .par
= (const uint32_t[]){
5242 XTENSA_OPTION_DEBUG
,
5244 .op_flags
= XTENSA_OP_PRIVILEGED
,
5246 .name
= "wsr.icountlevel",
5247 .translate
= translate_wsr_mask
,
5248 .test_exceptions
= test_exceptions_sr
,
5249 .par
= (const uint32_t[]){
5251 XTENSA_OPTION_DEBUG
,
5254 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
5256 .name
= "wsr.intclear",
5257 .translate
= translate_wsr_intclear
,
5258 .test_exceptions
= test_exceptions_sr
,
5259 .par
= (const uint32_t[]){
5261 XTENSA_OPTION_INTERRUPT
,
5264 XTENSA_OP_PRIVILEGED
|
5265 XTENSA_OP_EXIT_TB_0
|
5266 XTENSA_OP_CHECK_INTERRUPTS
,
5268 .name
= "wsr.intenable",
5269 .translate
= translate_wsr
,
5270 .test_exceptions
= test_exceptions_sr
,
5271 .par
= (const uint32_t[]){
5273 XTENSA_OPTION_INTERRUPT
,
5276 XTENSA_OP_PRIVILEGED
|
5277 XTENSA_OP_EXIT_TB_0
|
5278 XTENSA_OP_CHECK_INTERRUPTS
,
5280 .name
= "wsr.interrupt",
5281 .translate
= translate_wsr
,
5282 .test_exceptions
= test_exceptions_sr
,
5283 .par
= (const uint32_t[]){
5285 XTENSA_OPTION_INTERRUPT
,
5288 XTENSA_OP_PRIVILEGED
|
5289 XTENSA_OP_EXIT_TB_0
|
5290 XTENSA_OP_CHECK_INTERRUPTS
,
5292 .name
= "wsr.intset",
5293 .translate
= translate_wsr_intset
,
5294 .test_exceptions
= test_exceptions_sr
,
5295 .par
= (const uint32_t[]){
5297 XTENSA_OPTION_INTERRUPT
,
5300 XTENSA_OP_PRIVILEGED
|
5301 XTENSA_OP_EXIT_TB_0
|
5302 XTENSA_OP_CHECK_INTERRUPTS
,
5304 .name
= "wsr.itlbcfg",
5305 .translate
= translate_wsr_mask
,
5306 .test_exceptions
= test_exceptions_sr
,
5307 .par
= (const uint32_t[]){
5312 .op_flags
= XTENSA_OP_PRIVILEGED
,
5315 .translate
= translate_wsr
,
5316 .test_exceptions
= test_exceptions_sr
,
5317 .par
= (const uint32_t[]){
5321 .op_flags
= XTENSA_OP_EXIT_TB_M1
,
5323 .name
= "wsr.lcount",
5324 .translate
= translate_wsr
,
5325 .test_exceptions
= test_exceptions_sr
,
5326 .par
= (const uint32_t[]){
5332 .translate
= translate_wsr
,
5333 .test_exceptions
= test_exceptions_sr
,
5334 .par
= (const uint32_t[]){
5338 .op_flags
= XTENSA_OP_EXIT_TB_M1
,
5340 .name
= "wsr.litbase",
5341 .translate
= translate_wsr_mask
,
5342 .test_exceptions
= test_exceptions_sr
,
5343 .par
= (const uint32_t[]){
5345 XTENSA_OPTION_EXTENDED_L32R
,
5348 .op_flags
= XTENSA_OP_EXIT_TB_M1
,
5351 .translate
= translate_wsr
,
5352 .test_exceptions
= test_exceptions_sr
,
5353 .par
= (const uint32_t[]){
5355 XTENSA_OPTION_MAC16
,
5359 .translate
= translate_wsr
,
5360 .test_exceptions
= test_exceptions_sr
,
5361 .par
= (const uint32_t[]){
5363 XTENSA_OPTION_MAC16
,
5367 .translate
= translate_wsr
,
5368 .test_exceptions
= test_exceptions_sr
,
5369 .par
= (const uint32_t[]){
5371 XTENSA_OPTION_MAC16
,
5375 .translate
= translate_wsr
,
5376 .test_exceptions
= test_exceptions_sr
,
5377 .par
= (const uint32_t[]){
5379 XTENSA_OPTION_MAC16
,
5382 .name
= "wsr.memctl",
5383 .translate
= translate_wsr_memctl
,
5384 .par
= (const uint32_t[]){MEMCTL
},
5385 .op_flags
= XTENSA_OP_PRIVILEGED
,
5388 .translate
= translate_wsr
,
5389 .test_exceptions
= test_exceptions_sr
,
5390 .par
= (const uint32_t[]){
5392 XTENSA_OPTION_MEMORY_ECC_PARITY
,
5394 .op_flags
= XTENSA_OP_PRIVILEGED
,
5397 .translate
= translate_wsr
,
5398 .test_exceptions
= test_exceptions_sr
,
5399 .par
= (const uint32_t[]){
5401 XTENSA_OPTION_MEMORY_ECC_PARITY
,
5403 .op_flags
= XTENSA_OP_PRIVILEGED
,
5406 .translate
= translate_wsr
,
5407 .test_exceptions
= test_exceptions_sr
,
5408 .par
= (const uint32_t[]){
5410 XTENSA_OPTION_MEMORY_ECC_PARITY
,
5412 .op_flags
= XTENSA_OP_PRIVILEGED
,
5414 .name
= "wsr.mesave",
5415 .translate
= translate_wsr
,
5416 .test_exceptions
= test_exceptions_sr
,
5417 .par
= (const uint32_t[]){
5419 XTENSA_OPTION_MEMORY_ECC_PARITY
,
5421 .op_flags
= XTENSA_OP_PRIVILEGED
,
5424 .translate
= translate_wsr
,
5425 .test_exceptions
= test_exceptions_sr
,
5426 .par
= (const uint32_t[]){
5428 XTENSA_OPTION_MEMORY_ECC_PARITY
,
5430 .op_flags
= XTENSA_OP_PRIVILEGED
,
5432 .name
= "wsr.mevaddr",
5433 .translate
= translate_wsr
,
5434 .test_exceptions
= test_exceptions_sr
,
5435 .par
= (const uint32_t[]){
5437 XTENSA_OPTION_MEMORY_ECC_PARITY
,
5439 .op_flags
= XTENSA_OP_PRIVILEGED
,
5441 .name
= "wsr.misc0",
5442 .translate
= translate_wsr
,
5443 .test_exceptions
= test_exceptions_sr
,
5444 .par
= (const uint32_t[]){
5446 XTENSA_OPTION_MISC_SR
,
5448 .op_flags
= XTENSA_OP_PRIVILEGED
,
5450 .name
= "wsr.misc1",
5451 .translate
= translate_wsr
,
5452 .test_exceptions
= test_exceptions_sr
,
5453 .par
= (const uint32_t[]){
5455 XTENSA_OPTION_MISC_SR
,
5457 .op_flags
= XTENSA_OP_PRIVILEGED
,
5459 .name
= "wsr.misc2",
5460 .translate
= translate_wsr
,
5461 .test_exceptions
= test_exceptions_sr
,
5462 .par
= (const uint32_t[]){
5464 XTENSA_OPTION_MISC_SR
,
5466 .op_flags
= XTENSA_OP_PRIVILEGED
,
5468 .name
= "wsr.misc3",
5469 .translate
= translate_wsr
,
5470 .test_exceptions
= test_exceptions_sr
,
5471 .par
= (const uint32_t[]){
5473 XTENSA_OPTION_MISC_SR
,
5475 .op_flags
= XTENSA_OP_PRIVILEGED
,
5478 .translate
= translate_wsr
,
5479 .test_exceptions
= test_exceptions_sr
,
5480 .par
= (const uint32_t[]){
5482 XTENSA_OPTION_TRACE_PORT
,
5484 .op_flags
= XTENSA_OP_PRIVILEGED
,
5486 .name
= "wsr.mpuenb",
5487 .translate
= translate_wsr_mpuenb
,
5488 .test_exceptions
= test_exceptions_sr
,
5489 .par
= (const uint32_t[]){
5493 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
5495 .name
= "wsr.prefctl",
5496 .translate
= translate_wsr
,
5497 .par
= (const uint32_t[]){PREFCTL
},
5500 .op_flags
= XTENSA_OP_ILL
,
5503 .translate
= translate_wsr_ps
,
5504 .test_exceptions
= test_exceptions_sr
,
5505 .par
= (const uint32_t[]){
5507 XTENSA_OPTION_EXCEPTION
,
5510 XTENSA_OP_PRIVILEGED
|
5511 XTENSA_OP_EXIT_TB_M1
|
5512 XTENSA_OP_CHECK_INTERRUPTS
,
5514 .name
= "wsr.ptevaddr",
5515 .translate
= translate_wsr_mask
,
5516 .test_exceptions
= test_exceptions_sr
,
5517 .par
= (const uint32_t[]){
5522 .op_flags
= XTENSA_OP_PRIVILEGED
,
5524 .name
= "wsr.rasid",
5525 .translate
= translate_wsr_rasid
,
5526 .test_exceptions
= test_exceptions_sr
,
5527 .par
= (const uint32_t[]){
5531 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
5534 .translate
= translate_wsr_sar
,
5535 .par
= (const uint32_t[]){SAR
},
5537 .name
= "wsr.scompare1",
5538 .translate
= translate_wsr
,
5539 .test_exceptions
= test_exceptions_sr
,
5540 .par
= (const uint32_t[]){
5542 XTENSA_OPTION_CONDITIONAL_STORE
,
5545 .name
= "wsr.vecbase",
5546 .translate
= translate_wsr
,
5547 .test_exceptions
= test_exceptions_sr
,
5548 .par
= (const uint32_t[]){
5550 XTENSA_OPTION_RELOCATABLE_VECTOR
,
5552 .op_flags
= XTENSA_OP_PRIVILEGED
,
5554 .name
= "wsr.windowbase",
5555 .translate
= translate_wsr_windowbase
,
5556 .test_exceptions
= test_exceptions_sr
,
5557 .par
= (const uint32_t[]){
5559 XTENSA_OPTION_WINDOWED_REGISTER
,
5561 .op_flags
= XTENSA_OP_PRIVILEGED
|
5562 XTENSA_OP_EXIT_TB_M1
|
5563 XTENSA_OP_SYNC_REGISTER_WINDOW
,
5565 .name
= "wsr.windowstart",
5566 .translate
= translate_wsr_windowstart
,
5567 .test_exceptions
= test_exceptions_sr
,
5568 .par
= (const uint32_t[]){
5570 XTENSA_OPTION_WINDOWED_REGISTER
,
5572 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
5574 .name
= "wur.expstate",
5575 .translate
= translate_wur
,
5576 .par
= (const uint32_t[]){EXPSTATE
},
5578 .name
= "wur.threadptr",
5579 .translate
= translate_wur
,
5580 .par
= (const uint32_t[]){THREADPTR
},
5583 .translate
= translate_xor
,
5586 .translate
= translate_boolean
,
5587 .par
= (const uint32_t[]){BOOLEAN_XOR
},
5590 .op_flags
= XTENSA_OP_ILL
,
5593 .op_flags
= XTENSA_OP_ILL
,
5595 .name
= "xsr.acchi",
5596 .translate
= translate_xsr_acchi
,
5597 .test_exceptions
= test_exceptions_sr
,
5598 .par
= (const uint32_t[]){
5600 XTENSA_OPTION_MAC16
,
5603 .name
= "xsr.acclo",
5604 .translate
= translate_xsr
,
5605 .test_exceptions
= test_exceptions_sr
,
5606 .par
= (const uint32_t[]){
5608 XTENSA_OPTION_MAC16
,
5611 .name
= "xsr.atomctl",
5612 .translate
= translate_xsr_mask
,
5613 .test_exceptions
= test_exceptions_sr
,
5614 .par
= (const uint32_t[]){
5616 XTENSA_OPTION_ATOMCTL
,
5619 .op_flags
= XTENSA_OP_PRIVILEGED
,
5622 .translate
= translate_xsr_mask
,
5623 .test_exceptions
= test_exceptions_sr
,
5624 .par
= (const uint32_t[]){
5626 XTENSA_OPTION_BOOLEAN
,
5630 .name
= "xsr.cacheadrdis",
5631 .translate
= translate_xsr_mask
,
5632 .test_exceptions
= test_exceptions_sr
,
5633 .par
= (const uint32_t[]){
5638 .op_flags
= XTENSA_OP_PRIVILEGED
,
5640 .name
= "xsr.cacheattr",
5641 .translate
= translate_xsr
,
5642 .test_exceptions
= test_exceptions_sr
,
5643 .par
= (const uint32_t[]){
5645 XTENSA_OPTION_CACHEATTR
,
5647 .op_flags
= XTENSA_OP_PRIVILEGED
,
5649 .name
= "xsr.ccompare0",
5650 .translate
= translate_xsr_ccompare
,
5651 .test_exceptions
= test_exceptions_ccompare
,
5652 .par
= (const uint32_t[]){
5654 XTENSA_OPTION_TIMER_INTERRUPT
,
5656 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
5658 .name
= "xsr.ccompare1",
5659 .translate
= translate_xsr_ccompare
,
5660 .test_exceptions
= test_exceptions_ccompare
,
5661 .par
= (const uint32_t[]){
5663 XTENSA_OPTION_TIMER_INTERRUPT
,
5665 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
5667 .name
= "xsr.ccompare2",
5668 .translate
= translate_xsr_ccompare
,
5669 .test_exceptions
= test_exceptions_ccompare
,
5670 .par
= (const uint32_t[]){
5672 XTENSA_OPTION_TIMER_INTERRUPT
,
5674 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
5676 .name
= "xsr.ccount",
5677 .translate
= translate_xsr_ccount
,
5678 .test_exceptions
= test_exceptions_sr
,
5679 .par
= (const uint32_t[]){
5681 XTENSA_OPTION_TIMER_INTERRUPT
,
5683 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
5685 .name
= "xsr.configid0",
5686 .op_flags
= XTENSA_OP_ILL
,
5688 .name
= "xsr.configid1",
5689 .op_flags
= XTENSA_OP_ILL
,
5691 .name
= "xsr.cpenable",
5692 .translate
= translate_xsr_mask
,
5693 .test_exceptions
= test_exceptions_sr
,
5694 .par
= (const uint32_t[]){
5696 XTENSA_OPTION_COPROCESSOR
,
5699 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
5701 .name
= "xsr.dbreaka0",
5702 .translate
= translate_xsr_dbreaka
,
5703 .test_exceptions
= test_exceptions_dbreak
,
5704 .par
= (const uint32_t[]){
5706 XTENSA_OPTION_DEBUG
,
5708 .op_flags
= XTENSA_OP_PRIVILEGED
,
5710 .name
= "xsr.dbreaka1",
5711 .translate
= translate_xsr_dbreaka
,
5712 .test_exceptions
= test_exceptions_dbreak
,
5713 .par
= (const uint32_t[]){
5715 XTENSA_OPTION_DEBUG
,
5717 .op_flags
= XTENSA_OP_PRIVILEGED
,
5719 .name
= "xsr.dbreakc0",
5720 .translate
= translate_xsr_dbreakc
,
5721 .test_exceptions
= test_exceptions_dbreak
,
5722 .par
= (const uint32_t[]){
5724 XTENSA_OPTION_DEBUG
,
5726 .op_flags
= XTENSA_OP_PRIVILEGED
,
5728 .name
= "xsr.dbreakc1",
5729 .translate
= translate_xsr_dbreakc
,
5730 .test_exceptions
= test_exceptions_dbreak
,
5731 .par
= (const uint32_t[]){
5733 XTENSA_OPTION_DEBUG
,
5735 .op_flags
= XTENSA_OP_PRIVILEGED
,
5738 .translate
= translate_xsr
,
5739 .test_exceptions
= test_exceptions_sr
,
5740 .par
= (const uint32_t[]){
5742 XTENSA_OPTION_DEBUG
,
5744 .op_flags
= XTENSA_OP_PRIVILEGED
,
5746 .name
= "xsr.debugcause",
5747 .op_flags
= XTENSA_OP_ILL
,
5750 .translate
= translate_xsr
,
5751 .test_exceptions
= test_exceptions_sr
,
5752 .par
= (const uint32_t[]){
5754 XTENSA_OPTION_EXCEPTION
,
5756 .op_flags
= XTENSA_OP_PRIVILEGED
,
5758 .name
= "xsr.dtlbcfg",
5759 .translate
= translate_xsr_mask
,
5760 .test_exceptions
= test_exceptions_sr
,
5761 .par
= (const uint32_t[]){
5766 .op_flags
= XTENSA_OP_PRIVILEGED
,
5769 .translate
= translate_xsr
,
5770 .test_exceptions
= test_exceptions_sr
,
5771 .par
= (const uint32_t[]){
5773 XTENSA_OPTION_EXCEPTION
,
5775 .op_flags
= XTENSA_OP_PRIVILEGED
,
5778 .translate
= translate_xsr
,
5779 .test_exceptions
= test_exceptions_hpi
,
5780 .par
= (const uint32_t[]){
5782 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5784 .op_flags
= XTENSA_OP_PRIVILEGED
,
5787 .translate
= translate_xsr
,
5788 .test_exceptions
= test_exceptions_hpi
,
5789 .par
= (const uint32_t[]){
5791 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5793 .op_flags
= XTENSA_OP_PRIVILEGED
,
5796 .translate
= translate_xsr
,
5797 .test_exceptions
= test_exceptions_hpi
,
5798 .par
= (const uint32_t[]){
5800 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5802 .op_flags
= XTENSA_OP_PRIVILEGED
,
5805 .translate
= translate_xsr
,
5806 .test_exceptions
= test_exceptions_hpi
,
5807 .par
= (const uint32_t[]){
5809 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5811 .op_flags
= XTENSA_OP_PRIVILEGED
,
5814 .translate
= translate_xsr
,
5815 .test_exceptions
= test_exceptions_hpi
,
5816 .par
= (const uint32_t[]){
5818 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5820 .op_flags
= XTENSA_OP_PRIVILEGED
,
5823 .translate
= translate_xsr
,
5824 .test_exceptions
= test_exceptions_hpi
,
5825 .par
= (const uint32_t[]){
5827 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5829 .op_flags
= XTENSA_OP_PRIVILEGED
,
5832 .translate
= translate_xsr
,
5833 .test_exceptions
= test_exceptions_hpi
,
5834 .par
= (const uint32_t[]){
5836 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5838 .op_flags
= XTENSA_OP_PRIVILEGED
,
5841 .translate
= translate_xsr
,
5842 .test_exceptions
= test_exceptions_hpi
,
5843 .par
= (const uint32_t[]){
5845 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5847 .op_flags
= XTENSA_OP_PRIVILEGED
,
5850 .translate
= translate_xsr
,
5851 .test_exceptions
= test_exceptions_hpi
,
5852 .par
= (const uint32_t[]){
5854 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5856 .op_flags
= XTENSA_OP_PRIVILEGED
,
5859 .translate
= translate_xsr
,
5860 .test_exceptions
= test_exceptions_hpi
,
5861 .par
= (const uint32_t[]){
5863 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5865 .op_flags
= XTENSA_OP_PRIVILEGED
,
5868 .translate
= translate_xsr
,
5869 .test_exceptions
= test_exceptions_hpi
,
5870 .par
= (const uint32_t[]){
5872 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5874 .op_flags
= XTENSA_OP_PRIVILEGED
,
5877 .translate
= translate_xsr
,
5878 .test_exceptions
= test_exceptions_hpi
,
5879 .par
= (const uint32_t[]){
5881 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5883 .op_flags
= XTENSA_OP_PRIVILEGED
,
5885 .name
= "xsr.eraccess",
5886 .translate
= translate_xsr_mask
,
5887 .par
= (const uint32_t[]){
5892 .op_flags
= XTENSA_OP_PRIVILEGED
,
5894 .name
= "xsr.exccause",
5895 .translate
= translate_xsr
,
5896 .test_exceptions
= test_exceptions_sr
,
5897 .par
= (const uint32_t[]){
5899 XTENSA_OPTION_EXCEPTION
,
5901 .op_flags
= XTENSA_OP_PRIVILEGED
,
5903 .name
= "xsr.excsave1",
5904 .translate
= translate_xsr
,
5905 .test_exceptions
= test_exceptions_sr
,
5906 .par
= (const uint32_t[]){
5908 XTENSA_OPTION_EXCEPTION
,
5910 .op_flags
= XTENSA_OP_PRIVILEGED
,
5912 .name
= "xsr.excsave2",
5913 .translate
= translate_xsr
,
5914 .test_exceptions
= test_exceptions_hpi
,
5915 .par
= (const uint32_t[]){
5917 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5919 .op_flags
= XTENSA_OP_PRIVILEGED
,
5921 .name
= "xsr.excsave3",
5922 .translate
= translate_xsr
,
5923 .test_exceptions
= test_exceptions_hpi
,
5924 .par
= (const uint32_t[]){
5926 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5928 .op_flags
= XTENSA_OP_PRIVILEGED
,
5930 .name
= "xsr.excsave4",
5931 .translate
= translate_xsr
,
5932 .test_exceptions
= test_exceptions_hpi
,
5933 .par
= (const uint32_t[]){
5935 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5937 .op_flags
= XTENSA_OP_PRIVILEGED
,
5939 .name
= "xsr.excsave5",
5940 .translate
= translate_xsr
,
5941 .test_exceptions
= test_exceptions_hpi
,
5942 .par
= (const uint32_t[]){
5944 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5946 .op_flags
= XTENSA_OP_PRIVILEGED
,
5948 .name
= "xsr.excsave6",
5949 .translate
= translate_xsr
,
5950 .test_exceptions
= test_exceptions_hpi
,
5951 .par
= (const uint32_t[]){
5953 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5955 .op_flags
= XTENSA_OP_PRIVILEGED
,
5957 .name
= "xsr.excsave7",
5958 .translate
= translate_xsr
,
5959 .test_exceptions
= test_exceptions_hpi
,
5960 .par
= (const uint32_t[]){
5962 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5964 .op_flags
= XTENSA_OP_PRIVILEGED
,
5966 .name
= "xsr.excvaddr",
5967 .translate
= translate_xsr
,
5968 .test_exceptions
= test_exceptions_sr
,
5969 .par
= (const uint32_t[]){
5971 XTENSA_OPTION_EXCEPTION
,
5973 .op_flags
= XTENSA_OP_PRIVILEGED
,
5975 .name
= "xsr.ibreaka0",
5976 .translate
= translate_xsr_ibreaka
,
5977 .test_exceptions
= test_exceptions_ibreak
,
5978 .par
= (const uint32_t[]){
5980 XTENSA_OPTION_DEBUG
,
5982 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
5984 .name
= "xsr.ibreaka1",
5985 .translate
= translate_xsr_ibreaka
,
5986 .test_exceptions
= test_exceptions_ibreak
,
5987 .par
= (const uint32_t[]){
5989 XTENSA_OPTION_DEBUG
,
5991 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
5993 .name
= "xsr.ibreakenable",
5994 .translate
= translate_xsr_ibreakenable
,
5995 .test_exceptions
= test_exceptions_sr
,
5996 .par
= (const uint32_t[]){
5998 XTENSA_OPTION_DEBUG
,
6000 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
6002 .name
= "xsr.icount",
6003 .translate
= translate_xsr_icount
,
6004 .test_exceptions
= test_exceptions_sr
,
6005 .par
= (const uint32_t[]){
6007 XTENSA_OPTION_DEBUG
,
6009 .op_flags
= XTENSA_OP_PRIVILEGED
,
6011 .name
= "xsr.icountlevel",
6012 .translate
= translate_xsr_mask
,
6013 .test_exceptions
= test_exceptions_sr
,
6014 .par
= (const uint32_t[]){
6016 XTENSA_OPTION_DEBUG
,
6019 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
6021 .name
= "xsr.intclear",
6022 .op_flags
= XTENSA_OP_ILL
,
6024 .name
= "xsr.intenable",
6025 .translate
= translate_xsr
,
6026 .test_exceptions
= test_exceptions_sr
,
6027 .par
= (const uint32_t[]){
6029 XTENSA_OPTION_INTERRUPT
,
6032 XTENSA_OP_PRIVILEGED
|
6033 XTENSA_OP_EXIT_TB_0
|
6034 XTENSA_OP_CHECK_INTERRUPTS
,
6036 .name
= "xsr.interrupt",
6037 .op_flags
= XTENSA_OP_ILL
,
6039 .name
= "xsr.intset",
6040 .op_flags
= XTENSA_OP_ILL
,
6042 .name
= "xsr.itlbcfg",
6043 .translate
= translate_xsr_mask
,
6044 .test_exceptions
= test_exceptions_sr
,
6045 .par
= (const uint32_t[]){
6050 .op_flags
= XTENSA_OP_PRIVILEGED
,
6053 .translate
= translate_xsr
,
6054 .test_exceptions
= test_exceptions_sr
,
6055 .par
= (const uint32_t[]){
6059 .op_flags
= XTENSA_OP_EXIT_TB_M1
,
6061 .name
= "xsr.lcount",
6062 .translate
= translate_xsr
,
6063 .test_exceptions
= test_exceptions_sr
,
6064 .par
= (const uint32_t[]){
6070 .translate
= translate_xsr
,
6071 .test_exceptions
= test_exceptions_sr
,
6072 .par
= (const uint32_t[]){
6076 .op_flags
= XTENSA_OP_EXIT_TB_M1
,
6078 .name
= "xsr.litbase",
6079 .translate
= translate_xsr_mask
,
6080 .test_exceptions
= test_exceptions_sr
,
6081 .par
= (const uint32_t[]){
6083 XTENSA_OPTION_EXTENDED_L32R
,
6086 .op_flags
= XTENSA_OP_EXIT_TB_M1
,
6089 .translate
= translate_xsr
,
6090 .test_exceptions
= test_exceptions_sr
,
6091 .par
= (const uint32_t[]){
6093 XTENSA_OPTION_MAC16
,
6097 .translate
= translate_xsr
,
6098 .test_exceptions
= test_exceptions_sr
,
6099 .par
= (const uint32_t[]){
6101 XTENSA_OPTION_MAC16
,
6105 .translate
= translate_xsr
,
6106 .test_exceptions
= test_exceptions_sr
,
6107 .par
= (const uint32_t[]){
6109 XTENSA_OPTION_MAC16
,
6113 .translate
= translate_xsr
,
6114 .test_exceptions
= test_exceptions_sr
,
6115 .par
= (const uint32_t[]){
6117 XTENSA_OPTION_MAC16
,
6120 .name
= "xsr.memctl",
6121 .translate
= translate_xsr_memctl
,
6122 .par
= (const uint32_t[]){MEMCTL
},
6123 .op_flags
= XTENSA_OP_PRIVILEGED
,
6126 .translate
= translate_xsr
,
6127 .test_exceptions
= test_exceptions_sr
,
6128 .par
= (const uint32_t[]){
6130 XTENSA_OPTION_MEMORY_ECC_PARITY
,
6132 .op_flags
= XTENSA_OP_PRIVILEGED
,
6135 .translate
= translate_xsr
,
6136 .test_exceptions
= test_exceptions_sr
,
6137 .par
= (const uint32_t[]){
6139 XTENSA_OPTION_MEMORY_ECC_PARITY
,
6141 .op_flags
= XTENSA_OP_PRIVILEGED
,
6144 .translate
= translate_xsr
,
6145 .test_exceptions
= test_exceptions_sr
,
6146 .par
= (const uint32_t[]){
6148 XTENSA_OPTION_MEMORY_ECC_PARITY
,
6150 .op_flags
= XTENSA_OP_PRIVILEGED
,
6152 .name
= "xsr.mesave",
6153 .translate
= translate_xsr
,
6154 .test_exceptions
= test_exceptions_sr
,
6155 .par
= (const uint32_t[]){
6157 XTENSA_OPTION_MEMORY_ECC_PARITY
,
6159 .op_flags
= XTENSA_OP_PRIVILEGED
,
6162 .translate
= translate_xsr
,
6163 .test_exceptions
= test_exceptions_sr
,
6164 .par
= (const uint32_t[]){
6166 XTENSA_OPTION_MEMORY_ECC_PARITY
,
6168 .op_flags
= XTENSA_OP_PRIVILEGED
,
6170 .name
= "xsr.mevaddr",
6171 .translate
= translate_xsr
,
6172 .test_exceptions
= test_exceptions_sr
,
6173 .par
= (const uint32_t[]){
6175 XTENSA_OPTION_MEMORY_ECC_PARITY
,
6177 .op_flags
= XTENSA_OP_PRIVILEGED
,
6179 .name
= "xsr.misc0",
6180 .translate
= translate_xsr
,
6181 .test_exceptions
= test_exceptions_sr
,
6182 .par
= (const uint32_t[]){
6184 XTENSA_OPTION_MISC_SR
,
6186 .op_flags
= XTENSA_OP_PRIVILEGED
,
6188 .name
= "xsr.misc1",
6189 .translate
= translate_xsr
,
6190 .test_exceptions
= test_exceptions_sr
,
6191 .par
= (const uint32_t[]){
6193 XTENSA_OPTION_MISC_SR
,
6195 .op_flags
= XTENSA_OP_PRIVILEGED
,
6197 .name
= "xsr.misc2",
6198 .translate
= translate_xsr
,
6199 .test_exceptions
= test_exceptions_sr
,
6200 .par
= (const uint32_t[]){
6202 XTENSA_OPTION_MISC_SR
,
6204 .op_flags
= XTENSA_OP_PRIVILEGED
,
6206 .name
= "xsr.misc3",
6207 .translate
= translate_xsr
,
6208 .test_exceptions
= test_exceptions_sr
,
6209 .par
= (const uint32_t[]){
6211 XTENSA_OPTION_MISC_SR
,
6213 .op_flags
= XTENSA_OP_PRIVILEGED
,
6215 .name
= "xsr.mpuenb",
6216 .translate
= translate_xsr_mpuenb
,
6217 .test_exceptions
= test_exceptions_sr
,
6218 .par
= (const uint32_t[]){
6222 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
6224 .name
= "xsr.prefctl",
6225 .translate
= translate_xsr
,
6226 .par
= (const uint32_t[]){PREFCTL
},
6229 .op_flags
= XTENSA_OP_ILL
,
6232 .translate
= translate_xsr_ps
,
6233 .test_exceptions
= test_exceptions_sr
,
6234 .par
= (const uint32_t[]){
6236 XTENSA_OPTION_EXCEPTION
,
6239 XTENSA_OP_PRIVILEGED
|
6240 XTENSA_OP_EXIT_TB_M1
|
6241 XTENSA_OP_CHECK_INTERRUPTS
,
6243 .name
= "xsr.ptevaddr",
6244 .translate
= translate_xsr_mask
,
6245 .test_exceptions
= test_exceptions_sr
,
6246 .par
= (const uint32_t[]){
6251 .op_flags
= XTENSA_OP_PRIVILEGED
,
6253 .name
= "xsr.rasid",
6254 .translate
= translate_xsr_rasid
,
6255 .test_exceptions
= test_exceptions_sr
,
6256 .par
= (const uint32_t[]){
6260 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
6263 .translate
= translate_xsr_sar
,
6264 .par
= (const uint32_t[]){SAR
},
6266 .name
= "xsr.scompare1",
6267 .translate
= translate_xsr
,
6268 .test_exceptions
= test_exceptions_sr
,
6269 .par
= (const uint32_t[]){
6271 XTENSA_OPTION_CONDITIONAL_STORE
,
6274 .name
= "xsr.vecbase",
6275 .translate
= translate_xsr
,
6276 .test_exceptions
= test_exceptions_sr
,
6277 .par
= (const uint32_t[]){
6279 XTENSA_OPTION_RELOCATABLE_VECTOR
,
6281 .op_flags
= XTENSA_OP_PRIVILEGED
,
6283 .name
= "xsr.windowbase",
6284 .translate
= translate_xsr_windowbase
,
6285 .test_exceptions
= test_exceptions_sr
,
6286 .par
= (const uint32_t[]){
6288 XTENSA_OPTION_WINDOWED_REGISTER
,
6290 .op_flags
= XTENSA_OP_PRIVILEGED
|
6291 XTENSA_OP_EXIT_TB_M1
|
6292 XTENSA_OP_SYNC_REGISTER_WINDOW
,
6294 .name
= "xsr.windowstart",
6295 .translate
= translate_xsr_windowstart
,
6296 .test_exceptions
= test_exceptions_sr
,
6297 .par
= (const uint32_t[]){
6299 XTENSA_OPTION_WINDOWED_REGISTER
,
6301 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
6305 const XtensaOpcodeTranslators xtensa_core_opcodes
= {
6306 .num_opcodes
= ARRAY_SIZE(core_ops
),
6311 static inline void get_f32_o1_i3(const OpcodeArg
*arg
, OpcodeArg
*arg32
,
6312 int o0
, int i0
, int i1
, int i2
)
6314 if ((i0
>= 0 && arg
[i0
].num_bits
== 64) ||
6315 (o0
>= 0 && arg
[o0
].num_bits
== 64)) {
6317 arg32
[o0
].out
= tcg_temp_new_i32();
6320 arg32
[i0
].in
= tcg_temp_new_i32();
6321 tcg_gen_extrl_i64_i32(arg32
[i0
].in
, arg
[i0
].in
);
6324 arg32
[i1
].in
= tcg_temp_new_i32();
6325 tcg_gen_extrl_i64_i32(arg32
[i1
].in
, arg
[i1
].in
);
6328 arg32
[i2
].in
= tcg_temp_new_i32();
6329 tcg_gen_extrl_i64_i32(arg32
[i2
].in
, arg
[i2
].in
);
6333 arg32
[o0
].out
= arg
[o0
].out
;
6336 arg32
[i0
].in
= arg
[i0
].in
;
6339 arg32
[i1
].in
= arg
[i1
].in
;
6342 arg32
[i2
].in
= arg
[i2
].in
;
6347 static inline void put_f32_o1_i3(const OpcodeArg
*arg
, const OpcodeArg
*arg32
,
6348 int o0
, int i0
, int i1
, int i2
)
6350 if ((i0
>= 0 && arg
[i0
].num_bits
== 64) ||
6351 (o0
>= 0 && arg
[o0
].num_bits
== 64)) {
6353 tcg_gen_extu_i32_i64(arg
[o0
].out
, arg32
[o0
].out
);
6354 tcg_temp_free_i32(arg32
[o0
].out
);
6357 tcg_temp_free_i32(arg32
[i0
].in
);
6360 tcg_temp_free_i32(arg32
[i1
].in
);
6363 tcg_temp_free_i32(arg32
[i2
].in
);
6368 static inline void get_f32_o1_i2(const OpcodeArg
*arg
, OpcodeArg
*arg32
,
6369 int o0
, int i0
, int i1
)
6371 get_f32_o1_i3(arg
, arg32
, o0
, i0
, i1
, -1);
6374 static inline void put_f32_o1_i2(const OpcodeArg
*arg
, const OpcodeArg
*arg32
,
6375 int o0
, int i0
, int i1
)
6377 put_f32_o1_i3(arg
, arg32
, o0
, i0
, i1
, -1);
6380 static inline void get_f32_o1_i1(const OpcodeArg
*arg
, OpcodeArg
*arg32
,
6383 get_f32_o1_i2(arg
, arg32
, o0
, i0
, -1);
6386 static inline void put_f32_o1_i1(const OpcodeArg
*arg
, const OpcodeArg
*arg32
,
6389 put_f32_o1_i2(arg
, arg32
, o0
, i0
, -1);
6392 static inline void get_f32_o1(const OpcodeArg
*arg
, OpcodeArg
*arg32
,
6395 get_f32_o1_i1(arg
, arg32
, o0
, -1);
6398 static inline void put_f32_o1(const OpcodeArg
*arg
, const OpcodeArg
*arg32
,
6401 put_f32_o1_i1(arg
, arg32
, o0
, -1);
6404 static inline void get_f32_i2(const OpcodeArg
*arg
, OpcodeArg
*arg32
,
6407 get_f32_o1_i2(arg
, arg32
, -1, i0
, i1
);
6410 static inline void put_f32_i2(const OpcodeArg
*arg
, const OpcodeArg
*arg32
,
6413 put_f32_o1_i2(arg
, arg32
, -1, i0
, i1
);
6416 static inline void get_f32_i1(const OpcodeArg
*arg
, OpcodeArg
*arg32
,
6419 get_f32_i2(arg
, arg32
, i0
, -1);
6422 static inline void put_f32_i1(const OpcodeArg
*arg
, const OpcodeArg
*arg32
,
6425 put_f32_i2(arg
, arg32
, i0
, -1);
6429 static void translate_abs_d(DisasContext
*dc
, const OpcodeArg arg
[],
6430 const uint32_t par
[])
6432 gen_helper_abs_d(arg
[0].out
, arg
[1].in
);
6435 static void translate_abs_s(DisasContext
*dc
, const OpcodeArg arg
[],
6436 const uint32_t par
[])
6440 get_f32_o1_i1(arg
, arg32
, 0, 1);
6441 gen_helper_abs_s(arg32
[0].out
, arg32
[1].in
);
6442 put_f32_o1_i1(arg
, arg32
, 0, 1);
6445 static void translate_fpu2k_add_s(DisasContext
*dc
, const OpcodeArg arg
[],
6446 const uint32_t par
[])
6448 gen_helper_fpu2k_add_s(arg
[0].out
, cpu_env
,
6449 arg
[1].in
, arg
[2].in
);
6462 static void translate_compare_d(DisasContext
*dc
, const OpcodeArg arg
[],
6463 const uint32_t par
[])
6465 static void (* const helper
[])(TCGv_i32 res
, TCGv_env env
,
6466 TCGv_i64 s
, TCGv_i64 t
) = {
6467 [COMPARE_UN
] = gen_helper_un_d
,
6468 [COMPARE_OEQ
] = gen_helper_oeq_d
,
6469 [COMPARE_UEQ
] = gen_helper_ueq_d
,
6470 [COMPARE_OLT
] = gen_helper_olt_d
,
6471 [COMPARE_ULT
] = gen_helper_ult_d
,
6472 [COMPARE_OLE
] = gen_helper_ole_d
,
6473 [COMPARE_ULE
] = gen_helper_ule_d
,
6475 TCGv_i32 zero
= tcg_const_i32(0);
6476 TCGv_i32 res
= tcg_temp_new_i32();
6477 TCGv_i32 set_br
= tcg_temp_new_i32();
6478 TCGv_i32 clr_br
= tcg_temp_new_i32();
6480 tcg_gen_ori_i32(set_br
, arg
[0].in
, 1 << arg
[0].imm
);
6481 tcg_gen_andi_i32(clr_br
, arg
[0].in
, ~(1 << arg
[0].imm
));
6483 helper
[par
[0]](res
, cpu_env
, arg
[1].in
, arg
[2].in
);
6484 tcg_gen_movcond_i32(TCG_COND_NE
,
6485 arg
[0].out
, res
, zero
,
6487 tcg_temp_free(zero
);
6489 tcg_temp_free(set_br
);
6490 tcg_temp_free(clr_br
);
6493 static void translate_compare_s(DisasContext
*dc
, const OpcodeArg arg
[],
6494 const uint32_t par
[])
6496 static void (* const helper
[])(TCGv_i32 res
, TCGv_env env
,
6497 TCGv_i32 s
, TCGv_i32 t
) = {
6498 [COMPARE_UN
] = gen_helper_un_s
,
6499 [COMPARE_OEQ
] = gen_helper_oeq_s
,
6500 [COMPARE_UEQ
] = gen_helper_ueq_s
,
6501 [COMPARE_OLT
] = gen_helper_olt_s
,
6502 [COMPARE_ULT
] = gen_helper_ult_s
,
6503 [COMPARE_OLE
] = gen_helper_ole_s
,
6504 [COMPARE_ULE
] = gen_helper_ule_s
,
6507 TCGv_i32 zero
= tcg_const_i32(0);
6508 TCGv_i32 res
= tcg_temp_new_i32();
6509 TCGv_i32 set_br
= tcg_temp_new_i32();
6510 TCGv_i32 clr_br
= tcg_temp_new_i32();
6512 tcg_gen_ori_i32(set_br
, arg
[0].in
, 1 << arg
[0].imm
);
6513 tcg_gen_andi_i32(clr_br
, arg
[0].in
, ~(1 << arg
[0].imm
));
6515 get_f32_i2(arg
, arg32
, 1, 2);
6516 helper
[par
[0]](res
, cpu_env
, arg32
[1].in
, arg32
[2].in
);
6517 tcg_gen_movcond_i32(TCG_COND_NE
,
6518 arg
[0].out
, res
, zero
,
6520 put_f32_i2(arg
, arg32
, 1, 2);
6521 tcg_temp_free(zero
);
6523 tcg_temp_free(set_br
);
6524 tcg_temp_free(clr_br
);
6527 static void translate_const_d(DisasContext
*dc
, const OpcodeArg arg
[],
6528 const uint32_t par
[])
6530 static const uint64_t v
[] = {
6531 UINT64_C(0x0000000000000000),
6532 UINT64_C(0x3ff0000000000000),
6533 UINT64_C(0x4000000000000000),
6534 UINT64_C(0x3fe0000000000000),
6537 tcg_gen_movi_i64(arg
[0].out
, v
[arg
[1].imm
% ARRAY_SIZE(v
)]);
6538 if (arg
[1].imm
>= ARRAY_SIZE(v
)) {
6539 qemu_log_mask(LOG_GUEST_ERROR
,
6540 "const.d f%d, #%d, immediate value is reserved\n",
6541 arg
[0].imm
, arg
[1].imm
);
6545 static void translate_const_s(DisasContext
*dc
, const OpcodeArg arg
[],
6546 const uint32_t par
[])
6548 static const uint32_t v
[] = {
6555 if (arg
[0].num_bits
== 32) {
6556 tcg_gen_movi_i32(arg
[0].out
, v
[arg
[1].imm
% ARRAY_SIZE(v
)]);
6558 tcg_gen_movi_i64(arg
[0].out
, v
[arg
[1].imm
% ARRAY_SIZE(v
)]);
6560 if (arg
[1].imm
>= ARRAY_SIZE(v
)) {
6561 qemu_log_mask(LOG_GUEST_ERROR
,
6562 "const.s f%d, #%d, immediate value is reserved\n",
6563 arg
[0].imm
, arg
[1].imm
);
6567 static void translate_float_d(DisasContext
*dc
, const OpcodeArg arg
[],
6568 const uint32_t par
[])
6570 TCGv_i32 scale
= tcg_const_i32(-arg
[2].imm
);
6573 gen_helper_uitof_d(arg
[0].out
, cpu_env
, arg
[1].in
, scale
);
6575 gen_helper_itof_d(arg
[0].out
, cpu_env
, arg
[1].in
, scale
);
6577 tcg_temp_free(scale
);
6580 static void translate_float_s(DisasContext
*dc
, const OpcodeArg arg
[],
6581 const uint32_t par
[])
6583 TCGv_i32 scale
= tcg_const_i32(-arg
[2].imm
);
6586 get_f32_o1(arg
, arg32
, 0);
6588 gen_helper_uitof_s(arg32
[0].out
, cpu_env
, arg
[1].in
, scale
);
6590 gen_helper_itof_s(arg32
[0].out
, cpu_env
, arg
[1].in
, scale
);
6592 put_f32_o1(arg
, arg32
, 0);
6593 tcg_temp_free(scale
);
6596 static void translate_ftoi_d(DisasContext
*dc
, const OpcodeArg arg
[],
6597 const uint32_t par
[])
6599 TCGv_i32 rounding_mode
= tcg_const_i32(par
[0]);
6600 TCGv_i32 scale
= tcg_const_i32(arg
[2].imm
);
6603 gen_helper_ftoui_d(arg
[0].out
, cpu_env
, arg
[1].in
,
6604 rounding_mode
, scale
);
6606 gen_helper_ftoi_d(arg
[0].out
, cpu_env
, arg
[1].in
,
6607 rounding_mode
, scale
);
6609 tcg_temp_free(rounding_mode
);
6610 tcg_temp_free(scale
);
6613 static void translate_ftoi_s(DisasContext
*dc
, const OpcodeArg arg
[],
6614 const uint32_t par
[])
6616 TCGv_i32 rounding_mode
= tcg_const_i32(par
[0]);
6617 TCGv_i32 scale
= tcg_const_i32(arg
[2].imm
);
6620 get_f32_i1(arg
, arg32
, 1);
6622 gen_helper_ftoui_s(arg
[0].out
, cpu_env
, arg32
[1].in
,
6623 rounding_mode
, scale
);
6625 gen_helper_ftoi_s(arg
[0].out
, cpu_env
, arg32
[1].in
,
6626 rounding_mode
, scale
);
6628 put_f32_i1(arg
, arg32
, 1);
6629 tcg_temp_free(rounding_mode
);
6630 tcg_temp_free(scale
);
6633 static void translate_ldsti(DisasContext
*dc
, const OpcodeArg arg
[],
6634 const uint32_t par
[])
6636 TCGv_i32 addr
= tcg_temp_new_i32();
6639 tcg_gen_addi_i32(addr
, arg
[1].in
, arg
[2].imm
);
6640 mop
= gen_load_store_alignment(dc
, MO_TEUL
, addr
);
6642 tcg_gen_qemu_st_tl(arg
[0].in
, addr
, dc
->cring
, mop
);
6644 tcg_gen_qemu_ld_tl(arg
[0].out
, addr
, dc
->cring
, mop
);
6647 tcg_gen_mov_i32(arg
[1].out
, addr
);
6649 tcg_temp_free(addr
);
6652 static void translate_ldstx(DisasContext
*dc
, const OpcodeArg arg
[],
6653 const uint32_t par
[])
6655 TCGv_i32 addr
= tcg_temp_new_i32();
6658 tcg_gen_add_i32(addr
, arg
[1].in
, arg
[2].in
);
6659 mop
= gen_load_store_alignment(dc
, MO_TEUL
, addr
);
6661 tcg_gen_qemu_st_tl(arg
[0].in
, addr
, dc
->cring
, mop
);
6663 tcg_gen_qemu_ld_tl(arg
[0].out
, addr
, dc
->cring
, mop
);
6666 tcg_gen_mov_i32(arg
[1].out
, addr
);
6668 tcg_temp_free(addr
);
6671 static void translate_fpu2k_madd_s(DisasContext
*dc
, const OpcodeArg arg
[],
6672 const uint32_t par
[])
6674 gen_helper_fpu2k_madd_s(arg
[0].out
, cpu_env
,
6675 arg
[0].in
, arg
[1].in
, arg
[2].in
);
6678 static void translate_mov_d(DisasContext
*dc
, const OpcodeArg arg
[],
6679 const uint32_t par
[])
6681 tcg_gen_mov_i64(arg
[0].out
, arg
[1].in
);
6684 static void translate_mov_s(DisasContext
*dc
, const OpcodeArg arg
[],
6685 const uint32_t par
[])
6687 if (arg
[0].num_bits
== 32) {
6688 tcg_gen_mov_i32(arg
[0].out
, arg
[1].in
);
6690 tcg_gen_mov_i64(arg
[0].out
, arg
[1].in
);
6694 static void translate_movcond_d(DisasContext
*dc
, const OpcodeArg arg
[],
6695 const uint32_t par
[])
6697 TCGv_i64 zero
= tcg_const_i64(0);
6698 TCGv_i64 arg2
= tcg_temp_new_i64();
6700 tcg_gen_ext_i32_i64(arg2
, arg
[2].in
);
6701 tcg_gen_movcond_i64(par
[0], arg
[0].out
,
6703 arg
[1].in
, arg
[0].in
);
6704 tcg_temp_free_i64(zero
);
6705 tcg_temp_free_i64(arg2
);
6708 static void translate_movcond_s(DisasContext
*dc
, const OpcodeArg arg
[],
6709 const uint32_t par
[])
6711 if (arg
[0].num_bits
== 32) {
6712 TCGv_i32 zero
= tcg_const_i32(0);
6714 tcg_gen_movcond_i32(par
[0], arg
[0].out
,
6716 arg
[1].in
, arg
[0].in
);
6717 tcg_temp_free(zero
);
6719 translate_movcond_d(dc
, arg
, par
);
6723 static void translate_movp_d(DisasContext
*dc
, const OpcodeArg arg
[],
6724 const uint32_t par
[])
6726 TCGv_i64 zero
= tcg_const_i64(0);
6727 TCGv_i32 tmp1
= tcg_temp_new_i32();
6728 TCGv_i64 tmp2
= tcg_temp_new_i64();
6730 tcg_gen_andi_i32(tmp1
, arg
[2].in
, 1 << arg
[2].imm
);
6731 tcg_gen_extu_i32_i64(tmp2
, tmp1
);
6732 tcg_gen_movcond_i64(par
[0],
6733 arg
[0].out
, tmp2
, zero
,
6734 arg
[1].in
, arg
[0].in
);
6735 tcg_temp_free_i64(zero
);
6736 tcg_temp_free_i32(tmp1
);
6737 tcg_temp_free_i64(tmp2
);
6740 static void translate_movp_s(DisasContext
*dc
, const OpcodeArg arg
[],
6741 const uint32_t par
[])
6743 if (arg
[0].num_bits
== 32) {
6744 TCGv_i32 zero
= tcg_const_i32(0);
6745 TCGv_i32 tmp
= tcg_temp_new_i32();
6747 tcg_gen_andi_i32(tmp
, arg
[2].in
, 1 << arg
[2].imm
);
6748 tcg_gen_movcond_i32(par
[0],
6749 arg
[0].out
, tmp
, zero
,
6750 arg
[1].in
, arg
[0].in
);
6752 tcg_temp_free(zero
);
6754 translate_movp_d(dc
, arg
, par
);
6758 static void translate_fpu2k_mul_s(DisasContext
*dc
, const OpcodeArg arg
[],
6759 const uint32_t par
[])
6761 gen_helper_fpu2k_mul_s(arg
[0].out
, cpu_env
,
6762 arg
[1].in
, arg
[2].in
);
6765 static void translate_fpu2k_msub_s(DisasContext
*dc
, const OpcodeArg arg
[],
6766 const uint32_t par
[])
6768 gen_helper_fpu2k_msub_s(arg
[0].out
, cpu_env
,
6769 arg
[0].in
, arg
[1].in
, arg
[2].in
);
6772 static void translate_neg_d(DisasContext
*dc
, const OpcodeArg arg
[],
6773 const uint32_t par
[])
6775 gen_helper_neg_d(arg
[0].out
, arg
[1].in
);
6778 static void translate_neg_s(DisasContext
*dc
, const OpcodeArg arg
[],
6779 const uint32_t par
[])
6783 get_f32_o1_i1(arg
, arg32
, 0, 1);
6784 gen_helper_neg_s(arg32
[0].out
, arg32
[1].in
);
6785 put_f32_o1_i1(arg
, arg32
, 0, 1);
6788 static void translate_rfr_d(DisasContext
*dc
, const OpcodeArg arg
[],
6789 const uint32_t par
[])
6791 tcg_gen_extrh_i64_i32(arg
[0].out
, arg
[1].in
);
6794 static void translate_rfr_s(DisasContext
*dc
, const OpcodeArg arg
[],
6795 const uint32_t par
[])
6797 if (arg
[1].num_bits
== 32) {
6798 tcg_gen_mov_i32(arg
[0].out
, arg
[1].in
);
6800 tcg_gen_extrl_i64_i32(arg
[0].out
, arg
[1].in
);
6804 static void translate_fpu2k_sub_s(DisasContext
*dc
, const OpcodeArg arg
[],
6805 const uint32_t par
[])
6807 gen_helper_fpu2k_sub_s(arg
[0].out
, cpu_env
,
6808 arg
[1].in
, arg
[2].in
);
6811 static void translate_wfr_d(DisasContext
*dc
, const OpcodeArg arg
[],
6812 const uint32_t par
[])
6814 tcg_gen_concat_i32_i64(arg
[0].out
, arg
[2].in
, arg
[1].in
);
6817 static void translate_wfr_s(DisasContext
*dc
, const OpcodeArg arg
[],
6818 const uint32_t par
[])
6820 if (arg
[0].num_bits
== 32) {
6821 tcg_gen_mov_i32(arg
[0].out
, arg
[1].in
);
6823 tcg_gen_ext_i32_i64(arg
[0].out
, arg
[1].in
);
6827 static void translate_wur_fpu2k_fcr(DisasContext
*dc
, const OpcodeArg arg
[],
6828 const uint32_t par
[])
6830 gen_helper_wur_fpu2k_fcr(cpu_env
, arg
[0].in
);
6833 static void translate_wur_fpu2k_fsr(DisasContext
*dc
, const OpcodeArg arg
[],
6834 const uint32_t par
[])
6836 tcg_gen_andi_i32(cpu_UR
[par
[0]], arg
[0].in
, 0xffffff80);
6839 static const XtensaOpcodeOps fpu2000_ops
[] = {
6842 .translate
= translate_abs_s
,
6846 .translate
= translate_fpu2k_add_s
,
6850 .translate
= translate_ftoi_s
,
6851 .par
= (const uint32_t[]){float_round_up
, false},
6855 .translate
= translate_float_s
,
6856 .par
= (const uint32_t[]){false},
6860 .translate
= translate_ftoi_s
,
6861 .par
= (const uint32_t[]){float_round_down
, false},
6865 .translate
= translate_ldsti
,
6866 .par
= (const uint32_t[]){false, false},
6867 .op_flags
= XTENSA_OP_LOAD
,
6871 .translate
= translate_ldsti
,
6872 .par
= (const uint32_t[]){false, true},
6873 .op_flags
= XTENSA_OP_LOAD
,
6877 .translate
= translate_ldstx
,
6878 .par
= (const uint32_t[]){false, false},
6879 .op_flags
= XTENSA_OP_LOAD
,
6883 .translate
= translate_ldstx
,
6884 .par
= (const uint32_t[]){false, true},
6885 .op_flags
= XTENSA_OP_LOAD
,
6889 .translate
= translate_fpu2k_madd_s
,
6893 .translate
= translate_mov_s
,
6897 .translate
= translate_movcond_s
,
6898 .par
= (const uint32_t[]){TCG_COND_EQ
},
6902 .translate
= translate_movp_s
,
6903 .par
= (const uint32_t[]){TCG_COND_EQ
},
6907 .translate
= translate_movcond_s
,
6908 .par
= (const uint32_t[]){TCG_COND_GE
},
6912 .translate
= translate_movcond_s
,
6913 .par
= (const uint32_t[]){TCG_COND_LT
},
6917 .translate
= translate_movcond_s
,
6918 .par
= (const uint32_t[]){TCG_COND_NE
},
6922 .translate
= translate_movp_s
,
6923 .par
= (const uint32_t[]){TCG_COND_NE
},
6927 .translate
= translate_fpu2k_msub_s
,
6931 .translate
= translate_fpu2k_mul_s
,
6935 .translate
= translate_neg_s
,
6939 .translate
= translate_compare_s
,
6940 .par
= (const uint32_t[]){COMPARE_OEQ
},
6944 .translate
= translate_compare_s
,
6945 .par
= (const uint32_t[]){COMPARE_OLE
},
6949 .translate
= translate_compare_s
,
6950 .par
= (const uint32_t[]){COMPARE_OLT
},
6954 .translate
= translate_rfr_s
,
6958 .translate
= translate_ftoi_s
,
6959 .par
= (const uint32_t[]){float_round_nearest_even
, false},
6963 .translate
= translate_rur
,
6964 .par
= (const uint32_t[]){FCR
},
6968 .translate
= translate_rur
,
6969 .par
= (const uint32_t[]){FSR
},
6973 .translate
= translate_ldsti
,
6974 .par
= (const uint32_t[]){true, false},
6975 .op_flags
= XTENSA_OP_STORE
,
6979 .translate
= translate_ldsti
,
6980 .par
= (const uint32_t[]){true, true},
6981 .op_flags
= XTENSA_OP_STORE
,
6985 .translate
= translate_ldstx
,
6986 .par
= (const uint32_t[]){true, false},
6987 .op_flags
= XTENSA_OP_STORE
,
6991 .translate
= translate_ldstx
,
6992 .par
= (const uint32_t[]){true, true},
6993 .op_flags
= XTENSA_OP_STORE
,
6997 .translate
= translate_fpu2k_sub_s
,
7001 .translate
= translate_ftoi_s
,
7002 .par
= (const uint32_t[]){float_round_to_zero
, false},
7006 .translate
= translate_compare_s
,
7007 .par
= (const uint32_t[]){COMPARE_UEQ
},
7011 .translate
= translate_float_s
,
7012 .par
= (const uint32_t[]){true},
7016 .translate
= translate_compare_s
,
7017 .par
= (const uint32_t[]){COMPARE_ULE
},
7021 .translate
= translate_compare_s
,
7022 .par
= (const uint32_t[]){COMPARE_ULT
},
7026 .translate
= translate_compare_s
,
7027 .par
= (const uint32_t[]){COMPARE_UN
},
7031 .translate
= translate_ftoi_s
,
7032 .par
= (const uint32_t[]){float_round_to_zero
, true},
7036 .translate
= translate_wfr_s
,
7040 .translate
= translate_wur_fpu2k_fcr
,
7041 .par
= (const uint32_t[]){FCR
},
7045 .translate
= translate_wur_fpu2k_fsr
,
7046 .par
= (const uint32_t[]){FSR
},
7051 const XtensaOpcodeTranslators xtensa_fpu2000_opcodes
= {
7052 .num_opcodes
= ARRAY_SIZE(fpu2000_ops
),
7053 .opcode
= fpu2000_ops
,
7056 static void translate_add_d(DisasContext
*dc
, const OpcodeArg arg
[],
7057 const uint32_t par
[])
7059 gen_helper_add_d(arg
[0].out
, cpu_env
, arg
[1].in
, arg
[2].in
);
7062 static void translate_add_s(DisasContext
*dc
, const OpcodeArg arg
[],
7063 const uint32_t par
[])
7065 if (option_enabled(dc
, XTENSA_OPTION_DFPU_SINGLE_ONLY
)) {
7066 gen_helper_fpu2k_add_s(arg
[0].out
, cpu_env
,
7067 arg
[1].in
, arg
[2].in
);
7071 get_f32_o1_i2(arg
, arg32
, 0, 1, 2);
7072 gen_helper_add_s(arg32
[0].out
, cpu_env
, arg32
[1].in
, arg32
[2].in
);
7073 put_f32_o1_i2(arg
, arg32
, 0, 1, 2);
7077 static void translate_cvtd_s(DisasContext
*dc
, const OpcodeArg arg
[],
7078 const uint32_t par
[])
7080 TCGv_i32 v
= tcg_temp_new_i32();
7082 tcg_gen_extrl_i64_i32(v
, arg
[1].in
);
7083 gen_helper_cvtd_s(arg
[0].out
, cpu_env
, v
);
7084 tcg_temp_free_i32(v
);
7087 static void translate_cvts_d(DisasContext
*dc
, const OpcodeArg arg
[],
7088 const uint32_t par
[])
7090 TCGv_i32 v
= tcg_temp_new_i32();
7092 gen_helper_cvts_d(v
, cpu_env
, arg
[1].in
);
7093 tcg_gen_extu_i32_i64(arg
[0].out
, v
);
7094 tcg_temp_free_i32(v
);
7097 static void translate_ldsti_d(DisasContext
*dc
, const OpcodeArg arg
[],
7098 const uint32_t par
[])
7104 addr
= tcg_temp_new_i32();
7105 tcg_gen_addi_i32(addr
, arg
[1].in
, arg
[2].imm
);
7109 mop
= gen_load_store_alignment(dc
, MO_TEQ
, addr
);
7111 tcg_gen_qemu_st_i64(arg
[0].in
, addr
, dc
->cring
, mop
);
7113 tcg_gen_qemu_ld_i64(arg
[0].out
, addr
, dc
->cring
, mop
);
7117 tcg_gen_mov_i32(arg
[1].out
, addr
);
7119 tcg_gen_addi_i32(arg
[1].out
, arg
[1].in
, arg
[2].imm
);
7123 tcg_temp_free(addr
);
7127 static void translate_ldsti_s(DisasContext
*dc
, const OpcodeArg arg
[],
7128 const uint32_t par
[])
7135 addr
= tcg_temp_new_i32();
7136 tcg_gen_addi_i32(addr
, arg
[1].in
, arg
[2].imm
);
7140 mop
= gen_load_store_alignment(dc
, MO_TEUL
, addr
);
7142 get_f32_i1(arg
, arg32
, 0);
7143 tcg_gen_qemu_st_tl(arg32
[0].in
, addr
, dc
->cring
, mop
);
7144 put_f32_i1(arg
, arg32
, 0);
7146 get_f32_o1(arg
, arg32
, 0);
7147 tcg_gen_qemu_ld_tl(arg32
[0].out
, addr
, dc
->cring
, mop
);
7148 put_f32_o1(arg
, arg32
, 0);
7152 tcg_gen_mov_i32(arg
[1].out
, addr
);
7154 tcg_gen_addi_i32(arg
[1].out
, arg
[1].in
, arg
[2].imm
);
7158 tcg_temp_free(addr
);
7162 static void translate_ldstx_d(DisasContext
*dc
, const OpcodeArg arg
[],
7163 const uint32_t par
[])
7169 addr
= tcg_temp_new_i32();
7170 tcg_gen_add_i32(addr
, arg
[1].in
, arg
[2].in
);
7174 mop
= gen_load_store_alignment(dc
, MO_TEQ
, addr
);
7176 tcg_gen_qemu_st_i64(arg
[0].in
, addr
, dc
->cring
, mop
);
7178 tcg_gen_qemu_ld_i64(arg
[0].out
, addr
, dc
->cring
, mop
);
7182 tcg_gen_mov_i32(arg
[1].out
, addr
);
7184 tcg_gen_add_i32(arg
[1].out
, arg
[1].in
, arg
[2].in
);
7188 tcg_temp_free(addr
);
7192 static void translate_ldstx_s(DisasContext
*dc
, const OpcodeArg arg
[],
7193 const uint32_t par
[])
7200 addr
= tcg_temp_new_i32();
7201 tcg_gen_add_i32(addr
, arg
[1].in
, arg
[2].in
);
7205 mop
= gen_load_store_alignment(dc
, MO_TEUL
, addr
);
7207 get_f32_i1(arg
, arg32
, 0);
7208 tcg_gen_qemu_st_tl(arg32
[0].in
, addr
, dc
->cring
, mop
);
7209 put_f32_i1(arg
, arg32
, 0);
7211 get_f32_o1(arg
, arg32
, 0);
7212 tcg_gen_qemu_ld_tl(arg32
[0].out
, addr
, dc
->cring
, mop
);
7213 put_f32_o1(arg
, arg32
, 0);
7217 tcg_gen_mov_i32(arg
[1].out
, addr
);
7219 tcg_gen_add_i32(arg
[1].out
, arg
[1].in
, arg
[2].in
);
7223 tcg_temp_free(addr
);
7227 static void translate_madd_d(DisasContext
*dc
, const OpcodeArg arg
[],
7228 const uint32_t par
[])
7230 gen_helper_madd_d(arg
[0].out
, cpu_env
,
7231 arg
[0].in
, arg
[1].in
, arg
[2].in
);
7234 static void translate_madd_s(DisasContext
*dc
, const OpcodeArg arg
[],
7235 const uint32_t par
[])
7237 if (option_enabled(dc
, XTENSA_OPTION_DFPU_SINGLE_ONLY
)) {
7238 gen_helper_fpu2k_madd_s(arg
[0].out
, cpu_env
,
7239 arg
[0].in
, arg
[1].in
, arg
[2].in
);
7243 get_f32_o1_i3(arg
, arg32
, 0, 0, 1, 2);
7244 gen_helper_madd_s(arg32
[0].out
, cpu_env
,
7245 arg32
[0].in
, arg32
[1].in
, arg32
[2].in
);
7246 put_f32_o1_i3(arg
, arg32
, 0, 0, 1, 2);
7250 static void translate_mul_d(DisasContext
*dc
, const OpcodeArg arg
[],
7251 const uint32_t par
[])
7253 gen_helper_mul_d(arg
[0].out
, cpu_env
, arg
[1].in
, arg
[2].in
);
7256 static void translate_mul_s(DisasContext
*dc
, const OpcodeArg arg
[],
7257 const uint32_t par
[])
7259 if (option_enabled(dc
, XTENSA_OPTION_DFPU_SINGLE_ONLY
)) {
7260 gen_helper_fpu2k_mul_s(arg
[0].out
, cpu_env
,
7261 arg
[1].in
, arg
[2].in
);
7265 get_f32_o1_i2(arg
, arg32
, 0, 1, 2);
7266 gen_helper_mul_s(arg32
[0].out
, cpu_env
, arg32
[1].in
, arg32
[2].in
);
7267 put_f32_o1_i2(arg
, arg32
, 0, 1, 2);
7271 static void translate_msub_d(DisasContext
*dc
, const OpcodeArg arg
[],
7272 const uint32_t par
[])
7274 gen_helper_msub_d(arg
[0].out
, cpu_env
,
7275 arg
[0].in
, arg
[1].in
, arg
[2].in
);
7278 static void translate_msub_s(DisasContext
*dc
, const OpcodeArg arg
[],
7279 const uint32_t par
[])
7281 if (option_enabled(dc
, XTENSA_OPTION_DFPU_SINGLE_ONLY
)) {
7282 gen_helper_fpu2k_msub_s(arg
[0].out
, cpu_env
,
7283 arg
[0].in
, arg
[1].in
, arg
[2].in
);
7287 get_f32_o1_i3(arg
, arg32
, 0, 0, 1, 2);
7288 gen_helper_msub_s(arg32
[0].out
, cpu_env
,
7289 arg32
[0].in
, arg32
[1].in
, arg32
[2].in
);
7290 put_f32_o1_i3(arg
, arg32
, 0, 0, 1, 2);
7294 static void translate_sub_d(DisasContext
*dc
, const OpcodeArg arg
[],
7295 const uint32_t par
[])
7297 gen_helper_sub_d(arg
[0].out
, cpu_env
, arg
[1].in
, arg
[2].in
);
7300 static void translate_sub_s(DisasContext
*dc
, const OpcodeArg arg
[],
7301 const uint32_t par
[])
7303 if (option_enabled(dc
, XTENSA_OPTION_DFPU_SINGLE_ONLY
)) {
7304 gen_helper_fpu2k_sub_s(arg
[0].out
, cpu_env
,
7305 arg
[1].in
, arg
[2].in
);
7309 get_f32_o1_i2(arg
, arg32
, 0, 1, 2);
7310 gen_helper_sub_s(arg32
[0].out
, cpu_env
, arg32
[1].in
, arg32
[2].in
);
7311 put_f32_o1_i2(arg
, arg32
, 0, 1, 2);
7315 static void translate_mkdadj_d(DisasContext
*dc
, const OpcodeArg arg
[],
7316 const uint32_t par
[])
7318 gen_helper_mkdadj_d(arg
[0].out
, cpu_env
, arg
[0].in
, arg
[1].in
);
7321 static void translate_mkdadj_s(DisasContext
*dc
, const OpcodeArg arg
[],
7322 const uint32_t par
[])
7326 get_f32_o1_i2(arg
, arg32
, 0, 0, 1);
7327 gen_helper_mkdadj_s(arg32
[0].out
, cpu_env
, arg32
[0].in
, arg32
[1].in
);
7328 put_f32_o1_i2(arg
, arg32
, 0, 0, 1);
7331 static void translate_mksadj_d(DisasContext
*dc
, const OpcodeArg arg
[],
7332 const uint32_t par
[])
7334 gen_helper_mksadj_d(arg
[0].out
, cpu_env
, arg
[1].in
);
7337 static void translate_mksadj_s(DisasContext
*dc
, const OpcodeArg arg
[],
7338 const uint32_t par
[])
7342 get_f32_o1_i1(arg
, arg32
, 0, 1);
7343 gen_helper_mksadj_s(arg32
[0].out
, cpu_env
, arg32
[1].in
);
7344 put_f32_o1_i1(arg
, arg32
, 0, 1);
7347 static void translate_wur_fpu_fcr(DisasContext
*dc
, const OpcodeArg arg
[],
7348 const uint32_t par
[])
7350 gen_helper_wur_fpu_fcr(cpu_env
, arg
[0].in
);
7353 static void translate_rur_fpu_fsr(DisasContext
*dc
, const OpcodeArg arg
[],
7354 const uint32_t par
[])
7356 gen_helper_rur_fpu_fsr(arg
[0].out
, cpu_env
);
7359 static void translate_wur_fpu_fsr(DisasContext
*dc
, const OpcodeArg arg
[],
7360 const uint32_t par
[])
7362 gen_helper_wur_fpu_fsr(cpu_env
, arg
[0].in
);
7365 static const XtensaOpcodeOps fpu_ops
[] = {
7368 .translate
= translate_abs_d
,
7372 .translate
= translate_abs_s
,
7376 .translate
= translate_add_d
,
7380 .translate
= translate_add_s
,
7384 .translate
= translate_nop
,
7388 .translate
= translate_nop
,
7391 .name
= "addexpm.d",
7392 .translate
= translate_mov_s
,
7395 .name
= "addexpm.s",
7396 .translate
= translate_mov_s
,
7400 .translate
= translate_ftoi_d
,
7401 .par
= (const uint32_t[]){float_round_up
, false},
7405 .translate
= translate_ftoi_s
,
7406 .par
= (const uint32_t[]){float_round_up
, false},
7410 .translate
= translate_const_d
,
7414 .translate
= translate_const_s
,
7418 .translate
= translate_cvtd_s
,
7422 .translate
= translate_cvts_d
,
7426 .translate
= translate_nop
,
7430 .translate
= translate_nop
,
7434 .translate
= translate_nop
,
7438 .translate
= translate_nop
,
7442 .translate
= translate_float_d
,
7443 .par
= (const uint32_t[]){false},
7447 .translate
= translate_float_s
,
7448 .par
= (const uint32_t[]){false},
7452 .translate
= translate_ftoi_d
,
7453 .par
= (const uint32_t[]){float_round_down
, false},
7457 .translate
= translate_ftoi_s
,
7458 .par
= (const uint32_t[]){float_round_down
, false},
7462 .translate
= translate_ldsti_d
,
7463 .par
= (const uint32_t[]){false, true, false},
7464 .op_flags
= XTENSA_OP_LOAD
,
7468 .translate
= translate_ldsti_d
,
7469 .par
= (const uint32_t[]){false, false, true},
7470 .op_flags
= XTENSA_OP_LOAD
,
7474 .translate
= translate_ldsti_d
,
7475 .par
= (const uint32_t[]){false, true, true},
7476 .op_flags
= XTENSA_OP_LOAD
,
7480 .translate
= translate_ldstx_d
,
7481 .par
= (const uint32_t[]){false, true, false},
7482 .op_flags
= XTENSA_OP_LOAD
,
7486 .translate
= translate_ldstx_d
,
7487 .par
= (const uint32_t[]){false, false, true},
7488 .op_flags
= XTENSA_OP_LOAD
,
7492 .translate
= translate_ldstx_d
,
7493 .par
= (const uint32_t[]){false, true, true},
7494 .op_flags
= XTENSA_OP_LOAD
,
7498 .translate
= translate_ldsti_s
,
7499 .par
= (const uint32_t[]){false, true, false},
7500 .op_flags
= XTENSA_OP_LOAD
,
7504 .translate
= translate_ldsti_s
,
7505 .par
= (const uint32_t[]){false, false, true},
7506 .op_flags
= XTENSA_OP_LOAD
,
7510 .translate
= translate_ldsti_s
,
7511 .par
= (const uint32_t[]){false, true, true},
7512 .op_flags
= XTENSA_OP_LOAD
,
7516 .translate
= translate_ldstx_s
,
7517 .par
= (const uint32_t[]){false, true, false},
7518 .op_flags
= XTENSA_OP_LOAD
,
7522 .translate
= translate_ldstx_s
,
7523 .par
= (const uint32_t[]){false, false, true},
7524 .op_flags
= XTENSA_OP_LOAD
,
7528 .translate
= translate_ldstx_s
,
7529 .par
= (const uint32_t[]){false, true, true},
7530 .op_flags
= XTENSA_OP_LOAD
,
7534 .translate
= translate_madd_d
,
7538 .translate
= translate_madd_s
,
7542 .translate
= translate_nop
,
7546 .translate
= translate_nop
,
7550 .translate
= translate_mkdadj_d
,
7554 .translate
= translate_mkdadj_s
,
7558 .translate
= translate_mksadj_d
,
7562 .translate
= translate_mksadj_s
,
7566 .translate
= translate_mov_d
,
7570 .translate
= translate_mov_s
,
7574 .translate
= translate_movcond_d
,
7575 .par
= (const uint32_t[]){TCG_COND_EQ
},
7579 .translate
= translate_movcond_s
,
7580 .par
= (const uint32_t[]){TCG_COND_EQ
},
7584 .translate
= translate_movp_d
,
7585 .par
= (const uint32_t[]){TCG_COND_EQ
},
7589 .translate
= translate_movp_s
,
7590 .par
= (const uint32_t[]){TCG_COND_EQ
},
7594 .translate
= translate_movcond_d
,
7595 .par
= (const uint32_t[]){TCG_COND_GE
},
7599 .translate
= translate_movcond_s
,
7600 .par
= (const uint32_t[]){TCG_COND_GE
},
7604 .translate
= translate_movcond_d
,
7605 .par
= (const uint32_t[]){TCG_COND_LT
},
7609 .translate
= translate_movcond_s
,
7610 .par
= (const uint32_t[]){TCG_COND_LT
},
7614 .translate
= translate_movcond_d
,
7615 .par
= (const uint32_t[]){TCG_COND_NE
},
7619 .translate
= translate_movcond_s
,
7620 .par
= (const uint32_t[]){TCG_COND_NE
},
7624 .translate
= translate_movp_d
,
7625 .par
= (const uint32_t[]){TCG_COND_NE
},
7629 .translate
= translate_movp_s
,
7630 .par
= (const uint32_t[]){TCG_COND_NE
},
7634 .translate
= translate_msub_d
,
7638 .translate
= translate_msub_s
,
7642 .translate
= translate_mul_d
,
7646 .translate
= translate_mul_s
,
7650 .translate
= translate_neg_d
,
7654 .translate
= translate_neg_s
,
7658 .translate
= translate_nop
,
7662 .translate
= translate_nop
,
7666 .translate
= translate_compare_d
,
7667 .par
= (const uint32_t[]){COMPARE_OEQ
},
7671 .translate
= translate_compare_s
,
7672 .par
= (const uint32_t[]){COMPARE_OEQ
},
7676 .translate
= translate_compare_d
,
7677 .par
= (const uint32_t[]){COMPARE_OLE
},
7681 .translate
= translate_compare_s
,
7682 .par
= (const uint32_t[]){COMPARE_OLE
},
7686 .translate
= translate_compare_d
,
7687 .par
= (const uint32_t[]){COMPARE_OLT
},
7691 .translate
= translate_compare_s
,
7692 .par
= (const uint32_t[]){COMPARE_OLT
},
7696 .translate
= translate_rfr_s
,
7700 .translate
= translate_rfr_d
,
7704 .translate
= translate_ftoi_d
,
7705 .par
= (const uint32_t[]){float_round_nearest_even
, false},
7709 .translate
= translate_ftoi_s
,
7710 .par
= (const uint32_t[]){float_round_nearest_even
, false},
7714 .translate
= translate_rur
,
7715 .par
= (const uint32_t[]){FCR
},
7719 .translate
= translate_rur_fpu_fsr
,
7723 .translate
= translate_ldsti_d
,
7724 .par
= (const uint32_t[]){true, true, false},
7725 .op_flags
= XTENSA_OP_STORE
,
7729 .translate
= translate_ldsti_d
,
7730 .par
= (const uint32_t[]){true, false, true},
7731 .op_flags
= XTENSA_OP_STORE
,
7735 .translate
= translate_ldsti_d
,
7736 .par
= (const uint32_t[]){true, true, true},
7737 .op_flags
= XTENSA_OP_STORE
,
7741 .translate
= translate_ldstx_d
,
7742 .par
= (const uint32_t[]){true, true, false},
7743 .op_flags
= XTENSA_OP_STORE
,
7747 .translate
= translate_ldstx_d
,
7748 .par
= (const uint32_t[]){true, false, true},
7749 .op_flags
= XTENSA_OP_STORE
,
7753 .translate
= translate_ldstx_d
,
7754 .par
= (const uint32_t[]){true, true, true},
7755 .op_flags
= XTENSA_OP_STORE
,
7759 .translate
= translate_nop
,
7763 .translate
= translate_nop
,
7767 .translate
= translate_ldsti_s
,
7768 .par
= (const uint32_t[]){true, true, false},
7769 .op_flags
= XTENSA_OP_STORE
,
7773 .translate
= translate_ldsti_s
,
7774 .par
= (const uint32_t[]){true, false, true},
7775 .op_flags
= XTENSA_OP_STORE
,
7779 .translate
= translate_ldsti_s
,
7780 .par
= (const uint32_t[]){true, true, true},
7781 .op_flags
= XTENSA_OP_STORE
,
7785 .translate
= translate_ldstx_s
,
7786 .par
= (const uint32_t[]){true, true, false},
7787 .op_flags
= XTENSA_OP_STORE
,
7791 .translate
= translate_ldstx_s
,
7792 .par
= (const uint32_t[]){true, false, true},
7793 .op_flags
= XTENSA_OP_STORE
,
7797 .translate
= translate_ldstx_s
,
7798 .par
= (const uint32_t[]){true, true, true},
7799 .op_flags
= XTENSA_OP_STORE
,
7803 .translate
= translate_sub_d
,
7807 .translate
= translate_sub_s
,
7811 .translate
= translate_ftoi_d
,
7812 .par
= (const uint32_t[]){float_round_to_zero
, false},
7816 .translate
= translate_ftoi_s
,
7817 .par
= (const uint32_t[]){float_round_to_zero
, false},
7821 .translate
= translate_compare_d
,
7822 .par
= (const uint32_t[]){COMPARE_UEQ
},
7826 .translate
= translate_compare_s
,
7827 .par
= (const uint32_t[]){COMPARE_UEQ
},
7831 .translate
= translate_float_d
,
7832 .par
= (const uint32_t[]){true},
7836 .translate
= translate_float_s
,
7837 .par
= (const uint32_t[]){true},
7841 .translate
= translate_compare_d
,
7842 .par
= (const uint32_t[]){COMPARE_ULE
},
7846 .translate
= translate_compare_s
,
7847 .par
= (const uint32_t[]){COMPARE_ULE
},
7851 .translate
= translate_compare_d
,
7852 .par
= (const uint32_t[]){COMPARE_ULT
},
7856 .translate
= translate_compare_s
,
7857 .par
= (const uint32_t[]){COMPARE_ULT
},
7861 .translate
= translate_compare_d
,
7862 .par
= (const uint32_t[]){COMPARE_UN
},
7866 .translate
= translate_compare_s
,
7867 .par
= (const uint32_t[]){COMPARE_UN
},
7871 .translate
= translate_ftoi_d
,
7872 .par
= (const uint32_t[]){float_round_to_zero
, true},
7876 .translate
= translate_ftoi_s
,
7877 .par
= (const uint32_t[]){float_round_to_zero
, true},
7881 .translate
= translate_wfr_s
,
7885 .translate
= translate_wfr_d
,
7889 .translate
= translate_wur_fpu_fcr
,
7890 .par
= (const uint32_t[]){FCR
},
7894 .translate
= translate_wur_fpu_fsr
,
7899 const XtensaOpcodeTranslators xtensa_fpu_opcodes
= {
7900 .num_opcodes
= ARRAY_SIZE(fpu_ops
),