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"
46 #include "trace-tcg.h"
51 DisasContextBase base
;
52 const XtensaConfig
*config
;
61 bool sar_m32_allocated
;
75 xtensa_insnbuf_word insnbuf
[MAX_INSNBUF_LENGTH
];
76 xtensa_insnbuf_word slotbuf
[MAX_INSNBUF_LENGTH
];
79 static TCGv_i32 cpu_pc
;
80 static TCGv_i32 cpu_R
[16];
81 static TCGv_i32 cpu_FR
[16];
82 static TCGv_i64 cpu_FRD
[16];
83 static TCGv_i32 cpu_MR
[4];
84 static TCGv_i32 cpu_BR
[16];
85 static TCGv_i32 cpu_BR4
[4];
86 static TCGv_i32 cpu_BR8
[2];
87 static TCGv_i32 cpu_SR
[256];
88 static TCGv_i32 cpu_UR
[256];
89 static TCGv_i32 cpu_windowbase_next
;
90 static TCGv_i32 cpu_exclusive_addr
;
91 static TCGv_i32 cpu_exclusive_val
;
93 static GHashTable
*xtensa_regfile_table
;
95 #include "exec/gen-icount.h"
97 static char *sr_name
[256];
98 static char *ur_name
[256];
100 void xtensa_collect_sr_names(const XtensaConfig
*config
)
102 xtensa_isa isa
= config
->isa
;
103 int n
= xtensa_isa_num_sysregs(isa
);
106 for (i
= 0; i
< n
; ++i
) {
107 int sr
= xtensa_sysreg_number(isa
, i
);
109 if (sr
>= 0 && sr
< 256) {
110 const char *name
= xtensa_sysreg_name(isa
, i
);
112 (xtensa_sysreg_is_user(isa
, i
) ? ur_name
: sr_name
) + sr
;
115 if (strstr(*pname
, name
) == NULL
) {
117 malloc(strlen(*pname
) + strlen(name
) + 2);
119 strcpy(new_name
, *pname
);
120 strcat(new_name
, "/");
121 strcat(new_name
, name
);
126 *pname
= strdup(name
);
132 void xtensa_translate_init(void)
134 static const char * const regnames
[] = {
135 "ar0", "ar1", "ar2", "ar3",
136 "ar4", "ar5", "ar6", "ar7",
137 "ar8", "ar9", "ar10", "ar11",
138 "ar12", "ar13", "ar14", "ar15",
140 static const char * const fregnames
[] = {
141 "f0", "f1", "f2", "f3",
142 "f4", "f5", "f6", "f7",
143 "f8", "f9", "f10", "f11",
144 "f12", "f13", "f14", "f15",
146 static const char * const mregnames
[] = {
147 "m0", "m1", "m2", "m3",
149 static const char * const bregnames
[] = {
150 "b0", "b1", "b2", "b3",
151 "b4", "b5", "b6", "b7",
152 "b8", "b9", "b10", "b11",
153 "b12", "b13", "b14", "b15",
157 cpu_pc
= tcg_global_mem_new_i32(cpu_env
,
158 offsetof(CPUXtensaState
, pc
), "pc");
160 for (i
= 0; i
< 16; i
++) {
161 cpu_R
[i
] = tcg_global_mem_new_i32(cpu_env
,
162 offsetof(CPUXtensaState
, regs
[i
]),
166 for (i
= 0; i
< 16; i
++) {
167 cpu_FR
[i
] = tcg_global_mem_new_i32(cpu_env
,
168 offsetof(CPUXtensaState
,
169 fregs
[i
].f32
[FP_F32_LOW
]),
173 for (i
= 0; i
< 16; i
++) {
174 cpu_FRD
[i
] = tcg_global_mem_new_i64(cpu_env
,
175 offsetof(CPUXtensaState
,
180 for (i
= 0; i
< 4; i
++) {
181 cpu_MR
[i
] = tcg_global_mem_new_i32(cpu_env
,
182 offsetof(CPUXtensaState
,
187 for (i
= 0; i
< 16; i
++) {
188 cpu_BR
[i
] = tcg_global_mem_new_i32(cpu_env
,
189 offsetof(CPUXtensaState
,
193 cpu_BR4
[i
/ 4] = tcg_global_mem_new_i32(cpu_env
,
194 offsetof(CPUXtensaState
,
199 cpu_BR8
[i
/ 8] = tcg_global_mem_new_i32(cpu_env
,
200 offsetof(CPUXtensaState
,
206 for (i
= 0; i
< 256; ++i
) {
208 cpu_SR
[i
] = tcg_global_mem_new_i32(cpu_env
,
209 offsetof(CPUXtensaState
,
215 for (i
= 0; i
< 256; ++i
) {
217 cpu_UR
[i
] = tcg_global_mem_new_i32(cpu_env
,
218 offsetof(CPUXtensaState
,
224 cpu_windowbase_next
=
225 tcg_global_mem_new_i32(cpu_env
,
226 offsetof(CPUXtensaState
, windowbase_next
),
229 tcg_global_mem_new_i32(cpu_env
,
230 offsetof(CPUXtensaState
, exclusive_addr
),
233 tcg_global_mem_new_i32(cpu_env
,
234 offsetof(CPUXtensaState
, exclusive_val
),
238 void **xtensa_get_regfile_by_name(const char *name
, int entries
, int bits
)
243 if (xtensa_regfile_table
== NULL
) {
244 xtensa_regfile_table
= g_hash_table_new(g_str_hash
, g_str_equal
);
246 * AR is special. Xtensa translator uses it as a current register
247 * window, but configuration overlays represent it as a complete
248 * physical register file.
250 g_hash_table_insert(xtensa_regfile_table
,
251 (void *)"AR 16x32", (void *)cpu_R
);
252 g_hash_table_insert(xtensa_regfile_table
,
253 (void *)"AR 32x32", (void *)cpu_R
);
254 g_hash_table_insert(xtensa_regfile_table
,
255 (void *)"AR 64x32", (void *)cpu_R
);
257 g_hash_table_insert(xtensa_regfile_table
,
258 (void *)"MR 4x32", (void *)cpu_MR
);
260 g_hash_table_insert(xtensa_regfile_table
,
261 (void *)"FR 16x32", (void *)cpu_FR
);
262 g_hash_table_insert(xtensa_regfile_table
,
263 (void *)"FR 16x64", (void *)cpu_FRD
);
265 g_hash_table_insert(xtensa_regfile_table
,
266 (void *)"BR 16x1", (void *)cpu_BR
);
267 g_hash_table_insert(xtensa_regfile_table
,
268 (void *)"BR4 4x4", (void *)cpu_BR4
);
269 g_hash_table_insert(xtensa_regfile_table
,
270 (void *)"BR8 2x8", (void *)cpu_BR8
);
273 geometry_name
= g_strdup_printf("%s %dx%d", name
, entries
, bits
);
274 res
= (void **)g_hash_table_lookup(xtensa_regfile_table
, geometry_name
);
275 g_free(geometry_name
);
279 static inline bool option_enabled(DisasContext
*dc
, int opt
)
281 return xtensa_option_enabled(dc
->config
, opt
);
284 static void init_sar_tracker(DisasContext
*dc
)
286 dc
->sar_5bit
= false;
287 dc
->sar_m32_5bit
= false;
288 dc
->sar_m32_allocated
= false;
291 static void reset_sar_tracker(DisasContext
*dc
)
293 if (dc
->sar_m32_allocated
) {
294 tcg_temp_free(dc
->sar_m32
);
298 static void gen_right_shift_sar(DisasContext
*dc
, TCGv_i32 sa
)
300 tcg_gen_andi_i32(cpu_SR
[SAR
], sa
, 0x1f);
301 if (dc
->sar_m32_5bit
) {
302 tcg_gen_discard_i32(dc
->sar_m32
);
305 dc
->sar_m32_5bit
= false;
308 static void gen_left_shift_sar(DisasContext
*dc
, TCGv_i32 sa
)
310 TCGv_i32 tmp
= tcg_const_i32(32);
311 if (!dc
->sar_m32_allocated
) {
312 dc
->sar_m32
= tcg_temp_local_new_i32();
313 dc
->sar_m32_allocated
= true;
315 tcg_gen_andi_i32(dc
->sar_m32
, sa
, 0x1f);
316 tcg_gen_sub_i32(cpu_SR
[SAR
], tmp
, dc
->sar_m32
);
317 dc
->sar_5bit
= false;
318 dc
->sar_m32_5bit
= true;
322 static void gen_exception(DisasContext
*dc
, int excp
)
324 TCGv_i32 tmp
= tcg_const_i32(excp
);
325 gen_helper_exception(cpu_env
, tmp
);
329 static void gen_exception_cause(DisasContext
*dc
, uint32_t cause
)
331 TCGv_i32 tpc
= tcg_const_i32(dc
->pc
);
332 TCGv_i32 tcause
= tcg_const_i32(cause
);
333 gen_helper_exception_cause(cpu_env
, tpc
, tcause
);
335 tcg_temp_free(tcause
);
336 if (cause
== ILLEGAL_INSTRUCTION_CAUSE
||
337 cause
== SYSCALL_CAUSE
) {
338 dc
->base
.is_jmp
= DISAS_NORETURN
;
342 static void gen_debug_exception(DisasContext
*dc
, uint32_t cause
)
344 TCGv_i32 tpc
= tcg_const_i32(dc
->pc
);
345 TCGv_i32 tcause
= tcg_const_i32(cause
);
346 gen_helper_debug_exception(cpu_env
, tpc
, tcause
);
348 tcg_temp_free(tcause
);
349 if (cause
& (DEBUGCAUSE_IB
| DEBUGCAUSE_BI
| DEBUGCAUSE_BN
)) {
350 dc
->base
.is_jmp
= DISAS_NORETURN
;
354 static bool gen_check_privilege(DisasContext
*dc
)
356 #ifndef CONFIG_USER_ONLY
361 gen_exception_cause(dc
, PRIVILEGED_CAUSE
);
362 dc
->base
.is_jmp
= DISAS_NORETURN
;
366 static bool gen_check_cpenable(DisasContext
*dc
, uint32_t cp_mask
)
368 cp_mask
&= ~dc
->cpenable
;
370 if (option_enabled(dc
, XTENSA_OPTION_COPROCESSOR
) && cp_mask
) {
371 gen_exception_cause(dc
, COPROCESSOR0_DISABLED
+ ctz32(cp_mask
));
372 dc
->base
.is_jmp
= DISAS_NORETURN
;
378 static int gen_postprocess(DisasContext
*dc
, int slot
);
380 static void gen_jump_slot(DisasContext
*dc
, TCGv dest
, int slot
)
382 tcg_gen_mov_i32(cpu_pc
, dest
);
384 tcg_gen_mov_i32(cpu_SR
[ICOUNT
], dc
->next_icount
);
386 if (dc
->base
.singlestep_enabled
) {
387 gen_exception(dc
, EXCP_DEBUG
);
389 if (dc
->op_flags
& XTENSA_OP_POSTPROCESS
) {
390 slot
= gen_postprocess(dc
, slot
);
393 tcg_gen_goto_tb(slot
);
394 tcg_gen_exit_tb(dc
->base
.tb
, slot
);
396 tcg_gen_exit_tb(NULL
, 0);
399 dc
->base
.is_jmp
= DISAS_NORETURN
;
402 static void gen_jump(DisasContext
*dc
, TCGv dest
)
404 gen_jump_slot(dc
, dest
, -1);
407 static int adjust_jump_slot(DisasContext
*dc
, uint32_t dest
, int slot
)
409 if (((dc
->base
.pc_first
^ dest
) & TARGET_PAGE_MASK
) != 0) {
416 static void gen_jumpi(DisasContext
*dc
, uint32_t dest
, int slot
)
418 TCGv_i32 tmp
= tcg_const_i32(dest
);
419 gen_jump_slot(dc
, tmp
, adjust_jump_slot(dc
, dest
, slot
));
423 static void gen_callw_slot(DisasContext
*dc
, int callinc
, TCGv_i32 dest
,
426 TCGv_i32 tcallinc
= tcg_const_i32(callinc
);
428 tcg_gen_deposit_i32(cpu_SR
[PS
], cpu_SR
[PS
],
429 tcallinc
, PS_CALLINC_SHIFT
, PS_CALLINC_LEN
);
430 tcg_temp_free(tcallinc
);
431 tcg_gen_movi_i32(cpu_R
[callinc
<< 2],
432 (callinc
<< 30) | (dc
->base
.pc_next
& 0x3fffffff));
433 gen_jump_slot(dc
, dest
, slot
);
436 static bool gen_check_loop_end(DisasContext
*dc
, int slot
)
438 if (dc
->base
.pc_next
== dc
->lend
) {
439 TCGLabel
*label
= gen_new_label();
441 tcg_gen_brcondi_i32(TCG_COND_EQ
, cpu_SR
[LCOUNT
], 0, label
);
442 tcg_gen_subi_i32(cpu_SR
[LCOUNT
], cpu_SR
[LCOUNT
], 1);
444 gen_jumpi(dc
, dc
->base
.pc_next
- dc
->lbeg_off
, slot
);
446 gen_jump(dc
, cpu_SR
[LBEG
]);
448 gen_set_label(label
);
449 gen_jumpi(dc
, dc
->base
.pc_next
, -1);
455 static void gen_jumpi_check_loop_end(DisasContext
*dc
, int slot
)
457 if (!gen_check_loop_end(dc
, slot
)) {
458 gen_jumpi(dc
, dc
->base
.pc_next
, slot
);
462 static void gen_brcond(DisasContext
*dc
, TCGCond cond
,
463 TCGv_i32 t0
, TCGv_i32 t1
, uint32_t addr
)
465 TCGLabel
*label
= gen_new_label();
467 tcg_gen_brcond_i32(cond
, t0
, t1
, label
);
468 gen_jumpi_check_loop_end(dc
, 0);
469 gen_set_label(label
);
470 gen_jumpi(dc
, addr
, 1);
473 static void gen_brcondi(DisasContext
*dc
, TCGCond cond
,
474 TCGv_i32 t0
, uint32_t t1
, uint32_t addr
)
476 TCGv_i32 tmp
= tcg_const_i32(t1
);
477 gen_brcond(dc
, cond
, t0
, tmp
, addr
);
481 static uint32_t test_exceptions_sr(DisasContext
*dc
, const OpcodeArg arg
[],
482 const uint32_t par
[])
484 return xtensa_option_enabled(dc
->config
, par
[1]) ? 0 : XTENSA_OP_ILL
;
487 static uint32_t test_exceptions_ccompare(DisasContext
*dc
,
488 const OpcodeArg arg
[],
489 const uint32_t par
[])
491 unsigned n
= par
[0] - CCOMPARE
;
493 if (n
>= dc
->config
->nccompare
) {
494 return XTENSA_OP_ILL
;
496 return test_exceptions_sr(dc
, arg
, par
);
499 static uint32_t test_exceptions_dbreak(DisasContext
*dc
, const OpcodeArg arg
[],
500 const uint32_t par
[])
502 unsigned n
= MAX_NDBREAK
;
504 if (par
[0] >= DBREAKA
&& par
[0] < DBREAKA
+ MAX_NDBREAK
) {
505 n
= par
[0] - DBREAKA
;
507 if (par
[0] >= DBREAKC
&& par
[0] < DBREAKC
+ MAX_NDBREAK
) {
508 n
= par
[0] - DBREAKC
;
510 if (n
>= dc
->config
->ndbreak
) {
511 return XTENSA_OP_ILL
;
513 return test_exceptions_sr(dc
, arg
, par
);
516 static uint32_t test_exceptions_ibreak(DisasContext
*dc
, const OpcodeArg arg
[],
517 const uint32_t par
[])
519 unsigned n
= par
[0] - IBREAKA
;
521 if (n
>= dc
->config
->nibreak
) {
522 return XTENSA_OP_ILL
;
524 return test_exceptions_sr(dc
, arg
, par
);
527 static uint32_t test_exceptions_hpi(DisasContext
*dc
, const OpcodeArg arg
[],
528 const uint32_t par
[])
530 unsigned n
= MAX_NLEVEL
+ 1;
532 if (par
[0] >= EXCSAVE1
&& par
[0] < EXCSAVE1
+ MAX_NLEVEL
) {
533 n
= par
[0] - EXCSAVE1
+ 1;
535 if (par
[0] >= EPC1
&& par
[0] < EPC1
+ MAX_NLEVEL
) {
536 n
= par
[0] - EPC1
+ 1;
538 if (par
[0] >= EPS2
&& par
[0] < EPS2
+ MAX_NLEVEL
- 1) {
539 n
= par
[0] - EPS2
+ 2;
541 if (n
> dc
->config
->nlevel
) {
542 return XTENSA_OP_ILL
;
544 return test_exceptions_sr(dc
, arg
, par
);
547 static MemOp
gen_load_store_alignment(DisasContext
*dc
, MemOp mop
,
550 if ((mop
& MO_SIZE
) == MO_8
) {
553 if ((mop
& MO_AMASK
) == MO_UNALN
&&
554 !option_enabled(dc
, XTENSA_OPTION_HW_ALIGNMENT
)) {
557 if (!option_enabled(dc
, XTENSA_OPTION_UNALIGNED_EXCEPTION
)) {
558 tcg_gen_andi_i32(addr
, addr
, ~0 << get_alignment_bits(mop
));
563 #ifndef CONFIG_USER_ONLY
564 static void gen_waiti(DisasContext
*dc
, uint32_t imm4
)
566 TCGv_i32 pc
= tcg_const_i32(dc
->base
.pc_next
);
567 TCGv_i32 intlevel
= tcg_const_i32(imm4
);
569 if (tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
) {
572 gen_helper_waiti(cpu_env
, pc
, intlevel
);
574 tcg_temp_free(intlevel
);
578 static bool gen_window_check(DisasContext
*dc
, uint32_t mask
)
580 unsigned r
= 31 - clz32(mask
);
582 if (r
/ 4 > dc
->window
) {
583 TCGv_i32 pc
= tcg_const_i32(dc
->pc
);
584 TCGv_i32 w
= tcg_const_i32(r
/ 4);
586 gen_helper_window_check(cpu_env
, pc
, w
);
587 dc
->base
.is_jmp
= DISAS_NORETURN
;
593 static TCGv_i32
gen_mac16_m(TCGv_i32 v
, bool hi
, bool is_unsigned
)
595 TCGv_i32 m
= tcg_temp_new_i32();
598 (is_unsigned
? tcg_gen_shri_i32
: tcg_gen_sari_i32
)(m
, v
, 16);
600 (is_unsigned
? tcg_gen_ext16u_i32
: tcg_gen_ext16s_i32
)(m
, v
);
605 static void gen_zero_check(DisasContext
*dc
, const OpcodeArg arg
[])
607 TCGLabel
*label
= gen_new_label();
609 tcg_gen_brcondi_i32(TCG_COND_NE
, arg
[2].in
, 0, label
);
610 gen_exception_cause(dc
, INTEGER_DIVIDE_BY_ZERO_CAUSE
);
611 gen_set_label(label
);
614 static inline unsigned xtensa_op0_insn_len(DisasContext
*dc
, uint8_t op0
)
616 return xtensa_isa_length_from_chars(dc
->config
->isa
, &op0
);
619 static int gen_postprocess(DisasContext
*dc
, int slot
)
621 uint32_t op_flags
= dc
->op_flags
;
623 #ifndef CONFIG_USER_ONLY
624 if (op_flags
& XTENSA_OP_CHECK_INTERRUPTS
) {
625 if (tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
) {
628 gen_helper_check_interrupts(cpu_env
);
631 if (op_flags
& XTENSA_OP_SYNC_REGISTER_WINDOW
) {
632 gen_helper_sync_windowbase(cpu_env
);
634 if (op_flags
& XTENSA_OP_EXIT_TB_M1
) {
640 struct opcode_arg_copy
{
646 struct opcode_arg_info
{
652 XtensaOpcodeOps
*ops
;
653 OpcodeArg arg
[MAX_OPCODE_ARGS
];
654 struct opcode_arg_info in
[MAX_OPCODE_ARGS
];
655 struct opcode_arg_info out
[MAX_OPCODE_ARGS
];
667 static uint32_t encode_resource(enum resource_type r
, unsigned g
, unsigned n
)
669 assert(r
< RES_MAX
&& g
< 256 && n
< 65536);
670 return (r
<< 24) | (g
<< 16) | n
;
673 static enum resource_type
get_resource_type(uint32_t resource
)
675 return resource
>> 24;
679 * a depends on b if b must be executed before a,
680 * because a's side effects will destroy b's inputs.
682 static bool op_depends_on(const struct slot_prop
*a
,
683 const struct slot_prop
*b
)
688 if (a
->op_flags
& XTENSA_OP_CONTROL_FLOW
) {
691 if ((a
->op_flags
& XTENSA_OP_LOAD_STORE
) <
692 (b
->op_flags
& XTENSA_OP_LOAD_STORE
)) {
695 while (i
< a
->n_out
&& j
< b
->n_in
) {
696 if (a
->out
[i
].resource
< b
->in
[j
].resource
) {
698 } else if (a
->out
[i
].resource
> b
->in
[j
].resource
) {
708 * Try to break a dependency on b, append temporary register copy records
709 * to the end of copy and update n_copy in case of success.
710 * This is not always possible: e.g. control flow must always be the last,
711 * load/store must be first and state dependencies are not supported yet.
713 static bool break_dependency(struct slot_prop
*a
,
715 struct opcode_arg_copy
*copy
,
720 unsigned n
= *n_copy
;
723 if (a
->op_flags
& XTENSA_OP_CONTROL_FLOW
) {
726 if ((a
->op_flags
& XTENSA_OP_LOAD_STORE
) <
727 (b
->op_flags
& XTENSA_OP_LOAD_STORE
)) {
730 while (i
< a
->n_out
&& j
< b
->n_in
) {
731 if (a
->out
[i
].resource
< b
->in
[j
].resource
) {
733 } else if (a
->out
[i
].resource
> b
->in
[j
].resource
) {
736 int index
= b
->in
[j
].index
;
738 if (get_resource_type(a
->out
[i
].resource
) != RES_REGFILE
||
742 copy
[n
].resource
= b
->in
[j
].resource
;
743 copy
[n
].arg
= b
->arg
+ index
;
754 * Calculate evaluation order for slot opcodes.
755 * Build opcode order graph and output its nodes in topological sort order.
756 * An edge a -> b in the graph means that opcode a must be followed by
759 static bool tsort(struct slot_prop
*slot
,
760 struct slot_prop
*sorted
[],
762 struct opcode_arg_copy
*copy
,
768 unsigned out_edge
[MAX_INSN_SLOTS
];
769 } node
[MAX_INSN_SLOTS
];
771 unsigned in
[MAX_INSN_SLOTS
];
777 unsigned node_idx
= 0;
779 for (i
= 0; i
< n
; ++i
) {
780 node
[i
].n_in_edge
= 0;
781 node
[i
].n_out_edge
= 0;
784 for (i
= 0; i
< n
; ++i
) {
785 unsigned n_out_edge
= 0;
787 for (j
= 0; j
< n
; ++j
) {
788 if (i
!= j
&& op_depends_on(slot
+ j
, slot
+ i
)) {
789 node
[i
].out_edge
[n_out_edge
] = j
;
795 node
[i
].n_out_edge
= n_out_edge
;
798 for (i
= 0; i
< n
; ++i
) {
799 if (!node
[i
].n_in_edge
) {
806 for (; in_idx
< n_in
; ++in_idx
) {
808 sorted
[n_out
] = slot
+ i
;
810 for (j
= 0; j
< node
[i
].n_out_edge
; ++j
) {
812 if (--node
[node
[i
].out_edge
[j
]].n_in_edge
== 0) {
813 in
[n_in
] = node
[i
].out_edge
[j
];
819 for (; node_idx
< n
; ++node_idx
) {
820 struct tsnode
*cnode
= node
+ node_idx
;
822 if (cnode
->n_in_edge
) {
823 for (j
= 0; j
< cnode
->n_out_edge
; ++j
) {
824 unsigned k
= cnode
->out_edge
[j
];
826 if (break_dependency(slot
+ k
, slot
+ node_idx
,
828 --node
[k
].n_in_edge
== 0) {
833 cnode
->out_edge
[cnode
->n_out_edge
- 1];
844 static void opcode_add_resource(struct slot_prop
*op
,
845 uint32_t resource
, char direction
,
851 assert(op
->n_in
< ARRAY_SIZE(op
->in
));
852 op
->in
[op
->n_in
].resource
= resource
;
853 op
->in
[op
->n_in
].index
= index
;
857 if (direction
== 'm' || direction
== 'o') {
858 assert(op
->n_out
< ARRAY_SIZE(op
->out
));
859 op
->out
[op
->n_out
].resource
= resource
;
860 op
->out
[op
->n_out
].index
= index
;
865 g_assert_not_reached();
869 static int resource_compare(const void *a
, const void *b
)
871 const struct opcode_arg_info
*pa
= a
;
872 const struct opcode_arg_info
*pb
= b
;
874 return pa
->resource
< pb
->resource
?
875 -1 : (pa
->resource
> pb
->resource
? 1 : 0);
878 static int arg_copy_compare(const void *a
, const void *b
)
880 const struct opcode_arg_copy
*pa
= a
;
881 const struct opcode_arg_copy
*pb
= b
;
883 return pa
->resource
< pb
->resource
?
884 -1 : (pa
->resource
> pb
->resource
? 1 : 0);
887 static void disas_xtensa_insn(CPUXtensaState
*env
, DisasContext
*dc
)
889 xtensa_isa isa
= dc
->config
->isa
;
890 unsigned char b
[MAX_INSN_LENGTH
] = {translator_ldub(env
, dc
->pc
)};
891 unsigned len
= xtensa_op0_insn_len(dc
, b
[0]);
895 uint32_t op_flags
= 0;
896 struct slot_prop slot_prop
[MAX_INSN_SLOTS
];
897 struct slot_prop
*ordered
[MAX_INSN_SLOTS
];
898 struct opcode_arg_copy arg_copy
[MAX_INSN_SLOTS
* MAX_OPCODE_ARGS
];
899 unsigned n_arg_copy
= 0;
900 uint32_t debug_cause
= 0;
901 uint32_t windowed_register
= 0;
902 uint32_t coprocessor
= 0;
904 if (len
== XTENSA_UNDEFINED
) {
905 qemu_log_mask(LOG_GUEST_ERROR
,
906 "unknown instruction length (pc = %08x)\n",
908 gen_exception_cause(dc
, ILLEGAL_INSTRUCTION_CAUSE
);
909 dc
->base
.pc_next
= dc
->pc
+ 1;
913 dc
->base
.pc_next
= dc
->pc
+ len
;
914 for (i
= 1; i
< len
; ++i
) {
915 b
[i
] = translator_ldub(env
, dc
->pc
+ i
);
917 xtensa_insnbuf_from_chars(isa
, dc
->insnbuf
, b
, len
);
918 fmt
= xtensa_format_decode(isa
, dc
->insnbuf
);
919 if (fmt
== XTENSA_UNDEFINED
) {
920 qemu_log_mask(LOG_GUEST_ERROR
,
921 "unrecognized instruction format (pc = %08x)\n",
923 gen_exception_cause(dc
, ILLEGAL_INSTRUCTION_CAUSE
);
926 slots
= xtensa_format_num_slots(isa
, fmt
);
927 for (slot
= 0; slot
< slots
; ++slot
) {
929 int opnd
, vopnd
, opnds
;
930 OpcodeArg
*arg
= slot_prop
[slot
].arg
;
931 XtensaOpcodeOps
*ops
;
933 xtensa_format_get_slot(isa
, fmt
, slot
, dc
->insnbuf
, dc
->slotbuf
);
934 opc
= xtensa_opcode_decode(isa
, fmt
, slot
, dc
->slotbuf
);
935 if (opc
== XTENSA_UNDEFINED
) {
936 qemu_log_mask(LOG_GUEST_ERROR
,
937 "unrecognized opcode in slot %d (pc = %08x)\n",
939 gen_exception_cause(dc
, ILLEGAL_INSTRUCTION_CAUSE
);
942 opnds
= xtensa_opcode_num_operands(isa
, opc
);
944 for (opnd
= vopnd
= 0; opnd
< opnds
; ++opnd
) {
945 void **register_file
= NULL
;
948 if (xtensa_operand_is_register(isa
, opc
, opnd
)) {
949 rf
= xtensa_operand_regfile(isa
, opc
, opnd
);
950 register_file
= dc
->config
->regfile
[rf
];
952 if (rf
== dc
->config
->a_regfile
) {
955 xtensa_operand_get_field(isa
, opc
, opnd
, fmt
, slot
,
957 xtensa_operand_decode(isa
, opc
, opnd
, &v
);
958 windowed_register
|= 1u << v
;
961 if (xtensa_operand_is_visible(isa
, opc
, opnd
)) {
964 xtensa_operand_get_field(isa
, opc
, opnd
, fmt
, slot
,
966 xtensa_operand_decode(isa
, opc
, opnd
, &v
);
967 arg
[vopnd
].raw_imm
= v
;
968 if (xtensa_operand_is_PCrelative(isa
, opc
, opnd
)) {
969 xtensa_operand_undo_reloc(isa
, opc
, opnd
, &v
, dc
->pc
);
973 arg
[vopnd
].in
= register_file
[v
];
974 arg
[vopnd
].out
= register_file
[v
];
975 arg
[vopnd
].num_bits
= xtensa_regfile_num_bits(isa
, rf
);
977 arg
[vopnd
].num_bits
= 32;
982 ops
= dc
->config
->opcode_ops
[opc
];
983 slot_prop
[slot
].ops
= ops
;
986 op_flags
|= ops
->op_flags
;
987 if (ops
->test_exceptions
) {
988 op_flags
|= ops
->test_exceptions(dc
, arg
, ops
->par
);
991 qemu_log_mask(LOG_UNIMP
,
992 "unimplemented opcode '%s' in slot %d (pc = %08x)\n",
993 xtensa_opcode_name(isa
, opc
), slot
, dc
->pc
);
994 op_flags
|= XTENSA_OP_ILL
;
996 if (op_flags
& XTENSA_OP_ILL
) {
997 gen_exception_cause(dc
, ILLEGAL_INSTRUCTION_CAUSE
);
1000 if (op_flags
& XTENSA_OP_DEBUG_BREAK
) {
1001 debug_cause
|= ops
->par
[0];
1003 if (ops
->test_overflow
) {
1004 windowed_register
|= ops
->test_overflow(dc
, arg
, ops
->par
);
1006 coprocessor
|= ops
->coprocessor
;
1009 slot_prop
[slot
].n_in
= 0;
1010 slot_prop
[slot
].n_out
= 0;
1011 slot_prop
[slot
].op_flags
= ops
->op_flags
& XTENSA_OP_LOAD_STORE
;
1013 opnds
= xtensa_opcode_num_operands(isa
, opc
);
1015 for (opnd
= vopnd
= 0; opnd
< opnds
; ++opnd
) {
1016 bool visible
= xtensa_operand_is_visible(isa
, opc
, opnd
);
1018 if (xtensa_operand_is_register(isa
, opc
, opnd
)) {
1019 xtensa_regfile rf
= xtensa_operand_regfile(isa
, opc
, opnd
);
1022 xtensa_operand_get_field(isa
, opc
, opnd
, fmt
, slot
,
1024 xtensa_operand_decode(isa
, opc
, opnd
, &v
);
1025 opcode_add_resource(slot_prop
+ slot
,
1026 encode_resource(RES_REGFILE
, rf
, v
),
1027 xtensa_operand_inout(isa
, opc
, opnd
),
1028 visible
? vopnd
: -1);
1035 opnds
= xtensa_opcode_num_stateOperands(isa
, opc
);
1037 for (opnd
= 0; opnd
< opnds
; ++opnd
) {
1038 xtensa_state state
= xtensa_stateOperand_state(isa
, opc
, opnd
);
1040 opcode_add_resource(slot_prop
+ slot
,
1041 encode_resource(RES_STATE
, 0, state
),
1042 xtensa_stateOperand_inout(isa
, opc
, opnd
),
1045 if (xtensa_opcode_is_branch(isa
, opc
) ||
1046 xtensa_opcode_is_jump(isa
, opc
) ||
1047 xtensa_opcode_is_loop(isa
, opc
) ||
1048 xtensa_opcode_is_call(isa
, opc
)) {
1049 slot_prop
[slot
].op_flags
|= XTENSA_OP_CONTROL_FLOW
;
1052 qsort(slot_prop
[slot
].in
, slot_prop
[slot
].n_in
,
1053 sizeof(slot_prop
[slot
].in
[0]), resource_compare
);
1054 qsort(slot_prop
[slot
].out
, slot_prop
[slot
].n_out
,
1055 sizeof(slot_prop
[slot
].out
[0]), resource_compare
);
1060 if (!tsort(slot_prop
, ordered
, slots
, arg_copy
, &n_arg_copy
)) {
1061 qemu_log_mask(LOG_UNIMP
,
1062 "Circular resource dependencies (pc = %08x)\n",
1064 gen_exception_cause(dc
, ILLEGAL_INSTRUCTION_CAUSE
);
1068 ordered
[0] = slot_prop
+ 0;
1071 if ((op_flags
& XTENSA_OP_PRIVILEGED
) &&
1072 !gen_check_privilege(dc
)) {
1076 if (op_flags
& XTENSA_OP_SYSCALL
) {
1077 gen_exception_cause(dc
, SYSCALL_CAUSE
);
1081 if ((op_flags
& XTENSA_OP_DEBUG_BREAK
) && dc
->debug
) {
1082 gen_debug_exception(dc
, debug_cause
);
1086 if (windowed_register
&& !gen_window_check(dc
, windowed_register
)) {
1090 if (op_flags
& XTENSA_OP_UNDERFLOW
) {
1091 TCGv_i32 tmp
= tcg_const_i32(dc
->pc
);
1093 gen_helper_test_underflow_retw(cpu_env
, tmp
);
1097 if (op_flags
& XTENSA_OP_ALLOCA
) {
1098 TCGv_i32 tmp
= tcg_const_i32(dc
->pc
);
1100 gen_helper_movsp(cpu_env
, tmp
);
1104 if (coprocessor
&& !gen_check_cpenable(dc
, coprocessor
)) {
1113 qsort(arg_copy
, n_arg_copy
, sizeof(*arg_copy
), arg_copy_compare
);
1114 for (i
= j
= 0; i
< n_arg_copy
; ++i
) {
1115 if (i
== 0 || arg_copy
[i
].resource
!= resource
) {
1116 resource
= arg_copy
[i
].resource
;
1117 if (arg_copy
[i
].arg
->num_bits
<= 32) {
1118 temp
= tcg_temp_local_new_i32();
1119 tcg_gen_mov_i32(temp
, arg_copy
[i
].arg
->in
);
1120 } else if (arg_copy
[i
].arg
->num_bits
<= 64) {
1121 temp
= tcg_temp_local_new_i64();
1122 tcg_gen_mov_i64(temp
, arg_copy
[i
].arg
->in
);
1124 g_assert_not_reached();
1126 arg_copy
[i
].temp
= temp
;
1129 arg_copy
[j
] = arg_copy
[i
];
1133 arg_copy
[i
].arg
->in
= temp
;
1138 if (op_flags
& XTENSA_OP_DIVIDE_BY_ZERO
) {
1139 for (slot
= 0; slot
< slots
; ++slot
) {
1140 if (slot_prop
[slot
].ops
->op_flags
& XTENSA_OP_DIVIDE_BY_ZERO
) {
1141 gen_zero_check(dc
, slot_prop
[slot
].arg
);
1146 dc
->op_flags
= op_flags
;
1148 for (slot
= 0; slot
< slots
; ++slot
) {
1149 struct slot_prop
*pslot
= ordered
[slot
];
1150 XtensaOpcodeOps
*ops
= pslot
->ops
;
1152 ops
->translate(dc
, pslot
->arg
, ops
->par
);
1155 for (i
= 0; i
< n_arg_copy
; ++i
) {
1156 if (arg_copy
[i
].arg
->num_bits
<= 32) {
1157 tcg_temp_free_i32(arg_copy
[i
].temp
);
1158 } else if (arg_copy
[i
].arg
->num_bits
<= 64) {
1159 tcg_temp_free_i64(arg_copy
[i
].temp
);
1161 g_assert_not_reached();
1165 if (dc
->base
.is_jmp
== DISAS_NEXT
) {
1166 gen_postprocess(dc
, 0);
1168 if (op_flags
& XTENSA_OP_EXIT_TB_M1
) {
1169 /* Change in mmu index, memory mapping or tb->flags; exit tb */
1170 gen_jumpi_check_loop_end(dc
, -1);
1171 } else if (op_flags
& XTENSA_OP_EXIT_TB_0
) {
1172 gen_jumpi_check_loop_end(dc
, 0);
1174 gen_check_loop_end(dc
, 0);
1177 dc
->pc
= dc
->base
.pc_next
;
1180 static inline unsigned xtensa_insn_len(CPUXtensaState
*env
, DisasContext
*dc
)
1182 uint8_t b0
= cpu_ldub_code(env
, dc
->pc
);
1183 return xtensa_op0_insn_len(dc
, b0
);
1186 static void gen_ibreak_check(CPUXtensaState
*env
, DisasContext
*dc
)
1190 for (i
= 0; i
< dc
->config
->nibreak
; ++i
) {
1191 if ((env
->sregs
[IBREAKENABLE
] & (1 << i
)) &&
1192 env
->sregs
[IBREAKA
+ i
] == dc
->pc
) {
1193 gen_debug_exception(dc
, DEBUGCAUSE_IB
);
1199 static void xtensa_tr_init_disas_context(DisasContextBase
*dcbase
,
1202 DisasContext
*dc
= container_of(dcbase
, DisasContext
, base
);
1203 CPUXtensaState
*env
= cpu
->env_ptr
;
1204 uint32_t tb_flags
= dc
->base
.tb
->flags
;
1206 dc
->config
= env
->config
;
1207 dc
->pc
= dc
->base
.pc_first
;
1208 dc
->ring
= tb_flags
& XTENSA_TBFLAG_RING_MASK
;
1209 dc
->cring
= (tb_flags
& XTENSA_TBFLAG_EXCM
) ? 0 : dc
->ring
;
1210 dc
->lbeg_off
= (dc
->base
.tb
->cs_base
& XTENSA_CSBASE_LBEG_OFF_MASK
) >>
1211 XTENSA_CSBASE_LBEG_OFF_SHIFT
;
1212 dc
->lend
= (dc
->base
.tb
->cs_base
& XTENSA_CSBASE_LEND_MASK
) +
1213 (dc
->base
.pc_first
& TARGET_PAGE_MASK
);
1214 dc
->debug
= tb_flags
& XTENSA_TBFLAG_DEBUG
;
1215 dc
->icount
= tb_flags
& XTENSA_TBFLAG_ICOUNT
;
1216 dc
->cpenable
= (tb_flags
& XTENSA_TBFLAG_CPENABLE_MASK
) >>
1217 XTENSA_TBFLAG_CPENABLE_SHIFT
;
1218 dc
->window
= ((tb_flags
& XTENSA_TBFLAG_WINDOW_MASK
) >>
1219 XTENSA_TBFLAG_WINDOW_SHIFT
);
1220 dc
->cwoe
= tb_flags
& XTENSA_TBFLAG_CWOE
;
1221 dc
->callinc
= ((tb_flags
& XTENSA_TBFLAG_CALLINC_MASK
) >>
1222 XTENSA_TBFLAG_CALLINC_SHIFT
);
1223 init_sar_tracker(dc
);
1226 static void xtensa_tr_tb_start(DisasContextBase
*dcbase
, CPUState
*cpu
)
1228 DisasContext
*dc
= container_of(dcbase
, DisasContext
, base
);
1231 dc
->next_icount
= tcg_temp_local_new_i32();
1235 static void xtensa_tr_insn_start(DisasContextBase
*dcbase
, CPUState
*cpu
)
1237 tcg_gen_insn_start(dcbase
->pc_next
);
1240 static bool xtensa_tr_breakpoint_check(DisasContextBase
*dcbase
, CPUState
*cpu
,
1241 const CPUBreakpoint
*bp
)
1243 DisasContext
*dc
= container_of(dcbase
, DisasContext
, base
);
1245 tcg_gen_movi_i32(cpu_pc
, dc
->base
.pc_next
);
1246 gen_exception(dc
, EXCP_DEBUG
);
1247 dc
->base
.is_jmp
= DISAS_NORETURN
;
1248 /* The address covered by the breakpoint must be included in
1249 [tb->pc, tb->pc + tb->size) in order to for it to be
1250 properly cleared -- thus we increment the PC here so that
1251 the logic setting tb->size below does the right thing. */
1252 dc
->base
.pc_next
+= 2;
1256 static void xtensa_tr_translate_insn(DisasContextBase
*dcbase
, CPUState
*cpu
)
1258 DisasContext
*dc
= container_of(dcbase
, DisasContext
, base
);
1259 CPUXtensaState
*env
= cpu
->env_ptr
;
1260 target_ulong page_start
;
1262 /* These two conditions only apply to the first insn in the TB,
1263 but this is the first TranslateOps hook that allows exiting. */
1264 if ((tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
)
1265 && (dc
->base
.tb
->flags
& XTENSA_TBFLAG_YIELD
)) {
1266 gen_exception(dc
, EXCP_YIELD
);
1267 dc
->base
.pc_next
= dc
->pc
+ 1;
1268 dc
->base
.is_jmp
= DISAS_NORETURN
;
1273 TCGLabel
*label
= gen_new_label();
1275 tcg_gen_addi_i32(dc
->next_icount
, cpu_SR
[ICOUNT
], 1);
1276 tcg_gen_brcondi_i32(TCG_COND_NE
, dc
->next_icount
, 0, label
);
1277 tcg_gen_mov_i32(dc
->next_icount
, cpu_SR
[ICOUNT
]);
1279 gen_debug_exception(dc
, DEBUGCAUSE_IC
);
1281 gen_set_label(label
);
1285 gen_ibreak_check(env
, dc
);
1288 disas_xtensa_insn(env
, dc
);
1291 tcg_gen_mov_i32(cpu_SR
[ICOUNT
], dc
->next_icount
);
1294 /* End the TB if the next insn will cross into the next page. */
1295 page_start
= dc
->base
.pc_first
& TARGET_PAGE_MASK
;
1296 if (dc
->base
.is_jmp
== DISAS_NEXT
&&
1297 (dc
->pc
- page_start
>= TARGET_PAGE_SIZE
||
1298 dc
->pc
- page_start
+ xtensa_insn_len(env
, dc
) > TARGET_PAGE_SIZE
)) {
1299 dc
->base
.is_jmp
= DISAS_TOO_MANY
;
1303 static void xtensa_tr_tb_stop(DisasContextBase
*dcbase
, CPUState
*cpu
)
1305 DisasContext
*dc
= container_of(dcbase
, DisasContext
, base
);
1307 reset_sar_tracker(dc
);
1309 tcg_temp_free(dc
->next_icount
);
1312 switch (dc
->base
.is_jmp
) {
1313 case DISAS_NORETURN
:
1315 case DISAS_TOO_MANY
:
1316 if (dc
->base
.singlestep_enabled
) {
1317 tcg_gen_movi_i32(cpu_pc
, dc
->pc
);
1318 gen_exception(dc
, EXCP_DEBUG
);
1320 gen_jumpi(dc
, dc
->pc
, 0);
1324 g_assert_not_reached();
1328 static void xtensa_tr_disas_log(const DisasContextBase
*dcbase
, CPUState
*cpu
)
1330 qemu_log("IN: %s\n", lookup_symbol(dcbase
->pc_first
));
1331 log_target_disas(cpu
, dcbase
->pc_first
, dcbase
->tb
->size
);
1334 static const TranslatorOps xtensa_translator_ops
= {
1335 .init_disas_context
= xtensa_tr_init_disas_context
,
1336 .tb_start
= xtensa_tr_tb_start
,
1337 .insn_start
= xtensa_tr_insn_start
,
1338 .breakpoint_check
= xtensa_tr_breakpoint_check
,
1339 .translate_insn
= xtensa_tr_translate_insn
,
1340 .tb_stop
= xtensa_tr_tb_stop
,
1341 .disas_log
= xtensa_tr_disas_log
,
1344 void gen_intermediate_code(CPUState
*cpu
, TranslationBlock
*tb
, int max_insns
)
1346 DisasContext dc
= {};
1347 translator_loop(&xtensa_translator_ops
, &dc
.base
, cpu
, tb
, max_insns
);
1350 void xtensa_cpu_dump_state(CPUState
*cs
, FILE *f
, int flags
)
1352 XtensaCPU
*cpu
= XTENSA_CPU(cs
);
1353 CPUXtensaState
*env
= &cpu
->env
;
1354 xtensa_isa isa
= env
->config
->isa
;
1357 qemu_fprintf(f
, "PC=%08x\n\n", env
->pc
);
1359 for (i
= j
= 0; i
< xtensa_isa_num_sysregs(isa
); ++i
) {
1360 const uint32_t *reg
=
1361 xtensa_sysreg_is_user(isa
, i
) ? env
->uregs
: env
->sregs
;
1362 int regno
= xtensa_sysreg_number(isa
, i
);
1365 qemu_fprintf(f
, "%12s=%08x%c",
1366 xtensa_sysreg_name(isa
, i
),
1368 (j
++ % 4) == 3 ? '\n' : ' ');
1372 qemu_fprintf(f
, (j
% 4) == 0 ? "\n" : "\n\n");
1374 for (i
= 0; i
< 16; ++i
) {
1375 qemu_fprintf(f
, " A%02d=%08x%c",
1376 i
, env
->regs
[i
], (i
% 4) == 3 ? '\n' : ' ');
1379 xtensa_sync_phys_from_window(env
);
1380 qemu_fprintf(f
, "\n");
1382 for (i
= 0; i
< env
->config
->nareg
; ++i
) {
1383 qemu_fprintf(f
, "AR%02d=%08x ", i
, env
->phys_regs
[i
]);
1385 bool ws
= (env
->sregs
[WINDOW_START
] & (1 << (i
/ 4))) != 0;
1386 bool cw
= env
->sregs
[WINDOW_BASE
] == i
/ 4;
1388 qemu_fprintf(f
, "%c%c\n", ws
? '<' : ' ', cw
? '=' : ' ');
1392 if ((flags
& CPU_DUMP_FPU
) &&
1393 xtensa_option_enabled(env
->config
, XTENSA_OPTION_FP_COPROCESSOR
)) {
1394 qemu_fprintf(f
, "\n");
1396 for (i
= 0; i
< 16; ++i
) {
1397 qemu_fprintf(f
, "F%02d=%08x (%-+15.8e)%c", i
,
1398 float32_val(env
->fregs
[i
].f32
[FP_F32_LOW
]),
1399 *(float *)(env
->fregs
[i
].f32
+ FP_F32_LOW
),
1400 (i
% 2) == 1 ? '\n' : ' ');
1404 if ((flags
& CPU_DUMP_FPU
) &&
1405 xtensa_option_enabled(env
->config
, XTENSA_OPTION_DFP_COPROCESSOR
) &&
1406 !xtensa_option_enabled(env
->config
, XTENSA_OPTION_DFPU_SINGLE_ONLY
)) {
1407 qemu_fprintf(f
, "\n");
1409 for (i
= 0; i
< 16; ++i
) {
1410 qemu_fprintf(f
, "F%02d=%016"PRIx64
" (%-+24.16le)%c", i
,
1411 float64_val(env
->fregs
[i
].f64
),
1412 *(double *)(&env
->fregs
[i
].f64
),
1413 (i
% 2) == 1 ? '\n' : ' ');
1418 void restore_state_to_opc(CPUXtensaState
*env
, TranslationBlock
*tb
,
1424 static void translate_abs(DisasContext
*dc
, const OpcodeArg arg
[],
1425 const uint32_t par
[])
1427 tcg_gen_abs_i32(arg
[0].out
, arg
[1].in
);
1430 static void translate_add(DisasContext
*dc
, const OpcodeArg arg
[],
1431 const uint32_t par
[])
1433 tcg_gen_add_i32(arg
[0].out
, arg
[1].in
, arg
[2].in
);
1436 static void translate_addi(DisasContext
*dc
, const OpcodeArg arg
[],
1437 const uint32_t par
[])
1439 tcg_gen_addi_i32(arg
[0].out
, arg
[1].in
, arg
[2].imm
);
1442 static void translate_addx(DisasContext
*dc
, const OpcodeArg arg
[],
1443 const uint32_t par
[])
1445 TCGv_i32 tmp
= tcg_temp_new_i32();
1446 tcg_gen_shli_i32(tmp
, arg
[1].in
, par
[0]);
1447 tcg_gen_add_i32(arg
[0].out
, tmp
, arg
[2].in
);
1451 static void translate_all(DisasContext
*dc
, const OpcodeArg arg
[],
1452 const uint32_t par
[])
1454 uint32_t shift
= par
[1];
1455 TCGv_i32 mask
= tcg_const_i32(((1 << shift
) - 1) << arg
[1].imm
);
1456 TCGv_i32 tmp
= tcg_temp_new_i32();
1458 tcg_gen_and_i32(tmp
, arg
[1].in
, mask
);
1460 tcg_gen_addi_i32(tmp
, tmp
, 1 << arg
[1].imm
);
1462 tcg_gen_add_i32(tmp
, tmp
, mask
);
1464 tcg_gen_shri_i32(tmp
, tmp
, arg
[1].imm
+ shift
);
1465 tcg_gen_deposit_i32(arg
[0].out
, arg
[0].out
,
1466 tmp
, arg
[0].imm
, 1);
1467 tcg_temp_free(mask
);
1471 static void translate_and(DisasContext
*dc
, const OpcodeArg arg
[],
1472 const uint32_t par
[])
1474 tcg_gen_and_i32(arg
[0].out
, arg
[1].in
, arg
[2].in
);
1477 static void translate_ball(DisasContext
*dc
, const OpcodeArg arg
[],
1478 const uint32_t par
[])
1480 TCGv_i32 tmp
= tcg_temp_new_i32();
1481 tcg_gen_and_i32(tmp
, arg
[0].in
, arg
[1].in
);
1482 gen_brcond(dc
, par
[0], tmp
, arg
[1].in
, arg
[2].imm
);
1486 static void translate_bany(DisasContext
*dc
, const OpcodeArg arg
[],
1487 const uint32_t par
[])
1489 TCGv_i32 tmp
= tcg_temp_new_i32();
1490 tcg_gen_and_i32(tmp
, arg
[0].in
, arg
[1].in
);
1491 gen_brcondi(dc
, par
[0], tmp
, 0, arg
[2].imm
);
1495 static void translate_b(DisasContext
*dc
, const OpcodeArg arg
[],
1496 const uint32_t par
[])
1498 gen_brcond(dc
, par
[0], arg
[0].in
, arg
[1].in
, arg
[2].imm
);
1501 static void translate_bb(DisasContext
*dc
, const OpcodeArg arg
[],
1502 const uint32_t par
[])
1504 #ifdef TARGET_WORDS_BIGENDIAN
1505 TCGv_i32 bit
= tcg_const_i32(0x80000000u
);
1507 TCGv_i32 bit
= tcg_const_i32(0x00000001u
);
1509 TCGv_i32 tmp
= tcg_temp_new_i32();
1510 tcg_gen_andi_i32(tmp
, arg
[1].in
, 0x1f);
1511 #ifdef TARGET_WORDS_BIGENDIAN
1512 tcg_gen_shr_i32(bit
, bit
, tmp
);
1514 tcg_gen_shl_i32(bit
, bit
, tmp
);
1516 tcg_gen_and_i32(tmp
, arg
[0].in
, bit
);
1517 gen_brcondi(dc
, par
[0], tmp
, 0, arg
[2].imm
);
1522 static void translate_bbi(DisasContext
*dc
, const OpcodeArg arg
[],
1523 const uint32_t par
[])
1525 TCGv_i32 tmp
= tcg_temp_new_i32();
1526 #ifdef TARGET_WORDS_BIGENDIAN
1527 tcg_gen_andi_i32(tmp
, arg
[0].in
, 0x80000000u
>> arg
[1].imm
);
1529 tcg_gen_andi_i32(tmp
, arg
[0].in
, 0x00000001u
<< arg
[1].imm
);
1531 gen_brcondi(dc
, par
[0], tmp
, 0, arg
[2].imm
);
1535 static void translate_bi(DisasContext
*dc
, const OpcodeArg arg
[],
1536 const uint32_t par
[])
1538 gen_brcondi(dc
, par
[0], arg
[0].in
, arg
[1].imm
, arg
[2].imm
);
1541 static void translate_bz(DisasContext
*dc
, const OpcodeArg arg
[],
1542 const uint32_t par
[])
1544 gen_brcondi(dc
, par
[0], arg
[0].in
, 0, arg
[1].imm
);
1555 static void translate_boolean(DisasContext
*dc
, const OpcodeArg arg
[],
1556 const uint32_t par
[])
1558 static void (* const op
[])(TCGv_i32
, TCGv_i32
, TCGv_i32
) = {
1559 [BOOLEAN_AND
] = tcg_gen_and_i32
,
1560 [BOOLEAN_ANDC
] = tcg_gen_andc_i32
,
1561 [BOOLEAN_OR
] = tcg_gen_or_i32
,
1562 [BOOLEAN_ORC
] = tcg_gen_orc_i32
,
1563 [BOOLEAN_XOR
] = tcg_gen_xor_i32
,
1566 TCGv_i32 tmp1
= tcg_temp_new_i32();
1567 TCGv_i32 tmp2
= tcg_temp_new_i32();
1569 tcg_gen_shri_i32(tmp1
, arg
[1].in
, arg
[1].imm
);
1570 tcg_gen_shri_i32(tmp2
, arg
[2].in
, arg
[2].imm
);
1571 op
[par
[0]](tmp1
, tmp1
, tmp2
);
1572 tcg_gen_deposit_i32(arg
[0].out
, arg
[0].out
, tmp1
, arg
[0].imm
, 1);
1573 tcg_temp_free(tmp1
);
1574 tcg_temp_free(tmp2
);
1577 static void translate_bp(DisasContext
*dc
, const OpcodeArg arg
[],
1578 const uint32_t par
[])
1580 TCGv_i32 tmp
= tcg_temp_new_i32();
1582 tcg_gen_andi_i32(tmp
, arg
[0].in
, 1 << arg
[0].imm
);
1583 gen_brcondi(dc
, par
[0], tmp
, 0, arg
[1].imm
);
1587 static void translate_call0(DisasContext
*dc
, const OpcodeArg arg
[],
1588 const uint32_t par
[])
1590 tcg_gen_movi_i32(cpu_R
[0], dc
->base
.pc_next
);
1591 gen_jumpi(dc
, arg
[0].imm
, 0);
1594 static void translate_callw(DisasContext
*dc
, const OpcodeArg arg
[],
1595 const uint32_t par
[])
1597 TCGv_i32 tmp
= tcg_const_i32(arg
[0].imm
);
1598 gen_callw_slot(dc
, par
[0], tmp
, adjust_jump_slot(dc
, arg
[0].imm
, 0));
1602 static void translate_callx0(DisasContext
*dc
, const OpcodeArg arg
[],
1603 const uint32_t par
[])
1605 TCGv_i32 tmp
= tcg_temp_new_i32();
1606 tcg_gen_mov_i32(tmp
, arg
[0].in
);
1607 tcg_gen_movi_i32(cpu_R
[0], dc
->base
.pc_next
);
1612 static void translate_callxw(DisasContext
*dc
, const OpcodeArg arg
[],
1613 const uint32_t par
[])
1615 TCGv_i32 tmp
= tcg_temp_new_i32();
1617 tcg_gen_mov_i32(tmp
, arg
[0].in
);
1618 gen_callw_slot(dc
, par
[0], tmp
, -1);
1622 static void translate_clamps(DisasContext
*dc
, const OpcodeArg arg
[],
1623 const uint32_t par
[])
1625 TCGv_i32 tmp1
= tcg_const_i32(-1u << arg
[2].imm
);
1626 TCGv_i32 tmp2
= tcg_const_i32((1 << arg
[2].imm
) - 1);
1628 tcg_gen_smax_i32(tmp1
, tmp1
, arg
[1].in
);
1629 tcg_gen_smin_i32(arg
[0].out
, tmp1
, tmp2
);
1630 tcg_temp_free(tmp1
);
1631 tcg_temp_free(tmp2
);
1634 static void translate_clrb_expstate(DisasContext
*dc
, const OpcodeArg arg
[],
1635 const uint32_t par
[])
1637 /* TODO: GPIO32 may be a part of coprocessor */
1638 tcg_gen_andi_i32(cpu_UR
[EXPSTATE
], cpu_UR
[EXPSTATE
], ~(1u << arg
[0].imm
));
1641 static void translate_clrex(DisasContext
*dc
, const OpcodeArg arg
[],
1642 const uint32_t par
[])
1644 tcg_gen_movi_i32(cpu_exclusive_addr
, -1);
1647 static void translate_const16(DisasContext
*dc
, const OpcodeArg arg
[],
1648 const uint32_t par
[])
1650 TCGv_i32 c
= tcg_const_i32(arg
[1].imm
);
1652 tcg_gen_deposit_i32(arg
[0].out
, c
, arg
[0].in
, 16, 16);
1656 static void translate_dcache(DisasContext
*dc
, const OpcodeArg arg
[],
1657 const uint32_t par
[])
1659 TCGv_i32 addr
= tcg_temp_new_i32();
1660 TCGv_i32 res
= tcg_temp_new_i32();
1662 tcg_gen_addi_i32(addr
, arg
[0].in
, arg
[1].imm
);
1663 tcg_gen_qemu_ld8u(res
, addr
, dc
->cring
);
1664 tcg_temp_free(addr
);
1668 static void translate_depbits(DisasContext
*dc
, const OpcodeArg arg
[],
1669 const uint32_t par
[])
1671 tcg_gen_deposit_i32(arg
[1].out
, arg
[1].in
, arg
[0].in
,
1672 arg
[2].imm
, arg
[3].imm
);
1675 static void translate_diwbuip(DisasContext
*dc
, const OpcodeArg arg
[],
1676 const uint32_t par
[])
1678 tcg_gen_addi_i32(arg
[0].out
, arg
[0].in
, dc
->config
->dcache_line_bytes
);
1681 static uint32_t test_exceptions_entry(DisasContext
*dc
, const OpcodeArg arg
[],
1682 const uint32_t par
[])
1684 if (arg
[0].imm
> 3 || !dc
->cwoe
) {
1685 qemu_log_mask(LOG_GUEST_ERROR
,
1686 "Illegal entry instruction(pc = %08x)\n", dc
->pc
);
1687 return XTENSA_OP_ILL
;
1693 static uint32_t test_overflow_entry(DisasContext
*dc
, const OpcodeArg arg
[],
1694 const uint32_t par
[])
1696 return 1 << (dc
->callinc
* 4);
1699 static void translate_entry(DisasContext
*dc
, const OpcodeArg arg
[],
1700 const uint32_t par
[])
1702 TCGv_i32 pc
= tcg_const_i32(dc
->pc
);
1703 TCGv_i32 s
= tcg_const_i32(arg
[0].imm
);
1704 TCGv_i32 imm
= tcg_const_i32(arg
[1].imm
);
1705 gen_helper_entry(cpu_env
, pc
, s
, imm
);
1711 static void translate_extui(DisasContext
*dc
, const OpcodeArg arg
[],
1712 const uint32_t par
[])
1714 int maskimm
= (1 << arg
[3].imm
) - 1;
1716 TCGv_i32 tmp
= tcg_temp_new_i32();
1717 tcg_gen_shri_i32(tmp
, arg
[1].in
, arg
[2].imm
);
1718 tcg_gen_andi_i32(arg
[0].out
, tmp
, maskimm
);
1722 static void translate_getex(DisasContext
*dc
, const OpcodeArg arg
[],
1723 const uint32_t par
[])
1725 TCGv_i32 tmp
= tcg_temp_new_i32();
1727 tcg_gen_extract_i32(tmp
, cpu_SR
[ATOMCTL
], 8, 1);
1728 tcg_gen_deposit_i32(cpu_SR
[ATOMCTL
], cpu_SR
[ATOMCTL
], arg
[0].in
, 8, 1);
1729 tcg_gen_mov_i32(arg
[0].out
, tmp
);
1733 static void translate_icache(DisasContext
*dc
, const OpcodeArg arg
[],
1734 const uint32_t par
[])
1736 #ifndef CONFIG_USER_ONLY
1737 TCGv_i32 addr
= tcg_temp_new_i32();
1739 tcg_gen_movi_i32(cpu_pc
, dc
->pc
);
1740 tcg_gen_addi_i32(addr
, arg
[0].in
, arg
[1].imm
);
1741 gen_helper_itlb_hit_test(cpu_env
, addr
);
1742 tcg_temp_free(addr
);
1746 static void translate_itlb(DisasContext
*dc
, const OpcodeArg arg
[],
1747 const uint32_t par
[])
1749 #ifndef CONFIG_USER_ONLY
1750 TCGv_i32 dtlb
= tcg_const_i32(par
[0]);
1752 gen_helper_itlb(cpu_env
, arg
[0].in
, dtlb
);
1753 tcg_temp_free(dtlb
);
1757 static void translate_j(DisasContext
*dc
, const OpcodeArg arg
[],
1758 const uint32_t par
[])
1760 gen_jumpi(dc
, arg
[0].imm
, 0);
1763 static void translate_jx(DisasContext
*dc
, const OpcodeArg arg
[],
1764 const uint32_t par
[])
1766 gen_jump(dc
, arg
[0].in
);
1769 static void translate_l32e(DisasContext
*dc
, const OpcodeArg arg
[],
1770 const uint32_t par
[])
1772 TCGv_i32 addr
= tcg_temp_new_i32();
1775 tcg_gen_addi_i32(addr
, arg
[1].in
, arg
[2].imm
);
1776 mop
= gen_load_store_alignment(dc
, MO_TEUL
, addr
);
1777 tcg_gen_qemu_ld_tl(arg
[0].out
, addr
, dc
->ring
, mop
);
1778 tcg_temp_free(addr
);
1781 #ifdef CONFIG_USER_ONLY
1782 static void gen_check_exclusive(DisasContext
*dc
, TCGv_i32 addr
, bool is_write
)
1786 static void gen_check_exclusive(DisasContext
*dc
, TCGv_i32 addr
, bool is_write
)
1788 if (!option_enabled(dc
, XTENSA_OPTION_MPU
)) {
1789 TCGv_i32 tpc
= tcg_const_i32(dc
->pc
);
1790 TCGv_i32 write
= tcg_const_i32(is_write
);
1792 gen_helper_check_exclusive(cpu_env
, tpc
, addr
, write
);
1794 tcg_temp_free(write
);
1799 static void translate_l32ex(DisasContext
*dc
, const OpcodeArg arg
[],
1800 const uint32_t par
[])
1802 TCGv_i32 addr
= tcg_temp_new_i32();
1805 tcg_gen_mov_i32(addr
, arg
[1].in
);
1806 mop
= gen_load_store_alignment(dc
, MO_TEUL
| MO_ALIGN
, addr
);
1807 gen_check_exclusive(dc
, addr
, false);
1808 tcg_gen_qemu_ld_i32(arg
[0].out
, addr
, dc
->cring
, mop
);
1809 tcg_gen_mov_i32(cpu_exclusive_addr
, addr
);
1810 tcg_gen_mov_i32(cpu_exclusive_val
, arg
[0].out
);
1811 tcg_temp_free(addr
);
1814 static void translate_ldst(DisasContext
*dc
, const OpcodeArg arg
[],
1815 const uint32_t par
[])
1817 TCGv_i32 addr
= tcg_temp_new_i32();
1820 tcg_gen_addi_i32(addr
, arg
[1].in
, arg
[2].imm
);
1821 mop
= gen_load_store_alignment(dc
, par
[0], addr
);
1825 tcg_gen_mb(TCG_BAR_STRL
| TCG_MO_ALL
);
1827 tcg_gen_qemu_st_tl(arg
[0].in
, addr
, dc
->cring
, mop
);
1829 tcg_gen_qemu_ld_tl(arg
[0].out
, addr
, dc
->cring
, mop
);
1831 tcg_gen_mb(TCG_BAR_LDAQ
| TCG_MO_ALL
);
1834 tcg_temp_free(addr
);
1837 static void translate_l32r(DisasContext
*dc
, const OpcodeArg arg
[],
1838 const uint32_t par
[])
1842 if (dc
->base
.tb
->flags
& XTENSA_TBFLAG_LITBASE
) {
1843 tmp
= tcg_const_i32(arg
[1].raw_imm
- 1);
1844 tcg_gen_add_i32(tmp
, cpu_SR
[LITBASE
], tmp
);
1846 tmp
= tcg_const_i32(arg
[1].imm
);
1848 tcg_gen_qemu_ld32u(arg
[0].out
, tmp
, dc
->cring
);
1852 static void translate_loop(DisasContext
*dc
, const OpcodeArg arg
[],
1853 const uint32_t par
[])
1855 uint32_t lend
= arg
[1].imm
;
1857 tcg_gen_subi_i32(cpu_SR
[LCOUNT
], arg
[0].in
, 1);
1858 tcg_gen_movi_i32(cpu_SR
[LBEG
], dc
->base
.pc_next
);
1859 tcg_gen_movi_i32(cpu_SR
[LEND
], lend
);
1861 if (par
[0] != TCG_COND_NEVER
) {
1862 TCGLabel
*label
= gen_new_label();
1863 tcg_gen_brcondi_i32(par
[0], arg
[0].in
, 0, label
);
1864 gen_jumpi(dc
, lend
, 1);
1865 gen_set_label(label
);
1868 gen_jumpi(dc
, dc
->base
.pc_next
, 0);
1889 static void translate_mac16(DisasContext
*dc
, const OpcodeArg arg
[],
1890 const uint32_t par
[])
1893 unsigned half
= par
[1];
1894 uint32_t ld_offset
= par
[2];
1895 unsigned off
= ld_offset
? 2 : 0;
1896 TCGv_i32 vaddr
= tcg_temp_new_i32();
1897 TCGv_i32 mem32
= tcg_temp_new_i32();
1902 tcg_gen_addi_i32(vaddr
, arg
[1].in
, ld_offset
);
1903 mop
= gen_load_store_alignment(dc
, MO_TEUL
, vaddr
);
1904 tcg_gen_qemu_ld_tl(mem32
, vaddr
, dc
->cring
, mop
);
1906 if (op
!= MAC16_NONE
) {
1907 TCGv_i32 m1
= gen_mac16_m(arg
[off
].in
,
1908 half
& MAC16_HX
, op
== MAC16_UMUL
);
1909 TCGv_i32 m2
= gen_mac16_m(arg
[off
+ 1].in
,
1910 half
& MAC16_XH
, op
== MAC16_UMUL
);
1912 if (op
== MAC16_MUL
|| op
== MAC16_UMUL
) {
1913 tcg_gen_mul_i32(cpu_SR
[ACCLO
], m1
, m2
);
1914 if (op
== MAC16_UMUL
) {
1915 tcg_gen_movi_i32(cpu_SR
[ACCHI
], 0);
1917 tcg_gen_sari_i32(cpu_SR
[ACCHI
], cpu_SR
[ACCLO
], 31);
1920 TCGv_i32 lo
= tcg_temp_new_i32();
1921 TCGv_i32 hi
= tcg_temp_new_i32();
1923 tcg_gen_mul_i32(lo
, m1
, m2
);
1924 tcg_gen_sari_i32(hi
, lo
, 31);
1925 if (op
== MAC16_MULA
) {
1926 tcg_gen_add2_i32(cpu_SR
[ACCLO
], cpu_SR
[ACCHI
],
1927 cpu_SR
[ACCLO
], cpu_SR
[ACCHI
],
1930 tcg_gen_sub2_i32(cpu_SR
[ACCLO
], cpu_SR
[ACCHI
],
1931 cpu_SR
[ACCLO
], cpu_SR
[ACCHI
],
1934 tcg_gen_ext8s_i32(cpu_SR
[ACCHI
], cpu_SR
[ACCHI
]);
1936 tcg_temp_free_i32(lo
);
1937 tcg_temp_free_i32(hi
);
1943 tcg_gen_mov_i32(arg
[1].out
, vaddr
);
1944 tcg_gen_mov_i32(cpu_SR
[MR
+ arg
[0].imm
], mem32
);
1946 tcg_temp_free(vaddr
);
1947 tcg_temp_free(mem32
);
1950 static void translate_memw(DisasContext
*dc
, const OpcodeArg arg
[],
1951 const uint32_t par
[])
1953 tcg_gen_mb(TCG_BAR_SC
| TCG_MO_ALL
);
1956 static void translate_smin(DisasContext
*dc
, const OpcodeArg arg
[],
1957 const uint32_t par
[])
1959 tcg_gen_smin_i32(arg
[0].out
, arg
[1].in
, arg
[2].in
);
1962 static void translate_umin(DisasContext
*dc
, const OpcodeArg arg
[],
1963 const uint32_t par
[])
1965 tcg_gen_umin_i32(arg
[0].out
, arg
[1].in
, arg
[2].in
);
1968 static void translate_smax(DisasContext
*dc
, const OpcodeArg arg
[],
1969 const uint32_t par
[])
1971 tcg_gen_smax_i32(arg
[0].out
, arg
[1].in
, arg
[2].in
);
1974 static void translate_umax(DisasContext
*dc
, const OpcodeArg arg
[],
1975 const uint32_t par
[])
1977 tcg_gen_umax_i32(arg
[0].out
, arg
[1].in
, arg
[2].in
);
1980 static void translate_mov(DisasContext
*dc
, const OpcodeArg arg
[],
1981 const uint32_t par
[])
1983 tcg_gen_mov_i32(arg
[0].out
, arg
[1].in
);
1986 static void translate_movcond(DisasContext
*dc
, const OpcodeArg arg
[],
1987 const uint32_t par
[])
1989 TCGv_i32 zero
= tcg_const_i32(0);
1991 tcg_gen_movcond_i32(par
[0], arg
[0].out
,
1992 arg
[2].in
, zero
, arg
[1].in
, arg
[0].in
);
1993 tcg_temp_free(zero
);
1996 static void translate_movi(DisasContext
*dc
, const OpcodeArg arg
[],
1997 const uint32_t par
[])
1999 tcg_gen_movi_i32(arg
[0].out
, arg
[1].imm
);
2002 static void translate_movp(DisasContext
*dc
, const OpcodeArg arg
[],
2003 const uint32_t par
[])
2005 TCGv_i32 zero
= tcg_const_i32(0);
2006 TCGv_i32 tmp
= tcg_temp_new_i32();
2008 tcg_gen_andi_i32(tmp
, arg
[2].in
, 1 << arg
[2].imm
);
2009 tcg_gen_movcond_i32(par
[0],
2010 arg
[0].out
, tmp
, zero
,
2011 arg
[1].in
, arg
[0].in
);
2013 tcg_temp_free(zero
);
2016 static void translate_movsp(DisasContext
*dc
, const OpcodeArg arg
[],
2017 const uint32_t par
[])
2019 tcg_gen_mov_i32(arg
[0].out
, arg
[1].in
);
2022 static void translate_mul16(DisasContext
*dc
, const OpcodeArg arg
[],
2023 const uint32_t par
[])
2025 TCGv_i32 v1
= tcg_temp_new_i32();
2026 TCGv_i32 v2
= tcg_temp_new_i32();
2029 tcg_gen_ext16s_i32(v1
, arg
[1].in
);
2030 tcg_gen_ext16s_i32(v2
, arg
[2].in
);
2032 tcg_gen_ext16u_i32(v1
, arg
[1].in
);
2033 tcg_gen_ext16u_i32(v2
, arg
[2].in
);
2035 tcg_gen_mul_i32(arg
[0].out
, v1
, v2
);
2040 static void translate_mull(DisasContext
*dc
, const OpcodeArg arg
[],
2041 const uint32_t par
[])
2043 tcg_gen_mul_i32(arg
[0].out
, arg
[1].in
, arg
[2].in
);
2046 static void translate_mulh(DisasContext
*dc
, const OpcodeArg arg
[],
2047 const uint32_t par
[])
2049 TCGv_i32 lo
= tcg_temp_new();
2052 tcg_gen_muls2_i32(lo
, arg
[0].out
, arg
[1].in
, arg
[2].in
);
2054 tcg_gen_mulu2_i32(lo
, arg
[0].out
, arg
[1].in
, arg
[2].in
);
2059 static void translate_neg(DisasContext
*dc
, const OpcodeArg arg
[],
2060 const uint32_t par
[])
2062 tcg_gen_neg_i32(arg
[0].out
, arg
[1].in
);
2065 static void translate_nop(DisasContext
*dc
, const OpcodeArg arg
[],
2066 const uint32_t par
[])
2070 static void translate_nsa(DisasContext
*dc
, const OpcodeArg arg
[],
2071 const uint32_t par
[])
2073 tcg_gen_clrsb_i32(arg
[0].out
, arg
[1].in
);
2076 static void translate_nsau(DisasContext
*dc
, const OpcodeArg arg
[],
2077 const uint32_t par
[])
2079 tcg_gen_clzi_i32(arg
[0].out
, arg
[1].in
, 32);
2082 static void translate_or(DisasContext
*dc
, const OpcodeArg arg
[],
2083 const uint32_t par
[])
2085 tcg_gen_or_i32(arg
[0].out
, arg
[1].in
, arg
[2].in
);
2088 static void translate_ptlb(DisasContext
*dc
, const OpcodeArg arg
[],
2089 const uint32_t par
[])
2091 #ifndef CONFIG_USER_ONLY
2092 TCGv_i32 dtlb
= tcg_const_i32(par
[0]);
2094 tcg_gen_movi_i32(cpu_pc
, dc
->pc
);
2095 gen_helper_ptlb(arg
[0].out
, cpu_env
, arg
[1].in
, dtlb
);
2096 tcg_temp_free(dtlb
);
2100 static void translate_pptlb(DisasContext
*dc
, const OpcodeArg arg
[],
2101 const uint32_t par
[])
2103 #ifndef CONFIG_USER_ONLY
2104 tcg_gen_movi_i32(cpu_pc
, dc
->pc
);
2105 gen_helper_pptlb(arg
[0].out
, cpu_env
, arg
[1].in
);
2109 static void translate_quos(DisasContext
*dc
, const OpcodeArg arg
[],
2110 const uint32_t par
[])
2112 TCGLabel
*label1
= gen_new_label();
2113 TCGLabel
*label2
= gen_new_label();
2115 tcg_gen_brcondi_i32(TCG_COND_NE
, arg
[1].in
, 0x80000000,
2117 tcg_gen_brcondi_i32(TCG_COND_NE
, arg
[2].in
, 0xffffffff,
2119 tcg_gen_movi_i32(arg
[0].out
,
2120 par
[0] ? 0x80000000 : 0);
2122 gen_set_label(label1
);
2124 tcg_gen_div_i32(arg
[0].out
,
2125 arg
[1].in
, arg
[2].in
);
2127 tcg_gen_rem_i32(arg
[0].out
,
2128 arg
[1].in
, arg
[2].in
);
2130 gen_set_label(label2
);
2133 static void translate_quou(DisasContext
*dc
, const OpcodeArg arg
[],
2134 const uint32_t par
[])
2136 tcg_gen_divu_i32(arg
[0].out
,
2137 arg
[1].in
, arg
[2].in
);
2140 static void translate_read_impwire(DisasContext
*dc
, const OpcodeArg arg
[],
2141 const uint32_t par
[])
2143 /* TODO: GPIO32 may be a part of coprocessor */
2144 tcg_gen_movi_i32(arg
[0].out
, 0);
2147 static void translate_remu(DisasContext
*dc
, const OpcodeArg arg
[],
2148 const uint32_t par
[])
2150 tcg_gen_remu_i32(arg
[0].out
,
2151 arg
[1].in
, arg
[2].in
);
2154 static void translate_rer(DisasContext
*dc
, const OpcodeArg arg
[],
2155 const uint32_t par
[])
2157 gen_helper_rer(arg
[0].out
, cpu_env
, arg
[1].in
);
2160 static void translate_ret(DisasContext
*dc
, const OpcodeArg arg
[],
2161 const uint32_t par
[])
2163 gen_jump(dc
, cpu_R
[0]);
2166 static uint32_t test_exceptions_retw(DisasContext
*dc
, const OpcodeArg arg
[],
2167 const uint32_t par
[])
2170 qemu_log_mask(LOG_GUEST_ERROR
,
2171 "Illegal retw instruction(pc = %08x)\n", dc
->pc
);
2172 return XTENSA_OP_ILL
;
2174 TCGv_i32 tmp
= tcg_const_i32(dc
->pc
);
2176 gen_helper_test_ill_retw(cpu_env
, tmp
);
2182 static void translate_retw(DisasContext
*dc
, const OpcodeArg arg
[],
2183 const uint32_t par
[])
2185 TCGv_i32 tmp
= tcg_const_i32(1);
2186 tcg_gen_shl_i32(tmp
, tmp
, cpu_SR
[WINDOW_BASE
]);
2187 tcg_gen_andc_i32(cpu_SR
[WINDOW_START
],
2188 cpu_SR
[WINDOW_START
], tmp
);
2189 tcg_gen_movi_i32(tmp
, dc
->pc
);
2190 tcg_gen_deposit_i32(tmp
, tmp
, cpu_R
[0], 0, 30);
2191 gen_helper_retw(cpu_env
, cpu_R
[0]);
2196 static void translate_rfde(DisasContext
*dc
, const OpcodeArg arg
[],
2197 const uint32_t par
[])
2199 gen_jump(dc
, cpu_SR
[dc
->config
->ndepc
? DEPC
: EPC1
]);
2202 static void translate_rfe(DisasContext
*dc
, const OpcodeArg arg
[],
2203 const uint32_t par
[])
2205 tcg_gen_andi_i32(cpu_SR
[PS
], cpu_SR
[PS
], ~PS_EXCM
);
2206 gen_jump(dc
, cpu_SR
[EPC1
]);
2209 static void translate_rfi(DisasContext
*dc
, const OpcodeArg arg
[],
2210 const uint32_t par
[])
2212 tcg_gen_mov_i32(cpu_SR
[PS
], cpu_SR
[EPS2
+ arg
[0].imm
- 2]);
2213 gen_jump(dc
, cpu_SR
[EPC1
+ arg
[0].imm
- 1]);
2216 static void translate_rfw(DisasContext
*dc
, const OpcodeArg arg
[],
2217 const uint32_t par
[])
2219 TCGv_i32 tmp
= tcg_const_i32(1);
2221 tcg_gen_andi_i32(cpu_SR
[PS
], cpu_SR
[PS
], ~PS_EXCM
);
2222 tcg_gen_shl_i32(tmp
, tmp
, cpu_SR
[WINDOW_BASE
]);
2225 tcg_gen_andc_i32(cpu_SR
[WINDOW_START
],
2226 cpu_SR
[WINDOW_START
], tmp
);
2228 tcg_gen_or_i32(cpu_SR
[WINDOW_START
],
2229 cpu_SR
[WINDOW_START
], tmp
);
2233 gen_helper_restore_owb(cpu_env
);
2234 gen_jump(dc
, cpu_SR
[EPC1
]);
2237 static void translate_rotw(DisasContext
*dc
, const OpcodeArg arg
[],
2238 const uint32_t par
[])
2240 tcg_gen_addi_i32(cpu_windowbase_next
, cpu_SR
[WINDOW_BASE
], arg
[0].imm
);
2243 static void translate_rsil(DisasContext
*dc
, const OpcodeArg arg
[],
2244 const uint32_t par
[])
2246 tcg_gen_mov_i32(arg
[0].out
, cpu_SR
[PS
]);
2247 tcg_gen_andi_i32(cpu_SR
[PS
], cpu_SR
[PS
], ~PS_INTLEVEL
);
2248 tcg_gen_ori_i32(cpu_SR
[PS
], cpu_SR
[PS
], arg
[1].imm
);
2251 static void translate_rsr(DisasContext
*dc
, const OpcodeArg arg
[],
2252 const uint32_t par
[])
2254 if (sr_name
[par
[0]]) {
2255 tcg_gen_mov_i32(arg
[0].out
, cpu_SR
[par
[0]]);
2257 tcg_gen_movi_i32(arg
[0].out
, 0);
2261 static void translate_rsr_ccount(DisasContext
*dc
, const OpcodeArg arg
[],
2262 const uint32_t par
[])
2264 #ifndef CONFIG_USER_ONLY
2265 if (tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
) {
2268 gen_helper_update_ccount(cpu_env
);
2269 tcg_gen_mov_i32(arg
[0].out
, cpu_SR
[par
[0]]);
2273 static void translate_rsr_ptevaddr(DisasContext
*dc
, const OpcodeArg arg
[],
2274 const uint32_t par
[])
2276 #ifndef CONFIG_USER_ONLY
2277 TCGv_i32 tmp
= tcg_temp_new_i32();
2279 tcg_gen_shri_i32(tmp
, cpu_SR
[EXCVADDR
], 10);
2280 tcg_gen_or_i32(tmp
, tmp
, cpu_SR
[PTEVADDR
]);
2281 tcg_gen_andi_i32(arg
[0].out
, tmp
, 0xfffffffc);
2286 static void translate_rtlb(DisasContext
*dc
, const OpcodeArg arg
[],
2287 const uint32_t par
[])
2289 #ifndef CONFIG_USER_ONLY
2290 static void (* const helper
[])(TCGv_i32 r
, TCGv_env env
, TCGv_i32 a1
,
2295 TCGv_i32 dtlb
= tcg_const_i32(par
[0]);
2297 helper
[par
[1]](arg
[0].out
, cpu_env
, arg
[1].in
, dtlb
);
2298 tcg_temp_free(dtlb
);
2302 static void translate_rptlb0(DisasContext
*dc
, const OpcodeArg arg
[],
2303 const uint32_t par
[])
2305 #ifndef CONFIG_USER_ONLY
2306 gen_helper_rptlb0(arg
[0].out
, cpu_env
, arg
[1].in
);
2310 static void translate_rptlb1(DisasContext
*dc
, const OpcodeArg arg
[],
2311 const uint32_t par
[])
2313 #ifndef CONFIG_USER_ONLY
2314 gen_helper_rptlb1(arg
[0].out
, cpu_env
, arg
[1].in
);
2318 static void translate_rur(DisasContext
*dc
, const OpcodeArg arg
[],
2319 const uint32_t par
[])
2321 tcg_gen_mov_i32(arg
[0].out
, cpu_UR
[par
[0]]);
2324 static void translate_setb_expstate(DisasContext
*dc
, const OpcodeArg arg
[],
2325 const uint32_t par
[])
2327 /* TODO: GPIO32 may be a part of coprocessor */
2328 tcg_gen_ori_i32(cpu_UR
[EXPSTATE
], cpu_UR
[EXPSTATE
], 1u << arg
[0].imm
);
2331 #ifdef CONFIG_USER_ONLY
2332 static void gen_check_atomctl(DisasContext
*dc
, TCGv_i32 addr
)
2336 static void gen_check_atomctl(DisasContext
*dc
, TCGv_i32 addr
)
2338 TCGv_i32 tpc
= tcg_const_i32(dc
->pc
);
2340 gen_helper_check_atomctl(cpu_env
, tpc
, addr
);
2345 static void translate_s32c1i(DisasContext
*dc
, const OpcodeArg arg
[],
2346 const uint32_t par
[])
2348 TCGv_i32 tmp
= tcg_temp_local_new_i32();
2349 TCGv_i32 addr
= tcg_temp_local_new_i32();
2352 tcg_gen_mov_i32(tmp
, arg
[0].in
);
2353 tcg_gen_addi_i32(addr
, arg
[1].in
, arg
[2].imm
);
2354 mop
= gen_load_store_alignment(dc
, MO_TEUL
| MO_ALIGN
, addr
);
2355 gen_check_atomctl(dc
, addr
);
2356 tcg_gen_atomic_cmpxchg_i32(arg
[0].out
, addr
, cpu_SR
[SCOMPARE1
],
2357 tmp
, dc
->cring
, mop
);
2358 tcg_temp_free(addr
);
2362 static void translate_s32e(DisasContext
*dc
, const OpcodeArg arg
[],
2363 const uint32_t par
[])
2365 TCGv_i32 addr
= tcg_temp_new_i32();
2368 tcg_gen_addi_i32(addr
, arg
[1].in
, arg
[2].imm
);
2369 mop
= gen_load_store_alignment(dc
, MO_TEUL
, addr
);
2370 tcg_gen_qemu_st_tl(arg
[0].in
, addr
, dc
->ring
, mop
);
2371 tcg_temp_free(addr
);
2374 static void translate_s32ex(DisasContext
*dc
, const OpcodeArg arg
[],
2375 const uint32_t par
[])
2377 TCGv_i32 prev
= tcg_temp_new_i32();
2378 TCGv_i32 addr
= tcg_temp_local_new_i32();
2379 TCGv_i32 res
= tcg_temp_local_new_i32();
2380 TCGLabel
*label
= gen_new_label();
2383 tcg_gen_movi_i32(res
, 0);
2384 tcg_gen_mov_i32(addr
, arg
[1].in
);
2385 mop
= gen_load_store_alignment(dc
, MO_TEUL
| MO_ALIGN
, addr
);
2386 tcg_gen_brcond_i32(TCG_COND_NE
, addr
, cpu_exclusive_addr
, label
);
2387 gen_check_exclusive(dc
, addr
, true);
2388 tcg_gen_atomic_cmpxchg_i32(prev
, cpu_exclusive_addr
, cpu_exclusive_val
,
2389 arg
[0].in
, dc
->cring
, mop
);
2390 tcg_gen_setcond_i32(TCG_COND_EQ
, res
, prev
, cpu_exclusive_val
);
2391 tcg_gen_movcond_i32(TCG_COND_EQ
, cpu_exclusive_val
,
2392 prev
, cpu_exclusive_val
, prev
, cpu_exclusive_val
);
2393 tcg_gen_movi_i32(cpu_exclusive_addr
, -1);
2394 gen_set_label(label
);
2395 tcg_gen_extract_i32(arg
[0].out
, cpu_SR
[ATOMCTL
], 8, 1);
2396 tcg_gen_deposit_i32(cpu_SR
[ATOMCTL
], cpu_SR
[ATOMCTL
], res
, 8, 1);
2397 tcg_temp_free(prev
);
2398 tcg_temp_free(addr
);
2402 static void translate_salt(DisasContext
*dc
, const OpcodeArg arg
[],
2403 const uint32_t par
[])
2405 tcg_gen_setcond_i32(par
[0],
2407 arg
[1].in
, arg
[2].in
);
2410 static void translate_sext(DisasContext
*dc
, const OpcodeArg arg
[],
2411 const uint32_t par
[])
2413 int shift
= 31 - arg
[2].imm
;
2416 tcg_gen_ext8s_i32(arg
[0].out
, arg
[1].in
);
2417 } else if (shift
== 16) {
2418 tcg_gen_ext16s_i32(arg
[0].out
, arg
[1].in
);
2420 TCGv_i32 tmp
= tcg_temp_new_i32();
2421 tcg_gen_shli_i32(tmp
, arg
[1].in
, shift
);
2422 tcg_gen_sari_i32(arg
[0].out
, tmp
, shift
);
2427 static uint32_t test_exceptions_simcall(DisasContext
*dc
,
2428 const OpcodeArg arg
[],
2429 const uint32_t par
[])
2431 #ifdef CONFIG_USER_ONLY
2434 /* Between RE.2 and RE.3 simcall opcode's become nop for the hardware. */
2435 bool ill
= dc
->config
->hw_version
<= 250002 && !semihosting_enabled();
2437 if (ill
|| !semihosting_enabled()) {
2438 qemu_log_mask(LOG_GUEST_ERROR
, "SIMCALL but semihosting is disabled\n");
2440 return ill
? XTENSA_OP_ILL
: 0;
2443 static void translate_simcall(DisasContext
*dc
, const OpcodeArg arg
[],
2444 const uint32_t par
[])
2446 #ifndef CONFIG_USER_ONLY
2447 if (semihosting_enabled()) {
2448 gen_helper_simcall(cpu_env
);
2454 * Note: 64 bit ops are used here solely because SAR values
2457 #define gen_shift_reg(cmd, reg) do { \
2458 TCGv_i64 tmp = tcg_temp_new_i64(); \
2459 tcg_gen_extu_i32_i64(tmp, reg); \
2460 tcg_gen_##cmd##_i64(v, v, tmp); \
2461 tcg_gen_extrl_i64_i32(arg[0].out, v); \
2462 tcg_temp_free_i64(v); \
2463 tcg_temp_free_i64(tmp); \
2466 #define gen_shift(cmd) gen_shift_reg(cmd, cpu_SR[SAR])
2468 static void translate_sll(DisasContext
*dc
, const OpcodeArg arg
[],
2469 const uint32_t par
[])
2471 if (dc
->sar_m32_5bit
) {
2472 tcg_gen_shl_i32(arg
[0].out
, arg
[1].in
, dc
->sar_m32
);
2474 TCGv_i64 v
= tcg_temp_new_i64();
2475 TCGv_i32 s
= tcg_const_i32(32);
2476 tcg_gen_sub_i32(s
, s
, cpu_SR
[SAR
]);
2477 tcg_gen_andi_i32(s
, s
, 0x3f);
2478 tcg_gen_extu_i32_i64(v
, arg
[1].in
);
2479 gen_shift_reg(shl
, s
);
2484 static void translate_slli(DisasContext
*dc
, const OpcodeArg arg
[],
2485 const uint32_t par
[])
2487 if (arg
[2].imm
== 32) {
2488 qemu_log_mask(LOG_GUEST_ERROR
, "slli a%d, a%d, 32 is undefined\n",
2489 arg
[0].imm
, arg
[1].imm
);
2491 tcg_gen_shli_i32(arg
[0].out
, arg
[1].in
, arg
[2].imm
& 0x1f);
2494 static void translate_sra(DisasContext
*dc
, const OpcodeArg arg
[],
2495 const uint32_t par
[])
2497 if (dc
->sar_m32_5bit
) {
2498 tcg_gen_sar_i32(arg
[0].out
, arg
[1].in
, cpu_SR
[SAR
]);
2500 TCGv_i64 v
= tcg_temp_new_i64();
2501 tcg_gen_ext_i32_i64(v
, arg
[1].in
);
2506 static void translate_srai(DisasContext
*dc
, const OpcodeArg arg
[],
2507 const uint32_t par
[])
2509 tcg_gen_sari_i32(arg
[0].out
, arg
[1].in
, arg
[2].imm
);
2512 static void translate_src(DisasContext
*dc
, const OpcodeArg arg
[],
2513 const uint32_t par
[])
2515 TCGv_i64 v
= tcg_temp_new_i64();
2516 tcg_gen_concat_i32_i64(v
, arg
[2].in
, arg
[1].in
);
2520 static void translate_srl(DisasContext
*dc
, const OpcodeArg arg
[],
2521 const uint32_t par
[])
2523 if (dc
->sar_m32_5bit
) {
2524 tcg_gen_shr_i32(arg
[0].out
, arg
[1].in
, cpu_SR
[SAR
]);
2526 TCGv_i64 v
= tcg_temp_new_i64();
2527 tcg_gen_extu_i32_i64(v
, arg
[1].in
);
2533 #undef gen_shift_reg
2535 static void translate_srli(DisasContext
*dc
, const OpcodeArg arg
[],
2536 const uint32_t par
[])
2538 tcg_gen_shri_i32(arg
[0].out
, arg
[1].in
, arg
[2].imm
);
2541 static void translate_ssa8b(DisasContext
*dc
, const OpcodeArg arg
[],
2542 const uint32_t par
[])
2544 TCGv_i32 tmp
= tcg_temp_new_i32();
2545 tcg_gen_shli_i32(tmp
, arg
[0].in
, 3);
2546 gen_left_shift_sar(dc
, tmp
);
2550 static void translate_ssa8l(DisasContext
*dc
, const OpcodeArg arg
[],
2551 const uint32_t par
[])
2553 TCGv_i32 tmp
= tcg_temp_new_i32();
2554 tcg_gen_shli_i32(tmp
, arg
[0].in
, 3);
2555 gen_right_shift_sar(dc
, tmp
);
2559 static void translate_ssai(DisasContext
*dc
, const OpcodeArg arg
[],
2560 const uint32_t par
[])
2562 TCGv_i32 tmp
= tcg_const_i32(arg
[0].imm
);
2563 gen_right_shift_sar(dc
, tmp
);
2567 static void translate_ssl(DisasContext
*dc
, const OpcodeArg arg
[],
2568 const uint32_t par
[])
2570 gen_left_shift_sar(dc
, arg
[0].in
);
2573 static void translate_ssr(DisasContext
*dc
, const OpcodeArg arg
[],
2574 const uint32_t par
[])
2576 gen_right_shift_sar(dc
, arg
[0].in
);
2579 static void translate_sub(DisasContext
*dc
, const OpcodeArg arg
[],
2580 const uint32_t par
[])
2582 tcg_gen_sub_i32(arg
[0].out
, arg
[1].in
, arg
[2].in
);
2585 static void translate_subx(DisasContext
*dc
, const OpcodeArg arg
[],
2586 const uint32_t par
[])
2588 TCGv_i32 tmp
= tcg_temp_new_i32();
2589 tcg_gen_shli_i32(tmp
, arg
[1].in
, par
[0]);
2590 tcg_gen_sub_i32(arg
[0].out
, tmp
, arg
[2].in
);
2594 static void translate_waiti(DisasContext
*dc
, const OpcodeArg arg
[],
2595 const uint32_t par
[])
2597 #ifndef CONFIG_USER_ONLY
2598 gen_waiti(dc
, arg
[0].imm
);
2602 static void translate_wtlb(DisasContext
*dc
, const OpcodeArg arg
[],
2603 const uint32_t par
[])
2605 #ifndef CONFIG_USER_ONLY
2606 TCGv_i32 dtlb
= tcg_const_i32(par
[0]);
2608 gen_helper_wtlb(cpu_env
, arg
[0].in
, arg
[1].in
, dtlb
);
2609 tcg_temp_free(dtlb
);
2613 static void translate_wptlb(DisasContext
*dc
, const OpcodeArg arg
[],
2614 const uint32_t par
[])
2616 #ifndef CONFIG_USER_ONLY
2617 gen_helper_wptlb(cpu_env
, arg
[0].in
, arg
[1].in
);
2621 static void translate_wer(DisasContext
*dc
, const OpcodeArg arg
[],
2622 const uint32_t par
[])
2624 gen_helper_wer(cpu_env
, arg
[0].in
, arg
[1].in
);
2627 static void translate_wrmsk_expstate(DisasContext
*dc
, const OpcodeArg arg
[],
2628 const uint32_t par
[])
2630 /* TODO: GPIO32 may be a part of coprocessor */
2631 tcg_gen_and_i32(cpu_UR
[EXPSTATE
], arg
[0].in
, arg
[1].in
);
2634 static void translate_wsr(DisasContext
*dc
, const OpcodeArg arg
[],
2635 const uint32_t par
[])
2637 if (sr_name
[par
[0]]) {
2638 tcg_gen_mov_i32(cpu_SR
[par
[0]], arg
[0].in
);
2642 static void translate_wsr_mask(DisasContext
*dc
, const OpcodeArg arg
[],
2643 const uint32_t par
[])
2645 if (sr_name
[par
[0]]) {
2646 tcg_gen_andi_i32(cpu_SR
[par
[0]], arg
[0].in
, par
[2]);
2650 static void translate_wsr_acchi(DisasContext
*dc
, const OpcodeArg arg
[],
2651 const uint32_t par
[])
2653 tcg_gen_ext8s_i32(cpu_SR
[par
[0]], arg
[0].in
);
2656 static void translate_wsr_ccompare(DisasContext
*dc
, const OpcodeArg arg
[],
2657 const uint32_t par
[])
2659 #ifndef CONFIG_USER_ONLY
2660 uint32_t id
= par
[0] - CCOMPARE
;
2661 TCGv_i32 tmp
= tcg_const_i32(id
);
2663 assert(id
< dc
->config
->nccompare
);
2664 if (tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
) {
2667 tcg_gen_mov_i32(cpu_SR
[par
[0]], arg
[0].in
);
2668 gen_helper_update_ccompare(cpu_env
, tmp
);
2673 static void translate_wsr_ccount(DisasContext
*dc
, const OpcodeArg arg
[],
2674 const uint32_t par
[])
2676 #ifndef CONFIG_USER_ONLY
2677 if (tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
) {
2680 gen_helper_wsr_ccount(cpu_env
, arg
[0].in
);
2684 static void translate_wsr_dbreaka(DisasContext
*dc
, const OpcodeArg arg
[],
2685 const uint32_t par
[])
2687 #ifndef CONFIG_USER_ONLY
2688 unsigned id
= par
[0] - DBREAKA
;
2689 TCGv_i32 tmp
= tcg_const_i32(id
);
2691 assert(id
< dc
->config
->ndbreak
);
2692 gen_helper_wsr_dbreaka(cpu_env
, tmp
, arg
[0].in
);
2697 static void translate_wsr_dbreakc(DisasContext
*dc
, const OpcodeArg arg
[],
2698 const uint32_t par
[])
2700 #ifndef CONFIG_USER_ONLY
2701 unsigned id
= par
[0] - DBREAKC
;
2702 TCGv_i32 tmp
= tcg_const_i32(id
);
2704 assert(id
< dc
->config
->ndbreak
);
2705 gen_helper_wsr_dbreakc(cpu_env
, tmp
, arg
[0].in
);
2710 static void translate_wsr_ibreaka(DisasContext
*dc
, const OpcodeArg arg
[],
2711 const uint32_t par
[])
2713 #ifndef CONFIG_USER_ONLY
2714 unsigned id
= par
[0] - IBREAKA
;
2715 TCGv_i32 tmp
= tcg_const_i32(id
);
2717 assert(id
< dc
->config
->nibreak
);
2718 gen_helper_wsr_ibreaka(cpu_env
, tmp
, arg
[0].in
);
2723 static void translate_wsr_ibreakenable(DisasContext
*dc
, const OpcodeArg arg
[],
2724 const uint32_t par
[])
2726 #ifndef CONFIG_USER_ONLY
2727 gen_helper_wsr_ibreakenable(cpu_env
, arg
[0].in
);
2731 static void translate_wsr_icount(DisasContext
*dc
, const OpcodeArg arg
[],
2732 const uint32_t par
[])
2734 #ifndef CONFIG_USER_ONLY
2736 tcg_gen_mov_i32(dc
->next_icount
, arg
[0].in
);
2738 tcg_gen_mov_i32(cpu_SR
[par
[0]], arg
[0].in
);
2743 static void translate_wsr_intclear(DisasContext
*dc
, const OpcodeArg arg
[],
2744 const uint32_t par
[])
2746 #ifndef CONFIG_USER_ONLY
2747 gen_helper_intclear(cpu_env
, arg
[0].in
);
2751 static void translate_wsr_intset(DisasContext
*dc
, const OpcodeArg arg
[],
2752 const uint32_t par
[])
2754 #ifndef CONFIG_USER_ONLY
2755 gen_helper_intset(cpu_env
, arg
[0].in
);
2759 static void translate_wsr_memctl(DisasContext
*dc
, const OpcodeArg arg
[],
2760 const uint32_t par
[])
2762 #ifndef CONFIG_USER_ONLY
2763 gen_helper_wsr_memctl(cpu_env
, arg
[0].in
);
2767 static void translate_wsr_mpuenb(DisasContext
*dc
, const OpcodeArg arg
[],
2768 const uint32_t par
[])
2770 #ifndef CONFIG_USER_ONLY
2771 gen_helper_wsr_mpuenb(cpu_env
, arg
[0].in
);
2775 static void translate_wsr_ps(DisasContext
*dc
, const OpcodeArg arg
[],
2776 const uint32_t par
[])
2778 #ifndef CONFIG_USER_ONLY
2779 uint32_t mask
= PS_WOE
| PS_CALLINC
| PS_OWB
|
2780 PS_UM
| PS_EXCM
| PS_INTLEVEL
;
2782 if (option_enabled(dc
, XTENSA_OPTION_MMU
) ||
2783 option_enabled(dc
, XTENSA_OPTION_MPU
)) {
2786 tcg_gen_andi_i32(cpu_SR
[par
[0]], arg
[0].in
, mask
);
2790 static void translate_wsr_rasid(DisasContext
*dc
, const OpcodeArg arg
[],
2791 const uint32_t par
[])
2793 #ifndef CONFIG_USER_ONLY
2794 gen_helper_wsr_rasid(cpu_env
, arg
[0].in
);
2798 static void translate_wsr_sar(DisasContext
*dc
, const OpcodeArg arg
[],
2799 const uint32_t par
[])
2801 tcg_gen_andi_i32(cpu_SR
[par
[0]], arg
[0].in
, 0x3f);
2802 if (dc
->sar_m32_5bit
) {
2803 tcg_gen_discard_i32(dc
->sar_m32
);
2805 dc
->sar_5bit
= false;
2806 dc
->sar_m32_5bit
= false;
2809 static void translate_wsr_windowbase(DisasContext
*dc
, const OpcodeArg arg
[],
2810 const uint32_t par
[])
2812 #ifndef CONFIG_USER_ONLY
2813 tcg_gen_mov_i32(cpu_windowbase_next
, arg
[0].in
);
2817 static void translate_wsr_windowstart(DisasContext
*dc
, const OpcodeArg arg
[],
2818 const uint32_t par
[])
2820 #ifndef CONFIG_USER_ONLY
2821 tcg_gen_andi_i32(cpu_SR
[par
[0]], arg
[0].in
,
2822 (1 << dc
->config
->nareg
/ 4) - 1);
2826 static void translate_wur(DisasContext
*dc
, const OpcodeArg arg
[],
2827 const uint32_t par
[])
2829 tcg_gen_mov_i32(cpu_UR
[par
[0]], arg
[0].in
);
2832 static void translate_xor(DisasContext
*dc
, const OpcodeArg arg
[],
2833 const uint32_t par
[])
2835 tcg_gen_xor_i32(arg
[0].out
, arg
[1].in
, arg
[2].in
);
2838 static void translate_xsr(DisasContext
*dc
, const OpcodeArg arg
[],
2839 const uint32_t par
[])
2841 if (sr_name
[par
[0]]) {
2842 TCGv_i32 tmp
= tcg_temp_new_i32();
2844 tcg_gen_mov_i32(tmp
, arg
[0].in
);
2845 tcg_gen_mov_i32(arg
[0].out
, cpu_SR
[par
[0]]);
2846 tcg_gen_mov_i32(cpu_SR
[par
[0]], tmp
);
2849 tcg_gen_movi_i32(arg
[0].out
, 0);
2853 static void translate_xsr_mask(DisasContext
*dc
, const OpcodeArg arg
[],
2854 const uint32_t par
[])
2856 if (sr_name
[par
[0]]) {
2857 TCGv_i32 tmp
= tcg_temp_new_i32();
2859 tcg_gen_mov_i32(tmp
, arg
[0].in
);
2860 tcg_gen_mov_i32(arg
[0].out
, cpu_SR
[par
[0]]);
2861 tcg_gen_andi_i32(cpu_SR
[par
[0]], tmp
, par
[2]);
2864 tcg_gen_movi_i32(arg
[0].out
, 0);
2868 static void translate_xsr_ccount(DisasContext
*dc
, const OpcodeArg arg
[],
2869 const uint32_t par
[])
2871 #ifndef CONFIG_USER_ONLY
2872 TCGv_i32 tmp
= tcg_temp_new_i32();
2874 if (tb_cflags(dc
->base
.tb
) & CF_USE_ICOUNT
) {
2878 gen_helper_update_ccount(cpu_env
);
2879 tcg_gen_mov_i32(tmp
, cpu_SR
[par
[0]]);
2880 gen_helper_wsr_ccount(cpu_env
, arg
[0].in
);
2881 tcg_gen_mov_i32(arg
[0].out
, tmp
);
2887 #define gen_translate_xsr(name) \
2888 static void translate_xsr_##name(DisasContext *dc, const OpcodeArg arg[], \
2889 const uint32_t par[]) \
2891 TCGv_i32 tmp = tcg_temp_new_i32(); \
2893 if (sr_name[par[0]]) { \
2894 tcg_gen_mov_i32(tmp, cpu_SR[par[0]]); \
2896 tcg_gen_movi_i32(tmp, 0); \
2898 translate_wsr_##name(dc, arg, par); \
2899 tcg_gen_mov_i32(arg[0].out, tmp); \
2900 tcg_temp_free(tmp); \
2903 gen_translate_xsr(acchi
)
2904 gen_translate_xsr(ccompare
)
2905 gen_translate_xsr(dbreaka
)
2906 gen_translate_xsr(dbreakc
)
2907 gen_translate_xsr(ibreaka
)
2908 gen_translate_xsr(ibreakenable
)
2909 gen_translate_xsr(icount
)
2910 gen_translate_xsr(memctl
)
2911 gen_translate_xsr(mpuenb
)
2912 gen_translate_xsr(ps
)
2913 gen_translate_xsr(rasid
)
2914 gen_translate_xsr(sar
)
2915 gen_translate_xsr(windowbase
)
2916 gen_translate_xsr(windowstart
)
2918 #undef gen_translate_xsr
2920 static const XtensaOpcodeOps core_ops
[] = {
2923 .translate
= translate_abs
,
2925 .name
= (const char * const[]) {
2926 "add", "add.n", NULL
,
2928 .translate
= translate_add
,
2929 .op_flags
= XTENSA_OP_NAME_ARRAY
,
2931 .name
= (const char * const[]) {
2932 "addi", "addi.n", NULL
,
2934 .translate
= translate_addi
,
2935 .op_flags
= XTENSA_OP_NAME_ARRAY
,
2938 .translate
= translate_addi
,
2941 .translate
= translate_addx
,
2942 .par
= (const uint32_t[]){1},
2945 .translate
= translate_addx
,
2946 .par
= (const uint32_t[]){2},
2949 .translate
= translate_addx
,
2950 .par
= (const uint32_t[]){3},
2953 .translate
= translate_all
,
2954 .par
= (const uint32_t[]){true, 4},
2957 .translate
= translate_all
,
2958 .par
= (const uint32_t[]){true, 8},
2961 .translate
= translate_and
,
2964 .translate
= translate_boolean
,
2965 .par
= (const uint32_t[]){BOOLEAN_AND
},
2968 .translate
= translate_boolean
,
2969 .par
= (const uint32_t[]){BOOLEAN_ANDC
},
2972 .translate
= translate_all
,
2973 .par
= (const uint32_t[]){false, 4},
2976 .translate
= translate_all
,
2977 .par
= (const uint32_t[]){false, 8},
2979 .name
= (const char * const[]) {
2980 "ball", "ball.w15", "ball.w18", NULL
,
2982 .translate
= translate_ball
,
2983 .par
= (const uint32_t[]){TCG_COND_EQ
},
2984 .op_flags
= XTENSA_OP_NAME_ARRAY
,
2986 .name
= (const char * const[]) {
2987 "bany", "bany.w15", "bany.w18", NULL
,
2989 .translate
= translate_bany
,
2990 .par
= (const uint32_t[]){TCG_COND_NE
},
2991 .op_flags
= XTENSA_OP_NAME_ARRAY
,
2993 .name
= (const char * const[]) {
2994 "bbc", "bbc.w15", "bbc.w18", NULL
,
2996 .translate
= translate_bb
,
2997 .par
= (const uint32_t[]){TCG_COND_EQ
},
2998 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3000 .name
= (const char * const[]) {
3001 "bbci", "bbci.w15", "bbci.w18", NULL
,
3003 .translate
= translate_bbi
,
3004 .par
= (const uint32_t[]){TCG_COND_EQ
},
3005 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3007 .name
= (const char * const[]) {
3008 "bbs", "bbs.w15", "bbs.w18", NULL
,
3010 .translate
= translate_bb
,
3011 .par
= (const uint32_t[]){TCG_COND_NE
},
3012 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3014 .name
= (const char * const[]) {
3015 "bbsi", "bbsi.w15", "bbsi.w18", NULL
,
3017 .translate
= translate_bbi
,
3018 .par
= (const uint32_t[]){TCG_COND_NE
},
3019 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3021 .name
= (const char * const[]) {
3022 "beq", "beq.w15", "beq.w18", NULL
,
3024 .translate
= translate_b
,
3025 .par
= (const uint32_t[]){TCG_COND_EQ
},
3026 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3028 .name
= (const char * const[]) {
3029 "beqi", "beqi.w15", "beqi.w18", NULL
,
3031 .translate
= translate_bi
,
3032 .par
= (const uint32_t[]){TCG_COND_EQ
},
3033 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3035 .name
= (const char * const[]) {
3036 "beqz", "beqz.n", "beqz.w15", "beqz.w18", NULL
,
3038 .translate
= translate_bz
,
3039 .par
= (const uint32_t[]){TCG_COND_EQ
},
3040 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3043 .translate
= translate_bp
,
3044 .par
= (const uint32_t[]){TCG_COND_EQ
},
3046 .name
= (const char * const[]) {
3047 "bge", "bge.w15", "bge.w18", NULL
,
3049 .translate
= translate_b
,
3050 .par
= (const uint32_t[]){TCG_COND_GE
},
3051 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3053 .name
= (const char * const[]) {
3054 "bgei", "bgei.w15", "bgei.w18", NULL
,
3056 .translate
= translate_bi
,
3057 .par
= (const uint32_t[]){TCG_COND_GE
},
3058 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3060 .name
= (const char * const[]) {
3061 "bgeu", "bgeu.w15", "bgeu.w18", NULL
,
3063 .translate
= translate_b
,
3064 .par
= (const uint32_t[]){TCG_COND_GEU
},
3065 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3067 .name
= (const char * const[]) {
3068 "bgeui", "bgeui.w15", "bgeui.w18", NULL
,
3070 .translate
= translate_bi
,
3071 .par
= (const uint32_t[]){TCG_COND_GEU
},
3072 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3074 .name
= (const char * const[]) {
3075 "bgez", "bgez.w15", "bgez.w18", NULL
,
3077 .translate
= translate_bz
,
3078 .par
= (const uint32_t[]){TCG_COND_GE
},
3079 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3081 .name
= (const char * const[]) {
3082 "blt", "blt.w15", "blt.w18", NULL
,
3084 .translate
= translate_b
,
3085 .par
= (const uint32_t[]){TCG_COND_LT
},
3086 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3088 .name
= (const char * const[]) {
3089 "blti", "blti.w15", "blti.w18", NULL
,
3091 .translate
= translate_bi
,
3092 .par
= (const uint32_t[]){TCG_COND_LT
},
3093 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3095 .name
= (const char * const[]) {
3096 "bltu", "bltu.w15", "bltu.w18", NULL
,
3098 .translate
= translate_b
,
3099 .par
= (const uint32_t[]){TCG_COND_LTU
},
3100 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3102 .name
= (const char * const[]) {
3103 "bltui", "bltui.w15", "bltui.w18", NULL
,
3105 .translate
= translate_bi
,
3106 .par
= (const uint32_t[]){TCG_COND_LTU
},
3107 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3109 .name
= (const char * const[]) {
3110 "bltz", "bltz.w15", "bltz.w18", NULL
,
3112 .translate
= translate_bz
,
3113 .par
= (const uint32_t[]){TCG_COND_LT
},
3114 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3116 .name
= (const char * const[]) {
3117 "bnall", "bnall.w15", "bnall.w18", NULL
,
3119 .translate
= translate_ball
,
3120 .par
= (const uint32_t[]){TCG_COND_NE
},
3121 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3123 .name
= (const char * const[]) {
3124 "bne", "bne.w15", "bne.w18", NULL
,
3126 .translate
= translate_b
,
3127 .par
= (const uint32_t[]){TCG_COND_NE
},
3128 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3130 .name
= (const char * const[]) {
3131 "bnei", "bnei.w15", "bnei.w18", NULL
,
3133 .translate
= translate_bi
,
3134 .par
= (const uint32_t[]){TCG_COND_NE
},
3135 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3137 .name
= (const char * const[]) {
3138 "bnez", "bnez.n", "bnez.w15", "bnez.w18", NULL
,
3140 .translate
= translate_bz
,
3141 .par
= (const uint32_t[]){TCG_COND_NE
},
3142 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3144 .name
= (const char * const[]) {
3145 "bnone", "bnone.w15", "bnone.w18", NULL
,
3147 .translate
= translate_bany
,
3148 .par
= (const uint32_t[]){TCG_COND_EQ
},
3149 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3152 .translate
= translate_nop
,
3153 .par
= (const uint32_t[]){DEBUGCAUSE_BI
},
3154 .op_flags
= XTENSA_OP_DEBUG_BREAK
,
3157 .translate
= translate_nop
,
3158 .par
= (const uint32_t[]){DEBUGCAUSE_BN
},
3159 .op_flags
= XTENSA_OP_DEBUG_BREAK
,
3162 .translate
= translate_bp
,
3163 .par
= (const uint32_t[]){TCG_COND_NE
},
3166 .translate
= translate_call0
,
3169 .translate
= translate_callw
,
3170 .par
= (const uint32_t[]){3},
3173 .translate
= translate_callw
,
3174 .par
= (const uint32_t[]){1},
3177 .translate
= translate_callw
,
3178 .par
= (const uint32_t[]){2},
3181 .translate
= translate_callx0
,
3184 .translate
= translate_callxw
,
3185 .par
= (const uint32_t[]){3},
3188 .translate
= translate_callxw
,
3189 .par
= (const uint32_t[]){1},
3192 .translate
= translate_callxw
,
3193 .par
= (const uint32_t[]){2},
3196 .translate
= translate_clamps
,
3198 .name
= "clrb_expstate",
3199 .translate
= translate_clrb_expstate
,
3202 .translate
= translate_clrex
,
3205 .translate
= translate_const16
,
3208 .translate
= translate_depbits
,
3211 .translate
= translate_dcache
,
3212 .op_flags
= XTENSA_OP_PRIVILEGED
,
3215 .translate
= translate_nop
,
3218 .translate
= translate_dcache
,
3219 .op_flags
= XTENSA_OP_PRIVILEGED
,
3222 .translate
= translate_dcache
,
3225 .translate
= translate_nop
,
3228 .translate
= translate_dcache
,
3231 .translate
= translate_nop
,
3234 .translate
= translate_nop
,
3235 .op_flags
= XTENSA_OP_PRIVILEGED
,
3238 .translate
= translate_nop
,
3239 .op_flags
= XTENSA_OP_PRIVILEGED
,
3242 .translate
= translate_nop
,
3243 .op_flags
= XTENSA_OP_PRIVILEGED
,
3246 .translate
= translate_nop
,
3247 .op_flags
= XTENSA_OP_PRIVILEGED
,
3250 .translate
= translate_diwbuip
,
3251 .op_flags
= XTENSA_OP_PRIVILEGED
,
3254 .translate
= translate_dcache
,
3255 .op_flags
= XTENSA_OP_PRIVILEGED
,
3258 .translate
= translate_nop
,
3261 .translate
= translate_nop
,
3264 .translate
= translate_nop
,
3267 .translate
= translate_nop
,
3270 .translate
= translate_nop
,
3273 .translate
= translate_nop
,
3276 .translate
= translate_nop
,
3279 .translate
= translate_nop
,
3282 .translate
= translate_nop
,
3285 .translate
= translate_nop
,
3288 .translate
= translate_nop
,
3291 .translate
= translate_entry
,
3292 .test_exceptions
= test_exceptions_entry
,
3293 .test_overflow
= test_overflow_entry
,
3294 .op_flags
= XTENSA_OP_EXIT_TB_M1
|
3295 XTENSA_OP_SYNC_REGISTER_WINDOW
,
3298 .translate
= translate_nop
,
3301 .translate
= translate_nop
,
3304 .translate
= translate_extui
,
3307 .translate
= translate_memw
,
3310 .translate
= translate_getex
,
3313 .op_flags
= XTENSA_OP_ILL
,
3316 .op_flags
= XTENSA_OP_ILL
,
3319 .translate
= translate_itlb
,
3320 .par
= (const uint32_t[]){true},
3321 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
3324 .translate
= translate_icache
,
3327 .translate
= translate_icache
,
3328 .op_flags
= XTENSA_OP_PRIVILEGED
,
3331 .translate
= translate_nop
,
3332 .op_flags
= XTENSA_OP_PRIVILEGED
,
3335 .translate
= translate_itlb
,
3336 .par
= (const uint32_t[]){false},
3337 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
3340 .translate
= translate_nop
,
3341 .op_flags
= XTENSA_OP_PRIVILEGED
,
3343 .name
= (const char * const[]) {
3344 "ill", "ill.n", NULL
,
3346 .op_flags
= XTENSA_OP_ILL
| XTENSA_OP_NAME_ARRAY
,
3349 .translate
= translate_nop
,
3352 .translate
= translate_icache
,
3353 .op_flags
= XTENSA_OP_PRIVILEGED
,
3356 .translate
= translate_nop
,
3359 .translate
= translate_j
,
3362 .translate
= translate_jx
,
3365 .translate
= translate_ldst
,
3366 .par
= (const uint32_t[]){MO_TESW
, false, false},
3367 .op_flags
= XTENSA_OP_LOAD
,
3370 .translate
= translate_ldst
,
3371 .par
= (const uint32_t[]){MO_TEUW
, false, false},
3372 .op_flags
= XTENSA_OP_LOAD
,
3375 .translate
= translate_ldst
,
3376 .par
= (const uint32_t[]){MO_TEUL
| MO_ALIGN
, true, false},
3377 .op_flags
= XTENSA_OP_LOAD
,
3380 .translate
= translate_l32e
,
3381 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_LOAD
,
3384 .translate
= translate_l32ex
,
3385 .op_flags
= XTENSA_OP_LOAD
,
3387 .name
= (const char * const[]) {
3388 "l32i", "l32i.n", NULL
,
3390 .translate
= translate_ldst
,
3391 .par
= (const uint32_t[]){MO_TEUL
, false, false},
3392 .op_flags
= XTENSA_OP_NAME_ARRAY
| XTENSA_OP_LOAD
,
3395 .translate
= translate_l32r
,
3396 .op_flags
= XTENSA_OP_LOAD
,
3399 .translate
= translate_ldst
,
3400 .par
= (const uint32_t[]){MO_UB
, false, false},
3401 .op_flags
= XTENSA_OP_LOAD
,
3404 .translate
= translate_mac16
,
3405 .par
= (const uint32_t[]){MAC16_NONE
, 0, -4},
3406 .op_flags
= XTENSA_OP_LOAD
,
3409 .translate
= translate_mac16
,
3410 .par
= (const uint32_t[]){MAC16_NONE
, 0, 4},
3411 .op_flags
= XTENSA_OP_LOAD
,
3414 .op_flags
= XTENSA_OP_ILL
,
3416 .name
= (const char * const[]) {
3417 "loop", "loop.w15", NULL
,
3419 .translate
= translate_loop
,
3420 .par
= (const uint32_t[]){TCG_COND_NEVER
},
3421 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3423 .name
= (const char * const[]) {
3424 "loopgtz", "loopgtz.w15", NULL
,
3426 .translate
= translate_loop
,
3427 .par
= (const uint32_t[]){TCG_COND_GT
},
3428 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3430 .name
= (const char * const[]) {
3431 "loopnez", "loopnez.w15", NULL
,
3433 .translate
= translate_loop
,
3434 .par
= (const uint32_t[]){TCG_COND_NE
},
3435 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3438 .translate
= translate_smax
,
3441 .translate
= translate_umax
,
3444 .translate
= translate_memw
,
3447 .translate
= translate_smin
,
3450 .translate
= translate_umin
,
3452 .name
= (const char * const[]) {
3453 "mov", "mov.n", NULL
,
3455 .translate
= translate_mov
,
3456 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3459 .translate
= translate_movcond
,
3460 .par
= (const uint32_t[]){TCG_COND_EQ
},
3463 .translate
= translate_movp
,
3464 .par
= (const uint32_t[]){TCG_COND_EQ
},
3467 .translate
= translate_movcond
,
3468 .par
= (const uint32_t[]){TCG_COND_GE
},
3471 .translate
= translate_movi
,
3474 .translate
= translate_movi
,
3477 .translate
= translate_movcond
,
3478 .par
= (const uint32_t[]){TCG_COND_LT
},
3481 .translate
= translate_movcond
,
3482 .par
= (const uint32_t[]){TCG_COND_NE
},
3485 .translate
= translate_movsp
,
3486 .op_flags
= XTENSA_OP_ALLOCA
,
3489 .translate
= translate_movp
,
3490 .par
= (const uint32_t[]){TCG_COND_NE
},
3492 .name
= "mul.aa.hh",
3493 .translate
= translate_mac16
,
3494 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_HH
, 0},
3496 .name
= "mul.aa.hl",
3497 .translate
= translate_mac16
,
3498 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_HL
, 0},
3500 .name
= "mul.aa.lh",
3501 .translate
= translate_mac16
,
3502 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_LH
, 0},
3504 .name
= "mul.aa.ll",
3505 .translate
= translate_mac16
,
3506 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_LL
, 0},
3508 .name
= "mul.ad.hh",
3509 .translate
= translate_mac16
,
3510 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_HH
, 0},
3512 .name
= "mul.ad.hl",
3513 .translate
= translate_mac16
,
3514 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_HL
, 0},
3516 .name
= "mul.ad.lh",
3517 .translate
= translate_mac16
,
3518 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_LH
, 0},
3520 .name
= "mul.ad.ll",
3521 .translate
= translate_mac16
,
3522 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_LL
, 0},
3524 .name
= "mul.da.hh",
3525 .translate
= translate_mac16
,
3526 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_HH
, 0},
3528 .name
= "mul.da.hl",
3529 .translate
= translate_mac16
,
3530 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_HL
, 0},
3532 .name
= "mul.da.lh",
3533 .translate
= translate_mac16
,
3534 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_LH
, 0},
3536 .name
= "mul.da.ll",
3537 .translate
= translate_mac16
,
3538 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_LL
, 0},
3540 .name
= "mul.dd.hh",
3541 .translate
= translate_mac16
,
3542 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_HH
, 0},
3544 .name
= "mul.dd.hl",
3545 .translate
= translate_mac16
,
3546 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_HL
, 0},
3548 .name
= "mul.dd.lh",
3549 .translate
= translate_mac16
,
3550 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_LH
, 0},
3552 .name
= "mul.dd.ll",
3553 .translate
= translate_mac16
,
3554 .par
= (const uint32_t[]){MAC16_MUL
, MAC16_LL
, 0},
3557 .translate
= translate_mul16
,
3558 .par
= (const uint32_t[]){true},
3561 .translate
= translate_mul16
,
3562 .par
= (const uint32_t[]){false},
3564 .name
= "mula.aa.hh",
3565 .translate
= translate_mac16
,
3566 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HH
, 0},
3568 .name
= "mula.aa.hl",
3569 .translate
= translate_mac16
,
3570 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HL
, 0},
3572 .name
= "mula.aa.lh",
3573 .translate
= translate_mac16
,
3574 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LH
, 0},
3576 .name
= "mula.aa.ll",
3577 .translate
= translate_mac16
,
3578 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LL
, 0},
3580 .name
= "mula.ad.hh",
3581 .translate
= translate_mac16
,
3582 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HH
, 0},
3584 .name
= "mula.ad.hl",
3585 .translate
= translate_mac16
,
3586 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HL
, 0},
3588 .name
= "mula.ad.lh",
3589 .translate
= translate_mac16
,
3590 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LH
, 0},
3592 .name
= "mula.ad.ll",
3593 .translate
= translate_mac16
,
3594 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LL
, 0},
3596 .name
= "mula.da.hh",
3597 .translate
= translate_mac16
,
3598 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HH
, 0},
3600 .name
= "mula.da.hh.lddec",
3601 .translate
= translate_mac16
,
3602 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HH
, -4},
3604 .name
= "mula.da.hh.ldinc",
3605 .translate
= translate_mac16
,
3606 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HH
, 4},
3608 .name
= "mula.da.hl",
3609 .translate
= translate_mac16
,
3610 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HL
, 0},
3612 .name
= "mula.da.hl.lddec",
3613 .translate
= translate_mac16
,
3614 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HL
, -4},
3616 .name
= "mula.da.hl.ldinc",
3617 .translate
= translate_mac16
,
3618 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HL
, 4},
3620 .name
= "mula.da.lh",
3621 .translate
= translate_mac16
,
3622 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LH
, 0},
3624 .name
= "mula.da.lh.lddec",
3625 .translate
= translate_mac16
,
3626 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LH
, -4},
3628 .name
= "mula.da.lh.ldinc",
3629 .translate
= translate_mac16
,
3630 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LH
, 4},
3632 .name
= "mula.da.ll",
3633 .translate
= translate_mac16
,
3634 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LL
, 0},
3636 .name
= "mula.da.ll.lddec",
3637 .translate
= translate_mac16
,
3638 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LL
, -4},
3640 .name
= "mula.da.ll.ldinc",
3641 .translate
= translate_mac16
,
3642 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LL
, 4},
3644 .name
= "mula.dd.hh",
3645 .translate
= translate_mac16
,
3646 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HH
, 0},
3648 .name
= "mula.dd.hh.lddec",
3649 .translate
= translate_mac16
,
3650 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HH
, -4},
3652 .name
= "mula.dd.hh.ldinc",
3653 .translate
= translate_mac16
,
3654 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HH
, 4},
3656 .name
= "mula.dd.hl",
3657 .translate
= translate_mac16
,
3658 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HL
, 0},
3660 .name
= "mula.dd.hl.lddec",
3661 .translate
= translate_mac16
,
3662 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HL
, -4},
3664 .name
= "mula.dd.hl.ldinc",
3665 .translate
= translate_mac16
,
3666 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_HL
, 4},
3668 .name
= "mula.dd.lh",
3669 .translate
= translate_mac16
,
3670 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LH
, 0},
3672 .name
= "mula.dd.lh.lddec",
3673 .translate
= translate_mac16
,
3674 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LH
, -4},
3676 .name
= "mula.dd.lh.ldinc",
3677 .translate
= translate_mac16
,
3678 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LH
, 4},
3680 .name
= "mula.dd.ll",
3681 .translate
= translate_mac16
,
3682 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LL
, 0},
3684 .name
= "mula.dd.ll.lddec",
3685 .translate
= translate_mac16
,
3686 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LL
, -4},
3688 .name
= "mula.dd.ll.ldinc",
3689 .translate
= translate_mac16
,
3690 .par
= (const uint32_t[]){MAC16_MULA
, MAC16_LL
, 4},
3693 .translate
= translate_mull
,
3695 .name
= "muls.aa.hh",
3696 .translate
= translate_mac16
,
3697 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_HH
, 0},
3699 .name
= "muls.aa.hl",
3700 .translate
= translate_mac16
,
3701 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_HL
, 0},
3703 .name
= "muls.aa.lh",
3704 .translate
= translate_mac16
,
3705 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_LH
, 0},
3707 .name
= "muls.aa.ll",
3708 .translate
= translate_mac16
,
3709 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_LL
, 0},
3711 .name
= "muls.ad.hh",
3712 .translate
= translate_mac16
,
3713 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_HH
, 0},
3715 .name
= "muls.ad.hl",
3716 .translate
= translate_mac16
,
3717 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_HL
, 0},
3719 .name
= "muls.ad.lh",
3720 .translate
= translate_mac16
,
3721 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_LH
, 0},
3723 .name
= "muls.ad.ll",
3724 .translate
= translate_mac16
,
3725 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_LL
, 0},
3727 .name
= "muls.da.hh",
3728 .translate
= translate_mac16
,
3729 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_HH
, 0},
3731 .name
= "muls.da.hl",
3732 .translate
= translate_mac16
,
3733 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_HL
, 0},
3735 .name
= "muls.da.lh",
3736 .translate
= translate_mac16
,
3737 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_LH
, 0},
3739 .name
= "muls.da.ll",
3740 .translate
= translate_mac16
,
3741 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_LL
, 0},
3743 .name
= "muls.dd.hh",
3744 .translate
= translate_mac16
,
3745 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_HH
, 0},
3747 .name
= "muls.dd.hl",
3748 .translate
= translate_mac16
,
3749 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_HL
, 0},
3751 .name
= "muls.dd.lh",
3752 .translate
= translate_mac16
,
3753 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_LH
, 0},
3755 .name
= "muls.dd.ll",
3756 .translate
= translate_mac16
,
3757 .par
= (const uint32_t[]){MAC16_MULS
, MAC16_LL
, 0},
3760 .translate
= translate_mulh
,
3761 .par
= (const uint32_t[]){true},
3764 .translate
= translate_mulh
,
3765 .par
= (const uint32_t[]){false},
3768 .translate
= translate_neg
,
3770 .name
= (const char * const[]) {
3771 "nop", "nop.n", NULL
,
3773 .translate
= translate_nop
,
3774 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3777 .translate
= translate_nsa
,
3780 .translate
= translate_nsau
,
3783 .translate
= translate_or
,
3786 .translate
= translate_boolean
,
3787 .par
= (const uint32_t[]){BOOLEAN_OR
},
3790 .translate
= translate_boolean
,
3791 .par
= (const uint32_t[]){BOOLEAN_ORC
},
3794 .translate
= translate_ptlb
,
3795 .par
= (const uint32_t[]){true},
3796 .op_flags
= XTENSA_OP_PRIVILEGED
,
3799 .translate
= translate_nop
,
3802 .translate
= translate_nop
,
3805 .translate
= translate_nop
,
3808 .translate
= translate_nop
,
3811 .translate
= translate_nop
,
3814 .translate
= translate_ptlb
,
3815 .par
= (const uint32_t[]){false},
3816 .op_flags
= XTENSA_OP_PRIVILEGED
,
3819 .translate
= translate_pptlb
,
3820 .op_flags
= XTENSA_OP_PRIVILEGED
,
3823 .translate
= translate_quos
,
3824 .par
= (const uint32_t[]){true},
3825 .op_flags
= XTENSA_OP_DIVIDE_BY_ZERO
,
3828 .translate
= translate_quou
,
3829 .op_flags
= XTENSA_OP_DIVIDE_BY_ZERO
,
3832 .translate
= translate_rtlb
,
3833 .par
= (const uint32_t[]){true, 0},
3834 .op_flags
= XTENSA_OP_PRIVILEGED
,
3837 .translate
= translate_rtlb
,
3838 .par
= (const uint32_t[]){true, 1},
3839 .op_flags
= XTENSA_OP_PRIVILEGED
,
3841 .name
= "read_impwire",
3842 .translate
= translate_read_impwire
,
3845 .translate
= translate_quos
,
3846 .par
= (const uint32_t[]){false},
3847 .op_flags
= XTENSA_OP_DIVIDE_BY_ZERO
,
3850 .translate
= translate_remu
,
3851 .op_flags
= XTENSA_OP_DIVIDE_BY_ZERO
,
3854 .translate
= translate_rer
,
3855 .op_flags
= XTENSA_OP_PRIVILEGED
,
3857 .name
= (const char * const[]) {
3858 "ret", "ret.n", NULL
,
3860 .translate
= translate_ret
,
3861 .op_flags
= XTENSA_OP_NAME_ARRAY
,
3863 .name
= (const char * const[]) {
3864 "retw", "retw.n", NULL
,
3866 .translate
= translate_retw
,
3867 .test_exceptions
= test_exceptions_retw
,
3868 .op_flags
= XTENSA_OP_UNDERFLOW
| XTENSA_OP_NAME_ARRAY
,
3871 .op_flags
= XTENSA_OP_ILL
,
3874 .translate
= translate_rfde
,
3875 .op_flags
= XTENSA_OP_PRIVILEGED
,
3878 .op_flags
= XTENSA_OP_ILL
,
3881 .translate
= translate_rfe
,
3882 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_CHECK_INTERRUPTS
,
3885 .translate
= translate_rfi
,
3886 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_CHECK_INTERRUPTS
,
3889 .translate
= translate_rfw
,
3890 .par
= (const uint32_t[]){true},
3891 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_CHECK_INTERRUPTS
,
3894 .translate
= translate_rfw
,
3895 .par
= (const uint32_t[]){false},
3896 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_CHECK_INTERRUPTS
,
3899 .translate
= translate_rtlb
,
3900 .par
= (const uint32_t[]){false, 0},
3901 .op_flags
= XTENSA_OP_PRIVILEGED
,
3904 .translate
= translate_rtlb
,
3905 .par
= (const uint32_t[]){false, 1},
3906 .op_flags
= XTENSA_OP_PRIVILEGED
,
3909 .translate
= translate_rptlb0
,
3910 .op_flags
= XTENSA_OP_PRIVILEGED
,
3913 .translate
= translate_rptlb1
,
3914 .op_flags
= XTENSA_OP_PRIVILEGED
,
3917 .translate
= translate_rotw
,
3918 .op_flags
= XTENSA_OP_PRIVILEGED
|
3919 XTENSA_OP_EXIT_TB_M1
|
3920 XTENSA_OP_SYNC_REGISTER_WINDOW
,
3923 .translate
= translate_rsil
,
3925 XTENSA_OP_PRIVILEGED
|
3926 XTENSA_OP_EXIT_TB_0
|
3927 XTENSA_OP_CHECK_INTERRUPTS
,
3930 .translate
= translate_rsr
,
3931 .par
= (const uint32_t[]){176},
3932 .op_flags
= XTENSA_OP_PRIVILEGED
,
3935 .translate
= translate_rsr
,
3936 .par
= (const uint32_t[]){208},
3937 .op_flags
= XTENSA_OP_PRIVILEGED
,
3939 .name
= "rsr.acchi",
3940 .translate
= translate_rsr
,
3941 .test_exceptions
= test_exceptions_sr
,
3942 .par
= (const uint32_t[]){
3944 XTENSA_OPTION_MAC16
,
3947 .name
= "rsr.acclo",
3948 .translate
= translate_rsr
,
3949 .test_exceptions
= test_exceptions_sr
,
3950 .par
= (const uint32_t[]){
3952 XTENSA_OPTION_MAC16
,
3955 .name
= "rsr.atomctl",
3956 .translate
= translate_rsr
,
3957 .test_exceptions
= test_exceptions_sr
,
3958 .par
= (const uint32_t[]){
3960 XTENSA_OPTION_ATOMCTL
,
3962 .op_flags
= XTENSA_OP_PRIVILEGED
,
3965 .translate
= translate_rsr
,
3966 .test_exceptions
= test_exceptions_sr
,
3967 .par
= (const uint32_t[]){
3969 XTENSA_OPTION_BOOLEAN
,
3972 .name
= "rsr.cacheadrdis",
3973 .translate
= translate_rsr
,
3974 .test_exceptions
= test_exceptions_sr
,
3975 .par
= (const uint32_t[]){
3979 .op_flags
= XTENSA_OP_PRIVILEGED
,
3981 .name
= "rsr.cacheattr",
3982 .translate
= translate_rsr
,
3983 .test_exceptions
= test_exceptions_sr
,
3984 .par
= (const uint32_t[]){
3986 XTENSA_OPTION_CACHEATTR
,
3988 .op_flags
= XTENSA_OP_PRIVILEGED
,
3990 .name
= "rsr.ccompare0",
3991 .translate
= translate_rsr
,
3992 .test_exceptions
= test_exceptions_ccompare
,
3993 .par
= (const uint32_t[]){
3995 XTENSA_OPTION_TIMER_INTERRUPT
,
3997 .op_flags
= XTENSA_OP_PRIVILEGED
,
3999 .name
= "rsr.ccompare1",
4000 .translate
= translate_rsr
,
4001 .test_exceptions
= test_exceptions_ccompare
,
4002 .par
= (const uint32_t[]){
4004 XTENSA_OPTION_TIMER_INTERRUPT
,
4006 .op_flags
= XTENSA_OP_PRIVILEGED
,
4008 .name
= "rsr.ccompare2",
4009 .translate
= translate_rsr
,
4010 .test_exceptions
= test_exceptions_ccompare
,
4011 .par
= (const uint32_t[]){
4013 XTENSA_OPTION_TIMER_INTERRUPT
,
4015 .op_flags
= XTENSA_OP_PRIVILEGED
,
4017 .name
= "rsr.ccount",
4018 .translate
= translate_rsr_ccount
,
4019 .test_exceptions
= test_exceptions_sr
,
4020 .par
= (const uint32_t[]){
4022 XTENSA_OPTION_TIMER_INTERRUPT
,
4024 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
4026 .name
= "rsr.configid0",
4027 .translate
= translate_rsr
,
4028 .par
= (const uint32_t[]){CONFIGID0
},
4029 .op_flags
= XTENSA_OP_PRIVILEGED
,
4031 .name
= "rsr.configid1",
4032 .translate
= translate_rsr
,
4033 .par
= (const uint32_t[]){CONFIGID1
},
4034 .op_flags
= XTENSA_OP_PRIVILEGED
,
4036 .name
= "rsr.cpenable",
4037 .translate
= translate_rsr
,
4038 .test_exceptions
= test_exceptions_sr
,
4039 .par
= (const uint32_t[]){
4041 XTENSA_OPTION_COPROCESSOR
,
4043 .op_flags
= XTENSA_OP_PRIVILEGED
,
4045 .name
= "rsr.dbreaka0",
4046 .translate
= translate_rsr
,
4047 .test_exceptions
= test_exceptions_dbreak
,
4048 .par
= (const uint32_t[]){
4050 XTENSA_OPTION_DEBUG
,
4052 .op_flags
= XTENSA_OP_PRIVILEGED
,
4054 .name
= "rsr.dbreaka1",
4055 .translate
= translate_rsr
,
4056 .test_exceptions
= test_exceptions_dbreak
,
4057 .par
= (const uint32_t[]){
4059 XTENSA_OPTION_DEBUG
,
4061 .op_flags
= XTENSA_OP_PRIVILEGED
,
4063 .name
= "rsr.dbreakc0",
4064 .translate
= translate_rsr
,
4065 .test_exceptions
= test_exceptions_dbreak
,
4066 .par
= (const uint32_t[]){
4068 XTENSA_OPTION_DEBUG
,
4070 .op_flags
= XTENSA_OP_PRIVILEGED
,
4072 .name
= "rsr.dbreakc1",
4073 .translate
= translate_rsr
,
4074 .test_exceptions
= test_exceptions_dbreak
,
4075 .par
= (const uint32_t[]){
4077 XTENSA_OPTION_DEBUG
,
4079 .op_flags
= XTENSA_OP_PRIVILEGED
,
4082 .translate
= translate_rsr
,
4083 .test_exceptions
= test_exceptions_sr
,
4084 .par
= (const uint32_t[]){
4086 XTENSA_OPTION_DEBUG
,
4088 .op_flags
= XTENSA_OP_PRIVILEGED
,
4090 .name
= "rsr.debugcause",
4091 .translate
= translate_rsr
,
4092 .test_exceptions
= test_exceptions_sr
,
4093 .par
= (const uint32_t[]){
4095 XTENSA_OPTION_DEBUG
,
4097 .op_flags
= XTENSA_OP_PRIVILEGED
,
4100 .translate
= translate_rsr
,
4101 .test_exceptions
= test_exceptions_sr
,
4102 .par
= (const uint32_t[]){
4104 XTENSA_OPTION_EXCEPTION
,
4106 .op_flags
= XTENSA_OP_PRIVILEGED
,
4108 .name
= "rsr.dtlbcfg",
4109 .translate
= translate_rsr
,
4110 .test_exceptions
= test_exceptions_sr
,
4111 .par
= (const uint32_t[]){
4115 .op_flags
= XTENSA_OP_PRIVILEGED
,
4118 .translate
= translate_rsr
,
4119 .test_exceptions
= test_exceptions_sr
,
4120 .par
= (const uint32_t[]){
4122 XTENSA_OPTION_EXCEPTION
,
4124 .op_flags
= XTENSA_OP_PRIVILEGED
,
4127 .translate
= translate_rsr
,
4128 .test_exceptions
= test_exceptions_hpi
,
4129 .par
= (const uint32_t[]){
4131 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4133 .op_flags
= XTENSA_OP_PRIVILEGED
,
4136 .translate
= translate_rsr
,
4137 .test_exceptions
= test_exceptions_hpi
,
4138 .par
= (const uint32_t[]){
4140 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4142 .op_flags
= XTENSA_OP_PRIVILEGED
,
4145 .translate
= translate_rsr
,
4146 .test_exceptions
= test_exceptions_hpi
,
4147 .par
= (const uint32_t[]){
4149 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4151 .op_flags
= XTENSA_OP_PRIVILEGED
,
4154 .translate
= translate_rsr
,
4155 .test_exceptions
= test_exceptions_hpi
,
4156 .par
= (const uint32_t[]){
4158 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4160 .op_flags
= XTENSA_OP_PRIVILEGED
,
4163 .translate
= translate_rsr
,
4164 .test_exceptions
= test_exceptions_hpi
,
4165 .par
= (const uint32_t[]){
4167 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4169 .op_flags
= XTENSA_OP_PRIVILEGED
,
4172 .translate
= translate_rsr
,
4173 .test_exceptions
= test_exceptions_hpi
,
4174 .par
= (const uint32_t[]){
4176 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4178 .op_flags
= XTENSA_OP_PRIVILEGED
,
4181 .translate
= translate_rsr
,
4182 .test_exceptions
= test_exceptions_hpi
,
4183 .par
= (const uint32_t[]){
4185 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4187 .op_flags
= XTENSA_OP_PRIVILEGED
,
4190 .translate
= translate_rsr
,
4191 .test_exceptions
= test_exceptions_hpi
,
4192 .par
= (const uint32_t[]){
4194 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4196 .op_flags
= XTENSA_OP_PRIVILEGED
,
4199 .translate
= translate_rsr
,
4200 .test_exceptions
= test_exceptions_hpi
,
4201 .par
= (const uint32_t[]){
4203 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4205 .op_flags
= XTENSA_OP_PRIVILEGED
,
4208 .translate
= translate_rsr
,
4209 .test_exceptions
= test_exceptions_hpi
,
4210 .par
= (const uint32_t[]){
4212 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4214 .op_flags
= XTENSA_OP_PRIVILEGED
,
4217 .translate
= translate_rsr
,
4218 .test_exceptions
= test_exceptions_hpi
,
4219 .par
= (const uint32_t[]){
4221 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4223 .op_flags
= XTENSA_OP_PRIVILEGED
,
4226 .translate
= translate_rsr
,
4227 .test_exceptions
= test_exceptions_hpi
,
4228 .par
= (const uint32_t[]){
4230 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4232 .op_flags
= XTENSA_OP_PRIVILEGED
,
4234 .name
= "rsr.eraccess",
4235 .translate
= translate_rsr
,
4236 .par
= (const uint32_t[]){ERACCESS
},
4237 .op_flags
= XTENSA_OP_PRIVILEGED
,
4239 .name
= "rsr.exccause",
4240 .translate
= translate_rsr
,
4241 .test_exceptions
= test_exceptions_sr
,
4242 .par
= (const uint32_t[]){
4244 XTENSA_OPTION_EXCEPTION
,
4246 .op_flags
= XTENSA_OP_PRIVILEGED
,
4248 .name
= "rsr.excsave1",
4249 .translate
= translate_rsr
,
4250 .test_exceptions
= test_exceptions_sr
,
4251 .par
= (const uint32_t[]){
4253 XTENSA_OPTION_EXCEPTION
,
4255 .op_flags
= XTENSA_OP_PRIVILEGED
,
4257 .name
= "rsr.excsave2",
4258 .translate
= translate_rsr
,
4259 .test_exceptions
= test_exceptions_hpi
,
4260 .par
= (const uint32_t[]){
4262 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4264 .op_flags
= XTENSA_OP_PRIVILEGED
,
4266 .name
= "rsr.excsave3",
4267 .translate
= translate_rsr
,
4268 .test_exceptions
= test_exceptions_hpi
,
4269 .par
= (const uint32_t[]){
4271 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4273 .op_flags
= XTENSA_OP_PRIVILEGED
,
4275 .name
= "rsr.excsave4",
4276 .translate
= translate_rsr
,
4277 .test_exceptions
= test_exceptions_hpi
,
4278 .par
= (const uint32_t[]){
4280 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4282 .op_flags
= XTENSA_OP_PRIVILEGED
,
4284 .name
= "rsr.excsave5",
4285 .translate
= translate_rsr
,
4286 .test_exceptions
= test_exceptions_hpi
,
4287 .par
= (const uint32_t[]){
4289 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4291 .op_flags
= XTENSA_OP_PRIVILEGED
,
4293 .name
= "rsr.excsave6",
4294 .translate
= translate_rsr
,
4295 .test_exceptions
= test_exceptions_hpi
,
4296 .par
= (const uint32_t[]){
4298 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4300 .op_flags
= XTENSA_OP_PRIVILEGED
,
4302 .name
= "rsr.excsave7",
4303 .translate
= translate_rsr
,
4304 .test_exceptions
= test_exceptions_hpi
,
4305 .par
= (const uint32_t[]){
4307 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
4309 .op_flags
= XTENSA_OP_PRIVILEGED
,
4311 .name
= "rsr.excvaddr",
4312 .translate
= translate_rsr
,
4313 .test_exceptions
= test_exceptions_sr
,
4314 .par
= (const uint32_t[]){
4316 XTENSA_OPTION_EXCEPTION
,
4318 .op_flags
= XTENSA_OP_PRIVILEGED
,
4320 .name
= "rsr.ibreaka0",
4321 .translate
= translate_rsr
,
4322 .test_exceptions
= test_exceptions_ibreak
,
4323 .par
= (const uint32_t[]){
4325 XTENSA_OPTION_DEBUG
,
4327 .op_flags
= XTENSA_OP_PRIVILEGED
,
4329 .name
= "rsr.ibreaka1",
4330 .translate
= translate_rsr
,
4331 .test_exceptions
= test_exceptions_ibreak
,
4332 .par
= (const uint32_t[]){
4334 XTENSA_OPTION_DEBUG
,
4336 .op_flags
= XTENSA_OP_PRIVILEGED
,
4338 .name
= "rsr.ibreakenable",
4339 .translate
= translate_rsr
,
4340 .test_exceptions
= test_exceptions_sr
,
4341 .par
= (const uint32_t[]){
4343 XTENSA_OPTION_DEBUG
,
4345 .op_flags
= XTENSA_OP_PRIVILEGED
,
4347 .name
= "rsr.icount",
4348 .translate
= translate_rsr
,
4349 .test_exceptions
= test_exceptions_sr
,
4350 .par
= (const uint32_t[]){
4352 XTENSA_OPTION_DEBUG
,
4354 .op_flags
= XTENSA_OP_PRIVILEGED
,
4356 .name
= "rsr.icountlevel",
4357 .translate
= translate_rsr
,
4358 .test_exceptions
= test_exceptions_sr
,
4359 .par
= (const uint32_t[]){
4361 XTENSA_OPTION_DEBUG
,
4363 .op_flags
= XTENSA_OP_PRIVILEGED
,
4365 .name
= "rsr.intclear",
4366 .translate
= translate_rsr
,
4367 .test_exceptions
= test_exceptions_sr
,
4368 .par
= (const uint32_t[]){
4370 XTENSA_OPTION_INTERRUPT
,
4372 .op_flags
= XTENSA_OP_PRIVILEGED
,
4374 .name
= "rsr.intenable",
4375 .translate
= translate_rsr
,
4376 .test_exceptions
= test_exceptions_sr
,
4377 .par
= (const uint32_t[]){
4379 XTENSA_OPTION_INTERRUPT
,
4381 .op_flags
= XTENSA_OP_PRIVILEGED
,
4383 .name
= "rsr.interrupt",
4384 .translate
= translate_rsr_ccount
,
4385 .test_exceptions
= test_exceptions_sr
,
4386 .par
= (const uint32_t[]){
4388 XTENSA_OPTION_INTERRUPT
,
4390 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
4392 .name
= "rsr.intset",
4393 .translate
= translate_rsr_ccount
,
4394 .test_exceptions
= test_exceptions_sr
,
4395 .par
= (const uint32_t[]){
4397 XTENSA_OPTION_INTERRUPT
,
4399 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
4401 .name
= "rsr.itlbcfg",
4402 .translate
= translate_rsr
,
4403 .test_exceptions
= test_exceptions_sr
,
4404 .par
= (const uint32_t[]){
4408 .op_flags
= XTENSA_OP_PRIVILEGED
,
4411 .translate
= translate_rsr
,
4412 .test_exceptions
= test_exceptions_sr
,
4413 .par
= (const uint32_t[]){
4418 .name
= "rsr.lcount",
4419 .translate
= translate_rsr
,
4420 .test_exceptions
= test_exceptions_sr
,
4421 .par
= (const uint32_t[]){
4427 .translate
= translate_rsr
,
4428 .test_exceptions
= test_exceptions_sr
,
4429 .par
= (const uint32_t[]){
4434 .name
= "rsr.litbase",
4435 .translate
= translate_rsr
,
4436 .test_exceptions
= test_exceptions_sr
,
4437 .par
= (const uint32_t[]){
4439 XTENSA_OPTION_EXTENDED_L32R
,
4443 .translate
= translate_rsr
,
4444 .test_exceptions
= test_exceptions_sr
,
4445 .par
= (const uint32_t[]){
4447 XTENSA_OPTION_MAC16
,
4451 .translate
= translate_rsr
,
4452 .test_exceptions
= test_exceptions_sr
,
4453 .par
= (const uint32_t[]){
4455 XTENSA_OPTION_MAC16
,
4459 .translate
= translate_rsr
,
4460 .test_exceptions
= test_exceptions_sr
,
4461 .par
= (const uint32_t[]){
4463 XTENSA_OPTION_MAC16
,
4467 .translate
= translate_rsr
,
4468 .test_exceptions
= test_exceptions_sr
,
4469 .par
= (const uint32_t[]){
4471 XTENSA_OPTION_MAC16
,
4474 .name
= "rsr.memctl",
4475 .translate
= translate_rsr
,
4476 .par
= (const uint32_t[]){MEMCTL
},
4477 .op_flags
= XTENSA_OP_PRIVILEGED
,
4480 .translate
= translate_rsr
,
4481 .test_exceptions
= test_exceptions_sr
,
4482 .par
= (const uint32_t[]){
4484 XTENSA_OPTION_MEMORY_ECC_PARITY
,
4486 .op_flags
= XTENSA_OP_PRIVILEGED
,
4489 .translate
= translate_rsr
,
4490 .test_exceptions
= test_exceptions_sr
,
4491 .par
= (const uint32_t[]){
4493 XTENSA_OPTION_MEMORY_ECC_PARITY
,
4495 .op_flags
= XTENSA_OP_PRIVILEGED
,
4498 .translate
= translate_rsr
,
4499 .test_exceptions
= test_exceptions_sr
,
4500 .par
= (const uint32_t[]){
4502 XTENSA_OPTION_MEMORY_ECC_PARITY
,
4504 .op_flags
= XTENSA_OP_PRIVILEGED
,
4506 .name
= "rsr.mesave",
4507 .translate
= translate_rsr
,
4508 .test_exceptions
= test_exceptions_sr
,
4509 .par
= (const uint32_t[]){
4511 XTENSA_OPTION_MEMORY_ECC_PARITY
,
4513 .op_flags
= XTENSA_OP_PRIVILEGED
,
4516 .translate
= translate_rsr
,
4517 .test_exceptions
= test_exceptions_sr
,
4518 .par
= (const uint32_t[]){
4520 XTENSA_OPTION_MEMORY_ECC_PARITY
,
4522 .op_flags
= XTENSA_OP_PRIVILEGED
,
4524 .name
= "rsr.mevaddr",
4525 .translate
= translate_rsr
,
4526 .test_exceptions
= test_exceptions_sr
,
4527 .par
= (const uint32_t[]){
4529 XTENSA_OPTION_MEMORY_ECC_PARITY
,
4531 .op_flags
= XTENSA_OP_PRIVILEGED
,
4533 .name
= "rsr.misc0",
4534 .translate
= translate_rsr
,
4535 .test_exceptions
= test_exceptions_sr
,
4536 .par
= (const uint32_t[]){
4538 XTENSA_OPTION_MISC_SR
,
4540 .op_flags
= XTENSA_OP_PRIVILEGED
,
4542 .name
= "rsr.misc1",
4543 .translate
= translate_rsr
,
4544 .test_exceptions
= test_exceptions_sr
,
4545 .par
= (const uint32_t[]){
4547 XTENSA_OPTION_MISC_SR
,
4549 .op_flags
= XTENSA_OP_PRIVILEGED
,
4551 .name
= "rsr.misc2",
4552 .translate
= translate_rsr
,
4553 .test_exceptions
= test_exceptions_sr
,
4554 .par
= (const uint32_t[]){
4556 XTENSA_OPTION_MISC_SR
,
4558 .op_flags
= XTENSA_OP_PRIVILEGED
,
4560 .name
= "rsr.misc3",
4561 .translate
= translate_rsr
,
4562 .test_exceptions
= test_exceptions_sr
,
4563 .par
= (const uint32_t[]){
4565 XTENSA_OPTION_MISC_SR
,
4567 .op_flags
= XTENSA_OP_PRIVILEGED
,
4569 .name
= "rsr.mpucfg",
4570 .translate
= translate_rsr
,
4571 .test_exceptions
= test_exceptions_sr
,
4572 .par
= (const uint32_t[]){
4576 .op_flags
= XTENSA_OP_PRIVILEGED
,
4578 .name
= "rsr.mpuenb",
4579 .translate
= translate_rsr
,
4580 .test_exceptions
= test_exceptions_sr
,
4581 .par
= (const uint32_t[]){
4585 .op_flags
= XTENSA_OP_PRIVILEGED
,
4587 .name
= "rsr.prefctl",
4588 .translate
= translate_rsr
,
4589 .par
= (const uint32_t[]){PREFCTL
},
4592 .translate
= translate_rsr
,
4593 .test_exceptions
= test_exceptions_sr
,
4594 .par
= (const uint32_t[]){
4596 XTENSA_OPTION_PROCESSOR_ID
,
4598 .op_flags
= XTENSA_OP_PRIVILEGED
,
4601 .translate
= translate_rsr
,
4602 .test_exceptions
= test_exceptions_sr
,
4603 .par
= (const uint32_t[]){
4605 XTENSA_OPTION_EXCEPTION
,
4607 .op_flags
= XTENSA_OP_PRIVILEGED
,
4609 .name
= "rsr.ptevaddr",
4610 .translate
= translate_rsr_ptevaddr
,
4611 .test_exceptions
= test_exceptions_sr
,
4612 .par
= (const uint32_t[]){
4616 .op_flags
= XTENSA_OP_PRIVILEGED
,
4618 .name
= "rsr.rasid",
4619 .translate
= translate_rsr
,
4620 .test_exceptions
= test_exceptions_sr
,
4621 .par
= (const uint32_t[]){
4625 .op_flags
= XTENSA_OP_PRIVILEGED
,
4628 .translate
= translate_rsr
,
4629 .par
= (const uint32_t[]){SAR
},
4631 .name
= "rsr.scompare1",
4632 .translate
= translate_rsr
,
4633 .test_exceptions
= test_exceptions_sr
,
4634 .par
= (const uint32_t[]){
4636 XTENSA_OPTION_CONDITIONAL_STORE
,
4639 .name
= "rsr.vecbase",
4640 .translate
= translate_rsr
,
4641 .test_exceptions
= test_exceptions_sr
,
4642 .par
= (const uint32_t[]){
4644 XTENSA_OPTION_RELOCATABLE_VECTOR
,
4646 .op_flags
= XTENSA_OP_PRIVILEGED
,
4648 .name
= "rsr.windowbase",
4649 .translate
= translate_rsr
,
4650 .test_exceptions
= test_exceptions_sr
,
4651 .par
= (const uint32_t[]){
4653 XTENSA_OPTION_WINDOWED_REGISTER
,
4655 .op_flags
= XTENSA_OP_PRIVILEGED
,
4657 .name
= "rsr.windowstart",
4658 .translate
= translate_rsr
,
4659 .test_exceptions
= test_exceptions_sr
,
4660 .par
= (const uint32_t[]){
4662 XTENSA_OPTION_WINDOWED_REGISTER
,
4664 .op_flags
= XTENSA_OP_PRIVILEGED
,
4667 .translate
= translate_nop
,
4669 .name
= "rur.expstate",
4670 .translate
= translate_rur
,
4671 .par
= (const uint32_t[]){EXPSTATE
},
4673 .name
= "rur.threadptr",
4674 .translate
= translate_rur
,
4675 .par
= (const uint32_t[]){THREADPTR
},
4678 .translate
= translate_ldst
,
4679 .par
= (const uint32_t[]){MO_TEUW
, false, true},
4680 .op_flags
= XTENSA_OP_STORE
,
4683 .translate
= translate_s32c1i
,
4684 .op_flags
= XTENSA_OP_LOAD
| XTENSA_OP_STORE
,
4687 .translate
= translate_s32e
,
4688 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_STORE
,
4691 .translate
= translate_s32ex
,
4692 .op_flags
= XTENSA_OP_LOAD
| XTENSA_OP_STORE
,
4694 .name
= (const char * const[]) {
4695 "s32i", "s32i.n", "s32nb", NULL
,
4697 .translate
= translate_ldst
,
4698 .par
= (const uint32_t[]){MO_TEUL
, false, true},
4699 .op_flags
= XTENSA_OP_NAME_ARRAY
| XTENSA_OP_STORE
,
4702 .translate
= translate_ldst
,
4703 .par
= (const uint32_t[]){MO_TEUL
| MO_ALIGN
, true, true},
4704 .op_flags
= XTENSA_OP_STORE
,
4707 .translate
= translate_ldst
,
4708 .par
= (const uint32_t[]){MO_UB
, false, true},
4709 .op_flags
= XTENSA_OP_STORE
,
4712 .translate
= translate_salt
,
4713 .par
= (const uint32_t[]){TCG_COND_LT
},
4716 .translate
= translate_salt
,
4717 .par
= (const uint32_t[]){TCG_COND_LTU
},
4719 .name
= "setb_expstate",
4720 .translate
= translate_setb_expstate
,
4723 .translate
= translate_sext
,
4726 .translate
= translate_simcall
,
4727 .test_exceptions
= test_exceptions_simcall
,
4728 .op_flags
= XTENSA_OP_PRIVILEGED
,
4731 .translate
= translate_sll
,
4734 .translate
= translate_slli
,
4737 .translate
= translate_sra
,
4740 .translate
= translate_srai
,
4743 .translate
= translate_src
,
4746 .translate
= translate_srl
,
4749 .translate
= translate_srli
,
4752 .translate
= translate_ssa8b
,
4755 .translate
= translate_ssa8l
,
4758 .translate
= translate_ssai
,
4761 .translate
= translate_ssl
,
4764 .translate
= translate_ssr
,
4767 .translate
= translate_sub
,
4770 .translate
= translate_subx
,
4771 .par
= (const uint32_t[]){1},
4774 .translate
= translate_subx
,
4775 .par
= (const uint32_t[]){2},
4778 .translate
= translate_subx
,
4779 .par
= (const uint32_t[]){3},
4782 .op_flags
= XTENSA_OP_SYSCALL
,
4784 .name
= "umul.aa.hh",
4785 .translate
= translate_mac16
,
4786 .par
= (const uint32_t[]){MAC16_UMUL
, MAC16_HH
, 0},
4788 .name
= "umul.aa.hl",
4789 .translate
= translate_mac16
,
4790 .par
= (const uint32_t[]){MAC16_UMUL
, MAC16_HL
, 0},
4792 .name
= "umul.aa.lh",
4793 .translate
= translate_mac16
,
4794 .par
= (const uint32_t[]){MAC16_UMUL
, MAC16_LH
, 0},
4796 .name
= "umul.aa.ll",
4797 .translate
= translate_mac16
,
4798 .par
= (const uint32_t[]){MAC16_UMUL
, MAC16_LL
, 0},
4801 .translate
= translate_waiti
,
4802 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
4805 .translate
= translate_wtlb
,
4806 .par
= (const uint32_t[]){true},
4807 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
4810 .translate
= translate_wer
,
4811 .op_flags
= XTENSA_OP_PRIVILEGED
,
4814 .translate
= translate_wtlb
,
4815 .par
= (const uint32_t[]){false},
4816 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
4819 .translate
= translate_wptlb
,
4820 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
4822 .name
= "wrmsk_expstate",
4823 .translate
= translate_wrmsk_expstate
,
4826 .op_flags
= XTENSA_OP_ILL
,
4829 .op_flags
= XTENSA_OP_ILL
,
4831 .name
= "wsr.acchi",
4832 .translate
= translate_wsr_acchi
,
4833 .test_exceptions
= test_exceptions_sr
,
4834 .par
= (const uint32_t[]){
4836 XTENSA_OPTION_MAC16
,
4839 .name
= "wsr.acclo",
4840 .translate
= translate_wsr
,
4841 .test_exceptions
= test_exceptions_sr
,
4842 .par
= (const uint32_t[]){
4844 XTENSA_OPTION_MAC16
,
4847 .name
= "wsr.atomctl",
4848 .translate
= translate_wsr_mask
,
4849 .test_exceptions
= test_exceptions_sr
,
4850 .par
= (const uint32_t[]){
4852 XTENSA_OPTION_ATOMCTL
,
4855 .op_flags
= XTENSA_OP_PRIVILEGED
,
4858 .translate
= translate_wsr_mask
,
4859 .test_exceptions
= test_exceptions_sr
,
4860 .par
= (const uint32_t[]){
4862 XTENSA_OPTION_BOOLEAN
,
4866 .name
= "wsr.cacheadrdis",
4867 .translate
= translate_wsr_mask
,
4868 .test_exceptions
= test_exceptions_sr
,
4869 .par
= (const uint32_t[]){
4874 .op_flags
= XTENSA_OP_PRIVILEGED
,
4876 .name
= "wsr.cacheattr",
4877 .translate
= translate_wsr
,
4878 .test_exceptions
= test_exceptions_sr
,
4879 .par
= (const uint32_t[]){
4881 XTENSA_OPTION_CACHEATTR
,
4883 .op_flags
= XTENSA_OP_PRIVILEGED
,
4885 .name
= "wsr.ccompare0",
4886 .translate
= translate_wsr_ccompare
,
4887 .test_exceptions
= test_exceptions_ccompare
,
4888 .par
= (const uint32_t[]){
4890 XTENSA_OPTION_TIMER_INTERRUPT
,
4892 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
4894 .name
= "wsr.ccompare1",
4895 .translate
= translate_wsr_ccompare
,
4896 .test_exceptions
= test_exceptions_ccompare
,
4897 .par
= (const uint32_t[]){
4899 XTENSA_OPTION_TIMER_INTERRUPT
,
4901 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
4903 .name
= "wsr.ccompare2",
4904 .translate
= translate_wsr_ccompare
,
4905 .test_exceptions
= test_exceptions_ccompare
,
4906 .par
= (const uint32_t[]){
4908 XTENSA_OPTION_TIMER_INTERRUPT
,
4910 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
4912 .name
= "wsr.ccount",
4913 .translate
= translate_wsr_ccount
,
4914 .test_exceptions
= test_exceptions_sr
,
4915 .par
= (const uint32_t[]){
4917 XTENSA_OPTION_TIMER_INTERRUPT
,
4919 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
4921 .name
= "wsr.configid0",
4922 .op_flags
= XTENSA_OP_ILL
,
4924 .name
= "wsr.configid1",
4925 .op_flags
= XTENSA_OP_ILL
,
4927 .name
= "wsr.cpenable",
4928 .translate
= translate_wsr_mask
,
4929 .test_exceptions
= test_exceptions_sr
,
4930 .par
= (const uint32_t[]){
4932 XTENSA_OPTION_COPROCESSOR
,
4935 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
4937 .name
= "wsr.dbreaka0",
4938 .translate
= translate_wsr_dbreaka
,
4939 .test_exceptions
= test_exceptions_dbreak
,
4940 .par
= (const uint32_t[]){
4942 XTENSA_OPTION_DEBUG
,
4944 .op_flags
= XTENSA_OP_PRIVILEGED
,
4946 .name
= "wsr.dbreaka1",
4947 .translate
= translate_wsr_dbreaka
,
4948 .test_exceptions
= test_exceptions_dbreak
,
4949 .par
= (const uint32_t[]){
4951 XTENSA_OPTION_DEBUG
,
4953 .op_flags
= XTENSA_OP_PRIVILEGED
,
4955 .name
= "wsr.dbreakc0",
4956 .translate
= translate_wsr_dbreakc
,
4957 .test_exceptions
= test_exceptions_dbreak
,
4958 .par
= (const uint32_t[]){
4960 XTENSA_OPTION_DEBUG
,
4962 .op_flags
= XTENSA_OP_PRIVILEGED
,
4964 .name
= "wsr.dbreakc1",
4965 .translate
= translate_wsr_dbreakc
,
4966 .test_exceptions
= test_exceptions_dbreak
,
4967 .par
= (const uint32_t[]){
4969 XTENSA_OPTION_DEBUG
,
4971 .op_flags
= XTENSA_OP_PRIVILEGED
,
4974 .translate
= translate_wsr
,
4975 .test_exceptions
= test_exceptions_sr
,
4976 .par
= (const uint32_t[]){
4978 XTENSA_OPTION_DEBUG
,
4980 .op_flags
= XTENSA_OP_PRIVILEGED
,
4982 .name
= "wsr.debugcause",
4983 .op_flags
= XTENSA_OP_ILL
,
4986 .translate
= translate_wsr
,
4987 .test_exceptions
= test_exceptions_sr
,
4988 .par
= (const uint32_t[]){
4990 XTENSA_OPTION_EXCEPTION
,
4992 .op_flags
= XTENSA_OP_PRIVILEGED
,
4994 .name
= "wsr.dtlbcfg",
4995 .translate
= translate_wsr_mask
,
4996 .test_exceptions
= test_exceptions_sr
,
4997 .par
= (const uint32_t[]){
5002 .op_flags
= XTENSA_OP_PRIVILEGED
,
5005 .translate
= translate_wsr
,
5006 .test_exceptions
= test_exceptions_sr
,
5007 .par
= (const uint32_t[]){
5009 XTENSA_OPTION_EXCEPTION
,
5011 .op_flags
= XTENSA_OP_PRIVILEGED
,
5014 .translate
= translate_wsr
,
5015 .test_exceptions
= test_exceptions_hpi
,
5016 .par
= (const uint32_t[]){
5018 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5020 .op_flags
= XTENSA_OP_PRIVILEGED
,
5023 .translate
= translate_wsr
,
5024 .test_exceptions
= test_exceptions_hpi
,
5025 .par
= (const uint32_t[]){
5027 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5029 .op_flags
= XTENSA_OP_PRIVILEGED
,
5032 .translate
= translate_wsr
,
5033 .test_exceptions
= test_exceptions_hpi
,
5034 .par
= (const uint32_t[]){
5036 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5038 .op_flags
= XTENSA_OP_PRIVILEGED
,
5041 .translate
= translate_wsr
,
5042 .test_exceptions
= test_exceptions_hpi
,
5043 .par
= (const uint32_t[]){
5045 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5047 .op_flags
= XTENSA_OP_PRIVILEGED
,
5050 .translate
= translate_wsr
,
5051 .test_exceptions
= test_exceptions_hpi
,
5052 .par
= (const uint32_t[]){
5054 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5056 .op_flags
= XTENSA_OP_PRIVILEGED
,
5059 .translate
= translate_wsr
,
5060 .test_exceptions
= test_exceptions_hpi
,
5061 .par
= (const uint32_t[]){
5063 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5065 .op_flags
= XTENSA_OP_PRIVILEGED
,
5068 .translate
= translate_wsr
,
5069 .test_exceptions
= test_exceptions_hpi
,
5070 .par
= (const uint32_t[]){
5072 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5074 .op_flags
= XTENSA_OP_PRIVILEGED
,
5077 .translate
= translate_wsr
,
5078 .test_exceptions
= test_exceptions_hpi
,
5079 .par
= (const uint32_t[]){
5081 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5083 .op_flags
= XTENSA_OP_PRIVILEGED
,
5086 .translate
= translate_wsr
,
5087 .test_exceptions
= test_exceptions_hpi
,
5088 .par
= (const uint32_t[]){
5090 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5092 .op_flags
= XTENSA_OP_PRIVILEGED
,
5095 .translate
= translate_wsr
,
5096 .test_exceptions
= test_exceptions_hpi
,
5097 .par
= (const uint32_t[]){
5099 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5101 .op_flags
= XTENSA_OP_PRIVILEGED
,
5104 .translate
= translate_wsr
,
5105 .test_exceptions
= test_exceptions_hpi
,
5106 .par
= (const uint32_t[]){
5108 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5110 .op_flags
= XTENSA_OP_PRIVILEGED
,
5113 .translate
= translate_wsr
,
5114 .test_exceptions
= test_exceptions_hpi
,
5115 .par
= (const uint32_t[]){
5117 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5119 .op_flags
= XTENSA_OP_PRIVILEGED
,
5121 .name
= "wsr.eraccess",
5122 .translate
= translate_wsr_mask
,
5123 .par
= (const uint32_t[]){
5128 .op_flags
= XTENSA_OP_PRIVILEGED
,
5130 .name
= "wsr.exccause",
5131 .translate
= translate_wsr
,
5132 .test_exceptions
= test_exceptions_sr
,
5133 .par
= (const uint32_t[]){
5135 XTENSA_OPTION_EXCEPTION
,
5137 .op_flags
= XTENSA_OP_PRIVILEGED
,
5139 .name
= "wsr.excsave1",
5140 .translate
= translate_wsr
,
5141 .test_exceptions
= test_exceptions_sr
,
5142 .par
= (const uint32_t[]){
5144 XTENSA_OPTION_EXCEPTION
,
5146 .op_flags
= XTENSA_OP_PRIVILEGED
,
5148 .name
= "wsr.excsave2",
5149 .translate
= translate_wsr
,
5150 .test_exceptions
= test_exceptions_hpi
,
5151 .par
= (const uint32_t[]){
5153 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5155 .op_flags
= XTENSA_OP_PRIVILEGED
,
5157 .name
= "wsr.excsave3",
5158 .translate
= translate_wsr
,
5159 .test_exceptions
= test_exceptions_hpi
,
5160 .par
= (const uint32_t[]){
5162 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5164 .op_flags
= XTENSA_OP_PRIVILEGED
,
5166 .name
= "wsr.excsave4",
5167 .translate
= translate_wsr
,
5168 .test_exceptions
= test_exceptions_hpi
,
5169 .par
= (const uint32_t[]){
5171 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5173 .op_flags
= XTENSA_OP_PRIVILEGED
,
5175 .name
= "wsr.excsave5",
5176 .translate
= translate_wsr
,
5177 .test_exceptions
= test_exceptions_hpi
,
5178 .par
= (const uint32_t[]){
5180 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5182 .op_flags
= XTENSA_OP_PRIVILEGED
,
5184 .name
= "wsr.excsave6",
5185 .translate
= translate_wsr
,
5186 .test_exceptions
= test_exceptions_hpi
,
5187 .par
= (const uint32_t[]){
5189 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5191 .op_flags
= XTENSA_OP_PRIVILEGED
,
5193 .name
= "wsr.excsave7",
5194 .translate
= translate_wsr
,
5195 .test_exceptions
= test_exceptions_hpi
,
5196 .par
= (const uint32_t[]){
5198 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5200 .op_flags
= XTENSA_OP_PRIVILEGED
,
5202 .name
= "wsr.excvaddr",
5203 .translate
= translate_wsr
,
5204 .test_exceptions
= test_exceptions_sr
,
5205 .par
= (const uint32_t[]){
5207 XTENSA_OPTION_EXCEPTION
,
5209 .op_flags
= XTENSA_OP_PRIVILEGED
,
5211 .name
= "wsr.ibreaka0",
5212 .translate
= translate_wsr_ibreaka
,
5213 .test_exceptions
= test_exceptions_ibreak
,
5214 .par
= (const uint32_t[]){
5216 XTENSA_OPTION_DEBUG
,
5218 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
5220 .name
= "wsr.ibreaka1",
5221 .translate
= translate_wsr_ibreaka
,
5222 .test_exceptions
= test_exceptions_ibreak
,
5223 .par
= (const uint32_t[]){
5225 XTENSA_OPTION_DEBUG
,
5227 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
5229 .name
= "wsr.ibreakenable",
5230 .translate
= translate_wsr_ibreakenable
,
5231 .test_exceptions
= test_exceptions_sr
,
5232 .par
= (const uint32_t[]){
5234 XTENSA_OPTION_DEBUG
,
5236 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
5238 .name
= "wsr.icount",
5239 .translate
= translate_wsr_icount
,
5240 .test_exceptions
= test_exceptions_sr
,
5241 .par
= (const uint32_t[]){
5243 XTENSA_OPTION_DEBUG
,
5245 .op_flags
= XTENSA_OP_PRIVILEGED
,
5247 .name
= "wsr.icountlevel",
5248 .translate
= translate_wsr_mask
,
5249 .test_exceptions
= test_exceptions_sr
,
5250 .par
= (const uint32_t[]){
5252 XTENSA_OPTION_DEBUG
,
5255 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
5257 .name
= "wsr.intclear",
5258 .translate
= translate_wsr_intclear
,
5259 .test_exceptions
= test_exceptions_sr
,
5260 .par
= (const uint32_t[]){
5262 XTENSA_OPTION_INTERRUPT
,
5265 XTENSA_OP_PRIVILEGED
|
5266 XTENSA_OP_EXIT_TB_0
|
5267 XTENSA_OP_CHECK_INTERRUPTS
,
5269 .name
= "wsr.intenable",
5270 .translate
= translate_wsr
,
5271 .test_exceptions
= test_exceptions_sr
,
5272 .par
= (const uint32_t[]){
5274 XTENSA_OPTION_INTERRUPT
,
5277 XTENSA_OP_PRIVILEGED
|
5278 XTENSA_OP_EXIT_TB_0
|
5279 XTENSA_OP_CHECK_INTERRUPTS
,
5281 .name
= "wsr.interrupt",
5282 .translate
= translate_wsr
,
5283 .test_exceptions
= test_exceptions_sr
,
5284 .par
= (const uint32_t[]){
5286 XTENSA_OPTION_INTERRUPT
,
5289 XTENSA_OP_PRIVILEGED
|
5290 XTENSA_OP_EXIT_TB_0
|
5291 XTENSA_OP_CHECK_INTERRUPTS
,
5293 .name
= "wsr.intset",
5294 .translate
= translate_wsr_intset
,
5295 .test_exceptions
= test_exceptions_sr
,
5296 .par
= (const uint32_t[]){
5298 XTENSA_OPTION_INTERRUPT
,
5301 XTENSA_OP_PRIVILEGED
|
5302 XTENSA_OP_EXIT_TB_0
|
5303 XTENSA_OP_CHECK_INTERRUPTS
,
5305 .name
= "wsr.itlbcfg",
5306 .translate
= translate_wsr_mask
,
5307 .test_exceptions
= test_exceptions_sr
,
5308 .par
= (const uint32_t[]){
5313 .op_flags
= XTENSA_OP_PRIVILEGED
,
5316 .translate
= translate_wsr
,
5317 .test_exceptions
= test_exceptions_sr
,
5318 .par
= (const uint32_t[]){
5322 .op_flags
= XTENSA_OP_EXIT_TB_M1
,
5324 .name
= "wsr.lcount",
5325 .translate
= translate_wsr
,
5326 .test_exceptions
= test_exceptions_sr
,
5327 .par
= (const uint32_t[]){
5333 .translate
= translate_wsr
,
5334 .test_exceptions
= test_exceptions_sr
,
5335 .par
= (const uint32_t[]){
5339 .op_flags
= XTENSA_OP_EXIT_TB_M1
,
5341 .name
= "wsr.litbase",
5342 .translate
= translate_wsr_mask
,
5343 .test_exceptions
= test_exceptions_sr
,
5344 .par
= (const uint32_t[]){
5346 XTENSA_OPTION_EXTENDED_L32R
,
5349 .op_flags
= XTENSA_OP_EXIT_TB_M1
,
5352 .translate
= translate_wsr
,
5353 .test_exceptions
= test_exceptions_sr
,
5354 .par
= (const uint32_t[]){
5356 XTENSA_OPTION_MAC16
,
5360 .translate
= translate_wsr
,
5361 .test_exceptions
= test_exceptions_sr
,
5362 .par
= (const uint32_t[]){
5364 XTENSA_OPTION_MAC16
,
5368 .translate
= translate_wsr
,
5369 .test_exceptions
= test_exceptions_sr
,
5370 .par
= (const uint32_t[]){
5372 XTENSA_OPTION_MAC16
,
5376 .translate
= translate_wsr
,
5377 .test_exceptions
= test_exceptions_sr
,
5378 .par
= (const uint32_t[]){
5380 XTENSA_OPTION_MAC16
,
5383 .name
= "wsr.memctl",
5384 .translate
= translate_wsr_memctl
,
5385 .par
= (const uint32_t[]){MEMCTL
},
5386 .op_flags
= XTENSA_OP_PRIVILEGED
,
5389 .translate
= translate_wsr
,
5390 .test_exceptions
= test_exceptions_sr
,
5391 .par
= (const uint32_t[]){
5393 XTENSA_OPTION_MEMORY_ECC_PARITY
,
5395 .op_flags
= XTENSA_OP_PRIVILEGED
,
5398 .translate
= translate_wsr
,
5399 .test_exceptions
= test_exceptions_sr
,
5400 .par
= (const uint32_t[]){
5402 XTENSA_OPTION_MEMORY_ECC_PARITY
,
5404 .op_flags
= XTENSA_OP_PRIVILEGED
,
5407 .translate
= translate_wsr
,
5408 .test_exceptions
= test_exceptions_sr
,
5409 .par
= (const uint32_t[]){
5411 XTENSA_OPTION_MEMORY_ECC_PARITY
,
5413 .op_flags
= XTENSA_OP_PRIVILEGED
,
5415 .name
= "wsr.mesave",
5416 .translate
= translate_wsr
,
5417 .test_exceptions
= test_exceptions_sr
,
5418 .par
= (const uint32_t[]){
5420 XTENSA_OPTION_MEMORY_ECC_PARITY
,
5422 .op_flags
= XTENSA_OP_PRIVILEGED
,
5425 .translate
= translate_wsr
,
5426 .test_exceptions
= test_exceptions_sr
,
5427 .par
= (const uint32_t[]){
5429 XTENSA_OPTION_MEMORY_ECC_PARITY
,
5431 .op_flags
= XTENSA_OP_PRIVILEGED
,
5433 .name
= "wsr.mevaddr",
5434 .translate
= translate_wsr
,
5435 .test_exceptions
= test_exceptions_sr
,
5436 .par
= (const uint32_t[]){
5438 XTENSA_OPTION_MEMORY_ECC_PARITY
,
5440 .op_flags
= XTENSA_OP_PRIVILEGED
,
5442 .name
= "wsr.misc0",
5443 .translate
= translate_wsr
,
5444 .test_exceptions
= test_exceptions_sr
,
5445 .par
= (const uint32_t[]){
5447 XTENSA_OPTION_MISC_SR
,
5449 .op_flags
= XTENSA_OP_PRIVILEGED
,
5451 .name
= "wsr.misc1",
5452 .translate
= translate_wsr
,
5453 .test_exceptions
= test_exceptions_sr
,
5454 .par
= (const uint32_t[]){
5456 XTENSA_OPTION_MISC_SR
,
5458 .op_flags
= XTENSA_OP_PRIVILEGED
,
5460 .name
= "wsr.misc2",
5461 .translate
= translate_wsr
,
5462 .test_exceptions
= test_exceptions_sr
,
5463 .par
= (const uint32_t[]){
5465 XTENSA_OPTION_MISC_SR
,
5467 .op_flags
= XTENSA_OP_PRIVILEGED
,
5469 .name
= "wsr.misc3",
5470 .translate
= translate_wsr
,
5471 .test_exceptions
= test_exceptions_sr
,
5472 .par
= (const uint32_t[]){
5474 XTENSA_OPTION_MISC_SR
,
5476 .op_flags
= XTENSA_OP_PRIVILEGED
,
5479 .translate
= translate_wsr
,
5480 .test_exceptions
= test_exceptions_sr
,
5481 .par
= (const uint32_t[]){
5483 XTENSA_OPTION_TRACE_PORT
,
5485 .op_flags
= XTENSA_OP_PRIVILEGED
,
5487 .name
= "wsr.mpuenb",
5488 .translate
= translate_wsr_mpuenb
,
5489 .test_exceptions
= test_exceptions_sr
,
5490 .par
= (const uint32_t[]){
5494 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
5496 .name
= "wsr.prefctl",
5497 .translate
= translate_wsr
,
5498 .par
= (const uint32_t[]){PREFCTL
},
5501 .op_flags
= XTENSA_OP_ILL
,
5504 .translate
= translate_wsr_ps
,
5505 .test_exceptions
= test_exceptions_sr
,
5506 .par
= (const uint32_t[]){
5508 XTENSA_OPTION_EXCEPTION
,
5511 XTENSA_OP_PRIVILEGED
|
5512 XTENSA_OP_EXIT_TB_M1
|
5513 XTENSA_OP_CHECK_INTERRUPTS
,
5515 .name
= "wsr.ptevaddr",
5516 .translate
= translate_wsr_mask
,
5517 .test_exceptions
= test_exceptions_sr
,
5518 .par
= (const uint32_t[]){
5523 .op_flags
= XTENSA_OP_PRIVILEGED
,
5525 .name
= "wsr.rasid",
5526 .translate
= translate_wsr_rasid
,
5527 .test_exceptions
= test_exceptions_sr
,
5528 .par
= (const uint32_t[]){
5532 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
5535 .translate
= translate_wsr_sar
,
5536 .par
= (const uint32_t[]){SAR
},
5538 .name
= "wsr.scompare1",
5539 .translate
= translate_wsr
,
5540 .test_exceptions
= test_exceptions_sr
,
5541 .par
= (const uint32_t[]){
5543 XTENSA_OPTION_CONDITIONAL_STORE
,
5546 .name
= "wsr.vecbase",
5547 .translate
= translate_wsr
,
5548 .test_exceptions
= test_exceptions_sr
,
5549 .par
= (const uint32_t[]){
5551 XTENSA_OPTION_RELOCATABLE_VECTOR
,
5553 .op_flags
= XTENSA_OP_PRIVILEGED
,
5555 .name
= "wsr.windowbase",
5556 .translate
= translate_wsr_windowbase
,
5557 .test_exceptions
= test_exceptions_sr
,
5558 .par
= (const uint32_t[]){
5560 XTENSA_OPTION_WINDOWED_REGISTER
,
5562 .op_flags
= XTENSA_OP_PRIVILEGED
|
5563 XTENSA_OP_EXIT_TB_M1
|
5564 XTENSA_OP_SYNC_REGISTER_WINDOW
,
5566 .name
= "wsr.windowstart",
5567 .translate
= translate_wsr_windowstart
,
5568 .test_exceptions
= test_exceptions_sr
,
5569 .par
= (const uint32_t[]){
5571 XTENSA_OPTION_WINDOWED_REGISTER
,
5573 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
5575 .name
= "wur.expstate",
5576 .translate
= translate_wur
,
5577 .par
= (const uint32_t[]){EXPSTATE
},
5579 .name
= "wur.threadptr",
5580 .translate
= translate_wur
,
5581 .par
= (const uint32_t[]){THREADPTR
},
5584 .translate
= translate_xor
,
5587 .translate
= translate_boolean
,
5588 .par
= (const uint32_t[]){BOOLEAN_XOR
},
5591 .op_flags
= XTENSA_OP_ILL
,
5594 .op_flags
= XTENSA_OP_ILL
,
5596 .name
= "xsr.acchi",
5597 .translate
= translate_xsr_acchi
,
5598 .test_exceptions
= test_exceptions_sr
,
5599 .par
= (const uint32_t[]){
5601 XTENSA_OPTION_MAC16
,
5604 .name
= "xsr.acclo",
5605 .translate
= translate_xsr
,
5606 .test_exceptions
= test_exceptions_sr
,
5607 .par
= (const uint32_t[]){
5609 XTENSA_OPTION_MAC16
,
5612 .name
= "xsr.atomctl",
5613 .translate
= translate_xsr_mask
,
5614 .test_exceptions
= test_exceptions_sr
,
5615 .par
= (const uint32_t[]){
5617 XTENSA_OPTION_ATOMCTL
,
5620 .op_flags
= XTENSA_OP_PRIVILEGED
,
5623 .translate
= translate_xsr_mask
,
5624 .test_exceptions
= test_exceptions_sr
,
5625 .par
= (const uint32_t[]){
5627 XTENSA_OPTION_BOOLEAN
,
5631 .name
= "xsr.cacheadrdis",
5632 .translate
= translate_xsr_mask
,
5633 .test_exceptions
= test_exceptions_sr
,
5634 .par
= (const uint32_t[]){
5639 .op_flags
= XTENSA_OP_PRIVILEGED
,
5641 .name
= "xsr.cacheattr",
5642 .translate
= translate_xsr
,
5643 .test_exceptions
= test_exceptions_sr
,
5644 .par
= (const uint32_t[]){
5646 XTENSA_OPTION_CACHEATTR
,
5648 .op_flags
= XTENSA_OP_PRIVILEGED
,
5650 .name
= "xsr.ccompare0",
5651 .translate
= translate_xsr_ccompare
,
5652 .test_exceptions
= test_exceptions_ccompare
,
5653 .par
= (const uint32_t[]){
5655 XTENSA_OPTION_TIMER_INTERRUPT
,
5657 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
5659 .name
= "xsr.ccompare1",
5660 .translate
= translate_xsr_ccompare
,
5661 .test_exceptions
= test_exceptions_ccompare
,
5662 .par
= (const uint32_t[]){
5664 XTENSA_OPTION_TIMER_INTERRUPT
,
5666 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
5668 .name
= "xsr.ccompare2",
5669 .translate
= translate_xsr_ccompare
,
5670 .test_exceptions
= test_exceptions_ccompare
,
5671 .par
= (const uint32_t[]){
5673 XTENSA_OPTION_TIMER_INTERRUPT
,
5675 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
5677 .name
= "xsr.ccount",
5678 .translate
= translate_xsr_ccount
,
5679 .test_exceptions
= test_exceptions_sr
,
5680 .par
= (const uint32_t[]){
5682 XTENSA_OPTION_TIMER_INTERRUPT
,
5684 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
5686 .name
= "xsr.configid0",
5687 .op_flags
= XTENSA_OP_ILL
,
5689 .name
= "xsr.configid1",
5690 .op_flags
= XTENSA_OP_ILL
,
5692 .name
= "xsr.cpenable",
5693 .translate
= translate_xsr_mask
,
5694 .test_exceptions
= test_exceptions_sr
,
5695 .par
= (const uint32_t[]){
5697 XTENSA_OPTION_COPROCESSOR
,
5700 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
5702 .name
= "xsr.dbreaka0",
5703 .translate
= translate_xsr_dbreaka
,
5704 .test_exceptions
= test_exceptions_dbreak
,
5705 .par
= (const uint32_t[]){
5707 XTENSA_OPTION_DEBUG
,
5709 .op_flags
= XTENSA_OP_PRIVILEGED
,
5711 .name
= "xsr.dbreaka1",
5712 .translate
= translate_xsr_dbreaka
,
5713 .test_exceptions
= test_exceptions_dbreak
,
5714 .par
= (const uint32_t[]){
5716 XTENSA_OPTION_DEBUG
,
5718 .op_flags
= XTENSA_OP_PRIVILEGED
,
5720 .name
= "xsr.dbreakc0",
5721 .translate
= translate_xsr_dbreakc
,
5722 .test_exceptions
= test_exceptions_dbreak
,
5723 .par
= (const uint32_t[]){
5725 XTENSA_OPTION_DEBUG
,
5727 .op_flags
= XTENSA_OP_PRIVILEGED
,
5729 .name
= "xsr.dbreakc1",
5730 .translate
= translate_xsr_dbreakc
,
5731 .test_exceptions
= test_exceptions_dbreak
,
5732 .par
= (const uint32_t[]){
5734 XTENSA_OPTION_DEBUG
,
5736 .op_flags
= XTENSA_OP_PRIVILEGED
,
5739 .translate
= translate_xsr
,
5740 .test_exceptions
= test_exceptions_sr
,
5741 .par
= (const uint32_t[]){
5743 XTENSA_OPTION_DEBUG
,
5745 .op_flags
= XTENSA_OP_PRIVILEGED
,
5747 .name
= "xsr.debugcause",
5748 .op_flags
= XTENSA_OP_ILL
,
5751 .translate
= translate_xsr
,
5752 .test_exceptions
= test_exceptions_sr
,
5753 .par
= (const uint32_t[]){
5755 XTENSA_OPTION_EXCEPTION
,
5757 .op_flags
= XTENSA_OP_PRIVILEGED
,
5759 .name
= "xsr.dtlbcfg",
5760 .translate
= translate_xsr_mask
,
5761 .test_exceptions
= test_exceptions_sr
,
5762 .par
= (const uint32_t[]){
5767 .op_flags
= XTENSA_OP_PRIVILEGED
,
5770 .translate
= translate_xsr
,
5771 .test_exceptions
= test_exceptions_sr
,
5772 .par
= (const uint32_t[]){
5774 XTENSA_OPTION_EXCEPTION
,
5776 .op_flags
= XTENSA_OP_PRIVILEGED
,
5779 .translate
= translate_xsr
,
5780 .test_exceptions
= test_exceptions_hpi
,
5781 .par
= (const uint32_t[]){
5783 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5785 .op_flags
= XTENSA_OP_PRIVILEGED
,
5788 .translate
= translate_xsr
,
5789 .test_exceptions
= test_exceptions_hpi
,
5790 .par
= (const uint32_t[]){
5792 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5794 .op_flags
= XTENSA_OP_PRIVILEGED
,
5797 .translate
= translate_xsr
,
5798 .test_exceptions
= test_exceptions_hpi
,
5799 .par
= (const uint32_t[]){
5801 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5803 .op_flags
= XTENSA_OP_PRIVILEGED
,
5806 .translate
= translate_xsr
,
5807 .test_exceptions
= test_exceptions_hpi
,
5808 .par
= (const uint32_t[]){
5810 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5812 .op_flags
= XTENSA_OP_PRIVILEGED
,
5815 .translate
= translate_xsr
,
5816 .test_exceptions
= test_exceptions_hpi
,
5817 .par
= (const uint32_t[]){
5819 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5821 .op_flags
= XTENSA_OP_PRIVILEGED
,
5824 .translate
= translate_xsr
,
5825 .test_exceptions
= test_exceptions_hpi
,
5826 .par
= (const uint32_t[]){
5828 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5830 .op_flags
= XTENSA_OP_PRIVILEGED
,
5833 .translate
= translate_xsr
,
5834 .test_exceptions
= test_exceptions_hpi
,
5835 .par
= (const uint32_t[]){
5837 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5839 .op_flags
= XTENSA_OP_PRIVILEGED
,
5842 .translate
= translate_xsr
,
5843 .test_exceptions
= test_exceptions_hpi
,
5844 .par
= (const uint32_t[]){
5846 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5848 .op_flags
= XTENSA_OP_PRIVILEGED
,
5851 .translate
= translate_xsr
,
5852 .test_exceptions
= test_exceptions_hpi
,
5853 .par
= (const uint32_t[]){
5855 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5857 .op_flags
= XTENSA_OP_PRIVILEGED
,
5860 .translate
= translate_xsr
,
5861 .test_exceptions
= test_exceptions_hpi
,
5862 .par
= (const uint32_t[]){
5864 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5866 .op_flags
= XTENSA_OP_PRIVILEGED
,
5869 .translate
= translate_xsr
,
5870 .test_exceptions
= test_exceptions_hpi
,
5871 .par
= (const uint32_t[]){
5873 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5875 .op_flags
= XTENSA_OP_PRIVILEGED
,
5878 .translate
= translate_xsr
,
5879 .test_exceptions
= test_exceptions_hpi
,
5880 .par
= (const uint32_t[]){
5882 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5884 .op_flags
= XTENSA_OP_PRIVILEGED
,
5886 .name
= "xsr.eraccess",
5887 .translate
= translate_xsr_mask
,
5888 .par
= (const uint32_t[]){
5893 .op_flags
= XTENSA_OP_PRIVILEGED
,
5895 .name
= "xsr.exccause",
5896 .translate
= translate_xsr
,
5897 .test_exceptions
= test_exceptions_sr
,
5898 .par
= (const uint32_t[]){
5900 XTENSA_OPTION_EXCEPTION
,
5902 .op_flags
= XTENSA_OP_PRIVILEGED
,
5904 .name
= "xsr.excsave1",
5905 .translate
= translate_xsr
,
5906 .test_exceptions
= test_exceptions_sr
,
5907 .par
= (const uint32_t[]){
5909 XTENSA_OPTION_EXCEPTION
,
5911 .op_flags
= XTENSA_OP_PRIVILEGED
,
5913 .name
= "xsr.excsave2",
5914 .translate
= translate_xsr
,
5915 .test_exceptions
= test_exceptions_hpi
,
5916 .par
= (const uint32_t[]){
5918 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5920 .op_flags
= XTENSA_OP_PRIVILEGED
,
5922 .name
= "xsr.excsave3",
5923 .translate
= translate_xsr
,
5924 .test_exceptions
= test_exceptions_hpi
,
5925 .par
= (const uint32_t[]){
5927 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5929 .op_flags
= XTENSA_OP_PRIVILEGED
,
5931 .name
= "xsr.excsave4",
5932 .translate
= translate_xsr
,
5933 .test_exceptions
= test_exceptions_hpi
,
5934 .par
= (const uint32_t[]){
5936 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5938 .op_flags
= XTENSA_OP_PRIVILEGED
,
5940 .name
= "xsr.excsave5",
5941 .translate
= translate_xsr
,
5942 .test_exceptions
= test_exceptions_hpi
,
5943 .par
= (const uint32_t[]){
5945 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5947 .op_flags
= XTENSA_OP_PRIVILEGED
,
5949 .name
= "xsr.excsave6",
5950 .translate
= translate_xsr
,
5951 .test_exceptions
= test_exceptions_hpi
,
5952 .par
= (const uint32_t[]){
5954 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5956 .op_flags
= XTENSA_OP_PRIVILEGED
,
5958 .name
= "xsr.excsave7",
5959 .translate
= translate_xsr
,
5960 .test_exceptions
= test_exceptions_hpi
,
5961 .par
= (const uint32_t[]){
5963 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT
,
5965 .op_flags
= XTENSA_OP_PRIVILEGED
,
5967 .name
= "xsr.excvaddr",
5968 .translate
= translate_xsr
,
5969 .test_exceptions
= test_exceptions_sr
,
5970 .par
= (const uint32_t[]){
5972 XTENSA_OPTION_EXCEPTION
,
5974 .op_flags
= XTENSA_OP_PRIVILEGED
,
5976 .name
= "xsr.ibreaka0",
5977 .translate
= translate_xsr_ibreaka
,
5978 .test_exceptions
= test_exceptions_ibreak
,
5979 .par
= (const uint32_t[]){
5981 XTENSA_OPTION_DEBUG
,
5983 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
5985 .name
= "xsr.ibreaka1",
5986 .translate
= translate_xsr_ibreaka
,
5987 .test_exceptions
= test_exceptions_ibreak
,
5988 .par
= (const uint32_t[]){
5990 XTENSA_OPTION_DEBUG
,
5992 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
5994 .name
= "xsr.ibreakenable",
5995 .translate
= translate_xsr_ibreakenable
,
5996 .test_exceptions
= test_exceptions_sr
,
5997 .par
= (const uint32_t[]){
5999 XTENSA_OPTION_DEBUG
,
6001 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_0
,
6003 .name
= "xsr.icount",
6004 .translate
= translate_xsr_icount
,
6005 .test_exceptions
= test_exceptions_sr
,
6006 .par
= (const uint32_t[]){
6008 XTENSA_OPTION_DEBUG
,
6010 .op_flags
= XTENSA_OP_PRIVILEGED
,
6012 .name
= "xsr.icountlevel",
6013 .translate
= translate_xsr_mask
,
6014 .test_exceptions
= test_exceptions_sr
,
6015 .par
= (const uint32_t[]){
6017 XTENSA_OPTION_DEBUG
,
6020 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
6022 .name
= "xsr.intclear",
6023 .op_flags
= XTENSA_OP_ILL
,
6025 .name
= "xsr.intenable",
6026 .translate
= translate_xsr
,
6027 .test_exceptions
= test_exceptions_sr
,
6028 .par
= (const uint32_t[]){
6030 XTENSA_OPTION_INTERRUPT
,
6033 XTENSA_OP_PRIVILEGED
|
6034 XTENSA_OP_EXIT_TB_0
|
6035 XTENSA_OP_CHECK_INTERRUPTS
,
6037 .name
= "xsr.interrupt",
6038 .op_flags
= XTENSA_OP_ILL
,
6040 .name
= "xsr.intset",
6041 .op_flags
= XTENSA_OP_ILL
,
6043 .name
= "xsr.itlbcfg",
6044 .translate
= translate_xsr_mask
,
6045 .test_exceptions
= test_exceptions_sr
,
6046 .par
= (const uint32_t[]){
6051 .op_flags
= XTENSA_OP_PRIVILEGED
,
6054 .translate
= translate_xsr
,
6055 .test_exceptions
= test_exceptions_sr
,
6056 .par
= (const uint32_t[]){
6060 .op_flags
= XTENSA_OP_EXIT_TB_M1
,
6062 .name
= "xsr.lcount",
6063 .translate
= translate_xsr
,
6064 .test_exceptions
= test_exceptions_sr
,
6065 .par
= (const uint32_t[]){
6071 .translate
= translate_xsr
,
6072 .test_exceptions
= test_exceptions_sr
,
6073 .par
= (const uint32_t[]){
6077 .op_flags
= XTENSA_OP_EXIT_TB_M1
,
6079 .name
= "xsr.litbase",
6080 .translate
= translate_xsr_mask
,
6081 .test_exceptions
= test_exceptions_sr
,
6082 .par
= (const uint32_t[]){
6084 XTENSA_OPTION_EXTENDED_L32R
,
6087 .op_flags
= XTENSA_OP_EXIT_TB_M1
,
6090 .translate
= translate_xsr
,
6091 .test_exceptions
= test_exceptions_sr
,
6092 .par
= (const uint32_t[]){
6094 XTENSA_OPTION_MAC16
,
6098 .translate
= translate_xsr
,
6099 .test_exceptions
= test_exceptions_sr
,
6100 .par
= (const uint32_t[]){
6102 XTENSA_OPTION_MAC16
,
6106 .translate
= translate_xsr
,
6107 .test_exceptions
= test_exceptions_sr
,
6108 .par
= (const uint32_t[]){
6110 XTENSA_OPTION_MAC16
,
6114 .translate
= translate_xsr
,
6115 .test_exceptions
= test_exceptions_sr
,
6116 .par
= (const uint32_t[]){
6118 XTENSA_OPTION_MAC16
,
6121 .name
= "xsr.memctl",
6122 .translate
= translate_xsr_memctl
,
6123 .par
= (const uint32_t[]){MEMCTL
},
6124 .op_flags
= XTENSA_OP_PRIVILEGED
,
6127 .translate
= translate_xsr
,
6128 .test_exceptions
= test_exceptions_sr
,
6129 .par
= (const uint32_t[]){
6131 XTENSA_OPTION_MEMORY_ECC_PARITY
,
6133 .op_flags
= XTENSA_OP_PRIVILEGED
,
6136 .translate
= translate_xsr
,
6137 .test_exceptions
= test_exceptions_sr
,
6138 .par
= (const uint32_t[]){
6140 XTENSA_OPTION_MEMORY_ECC_PARITY
,
6142 .op_flags
= XTENSA_OP_PRIVILEGED
,
6145 .translate
= translate_xsr
,
6146 .test_exceptions
= test_exceptions_sr
,
6147 .par
= (const uint32_t[]){
6149 XTENSA_OPTION_MEMORY_ECC_PARITY
,
6151 .op_flags
= XTENSA_OP_PRIVILEGED
,
6153 .name
= "xsr.mesave",
6154 .translate
= translate_xsr
,
6155 .test_exceptions
= test_exceptions_sr
,
6156 .par
= (const uint32_t[]){
6158 XTENSA_OPTION_MEMORY_ECC_PARITY
,
6160 .op_flags
= XTENSA_OP_PRIVILEGED
,
6163 .translate
= translate_xsr
,
6164 .test_exceptions
= test_exceptions_sr
,
6165 .par
= (const uint32_t[]){
6167 XTENSA_OPTION_MEMORY_ECC_PARITY
,
6169 .op_flags
= XTENSA_OP_PRIVILEGED
,
6171 .name
= "xsr.mevaddr",
6172 .translate
= translate_xsr
,
6173 .test_exceptions
= test_exceptions_sr
,
6174 .par
= (const uint32_t[]){
6176 XTENSA_OPTION_MEMORY_ECC_PARITY
,
6178 .op_flags
= XTENSA_OP_PRIVILEGED
,
6180 .name
= "xsr.misc0",
6181 .translate
= translate_xsr
,
6182 .test_exceptions
= test_exceptions_sr
,
6183 .par
= (const uint32_t[]){
6185 XTENSA_OPTION_MISC_SR
,
6187 .op_flags
= XTENSA_OP_PRIVILEGED
,
6189 .name
= "xsr.misc1",
6190 .translate
= translate_xsr
,
6191 .test_exceptions
= test_exceptions_sr
,
6192 .par
= (const uint32_t[]){
6194 XTENSA_OPTION_MISC_SR
,
6196 .op_flags
= XTENSA_OP_PRIVILEGED
,
6198 .name
= "xsr.misc2",
6199 .translate
= translate_xsr
,
6200 .test_exceptions
= test_exceptions_sr
,
6201 .par
= (const uint32_t[]){
6203 XTENSA_OPTION_MISC_SR
,
6205 .op_flags
= XTENSA_OP_PRIVILEGED
,
6207 .name
= "xsr.misc3",
6208 .translate
= translate_xsr
,
6209 .test_exceptions
= test_exceptions_sr
,
6210 .par
= (const uint32_t[]){
6212 XTENSA_OPTION_MISC_SR
,
6214 .op_flags
= XTENSA_OP_PRIVILEGED
,
6216 .name
= "xsr.mpuenb",
6217 .translate
= translate_xsr_mpuenb
,
6218 .test_exceptions
= test_exceptions_sr
,
6219 .par
= (const uint32_t[]){
6223 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
6225 .name
= "xsr.prefctl",
6226 .translate
= translate_xsr
,
6227 .par
= (const uint32_t[]){PREFCTL
},
6230 .op_flags
= XTENSA_OP_ILL
,
6233 .translate
= translate_xsr_ps
,
6234 .test_exceptions
= test_exceptions_sr
,
6235 .par
= (const uint32_t[]){
6237 XTENSA_OPTION_EXCEPTION
,
6240 XTENSA_OP_PRIVILEGED
|
6241 XTENSA_OP_EXIT_TB_M1
|
6242 XTENSA_OP_CHECK_INTERRUPTS
,
6244 .name
= "xsr.ptevaddr",
6245 .translate
= translate_xsr_mask
,
6246 .test_exceptions
= test_exceptions_sr
,
6247 .par
= (const uint32_t[]){
6252 .op_flags
= XTENSA_OP_PRIVILEGED
,
6254 .name
= "xsr.rasid",
6255 .translate
= translate_xsr_rasid
,
6256 .test_exceptions
= test_exceptions_sr
,
6257 .par
= (const uint32_t[]){
6261 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
6264 .translate
= translate_xsr_sar
,
6265 .par
= (const uint32_t[]){SAR
},
6267 .name
= "xsr.scompare1",
6268 .translate
= translate_xsr
,
6269 .test_exceptions
= test_exceptions_sr
,
6270 .par
= (const uint32_t[]){
6272 XTENSA_OPTION_CONDITIONAL_STORE
,
6275 .name
= "xsr.vecbase",
6276 .translate
= translate_xsr
,
6277 .test_exceptions
= test_exceptions_sr
,
6278 .par
= (const uint32_t[]){
6280 XTENSA_OPTION_RELOCATABLE_VECTOR
,
6282 .op_flags
= XTENSA_OP_PRIVILEGED
,
6284 .name
= "xsr.windowbase",
6285 .translate
= translate_xsr_windowbase
,
6286 .test_exceptions
= test_exceptions_sr
,
6287 .par
= (const uint32_t[]){
6289 XTENSA_OPTION_WINDOWED_REGISTER
,
6291 .op_flags
= XTENSA_OP_PRIVILEGED
|
6292 XTENSA_OP_EXIT_TB_M1
|
6293 XTENSA_OP_SYNC_REGISTER_WINDOW
,
6295 .name
= "xsr.windowstart",
6296 .translate
= translate_xsr_windowstart
,
6297 .test_exceptions
= test_exceptions_sr
,
6298 .par
= (const uint32_t[]){
6300 XTENSA_OPTION_WINDOWED_REGISTER
,
6302 .op_flags
= XTENSA_OP_PRIVILEGED
| XTENSA_OP_EXIT_TB_M1
,
6306 const XtensaOpcodeTranslators xtensa_core_opcodes
= {
6307 .num_opcodes
= ARRAY_SIZE(core_ops
),
6312 static inline void get_f32_o1_i3(const OpcodeArg
*arg
, OpcodeArg
*arg32
,
6313 int o0
, int i0
, int i1
, int i2
)
6315 if ((i0
>= 0 && arg
[i0
].num_bits
== 64) ||
6316 (o0
>= 0 && arg
[o0
].num_bits
== 64)) {
6318 arg32
[o0
].out
= tcg_temp_new_i32();
6321 arg32
[i0
].in
= tcg_temp_new_i32();
6322 tcg_gen_extrl_i64_i32(arg32
[i0
].in
, arg
[i0
].in
);
6325 arg32
[i1
].in
= tcg_temp_new_i32();
6326 tcg_gen_extrl_i64_i32(arg32
[i1
].in
, arg
[i1
].in
);
6329 arg32
[i2
].in
= tcg_temp_new_i32();
6330 tcg_gen_extrl_i64_i32(arg32
[i2
].in
, arg
[i2
].in
);
6334 arg32
[o0
].out
= arg
[o0
].out
;
6337 arg32
[i0
].in
= arg
[i0
].in
;
6340 arg32
[i1
].in
= arg
[i1
].in
;
6343 arg32
[i2
].in
= arg
[i2
].in
;
6348 static inline void put_f32_o1_i3(const OpcodeArg
*arg
, const OpcodeArg
*arg32
,
6349 int o0
, int i0
, int i1
, int i2
)
6351 if ((i0
>= 0 && arg
[i0
].num_bits
== 64) ||
6352 (o0
>= 0 && arg
[o0
].num_bits
== 64)) {
6354 tcg_gen_extu_i32_i64(arg
[o0
].out
, arg32
[o0
].out
);
6355 tcg_temp_free_i32(arg32
[o0
].out
);
6358 tcg_temp_free_i32(arg32
[i0
].in
);
6361 tcg_temp_free_i32(arg32
[i1
].in
);
6364 tcg_temp_free_i32(arg32
[i2
].in
);
6369 static inline void get_f32_o1_i2(const OpcodeArg
*arg
, OpcodeArg
*arg32
,
6370 int o0
, int i0
, int i1
)
6372 get_f32_o1_i3(arg
, arg32
, o0
, i0
, i1
, -1);
6375 static inline void put_f32_o1_i2(const OpcodeArg
*arg
, const OpcodeArg
*arg32
,
6376 int o0
, int i0
, int i1
)
6378 put_f32_o1_i3(arg
, arg32
, o0
, i0
, i1
, -1);
6381 static inline void get_f32_o1_i1(const OpcodeArg
*arg
, OpcodeArg
*arg32
,
6384 get_f32_o1_i2(arg
, arg32
, o0
, i0
, -1);
6387 static inline void put_f32_o1_i1(const OpcodeArg
*arg
, const OpcodeArg
*arg32
,
6390 put_f32_o1_i2(arg
, arg32
, o0
, i0
, -1);
6393 static inline void get_f32_o1(const OpcodeArg
*arg
, OpcodeArg
*arg32
,
6396 get_f32_o1_i1(arg
, arg32
, o0
, -1);
6399 static inline void put_f32_o1(const OpcodeArg
*arg
, const OpcodeArg
*arg32
,
6402 put_f32_o1_i1(arg
, arg32
, o0
, -1);
6405 static inline void get_f32_i2(const OpcodeArg
*arg
, OpcodeArg
*arg32
,
6408 get_f32_o1_i2(arg
, arg32
, -1, i0
, i1
);
6411 static inline void put_f32_i2(const OpcodeArg
*arg
, const OpcodeArg
*arg32
,
6414 put_f32_o1_i2(arg
, arg32
, -1, i0
, i1
);
6417 static inline void get_f32_i1(const OpcodeArg
*arg
, OpcodeArg
*arg32
,
6420 get_f32_i2(arg
, arg32
, i0
, -1);
6423 static inline void put_f32_i1(const OpcodeArg
*arg
, const OpcodeArg
*arg32
,
6426 put_f32_i2(arg
, arg32
, i0
, -1);
6430 static void translate_abs_d(DisasContext
*dc
, const OpcodeArg arg
[],
6431 const uint32_t par
[])
6433 gen_helper_abs_d(arg
[0].out
, arg
[1].in
);
6436 static void translate_abs_s(DisasContext
*dc
, const OpcodeArg arg
[],
6437 const uint32_t par
[])
6441 get_f32_o1_i1(arg
, arg32
, 0, 1);
6442 gen_helper_abs_s(arg32
[0].out
, arg32
[1].in
);
6443 put_f32_o1_i1(arg
, arg32
, 0, 1);
6446 static void translate_fpu2k_add_s(DisasContext
*dc
, const OpcodeArg arg
[],
6447 const uint32_t par
[])
6449 gen_helper_fpu2k_add_s(arg
[0].out
, cpu_env
,
6450 arg
[1].in
, arg
[2].in
);
6463 static void translate_compare_d(DisasContext
*dc
, const OpcodeArg arg
[],
6464 const uint32_t par
[])
6466 static void (* const helper
[])(TCGv_i32 res
, TCGv_env env
,
6467 TCGv_i64 s
, TCGv_i64 t
) = {
6468 [COMPARE_UN
] = gen_helper_un_d
,
6469 [COMPARE_OEQ
] = gen_helper_oeq_d
,
6470 [COMPARE_UEQ
] = gen_helper_ueq_d
,
6471 [COMPARE_OLT
] = gen_helper_olt_d
,
6472 [COMPARE_ULT
] = gen_helper_ult_d
,
6473 [COMPARE_OLE
] = gen_helper_ole_d
,
6474 [COMPARE_ULE
] = gen_helper_ule_d
,
6476 TCGv_i32 zero
= tcg_const_i32(0);
6477 TCGv_i32 res
= tcg_temp_new_i32();
6478 TCGv_i32 set_br
= tcg_temp_new_i32();
6479 TCGv_i32 clr_br
= tcg_temp_new_i32();
6481 tcg_gen_ori_i32(set_br
, arg
[0].in
, 1 << arg
[0].imm
);
6482 tcg_gen_andi_i32(clr_br
, arg
[0].in
, ~(1 << arg
[0].imm
));
6484 helper
[par
[0]](res
, cpu_env
, arg
[1].in
, arg
[2].in
);
6485 tcg_gen_movcond_i32(TCG_COND_NE
,
6486 arg
[0].out
, res
, zero
,
6488 tcg_temp_free(zero
);
6490 tcg_temp_free(set_br
);
6491 tcg_temp_free(clr_br
);
6494 static void translate_compare_s(DisasContext
*dc
, const OpcodeArg arg
[],
6495 const uint32_t par
[])
6497 static void (* const helper
[])(TCGv_i32 res
, TCGv_env env
,
6498 TCGv_i32 s
, TCGv_i32 t
) = {
6499 [COMPARE_UN
] = gen_helper_un_s
,
6500 [COMPARE_OEQ
] = gen_helper_oeq_s
,
6501 [COMPARE_UEQ
] = gen_helper_ueq_s
,
6502 [COMPARE_OLT
] = gen_helper_olt_s
,
6503 [COMPARE_ULT
] = gen_helper_ult_s
,
6504 [COMPARE_OLE
] = gen_helper_ole_s
,
6505 [COMPARE_ULE
] = gen_helper_ule_s
,
6508 TCGv_i32 zero
= tcg_const_i32(0);
6509 TCGv_i32 res
= tcg_temp_new_i32();
6510 TCGv_i32 set_br
= tcg_temp_new_i32();
6511 TCGv_i32 clr_br
= tcg_temp_new_i32();
6513 tcg_gen_ori_i32(set_br
, arg
[0].in
, 1 << arg
[0].imm
);
6514 tcg_gen_andi_i32(clr_br
, arg
[0].in
, ~(1 << arg
[0].imm
));
6516 get_f32_i2(arg
, arg32
, 1, 2);
6517 helper
[par
[0]](res
, cpu_env
, arg32
[1].in
, arg32
[2].in
);
6518 tcg_gen_movcond_i32(TCG_COND_NE
,
6519 arg
[0].out
, res
, zero
,
6521 put_f32_i2(arg
, arg32
, 1, 2);
6522 tcg_temp_free(zero
);
6524 tcg_temp_free(set_br
);
6525 tcg_temp_free(clr_br
);
6528 static void translate_const_d(DisasContext
*dc
, const OpcodeArg arg
[],
6529 const uint32_t par
[])
6531 static const uint64_t v
[] = {
6532 UINT64_C(0x0000000000000000),
6533 UINT64_C(0x3ff0000000000000),
6534 UINT64_C(0x4000000000000000),
6535 UINT64_C(0x3fe0000000000000),
6538 tcg_gen_movi_i64(arg
[0].out
, v
[arg
[1].imm
% ARRAY_SIZE(v
)]);
6539 if (arg
[1].imm
>= ARRAY_SIZE(v
)) {
6540 qemu_log_mask(LOG_GUEST_ERROR
,
6541 "const.d f%d, #%d, immediate value is reserved\n",
6542 arg
[0].imm
, arg
[1].imm
);
6546 static void translate_const_s(DisasContext
*dc
, const OpcodeArg arg
[],
6547 const uint32_t par
[])
6549 static const uint32_t v
[] = {
6556 if (arg
[0].num_bits
== 32) {
6557 tcg_gen_movi_i32(arg
[0].out
, v
[arg
[1].imm
% ARRAY_SIZE(v
)]);
6559 tcg_gen_movi_i64(arg
[0].out
, v
[arg
[1].imm
% ARRAY_SIZE(v
)]);
6561 if (arg
[1].imm
>= ARRAY_SIZE(v
)) {
6562 qemu_log_mask(LOG_GUEST_ERROR
,
6563 "const.s f%d, #%d, immediate value is reserved\n",
6564 arg
[0].imm
, arg
[1].imm
);
6568 static void translate_float_d(DisasContext
*dc
, const OpcodeArg arg
[],
6569 const uint32_t par
[])
6571 TCGv_i32 scale
= tcg_const_i32(-arg
[2].imm
);
6574 gen_helper_uitof_d(arg
[0].out
, cpu_env
, arg
[1].in
, scale
);
6576 gen_helper_itof_d(arg
[0].out
, cpu_env
, arg
[1].in
, scale
);
6578 tcg_temp_free(scale
);
6581 static void translate_float_s(DisasContext
*dc
, const OpcodeArg arg
[],
6582 const uint32_t par
[])
6584 TCGv_i32 scale
= tcg_const_i32(-arg
[2].imm
);
6587 get_f32_o1(arg
, arg32
, 0);
6589 gen_helper_uitof_s(arg32
[0].out
, cpu_env
, arg
[1].in
, scale
);
6591 gen_helper_itof_s(arg32
[0].out
, cpu_env
, arg
[1].in
, scale
);
6593 put_f32_o1(arg
, arg32
, 0);
6594 tcg_temp_free(scale
);
6597 static void translate_ftoi_d(DisasContext
*dc
, const OpcodeArg arg
[],
6598 const uint32_t par
[])
6600 TCGv_i32 rounding_mode
= tcg_const_i32(par
[0]);
6601 TCGv_i32 scale
= tcg_const_i32(arg
[2].imm
);
6604 gen_helper_ftoui_d(arg
[0].out
, cpu_env
, arg
[1].in
,
6605 rounding_mode
, scale
);
6607 gen_helper_ftoi_d(arg
[0].out
, cpu_env
, arg
[1].in
,
6608 rounding_mode
, scale
);
6610 tcg_temp_free(rounding_mode
);
6611 tcg_temp_free(scale
);
6614 static void translate_ftoi_s(DisasContext
*dc
, const OpcodeArg arg
[],
6615 const uint32_t par
[])
6617 TCGv_i32 rounding_mode
= tcg_const_i32(par
[0]);
6618 TCGv_i32 scale
= tcg_const_i32(arg
[2].imm
);
6621 get_f32_i1(arg
, arg32
, 1);
6623 gen_helper_ftoui_s(arg
[0].out
, cpu_env
, arg32
[1].in
,
6624 rounding_mode
, scale
);
6626 gen_helper_ftoi_s(arg
[0].out
, cpu_env
, arg32
[1].in
,
6627 rounding_mode
, scale
);
6629 put_f32_i1(arg
, arg32
, 1);
6630 tcg_temp_free(rounding_mode
);
6631 tcg_temp_free(scale
);
6634 static void translate_ldsti(DisasContext
*dc
, const OpcodeArg arg
[],
6635 const uint32_t par
[])
6637 TCGv_i32 addr
= tcg_temp_new_i32();
6640 tcg_gen_addi_i32(addr
, arg
[1].in
, arg
[2].imm
);
6641 mop
= gen_load_store_alignment(dc
, MO_TEUL
, addr
);
6643 tcg_gen_qemu_st_tl(arg
[0].in
, addr
, dc
->cring
, mop
);
6645 tcg_gen_qemu_ld_tl(arg
[0].out
, addr
, dc
->cring
, mop
);
6648 tcg_gen_mov_i32(arg
[1].out
, addr
);
6650 tcg_temp_free(addr
);
6653 static void translate_ldstx(DisasContext
*dc
, const OpcodeArg arg
[],
6654 const uint32_t par
[])
6656 TCGv_i32 addr
= tcg_temp_new_i32();
6659 tcg_gen_add_i32(addr
, arg
[1].in
, arg
[2].in
);
6660 mop
= gen_load_store_alignment(dc
, MO_TEUL
, addr
);
6662 tcg_gen_qemu_st_tl(arg
[0].in
, addr
, dc
->cring
, mop
);
6664 tcg_gen_qemu_ld_tl(arg
[0].out
, addr
, dc
->cring
, mop
);
6667 tcg_gen_mov_i32(arg
[1].out
, addr
);
6669 tcg_temp_free(addr
);
6672 static void translate_fpu2k_madd_s(DisasContext
*dc
, const OpcodeArg arg
[],
6673 const uint32_t par
[])
6675 gen_helper_fpu2k_madd_s(arg
[0].out
, cpu_env
,
6676 arg
[0].in
, arg
[1].in
, arg
[2].in
);
6679 static void translate_mov_d(DisasContext
*dc
, const OpcodeArg arg
[],
6680 const uint32_t par
[])
6682 tcg_gen_mov_i64(arg
[0].out
, arg
[1].in
);
6685 static void translate_mov_s(DisasContext
*dc
, const OpcodeArg arg
[],
6686 const uint32_t par
[])
6688 if (arg
[0].num_bits
== 32) {
6689 tcg_gen_mov_i32(arg
[0].out
, arg
[1].in
);
6691 tcg_gen_mov_i64(arg
[0].out
, arg
[1].in
);
6695 static void translate_movcond_d(DisasContext
*dc
, const OpcodeArg arg
[],
6696 const uint32_t par
[])
6698 TCGv_i64 zero
= tcg_const_i64(0);
6699 TCGv_i64 arg2
= tcg_temp_new_i64();
6701 tcg_gen_ext_i32_i64(arg2
, arg
[2].in
);
6702 tcg_gen_movcond_i64(par
[0], arg
[0].out
,
6704 arg
[1].in
, arg
[0].in
);
6705 tcg_temp_free_i64(zero
);
6706 tcg_temp_free_i64(arg2
);
6709 static void translate_movcond_s(DisasContext
*dc
, const OpcodeArg arg
[],
6710 const uint32_t par
[])
6712 if (arg
[0].num_bits
== 32) {
6713 TCGv_i32 zero
= tcg_const_i32(0);
6715 tcg_gen_movcond_i32(par
[0], arg
[0].out
,
6717 arg
[1].in
, arg
[0].in
);
6718 tcg_temp_free(zero
);
6720 translate_movcond_d(dc
, arg
, par
);
6724 static void translate_movp_d(DisasContext
*dc
, const OpcodeArg arg
[],
6725 const uint32_t par
[])
6727 TCGv_i64 zero
= tcg_const_i64(0);
6728 TCGv_i32 tmp1
= tcg_temp_new_i32();
6729 TCGv_i64 tmp2
= tcg_temp_new_i64();
6731 tcg_gen_andi_i32(tmp1
, arg
[2].in
, 1 << arg
[2].imm
);
6732 tcg_gen_extu_i32_i64(tmp2
, tmp1
);
6733 tcg_gen_movcond_i64(par
[0],
6734 arg
[0].out
, tmp2
, zero
,
6735 arg
[1].in
, arg
[0].in
);
6736 tcg_temp_free_i64(zero
);
6737 tcg_temp_free_i32(tmp1
);
6738 tcg_temp_free_i64(tmp2
);
6741 static void translate_movp_s(DisasContext
*dc
, const OpcodeArg arg
[],
6742 const uint32_t par
[])
6744 if (arg
[0].num_bits
== 32) {
6745 TCGv_i32 zero
= tcg_const_i32(0);
6746 TCGv_i32 tmp
= tcg_temp_new_i32();
6748 tcg_gen_andi_i32(tmp
, arg
[2].in
, 1 << arg
[2].imm
);
6749 tcg_gen_movcond_i32(par
[0],
6750 arg
[0].out
, tmp
, zero
,
6751 arg
[1].in
, arg
[0].in
);
6753 tcg_temp_free(zero
);
6755 translate_movp_d(dc
, arg
, par
);
6759 static void translate_fpu2k_mul_s(DisasContext
*dc
, const OpcodeArg arg
[],
6760 const uint32_t par
[])
6762 gen_helper_fpu2k_mul_s(arg
[0].out
, cpu_env
,
6763 arg
[1].in
, arg
[2].in
);
6766 static void translate_fpu2k_msub_s(DisasContext
*dc
, const OpcodeArg arg
[],
6767 const uint32_t par
[])
6769 gen_helper_fpu2k_msub_s(arg
[0].out
, cpu_env
,
6770 arg
[0].in
, arg
[1].in
, arg
[2].in
);
6773 static void translate_neg_d(DisasContext
*dc
, const OpcodeArg arg
[],
6774 const uint32_t par
[])
6776 gen_helper_neg_d(arg
[0].out
, arg
[1].in
);
6779 static void translate_neg_s(DisasContext
*dc
, const OpcodeArg arg
[],
6780 const uint32_t par
[])
6784 get_f32_o1_i1(arg
, arg32
, 0, 1);
6785 gen_helper_neg_s(arg32
[0].out
, arg32
[1].in
);
6786 put_f32_o1_i1(arg
, arg32
, 0, 1);
6789 static void translate_rfr_d(DisasContext
*dc
, const OpcodeArg arg
[],
6790 const uint32_t par
[])
6792 tcg_gen_extrh_i64_i32(arg
[0].out
, arg
[1].in
);
6795 static void translate_rfr_s(DisasContext
*dc
, const OpcodeArg arg
[],
6796 const uint32_t par
[])
6798 if (arg
[1].num_bits
== 32) {
6799 tcg_gen_mov_i32(arg
[0].out
, arg
[1].in
);
6801 tcg_gen_extrl_i64_i32(arg
[0].out
, arg
[1].in
);
6805 static void translate_fpu2k_sub_s(DisasContext
*dc
, const OpcodeArg arg
[],
6806 const uint32_t par
[])
6808 gen_helper_fpu2k_sub_s(arg
[0].out
, cpu_env
,
6809 arg
[1].in
, arg
[2].in
);
6812 static void translate_wfr_d(DisasContext
*dc
, const OpcodeArg arg
[],
6813 const uint32_t par
[])
6815 tcg_gen_concat_i32_i64(arg
[0].out
, arg
[2].in
, arg
[1].in
);
6818 static void translate_wfr_s(DisasContext
*dc
, const OpcodeArg arg
[],
6819 const uint32_t par
[])
6821 if (arg
[0].num_bits
== 32) {
6822 tcg_gen_mov_i32(arg
[0].out
, arg
[1].in
);
6824 tcg_gen_ext_i32_i64(arg
[0].out
, arg
[1].in
);
6828 static void translate_wur_fpu2k_fcr(DisasContext
*dc
, const OpcodeArg arg
[],
6829 const uint32_t par
[])
6831 gen_helper_wur_fpu2k_fcr(cpu_env
, arg
[0].in
);
6834 static void translate_wur_fpu2k_fsr(DisasContext
*dc
, const OpcodeArg arg
[],
6835 const uint32_t par
[])
6837 tcg_gen_andi_i32(cpu_UR
[par
[0]], arg
[0].in
, 0xffffff80);
6840 static const XtensaOpcodeOps fpu2000_ops
[] = {
6843 .translate
= translate_abs_s
,
6847 .translate
= translate_fpu2k_add_s
,
6851 .translate
= translate_ftoi_s
,
6852 .par
= (const uint32_t[]){float_round_up
, false},
6856 .translate
= translate_float_s
,
6857 .par
= (const uint32_t[]){false},
6861 .translate
= translate_ftoi_s
,
6862 .par
= (const uint32_t[]){float_round_down
, false},
6866 .translate
= translate_ldsti
,
6867 .par
= (const uint32_t[]){false, false},
6868 .op_flags
= XTENSA_OP_LOAD
,
6872 .translate
= translate_ldsti
,
6873 .par
= (const uint32_t[]){false, true},
6874 .op_flags
= XTENSA_OP_LOAD
,
6878 .translate
= translate_ldstx
,
6879 .par
= (const uint32_t[]){false, false},
6880 .op_flags
= XTENSA_OP_LOAD
,
6884 .translate
= translate_ldstx
,
6885 .par
= (const uint32_t[]){false, true},
6886 .op_flags
= XTENSA_OP_LOAD
,
6890 .translate
= translate_fpu2k_madd_s
,
6894 .translate
= translate_mov_s
,
6898 .translate
= translate_movcond_s
,
6899 .par
= (const uint32_t[]){TCG_COND_EQ
},
6903 .translate
= translate_movp_s
,
6904 .par
= (const uint32_t[]){TCG_COND_EQ
},
6908 .translate
= translate_movcond_s
,
6909 .par
= (const uint32_t[]){TCG_COND_GE
},
6913 .translate
= translate_movcond_s
,
6914 .par
= (const uint32_t[]){TCG_COND_LT
},
6918 .translate
= translate_movcond_s
,
6919 .par
= (const uint32_t[]){TCG_COND_NE
},
6923 .translate
= translate_movp_s
,
6924 .par
= (const uint32_t[]){TCG_COND_NE
},
6928 .translate
= translate_fpu2k_msub_s
,
6932 .translate
= translate_fpu2k_mul_s
,
6936 .translate
= translate_neg_s
,
6940 .translate
= translate_compare_s
,
6941 .par
= (const uint32_t[]){COMPARE_OEQ
},
6945 .translate
= translate_compare_s
,
6946 .par
= (const uint32_t[]){COMPARE_OLE
},
6950 .translate
= translate_compare_s
,
6951 .par
= (const uint32_t[]){COMPARE_OLT
},
6955 .translate
= translate_rfr_s
,
6959 .translate
= translate_ftoi_s
,
6960 .par
= (const uint32_t[]){float_round_nearest_even
, false},
6964 .translate
= translate_rur
,
6965 .par
= (const uint32_t[]){FCR
},
6969 .translate
= translate_rur
,
6970 .par
= (const uint32_t[]){FSR
},
6974 .translate
= translate_ldsti
,
6975 .par
= (const uint32_t[]){true, false},
6976 .op_flags
= XTENSA_OP_STORE
,
6980 .translate
= translate_ldsti
,
6981 .par
= (const uint32_t[]){true, true},
6982 .op_flags
= XTENSA_OP_STORE
,
6986 .translate
= translate_ldstx
,
6987 .par
= (const uint32_t[]){true, false},
6988 .op_flags
= XTENSA_OP_STORE
,
6992 .translate
= translate_ldstx
,
6993 .par
= (const uint32_t[]){true, true},
6994 .op_flags
= XTENSA_OP_STORE
,
6998 .translate
= translate_fpu2k_sub_s
,
7002 .translate
= translate_ftoi_s
,
7003 .par
= (const uint32_t[]){float_round_to_zero
, false},
7007 .translate
= translate_compare_s
,
7008 .par
= (const uint32_t[]){COMPARE_UEQ
},
7012 .translate
= translate_float_s
,
7013 .par
= (const uint32_t[]){true},
7017 .translate
= translate_compare_s
,
7018 .par
= (const uint32_t[]){COMPARE_ULE
},
7022 .translate
= translate_compare_s
,
7023 .par
= (const uint32_t[]){COMPARE_ULT
},
7027 .translate
= translate_compare_s
,
7028 .par
= (const uint32_t[]){COMPARE_UN
},
7032 .translate
= translate_ftoi_s
,
7033 .par
= (const uint32_t[]){float_round_to_zero
, true},
7037 .translate
= translate_wfr_s
,
7041 .translate
= translate_wur_fpu2k_fcr
,
7042 .par
= (const uint32_t[]){FCR
},
7046 .translate
= translate_wur_fpu2k_fsr
,
7047 .par
= (const uint32_t[]){FSR
},
7052 const XtensaOpcodeTranslators xtensa_fpu2000_opcodes
= {
7053 .num_opcodes
= ARRAY_SIZE(fpu2000_ops
),
7054 .opcode
= fpu2000_ops
,
7057 static void translate_add_d(DisasContext
*dc
, const OpcodeArg arg
[],
7058 const uint32_t par
[])
7060 gen_helper_add_d(arg
[0].out
, cpu_env
, arg
[1].in
, arg
[2].in
);
7063 static void translate_add_s(DisasContext
*dc
, const OpcodeArg arg
[],
7064 const uint32_t par
[])
7066 if (option_enabled(dc
, XTENSA_OPTION_DFPU_SINGLE_ONLY
)) {
7067 gen_helper_fpu2k_add_s(arg
[0].out
, cpu_env
,
7068 arg
[1].in
, arg
[2].in
);
7072 get_f32_o1_i2(arg
, arg32
, 0, 1, 2);
7073 gen_helper_add_s(arg32
[0].out
, cpu_env
, arg32
[1].in
, arg32
[2].in
);
7074 put_f32_o1_i2(arg
, arg32
, 0, 1, 2);
7078 static void translate_cvtd_s(DisasContext
*dc
, const OpcodeArg arg
[],
7079 const uint32_t par
[])
7081 TCGv_i32 v
= tcg_temp_new_i32();
7083 tcg_gen_extrl_i64_i32(v
, arg
[1].in
);
7084 gen_helper_cvtd_s(arg
[0].out
, cpu_env
, v
);
7085 tcg_temp_free_i32(v
);
7088 static void translate_cvts_d(DisasContext
*dc
, const OpcodeArg arg
[],
7089 const uint32_t par
[])
7091 TCGv_i32 v
= tcg_temp_new_i32();
7093 gen_helper_cvts_d(v
, cpu_env
, arg
[1].in
);
7094 tcg_gen_extu_i32_i64(arg
[0].out
, v
);
7095 tcg_temp_free_i32(v
);
7098 static void translate_ldsti_d(DisasContext
*dc
, const OpcodeArg arg
[],
7099 const uint32_t par
[])
7105 addr
= tcg_temp_new_i32();
7106 tcg_gen_addi_i32(addr
, arg
[1].in
, arg
[2].imm
);
7110 mop
= gen_load_store_alignment(dc
, MO_TEQ
, addr
);
7112 tcg_gen_qemu_st_i64(arg
[0].in
, addr
, dc
->cring
, mop
);
7114 tcg_gen_qemu_ld_i64(arg
[0].out
, addr
, dc
->cring
, mop
);
7118 tcg_gen_mov_i32(arg
[1].out
, addr
);
7120 tcg_gen_addi_i32(arg
[1].out
, arg
[1].in
, arg
[2].imm
);
7124 tcg_temp_free(addr
);
7128 static void translate_ldsti_s(DisasContext
*dc
, const OpcodeArg arg
[],
7129 const uint32_t par
[])
7136 addr
= tcg_temp_new_i32();
7137 tcg_gen_addi_i32(addr
, arg
[1].in
, arg
[2].imm
);
7141 mop
= gen_load_store_alignment(dc
, MO_TEUL
, addr
);
7143 get_f32_i1(arg
, arg32
, 0);
7144 tcg_gen_qemu_st_tl(arg32
[0].in
, addr
, dc
->cring
, mop
);
7145 put_f32_i1(arg
, arg32
, 0);
7147 get_f32_o1(arg
, arg32
, 0);
7148 tcg_gen_qemu_ld_tl(arg32
[0].out
, addr
, dc
->cring
, mop
);
7149 put_f32_o1(arg
, arg32
, 0);
7153 tcg_gen_mov_i32(arg
[1].out
, addr
);
7155 tcg_gen_addi_i32(arg
[1].out
, arg
[1].in
, arg
[2].imm
);
7159 tcg_temp_free(addr
);
7163 static void translate_ldstx_d(DisasContext
*dc
, const OpcodeArg arg
[],
7164 const uint32_t par
[])
7170 addr
= tcg_temp_new_i32();
7171 tcg_gen_add_i32(addr
, arg
[1].in
, arg
[2].in
);
7175 mop
= gen_load_store_alignment(dc
, MO_TEQ
, addr
);
7177 tcg_gen_qemu_st_i64(arg
[0].in
, addr
, dc
->cring
, mop
);
7179 tcg_gen_qemu_ld_i64(arg
[0].out
, addr
, dc
->cring
, mop
);
7183 tcg_gen_mov_i32(arg
[1].out
, addr
);
7185 tcg_gen_add_i32(arg
[1].out
, arg
[1].in
, arg
[2].in
);
7189 tcg_temp_free(addr
);
7193 static void translate_ldstx_s(DisasContext
*dc
, const OpcodeArg arg
[],
7194 const uint32_t par
[])
7201 addr
= tcg_temp_new_i32();
7202 tcg_gen_add_i32(addr
, arg
[1].in
, arg
[2].in
);
7206 mop
= gen_load_store_alignment(dc
, MO_TEUL
, addr
);
7208 get_f32_i1(arg
, arg32
, 0);
7209 tcg_gen_qemu_st_tl(arg32
[0].in
, addr
, dc
->cring
, mop
);
7210 put_f32_i1(arg
, arg32
, 0);
7212 get_f32_o1(arg
, arg32
, 0);
7213 tcg_gen_qemu_ld_tl(arg32
[0].out
, addr
, dc
->cring
, mop
);
7214 put_f32_o1(arg
, arg32
, 0);
7218 tcg_gen_mov_i32(arg
[1].out
, addr
);
7220 tcg_gen_add_i32(arg
[1].out
, arg
[1].in
, arg
[2].in
);
7224 tcg_temp_free(addr
);
7228 static void translate_madd_d(DisasContext
*dc
, const OpcodeArg arg
[],
7229 const uint32_t par
[])
7231 gen_helper_madd_d(arg
[0].out
, cpu_env
,
7232 arg
[0].in
, arg
[1].in
, arg
[2].in
);
7235 static void translate_madd_s(DisasContext
*dc
, const OpcodeArg arg
[],
7236 const uint32_t par
[])
7238 if (option_enabled(dc
, XTENSA_OPTION_DFPU_SINGLE_ONLY
)) {
7239 gen_helper_fpu2k_madd_s(arg
[0].out
, cpu_env
,
7240 arg
[0].in
, arg
[1].in
, arg
[2].in
);
7244 get_f32_o1_i3(arg
, arg32
, 0, 0, 1, 2);
7245 gen_helper_madd_s(arg32
[0].out
, cpu_env
,
7246 arg32
[0].in
, arg32
[1].in
, arg32
[2].in
);
7247 put_f32_o1_i3(arg
, arg32
, 0, 0, 1, 2);
7251 static void translate_mul_d(DisasContext
*dc
, const OpcodeArg arg
[],
7252 const uint32_t par
[])
7254 gen_helper_mul_d(arg
[0].out
, cpu_env
, arg
[1].in
, arg
[2].in
);
7257 static void translate_mul_s(DisasContext
*dc
, const OpcodeArg arg
[],
7258 const uint32_t par
[])
7260 if (option_enabled(dc
, XTENSA_OPTION_DFPU_SINGLE_ONLY
)) {
7261 gen_helper_fpu2k_mul_s(arg
[0].out
, cpu_env
,
7262 arg
[1].in
, arg
[2].in
);
7266 get_f32_o1_i2(arg
, arg32
, 0, 1, 2);
7267 gen_helper_mul_s(arg32
[0].out
, cpu_env
, arg32
[1].in
, arg32
[2].in
);
7268 put_f32_o1_i2(arg
, arg32
, 0, 1, 2);
7272 static void translate_msub_d(DisasContext
*dc
, const OpcodeArg arg
[],
7273 const uint32_t par
[])
7275 gen_helper_msub_d(arg
[0].out
, cpu_env
,
7276 arg
[0].in
, arg
[1].in
, arg
[2].in
);
7279 static void translate_msub_s(DisasContext
*dc
, const OpcodeArg arg
[],
7280 const uint32_t par
[])
7282 if (option_enabled(dc
, XTENSA_OPTION_DFPU_SINGLE_ONLY
)) {
7283 gen_helper_fpu2k_msub_s(arg
[0].out
, cpu_env
,
7284 arg
[0].in
, arg
[1].in
, arg
[2].in
);
7288 get_f32_o1_i3(arg
, arg32
, 0, 0, 1, 2);
7289 gen_helper_msub_s(arg32
[0].out
, cpu_env
,
7290 arg32
[0].in
, arg32
[1].in
, arg32
[2].in
);
7291 put_f32_o1_i3(arg
, arg32
, 0, 0, 1, 2);
7295 static void translate_sub_d(DisasContext
*dc
, const OpcodeArg arg
[],
7296 const uint32_t par
[])
7298 gen_helper_sub_d(arg
[0].out
, cpu_env
, arg
[1].in
, arg
[2].in
);
7301 static void translate_sub_s(DisasContext
*dc
, const OpcodeArg arg
[],
7302 const uint32_t par
[])
7304 if (option_enabled(dc
, XTENSA_OPTION_DFPU_SINGLE_ONLY
)) {
7305 gen_helper_fpu2k_sub_s(arg
[0].out
, cpu_env
,
7306 arg
[1].in
, arg
[2].in
);
7310 get_f32_o1_i2(arg
, arg32
, 0, 1, 2);
7311 gen_helper_sub_s(arg32
[0].out
, cpu_env
, arg32
[1].in
, arg32
[2].in
);
7312 put_f32_o1_i2(arg
, arg32
, 0, 1, 2);
7316 static void translate_mkdadj_d(DisasContext
*dc
, const OpcodeArg arg
[],
7317 const uint32_t par
[])
7319 gen_helper_mkdadj_d(arg
[0].out
, cpu_env
, arg
[0].in
, arg
[1].in
);
7322 static void translate_mkdadj_s(DisasContext
*dc
, const OpcodeArg arg
[],
7323 const uint32_t par
[])
7327 get_f32_o1_i2(arg
, arg32
, 0, 0, 1);
7328 gen_helper_mkdadj_s(arg32
[0].out
, cpu_env
, arg32
[0].in
, arg32
[1].in
);
7329 put_f32_o1_i2(arg
, arg32
, 0, 0, 1);
7332 static void translate_mksadj_d(DisasContext
*dc
, const OpcodeArg arg
[],
7333 const uint32_t par
[])
7335 gen_helper_mksadj_d(arg
[0].out
, cpu_env
, arg
[1].in
);
7338 static void translate_mksadj_s(DisasContext
*dc
, const OpcodeArg arg
[],
7339 const uint32_t par
[])
7343 get_f32_o1_i1(arg
, arg32
, 0, 1);
7344 gen_helper_mksadj_s(arg32
[0].out
, cpu_env
, arg32
[1].in
);
7345 put_f32_o1_i1(arg
, arg32
, 0, 1);
7348 static void translate_wur_fpu_fcr(DisasContext
*dc
, const OpcodeArg arg
[],
7349 const uint32_t par
[])
7351 gen_helper_wur_fpu_fcr(cpu_env
, arg
[0].in
);
7354 static void translate_rur_fpu_fsr(DisasContext
*dc
, const OpcodeArg arg
[],
7355 const uint32_t par
[])
7357 gen_helper_rur_fpu_fsr(arg
[0].out
, cpu_env
);
7360 static void translate_wur_fpu_fsr(DisasContext
*dc
, const OpcodeArg arg
[],
7361 const uint32_t par
[])
7363 gen_helper_wur_fpu_fsr(cpu_env
, arg
[0].in
);
7366 static const XtensaOpcodeOps fpu_ops
[] = {
7369 .translate
= translate_abs_d
,
7373 .translate
= translate_abs_s
,
7377 .translate
= translate_add_d
,
7381 .translate
= translate_add_s
,
7385 .translate
= translate_nop
,
7389 .translate
= translate_nop
,
7392 .name
= "addexpm.d",
7393 .translate
= translate_mov_s
,
7396 .name
= "addexpm.s",
7397 .translate
= translate_mov_s
,
7401 .translate
= translate_ftoi_d
,
7402 .par
= (const uint32_t[]){float_round_up
, false},
7406 .translate
= translate_ftoi_s
,
7407 .par
= (const uint32_t[]){float_round_up
, false},
7411 .translate
= translate_const_d
,
7415 .translate
= translate_const_s
,
7419 .translate
= translate_cvtd_s
,
7423 .translate
= translate_cvts_d
,
7427 .translate
= translate_nop
,
7431 .translate
= translate_nop
,
7435 .translate
= translate_nop
,
7439 .translate
= translate_nop
,
7443 .translate
= translate_float_d
,
7444 .par
= (const uint32_t[]){false},
7448 .translate
= translate_float_s
,
7449 .par
= (const uint32_t[]){false},
7453 .translate
= translate_ftoi_d
,
7454 .par
= (const uint32_t[]){float_round_down
, false},
7458 .translate
= translate_ftoi_s
,
7459 .par
= (const uint32_t[]){float_round_down
, false},
7463 .translate
= translate_ldsti_d
,
7464 .par
= (const uint32_t[]){false, true, false},
7465 .op_flags
= XTENSA_OP_LOAD
,
7469 .translate
= translate_ldsti_d
,
7470 .par
= (const uint32_t[]){false, false, true},
7471 .op_flags
= XTENSA_OP_LOAD
,
7475 .translate
= translate_ldsti_d
,
7476 .par
= (const uint32_t[]){false, true, true},
7477 .op_flags
= XTENSA_OP_LOAD
,
7481 .translate
= translate_ldstx_d
,
7482 .par
= (const uint32_t[]){false, true, false},
7483 .op_flags
= XTENSA_OP_LOAD
,
7487 .translate
= translate_ldstx_d
,
7488 .par
= (const uint32_t[]){false, false, true},
7489 .op_flags
= XTENSA_OP_LOAD
,
7493 .translate
= translate_ldstx_d
,
7494 .par
= (const uint32_t[]){false, true, true},
7495 .op_flags
= XTENSA_OP_LOAD
,
7499 .translate
= translate_ldsti_s
,
7500 .par
= (const uint32_t[]){false, true, false},
7501 .op_flags
= XTENSA_OP_LOAD
,
7505 .translate
= translate_ldsti_s
,
7506 .par
= (const uint32_t[]){false, false, true},
7507 .op_flags
= XTENSA_OP_LOAD
,
7511 .translate
= translate_ldsti_s
,
7512 .par
= (const uint32_t[]){false, true, true},
7513 .op_flags
= XTENSA_OP_LOAD
,
7517 .translate
= translate_ldstx_s
,
7518 .par
= (const uint32_t[]){false, true, false},
7519 .op_flags
= XTENSA_OP_LOAD
,
7523 .translate
= translate_ldstx_s
,
7524 .par
= (const uint32_t[]){false, false, true},
7525 .op_flags
= XTENSA_OP_LOAD
,
7529 .translate
= translate_ldstx_s
,
7530 .par
= (const uint32_t[]){false, true, true},
7531 .op_flags
= XTENSA_OP_LOAD
,
7535 .translate
= translate_madd_d
,
7539 .translate
= translate_madd_s
,
7543 .translate
= translate_nop
,
7547 .translate
= translate_nop
,
7551 .translate
= translate_mkdadj_d
,
7555 .translate
= translate_mkdadj_s
,
7559 .translate
= translate_mksadj_d
,
7563 .translate
= translate_mksadj_s
,
7567 .translate
= translate_mov_d
,
7571 .translate
= translate_mov_s
,
7575 .translate
= translate_movcond_d
,
7576 .par
= (const uint32_t[]){TCG_COND_EQ
},
7580 .translate
= translate_movcond_s
,
7581 .par
= (const uint32_t[]){TCG_COND_EQ
},
7585 .translate
= translate_movp_d
,
7586 .par
= (const uint32_t[]){TCG_COND_EQ
},
7590 .translate
= translate_movp_s
,
7591 .par
= (const uint32_t[]){TCG_COND_EQ
},
7595 .translate
= translate_movcond_d
,
7596 .par
= (const uint32_t[]){TCG_COND_GE
},
7600 .translate
= translate_movcond_s
,
7601 .par
= (const uint32_t[]){TCG_COND_GE
},
7605 .translate
= translate_movcond_d
,
7606 .par
= (const uint32_t[]){TCG_COND_LT
},
7610 .translate
= translate_movcond_s
,
7611 .par
= (const uint32_t[]){TCG_COND_LT
},
7615 .translate
= translate_movcond_d
,
7616 .par
= (const uint32_t[]){TCG_COND_NE
},
7620 .translate
= translate_movcond_s
,
7621 .par
= (const uint32_t[]){TCG_COND_NE
},
7625 .translate
= translate_movp_d
,
7626 .par
= (const uint32_t[]){TCG_COND_NE
},
7630 .translate
= translate_movp_s
,
7631 .par
= (const uint32_t[]){TCG_COND_NE
},
7635 .translate
= translate_msub_d
,
7639 .translate
= translate_msub_s
,
7643 .translate
= translate_mul_d
,
7647 .translate
= translate_mul_s
,
7651 .translate
= translate_neg_d
,
7655 .translate
= translate_neg_s
,
7659 .translate
= translate_nop
,
7663 .translate
= translate_nop
,
7667 .translate
= translate_compare_d
,
7668 .par
= (const uint32_t[]){COMPARE_OEQ
},
7672 .translate
= translate_compare_s
,
7673 .par
= (const uint32_t[]){COMPARE_OEQ
},
7677 .translate
= translate_compare_d
,
7678 .par
= (const uint32_t[]){COMPARE_OLE
},
7682 .translate
= translate_compare_s
,
7683 .par
= (const uint32_t[]){COMPARE_OLE
},
7687 .translate
= translate_compare_d
,
7688 .par
= (const uint32_t[]){COMPARE_OLT
},
7692 .translate
= translate_compare_s
,
7693 .par
= (const uint32_t[]){COMPARE_OLT
},
7697 .translate
= translate_rfr_s
,
7701 .translate
= translate_rfr_d
,
7705 .translate
= translate_ftoi_d
,
7706 .par
= (const uint32_t[]){float_round_nearest_even
, false},
7710 .translate
= translate_ftoi_s
,
7711 .par
= (const uint32_t[]){float_round_nearest_even
, false},
7715 .translate
= translate_rur
,
7716 .par
= (const uint32_t[]){FCR
},
7720 .translate
= translate_rur_fpu_fsr
,
7724 .translate
= translate_ldsti_d
,
7725 .par
= (const uint32_t[]){true, true, false},
7726 .op_flags
= XTENSA_OP_STORE
,
7730 .translate
= translate_ldsti_d
,
7731 .par
= (const uint32_t[]){true, false, true},
7732 .op_flags
= XTENSA_OP_STORE
,
7736 .translate
= translate_ldsti_d
,
7737 .par
= (const uint32_t[]){true, true, true},
7738 .op_flags
= XTENSA_OP_STORE
,
7742 .translate
= translate_ldstx_d
,
7743 .par
= (const uint32_t[]){true, true, false},
7744 .op_flags
= XTENSA_OP_STORE
,
7748 .translate
= translate_ldstx_d
,
7749 .par
= (const uint32_t[]){true, false, true},
7750 .op_flags
= XTENSA_OP_STORE
,
7754 .translate
= translate_ldstx_d
,
7755 .par
= (const uint32_t[]){true, true, true},
7756 .op_flags
= XTENSA_OP_STORE
,
7760 .translate
= translate_nop
,
7764 .translate
= translate_nop
,
7768 .translate
= translate_ldsti_s
,
7769 .par
= (const uint32_t[]){true, true, false},
7770 .op_flags
= XTENSA_OP_STORE
,
7774 .translate
= translate_ldsti_s
,
7775 .par
= (const uint32_t[]){true, false, true},
7776 .op_flags
= XTENSA_OP_STORE
,
7780 .translate
= translate_ldsti_s
,
7781 .par
= (const uint32_t[]){true, true, true},
7782 .op_flags
= XTENSA_OP_STORE
,
7786 .translate
= translate_ldstx_s
,
7787 .par
= (const uint32_t[]){true, true, false},
7788 .op_flags
= XTENSA_OP_STORE
,
7792 .translate
= translate_ldstx_s
,
7793 .par
= (const uint32_t[]){true, false, true},
7794 .op_flags
= XTENSA_OP_STORE
,
7798 .translate
= translate_ldstx_s
,
7799 .par
= (const uint32_t[]){true, true, true},
7800 .op_flags
= XTENSA_OP_STORE
,
7804 .translate
= translate_sub_d
,
7808 .translate
= translate_sub_s
,
7812 .translate
= translate_ftoi_d
,
7813 .par
= (const uint32_t[]){float_round_to_zero
, false},
7817 .translate
= translate_ftoi_s
,
7818 .par
= (const uint32_t[]){float_round_to_zero
, false},
7822 .translate
= translate_compare_d
,
7823 .par
= (const uint32_t[]){COMPARE_UEQ
},
7827 .translate
= translate_compare_s
,
7828 .par
= (const uint32_t[]){COMPARE_UEQ
},
7832 .translate
= translate_float_d
,
7833 .par
= (const uint32_t[]){true},
7837 .translate
= translate_float_s
,
7838 .par
= (const uint32_t[]){true},
7842 .translate
= translate_compare_d
,
7843 .par
= (const uint32_t[]){COMPARE_ULE
},
7847 .translate
= translate_compare_s
,
7848 .par
= (const uint32_t[]){COMPARE_ULE
},
7852 .translate
= translate_compare_d
,
7853 .par
= (const uint32_t[]){COMPARE_ULT
},
7857 .translate
= translate_compare_s
,
7858 .par
= (const uint32_t[]){COMPARE_ULT
},
7862 .translate
= translate_compare_d
,
7863 .par
= (const uint32_t[]){COMPARE_UN
},
7867 .translate
= translate_compare_s
,
7868 .par
= (const uint32_t[]){COMPARE_UN
},
7872 .translate
= translate_ftoi_d
,
7873 .par
= (const uint32_t[]){float_round_to_zero
, true},
7877 .translate
= translate_ftoi_s
,
7878 .par
= (const uint32_t[]){float_round_to_zero
, true},
7882 .translate
= translate_wfr_s
,
7886 .translate
= translate_wfr_d
,
7890 .translate
= translate_wur_fpu_fcr
,
7891 .par
= (const uint32_t[]){FCR
},
7895 .translate
= translate_wur_fpu_fsr
,
7900 const XtensaOpcodeTranslators xtensa_fpu_opcodes
= {
7901 .num_opcodes
= ARRAY_SIZE(fpu_ops
),