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 return translator_use_goto_tb(&dc
->base
, dest
) ? slot
: -1;
411 static void gen_jumpi(DisasContext
*dc
, uint32_t dest
, int slot
)
413 TCGv_i32 tmp
= tcg_const_i32(dest
);
414 gen_jump_slot(dc
, tmp
, adjust_jump_slot(dc
, dest
, slot
));
418 static void gen_callw_slot(DisasContext
*dc
, int callinc
, TCGv_i32 dest
,
421 TCGv_i32 tcallinc
= tcg_const_i32(callinc
);
423 tcg_gen_deposit_i32(cpu_SR
[PS
], cpu_SR
[PS
],
424 tcallinc
, PS_CALLINC_SHIFT
, PS_CALLINC_LEN
);
425 tcg_temp_free(tcallinc
);
426 tcg_gen_movi_i32(cpu_R
[callinc
<< 2],
427 (callinc
<< 30) | (dc
->base
.pc_next
& 0x3fffffff));
428 gen_jump_slot(dc
, dest
, slot
);
431 static bool gen_check_loop_end(DisasContext
*dc
, int slot
)
433 if (dc
->base
.pc_next
== dc
->lend
) {
434 TCGLabel
*label
= gen_new_label();
436 tcg_gen_brcondi_i32(TCG_COND_EQ
, cpu_SR
[LCOUNT
], 0, label
);
437 tcg_gen_subi_i32(cpu_SR
[LCOUNT
], cpu_SR
[LCOUNT
], 1);
439 gen_jumpi(dc
, dc
->base
.pc_next
- dc
->lbeg_off
, slot
);
441 gen_jump(dc
, cpu_SR
[LBEG
]);
443 gen_set_label(label
);
444 gen_jumpi(dc
, dc
->base
.pc_next
, -1);
450 static void gen_jumpi_check_loop_end(DisasContext
*dc
, int slot
)
452 if (!gen_check_loop_end(dc
, slot
)) {
453 gen_jumpi(dc
, dc
->base
.pc_next
, slot
);
457 static void gen_brcond(DisasContext
*dc
, TCGCond cond
,
458 TCGv_i32 t0
, TCGv_i32 t1
, uint32_t addr
)
460 TCGLabel
*label
= gen_new_label();
462 tcg_gen_brcond_i32(cond
, t0
, t1
, label
);
463 gen_jumpi_check_loop_end(dc
, 0);
464 gen_set_label(label
);
465 gen_jumpi(dc
, addr
, 1);
468 static void gen_brcondi(DisasContext
*dc
, TCGCond cond
,
469 TCGv_i32 t0
, uint32_t t1
, uint32_t addr
)
471 TCGv_i32 tmp
= tcg_const_i32(t1
);
472 gen_brcond(dc
, cond
, t0
, tmp
, addr
);
476 static uint32_t test_exceptions_sr(DisasContext
*dc
, const OpcodeArg arg
[],
477 const uint32_t par
[])
479 return xtensa_option_enabled(dc
->config
, par
[1]) ? 0 : XTENSA_OP_ILL
;
482 static uint32_t test_exceptions_ccompare(DisasContext
*dc
,
483 const OpcodeArg arg
[],
484 const uint32_t par
[])
486 unsigned n
= par
[0] - CCOMPARE
;
488 if (n
>= dc
->config
->nccompare
) {
489 return XTENSA_OP_ILL
;
491 return test_exceptions_sr(dc
, arg
, par
);
494 static uint32_t test_exceptions_dbreak(DisasContext
*dc
, const OpcodeArg arg
[],
495 const uint32_t par
[])
497 unsigned n
= MAX_NDBREAK
;
499 if (par
[0] >= DBREAKA
&& par
[0] < DBREAKA
+ MAX_NDBREAK
) {
500 n
= par
[0] - DBREAKA
;
502 if (par
[0] >= DBREAKC
&& par
[0] < DBREAKC
+ MAX_NDBREAK
) {
503 n
= par
[0] - DBREAKC
;
505 if (n
>= dc
->config
->ndbreak
) {
506 return XTENSA_OP_ILL
;
508 return test_exceptions_sr(dc
, arg
, par
);
511 static uint32_t test_exceptions_ibreak(DisasContext
*dc
, const OpcodeArg arg
[],
512 const uint32_t par
[])
514 unsigned n
= par
[0] - IBREAKA
;
516 if (n
>= dc
->config
->nibreak
) {
517 return XTENSA_OP_ILL
;
519 return test_exceptions_sr(dc
, arg
, par
);
522 static uint32_t test_exceptions_hpi(DisasContext
*dc
, const OpcodeArg arg
[],
523 const uint32_t par
[])
525 unsigned n
= MAX_NLEVEL
+ 1;
527 if (par
[0] >= EXCSAVE1
&& par
[0] < EXCSAVE1
+ MAX_NLEVEL
) {
528 n
= par
[0] - EXCSAVE1
+ 1;
530 if (par
[0] >= EPC1
&& par
[0] < EPC1
+ MAX_NLEVEL
) {
531 n
= par
[0] - EPC1
+ 1;
533 if (par
[0] >= EPS2
&& par
[0] < EPS2
+ MAX_NLEVEL
- 1) {
534 n
= par
[0] - EPS2
+ 2;
536 if (n
> dc
->config
->nlevel
) {
537 return XTENSA_OP_ILL
;
539 return test_exceptions_sr(dc
, arg
, par
);
542 static MemOp
gen_load_store_alignment(DisasContext
*dc
, MemOp mop
,
545 if ((mop
& MO_SIZE
) == MO_8
) {
548 if ((mop
& MO_AMASK
) == MO_UNALN
&&
549 !option_enabled(dc
, XTENSA_OPTION_HW_ALIGNMENT
)) {
552 if (!option_enabled(dc
, XTENSA_OPTION_UNALIGNED_EXCEPTION
)) {
553 tcg_gen_andi_i32(addr
, addr
, ~0 << get_alignment_bits(mop
));
558 #ifndef CONFIG_USER_ONLY
559 static void gen_waiti(DisasContext
*dc
, uint32_t imm4
)
561 TCGv_i32 pc
= tcg_const_i32(dc
->base
.pc_next
);
562 TCGv_i32 intlevel
= tcg_const_i32(imm4
);
564 if (tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
) {
567 gen_helper_waiti(cpu_env
, pc
, intlevel
);
569 tcg_temp_free(intlevel
);
573 static bool gen_window_check(DisasContext
*dc
, uint32_t mask
)
575 unsigned r
= 31 - clz32(mask
);
577 if (r
/ 4 > dc
->window
) {
578 TCGv_i32 pc
= tcg_const_i32(dc
->pc
);
579 TCGv_i32 w
= tcg_const_i32(r
/ 4);
581 gen_helper_window_check(cpu_env
, pc
, w
);
582 dc
->base
.is_jmp
= DISAS_NORETURN
;
588 static TCGv_i32
gen_mac16_m(TCGv_i32 v
, bool hi
, bool is_unsigned
)
590 TCGv_i32 m
= tcg_temp_new_i32();
593 (is_unsigned
? tcg_gen_shri_i32
: tcg_gen_sari_i32
)(m
, v
, 16);
595 (is_unsigned
? tcg_gen_ext16u_i32
: tcg_gen_ext16s_i32
)(m
, v
);
600 static void gen_zero_check(DisasContext
*dc
, const OpcodeArg arg
[])
602 TCGLabel
*label
= gen_new_label();
604 tcg_gen_brcondi_i32(TCG_COND_NE
, arg
[2].in
, 0, label
);
605 gen_exception_cause(dc
, INTEGER_DIVIDE_BY_ZERO_CAUSE
);
606 gen_set_label(label
);
609 static inline unsigned xtensa_op0_insn_len(DisasContext
*dc
, uint8_t op0
)
611 return xtensa_isa_length_from_chars(dc
->config
->isa
, &op0
);
614 static int gen_postprocess(DisasContext
*dc
, int slot
)
616 uint32_t op_flags
= dc
->op_flags
;
618 #ifndef CONFIG_USER_ONLY
619 if (op_flags
& XTENSA_OP_CHECK_INTERRUPTS
) {
620 if (tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
) {
623 gen_helper_check_interrupts(cpu_env
);
626 if (op_flags
& XTENSA_OP_SYNC_REGISTER_WINDOW
) {
627 gen_helper_sync_windowbase(cpu_env
);
629 if (op_flags
& XTENSA_OP_EXIT_TB_M1
) {
635 struct opcode_arg_copy
{
641 struct opcode_arg_info
{
647 XtensaOpcodeOps
*ops
;
648 OpcodeArg arg
[MAX_OPCODE_ARGS
];
649 struct opcode_arg_info in
[MAX_OPCODE_ARGS
];
650 struct opcode_arg_info out
[MAX_OPCODE_ARGS
];
662 static uint32_t encode_resource(enum resource_type r
, unsigned g
, unsigned n
)
664 assert(r
< RES_MAX
&& g
< 256 && n
< 65536);
665 return (r
<< 24) | (g
<< 16) | n
;
668 static enum resource_type
get_resource_type(uint32_t resource
)
670 return resource
>> 24;
674 * a depends on b if b must be executed before a,
675 * because a's side effects will destroy b's inputs.
677 static bool op_depends_on(const struct slot_prop
*a
,
678 const struct slot_prop
*b
)
683 if (a
->op_flags
& XTENSA_OP_CONTROL_FLOW
) {
686 if ((a
->op_flags
& XTENSA_OP_LOAD_STORE
) <
687 (b
->op_flags
& XTENSA_OP_LOAD_STORE
)) {
690 while (i
< a
->n_out
&& j
< b
->n_in
) {
691 if (a
->out
[i
].resource
< b
->in
[j
].resource
) {
693 } else if (a
->out
[i
].resource
> b
->in
[j
].resource
) {
703 * Try to break a dependency on b, append temporary register copy records
704 * to the end of copy and update n_copy in case of success.
705 * This is not always possible: e.g. control flow must always be the last,
706 * load/store must be first and state dependencies are not supported yet.
708 static bool break_dependency(struct slot_prop
*a
,
710 struct opcode_arg_copy
*copy
,
715 unsigned n
= *n_copy
;
718 if (a
->op_flags
& XTENSA_OP_CONTROL_FLOW
) {
721 if ((a
->op_flags
& XTENSA_OP_LOAD_STORE
) <
722 (b
->op_flags
& XTENSA_OP_LOAD_STORE
)) {
725 while (i
< a
->n_out
&& j
< b
->n_in
) {
726 if (a
->out
[i
].resource
< b
->in
[j
].resource
) {
728 } else if (a
->out
[i
].resource
> b
->in
[j
].resource
) {
731 int index
= b
->in
[j
].index
;
733 if (get_resource_type(a
->out
[i
].resource
) != RES_REGFILE
||
737 copy
[n
].resource
= b
->in
[j
].resource
;
738 copy
[n
].arg
= b
->arg
+ index
;
749 * Calculate evaluation order for slot opcodes.
750 * Build opcode order graph and output its nodes in topological sort order.
751 * An edge a -> b in the graph means that opcode a must be followed by
754 static bool tsort(struct slot_prop
*slot
,
755 struct slot_prop
*sorted
[],
757 struct opcode_arg_copy
*copy
,
763 unsigned out_edge
[MAX_INSN_SLOTS
];
764 } node
[MAX_INSN_SLOTS
];
766 unsigned in
[MAX_INSN_SLOTS
];
772 unsigned node_idx
= 0;
774 for (i
= 0; i
< n
; ++i
) {
775 node
[i
].n_in_edge
= 0;
776 node
[i
].n_out_edge
= 0;
779 for (i
= 0; i
< n
; ++i
) {
780 unsigned n_out_edge
= 0;
782 for (j
= 0; j
< n
; ++j
) {
783 if (i
!= j
&& op_depends_on(slot
+ j
, slot
+ i
)) {
784 node
[i
].out_edge
[n_out_edge
] = j
;
790 node
[i
].n_out_edge
= n_out_edge
;
793 for (i
= 0; i
< n
; ++i
) {
794 if (!node
[i
].n_in_edge
) {
801 for (; in_idx
< n_in
; ++in_idx
) {
803 sorted
[n_out
] = slot
+ i
;
805 for (j
= 0; j
< node
[i
].n_out_edge
; ++j
) {
807 if (--node
[node
[i
].out_edge
[j
]].n_in_edge
== 0) {
808 in
[n_in
] = node
[i
].out_edge
[j
];
814 for (; node_idx
< n
; ++node_idx
) {
815 struct tsnode
*cnode
= node
+ node_idx
;
817 if (cnode
->n_in_edge
) {
818 for (j
= 0; j
< cnode
->n_out_edge
; ++j
) {
819 unsigned k
= cnode
->out_edge
[j
];
821 if (break_dependency(slot
+ k
, slot
+ node_idx
,
823 --node
[k
].n_in_edge
== 0) {
828 cnode
->out_edge
[cnode
->n_out_edge
- 1];
839 static void opcode_add_resource(struct slot_prop
*op
,
840 uint32_t resource
, char direction
,
846 assert(op
->n_in
< ARRAY_SIZE(op
->in
));
847 op
->in
[op
->n_in
].resource
= resource
;
848 op
->in
[op
->n_in
].index
= index
;
852 if (direction
== 'm' || direction
== 'o') {
853 assert(op
->n_out
< ARRAY_SIZE(op
->out
));
854 op
->out
[op
->n_out
].resource
= resource
;
855 op
->out
[op
->n_out
].index
= index
;
860 g_assert_not_reached();
864 static int resource_compare(const void *a
, const void *b
)
866 const struct opcode_arg_info
*pa
= a
;
867 const struct opcode_arg_info
*pb
= b
;
869 return pa
->resource
< pb
->resource
?
870 -1 : (pa
->resource
> pb
->resource
? 1 : 0);
873 static int arg_copy_compare(const void *a
, const void *b
)
875 const struct opcode_arg_copy
*pa
= a
;
876 const struct opcode_arg_copy
*pb
= b
;
878 return pa
->resource
< pb
->resource
?
879 -1 : (pa
->resource
> pb
->resource
? 1 : 0);
882 static void disas_xtensa_insn(CPUXtensaState
*env
, DisasContext
*dc
)
884 xtensa_isa isa
= dc
->config
->isa
;
885 unsigned char b
[MAX_INSN_LENGTH
] = {translator_ldub(env
, &dc
->base
,
887 unsigned len
= xtensa_op0_insn_len(dc
, b
[0]);
891 uint32_t op_flags
= 0;
892 struct slot_prop slot_prop
[MAX_INSN_SLOTS
];
893 struct slot_prop
*ordered
[MAX_INSN_SLOTS
];
894 struct opcode_arg_copy arg_copy
[MAX_INSN_SLOTS
* MAX_OPCODE_ARGS
];
895 unsigned n_arg_copy
= 0;
896 uint32_t debug_cause
= 0;
897 uint32_t windowed_register
= 0;
898 uint32_t coprocessor
= 0;
900 if (len
== XTENSA_UNDEFINED
) {
901 qemu_log_mask(LOG_GUEST_ERROR
,
902 "unknown instruction length (pc = %08x)\n",
904 gen_exception_cause(dc
, ILLEGAL_INSTRUCTION_CAUSE
);
905 dc
->base
.pc_next
= dc
->pc
+ 1;
909 dc
->base
.pc_next
= dc
->pc
+ len
;
910 for (i
= 1; i
< len
; ++i
) {
911 b
[i
] = translator_ldub(env
, &dc
->base
, dc
->pc
+ i
);
913 xtensa_insnbuf_from_chars(isa
, dc
->insnbuf
, b
, len
);
914 fmt
= xtensa_format_decode(isa
, dc
->insnbuf
);
915 if (fmt
== XTENSA_UNDEFINED
) {
916 qemu_log_mask(LOG_GUEST_ERROR
,
917 "unrecognized instruction format (pc = %08x)\n",
919 gen_exception_cause(dc
, ILLEGAL_INSTRUCTION_CAUSE
);
922 slots
= xtensa_format_num_slots(isa
, fmt
);
923 for (slot
= 0; slot
< slots
; ++slot
) {
925 int opnd
, vopnd
, opnds
;
926 OpcodeArg
*arg
= slot_prop
[slot
].arg
;
927 XtensaOpcodeOps
*ops
;
929 xtensa_format_get_slot(isa
, fmt
, slot
, dc
->insnbuf
, dc
->slotbuf
);
930 opc
= xtensa_opcode_decode(isa
, fmt
, slot
, dc
->slotbuf
);
931 if (opc
== XTENSA_UNDEFINED
) {
932 qemu_log_mask(LOG_GUEST_ERROR
,
933 "unrecognized opcode in slot %d (pc = %08x)\n",
935 gen_exception_cause(dc
, ILLEGAL_INSTRUCTION_CAUSE
);
938 opnds
= xtensa_opcode_num_operands(isa
, opc
);
940 for (opnd
= vopnd
= 0; opnd
< opnds
; ++opnd
) {
941 void **register_file
= NULL
;
944 if (xtensa_operand_is_register(isa
, opc
, opnd
)) {
945 rf
= xtensa_operand_regfile(isa
, opc
, opnd
);
946 register_file
= dc
->config
->regfile
[rf
];
948 if (rf
== dc
->config
->a_regfile
) {
951 xtensa_operand_get_field(isa
, opc
, opnd
, fmt
, slot
,
953 xtensa_operand_decode(isa
, opc
, opnd
, &v
);
954 windowed_register
|= 1u << v
;
957 if (xtensa_operand_is_visible(isa
, opc
, opnd
)) {
960 xtensa_operand_get_field(isa
, opc
, opnd
, fmt
, slot
,
962 xtensa_operand_decode(isa
, opc
, opnd
, &v
);
963 arg
[vopnd
].raw_imm
= v
;
964 if (xtensa_operand_is_PCrelative(isa
, opc
, opnd
)) {
965 xtensa_operand_undo_reloc(isa
, opc
, opnd
, &v
, dc
->pc
);
969 arg
[vopnd
].in
= register_file
[v
];
970 arg
[vopnd
].out
= register_file
[v
];
971 arg
[vopnd
].num_bits
= xtensa_regfile_num_bits(isa
, rf
);
973 arg
[vopnd
].num_bits
= 32;
978 ops
= dc
->config
->opcode_ops
[opc
];
979 slot_prop
[slot
].ops
= ops
;
982 op_flags
|= ops
->op_flags
;
983 if (ops
->test_exceptions
) {
984 op_flags
|= ops
->test_exceptions(dc
, arg
, ops
->par
);
987 qemu_log_mask(LOG_UNIMP
,
988 "unimplemented opcode '%s' in slot %d (pc = %08x)\n",
989 xtensa_opcode_name(isa
, opc
), slot
, dc
->pc
);
990 op_flags
|= XTENSA_OP_ILL
;
992 if (op_flags
& XTENSA_OP_ILL
) {
993 gen_exception_cause(dc
, ILLEGAL_INSTRUCTION_CAUSE
);
996 if (op_flags
& XTENSA_OP_DEBUG_BREAK
) {
997 debug_cause
|= ops
->par
[0];
999 if (ops
->test_overflow
) {
1000 windowed_register
|= ops
->test_overflow(dc
, arg
, ops
->par
);
1002 coprocessor
|= ops
->coprocessor
;
1005 slot_prop
[slot
].n_in
= 0;
1006 slot_prop
[slot
].n_out
= 0;
1007 slot_prop
[slot
].op_flags
= ops
->op_flags
& XTENSA_OP_LOAD_STORE
;
1009 opnds
= xtensa_opcode_num_operands(isa
, opc
);
1011 for (opnd
= vopnd
= 0; opnd
< opnds
; ++opnd
) {
1012 bool visible
= xtensa_operand_is_visible(isa
, opc
, opnd
);
1014 if (xtensa_operand_is_register(isa
, opc
, opnd
)) {
1015 xtensa_regfile rf
= xtensa_operand_regfile(isa
, opc
, opnd
);
1018 xtensa_operand_get_field(isa
, opc
, opnd
, fmt
, slot
,
1020 xtensa_operand_decode(isa
, opc
, opnd
, &v
);
1021 opcode_add_resource(slot_prop
+ slot
,
1022 encode_resource(RES_REGFILE
, rf
, v
),
1023 xtensa_operand_inout(isa
, opc
, opnd
),
1024 visible
? vopnd
: -1);
1031 opnds
= xtensa_opcode_num_stateOperands(isa
, opc
);
1033 for (opnd
= 0; opnd
< opnds
; ++opnd
) {
1034 xtensa_state state
= xtensa_stateOperand_state(isa
, opc
, opnd
);
1036 opcode_add_resource(slot_prop
+ slot
,
1037 encode_resource(RES_STATE
, 0, state
),
1038 xtensa_stateOperand_inout(isa
, opc
, opnd
),
1041 if (xtensa_opcode_is_branch(isa
, opc
) ||
1042 xtensa_opcode_is_jump(isa
, opc
) ||
1043 xtensa_opcode_is_loop(isa
, opc
) ||
1044 xtensa_opcode_is_call(isa
, opc
)) {
1045 slot_prop
[slot
].op_flags
|= XTENSA_OP_CONTROL_FLOW
;
1048 qsort(slot_prop
[slot
].in
, slot_prop
[slot
].n_in
,
1049 sizeof(slot_prop
[slot
].in
[0]), resource_compare
);
1050 qsort(slot_prop
[slot
].out
, slot_prop
[slot
].n_out
,
1051 sizeof(slot_prop
[slot
].out
[0]), resource_compare
);
1056 if (!tsort(slot_prop
, ordered
, slots
, arg_copy
, &n_arg_copy
)) {
1057 qemu_log_mask(LOG_UNIMP
,
1058 "Circular resource dependencies (pc = %08x)\n",
1060 gen_exception_cause(dc
, ILLEGAL_INSTRUCTION_CAUSE
);
1064 ordered
[0] = slot_prop
+ 0;
1067 if ((op_flags
& XTENSA_OP_PRIVILEGED
) &&
1068 !gen_check_privilege(dc
)) {
1072 if (op_flags
& XTENSA_OP_SYSCALL
) {
1073 gen_exception_cause(dc
, SYSCALL_CAUSE
);
1077 if ((op_flags
& XTENSA_OP_DEBUG_BREAK
) && dc
->debug
) {
1078 gen_debug_exception(dc
, debug_cause
);
1082 if (windowed_register
&& !gen_window_check(dc
, windowed_register
)) {
1086 if (op_flags
& XTENSA_OP_UNDERFLOW
) {
1087 TCGv_i32 tmp
= tcg_const_i32(dc
->pc
);
1089 gen_helper_test_underflow_retw(cpu_env
, tmp
);
1093 if (op_flags
& XTENSA_OP_ALLOCA
) {
1094 TCGv_i32 tmp
= tcg_const_i32(dc
->pc
);
1096 gen_helper_movsp(cpu_env
, tmp
);
1100 if (coprocessor
&& !gen_check_cpenable(dc
, coprocessor
)) {
1109 qsort(arg_copy
, n_arg_copy
, sizeof(*arg_copy
), arg_copy_compare
);
1110 for (i
= j
= 0; i
< n_arg_copy
; ++i
) {
1111 if (i
== 0 || arg_copy
[i
].resource
!= resource
) {
1112 resource
= arg_copy
[i
].resource
;
1113 if (arg_copy
[i
].arg
->num_bits
<= 32) {
1114 temp
= tcg_temp_local_new_i32();
1115 tcg_gen_mov_i32(temp
, arg_copy
[i
].arg
->in
);
1116 } else if (arg_copy
[i
].arg
->num_bits
<= 64) {
1117 temp
= tcg_temp_local_new_i64();
1118 tcg_gen_mov_i64(temp
, arg_copy
[i
].arg
->in
);
1120 g_assert_not_reached();
1122 arg_copy
[i
].temp
= temp
;
1125 arg_copy
[j
] = arg_copy
[i
];
1129 arg_copy
[i
].arg
->in
= temp
;
1134 if (op_flags
& XTENSA_OP_DIVIDE_BY_ZERO
) {
1135 for (slot
= 0; slot
< slots
; ++slot
) {
1136 if (slot_prop
[slot
].ops
->op_flags
& XTENSA_OP_DIVIDE_BY_ZERO
) {
1137 gen_zero_check(dc
, slot_prop
[slot
].arg
);
1142 dc
->op_flags
= op_flags
;
1144 for (slot
= 0; slot
< slots
; ++slot
) {
1145 struct slot_prop
*pslot
= ordered
[slot
];
1146 XtensaOpcodeOps
*ops
= pslot
->ops
;
1148 ops
->translate(dc
, pslot
->arg
, ops
->par
);
1151 for (i
= 0; i
< n_arg_copy
; ++i
) {
1152 if (arg_copy
[i
].arg
->num_bits
<= 32) {
1153 tcg_temp_free_i32(arg_copy
[i
].temp
);
1154 } else if (arg_copy
[i
].arg
->num_bits
<= 64) {
1155 tcg_temp_free_i64(arg_copy
[i
].temp
);
1157 g_assert_not_reached();
1161 if (dc
->base
.is_jmp
== DISAS_NEXT
) {
1162 gen_postprocess(dc
, 0);
1164 if (op_flags
& XTENSA_OP_EXIT_TB_M1
) {
1165 /* Change in mmu index, memory mapping or tb->flags; exit tb */
1166 gen_jumpi_check_loop_end(dc
, -1);
1167 } else if (op_flags
& XTENSA_OP_EXIT_TB_0
) {
1168 gen_jumpi_check_loop_end(dc
, 0);
1170 gen_check_loop_end(dc
, 0);
1173 dc
->pc
= dc
->base
.pc_next
;
1176 static inline unsigned xtensa_insn_len(CPUXtensaState
*env
, DisasContext
*dc
)
1178 uint8_t b0
= cpu_ldub_code(env
, dc
->pc
);
1179 return xtensa_op0_insn_len(dc
, b0
);
1182 static void gen_ibreak_check(CPUXtensaState
*env
, DisasContext
*dc
)
1186 for (i
= 0; i
< dc
->config
->nibreak
; ++i
) {
1187 if ((env
->sregs
[IBREAKENABLE
] & (1 << i
)) &&
1188 env
->sregs
[IBREAKA
+ i
] == dc
->pc
) {
1189 gen_debug_exception(dc
, DEBUGCAUSE_IB
);
1195 static void xtensa_tr_init_disas_context(DisasContextBase
*dcbase
,
1198 DisasContext
*dc
= container_of(dcbase
, DisasContext
, base
);
1199 CPUXtensaState
*env
= cpu
->env_ptr
;
1200 uint32_t tb_flags
= dc
->base
.tb
->flags
;
1202 dc
->config
= env
->config
;
1203 dc
->pc
= dc
->base
.pc_first
;
1204 dc
->ring
= tb_flags
& XTENSA_TBFLAG_RING_MASK
;
1205 dc
->cring
= (tb_flags
& XTENSA_TBFLAG_EXCM
) ? 0 : dc
->ring
;
1206 dc
->lbeg_off
= (dc
->base
.tb
->cs_base
& XTENSA_CSBASE_LBEG_OFF_MASK
) >>
1207 XTENSA_CSBASE_LBEG_OFF_SHIFT
;
1208 dc
->lend
= (dc
->base
.tb
->cs_base
& XTENSA_CSBASE_LEND_MASK
) +
1209 (dc
->base
.pc_first
& TARGET_PAGE_MASK
);
1210 dc
->debug
= tb_flags
& XTENSA_TBFLAG_DEBUG
;
1211 dc
->icount
= tb_flags
& XTENSA_TBFLAG_ICOUNT
;
1212 dc
->cpenable
= (tb_flags
& XTENSA_TBFLAG_CPENABLE_MASK
) >>
1213 XTENSA_TBFLAG_CPENABLE_SHIFT
;
1214 dc
->window
= ((tb_flags
& XTENSA_TBFLAG_WINDOW_MASK
) >>
1215 XTENSA_TBFLAG_WINDOW_SHIFT
);
1216 dc
->cwoe
= tb_flags
& XTENSA_TBFLAG_CWOE
;
1217 dc
->callinc
= ((tb_flags
& XTENSA_TBFLAG_CALLINC_MASK
) >>
1218 XTENSA_TBFLAG_CALLINC_SHIFT
);
1219 init_sar_tracker(dc
);
1222 static void xtensa_tr_tb_start(DisasContextBase
*dcbase
, CPUState
*cpu
)
1224 DisasContext
*dc
= container_of(dcbase
, DisasContext
, base
);
1227 dc
->next_icount
= tcg_temp_local_new_i32();
1231 static void xtensa_tr_insn_start(DisasContextBase
*dcbase
, CPUState
*cpu
)
1233 tcg_gen_insn_start(dcbase
->pc_next
);
1236 static void xtensa_tr_translate_insn(DisasContextBase
*dcbase
, CPUState
*cpu
)
1238 DisasContext
*dc
= container_of(dcbase
, DisasContext
, base
);
1239 CPUXtensaState
*env
= cpu
->env_ptr
;
1240 target_ulong page_start
;
1242 /* These two conditions only apply to the first insn in the TB,
1243 but this is the first TranslateOps hook that allows exiting. */
1244 if ((tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
)
1245 && (dc
->base
.tb
->flags
& XTENSA_TBFLAG_YIELD
)) {
1246 gen_exception(dc
, EXCP_YIELD
);
1247 dc
->base
.pc_next
= dc
->pc
+ 1;
1248 dc
->base
.is_jmp
= DISAS_NORETURN
;
1253 TCGLabel
*label
= gen_new_label();
1255 tcg_gen_addi_i32(dc
->next_icount
, cpu_SR
[ICOUNT
], 1);
1256 tcg_gen_brcondi_i32(TCG_COND_NE
, dc
->next_icount
, 0, label
);
1257 tcg_gen_mov_i32(dc
->next_icount
, cpu_SR
[ICOUNT
]);
1259 gen_debug_exception(dc
, DEBUGCAUSE_IC
);
1261 gen_set_label(label
);
1265 gen_ibreak_check(env
, dc
);
1268 disas_xtensa_insn(env
, dc
);
1271 tcg_gen_mov_i32(cpu_SR
[ICOUNT
], dc
->next_icount
);
1274 /* End the TB if the next insn will cross into the next page. */
1275 page_start
= dc
->base
.pc_first
& TARGET_PAGE_MASK
;
1276 if (dc
->base
.is_jmp
== DISAS_NEXT
&&
1277 (dc
->pc
- page_start
>= TARGET_PAGE_SIZE
||
1278 dc
->pc
- page_start
+ xtensa_insn_len(env
, dc
) > TARGET_PAGE_SIZE
)) {
1279 dc
->base
.is_jmp
= DISAS_TOO_MANY
;
1283 static void xtensa_tr_tb_stop(DisasContextBase
*dcbase
, CPUState
*cpu
)
1285 DisasContext
*dc
= container_of(dcbase
, DisasContext
, base
);
1287 reset_sar_tracker(dc
);
1289 tcg_temp_free(dc
->next_icount
);
1292 switch (dc
->base
.is_jmp
) {
1293 case DISAS_NORETURN
:
1295 case DISAS_TOO_MANY
:
1296 if (dc
->base
.singlestep_enabled
) {
1297 tcg_gen_movi_i32(cpu_pc
, dc
->pc
);
1298 gen_exception(dc
, EXCP_DEBUG
);
1300 gen_jumpi(dc
, dc
->pc
, 0);
1304 g_assert_not_reached();
1308 static void xtensa_tr_disas_log(const DisasContextBase
*dcbase
, CPUState
*cpu
)
1310 qemu_log("IN: %s\n", lookup_symbol(dcbase
->pc_first
));
1311 log_target_disas(cpu
, dcbase
->pc_first
, dcbase
->tb
->size
);
1314 static const TranslatorOps xtensa_translator_ops
= {
1315 .init_disas_context
= xtensa_tr_init_disas_context
,
1316 .tb_start
= xtensa_tr_tb_start
,
1317 .insn_start
= xtensa_tr_insn_start
,
1318 .translate_insn
= xtensa_tr_translate_insn
,
1319 .tb_stop
= xtensa_tr_tb_stop
,
1320 .disas_log
= xtensa_tr_disas_log
,
1323 void gen_intermediate_code(CPUState
*cpu
, TranslationBlock
*tb
, int max_insns
)
1325 DisasContext dc
= {};
1326 translator_loop(&xtensa_translator_ops
, &dc
.base
, cpu
, tb
, max_insns
);
1329 void xtensa_cpu_dump_state(CPUState
*cs
, FILE *f
, int flags
)
1331 XtensaCPU
*cpu
= XTENSA_CPU(cs
);
1332 CPUXtensaState
*env
= &cpu
->env
;
1333 xtensa_isa isa
= env
->config
->isa
;
1336 qemu_fprintf(f
, "PC=%08x\n\n", env
->pc
);
1338 for (i
= j
= 0; i
< xtensa_isa_num_sysregs(isa
); ++i
) {
1339 const uint32_t *reg
=
1340 xtensa_sysreg_is_user(isa
, i
) ? env
->uregs
: env
->sregs
;
1341 int regno
= xtensa_sysreg_number(isa
, i
);
1344 qemu_fprintf(f
, "%12s=%08x%c",
1345 xtensa_sysreg_name(isa
, i
),
1347 (j
++ % 4) == 3 ? '\n' : ' ');
1351 qemu_fprintf(f
, (j
% 4) == 0 ? "\n" : "\n\n");
1353 for (i
= 0; i
< 16; ++i
) {
1354 qemu_fprintf(f
, " A%02d=%08x%c",
1355 i
, env
->regs
[i
], (i
% 4) == 3 ? '\n' : ' ');
1358 xtensa_sync_phys_from_window(env
);
1359 qemu_fprintf(f
, "\n");
1361 for (i
= 0; i
< env
->config
->nareg
; ++i
) {
1362 qemu_fprintf(f
, "AR%02d=%08x ", i
, env
->phys_regs
[i
]);
1364 bool ws
= (env
->sregs
[WINDOW_START
] & (1 << (i
/ 4))) != 0;
1365 bool cw
= env
->sregs
[WINDOW_BASE
] == i
/ 4;
1367 qemu_fprintf(f
, "%c%c\n", ws
? '<' : ' ', cw
? '=' : ' ');
1371 if ((flags
& CPU_DUMP_FPU
) &&
1372 xtensa_option_enabled(env
->config
, XTENSA_OPTION_FP_COPROCESSOR
)) {
1373 qemu_fprintf(f
, "\n");
1375 for (i
= 0; i
< 16; ++i
) {
1376 qemu_fprintf(f
, "F%02d=%08x (%-+15.8e)%c", i
,
1377 float32_val(env
->fregs
[i
].f32
[FP_F32_LOW
]),
1378 *(float *)(env
->fregs
[i
].f32
+ FP_F32_LOW
),
1379 (i
% 2) == 1 ? '\n' : ' ');
1383 if ((flags
& CPU_DUMP_FPU
) &&
1384 xtensa_option_enabled(env
->config
, XTENSA_OPTION_DFP_COPROCESSOR
) &&
1385 !xtensa_option_enabled(env
->config
, XTENSA_OPTION_DFPU_SINGLE_ONLY
)) {
1386 qemu_fprintf(f
, "\n");
1388 for (i
= 0; i
< 16; ++i
) {
1389 qemu_fprintf(f
, "F%02d=%016"PRIx64
" (%-+24.16le)%c", i
,
1390 float64_val(env
->fregs
[i
].f64
),
1391 *(double *)(&env
->fregs
[i
].f64
),
1392 (i
% 2) == 1 ? '\n' : ' ');
1397 void restore_state_to_opc(CPUXtensaState
*env
, TranslationBlock
*tb
,
1403 static void translate_abs(DisasContext
*dc
, const OpcodeArg arg
[],
1404 const uint32_t par
[])
1406 tcg_gen_abs_i32(arg
[0].out
, arg
[1].in
);
1409 static void translate_add(DisasContext
*dc
, const OpcodeArg arg
[],
1410 const uint32_t par
[])
1412 tcg_gen_add_i32(arg
[0].out
, arg
[1].in
, arg
[2].in
);
1415 static void translate_addi(DisasContext
*dc
, const OpcodeArg arg
[],
1416 const uint32_t par
[])
1418 tcg_gen_addi_i32(arg
[0].out
, arg
[1].in
, arg
[2].imm
);
1421 static void translate_addx(DisasContext
*dc
, const OpcodeArg arg
[],
1422 const uint32_t par
[])
1424 TCGv_i32 tmp
= tcg_temp_new_i32();
1425 tcg_gen_shli_i32(tmp
, arg
[1].in
, par
[0]);
1426 tcg_gen_add_i32(arg
[0].out
, tmp
, arg
[2].in
);
1430 static void translate_all(DisasContext
*dc
, const OpcodeArg arg
[],
1431 const uint32_t par
[])
1433 uint32_t shift
= par
[1];
1434 TCGv_i32 mask
= tcg_const_i32(((1 << shift
) - 1) << arg
[1].imm
);
1435 TCGv_i32 tmp
= tcg_temp_new_i32();
1437 tcg_gen_and_i32(tmp
, arg
[1].in
, mask
);
1439 tcg_gen_addi_i32(tmp
, tmp
, 1 << arg
[1].imm
);
1441 tcg_gen_add_i32(tmp
, tmp
, mask
);
1443 tcg_gen_shri_i32(tmp
, tmp
, arg
[1].imm
+ shift
);
1444 tcg_gen_deposit_i32(arg
[0].out
, arg
[0].out
,
1445 tmp
, arg
[0].imm
, 1);
1446 tcg_temp_free(mask
);
1450 static void translate_and(DisasContext
*dc
, const OpcodeArg arg
[],
1451 const uint32_t par
[])
1453 tcg_gen_and_i32(arg
[0].out
, arg
[1].in
, arg
[2].in
);
1456 static void translate_ball(DisasContext
*dc
, const OpcodeArg arg
[],
1457 const uint32_t par
[])
1459 TCGv_i32 tmp
= tcg_temp_new_i32();
1460 tcg_gen_and_i32(tmp
, arg
[0].in
, arg
[1].in
);
1461 gen_brcond(dc
, par
[0], tmp
, arg
[1].in
, arg
[2].imm
);
1465 static void translate_bany(DisasContext
*dc
, const OpcodeArg arg
[],
1466 const uint32_t par
[])
1468 TCGv_i32 tmp
= tcg_temp_new_i32();
1469 tcg_gen_and_i32(tmp
, arg
[0].in
, arg
[1].in
);
1470 gen_brcondi(dc
, par
[0], tmp
, 0, arg
[2].imm
);
1474 static void translate_b(DisasContext
*dc
, const OpcodeArg arg
[],
1475 const uint32_t par
[])
1477 gen_brcond(dc
, par
[0], arg
[0].in
, arg
[1].in
, arg
[2].imm
);
1480 static void translate_bb(DisasContext
*dc
, const OpcodeArg arg
[],
1481 const uint32_t par
[])
1483 #ifdef TARGET_WORDS_BIGENDIAN
1484 TCGv_i32 bit
= tcg_const_i32(0x80000000u
);
1486 TCGv_i32 bit
= tcg_const_i32(0x00000001u
);
1488 TCGv_i32 tmp
= tcg_temp_new_i32();
1489 tcg_gen_andi_i32(tmp
, arg
[1].in
, 0x1f);
1490 #ifdef TARGET_WORDS_BIGENDIAN
1491 tcg_gen_shr_i32(bit
, bit
, tmp
);
1493 tcg_gen_shl_i32(bit
, bit
, tmp
);
1495 tcg_gen_and_i32(tmp
, arg
[0].in
, bit
);
1496 gen_brcondi(dc
, par
[0], tmp
, 0, arg
[2].imm
);
1501 static void translate_bbi(DisasContext
*dc
, const OpcodeArg arg
[],
1502 const uint32_t par
[])
1504 TCGv_i32 tmp
= tcg_temp_new_i32();
1505 #ifdef TARGET_WORDS_BIGENDIAN
1506 tcg_gen_andi_i32(tmp
, arg
[0].in
, 0x80000000u
>> arg
[1].imm
);
1508 tcg_gen_andi_i32(tmp
, arg
[0].in
, 0x00000001u
<< arg
[1].imm
);
1510 gen_brcondi(dc
, par
[0], tmp
, 0, arg
[2].imm
);
1514 static void translate_bi(DisasContext
*dc
, const OpcodeArg arg
[],
1515 const uint32_t par
[])
1517 gen_brcondi(dc
, par
[0], arg
[0].in
, arg
[1].imm
, arg
[2].imm
);
1520 static void translate_bz(DisasContext
*dc
, const OpcodeArg arg
[],
1521 const uint32_t par
[])
1523 gen_brcondi(dc
, par
[0], arg
[0].in
, 0, arg
[1].imm
);
1534 static void translate_boolean(DisasContext
*dc
, const OpcodeArg arg
[],
1535 const uint32_t par
[])
1537 static void (* const op
[])(TCGv_i32
, TCGv_i32
, TCGv_i32
) = {
1538 [BOOLEAN_AND
] = tcg_gen_and_i32
,
1539 [BOOLEAN_ANDC
] = tcg_gen_andc_i32
,
1540 [BOOLEAN_OR
] = tcg_gen_or_i32
,
1541 [BOOLEAN_ORC
] = tcg_gen_orc_i32
,
1542 [BOOLEAN_XOR
] = tcg_gen_xor_i32
,
1545 TCGv_i32 tmp1
= tcg_temp_new_i32();
1546 TCGv_i32 tmp2
= tcg_temp_new_i32();
1548 tcg_gen_shri_i32(tmp1
, arg
[1].in
, arg
[1].imm
);
1549 tcg_gen_shri_i32(tmp2
, arg
[2].in
, arg
[2].imm
);
1550 op
[par
[0]](tmp1
, tmp1
, tmp2
);
1551 tcg_gen_deposit_i32(arg
[0].out
, arg
[0].out
, tmp1
, arg
[0].imm
, 1);
1552 tcg_temp_free(tmp1
);
1553 tcg_temp_free(tmp2
);
1556 static void translate_bp(DisasContext
*dc
, const OpcodeArg arg
[],
1557 const uint32_t par
[])
1559 TCGv_i32 tmp
= tcg_temp_new_i32();
1561 tcg_gen_andi_i32(tmp
, arg
[0].in
, 1 << arg
[0].imm
);
1562 gen_brcondi(dc
, par
[0], tmp
, 0, arg
[1].imm
);
1566 static void translate_call0(DisasContext
*dc
, const OpcodeArg arg
[],
1567 const uint32_t par
[])
1569 tcg_gen_movi_i32(cpu_R
[0], dc
->base
.pc_next
);
1570 gen_jumpi(dc
, arg
[0].imm
, 0);
1573 static void translate_callw(DisasContext
*dc
, const OpcodeArg arg
[],
1574 const uint32_t par
[])
1576 TCGv_i32 tmp
= tcg_const_i32(arg
[0].imm
);
1577 gen_callw_slot(dc
, par
[0], tmp
, adjust_jump_slot(dc
, arg
[0].imm
, 0));
1581 static void translate_callx0(DisasContext
*dc
, const OpcodeArg arg
[],
1582 const uint32_t par
[])
1584 TCGv_i32 tmp
= tcg_temp_new_i32();
1585 tcg_gen_mov_i32(tmp
, arg
[0].in
);
1586 tcg_gen_movi_i32(cpu_R
[0], dc
->base
.pc_next
);
1591 static void translate_callxw(DisasContext
*dc
, const OpcodeArg arg
[],
1592 const uint32_t par
[])
1594 TCGv_i32 tmp
= tcg_temp_new_i32();
1596 tcg_gen_mov_i32(tmp
, arg
[0].in
);
1597 gen_callw_slot(dc
, par
[0], tmp
, -1);
1601 static void translate_clamps(DisasContext
*dc
, const OpcodeArg arg
[],
1602 const uint32_t par
[])
1604 TCGv_i32 tmp1
= tcg_const_i32(-1u << arg
[2].imm
);
1605 TCGv_i32 tmp2
= tcg_const_i32((1 << arg
[2].imm
) - 1);
1607 tcg_gen_smax_i32(tmp1
, tmp1
, arg
[1].in
);
1608 tcg_gen_smin_i32(arg
[0].out
, tmp1
, tmp2
);
1609 tcg_temp_free(tmp1
);
1610 tcg_temp_free(tmp2
);
1613 static void translate_clrb_expstate(DisasContext
*dc
, const OpcodeArg arg
[],
1614 const uint32_t par
[])
1616 /* TODO: GPIO32 may be a part of coprocessor */
1617 tcg_gen_andi_i32(cpu_UR
[EXPSTATE
], cpu_UR
[EXPSTATE
], ~(1u << arg
[0].imm
));
1620 static void translate_clrex(DisasContext
*dc
, const OpcodeArg arg
[],
1621 const uint32_t par
[])
1623 tcg_gen_movi_i32(cpu_exclusive_addr
, -1);
1626 static void translate_const16(DisasContext
*dc
, const OpcodeArg arg
[],
1627 const uint32_t par
[])
1629 TCGv_i32 c
= tcg_const_i32(arg
[1].imm
);
1631 tcg_gen_deposit_i32(arg
[0].out
, c
, arg
[0].in
, 16, 16);
1635 static void translate_dcache(DisasContext
*dc
, const OpcodeArg arg
[],
1636 const uint32_t par
[])
1638 TCGv_i32 addr
= tcg_temp_new_i32();
1639 TCGv_i32 res
= tcg_temp_new_i32();
1641 tcg_gen_addi_i32(addr
, arg
[0].in
, arg
[1].imm
);
1642 tcg_gen_qemu_ld8u(res
, addr
, dc
->cring
);
1643 tcg_temp_free(addr
);
1647 static void translate_depbits(DisasContext
*dc
, const OpcodeArg arg
[],
1648 const uint32_t par
[])
1650 tcg_gen_deposit_i32(arg
[1].out
, arg
[1].in
, arg
[0].in
,
1651 arg
[2].imm
, arg
[3].imm
);
1654 static void translate_diwbuip(DisasContext
*dc
, const OpcodeArg arg
[],
1655 const uint32_t par
[])
1657 tcg_gen_addi_i32(arg
[0].out
, arg
[0].in
, dc
->config
->dcache_line_bytes
);
1660 static uint32_t test_exceptions_entry(DisasContext
*dc
, const OpcodeArg arg
[],
1661 const uint32_t par
[])
1663 if (arg
[0].imm
> 3 || !dc
->cwoe
) {
1664 qemu_log_mask(LOG_GUEST_ERROR
,
1665 "Illegal entry instruction(pc = %08x)\n", dc
->pc
);
1666 return XTENSA_OP_ILL
;
1672 static uint32_t test_overflow_entry(DisasContext
*dc
, const OpcodeArg arg
[],
1673 const uint32_t par
[])
1675 return 1 << (dc
->callinc
* 4);
1678 static void translate_entry(DisasContext
*dc
, const OpcodeArg arg
[],
1679 const uint32_t par
[])
1681 TCGv_i32 pc
= tcg_const_i32(dc
->pc
);
1682 TCGv_i32 s
= tcg_const_i32(arg
[0].imm
);
1683 TCGv_i32 imm
= tcg_const_i32(arg
[1].imm
);
1684 gen_helper_entry(cpu_env
, pc
, s
, imm
);
1690 static void translate_extui(DisasContext
*dc
, const OpcodeArg arg
[],
1691 const uint32_t par
[])
1693 int maskimm
= (1 << arg
[3].imm
) - 1;
1695 TCGv_i32 tmp
= tcg_temp_new_i32();
1696 tcg_gen_shri_i32(tmp
, arg
[1].in
, arg
[2].imm
);
1697 tcg_gen_andi_i32(arg
[0].out
, tmp
, maskimm
);
1701 static void translate_getex(DisasContext
*dc
, const OpcodeArg arg
[],
1702 const uint32_t par
[])
1704 TCGv_i32 tmp
= tcg_temp_new_i32();
1706 tcg_gen_extract_i32(tmp
, cpu_SR
[ATOMCTL
], 8, 1);
1707 tcg_gen_deposit_i32(cpu_SR
[ATOMCTL
], cpu_SR
[ATOMCTL
], arg
[0].in
, 8, 1);
1708 tcg_gen_mov_i32(arg
[0].out
, tmp
);
1712 static void translate_icache(DisasContext
*dc
, const OpcodeArg arg
[],
1713 const uint32_t par
[])
1715 #ifndef CONFIG_USER_ONLY
1716 TCGv_i32 addr
= tcg_temp_new_i32();
1718 tcg_gen_movi_i32(cpu_pc
, dc
->pc
);
1719 tcg_gen_addi_i32(addr
, arg
[0].in
, arg
[1].imm
);
1720 gen_helper_itlb_hit_test(cpu_env
, addr
);
1721 tcg_temp_free(addr
);
1725 static void translate_itlb(DisasContext
*dc
, const OpcodeArg arg
[],
1726 const uint32_t par
[])
1728 #ifndef CONFIG_USER_ONLY
1729 TCGv_i32 dtlb
= tcg_const_i32(par
[0]);
1731 gen_helper_itlb(cpu_env
, arg
[0].in
, dtlb
);
1732 tcg_temp_free(dtlb
);
1736 static void translate_j(DisasContext
*dc
, const OpcodeArg arg
[],
1737 const uint32_t par
[])
1739 gen_jumpi(dc
, arg
[0].imm
, 0);
1742 static void translate_jx(DisasContext
*dc
, const OpcodeArg arg
[],
1743 const uint32_t par
[])
1745 gen_jump(dc
, arg
[0].in
);
1748 static void translate_l32e(DisasContext
*dc
, const OpcodeArg arg
[],
1749 const uint32_t par
[])
1751 TCGv_i32 addr
= tcg_temp_new_i32();
1754 tcg_gen_addi_i32(addr
, arg
[1].in
, arg
[2].imm
);
1755 mop
= gen_load_store_alignment(dc
, MO_TEUL
, addr
);
1756 tcg_gen_qemu_ld_tl(arg
[0].out
, addr
, dc
->ring
, mop
);
1757 tcg_temp_free(addr
);
1760 #ifdef CONFIG_USER_ONLY
1761 static void gen_check_exclusive(DisasContext
*dc
, TCGv_i32 addr
, bool is_write
)
1765 static void gen_check_exclusive(DisasContext
*dc
, TCGv_i32 addr
, bool is_write
)
1767 if (!option_enabled(dc
, XTENSA_OPTION_MPU
)) {
1768 TCGv_i32 tpc
= tcg_const_i32(dc
->pc
);
1769 TCGv_i32 write
= tcg_const_i32(is_write
);
1771 gen_helper_check_exclusive(cpu_env
, tpc
, addr
, write
);
1773 tcg_temp_free(write
);
1778 static void translate_l32ex(DisasContext
*dc
, const OpcodeArg arg
[],
1779 const uint32_t par
[])
1781 TCGv_i32 addr
= tcg_temp_new_i32();
1784 tcg_gen_mov_i32(addr
, arg
[1].in
);
1785 mop
= gen_load_store_alignment(dc
, MO_TEUL
| MO_ALIGN
, addr
);
1786 gen_check_exclusive(dc
, addr
, false);
1787 tcg_gen_qemu_ld_i32(arg
[0].out
, addr
, dc
->cring
, mop
);
1788 tcg_gen_mov_i32(cpu_exclusive_addr
, addr
);
1789 tcg_gen_mov_i32(cpu_exclusive_val
, arg
[0].out
);
1790 tcg_temp_free(addr
);
1793 static void translate_ldst(DisasContext
*dc
, const OpcodeArg arg
[],
1794 const uint32_t par
[])
1796 TCGv_i32 addr
= tcg_temp_new_i32();
1799 tcg_gen_addi_i32(addr
, arg
[1].in
, arg
[2].imm
);
1800 mop
= gen_load_store_alignment(dc
, par
[0], addr
);
1804 tcg_gen_mb(TCG_BAR_STRL
| TCG_MO_ALL
);
1806 tcg_gen_qemu_st_tl(arg
[0].in
, addr
, dc
->cring
, mop
);
1808 tcg_gen_qemu_ld_tl(arg
[0].out
, addr
, dc
->cring
, mop
);
1810 tcg_gen_mb(TCG_BAR_LDAQ
| TCG_MO_ALL
);
1813 tcg_temp_free(addr
);
1816 static void translate_l32r(DisasContext
*dc
, const OpcodeArg arg
[],
1817 const uint32_t par
[])
1821 if (dc
->base
.tb
->flags
& XTENSA_TBFLAG_LITBASE
) {
1822 tmp
= tcg_const_i32(arg
[1].raw_imm
- 1);
1823 tcg_gen_add_i32(tmp
, cpu_SR
[LITBASE
], tmp
);
1825 tmp
= tcg_const_i32(arg
[1].imm
);
1827 tcg_gen_qemu_ld32u(arg
[0].out
, tmp
, dc
->cring
);
1831 static void translate_loop(DisasContext
*dc
, const OpcodeArg arg
[],
1832 const uint32_t par
[])
1834 uint32_t lend
= arg
[1].imm
;
1836 tcg_gen_subi_i32(cpu_SR
[LCOUNT
], arg
[0].in
, 1);
1837 tcg_gen_movi_i32(cpu_SR
[LBEG
], dc
->base
.pc_next
);
1838 tcg_gen_movi_i32(cpu_SR
[LEND
], lend
);
1840 if (par
[0] != TCG_COND_NEVER
) {
1841 TCGLabel
*label
= gen_new_label();
1842 tcg_gen_brcondi_i32(par
[0], arg
[0].in
, 0, label
);
1843 gen_jumpi(dc
, lend
, 1);
1844 gen_set_label(label
);
1847 gen_jumpi(dc
, dc
->base
.pc_next
, 0);
1868 static void translate_mac16(DisasContext
*dc
, const OpcodeArg arg
[],
1869 const uint32_t par
[])
1872 unsigned half
= par
[1];
1873 uint32_t ld_offset
= par
[2];
1874 unsigned off
= ld_offset
? 2 : 0;
1875 TCGv_i32 vaddr
= tcg_temp_new_i32();
1876 TCGv_i32 mem32
= tcg_temp_new_i32();
1881 tcg_gen_addi_i32(vaddr
, arg
[1].in
, ld_offset
);
1882 mop
= gen_load_store_alignment(dc
, MO_TEUL
, vaddr
);
1883 tcg_gen_qemu_ld_tl(mem32
, vaddr
, dc
->cring
, mop
);
1885 if (op
!= MAC16_NONE
) {
1886 TCGv_i32 m1
= gen_mac16_m(arg
[off
].in
,
1887 half
& MAC16_HX
, op
== MAC16_UMUL
);
1888 TCGv_i32 m2
= gen_mac16_m(arg
[off
+ 1].in
,
1889 half
& MAC16_XH
, op
== MAC16_UMUL
);
1891 if (op
== MAC16_MUL
|| op
== MAC16_UMUL
) {
1892 tcg_gen_mul_i32(cpu_SR
[ACCLO
], m1
, m2
);
1893 if (op
== MAC16_UMUL
) {
1894 tcg_gen_movi_i32(cpu_SR
[ACCHI
], 0);
1896 tcg_gen_sari_i32(cpu_SR
[ACCHI
], cpu_SR
[ACCLO
], 31);
1899 TCGv_i32 lo
= tcg_temp_new_i32();
1900 TCGv_i32 hi
= tcg_temp_new_i32();
1902 tcg_gen_mul_i32(lo
, m1
, m2
);
1903 tcg_gen_sari_i32(hi
, lo
, 31);
1904 if (op
== MAC16_MULA
) {
1905 tcg_gen_add2_i32(cpu_SR
[ACCLO
], cpu_SR
[ACCHI
],
1906 cpu_SR
[ACCLO
], cpu_SR
[ACCHI
],
1909 tcg_gen_sub2_i32(cpu_SR
[ACCLO
], cpu_SR
[ACCHI
],
1910 cpu_SR
[ACCLO
], cpu_SR
[ACCHI
],
1913 tcg_gen_ext8s_i32(cpu_SR
[ACCHI
], cpu_SR
[ACCHI
]);
1915 tcg_temp_free_i32(lo
);
1916 tcg_temp_free_i32(hi
);
1922 tcg_gen_mov_i32(arg
[1].out
, vaddr
);
1923 tcg_gen_mov_i32(cpu_SR
[MR
+ arg
[0].imm
], mem32
);
1925 tcg_temp_free(vaddr
);
1926 tcg_temp_free(mem32
);
1929 static void translate_memw(DisasContext
*dc
, const OpcodeArg arg
[],
1930 const uint32_t par
[])
1932 tcg_gen_mb(TCG_BAR_SC
| TCG_MO_ALL
);
1935 static void translate_smin(DisasContext
*dc
, const OpcodeArg arg
[],
1936 const uint32_t par
[])
1938 tcg_gen_smin_i32(arg
[0].out
, arg
[1].in
, arg
[2].in
);
1941 static void translate_umin(DisasContext
*dc
, const OpcodeArg arg
[],
1942 const uint32_t par
[])
1944 tcg_gen_umin_i32(arg
[0].out
, arg
[1].in
, arg
[2].in
);
1947 static void translate_smax(DisasContext
*dc
, const OpcodeArg arg
[],
1948 const uint32_t par
[])
1950 tcg_gen_smax_i32(arg
[0].out
, arg
[1].in
, arg
[2].in
);
1953 static void translate_umax(DisasContext
*dc
, const OpcodeArg arg
[],
1954 const uint32_t par
[])
1956 tcg_gen_umax_i32(arg
[0].out
, arg
[1].in
, arg
[2].in
);
1959 static void translate_mov(DisasContext
*dc
, const OpcodeArg arg
[],
1960 const uint32_t par
[])
1962 tcg_gen_mov_i32(arg
[0].out
, arg
[1].in
);
1965 static void translate_movcond(DisasContext
*dc
, const OpcodeArg arg
[],
1966 const uint32_t par
[])
1968 TCGv_i32 zero
= tcg_const_i32(0);
1970 tcg_gen_movcond_i32(par
[0], arg
[0].out
,
1971 arg
[2].in
, zero
, arg
[1].in
, arg
[0].in
);
1972 tcg_temp_free(zero
);
1975 static void translate_movi(DisasContext
*dc
, const OpcodeArg arg
[],
1976 const uint32_t par
[])
1978 tcg_gen_movi_i32(arg
[0].out
, arg
[1].imm
);
1981 static void translate_movp(DisasContext
*dc
, const OpcodeArg arg
[],
1982 const uint32_t par
[])
1984 TCGv_i32 zero
= tcg_const_i32(0);
1985 TCGv_i32 tmp
= tcg_temp_new_i32();
1987 tcg_gen_andi_i32(tmp
, arg
[2].in
, 1 << arg
[2].imm
);
1988 tcg_gen_movcond_i32(par
[0],
1989 arg
[0].out
, tmp
, zero
,
1990 arg
[1].in
, arg
[0].in
);
1992 tcg_temp_free(zero
);
1995 static void translate_movsp(DisasContext
*dc
, const OpcodeArg arg
[],
1996 const uint32_t par
[])
1998 tcg_gen_mov_i32(arg
[0].out
, arg
[1].in
);
2001 static void translate_mul16(DisasContext
*dc
, const OpcodeArg arg
[],
2002 const uint32_t par
[])
2004 TCGv_i32 v1
= tcg_temp_new_i32();
2005 TCGv_i32 v2
= tcg_temp_new_i32();
2008 tcg_gen_ext16s_i32(v1
, arg
[1].in
);
2009 tcg_gen_ext16s_i32(v2
, arg
[2].in
);
2011 tcg_gen_ext16u_i32(v1
, arg
[1].in
);
2012 tcg_gen_ext16u_i32(v2
, arg
[2].in
);
2014 tcg_gen_mul_i32(arg
[0].out
, v1
, v2
);
2019 static void translate_mull(DisasContext
*dc
, const OpcodeArg arg
[],
2020 const uint32_t par
[])
2022 tcg_gen_mul_i32(arg
[0].out
, arg
[1].in
, arg
[2].in
);
2025 static void translate_mulh(DisasContext
*dc
, const OpcodeArg arg
[],
2026 const uint32_t par
[])
2028 TCGv_i32 lo
= tcg_temp_new();
2031 tcg_gen_muls2_i32(lo
, arg
[0].out
, arg
[1].in
, arg
[2].in
);
2033 tcg_gen_mulu2_i32(lo
, arg
[0].out
, arg
[1].in
, arg
[2].in
);
2038 static void translate_neg(DisasContext
*dc
, const OpcodeArg arg
[],
2039 const uint32_t par
[])
2041 tcg_gen_neg_i32(arg
[0].out
, arg
[1].in
);
2044 static void translate_nop(DisasContext
*dc
, const OpcodeArg arg
[],
2045 const uint32_t par
[])
2049 static void translate_nsa(DisasContext
*dc
, const OpcodeArg arg
[],
2050 const uint32_t par
[])
2052 tcg_gen_clrsb_i32(arg
[0].out
, arg
[1].in
);
2055 static void translate_nsau(DisasContext
*dc
, const OpcodeArg arg
[],
2056 const uint32_t par
[])
2058 tcg_gen_clzi_i32(arg
[0].out
, arg
[1].in
, 32);
2061 static void translate_or(DisasContext
*dc
, const OpcodeArg arg
[],
2062 const uint32_t par
[])
2064 tcg_gen_or_i32(arg
[0].out
, arg
[1].in
, arg
[2].in
);
2067 static void translate_ptlb(DisasContext
*dc
, const OpcodeArg arg
[],
2068 const uint32_t par
[])
2070 #ifndef CONFIG_USER_ONLY
2071 TCGv_i32 dtlb
= tcg_const_i32(par
[0]);
2073 tcg_gen_movi_i32(cpu_pc
, dc
->pc
);
2074 gen_helper_ptlb(arg
[0].out
, cpu_env
, arg
[1].in
, dtlb
);
2075 tcg_temp_free(dtlb
);
2079 static void translate_pptlb(DisasContext
*dc
, const OpcodeArg arg
[],
2080 const uint32_t par
[])
2082 #ifndef CONFIG_USER_ONLY
2083 tcg_gen_movi_i32(cpu_pc
, dc
->pc
);
2084 gen_helper_pptlb(arg
[0].out
, cpu_env
, arg
[1].in
);
2088 static void translate_quos(DisasContext
*dc
, const OpcodeArg arg
[],
2089 const uint32_t par
[])
2091 TCGLabel
*label1
= gen_new_label();
2092 TCGLabel
*label2
= gen_new_label();
2094 tcg_gen_brcondi_i32(TCG_COND_NE
, arg
[1].in
, 0x80000000,
2096 tcg_gen_brcondi_i32(TCG_COND_NE
, arg
[2].in
, 0xffffffff,
2098 tcg_gen_movi_i32(arg
[0].out
,
2099 par
[0] ? 0x80000000 : 0);
2101 gen_set_label(label1
);
2103 tcg_gen_div_i32(arg
[0].out
,
2104 arg
[1].in
, arg
[2].in
);
2106 tcg_gen_rem_i32(arg
[0].out
,
2107 arg
[1].in
, arg
[2].in
);
2109 gen_set_label(label2
);
2112 static void translate_quou(DisasContext
*dc
, const OpcodeArg arg
[],
2113 const uint32_t par
[])
2115 tcg_gen_divu_i32(arg
[0].out
,
2116 arg
[1].in
, arg
[2].in
);
2119 static void translate_read_impwire(DisasContext
*dc
, const OpcodeArg arg
[],
2120 const uint32_t par
[])
2122 /* TODO: GPIO32 may be a part of coprocessor */
2123 tcg_gen_movi_i32(arg
[0].out
, 0);
2126 static void translate_remu(DisasContext
*dc
, const OpcodeArg arg
[],
2127 const uint32_t par
[])
2129 tcg_gen_remu_i32(arg
[0].out
,
2130 arg
[1].in
, arg
[2].in
);
2133 static void translate_rer(DisasContext
*dc
, const OpcodeArg arg
[],
2134 const uint32_t par
[])
2136 gen_helper_rer(arg
[0].out
, cpu_env
, arg
[1].in
);
2139 static void translate_ret(DisasContext
*dc
, const OpcodeArg arg
[],
2140 const uint32_t par
[])
2142 gen_jump(dc
, cpu_R
[0]);
2145 static uint32_t test_exceptions_retw(DisasContext
*dc
, const OpcodeArg arg
[],
2146 const uint32_t par
[])
2149 qemu_log_mask(LOG_GUEST_ERROR
,
2150 "Illegal retw instruction(pc = %08x)\n", dc
->pc
);
2151 return XTENSA_OP_ILL
;
2153 TCGv_i32 tmp
= tcg_const_i32(dc
->pc
);
2155 gen_helper_test_ill_retw(cpu_env
, tmp
);
2161 static void translate_retw(DisasContext
*dc
, const OpcodeArg arg
[],
2162 const uint32_t par
[])
2164 TCGv_i32 tmp
= tcg_const_i32(1);
2165 tcg_gen_shl_i32(tmp
, tmp
, cpu_SR
[WINDOW_BASE
]);
2166 tcg_gen_andc_i32(cpu_SR
[WINDOW_START
],
2167 cpu_SR
[WINDOW_START
], tmp
);
2168 tcg_gen_movi_i32(tmp
, dc
->pc
);
2169 tcg_gen_deposit_i32(tmp
, tmp
, cpu_R
[0], 0, 30);
2170 gen_helper_retw(cpu_env
, cpu_R
[0]);
2175 static void translate_rfde(DisasContext
*dc
, const OpcodeArg arg
[],
2176 const uint32_t par
[])
2178 gen_jump(dc
, cpu_SR
[dc
->config
->ndepc
? DEPC
: EPC1
]);
2181 static void translate_rfe(DisasContext
*dc
, const OpcodeArg arg
[],
2182 const uint32_t par
[])
2184 tcg_gen_andi_i32(cpu_SR
[PS
], cpu_SR
[PS
], ~PS_EXCM
);
2185 gen_jump(dc
, cpu_SR
[EPC1
]);
2188 static void translate_rfi(DisasContext
*dc
, const OpcodeArg arg
[],
2189 const uint32_t par
[])
2191 tcg_gen_mov_i32(cpu_SR
[PS
], cpu_SR
[EPS2
+ arg
[0].imm
- 2]);
2192 gen_jump(dc
, cpu_SR
[EPC1
+ arg
[0].imm
- 1]);
2195 static void translate_rfw(DisasContext
*dc
, const OpcodeArg arg
[],
2196 const uint32_t par
[])
2198 TCGv_i32 tmp
= tcg_const_i32(1);
2200 tcg_gen_andi_i32(cpu_SR
[PS
], cpu_SR
[PS
], ~PS_EXCM
);
2201 tcg_gen_shl_i32(tmp
, tmp
, cpu_SR
[WINDOW_BASE
]);
2204 tcg_gen_andc_i32(cpu_SR
[WINDOW_START
],
2205 cpu_SR
[WINDOW_START
], tmp
);
2207 tcg_gen_or_i32(cpu_SR
[WINDOW_START
],
2208 cpu_SR
[WINDOW_START
], tmp
);
2212 gen_helper_restore_owb(cpu_env
);
2213 gen_jump(dc
, cpu_SR
[EPC1
]);
2216 static void translate_rotw(DisasContext
*dc
, const OpcodeArg arg
[],
2217 const uint32_t par
[])
2219 tcg_gen_addi_i32(cpu_windowbase_next
, cpu_SR
[WINDOW_BASE
], arg
[0].imm
);
2222 static void translate_rsil(DisasContext
*dc
, const OpcodeArg arg
[],
2223 const uint32_t par
[])
2225 tcg_gen_mov_i32(arg
[0].out
, cpu_SR
[PS
]);
2226 tcg_gen_andi_i32(cpu_SR
[PS
], cpu_SR
[PS
], ~PS_INTLEVEL
);
2227 tcg_gen_ori_i32(cpu_SR
[PS
], cpu_SR
[PS
], arg
[1].imm
);
2230 static void translate_rsr(DisasContext
*dc
, const OpcodeArg arg
[],
2231 const uint32_t par
[])
2233 if (sr_name
[par
[0]]) {
2234 tcg_gen_mov_i32(arg
[0].out
, cpu_SR
[par
[0]]);
2236 tcg_gen_movi_i32(arg
[0].out
, 0);
2240 static void translate_rsr_ccount(DisasContext
*dc
, const OpcodeArg arg
[],
2241 const uint32_t par
[])
2243 #ifndef CONFIG_USER_ONLY
2244 if (tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
) {
2247 gen_helper_update_ccount(cpu_env
);
2248 tcg_gen_mov_i32(arg
[0].out
, cpu_SR
[par
[0]]);
2252 static void translate_rsr_ptevaddr(DisasContext
*dc
, const OpcodeArg arg
[],
2253 const uint32_t par
[])
2255 #ifndef CONFIG_USER_ONLY
2256 TCGv_i32 tmp
= tcg_temp_new_i32();
2258 tcg_gen_shri_i32(tmp
, cpu_SR
[EXCVADDR
], 10);
2259 tcg_gen_or_i32(tmp
, tmp
, cpu_SR
[PTEVADDR
]);
2260 tcg_gen_andi_i32(arg
[0].out
, tmp
, 0xfffffffc);
2265 static void translate_rtlb(DisasContext
*dc
, const OpcodeArg arg
[],
2266 const uint32_t par
[])
2268 #ifndef CONFIG_USER_ONLY
2269 static void (* const helper
[])(TCGv_i32 r
, TCGv_env env
, TCGv_i32 a1
,
2274 TCGv_i32 dtlb
= tcg_const_i32(par
[0]);
2276 helper
[par
[1]](arg
[0].out
, cpu_env
, arg
[1].in
, dtlb
);
2277 tcg_temp_free(dtlb
);
2281 static void translate_rptlb0(DisasContext
*dc
, const OpcodeArg arg
[],
2282 const uint32_t par
[])
2284 #ifndef CONFIG_USER_ONLY
2285 gen_helper_rptlb0(arg
[0].out
, cpu_env
, arg
[1].in
);
2289 static void translate_rptlb1(DisasContext
*dc
, const OpcodeArg arg
[],
2290 const uint32_t par
[])
2292 #ifndef CONFIG_USER_ONLY
2293 gen_helper_rptlb1(arg
[0].out
, cpu_env
, arg
[1].in
);
2297 static void translate_rur(DisasContext
*dc
, const OpcodeArg arg
[],
2298 const uint32_t par
[])
2300 tcg_gen_mov_i32(arg
[0].out
, cpu_UR
[par
[0]]);
2303 static void translate_setb_expstate(DisasContext
*dc
, const OpcodeArg arg
[],
2304 const uint32_t par
[])
2306 /* TODO: GPIO32 may be a part of coprocessor */
2307 tcg_gen_ori_i32(cpu_UR
[EXPSTATE
], cpu_UR
[EXPSTATE
], 1u << arg
[0].imm
);
2310 #ifdef CONFIG_USER_ONLY
2311 static void gen_check_atomctl(DisasContext
*dc
, TCGv_i32 addr
)
2315 static void gen_check_atomctl(DisasContext
*dc
, TCGv_i32 addr
)
2317 TCGv_i32 tpc
= tcg_const_i32(dc
->pc
);
2319 gen_helper_check_atomctl(cpu_env
, tpc
, addr
);
2324 static void translate_s32c1i(DisasContext
*dc
, const OpcodeArg arg
[],
2325 const uint32_t par
[])
2327 TCGv_i32 tmp
= tcg_temp_local_new_i32();
2328 TCGv_i32 addr
= tcg_temp_local_new_i32();
2331 tcg_gen_mov_i32(tmp
, arg
[0].in
);
2332 tcg_gen_addi_i32(addr
, arg
[1].in
, arg
[2].imm
);
2333 mop
= gen_load_store_alignment(dc
, MO_TEUL
| MO_ALIGN
, addr
);
2334 gen_check_atomctl(dc
, addr
);
2335 tcg_gen_atomic_cmpxchg_i32(arg
[0].out
, addr
, cpu_SR
[SCOMPARE1
],
2336 tmp
, dc
->cring
, mop
);
2337 tcg_temp_free(addr
);
2341 static void translate_s32e(DisasContext
*dc
, const OpcodeArg arg
[],
2342 const uint32_t par
[])
2344 TCGv_i32 addr
= tcg_temp_new_i32();
2347 tcg_gen_addi_i32(addr
, arg
[1].in
, arg
[2].imm
);
2348 mop
= gen_load_store_alignment(dc
, MO_TEUL
, addr
);
2349 tcg_gen_qemu_st_tl(arg
[0].in
, addr
, dc
->ring
, mop
);
2350 tcg_temp_free(addr
);
2353 static void translate_s32ex(DisasContext
*dc
, const OpcodeArg arg
[],
2354 const uint32_t par
[])
2356 TCGv_i32 prev
= tcg_temp_new_i32();
2357 TCGv_i32 addr
= tcg_temp_local_new_i32();
2358 TCGv_i32 res
= tcg_temp_local_new_i32();
2359 TCGLabel
*label
= gen_new_label();
2362 tcg_gen_movi_i32(res
, 0);
2363 tcg_gen_mov_i32(addr
, arg
[1].in
);
2364 mop
= gen_load_store_alignment(dc
, MO_TEUL
| MO_ALIGN
, addr
);
2365 tcg_gen_brcond_i32(TCG_COND_NE
, addr
, cpu_exclusive_addr
, label
);
2366 gen_check_exclusive(dc
, addr
, true);
2367 tcg_gen_atomic_cmpxchg_i32(prev
, cpu_exclusive_addr
, cpu_exclusive_val
,
2368 arg
[0].in
, dc
->cring
, mop
);
2369 tcg_gen_setcond_i32(TCG_COND_EQ
, res
, prev
, cpu_exclusive_val
);
2370 tcg_gen_movcond_i32(TCG_COND_EQ
, cpu_exclusive_val
,
2371 prev
, cpu_exclusive_val
, prev
, cpu_exclusive_val
);
2372 tcg_gen_movi_i32(cpu_exclusive_addr
, -1);
2373 gen_set_label(label
);
2374 tcg_gen_extract_i32(arg
[0].out
, cpu_SR
[ATOMCTL
], 8, 1);
2375 tcg_gen_deposit_i32(cpu_SR
[ATOMCTL
], cpu_SR
[ATOMCTL
], res
, 8, 1);
2376 tcg_temp_free(prev
);
2377 tcg_temp_free(addr
);
2381 static void translate_salt(DisasContext
*dc
, const OpcodeArg arg
[],
2382 const uint32_t par
[])
2384 tcg_gen_setcond_i32(par
[0],
2386 arg
[1].in
, arg
[2].in
);
2389 static void translate_sext(DisasContext
*dc
, const OpcodeArg arg
[],
2390 const uint32_t par
[])
2392 int shift
= 31 - arg
[2].imm
;
2395 tcg_gen_ext8s_i32(arg
[0].out
, arg
[1].in
);
2396 } else if (shift
== 16) {
2397 tcg_gen_ext16s_i32(arg
[0].out
, arg
[1].in
);
2399 TCGv_i32 tmp
= tcg_temp_new_i32();
2400 tcg_gen_shli_i32(tmp
, arg
[1].in
, shift
);
2401 tcg_gen_sari_i32(arg
[0].out
, tmp
, shift
);
2406 static uint32_t test_exceptions_simcall(DisasContext
*dc
,
2407 const OpcodeArg arg
[],
2408 const uint32_t par
[])
2410 #ifdef CONFIG_USER_ONLY
2413 /* Between RE.2 and RE.3 simcall opcode's become nop for the hardware. */
2414 bool ill
= dc
->config
->hw_version
<= 250002 && !semihosting_enabled();
2416 if (ill
|| !semihosting_enabled()) {
2417 qemu_log_mask(LOG_GUEST_ERROR
, "SIMCALL but semihosting is disabled\n");
2419 return ill
? XTENSA_OP_ILL
: 0;
2422 static void translate_simcall(DisasContext
*dc
, const OpcodeArg arg
[],
2423 const uint32_t par
[])
2425 #ifndef CONFIG_USER_ONLY
2426 if (semihosting_enabled()) {
2427 gen_helper_simcall(cpu_env
);
2433 * Note: 64 bit ops are used here solely because SAR values
2436 #define gen_shift_reg(cmd, reg) do { \
2437 TCGv_i64 tmp = tcg_temp_new_i64(); \
2438 tcg_gen_extu_i32_i64(tmp, reg); \
2439 tcg_gen_##cmd##_i64(v, v, tmp); \
2440 tcg_gen_extrl_i64_i32(arg[0].out, v); \
2441 tcg_temp_free_i64(v); \
2442 tcg_temp_free_i64(tmp); \
2445 #define gen_shift(cmd) gen_shift_reg(cmd, cpu_SR[SAR])
2447 static void translate_sll(DisasContext
*dc
, const OpcodeArg arg
[],
2448 const uint32_t par
[])
2450 if (dc
->sar_m32_5bit
) {
2451 tcg_gen_shl_i32(arg
[0].out
, arg
[1].in
, dc
->sar_m32
);
2453 TCGv_i64 v
= tcg_temp_new_i64();
2454 TCGv_i32 s
= tcg_const_i32(32);
2455 tcg_gen_sub_i32(s
, s
, cpu_SR
[SAR
]);
2456 tcg_gen_andi_i32(s
, s
, 0x3f);
2457 tcg_gen_extu_i32_i64(v
, arg
[1].in
);
2458 gen_shift_reg(shl
, s
);
2463 static void translate_slli(DisasContext
*dc
, const OpcodeArg arg
[],
2464 const uint32_t par
[])
2466 if (arg
[2].imm
== 32) {
2467 qemu_log_mask(LOG_GUEST_ERROR
, "slli a%d, a%d, 32 is undefined\n",
2468 arg
[0].imm
, arg
[1].imm
);
2470 tcg_gen_shli_i32(arg
[0].out
, arg
[1].in
, arg
[2].imm
& 0x1f);
2473 static void translate_sra(DisasContext
*dc
, const OpcodeArg arg
[],
2474 const uint32_t par
[])
2476 if (dc
->sar_m32_5bit
) {
2477 tcg_gen_sar_i32(arg
[0].out
, arg
[1].in
, cpu_SR
[SAR
]);
2479 TCGv_i64 v
= tcg_temp_new_i64();
2480 tcg_gen_ext_i32_i64(v
, arg
[1].in
);
2485 static void translate_srai(DisasContext
*dc
, const OpcodeArg arg
[],
2486 const uint32_t par
[])
2488 tcg_gen_sari_i32(arg
[0].out
, arg
[1].in
, arg
[2].imm
);
2491 static void translate_src(DisasContext
*dc
, const OpcodeArg arg
[],
2492 const uint32_t par
[])
2494 TCGv_i64 v
= tcg_temp_new_i64();
2495 tcg_gen_concat_i32_i64(v
, arg
[2].in
, arg
[1].in
);
2499 static void translate_srl(DisasContext
*dc
, const OpcodeArg arg
[],
2500 const uint32_t par
[])
2502 if (dc
->sar_m32_5bit
) {
2503 tcg_gen_shr_i32(arg
[0].out
, arg
[1].in
, cpu_SR
[SAR
]);
2505 TCGv_i64 v
= tcg_temp_new_i64();
2506 tcg_gen_extu_i32_i64(v
, arg
[1].in
);
2512 #undef gen_shift_reg
2514 static void translate_srli(DisasContext
*dc
, const OpcodeArg arg
[],
2515 const uint32_t par
[])
2517 tcg_gen_shri_i32(arg
[0].out
, arg
[1].in
, arg
[2].imm
);
2520 static void translate_ssa8b(DisasContext
*dc
, const OpcodeArg arg
[],
2521 const uint32_t par
[])
2523 TCGv_i32 tmp
= tcg_temp_new_i32();
2524 tcg_gen_shli_i32(tmp
, arg
[0].in
, 3);
2525 gen_left_shift_sar(dc
, tmp
);
2529 static void translate_ssa8l(DisasContext
*dc
, const OpcodeArg arg
[],
2530 const uint32_t par
[])
2532 TCGv_i32 tmp
= tcg_temp_new_i32();
2533 tcg_gen_shli_i32(tmp
, arg
[0].in
, 3);
2534 gen_right_shift_sar(dc
, tmp
);
2538 static void translate_ssai(DisasContext
*dc
, const OpcodeArg arg
[],
2539 const uint32_t par
[])
2541 TCGv_i32 tmp
= tcg_const_i32(arg
[0].imm
);
2542 gen_right_shift_sar(dc
, tmp
);
2546 static void translate_ssl(DisasContext
*dc
, const OpcodeArg arg
[],
2547 const uint32_t par
[])
2549 gen_left_shift_sar(dc
, arg
[0].in
);
2552 static void translate_ssr(DisasContext
*dc
, const OpcodeArg arg
[],
2553 const uint32_t par
[])
2555 gen_right_shift_sar(dc
, arg
[0].in
);
2558 static void translate_sub(DisasContext
*dc
, const OpcodeArg arg
[],
2559 const uint32_t par
[])
2561 tcg_gen_sub_i32(arg
[0].out
, arg
[1].in
, arg
[2].in
);
2564 static void translate_subx(DisasContext
*dc
, const OpcodeArg arg
[],
2565 const uint32_t par
[])
2567 TCGv_i32 tmp
= tcg_temp_new_i32();
2568 tcg_gen_shli_i32(tmp
, arg
[1].in
, par
[0]);
2569 tcg_gen_sub_i32(arg
[0].out
, tmp
, arg
[2].in
);
2573 static void translate_waiti(DisasContext
*dc
, const OpcodeArg arg
[],
2574 const uint32_t par
[])
2576 #ifndef CONFIG_USER_ONLY
2577 gen_waiti(dc
, arg
[0].imm
);
2581 static void translate_wtlb(DisasContext
*dc
, const OpcodeArg arg
[],
2582 const uint32_t par
[])
2584 #ifndef CONFIG_USER_ONLY
2585 TCGv_i32 dtlb
= tcg_const_i32(par
[0]);
2587 gen_helper_wtlb(cpu_env
, arg
[0].in
, arg
[1].in
, dtlb
);
2588 tcg_temp_free(dtlb
);
2592 static void translate_wptlb(DisasContext
*dc
, const OpcodeArg arg
[],
2593 const uint32_t par
[])
2595 #ifndef CONFIG_USER_ONLY
2596 gen_helper_wptlb(cpu_env
, arg
[0].in
, arg
[1].in
);
2600 static void translate_wer(DisasContext
*dc
, const OpcodeArg arg
[],
2601 const uint32_t par
[])
2603 gen_helper_wer(cpu_env
, arg
[0].in
, arg
[1].in
);
2606 static void translate_wrmsk_expstate(DisasContext
*dc
, const OpcodeArg arg
[],
2607 const uint32_t par
[])
2609 /* TODO: GPIO32 may be a part of coprocessor */
2610 tcg_gen_and_i32(cpu_UR
[EXPSTATE
], arg
[0].in
, arg
[1].in
);
2613 static void translate_wsr(DisasContext
*dc
, const OpcodeArg arg
[],
2614 const uint32_t par
[])
2616 if (sr_name
[par
[0]]) {
2617 tcg_gen_mov_i32(cpu_SR
[par
[0]], arg
[0].in
);
2621 static void translate_wsr_mask(DisasContext
*dc
, const OpcodeArg arg
[],
2622 const uint32_t par
[])
2624 if (sr_name
[par
[0]]) {
2625 tcg_gen_andi_i32(cpu_SR
[par
[0]], arg
[0].in
, par
[2]);
2629 static void translate_wsr_acchi(DisasContext
*dc
, const OpcodeArg arg
[],
2630 const uint32_t par
[])
2632 tcg_gen_ext8s_i32(cpu_SR
[par
[0]], arg
[0].in
);
2635 static void translate_wsr_ccompare(DisasContext
*dc
, const OpcodeArg arg
[],
2636 const uint32_t par
[])
2638 #ifndef CONFIG_USER_ONLY
2639 uint32_t id
= par
[0] - CCOMPARE
;
2640 TCGv_i32 tmp
= tcg_const_i32(id
);
2642 assert(id
< dc
->config
->nccompare
);
2643 if (tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
) {
2646 tcg_gen_mov_i32(cpu_SR
[par
[0]], arg
[0].in
);
2647 gen_helper_update_ccompare(cpu_env
, tmp
);
2652 static void translate_wsr_ccount(DisasContext
*dc
, const OpcodeArg arg
[],
2653 const uint32_t par
[])
2655 #ifndef CONFIG_USER_ONLY
2656 if (tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
) {
2659 gen_helper_wsr_ccount(cpu_env
, arg
[0].in
);
2663 static void translate_wsr_dbreaka(DisasContext
*dc
, const OpcodeArg arg
[],
2664 const uint32_t par
[])
2666 #ifndef CONFIG_USER_ONLY
2667 unsigned id
= par
[0] - DBREAKA
;
2668 TCGv_i32 tmp
= tcg_const_i32(id
);
2670 assert(id
< dc
->config
->ndbreak
);
2671 gen_helper_wsr_dbreaka(cpu_env
, tmp
, arg
[0].in
);
2676 static void translate_wsr_dbreakc(DisasContext
*dc
, const OpcodeArg arg
[],
2677 const uint32_t par
[])
2679 #ifndef CONFIG_USER_ONLY
2680 unsigned id
= par
[0] - DBREAKC
;
2681 TCGv_i32 tmp
= tcg_const_i32(id
);
2683 assert(id
< dc
->config
->ndbreak
);
2684 gen_helper_wsr_dbreakc(cpu_env
, tmp
, arg
[0].in
);
2689 static void translate_wsr_ibreaka(DisasContext
*dc
, const OpcodeArg arg
[],
2690 const uint32_t par
[])
2692 #ifndef CONFIG_USER_ONLY
2693 unsigned id
= par
[0] - IBREAKA
;
2694 TCGv_i32 tmp
= tcg_const_i32(id
);
2696 assert(id
< dc
->config
->nibreak
);
2697 gen_helper_wsr_ibreaka(cpu_env
, tmp
, arg
[0].in
);
2702 static void translate_wsr_ibreakenable(DisasContext
*dc
, const OpcodeArg arg
[],
2703 const uint32_t par
[])
2705 #ifndef CONFIG_USER_ONLY
2706 gen_helper_wsr_ibreakenable(cpu_env
, arg
[0].in
);
2710 static void translate_wsr_icount(DisasContext
*dc
, const OpcodeArg arg
[],
2711 const uint32_t par
[])
2713 #ifndef CONFIG_USER_ONLY
2715 tcg_gen_mov_i32(dc
->next_icount
, arg
[0].in
);
2717 tcg_gen_mov_i32(cpu_SR
[par
[0]], arg
[0].in
);
2722 static void translate_wsr_intclear(DisasContext
*dc
, const OpcodeArg arg
[],
2723 const uint32_t par
[])
2725 #ifndef CONFIG_USER_ONLY
2726 gen_helper_intclear(cpu_env
, arg
[0].in
);
2730 static void translate_wsr_intset(DisasContext
*dc
, const OpcodeArg arg
[],
2731 const uint32_t par
[])
2733 #ifndef CONFIG_USER_ONLY
2734 gen_helper_intset(cpu_env
, arg
[0].in
);
2738 static void translate_wsr_memctl(DisasContext
*dc
, const OpcodeArg arg
[],
2739 const uint32_t par
[])
2741 #ifndef CONFIG_USER_ONLY
2742 gen_helper_wsr_memctl(cpu_env
, arg
[0].in
);
2746 static void translate_wsr_mpuenb(DisasContext
*dc
, const OpcodeArg arg
[],
2747 const uint32_t par
[])
2749 #ifndef CONFIG_USER_ONLY
2750 gen_helper_wsr_mpuenb(cpu_env
, arg
[0].in
);
2754 static void translate_wsr_ps(DisasContext
*dc
, const OpcodeArg arg
[],
2755 const uint32_t par
[])
2757 #ifndef CONFIG_USER_ONLY
2758 uint32_t mask
= PS_WOE
| PS_CALLINC
| PS_OWB
|
2759 PS_UM
| PS_EXCM
| PS_INTLEVEL
;
2761 if (option_enabled(dc
, XTENSA_OPTION_MMU
) ||
2762 option_enabled(dc
, XTENSA_OPTION_MPU
)) {
2765 tcg_gen_andi_i32(cpu_SR
[par
[0]], arg
[0].in
, mask
);
2769 static void translate_wsr_rasid(DisasContext
*dc
, const OpcodeArg arg
[],
2770 const uint32_t par
[])
2772 #ifndef CONFIG_USER_ONLY
2773 gen_helper_wsr_rasid(cpu_env
, arg
[0].in
);
2777 static void translate_wsr_sar(DisasContext
*dc
, const OpcodeArg arg
[],
2778 const uint32_t par
[])
2780 tcg_gen_andi_i32(cpu_SR
[par
[0]], arg
[0].in
, 0x3f);
2781 if (dc
->sar_m32_5bit
) {
2782 tcg_gen_discard_i32(dc
->sar_m32
);
2784 dc
->sar_5bit
= false;
2785 dc
->sar_m32_5bit
= false;
2788 static void translate_wsr_windowbase(DisasContext
*dc
, const OpcodeArg arg
[],
2789 const uint32_t par
[])
2791 #ifndef CONFIG_USER_ONLY
2792 tcg_gen_mov_i32(cpu_windowbase_next
, arg
[0].in
);
2796 static void translate_wsr_windowstart(DisasContext
*dc
, const OpcodeArg arg
[],
2797 const uint32_t par
[])
2799 #ifndef CONFIG_USER_ONLY
2800 tcg_gen_andi_i32(cpu_SR
[par
[0]], arg
[0].in
,
2801 (1 << dc
->config
->nareg
/ 4) - 1);
2805 static void translate_wur(DisasContext
*dc
, const OpcodeArg arg
[],
2806 const uint32_t par
[])
2808 tcg_gen_mov_i32(cpu_UR
[par
[0]], arg
[0].in
);
2811 static void translate_xor(DisasContext
*dc
, const OpcodeArg arg
[],
2812 const uint32_t par
[])
2814 tcg_gen_xor_i32(arg
[0].out
, arg
[1].in
, arg
[2].in
);
2817 static void translate_xsr(DisasContext
*dc
, const OpcodeArg arg
[],
2818 const uint32_t par
[])
2820 if (sr_name
[par
[0]]) {
2821 TCGv_i32 tmp
= tcg_temp_new_i32();
2823 tcg_gen_mov_i32(tmp
, arg
[0].in
);
2824 tcg_gen_mov_i32(arg
[0].out
, cpu_SR
[par
[0]]);
2825 tcg_gen_mov_i32(cpu_SR
[par
[0]], tmp
);
2828 tcg_gen_movi_i32(arg
[0].out
, 0);
2832 static void translate_xsr_mask(DisasContext
*dc
, const OpcodeArg arg
[],
2833 const uint32_t par
[])
2835 if (sr_name
[par
[0]]) {
2836 TCGv_i32 tmp
= tcg_temp_new_i32();
2838 tcg_gen_mov_i32(tmp
, arg
[0].in
);
2839 tcg_gen_mov_i32(arg
[0].out
, cpu_SR
[par
[0]]);
2840 tcg_gen_andi_i32(cpu_SR
[par
[0]], tmp
, par
[2]);
2843 tcg_gen_movi_i32(arg
[0].out
, 0);
2847 static void translate_xsr_ccount(DisasContext
*dc
, const OpcodeArg arg
[],
2848 const uint32_t par
[])
2850 #ifndef CONFIG_USER_ONLY
2851 TCGv_i32 tmp
= tcg_temp_new_i32();
2853 if (tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
) {
2857 gen_helper_update_ccount(cpu_env
);
2858 tcg_gen_mov_i32(tmp
, cpu_SR
[par
[0]]);
2859 gen_helper_wsr_ccount(cpu_env
, arg
[0].in
);
2860 tcg_gen_mov_i32(arg
[0].out
, tmp
);
2866 #define gen_translate_xsr(name) \
2867 static void translate_xsr_##name(DisasContext *dc, const OpcodeArg arg[], \
2868 const uint32_t par[]) \
2870 TCGv_i32 tmp = tcg_temp_new_i32(); \
2872 if (sr_name[par[0]]) { \
2873 tcg_gen_mov_i32(tmp, cpu_SR[par[0]]); \
2875 tcg_gen_movi_i32(tmp, 0); \
2877 translate_wsr_##name(dc, arg, par); \
2878 tcg_gen_mov_i32(arg[0].out, tmp); \
2879 tcg_temp_free(tmp); \
2882 gen_translate_xsr(acchi
)
2883 gen_translate_xsr(ccompare
)
2884 gen_translate_xsr(dbreaka
)
2885 gen_translate_xsr(dbreakc
)
2886 gen_translate_xsr(ibreaka
)
2887 gen_translate_xsr(ibreakenable
)
2888 gen_translate_xsr(icount
)
2889 gen_translate_xsr(memctl
)
2890 gen_translate_xsr(mpuenb
)
2891 gen_translate_xsr(ps
)
2892 gen_translate_xsr(rasid
)
2893 gen_translate_xsr(sar
)
2894 gen_translate_xsr(windowbase
)
2895 gen_translate_xsr(windowstart
)
2897 #undef gen_translate_xsr
2899 static const XtensaOpcodeOps core_ops
[] = {
2902 .translate
= translate_abs
,
2904 .name
= (const char * const[]) {
2905 "add", "add.n", NULL
,
2907 .translate
= translate_add
,
2908 .op_flags
= XTENSA_OP_NAME_ARRAY
,
2910 .name
= (const char * const[]) {
2911 "addi", "addi.n", NULL
,
2913 .translate
= translate_addi
,
2914 .op_flags
= XTENSA_OP_NAME_ARRAY
,
2917 .translate
= translate_addi
,
2920 .translate
= translate_addx
,
2921 .par
= (const uint32_t[]){1},
2924 .translate
= translate_addx
,
2925 .par
= (const uint32_t[]){2},
2928 .translate
= translate_addx
,
2929 .par
= (const uint32_t[]){3},
2932 .translate
= translate_all
,
2933 .par
= (const uint32_t[]){true, 4},
2936 .translate
= translate_all
,
2937 .par
= (const uint32_t[]){true, 8},
2940 .translate
= translate_and
,
2943 .translate
= translate_boolean
,
2944 .par
= (const uint32_t[]){BOOLEAN_AND
},
2947 .translate
= translate_boolean
,
2948 .par
= (const uint32_t[]){BOOLEAN_ANDC
},
2951 .translate
= translate_all
,
2952 .par
= (const uint32_t[]){false, 4},
2955 .translate
= translate_all
,
2956 .par
= (const uint32_t[]){false, 8},
2958 .name
= (const char * const[]) {
2959 "ball", "ball.w15", "ball.w18", NULL
,
2961 .translate
= translate_ball
,
2962 .par
= (const uint32_t[]){TCG_COND_EQ
},
2963 .op_flags
= XTENSA_OP_NAME_ARRAY
,
2965 .name
= (const char * const[]) {
2966 "bany", "bany.w15", "bany.w18", NULL
,
2968 .translate
= translate_bany
,
2969 .par
= (const uint32_t[]){TCG_COND_NE
},
2970 .op_flags
= XTENSA_OP_NAME_ARRAY
,
2972 .name
= (const char * const[]) {
2973 "bbc", "bbc.w15", "bbc.w18", NULL
,
2975 .translate
= translate_bb
,
2976 .par
= (const uint32_t[]){TCG_COND_EQ
},
2977 .op_flags
= XTENSA_OP_NAME_ARRAY
,
2979 .name
= (const char * const[]) {
2980 "bbci", "bbci.w15", "bbci.w18", NULL
,
2982 .translate
= translate_bbi
,
2983 .par
= (const uint32_t[]){TCG_COND_EQ
},
2984 .op_flags
= XTENSA_OP_NAME_ARRAY
,
2986 .name
= (const char * const[]) {
2987 "bbs", "bbs.w15", "bbs.w18", NULL
,
2989 .translate
= translate_bb
,
2990 .par
= (const uint32_t[]){TCG_COND_NE
},
2991 .op_flags
= XTENSA_OP_NAME_ARRAY
,
2993 .name
= (const char * const[]) {
2994 "bbsi", "bbsi.w15", "bbsi.w18", NULL
,
2996 .translate
= translate_bbi
,
2997 .par
= (const uint32_t[]){TCG_COND_NE
},
2998 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3000 .name
= (const char * const[]) {
3001 "beq", "beq.w15", "beq.w18", NULL
,
3003 .translate
= translate_b
,
3004 .par
= (const uint32_t[]){TCG_COND_EQ
},
3005 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3007 .name
= (const char * const[]) {
3008 "beqi", "beqi.w15", "beqi.w18", NULL
,
3010 .translate
= translate_bi
,
3011 .par
= (const uint32_t[]){TCG_COND_EQ
},
3012 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3014 .name
= (const char * const[]) {
3015 "beqz", "beqz.n", "beqz.w15", "beqz.w18", NULL
,
3017 .translate
= translate_bz
,
3018 .par
= (const uint32_t[]){TCG_COND_EQ
},
3019 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3022 .translate
= translate_bp
,
3023 .par
= (const uint32_t[]){TCG_COND_EQ
},
3025 .name
= (const char * const[]) {
3026 "bge", "bge.w15", "bge.w18", NULL
,
3028 .translate
= translate_b
,
3029 .par
= (const uint32_t[]){TCG_COND_GE
},
3030 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3032 .name
= (const char * const[]) {
3033 "bgei", "bgei.w15", "bgei.w18", NULL
,
3035 .translate
= translate_bi
,
3036 .par
= (const uint32_t[]){TCG_COND_GE
},
3037 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3039 .name
= (const char * const[]) {
3040 "bgeu", "bgeu.w15", "bgeu.w18", NULL
,
3042 .translate
= translate_b
,
3043 .par
= (const uint32_t[]){TCG_COND_GEU
},
3044 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3046 .name
= (const char * const[]) {
3047 "bgeui", "bgeui.w15", "bgeui.w18", NULL
,
3049 .translate
= translate_bi
,
3050 .par
= (const uint32_t[]){TCG_COND_GEU
},
3051 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3053 .name
= (const char * const[]) {
3054 "bgez", "bgez.w15", "bgez.w18", NULL
,
3056 .translate
= translate_bz
,
3057 .par
= (const uint32_t[]){TCG_COND_GE
},
3058 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3060 .name
= (const char * const[]) {
3061 "blt", "blt.w15", "blt.w18", NULL
,
3063 .translate
= translate_b
,
3064 .par
= (const uint32_t[]){TCG_COND_LT
},
3065 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3067 .name
= (const char * const[]) {
3068 "blti", "blti.w15", "blti.w18", NULL
,
3070 .translate
= translate_bi
,
3071 .par
= (const uint32_t[]){TCG_COND_LT
},
3072 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3074 .name
= (const char * const[]) {
3075 "bltu", "bltu.w15", "bltu.w18", NULL
,
3077 .translate
= translate_b
,
3078 .par
= (const uint32_t[]){TCG_COND_LTU
},
3079 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3081 .name
= (const char * const[]) {
3082 "bltui", "bltui.w15", "bltui.w18", NULL
,
3084 .translate
= translate_bi
,
3085 .par
= (const uint32_t[]){TCG_COND_LTU
},
3086 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3088 .name
= (const char * const[]) {
3089 "bltz", "bltz.w15", "bltz.w18", NULL
,
3091 .translate
= translate_bz
,
3092 .par
= (const uint32_t[]){TCG_COND_LT
},
3093 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3095 .name
= (const char * const[]) {
3096 "bnall", "bnall.w15", "bnall.w18", NULL
,
3098 .translate
= translate_ball
,
3099 .par
= (const uint32_t[]){TCG_COND_NE
},
3100 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3102 .name
= (const char * const[]) {
3103 "bne", "bne.w15", "bne.w18", NULL
,
3105 .translate
= translate_b
,
3106 .par
= (const uint32_t[]){TCG_COND_NE
},
3107 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3109 .name
= (const char * const[]) {
3110 "bnei", "bnei.w15", "bnei.w18", NULL
,
3112 .translate
= translate_bi
,
3113 .par
= (const uint32_t[]){TCG_COND_NE
},
3114 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3116 .name
= (const char * const[]) {
3117 "bnez", "bnez.n", "bnez.w15", "bnez.w18", NULL
,
3119 .translate
= translate_bz
,
3120 .par
= (const uint32_t[]){TCG_COND_NE
},
3121 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3123 .name
= (const char * const[]) {
3124 "bnone", "bnone.w15", "bnone.w18", NULL
,
3126 .translate
= translate_bany
,
3127 .par
= (const uint32_t[]){TCG_COND_EQ
},
3128 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3131 .translate
= translate_nop
,
3132 .par
= (const uint32_t[]){DEBUGCAUSE_BI
},
3133 .op_flags
= XTENSA_OP_DEBUG_BREAK
,
3136 .translate
= translate_nop
,
3137 .par
= (const uint32_t[]){DEBUGCAUSE_BN
},
3138 .op_flags
= XTENSA_OP_DEBUG_BREAK
,
3141 .translate
= translate_bp
,
3142 .par
= (const uint32_t[]){TCG_COND_NE
},
3145 .translate
= translate_call0
,
3148 .translate
= translate_callw
,
3149 .par
= (const uint32_t[]){3},
3152 .translate
= translate_callw
,
3153 .par
= (const uint32_t[]){1},
3156 .translate
= translate_callw
,
3157 .par
= (const uint32_t[]){2},
3160 .translate
= translate_callx0
,
3163 .translate
= translate_callxw
,
3164 .par
= (const uint32_t[]){3},
3167 .translate
= translate_callxw
,
3168 .par
= (const uint32_t[]){1},
3171 .translate
= translate_callxw
,
3172 .par
= (const uint32_t[]){2},
3175 .translate
= translate_clamps
,
3177 .name
= "clrb_expstate",
3178 .translate
= translate_clrb_expstate
,
3181 .translate
= translate_clrex
,
3184 .translate
= translate_const16
,
3187 .translate
= translate_depbits
,
3190 .translate
= translate_dcache
,
3191 .op_flags
= XTENSA_OP_PRIVILEGED
,
3194 .translate
= translate_nop
,
3197 .translate
= translate_dcache
,
3198 .op_flags
= XTENSA_OP_PRIVILEGED
,
3201 .translate
= translate_dcache
,
3204 .translate
= translate_nop
,
3207 .translate
= translate_dcache
,
3210 .translate
= translate_nop
,
3213 .translate
= translate_nop
,
3214 .op_flags
= XTENSA_OP_PRIVILEGED
,
3217 .translate
= translate_nop
,
3218 .op_flags
= XTENSA_OP_PRIVILEGED
,
3221 .translate
= translate_nop
,
3222 .op_flags
= XTENSA_OP_PRIVILEGED
,
3225 .translate
= translate_nop
,
3226 .op_flags
= XTENSA_OP_PRIVILEGED
,
3229 .translate
= translate_diwbuip
,
3230 .op_flags
= XTENSA_OP_PRIVILEGED
,
3233 .translate
= translate_dcache
,
3234 .op_flags
= XTENSA_OP_PRIVILEGED
,
3237 .translate
= translate_nop
,
3240 .translate
= translate_nop
,
3243 .translate
= translate_nop
,
3246 .translate
= translate_nop
,
3249 .translate
= translate_nop
,
3252 .translate
= translate_nop
,
3255 .translate
= translate_nop
,
3258 .translate
= translate_nop
,
3261 .translate
= translate_nop
,
3264 .translate
= translate_nop
,
3267 .translate
= translate_nop
,
3270 .translate
= translate_entry
,
3271 .test_exceptions
= test_exceptions_entry
,
3272 .test_overflow
= test_overflow_entry
,
3273 .op_flags
= XTENSA_OP_EXIT_TB_M1
|
3274 XTENSA_OP_SYNC_REGISTER_WINDOW
,
3277 .translate
= translate_nop
,
3280 .translate
= translate_nop
,
3283 .translate
= translate_extui
,
3286 .translate
= translate_memw
,
3289 .translate
= translate_getex
,
3292 .op_flags
= XTENSA_OP_ILL
,
3295 .op_flags
= XTENSA_OP_ILL
,
3298 .translate
= translate_itlb
,
3299 .par
= (const uint32_t[]){true},
3300 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
3303 .translate
= translate_icache
,
3306 .translate
= translate_icache
,
3307 .op_flags
= XTENSA_OP_PRIVILEGED
,
3310 .translate
= translate_nop
,
3311 .op_flags
= XTENSA_OP_PRIVILEGED
,
3314 .translate
= translate_itlb
,
3315 .par
= (const uint32_t[]){false},
3316 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
3319 .translate
= translate_nop
,
3320 .op_flags
= XTENSA_OP_PRIVILEGED
,
3322 .name
= (const char * const[]) {
3323 "ill", "ill.n", NULL
,
3325 .op_flags
= XTENSA_OP_ILL
| XTENSA_OP_NAME_ARRAY
,
3328 .translate
= translate_nop
,
3331 .translate
= translate_icache
,
3332 .op_flags
= XTENSA_OP_PRIVILEGED
,
3335 .translate
= translate_nop
,
3338 .translate
= translate_j
,
3341 .translate
= translate_jx
,
3344 .translate
= translate_ldst
,
3345 .par
= (const uint32_t[]){MO_TESW
, false, false},
3346 .op_flags
= XTENSA_OP_LOAD
,
3349 .translate
= translate_ldst
,
3350 .par
= (const uint32_t[]){MO_TEUW
, false, false},
3351 .op_flags
= XTENSA_OP_LOAD
,
3354 .translate
= translate_ldst
,
3355 .par
= (const uint32_t[]){MO_TEUL
| MO_ALIGN
, true, false},
3356 .op_flags
= XTENSA_OP_LOAD
,
3359 .translate
= translate_l32e
,
3360 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_LOAD
,
3363 .translate
= translate_l32ex
,
3364 .op_flags
= XTENSA_OP_LOAD
,
3366 .name
= (const char * const[]) {
3367 "l32i", "l32i.n", NULL
,
3369 .translate
= translate_ldst
,
3370 .par
= (const uint32_t[]){MO_TEUL
, false, false},
3371 .op_flags
= XTENSA_OP_NAME_ARRAY
| XTENSA_OP_LOAD
,
3374 .translate
= translate_l32r
,
3375 .op_flags
= XTENSA_OP_LOAD
,
3378 .translate
= translate_ldst
,
3379 .par
= (const uint32_t[]){MO_UB
, false, false},
3380 .op_flags
= XTENSA_OP_LOAD
,
3383 .translate
= translate_mac16
,
3384 .par
= (const uint32_t[]){MAC16_NONE
, 0, -4},
3385 .op_flags
= XTENSA_OP_LOAD
,
3388 .translate
= translate_mac16
,
3389 .par
= (const uint32_t[]){MAC16_NONE
, 0, 4},
3390 .op_flags
= XTENSA_OP_LOAD
,
3393 .op_flags
= XTENSA_OP_ILL
,
3395 .name
= (const char * const[]) {
3396 "loop", "loop.w15", NULL
,
3398 .translate
= translate_loop
,
3399 .par
= (const uint32_t[]){TCG_COND_NEVER
},
3400 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3402 .name
= (const char * const[]) {
3403 "loopgtz", "loopgtz.w15", NULL
,
3405 .translate
= translate_loop
,
3406 .par
= (const uint32_t[]){TCG_COND_GT
},
3407 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3409 .name
= (const char * const[]) {
3410 "loopnez", "loopnez.w15", NULL
,
3412 .translate
= translate_loop
,
3413 .par
= (const uint32_t[]){TCG_COND_NE
},
3414 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3417 .translate
= translate_smax
,
3420 .translate
= translate_umax
,
3423 .translate
= translate_memw
,
3426 .translate
= translate_smin
,
3429 .translate
= translate_umin
,
3431 .name
= (const char * const[]) {
3432 "mov", "mov.n", NULL
,
3434 .translate
= translate_mov
,
3435 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3438 .translate
= translate_movcond
,
3439 .par
= (const uint32_t[]){TCG_COND_EQ
},
3442 .translate
= translate_movp
,
3443 .par
= (const uint32_t[]){TCG_COND_EQ
},
3446 .translate
= translate_movcond
,
3447 .par
= (const uint32_t[]){TCG_COND_GE
},
3450 .translate
= translate_movi
,
3453 .translate
= translate_movi
,
3456 .translate
= translate_movcond
,
3457 .par
= (const uint32_t[]){TCG_COND_LT
},
3460 .translate
= translate_movcond
,
3461 .par
= (const uint32_t[]){TCG_COND_NE
},
3464 .translate
= translate_movsp
,
3465 .op_flags
= XTENSA_OP_ALLOCA
,
3468 .translate
= translate_movp
,
3469 .par
= (const uint32_t[]){TCG_COND_NE
},
3471 .name
= "mul.aa.hh",
3472 .translate
= translate_mac16
,
3473 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_HH
, 0},
3475 .name
= "mul.aa.hl",
3476 .translate
= translate_mac16
,
3477 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_HL
, 0},
3479 .name
= "mul.aa.lh",
3480 .translate
= translate_mac16
,
3481 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_LH
, 0},
3483 .name
= "mul.aa.ll",
3484 .translate
= translate_mac16
,
3485 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_LL
, 0},
3487 .name
= "mul.ad.hh",
3488 .translate
= translate_mac16
,
3489 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_HH
, 0},
3491 .name
= "mul.ad.hl",
3492 .translate
= translate_mac16
,
3493 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_HL
, 0},
3495 .name
= "mul.ad.lh",
3496 .translate
= translate_mac16
,
3497 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_LH
, 0},
3499 .name
= "mul.ad.ll",
3500 .translate
= translate_mac16
,
3501 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_LL
, 0},
3503 .name
= "mul.da.hh",
3504 .translate
= translate_mac16
,
3505 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_HH
, 0},
3507 .name
= "mul.da.hl",
3508 .translate
= translate_mac16
,
3509 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_HL
, 0},
3511 .name
= "mul.da.lh",
3512 .translate
= translate_mac16
,
3513 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_LH
, 0},
3515 .name
= "mul.da.ll",
3516 .translate
= translate_mac16
,
3517 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_LL
, 0},
3519 .name
= "mul.dd.hh",
3520 .translate
= translate_mac16
,
3521 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_HH
, 0},
3523 .name
= "mul.dd.hl",
3524 .translate
= translate_mac16
,
3525 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_HL
, 0},
3527 .name
= "mul.dd.lh",
3528 .translate
= translate_mac16
,
3529 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_LH
, 0},
3531 .name
= "mul.dd.ll",
3532 .translate
= translate_mac16
,
3533 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_LL
, 0},
3536 .translate
= translate_mul16
,
3537 .par
= (const uint32_t[]){true},
3540 .translate
= translate_mul16
,
3541 .par
= (const uint32_t[]){false},
3543 .name
= "mula.aa.hh",
3544 .translate
= translate_mac16
,
3545 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HH
, 0},
3547 .name
= "mula.aa.hl",
3548 .translate
= translate_mac16
,
3549 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HL
, 0},
3551 .name
= "mula.aa.lh",
3552 .translate
= translate_mac16
,
3553 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LH
, 0},
3555 .name
= "mula.aa.ll",
3556 .translate
= translate_mac16
,
3557 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LL
, 0},
3559 .name
= "mula.ad.hh",
3560 .translate
= translate_mac16
,
3561 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HH
, 0},
3563 .name
= "mula.ad.hl",
3564 .translate
= translate_mac16
,
3565 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HL
, 0},
3567 .name
= "mula.ad.lh",
3568 .translate
= translate_mac16
,
3569 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LH
, 0},
3571 .name
= "mula.ad.ll",
3572 .translate
= translate_mac16
,
3573 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LL
, 0},
3575 .name
= "mula.da.hh",
3576 .translate
= translate_mac16
,
3577 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HH
, 0},
3579 .name
= "mula.da.hh.lddec",
3580 .translate
= translate_mac16
,
3581 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HH
, -4},
3583 .name
= "mula.da.hh.ldinc",
3584 .translate
= translate_mac16
,
3585 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HH
, 4},
3587 .name
= "mula.da.hl",
3588 .translate
= translate_mac16
,
3589 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HL
, 0},
3591 .name
= "mula.da.hl.lddec",
3592 .translate
= translate_mac16
,
3593 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HL
, -4},
3595 .name
= "mula.da.hl.ldinc",
3596 .translate
= translate_mac16
,
3597 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HL
, 4},
3599 .name
= "mula.da.lh",
3600 .translate
= translate_mac16
,
3601 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LH
, 0},
3603 .name
= "mula.da.lh.lddec",
3604 .translate
= translate_mac16
,
3605 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LH
, -4},
3607 .name
= "mula.da.lh.ldinc",
3608 .translate
= translate_mac16
,
3609 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LH
, 4},
3611 .name
= "mula.da.ll",
3612 .translate
= translate_mac16
,
3613 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LL
, 0},
3615 .name
= "mula.da.ll.lddec",
3616 .translate
= translate_mac16
,
3617 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LL
, -4},
3619 .name
= "mula.da.ll.ldinc",
3620 .translate
= translate_mac16
,
3621 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LL
, 4},
3623 .name
= "mula.dd.hh",
3624 .translate
= translate_mac16
,
3625 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HH
, 0},
3627 .name
= "mula.dd.hh.lddec",
3628 .translate
= translate_mac16
,
3629 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HH
, -4},
3631 .name
= "mula.dd.hh.ldinc",
3632 .translate
= translate_mac16
,
3633 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HH
, 4},
3635 .name
= "mula.dd.hl",
3636 .translate
= translate_mac16
,
3637 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HL
, 0},
3639 .name
= "mula.dd.hl.lddec",
3640 .translate
= translate_mac16
,
3641 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HL
, -4},
3643 .name
= "mula.dd.hl.ldinc",
3644 .translate
= translate_mac16
,
3645 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HL
, 4},
3647 .name
= "mula.dd.lh",
3648 .translate
= translate_mac16
,
3649 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LH
, 0},
3651 .name
= "mula.dd.lh.lddec",
3652 .translate
= translate_mac16
,
3653 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LH
, -4},
3655 .name
= "mula.dd.lh.ldinc",
3656 .translate
= translate_mac16
,
3657 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LH
, 4},
3659 .name
= "mula.dd.ll",
3660 .translate
= translate_mac16
,
3661 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LL
, 0},
3663 .name
= "mula.dd.ll.lddec",
3664 .translate
= translate_mac16
,
3665 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LL
, -4},
3667 .name
= "mula.dd.ll.ldinc",
3668 .translate
= translate_mac16
,
3669 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LL
, 4},
3672 .translate
= translate_mull
,
3674 .name
= "muls.aa.hh",
3675 .translate
= translate_mac16
,
3676 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_HH
, 0},
3678 .name
= "muls.aa.hl",
3679 .translate
= translate_mac16
,
3680 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_HL
, 0},
3682 .name
= "muls.aa.lh",
3683 .translate
= translate_mac16
,
3684 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_LH
, 0},
3686 .name
= "muls.aa.ll",
3687 .translate
= translate_mac16
,
3688 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_LL
, 0},
3690 .name
= "muls.ad.hh",
3691 .translate
= translate_mac16
,
3692 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_HH
, 0},
3694 .name
= "muls.ad.hl",
3695 .translate
= translate_mac16
,
3696 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_HL
, 0},
3698 .name
= "muls.ad.lh",
3699 .translate
= translate_mac16
,
3700 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_LH
, 0},
3702 .name
= "muls.ad.ll",
3703 .translate
= translate_mac16
,
3704 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_LL
, 0},
3706 .name
= "muls.da.hh",
3707 .translate
= translate_mac16
,
3708 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_HH
, 0},
3710 .name
= "muls.da.hl",
3711 .translate
= translate_mac16
,
3712 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_HL
, 0},
3714 .name
= "muls.da.lh",
3715 .translate
= translate_mac16
,
3716 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_LH
, 0},
3718 .name
= "muls.da.ll",
3719 .translate
= translate_mac16
,
3720 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_LL
, 0},
3722 .name
= "muls.dd.hh",
3723 .translate
= translate_mac16
,
3724 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_HH
, 0},
3726 .name
= "muls.dd.hl",
3727 .translate
= translate_mac16
,
3728 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_HL
, 0},
3730 .name
= "muls.dd.lh",
3731 .translate
= translate_mac16
,
3732 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_LH
, 0},
3734 .name
= "muls.dd.ll",
3735 .translate
= translate_mac16
,
3736 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_LL
, 0},
3739 .translate
= translate_mulh
,
3740 .par
= (const uint32_t[]){true},
3743 .translate
= translate_mulh
,
3744 .par
= (const uint32_t[]){false},
3747 .translate
= translate_neg
,
3749 .name
= (const char * const[]) {
3750 "nop", "nop.n", NULL
,
3752 .translate
= translate_nop
,
3753 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3756 .translate
= translate_nsa
,
3759 .translate
= translate_nsau
,
3762 .translate
= translate_or
,
3765 .translate
= translate_boolean
,
3766 .par
= (const uint32_t[]){BOOLEAN_OR
},
3769 .translate
= translate_boolean
,
3770 .par
= (const uint32_t[]){BOOLEAN_ORC
},
3773 .translate
= translate_ptlb
,
3774 .par
= (const uint32_t[]){true},
3775 .op_flags
= XTENSA_OP_PRIVILEGED
,
3778 .translate
= translate_nop
,
3781 .translate
= translate_nop
,
3784 .translate
= translate_nop
,
3787 .translate
= translate_nop
,
3790 .translate
= translate_nop
,
3793 .translate
= translate_ptlb
,
3794 .par
= (const uint32_t[]){false},
3795 .op_flags
= XTENSA_OP_PRIVILEGED
,
3798 .translate
= translate_pptlb
,
3799 .op_flags
= XTENSA_OP_PRIVILEGED
,
3802 .translate
= translate_quos
,
3803 .par
= (const uint32_t[]){true},
3804 .op_flags
= XTENSA_OP_DIVIDE_BY_ZERO
,
3807 .translate
= translate_quou
,
3808 .op_flags
= XTENSA_OP_DIVIDE_BY_ZERO
,
3811 .translate
= translate_rtlb
,
3812 .par
= (const uint32_t[]){true, 0},
3813 .op_flags
= XTENSA_OP_PRIVILEGED
,
3816 .translate
= translate_rtlb
,
3817 .par
= (const uint32_t[]){true, 1},
3818 .op_flags
= XTENSA_OP_PRIVILEGED
,
3820 .name
= "read_impwire",
3821 .translate
= translate_read_impwire
,
3824 .translate
= translate_quos
,
3825 .par
= (const uint32_t[]){false},
3826 .op_flags
= XTENSA_OP_DIVIDE_BY_ZERO
,
3829 .translate
= translate_remu
,
3830 .op_flags
= XTENSA_OP_DIVIDE_BY_ZERO
,
3833 .translate
= translate_rer
,
3834 .op_flags
= XTENSA_OP_PRIVILEGED
,
3836 .name
= (const char * const[]) {
3837 "ret", "ret.n", NULL
,
3839 .translate
= translate_ret
,
3840 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3842 .name
= (const char * const[]) {
3843 "retw", "retw.n", NULL
,
3845 .translate
= translate_retw
,
3846 .test_exceptions
= test_exceptions_retw
,
3847 .op_flags
= XTENSA_OP_UNDERFLOW
| XTENSA_OP_NAME_ARRAY
,
3850 .op_flags
= XTENSA_OP_ILL
,
3853 .translate
= translate_rfde
,
3854 .op_flags
= XTENSA_OP_PRIVILEGED
,
3857 .op_flags
= XTENSA_OP_ILL
,
3860 .translate
= translate_rfe
,
3861 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_CHECK_INTERRUPTS
,
3864 .translate
= translate_rfi
,
3865 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_CHECK_INTERRUPTS
,
3868 .translate
= translate_rfw
,
3869 .par
= (const uint32_t[]){true},
3870 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_CHECK_INTERRUPTS
,
3873 .translate
= translate_rfw
,
3874 .par
= (const uint32_t[]){false},
3875 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_CHECK_INTERRUPTS
,
3878 .translate
= translate_rtlb
,
3879 .par
= (const uint32_t[]){false, 0},
3880 .op_flags
= XTENSA_OP_PRIVILEGED
,
3883 .translate
= translate_rtlb
,
3884 .par
= (const uint32_t[]){false, 1},
3885 .op_flags
= XTENSA_OP_PRIVILEGED
,
3888 .translate
= translate_rptlb0
,
3889 .op_flags
= XTENSA_OP_PRIVILEGED
,
3892 .translate
= translate_rptlb1
,
3893 .op_flags
= XTENSA_OP_PRIVILEGED
,
3896 .translate
= translate_rotw
,
3897 .op_flags
= XTENSA_OP_PRIVILEGED
|
3898 XTENSA_OP_EXIT_TB_M1
|
3899 XTENSA_OP_SYNC_REGISTER_WINDOW
,
3902 .translate
= translate_rsil
,
3904 XTENSA_OP_PRIVILEGED
|
3905 XTENSA_OP_EXIT_TB_0
|
3906 XTENSA_OP_CHECK_INTERRUPTS
,
3909 .translate
= translate_rsr
,
3910 .par
= (const uint32_t[]){176},
3911 .op_flags
= XTENSA_OP_PRIVILEGED
,
3914 .translate
= translate_rsr
,
3915 .par
= (const uint32_t[]){208},
3916 .op_flags
= XTENSA_OP_PRIVILEGED
,
3918 .name
= "rsr.acchi",
3919 .translate
= translate_rsr
,
3920 .test_exceptions
= test_exceptions_sr
,
3921 .par
= (const uint32_t[]){
3923 XTENSA_OPTION_MAC16
,
3926 .name
= "rsr.acclo",
3927 .translate
= translate_rsr
,
3928 .test_exceptions
= test_exceptions_sr
,
3929 .par
= (const uint32_t[]){
3931 XTENSA_OPTION_MAC16
,
3934 .name
= "rsr.atomctl",
3935 .translate
= translate_rsr
,
3936 .test_exceptions
= test_exceptions_sr
,
3937 .par
= (const uint32_t[]){
3939 XTENSA_OPTION_ATOMCTL
,
3941 .op_flags
= XTENSA_OP_PRIVILEGED
,
3944 .translate
= translate_rsr
,
3945 .test_exceptions
= test_exceptions_sr
,
3946 .par
= (const uint32_t[]){
3948 XTENSA_OPTION_BOOLEAN
,
3951 .name
= "rsr.cacheadrdis",
3952 .translate
= translate_rsr
,
3953 .test_exceptions
= test_exceptions_sr
,
3954 .par
= (const uint32_t[]){
3958 .op_flags
= XTENSA_OP_PRIVILEGED
,
3960 .name
= "rsr.cacheattr",
3961 .translate
= translate_rsr
,
3962 .test_exceptions
= test_exceptions_sr
,
3963 .par
= (const uint32_t[]){
3965 XTENSA_OPTION_CACHEATTR
,
3967 .op_flags
= XTENSA_OP_PRIVILEGED
,
3969 .name
= "rsr.ccompare0",
3970 .translate
= translate_rsr
,
3971 .test_exceptions
= test_exceptions_ccompare
,
3972 .par
= (const uint32_t[]){
3974 XTENSA_OPTION_TIMER_INTERRUPT
,
3976 .op_flags
= XTENSA_OP_PRIVILEGED
,
3978 .name
= "rsr.ccompare1",
3979 .translate
= translate_rsr
,
3980 .test_exceptions
= test_exceptions_ccompare
,
3981 .par
= (const uint32_t[]){
3983 XTENSA_OPTION_TIMER_INTERRUPT
,
3985 .op_flags
= XTENSA_OP_PRIVILEGED
,
3987 .name
= "rsr.ccompare2",
3988 .translate
= translate_rsr
,
3989 .test_exceptions
= test_exceptions_ccompare
,
3990 .par
= (const uint32_t[]){
3992 XTENSA_OPTION_TIMER_INTERRUPT
,
3994 .op_flags
= XTENSA_OP_PRIVILEGED
,
3996 .name
= "rsr.ccount",
3997 .translate
= translate_rsr_ccount
,
3998 .test_exceptions
= test_exceptions_sr
,
3999 .par
= (const uint32_t[]){
4001 XTENSA_OPTION_TIMER_INTERRUPT
,
4003 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
4005 .name
= "rsr.configid0",
4006 .translate
= translate_rsr
,
4007 .par
= (const uint32_t[]){CONFIGID0
},
4008 .op_flags
= XTENSA_OP_PRIVILEGED
,
4010 .name
= "rsr.configid1",
4011 .translate
= translate_rsr
,
4012 .par
= (const uint32_t[]){CONFIGID1
},
4013 .op_flags
= XTENSA_OP_PRIVILEGED
,
4015 .name
= "rsr.cpenable",
4016 .translate
= translate_rsr
,
4017 .test_exceptions
= test_exceptions_sr
,
4018 .par
= (const uint32_t[]){
4020 XTENSA_OPTION_COPROCESSOR
,
4022 .op_flags
= XTENSA_OP_PRIVILEGED
,
4024 .name
= "rsr.dbreaka0",
4025 .translate
= translate_rsr
,
4026 .test_exceptions
= test_exceptions_dbreak
,
4027 .par
= (const uint32_t[]){
4029 XTENSA_OPTION_DEBUG
,
4031 .op_flags
= XTENSA_OP_PRIVILEGED
,
4033 .name
= "rsr.dbreaka1",
4034 .translate
= translate_rsr
,
4035 .test_exceptions
= test_exceptions_dbreak
,
4036 .par
= (const uint32_t[]){
4038 XTENSA_OPTION_DEBUG
,
4040 .op_flags
= XTENSA_OP_PRIVILEGED
,
4042 .name
= "rsr.dbreakc0",
4043 .translate
= translate_rsr
,
4044 .test_exceptions
= test_exceptions_dbreak
,
4045 .par
= (const uint32_t[]){
4047 XTENSA_OPTION_DEBUG
,
4049 .op_flags
= XTENSA_OP_PRIVILEGED
,
4051 .name
= "rsr.dbreakc1",
4052 .translate
= translate_rsr
,
4053 .test_exceptions
= test_exceptions_dbreak
,
4054 .par
= (const uint32_t[]){
4056 XTENSA_OPTION_DEBUG
,
4058 .op_flags
= XTENSA_OP_PRIVILEGED
,
4061 .translate
= translate_rsr
,
4062 .test_exceptions
= test_exceptions_sr
,
4063 .par
= (const uint32_t[]){
4065 XTENSA_OPTION_DEBUG
,
4067 .op_flags
= XTENSA_OP_PRIVILEGED
,
4069 .name
= "rsr.debugcause",
4070 .translate
= translate_rsr
,
4071 .test_exceptions
= test_exceptions_sr
,
4072 .par
= (const uint32_t[]){
4074 XTENSA_OPTION_DEBUG
,
4076 .op_flags
= XTENSA_OP_PRIVILEGED
,
4079 .translate
= translate_rsr
,
4080 .test_exceptions
= test_exceptions_sr
,
4081 .par
= (const uint32_t[]){
4083 XTENSA_OPTION_EXCEPTION
,
4085 .op_flags
= XTENSA_OP_PRIVILEGED
,
4087 .name
= "rsr.dtlbcfg",
4088 .translate
= translate_rsr
,
4089 .test_exceptions
= test_exceptions_sr
,
4090 .par
= (const uint32_t[]){
4094 .op_flags
= XTENSA_OP_PRIVILEGED
,
4097 .translate
= translate_rsr
,
4098 .test_exceptions
= test_exceptions_sr
,
4099 .par
= (const uint32_t[]){
4101 XTENSA_OPTION_EXCEPTION
,
4103 .op_flags
= XTENSA_OP_PRIVILEGED
,
4106 .translate
= translate_rsr
,
4107 .test_exceptions
= test_exceptions_hpi
,
4108 .par
= (const uint32_t[]){
4110 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4112 .op_flags
= XTENSA_OP_PRIVILEGED
,
4115 .translate
= translate_rsr
,
4116 .test_exceptions
= test_exceptions_hpi
,
4117 .par
= (const uint32_t[]){
4119 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4121 .op_flags
= XTENSA_OP_PRIVILEGED
,
4124 .translate
= translate_rsr
,
4125 .test_exceptions
= test_exceptions_hpi
,
4126 .par
= (const uint32_t[]){
4128 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4130 .op_flags
= XTENSA_OP_PRIVILEGED
,
4133 .translate
= translate_rsr
,
4134 .test_exceptions
= test_exceptions_hpi
,
4135 .par
= (const uint32_t[]){
4137 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4139 .op_flags
= XTENSA_OP_PRIVILEGED
,
4142 .translate
= translate_rsr
,
4143 .test_exceptions
= test_exceptions_hpi
,
4144 .par
= (const uint32_t[]){
4146 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4148 .op_flags
= XTENSA_OP_PRIVILEGED
,
4151 .translate
= translate_rsr
,
4152 .test_exceptions
= test_exceptions_hpi
,
4153 .par
= (const uint32_t[]){
4155 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4157 .op_flags
= XTENSA_OP_PRIVILEGED
,
4160 .translate
= translate_rsr
,
4161 .test_exceptions
= test_exceptions_hpi
,
4162 .par
= (const uint32_t[]){
4164 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4166 .op_flags
= XTENSA_OP_PRIVILEGED
,
4169 .translate
= translate_rsr
,
4170 .test_exceptions
= test_exceptions_hpi
,
4171 .par
= (const uint32_t[]){
4173 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4175 .op_flags
= XTENSA_OP_PRIVILEGED
,
4178 .translate
= translate_rsr
,
4179 .test_exceptions
= test_exceptions_hpi
,
4180 .par
= (const uint32_t[]){
4182 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4184 .op_flags
= XTENSA_OP_PRIVILEGED
,
4187 .translate
= translate_rsr
,
4188 .test_exceptions
= test_exceptions_hpi
,
4189 .par
= (const uint32_t[]){
4191 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4193 .op_flags
= XTENSA_OP_PRIVILEGED
,
4196 .translate
= translate_rsr
,
4197 .test_exceptions
= test_exceptions_hpi
,
4198 .par
= (const uint32_t[]){
4200 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4202 .op_flags
= XTENSA_OP_PRIVILEGED
,
4205 .translate
= translate_rsr
,
4206 .test_exceptions
= test_exceptions_hpi
,
4207 .par
= (const uint32_t[]){
4209 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4211 .op_flags
= XTENSA_OP_PRIVILEGED
,
4213 .name
= "rsr.eraccess",
4214 .translate
= translate_rsr
,
4215 .par
= (const uint32_t[]){ERACCESS
},
4216 .op_flags
= XTENSA_OP_PRIVILEGED
,
4218 .name
= "rsr.exccause",
4219 .translate
= translate_rsr
,
4220 .test_exceptions
= test_exceptions_sr
,
4221 .par
= (const uint32_t[]){
4223 XTENSA_OPTION_EXCEPTION
,
4225 .op_flags
= XTENSA_OP_PRIVILEGED
,
4227 .name
= "rsr.excsave1",
4228 .translate
= translate_rsr
,
4229 .test_exceptions
= test_exceptions_sr
,
4230 .par
= (const uint32_t[]){
4232 XTENSA_OPTION_EXCEPTION
,
4234 .op_flags
= XTENSA_OP_PRIVILEGED
,
4236 .name
= "rsr.excsave2",
4237 .translate
= translate_rsr
,
4238 .test_exceptions
= test_exceptions_hpi
,
4239 .par
= (const uint32_t[]){
4241 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4243 .op_flags
= XTENSA_OP_PRIVILEGED
,
4245 .name
= "rsr.excsave3",
4246 .translate
= translate_rsr
,
4247 .test_exceptions
= test_exceptions_hpi
,
4248 .par
= (const uint32_t[]){
4250 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4252 .op_flags
= XTENSA_OP_PRIVILEGED
,
4254 .name
= "rsr.excsave4",
4255 .translate
= translate_rsr
,
4256 .test_exceptions
= test_exceptions_hpi
,
4257 .par
= (const uint32_t[]){
4259 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4261 .op_flags
= XTENSA_OP_PRIVILEGED
,
4263 .name
= "rsr.excsave5",
4264 .translate
= translate_rsr
,
4265 .test_exceptions
= test_exceptions_hpi
,
4266 .par
= (const uint32_t[]){
4268 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4270 .op_flags
= XTENSA_OP_PRIVILEGED
,
4272 .name
= "rsr.excsave6",
4273 .translate
= translate_rsr
,
4274 .test_exceptions
= test_exceptions_hpi
,
4275 .par
= (const uint32_t[]){
4277 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4279 .op_flags
= XTENSA_OP_PRIVILEGED
,
4281 .name
= "rsr.excsave7",
4282 .translate
= translate_rsr
,
4283 .test_exceptions
= test_exceptions_hpi
,
4284 .par
= (const uint32_t[]){
4286 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4288 .op_flags
= XTENSA_OP_PRIVILEGED
,
4290 .name
= "rsr.excvaddr",
4291 .translate
= translate_rsr
,
4292 .test_exceptions
= test_exceptions_sr
,
4293 .par
= (const uint32_t[]){
4295 XTENSA_OPTION_EXCEPTION
,
4297 .op_flags
= XTENSA_OP_PRIVILEGED
,
4299 .name
= "rsr.ibreaka0",
4300 .translate
= translate_rsr
,
4301 .test_exceptions
= test_exceptions_ibreak
,
4302 .par
= (const uint32_t[]){
4304 XTENSA_OPTION_DEBUG
,
4306 .op_flags
= XTENSA_OP_PRIVILEGED
,
4308 .name
= "rsr.ibreaka1",
4309 .translate
= translate_rsr
,
4310 .test_exceptions
= test_exceptions_ibreak
,
4311 .par
= (const uint32_t[]){
4313 XTENSA_OPTION_DEBUG
,
4315 .op_flags
= XTENSA_OP_PRIVILEGED
,
4317 .name
= "rsr.ibreakenable",
4318 .translate
= translate_rsr
,
4319 .test_exceptions
= test_exceptions_sr
,
4320 .par
= (const uint32_t[]){
4322 XTENSA_OPTION_DEBUG
,
4324 .op_flags
= XTENSA_OP_PRIVILEGED
,
4326 .name
= "rsr.icount",
4327 .translate
= translate_rsr
,
4328 .test_exceptions
= test_exceptions_sr
,
4329 .par
= (const uint32_t[]){
4331 XTENSA_OPTION_DEBUG
,
4333 .op_flags
= XTENSA_OP_PRIVILEGED
,
4335 .name
= "rsr.icountlevel",
4336 .translate
= translate_rsr
,
4337 .test_exceptions
= test_exceptions_sr
,
4338 .par
= (const uint32_t[]){
4340 XTENSA_OPTION_DEBUG
,
4342 .op_flags
= XTENSA_OP_PRIVILEGED
,
4344 .name
= "rsr.intclear",
4345 .translate
= translate_rsr
,
4346 .test_exceptions
= test_exceptions_sr
,
4347 .par
= (const uint32_t[]){
4349 XTENSA_OPTION_INTERRUPT
,
4351 .op_flags
= XTENSA_OP_PRIVILEGED
,
4353 .name
= "rsr.intenable",
4354 .translate
= translate_rsr
,
4355 .test_exceptions
= test_exceptions_sr
,
4356 .par
= (const uint32_t[]){
4358 XTENSA_OPTION_INTERRUPT
,
4360 .op_flags
= XTENSA_OP_PRIVILEGED
,
4362 .name
= "rsr.interrupt",
4363 .translate
= translate_rsr_ccount
,
4364 .test_exceptions
= test_exceptions_sr
,
4365 .par
= (const uint32_t[]){
4367 XTENSA_OPTION_INTERRUPT
,
4369 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
4371 .name
= "rsr.intset",
4372 .translate
= translate_rsr_ccount
,
4373 .test_exceptions
= test_exceptions_sr
,
4374 .par
= (const uint32_t[]){
4376 XTENSA_OPTION_INTERRUPT
,
4378 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
4380 .name
= "rsr.itlbcfg",
4381 .translate
= translate_rsr
,
4382 .test_exceptions
= test_exceptions_sr
,
4383 .par
= (const uint32_t[]){
4387 .op_flags
= XTENSA_OP_PRIVILEGED
,
4390 .translate
= translate_rsr
,
4391 .test_exceptions
= test_exceptions_sr
,
4392 .par
= (const uint32_t[]){
4397 .name
= "rsr.lcount",
4398 .translate
= translate_rsr
,
4399 .test_exceptions
= test_exceptions_sr
,
4400 .par
= (const uint32_t[]){
4406 .translate
= translate_rsr
,
4407 .test_exceptions
= test_exceptions_sr
,
4408 .par
= (const uint32_t[]){
4413 .name
= "rsr.litbase",
4414 .translate
= translate_rsr
,
4415 .test_exceptions
= test_exceptions_sr
,
4416 .par
= (const uint32_t[]){
4418 XTENSA_OPTION_EXTENDED_L32R
,
4422 .translate
= translate_rsr
,
4423 .test_exceptions
= test_exceptions_sr
,
4424 .par
= (const uint32_t[]){
4426 XTENSA_OPTION_MAC16
,
4430 .translate
= translate_rsr
,
4431 .test_exceptions
= test_exceptions_sr
,
4432 .par
= (const uint32_t[]){
4434 XTENSA_OPTION_MAC16
,
4438 .translate
= translate_rsr
,
4439 .test_exceptions
= test_exceptions_sr
,
4440 .par
= (const uint32_t[]){
4442 XTENSA_OPTION_MAC16
,
4446 .translate
= translate_rsr
,
4447 .test_exceptions
= test_exceptions_sr
,
4448 .par
= (const uint32_t[]){
4450 XTENSA_OPTION_MAC16
,
4453 .name
= "rsr.memctl",
4454 .translate
= translate_rsr
,
4455 .par
= (const uint32_t[]){MEMCTL
},
4456 .op_flags
= XTENSA_OP_PRIVILEGED
,
4459 .translate
= translate_rsr
,
4460 .test_exceptions
= test_exceptions_sr
,
4461 .par
= (const uint32_t[]){
4463 XTENSA_OPTION_MEMORY_ECC_PARITY
,
4465 .op_flags
= XTENSA_OP_PRIVILEGED
,
4468 .translate
= translate_rsr
,
4469 .test_exceptions
= test_exceptions_sr
,
4470 .par
= (const uint32_t[]){
4472 XTENSA_OPTION_MEMORY_ECC_PARITY
,
4474 .op_flags
= XTENSA_OP_PRIVILEGED
,
4477 .translate
= translate_rsr
,
4478 .test_exceptions
= test_exceptions_sr
,
4479 .par
= (const uint32_t[]){
4481 XTENSA_OPTION_MEMORY_ECC_PARITY
,
4483 .op_flags
= XTENSA_OP_PRIVILEGED
,
4485 .name
= "rsr.mesave",
4486 .translate
= translate_rsr
,
4487 .test_exceptions
= test_exceptions_sr
,
4488 .par
= (const uint32_t[]){
4490 XTENSA_OPTION_MEMORY_ECC_PARITY
,
4492 .op_flags
= XTENSA_OP_PRIVILEGED
,
4495 .translate
= translate_rsr
,
4496 .test_exceptions
= test_exceptions_sr
,
4497 .par
= (const uint32_t[]){
4499 XTENSA_OPTION_MEMORY_ECC_PARITY
,
4501 .op_flags
= XTENSA_OP_PRIVILEGED
,
4503 .name
= "rsr.mevaddr",
4504 .translate
= translate_rsr
,
4505 .test_exceptions
= test_exceptions_sr
,
4506 .par
= (const uint32_t[]){
4508 XTENSA_OPTION_MEMORY_ECC_PARITY
,
4510 .op_flags
= XTENSA_OP_PRIVILEGED
,
4512 .name
= "rsr.misc0",
4513 .translate
= translate_rsr
,
4514 .test_exceptions
= test_exceptions_sr
,
4515 .par
= (const uint32_t[]){
4517 XTENSA_OPTION_MISC_SR
,
4519 .op_flags
= XTENSA_OP_PRIVILEGED
,
4521 .name
= "rsr.misc1",
4522 .translate
= translate_rsr
,
4523 .test_exceptions
= test_exceptions_sr
,
4524 .par
= (const uint32_t[]){
4526 XTENSA_OPTION_MISC_SR
,
4528 .op_flags
= XTENSA_OP_PRIVILEGED
,
4530 .name
= "rsr.misc2",
4531 .translate
= translate_rsr
,
4532 .test_exceptions
= test_exceptions_sr
,
4533 .par
= (const uint32_t[]){
4535 XTENSA_OPTION_MISC_SR
,
4537 .op_flags
= XTENSA_OP_PRIVILEGED
,
4539 .name
= "rsr.misc3",
4540 .translate
= translate_rsr
,
4541 .test_exceptions
= test_exceptions_sr
,
4542 .par
= (const uint32_t[]){
4544 XTENSA_OPTION_MISC_SR
,
4546 .op_flags
= XTENSA_OP_PRIVILEGED
,
4548 .name
= "rsr.mpucfg",
4549 .translate
= translate_rsr
,
4550 .test_exceptions
= test_exceptions_sr
,
4551 .par
= (const uint32_t[]){
4555 .op_flags
= XTENSA_OP_PRIVILEGED
,
4557 .name
= "rsr.mpuenb",
4558 .translate
= translate_rsr
,
4559 .test_exceptions
= test_exceptions_sr
,
4560 .par
= (const uint32_t[]){
4564 .op_flags
= XTENSA_OP_PRIVILEGED
,
4566 .name
= "rsr.prefctl",
4567 .translate
= translate_rsr
,
4568 .par
= (const uint32_t[]){PREFCTL
},
4571 .translate
= translate_rsr
,
4572 .test_exceptions
= test_exceptions_sr
,
4573 .par
= (const uint32_t[]){
4575 XTENSA_OPTION_PROCESSOR_ID
,
4577 .op_flags
= XTENSA_OP_PRIVILEGED
,
4580 .translate
= translate_rsr
,
4581 .test_exceptions
= test_exceptions_sr
,
4582 .par
= (const uint32_t[]){
4584 XTENSA_OPTION_EXCEPTION
,
4586 .op_flags
= XTENSA_OP_PRIVILEGED
,
4588 .name
= "rsr.ptevaddr",
4589 .translate
= translate_rsr_ptevaddr
,
4590 .test_exceptions
= test_exceptions_sr
,
4591 .par
= (const uint32_t[]){
4595 .op_flags
= XTENSA_OP_PRIVILEGED
,
4597 .name
= "rsr.rasid",
4598 .translate
= translate_rsr
,
4599 .test_exceptions
= test_exceptions_sr
,
4600 .par
= (const uint32_t[]){
4604 .op_flags
= XTENSA_OP_PRIVILEGED
,
4607 .translate
= translate_rsr
,
4608 .par
= (const uint32_t[]){SAR
},
4610 .name
= "rsr.scompare1",
4611 .translate
= translate_rsr
,
4612 .test_exceptions
= test_exceptions_sr
,
4613 .par
= (const uint32_t[]){
4615 XTENSA_OPTION_CONDITIONAL_STORE
,
4618 .name
= "rsr.vecbase",
4619 .translate
= translate_rsr
,
4620 .test_exceptions
= test_exceptions_sr
,
4621 .par
= (const uint32_t[]){
4623 XTENSA_OPTION_RELOCATABLE_VECTOR
,
4625 .op_flags
= XTENSA_OP_PRIVILEGED
,
4627 .name
= "rsr.windowbase",
4628 .translate
= translate_rsr
,
4629 .test_exceptions
= test_exceptions_sr
,
4630 .par
= (const uint32_t[]){
4632 XTENSA_OPTION_WINDOWED_REGISTER
,
4634 .op_flags
= XTENSA_OP_PRIVILEGED
,
4636 .name
= "rsr.windowstart",
4637 .translate
= translate_rsr
,
4638 .test_exceptions
= test_exceptions_sr
,
4639 .par
= (const uint32_t[]){
4641 XTENSA_OPTION_WINDOWED_REGISTER
,
4643 .op_flags
= XTENSA_OP_PRIVILEGED
,
4646 .translate
= translate_nop
,
4648 .name
= "rur.expstate",
4649 .translate
= translate_rur
,
4650 .par
= (const uint32_t[]){EXPSTATE
},
4652 .name
= "rur.threadptr",
4653 .translate
= translate_rur
,
4654 .par
= (const uint32_t[]){THREADPTR
},
4657 .translate
= translate_ldst
,
4658 .par
= (const uint32_t[]){MO_TEUW
, false, true},
4659 .op_flags
= XTENSA_OP_STORE
,
4662 .translate
= translate_s32c1i
,
4663 .op_flags
= XTENSA_OP_LOAD
| XTENSA_OP_STORE
,
4666 .translate
= translate_s32e
,
4667 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_STORE
,
4670 .translate
= translate_s32ex
,
4671 .op_flags
= XTENSA_OP_LOAD
| XTENSA_OP_STORE
,
4673 .name
= (const char * const[]) {
4674 "s32i", "s32i.n", "s32nb", NULL
,
4676 .translate
= translate_ldst
,
4677 .par
= (const uint32_t[]){MO_TEUL
, false, true},
4678 .op_flags
= XTENSA_OP_NAME_ARRAY
| XTENSA_OP_STORE
,
4681 .translate
= translate_ldst
,
4682 .par
= (const uint32_t[]){MO_TEUL
| MO_ALIGN
, true, true},
4683 .op_flags
= XTENSA_OP_STORE
,
4686 .translate
= translate_ldst
,
4687 .par
= (const uint32_t[]){MO_UB
, false, true},
4688 .op_flags
= XTENSA_OP_STORE
,
4691 .translate
= translate_salt
,
4692 .par
= (const uint32_t[]){TCG_COND_LT
},
4695 .translate
= translate_salt
,
4696 .par
= (const uint32_t[]){TCG_COND_LTU
},
4698 .name
= "setb_expstate",
4699 .translate
= translate_setb_expstate
,
4702 .translate
= translate_sext
,
4705 .translate
= translate_simcall
,
4706 .test_exceptions
= test_exceptions_simcall
,
4707 .op_flags
= XTENSA_OP_PRIVILEGED
,
4710 .translate
= translate_sll
,
4713 .translate
= translate_slli
,
4716 .translate
= translate_sra
,
4719 .translate
= translate_srai
,
4722 .translate
= translate_src
,
4725 .translate
= translate_srl
,
4728 .translate
= translate_srli
,
4731 .translate
= translate_ssa8b
,
4734 .translate
= translate_ssa8l
,
4737 .translate
= translate_ssai
,
4740 .translate
= translate_ssl
,
4743 .translate
= translate_ssr
,
4746 .translate
= translate_sub
,
4749 .translate
= translate_subx
,
4750 .par
= (const uint32_t[]){1},
4753 .translate
= translate_subx
,
4754 .par
= (const uint32_t[]){2},
4757 .translate
= translate_subx
,
4758 .par
= (const uint32_t[]){3},
4761 .op_flags
= XTENSA_OP_SYSCALL
,
4763 .name
= "umul.aa.hh",
4764 .translate
= translate_mac16
,
4765 .par
= (const uint32_t[]){MAC16_UMUL
, MAC16_HH
, 0},
4767 .name
= "umul.aa.hl",
4768 .translate
= translate_mac16
,
4769 .par
= (const uint32_t[]){MAC16_UMUL
, MAC16_HL
, 0},
4771 .name
= "umul.aa.lh",
4772 .translate
= translate_mac16
,
4773 .par
= (const uint32_t[]){MAC16_UMUL
, MAC16_LH
, 0},
4775 .name
= "umul.aa.ll",
4776 .translate
= translate_mac16
,
4777 .par
= (const uint32_t[]){MAC16_UMUL
, MAC16_LL
, 0},
4780 .translate
= translate_waiti
,
4781 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
4784 .translate
= translate_wtlb
,
4785 .par
= (const uint32_t[]){true},
4786 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
4789 .translate
= translate_wer
,
4790 .op_flags
= XTENSA_OP_PRIVILEGED
,
4793 .translate
= translate_wtlb
,
4794 .par
= (const uint32_t[]){false},
4795 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
4798 .translate
= translate_wptlb
,
4799 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
4801 .name
= "wrmsk_expstate",
4802 .translate
= translate_wrmsk_expstate
,
4805 .op_flags
= XTENSA_OP_ILL
,
4808 .op_flags
= XTENSA_OP_ILL
,
4810 .name
= "wsr.acchi",
4811 .translate
= translate_wsr_acchi
,
4812 .test_exceptions
= test_exceptions_sr
,
4813 .par
= (const uint32_t[]){
4815 XTENSA_OPTION_MAC16
,
4818 .name
= "wsr.acclo",
4819 .translate
= translate_wsr
,
4820 .test_exceptions
= test_exceptions_sr
,
4821 .par
= (const uint32_t[]){
4823 XTENSA_OPTION_MAC16
,
4826 .name
= "wsr.atomctl",
4827 .translate
= translate_wsr_mask
,
4828 .test_exceptions
= test_exceptions_sr
,
4829 .par
= (const uint32_t[]){
4831 XTENSA_OPTION_ATOMCTL
,
4834 .op_flags
= XTENSA_OP_PRIVILEGED
,
4837 .translate
= translate_wsr_mask
,
4838 .test_exceptions
= test_exceptions_sr
,
4839 .par
= (const uint32_t[]){
4841 XTENSA_OPTION_BOOLEAN
,
4845 .name
= "wsr.cacheadrdis",
4846 .translate
= translate_wsr_mask
,
4847 .test_exceptions
= test_exceptions_sr
,
4848 .par
= (const uint32_t[]){
4853 .op_flags
= XTENSA_OP_PRIVILEGED
,
4855 .name
= "wsr.cacheattr",
4856 .translate
= translate_wsr
,
4857 .test_exceptions
= test_exceptions_sr
,
4858 .par
= (const uint32_t[]){
4860 XTENSA_OPTION_CACHEATTR
,
4862 .op_flags
= XTENSA_OP_PRIVILEGED
,
4864 .name
= "wsr.ccompare0",
4865 .translate
= translate_wsr_ccompare
,
4866 .test_exceptions
= test_exceptions_ccompare
,
4867 .par
= (const uint32_t[]){
4869 XTENSA_OPTION_TIMER_INTERRUPT
,
4871 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
4873 .name
= "wsr.ccompare1",
4874 .translate
= translate_wsr_ccompare
,
4875 .test_exceptions
= test_exceptions_ccompare
,
4876 .par
= (const uint32_t[]){
4878 XTENSA_OPTION_TIMER_INTERRUPT
,
4880 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
4882 .name
= "wsr.ccompare2",
4883 .translate
= translate_wsr_ccompare
,
4884 .test_exceptions
= test_exceptions_ccompare
,
4885 .par
= (const uint32_t[]){
4887 XTENSA_OPTION_TIMER_INTERRUPT
,
4889 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
4891 .name
= "wsr.ccount",
4892 .translate
= translate_wsr_ccount
,
4893 .test_exceptions
= test_exceptions_sr
,
4894 .par
= (const uint32_t[]){
4896 XTENSA_OPTION_TIMER_INTERRUPT
,
4898 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
4900 .name
= "wsr.configid0",
4901 .op_flags
= XTENSA_OP_ILL
,
4903 .name
= "wsr.configid1",
4904 .op_flags
= XTENSA_OP_ILL
,
4906 .name
= "wsr.cpenable",
4907 .translate
= translate_wsr_mask
,
4908 .test_exceptions
= test_exceptions_sr
,
4909 .par
= (const uint32_t[]){
4911 XTENSA_OPTION_COPROCESSOR
,
4914 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
4916 .name
= "wsr.dbreaka0",
4917 .translate
= translate_wsr_dbreaka
,
4918 .test_exceptions
= test_exceptions_dbreak
,
4919 .par
= (const uint32_t[]){
4921 XTENSA_OPTION_DEBUG
,
4923 .op_flags
= XTENSA_OP_PRIVILEGED
,
4925 .name
= "wsr.dbreaka1",
4926 .translate
= translate_wsr_dbreaka
,
4927 .test_exceptions
= test_exceptions_dbreak
,
4928 .par
= (const uint32_t[]){
4930 XTENSA_OPTION_DEBUG
,
4932 .op_flags
= XTENSA_OP_PRIVILEGED
,
4934 .name
= "wsr.dbreakc0",
4935 .translate
= translate_wsr_dbreakc
,
4936 .test_exceptions
= test_exceptions_dbreak
,
4937 .par
= (const uint32_t[]){
4939 XTENSA_OPTION_DEBUG
,
4941 .op_flags
= XTENSA_OP_PRIVILEGED
,
4943 .name
= "wsr.dbreakc1",
4944 .translate
= translate_wsr_dbreakc
,
4945 .test_exceptions
= test_exceptions_dbreak
,
4946 .par
= (const uint32_t[]){
4948 XTENSA_OPTION_DEBUG
,
4950 .op_flags
= XTENSA_OP_PRIVILEGED
,
4953 .translate
= translate_wsr
,
4954 .test_exceptions
= test_exceptions_sr
,
4955 .par
= (const uint32_t[]){
4957 XTENSA_OPTION_DEBUG
,
4959 .op_flags
= XTENSA_OP_PRIVILEGED
,
4961 .name
= "wsr.debugcause",
4962 .op_flags
= XTENSA_OP_ILL
,
4965 .translate
= translate_wsr
,
4966 .test_exceptions
= test_exceptions_sr
,
4967 .par
= (const uint32_t[]){
4969 XTENSA_OPTION_EXCEPTION
,
4971 .op_flags
= XTENSA_OP_PRIVILEGED
,
4973 .name
= "wsr.dtlbcfg",
4974 .translate
= translate_wsr_mask
,
4975 .test_exceptions
= test_exceptions_sr
,
4976 .par
= (const uint32_t[]){
4981 .op_flags
= XTENSA_OP_PRIVILEGED
,
4984 .translate
= translate_wsr
,
4985 .test_exceptions
= test_exceptions_sr
,
4986 .par
= (const uint32_t[]){
4988 XTENSA_OPTION_EXCEPTION
,
4990 .op_flags
= XTENSA_OP_PRIVILEGED
,
4993 .translate
= translate_wsr
,
4994 .test_exceptions
= test_exceptions_hpi
,
4995 .par
= (const uint32_t[]){
4997 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4999 .op_flags
= XTENSA_OP_PRIVILEGED
,
5002 .translate
= translate_wsr
,
5003 .test_exceptions
= test_exceptions_hpi
,
5004 .par
= (const uint32_t[]){
5006 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5008 .op_flags
= XTENSA_OP_PRIVILEGED
,
5011 .translate
= translate_wsr
,
5012 .test_exceptions
= test_exceptions_hpi
,
5013 .par
= (const uint32_t[]){
5015 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5017 .op_flags
= XTENSA_OP_PRIVILEGED
,
5020 .translate
= translate_wsr
,
5021 .test_exceptions
= test_exceptions_hpi
,
5022 .par
= (const uint32_t[]){
5024 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5026 .op_flags
= XTENSA_OP_PRIVILEGED
,
5029 .translate
= translate_wsr
,
5030 .test_exceptions
= test_exceptions_hpi
,
5031 .par
= (const uint32_t[]){
5033 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5035 .op_flags
= XTENSA_OP_PRIVILEGED
,
5038 .translate
= translate_wsr
,
5039 .test_exceptions
= test_exceptions_hpi
,
5040 .par
= (const uint32_t[]){
5042 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5044 .op_flags
= XTENSA_OP_PRIVILEGED
,
5047 .translate
= translate_wsr
,
5048 .test_exceptions
= test_exceptions_hpi
,
5049 .par
= (const uint32_t[]){
5051 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5053 .op_flags
= XTENSA_OP_PRIVILEGED
,
5056 .translate
= translate_wsr
,
5057 .test_exceptions
= test_exceptions_hpi
,
5058 .par
= (const uint32_t[]){
5060 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5062 .op_flags
= XTENSA_OP_PRIVILEGED
,
5065 .translate
= translate_wsr
,
5066 .test_exceptions
= test_exceptions_hpi
,
5067 .par
= (const uint32_t[]){
5069 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5071 .op_flags
= XTENSA_OP_PRIVILEGED
,
5074 .translate
= translate_wsr
,
5075 .test_exceptions
= test_exceptions_hpi
,
5076 .par
= (const uint32_t[]){
5078 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5080 .op_flags
= XTENSA_OP_PRIVILEGED
,
5083 .translate
= translate_wsr
,
5084 .test_exceptions
= test_exceptions_hpi
,
5085 .par
= (const uint32_t[]){
5087 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5089 .op_flags
= XTENSA_OP_PRIVILEGED
,
5092 .translate
= translate_wsr
,
5093 .test_exceptions
= test_exceptions_hpi
,
5094 .par
= (const uint32_t[]){
5096 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5098 .op_flags
= XTENSA_OP_PRIVILEGED
,
5100 .name
= "wsr.eraccess",
5101 .translate
= translate_wsr_mask
,
5102 .par
= (const uint32_t[]){
5107 .op_flags
= XTENSA_OP_PRIVILEGED
,
5109 .name
= "wsr.exccause",
5110 .translate
= translate_wsr
,
5111 .test_exceptions
= test_exceptions_sr
,
5112 .par
= (const uint32_t[]){
5114 XTENSA_OPTION_EXCEPTION
,
5116 .op_flags
= XTENSA_OP_PRIVILEGED
,
5118 .name
= "wsr.excsave1",
5119 .translate
= translate_wsr
,
5120 .test_exceptions
= test_exceptions_sr
,
5121 .par
= (const uint32_t[]){
5123 XTENSA_OPTION_EXCEPTION
,
5125 .op_flags
= XTENSA_OP_PRIVILEGED
,
5127 .name
= "wsr.excsave2",
5128 .translate
= translate_wsr
,
5129 .test_exceptions
= test_exceptions_hpi
,
5130 .par
= (const uint32_t[]){
5132 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5134 .op_flags
= XTENSA_OP_PRIVILEGED
,
5136 .name
= "wsr.excsave3",
5137 .translate
= translate_wsr
,
5138 .test_exceptions
= test_exceptions_hpi
,
5139 .par
= (const uint32_t[]){
5141 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5143 .op_flags
= XTENSA_OP_PRIVILEGED
,
5145 .name
= "wsr.excsave4",
5146 .translate
= translate_wsr
,
5147 .test_exceptions
= test_exceptions_hpi
,
5148 .par
= (const uint32_t[]){
5150 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5152 .op_flags
= XTENSA_OP_PRIVILEGED
,
5154 .name
= "wsr.excsave5",
5155 .translate
= translate_wsr
,
5156 .test_exceptions
= test_exceptions_hpi
,
5157 .par
= (const uint32_t[]){
5159 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5161 .op_flags
= XTENSA_OP_PRIVILEGED
,
5163 .name
= "wsr.excsave6",
5164 .translate
= translate_wsr
,
5165 .test_exceptions
= test_exceptions_hpi
,
5166 .par
= (const uint32_t[]){
5168 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5170 .op_flags
= XTENSA_OP_PRIVILEGED
,
5172 .name
= "wsr.excsave7",
5173 .translate
= translate_wsr
,
5174 .test_exceptions
= test_exceptions_hpi
,
5175 .par
= (const uint32_t[]){
5177 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5179 .op_flags
= XTENSA_OP_PRIVILEGED
,
5181 .name
= "wsr.excvaddr",
5182 .translate
= translate_wsr
,
5183 .test_exceptions
= test_exceptions_sr
,
5184 .par
= (const uint32_t[]){
5186 XTENSA_OPTION_EXCEPTION
,
5188 .op_flags
= XTENSA_OP_PRIVILEGED
,
5190 .name
= "wsr.ibreaka0",
5191 .translate
= translate_wsr_ibreaka
,
5192 .test_exceptions
= test_exceptions_ibreak
,
5193 .par
= (const uint32_t[]){
5195 XTENSA_OPTION_DEBUG
,
5197 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
5199 .name
= "wsr.ibreaka1",
5200 .translate
= translate_wsr_ibreaka
,
5201 .test_exceptions
= test_exceptions_ibreak
,
5202 .par
= (const uint32_t[]){
5204 XTENSA_OPTION_DEBUG
,
5206 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
5208 .name
= "wsr.ibreakenable",
5209 .translate
= translate_wsr_ibreakenable
,
5210 .test_exceptions
= test_exceptions_sr
,
5211 .par
= (const uint32_t[]){
5213 XTENSA_OPTION_DEBUG
,
5215 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
5217 .name
= "wsr.icount",
5218 .translate
= translate_wsr_icount
,
5219 .test_exceptions
= test_exceptions_sr
,
5220 .par
= (const uint32_t[]){
5222 XTENSA_OPTION_DEBUG
,
5224 .op_flags
= XTENSA_OP_PRIVILEGED
,
5226 .name
= "wsr.icountlevel",
5227 .translate
= translate_wsr_mask
,
5228 .test_exceptions
= test_exceptions_sr
,
5229 .par
= (const uint32_t[]){
5231 XTENSA_OPTION_DEBUG
,
5234 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
5236 .name
= "wsr.intclear",
5237 .translate
= translate_wsr_intclear
,
5238 .test_exceptions
= test_exceptions_sr
,
5239 .par
= (const uint32_t[]){
5241 XTENSA_OPTION_INTERRUPT
,
5244 XTENSA_OP_PRIVILEGED
|
5245 XTENSA_OP_EXIT_TB_0
|
5246 XTENSA_OP_CHECK_INTERRUPTS
,
5248 .name
= "wsr.intenable",
5249 .translate
= translate_wsr
,
5250 .test_exceptions
= test_exceptions_sr
,
5251 .par
= (const uint32_t[]){
5253 XTENSA_OPTION_INTERRUPT
,
5256 XTENSA_OP_PRIVILEGED
|
5257 XTENSA_OP_EXIT_TB_0
|
5258 XTENSA_OP_CHECK_INTERRUPTS
,
5260 .name
= "wsr.interrupt",
5261 .translate
= translate_wsr
,
5262 .test_exceptions
= test_exceptions_sr
,
5263 .par
= (const uint32_t[]){
5265 XTENSA_OPTION_INTERRUPT
,
5268 XTENSA_OP_PRIVILEGED
|
5269 XTENSA_OP_EXIT_TB_0
|
5270 XTENSA_OP_CHECK_INTERRUPTS
,
5272 .name
= "wsr.intset",
5273 .translate
= translate_wsr_intset
,
5274 .test_exceptions
= test_exceptions_sr
,
5275 .par
= (const uint32_t[]){
5277 XTENSA_OPTION_INTERRUPT
,
5280 XTENSA_OP_PRIVILEGED
|
5281 XTENSA_OP_EXIT_TB_0
|
5282 XTENSA_OP_CHECK_INTERRUPTS
,
5284 .name
= "wsr.itlbcfg",
5285 .translate
= translate_wsr_mask
,
5286 .test_exceptions
= test_exceptions_sr
,
5287 .par
= (const uint32_t[]){
5292 .op_flags
= XTENSA_OP_PRIVILEGED
,
5295 .translate
= translate_wsr
,
5296 .test_exceptions
= test_exceptions_sr
,
5297 .par
= (const uint32_t[]){
5301 .op_flags
= XTENSA_OP_EXIT_TB_M1
,
5303 .name
= "wsr.lcount",
5304 .translate
= translate_wsr
,
5305 .test_exceptions
= test_exceptions_sr
,
5306 .par
= (const uint32_t[]){
5312 .translate
= translate_wsr
,
5313 .test_exceptions
= test_exceptions_sr
,
5314 .par
= (const uint32_t[]){
5318 .op_flags
= XTENSA_OP_EXIT_TB_M1
,
5320 .name
= "wsr.litbase",
5321 .translate
= translate_wsr_mask
,
5322 .test_exceptions
= test_exceptions_sr
,
5323 .par
= (const uint32_t[]){
5325 XTENSA_OPTION_EXTENDED_L32R
,
5328 .op_flags
= XTENSA_OP_EXIT_TB_M1
,
5331 .translate
= translate_wsr
,
5332 .test_exceptions
= test_exceptions_sr
,
5333 .par
= (const uint32_t[]){
5335 XTENSA_OPTION_MAC16
,
5339 .translate
= translate_wsr
,
5340 .test_exceptions
= test_exceptions_sr
,
5341 .par
= (const uint32_t[]){
5343 XTENSA_OPTION_MAC16
,
5347 .translate
= translate_wsr
,
5348 .test_exceptions
= test_exceptions_sr
,
5349 .par
= (const uint32_t[]){
5351 XTENSA_OPTION_MAC16
,
5355 .translate
= translate_wsr
,
5356 .test_exceptions
= test_exceptions_sr
,
5357 .par
= (const uint32_t[]){
5359 XTENSA_OPTION_MAC16
,
5362 .name
= "wsr.memctl",
5363 .translate
= translate_wsr_memctl
,
5364 .par
= (const uint32_t[]){MEMCTL
},
5365 .op_flags
= XTENSA_OP_PRIVILEGED
,
5368 .translate
= translate_wsr
,
5369 .test_exceptions
= test_exceptions_sr
,
5370 .par
= (const uint32_t[]){
5372 XTENSA_OPTION_MEMORY_ECC_PARITY
,
5374 .op_flags
= XTENSA_OP_PRIVILEGED
,
5377 .translate
= translate_wsr
,
5378 .test_exceptions
= test_exceptions_sr
,
5379 .par
= (const uint32_t[]){
5381 XTENSA_OPTION_MEMORY_ECC_PARITY
,
5383 .op_flags
= XTENSA_OP_PRIVILEGED
,
5386 .translate
= translate_wsr
,
5387 .test_exceptions
= test_exceptions_sr
,
5388 .par
= (const uint32_t[]){
5390 XTENSA_OPTION_MEMORY_ECC_PARITY
,
5392 .op_flags
= XTENSA_OP_PRIVILEGED
,
5394 .name
= "wsr.mesave",
5395 .translate
= translate_wsr
,
5396 .test_exceptions
= test_exceptions_sr
,
5397 .par
= (const uint32_t[]){
5399 XTENSA_OPTION_MEMORY_ECC_PARITY
,
5401 .op_flags
= XTENSA_OP_PRIVILEGED
,
5404 .translate
= translate_wsr
,
5405 .test_exceptions
= test_exceptions_sr
,
5406 .par
= (const uint32_t[]){
5408 XTENSA_OPTION_MEMORY_ECC_PARITY
,
5410 .op_flags
= XTENSA_OP_PRIVILEGED
,
5412 .name
= "wsr.mevaddr",
5413 .translate
= translate_wsr
,
5414 .test_exceptions
= test_exceptions_sr
,
5415 .par
= (const uint32_t[]){
5417 XTENSA_OPTION_MEMORY_ECC_PARITY
,
5419 .op_flags
= XTENSA_OP_PRIVILEGED
,
5421 .name
= "wsr.misc0",
5422 .translate
= translate_wsr
,
5423 .test_exceptions
= test_exceptions_sr
,
5424 .par
= (const uint32_t[]){
5426 XTENSA_OPTION_MISC_SR
,
5428 .op_flags
= XTENSA_OP_PRIVILEGED
,
5430 .name
= "wsr.misc1",
5431 .translate
= translate_wsr
,
5432 .test_exceptions
= test_exceptions_sr
,
5433 .par
= (const uint32_t[]){
5435 XTENSA_OPTION_MISC_SR
,
5437 .op_flags
= XTENSA_OP_PRIVILEGED
,
5439 .name
= "wsr.misc2",
5440 .translate
= translate_wsr
,
5441 .test_exceptions
= test_exceptions_sr
,
5442 .par
= (const uint32_t[]){
5444 XTENSA_OPTION_MISC_SR
,
5446 .op_flags
= XTENSA_OP_PRIVILEGED
,
5448 .name
= "wsr.misc3",
5449 .translate
= translate_wsr
,
5450 .test_exceptions
= test_exceptions_sr
,
5451 .par
= (const uint32_t[]){
5453 XTENSA_OPTION_MISC_SR
,
5455 .op_flags
= XTENSA_OP_PRIVILEGED
,
5458 .translate
= translate_wsr
,
5459 .test_exceptions
= test_exceptions_sr
,
5460 .par
= (const uint32_t[]){
5462 XTENSA_OPTION_TRACE_PORT
,
5464 .op_flags
= XTENSA_OP_PRIVILEGED
,
5466 .name
= "wsr.mpuenb",
5467 .translate
= translate_wsr_mpuenb
,
5468 .test_exceptions
= test_exceptions_sr
,
5469 .par
= (const uint32_t[]){
5473 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
5475 .name
= "wsr.prefctl",
5476 .translate
= translate_wsr
,
5477 .par
= (const uint32_t[]){PREFCTL
},
5480 .op_flags
= XTENSA_OP_ILL
,
5483 .translate
= translate_wsr_ps
,
5484 .test_exceptions
= test_exceptions_sr
,
5485 .par
= (const uint32_t[]){
5487 XTENSA_OPTION_EXCEPTION
,
5490 XTENSA_OP_PRIVILEGED
|
5491 XTENSA_OP_EXIT_TB_M1
|
5492 XTENSA_OP_CHECK_INTERRUPTS
,
5494 .name
= "wsr.ptevaddr",
5495 .translate
= translate_wsr_mask
,
5496 .test_exceptions
= test_exceptions_sr
,
5497 .par
= (const uint32_t[]){
5502 .op_flags
= XTENSA_OP_PRIVILEGED
,
5504 .name
= "wsr.rasid",
5505 .translate
= translate_wsr_rasid
,
5506 .test_exceptions
= test_exceptions_sr
,
5507 .par
= (const uint32_t[]){
5511 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
5514 .translate
= translate_wsr_sar
,
5515 .par
= (const uint32_t[]){SAR
},
5517 .name
= "wsr.scompare1",
5518 .translate
= translate_wsr
,
5519 .test_exceptions
= test_exceptions_sr
,
5520 .par
= (const uint32_t[]){
5522 XTENSA_OPTION_CONDITIONAL_STORE
,
5525 .name
= "wsr.vecbase",
5526 .translate
= translate_wsr
,
5527 .test_exceptions
= test_exceptions_sr
,
5528 .par
= (const uint32_t[]){
5530 XTENSA_OPTION_RELOCATABLE_VECTOR
,
5532 .op_flags
= XTENSA_OP_PRIVILEGED
,
5534 .name
= "wsr.windowbase",
5535 .translate
= translate_wsr_windowbase
,
5536 .test_exceptions
= test_exceptions_sr
,
5537 .par
= (const uint32_t[]){
5539 XTENSA_OPTION_WINDOWED_REGISTER
,
5541 .op_flags
= XTENSA_OP_PRIVILEGED
|
5542 XTENSA_OP_EXIT_TB_M1
|
5543 XTENSA_OP_SYNC_REGISTER_WINDOW
,
5545 .name
= "wsr.windowstart",
5546 .translate
= translate_wsr_windowstart
,
5547 .test_exceptions
= test_exceptions_sr
,
5548 .par
= (const uint32_t[]){
5550 XTENSA_OPTION_WINDOWED_REGISTER
,
5552 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
5554 .name
= "wur.expstate",
5555 .translate
= translate_wur
,
5556 .par
= (const uint32_t[]){EXPSTATE
},
5558 .name
= "wur.threadptr",
5559 .translate
= translate_wur
,
5560 .par
= (const uint32_t[]){THREADPTR
},
5563 .translate
= translate_xor
,
5566 .translate
= translate_boolean
,
5567 .par
= (const uint32_t[]){BOOLEAN_XOR
},
5570 .op_flags
= XTENSA_OP_ILL
,
5573 .op_flags
= XTENSA_OP_ILL
,
5575 .name
= "xsr.acchi",
5576 .translate
= translate_xsr_acchi
,
5577 .test_exceptions
= test_exceptions_sr
,
5578 .par
= (const uint32_t[]){
5580 XTENSA_OPTION_MAC16
,
5583 .name
= "xsr.acclo",
5584 .translate
= translate_xsr
,
5585 .test_exceptions
= test_exceptions_sr
,
5586 .par
= (const uint32_t[]){
5588 XTENSA_OPTION_MAC16
,
5591 .name
= "xsr.atomctl",
5592 .translate
= translate_xsr_mask
,
5593 .test_exceptions
= test_exceptions_sr
,
5594 .par
= (const uint32_t[]){
5596 XTENSA_OPTION_ATOMCTL
,
5599 .op_flags
= XTENSA_OP_PRIVILEGED
,
5602 .translate
= translate_xsr_mask
,
5603 .test_exceptions
= test_exceptions_sr
,
5604 .par
= (const uint32_t[]){
5606 XTENSA_OPTION_BOOLEAN
,
5610 .name
= "xsr.cacheadrdis",
5611 .translate
= translate_xsr_mask
,
5612 .test_exceptions
= test_exceptions_sr
,
5613 .par
= (const uint32_t[]){
5618 .op_flags
= XTENSA_OP_PRIVILEGED
,
5620 .name
= "xsr.cacheattr",
5621 .translate
= translate_xsr
,
5622 .test_exceptions
= test_exceptions_sr
,
5623 .par
= (const uint32_t[]){
5625 XTENSA_OPTION_CACHEATTR
,
5627 .op_flags
= XTENSA_OP_PRIVILEGED
,
5629 .name
= "xsr.ccompare0",
5630 .translate
= translate_xsr_ccompare
,
5631 .test_exceptions
= test_exceptions_ccompare
,
5632 .par
= (const uint32_t[]){
5634 XTENSA_OPTION_TIMER_INTERRUPT
,
5636 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
5638 .name
= "xsr.ccompare1",
5639 .translate
= translate_xsr_ccompare
,
5640 .test_exceptions
= test_exceptions_ccompare
,
5641 .par
= (const uint32_t[]){
5643 XTENSA_OPTION_TIMER_INTERRUPT
,
5645 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
5647 .name
= "xsr.ccompare2",
5648 .translate
= translate_xsr_ccompare
,
5649 .test_exceptions
= test_exceptions_ccompare
,
5650 .par
= (const uint32_t[]){
5652 XTENSA_OPTION_TIMER_INTERRUPT
,
5654 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
5656 .name
= "xsr.ccount",
5657 .translate
= translate_xsr_ccount
,
5658 .test_exceptions
= test_exceptions_sr
,
5659 .par
= (const uint32_t[]){
5661 XTENSA_OPTION_TIMER_INTERRUPT
,
5663 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
5665 .name
= "xsr.configid0",
5666 .op_flags
= XTENSA_OP_ILL
,
5668 .name
= "xsr.configid1",
5669 .op_flags
= XTENSA_OP_ILL
,
5671 .name
= "xsr.cpenable",
5672 .translate
= translate_xsr_mask
,
5673 .test_exceptions
= test_exceptions_sr
,
5674 .par
= (const uint32_t[]){
5676 XTENSA_OPTION_COPROCESSOR
,
5679 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
5681 .name
= "xsr.dbreaka0",
5682 .translate
= translate_xsr_dbreaka
,
5683 .test_exceptions
= test_exceptions_dbreak
,
5684 .par
= (const uint32_t[]){
5686 XTENSA_OPTION_DEBUG
,
5688 .op_flags
= XTENSA_OP_PRIVILEGED
,
5690 .name
= "xsr.dbreaka1",
5691 .translate
= translate_xsr_dbreaka
,
5692 .test_exceptions
= test_exceptions_dbreak
,
5693 .par
= (const uint32_t[]){
5695 XTENSA_OPTION_DEBUG
,
5697 .op_flags
= XTENSA_OP_PRIVILEGED
,
5699 .name
= "xsr.dbreakc0",
5700 .translate
= translate_xsr_dbreakc
,
5701 .test_exceptions
= test_exceptions_dbreak
,
5702 .par
= (const uint32_t[]){
5704 XTENSA_OPTION_DEBUG
,
5706 .op_flags
= XTENSA_OP_PRIVILEGED
,
5708 .name
= "xsr.dbreakc1",
5709 .translate
= translate_xsr_dbreakc
,
5710 .test_exceptions
= test_exceptions_dbreak
,
5711 .par
= (const uint32_t[]){
5713 XTENSA_OPTION_DEBUG
,
5715 .op_flags
= XTENSA_OP_PRIVILEGED
,
5718 .translate
= translate_xsr
,
5719 .test_exceptions
= test_exceptions_sr
,
5720 .par
= (const uint32_t[]){
5722 XTENSA_OPTION_DEBUG
,
5724 .op_flags
= XTENSA_OP_PRIVILEGED
,
5726 .name
= "xsr.debugcause",
5727 .op_flags
= XTENSA_OP_ILL
,
5730 .translate
= translate_xsr
,
5731 .test_exceptions
= test_exceptions_sr
,
5732 .par
= (const uint32_t[]){
5734 XTENSA_OPTION_EXCEPTION
,
5736 .op_flags
= XTENSA_OP_PRIVILEGED
,
5738 .name
= "xsr.dtlbcfg",
5739 .translate
= translate_xsr_mask
,
5740 .test_exceptions
= test_exceptions_sr
,
5741 .par
= (const uint32_t[]){
5746 .op_flags
= XTENSA_OP_PRIVILEGED
,
5749 .translate
= translate_xsr
,
5750 .test_exceptions
= test_exceptions_sr
,
5751 .par
= (const uint32_t[]){
5753 XTENSA_OPTION_EXCEPTION
,
5755 .op_flags
= XTENSA_OP_PRIVILEGED
,
5758 .translate
= translate_xsr
,
5759 .test_exceptions
= test_exceptions_hpi
,
5760 .par
= (const uint32_t[]){
5762 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5764 .op_flags
= XTENSA_OP_PRIVILEGED
,
5767 .translate
= translate_xsr
,
5768 .test_exceptions
= test_exceptions_hpi
,
5769 .par
= (const uint32_t[]){
5771 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5773 .op_flags
= XTENSA_OP_PRIVILEGED
,
5776 .translate
= translate_xsr
,
5777 .test_exceptions
= test_exceptions_hpi
,
5778 .par
= (const uint32_t[]){
5780 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5782 .op_flags
= XTENSA_OP_PRIVILEGED
,
5785 .translate
= translate_xsr
,
5786 .test_exceptions
= test_exceptions_hpi
,
5787 .par
= (const uint32_t[]){
5789 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5791 .op_flags
= XTENSA_OP_PRIVILEGED
,
5794 .translate
= translate_xsr
,
5795 .test_exceptions
= test_exceptions_hpi
,
5796 .par
= (const uint32_t[]){
5798 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5800 .op_flags
= XTENSA_OP_PRIVILEGED
,
5803 .translate
= translate_xsr
,
5804 .test_exceptions
= test_exceptions_hpi
,
5805 .par
= (const uint32_t[]){
5807 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5809 .op_flags
= XTENSA_OP_PRIVILEGED
,
5812 .translate
= translate_xsr
,
5813 .test_exceptions
= test_exceptions_hpi
,
5814 .par
= (const uint32_t[]){
5816 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5818 .op_flags
= XTENSA_OP_PRIVILEGED
,
5821 .translate
= translate_xsr
,
5822 .test_exceptions
= test_exceptions_hpi
,
5823 .par
= (const uint32_t[]){
5825 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5827 .op_flags
= XTENSA_OP_PRIVILEGED
,
5830 .translate
= translate_xsr
,
5831 .test_exceptions
= test_exceptions_hpi
,
5832 .par
= (const uint32_t[]){
5834 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5836 .op_flags
= XTENSA_OP_PRIVILEGED
,
5839 .translate
= translate_xsr
,
5840 .test_exceptions
= test_exceptions_hpi
,
5841 .par
= (const uint32_t[]){
5843 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5845 .op_flags
= XTENSA_OP_PRIVILEGED
,
5848 .translate
= translate_xsr
,
5849 .test_exceptions
= test_exceptions_hpi
,
5850 .par
= (const uint32_t[]){
5852 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5854 .op_flags
= XTENSA_OP_PRIVILEGED
,
5857 .translate
= translate_xsr
,
5858 .test_exceptions
= test_exceptions_hpi
,
5859 .par
= (const uint32_t[]){
5861 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5863 .op_flags
= XTENSA_OP_PRIVILEGED
,
5865 .name
= "xsr.eraccess",
5866 .translate
= translate_xsr_mask
,
5867 .par
= (const uint32_t[]){
5872 .op_flags
= XTENSA_OP_PRIVILEGED
,
5874 .name
= "xsr.exccause",
5875 .translate
= translate_xsr
,
5876 .test_exceptions
= test_exceptions_sr
,
5877 .par
= (const uint32_t[]){
5879 XTENSA_OPTION_EXCEPTION
,
5881 .op_flags
= XTENSA_OP_PRIVILEGED
,
5883 .name
= "xsr.excsave1",
5884 .translate
= translate_xsr
,
5885 .test_exceptions
= test_exceptions_sr
,
5886 .par
= (const uint32_t[]){
5888 XTENSA_OPTION_EXCEPTION
,
5890 .op_flags
= XTENSA_OP_PRIVILEGED
,
5892 .name
= "xsr.excsave2",
5893 .translate
= translate_xsr
,
5894 .test_exceptions
= test_exceptions_hpi
,
5895 .par
= (const uint32_t[]){
5897 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5899 .op_flags
= XTENSA_OP_PRIVILEGED
,
5901 .name
= "xsr.excsave3",
5902 .translate
= translate_xsr
,
5903 .test_exceptions
= test_exceptions_hpi
,
5904 .par
= (const uint32_t[]){
5906 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5908 .op_flags
= XTENSA_OP_PRIVILEGED
,
5910 .name
= "xsr.excsave4",
5911 .translate
= translate_xsr
,
5912 .test_exceptions
= test_exceptions_hpi
,
5913 .par
= (const uint32_t[]){
5915 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5917 .op_flags
= XTENSA_OP_PRIVILEGED
,
5919 .name
= "xsr.excsave5",
5920 .translate
= translate_xsr
,
5921 .test_exceptions
= test_exceptions_hpi
,
5922 .par
= (const uint32_t[]){
5924 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5926 .op_flags
= XTENSA_OP_PRIVILEGED
,
5928 .name
= "xsr.excsave6",
5929 .translate
= translate_xsr
,
5930 .test_exceptions
= test_exceptions_hpi
,
5931 .par
= (const uint32_t[]){
5933 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5935 .op_flags
= XTENSA_OP_PRIVILEGED
,
5937 .name
= "xsr.excsave7",
5938 .translate
= translate_xsr
,
5939 .test_exceptions
= test_exceptions_hpi
,
5940 .par
= (const uint32_t[]){
5942 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5944 .op_flags
= XTENSA_OP_PRIVILEGED
,
5946 .name
= "xsr.excvaddr",
5947 .translate
= translate_xsr
,
5948 .test_exceptions
= test_exceptions_sr
,
5949 .par
= (const uint32_t[]){
5951 XTENSA_OPTION_EXCEPTION
,
5953 .op_flags
= XTENSA_OP_PRIVILEGED
,
5955 .name
= "xsr.ibreaka0",
5956 .translate
= translate_xsr_ibreaka
,
5957 .test_exceptions
= test_exceptions_ibreak
,
5958 .par
= (const uint32_t[]){
5960 XTENSA_OPTION_DEBUG
,
5962 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
5964 .name
= "xsr.ibreaka1",
5965 .translate
= translate_xsr_ibreaka
,
5966 .test_exceptions
= test_exceptions_ibreak
,
5967 .par
= (const uint32_t[]){
5969 XTENSA_OPTION_DEBUG
,
5971 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
5973 .name
= "xsr.ibreakenable",
5974 .translate
= translate_xsr_ibreakenable
,
5975 .test_exceptions
= test_exceptions_sr
,
5976 .par
= (const uint32_t[]){
5978 XTENSA_OPTION_DEBUG
,
5980 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
5982 .name
= "xsr.icount",
5983 .translate
= translate_xsr_icount
,
5984 .test_exceptions
= test_exceptions_sr
,
5985 .par
= (const uint32_t[]){
5987 XTENSA_OPTION_DEBUG
,
5989 .op_flags
= XTENSA_OP_PRIVILEGED
,
5991 .name
= "xsr.icountlevel",
5992 .translate
= translate_xsr_mask
,
5993 .test_exceptions
= test_exceptions_sr
,
5994 .par
= (const uint32_t[]){
5996 XTENSA_OPTION_DEBUG
,
5999 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
6001 .name
= "xsr.intclear",
6002 .op_flags
= XTENSA_OP_ILL
,
6004 .name
= "xsr.intenable",
6005 .translate
= translate_xsr
,
6006 .test_exceptions
= test_exceptions_sr
,
6007 .par
= (const uint32_t[]){
6009 XTENSA_OPTION_INTERRUPT
,
6012 XTENSA_OP_PRIVILEGED
|
6013 XTENSA_OP_EXIT_TB_0
|
6014 XTENSA_OP_CHECK_INTERRUPTS
,
6016 .name
= "xsr.interrupt",
6017 .op_flags
= XTENSA_OP_ILL
,
6019 .name
= "xsr.intset",
6020 .op_flags
= XTENSA_OP_ILL
,
6022 .name
= "xsr.itlbcfg",
6023 .translate
= translate_xsr_mask
,
6024 .test_exceptions
= test_exceptions_sr
,
6025 .par
= (const uint32_t[]){
6030 .op_flags
= XTENSA_OP_PRIVILEGED
,
6033 .translate
= translate_xsr
,
6034 .test_exceptions
= test_exceptions_sr
,
6035 .par
= (const uint32_t[]){
6039 .op_flags
= XTENSA_OP_EXIT_TB_M1
,
6041 .name
= "xsr.lcount",
6042 .translate
= translate_xsr
,
6043 .test_exceptions
= test_exceptions_sr
,
6044 .par
= (const uint32_t[]){
6050 .translate
= translate_xsr
,
6051 .test_exceptions
= test_exceptions_sr
,
6052 .par
= (const uint32_t[]){
6056 .op_flags
= XTENSA_OP_EXIT_TB_M1
,
6058 .name
= "xsr.litbase",
6059 .translate
= translate_xsr_mask
,
6060 .test_exceptions
= test_exceptions_sr
,
6061 .par
= (const uint32_t[]){
6063 XTENSA_OPTION_EXTENDED_L32R
,
6066 .op_flags
= XTENSA_OP_EXIT_TB_M1
,
6069 .translate
= translate_xsr
,
6070 .test_exceptions
= test_exceptions_sr
,
6071 .par
= (const uint32_t[]){
6073 XTENSA_OPTION_MAC16
,
6077 .translate
= translate_xsr
,
6078 .test_exceptions
= test_exceptions_sr
,
6079 .par
= (const uint32_t[]){
6081 XTENSA_OPTION_MAC16
,
6085 .translate
= translate_xsr
,
6086 .test_exceptions
= test_exceptions_sr
,
6087 .par
= (const uint32_t[]){
6089 XTENSA_OPTION_MAC16
,
6093 .translate
= translate_xsr
,
6094 .test_exceptions
= test_exceptions_sr
,
6095 .par
= (const uint32_t[]){
6097 XTENSA_OPTION_MAC16
,
6100 .name
= "xsr.memctl",
6101 .translate
= translate_xsr_memctl
,
6102 .par
= (const uint32_t[]){MEMCTL
},
6103 .op_flags
= XTENSA_OP_PRIVILEGED
,
6106 .translate
= translate_xsr
,
6107 .test_exceptions
= test_exceptions_sr
,
6108 .par
= (const uint32_t[]){
6110 XTENSA_OPTION_MEMORY_ECC_PARITY
,
6112 .op_flags
= XTENSA_OP_PRIVILEGED
,
6115 .translate
= translate_xsr
,
6116 .test_exceptions
= test_exceptions_sr
,
6117 .par
= (const uint32_t[]){
6119 XTENSA_OPTION_MEMORY_ECC_PARITY
,
6121 .op_flags
= XTENSA_OP_PRIVILEGED
,
6124 .translate
= translate_xsr
,
6125 .test_exceptions
= test_exceptions_sr
,
6126 .par
= (const uint32_t[]){
6128 XTENSA_OPTION_MEMORY_ECC_PARITY
,
6130 .op_flags
= XTENSA_OP_PRIVILEGED
,
6132 .name
= "xsr.mesave",
6133 .translate
= translate_xsr
,
6134 .test_exceptions
= test_exceptions_sr
,
6135 .par
= (const uint32_t[]){
6137 XTENSA_OPTION_MEMORY_ECC_PARITY
,
6139 .op_flags
= XTENSA_OP_PRIVILEGED
,
6142 .translate
= translate_xsr
,
6143 .test_exceptions
= test_exceptions_sr
,
6144 .par
= (const uint32_t[]){
6146 XTENSA_OPTION_MEMORY_ECC_PARITY
,
6148 .op_flags
= XTENSA_OP_PRIVILEGED
,
6150 .name
= "xsr.mevaddr",
6151 .translate
= translate_xsr
,
6152 .test_exceptions
= test_exceptions_sr
,
6153 .par
= (const uint32_t[]){
6155 XTENSA_OPTION_MEMORY_ECC_PARITY
,
6157 .op_flags
= XTENSA_OP_PRIVILEGED
,
6159 .name
= "xsr.misc0",
6160 .translate
= translate_xsr
,
6161 .test_exceptions
= test_exceptions_sr
,
6162 .par
= (const uint32_t[]){
6164 XTENSA_OPTION_MISC_SR
,
6166 .op_flags
= XTENSA_OP_PRIVILEGED
,
6168 .name
= "xsr.misc1",
6169 .translate
= translate_xsr
,
6170 .test_exceptions
= test_exceptions_sr
,
6171 .par
= (const uint32_t[]){
6173 XTENSA_OPTION_MISC_SR
,
6175 .op_flags
= XTENSA_OP_PRIVILEGED
,
6177 .name
= "xsr.misc2",
6178 .translate
= translate_xsr
,
6179 .test_exceptions
= test_exceptions_sr
,
6180 .par
= (const uint32_t[]){
6182 XTENSA_OPTION_MISC_SR
,
6184 .op_flags
= XTENSA_OP_PRIVILEGED
,
6186 .name
= "xsr.misc3",
6187 .translate
= translate_xsr
,
6188 .test_exceptions
= test_exceptions_sr
,
6189 .par
= (const uint32_t[]){
6191 XTENSA_OPTION_MISC_SR
,
6193 .op_flags
= XTENSA_OP_PRIVILEGED
,
6195 .name
= "xsr.mpuenb",
6196 .translate
= translate_xsr_mpuenb
,
6197 .test_exceptions
= test_exceptions_sr
,
6198 .par
= (const uint32_t[]){
6202 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
6204 .name
= "xsr.prefctl",
6205 .translate
= translate_xsr
,
6206 .par
= (const uint32_t[]){PREFCTL
},
6209 .op_flags
= XTENSA_OP_ILL
,
6212 .translate
= translate_xsr_ps
,
6213 .test_exceptions
= test_exceptions_sr
,
6214 .par
= (const uint32_t[]){
6216 XTENSA_OPTION_EXCEPTION
,
6219 XTENSA_OP_PRIVILEGED
|
6220 XTENSA_OP_EXIT_TB_M1
|
6221 XTENSA_OP_CHECK_INTERRUPTS
,
6223 .name
= "xsr.ptevaddr",
6224 .translate
= translate_xsr_mask
,
6225 .test_exceptions
= test_exceptions_sr
,
6226 .par
= (const uint32_t[]){
6231 .op_flags
= XTENSA_OP_PRIVILEGED
,
6233 .name
= "xsr.rasid",
6234 .translate
= translate_xsr_rasid
,
6235 .test_exceptions
= test_exceptions_sr
,
6236 .par
= (const uint32_t[]){
6240 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
6243 .translate
= translate_xsr_sar
,
6244 .par
= (const uint32_t[]){SAR
},
6246 .name
= "xsr.scompare1",
6247 .translate
= translate_xsr
,
6248 .test_exceptions
= test_exceptions_sr
,
6249 .par
= (const uint32_t[]){
6251 XTENSA_OPTION_CONDITIONAL_STORE
,
6254 .name
= "xsr.vecbase",
6255 .translate
= translate_xsr
,
6256 .test_exceptions
= test_exceptions_sr
,
6257 .par
= (const uint32_t[]){
6259 XTENSA_OPTION_RELOCATABLE_VECTOR
,
6261 .op_flags
= XTENSA_OP_PRIVILEGED
,
6263 .name
= "xsr.windowbase",
6264 .translate
= translate_xsr_windowbase
,
6265 .test_exceptions
= test_exceptions_sr
,
6266 .par
= (const uint32_t[]){
6268 XTENSA_OPTION_WINDOWED_REGISTER
,
6270 .op_flags
= XTENSA_OP_PRIVILEGED
|
6271 XTENSA_OP_EXIT_TB_M1
|
6272 XTENSA_OP_SYNC_REGISTER_WINDOW
,
6274 .name
= "xsr.windowstart",
6275 .translate
= translate_xsr_windowstart
,
6276 .test_exceptions
= test_exceptions_sr
,
6277 .par
= (const uint32_t[]){
6279 XTENSA_OPTION_WINDOWED_REGISTER
,
6281 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
6285 const XtensaOpcodeTranslators xtensa_core_opcodes
= {
6286 .num_opcodes
= ARRAY_SIZE(core_ops
),
6291 static inline void get_f32_o1_i3(const OpcodeArg
*arg
, OpcodeArg
*arg32
,
6292 int o0
, int i0
, int i1
, int i2
)
6294 if ((i0
>= 0 && arg
[i0
].num_bits
== 64) ||
6295 (o0
>= 0 && arg
[o0
].num_bits
== 64)) {
6297 arg32
[o0
].out
= tcg_temp_new_i32();
6300 arg32
[i0
].in
= tcg_temp_new_i32();
6301 tcg_gen_extrl_i64_i32(arg32
[i0
].in
, arg
[i0
].in
);
6304 arg32
[i1
].in
= tcg_temp_new_i32();
6305 tcg_gen_extrl_i64_i32(arg32
[i1
].in
, arg
[i1
].in
);
6308 arg32
[i2
].in
= tcg_temp_new_i32();
6309 tcg_gen_extrl_i64_i32(arg32
[i2
].in
, arg
[i2
].in
);
6313 arg32
[o0
].out
= arg
[o0
].out
;
6316 arg32
[i0
].in
= arg
[i0
].in
;
6319 arg32
[i1
].in
= arg
[i1
].in
;
6322 arg32
[i2
].in
= arg
[i2
].in
;
6327 static inline void put_f32_o1_i3(const OpcodeArg
*arg
, const OpcodeArg
*arg32
,
6328 int o0
, int i0
, int i1
, int i2
)
6330 if ((i0
>= 0 && arg
[i0
].num_bits
== 64) ||
6331 (o0
>= 0 && arg
[o0
].num_bits
== 64)) {
6333 tcg_gen_extu_i32_i64(arg
[o0
].out
, arg32
[o0
].out
);
6334 tcg_temp_free_i32(arg32
[o0
].out
);
6337 tcg_temp_free_i32(arg32
[i0
].in
);
6340 tcg_temp_free_i32(arg32
[i1
].in
);
6343 tcg_temp_free_i32(arg32
[i2
].in
);
6348 static inline void get_f32_o1_i2(const OpcodeArg
*arg
, OpcodeArg
*arg32
,
6349 int o0
, int i0
, int i1
)
6351 get_f32_o1_i3(arg
, arg32
, o0
, i0
, i1
, -1);
6354 static inline void put_f32_o1_i2(const OpcodeArg
*arg
, const OpcodeArg
*arg32
,
6355 int o0
, int i0
, int i1
)
6357 put_f32_o1_i3(arg
, arg32
, o0
, i0
, i1
, -1);
6360 static inline void get_f32_o1_i1(const OpcodeArg
*arg
, OpcodeArg
*arg32
,
6363 get_f32_o1_i2(arg
, arg32
, o0
, i0
, -1);
6366 static inline void put_f32_o1_i1(const OpcodeArg
*arg
, const OpcodeArg
*arg32
,
6369 put_f32_o1_i2(arg
, arg32
, o0
, i0
, -1);
6372 static inline void get_f32_o1(const OpcodeArg
*arg
, OpcodeArg
*arg32
,
6375 get_f32_o1_i1(arg
, arg32
, o0
, -1);
6378 static inline void put_f32_o1(const OpcodeArg
*arg
, const OpcodeArg
*arg32
,
6381 put_f32_o1_i1(arg
, arg32
, o0
, -1);
6384 static inline void get_f32_i2(const OpcodeArg
*arg
, OpcodeArg
*arg32
,
6387 get_f32_o1_i2(arg
, arg32
, -1, i0
, i1
);
6390 static inline void put_f32_i2(const OpcodeArg
*arg
, const OpcodeArg
*arg32
,
6393 put_f32_o1_i2(arg
, arg32
, -1, i0
, i1
);
6396 static inline void get_f32_i1(const OpcodeArg
*arg
, OpcodeArg
*arg32
,
6399 get_f32_i2(arg
, arg32
, i0
, -1);
6402 static inline void put_f32_i1(const OpcodeArg
*arg
, const OpcodeArg
*arg32
,
6405 put_f32_i2(arg
, arg32
, i0
, -1);
6409 static void translate_abs_d(DisasContext
*dc
, const OpcodeArg arg
[],
6410 const uint32_t par
[])
6412 gen_helper_abs_d(arg
[0].out
, arg
[1].in
);
6415 static void translate_abs_s(DisasContext
*dc
, const OpcodeArg arg
[],
6416 const uint32_t par
[])
6420 get_f32_o1_i1(arg
, arg32
, 0, 1);
6421 gen_helper_abs_s(arg32
[0].out
, arg32
[1].in
);
6422 put_f32_o1_i1(arg
, arg32
, 0, 1);
6425 static void translate_fpu2k_add_s(DisasContext
*dc
, const OpcodeArg arg
[],
6426 const uint32_t par
[])
6428 gen_helper_fpu2k_add_s(arg
[0].out
, cpu_env
,
6429 arg
[1].in
, arg
[2].in
);
6442 static void translate_compare_d(DisasContext
*dc
, const OpcodeArg arg
[],
6443 const uint32_t par
[])
6445 static void (* const helper
[])(TCGv_i32 res
, TCGv_env env
,
6446 TCGv_i64 s
, TCGv_i64 t
) = {
6447 [COMPARE_UN
] = gen_helper_un_d
,
6448 [COMPARE_OEQ
] = gen_helper_oeq_d
,
6449 [COMPARE_UEQ
] = gen_helper_ueq_d
,
6450 [COMPARE_OLT
] = gen_helper_olt_d
,
6451 [COMPARE_ULT
] = gen_helper_ult_d
,
6452 [COMPARE_OLE
] = gen_helper_ole_d
,
6453 [COMPARE_ULE
] = gen_helper_ule_d
,
6455 TCGv_i32 zero
= tcg_const_i32(0);
6456 TCGv_i32 res
= tcg_temp_new_i32();
6457 TCGv_i32 set_br
= tcg_temp_new_i32();
6458 TCGv_i32 clr_br
= tcg_temp_new_i32();
6460 tcg_gen_ori_i32(set_br
, arg
[0].in
, 1 << arg
[0].imm
);
6461 tcg_gen_andi_i32(clr_br
, arg
[0].in
, ~(1 << arg
[0].imm
));
6463 helper
[par
[0]](res
, cpu_env
, arg
[1].in
, arg
[2].in
);
6464 tcg_gen_movcond_i32(TCG_COND_NE
,
6465 arg
[0].out
, res
, zero
,
6467 tcg_temp_free(zero
);
6469 tcg_temp_free(set_br
);
6470 tcg_temp_free(clr_br
);
6473 static void translate_compare_s(DisasContext
*dc
, const OpcodeArg arg
[],
6474 const uint32_t par
[])
6476 static void (* const helper
[])(TCGv_i32 res
, TCGv_env env
,
6477 TCGv_i32 s
, TCGv_i32 t
) = {
6478 [COMPARE_UN
] = gen_helper_un_s
,
6479 [COMPARE_OEQ
] = gen_helper_oeq_s
,
6480 [COMPARE_UEQ
] = gen_helper_ueq_s
,
6481 [COMPARE_OLT
] = gen_helper_olt_s
,
6482 [COMPARE_ULT
] = gen_helper_ult_s
,
6483 [COMPARE_OLE
] = gen_helper_ole_s
,
6484 [COMPARE_ULE
] = gen_helper_ule_s
,
6487 TCGv_i32 zero
= tcg_const_i32(0);
6488 TCGv_i32 res
= tcg_temp_new_i32();
6489 TCGv_i32 set_br
= tcg_temp_new_i32();
6490 TCGv_i32 clr_br
= tcg_temp_new_i32();
6492 tcg_gen_ori_i32(set_br
, arg
[0].in
, 1 << arg
[0].imm
);
6493 tcg_gen_andi_i32(clr_br
, arg
[0].in
, ~(1 << arg
[0].imm
));
6495 get_f32_i2(arg
, arg32
, 1, 2);
6496 helper
[par
[0]](res
, cpu_env
, arg32
[1].in
, arg32
[2].in
);
6497 tcg_gen_movcond_i32(TCG_COND_NE
,
6498 arg
[0].out
, res
, zero
,
6500 put_f32_i2(arg
, arg32
, 1, 2);
6501 tcg_temp_free(zero
);
6503 tcg_temp_free(set_br
);
6504 tcg_temp_free(clr_br
);
6507 static void translate_const_d(DisasContext
*dc
, const OpcodeArg arg
[],
6508 const uint32_t par
[])
6510 static const uint64_t v
[] = {
6511 UINT64_C(0x0000000000000000),
6512 UINT64_C(0x3ff0000000000000),
6513 UINT64_C(0x4000000000000000),
6514 UINT64_C(0x3fe0000000000000),
6517 tcg_gen_movi_i64(arg
[0].out
, v
[arg
[1].imm
% ARRAY_SIZE(v
)]);
6518 if (arg
[1].imm
>= ARRAY_SIZE(v
)) {
6519 qemu_log_mask(LOG_GUEST_ERROR
,
6520 "const.d f%d, #%d, immediate value is reserved\n",
6521 arg
[0].imm
, arg
[1].imm
);
6525 static void translate_const_s(DisasContext
*dc
, const OpcodeArg arg
[],
6526 const uint32_t par
[])
6528 static const uint32_t v
[] = {
6535 if (arg
[0].num_bits
== 32) {
6536 tcg_gen_movi_i32(arg
[0].out
, v
[arg
[1].imm
% ARRAY_SIZE(v
)]);
6538 tcg_gen_movi_i64(arg
[0].out
, v
[arg
[1].imm
% ARRAY_SIZE(v
)]);
6540 if (arg
[1].imm
>= ARRAY_SIZE(v
)) {
6541 qemu_log_mask(LOG_GUEST_ERROR
,
6542 "const.s f%d, #%d, immediate value is reserved\n",
6543 arg
[0].imm
, arg
[1].imm
);
6547 static void translate_float_d(DisasContext
*dc
, const OpcodeArg arg
[],
6548 const uint32_t par
[])
6550 TCGv_i32 scale
= tcg_const_i32(-arg
[2].imm
);
6553 gen_helper_uitof_d(arg
[0].out
, cpu_env
, arg
[1].in
, scale
);
6555 gen_helper_itof_d(arg
[0].out
, cpu_env
, arg
[1].in
, scale
);
6557 tcg_temp_free(scale
);
6560 static void translate_float_s(DisasContext
*dc
, const OpcodeArg arg
[],
6561 const uint32_t par
[])
6563 TCGv_i32 scale
= tcg_const_i32(-arg
[2].imm
);
6566 get_f32_o1(arg
, arg32
, 0);
6568 gen_helper_uitof_s(arg32
[0].out
, cpu_env
, arg
[1].in
, scale
);
6570 gen_helper_itof_s(arg32
[0].out
, cpu_env
, arg
[1].in
, scale
);
6572 put_f32_o1(arg
, arg32
, 0);
6573 tcg_temp_free(scale
);
6576 static void translate_ftoi_d(DisasContext
*dc
, const OpcodeArg arg
[],
6577 const uint32_t par
[])
6579 TCGv_i32 rounding_mode
= tcg_const_i32(par
[0]);
6580 TCGv_i32 scale
= tcg_const_i32(arg
[2].imm
);
6583 gen_helper_ftoui_d(arg
[0].out
, cpu_env
, arg
[1].in
,
6584 rounding_mode
, scale
);
6586 gen_helper_ftoi_d(arg
[0].out
, cpu_env
, arg
[1].in
,
6587 rounding_mode
, scale
);
6589 tcg_temp_free(rounding_mode
);
6590 tcg_temp_free(scale
);
6593 static void translate_ftoi_s(DisasContext
*dc
, const OpcodeArg arg
[],
6594 const uint32_t par
[])
6596 TCGv_i32 rounding_mode
= tcg_const_i32(par
[0]);
6597 TCGv_i32 scale
= tcg_const_i32(arg
[2].imm
);
6600 get_f32_i1(arg
, arg32
, 1);
6602 gen_helper_ftoui_s(arg
[0].out
, cpu_env
, arg32
[1].in
,
6603 rounding_mode
, scale
);
6605 gen_helper_ftoi_s(arg
[0].out
, cpu_env
, arg32
[1].in
,
6606 rounding_mode
, scale
);
6608 put_f32_i1(arg
, arg32
, 1);
6609 tcg_temp_free(rounding_mode
);
6610 tcg_temp_free(scale
);
6613 static void translate_ldsti(DisasContext
*dc
, const OpcodeArg arg
[],
6614 const uint32_t par
[])
6616 TCGv_i32 addr
= tcg_temp_new_i32();
6619 tcg_gen_addi_i32(addr
, arg
[1].in
, arg
[2].imm
);
6620 mop
= gen_load_store_alignment(dc
, MO_TEUL
, addr
);
6622 tcg_gen_qemu_st_tl(arg
[0].in
, addr
, dc
->cring
, mop
);
6624 tcg_gen_qemu_ld_tl(arg
[0].out
, addr
, dc
->cring
, mop
);
6627 tcg_gen_mov_i32(arg
[1].out
, addr
);
6629 tcg_temp_free(addr
);
6632 static void translate_ldstx(DisasContext
*dc
, const OpcodeArg arg
[],
6633 const uint32_t par
[])
6635 TCGv_i32 addr
= tcg_temp_new_i32();
6638 tcg_gen_add_i32(addr
, arg
[1].in
, arg
[2].in
);
6639 mop
= gen_load_store_alignment(dc
, MO_TEUL
, addr
);
6641 tcg_gen_qemu_st_tl(arg
[0].in
, addr
, dc
->cring
, mop
);
6643 tcg_gen_qemu_ld_tl(arg
[0].out
, addr
, dc
->cring
, mop
);
6646 tcg_gen_mov_i32(arg
[1].out
, addr
);
6648 tcg_temp_free(addr
);
6651 static void translate_fpu2k_madd_s(DisasContext
*dc
, const OpcodeArg arg
[],
6652 const uint32_t par
[])
6654 gen_helper_fpu2k_madd_s(arg
[0].out
, cpu_env
,
6655 arg
[0].in
, arg
[1].in
, arg
[2].in
);
6658 static void translate_mov_d(DisasContext
*dc
, const OpcodeArg arg
[],
6659 const uint32_t par
[])
6661 tcg_gen_mov_i64(arg
[0].out
, arg
[1].in
);
6664 static void translate_mov_s(DisasContext
*dc
, const OpcodeArg arg
[],
6665 const uint32_t par
[])
6667 if (arg
[0].num_bits
== 32) {
6668 tcg_gen_mov_i32(arg
[0].out
, arg
[1].in
);
6670 tcg_gen_mov_i64(arg
[0].out
, arg
[1].in
);
6674 static void translate_movcond_d(DisasContext
*dc
, const OpcodeArg arg
[],
6675 const uint32_t par
[])
6677 TCGv_i64 zero
= tcg_const_i64(0);
6678 TCGv_i64 arg2
= tcg_temp_new_i64();
6680 tcg_gen_ext_i32_i64(arg2
, arg
[2].in
);
6681 tcg_gen_movcond_i64(par
[0], arg
[0].out
,
6683 arg
[1].in
, arg
[0].in
);
6684 tcg_temp_free_i64(zero
);
6685 tcg_temp_free_i64(arg2
);
6688 static void translate_movcond_s(DisasContext
*dc
, const OpcodeArg arg
[],
6689 const uint32_t par
[])
6691 if (arg
[0].num_bits
== 32) {
6692 TCGv_i32 zero
= tcg_const_i32(0);
6694 tcg_gen_movcond_i32(par
[0], arg
[0].out
,
6696 arg
[1].in
, arg
[0].in
);
6697 tcg_temp_free(zero
);
6699 translate_movcond_d(dc
, arg
, par
);
6703 static void translate_movp_d(DisasContext
*dc
, const OpcodeArg arg
[],
6704 const uint32_t par
[])
6706 TCGv_i64 zero
= tcg_const_i64(0);
6707 TCGv_i32 tmp1
= tcg_temp_new_i32();
6708 TCGv_i64 tmp2
= tcg_temp_new_i64();
6710 tcg_gen_andi_i32(tmp1
, arg
[2].in
, 1 << arg
[2].imm
);
6711 tcg_gen_extu_i32_i64(tmp2
, tmp1
);
6712 tcg_gen_movcond_i64(par
[0],
6713 arg
[0].out
, tmp2
, zero
,
6714 arg
[1].in
, arg
[0].in
);
6715 tcg_temp_free_i64(zero
);
6716 tcg_temp_free_i32(tmp1
);
6717 tcg_temp_free_i64(tmp2
);
6720 static void translate_movp_s(DisasContext
*dc
, const OpcodeArg arg
[],
6721 const uint32_t par
[])
6723 if (arg
[0].num_bits
== 32) {
6724 TCGv_i32 zero
= tcg_const_i32(0);
6725 TCGv_i32 tmp
= tcg_temp_new_i32();
6727 tcg_gen_andi_i32(tmp
, arg
[2].in
, 1 << arg
[2].imm
);
6728 tcg_gen_movcond_i32(par
[0],
6729 arg
[0].out
, tmp
, zero
,
6730 arg
[1].in
, arg
[0].in
);
6732 tcg_temp_free(zero
);
6734 translate_movp_d(dc
, arg
, par
);
6738 static void translate_fpu2k_mul_s(DisasContext
*dc
, const OpcodeArg arg
[],
6739 const uint32_t par
[])
6741 gen_helper_fpu2k_mul_s(arg
[0].out
, cpu_env
,
6742 arg
[1].in
, arg
[2].in
);
6745 static void translate_fpu2k_msub_s(DisasContext
*dc
, const OpcodeArg arg
[],
6746 const uint32_t par
[])
6748 gen_helper_fpu2k_msub_s(arg
[0].out
, cpu_env
,
6749 arg
[0].in
, arg
[1].in
, arg
[2].in
);
6752 static void translate_neg_d(DisasContext
*dc
, const OpcodeArg arg
[],
6753 const uint32_t par
[])
6755 gen_helper_neg_d(arg
[0].out
, arg
[1].in
);
6758 static void translate_neg_s(DisasContext
*dc
, const OpcodeArg arg
[],
6759 const uint32_t par
[])
6763 get_f32_o1_i1(arg
, arg32
, 0, 1);
6764 gen_helper_neg_s(arg32
[0].out
, arg32
[1].in
);
6765 put_f32_o1_i1(arg
, arg32
, 0, 1);
6768 static void translate_rfr_d(DisasContext
*dc
, const OpcodeArg arg
[],
6769 const uint32_t par
[])
6771 tcg_gen_extrh_i64_i32(arg
[0].out
, arg
[1].in
);
6774 static void translate_rfr_s(DisasContext
*dc
, const OpcodeArg arg
[],
6775 const uint32_t par
[])
6777 if (arg
[1].num_bits
== 32) {
6778 tcg_gen_mov_i32(arg
[0].out
, arg
[1].in
);
6780 tcg_gen_extrl_i64_i32(arg
[0].out
, arg
[1].in
);
6784 static void translate_fpu2k_sub_s(DisasContext
*dc
, const OpcodeArg arg
[],
6785 const uint32_t par
[])
6787 gen_helper_fpu2k_sub_s(arg
[0].out
, cpu_env
,
6788 arg
[1].in
, arg
[2].in
);
6791 static void translate_wfr_d(DisasContext
*dc
, const OpcodeArg arg
[],
6792 const uint32_t par
[])
6794 tcg_gen_concat_i32_i64(arg
[0].out
, arg
[2].in
, arg
[1].in
);
6797 static void translate_wfr_s(DisasContext
*dc
, const OpcodeArg arg
[],
6798 const uint32_t par
[])
6800 if (arg
[0].num_bits
== 32) {
6801 tcg_gen_mov_i32(arg
[0].out
, arg
[1].in
);
6803 tcg_gen_ext_i32_i64(arg
[0].out
, arg
[1].in
);
6807 static void translate_wur_fpu2k_fcr(DisasContext
*dc
, const OpcodeArg arg
[],
6808 const uint32_t par
[])
6810 gen_helper_wur_fpu2k_fcr(cpu_env
, arg
[0].in
);
6813 static void translate_wur_fpu2k_fsr(DisasContext
*dc
, const OpcodeArg arg
[],
6814 const uint32_t par
[])
6816 tcg_gen_andi_i32(cpu_UR
[par
[0]], arg
[0].in
, 0xffffff80);
6819 static const XtensaOpcodeOps fpu2000_ops
[] = {
6822 .translate
= translate_abs_s
,
6826 .translate
= translate_fpu2k_add_s
,
6830 .translate
= translate_ftoi_s
,
6831 .par
= (const uint32_t[]){float_round_up
, false},
6835 .translate
= translate_float_s
,
6836 .par
= (const uint32_t[]){false},
6840 .translate
= translate_ftoi_s
,
6841 .par
= (const uint32_t[]){float_round_down
, false},
6845 .translate
= translate_ldsti
,
6846 .par
= (const uint32_t[]){false, false},
6847 .op_flags
= XTENSA_OP_LOAD
,
6851 .translate
= translate_ldsti
,
6852 .par
= (const uint32_t[]){false, true},
6853 .op_flags
= XTENSA_OP_LOAD
,
6857 .translate
= translate_ldstx
,
6858 .par
= (const uint32_t[]){false, false},
6859 .op_flags
= XTENSA_OP_LOAD
,
6863 .translate
= translate_ldstx
,
6864 .par
= (const uint32_t[]){false, true},
6865 .op_flags
= XTENSA_OP_LOAD
,
6869 .translate
= translate_fpu2k_madd_s
,
6873 .translate
= translate_mov_s
,
6877 .translate
= translate_movcond_s
,
6878 .par
= (const uint32_t[]){TCG_COND_EQ
},
6882 .translate
= translate_movp_s
,
6883 .par
= (const uint32_t[]){TCG_COND_EQ
},
6887 .translate
= translate_movcond_s
,
6888 .par
= (const uint32_t[]){TCG_COND_GE
},
6892 .translate
= translate_movcond_s
,
6893 .par
= (const uint32_t[]){TCG_COND_LT
},
6897 .translate
= translate_movcond_s
,
6898 .par
= (const uint32_t[]){TCG_COND_NE
},
6902 .translate
= translate_movp_s
,
6903 .par
= (const uint32_t[]){TCG_COND_NE
},
6907 .translate
= translate_fpu2k_msub_s
,
6911 .translate
= translate_fpu2k_mul_s
,
6915 .translate
= translate_neg_s
,
6919 .translate
= translate_compare_s
,
6920 .par
= (const uint32_t[]){COMPARE_OEQ
},
6924 .translate
= translate_compare_s
,
6925 .par
= (const uint32_t[]){COMPARE_OLE
},
6929 .translate
= translate_compare_s
,
6930 .par
= (const uint32_t[]){COMPARE_OLT
},
6934 .translate
= translate_rfr_s
,
6938 .translate
= translate_ftoi_s
,
6939 .par
= (const uint32_t[]){float_round_nearest_even
, false},
6943 .translate
= translate_rur
,
6944 .par
= (const uint32_t[]){FCR
},
6948 .translate
= translate_rur
,
6949 .par
= (const uint32_t[]){FSR
},
6953 .translate
= translate_ldsti
,
6954 .par
= (const uint32_t[]){true, false},
6955 .op_flags
= XTENSA_OP_STORE
,
6959 .translate
= translate_ldsti
,
6960 .par
= (const uint32_t[]){true, true},
6961 .op_flags
= XTENSA_OP_STORE
,
6965 .translate
= translate_ldstx
,
6966 .par
= (const uint32_t[]){true, false},
6967 .op_flags
= XTENSA_OP_STORE
,
6971 .translate
= translate_ldstx
,
6972 .par
= (const uint32_t[]){true, true},
6973 .op_flags
= XTENSA_OP_STORE
,
6977 .translate
= translate_fpu2k_sub_s
,
6981 .translate
= translate_ftoi_s
,
6982 .par
= (const uint32_t[]){float_round_to_zero
, false},
6986 .translate
= translate_compare_s
,
6987 .par
= (const uint32_t[]){COMPARE_UEQ
},
6991 .translate
= translate_float_s
,
6992 .par
= (const uint32_t[]){true},
6996 .translate
= translate_compare_s
,
6997 .par
= (const uint32_t[]){COMPARE_ULE
},
7001 .translate
= translate_compare_s
,
7002 .par
= (const uint32_t[]){COMPARE_ULT
},
7006 .translate
= translate_compare_s
,
7007 .par
= (const uint32_t[]){COMPARE_UN
},
7011 .translate
= translate_ftoi_s
,
7012 .par
= (const uint32_t[]){float_round_to_zero
, true},
7016 .translate
= translate_wfr_s
,
7020 .translate
= translate_wur_fpu2k_fcr
,
7021 .par
= (const uint32_t[]){FCR
},
7025 .translate
= translate_wur_fpu2k_fsr
,
7026 .par
= (const uint32_t[]){FSR
},
7031 const XtensaOpcodeTranslators xtensa_fpu2000_opcodes
= {
7032 .num_opcodes
= ARRAY_SIZE(fpu2000_ops
),
7033 .opcode
= fpu2000_ops
,
7036 static void translate_add_d(DisasContext
*dc
, const OpcodeArg arg
[],
7037 const uint32_t par
[])
7039 gen_helper_add_d(arg
[0].out
, cpu_env
, arg
[1].in
, arg
[2].in
);
7042 static void translate_add_s(DisasContext
*dc
, const OpcodeArg arg
[],
7043 const uint32_t par
[])
7045 if (option_enabled(dc
, XTENSA_OPTION_DFPU_SINGLE_ONLY
)) {
7046 gen_helper_fpu2k_add_s(arg
[0].out
, cpu_env
,
7047 arg
[1].in
, arg
[2].in
);
7051 get_f32_o1_i2(arg
, arg32
, 0, 1, 2);
7052 gen_helper_add_s(arg32
[0].out
, cpu_env
, arg32
[1].in
, arg32
[2].in
);
7053 put_f32_o1_i2(arg
, arg32
, 0, 1, 2);
7057 static void translate_cvtd_s(DisasContext
*dc
, const OpcodeArg arg
[],
7058 const uint32_t par
[])
7060 TCGv_i32 v
= tcg_temp_new_i32();
7062 tcg_gen_extrl_i64_i32(v
, arg
[1].in
);
7063 gen_helper_cvtd_s(arg
[0].out
, cpu_env
, v
);
7064 tcg_temp_free_i32(v
);
7067 static void translate_cvts_d(DisasContext
*dc
, const OpcodeArg arg
[],
7068 const uint32_t par
[])
7070 TCGv_i32 v
= tcg_temp_new_i32();
7072 gen_helper_cvts_d(v
, cpu_env
, arg
[1].in
);
7073 tcg_gen_extu_i32_i64(arg
[0].out
, v
);
7074 tcg_temp_free_i32(v
);
7077 static void translate_ldsti_d(DisasContext
*dc
, const OpcodeArg arg
[],
7078 const uint32_t par
[])
7084 addr
= tcg_temp_new_i32();
7085 tcg_gen_addi_i32(addr
, arg
[1].in
, arg
[2].imm
);
7089 mop
= gen_load_store_alignment(dc
, MO_TEQ
, addr
);
7091 tcg_gen_qemu_st_i64(arg
[0].in
, addr
, dc
->cring
, mop
);
7093 tcg_gen_qemu_ld_i64(arg
[0].out
, addr
, dc
->cring
, mop
);
7097 tcg_gen_mov_i32(arg
[1].out
, addr
);
7099 tcg_gen_addi_i32(arg
[1].out
, arg
[1].in
, arg
[2].imm
);
7103 tcg_temp_free(addr
);
7107 static void translate_ldsti_s(DisasContext
*dc
, const OpcodeArg arg
[],
7108 const uint32_t par
[])
7115 addr
= tcg_temp_new_i32();
7116 tcg_gen_addi_i32(addr
, arg
[1].in
, arg
[2].imm
);
7120 mop
= gen_load_store_alignment(dc
, MO_TEUL
, addr
);
7122 get_f32_i1(arg
, arg32
, 0);
7123 tcg_gen_qemu_st_tl(arg32
[0].in
, addr
, dc
->cring
, mop
);
7124 put_f32_i1(arg
, arg32
, 0);
7126 get_f32_o1(arg
, arg32
, 0);
7127 tcg_gen_qemu_ld_tl(arg32
[0].out
, addr
, dc
->cring
, mop
);
7128 put_f32_o1(arg
, arg32
, 0);
7132 tcg_gen_mov_i32(arg
[1].out
, addr
);
7134 tcg_gen_addi_i32(arg
[1].out
, arg
[1].in
, arg
[2].imm
);
7138 tcg_temp_free(addr
);
7142 static void translate_ldstx_d(DisasContext
*dc
, const OpcodeArg arg
[],
7143 const uint32_t par
[])
7149 addr
= tcg_temp_new_i32();
7150 tcg_gen_add_i32(addr
, arg
[1].in
, arg
[2].in
);
7154 mop
= gen_load_store_alignment(dc
, MO_TEQ
, addr
);
7156 tcg_gen_qemu_st_i64(arg
[0].in
, addr
, dc
->cring
, mop
);
7158 tcg_gen_qemu_ld_i64(arg
[0].out
, addr
, dc
->cring
, mop
);
7162 tcg_gen_mov_i32(arg
[1].out
, addr
);
7164 tcg_gen_add_i32(arg
[1].out
, arg
[1].in
, arg
[2].in
);
7168 tcg_temp_free(addr
);
7172 static void translate_ldstx_s(DisasContext
*dc
, const OpcodeArg arg
[],
7173 const uint32_t par
[])
7180 addr
= tcg_temp_new_i32();
7181 tcg_gen_add_i32(addr
, arg
[1].in
, arg
[2].in
);
7185 mop
= gen_load_store_alignment(dc
, MO_TEUL
, addr
);
7187 get_f32_i1(arg
, arg32
, 0);
7188 tcg_gen_qemu_st_tl(arg32
[0].in
, addr
, dc
->cring
, mop
);
7189 put_f32_i1(arg
, arg32
, 0);
7191 get_f32_o1(arg
, arg32
, 0);
7192 tcg_gen_qemu_ld_tl(arg32
[0].out
, addr
, dc
->cring
, mop
);
7193 put_f32_o1(arg
, arg32
, 0);
7197 tcg_gen_mov_i32(arg
[1].out
, addr
);
7199 tcg_gen_add_i32(arg
[1].out
, arg
[1].in
, arg
[2].in
);
7203 tcg_temp_free(addr
);
7207 static void translate_madd_d(DisasContext
*dc
, const OpcodeArg arg
[],
7208 const uint32_t par
[])
7210 gen_helper_madd_d(arg
[0].out
, cpu_env
,
7211 arg
[0].in
, arg
[1].in
, arg
[2].in
);
7214 static void translate_madd_s(DisasContext
*dc
, const OpcodeArg arg
[],
7215 const uint32_t par
[])
7217 if (option_enabled(dc
, XTENSA_OPTION_DFPU_SINGLE_ONLY
)) {
7218 gen_helper_fpu2k_madd_s(arg
[0].out
, cpu_env
,
7219 arg
[0].in
, arg
[1].in
, arg
[2].in
);
7223 get_f32_o1_i3(arg
, arg32
, 0, 0, 1, 2);
7224 gen_helper_madd_s(arg32
[0].out
, cpu_env
,
7225 arg32
[0].in
, arg32
[1].in
, arg32
[2].in
);
7226 put_f32_o1_i3(arg
, arg32
, 0, 0, 1, 2);
7230 static void translate_mul_d(DisasContext
*dc
, const OpcodeArg arg
[],
7231 const uint32_t par
[])
7233 gen_helper_mul_d(arg
[0].out
, cpu_env
, arg
[1].in
, arg
[2].in
);
7236 static void translate_mul_s(DisasContext
*dc
, const OpcodeArg arg
[],
7237 const uint32_t par
[])
7239 if (option_enabled(dc
, XTENSA_OPTION_DFPU_SINGLE_ONLY
)) {
7240 gen_helper_fpu2k_mul_s(arg
[0].out
, cpu_env
,
7241 arg
[1].in
, arg
[2].in
);
7245 get_f32_o1_i2(arg
, arg32
, 0, 1, 2);
7246 gen_helper_mul_s(arg32
[0].out
, cpu_env
, arg32
[1].in
, arg32
[2].in
);
7247 put_f32_o1_i2(arg
, arg32
, 0, 1, 2);
7251 static void translate_msub_d(DisasContext
*dc
, const OpcodeArg arg
[],
7252 const uint32_t par
[])
7254 gen_helper_msub_d(arg
[0].out
, cpu_env
,
7255 arg
[0].in
, arg
[1].in
, arg
[2].in
);
7258 static void translate_msub_s(DisasContext
*dc
, const OpcodeArg arg
[],
7259 const uint32_t par
[])
7261 if (option_enabled(dc
, XTENSA_OPTION_DFPU_SINGLE_ONLY
)) {
7262 gen_helper_fpu2k_msub_s(arg
[0].out
, cpu_env
,
7263 arg
[0].in
, arg
[1].in
, arg
[2].in
);
7267 get_f32_o1_i3(arg
, arg32
, 0, 0, 1, 2);
7268 gen_helper_msub_s(arg32
[0].out
, cpu_env
,
7269 arg32
[0].in
, arg32
[1].in
, arg32
[2].in
);
7270 put_f32_o1_i3(arg
, arg32
, 0, 0, 1, 2);
7274 static void translate_sub_d(DisasContext
*dc
, const OpcodeArg arg
[],
7275 const uint32_t par
[])
7277 gen_helper_sub_d(arg
[0].out
, cpu_env
, arg
[1].in
, arg
[2].in
);
7280 static void translate_sub_s(DisasContext
*dc
, const OpcodeArg arg
[],
7281 const uint32_t par
[])
7283 if (option_enabled(dc
, XTENSA_OPTION_DFPU_SINGLE_ONLY
)) {
7284 gen_helper_fpu2k_sub_s(arg
[0].out
, cpu_env
,
7285 arg
[1].in
, arg
[2].in
);
7289 get_f32_o1_i2(arg
, arg32
, 0, 1, 2);
7290 gen_helper_sub_s(arg32
[0].out
, cpu_env
, arg32
[1].in
, arg32
[2].in
);
7291 put_f32_o1_i2(arg
, arg32
, 0, 1, 2);
7295 static void translate_mkdadj_d(DisasContext
*dc
, const OpcodeArg arg
[],
7296 const uint32_t par
[])
7298 gen_helper_mkdadj_d(arg
[0].out
, cpu_env
, arg
[0].in
, arg
[1].in
);
7301 static void translate_mkdadj_s(DisasContext
*dc
, const OpcodeArg arg
[],
7302 const uint32_t par
[])
7306 get_f32_o1_i2(arg
, arg32
, 0, 0, 1);
7307 gen_helper_mkdadj_s(arg32
[0].out
, cpu_env
, arg32
[0].in
, arg32
[1].in
);
7308 put_f32_o1_i2(arg
, arg32
, 0, 0, 1);
7311 static void translate_mksadj_d(DisasContext
*dc
, const OpcodeArg arg
[],
7312 const uint32_t par
[])
7314 gen_helper_mksadj_d(arg
[0].out
, cpu_env
, arg
[1].in
);
7317 static void translate_mksadj_s(DisasContext
*dc
, const OpcodeArg arg
[],
7318 const uint32_t par
[])
7322 get_f32_o1_i1(arg
, arg32
, 0, 1);
7323 gen_helper_mksadj_s(arg32
[0].out
, cpu_env
, arg32
[1].in
);
7324 put_f32_o1_i1(arg
, arg32
, 0, 1);
7327 static void translate_wur_fpu_fcr(DisasContext
*dc
, const OpcodeArg arg
[],
7328 const uint32_t par
[])
7330 gen_helper_wur_fpu_fcr(cpu_env
, arg
[0].in
);
7333 static void translate_rur_fpu_fsr(DisasContext
*dc
, const OpcodeArg arg
[],
7334 const uint32_t par
[])
7336 gen_helper_rur_fpu_fsr(arg
[0].out
, cpu_env
);
7339 static void translate_wur_fpu_fsr(DisasContext
*dc
, const OpcodeArg arg
[],
7340 const uint32_t par
[])
7342 gen_helper_wur_fpu_fsr(cpu_env
, arg
[0].in
);
7345 static const XtensaOpcodeOps fpu_ops
[] = {
7348 .translate
= translate_abs_d
,
7352 .translate
= translate_abs_s
,
7356 .translate
= translate_add_d
,
7360 .translate
= translate_add_s
,
7364 .translate
= translate_nop
,
7368 .translate
= translate_nop
,
7371 .name
= "addexpm.d",
7372 .translate
= translate_mov_s
,
7375 .name
= "addexpm.s",
7376 .translate
= translate_mov_s
,
7380 .translate
= translate_ftoi_d
,
7381 .par
= (const uint32_t[]){float_round_up
, false},
7385 .translate
= translate_ftoi_s
,
7386 .par
= (const uint32_t[]){float_round_up
, false},
7390 .translate
= translate_const_d
,
7394 .translate
= translate_const_s
,
7398 .translate
= translate_cvtd_s
,
7402 .translate
= translate_cvts_d
,
7406 .translate
= translate_nop
,
7410 .translate
= translate_nop
,
7414 .translate
= translate_nop
,
7418 .translate
= translate_nop
,
7422 .translate
= translate_float_d
,
7423 .par
= (const uint32_t[]){false},
7427 .translate
= translate_float_s
,
7428 .par
= (const uint32_t[]){false},
7432 .translate
= translate_ftoi_d
,
7433 .par
= (const uint32_t[]){float_round_down
, false},
7437 .translate
= translate_ftoi_s
,
7438 .par
= (const uint32_t[]){float_round_down
, false},
7442 .translate
= translate_ldsti_d
,
7443 .par
= (const uint32_t[]){false, true, false},
7444 .op_flags
= XTENSA_OP_LOAD
,
7448 .translate
= translate_ldsti_d
,
7449 .par
= (const uint32_t[]){false, false, true},
7450 .op_flags
= XTENSA_OP_LOAD
,
7454 .translate
= translate_ldsti_d
,
7455 .par
= (const uint32_t[]){false, true, true},
7456 .op_flags
= XTENSA_OP_LOAD
,
7460 .translate
= translate_ldstx_d
,
7461 .par
= (const uint32_t[]){false, true, false},
7462 .op_flags
= XTENSA_OP_LOAD
,
7466 .translate
= translate_ldstx_d
,
7467 .par
= (const uint32_t[]){false, false, true},
7468 .op_flags
= XTENSA_OP_LOAD
,
7472 .translate
= translate_ldstx_d
,
7473 .par
= (const uint32_t[]){false, true, true},
7474 .op_flags
= XTENSA_OP_LOAD
,
7478 .translate
= translate_ldsti_s
,
7479 .par
= (const uint32_t[]){false, true, false},
7480 .op_flags
= XTENSA_OP_LOAD
,
7484 .translate
= translate_ldsti_s
,
7485 .par
= (const uint32_t[]){false, false, true},
7486 .op_flags
= XTENSA_OP_LOAD
,
7490 .translate
= translate_ldsti_s
,
7491 .par
= (const uint32_t[]){false, true, true},
7492 .op_flags
= XTENSA_OP_LOAD
,
7496 .translate
= translate_ldstx_s
,
7497 .par
= (const uint32_t[]){false, true, false},
7498 .op_flags
= XTENSA_OP_LOAD
,
7502 .translate
= translate_ldstx_s
,
7503 .par
= (const uint32_t[]){false, false, true},
7504 .op_flags
= XTENSA_OP_LOAD
,
7508 .translate
= translate_ldstx_s
,
7509 .par
= (const uint32_t[]){false, true, true},
7510 .op_flags
= XTENSA_OP_LOAD
,
7514 .translate
= translate_madd_d
,
7518 .translate
= translate_madd_s
,
7522 .translate
= translate_nop
,
7526 .translate
= translate_nop
,
7530 .translate
= translate_mkdadj_d
,
7534 .translate
= translate_mkdadj_s
,
7538 .translate
= translate_mksadj_d
,
7542 .translate
= translate_mksadj_s
,
7546 .translate
= translate_mov_d
,
7550 .translate
= translate_mov_s
,
7554 .translate
= translate_movcond_d
,
7555 .par
= (const uint32_t[]){TCG_COND_EQ
},
7559 .translate
= translate_movcond_s
,
7560 .par
= (const uint32_t[]){TCG_COND_EQ
},
7564 .translate
= translate_movp_d
,
7565 .par
= (const uint32_t[]){TCG_COND_EQ
},
7569 .translate
= translate_movp_s
,
7570 .par
= (const uint32_t[]){TCG_COND_EQ
},
7574 .translate
= translate_movcond_d
,
7575 .par
= (const uint32_t[]){TCG_COND_GE
},
7579 .translate
= translate_movcond_s
,
7580 .par
= (const uint32_t[]){TCG_COND_GE
},
7584 .translate
= translate_movcond_d
,
7585 .par
= (const uint32_t[]){TCG_COND_LT
},
7589 .translate
= translate_movcond_s
,
7590 .par
= (const uint32_t[]){TCG_COND_LT
},
7594 .translate
= translate_movcond_d
,
7595 .par
= (const uint32_t[]){TCG_COND_NE
},
7599 .translate
= translate_movcond_s
,
7600 .par
= (const uint32_t[]){TCG_COND_NE
},
7604 .translate
= translate_movp_d
,
7605 .par
= (const uint32_t[]){TCG_COND_NE
},
7609 .translate
= translate_movp_s
,
7610 .par
= (const uint32_t[]){TCG_COND_NE
},
7614 .translate
= translate_msub_d
,
7618 .translate
= translate_msub_s
,
7622 .translate
= translate_mul_d
,
7626 .translate
= translate_mul_s
,
7630 .translate
= translate_neg_d
,
7634 .translate
= translate_neg_s
,
7638 .translate
= translate_nop
,
7642 .translate
= translate_nop
,
7646 .translate
= translate_compare_d
,
7647 .par
= (const uint32_t[]){COMPARE_OEQ
},
7651 .translate
= translate_compare_s
,
7652 .par
= (const uint32_t[]){COMPARE_OEQ
},
7656 .translate
= translate_compare_d
,
7657 .par
= (const uint32_t[]){COMPARE_OLE
},
7661 .translate
= translate_compare_s
,
7662 .par
= (const uint32_t[]){COMPARE_OLE
},
7666 .translate
= translate_compare_d
,
7667 .par
= (const uint32_t[]){COMPARE_OLT
},
7671 .translate
= translate_compare_s
,
7672 .par
= (const uint32_t[]){COMPARE_OLT
},
7676 .translate
= translate_rfr_s
,
7680 .translate
= translate_rfr_d
,
7684 .translate
= translate_ftoi_d
,
7685 .par
= (const uint32_t[]){float_round_nearest_even
, false},
7689 .translate
= translate_ftoi_s
,
7690 .par
= (const uint32_t[]){float_round_nearest_even
, false},
7694 .translate
= translate_rur
,
7695 .par
= (const uint32_t[]){FCR
},
7699 .translate
= translate_rur_fpu_fsr
,
7703 .translate
= translate_ldsti_d
,
7704 .par
= (const uint32_t[]){true, true, false},
7705 .op_flags
= XTENSA_OP_STORE
,
7709 .translate
= translate_ldsti_d
,
7710 .par
= (const uint32_t[]){true, false, true},
7711 .op_flags
= XTENSA_OP_STORE
,
7715 .translate
= translate_ldsti_d
,
7716 .par
= (const uint32_t[]){true, true, true},
7717 .op_flags
= XTENSA_OP_STORE
,
7721 .translate
= translate_ldstx_d
,
7722 .par
= (const uint32_t[]){true, true, false},
7723 .op_flags
= XTENSA_OP_STORE
,
7727 .translate
= translate_ldstx_d
,
7728 .par
= (const uint32_t[]){true, false, true},
7729 .op_flags
= XTENSA_OP_STORE
,
7733 .translate
= translate_ldstx_d
,
7734 .par
= (const uint32_t[]){true, true, true},
7735 .op_flags
= XTENSA_OP_STORE
,
7739 .translate
= translate_nop
,
7743 .translate
= translate_nop
,
7747 .translate
= translate_ldsti_s
,
7748 .par
= (const uint32_t[]){true, true, false},
7749 .op_flags
= XTENSA_OP_STORE
,
7753 .translate
= translate_ldsti_s
,
7754 .par
= (const uint32_t[]){true, false, true},
7755 .op_flags
= XTENSA_OP_STORE
,
7759 .translate
= translate_ldsti_s
,
7760 .par
= (const uint32_t[]){true, true, true},
7761 .op_flags
= XTENSA_OP_STORE
,
7765 .translate
= translate_ldstx_s
,
7766 .par
= (const uint32_t[]){true, true, false},
7767 .op_flags
= XTENSA_OP_STORE
,
7771 .translate
= translate_ldstx_s
,
7772 .par
= (const uint32_t[]){true, false, true},
7773 .op_flags
= XTENSA_OP_STORE
,
7777 .translate
= translate_ldstx_s
,
7778 .par
= (const uint32_t[]){true, true, true},
7779 .op_flags
= XTENSA_OP_STORE
,
7783 .translate
= translate_sub_d
,
7787 .translate
= translate_sub_s
,
7791 .translate
= translate_ftoi_d
,
7792 .par
= (const uint32_t[]){float_round_to_zero
, false},
7796 .translate
= translate_ftoi_s
,
7797 .par
= (const uint32_t[]){float_round_to_zero
, false},
7801 .translate
= translate_compare_d
,
7802 .par
= (const uint32_t[]){COMPARE_UEQ
},
7806 .translate
= translate_compare_s
,
7807 .par
= (const uint32_t[]){COMPARE_UEQ
},
7811 .translate
= translate_float_d
,
7812 .par
= (const uint32_t[]){true},
7816 .translate
= translate_float_s
,
7817 .par
= (const uint32_t[]){true},
7821 .translate
= translate_compare_d
,
7822 .par
= (const uint32_t[]){COMPARE_ULE
},
7826 .translate
= translate_compare_s
,
7827 .par
= (const uint32_t[]){COMPARE_ULE
},
7831 .translate
= translate_compare_d
,
7832 .par
= (const uint32_t[]){COMPARE_ULT
},
7836 .translate
= translate_compare_s
,
7837 .par
= (const uint32_t[]){COMPARE_ULT
},
7841 .translate
= translate_compare_d
,
7842 .par
= (const uint32_t[]){COMPARE_UN
},
7846 .translate
= translate_compare_s
,
7847 .par
= (const uint32_t[]){COMPARE_UN
},
7851 .translate
= translate_ftoi_d
,
7852 .par
= (const uint32_t[]){float_round_to_zero
, true},
7856 .translate
= translate_ftoi_s
,
7857 .par
= (const uint32_t[]){float_round_to_zero
, true},
7861 .translate
= translate_wfr_s
,
7865 .translate
= translate_wfr_d
,
7869 .translate
= translate_wur_fpu_fcr
,
7870 .par
= (const uint32_t[]){FCR
},
7874 .translate
= translate_wur_fpu_fsr
,
7879 const XtensaOpcodeTranslators xtensa_fpu_opcodes
= {
7880 .num_opcodes
= ARRAY_SIZE(fpu_ops
),