]> Git Repo - qemu.git/blame - target/xtensa/translate.c
target/xtensa: rename FPU2000 translators and helpers
[qemu.git] / target / xtensa / translate.c
CommitLineData
2328826b
MF
1/*
2 * Xtensa ISA:
3 * http://www.tensilica.com/products/literature-docs/documentation/xtensa-isa-databook.htm
4 *
5 * Copyright (c) 2011, Max Filippov, Open Source and Linux Lab.
6 * All rights reserved.
7 *
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.
18 *
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.
29 */
30
09aae23d 31#include "qemu/osdep.h"
2328826b
MF
32
33#include "cpu.h"
022c62cb 34#include "exec/exec-all.h"
76cad711 35#include "disas/disas.h"
dcb32f1d 36#include "tcg/tcg-op.h"
1de7afc9 37#include "qemu/log.h"
90c84c56 38#include "qemu/qemu-print.h"
f08b6170 39#include "exec/cpu_ldst.h"
f1672e6f 40#include "hw/semihosting/semihost.h"
77fc6f5e 41#include "exec/translator.h"
2328826b 42
2ef6175a
RH
43#include "exec/helper-proto.h"
44#include "exec/helper-gen.h"
dedc5eae 45
a7e30d84 46#include "trace-tcg.h"
508127e2 47#include "exec/log.h"
a7e30d84
LV
48
49
a3380cf6 50struct DisasContext {
3cc18eec 51 DisasContextBase base;
dedc5eae 52 const XtensaConfig *config;
dedc5eae 53 uint32_t pc;
f0a548b9
MF
54 int cring;
55 int ring;
5d630cef 56 uint32_t lbeg_off;
797d780b 57 uint32_t lend;
3580ecad
MF
58
59 bool sar_5bit;
60 bool sar_m32_5bit;
61 bool sar_m32_allocated;
62 TCGv_i32 sar_m32;
b994e91b 63
2db59a76 64 unsigned window;
6416d16f 65 unsigned callinc;
09460970 66 bool cwoe;
e61dc8f7
MF
67
68 bool debug;
35b5c044
MF
69 bool icount;
70 TCGv_i32 next_icount;
ef04a846
MF
71
72 unsigned cpenable;
168c12b0 73
45b71a79 74 uint32_t op_flags;
fde557ad
MF
75 xtensa_insnbuf_word insnbuf[MAX_INSNBUF_LENGTH];
76 xtensa_insnbuf_word slotbuf[MAX_INSNBUF_LENGTH];
a3380cf6 77};
dedc5eae 78
dedc5eae
MF
79static TCGv_i32 cpu_pc;
80static TCGv_i32 cpu_R[16];
dd519cbe 81static TCGv_i32 cpu_FR[16];
7aa78341 82static TCGv_i32 cpu_MR[4];
575e962a
MF
83static TCGv_i32 cpu_BR[16];
84static TCGv_i32 cpu_BR4[4];
85static TCGv_i32 cpu_BR8[2];
2af3da91
MF
86static TCGv_i32 cpu_SR[256];
87static TCGv_i32 cpu_UR[256];
8df3fd35 88static TCGv_i32 cpu_windowbase_next;
b345e140
MF
89static TCGv_i32 cpu_exclusive_addr;
90static TCGv_i32 cpu_exclusive_val;
dedc5eae 91
b0b24bdc
MF
92static GHashTable *xtensa_regfile_table;
93
022c62cb 94#include "exec/gen-icount.h"
2328826b 95
59419607
MF
96static char *sr_name[256];
97static char *ur_name[256];
fe0bd475 98
59419607
MF
99void xtensa_collect_sr_names(const XtensaConfig *config)
100{
101 xtensa_isa isa = config->isa;
102 int n = xtensa_isa_num_sysregs(isa);
103 int i;
53593e90 104
59419607
MF
105 for (i = 0; i < n; ++i) {
106 int sr = xtensa_sysreg_number(isa, i);
107
108 if (sr >= 0 && sr < 256) {
109 const char *name = xtensa_sysreg_name(isa, i);
110 char **pname =
111 (xtensa_sysreg_is_user(isa, i) ? ur_name : sr_name) + sr;
112
113 if (*pname) {
114 if (strstr(*pname, name) == NULL) {
115 char *new_name =
116 malloc(strlen(*pname) + strlen(name) + 2);
117
118 strcpy(new_name, *pname);
119 strcat(new_name, "/");
120 strcat(new_name, name);
121 free(*pname);
122 *pname = new_name;
123 }
124 } else {
125 *pname = strdup(name);
126 }
127 }
fe0bd475 128 }
59419607 129}
2af3da91 130
2328826b
MF
131void xtensa_translate_init(void)
132{
dedc5eae
MF
133 static const char * const regnames[] = {
134 "ar0", "ar1", "ar2", "ar3",
135 "ar4", "ar5", "ar6", "ar7",
136 "ar8", "ar9", "ar10", "ar11",
137 "ar12", "ar13", "ar14", "ar15",
138 };
dd519cbe
MF
139 static const char * const fregnames[] = {
140 "f0", "f1", "f2", "f3",
141 "f4", "f5", "f6", "f7",
142 "f8", "f9", "f10", "f11",
143 "f12", "f13", "f14", "f15",
144 };
7aa78341
MF
145 static const char * const mregnames[] = {
146 "m0", "m1", "m2", "m3",
147 };
575e962a
MF
148 static const char * const bregnames[] = {
149 "b0", "b1", "b2", "b3",
150 "b4", "b5", "b6", "b7",
151 "b8", "b9", "b10", "b11",
152 "b12", "b13", "b14", "b15",
153 };
dedc5eae
MF
154 int i;
155
e1ccc054 156 cpu_pc = tcg_global_mem_new_i32(cpu_env,
97129ac8 157 offsetof(CPUXtensaState, pc), "pc");
dedc5eae
MF
158
159 for (i = 0; i < 16; i++) {
e1ccc054 160 cpu_R[i] = tcg_global_mem_new_i32(cpu_env,
7aa78341
MF
161 offsetof(CPUXtensaState, regs[i]),
162 regnames[i]);
dedc5eae 163 }
2af3da91 164
dd519cbe 165 for (i = 0; i < 16; i++) {
e1ccc054 166 cpu_FR[i] = tcg_global_mem_new_i32(cpu_env,
7aa78341
MF
167 offsetof(CPUXtensaState,
168 fregs[i].f32[FP_F32_LOW]),
169 fregnames[i]);
170 }
171
172 for (i = 0; i < 4; i++) {
173 cpu_MR[i] = tcg_global_mem_new_i32(cpu_env,
174 offsetof(CPUXtensaState,
175 sregs[MR + i]),
176 mregnames[i]);
dd519cbe
MF
177 }
178
575e962a
MF
179 for (i = 0; i < 16; i++) {
180 cpu_BR[i] = tcg_global_mem_new_i32(cpu_env,
181 offsetof(CPUXtensaState,
182 sregs[BR]),
183 bregnames[i]);
184 if (i % 4 == 0) {
185 cpu_BR4[i / 4] = tcg_global_mem_new_i32(cpu_env,
186 offsetof(CPUXtensaState,
187 sregs[BR]),
188 bregnames[i]);
189 }
190 if (i % 8 == 0) {
191 cpu_BR8[i / 8] = tcg_global_mem_new_i32(cpu_env,
192 offsetof(CPUXtensaState,
193 sregs[BR]),
194 bregnames[i]);
195 }
196 }
197
2af3da91 198 for (i = 0; i < 256; ++i) {
59419607 199 if (sr_name[i]) {
e1ccc054 200 cpu_SR[i] = tcg_global_mem_new_i32(cpu_env,
59419607
MF
201 offsetof(CPUXtensaState,
202 sregs[i]),
203 sr_name[i]);
2af3da91
MF
204 }
205 }
206
207 for (i = 0; i < 256; ++i) {
59419607 208 if (ur_name[i]) {
e1ccc054 209 cpu_UR[i] = tcg_global_mem_new_i32(cpu_env,
59419607
MF
210 offsetof(CPUXtensaState,
211 uregs[i]),
212 ur_name[i]);
2af3da91
MF
213 }
214 }
8df3fd35
MF
215
216 cpu_windowbase_next =
217 tcg_global_mem_new_i32(cpu_env,
218 offsetof(CPUXtensaState, windowbase_next),
219 "windowbase_next");
b345e140
MF
220 cpu_exclusive_addr =
221 tcg_global_mem_new_i32(cpu_env,
222 offsetof(CPUXtensaState, exclusive_addr),
223 "exclusive_addr");
224 cpu_exclusive_val =
225 tcg_global_mem_new_i32(cpu_env,
226 offsetof(CPUXtensaState, exclusive_val),
227 "exclusive_val");
dedc5eae
MF
228}
229
ee659da2 230void **xtensa_get_regfile_by_name(const char *name, int entries, int bits)
b0b24bdc 231{
ee659da2
MF
232 char *geometry_name;
233 void **res;
234
b0b24bdc
MF
235 if (xtensa_regfile_table == NULL) {
236 xtensa_regfile_table = g_hash_table_new(g_str_hash, g_str_equal);
ee659da2
MF
237 /*
238 * AR is special. Xtensa translator uses it as a current register
239 * window, but configuration overlays represent it as a complete
240 * physical register file.
241 */
b0b24bdc 242 g_hash_table_insert(xtensa_regfile_table,
ee659da2 243 (void *)"AR 16x32", (void *)cpu_R);
7aa78341 244 g_hash_table_insert(xtensa_regfile_table,
ee659da2 245 (void *)"AR 32x32", (void *)cpu_R);
b0b24bdc 246 g_hash_table_insert(xtensa_regfile_table,
ee659da2
MF
247 (void *)"AR 64x32", (void *)cpu_R);
248
575e962a 249 g_hash_table_insert(xtensa_regfile_table,
ee659da2
MF
250 (void *)"MR 4x32", (void *)cpu_MR);
251
575e962a 252 g_hash_table_insert(xtensa_regfile_table,
ee659da2
MF
253 (void *)"FR 16x32", (void *)cpu_FR);
254
575e962a 255 g_hash_table_insert(xtensa_regfile_table,
ee659da2
MF
256 (void *)"BR 16x1", (void *)cpu_BR);
257 g_hash_table_insert(xtensa_regfile_table,
258 (void *)"BR4 4x4", (void *)cpu_BR4);
259 g_hash_table_insert(xtensa_regfile_table,
260 (void *)"BR8 2x8", (void *)cpu_BR8);
b0b24bdc 261 }
ee659da2
MF
262
263 geometry_name = g_strdup_printf("%s %dx%d", name, entries, bits);
264 res = (void **)g_hash_table_lookup(xtensa_regfile_table, geometry_name);
265 g_free(geometry_name);
266 return res;
b0b24bdc
MF
267}
268
dedc5eae
MF
269static inline bool option_enabled(DisasContext *dc, int opt)
270{
271 return xtensa_option_enabled(dc->config, opt);
272}
273
3580ecad
MF
274static void init_sar_tracker(DisasContext *dc)
275{
276 dc->sar_5bit = false;
277 dc->sar_m32_5bit = false;
278 dc->sar_m32_allocated = false;
279}
280
281static void reset_sar_tracker(DisasContext *dc)
282{
283 if (dc->sar_m32_allocated) {
284 tcg_temp_free(dc->sar_m32);
285 }
286}
287
288static void gen_right_shift_sar(DisasContext *dc, TCGv_i32 sa)
289{
290 tcg_gen_andi_i32(cpu_SR[SAR], sa, 0x1f);
291 if (dc->sar_m32_5bit) {
292 tcg_gen_discard_i32(dc->sar_m32);
293 }
294 dc->sar_5bit = true;
295 dc->sar_m32_5bit = false;
296}
297
298static void gen_left_shift_sar(DisasContext *dc, TCGv_i32 sa)
299{
300 TCGv_i32 tmp = tcg_const_i32(32);
301 if (!dc->sar_m32_allocated) {
302 dc->sar_m32 = tcg_temp_local_new_i32();
303 dc->sar_m32_allocated = true;
304 }
305 tcg_gen_andi_i32(dc->sar_m32, sa, 0x1f);
306 tcg_gen_sub_i32(cpu_SR[SAR], tmp, dc->sar_m32);
307 dc->sar_5bit = false;
308 dc->sar_m32_5bit = true;
309 tcg_temp_free(tmp);
310}
311
b994e91b 312static void gen_exception(DisasContext *dc, int excp)
dedc5eae
MF
313{
314 TCGv_i32 tmp = tcg_const_i32(excp);
f492b82d 315 gen_helper_exception(cpu_env, tmp);
dedc5eae
MF
316 tcg_temp_free(tmp);
317}
318
40643d7c
MF
319static void gen_exception_cause(DisasContext *dc, uint32_t cause)
320{
321 TCGv_i32 tpc = tcg_const_i32(dc->pc);
322 TCGv_i32 tcause = tcg_const_i32(cause);
f492b82d 323 gen_helper_exception_cause(cpu_env, tpc, tcause);
40643d7c
MF
324 tcg_temp_free(tpc);
325 tcg_temp_free(tcause);
6b814719
MF
326 if (cause == ILLEGAL_INSTRUCTION_CAUSE ||
327 cause == SYSCALL_CAUSE) {
3cc18eec 328 dc->base.is_jmp = DISAS_NORETURN;
6b814719 329 }
40643d7c
MF
330}
331
5b4e481b
MF
332static void gen_exception_cause_vaddr(DisasContext *dc, uint32_t cause,
333 TCGv_i32 vaddr)
334{
335 TCGv_i32 tpc = tcg_const_i32(dc->pc);
336 TCGv_i32 tcause = tcg_const_i32(cause);
f492b82d 337 gen_helper_exception_cause_vaddr(cpu_env, tpc, tcause, vaddr);
5b4e481b
MF
338 tcg_temp_free(tpc);
339 tcg_temp_free(tcause);
340}
341
e61dc8f7
MF
342static void gen_debug_exception(DisasContext *dc, uint32_t cause)
343{
344 TCGv_i32 tpc = tcg_const_i32(dc->pc);
345 TCGv_i32 tcause = tcg_const_i32(cause);
f492b82d 346 gen_helper_debug_exception(cpu_env, tpc, tcause);
e61dc8f7
MF
347 tcg_temp_free(tpc);
348 tcg_temp_free(tcause);
349 if (cause & (DEBUGCAUSE_IB | DEBUGCAUSE_BI | DEBUGCAUSE_BN)) {
3cc18eec 350 dc->base.is_jmp = DISAS_NORETURN;
e61dc8f7
MF
351 }
352}
353
97e89ee9 354static bool gen_check_privilege(DisasContext *dc)
40643d7c 355{
ba7651fb
MF
356#ifndef CONFIG_USER_ONLY
357 if (!dc->cring) {
358 return true;
40643d7c 359 }
ba7651fb
MF
360#endif
361 gen_exception_cause(dc, PRIVILEGED_CAUSE);
3cc18eec 362 dc->base.is_jmp = DISAS_NORETURN;
ba7651fb 363 return false;
40643d7c
MF
364}
365
582fef0f 366static bool gen_check_cpenable(DisasContext *dc, uint32_t cp_mask)
ef04a846 367{
582fef0f
MF
368 cp_mask &= ~dc->cpenable;
369
370 if (option_enabled(dc, XTENSA_OPTION_COPROCESSOR) && cp_mask) {
371 gen_exception_cause(dc, COPROCESSOR0_DISABLED + ctz32(cp_mask));
3cc18eec 372 dc->base.is_jmp = DISAS_NORETURN;
97e89ee9 373 return false;
ef04a846 374 }
97e89ee9 375 return true;
ef04a846
MF
376}
377
45b71a79
MF
378static int gen_postprocess(DisasContext *dc, int slot);
379
dedc5eae
MF
380static void gen_jump_slot(DisasContext *dc, TCGv dest, int slot)
381{
382 tcg_gen_mov_i32(cpu_pc, dest);
35b5c044
MF
383 if (dc->icount) {
384 tcg_gen_mov_i32(cpu_SR[ICOUNT], dc->next_icount);
385 }
3cc18eec 386 if (dc->base.singlestep_enabled) {
b994e91b 387 gen_exception(dc, EXCP_DEBUG);
dedc5eae 388 } else {
45b71a79
MF
389 if (dc->op_flags & XTENSA_OP_POSTPROCESS) {
390 slot = gen_postprocess(dc, slot);
391 }
dedc5eae
MF
392 if (slot >= 0) {
393 tcg_gen_goto_tb(slot);
3cc18eec 394 tcg_gen_exit_tb(dc->base.tb, slot);
dedc5eae 395 } else {
07ea28b4 396 tcg_gen_exit_tb(NULL, 0);
dedc5eae
MF
397 }
398 }
3cc18eec 399 dc->base.is_jmp = DISAS_NORETURN;
dedc5eae
MF
400}
401
67882fd1
MF
402static void gen_jump(DisasContext *dc, TCGv dest)
403{
404 gen_jump_slot(dc, dest, -1);
405}
406
9791e7e9 407static int adjust_jump_slot(DisasContext *dc, uint32_t dest, int slot)
dedc5eae 408{
3cc18eec 409 if (((dc->base.pc_first ^ dest) & TARGET_PAGE_MASK) != 0) {
9791e7e9
MF
410 return -1;
411 } else {
412 return slot;
dedc5eae 413 }
9791e7e9
MF
414}
415
416static void gen_jumpi(DisasContext *dc, uint32_t dest, int slot)
417{
418 TCGv_i32 tmp = tcg_const_i32(dest);
419 gen_jump_slot(dc, tmp, adjust_jump_slot(dc, dest, slot));
dedc5eae
MF
420 tcg_temp_free(tmp);
421}
422
553e44f9
MF
423static void gen_callw_slot(DisasContext *dc, int callinc, TCGv_i32 dest,
424 int slot)
425{
426 TCGv_i32 tcallinc = tcg_const_i32(callinc);
427
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],
3cc18eec 432 (callinc << 30) | (dc->base.pc_next & 0x3fffffff));
553e44f9
MF
433 gen_jump_slot(dc, dest, slot);
434}
435
797d780b
MF
436static bool gen_check_loop_end(DisasContext *dc, int slot)
437{
5d630cef 438 if (dc->base.pc_next == dc->lend) {
42a268c2 439 TCGLabel *label = gen_new_label();
797d780b
MF
440
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);
5d630cef
MF
443 if (dc->lbeg_off) {
444 gen_jumpi(dc, dc->base.pc_next - dc->lbeg_off, slot);
445 } else {
446 gen_jump(dc, cpu_SR[LBEG]);
447 }
797d780b 448 gen_set_label(label);
3cc18eec 449 gen_jumpi(dc, dc->base.pc_next, -1);
797d780b
MF
450 return true;
451 }
452 return false;
453}
454
455static void gen_jumpi_check_loop_end(DisasContext *dc, int slot)
456{
457 if (!gen_check_loop_end(dc, slot)) {
3cc18eec 458 gen_jumpi(dc, dc->base.pc_next, slot);
797d780b
MF
459 }
460}
461
bd57fb91 462static void gen_brcond(DisasContext *dc, TCGCond cond,
33071f68 463 TCGv_i32 t0, TCGv_i32 t1, uint32_t addr)
bd57fb91 464{
42a268c2 465 TCGLabel *label = gen_new_label();
bd57fb91
MF
466
467 tcg_gen_brcond_i32(cond, t0, t1, label);
797d780b 468 gen_jumpi_check_loop_end(dc, 0);
bd57fb91 469 gen_set_label(label);
33071f68 470 gen_jumpi(dc, addr, 1);
bd57fb91
MF
471}
472
473static void gen_brcondi(DisasContext *dc, TCGCond cond,
33071f68 474 TCGv_i32 t0, uint32_t t1, uint32_t addr)
bd57fb91
MF
475{
476 TCGv_i32 tmp = tcg_const_i32(t1);
33071f68 477 gen_brcond(dc, cond, t0, tmp, addr);
bd57fb91
MF
478 tcg_temp_free(tmp);
479}
480
91dc2b2d
MF
481static uint32_t test_exceptions_sr(DisasContext *dc, const OpcodeArg arg[],
482 const uint32_t par[])
b994e91b 483{
91dc2b2d 484 return xtensa_option_enabled(dc->config, par[1]) ? 0 : XTENSA_OP_ILL;
b994e91b
MF
485}
486
91dc2b2d
MF
487static uint32_t test_exceptions_ccompare(DisasContext *dc,
488 const OpcodeArg arg[],
489 const uint32_t par[])
b994e91b 490{
59419607 491 unsigned n = par[0] - CCOMPARE;
b994e91b 492
91dc2b2d
MF
493 if (n >= dc->config->nccompare) {
494 return XTENSA_OP_ILL;
495 }
496 return test_exceptions_sr(dc, arg, par);
b994e91b
MF
497}
498
91dc2b2d
MF
499static uint32_t test_exceptions_dbreak(DisasContext *dc, const OpcodeArg arg[],
500 const uint32_t par[])
f0a548b9 501{
59419607 502 unsigned n = MAX_NDBREAK;
f0a548b9 503
59419607
MF
504 if (par[0] >= DBREAKA && par[0] < DBREAKA + MAX_NDBREAK) {
505 n = par[0] - DBREAKA;
d2132510 506 }
59419607
MF
507 if (par[0] >= DBREAKC && par[0] < DBREAKC + MAX_NDBREAK) {
508 n = par[0] - DBREAKC;
d2132510 509 }
91dc2b2d
MF
510 if (n >= dc->config->ndbreak) {
511 return XTENSA_OP_ILL;
512 }
513 return test_exceptions_sr(dc, arg, par);
f0a548b9
MF
514}
515
91dc2b2d
MF
516static uint32_t test_exceptions_ibreak(DisasContext *dc, const OpcodeArg arg[],
517 const uint32_t par[])
35b5c044 518{
59419607 519 unsigned n = par[0] - IBREAKA;
35b5c044 520
91dc2b2d
MF
521 if (n >= dc->config->nibreak) {
522 return XTENSA_OP_ILL;
523 }
524 return test_exceptions_sr(dc, arg, par);
35b5c044
MF
525}
526
91dc2b2d
MF
527static uint32_t test_exceptions_hpi(DisasContext *dc, const OpcodeArg arg[],
528 const uint32_t par[])
b994e91b 529{
59419607 530 unsigned n = MAX_NLEVEL + 1;
59a71f75 531
59419607
MF
532 if (par[0] >= EXCSAVE1 && par[0] < EXCSAVE1 + MAX_NLEVEL) {
533 n = par[0] - EXCSAVE1 + 1;
b994e91b 534 }
59419607
MF
535 if (par[0] >= EPC1 && par[0] < EPC1 + MAX_NLEVEL) {
536 n = par[0] - EPC1 + 1;
b8132eff 537 }
59419607
MF
538 if (par[0] >= EPS2 && par[0] < EPS2 + MAX_NLEVEL - 1) {
539 n = par[0] - EPS2 + 2;
dd519cbe 540 }
91dc2b2d
MF
541 if (n > dc->config->nlevel) {
542 return XTENSA_OP_ILL;
543 }
544 return test_exceptions_sr(dc, arg, par);
dd519cbe
MF
545}
546
5b4e481b
MF
547static void gen_load_store_alignment(DisasContext *dc, int shift,
548 TCGv_i32 addr, bool no_hw_alignment)
549{
550 if (!option_enabled(dc, XTENSA_OPTION_UNALIGNED_EXCEPTION)) {
551 tcg_gen_andi_i32(addr, addr, ~0 << shift);
552 } else if (option_enabled(dc, XTENSA_OPTION_HW_ALIGNMENT) &&
553 no_hw_alignment) {
42a268c2 554 TCGLabel *label = gen_new_label();
5b4e481b
MF
555 TCGv_i32 tmp = tcg_temp_new_i32();
556 tcg_gen_andi_i32(tmp, addr, ~(~0 << shift));
557 tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 0, label);
558 gen_exception_cause_vaddr(dc, LOAD_STORE_ALIGNMENT_CAUSE, addr);
559 gen_set_label(label);
560 tcg_temp_free(tmp);
561 }
562}
563
ba7651fb 564#ifndef CONFIG_USER_ONLY
b994e91b
MF
565static void gen_waiti(DisasContext *dc, uint32_t imm4)
566{
3cc18eec 567 TCGv_i32 pc = tcg_const_i32(dc->base.pc_next);
b994e91b 568 TCGv_i32 intlevel = tcg_const_i32(imm4);
d2132510 569
3cc18eec 570 if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
d2132510
MF
571 gen_io_start();
572 }
f492b82d 573 gen_helper_waiti(cpu_env, pc, intlevel);
b994e91b
MF
574 tcg_temp_free(pc);
575 tcg_temp_free(intlevel);
576}
ba7651fb 577#endif
b994e91b 578
6416d16f 579static bool gen_window_check(DisasContext *dc, uint32_t mask)
772177c1 580{
6416d16f
MF
581 unsigned r = 31 - clz32(mask);
582
583 if (r / 4 > dc->window) {
2db59a76 584 TCGv_i32 pc = tcg_const_i32(dc->pc);
6416d16f 585 TCGv_i32 w = tcg_const_i32(r / 4);
908c67fc 586
2db59a76 587 gen_helper_window_check(cpu_env, pc, w);
3cc18eec 588 dc->base.is_jmp = DISAS_NORETURN;
97e89ee9 589 return false;
772177c1 590 }
97e89ee9 591 return true;
772177c1
MF
592}
593
6825b6c3
MF
594static TCGv_i32 gen_mac16_m(TCGv_i32 v, bool hi, bool is_unsigned)
595{
596 TCGv_i32 m = tcg_temp_new_i32();
597
598 if (hi) {
599 (is_unsigned ? tcg_gen_shri_i32 : tcg_gen_sari_i32)(m, v, 16);
600 } else {
601 (is_unsigned ? tcg_gen_ext16u_i32 : tcg_gen_ext16s_i32)(m, v);
602 }
603 return m;
604}
605
b0b24bdc 606static void gen_zero_check(DisasContext *dc, const OpcodeArg arg[])
4a038955
MF
607{
608 TCGLabel *label = gen_new_label();
609
b0b24bdc 610 tcg_gen_brcondi_i32(TCG_COND_NE, arg[2].in, 0, label);
4a038955
MF
611 gen_exception_cause(dc, INTEGER_DIVIDE_BY_ZERO_CAUSE);
612 gen_set_label(label);
613}
614
33071f68 615static inline unsigned xtensa_op0_insn_len(DisasContext *dc, uint8_t op0)
01673a34 616{
33071f68 617 return xtensa_isa_length_from_chars(dc->config->isa, &op0);
01673a34
MF
618}
619
45b71a79
MF
620static int gen_postprocess(DisasContext *dc, int slot)
621{
622 uint32_t op_flags = dc->op_flags;
623
59419607 624#ifndef CONFIG_USER_ONLY
45b71a79 625 if (op_flags & XTENSA_OP_CHECK_INTERRUPTS) {
59419607
MF
626 if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
627 gen_io_start();
628 }
629 gen_helper_check_interrupts(cpu_env);
45b71a79 630 }
59419607 631#endif
8df3fd35
MF
632 if (op_flags & XTENSA_OP_SYNC_REGISTER_WINDOW) {
633 gen_helper_sync_windowbase(cpu_env);
634 }
45b71a79
MF
635 if (op_flags & XTENSA_OP_EXIT_TB_M1) {
636 slot = -1;
637 }
638 return slot;
639}
640
89bec9e9
MF
641struct opcode_arg_copy {
642 uint32_t resource;
643 void *temp;
644 OpcodeArg *arg;
645};
646
20e9fd0f
MF
647struct opcode_arg_info {
648 uint32_t resource;
649 int index;
650};
651
652struct slot_prop {
653 XtensaOpcodeOps *ops;
b0b24bdc 654 OpcodeArg arg[MAX_OPCODE_ARGS];
20e9fd0f
MF
655 struct opcode_arg_info in[MAX_OPCODE_ARGS];
656 struct opcode_arg_info out[MAX_OPCODE_ARGS];
657 unsigned n_in;
658 unsigned n_out;
659 uint32_t op_flags;
660};
661
662enum resource_type {
663 RES_REGFILE,
664 RES_STATE,
665 RES_MAX,
666};
667
668static uint32_t encode_resource(enum resource_type r, unsigned g, unsigned n)
669{
670 assert(r < RES_MAX && g < 256 && n < 65536);
671 return (r << 24) | (g << 16) | n;
672}
673
89bec9e9
MF
674static enum resource_type get_resource_type(uint32_t resource)
675{
676 return resource >> 24;
677}
678
20e9fd0f
MF
679/*
680 * a depends on b if b must be executed before a,
681 * because a's side effects will destroy b's inputs.
682 */
683static bool op_depends_on(const struct slot_prop *a,
684 const struct slot_prop *b)
685{
686 unsigned i = 0;
687 unsigned j = 0;
688
689 if (a->op_flags & XTENSA_OP_CONTROL_FLOW) {
690 return true;
691 }
068e538a
MF
692 if ((a->op_flags & XTENSA_OP_LOAD_STORE) <
693 (b->op_flags & XTENSA_OP_LOAD_STORE)) {
694 return true;
695 }
20e9fd0f
MF
696 while (i < a->n_out && j < b->n_in) {
697 if (a->out[i].resource < b->in[j].resource) {
698 ++i;
699 } else if (a->out[i].resource > b->in[j].resource) {
700 ++j;
701 } else {
702 return true;
703 }
704 }
705 return false;
706}
707
89bec9e9
MF
708/*
709 * Try to break a dependency on b, append temporary register copy records
710 * to the end of copy and update n_copy in case of success.
711 * This is not always possible: e.g. control flow must always be the last,
712 * load/store must be first and state dependencies are not supported yet.
713 */
714static bool break_dependency(struct slot_prop *a,
715 struct slot_prop *b,
716 struct opcode_arg_copy *copy,
717 unsigned *n_copy)
718{
719 unsigned i = 0;
720 unsigned j = 0;
721 unsigned n = *n_copy;
722 bool rv = false;
723
724 if (a->op_flags & XTENSA_OP_CONTROL_FLOW) {
725 return false;
726 }
068e538a
MF
727 if ((a->op_flags & XTENSA_OP_LOAD_STORE) <
728 (b->op_flags & XTENSA_OP_LOAD_STORE)) {
729 return false;
730 }
89bec9e9
MF
731 while (i < a->n_out && j < b->n_in) {
732 if (a->out[i].resource < b->in[j].resource) {
733 ++i;
734 } else if (a->out[i].resource > b->in[j].resource) {
735 ++j;
736 } else {
737 int index = b->in[j].index;
738
739 if (get_resource_type(a->out[i].resource) != RES_REGFILE ||
740 index < 0) {
741 return false;
742 }
743 copy[n].resource = b->in[j].resource;
744 copy[n].arg = b->arg + index;
745 ++n;
89bec9e9
MF
746 ++j;
747 rv = true;
748 }
749 }
750 *n_copy = n;
751 return rv;
752}
753
20e9fd0f
MF
754/*
755 * Calculate evaluation order for slot opcodes.
756 * Build opcode order graph and output its nodes in topological sort order.
757 * An edge a -> b in the graph means that opcode a must be followed by
758 * opcode b.
759 */
760static bool tsort(struct slot_prop *slot,
761 struct slot_prop *sorted[],
89bec9e9
MF
762 unsigned n,
763 struct opcode_arg_copy *copy,
764 unsigned *n_copy)
20e9fd0f
MF
765{
766 struct tsnode {
767 unsigned n_in_edge;
768 unsigned n_out_edge;
769 unsigned out_edge[MAX_INSN_SLOTS];
770 } node[MAX_INSN_SLOTS];
771
772 unsigned in[MAX_INSN_SLOTS];
773 unsigned i, j;
774 unsigned n_in = 0;
775 unsigned n_out = 0;
776 unsigned n_edge = 0;
89bec9e9
MF
777 unsigned in_idx = 0;
778 unsigned node_idx = 0;
20e9fd0f
MF
779
780 for (i = 0; i < n; ++i) {
781 node[i].n_in_edge = 0;
782 node[i].n_out_edge = 0;
783 }
784
785 for (i = 0; i < n; ++i) {
786 unsigned n_out_edge = 0;
787
788 for (j = 0; j < n; ++j) {
789 if (i != j && op_depends_on(slot + j, slot + i)) {
790 node[i].out_edge[n_out_edge] = j;
791 ++node[j].n_in_edge;
792 ++n_out_edge;
793 ++n_edge;
794 }
795 }
796 node[i].n_out_edge = n_out_edge;
797 }
798
799 for (i = 0; i < n; ++i) {
800 if (!node[i].n_in_edge) {
801 in[n_in] = i;
802 ++n_in;
803 }
804 }
805
89bec9e9
MF
806again:
807 for (; in_idx < n_in; ++in_idx) {
20e9fd0f
MF
808 i = in[in_idx];
809 sorted[n_out] = slot + i;
810 ++n_out;
811 for (j = 0; j < node[i].n_out_edge; ++j) {
812 --n_edge;
813 if (--node[node[i].out_edge[j]].n_in_edge == 0) {
814 in[n_in] = node[i].out_edge[j];
815 ++n_in;
816 }
817 }
818 }
89bec9e9
MF
819 if (n_edge) {
820 for (; node_idx < n; ++node_idx) {
821 struct tsnode *cnode = node + node_idx;
822
823 if (cnode->n_in_edge) {
824 for (j = 0; j < cnode->n_out_edge; ++j) {
825 unsigned k = cnode->out_edge[j];
826
827 if (break_dependency(slot + k, slot + node_idx,
828 copy, n_copy) &&
829 --node[k].n_in_edge == 0) {
830 in[n_in] = k;
831 ++n_in;
832 --n_edge;
833 cnode->out_edge[j] =
834 cnode->out_edge[cnode->n_out_edge - 1];
835 --cnode->n_out_edge;
836 goto again;
837 }
838 }
839 }
840 }
841 }
20e9fd0f
MF
842 return n_edge == 0;
843}
844
845static void opcode_add_resource(struct slot_prop *op,
846 uint32_t resource, char direction,
847 int index)
848{
849 switch (direction) {
850 case 'm':
851 case 'i':
852 assert(op->n_in < ARRAY_SIZE(op->in));
853 op->in[op->n_in].resource = resource;
854 op->in[op->n_in].index = index;
855 ++op->n_in;
856 /* fall through */
857 case 'o':
858 if (direction == 'm' || direction == 'o') {
859 assert(op->n_out < ARRAY_SIZE(op->out));
860 op->out[op->n_out].resource = resource;
861 op->out[op->n_out].index = index;
862 ++op->n_out;
863 }
864 break;
865 default:
866 g_assert_not_reached();
867 }
868}
869
870static int resource_compare(const void *a, const void *b)
871{
872 const struct opcode_arg_info *pa = a;
873 const struct opcode_arg_info *pb = b;
874
875 return pa->resource < pb->resource ?
876 -1 : (pa->resource > pb->resource ? 1 : 0);
877}
878
89bec9e9
MF
879static int arg_copy_compare(const void *a, const void *b)
880{
881 const struct opcode_arg_copy *pa = a;
882 const struct opcode_arg_copy *pb = b;
883
884 return pa->resource < pb->resource ?
885 -1 : (pa->resource > pb->resource ? 1 : 0);
886}
887
0c4fabea 888static void disas_xtensa_insn(CPUXtensaState *env, DisasContext *dc)
dedc5eae 889{
33071f68 890 xtensa_isa isa = dc->config->isa;
4d246bb4 891 unsigned char b[MAX_INSN_LENGTH] = {translator_ldub(env, dc->pc)};
33071f68
MF
892 unsigned len = xtensa_op0_insn_len(dc, b[0]);
893 xtensa_format fmt;
847a6473 894 int slot, slots;
33071f68 895 unsigned i;
09460970 896 uint32_t op_flags = 0;
20e9fd0f
MF
897 struct slot_prop slot_prop[MAX_INSN_SLOTS];
898 struct slot_prop *ordered[MAX_INSN_SLOTS];
89bec9e9
MF
899 struct opcode_arg_copy arg_copy[MAX_INSN_SLOTS * MAX_OPCODE_ARGS];
900 unsigned n_arg_copy = 0;
15477819 901 uint32_t debug_cause = 0;
6416d16f 902 uint32_t windowed_register = 0;
582fef0f 903 uint32_t coprocessor = 0;
01673a34 904
33071f68
MF
905 if (len == XTENSA_UNDEFINED) {
906 qemu_log_mask(LOG_GUEST_ERROR,
907 "unknown instruction length (pc = %08x)\n",
908 dc->pc);
909 gen_exception_cause(dc, ILLEGAL_INSTRUCTION_CAUSE);
910 return;
dedc5eae 911 }
dedc5eae 912
3cc18eec 913 dc->base.pc_next = dc->pc + len;
33071f68 914 for (i = 1; i < len; ++i) {
4d246bb4 915 b[i] = translator_ldub(env, dc->pc + i);
33071f68
MF
916 }
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",
922 dc->pc);
923 gen_exception_cause(dc, ILLEGAL_INSTRUCTION_CAUSE);
924 return;
925 }
926 slots = xtensa_format_num_slots(isa, fmt);
927 for (slot = 0; slot < slots; ++slot) {
928 xtensa_opcode opc;
847a6473 929 int opnd, vopnd, opnds;
b0b24bdc 930 OpcodeArg *arg = slot_prop[slot].arg;
33071f68
MF
931 XtensaOpcodeOps *ops;
932
33071f68
MF
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",
938 slot, dc->pc);
939 gen_exception_cause(dc, ILLEGAL_INSTRUCTION_CAUSE);
940 return;
dedc5eae 941 }
33071f68 942 opnds = xtensa_opcode_num_operands(isa, opc);
bd57fb91 943
33071f68 944 for (opnd = vopnd = 0; opnd < opnds; ++opnd) {
b0b24bdc 945 void **register_file = NULL;
ed07f685 946 xtensa_regfile rf;
fe7869d6 947
b0b24bdc 948 if (xtensa_operand_is_register(isa, opc, opnd)) {
ed07f685 949 rf = xtensa_operand_regfile(isa, opc, opnd);
b0b24bdc
MF
950 register_file = dc->config->regfile[rf];
951
952 if (rf == dc->config->a_regfile) {
953 uint32_t v;
954
955 xtensa_operand_get_field(isa, opc, opnd, fmt, slot,
956 dc->slotbuf, &v);
957 xtensa_operand_decode(isa, opc, opnd, &v);
958 windowed_register |= 1u << v;
959 }
fe7869d6 960 }
33071f68
MF
961 if (xtensa_operand_is_visible(isa, opc, opnd)) {
962 uint32_t v;
dedc5eae 963
33071f68
MF
964 xtensa_operand_get_field(isa, opc, opnd, fmt, slot,
965 dc->slotbuf, &v);
966 xtensa_operand_decode(isa, opc, opnd, &v);
b0b24bdc 967 arg[vopnd].raw_imm = v;
33071f68
MF
968 if (xtensa_operand_is_PCrelative(isa, opc, opnd)) {
969 xtensa_operand_undo_reloc(isa, opc, opnd, &v, dc->pc);
bd57fb91 970 }
b0b24bdc
MF
971 arg[vopnd].imm = v;
972 if (register_file) {
973 arg[vopnd].in = register_file[v];
974 arg[vopnd].out = register_file[v];
ed07f685
MF
975 arg[vopnd].num_bits = xtensa_regfile_num_bits(isa, rf);
976 } else {
977 arg[vopnd].num_bits = 32;
b0b24bdc 978 }
33071f68 979 ++vopnd;
bd57fb91
MF
980 }
981 }
33071f68 982 ops = dc->config->opcode_ops[opc];
09460970
MF
983 slot_prop[slot].ops = ops;
984
33071f68 985 if (ops) {
09460970 986 op_flags |= ops->op_flags;
91dc2b2d
MF
987 if (ops->test_exceptions) {
988 op_flags |= ops->test_exceptions(dc, arg, ops->par);
989 }
33071f68 990 } else {
09460970 991 qemu_log_mask(LOG_UNIMP,
33071f68
MF
992 "unimplemented opcode '%s' in slot %d (pc = %08x)\n",
993 xtensa_opcode_name(isa, opc), slot, dc->pc);
09460970
MF
994 op_flags |= XTENSA_OP_ILL;
995 }
91dc2b2d 996 if (op_flags & XTENSA_OP_ILL) {
33071f68
MF
997 gen_exception_cause(dc, ILLEGAL_INSTRUCTION_CAUSE);
998 return;
67882fd1 999 }
91dc2b2d 1000 if (op_flags & XTENSA_OP_DEBUG_BREAK) {
15477819
MF
1001 debug_cause |= ops->par[0];
1002 }
6416d16f
MF
1003 if (ops->test_overflow) {
1004 windowed_register |= ops->test_overflow(dc, arg, ops->par);
1005 }
582fef0f 1006 coprocessor |= ops->coprocessor;
20e9fd0f
MF
1007
1008 if (slots > 1) {
1009 slot_prop[slot].n_in = 0;
1010 slot_prop[slot].n_out = 0;
068e538a 1011 slot_prop[slot].op_flags = ops->op_flags & XTENSA_OP_LOAD_STORE;
20e9fd0f
MF
1012
1013 opnds = xtensa_opcode_num_operands(isa, opc);
1014
1015 for (opnd = vopnd = 0; opnd < opnds; ++opnd) {
1016 bool visible = xtensa_operand_is_visible(isa, opc, opnd);
1017
1018 if (xtensa_operand_is_register(isa, opc, opnd)) {
1019 xtensa_regfile rf = xtensa_operand_regfile(isa, opc, opnd);
1020 uint32_t v = 0;
1021
1022 xtensa_operand_get_field(isa, opc, opnd, fmt, slot,
1023 dc->slotbuf, &v);
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);
1029 }
1030 if (visible) {
1031 ++vopnd;
1032 }
1033 }
1034
1035 opnds = xtensa_opcode_num_stateOperands(isa, opc);
1036
1037 for (opnd = 0; opnd < opnds; ++opnd) {
1038 xtensa_state state = xtensa_stateOperand_state(isa, opc, opnd);
1039
1040 opcode_add_resource(slot_prop + slot,
1041 encode_resource(RES_STATE, 0, state),
1042 xtensa_stateOperand_inout(isa, opc, opnd),
1043 -1);
1044 }
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;
1050 }
1051
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);
1056 }
1057 }
1058
1059 if (slots > 1) {
89bec9e9 1060 if (!tsort(slot_prop, ordered, slots, arg_copy, &n_arg_copy)) {
20e9fd0f
MF
1061 qemu_log_mask(LOG_UNIMP,
1062 "Circular resource dependencies (pc = %08x)\n",
1063 dc->pc);
1064 gen_exception_cause(dc, ILLEGAL_INSTRUCTION_CAUSE);
1065 return;
1066 }
1067 } else {
1068 ordered[0] = slot_prop + 0;
dedc5eae 1069 }
09460970 1070
21a2dad5
MF
1071 if ((op_flags & XTENSA_OP_PRIVILEGED) &&
1072 !gen_check_privilege(dc)) {
1073 return;
1074 }
1075
4c6ec5f3
MF
1076 if (op_flags & XTENSA_OP_SYSCALL) {
1077 gen_exception_cause(dc, SYSCALL_CAUSE);
1078 return;
1079 }
1080
15477819
MF
1081 if ((op_flags & XTENSA_OP_DEBUG_BREAK) && dc->debug) {
1082 gen_debug_exception(dc, debug_cause);
1083 return;
1084 }
1085
6416d16f
MF
1086 if (windowed_register && !gen_window_check(dc, windowed_register)) {
1087 return;
1088 }
1089
f473019a
MF
1090 if (op_flags & XTENSA_OP_UNDERFLOW) {
1091 TCGv_i32 tmp = tcg_const_i32(dc->pc);
1092
1093 gen_helper_test_underflow_retw(cpu_env, tmp);
1094 tcg_temp_free(tmp);
1095 }
1096
90d6494d
MF
1097 if (op_flags & XTENSA_OP_ALLOCA) {
1098 TCGv_i32 tmp = tcg_const_i32(dc->pc);
1099
1100 gen_helper_movsp(cpu_env, tmp);
1101 tcg_temp_free(tmp);
1102 }
1103
582fef0f
MF
1104 if (coprocessor && !gen_check_cpenable(dc, coprocessor)) {
1105 return;
1106 }
1107
89bec9e9
MF
1108 if (n_arg_copy) {
1109 uint32_t resource;
1110 void *temp;
1111 unsigned j;
1112
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;
ed07f685
MF
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);
1123 } else {
1124 g_assert_not_reached();
1125 }
89bec9e9
MF
1126 arg_copy[i].temp = temp;
1127
1128 if (i != j) {
1129 arg_copy[j] = arg_copy[i];
1130 }
1131 ++j;
1132 }
1133 arg_copy[i].arg->in = temp;
1134 }
1135 n_arg_copy = j;
1136 }
1137
4a038955
MF
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);
1142 }
1143 }
1144 }
1145
45b71a79
MF
1146 dc->op_flags = op_flags;
1147
09460970 1148 for (slot = 0; slot < slots; ++slot) {
20e9fd0f
MF
1149 struct slot_prop *pslot = ordered[slot];
1150 XtensaOpcodeOps *ops = pslot->ops;
09460970 1151
20e9fd0f 1152 ops->translate(dc, pslot->arg, ops->par);
09460970 1153 }
226444a8 1154
89bec9e9 1155 for (i = 0; i < n_arg_copy; ++i) {
ed07f685
MF
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);
1160 } else {
1161 g_assert_not_reached();
1162 }
89bec9e9
MF
1163 }
1164
226444a8 1165 if (dc->base.is_jmp == DISAS_NEXT) {
45b71a79
MF
1166 gen_postprocess(dc, 0);
1167 dc->op_flags = 0;
226444a8
MF
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);
bf525107
MF
1171 } else if (op_flags & XTENSA_OP_EXIT_TB_0) {
1172 gen_jumpi_check_loop_end(dc, 0);
45b71a79
MF
1173 } else {
1174 gen_check_loop_end(dc, 0);
226444a8
MF
1175 }
1176 }
3cc18eec 1177 dc->pc = dc->base.pc_next;
dedc5eae
MF
1178}
1179
01673a34
MF
1180static inline unsigned xtensa_insn_len(CPUXtensaState *env, DisasContext *dc)
1181{
1182 uint8_t b0 = cpu_ldub_code(env, dc->pc);
33071f68 1183 return xtensa_op0_insn_len(dc, b0);
01673a34
MF
1184}
1185
97129ac8 1186static void gen_ibreak_check(CPUXtensaState *env, DisasContext *dc)
e61dc8f7
MF
1187{
1188 unsigned i;
1189
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);
1194 break;
1195 }
1196 }
1197}
1198
9c509ff9
RH
1199static void xtensa_tr_init_disas_context(DisasContextBase *dcbase,
1200 CPUState *cpu)
dedc5eae 1201{
9c509ff9
RH
1202 DisasContext *dc = container_of(dcbase, DisasContext, base);
1203 CPUXtensaState *env = cpu->env_ptr;
1204 uint32_t tb_flags = dc->base.tb->flags;
dedc5eae 1205
1d38a701 1206 dc->config = env->config;
9c509ff9
RH
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;
5d630cef
MF
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);
9c509ff9
RH
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) >>
ef04a846 1217 XTENSA_TBFLAG_CPENABLE_SHIFT;
9c509ff9 1218 dc->window = ((tb_flags & XTENSA_TBFLAG_WINDOW_MASK) >>
2db59a76 1219 XTENSA_TBFLAG_WINDOW_SHIFT);
09460970 1220 dc->cwoe = tb_flags & XTENSA_TBFLAG_CWOE;
6416d16f
MF
1221 dc->callinc = ((tb_flags & XTENSA_TBFLAG_CALLINC_MASK) >>
1222 XTENSA_TBFLAG_CALLINC_SHIFT);
1d38a701 1223 init_sar_tracker(dc);
9c509ff9
RH
1224}
1225
1226static void xtensa_tr_tb_start(DisasContextBase *dcbase, CPUState *cpu)
1227{
1228 DisasContext *dc = container_of(dcbase, DisasContext, base);
1229
1d38a701
RH
1230 if (dc->icount) {
1231 dc->next_icount = tcg_temp_local_new_i32();
35b5c044 1232 }
9c509ff9 1233}
3580ecad 1234
9c509ff9
RH
1235static void xtensa_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu)
1236{
1237 tcg_gen_insn_start(dcbase->pc_next);
1238}
1239
1240static bool xtensa_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu,
1241 const CPUBreakpoint *bp)
1242{
1243 DisasContext *dc = container_of(dcbase, DisasContext, base);
1244
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;
1253 return true;
1254}
1255
1256static void xtensa_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
1257{
1258 DisasContext *dc = container_of(dcbase, DisasContext, base);
1259 CPUXtensaState *env = cpu->env_ptr;
1260 target_ulong page_start;
dedc5eae 1261
9c509ff9
RH
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)) {
1d38a701
RH
1266 gen_exception(dc, EXCP_YIELD);
1267 dc->base.is_jmp = DISAS_NORETURN;
9c509ff9 1268 return;
d2132510 1269 }
9c509ff9 1270 if (dc->base.tb->flags & XTENSA_TBFLAG_EXCEPTION) {
1d38a701
RH
1271 gen_exception(dc, EXCP_DEBUG);
1272 dc->base.is_jmp = DISAS_NORETURN;
9c509ff9 1273 return;
40643d7c
MF
1274 }
1275
9c509ff9
RH
1276 if (dc->icount) {
1277 TCGLabel *label = gen_new_label();
dedc5eae 1278
9c509ff9
RH
1279 tcg_gen_addi_i32(dc->next_icount, cpu_SR[ICOUNT], 1);
1280 tcg_gen_brcondi_i32(TCG_COND_NE, dc->next_icount, 0, label);
1281 tcg_gen_mov_i32(dc->next_icount, cpu_SR[ICOUNT]);
1282 if (dc->debug) {
1283 gen_debug_exception(dc, DEBUGCAUSE_IC);
b933066a 1284 }
9c509ff9
RH
1285 gen_set_label(label);
1286 }
b933066a 1287
9c509ff9
RH
1288 if (dc->debug) {
1289 gen_ibreak_check(env, dc);
1290 }
b994e91b 1291
9c509ff9 1292 disas_xtensa_insn(env, dc);
35b5c044 1293
9c509ff9
RH
1294 if (dc->icount) {
1295 tcg_gen_mov_i32(cpu_SR[ICOUNT], dc->next_icount);
1296 }
35b5c044 1297
9c509ff9
RH
1298 /* End the TB if the next insn will cross into the next page. */
1299 page_start = dc->base.pc_first & TARGET_PAGE_MASK;
1300 if (dc->base.is_jmp == DISAS_NEXT &&
1301 (dc->pc - page_start >= TARGET_PAGE_SIZE ||
1302 dc->pc - page_start + xtensa_insn_len(env, dc) > TARGET_PAGE_SIZE)) {
1303 dc->base.is_jmp = DISAS_TOO_MANY;
1304 }
1305}
1306
1307static void xtensa_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)
1308{
1309 DisasContext *dc = container_of(dcbase, DisasContext, base);
e61dc8f7 1310
1d38a701 1311 reset_sar_tracker(dc);
9c509ff9
RH
1312 if (dc->icount) {
1313 tcg_temp_free(dc->next_icount);
b994e91b
MF
1314 }
1315
9c509ff9
RH
1316 switch (dc->base.is_jmp) {
1317 case DISAS_NORETURN:
1318 break;
1319 case DISAS_TOO_MANY:
1320 if (dc->base.singlestep_enabled) {
1321 tcg_gen_movi_i32(cpu_pc, dc->pc);
1322 gen_exception(dc, EXCP_DEBUG);
1323 } else {
1324 gen_jumpi(dc, dc->pc, 0);
1325 }
1326 break;
1327 default:
1328 g_assert_not_reached();
ca529f8e 1329 }
9c509ff9
RH
1330}
1331
1332static void xtensa_tr_disas_log(const DisasContextBase *dcbase, CPUState *cpu)
1333{
1334 qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first));
1335 log_target_disas(cpu, dcbase->pc_first, dcbase->tb->size);
1336}
1337
1338static const TranslatorOps xtensa_translator_ops = {
1339 .init_disas_context = xtensa_tr_init_disas_context,
1340 .tb_start = xtensa_tr_tb_start,
1341 .insn_start = xtensa_tr_insn_start,
1342 .breakpoint_check = xtensa_tr_breakpoint_check,
1343 .translate_insn = xtensa_tr_translate_insn,
1344 .tb_stop = xtensa_tr_tb_stop,
1345 .disas_log = xtensa_tr_disas_log,
1346};
1347
8b86d6d2 1348void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb, int max_insns)
9c509ff9
RH
1349{
1350 DisasContext dc = {};
8b86d6d2 1351 translator_loop(&xtensa_translator_ops, &dc.base, cpu, tb, max_insns);
2328826b
MF
1352}
1353
90c84c56 1354void xtensa_cpu_dump_state(CPUState *cs, FILE *f, int flags)
2328826b 1355{
878096ee
AF
1356 XtensaCPU *cpu = XTENSA_CPU(cs);
1357 CPUXtensaState *env = &cpu->env;
59419607 1358 xtensa_isa isa = env->config->isa;
2af3da91
MF
1359 int i, j;
1360
90c84c56 1361 qemu_fprintf(f, "PC=%08x\n\n", env->pc);
2af3da91 1362
59419607
MF
1363 for (i = j = 0; i < xtensa_isa_num_sysregs(isa); ++i) {
1364 const uint32_t *reg =
1365 xtensa_sysreg_is_user(isa, i) ? env->uregs : env->sregs;
1366 int regno = xtensa_sysreg_number(isa, i);
2af3da91 1367
59419607
MF
1368 if (regno >= 0) {
1369 qemu_fprintf(f, "%12s=%08x%c",
1370 xtensa_sysreg_name(isa, i),
1371 reg[regno],
90c84c56 1372 (j++ % 4) == 3 ? '\n' : ' ');
2af3da91
MF
1373 }
1374 }
2328826b 1375
90c84c56 1376 qemu_fprintf(f, (j % 4) == 0 ? "\n" : "\n\n");
2328826b
MF
1377
1378 for (i = 0; i < 16; ++i) {
90c84c56
MA
1379 qemu_fprintf(f, " A%02d=%08x%c",
1380 i, env->regs[i], (i % 4) == 3 ? '\n' : ' ');
2328826b 1381 }
553e44f9 1382
b55b1afd 1383 xtensa_sync_phys_from_window(env);
90c84c56 1384 qemu_fprintf(f, "\n");
553e44f9
MF
1385
1386 for (i = 0; i < env->config->nareg; ++i) {
90c84c56 1387 qemu_fprintf(f, "AR%02d=%08x ", i, env->phys_regs[i]);
b9317a2a
MF
1388 if (i % 4 == 3) {
1389 bool ws = (env->sregs[WINDOW_START] & (1 << (i / 4))) != 0;
1390 bool cw = env->sregs[WINDOW_BASE] == i / 4;
1391
90c84c56 1392 qemu_fprintf(f, "%c%c\n", ws ? '<' : ' ', cw ? '=' : ' ');
b9317a2a 1393 }
553e44f9 1394 }
dd519cbe 1395
f29c0b17
RH
1396 if ((flags & CPU_DUMP_FPU) &&
1397 xtensa_option_enabled(env->config, XTENSA_OPTION_FP_COPROCESSOR)) {
90c84c56 1398 qemu_fprintf(f, "\n");
dd519cbe
MF
1399
1400 for (i = 0; i < 16; ++i) {
90c84c56
MA
1401 qemu_fprintf(f, "F%02d=%08x (%+10.8e)%c", i,
1402 float32_val(env->fregs[i].f32[FP_F32_LOW]),
1403 *(float *)(env->fregs[i].f32 + FP_F32_LOW),
1404 (i % 2) == 1 ? '\n' : ' ');
dd519cbe
MF
1405 }
1406 }
2328826b
MF
1407}
1408
bad729e2
RH
1409void restore_state_to_opc(CPUXtensaState *env, TranslationBlock *tb,
1410 target_ulong *data)
2328826b 1411{
bad729e2 1412 env->pc = data[0];
2328826b 1413}
168c12b0 1414
b0b24bdc 1415static void translate_abs(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1416 const uint32_t par[])
1417{
e1c47865 1418 tcg_gen_abs_i32(arg[0].out, arg[1].in);
168c12b0
MF
1419}
1420
b0b24bdc 1421static void translate_add(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1422 const uint32_t par[])
1423{
b0b24bdc 1424 tcg_gen_add_i32(arg[0].out, arg[1].in, arg[2].in);
168c12b0
MF
1425}
1426
b0b24bdc 1427static void translate_addi(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1428 const uint32_t par[])
1429{
b0b24bdc 1430 tcg_gen_addi_i32(arg[0].out, arg[1].in, arg[2].imm);
168c12b0
MF
1431}
1432
b0b24bdc 1433static void translate_addx(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1434 const uint32_t par[])
1435{
6416d16f 1436 TCGv_i32 tmp = tcg_temp_new_i32();
b0b24bdc
MF
1437 tcg_gen_shli_i32(tmp, arg[1].in, par[0]);
1438 tcg_gen_add_i32(arg[0].out, tmp, arg[2].in);
6416d16f 1439 tcg_temp_free(tmp);
168c12b0
MF
1440}
1441
b0b24bdc 1442static void translate_all(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1443 const uint32_t par[])
1444{
1445 uint32_t shift = par[1];
b0b24bdc 1446 TCGv_i32 mask = tcg_const_i32(((1 << shift) - 1) << arg[1].imm);
168c12b0
MF
1447 TCGv_i32 tmp = tcg_temp_new_i32();
1448
575e962a 1449 tcg_gen_and_i32(tmp, arg[1].in, mask);
168c12b0 1450 if (par[0]) {
b0b24bdc 1451 tcg_gen_addi_i32(tmp, tmp, 1 << arg[1].imm);
168c12b0
MF
1452 } else {
1453 tcg_gen_add_i32(tmp, tmp, mask);
1454 }
b0b24bdc 1455 tcg_gen_shri_i32(tmp, tmp, arg[1].imm + shift);
575e962a 1456 tcg_gen_deposit_i32(arg[0].out, arg[0].out,
b0b24bdc 1457 tmp, arg[0].imm, 1);
168c12b0
MF
1458 tcg_temp_free(mask);
1459 tcg_temp_free(tmp);
1460}
1461
b0b24bdc 1462static void translate_and(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1463 const uint32_t par[])
1464{
b0b24bdc 1465 tcg_gen_and_i32(arg[0].out, arg[1].in, arg[2].in);
168c12b0
MF
1466}
1467
b0b24bdc 1468static void translate_ball(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1469 const uint32_t par[])
1470{
6416d16f 1471 TCGv_i32 tmp = tcg_temp_new_i32();
b0b24bdc
MF
1472 tcg_gen_and_i32(tmp, arg[0].in, arg[1].in);
1473 gen_brcond(dc, par[0], tmp, arg[1].in, arg[2].imm);
6416d16f 1474 tcg_temp_free(tmp);
168c12b0
MF
1475}
1476
b0b24bdc 1477static void translate_bany(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1478 const uint32_t par[])
1479{
6416d16f 1480 TCGv_i32 tmp = tcg_temp_new_i32();
b0b24bdc
MF
1481 tcg_gen_and_i32(tmp, arg[0].in, arg[1].in);
1482 gen_brcondi(dc, par[0], tmp, 0, arg[2].imm);
6416d16f 1483 tcg_temp_free(tmp);
168c12b0
MF
1484}
1485
b0b24bdc 1486static void translate_b(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1487 const uint32_t par[])
1488{
b0b24bdc 1489 gen_brcond(dc, par[0], arg[0].in, arg[1].in, arg[2].imm);
168c12b0
MF
1490}
1491
b0b24bdc 1492static void translate_bb(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1493 const uint32_t par[])
1494{
168c12b0 1495#ifdef TARGET_WORDS_BIGENDIAN
6416d16f 1496 TCGv_i32 bit = tcg_const_i32(0x80000000u);
168c12b0 1497#else
6416d16f 1498 TCGv_i32 bit = tcg_const_i32(0x00000001u);
168c12b0 1499#endif
6416d16f 1500 TCGv_i32 tmp = tcg_temp_new_i32();
b0b24bdc 1501 tcg_gen_andi_i32(tmp, arg[1].in, 0x1f);
168c12b0 1502#ifdef TARGET_WORDS_BIGENDIAN
6416d16f 1503 tcg_gen_shr_i32(bit, bit, tmp);
168c12b0 1504#else
6416d16f 1505 tcg_gen_shl_i32(bit, bit, tmp);
168c12b0 1506#endif
b0b24bdc
MF
1507 tcg_gen_and_i32(tmp, arg[0].in, bit);
1508 gen_brcondi(dc, par[0], tmp, 0, arg[2].imm);
6416d16f
MF
1509 tcg_temp_free(tmp);
1510 tcg_temp_free(bit);
168c12b0
MF
1511}
1512
b0b24bdc 1513static void translate_bbi(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1514 const uint32_t par[])
1515{
6416d16f 1516 TCGv_i32 tmp = tcg_temp_new_i32();
168c12b0 1517#ifdef TARGET_WORDS_BIGENDIAN
b0b24bdc 1518 tcg_gen_andi_i32(tmp, arg[0].in, 0x80000000u >> arg[1].imm);
168c12b0 1519#else
b0b24bdc 1520 tcg_gen_andi_i32(tmp, arg[0].in, 0x00000001u << arg[1].imm);
168c12b0 1521#endif
b0b24bdc 1522 gen_brcondi(dc, par[0], tmp, 0, arg[2].imm);
6416d16f 1523 tcg_temp_free(tmp);
168c12b0
MF
1524}
1525
b0b24bdc 1526static void translate_bi(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1527 const uint32_t par[])
1528{
b0b24bdc 1529 gen_brcondi(dc, par[0], arg[0].in, arg[1].imm, arg[2].imm);
168c12b0
MF
1530}
1531
b0b24bdc 1532static void translate_bz(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1533 const uint32_t par[])
1534{
b0b24bdc 1535 gen_brcondi(dc, par[0], arg[0].in, 0, arg[1].imm);
168c12b0
MF
1536}
1537
1538enum {
1539 BOOLEAN_AND,
1540 BOOLEAN_ANDC,
1541 BOOLEAN_OR,
1542 BOOLEAN_ORC,
1543 BOOLEAN_XOR,
1544};
1545
b0b24bdc 1546static void translate_boolean(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1547 const uint32_t par[])
1548{
1549 static void (* const op[])(TCGv_i32, TCGv_i32, TCGv_i32) = {
1550 [BOOLEAN_AND] = tcg_gen_and_i32,
1551 [BOOLEAN_ANDC] = tcg_gen_andc_i32,
1552 [BOOLEAN_OR] = tcg_gen_or_i32,
1553 [BOOLEAN_ORC] = tcg_gen_orc_i32,
1554 [BOOLEAN_XOR] = tcg_gen_xor_i32,
1555 };
1556
1557 TCGv_i32 tmp1 = tcg_temp_new_i32();
1558 TCGv_i32 tmp2 = tcg_temp_new_i32();
1559
575e962a
MF
1560 tcg_gen_shri_i32(tmp1, arg[1].in, arg[1].imm);
1561 tcg_gen_shri_i32(tmp2, arg[2].in, arg[2].imm);
168c12b0 1562 op[par[0]](tmp1, tmp1, tmp2);
575e962a 1563 tcg_gen_deposit_i32(arg[0].out, arg[0].out, tmp1, arg[0].imm, 1);
168c12b0
MF
1564 tcg_temp_free(tmp1);
1565 tcg_temp_free(tmp2);
1566}
1567
b0b24bdc 1568static void translate_bp(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1569 const uint32_t par[])
1570{
1571 TCGv_i32 tmp = tcg_temp_new_i32();
1572
575e962a 1573 tcg_gen_andi_i32(tmp, arg[0].in, 1 << arg[0].imm);
b0b24bdc 1574 gen_brcondi(dc, par[0], tmp, 0, arg[1].imm);
168c12b0
MF
1575 tcg_temp_free(tmp);
1576}
1577
b0b24bdc 1578static void translate_call0(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1579 const uint32_t par[])
1580{
3cc18eec 1581 tcg_gen_movi_i32(cpu_R[0], dc->base.pc_next);
b0b24bdc 1582 gen_jumpi(dc, arg[0].imm, 0);
168c12b0
MF
1583}
1584
b0b24bdc 1585static void translate_callw(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1586 const uint32_t par[])
1587{
b0b24bdc
MF
1588 TCGv_i32 tmp = tcg_const_i32(arg[0].imm);
1589 gen_callw_slot(dc, par[0], tmp, adjust_jump_slot(dc, arg[0].imm, 0));
9791e7e9 1590 tcg_temp_free(tmp);
168c12b0
MF
1591}
1592
b0b24bdc 1593static void translate_callx0(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1594 const uint32_t par[])
1595{
6416d16f 1596 TCGv_i32 tmp = tcg_temp_new_i32();
b0b24bdc 1597 tcg_gen_mov_i32(tmp, arg[0].in);
6416d16f
MF
1598 tcg_gen_movi_i32(cpu_R[0], dc->base.pc_next);
1599 gen_jump(dc, tmp);
1600 tcg_temp_free(tmp);
168c12b0
MF
1601}
1602
b0b24bdc 1603static void translate_callxw(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1604 const uint32_t par[])
1605{
6416d16f 1606 TCGv_i32 tmp = tcg_temp_new_i32();
168c12b0 1607
b0b24bdc 1608 tcg_gen_mov_i32(tmp, arg[0].in);
9791e7e9 1609 gen_callw_slot(dc, par[0], tmp, -1);
6416d16f 1610 tcg_temp_free(tmp);
168c12b0
MF
1611}
1612
b0b24bdc 1613static void translate_clamps(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1614 const uint32_t par[])
1615{
b0b24bdc
MF
1616 TCGv_i32 tmp1 = tcg_const_i32(-1u << arg[2].imm);
1617 TCGv_i32 tmp2 = tcg_const_i32((1 << arg[2].imm) - 1);
168c12b0 1618
b0b24bdc
MF
1619 tcg_gen_smax_i32(tmp1, tmp1, arg[1].in);
1620 tcg_gen_smin_i32(arg[0].out, tmp1, tmp2);
6416d16f
MF
1621 tcg_temp_free(tmp1);
1622 tcg_temp_free(tmp2);
168c12b0
MF
1623}
1624
b0b24bdc 1625static void translate_clrb_expstate(DisasContext *dc, const OpcodeArg arg[],
e9872741
MF
1626 const uint32_t par[])
1627{
1628 /* TODO: GPIO32 may be a part of coprocessor */
b0b24bdc 1629 tcg_gen_andi_i32(cpu_UR[EXPSTATE], cpu_UR[EXPSTATE], ~(1u << arg[0].imm));
e9872741
MF
1630}
1631
b345e140
MF
1632static void translate_clrex(DisasContext *dc, const OpcodeArg arg[],
1633 const uint32_t par[])
1634{
1635 tcg_gen_movi_i32(cpu_exclusive_addr, -1);
1636}
1637
b0b24bdc 1638static void translate_const16(DisasContext *dc, const OpcodeArg arg[],
c5ac936e
MF
1639 const uint32_t par[])
1640{
b0b24bdc 1641 TCGv_i32 c = tcg_const_i32(arg[1].imm);
c5ac936e 1642
b0b24bdc 1643 tcg_gen_deposit_i32(arg[0].out, c, arg[0].in, 16, 16);
6416d16f 1644 tcg_temp_free(c);
c5ac936e
MF
1645}
1646
b0b24bdc 1647static void translate_dcache(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1648 const uint32_t par[])
1649{
6416d16f
MF
1650 TCGv_i32 addr = tcg_temp_new_i32();
1651 TCGv_i32 res = tcg_temp_new_i32();
168c12b0 1652
b0b24bdc 1653 tcg_gen_addi_i32(addr, arg[0].in, arg[1].imm);
6416d16f
MF
1654 tcg_gen_qemu_ld8u(res, addr, dc->cring);
1655 tcg_temp_free(addr);
1656 tcg_temp_free(res);
168c12b0
MF
1657}
1658
b0b24bdc 1659static void translate_depbits(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1660 const uint32_t par[])
1661{
b0b24bdc
MF
1662 tcg_gen_deposit_i32(arg[1].out, arg[1].in, arg[0].in,
1663 arg[2].imm, arg[3].imm);
168c12b0
MF
1664}
1665
75eed0e5
MF
1666static void translate_diwbuip(DisasContext *dc, const OpcodeArg arg[],
1667 const uint32_t par[])
1668{
1669 tcg_gen_addi_i32(arg[0].out, arg[0].in, dc->config->dcache_line_bytes);
1670}
1671
91dc2b2d
MF
1672static uint32_t test_exceptions_entry(DisasContext *dc, const OpcodeArg arg[],
1673 const uint32_t par[])
09460970 1674{
b0b24bdc 1675 if (arg[0].imm > 3 || !dc->cwoe) {
09460970
MF
1676 qemu_log_mask(LOG_GUEST_ERROR,
1677 "Illegal entry instruction(pc = %08x)\n", dc->pc);
91dc2b2d 1678 return XTENSA_OP_ILL;
09460970 1679 } else {
91dc2b2d 1680 return 0;
09460970
MF
1681 }
1682}
1683
b0b24bdc 1684static uint32_t test_overflow_entry(DisasContext *dc, const OpcodeArg arg[],
6416d16f
MF
1685 const uint32_t par[])
1686{
1687 return 1 << (dc->callinc * 4);
1688}
1689
b0b24bdc 1690static void translate_entry(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1691 const uint32_t par[])
1692{
1693 TCGv_i32 pc = tcg_const_i32(dc->pc);
b0b24bdc
MF
1694 TCGv_i32 s = tcg_const_i32(arg[0].imm);
1695 TCGv_i32 imm = tcg_const_i32(arg[1].imm);
168c12b0
MF
1696 gen_helper_entry(cpu_env, pc, s, imm);
1697 tcg_temp_free(imm);
1698 tcg_temp_free(s);
1699 tcg_temp_free(pc);
168c12b0
MF
1700}
1701
b0b24bdc 1702static void translate_extui(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1703 const uint32_t par[])
1704{
b0b24bdc 1705 int maskimm = (1 << arg[3].imm) - 1;
168c12b0 1706
6416d16f 1707 TCGv_i32 tmp = tcg_temp_new_i32();
b0b24bdc
MF
1708 tcg_gen_shri_i32(tmp, arg[1].in, arg[2].imm);
1709 tcg_gen_andi_i32(arg[0].out, tmp, maskimm);
6416d16f 1710 tcg_temp_free(tmp);
168c12b0
MF
1711}
1712
b345e140
MF
1713static void translate_getex(DisasContext *dc, const OpcodeArg arg[],
1714 const uint32_t par[])
1715{
1716 TCGv_i32 tmp = tcg_temp_new_i32();
1717
1718 tcg_gen_extract_i32(tmp, cpu_SR[ATOMCTL], 8, 1);
1719 tcg_gen_deposit_i32(cpu_SR[ATOMCTL], cpu_SR[ATOMCTL], arg[0].in, 8, 1);
1720 tcg_gen_mov_i32(arg[0].out, tmp);
1721 tcg_temp_free(tmp);
1722}
1723
b0b24bdc 1724static void translate_icache(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1725 const uint32_t par[])
1726{
ba7651fb 1727#ifndef CONFIG_USER_ONLY
6416d16f 1728 TCGv_i32 addr = tcg_temp_new_i32();
168c12b0 1729
6416d16f 1730 tcg_gen_movi_i32(cpu_pc, dc->pc);
b0b24bdc 1731 tcg_gen_addi_i32(addr, arg[0].in, arg[1].imm);
6416d16f
MF
1732 gen_helper_itlb_hit_test(cpu_env, addr);
1733 tcg_temp_free(addr);
ba7651fb 1734#endif
168c12b0
MF
1735}
1736
b0b24bdc 1737static void translate_itlb(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1738 const uint32_t par[])
1739{
ba7651fb 1740#ifndef CONFIG_USER_ONLY
6416d16f 1741 TCGv_i32 dtlb = tcg_const_i32(par[0]);
168c12b0 1742
b0b24bdc 1743 gen_helper_itlb(cpu_env, arg[0].in, dtlb);
6416d16f 1744 tcg_temp_free(dtlb);
ba7651fb 1745#endif
168c12b0
MF
1746}
1747
b0b24bdc 1748static void translate_j(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1749 const uint32_t par[])
1750{
b0b24bdc 1751 gen_jumpi(dc, arg[0].imm, 0);
168c12b0
MF
1752}
1753
b0b24bdc 1754static void translate_jx(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1755 const uint32_t par[])
1756{
b0b24bdc 1757 gen_jump(dc, arg[0].in);
168c12b0
MF
1758}
1759
b0b24bdc 1760static void translate_l32e(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1761 const uint32_t par[])
1762{
6416d16f 1763 TCGv_i32 addr = tcg_temp_new_i32();
168c12b0 1764
b0b24bdc 1765 tcg_gen_addi_i32(addr, arg[1].in, arg[2].imm);
6416d16f 1766 gen_load_store_alignment(dc, 2, addr, false);
b0b24bdc 1767 tcg_gen_qemu_ld_tl(arg[0].out, addr, dc->ring, MO_TEUL);
6416d16f 1768 tcg_temp_free(addr);
168c12b0
MF
1769}
1770
b345e140
MF
1771#ifdef CONFIG_USER_ONLY
1772static void gen_check_exclusive(DisasContext *dc, TCGv_i32 addr, bool is_write)
1773{
1774}
1775#else
1776static void gen_check_exclusive(DisasContext *dc, TCGv_i32 addr, bool is_write)
1777{
1778 if (!option_enabled(dc, XTENSA_OPTION_MPU)) {
1779 TCGv_i32 tpc = tcg_const_i32(dc->pc);
1780 TCGv_i32 write = tcg_const_i32(is_write);
1781
1782 gen_helper_check_exclusive(cpu_env, tpc, addr, write);
1783 tcg_temp_free(tpc);
1784 tcg_temp_free(write);
1785 }
1786}
1787#endif
1788
1789static void translate_l32ex(DisasContext *dc, const OpcodeArg arg[],
1790 const uint32_t par[])
1791{
1792 TCGv_i32 addr = tcg_temp_new_i32();
1793
1794 tcg_gen_mov_i32(addr, arg[1].in);
1795 gen_load_store_alignment(dc, 2, addr, true);
1796 gen_check_exclusive(dc, addr, false);
1797 tcg_gen_qemu_ld_i32(arg[0].out, addr, dc->ring, MO_TEUL);
1798 tcg_gen_mov_i32(cpu_exclusive_addr, addr);
1799 tcg_gen_mov_i32(cpu_exclusive_val, arg[0].out);
1800 tcg_temp_free(addr);
1801}
1802
b0b24bdc 1803static void translate_ldst(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1804 const uint32_t par[])
1805{
6416d16f 1806 TCGv_i32 addr = tcg_temp_new_i32();
168c12b0 1807
b0b24bdc 1808 tcg_gen_addi_i32(addr, arg[1].in, arg[2].imm);
6416d16f
MF
1809 if (par[0] & MO_SIZE) {
1810 gen_load_store_alignment(dc, par[0] & MO_SIZE, addr, par[1]);
1811 }
1812 if (par[2]) {
1813 if (par[1]) {
1814 tcg_gen_mb(TCG_BAR_STRL | TCG_MO_ALL);
168c12b0 1815 }
b0b24bdc 1816 tcg_gen_qemu_st_tl(arg[0].in, addr, dc->cring, par[0]);
6416d16f 1817 } else {
b0b24bdc 1818 tcg_gen_qemu_ld_tl(arg[0].out, addr, dc->cring, par[0]);
6416d16f
MF
1819 if (par[1]) {
1820 tcg_gen_mb(TCG_BAR_LDAQ | TCG_MO_ALL);
168c12b0 1821 }
168c12b0 1822 }
6416d16f 1823 tcg_temp_free(addr);
168c12b0
MF
1824}
1825
b0b24bdc 1826static void translate_l32r(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1827 const uint32_t par[])
1828{
6416d16f 1829 TCGv_i32 tmp;
168c12b0 1830
6416d16f 1831 if (dc->base.tb->flags & XTENSA_TBFLAG_LITBASE) {
b0b24bdc 1832 tmp = tcg_const_i32(arg[1].raw_imm - 1);
6416d16f
MF
1833 tcg_gen_add_i32(tmp, cpu_SR[LITBASE], tmp);
1834 } else {
b0b24bdc 1835 tmp = tcg_const_i32(arg[1].imm);
168c12b0 1836 }
b0b24bdc 1837 tcg_gen_qemu_ld32u(arg[0].out, tmp, dc->cring);
6416d16f 1838 tcg_temp_free(tmp);
168c12b0
MF
1839}
1840
b0b24bdc 1841static void translate_loop(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1842 const uint32_t par[])
1843{
b0b24bdc 1844 uint32_t lend = arg[1].imm;
168c12b0 1845
b0b24bdc 1846 tcg_gen_subi_i32(cpu_SR[LCOUNT], arg[0].in, 1);
6416d16f 1847 tcg_gen_movi_i32(cpu_SR[LBEG], dc->base.pc_next);
5d630cef 1848 tcg_gen_movi_i32(cpu_SR[LEND], lend);
168c12b0 1849
6416d16f
MF
1850 if (par[0] != TCG_COND_NEVER) {
1851 TCGLabel *label = gen_new_label();
b0b24bdc 1852 tcg_gen_brcondi_i32(par[0], arg[0].in, 0, label);
6416d16f
MF
1853 gen_jumpi(dc, lend, 1);
1854 gen_set_label(label);
168c12b0 1855 }
6416d16f
MF
1856
1857 gen_jumpi(dc, dc->base.pc_next, 0);
168c12b0
MF
1858}
1859
1860enum {
1861 MAC16_UMUL,
1862 MAC16_MUL,
1863 MAC16_MULA,
1864 MAC16_MULS,
1865 MAC16_NONE,
1866};
1867
1868enum {
1869 MAC16_LL,
1870 MAC16_HL,
1871 MAC16_LH,
1872 MAC16_HH,
1873
1874 MAC16_HX = 0x1,
1875 MAC16_XH = 0x2,
1876};
1877
b0b24bdc 1878static void translate_mac16(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1879 const uint32_t par[])
1880{
1881 int op = par[0];
7aa78341
MF
1882 unsigned half = par[1];
1883 uint32_t ld_offset = par[2];
168c12b0 1884 unsigned off = ld_offset ? 2 : 0;
6416d16f
MF
1885 TCGv_i32 vaddr = tcg_temp_new_i32();
1886 TCGv_i32 mem32 = tcg_temp_new_i32();
168c12b0
MF
1887
1888 if (ld_offset) {
b0b24bdc 1889 tcg_gen_addi_i32(vaddr, arg[1].in, ld_offset);
6416d16f
MF
1890 gen_load_store_alignment(dc, 2, vaddr, false);
1891 tcg_gen_qemu_ld32u(mem32, vaddr, dc->cring);
168c12b0 1892 }
6416d16f 1893 if (op != MAC16_NONE) {
7aa78341 1894 TCGv_i32 m1 = gen_mac16_m(arg[off].in,
6416d16f 1895 half & MAC16_HX, op == MAC16_UMUL);
7aa78341 1896 TCGv_i32 m2 = gen_mac16_m(arg[off + 1].in,
6416d16f
MF
1897 half & MAC16_XH, op == MAC16_UMUL);
1898
1899 if (op == MAC16_MUL || op == MAC16_UMUL) {
1900 tcg_gen_mul_i32(cpu_SR[ACCLO], m1, m2);
1901 if (op == MAC16_UMUL) {
1902 tcg_gen_movi_i32(cpu_SR[ACCHI], 0);
168c12b0 1903 } else {
6416d16f 1904 tcg_gen_sari_i32(cpu_SR[ACCHI], cpu_SR[ACCLO], 31);
168c12b0 1905 }
6416d16f
MF
1906 } else {
1907 TCGv_i32 lo = tcg_temp_new_i32();
1908 TCGv_i32 hi = tcg_temp_new_i32();
1909
1910 tcg_gen_mul_i32(lo, m1, m2);
1911 tcg_gen_sari_i32(hi, lo, 31);
1912 if (op == MAC16_MULA) {
1913 tcg_gen_add2_i32(cpu_SR[ACCLO], cpu_SR[ACCHI],
1914 cpu_SR[ACCLO], cpu_SR[ACCHI],
1915 lo, hi);
1916 } else {
1917 tcg_gen_sub2_i32(cpu_SR[ACCLO], cpu_SR[ACCHI],
1918 cpu_SR[ACCLO], cpu_SR[ACCHI],
1919 lo, hi);
1920 }
1921 tcg_gen_ext8s_i32(cpu_SR[ACCHI], cpu_SR[ACCHI]);
1922
1923 tcg_temp_free_i32(lo);
1924 tcg_temp_free_i32(hi);
168c12b0 1925 }
6416d16f
MF
1926 tcg_temp_free(m1);
1927 tcg_temp_free(m2);
1928 }
1929 if (ld_offset) {
b0b24bdc
MF
1930 tcg_gen_mov_i32(arg[1].out, vaddr);
1931 tcg_gen_mov_i32(cpu_SR[MR + arg[0].imm], mem32);
168c12b0 1932 }
6416d16f
MF
1933 tcg_temp_free(vaddr);
1934 tcg_temp_free(mem32);
168c12b0
MF
1935}
1936
b0b24bdc 1937static void translate_memw(DisasContext *dc, const OpcodeArg arg[],
9fb40342
MF
1938 const uint32_t par[])
1939{
1940 tcg_gen_mb(TCG_BAR_SC | TCG_MO_ALL);
1941}
1942
b0b24bdc 1943static void translate_smin(DisasContext *dc, const OpcodeArg arg[],
426afc3b 1944 const uint32_t par[])
168c12b0 1945{
b0b24bdc 1946 tcg_gen_smin_i32(arg[0].out, arg[1].in, arg[2].in);
426afc3b
RH
1947}
1948
b0b24bdc 1949static void translate_umin(DisasContext *dc, const OpcodeArg arg[],
426afc3b
RH
1950 const uint32_t par[])
1951{
b0b24bdc 1952 tcg_gen_umin_i32(arg[0].out, arg[1].in, arg[2].in);
426afc3b
RH
1953}
1954
b0b24bdc 1955static void translate_smax(DisasContext *dc, const OpcodeArg arg[],
426afc3b
RH
1956 const uint32_t par[])
1957{
b0b24bdc 1958 tcg_gen_smax_i32(arg[0].out, arg[1].in, arg[2].in);
426afc3b
RH
1959}
1960
b0b24bdc 1961static void translate_umax(DisasContext *dc, const OpcodeArg arg[],
426afc3b
RH
1962 const uint32_t par[])
1963{
b0b24bdc 1964 tcg_gen_umax_i32(arg[0].out, arg[1].in, arg[2].in);
168c12b0
MF
1965}
1966
b0b24bdc 1967static void translate_mov(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1968 const uint32_t par[])
1969{
b0b24bdc 1970 tcg_gen_mov_i32(arg[0].out, arg[1].in);
168c12b0
MF
1971}
1972
b0b24bdc 1973static void translate_movcond(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1974 const uint32_t par[])
1975{
6416d16f 1976 TCGv_i32 zero = tcg_const_i32(0);
168c12b0 1977
b0b24bdc
MF
1978 tcg_gen_movcond_i32(par[0], arg[0].out,
1979 arg[2].in, zero, arg[1].in, arg[0].in);
6416d16f 1980 tcg_temp_free(zero);
168c12b0
MF
1981}
1982
b0b24bdc 1983static void translate_movi(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1984 const uint32_t par[])
1985{
b0b24bdc 1986 tcg_gen_movi_i32(arg[0].out, arg[1].imm);
168c12b0
MF
1987}
1988
b0b24bdc 1989static void translate_movp(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
1990 const uint32_t par[])
1991{
6416d16f
MF
1992 TCGv_i32 zero = tcg_const_i32(0);
1993 TCGv_i32 tmp = tcg_temp_new_i32();
168c12b0 1994
575e962a 1995 tcg_gen_andi_i32(tmp, arg[2].in, 1 << arg[2].imm);
6416d16f 1996 tcg_gen_movcond_i32(par[0],
b0b24bdc
MF
1997 arg[0].out, tmp, zero,
1998 arg[1].in, arg[0].in);
6416d16f
MF
1999 tcg_temp_free(tmp);
2000 tcg_temp_free(zero);
168c12b0
MF
2001}
2002
b0b24bdc 2003static void translate_movsp(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2004 const uint32_t par[])
2005{
b0b24bdc 2006 tcg_gen_mov_i32(arg[0].out, arg[1].in);
168c12b0
MF
2007}
2008
b0b24bdc 2009static void translate_mul16(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2010 const uint32_t par[])
2011{
6416d16f
MF
2012 TCGv_i32 v1 = tcg_temp_new_i32();
2013 TCGv_i32 v2 = tcg_temp_new_i32();
168c12b0 2014
6416d16f 2015 if (par[0]) {
b0b24bdc
MF
2016 tcg_gen_ext16s_i32(v1, arg[1].in);
2017 tcg_gen_ext16s_i32(v2, arg[2].in);
6416d16f 2018 } else {
b0b24bdc
MF
2019 tcg_gen_ext16u_i32(v1, arg[1].in);
2020 tcg_gen_ext16u_i32(v2, arg[2].in);
168c12b0 2021 }
b0b24bdc 2022 tcg_gen_mul_i32(arg[0].out, v1, v2);
6416d16f
MF
2023 tcg_temp_free(v2);
2024 tcg_temp_free(v1);
168c12b0
MF
2025}
2026
b0b24bdc 2027static void translate_mull(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2028 const uint32_t par[])
2029{
b0b24bdc 2030 tcg_gen_mul_i32(arg[0].out, arg[1].in, arg[2].in);
168c12b0
MF
2031}
2032
b0b24bdc 2033static void translate_mulh(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2034 const uint32_t par[])
2035{
6416d16f 2036 TCGv_i32 lo = tcg_temp_new();
168c12b0 2037
6416d16f 2038 if (par[0]) {
b0b24bdc 2039 tcg_gen_muls2_i32(lo, arg[0].out, arg[1].in, arg[2].in);
6416d16f 2040 } else {
b0b24bdc 2041 tcg_gen_mulu2_i32(lo, arg[0].out, arg[1].in, arg[2].in);
168c12b0 2042 }
6416d16f 2043 tcg_temp_free(lo);
168c12b0
MF
2044}
2045
b0b24bdc 2046static void translate_neg(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2047 const uint32_t par[])
2048{
b0b24bdc 2049 tcg_gen_neg_i32(arg[0].out, arg[1].in);
168c12b0
MF
2050}
2051
b0b24bdc 2052static void translate_nop(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2053 const uint32_t par[])
2054{
2055}
2056
b0b24bdc 2057static void translate_nsa(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2058 const uint32_t par[])
2059{
b0b24bdc 2060 tcg_gen_clrsb_i32(arg[0].out, arg[1].in);
168c12b0
MF
2061}
2062
b0b24bdc 2063static void translate_nsau(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2064 const uint32_t par[])
2065{
b0b24bdc 2066 tcg_gen_clzi_i32(arg[0].out, arg[1].in, 32);
168c12b0
MF
2067}
2068
b0b24bdc 2069static void translate_or(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2070 const uint32_t par[])
2071{
b0b24bdc 2072 tcg_gen_or_i32(arg[0].out, arg[1].in, arg[2].in);
168c12b0
MF
2073}
2074
b0b24bdc 2075static void translate_ptlb(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2076 const uint32_t par[])
2077{
ba7651fb 2078#ifndef CONFIG_USER_ONLY
6416d16f 2079 TCGv_i32 dtlb = tcg_const_i32(par[0]);
168c12b0 2080
6416d16f 2081 tcg_gen_movi_i32(cpu_pc, dc->pc);
b0b24bdc 2082 gen_helper_ptlb(arg[0].out, cpu_env, arg[1].in, dtlb);
6416d16f 2083 tcg_temp_free(dtlb);
ba7651fb 2084#endif
168c12b0
MF
2085}
2086
4d04ea35
MF
2087static void translate_pptlb(DisasContext *dc, const OpcodeArg arg[],
2088 const uint32_t par[])
2089{
2090#ifndef CONFIG_USER_ONLY
2091 tcg_gen_movi_i32(cpu_pc, dc->pc);
2092 gen_helper_pptlb(arg[0].out, cpu_env, arg[1].in);
2093#endif
2094}
2095
b0b24bdc 2096static void translate_quos(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2097 const uint32_t par[])
2098{
6416d16f
MF
2099 TCGLabel *label1 = gen_new_label();
2100 TCGLabel *label2 = gen_new_label();
168c12b0 2101
b0b24bdc 2102 tcg_gen_brcondi_i32(TCG_COND_NE, arg[1].in, 0x80000000,
6416d16f 2103 label1);
b0b24bdc 2104 tcg_gen_brcondi_i32(TCG_COND_NE, arg[2].in, 0xffffffff,
6416d16f 2105 label1);
b0b24bdc 2106 tcg_gen_movi_i32(arg[0].out,
6416d16f
MF
2107 par[0] ? 0x80000000 : 0);
2108 tcg_gen_br(label2);
2109 gen_set_label(label1);
2110 if (par[0]) {
b0b24bdc
MF
2111 tcg_gen_div_i32(arg[0].out,
2112 arg[1].in, arg[2].in);
6416d16f 2113 } else {
b0b24bdc
MF
2114 tcg_gen_rem_i32(arg[0].out,
2115 arg[1].in, arg[2].in);
168c12b0 2116 }
6416d16f 2117 gen_set_label(label2);
168c12b0
MF
2118}
2119
b0b24bdc 2120static void translate_quou(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2121 const uint32_t par[])
2122{
b0b24bdc
MF
2123 tcg_gen_divu_i32(arg[0].out,
2124 arg[1].in, arg[2].in);
168c12b0
MF
2125}
2126
b0b24bdc 2127static void translate_read_impwire(DisasContext *dc, const OpcodeArg arg[],
e9872741
MF
2128 const uint32_t par[])
2129{
6416d16f 2130 /* TODO: GPIO32 may be a part of coprocessor */
b0b24bdc 2131 tcg_gen_movi_i32(arg[0].out, 0);
e9872741
MF
2132}
2133
b0b24bdc 2134static void translate_remu(DisasContext *dc, const OpcodeArg arg[],
4a038955
MF
2135 const uint32_t par[])
2136{
b0b24bdc
MF
2137 tcg_gen_remu_i32(arg[0].out,
2138 arg[1].in, arg[2].in);
4a038955
MF
2139}
2140
b0b24bdc 2141static void translate_rer(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2142 const uint32_t par[])
2143{
b0b24bdc 2144 gen_helper_rer(arg[0].out, cpu_env, arg[1].in);
168c12b0
MF
2145}
2146
b0b24bdc 2147static void translate_ret(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2148 const uint32_t par[])
2149{
2150 gen_jump(dc, cpu_R[0]);
2151}
2152
91dc2b2d
MF
2153static uint32_t test_exceptions_retw(DisasContext *dc, const OpcodeArg arg[],
2154 const uint32_t par[])
09460970
MF
2155{
2156 if (!dc->cwoe) {
2157 qemu_log_mask(LOG_GUEST_ERROR,
2158 "Illegal retw instruction(pc = %08x)\n", dc->pc);
91dc2b2d 2159 return XTENSA_OP_ILL;
09460970
MF
2160 } else {
2161 TCGv_i32 tmp = tcg_const_i32(dc->pc);
2162
2163 gen_helper_test_ill_retw(cpu_env, tmp);
2164 tcg_temp_free(tmp);
91dc2b2d 2165 return 0;
09460970
MF
2166 }
2167}
2168
b0b24bdc 2169static void translate_retw(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2170 const uint32_t par[])
2171{
c949009b
MF
2172 TCGv_i32 tmp = tcg_const_i32(1);
2173 tcg_gen_shl_i32(tmp, tmp, cpu_SR[WINDOW_BASE]);
2174 tcg_gen_andc_i32(cpu_SR[WINDOW_START],
2175 cpu_SR[WINDOW_START], tmp);
2176 tcg_gen_movi_i32(tmp, dc->pc);
2177 tcg_gen_deposit_i32(tmp, tmp, cpu_R[0], 0, 30);
2178 gen_helper_retw(cpu_env, cpu_R[0]);
168c12b0
MF
2179 gen_jump(dc, tmp);
2180 tcg_temp_free(tmp);
2181}
2182
b0b24bdc 2183static void translate_rfde(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2184 const uint32_t par[])
2185{
21a2dad5 2186 gen_jump(dc, cpu_SR[dc->config->ndepc ? DEPC : EPC1]);
168c12b0
MF
2187}
2188
b0b24bdc 2189static void translate_rfe(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2190 const uint32_t par[])
2191{
21a2dad5 2192 tcg_gen_andi_i32(cpu_SR[PS], cpu_SR[PS], ~PS_EXCM);
21a2dad5 2193 gen_jump(dc, cpu_SR[EPC1]);
168c12b0
MF
2194}
2195
b0b24bdc 2196static void translate_rfi(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2197 const uint32_t par[])
2198{
b0b24bdc
MF
2199 tcg_gen_mov_i32(cpu_SR[PS], cpu_SR[EPS2 + arg[0].imm - 2]);
2200 gen_jump(dc, cpu_SR[EPC1 + arg[0].imm - 1]);
168c12b0
MF
2201}
2202
b0b24bdc 2203static void translate_rfw(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2204 const uint32_t par[])
2205{
21a2dad5 2206 TCGv_i32 tmp = tcg_const_i32(1);
168c12b0 2207
21a2dad5
MF
2208 tcg_gen_andi_i32(cpu_SR[PS], cpu_SR[PS], ~PS_EXCM);
2209 tcg_gen_shl_i32(tmp, tmp, cpu_SR[WINDOW_BASE]);
168c12b0 2210
21a2dad5
MF
2211 if (par[0]) {
2212 tcg_gen_andc_i32(cpu_SR[WINDOW_START],
2213 cpu_SR[WINDOW_START], tmp);
2214 } else {
2215 tcg_gen_or_i32(cpu_SR[WINDOW_START],
2216 cpu_SR[WINDOW_START], tmp);
2217 }
168c12b0 2218
d74624e5 2219 tcg_temp_free(tmp);
21a2dad5 2220 gen_helper_restore_owb(cpu_env);
21a2dad5 2221 gen_jump(dc, cpu_SR[EPC1]);
168c12b0
MF
2222}
2223
b0b24bdc 2224static void translate_rotw(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2225 const uint32_t par[])
2226{
b0b24bdc 2227 tcg_gen_addi_i32(cpu_windowbase_next, cpu_SR[WINDOW_BASE], arg[0].imm);
168c12b0
MF
2228}
2229
b0b24bdc 2230static void translate_rsil(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2231 const uint32_t par[])
2232{
b0b24bdc 2233 tcg_gen_mov_i32(arg[0].out, cpu_SR[PS]);
6416d16f 2234 tcg_gen_andi_i32(cpu_SR[PS], cpu_SR[PS], ~PS_INTLEVEL);
b0b24bdc 2235 tcg_gen_ori_i32(cpu_SR[PS], cpu_SR[PS], arg[1].imm);
168c12b0
MF
2236}
2237
59419607
MF
2238static void translate_rsr(DisasContext *dc, const OpcodeArg arg[],
2239 const uint32_t par[])
09460970 2240{
59afd43d
MF
2241 if (sr_name[par[0]]) {
2242 tcg_gen_mov_i32(arg[0].out, cpu_SR[par[0]]);
2243 } else {
2244 tcg_gen_movi_i32(arg[0].out, 0);
2245 }
09460970
MF
2246}
2247
59419607
MF
2248static void translate_rsr_ccount(DisasContext *dc, const OpcodeArg arg[],
2249 const uint32_t par[])
2250{
2251#ifndef CONFIG_USER_ONLY
2252 if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
2253 gen_io_start();
2254 }
2255 gen_helper_update_ccount(cpu_env);
2256 tcg_gen_mov_i32(arg[0].out, cpu_SR[par[0]]);
59419607
MF
2257#endif
2258}
2259
2260static void translate_rsr_ptevaddr(DisasContext *dc, const OpcodeArg arg[],
2261 const uint32_t par[])
168c12b0 2262{
59419607
MF
2263#ifndef CONFIG_USER_ONLY
2264 TCGv_i32 tmp = tcg_temp_new_i32();
2265
2266 tcg_gen_shri_i32(tmp, cpu_SR[EXCVADDR], 10);
2267 tcg_gen_or_i32(tmp, tmp, cpu_SR[PTEVADDR]);
2268 tcg_gen_andi_i32(arg[0].out, tmp, 0xfffffffc);
2269 tcg_temp_free(tmp);
2270#endif
168c12b0
MF
2271}
2272
b0b24bdc 2273static void translate_rtlb(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2274 const uint32_t par[])
2275{
21a2dad5 2276#ifndef CONFIG_USER_ONLY
168c12b0
MF
2277 static void (* const helper[])(TCGv_i32 r, TCGv_env env, TCGv_i32 a1,
2278 TCGv_i32 a2) = {
2279 gen_helper_rtlb0,
2280 gen_helper_rtlb1,
2281 };
6416d16f 2282 TCGv_i32 dtlb = tcg_const_i32(par[0]);
168c12b0 2283
b0b24bdc 2284 helper[par[1]](arg[0].out, cpu_env, arg[1].in, dtlb);
6416d16f 2285 tcg_temp_free(dtlb);
21a2dad5 2286#endif
168c12b0
MF
2287}
2288
4d04ea35
MF
2289static void translate_rptlb0(DisasContext *dc, const OpcodeArg arg[],
2290 const uint32_t par[])
168c12b0 2291{
4d04ea35
MF
2292#ifndef CONFIG_USER_ONLY
2293 gen_helper_rptlb0(arg[0].out, cpu_env, arg[1].in);
2294#endif
2295}
2296
2297static void translate_rptlb1(DisasContext *dc, const OpcodeArg arg[],
2298 const uint32_t par[])
2299{
2300#ifndef CONFIG_USER_ONLY
2301 gen_helper_rptlb1(arg[0].out, cpu_env, arg[1].in);
2302#endif
2303}
2304
b0b24bdc 2305static void translate_rur(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2306 const uint32_t par[])
2307{
59419607 2308 tcg_gen_mov_i32(arg[0].out, cpu_UR[par[0]]);
168c12b0
MF
2309}
2310
b0b24bdc 2311static void translate_setb_expstate(DisasContext *dc, const OpcodeArg arg[],
e9872741
MF
2312 const uint32_t par[])
2313{
2314 /* TODO: GPIO32 may be a part of coprocessor */
b0b24bdc 2315 tcg_gen_ori_i32(cpu_UR[EXPSTATE], cpu_UR[EXPSTATE], 1u << arg[0].imm);
e9872741
MF
2316}
2317
9fb40342
MF
2318#ifdef CONFIG_USER_ONLY
2319static void gen_check_atomctl(DisasContext *dc, TCGv_i32 addr)
2320{
2321}
2322#else
2323static void gen_check_atomctl(DisasContext *dc, TCGv_i32 addr)
2324{
2325 TCGv_i32 tpc = tcg_const_i32(dc->pc);
2326
2327 gen_helper_check_atomctl(cpu_env, tpc, addr);
2328 tcg_temp_free(tpc);
2329}
2330#endif
2331
b0b24bdc 2332static void translate_s32c1i(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2333 const uint32_t par[])
2334{
6416d16f
MF
2335 TCGv_i32 tmp = tcg_temp_local_new_i32();
2336 TCGv_i32 addr = tcg_temp_local_new_i32();
168c12b0 2337
b0b24bdc
MF
2338 tcg_gen_mov_i32(tmp, arg[0].in);
2339 tcg_gen_addi_i32(addr, arg[1].in, arg[2].imm);
6416d16f
MF
2340 gen_load_store_alignment(dc, 2, addr, true);
2341 gen_check_atomctl(dc, addr);
b0b24bdc 2342 tcg_gen_atomic_cmpxchg_i32(arg[0].out, addr, cpu_SR[SCOMPARE1],
6416d16f
MF
2343 tmp, dc->cring, MO_TEUL);
2344 tcg_temp_free(addr);
2345 tcg_temp_free(tmp);
168c12b0
MF
2346}
2347
b0b24bdc 2348static void translate_s32e(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2349 const uint32_t par[])
2350{
6416d16f 2351 TCGv_i32 addr = tcg_temp_new_i32();
168c12b0 2352
b0b24bdc 2353 tcg_gen_addi_i32(addr, arg[1].in, arg[2].imm);
6416d16f 2354 gen_load_store_alignment(dc, 2, addr, false);
b0b24bdc 2355 tcg_gen_qemu_st_tl(arg[0].in, addr, dc->ring, MO_TEUL);
6416d16f 2356 tcg_temp_free(addr);
168c12b0
MF
2357}
2358
b345e140
MF
2359static void translate_s32ex(DisasContext *dc, const OpcodeArg arg[],
2360 const uint32_t par[])
2361{
2362 TCGv_i32 prev = tcg_temp_new_i32();
2363 TCGv_i32 addr = tcg_temp_local_new_i32();
2364 TCGv_i32 res = tcg_temp_local_new_i32();
2365 TCGLabel *label = gen_new_label();
2366
2367 tcg_gen_movi_i32(res, 0);
2368 tcg_gen_mov_i32(addr, arg[1].in);
2369 gen_load_store_alignment(dc, 2, addr, true);
2370 tcg_gen_brcond_i32(TCG_COND_NE, addr, cpu_exclusive_addr, label);
2371 gen_check_exclusive(dc, addr, true);
2372 tcg_gen_atomic_cmpxchg_i32(prev, cpu_exclusive_addr, cpu_exclusive_val,
2373 arg[0].in, dc->cring, MO_TEUL);
2374 tcg_gen_setcond_i32(TCG_COND_EQ, res, prev, cpu_exclusive_val);
2375 tcg_gen_movcond_i32(TCG_COND_EQ, cpu_exclusive_val,
2376 prev, cpu_exclusive_val, prev, cpu_exclusive_val);
2377 tcg_gen_movi_i32(cpu_exclusive_addr, -1);
2378 gen_set_label(label);
2379 tcg_gen_extract_i32(arg[0].out, cpu_SR[ATOMCTL], 8, 1);
2380 tcg_gen_deposit_i32(cpu_SR[ATOMCTL], cpu_SR[ATOMCTL], res, 8, 1);
2381 tcg_temp_free(prev);
2382 tcg_temp_free(addr);
2383 tcg_temp_free(res);
2384}
2385
b0b24bdc 2386static void translate_salt(DisasContext *dc, const OpcodeArg arg[],
d1e9b006
MF
2387 const uint32_t par[])
2388{
6416d16f 2389 tcg_gen_setcond_i32(par[0],
b0b24bdc
MF
2390 arg[0].out,
2391 arg[1].in, arg[2].in);
d1e9b006
MF
2392}
2393
b0b24bdc 2394static void translate_sext(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2395 const uint32_t par[])
2396{
b0b24bdc 2397 int shift = 31 - arg[2].imm;
168c12b0 2398
6416d16f 2399 if (shift == 24) {
b0b24bdc 2400 tcg_gen_ext8s_i32(arg[0].out, arg[1].in);
6416d16f 2401 } else if (shift == 16) {
b0b24bdc 2402 tcg_gen_ext16s_i32(arg[0].out, arg[1].in);
6416d16f
MF
2403 } else {
2404 TCGv_i32 tmp = tcg_temp_new_i32();
b0b24bdc
MF
2405 tcg_gen_shli_i32(tmp, arg[1].in, shift);
2406 tcg_gen_sari_i32(arg[0].out, tmp, shift);
6416d16f 2407 tcg_temp_free(tmp);
168c12b0
MF
2408 }
2409}
2410
91dc2b2d
MF
2411static uint32_t test_exceptions_simcall(DisasContext *dc,
2412 const OpcodeArg arg[],
2413 const uint32_t par[])
09460970
MF
2414{
2415#ifdef CONFIG_USER_ONLY
2416 bool ill = true;
2417#else
62ed68e3
MF
2418 /* Between RE.2 and RE.3 simcall opcode's become nop for the hardware. */
2419 bool ill = dc->config->hw_version <= 250002 && !semihosting_enabled();
09460970 2420#endif
62ed68e3 2421 if (ill || !semihosting_enabled()) {
09460970
MF
2422 qemu_log_mask(LOG_GUEST_ERROR, "SIMCALL but semihosting is disabled\n");
2423 }
91dc2b2d 2424 return ill ? XTENSA_OP_ILL : 0;
09460970
MF
2425}
2426
b0b24bdc 2427static void translate_simcall(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2428 const uint32_t par[])
2429{
ba7651fb 2430#ifndef CONFIG_USER_ONLY
62ed68e3
MF
2431 if (semihosting_enabled()) {
2432 gen_helper_simcall(cpu_env);
2433 }
09460970 2434#endif
168c12b0
MF
2435}
2436
2437/*
2438 * Note: 64 bit ops are used here solely because SAR values
2439 * have range 0..63
2440 */
2441#define gen_shift_reg(cmd, reg) do { \
2442 TCGv_i64 tmp = tcg_temp_new_i64(); \
2443 tcg_gen_extu_i32_i64(tmp, reg); \
2444 tcg_gen_##cmd##_i64(v, v, tmp); \
b0b24bdc 2445 tcg_gen_extrl_i64_i32(arg[0].out, v); \
168c12b0
MF
2446 tcg_temp_free_i64(v); \
2447 tcg_temp_free_i64(tmp); \
2448 } while (0)
2449
2450#define gen_shift(cmd) gen_shift_reg(cmd, cpu_SR[SAR])
2451
b0b24bdc 2452static void translate_sll(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2453 const uint32_t par[])
2454{
6416d16f 2455 if (dc->sar_m32_5bit) {
b0b24bdc 2456 tcg_gen_shl_i32(arg[0].out, arg[1].in, dc->sar_m32);
6416d16f
MF
2457 } else {
2458 TCGv_i64 v = tcg_temp_new_i64();
2459 TCGv_i32 s = tcg_const_i32(32);
2460 tcg_gen_sub_i32(s, s, cpu_SR[SAR]);
2461 tcg_gen_andi_i32(s, s, 0x3f);
b0b24bdc 2462 tcg_gen_extu_i32_i64(v, arg[1].in);
6416d16f
MF
2463 gen_shift_reg(shl, s);
2464 tcg_temp_free(s);
168c12b0
MF
2465 }
2466}
2467
b0b24bdc 2468static void translate_slli(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2469 const uint32_t par[])
2470{
b0b24bdc 2471 if (arg[2].imm == 32) {
6416d16f 2472 qemu_log_mask(LOG_GUEST_ERROR, "slli a%d, a%d, 32 is undefined\n",
b0b24bdc 2473 arg[0].imm, arg[1].imm);
168c12b0 2474 }
b0b24bdc 2475 tcg_gen_shli_i32(arg[0].out, arg[1].in, arg[2].imm & 0x1f);
168c12b0
MF
2476}
2477
b0b24bdc 2478static void translate_sra(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2479 const uint32_t par[])
2480{
6416d16f 2481 if (dc->sar_m32_5bit) {
b0b24bdc 2482 tcg_gen_sar_i32(arg[0].out, arg[1].in, cpu_SR[SAR]);
6416d16f
MF
2483 } else {
2484 TCGv_i64 v = tcg_temp_new_i64();
b0b24bdc 2485 tcg_gen_ext_i32_i64(v, arg[1].in);
6416d16f 2486 gen_shift(sar);
168c12b0
MF
2487 }
2488}
2489
b0b24bdc 2490static void translate_srai(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2491 const uint32_t par[])
2492{
b0b24bdc 2493 tcg_gen_sari_i32(arg[0].out, arg[1].in, arg[2].imm);
168c12b0
MF
2494}
2495
b0b24bdc 2496static void translate_src(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2497 const uint32_t par[])
2498{
6416d16f 2499 TCGv_i64 v = tcg_temp_new_i64();
b0b24bdc 2500 tcg_gen_concat_i32_i64(v, arg[2].in, arg[1].in);
6416d16f 2501 gen_shift(shr);
168c12b0
MF
2502}
2503
b0b24bdc 2504static void translate_srl(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2505 const uint32_t par[])
2506{
6416d16f 2507 if (dc->sar_m32_5bit) {
b0b24bdc 2508 tcg_gen_shr_i32(arg[0].out, arg[1].in, cpu_SR[SAR]);
6416d16f
MF
2509 } else {
2510 TCGv_i64 v = tcg_temp_new_i64();
b0b24bdc 2511 tcg_gen_extu_i32_i64(v, arg[1].in);
6416d16f 2512 gen_shift(shr);
168c12b0
MF
2513 }
2514}
2515
2516#undef gen_shift
2517#undef gen_shift_reg
2518
b0b24bdc 2519static void translate_srli(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2520 const uint32_t par[])
2521{
b0b24bdc 2522 tcg_gen_shri_i32(arg[0].out, arg[1].in, arg[2].imm);
168c12b0
MF
2523}
2524
b0b24bdc 2525static void translate_ssa8b(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2526 const uint32_t par[])
2527{
6416d16f 2528 TCGv_i32 tmp = tcg_temp_new_i32();
b0b24bdc 2529 tcg_gen_shli_i32(tmp, arg[0].in, 3);
6416d16f
MF
2530 gen_left_shift_sar(dc, tmp);
2531 tcg_temp_free(tmp);
168c12b0
MF
2532}
2533
b0b24bdc 2534static void translate_ssa8l(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2535 const uint32_t par[])
2536{
6416d16f 2537 TCGv_i32 tmp = tcg_temp_new_i32();
b0b24bdc 2538 tcg_gen_shli_i32(tmp, arg[0].in, 3);
6416d16f
MF
2539 gen_right_shift_sar(dc, tmp);
2540 tcg_temp_free(tmp);
168c12b0
MF
2541}
2542
b0b24bdc 2543static void translate_ssai(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2544 const uint32_t par[])
2545{
b0b24bdc 2546 TCGv_i32 tmp = tcg_const_i32(arg[0].imm);
168c12b0
MF
2547 gen_right_shift_sar(dc, tmp);
2548 tcg_temp_free(tmp);
2549}
2550
b0b24bdc 2551static void translate_ssl(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2552 const uint32_t par[])
2553{
b0b24bdc 2554 gen_left_shift_sar(dc, arg[0].in);
168c12b0
MF
2555}
2556
b0b24bdc 2557static void translate_ssr(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2558 const uint32_t par[])
2559{
b0b24bdc 2560 gen_right_shift_sar(dc, arg[0].in);
168c12b0
MF
2561}
2562
b0b24bdc 2563static void translate_sub(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2564 const uint32_t par[])
2565{
b0b24bdc 2566 tcg_gen_sub_i32(arg[0].out, arg[1].in, arg[2].in);
168c12b0
MF
2567}
2568
b0b24bdc 2569static void translate_subx(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2570 const uint32_t par[])
2571{
6416d16f 2572 TCGv_i32 tmp = tcg_temp_new_i32();
b0b24bdc
MF
2573 tcg_gen_shli_i32(tmp, arg[1].in, par[0]);
2574 tcg_gen_sub_i32(arg[0].out, tmp, arg[2].in);
6416d16f 2575 tcg_temp_free(tmp);
168c12b0
MF
2576}
2577
b0b24bdc 2578static void translate_waiti(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2579 const uint32_t par[])
2580{
ba7651fb 2581#ifndef CONFIG_USER_ONLY
b0b24bdc 2582 gen_waiti(dc, arg[0].imm);
ba7651fb 2583#endif
168c12b0
MF
2584}
2585
b0b24bdc 2586static void translate_wtlb(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2587 const uint32_t par[])
2588{
ba7651fb 2589#ifndef CONFIG_USER_ONLY
6416d16f 2590 TCGv_i32 dtlb = tcg_const_i32(par[0]);
168c12b0 2591
b0b24bdc 2592 gen_helper_wtlb(cpu_env, arg[0].in, arg[1].in, dtlb);
6416d16f 2593 tcg_temp_free(dtlb);
ba7651fb 2594#endif
168c12b0
MF
2595}
2596
4d04ea35
MF
2597static void translate_wptlb(DisasContext *dc, const OpcodeArg arg[],
2598 const uint32_t par[])
2599{
2600#ifndef CONFIG_USER_ONLY
2601 gen_helper_wptlb(cpu_env, arg[0].in, arg[1].in);
2602#endif
2603}
2604
b0b24bdc 2605static void translate_wer(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2606 const uint32_t par[])
2607{
b0b24bdc 2608 gen_helper_wer(cpu_env, arg[0].in, arg[1].in);
168c12b0
MF
2609}
2610
b0b24bdc 2611static void translate_wrmsk_expstate(DisasContext *dc, const OpcodeArg arg[],
e9872741
MF
2612 const uint32_t par[])
2613{
6416d16f 2614 /* TODO: GPIO32 may be a part of coprocessor */
b0b24bdc 2615 tcg_gen_and_i32(cpu_UR[EXPSTATE], arg[0].in, arg[1].in);
e9872741
MF
2616}
2617
59419607
MF
2618static void translate_wsr(DisasContext *dc, const OpcodeArg arg[],
2619 const uint32_t par[])
09460970 2620{
59afd43d
MF
2621 if (sr_name[par[0]]) {
2622 tcg_gen_mov_i32(cpu_SR[par[0]], arg[0].in);
2623 }
09460970
MF
2624}
2625
59419607
MF
2626static void translate_wsr_mask(DisasContext *dc, const OpcodeArg arg[],
2627 const uint32_t par[])
168c12b0 2628{
59afd43d
MF
2629 if (sr_name[par[0]]) {
2630 tcg_gen_andi_i32(cpu_SR[par[0]], arg[0].in, par[2]);
2631 }
168c12b0
MF
2632}
2633
59419607
MF
2634static void translate_wsr_acchi(DisasContext *dc, const OpcodeArg arg[],
2635 const uint32_t par[])
168c12b0 2636{
59419607 2637 tcg_gen_ext8s_i32(cpu_SR[par[0]], arg[0].in);
168c12b0
MF
2638}
2639
59419607
MF
2640static void translate_wsr_ccompare(DisasContext *dc, const OpcodeArg arg[],
2641 const uint32_t par[])
168c12b0 2642{
59419607
MF
2643#ifndef CONFIG_USER_ONLY
2644 uint32_t id = par[0] - CCOMPARE;
2645 TCGv_i32 tmp = tcg_const_i32(id);
2646
2647 assert(id < dc->config->nccompare);
2648 if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
2649 gen_io_start();
2650 }
2651 tcg_gen_mov_i32(cpu_SR[par[0]], arg[0].in);
2652 gen_helper_update_ccompare(cpu_env, tmp);
2653 tcg_temp_free(tmp);
59419607 2654#endif
168c12b0
MF
2655}
2656
59419607
MF
2657static void translate_wsr_ccount(DisasContext *dc, const OpcodeArg arg[],
2658 const uint32_t par[])
09460970 2659{
59419607
MF
2660#ifndef CONFIG_USER_ONLY
2661 if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
2662 gen_io_start();
2663 }
2664 gen_helper_wsr_ccount(cpu_env, arg[0].in);
59419607 2665#endif
09460970
MF
2666}
2667
59419607
MF
2668static void translate_wsr_dbreaka(DisasContext *dc, const OpcodeArg arg[],
2669 const uint32_t par[])
168c12b0 2670{
59419607
MF
2671#ifndef CONFIG_USER_ONLY
2672 unsigned id = par[0] - DBREAKA;
2673 TCGv_i32 tmp = tcg_const_i32(id);
168c12b0 2674
59419607
MF
2675 assert(id < dc->config->ndbreak);
2676 gen_helper_wsr_dbreaka(cpu_env, tmp, arg[0].in);
6416d16f 2677 tcg_temp_free(tmp);
59419607 2678#endif
168c12b0
MF
2679}
2680
59419607
MF
2681static void translate_wsr_dbreakc(DisasContext *dc, const OpcodeArg arg[],
2682 const uint32_t par[])
2683{
2684#ifndef CONFIG_USER_ONLY
2685 unsigned id = par[0] - DBREAKC;
2686 TCGv_i32 tmp = tcg_const_i32(id);
2687
2688 assert(id < dc->config->ndbreak);
2689 gen_helper_wsr_dbreakc(cpu_env, tmp, arg[0].in);
2690 tcg_temp_free(tmp);
2691#endif
2692}
2693
2694static void translate_wsr_ibreaka(DisasContext *dc, const OpcodeArg arg[],
2695 const uint32_t par[])
2696{
2697#ifndef CONFIG_USER_ONLY
2698 unsigned id = par[0] - IBREAKA;
2699 TCGv_i32 tmp = tcg_const_i32(id);
2700
2701 assert(id < dc->config->nibreak);
2702 gen_helper_wsr_ibreaka(cpu_env, tmp, arg[0].in);
2703 tcg_temp_free(tmp);
2704#endif
2705}
2706
2707static void translate_wsr_ibreakenable(DisasContext *dc, const OpcodeArg arg[],
2708 const uint32_t par[])
2709{
2710#ifndef CONFIG_USER_ONLY
2711 gen_helper_wsr_ibreakenable(cpu_env, arg[0].in);
2712#endif
2713}
2714
2715static void translate_wsr_icount(DisasContext *dc, const OpcodeArg arg[],
2716 const uint32_t par[])
168c12b0 2717{
59419607
MF
2718#ifndef CONFIG_USER_ONLY
2719 if (dc->icount) {
2720 tcg_gen_mov_i32(dc->next_icount, arg[0].in);
6416d16f 2721 } else {
59419607 2722 tcg_gen_mov_i32(cpu_SR[par[0]], arg[0].in);
168c12b0 2723 }
59419607 2724#endif
168c12b0
MF
2725}
2726
59419607
MF
2727static void translate_wsr_intclear(DisasContext *dc, const OpcodeArg arg[],
2728 const uint32_t par[])
2729{
2730#ifndef CONFIG_USER_ONLY
2731 gen_helper_intclear(cpu_env, arg[0].in);
2732#endif
2733}
2734
2735static void translate_wsr_intset(DisasContext *dc, const OpcodeArg arg[],
2736 const uint32_t par[])
2737{
2738#ifndef CONFIG_USER_ONLY
2739 gen_helper_intset(cpu_env, arg[0].in);
2740#endif
2741}
2742
2743static void translate_wsr_memctl(DisasContext *dc, const OpcodeArg arg[],
2744 const uint32_t par[])
2745{
2746#ifndef CONFIG_USER_ONLY
2747 gen_helper_wsr_memctl(cpu_env, arg[0].in);
2748#endif
2749}
2750
4d04ea35
MF
2751static void translate_wsr_mpuenb(DisasContext *dc, const OpcodeArg arg[],
2752 const uint32_t par[])
2753{
2754#ifndef CONFIG_USER_ONLY
2755 gen_helper_wsr_mpuenb(cpu_env, arg[0].in);
2756#endif
2757}
2758
59419607
MF
2759static void translate_wsr_ps(DisasContext *dc, const OpcodeArg arg[],
2760 const uint32_t par[])
2761{
2762#ifndef CONFIG_USER_ONLY
2763 uint32_t mask = PS_WOE | PS_CALLINC | PS_OWB |
2764 PS_UM | PS_EXCM | PS_INTLEVEL;
2765
6c438056
MF
2766 if (option_enabled(dc, XTENSA_OPTION_MMU) ||
2767 option_enabled(dc, XTENSA_OPTION_MPU)) {
59419607
MF
2768 mask |= PS_RING;
2769 }
2770 tcg_gen_andi_i32(cpu_SR[par[0]], arg[0].in, mask);
2771#endif
2772}
2773
2774static void translate_wsr_rasid(DisasContext *dc, const OpcodeArg arg[],
2775 const uint32_t par[])
2776{
2777#ifndef CONFIG_USER_ONLY
2778 gen_helper_wsr_rasid(cpu_env, arg[0].in);
2779#endif
2780}
2781
2782static void translate_wsr_sar(DisasContext *dc, const OpcodeArg arg[],
2783 const uint32_t par[])
2784{
2785 tcg_gen_andi_i32(cpu_SR[par[0]], arg[0].in, 0x3f);
2786 if (dc->sar_m32_5bit) {
2787 tcg_gen_discard_i32(dc->sar_m32);
2788 }
2789 dc->sar_5bit = false;
2790 dc->sar_m32_5bit = false;
2791}
2792
2793static void translate_wsr_windowbase(DisasContext *dc, const OpcodeArg arg[],
2794 const uint32_t par[])
2795{
2796#ifndef CONFIG_USER_ONLY
2797 tcg_gen_mov_i32(cpu_windowbase_next, arg[0].in);
2798#endif
2799}
2800
2801static void translate_wsr_windowstart(DisasContext *dc, const OpcodeArg arg[],
2802 const uint32_t par[])
2803{
2804#ifndef CONFIG_USER_ONLY
2805 tcg_gen_andi_i32(cpu_SR[par[0]], arg[0].in,
2806 (1 << dc->config->nareg / 4) - 1);
2807#endif
2808}
2809
2810static void translate_wur(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2811 const uint32_t par[])
2812{
59419607 2813 tcg_gen_mov_i32(cpu_UR[par[0]], arg[0].in);
168c12b0
MF
2814}
2815
5680f207
MF
2816static void translate_wur_fpu2k_fcr(DisasContext *dc, const OpcodeArg arg[],
2817 const uint32_t par[])
59419607 2818{
5680f207 2819 gen_helper_wur_fpu2k_fcr(cpu_env, arg[0].in);
59419607
MF
2820}
2821
2822static void translate_wur_fsr(DisasContext *dc, const OpcodeArg arg[],
2823 const uint32_t par[])
2824{
2825 tcg_gen_andi_i32(cpu_UR[par[0]], arg[0].in, 0xffffff80);
2826}
2827
2828static void translate_xor(DisasContext *dc, const OpcodeArg arg[],
2829 const uint32_t par[])
09460970 2830{
59419607 2831 tcg_gen_xor_i32(arg[0].out, arg[1].in, arg[2].in);
09460970
MF
2832}
2833
b0b24bdc 2834static void translate_xsr(DisasContext *dc, const OpcodeArg arg[],
168c12b0
MF
2835 const uint32_t par[])
2836{
59afd43d
MF
2837 if (sr_name[par[0]]) {
2838 TCGv_i32 tmp = tcg_temp_new_i32();
168c12b0 2839
59afd43d
MF
2840 tcg_gen_mov_i32(tmp, arg[0].in);
2841 tcg_gen_mov_i32(arg[0].out, cpu_SR[par[0]]);
2842 tcg_gen_mov_i32(cpu_SR[par[0]], tmp);
2843 tcg_temp_free(tmp);
2844 } else {
2845 tcg_gen_movi_i32(arg[0].out, 0);
2846 }
59419607
MF
2847}
2848
2849static void translate_xsr_mask(DisasContext *dc, const OpcodeArg arg[],
2850 const uint32_t par[])
2851{
59afd43d
MF
2852 if (sr_name[par[0]]) {
2853 TCGv_i32 tmp = tcg_temp_new_i32();
59419607 2854
59afd43d
MF
2855 tcg_gen_mov_i32(tmp, arg[0].in);
2856 tcg_gen_mov_i32(arg[0].out, cpu_SR[par[0]]);
2857 tcg_gen_andi_i32(cpu_SR[par[0]], tmp, par[2]);
2858 tcg_temp_free(tmp);
2859 } else {
2860 tcg_gen_movi_i32(arg[0].out, 0);
2861 }
59419607
MF
2862}
2863
2864static void translate_xsr_ccount(DisasContext *dc, const OpcodeArg arg[],
2865 const uint32_t par[])
2866{
2867#ifndef CONFIG_USER_ONLY
2868 TCGv_i32 tmp = tcg_temp_new_i32();
2869
2870 if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) {
2871 gen_io_start();
2872 }
2873
2874 gen_helper_update_ccount(cpu_env);
2875 tcg_gen_mov_i32(tmp, cpu_SR[par[0]]);
2876 gen_helper_wsr_ccount(cpu_env, arg[0].in);
2877 tcg_gen_mov_i32(arg[0].out, tmp);
6416d16f 2878 tcg_temp_free(tmp);
59419607 2879
59419607 2880#endif
168c12b0
MF
2881}
2882
59419607
MF
2883#define gen_translate_xsr(name) \
2884 static void translate_xsr_##name(DisasContext *dc, const OpcodeArg arg[], \
2885 const uint32_t par[]) \
2886{ \
2887 TCGv_i32 tmp = tcg_temp_new_i32(); \
2888 \
59afd43d
MF
2889 if (sr_name[par[0]]) { \
2890 tcg_gen_mov_i32(tmp, cpu_SR[par[0]]); \
2891 } else { \
2892 tcg_gen_movi_i32(tmp, 0); \
2893 } \
59419607
MF
2894 translate_wsr_##name(dc, arg, par); \
2895 tcg_gen_mov_i32(arg[0].out, tmp); \
2896 tcg_temp_free(tmp); \
2897}
2898
2899gen_translate_xsr(acchi)
2900gen_translate_xsr(ccompare)
2901gen_translate_xsr(dbreaka)
2902gen_translate_xsr(dbreakc)
2903gen_translate_xsr(ibreaka)
2904gen_translate_xsr(ibreakenable)
2905gen_translate_xsr(icount)
2906gen_translate_xsr(memctl)
4d04ea35 2907gen_translate_xsr(mpuenb)
59419607
MF
2908gen_translate_xsr(ps)
2909gen_translate_xsr(rasid)
2910gen_translate_xsr(sar)
2911gen_translate_xsr(windowbase)
2912gen_translate_xsr(windowstart)
2913
2914#undef gen_translate_xsr
2915
168c12b0
MF
2916static const XtensaOpcodeOps core_ops[] = {
2917 {
2918 .name = "abs",
2919 .translate = translate_abs,
2920 }, {
d863fcf7
MF
2921 .name = (const char * const[]) {
2922 "add", "add.n", NULL,
2923 },
168c12b0 2924 .translate = translate_add,
d863fcf7 2925 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0 2926 }, {
d863fcf7
MF
2927 .name = (const char * const[]) {
2928 "addi", "addi.n", NULL,
2929 },
168c12b0 2930 .translate = translate_addi,
d863fcf7 2931 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0
MF
2932 }, {
2933 .name = "addmi",
2934 .translate = translate_addi,
2935 }, {
2936 .name = "addx2",
2937 .translate = translate_addx,
2938 .par = (const uint32_t[]){1},
2939 }, {
2940 .name = "addx4",
2941 .translate = translate_addx,
2942 .par = (const uint32_t[]){2},
2943 }, {
2944 .name = "addx8",
2945 .translate = translate_addx,
2946 .par = (const uint32_t[]){3},
2947 }, {
2948 .name = "all4",
2949 .translate = translate_all,
2950 .par = (const uint32_t[]){true, 4},
2951 }, {
2952 .name = "all8",
2953 .translate = translate_all,
2954 .par = (const uint32_t[]){true, 8},
2955 }, {
2956 .name = "and",
2957 .translate = translate_and,
2958 }, {
2959 .name = "andb",
2960 .translate = translate_boolean,
2961 .par = (const uint32_t[]){BOOLEAN_AND},
2962 }, {
2963 .name = "andbc",
2964 .translate = translate_boolean,
2965 .par = (const uint32_t[]){BOOLEAN_ANDC},
2966 }, {
2967 .name = "any4",
2968 .translate = translate_all,
2969 .par = (const uint32_t[]){false, 4},
2970 }, {
2971 .name = "any8",
2972 .translate = translate_all,
2973 .par = (const uint32_t[]){false, 8},
2974 }, {
fa6bc73c
MF
2975 .name = (const char * const[]) {
2976 "ball", "ball.w15", "ball.w18", NULL,
2977 },
168c12b0
MF
2978 .translate = translate_ball,
2979 .par = (const uint32_t[]){TCG_COND_EQ},
fa6bc73c 2980 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0 2981 }, {
fa6bc73c
MF
2982 .name = (const char * const[]) {
2983 "bany", "bany.w15", "bany.w18", NULL,
2984 },
168c12b0
MF
2985 .translate = translate_bany,
2986 .par = (const uint32_t[]){TCG_COND_NE},
fa6bc73c 2987 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0 2988 }, {
fa6bc73c
MF
2989 .name = (const char * const[]) {
2990 "bbc", "bbc.w15", "bbc.w18", NULL,
2991 },
168c12b0
MF
2992 .translate = translate_bb,
2993 .par = (const uint32_t[]){TCG_COND_EQ},
fa6bc73c 2994 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0 2995 }, {
fa6bc73c
MF
2996 .name = (const char * const[]) {
2997 "bbci", "bbci.w15", "bbci.w18", NULL,
2998 },
168c12b0
MF
2999 .translate = translate_bbi,
3000 .par = (const uint32_t[]){TCG_COND_EQ},
fa6bc73c 3001 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0 3002 }, {
fa6bc73c
MF
3003 .name = (const char * const[]) {
3004 "bbs", "bbs.w15", "bbs.w18", NULL,
3005 },
168c12b0
MF
3006 .translate = translate_bb,
3007 .par = (const uint32_t[]){TCG_COND_NE},
fa6bc73c 3008 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0 3009 }, {
fa6bc73c
MF
3010 .name = (const char * const[]) {
3011 "bbsi", "bbsi.w15", "bbsi.w18", NULL,
3012 },
168c12b0
MF
3013 .translate = translate_bbi,
3014 .par = (const uint32_t[]){TCG_COND_NE},
fa6bc73c 3015 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0 3016 }, {
fa6bc73c
MF
3017 .name = (const char * const[]) {
3018 "beq", "beq.w15", "beq.w18", NULL,
3019 },
168c12b0
MF
3020 .translate = translate_b,
3021 .par = (const uint32_t[]){TCG_COND_EQ},
fa6bc73c 3022 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0 3023 }, {
fa6bc73c
MF
3024 .name = (const char * const[]) {
3025 "beqi", "beqi.w15", "beqi.w18", NULL,
3026 },
168c12b0
MF
3027 .translate = translate_bi,
3028 .par = (const uint32_t[]){TCG_COND_EQ},
fa6bc73c 3029 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0 3030 }, {
d863fcf7 3031 .name = (const char * const[]) {
fa6bc73c 3032 "beqz", "beqz.n", "beqz.w15", "beqz.w18", NULL,
d863fcf7 3033 },
168c12b0
MF
3034 .translate = translate_bz,
3035 .par = (const uint32_t[]){TCG_COND_EQ},
d863fcf7 3036 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0
MF
3037 }, {
3038 .name = "bf",
3039 .translate = translate_bp,
3040 .par = (const uint32_t[]){TCG_COND_EQ},
3041 }, {
fa6bc73c
MF
3042 .name = (const char * const[]) {
3043 "bge", "bge.w15", "bge.w18", NULL,
3044 },
168c12b0
MF
3045 .translate = translate_b,
3046 .par = (const uint32_t[]){TCG_COND_GE},
fa6bc73c 3047 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0 3048 }, {
fa6bc73c
MF
3049 .name = (const char * const[]) {
3050 "bgei", "bgei.w15", "bgei.w18", NULL,
3051 },
168c12b0
MF
3052 .translate = translate_bi,
3053 .par = (const uint32_t[]){TCG_COND_GE},
fa6bc73c 3054 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0 3055 }, {
fa6bc73c
MF
3056 .name = (const char * const[]) {
3057 "bgeu", "bgeu.w15", "bgeu.w18", NULL,
3058 },
168c12b0
MF
3059 .translate = translate_b,
3060 .par = (const uint32_t[]){TCG_COND_GEU},
fa6bc73c 3061 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0 3062 }, {
fa6bc73c
MF
3063 .name = (const char * const[]) {
3064 "bgeui", "bgeui.w15", "bgeui.w18", NULL,
3065 },
168c12b0
MF
3066 .translate = translate_bi,
3067 .par = (const uint32_t[]){TCG_COND_GEU},
fa6bc73c 3068 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0 3069 }, {
fa6bc73c
MF
3070 .name = (const char * const[]) {
3071 "bgez", "bgez.w15", "bgez.w18", NULL,
3072 },
168c12b0
MF
3073 .translate = translate_bz,
3074 .par = (const uint32_t[]){TCG_COND_GE},
fa6bc73c 3075 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0 3076 }, {
fa6bc73c
MF
3077 .name = (const char * const[]) {
3078 "blt", "blt.w15", "blt.w18", NULL,
3079 },
168c12b0
MF
3080 .translate = translate_b,
3081 .par = (const uint32_t[]){TCG_COND_LT},
fa6bc73c 3082 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0 3083 }, {
fa6bc73c
MF
3084 .name = (const char * const[]) {
3085 "blti", "blti.w15", "blti.w18", NULL,
3086 },
168c12b0
MF
3087 .translate = translate_bi,
3088 .par = (const uint32_t[]){TCG_COND_LT},
fa6bc73c 3089 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0 3090 }, {
fa6bc73c
MF
3091 .name = (const char * const[]) {
3092 "bltu", "bltu.w15", "bltu.w18", NULL,
3093 },
168c12b0
MF
3094 .translate = translate_b,
3095 .par = (const uint32_t[]){TCG_COND_LTU},
fa6bc73c 3096 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0 3097 }, {
fa6bc73c
MF
3098 .name = (const char * const[]) {
3099 "bltui", "bltui.w15", "bltui.w18", NULL,
3100 },
168c12b0
MF
3101 .translate = translate_bi,
3102 .par = (const uint32_t[]){TCG_COND_LTU},
fa6bc73c 3103 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0 3104 }, {
fa6bc73c
MF
3105 .name = (const char * const[]) {
3106 "bltz", "bltz.w15", "bltz.w18", NULL,
3107 },
168c12b0
MF
3108 .translate = translate_bz,
3109 .par = (const uint32_t[]){TCG_COND_LT},
fa6bc73c 3110 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0 3111 }, {
fa6bc73c
MF
3112 .name = (const char * const[]) {
3113 "bnall", "bnall.w15", "bnall.w18", NULL,
3114 },
168c12b0
MF
3115 .translate = translate_ball,
3116 .par = (const uint32_t[]){TCG_COND_NE},
fa6bc73c 3117 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0 3118 }, {
fa6bc73c
MF
3119 .name = (const char * const[]) {
3120 "bne", "bne.w15", "bne.w18", NULL,
3121 },
168c12b0
MF
3122 .translate = translate_b,
3123 .par = (const uint32_t[]){TCG_COND_NE},
fa6bc73c 3124 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0 3125 }, {
fa6bc73c
MF
3126 .name = (const char * const[]) {
3127 "bnei", "bnei.w15", "bnei.w18", NULL,
3128 },
168c12b0
MF
3129 .translate = translate_bi,
3130 .par = (const uint32_t[]){TCG_COND_NE},
fa6bc73c 3131 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0 3132 }, {
d863fcf7 3133 .name = (const char * const[]) {
fa6bc73c 3134 "bnez", "bnez.n", "bnez.w15", "bnez.w18", NULL,
d863fcf7 3135 },
168c12b0
MF
3136 .translate = translate_bz,
3137 .par = (const uint32_t[]){TCG_COND_NE},
d863fcf7 3138 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0 3139 }, {
fa6bc73c
MF
3140 .name = (const char * const[]) {
3141 "bnone", "bnone.w15", "bnone.w18", NULL,
3142 },
168c12b0
MF
3143 .translate = translate_bany,
3144 .par = (const uint32_t[]){TCG_COND_EQ},
fa6bc73c 3145 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0
MF
3146 }, {
3147 .name = "break",
15477819 3148 .translate = translate_nop,
168c12b0 3149 .par = (const uint32_t[]){DEBUGCAUSE_BI},
15477819 3150 .op_flags = XTENSA_OP_DEBUG_BREAK,
168c12b0
MF
3151 }, {
3152 .name = "break.n",
15477819 3153 .translate = translate_nop,
168c12b0 3154 .par = (const uint32_t[]){DEBUGCAUSE_BN},
15477819 3155 .op_flags = XTENSA_OP_DEBUG_BREAK,
168c12b0
MF
3156 }, {
3157 .name = "bt",
3158 .translate = translate_bp,
3159 .par = (const uint32_t[]){TCG_COND_NE},
3160 }, {
3161 .name = "call0",
3162 .translate = translate_call0,
3163 }, {
3164 .name = "call12",
3165 .translate = translate_callw,
3166 .par = (const uint32_t[]){3},
3167 }, {
3168 .name = "call4",
3169 .translate = translate_callw,
3170 .par = (const uint32_t[]){1},
3171 }, {
3172 .name = "call8",
3173 .translate = translate_callw,
3174 .par = (const uint32_t[]){2},
3175 }, {
3176 .name = "callx0",
3177 .translate = translate_callx0,
3178 }, {
3179 .name = "callx12",
3180 .translate = translate_callxw,
3181 .par = (const uint32_t[]){3},
3182 }, {
3183 .name = "callx4",
3184 .translate = translate_callxw,
3185 .par = (const uint32_t[]){1},
3186 }, {
3187 .name = "callx8",
3188 .translate = translate_callxw,
3189 .par = (const uint32_t[]){2},
3190 }, {
3191 .name = "clamps",
3192 .translate = translate_clamps,
e9872741
MF
3193 }, {
3194 .name = "clrb_expstate",
3195 .translate = translate_clrb_expstate,
b345e140
MF
3196 }, {
3197 .name = "clrex",
3198 .translate = translate_clrex,
c5ac936e
MF
3199 }, {
3200 .name = "const16",
3201 .translate = translate_const16,
168c12b0
MF
3202 }, {
3203 .name = "depbits",
3204 .translate = translate_depbits,
3205 }, {
3206 .name = "dhi",
3207 .translate = translate_dcache,
21a2dad5 3208 .op_flags = XTENSA_OP_PRIVILEGED,
c884400f
MF
3209 }, {
3210 .name = "dhi.b",
3211 .translate = translate_nop,
168c12b0
MF
3212 }, {
3213 .name = "dhu",
3214 .translate = translate_dcache,
21a2dad5 3215 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
3216 }, {
3217 .name = "dhwb",
3218 .translate = translate_dcache,
c884400f
MF
3219 }, {
3220 .name = "dhwb.b",
3221 .translate = translate_nop,
168c12b0
MF
3222 }, {
3223 .name = "dhwbi",
3224 .translate = translate_dcache,
c884400f
MF
3225 }, {
3226 .name = "dhwbi.b",
3227 .translate = translate_nop,
168c12b0
MF
3228 }, {
3229 .name = "dii",
6416d16f 3230 .translate = translate_nop,
21a2dad5 3231 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
3232 }, {
3233 .name = "diu",
6416d16f 3234 .translate = translate_nop,
21a2dad5 3235 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
3236 }, {
3237 .name = "diwb",
6416d16f 3238 .translate = translate_nop,
21a2dad5 3239 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
3240 }, {
3241 .name = "diwbi",
6416d16f 3242 .translate = translate_nop,
21a2dad5 3243 .op_flags = XTENSA_OP_PRIVILEGED,
75eed0e5
MF
3244 }, {
3245 .name = "diwbui.p",
3246 .translate = translate_diwbuip,
3247 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
3248 }, {
3249 .name = "dpfl",
3250 .translate = translate_dcache,
21a2dad5 3251 .op_flags = XTENSA_OP_PRIVILEGED,
c884400f
MF
3252 }, {
3253 .name = "dpfm.b",
3254 .translate = translate_nop,
3255 }, {
3256 .name = "dpfm.bf",
3257 .translate = translate_nop,
168c12b0
MF
3258 }, {
3259 .name = "dpfr",
6416d16f 3260 .translate = translate_nop,
c884400f
MF
3261 }, {
3262 .name = "dpfr.b",
3263 .translate = translate_nop,
3264 }, {
3265 .name = "dpfr.bf",
3266 .translate = translate_nop,
168c12b0
MF
3267 }, {
3268 .name = "dpfro",
6416d16f 3269 .translate = translate_nop,
168c12b0
MF
3270 }, {
3271 .name = "dpfw",
6416d16f 3272 .translate = translate_nop,
c884400f
MF
3273 }, {
3274 .name = "dpfw.b",
3275 .translate = translate_nop,
3276 }, {
3277 .name = "dpfw.bf",
3278 .translate = translate_nop,
168c12b0
MF
3279 }, {
3280 .name = "dpfwo",
6416d16f 3281 .translate = translate_nop,
168c12b0
MF
3282 }, {
3283 .name = "dsync",
3284 .translate = translate_nop,
3285 }, {
3286 .name = "entry",
3287 .translate = translate_entry,
91dc2b2d 3288 .test_exceptions = test_exceptions_entry,
6416d16f 3289 .test_overflow = test_overflow_entry,
8df3fd35
MF
3290 .op_flags = XTENSA_OP_EXIT_TB_M1 |
3291 XTENSA_OP_SYNC_REGISTER_WINDOW,
168c12b0
MF
3292 }, {
3293 .name = "esync",
3294 .translate = translate_nop,
3295 }, {
3296 .name = "excw",
3297 .translate = translate_nop,
3298 }, {
3299 .name = "extui",
3300 .translate = translate_extui,
3301 }, {
3302 .name = "extw",
9fb40342 3303 .translate = translate_memw,
b345e140
MF
3304 }, {
3305 .name = "getex",
3306 .translate = translate_getex,
13f6a7cd
MF
3307 }, {
3308 .name = "hwwdtlba",
09460970 3309 .op_flags = XTENSA_OP_ILL,
13f6a7cd
MF
3310 }, {
3311 .name = "hwwitlba",
09460970 3312 .op_flags = XTENSA_OP_ILL,
168c12b0
MF
3313 }, {
3314 .name = "idtlb",
3315 .translate = translate_itlb,
3316 .par = (const uint32_t[]){true},
226444a8 3317 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_M1,
168c12b0
MF
3318 }, {
3319 .name = "ihi",
3320 .translate = translate_icache,
168c12b0
MF
3321 }, {
3322 .name = "ihu",
3323 .translate = translate_icache,
21a2dad5 3324 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
3325 }, {
3326 .name = "iii",
6416d16f 3327 .translate = translate_nop,
21a2dad5 3328 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
3329 }, {
3330 .name = "iitlb",
3331 .translate = translate_itlb,
3332 .par = (const uint32_t[]){false},
226444a8 3333 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_M1,
168c12b0
MF
3334 }, {
3335 .name = "iiu",
6416d16f 3336 .translate = translate_nop,
21a2dad5 3337 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0 3338 }, {
d863fcf7
MF
3339 .name = (const char * const[]) {
3340 "ill", "ill.n", NULL,
3341 },
3342 .op_flags = XTENSA_OP_ILL | XTENSA_OP_NAME_ARRAY,
168c12b0
MF
3343 }, {
3344 .name = "ipf",
6416d16f 3345 .translate = translate_nop,
168c12b0
MF
3346 }, {
3347 .name = "ipfl",
3348 .translate = translate_icache,
21a2dad5 3349 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
3350 }, {
3351 .name = "isync",
3352 .translate = translate_nop,
3353 }, {
3354 .name = "j",
3355 .translate = translate_j,
3356 }, {
3357 .name = "jx",
3358 .translate = translate_jx,
3359 }, {
3360 .name = "l16si",
3361 .translate = translate_ldst,
3362 .par = (const uint32_t[]){MO_TESW, false, false},
068e538a 3363 .op_flags = XTENSA_OP_LOAD,
168c12b0
MF
3364 }, {
3365 .name = "l16ui",
3366 .translate = translate_ldst,
3367 .par = (const uint32_t[]){MO_TEUW, false, false},
068e538a 3368 .op_flags = XTENSA_OP_LOAD,
168c12b0
MF
3369 }, {
3370 .name = "l32ai",
3371 .translate = translate_ldst,
3372 .par = (const uint32_t[]){MO_TEUL, true, false},
068e538a 3373 .op_flags = XTENSA_OP_LOAD,
168c12b0
MF
3374 }, {
3375 .name = "l32e",
3376 .translate = translate_l32e,
068e538a 3377 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_LOAD,
b345e140
MF
3378 }, {
3379 .name = "l32ex",
3380 .translate = translate_l32ex,
3381 .op_flags = XTENSA_OP_LOAD,
168c12b0 3382 }, {
d863fcf7
MF
3383 .name = (const char * const[]) {
3384 "l32i", "l32i.n", NULL,
3385 },
168c12b0
MF
3386 .translate = translate_ldst,
3387 .par = (const uint32_t[]){MO_TEUL, false, false},
068e538a 3388 .op_flags = XTENSA_OP_NAME_ARRAY | XTENSA_OP_LOAD,
168c12b0
MF
3389 }, {
3390 .name = "l32r",
3391 .translate = translate_l32r,
068e538a 3392 .op_flags = XTENSA_OP_LOAD,
168c12b0
MF
3393 }, {
3394 .name = "l8ui",
3395 .translate = translate_ldst,
3396 .par = (const uint32_t[]){MO_UB, false, false},
068e538a 3397 .op_flags = XTENSA_OP_LOAD,
168c12b0
MF
3398 }, {
3399 .name = "lddec",
3400 .translate = translate_mac16,
7aa78341 3401 .par = (const uint32_t[]){MAC16_NONE, 0, -4},
068e538a 3402 .op_flags = XTENSA_OP_LOAD,
168c12b0
MF
3403 }, {
3404 .name = "ldinc",
3405 .translate = translate_mac16,
7aa78341 3406 .par = (const uint32_t[]){MAC16_NONE, 0, 4},
068e538a 3407 .op_flags = XTENSA_OP_LOAD,
13f6a7cd
MF
3408 }, {
3409 .name = "ldpte",
09460970 3410 .op_flags = XTENSA_OP_ILL,
168c12b0 3411 }, {
fa6bc73c
MF
3412 .name = (const char * const[]) {
3413 "loop", "loop.w15", NULL,
3414 },
168c12b0
MF
3415 .translate = translate_loop,
3416 .par = (const uint32_t[]){TCG_COND_NEVER},
fa6bc73c 3417 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0 3418 }, {
fa6bc73c
MF
3419 .name = (const char * const[]) {
3420 "loopgtz", "loopgtz.w15", NULL,
3421 },
168c12b0
MF
3422 .translate = translate_loop,
3423 .par = (const uint32_t[]){TCG_COND_GT},
fa6bc73c 3424 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0 3425 }, {
fa6bc73c
MF
3426 .name = (const char * const[]) {
3427 "loopnez", "loopnez.w15", NULL,
3428 },
168c12b0
MF
3429 .translate = translate_loop,
3430 .par = (const uint32_t[]){TCG_COND_NE},
fa6bc73c 3431 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0
MF
3432 }, {
3433 .name = "max",
426afc3b 3434 .translate = translate_smax,
168c12b0
MF
3435 }, {
3436 .name = "maxu",
426afc3b 3437 .translate = translate_umax,
168c12b0
MF
3438 }, {
3439 .name = "memw",
9fb40342 3440 .translate = translate_memw,
168c12b0
MF
3441 }, {
3442 .name = "min",
426afc3b 3443 .translate = translate_smin,
168c12b0
MF
3444 }, {
3445 .name = "minu",
426afc3b 3446 .translate = translate_umin,
168c12b0 3447 }, {
d863fcf7
MF
3448 .name = (const char * const[]) {
3449 "mov", "mov.n", NULL,
3450 },
168c12b0 3451 .translate = translate_mov,
d863fcf7 3452 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0
MF
3453 }, {
3454 .name = "moveqz",
3455 .translate = translate_movcond,
3456 .par = (const uint32_t[]){TCG_COND_EQ},
3457 }, {
3458 .name = "movf",
3459 .translate = translate_movp,
3460 .par = (const uint32_t[]){TCG_COND_EQ},
3461 }, {
3462 .name = "movgez",
3463 .translate = translate_movcond,
3464 .par = (const uint32_t[]){TCG_COND_GE},
3465 }, {
3466 .name = "movi",
3467 .translate = translate_movi,
3468 }, {
3469 .name = "movi.n",
3470 .translate = translate_movi,
3471 }, {
3472 .name = "movltz",
3473 .translate = translate_movcond,
3474 .par = (const uint32_t[]){TCG_COND_LT},
3475 }, {
3476 .name = "movnez",
3477 .translate = translate_movcond,
3478 .par = (const uint32_t[]){TCG_COND_NE},
3479 }, {
3480 .name = "movsp",
3481 .translate = translate_movsp,
90d6494d 3482 .op_flags = XTENSA_OP_ALLOCA,
168c12b0
MF
3483 }, {
3484 .name = "movt",
3485 .translate = translate_movp,
3486 .par = (const uint32_t[]){TCG_COND_NE},
3487 }, {
3488 .name = "mul.aa.hh",
3489 .translate = translate_mac16,
7aa78341 3490 .par = (const uint32_t[]){MAC16_MUL, MAC16_HH, 0},
168c12b0
MF
3491 }, {
3492 .name = "mul.aa.hl",
3493 .translate = translate_mac16,
7aa78341 3494 .par = (const uint32_t[]){MAC16_MUL, MAC16_HL, 0},
168c12b0
MF
3495 }, {
3496 .name = "mul.aa.lh",
3497 .translate = translate_mac16,
7aa78341 3498 .par = (const uint32_t[]){MAC16_MUL, MAC16_LH, 0},
168c12b0
MF
3499 }, {
3500 .name = "mul.aa.ll",
3501 .translate = translate_mac16,
7aa78341 3502 .par = (const uint32_t[]){MAC16_MUL, MAC16_LL, 0},
168c12b0
MF
3503 }, {
3504 .name = "mul.ad.hh",
3505 .translate = translate_mac16,
7aa78341 3506 .par = (const uint32_t[]){MAC16_MUL, MAC16_HH, 0},
168c12b0
MF
3507 }, {
3508 .name = "mul.ad.hl",
3509 .translate = translate_mac16,
7aa78341 3510 .par = (const uint32_t[]){MAC16_MUL, MAC16_HL, 0},
168c12b0
MF
3511 }, {
3512 .name = "mul.ad.lh",
3513 .translate = translate_mac16,
7aa78341 3514 .par = (const uint32_t[]){MAC16_MUL, MAC16_LH, 0},
168c12b0
MF
3515 }, {
3516 .name = "mul.ad.ll",
3517 .translate = translate_mac16,
7aa78341 3518 .par = (const uint32_t[]){MAC16_MUL, MAC16_LL, 0},
168c12b0
MF
3519 }, {
3520 .name = "mul.da.hh",
3521 .translate = translate_mac16,
7aa78341 3522 .par = (const uint32_t[]){MAC16_MUL, MAC16_HH, 0},
168c12b0
MF
3523 }, {
3524 .name = "mul.da.hl",
3525 .translate = translate_mac16,
7aa78341 3526 .par = (const uint32_t[]){MAC16_MUL, MAC16_HL, 0},
168c12b0
MF
3527 }, {
3528 .name = "mul.da.lh",
3529 .translate = translate_mac16,
7aa78341 3530 .par = (const uint32_t[]){MAC16_MUL, MAC16_LH, 0},
168c12b0
MF
3531 }, {
3532 .name = "mul.da.ll",
3533 .translate = translate_mac16,
7aa78341 3534 .par = (const uint32_t[]){MAC16_MUL, MAC16_LL, 0},
168c12b0
MF
3535 }, {
3536 .name = "mul.dd.hh",
3537 .translate = translate_mac16,
7aa78341 3538 .par = (const uint32_t[]){MAC16_MUL, MAC16_HH, 0},
168c12b0
MF
3539 }, {
3540 .name = "mul.dd.hl",
3541 .translate = translate_mac16,
7aa78341 3542 .par = (const uint32_t[]){MAC16_MUL, MAC16_HL, 0},
168c12b0
MF
3543 }, {
3544 .name = "mul.dd.lh",
3545 .translate = translate_mac16,
7aa78341 3546 .par = (const uint32_t[]){MAC16_MUL, MAC16_LH, 0},
168c12b0
MF
3547 }, {
3548 .name = "mul.dd.ll",
3549 .translate = translate_mac16,
7aa78341 3550 .par = (const uint32_t[]){MAC16_MUL, MAC16_LL, 0},
168c12b0
MF
3551 }, {
3552 .name = "mul16s",
3553 .translate = translate_mul16,
3554 .par = (const uint32_t[]){true},
3555 }, {
3556 .name = "mul16u",
3557 .translate = translate_mul16,
3558 .par = (const uint32_t[]){false},
3559 }, {
3560 .name = "mula.aa.hh",
3561 .translate = translate_mac16,
7aa78341 3562 .par = (const uint32_t[]){MAC16_MULA, MAC16_HH, 0},
168c12b0
MF
3563 }, {
3564 .name = "mula.aa.hl",
3565 .translate = translate_mac16,
7aa78341 3566 .par = (const uint32_t[]){MAC16_MULA, MAC16_HL, 0},
168c12b0
MF
3567 }, {
3568 .name = "mula.aa.lh",
3569 .translate = translate_mac16,
7aa78341 3570 .par = (const uint32_t[]){MAC16_MULA, MAC16_LH, 0},
168c12b0
MF
3571 }, {
3572 .name = "mula.aa.ll",
3573 .translate = translate_mac16,
7aa78341 3574 .par = (const uint32_t[]){MAC16_MULA, MAC16_LL, 0},
168c12b0
MF
3575 }, {
3576 .name = "mula.ad.hh",
3577 .translate = translate_mac16,
7aa78341 3578 .par = (const uint32_t[]){MAC16_MULA, MAC16_HH, 0},
168c12b0
MF
3579 }, {
3580 .name = "mula.ad.hl",
3581 .translate = translate_mac16,
7aa78341 3582 .par = (const uint32_t[]){MAC16_MULA, MAC16_HL, 0},
168c12b0
MF
3583 }, {
3584 .name = "mula.ad.lh",
3585 .translate = translate_mac16,
7aa78341 3586 .par = (const uint32_t[]){MAC16_MULA, MAC16_LH, 0},
168c12b0
MF
3587 }, {
3588 .name = "mula.ad.ll",
3589 .translate = translate_mac16,
7aa78341 3590 .par = (const uint32_t[]){MAC16_MULA, MAC16_LL, 0},
168c12b0
MF
3591 }, {
3592 .name = "mula.da.hh",
3593 .translate = translate_mac16,
7aa78341 3594 .par = (const uint32_t[]){MAC16_MULA, MAC16_HH, 0},
168c12b0
MF
3595 }, {
3596 .name = "mula.da.hh.lddec",
3597 .translate = translate_mac16,
7aa78341 3598 .par = (const uint32_t[]){MAC16_MULA, MAC16_HH, -4},
168c12b0
MF
3599 }, {
3600 .name = "mula.da.hh.ldinc",
3601 .translate = translate_mac16,
7aa78341 3602 .par = (const uint32_t[]){MAC16_MULA, MAC16_HH, 4},
168c12b0
MF
3603 }, {
3604 .name = "mula.da.hl",
3605 .translate = translate_mac16,
7aa78341 3606 .par = (const uint32_t[]){MAC16_MULA, MAC16_HL, 0},
168c12b0
MF
3607 }, {
3608 .name = "mula.da.hl.lddec",
3609 .translate = translate_mac16,
7aa78341 3610 .par = (const uint32_t[]){MAC16_MULA, MAC16_HL, -4},
168c12b0
MF
3611 }, {
3612 .name = "mula.da.hl.ldinc",
3613 .translate = translate_mac16,
7aa78341 3614 .par = (const uint32_t[]){MAC16_MULA, MAC16_HL, 4},
168c12b0
MF
3615 }, {
3616 .name = "mula.da.lh",
3617 .translate = translate_mac16,
7aa78341 3618 .par = (const uint32_t[]){MAC16_MULA, MAC16_LH, 0},
168c12b0
MF
3619 }, {
3620 .name = "mula.da.lh.lddec",
3621 .translate = translate_mac16,
7aa78341 3622 .par = (const uint32_t[]){MAC16_MULA, MAC16_LH, -4},
168c12b0
MF
3623 }, {
3624 .name = "mula.da.lh.ldinc",
3625 .translate = translate_mac16,
7aa78341 3626 .par = (const uint32_t[]){MAC16_MULA, MAC16_LH, 4},
168c12b0
MF
3627 }, {
3628 .name = "mula.da.ll",
3629 .translate = translate_mac16,
7aa78341 3630 .par = (const uint32_t[]){MAC16_MULA, MAC16_LL, 0},
168c12b0
MF
3631 }, {
3632 .name = "mula.da.ll.lddec",
3633 .translate = translate_mac16,
7aa78341 3634 .par = (const uint32_t[]){MAC16_MULA, MAC16_LL, -4},
168c12b0
MF
3635 }, {
3636 .name = "mula.da.ll.ldinc",
3637 .translate = translate_mac16,
7aa78341 3638 .par = (const uint32_t[]){MAC16_MULA, MAC16_LL, 4},
168c12b0
MF
3639 }, {
3640 .name = "mula.dd.hh",
3641 .translate = translate_mac16,
7aa78341 3642 .par = (const uint32_t[]){MAC16_MULA, MAC16_HH, 0},
168c12b0
MF
3643 }, {
3644 .name = "mula.dd.hh.lddec",
3645 .translate = translate_mac16,
7aa78341 3646 .par = (const uint32_t[]){MAC16_MULA, MAC16_HH, -4},
168c12b0
MF
3647 }, {
3648 .name = "mula.dd.hh.ldinc",
3649 .translate = translate_mac16,
7aa78341 3650 .par = (const uint32_t[]){MAC16_MULA, MAC16_HH, 4},
168c12b0
MF
3651 }, {
3652 .name = "mula.dd.hl",
3653 .translate = translate_mac16,
7aa78341 3654 .par = (const uint32_t[]){MAC16_MULA, MAC16_HL, 0},
168c12b0
MF
3655 }, {
3656 .name = "mula.dd.hl.lddec",
3657 .translate = translate_mac16,
7aa78341 3658 .par = (const uint32_t[]){MAC16_MULA, MAC16_HL, -4},
168c12b0
MF
3659 }, {
3660 .name = "mula.dd.hl.ldinc",
3661 .translate = translate_mac16,
7aa78341 3662 .par = (const uint32_t[]){MAC16_MULA, MAC16_HL, 4},
168c12b0
MF
3663 }, {
3664 .name = "mula.dd.lh",
3665 .translate = translate_mac16,
7aa78341 3666 .par = (const uint32_t[]){MAC16_MULA, MAC16_LH, 0},
168c12b0
MF
3667 }, {
3668 .name = "mula.dd.lh.lddec",
3669 .translate = translate_mac16,
7aa78341 3670 .par = (const uint32_t[]){MAC16_MULA, MAC16_LH, -4},
168c12b0
MF
3671 }, {
3672 .name = "mula.dd.lh.ldinc",
3673 .translate = translate_mac16,
7aa78341 3674 .par = (const uint32_t[]){MAC16_MULA, MAC16_LH, 4},
168c12b0
MF
3675 }, {
3676 .name = "mula.dd.ll",
3677 .translate = translate_mac16,
7aa78341 3678 .par = (const uint32_t[]){MAC16_MULA, MAC16_LL, 0},
168c12b0
MF
3679 }, {
3680 .name = "mula.dd.ll.lddec",
3681 .translate = translate_mac16,
7aa78341 3682 .par = (const uint32_t[]){MAC16_MULA, MAC16_LL, -4},
168c12b0
MF
3683 }, {
3684 .name = "mula.dd.ll.ldinc",
3685 .translate = translate_mac16,
7aa78341 3686 .par = (const uint32_t[]){MAC16_MULA, MAC16_LL, 4},
168c12b0
MF
3687 }, {
3688 .name = "mull",
3689 .translate = translate_mull,
3690 }, {
3691 .name = "muls.aa.hh",
3692 .translate = translate_mac16,
7aa78341 3693 .par = (const uint32_t[]){MAC16_MULS, MAC16_HH, 0},
168c12b0
MF
3694 }, {
3695 .name = "muls.aa.hl",
3696 .translate = translate_mac16,
7aa78341 3697 .par = (const uint32_t[]){MAC16_MULS, MAC16_HL, 0},
168c12b0
MF
3698 }, {
3699 .name = "muls.aa.lh",
3700 .translate = translate_mac16,
7aa78341 3701 .par = (const uint32_t[]){MAC16_MULS, MAC16_LH, 0},
168c12b0
MF
3702 }, {
3703 .name = "muls.aa.ll",
3704 .translate = translate_mac16,
7aa78341 3705 .par = (const uint32_t[]){MAC16_MULS, MAC16_LL, 0},
168c12b0
MF
3706 }, {
3707 .name = "muls.ad.hh",
3708 .translate = translate_mac16,
7aa78341 3709 .par = (const uint32_t[]){MAC16_MULS, MAC16_HH, 0},
168c12b0
MF
3710 }, {
3711 .name = "muls.ad.hl",
3712 .translate = translate_mac16,
7aa78341 3713 .par = (const uint32_t[]){MAC16_MULS, MAC16_HL, 0},
168c12b0
MF
3714 }, {
3715 .name = "muls.ad.lh",
3716 .translate = translate_mac16,
7aa78341 3717 .par = (const uint32_t[]){MAC16_MULS, MAC16_LH, 0},
168c12b0
MF
3718 }, {
3719 .name = "muls.ad.ll",
3720 .translate = translate_mac16,
7aa78341 3721 .par = (const uint32_t[]){MAC16_MULS, MAC16_LL, 0},
168c12b0
MF
3722 }, {
3723 .name = "muls.da.hh",
3724 .translate = translate_mac16,
7aa78341 3725 .par = (const uint32_t[]){MAC16_MULS, MAC16_HH, 0},
168c12b0
MF
3726 }, {
3727 .name = "muls.da.hl",
3728 .translate = translate_mac16,
7aa78341 3729 .par = (const uint32_t[]){MAC16_MULS, MAC16_HL, 0},
168c12b0
MF
3730 }, {
3731 .name = "muls.da.lh",
3732 .translate = translate_mac16,
7aa78341 3733 .par = (const uint32_t[]){MAC16_MULS, MAC16_LH, 0},
168c12b0
MF
3734 }, {
3735 .name = "muls.da.ll",
3736 .translate = translate_mac16,
7aa78341 3737 .par = (const uint32_t[]){MAC16_MULS, MAC16_LL, 0},
168c12b0
MF
3738 }, {
3739 .name = "muls.dd.hh",
3740 .translate = translate_mac16,
7aa78341 3741 .par = (const uint32_t[]){MAC16_MULS, MAC16_HH, 0},
168c12b0
MF
3742 }, {
3743 .name = "muls.dd.hl",
3744 .translate = translate_mac16,
7aa78341 3745 .par = (const uint32_t[]){MAC16_MULS, MAC16_HL, 0},
168c12b0
MF
3746 }, {
3747 .name = "muls.dd.lh",
3748 .translate = translate_mac16,
7aa78341 3749 .par = (const uint32_t[]){MAC16_MULS, MAC16_LH, 0},
168c12b0
MF
3750 }, {
3751 .name = "muls.dd.ll",
3752 .translate = translate_mac16,
7aa78341 3753 .par = (const uint32_t[]){MAC16_MULS, MAC16_LL, 0},
168c12b0
MF
3754 }, {
3755 .name = "mulsh",
3756 .translate = translate_mulh,
3757 .par = (const uint32_t[]){true},
3758 }, {
3759 .name = "muluh",
3760 .translate = translate_mulh,
3761 .par = (const uint32_t[]){false},
3762 }, {
3763 .name = "neg",
3764 .translate = translate_neg,
3765 }, {
d863fcf7
MF
3766 .name = (const char * const[]) {
3767 "nop", "nop.n", NULL,
3768 },
168c12b0 3769 .translate = translate_nop,
d863fcf7 3770 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0
MF
3771 }, {
3772 .name = "nsa",
3773 .translate = translate_nsa,
3774 }, {
3775 .name = "nsau",
3776 .translate = translate_nsau,
3777 }, {
3778 .name = "or",
3779 .translate = translate_or,
3780 }, {
3781 .name = "orb",
3782 .translate = translate_boolean,
3783 .par = (const uint32_t[]){BOOLEAN_OR},
3784 }, {
3785 .name = "orbc",
3786 .translate = translate_boolean,
3787 .par = (const uint32_t[]){BOOLEAN_ORC},
3788 }, {
3789 .name = "pdtlb",
3790 .translate = translate_ptlb,
3791 .par = (const uint32_t[]){true},
21a2dad5 3792 .op_flags = XTENSA_OP_PRIVILEGED,
c884400f
MF
3793 }, {
3794 .name = "pfend.a",
3795 .translate = translate_nop,
3796 }, {
3797 .name = "pfend.o",
3798 .translate = translate_nop,
3799 }, {
3800 .name = "pfnxt.f",
3801 .translate = translate_nop,
3802 }, {
3803 .name = "pfwait.a",
3804 .translate = translate_nop,
3805 }, {
1a03362b 3806 .name = "pfwait.r",
c884400f 3807 .translate = translate_nop,
168c12b0
MF
3808 }, {
3809 .name = "pitlb",
3810 .translate = translate_ptlb,
3811 .par = (const uint32_t[]){false},
21a2dad5 3812 .op_flags = XTENSA_OP_PRIVILEGED,
4d04ea35
MF
3813 }, {
3814 .name = "pptlb",
3815 .translate = translate_pptlb,
3816 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
3817 }, {
3818 .name = "quos",
3819 .translate = translate_quos,
3820 .par = (const uint32_t[]){true},
4a038955 3821 .op_flags = XTENSA_OP_DIVIDE_BY_ZERO,
168c12b0
MF
3822 }, {
3823 .name = "quou",
3824 .translate = translate_quou,
4a038955 3825 .op_flags = XTENSA_OP_DIVIDE_BY_ZERO,
168c12b0
MF
3826 }, {
3827 .name = "rdtlb0",
3828 .translate = translate_rtlb,
3829 .par = (const uint32_t[]){true, 0},
21a2dad5 3830 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
3831 }, {
3832 .name = "rdtlb1",
3833 .translate = translate_rtlb,
3834 .par = (const uint32_t[]){true, 1},
21a2dad5 3835 .op_flags = XTENSA_OP_PRIVILEGED,
e9872741
MF
3836 }, {
3837 .name = "read_impwire",
3838 .translate = translate_read_impwire,
168c12b0
MF
3839 }, {
3840 .name = "rems",
3841 .translate = translate_quos,
3842 .par = (const uint32_t[]){false},
4a038955 3843 .op_flags = XTENSA_OP_DIVIDE_BY_ZERO,
168c12b0
MF
3844 }, {
3845 .name = "remu",
4a038955
MF
3846 .translate = translate_remu,
3847 .op_flags = XTENSA_OP_DIVIDE_BY_ZERO,
168c12b0
MF
3848 }, {
3849 .name = "rer",
3850 .translate = translate_rer,
21a2dad5 3851 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0 3852 }, {
d863fcf7
MF
3853 .name = (const char * const[]) {
3854 "ret", "ret.n", NULL,
3855 },
168c12b0 3856 .translate = translate_ret,
d863fcf7 3857 .op_flags = XTENSA_OP_NAME_ARRAY,
168c12b0 3858 }, {
d863fcf7
MF
3859 .name = (const char * const[]) {
3860 "retw", "retw.n", NULL,
3861 },
168c12b0 3862 .translate = translate_retw,
91dc2b2d 3863 .test_exceptions = test_exceptions_retw,
d863fcf7 3864 .op_flags = XTENSA_OP_UNDERFLOW | XTENSA_OP_NAME_ARRAY,
13f6a7cd
MF
3865 }, {
3866 .name = "rfdd",
09460970 3867 .op_flags = XTENSA_OP_ILL,
168c12b0
MF
3868 }, {
3869 .name = "rfde",
3870 .translate = translate_rfde,
21a2dad5 3871 .op_flags = XTENSA_OP_PRIVILEGED,
13f6a7cd
MF
3872 }, {
3873 .name = "rfdo",
09460970 3874 .op_flags = XTENSA_OP_ILL,
168c12b0
MF
3875 }, {
3876 .name = "rfe",
3877 .translate = translate_rfe,
d74624e5 3878 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_CHECK_INTERRUPTS,
168c12b0
MF
3879 }, {
3880 .name = "rfi",
3881 .translate = translate_rfi,
d74624e5 3882 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_CHECK_INTERRUPTS,
168c12b0
MF
3883 }, {
3884 .name = "rfwo",
3885 .translate = translate_rfw,
3886 .par = (const uint32_t[]){true},
d74624e5 3887 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_CHECK_INTERRUPTS,
168c12b0
MF
3888 }, {
3889 .name = "rfwu",
3890 .translate = translate_rfw,
3891 .par = (const uint32_t[]){false},
d74624e5 3892 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_CHECK_INTERRUPTS,
168c12b0
MF
3893 }, {
3894 .name = "ritlb0",
3895 .translate = translate_rtlb,
3896 .par = (const uint32_t[]){false, 0},
21a2dad5 3897 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
3898 }, {
3899 .name = "ritlb1",
3900 .translate = translate_rtlb,
3901 .par = (const uint32_t[]){false, 1},
21a2dad5 3902 .op_flags = XTENSA_OP_PRIVILEGED,
4d04ea35
MF
3903 }, {
3904 .name = "rptlb0",
3905 .translate = translate_rptlb0,
3906 .op_flags = XTENSA_OP_PRIVILEGED,
3907 }, {
3908 .name = "rptlb1",
3909 .translate = translate_rptlb1,
3910 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
3911 }, {
3912 .name = "rotw",
3913 .translate = translate_rotw,
8df3fd35
MF
3914 .op_flags = XTENSA_OP_PRIVILEGED |
3915 XTENSA_OP_EXIT_TB_M1 |
3916 XTENSA_OP_SYNC_REGISTER_WINDOW,
168c12b0
MF
3917 }, {
3918 .name = "rsil",
3919 .translate = translate_rsil,
d74624e5
MF
3920 .op_flags =
3921 XTENSA_OP_PRIVILEGED |
3922 XTENSA_OP_EXIT_TB_0 |
3923 XTENSA_OP_CHECK_INTERRUPTS,
168c12b0
MF
3924 }, {
3925 .name = "rsr.176",
3926 .translate = translate_rsr,
3927 .par = (const uint32_t[]){176},
21a2dad5 3928 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
3929 }, {
3930 .name = "rsr.208",
3931 .translate = translate_rsr,
3932 .par = (const uint32_t[]){208},
21a2dad5 3933 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
3934 }, {
3935 .name = "rsr.acchi",
3936 .translate = translate_rsr,
91dc2b2d 3937 .test_exceptions = test_exceptions_sr,
59419607
MF
3938 .par = (const uint32_t[]){
3939 ACCHI,
3940 XTENSA_OPTION_MAC16,
3941 },
168c12b0
MF
3942 }, {
3943 .name = "rsr.acclo",
3944 .translate = translate_rsr,
91dc2b2d 3945 .test_exceptions = test_exceptions_sr,
59419607
MF
3946 .par = (const uint32_t[]){
3947 ACCLO,
3948 XTENSA_OPTION_MAC16,
3949 },
168c12b0
MF
3950 }, {
3951 .name = "rsr.atomctl",
3952 .translate = translate_rsr,
91dc2b2d 3953 .test_exceptions = test_exceptions_sr,
59419607
MF
3954 .par = (const uint32_t[]){
3955 ATOMCTL,
3956 XTENSA_OPTION_ATOMCTL,
3957 },
21a2dad5 3958 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
3959 }, {
3960 .name = "rsr.br",
3961 .translate = translate_rsr,
91dc2b2d 3962 .test_exceptions = test_exceptions_sr,
59419607
MF
3963 .par = (const uint32_t[]){
3964 BR,
3965 XTENSA_OPTION_BOOLEAN,
3966 },
4d04ea35
MF
3967 }, {
3968 .name = "rsr.cacheadrdis",
3969 .translate = translate_rsr,
91dc2b2d 3970 .test_exceptions = test_exceptions_sr,
4d04ea35
MF
3971 .par = (const uint32_t[]){
3972 CACHEADRDIS,
3973 XTENSA_OPTION_MPU,
3974 },
3975 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
3976 }, {
3977 .name = "rsr.cacheattr",
3978 .translate = translate_rsr,
91dc2b2d 3979 .test_exceptions = test_exceptions_sr,
59419607
MF
3980 .par = (const uint32_t[]){
3981 CACHEATTR,
3982 XTENSA_OPTION_CACHEATTR,
3983 },
21a2dad5 3984 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
3985 }, {
3986 .name = "rsr.ccompare0",
3987 .translate = translate_rsr,
91dc2b2d 3988 .test_exceptions = test_exceptions_ccompare,
59419607
MF
3989 .par = (const uint32_t[]){
3990 CCOMPARE,
3991 XTENSA_OPTION_TIMER_INTERRUPT,
3992 },
21a2dad5 3993 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
3994 }, {
3995 .name = "rsr.ccompare1",
3996 .translate = translate_rsr,
91dc2b2d 3997 .test_exceptions = test_exceptions_ccompare,
59419607
MF
3998 .par = (const uint32_t[]){
3999 CCOMPARE + 1,
4000 XTENSA_OPTION_TIMER_INTERRUPT,
4001 },
21a2dad5 4002 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4003 }, {
4004 .name = "rsr.ccompare2",
4005 .translate = translate_rsr,
91dc2b2d 4006 .test_exceptions = test_exceptions_ccompare,
59419607
MF
4007 .par = (const uint32_t[]){
4008 CCOMPARE + 2,
4009 XTENSA_OPTION_TIMER_INTERRUPT,
4010 },
21a2dad5 4011 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4012 }, {
4013 .name = "rsr.ccount",
59419607 4014 .translate = translate_rsr_ccount,
91dc2b2d 4015 .test_exceptions = test_exceptions_sr,
59419607
MF
4016 .par = (const uint32_t[]){
4017 CCOUNT,
4018 XTENSA_OPTION_TIMER_INTERRUPT,
4019 },
bf525107 4020 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
168c12b0
MF
4021 }, {
4022 .name = "rsr.configid0",
4023 .translate = translate_rsr,
4024 .par = (const uint32_t[]){CONFIGID0},
21a2dad5 4025 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4026 }, {
4027 .name = "rsr.configid1",
4028 .translate = translate_rsr,
4029 .par = (const uint32_t[]){CONFIGID1},
21a2dad5 4030 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4031 }, {
4032 .name = "rsr.cpenable",
4033 .translate = translate_rsr,
91dc2b2d 4034 .test_exceptions = test_exceptions_sr,
59419607
MF
4035 .par = (const uint32_t[]){
4036 CPENABLE,
4037 XTENSA_OPTION_COPROCESSOR,
4038 },
21a2dad5 4039 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4040 }, {
4041 .name = "rsr.dbreaka0",
4042 .translate = translate_rsr,
91dc2b2d 4043 .test_exceptions = test_exceptions_dbreak,
59419607
MF
4044 .par = (const uint32_t[]){
4045 DBREAKA,
4046 XTENSA_OPTION_DEBUG,
4047 },
21a2dad5 4048 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4049 }, {
4050 .name = "rsr.dbreaka1",
4051 .translate = translate_rsr,
91dc2b2d 4052 .test_exceptions = test_exceptions_dbreak,
59419607
MF
4053 .par = (const uint32_t[]){
4054 DBREAKA + 1,
4055 XTENSA_OPTION_DEBUG,
4056 },
21a2dad5 4057 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4058 }, {
4059 .name = "rsr.dbreakc0",
4060 .translate = translate_rsr,
91dc2b2d 4061 .test_exceptions = test_exceptions_dbreak,
59419607
MF
4062 .par = (const uint32_t[]){
4063 DBREAKC,
4064 XTENSA_OPTION_DEBUG,
4065 },
21a2dad5 4066 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4067 }, {
4068 .name = "rsr.dbreakc1",
4069 .translate = translate_rsr,
91dc2b2d 4070 .test_exceptions = test_exceptions_dbreak,
59419607
MF
4071 .par = (const uint32_t[]){
4072 DBREAKC + 1,
4073 XTENSA_OPTION_DEBUG,
4074 },
21a2dad5 4075 .op_flags = XTENSA_OP_PRIVILEGED,
13f6a7cd
MF
4076 }, {
4077 .name = "rsr.ddr",
4078 .translate = translate_rsr,
91dc2b2d 4079 .test_exceptions = test_exceptions_sr,
59419607
MF
4080 .par = (const uint32_t[]){
4081 DDR,
4082 XTENSA_OPTION_DEBUG,
4083 },
21a2dad5 4084 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4085 }, {
4086 .name = "rsr.debugcause",
4087 .translate = translate_rsr,
91dc2b2d 4088 .test_exceptions = test_exceptions_sr,
59419607
MF
4089 .par = (const uint32_t[]){
4090 DEBUGCAUSE,
4091 XTENSA_OPTION_DEBUG,
4092 },
21a2dad5 4093 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4094 }, {
4095 .name = "rsr.depc",
4096 .translate = translate_rsr,
91dc2b2d 4097 .test_exceptions = test_exceptions_sr,
59419607
MF
4098 .par = (const uint32_t[]){
4099 DEPC,
4100 XTENSA_OPTION_EXCEPTION,
4101 },
21a2dad5 4102 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4103 }, {
4104 .name = "rsr.dtlbcfg",
4105 .translate = translate_rsr,
91dc2b2d 4106 .test_exceptions = test_exceptions_sr,
59419607
MF
4107 .par = (const uint32_t[]){
4108 DTLBCFG,
4109 XTENSA_OPTION_MMU,
4110 },
21a2dad5 4111 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4112 }, {
4113 .name = "rsr.epc1",
4114 .translate = translate_rsr,
91dc2b2d 4115 .test_exceptions = test_exceptions_sr,
59419607
MF
4116 .par = (const uint32_t[]){
4117 EPC1,
4118 XTENSA_OPTION_EXCEPTION,
4119 },
21a2dad5 4120 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4121 }, {
4122 .name = "rsr.epc2",
4123 .translate = translate_rsr,
91dc2b2d 4124 .test_exceptions = test_exceptions_hpi,
59419607
MF
4125 .par = (const uint32_t[]){
4126 EPC1 + 1,
4127 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4128 },
21a2dad5 4129 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4130 }, {
4131 .name = "rsr.epc3",
4132 .translate = translate_rsr,
91dc2b2d 4133 .test_exceptions = test_exceptions_hpi,
59419607
MF
4134 .par = (const uint32_t[]){
4135 EPC1 + 2,
4136 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4137 },
21a2dad5 4138 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4139 }, {
4140 .name = "rsr.epc4",
4141 .translate = translate_rsr,
91dc2b2d 4142 .test_exceptions = test_exceptions_hpi,
59419607
MF
4143 .par = (const uint32_t[]){
4144 EPC1 + 3,
4145 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4146 },
21a2dad5 4147 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4148 }, {
4149 .name = "rsr.epc5",
4150 .translate = translate_rsr,
91dc2b2d 4151 .test_exceptions = test_exceptions_hpi,
59419607
MF
4152 .par = (const uint32_t[]){
4153 EPC1 + 4,
4154 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4155 },
21a2dad5 4156 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4157 }, {
4158 .name = "rsr.epc6",
4159 .translate = translate_rsr,
91dc2b2d 4160 .test_exceptions = test_exceptions_hpi,
59419607
MF
4161 .par = (const uint32_t[]){
4162 EPC1 + 5,
4163 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4164 },
21a2dad5 4165 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4166 }, {
4167 .name = "rsr.epc7",
4168 .translate = translate_rsr,
91dc2b2d 4169 .test_exceptions = test_exceptions_hpi,
59419607
MF
4170 .par = (const uint32_t[]){
4171 EPC1 + 6,
4172 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4173 },
21a2dad5 4174 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4175 }, {
4176 .name = "rsr.eps2",
4177 .translate = translate_rsr,
91dc2b2d 4178 .test_exceptions = test_exceptions_hpi,
59419607
MF
4179 .par = (const uint32_t[]){
4180 EPS2,
4181 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4182 },
21a2dad5 4183 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4184 }, {
4185 .name = "rsr.eps3",
4186 .translate = translate_rsr,
91dc2b2d 4187 .test_exceptions = test_exceptions_hpi,
59419607
MF
4188 .par = (const uint32_t[]){
4189 EPS2 + 1,
4190 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4191 },
21a2dad5 4192 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4193 }, {
4194 .name = "rsr.eps4",
4195 .translate = translate_rsr,
91dc2b2d 4196 .test_exceptions = test_exceptions_hpi,
59419607
MF
4197 .par = (const uint32_t[]){
4198 EPS2 + 2,
4199 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4200 },
21a2dad5 4201 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4202 }, {
4203 .name = "rsr.eps5",
4204 .translate = translate_rsr,
91dc2b2d 4205 .test_exceptions = test_exceptions_hpi,
59419607
MF
4206 .par = (const uint32_t[]){
4207 EPS2 + 3,
4208 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4209 },
21a2dad5 4210 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4211 }, {
4212 .name = "rsr.eps6",
4213 .translate = translate_rsr,
91dc2b2d 4214 .test_exceptions = test_exceptions_hpi,
59419607
MF
4215 .par = (const uint32_t[]){
4216 EPS2 + 4,
4217 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4218 },
21a2dad5 4219 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4220 }, {
4221 .name = "rsr.eps7",
4222 .translate = translate_rsr,
91dc2b2d 4223 .test_exceptions = test_exceptions_hpi,
59419607
MF
4224 .par = (const uint32_t[]){
4225 EPS2 + 5,
4226 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4227 },
21a2dad5 4228 .op_flags = XTENSA_OP_PRIVILEGED,
4d04ea35
MF
4229 }, {
4230 .name = "rsr.eraccess",
4231 .translate = translate_rsr,
4232 .par = (const uint32_t[]){ERACCESS},
21a2dad5 4233 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4234 }, {
4235 .name = "rsr.exccause",
4236 .translate = translate_rsr,
91dc2b2d 4237 .test_exceptions = test_exceptions_sr,
59419607
MF
4238 .par = (const uint32_t[]){
4239 EXCCAUSE,
4240 XTENSA_OPTION_EXCEPTION,
4241 },
21a2dad5 4242 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4243 }, {
4244 .name = "rsr.excsave1",
4245 .translate = translate_rsr,
91dc2b2d 4246 .test_exceptions = test_exceptions_sr,
59419607
MF
4247 .par = (const uint32_t[]){
4248 EXCSAVE1,
4249 XTENSA_OPTION_EXCEPTION,
4250 },
21a2dad5 4251 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4252 }, {
4253 .name = "rsr.excsave2",
4254 .translate = translate_rsr,
91dc2b2d 4255 .test_exceptions = test_exceptions_hpi,
59419607
MF
4256 .par = (const uint32_t[]){
4257 EXCSAVE1 + 1,
4258 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4259 },
21a2dad5 4260 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4261 }, {
4262 .name = "rsr.excsave3",
4263 .translate = translate_rsr,
91dc2b2d 4264 .test_exceptions = test_exceptions_hpi,
59419607
MF
4265 .par = (const uint32_t[]){
4266 EXCSAVE1 + 2,
4267 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4268 },
21a2dad5 4269 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4270 }, {
4271 .name = "rsr.excsave4",
4272 .translate = translate_rsr,
91dc2b2d 4273 .test_exceptions = test_exceptions_hpi,
59419607
MF
4274 .par = (const uint32_t[]){
4275 EXCSAVE1 + 3,
4276 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4277 },
21a2dad5 4278 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4279 }, {
4280 .name = "rsr.excsave5",
4281 .translate = translate_rsr,
91dc2b2d 4282 .test_exceptions = test_exceptions_hpi,
59419607
MF
4283 .par = (const uint32_t[]){
4284 EXCSAVE1 + 4,
4285 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4286 },
21a2dad5 4287 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4288 }, {
4289 .name = "rsr.excsave6",
4290 .translate = translate_rsr,
91dc2b2d 4291 .test_exceptions = test_exceptions_hpi,
59419607
MF
4292 .par = (const uint32_t[]){
4293 EXCSAVE1 + 5,
4294 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4295 },
21a2dad5 4296 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4297 }, {
4298 .name = "rsr.excsave7",
4299 .translate = translate_rsr,
91dc2b2d 4300 .test_exceptions = test_exceptions_hpi,
59419607
MF
4301 .par = (const uint32_t[]){
4302 EXCSAVE1 + 6,
4303 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
4304 },
21a2dad5 4305 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4306 }, {
4307 .name = "rsr.excvaddr",
4308 .translate = translate_rsr,
91dc2b2d 4309 .test_exceptions = test_exceptions_sr,
59419607
MF
4310 .par = (const uint32_t[]){
4311 EXCVADDR,
4312 XTENSA_OPTION_EXCEPTION,
4313 },
21a2dad5 4314 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4315 }, {
4316 .name = "rsr.ibreaka0",
4317 .translate = translate_rsr,
91dc2b2d 4318 .test_exceptions = test_exceptions_ibreak,
59419607
MF
4319 .par = (const uint32_t[]){
4320 IBREAKA,
4321 XTENSA_OPTION_DEBUG,
4322 },
21a2dad5 4323 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4324 }, {
4325 .name = "rsr.ibreaka1",
4326 .translate = translate_rsr,
91dc2b2d 4327 .test_exceptions = test_exceptions_ibreak,
59419607
MF
4328 .par = (const uint32_t[]){
4329 IBREAKA + 1,
4330 XTENSA_OPTION_DEBUG,
4331 },
21a2dad5 4332 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4333 }, {
4334 .name = "rsr.ibreakenable",
4335 .translate = translate_rsr,
91dc2b2d 4336 .test_exceptions = test_exceptions_sr,
59419607
MF
4337 .par = (const uint32_t[]){
4338 IBREAKENABLE,
4339 XTENSA_OPTION_DEBUG,
4340 },
21a2dad5 4341 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4342 }, {
4343 .name = "rsr.icount",
4344 .translate = translate_rsr,
91dc2b2d 4345 .test_exceptions = test_exceptions_sr,
59419607
MF
4346 .par = (const uint32_t[]){
4347 ICOUNT,
4348 XTENSA_OPTION_DEBUG,
4349 },
21a2dad5 4350 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4351 }, {
4352 .name = "rsr.icountlevel",
4353 .translate = translate_rsr,
91dc2b2d 4354 .test_exceptions = test_exceptions_sr,
59419607
MF
4355 .par = (const uint32_t[]){
4356 ICOUNTLEVEL,
4357 XTENSA_OPTION_DEBUG,
4358 },
21a2dad5 4359 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4360 }, {
4361 .name = "rsr.intclear",
4362 .translate = translate_rsr,
91dc2b2d 4363 .test_exceptions = test_exceptions_sr,
59419607
MF
4364 .par = (const uint32_t[]){
4365 INTCLEAR,
4366 XTENSA_OPTION_INTERRUPT,
4367 },
21a2dad5 4368 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4369 }, {
4370 .name = "rsr.intenable",
4371 .translate = translate_rsr,
91dc2b2d 4372 .test_exceptions = test_exceptions_sr,
59419607
MF
4373 .par = (const uint32_t[]){
4374 INTENABLE,
4375 XTENSA_OPTION_INTERRUPT,
4376 },
21a2dad5 4377 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4378 }, {
4379 .name = "rsr.interrupt",
59419607 4380 .translate = translate_rsr_ccount,
91dc2b2d 4381 .test_exceptions = test_exceptions_sr,
59419607
MF
4382 .par = (const uint32_t[]){
4383 INTSET,
4384 XTENSA_OPTION_INTERRUPT,
4385 },
bf525107 4386 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
168c12b0
MF
4387 }, {
4388 .name = "rsr.intset",
59419607 4389 .translate = translate_rsr_ccount,
91dc2b2d 4390 .test_exceptions = test_exceptions_sr,
59419607
MF
4391 .par = (const uint32_t[]){
4392 INTSET,
4393 XTENSA_OPTION_INTERRUPT,
4394 },
bf525107 4395 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
168c12b0
MF
4396 }, {
4397 .name = "rsr.itlbcfg",
4398 .translate = translate_rsr,
91dc2b2d 4399 .test_exceptions = test_exceptions_sr,
59419607
MF
4400 .par = (const uint32_t[]){
4401 ITLBCFG,
4402 XTENSA_OPTION_MMU,
4403 },
21a2dad5 4404 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4405 }, {
4406 .name = "rsr.lbeg",
4407 .translate = translate_rsr,
91dc2b2d 4408 .test_exceptions = test_exceptions_sr,
59419607
MF
4409 .par = (const uint32_t[]){
4410 LBEG,
4411 XTENSA_OPTION_LOOP,
4412 },
168c12b0
MF
4413 }, {
4414 .name = "rsr.lcount",
4415 .translate = translate_rsr,
91dc2b2d 4416 .test_exceptions = test_exceptions_sr,
59419607
MF
4417 .par = (const uint32_t[]){
4418 LCOUNT,
4419 XTENSA_OPTION_LOOP,
4420 },
168c12b0
MF
4421 }, {
4422 .name = "rsr.lend",
4423 .translate = translate_rsr,
91dc2b2d 4424 .test_exceptions = test_exceptions_sr,
59419607
MF
4425 .par = (const uint32_t[]){
4426 LEND,
4427 XTENSA_OPTION_LOOP,
4428 },
168c12b0
MF
4429 }, {
4430 .name = "rsr.litbase",
4431 .translate = translate_rsr,
91dc2b2d 4432 .test_exceptions = test_exceptions_sr,
59419607
MF
4433 .par = (const uint32_t[]){
4434 LITBASE,
4435 XTENSA_OPTION_EXTENDED_L32R,
4436 },
168c12b0
MF
4437 }, {
4438 .name = "rsr.m0",
4439 .translate = translate_rsr,
91dc2b2d 4440 .test_exceptions = test_exceptions_sr,
59419607
MF
4441 .par = (const uint32_t[]){
4442 MR,
4443 XTENSA_OPTION_MAC16,
4444 },
168c12b0
MF
4445 }, {
4446 .name = "rsr.m1",
4447 .translate = translate_rsr,
91dc2b2d 4448 .test_exceptions = test_exceptions_sr,
59419607
MF
4449 .par = (const uint32_t[]){
4450 MR + 1,
4451 XTENSA_OPTION_MAC16,
4452 },
168c12b0
MF
4453 }, {
4454 .name = "rsr.m2",
4455 .translate = translate_rsr,
91dc2b2d 4456 .test_exceptions = test_exceptions_sr,
59419607
MF
4457 .par = (const uint32_t[]){
4458 MR + 2,
4459 XTENSA_OPTION_MAC16,
4460 },
168c12b0
MF
4461 }, {
4462 .name = "rsr.m3",
4463 .translate = translate_rsr,
91dc2b2d 4464 .test_exceptions = test_exceptions_sr,
59419607
MF
4465 .par = (const uint32_t[]){
4466 MR + 3,
4467 XTENSA_OPTION_MAC16,
4468 },
168c12b0
MF
4469 }, {
4470 .name = "rsr.memctl",
4471 .translate = translate_rsr,
4472 .par = (const uint32_t[]){MEMCTL},
21a2dad5 4473 .op_flags = XTENSA_OP_PRIVILEGED,
631a77a0
MF
4474 }, {
4475 .name = "rsr.mecr",
4476 .translate = translate_rsr,
91dc2b2d 4477 .test_exceptions = test_exceptions_sr,
631a77a0
MF
4478 .par = (const uint32_t[]){
4479 MECR,
4480 XTENSA_OPTION_MEMORY_ECC_PARITY,
4481 },
4482 .op_flags = XTENSA_OP_PRIVILEGED,
4483 }, {
4484 .name = "rsr.mepc",
4485 .translate = translate_rsr,
91dc2b2d 4486 .test_exceptions = test_exceptions_sr,
631a77a0
MF
4487 .par = (const uint32_t[]){
4488 MEPC,
4489 XTENSA_OPTION_MEMORY_ECC_PARITY,
4490 },
4491 .op_flags = XTENSA_OP_PRIVILEGED,
4492 }, {
4493 .name = "rsr.meps",
4494 .translate = translate_rsr,
91dc2b2d 4495 .test_exceptions = test_exceptions_sr,
631a77a0
MF
4496 .par = (const uint32_t[]){
4497 MEPS,
4498 XTENSA_OPTION_MEMORY_ECC_PARITY,
4499 },
4500 .op_flags = XTENSA_OP_PRIVILEGED,
4501 }, {
4502 .name = "rsr.mesave",
4503 .translate = translate_rsr,
91dc2b2d 4504 .test_exceptions = test_exceptions_sr,
631a77a0
MF
4505 .par = (const uint32_t[]){
4506 MESAVE,
4507 XTENSA_OPTION_MEMORY_ECC_PARITY,
4508 },
4509 .op_flags = XTENSA_OP_PRIVILEGED,
4510 }, {
4511 .name = "rsr.mesr",
4512 .translate = translate_rsr,
91dc2b2d 4513 .test_exceptions = test_exceptions_sr,
631a77a0
MF
4514 .par = (const uint32_t[]){
4515 MESR,
4516 XTENSA_OPTION_MEMORY_ECC_PARITY,
4517 },
4518 .op_flags = XTENSA_OP_PRIVILEGED,
4519 }, {
4520 .name = "rsr.mevaddr",
4521 .translate = translate_rsr,
91dc2b2d 4522 .test_exceptions = test_exceptions_sr,
631a77a0
MF
4523 .par = (const uint32_t[]){
4524 MESR,
4525 XTENSA_OPTION_MEMORY_ECC_PARITY,
4526 },
4527 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4528 }, {
4529 .name = "rsr.misc0",
4530 .translate = translate_rsr,
91dc2b2d 4531 .test_exceptions = test_exceptions_sr,
59419607
MF
4532 .par = (const uint32_t[]){
4533 MISC,
4534 XTENSA_OPTION_MISC_SR,
4535 },
21a2dad5 4536 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4537 }, {
4538 .name = "rsr.misc1",
4539 .translate = translate_rsr,
91dc2b2d 4540 .test_exceptions = test_exceptions_sr,
59419607
MF
4541 .par = (const uint32_t[]){
4542 MISC + 1,
4543 XTENSA_OPTION_MISC_SR,
4544 },
21a2dad5 4545 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4546 }, {
4547 .name = "rsr.misc2",
4548 .translate = translate_rsr,
91dc2b2d 4549 .test_exceptions = test_exceptions_sr,
59419607
MF
4550 .par = (const uint32_t[]){
4551 MISC + 2,
4552 XTENSA_OPTION_MISC_SR,
4553 },
21a2dad5 4554 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4555 }, {
4556 .name = "rsr.misc3",
4557 .translate = translate_rsr,
91dc2b2d 4558 .test_exceptions = test_exceptions_sr,
59419607
MF
4559 .par = (const uint32_t[]){
4560 MISC + 3,
4561 XTENSA_OPTION_MISC_SR,
4562 },
21a2dad5 4563 .op_flags = XTENSA_OP_PRIVILEGED,
4d04ea35
MF
4564 }, {
4565 .name = "rsr.mpucfg",
4566 .translate = translate_rsr,
91dc2b2d 4567 .test_exceptions = test_exceptions_sr,
4d04ea35
MF
4568 .par = (const uint32_t[]){
4569 MPUCFG,
4570 XTENSA_OPTION_MPU,
4571 },
4572 .op_flags = XTENSA_OP_PRIVILEGED,
4573 }, {
4574 .name = "rsr.mpuenb",
4575 .translate = translate_rsr,
91dc2b2d 4576 .test_exceptions = test_exceptions_sr,
4d04ea35
MF
4577 .par = (const uint32_t[]){
4578 MPUENB,
4579 XTENSA_OPTION_MPU,
4580 },
21a2dad5 4581 .op_flags = XTENSA_OP_PRIVILEGED,
eb3f4298
MF
4582 }, {
4583 .name = "rsr.prefctl",
4584 .translate = translate_rsr,
eb3f4298 4585 .par = (const uint32_t[]){PREFCTL},
168c12b0
MF
4586 }, {
4587 .name = "rsr.prid",
4588 .translate = translate_rsr,
91dc2b2d 4589 .test_exceptions = test_exceptions_sr,
59419607
MF
4590 .par = (const uint32_t[]){
4591 PRID,
4592 XTENSA_OPTION_PROCESSOR_ID,
4593 },
21a2dad5 4594 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4595 }, {
4596 .name = "rsr.ps",
4597 .translate = translate_rsr,
91dc2b2d 4598 .test_exceptions = test_exceptions_sr,
59419607
MF
4599 .par = (const uint32_t[]){
4600 PS,
4601 XTENSA_OPTION_EXCEPTION,
4602 },
21a2dad5 4603 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4604 }, {
4605 .name = "rsr.ptevaddr",
59419607 4606 .translate = translate_rsr_ptevaddr,
91dc2b2d 4607 .test_exceptions = test_exceptions_sr,
59419607
MF
4608 .par = (const uint32_t[]){
4609 PTEVADDR,
4610 XTENSA_OPTION_MMU,
4611 },
21a2dad5 4612 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4613 }, {
4614 .name = "rsr.rasid",
4615 .translate = translate_rsr,
91dc2b2d 4616 .test_exceptions = test_exceptions_sr,
59419607
MF
4617 .par = (const uint32_t[]){
4618 RASID,
4619 XTENSA_OPTION_MMU,
4620 },
21a2dad5 4621 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4622 }, {
4623 .name = "rsr.sar",
4624 .translate = translate_rsr,
4625 .par = (const uint32_t[]){SAR},
4626 }, {
4627 .name = "rsr.scompare1",
4628 .translate = translate_rsr,
91dc2b2d 4629 .test_exceptions = test_exceptions_sr,
59419607
MF
4630 .par = (const uint32_t[]){
4631 SCOMPARE1,
4632 XTENSA_OPTION_CONDITIONAL_STORE,
4633 },
168c12b0
MF
4634 }, {
4635 .name = "rsr.vecbase",
4636 .translate = translate_rsr,
91dc2b2d 4637 .test_exceptions = test_exceptions_sr,
59419607
MF
4638 .par = (const uint32_t[]){
4639 VECBASE,
4640 XTENSA_OPTION_RELOCATABLE_VECTOR,
4641 },
21a2dad5 4642 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4643 }, {
4644 .name = "rsr.windowbase",
4645 .translate = translate_rsr,
91dc2b2d 4646 .test_exceptions = test_exceptions_sr,
59419607
MF
4647 .par = (const uint32_t[]){
4648 WINDOW_BASE,
4649 XTENSA_OPTION_WINDOWED_REGISTER,
4650 },
21a2dad5 4651 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4652 }, {
4653 .name = "rsr.windowstart",
4654 .translate = translate_rsr,
91dc2b2d 4655 .test_exceptions = test_exceptions_sr,
59419607
MF
4656 .par = (const uint32_t[]){
4657 WINDOW_START,
4658 XTENSA_OPTION_WINDOWED_REGISTER,
4659 },
21a2dad5 4660 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4661 }, {
4662 .name = "rsync",
4663 .translate = translate_nop,
e9872741
MF
4664 }, {
4665 .name = "rur.expstate",
4666 .translate = translate_rur,
4667 .par = (const uint32_t[]){EXPSTATE},
168c12b0
MF
4668 }, {
4669 .name = "rur.fcr",
4670 .translate = translate_rur,
4671 .par = (const uint32_t[]){FCR},
582fef0f 4672 .coprocessor = 0x1,
168c12b0
MF
4673 }, {
4674 .name = "rur.fsr",
4675 .translate = translate_rur,
4676 .par = (const uint32_t[]){FSR},
582fef0f 4677 .coprocessor = 0x1,
168c12b0
MF
4678 }, {
4679 .name = "rur.threadptr",
4680 .translate = translate_rur,
4681 .par = (const uint32_t[]){THREADPTR},
4682 }, {
4683 .name = "s16i",
4684 .translate = translate_ldst,
4685 .par = (const uint32_t[]){MO_TEUW, false, true},
068e538a 4686 .op_flags = XTENSA_OP_STORE,
168c12b0
MF
4687 }, {
4688 .name = "s32c1i",
4689 .translate = translate_s32c1i,
068e538a 4690 .op_flags = XTENSA_OP_LOAD | XTENSA_OP_STORE,
168c12b0
MF
4691 }, {
4692 .name = "s32e",
4693 .translate = translate_s32e,
068e538a 4694 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_STORE,
b345e140
MF
4695 }, {
4696 .name = "s32ex",
4697 .translate = translate_s32ex,
4698 .op_flags = XTENSA_OP_LOAD | XTENSA_OP_STORE,
168c12b0 4699 }, {
d863fcf7
MF
4700 .name = (const char * const[]) {
4701 "s32i", "s32i.n", "s32nb", NULL,
4702 },
168c12b0
MF
4703 .translate = translate_ldst,
4704 .par = (const uint32_t[]){MO_TEUL, false, true},
068e538a 4705 .op_flags = XTENSA_OP_NAME_ARRAY | XTENSA_OP_STORE,
168c12b0
MF
4706 }, {
4707 .name = "s32ri",
4708 .translate = translate_ldst,
4709 .par = (const uint32_t[]){MO_TEUL, true, true},
068e538a 4710 .op_flags = XTENSA_OP_STORE,
168c12b0
MF
4711 }, {
4712 .name = "s8i",
4713 .translate = translate_ldst,
4714 .par = (const uint32_t[]){MO_UB, false, true},
068e538a 4715 .op_flags = XTENSA_OP_STORE,
d1e9b006
MF
4716 }, {
4717 .name = "salt",
4718 .translate = translate_salt,
4719 .par = (const uint32_t[]){TCG_COND_LT},
4720 }, {
4721 .name = "saltu",
4722 .translate = translate_salt,
4723 .par = (const uint32_t[]){TCG_COND_LTU},
e9872741
MF
4724 }, {
4725 .name = "setb_expstate",
4726 .translate = translate_setb_expstate,
168c12b0
MF
4727 }, {
4728 .name = "sext",
4729 .translate = translate_sext,
4730 }, {
4731 .name = "simcall",
4732 .translate = translate_simcall,
91dc2b2d 4733 .test_exceptions = test_exceptions_simcall,
21a2dad5 4734 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4735 }, {
4736 .name = "sll",
4737 .translate = translate_sll,
4738 }, {
4739 .name = "slli",
4740 .translate = translate_slli,
4741 }, {
4742 .name = "sra",
4743 .translate = translate_sra,
4744 }, {
4745 .name = "srai",
4746 .translate = translate_srai,
4747 }, {
4748 .name = "src",
4749 .translate = translate_src,
4750 }, {
4751 .name = "srl",
4752 .translate = translate_srl,
4753 }, {
4754 .name = "srli",
4755 .translate = translate_srli,
4756 }, {
4757 .name = "ssa8b",
4758 .translate = translate_ssa8b,
4759 }, {
4760 .name = "ssa8l",
4761 .translate = translate_ssa8l,
4762 }, {
4763 .name = "ssai",
4764 .translate = translate_ssai,
4765 }, {
4766 .name = "ssl",
4767 .translate = translate_ssl,
4768 }, {
4769 .name = "ssr",
4770 .translate = translate_ssr,
4771 }, {
4772 .name = "sub",
4773 .translate = translate_sub,
4774 }, {
4775 .name = "subx2",
4776 .translate = translate_subx,
4777 .par = (const uint32_t[]){1},
4778 }, {
4779 .name = "subx4",
4780 .translate = translate_subx,
4781 .par = (const uint32_t[]){2},
4782 }, {
4783 .name = "subx8",
4784 .translate = translate_subx,
4785 .par = (const uint32_t[]){3},
4786 }, {
4787 .name = "syscall",
4c6ec5f3 4788 .op_flags = XTENSA_OP_SYSCALL,
168c12b0
MF
4789 }, {
4790 .name = "umul.aa.hh",
4791 .translate = translate_mac16,
7aa78341 4792 .par = (const uint32_t[]){MAC16_UMUL, MAC16_HH, 0},
168c12b0
MF
4793 }, {
4794 .name = "umul.aa.hl",
4795 .translate = translate_mac16,
7aa78341 4796 .par = (const uint32_t[]){MAC16_UMUL, MAC16_HL, 0},
168c12b0
MF
4797 }, {
4798 .name = "umul.aa.lh",
4799 .translate = translate_mac16,
7aa78341 4800 .par = (const uint32_t[]){MAC16_UMUL, MAC16_LH, 0},
168c12b0
MF
4801 }, {
4802 .name = "umul.aa.ll",
4803 .translate = translate_mac16,
7aa78341 4804 .par = (const uint32_t[]){MAC16_UMUL, MAC16_LL, 0},
168c12b0
MF
4805 }, {
4806 .name = "waiti",
4807 .translate = translate_waiti,
bf525107 4808 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
168c12b0
MF
4809 }, {
4810 .name = "wdtlb",
4811 .translate = translate_wtlb,
4812 .par = (const uint32_t[]){true},
226444a8 4813 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_M1,
168c12b0
MF
4814 }, {
4815 .name = "wer",
4816 .translate = translate_wer,
21a2dad5 4817 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4818 }, {
4819 .name = "witlb",
4820 .translate = translate_wtlb,
4821 .par = (const uint32_t[]){false},
226444a8 4822 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_M1,
4d04ea35
MF
4823 }, {
4824 .name = "wptlb",
4825 .translate = translate_wptlb,
4826 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_M1,
e9872741
MF
4827 }, {
4828 .name = "wrmsk_expstate",
4829 .translate = translate_wrmsk_expstate,
168c12b0
MF
4830 }, {
4831 .name = "wsr.176",
59419607 4832 .op_flags = XTENSA_OP_ILL,
168c12b0
MF
4833 }, {
4834 .name = "wsr.208",
59419607 4835 .op_flags = XTENSA_OP_ILL,
168c12b0
MF
4836 }, {
4837 .name = "wsr.acchi",
59419607 4838 .translate = translate_wsr_acchi,
91dc2b2d 4839 .test_exceptions = test_exceptions_sr,
59419607
MF
4840 .par = (const uint32_t[]){
4841 ACCHI,
4842 XTENSA_OPTION_MAC16,
4843 },
168c12b0
MF
4844 }, {
4845 .name = "wsr.acclo",
4846 .translate = translate_wsr,
91dc2b2d 4847 .test_exceptions = test_exceptions_sr,
59419607
MF
4848 .par = (const uint32_t[]){
4849 ACCLO,
4850 XTENSA_OPTION_MAC16,
4851 },
168c12b0
MF
4852 }, {
4853 .name = "wsr.atomctl",
59419607 4854 .translate = translate_wsr_mask,
91dc2b2d 4855 .test_exceptions = test_exceptions_sr,
59419607
MF
4856 .par = (const uint32_t[]){
4857 ATOMCTL,
4858 XTENSA_OPTION_ATOMCTL,
4859 0x3f,
4860 },
21a2dad5 4861 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4862 }, {
4863 .name = "wsr.br",
59419607 4864 .translate = translate_wsr_mask,
91dc2b2d 4865 .test_exceptions = test_exceptions_sr,
59419607
MF
4866 .par = (const uint32_t[]){
4867 BR,
4868 XTENSA_OPTION_BOOLEAN,
4869 0xffff,
4870 },
4d04ea35
MF
4871 }, {
4872 .name = "wsr.cacheadrdis",
4873 .translate = translate_wsr_mask,
91dc2b2d 4874 .test_exceptions = test_exceptions_sr,
4d04ea35
MF
4875 .par = (const uint32_t[]){
4876 CACHEADRDIS,
4877 XTENSA_OPTION_MPU,
4878 0xff,
4879 },
4880 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4881 }, {
4882 .name = "wsr.cacheattr",
4883 .translate = translate_wsr,
91dc2b2d 4884 .test_exceptions = test_exceptions_sr,
59419607
MF
4885 .par = (const uint32_t[]){
4886 CACHEATTR,
4887 XTENSA_OPTION_CACHEATTR,
4888 },
21a2dad5 4889 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4890 }, {
4891 .name = "wsr.ccompare0",
59419607 4892 .translate = translate_wsr_ccompare,
91dc2b2d 4893 .test_exceptions = test_exceptions_ccompare,
59419607
MF
4894 .par = (const uint32_t[]){
4895 CCOMPARE,
4896 XTENSA_OPTION_TIMER_INTERRUPT,
4897 },
bf525107 4898 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
168c12b0
MF
4899 }, {
4900 .name = "wsr.ccompare1",
59419607 4901 .translate = translate_wsr_ccompare,
91dc2b2d 4902 .test_exceptions = test_exceptions_ccompare,
59419607
MF
4903 .par = (const uint32_t[]){
4904 CCOMPARE + 1,
4905 XTENSA_OPTION_TIMER_INTERRUPT,
4906 },
bf525107 4907 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
168c12b0
MF
4908 }, {
4909 .name = "wsr.ccompare2",
59419607 4910 .translate = translate_wsr_ccompare,
91dc2b2d 4911 .test_exceptions = test_exceptions_ccompare,
59419607
MF
4912 .par = (const uint32_t[]){
4913 CCOMPARE + 2,
4914 XTENSA_OPTION_TIMER_INTERRUPT,
4915 },
bf525107 4916 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
168c12b0
MF
4917 }, {
4918 .name = "wsr.ccount",
59419607 4919 .translate = translate_wsr_ccount,
91dc2b2d 4920 .test_exceptions = test_exceptions_sr,
59419607
MF
4921 .par = (const uint32_t[]){
4922 CCOUNT,
4923 XTENSA_OPTION_TIMER_INTERRUPT,
4924 },
bf525107 4925 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
168c12b0
MF
4926 }, {
4927 .name = "wsr.configid0",
59419607 4928 .op_flags = XTENSA_OP_ILL,
168c12b0
MF
4929 }, {
4930 .name = "wsr.configid1",
59419607 4931 .op_flags = XTENSA_OP_ILL,
168c12b0
MF
4932 }, {
4933 .name = "wsr.cpenable",
59419607 4934 .translate = translate_wsr_mask,
91dc2b2d 4935 .test_exceptions = test_exceptions_sr,
59419607
MF
4936 .par = (const uint32_t[]){
4937 CPENABLE,
4938 XTENSA_OPTION_COPROCESSOR,
4939 0xff,
4940 },
226444a8 4941 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_M1,
168c12b0
MF
4942 }, {
4943 .name = "wsr.dbreaka0",
59419607 4944 .translate = translate_wsr_dbreaka,
91dc2b2d 4945 .test_exceptions = test_exceptions_dbreak,
59419607
MF
4946 .par = (const uint32_t[]){
4947 DBREAKA,
4948 XTENSA_OPTION_DEBUG,
4949 },
21a2dad5 4950 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4951 }, {
4952 .name = "wsr.dbreaka1",
59419607 4953 .translate = translate_wsr_dbreaka,
91dc2b2d 4954 .test_exceptions = test_exceptions_dbreak,
59419607
MF
4955 .par = (const uint32_t[]){
4956 DBREAKA + 1,
4957 XTENSA_OPTION_DEBUG,
4958 },
21a2dad5 4959 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4960 }, {
4961 .name = "wsr.dbreakc0",
59419607 4962 .translate = translate_wsr_dbreakc,
91dc2b2d 4963 .test_exceptions = test_exceptions_dbreak,
59419607
MF
4964 .par = (const uint32_t[]){
4965 DBREAKC,
4966 XTENSA_OPTION_DEBUG,
4967 },
21a2dad5 4968 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4969 }, {
4970 .name = "wsr.dbreakc1",
59419607 4971 .translate = translate_wsr_dbreakc,
91dc2b2d 4972 .test_exceptions = test_exceptions_dbreak,
59419607
MF
4973 .par = (const uint32_t[]){
4974 DBREAKC + 1,
4975 XTENSA_OPTION_DEBUG,
4976 },
21a2dad5 4977 .op_flags = XTENSA_OP_PRIVILEGED,
13f6a7cd
MF
4978 }, {
4979 .name = "wsr.ddr",
4980 .translate = translate_wsr,
91dc2b2d 4981 .test_exceptions = test_exceptions_sr,
59419607
MF
4982 .par = (const uint32_t[]){
4983 DDR,
4984 XTENSA_OPTION_DEBUG,
4985 },
21a2dad5 4986 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4987 }, {
4988 .name = "wsr.debugcause",
59419607 4989 .op_flags = XTENSA_OP_ILL,
168c12b0
MF
4990 }, {
4991 .name = "wsr.depc",
4992 .translate = translate_wsr,
91dc2b2d 4993 .test_exceptions = test_exceptions_sr,
59419607
MF
4994 .par = (const uint32_t[]){
4995 DEPC,
4996 XTENSA_OPTION_EXCEPTION,
4997 },
21a2dad5 4998 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
4999 }, {
5000 .name = "wsr.dtlbcfg",
59419607 5001 .translate = translate_wsr_mask,
91dc2b2d 5002 .test_exceptions = test_exceptions_sr,
59419607
MF
5003 .par = (const uint32_t[]){
5004 DTLBCFG,
5005 XTENSA_OPTION_MMU,
5006 0x01130000,
5007 },
21a2dad5 5008 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5009 }, {
5010 .name = "wsr.epc1",
5011 .translate = translate_wsr,
91dc2b2d 5012 .test_exceptions = test_exceptions_sr,
59419607
MF
5013 .par = (const uint32_t[]){
5014 EPC1,
5015 XTENSA_OPTION_EXCEPTION,
5016 },
21a2dad5 5017 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5018 }, {
5019 .name = "wsr.epc2",
5020 .translate = translate_wsr,
91dc2b2d 5021 .test_exceptions = test_exceptions_hpi,
59419607
MF
5022 .par = (const uint32_t[]){
5023 EPC1 + 1,
5024 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5025 },
21a2dad5 5026 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5027 }, {
5028 .name = "wsr.epc3",
5029 .translate = translate_wsr,
91dc2b2d 5030 .test_exceptions = test_exceptions_hpi,
59419607
MF
5031 .par = (const uint32_t[]){
5032 EPC1 + 2,
5033 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5034 },
21a2dad5 5035 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5036 }, {
5037 .name = "wsr.epc4",
5038 .translate = translate_wsr,
91dc2b2d 5039 .test_exceptions = test_exceptions_hpi,
59419607
MF
5040 .par = (const uint32_t[]){
5041 EPC1 + 3,
5042 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5043 },
21a2dad5 5044 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5045 }, {
5046 .name = "wsr.epc5",
5047 .translate = translate_wsr,
91dc2b2d 5048 .test_exceptions = test_exceptions_hpi,
59419607
MF
5049 .par = (const uint32_t[]){
5050 EPC1 + 4,
5051 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5052 },
21a2dad5 5053 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5054 }, {
5055 .name = "wsr.epc6",
5056 .translate = translate_wsr,
91dc2b2d 5057 .test_exceptions = test_exceptions_hpi,
59419607
MF
5058 .par = (const uint32_t[]){
5059 EPC1 + 5,
5060 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5061 },
21a2dad5 5062 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5063 }, {
5064 .name = "wsr.epc7",
5065 .translate = translate_wsr,
91dc2b2d 5066 .test_exceptions = test_exceptions_hpi,
59419607
MF
5067 .par = (const uint32_t[]){
5068 EPC1 + 6,
5069 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5070 },
21a2dad5 5071 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5072 }, {
5073 .name = "wsr.eps2",
5074 .translate = translate_wsr,
91dc2b2d 5075 .test_exceptions = test_exceptions_hpi,
59419607
MF
5076 .par = (const uint32_t[]){
5077 EPS2,
5078 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5079 },
21a2dad5 5080 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5081 }, {
5082 .name = "wsr.eps3",
5083 .translate = translate_wsr,
91dc2b2d 5084 .test_exceptions = test_exceptions_hpi,
59419607
MF
5085 .par = (const uint32_t[]){
5086 EPS2 + 1,
5087 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5088 },
21a2dad5 5089 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5090 }, {
5091 .name = "wsr.eps4",
5092 .translate = translate_wsr,
91dc2b2d 5093 .test_exceptions = test_exceptions_hpi,
59419607
MF
5094 .par = (const uint32_t[]){
5095 EPS2 + 2,
5096 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5097 },
21a2dad5 5098 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5099 }, {
5100 .name = "wsr.eps5",
5101 .translate = translate_wsr,
91dc2b2d 5102 .test_exceptions = test_exceptions_hpi,
59419607
MF
5103 .par = (const uint32_t[]){
5104 EPS2 + 3,
5105 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5106 },
21a2dad5 5107 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5108 }, {
5109 .name = "wsr.eps6",
5110 .translate = translate_wsr,
91dc2b2d 5111 .test_exceptions = test_exceptions_hpi,
59419607
MF
5112 .par = (const uint32_t[]){
5113 EPS2 + 4,
5114 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5115 },
21a2dad5 5116 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5117 }, {
5118 .name = "wsr.eps7",
5119 .translate = translate_wsr,
91dc2b2d 5120 .test_exceptions = test_exceptions_hpi,
59419607
MF
5121 .par = (const uint32_t[]){
5122 EPS2 + 5,
5123 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5124 },
21a2dad5 5125 .op_flags = XTENSA_OP_PRIVILEGED,
4d04ea35
MF
5126 }, {
5127 .name = "wsr.eraccess",
5128 .translate = translate_wsr_mask,
5129 .par = (const uint32_t[]){
5130 ERACCESS,
5131 0,
5132 0xffff,
5133 },
21a2dad5 5134 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5135 }, {
5136 .name = "wsr.exccause",
5137 .translate = translate_wsr,
91dc2b2d 5138 .test_exceptions = test_exceptions_sr,
59419607
MF
5139 .par = (const uint32_t[]){
5140 EXCCAUSE,
5141 XTENSA_OPTION_EXCEPTION,
5142 },
21a2dad5 5143 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5144 }, {
5145 .name = "wsr.excsave1",
5146 .translate = translate_wsr,
91dc2b2d 5147 .test_exceptions = test_exceptions_sr,
59419607
MF
5148 .par = (const uint32_t[]){
5149 EXCSAVE1,
5150 XTENSA_OPTION_EXCEPTION,
5151 },
21a2dad5 5152 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5153 }, {
5154 .name = "wsr.excsave2",
5155 .translate = translate_wsr,
91dc2b2d 5156 .test_exceptions = test_exceptions_hpi,
59419607
MF
5157 .par = (const uint32_t[]){
5158 EXCSAVE1 + 1,
5159 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5160 },
21a2dad5 5161 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5162 }, {
5163 .name = "wsr.excsave3",
5164 .translate = translate_wsr,
91dc2b2d 5165 .test_exceptions = test_exceptions_hpi,
59419607
MF
5166 .par = (const uint32_t[]){
5167 EXCSAVE1 + 2,
5168 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5169 },
21a2dad5 5170 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5171 }, {
5172 .name = "wsr.excsave4",
5173 .translate = translate_wsr,
91dc2b2d 5174 .test_exceptions = test_exceptions_hpi,
59419607
MF
5175 .par = (const uint32_t[]){
5176 EXCSAVE1 + 3,
5177 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5178 },
21a2dad5 5179 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5180 }, {
5181 .name = "wsr.excsave5",
5182 .translate = translate_wsr,
91dc2b2d 5183 .test_exceptions = test_exceptions_hpi,
59419607
MF
5184 .par = (const uint32_t[]){
5185 EXCSAVE1 + 4,
5186 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5187 },
21a2dad5 5188 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5189 }, {
5190 .name = "wsr.excsave6",
5191 .translate = translate_wsr,
91dc2b2d 5192 .test_exceptions = test_exceptions_hpi,
59419607
MF
5193 .par = (const uint32_t[]){
5194 EXCSAVE1 + 5,
5195 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5196 },
21a2dad5 5197 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5198 }, {
5199 .name = "wsr.excsave7",
5200 .translate = translate_wsr,
91dc2b2d 5201 .test_exceptions = test_exceptions_hpi,
59419607
MF
5202 .par = (const uint32_t[]){
5203 EXCSAVE1 + 6,
5204 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5205 },
21a2dad5 5206 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5207 }, {
5208 .name = "wsr.excvaddr",
5209 .translate = translate_wsr,
91dc2b2d 5210 .test_exceptions = test_exceptions_sr,
59419607
MF
5211 .par = (const uint32_t[]){
5212 EXCVADDR,
5213 XTENSA_OPTION_EXCEPTION,
5214 },
21a2dad5 5215 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5216 }, {
5217 .name = "wsr.ibreaka0",
59419607 5218 .translate = translate_wsr_ibreaka,
91dc2b2d 5219 .test_exceptions = test_exceptions_ibreak,
59419607
MF
5220 .par = (const uint32_t[]){
5221 IBREAKA,
5222 XTENSA_OPTION_DEBUG,
5223 },
bf525107 5224 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
168c12b0
MF
5225 }, {
5226 .name = "wsr.ibreaka1",
59419607 5227 .translate = translate_wsr_ibreaka,
91dc2b2d 5228 .test_exceptions = test_exceptions_ibreak,
59419607
MF
5229 .par = (const uint32_t[]){
5230 IBREAKA + 1,
5231 XTENSA_OPTION_DEBUG,
5232 },
bf525107 5233 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
168c12b0
MF
5234 }, {
5235 .name = "wsr.ibreakenable",
59419607 5236 .translate = translate_wsr_ibreakenable,
91dc2b2d 5237 .test_exceptions = test_exceptions_sr,
59419607
MF
5238 .par = (const uint32_t[]){
5239 IBREAKENABLE,
5240 XTENSA_OPTION_DEBUG,
5241 },
bf525107 5242 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
168c12b0
MF
5243 }, {
5244 .name = "wsr.icount",
59419607 5245 .translate = translate_wsr_icount,
91dc2b2d 5246 .test_exceptions = test_exceptions_sr,
59419607
MF
5247 .par = (const uint32_t[]){
5248 ICOUNT,
5249 XTENSA_OPTION_DEBUG,
5250 },
21a2dad5 5251 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5252 }, {
5253 .name = "wsr.icountlevel",
59419607 5254 .translate = translate_wsr_mask,
91dc2b2d 5255 .test_exceptions = test_exceptions_sr,
59419607
MF
5256 .par = (const uint32_t[]){
5257 ICOUNTLEVEL,
5258 XTENSA_OPTION_DEBUG,
5259 0xf,
5260 },
226444a8 5261 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_M1,
168c12b0
MF
5262 }, {
5263 .name = "wsr.intclear",
59419607 5264 .translate = translate_wsr_intclear,
91dc2b2d 5265 .test_exceptions = test_exceptions_sr,
59419607
MF
5266 .par = (const uint32_t[]){
5267 INTCLEAR,
5268 XTENSA_OPTION_INTERRUPT,
5269 },
d74624e5
MF
5270 .op_flags =
5271 XTENSA_OP_PRIVILEGED |
5272 XTENSA_OP_EXIT_TB_0 |
5273 XTENSA_OP_CHECK_INTERRUPTS,
168c12b0
MF
5274 }, {
5275 .name = "wsr.intenable",
5276 .translate = translate_wsr,
91dc2b2d 5277 .test_exceptions = test_exceptions_sr,
59419607
MF
5278 .par = (const uint32_t[]){
5279 INTENABLE,
5280 XTENSA_OPTION_INTERRUPT,
5281 },
d74624e5
MF
5282 .op_flags =
5283 XTENSA_OP_PRIVILEGED |
5284 XTENSA_OP_EXIT_TB_0 |
5285 XTENSA_OP_CHECK_INTERRUPTS,
168c12b0
MF
5286 }, {
5287 .name = "wsr.interrupt",
5288 .translate = translate_wsr,
91dc2b2d 5289 .test_exceptions = test_exceptions_sr,
59419607
MF
5290 .par = (const uint32_t[]){
5291 INTSET,
5292 XTENSA_OPTION_INTERRUPT,
5293 },
d74624e5
MF
5294 .op_flags =
5295 XTENSA_OP_PRIVILEGED |
5296 XTENSA_OP_EXIT_TB_0 |
5297 XTENSA_OP_CHECK_INTERRUPTS,
168c12b0
MF
5298 }, {
5299 .name = "wsr.intset",
59419607 5300 .translate = translate_wsr_intset,
91dc2b2d 5301 .test_exceptions = test_exceptions_sr,
59419607
MF
5302 .par = (const uint32_t[]){
5303 INTSET,
5304 XTENSA_OPTION_INTERRUPT,
5305 },
d74624e5
MF
5306 .op_flags =
5307 XTENSA_OP_PRIVILEGED |
5308 XTENSA_OP_EXIT_TB_0 |
5309 XTENSA_OP_CHECK_INTERRUPTS,
168c12b0
MF
5310 }, {
5311 .name = "wsr.itlbcfg",
59419607 5312 .translate = translate_wsr_mask,
91dc2b2d 5313 .test_exceptions = test_exceptions_sr,
59419607
MF
5314 .par = (const uint32_t[]){
5315 ITLBCFG,
5316 XTENSA_OPTION_MMU,
5317 0x01130000,
5318 },
21a2dad5 5319 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5320 }, {
5321 .name = "wsr.lbeg",
5322 .translate = translate_wsr,
91dc2b2d 5323 .test_exceptions = test_exceptions_sr,
59419607
MF
5324 .par = (const uint32_t[]){
5325 LBEG,
5326 XTENSA_OPTION_LOOP,
5327 },
5d630cef 5328 .op_flags = XTENSA_OP_EXIT_TB_M1,
168c12b0
MF
5329 }, {
5330 .name = "wsr.lcount",
5331 .translate = translate_wsr,
91dc2b2d 5332 .test_exceptions = test_exceptions_sr,
59419607
MF
5333 .par = (const uint32_t[]){
5334 LCOUNT,
5335 XTENSA_OPTION_LOOP,
5336 },
168c12b0
MF
5337 }, {
5338 .name = "wsr.lend",
5339 .translate = translate_wsr,
91dc2b2d 5340 .test_exceptions = test_exceptions_sr,
59419607
MF
5341 .par = (const uint32_t[]){
5342 LEND,
5343 XTENSA_OPTION_LOOP,
5344 },
5d630cef 5345 .op_flags = XTENSA_OP_EXIT_TB_M1,
168c12b0
MF
5346 }, {
5347 .name = "wsr.litbase",
59419607 5348 .translate = translate_wsr_mask,
91dc2b2d 5349 .test_exceptions = test_exceptions_sr,
59419607
MF
5350 .par = (const uint32_t[]){
5351 LITBASE,
5352 XTENSA_OPTION_EXTENDED_L32R,
5353 0xfffff001,
5354 },
226444a8 5355 .op_flags = XTENSA_OP_EXIT_TB_M1,
168c12b0
MF
5356 }, {
5357 .name = "wsr.m0",
5358 .translate = translate_wsr,
91dc2b2d 5359 .test_exceptions = test_exceptions_sr,
59419607
MF
5360 .par = (const uint32_t[]){
5361 MR,
5362 XTENSA_OPTION_MAC16,
5363 },
168c12b0
MF
5364 }, {
5365 .name = "wsr.m1",
5366 .translate = translate_wsr,
91dc2b2d 5367 .test_exceptions = test_exceptions_sr,
59419607
MF
5368 .par = (const uint32_t[]){
5369 MR + 1,
5370 XTENSA_OPTION_MAC16,
5371 },
168c12b0
MF
5372 }, {
5373 .name = "wsr.m2",
5374 .translate = translate_wsr,
91dc2b2d 5375 .test_exceptions = test_exceptions_sr,
59419607
MF
5376 .par = (const uint32_t[]){
5377 MR + 2,
5378 XTENSA_OPTION_MAC16,
5379 },
168c12b0
MF
5380 }, {
5381 .name = "wsr.m3",
5382 .translate = translate_wsr,
91dc2b2d 5383 .test_exceptions = test_exceptions_sr,
59419607
MF
5384 .par = (const uint32_t[]){
5385 MR + 3,
5386 XTENSA_OPTION_MAC16,
5387 },
168c12b0
MF
5388 }, {
5389 .name = "wsr.memctl",
59419607 5390 .translate = translate_wsr_memctl,
168c12b0 5391 .par = (const uint32_t[]){MEMCTL},
21a2dad5 5392 .op_flags = XTENSA_OP_PRIVILEGED,
631a77a0
MF
5393 }, {
5394 .name = "wsr.mecr",
5395 .translate = translate_wsr,
91dc2b2d 5396 .test_exceptions = test_exceptions_sr,
631a77a0
MF
5397 .par = (const uint32_t[]){
5398 MECR,
5399 XTENSA_OPTION_MEMORY_ECC_PARITY,
5400 },
5401 .op_flags = XTENSA_OP_PRIVILEGED,
5402 }, {
5403 .name = "wsr.mepc",
5404 .translate = translate_wsr,
91dc2b2d 5405 .test_exceptions = test_exceptions_sr,
631a77a0
MF
5406 .par = (const uint32_t[]){
5407 MEPC,
5408 XTENSA_OPTION_MEMORY_ECC_PARITY,
5409 },
5410 .op_flags = XTENSA_OP_PRIVILEGED,
5411 }, {
5412 .name = "wsr.meps",
5413 .translate = translate_wsr,
91dc2b2d 5414 .test_exceptions = test_exceptions_sr,
631a77a0
MF
5415 .par = (const uint32_t[]){
5416 MEPS,
5417 XTENSA_OPTION_MEMORY_ECC_PARITY,
5418 },
5419 .op_flags = XTENSA_OP_PRIVILEGED,
5420 }, {
5421 .name = "wsr.mesave",
5422 .translate = translate_wsr,
91dc2b2d 5423 .test_exceptions = test_exceptions_sr,
631a77a0
MF
5424 .par = (const uint32_t[]){
5425 MESAVE,
5426 XTENSA_OPTION_MEMORY_ECC_PARITY,
5427 },
5428 .op_flags = XTENSA_OP_PRIVILEGED,
5429 }, {
5430 .name = "wsr.mesr",
5431 .translate = translate_wsr,
91dc2b2d 5432 .test_exceptions = test_exceptions_sr,
631a77a0
MF
5433 .par = (const uint32_t[]){
5434 MESR,
5435 XTENSA_OPTION_MEMORY_ECC_PARITY,
5436 },
5437 .op_flags = XTENSA_OP_PRIVILEGED,
5438 }, {
5439 .name = "wsr.mevaddr",
5440 .translate = translate_wsr,
91dc2b2d 5441 .test_exceptions = test_exceptions_sr,
631a77a0
MF
5442 .par = (const uint32_t[]){
5443 MESR,
5444 XTENSA_OPTION_MEMORY_ECC_PARITY,
5445 },
5446 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5447 }, {
5448 .name = "wsr.misc0",
5449 .translate = translate_wsr,
91dc2b2d 5450 .test_exceptions = test_exceptions_sr,
59419607
MF
5451 .par = (const uint32_t[]){
5452 MISC,
5453 XTENSA_OPTION_MISC_SR,
5454 },
21a2dad5 5455 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5456 }, {
5457 .name = "wsr.misc1",
5458 .translate = translate_wsr,
91dc2b2d 5459 .test_exceptions = test_exceptions_sr,
59419607
MF
5460 .par = (const uint32_t[]){
5461 MISC + 1,
5462 XTENSA_OPTION_MISC_SR,
5463 },
21a2dad5 5464 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5465 }, {
5466 .name = "wsr.misc2",
5467 .translate = translate_wsr,
91dc2b2d 5468 .test_exceptions = test_exceptions_sr,
59419607
MF
5469 .par = (const uint32_t[]){
5470 MISC + 2,
5471 XTENSA_OPTION_MISC_SR,
5472 },
21a2dad5 5473 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5474 }, {
5475 .name = "wsr.misc3",
5476 .translate = translate_wsr,
91dc2b2d 5477 .test_exceptions = test_exceptions_sr,
59419607
MF
5478 .par = (const uint32_t[]){
5479 MISC + 3,
5480 XTENSA_OPTION_MISC_SR,
5481 },
21a2dad5 5482 .op_flags = XTENSA_OP_PRIVILEGED,
13f6a7cd
MF
5483 }, {
5484 .name = "wsr.mmid",
5485 .translate = translate_wsr,
91dc2b2d 5486 .test_exceptions = test_exceptions_sr,
59419607
MF
5487 .par = (const uint32_t[]){
5488 MMID,
5489 XTENSA_OPTION_TRACE_PORT,
5490 },
21a2dad5 5491 .op_flags = XTENSA_OP_PRIVILEGED,
4d04ea35
MF
5492 }, {
5493 .name = "wsr.mpuenb",
5494 .translate = translate_wsr_mpuenb,
91dc2b2d 5495 .test_exceptions = test_exceptions_sr,
4d04ea35
MF
5496 .par = (const uint32_t[]){
5497 MPUENB,
5498 XTENSA_OPTION_MPU,
5499 },
5500 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_M1,
eb3f4298
MF
5501 }, {
5502 .name = "wsr.prefctl",
5503 .translate = translate_wsr,
eb3f4298 5504 .par = (const uint32_t[]){PREFCTL},
168c12b0
MF
5505 }, {
5506 .name = "wsr.prid",
59419607 5507 .op_flags = XTENSA_OP_ILL,
168c12b0
MF
5508 }, {
5509 .name = "wsr.ps",
59419607 5510 .translate = translate_wsr_ps,
91dc2b2d 5511 .test_exceptions = test_exceptions_sr,
59419607
MF
5512 .par = (const uint32_t[]){
5513 PS,
5514 XTENSA_OPTION_EXCEPTION,
5515 },
d74624e5
MF
5516 .op_flags =
5517 XTENSA_OP_PRIVILEGED |
5518 XTENSA_OP_EXIT_TB_M1 |
5519 XTENSA_OP_CHECK_INTERRUPTS,
168c12b0
MF
5520 }, {
5521 .name = "wsr.ptevaddr",
59419607 5522 .translate = translate_wsr_mask,
91dc2b2d 5523 .test_exceptions = test_exceptions_sr,
59419607
MF
5524 .par = (const uint32_t[]){
5525 PTEVADDR,
5526 XTENSA_OPTION_MMU,
5527 0xffc00000,
5528 },
21a2dad5 5529 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5530 }, {
5531 .name = "wsr.rasid",
59419607 5532 .translate = translate_wsr_rasid,
91dc2b2d 5533 .test_exceptions = test_exceptions_sr,
59419607
MF
5534 .par = (const uint32_t[]){
5535 RASID,
5536 XTENSA_OPTION_MMU,
5537 },
226444a8 5538 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_M1,
168c12b0
MF
5539 }, {
5540 .name = "wsr.sar",
59419607 5541 .translate = translate_wsr_sar,
168c12b0
MF
5542 .par = (const uint32_t[]){SAR},
5543 }, {
5544 .name = "wsr.scompare1",
5545 .translate = translate_wsr,
91dc2b2d 5546 .test_exceptions = test_exceptions_sr,
59419607
MF
5547 .par = (const uint32_t[]){
5548 SCOMPARE1,
5549 XTENSA_OPTION_CONDITIONAL_STORE,
5550 },
168c12b0
MF
5551 }, {
5552 .name = "wsr.vecbase",
5553 .translate = translate_wsr,
91dc2b2d 5554 .test_exceptions = test_exceptions_sr,
59419607
MF
5555 .par = (const uint32_t[]){
5556 VECBASE,
5557 XTENSA_OPTION_RELOCATABLE_VECTOR,
5558 },
21a2dad5 5559 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5560 }, {
5561 .name = "wsr.windowbase",
59419607 5562 .translate = translate_wsr_windowbase,
91dc2b2d 5563 .test_exceptions = test_exceptions_sr,
59419607
MF
5564 .par = (const uint32_t[]){
5565 WINDOW_BASE,
5566 XTENSA_OPTION_WINDOWED_REGISTER,
5567 },
8df3fd35
MF
5568 .op_flags = XTENSA_OP_PRIVILEGED |
5569 XTENSA_OP_EXIT_TB_M1 |
5570 XTENSA_OP_SYNC_REGISTER_WINDOW,
168c12b0
MF
5571 }, {
5572 .name = "wsr.windowstart",
59419607 5573 .translate = translate_wsr_windowstart,
91dc2b2d 5574 .test_exceptions = test_exceptions_sr,
59419607
MF
5575 .par = (const uint32_t[]){
5576 WINDOW_START,
5577 XTENSA_OPTION_WINDOWED_REGISTER,
5578 },
226444a8 5579 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_M1,
e9872741
MF
5580 }, {
5581 .name = "wur.expstate",
5582 .translate = translate_wur,
5583 .par = (const uint32_t[]){EXPSTATE},
168c12b0
MF
5584 }, {
5585 .name = "wur.fcr",
5680f207 5586 .translate = translate_wur_fpu2k_fcr,
168c12b0 5587 .par = (const uint32_t[]){FCR},
582fef0f 5588 .coprocessor = 0x1,
168c12b0
MF
5589 }, {
5590 .name = "wur.fsr",
59419607 5591 .translate = translate_wur_fsr,
168c12b0 5592 .par = (const uint32_t[]){FSR},
582fef0f 5593 .coprocessor = 0x1,
168c12b0
MF
5594 }, {
5595 .name = "wur.threadptr",
5596 .translate = translate_wur,
5597 .par = (const uint32_t[]){THREADPTR},
5598 }, {
5599 .name = "xor",
5600 .translate = translate_xor,
5601 }, {
5602 .name = "xorb",
5603 .translate = translate_boolean,
5604 .par = (const uint32_t[]){BOOLEAN_XOR},
5605 }, {
5606 .name = "xsr.176",
59419607 5607 .op_flags = XTENSA_OP_ILL,
168c12b0
MF
5608 }, {
5609 .name = "xsr.208",
59419607 5610 .op_flags = XTENSA_OP_ILL,
168c12b0
MF
5611 }, {
5612 .name = "xsr.acchi",
59419607 5613 .translate = translate_xsr_acchi,
91dc2b2d 5614 .test_exceptions = test_exceptions_sr,
59419607
MF
5615 .par = (const uint32_t[]){
5616 ACCHI,
5617 XTENSA_OPTION_MAC16,
5618 },
168c12b0
MF
5619 }, {
5620 .name = "xsr.acclo",
5621 .translate = translate_xsr,
91dc2b2d 5622 .test_exceptions = test_exceptions_sr,
59419607
MF
5623 .par = (const uint32_t[]){
5624 ACCLO,
5625 XTENSA_OPTION_MAC16,
5626 },
168c12b0
MF
5627 }, {
5628 .name = "xsr.atomctl",
59419607 5629 .translate = translate_xsr_mask,
91dc2b2d 5630 .test_exceptions = test_exceptions_sr,
59419607
MF
5631 .par = (const uint32_t[]){
5632 ATOMCTL,
5633 XTENSA_OPTION_ATOMCTL,
5634 0x3f,
5635 },
21a2dad5 5636 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5637 }, {
5638 .name = "xsr.br",
59419607 5639 .translate = translate_xsr_mask,
91dc2b2d 5640 .test_exceptions = test_exceptions_sr,
59419607
MF
5641 .par = (const uint32_t[]){
5642 BR,
5643 XTENSA_OPTION_BOOLEAN,
5644 0xffff,
5645 },
4d04ea35
MF
5646 }, {
5647 .name = "xsr.cacheadrdis",
5648 .translate = translate_xsr_mask,
91dc2b2d 5649 .test_exceptions = test_exceptions_sr,
4d04ea35
MF
5650 .par = (const uint32_t[]){
5651 CACHEADRDIS,
5652 XTENSA_OPTION_MPU,
5653 0xff,
5654 },
5655 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5656 }, {
5657 .name = "xsr.cacheattr",
5658 .translate = translate_xsr,
91dc2b2d 5659 .test_exceptions = test_exceptions_sr,
59419607
MF
5660 .par = (const uint32_t[]){
5661 CACHEATTR,
5662 XTENSA_OPTION_CACHEATTR,
5663 },
21a2dad5 5664 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5665 }, {
5666 .name = "xsr.ccompare0",
59419607 5667 .translate = translate_xsr_ccompare,
91dc2b2d 5668 .test_exceptions = test_exceptions_ccompare,
59419607
MF
5669 .par = (const uint32_t[]){
5670 CCOMPARE,
5671 XTENSA_OPTION_TIMER_INTERRUPT,
5672 },
bf525107 5673 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
168c12b0
MF
5674 }, {
5675 .name = "xsr.ccompare1",
59419607 5676 .translate = translate_xsr_ccompare,
91dc2b2d 5677 .test_exceptions = test_exceptions_ccompare,
59419607
MF
5678 .par = (const uint32_t[]){
5679 CCOMPARE + 1,
5680 XTENSA_OPTION_TIMER_INTERRUPT,
5681 },
bf525107 5682 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
168c12b0
MF
5683 }, {
5684 .name = "xsr.ccompare2",
59419607 5685 .translate = translate_xsr_ccompare,
91dc2b2d 5686 .test_exceptions = test_exceptions_ccompare,
59419607
MF
5687 .par = (const uint32_t[]){
5688 CCOMPARE + 2,
5689 XTENSA_OPTION_TIMER_INTERRUPT,
5690 },
bf525107 5691 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
168c12b0
MF
5692 }, {
5693 .name = "xsr.ccount",
59419607 5694 .translate = translate_xsr_ccount,
91dc2b2d 5695 .test_exceptions = test_exceptions_sr,
59419607
MF
5696 .par = (const uint32_t[]){
5697 CCOUNT,
5698 XTENSA_OPTION_TIMER_INTERRUPT,
5699 },
bf525107 5700 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
168c12b0
MF
5701 }, {
5702 .name = "xsr.configid0",
59419607 5703 .op_flags = XTENSA_OP_ILL,
168c12b0
MF
5704 }, {
5705 .name = "xsr.configid1",
59419607 5706 .op_flags = XTENSA_OP_ILL,
168c12b0
MF
5707 }, {
5708 .name = "xsr.cpenable",
59419607 5709 .translate = translate_xsr_mask,
91dc2b2d 5710 .test_exceptions = test_exceptions_sr,
59419607
MF
5711 .par = (const uint32_t[]){
5712 CPENABLE,
5713 XTENSA_OPTION_COPROCESSOR,
5714 0xff,
5715 },
226444a8 5716 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_M1,
168c12b0
MF
5717 }, {
5718 .name = "xsr.dbreaka0",
59419607 5719 .translate = translate_xsr_dbreaka,
91dc2b2d 5720 .test_exceptions = test_exceptions_dbreak,
59419607
MF
5721 .par = (const uint32_t[]){
5722 DBREAKA,
5723 XTENSA_OPTION_DEBUG,
5724 },
21a2dad5 5725 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5726 }, {
5727 .name = "xsr.dbreaka1",
59419607 5728 .translate = translate_xsr_dbreaka,
91dc2b2d 5729 .test_exceptions = test_exceptions_dbreak,
59419607
MF
5730 .par = (const uint32_t[]){
5731 DBREAKA + 1,
5732 XTENSA_OPTION_DEBUG,
5733 },
21a2dad5 5734 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5735 }, {
5736 .name = "xsr.dbreakc0",
59419607 5737 .translate = translate_xsr_dbreakc,
91dc2b2d 5738 .test_exceptions = test_exceptions_dbreak,
59419607
MF
5739 .par = (const uint32_t[]){
5740 DBREAKC,
5741 XTENSA_OPTION_DEBUG,
5742 },
21a2dad5 5743 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5744 }, {
5745 .name = "xsr.dbreakc1",
59419607 5746 .translate = translate_xsr_dbreakc,
91dc2b2d 5747 .test_exceptions = test_exceptions_dbreak,
59419607
MF
5748 .par = (const uint32_t[]){
5749 DBREAKC + 1,
5750 XTENSA_OPTION_DEBUG,
5751 },
21a2dad5 5752 .op_flags = XTENSA_OP_PRIVILEGED,
13f6a7cd
MF
5753 }, {
5754 .name = "xsr.ddr",
5755 .translate = translate_xsr,
91dc2b2d 5756 .test_exceptions = test_exceptions_sr,
59419607
MF
5757 .par = (const uint32_t[]){
5758 DDR,
5759 XTENSA_OPTION_DEBUG,
5760 },
21a2dad5 5761 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5762 }, {
5763 .name = "xsr.debugcause",
59419607 5764 .op_flags = XTENSA_OP_ILL,
168c12b0
MF
5765 }, {
5766 .name = "xsr.depc",
5767 .translate = translate_xsr,
91dc2b2d 5768 .test_exceptions = test_exceptions_sr,
59419607
MF
5769 .par = (const uint32_t[]){
5770 DEPC,
5771 XTENSA_OPTION_EXCEPTION,
5772 },
21a2dad5 5773 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5774 }, {
5775 .name = "xsr.dtlbcfg",
59419607 5776 .translate = translate_xsr_mask,
91dc2b2d 5777 .test_exceptions = test_exceptions_sr,
59419607
MF
5778 .par = (const uint32_t[]){
5779 DTLBCFG,
5780 XTENSA_OPTION_MMU,
5781 0x01130000,
5782 },
21a2dad5 5783 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5784 }, {
5785 .name = "xsr.epc1",
5786 .translate = translate_xsr,
91dc2b2d 5787 .test_exceptions = test_exceptions_sr,
59419607
MF
5788 .par = (const uint32_t[]){
5789 EPC1,
5790 XTENSA_OPTION_EXCEPTION,
5791 },
21a2dad5 5792 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5793 }, {
5794 .name = "xsr.epc2",
5795 .translate = translate_xsr,
91dc2b2d 5796 .test_exceptions = test_exceptions_hpi,
59419607
MF
5797 .par = (const uint32_t[]){
5798 EPC1 + 1,
5799 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5800 },
21a2dad5 5801 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5802 }, {
5803 .name = "xsr.epc3",
5804 .translate = translate_xsr,
91dc2b2d 5805 .test_exceptions = test_exceptions_hpi,
59419607
MF
5806 .par = (const uint32_t[]){
5807 EPC1 + 2,
5808 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5809 },
21a2dad5 5810 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5811 }, {
5812 .name = "xsr.epc4",
5813 .translate = translate_xsr,
91dc2b2d 5814 .test_exceptions = test_exceptions_hpi,
59419607
MF
5815 .par = (const uint32_t[]){
5816 EPC1 + 3,
5817 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5818 },
21a2dad5 5819 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5820 }, {
5821 .name = "xsr.epc5",
5822 .translate = translate_xsr,
91dc2b2d 5823 .test_exceptions = test_exceptions_hpi,
59419607
MF
5824 .par = (const uint32_t[]){
5825 EPC1 + 4,
5826 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5827 },
21a2dad5 5828 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5829 }, {
5830 .name = "xsr.epc6",
5831 .translate = translate_xsr,
91dc2b2d 5832 .test_exceptions = test_exceptions_hpi,
59419607
MF
5833 .par = (const uint32_t[]){
5834 EPC1 + 5,
5835 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5836 },
21a2dad5 5837 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5838 }, {
5839 .name = "xsr.epc7",
5840 .translate = translate_xsr,
91dc2b2d 5841 .test_exceptions = test_exceptions_hpi,
59419607
MF
5842 .par = (const uint32_t[]){
5843 EPC1 + 6,
5844 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5845 },
21a2dad5 5846 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5847 }, {
5848 .name = "xsr.eps2",
5849 .translate = translate_xsr,
91dc2b2d 5850 .test_exceptions = test_exceptions_hpi,
59419607
MF
5851 .par = (const uint32_t[]){
5852 EPS2,
5853 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5854 },
21a2dad5 5855 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5856 }, {
5857 .name = "xsr.eps3",
5858 .translate = translate_xsr,
91dc2b2d 5859 .test_exceptions = test_exceptions_hpi,
59419607
MF
5860 .par = (const uint32_t[]){
5861 EPS2 + 1,
5862 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5863 },
21a2dad5 5864 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5865 }, {
5866 .name = "xsr.eps4",
5867 .translate = translate_xsr,
91dc2b2d 5868 .test_exceptions = test_exceptions_hpi,
59419607
MF
5869 .par = (const uint32_t[]){
5870 EPS2 + 2,
5871 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5872 },
21a2dad5 5873 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5874 }, {
5875 .name = "xsr.eps5",
5876 .translate = translate_xsr,
91dc2b2d 5877 .test_exceptions = test_exceptions_hpi,
59419607
MF
5878 .par = (const uint32_t[]){
5879 EPS2 + 3,
5880 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5881 },
21a2dad5 5882 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5883 }, {
5884 .name = "xsr.eps6",
5885 .translate = translate_xsr,
91dc2b2d 5886 .test_exceptions = test_exceptions_hpi,
59419607
MF
5887 .par = (const uint32_t[]){
5888 EPS2 + 4,
5889 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5890 },
21a2dad5 5891 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5892 }, {
5893 .name = "xsr.eps7",
5894 .translate = translate_xsr,
91dc2b2d 5895 .test_exceptions = test_exceptions_hpi,
59419607
MF
5896 .par = (const uint32_t[]){
5897 EPS2 + 5,
5898 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5899 },
21a2dad5 5900 .op_flags = XTENSA_OP_PRIVILEGED,
4d04ea35
MF
5901 }, {
5902 .name = "xsr.eraccess",
5903 .translate = translate_xsr_mask,
5904 .par = (const uint32_t[]){
5905 ERACCESS,
5906 0,
5907 0xffff,
5908 },
21a2dad5 5909 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5910 }, {
5911 .name = "xsr.exccause",
5912 .translate = translate_xsr,
91dc2b2d 5913 .test_exceptions = test_exceptions_sr,
59419607
MF
5914 .par = (const uint32_t[]){
5915 EXCCAUSE,
5916 XTENSA_OPTION_EXCEPTION,
5917 },
21a2dad5 5918 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5919 }, {
5920 .name = "xsr.excsave1",
5921 .translate = translate_xsr,
91dc2b2d 5922 .test_exceptions = test_exceptions_sr,
59419607
MF
5923 .par = (const uint32_t[]){
5924 EXCSAVE1,
5925 XTENSA_OPTION_EXCEPTION,
5926 },
21a2dad5 5927 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5928 }, {
5929 .name = "xsr.excsave2",
5930 .translate = translate_xsr,
91dc2b2d 5931 .test_exceptions = test_exceptions_hpi,
59419607
MF
5932 .par = (const uint32_t[]){
5933 EXCSAVE1 + 1,
5934 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5935 },
21a2dad5 5936 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5937 }, {
5938 .name = "xsr.excsave3",
5939 .translate = translate_xsr,
91dc2b2d 5940 .test_exceptions = test_exceptions_hpi,
59419607
MF
5941 .par = (const uint32_t[]){
5942 EXCSAVE1 + 2,
5943 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5944 },
21a2dad5 5945 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5946 }, {
5947 .name = "xsr.excsave4",
5948 .translate = translate_xsr,
91dc2b2d 5949 .test_exceptions = test_exceptions_hpi,
59419607
MF
5950 .par = (const uint32_t[]){
5951 EXCSAVE1 + 3,
5952 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5953 },
21a2dad5 5954 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5955 }, {
5956 .name = "xsr.excsave5",
5957 .translate = translate_xsr,
91dc2b2d 5958 .test_exceptions = test_exceptions_hpi,
59419607
MF
5959 .par = (const uint32_t[]){
5960 EXCSAVE1 + 4,
5961 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5962 },
21a2dad5 5963 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5964 }, {
5965 .name = "xsr.excsave6",
5966 .translate = translate_xsr,
91dc2b2d 5967 .test_exceptions = test_exceptions_hpi,
59419607
MF
5968 .par = (const uint32_t[]){
5969 EXCSAVE1 + 5,
5970 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5971 },
21a2dad5 5972 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5973 }, {
5974 .name = "xsr.excsave7",
5975 .translate = translate_xsr,
91dc2b2d 5976 .test_exceptions = test_exceptions_hpi,
59419607
MF
5977 .par = (const uint32_t[]){
5978 EXCSAVE1 + 6,
5979 XTENSA_OPTION_HIGH_PRIORITY_INTERRUPT,
5980 },
21a2dad5 5981 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5982 }, {
5983 .name = "xsr.excvaddr",
5984 .translate = translate_xsr,
91dc2b2d 5985 .test_exceptions = test_exceptions_sr,
59419607
MF
5986 .par = (const uint32_t[]){
5987 EXCVADDR,
5988 XTENSA_OPTION_EXCEPTION,
5989 },
21a2dad5 5990 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
5991 }, {
5992 .name = "xsr.ibreaka0",
59419607 5993 .translate = translate_xsr_ibreaka,
91dc2b2d 5994 .test_exceptions = test_exceptions_ibreak,
59419607
MF
5995 .par = (const uint32_t[]){
5996 IBREAKA,
5997 XTENSA_OPTION_DEBUG,
5998 },
bf525107 5999 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
168c12b0
MF
6000 }, {
6001 .name = "xsr.ibreaka1",
59419607 6002 .translate = translate_xsr_ibreaka,
91dc2b2d 6003 .test_exceptions = test_exceptions_ibreak,
59419607
MF
6004 .par = (const uint32_t[]){
6005 IBREAKA + 1,
6006 XTENSA_OPTION_DEBUG,
6007 },
bf525107 6008 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
168c12b0
MF
6009 }, {
6010 .name = "xsr.ibreakenable",
59419607 6011 .translate = translate_xsr_ibreakenable,
91dc2b2d 6012 .test_exceptions = test_exceptions_sr,
59419607
MF
6013 .par = (const uint32_t[]){
6014 IBREAKENABLE,
6015 XTENSA_OPTION_DEBUG,
6016 },
bf525107 6017 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_0,
168c12b0
MF
6018 }, {
6019 .name = "xsr.icount",
59419607 6020 .translate = translate_xsr_icount,
91dc2b2d 6021 .test_exceptions = test_exceptions_sr,
59419607
MF
6022 .par = (const uint32_t[]){
6023 ICOUNT,
6024 XTENSA_OPTION_DEBUG,
6025 },
21a2dad5 6026 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
6027 }, {
6028 .name = "xsr.icountlevel",
59419607 6029 .translate = translate_xsr_mask,
91dc2b2d 6030 .test_exceptions = test_exceptions_sr,
59419607
MF
6031 .par = (const uint32_t[]){
6032 ICOUNTLEVEL,
6033 XTENSA_OPTION_DEBUG,
6034 0xf,
6035 },
226444a8 6036 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_M1,
168c12b0
MF
6037 }, {
6038 .name = "xsr.intclear",
59419607 6039 .op_flags = XTENSA_OP_ILL,
168c12b0
MF
6040 }, {
6041 .name = "xsr.intenable",
6042 .translate = translate_xsr,
91dc2b2d 6043 .test_exceptions = test_exceptions_sr,
59419607
MF
6044 .par = (const uint32_t[]){
6045 INTENABLE,
6046 XTENSA_OPTION_INTERRUPT,
6047 },
d74624e5
MF
6048 .op_flags =
6049 XTENSA_OP_PRIVILEGED |
6050 XTENSA_OP_EXIT_TB_0 |
6051 XTENSA_OP_CHECK_INTERRUPTS,
168c12b0
MF
6052 }, {
6053 .name = "xsr.interrupt",
59419607 6054 .op_flags = XTENSA_OP_ILL,
168c12b0
MF
6055 }, {
6056 .name = "xsr.intset",
59419607 6057 .op_flags = XTENSA_OP_ILL,
168c12b0
MF
6058 }, {
6059 .name = "xsr.itlbcfg",
59419607 6060 .translate = translate_xsr_mask,
91dc2b2d 6061 .test_exceptions = test_exceptions_sr,
59419607
MF
6062 .par = (const uint32_t[]){
6063 ITLBCFG,
6064 XTENSA_OPTION_MMU,
6065 0x01130000,
6066 },
21a2dad5 6067 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
6068 }, {
6069 .name = "xsr.lbeg",
6070 .translate = translate_xsr,
91dc2b2d 6071 .test_exceptions = test_exceptions_sr,
59419607
MF
6072 .par = (const uint32_t[]){
6073 LBEG,
6074 XTENSA_OPTION_LOOP,
6075 },
5d630cef 6076 .op_flags = XTENSA_OP_EXIT_TB_M1,
168c12b0
MF
6077 }, {
6078 .name = "xsr.lcount",
6079 .translate = translate_xsr,
91dc2b2d 6080 .test_exceptions = test_exceptions_sr,
59419607
MF
6081 .par = (const uint32_t[]){
6082 LCOUNT,
6083 XTENSA_OPTION_LOOP,
6084 },
168c12b0
MF
6085 }, {
6086 .name = "xsr.lend",
6087 .translate = translate_xsr,
91dc2b2d 6088 .test_exceptions = test_exceptions_sr,
59419607
MF
6089 .par = (const uint32_t[]){
6090 LEND,
6091 XTENSA_OPTION_LOOP,
6092 },
5d630cef 6093 .op_flags = XTENSA_OP_EXIT_TB_M1,
168c12b0
MF
6094 }, {
6095 .name = "xsr.litbase",
59419607 6096 .translate = translate_xsr_mask,
91dc2b2d 6097 .test_exceptions = test_exceptions_sr,
59419607
MF
6098 .par = (const uint32_t[]){
6099 LITBASE,
6100 XTENSA_OPTION_EXTENDED_L32R,
6101 0xfffff001,
6102 },
226444a8 6103 .op_flags = XTENSA_OP_EXIT_TB_M1,
168c12b0
MF
6104 }, {
6105 .name = "xsr.m0",
6106 .translate = translate_xsr,
91dc2b2d 6107 .test_exceptions = test_exceptions_sr,
59419607
MF
6108 .par = (const uint32_t[]){
6109 MR,
6110 XTENSA_OPTION_MAC16,
6111 },
168c12b0
MF
6112 }, {
6113 .name = "xsr.m1",
6114 .translate = translate_xsr,
91dc2b2d 6115 .test_exceptions = test_exceptions_sr,
59419607
MF
6116 .par = (const uint32_t[]){
6117 MR + 1,
6118 XTENSA_OPTION_MAC16,
6119 },
168c12b0
MF
6120 }, {
6121 .name = "xsr.m2",
6122 .translate = translate_xsr,
91dc2b2d 6123 .test_exceptions = test_exceptions_sr,
59419607
MF
6124 .par = (const uint32_t[]){
6125 MR + 2,
6126 XTENSA_OPTION_MAC16,
6127 },
168c12b0
MF
6128 }, {
6129 .name = "xsr.m3",
6130 .translate = translate_xsr,
91dc2b2d 6131 .test_exceptions = test_exceptions_sr,
59419607
MF
6132 .par = (const uint32_t[]){
6133 MR + 3,
6134 XTENSA_OPTION_MAC16,
6135 },
168c12b0
MF
6136 }, {
6137 .name = "xsr.memctl",
59419607 6138 .translate = translate_xsr_memctl,
168c12b0 6139 .par = (const uint32_t[]){MEMCTL},
21a2dad5 6140 .op_flags = XTENSA_OP_PRIVILEGED,
631a77a0
MF
6141 }, {
6142 .name = "xsr.mecr",
6143 .translate = translate_xsr,
91dc2b2d 6144 .test_exceptions = test_exceptions_sr,
631a77a0
MF
6145 .par = (const uint32_t[]){
6146 MECR,
6147 XTENSA_OPTION_MEMORY_ECC_PARITY,
6148 },
6149 .op_flags = XTENSA_OP_PRIVILEGED,
6150 }, {
6151 .name = "xsr.mepc",
6152 .translate = translate_xsr,
91dc2b2d 6153 .test_exceptions = test_exceptions_sr,
631a77a0
MF
6154 .par = (const uint32_t[]){
6155 MEPC,
6156 XTENSA_OPTION_MEMORY_ECC_PARITY,
6157 },
6158 .op_flags = XTENSA_OP_PRIVILEGED,
6159 }, {
6160 .name = "xsr.meps",
6161 .translate = translate_xsr,
91dc2b2d 6162 .test_exceptions = test_exceptions_sr,
631a77a0
MF
6163 .par = (const uint32_t[]){
6164 MEPS,
6165 XTENSA_OPTION_MEMORY_ECC_PARITY,
6166 },
6167 .op_flags = XTENSA_OP_PRIVILEGED,
6168 }, {
6169 .name = "xsr.mesave",
6170 .translate = translate_xsr,
91dc2b2d 6171 .test_exceptions = test_exceptions_sr,
631a77a0
MF
6172 .par = (const uint32_t[]){
6173 MESAVE,
6174 XTENSA_OPTION_MEMORY_ECC_PARITY,
6175 },
6176 .op_flags = XTENSA_OP_PRIVILEGED,
6177 }, {
6178 .name = "xsr.mesr",
6179 .translate = translate_xsr,
91dc2b2d 6180 .test_exceptions = test_exceptions_sr,
631a77a0
MF
6181 .par = (const uint32_t[]){
6182 MESR,
6183 XTENSA_OPTION_MEMORY_ECC_PARITY,
6184 },
6185 .op_flags = XTENSA_OP_PRIVILEGED,
6186 }, {
6187 .name = "xsr.mevaddr",
6188 .translate = translate_xsr,
91dc2b2d 6189 .test_exceptions = test_exceptions_sr,
631a77a0
MF
6190 .par = (const uint32_t[]){
6191 MESR,
6192 XTENSA_OPTION_MEMORY_ECC_PARITY,
6193 },
6194 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
6195 }, {
6196 .name = "xsr.misc0",
6197 .translate = translate_xsr,
91dc2b2d 6198 .test_exceptions = test_exceptions_sr,
59419607
MF
6199 .par = (const uint32_t[]){
6200 MISC,
6201 XTENSA_OPTION_MISC_SR,
6202 },
21a2dad5 6203 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
6204 }, {
6205 .name = "xsr.misc1",
6206 .translate = translate_xsr,
91dc2b2d 6207 .test_exceptions = test_exceptions_sr,
59419607
MF
6208 .par = (const uint32_t[]){
6209 MISC + 1,
6210 XTENSA_OPTION_MISC_SR,
6211 },
21a2dad5 6212 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
6213 }, {
6214 .name = "xsr.misc2",
6215 .translate = translate_xsr,
91dc2b2d 6216 .test_exceptions = test_exceptions_sr,
59419607
MF
6217 .par = (const uint32_t[]){
6218 MISC + 2,
6219 XTENSA_OPTION_MISC_SR,
6220 },
21a2dad5 6221 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
6222 }, {
6223 .name = "xsr.misc3",
6224 .translate = translate_xsr,
91dc2b2d 6225 .test_exceptions = test_exceptions_sr,
59419607
MF
6226 .par = (const uint32_t[]){
6227 MISC + 3,
6228 XTENSA_OPTION_MISC_SR,
6229 },
21a2dad5 6230 .op_flags = XTENSA_OP_PRIVILEGED,
4d04ea35
MF
6231 }, {
6232 .name = "xsr.mpuenb",
6233 .translate = translate_xsr_mpuenb,
91dc2b2d 6234 .test_exceptions = test_exceptions_sr,
4d04ea35
MF
6235 .par = (const uint32_t[]){
6236 MPUENB,
6237 XTENSA_OPTION_MPU,
6238 },
6239 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_M1,
eb3f4298
MF
6240 }, {
6241 .name = "xsr.prefctl",
6242 .translate = translate_xsr,
eb3f4298 6243 .par = (const uint32_t[]){PREFCTL},
168c12b0
MF
6244 }, {
6245 .name = "xsr.prid",
59419607 6246 .op_flags = XTENSA_OP_ILL,
168c12b0
MF
6247 }, {
6248 .name = "xsr.ps",
59419607 6249 .translate = translate_xsr_ps,
91dc2b2d 6250 .test_exceptions = test_exceptions_sr,
59419607
MF
6251 .par = (const uint32_t[]){
6252 PS,
6253 XTENSA_OPTION_EXCEPTION,
6254 },
d74624e5
MF
6255 .op_flags =
6256 XTENSA_OP_PRIVILEGED |
6257 XTENSA_OP_EXIT_TB_M1 |
6258 XTENSA_OP_CHECK_INTERRUPTS,
168c12b0
MF
6259 }, {
6260 .name = "xsr.ptevaddr",
59419607 6261 .translate = translate_xsr_mask,
91dc2b2d 6262 .test_exceptions = test_exceptions_sr,
59419607
MF
6263 .par = (const uint32_t[]){
6264 PTEVADDR,
6265 XTENSA_OPTION_MMU,
6266 0xffc00000,
6267 },
21a2dad5 6268 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
6269 }, {
6270 .name = "xsr.rasid",
59419607 6271 .translate = translate_xsr_rasid,
91dc2b2d 6272 .test_exceptions = test_exceptions_sr,
59419607
MF
6273 .par = (const uint32_t[]){
6274 RASID,
6275 XTENSA_OPTION_MMU,
6276 },
226444a8 6277 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_M1,
168c12b0
MF
6278 }, {
6279 .name = "xsr.sar",
59419607 6280 .translate = translate_xsr_sar,
168c12b0
MF
6281 .par = (const uint32_t[]){SAR},
6282 }, {
6283 .name = "xsr.scompare1",
6284 .translate = translate_xsr,
91dc2b2d 6285 .test_exceptions = test_exceptions_sr,
59419607
MF
6286 .par = (const uint32_t[]){
6287 SCOMPARE1,
6288 XTENSA_OPTION_CONDITIONAL_STORE,
6289 },
168c12b0
MF
6290 }, {
6291 .name = "xsr.vecbase",
6292 .translate = translate_xsr,
91dc2b2d 6293 .test_exceptions = test_exceptions_sr,
59419607
MF
6294 .par = (const uint32_t[]){
6295 VECBASE,
6296 XTENSA_OPTION_RELOCATABLE_VECTOR,
6297 },
21a2dad5 6298 .op_flags = XTENSA_OP_PRIVILEGED,
168c12b0
MF
6299 }, {
6300 .name = "xsr.windowbase",
59419607 6301 .translate = translate_xsr_windowbase,
91dc2b2d 6302 .test_exceptions = test_exceptions_sr,
59419607
MF
6303 .par = (const uint32_t[]){
6304 WINDOW_BASE,
6305 XTENSA_OPTION_WINDOWED_REGISTER,
6306 },
8df3fd35
MF
6307 .op_flags = XTENSA_OP_PRIVILEGED |
6308 XTENSA_OP_EXIT_TB_M1 |
6309 XTENSA_OP_SYNC_REGISTER_WINDOW,
168c12b0
MF
6310 }, {
6311 .name = "xsr.windowstart",
59419607 6312 .translate = translate_xsr_windowstart,
91dc2b2d 6313 .test_exceptions = test_exceptions_sr,
59419607
MF
6314 .par = (const uint32_t[]){
6315 WINDOW_START,
6316 XTENSA_OPTION_WINDOWED_REGISTER,
6317 },
226444a8 6318 .op_flags = XTENSA_OP_PRIVILEGED | XTENSA_OP_EXIT_TB_M1,
168c12b0
MF
6319 },
6320};
6321
6322const XtensaOpcodeTranslators xtensa_core_opcodes = {
6323 .num_opcodes = ARRAY_SIZE(core_ops),
6324 .opcode = core_ops,
6325};
c04e1692
MF
6326
6327
b0b24bdc 6328static void translate_abs_s(DisasContext *dc, const OpcodeArg arg[],
c04e1692
MF
6329 const uint32_t par[])
6330{
b0b24bdc 6331 gen_helper_abs_s(arg[0].out, arg[1].in);
c04e1692
MF
6332}
6333
5680f207
MF
6334static void translate_fpu2k_add_s(DisasContext *dc, const OpcodeArg arg[],
6335 const uint32_t par[])
c04e1692 6336{
5680f207
MF
6337 gen_helper_fpu2k_add_s(arg[0].out, cpu_env,
6338 arg[1].in, arg[2].in);
c04e1692
MF
6339}
6340
6341enum {
6342 COMPARE_UN,
6343 COMPARE_OEQ,
6344 COMPARE_UEQ,
6345 COMPARE_OLT,
6346 COMPARE_ULT,
6347 COMPARE_OLE,
6348 COMPARE_ULE,
6349};
6350
b0b24bdc 6351static void translate_compare_s(DisasContext *dc, const OpcodeArg arg[],
c04e1692
MF
6352 const uint32_t par[])
6353{
6354 static void (* const helper[])(TCGv_env env, TCGv_i32 bit,
6355 TCGv_i32 s, TCGv_i32 t) = {
6356 [COMPARE_UN] = gen_helper_un_s,
6357 [COMPARE_OEQ] = gen_helper_oeq_s,
6358 [COMPARE_UEQ] = gen_helper_ueq_s,
6359 [COMPARE_OLT] = gen_helper_olt_s,
6360 [COMPARE_ULT] = gen_helper_ult_s,
6361 [COMPARE_OLE] = gen_helper_ole_s,
6362 [COMPARE_ULE] = gen_helper_ule_s,
6363 };
b0b24bdc 6364 TCGv_i32 bit = tcg_const_i32(1 << arg[0].imm);
c04e1692 6365
b0b24bdc 6366 helper[par[0]](cpu_env, bit, arg[1].in, arg[2].in);
582fef0f 6367 tcg_temp_free(bit);
c04e1692
MF
6368}
6369
b0b24bdc 6370static void translate_float_s(DisasContext *dc, const OpcodeArg arg[],
c04e1692
MF
6371 const uint32_t par[])
6372{
b0b24bdc 6373 TCGv_i32 scale = tcg_const_i32(-arg[2].imm);
c04e1692 6374
582fef0f 6375 if (par[0]) {
5680f207 6376 gen_helper_uitof_s(arg[0].out, cpu_env, arg[1].in, scale);
582fef0f 6377 } else {
5680f207 6378 gen_helper_itof_s(arg[0].out, cpu_env, arg[1].in, scale);
c04e1692 6379 }
582fef0f 6380 tcg_temp_free(scale);
c04e1692
MF
6381}
6382
b0b24bdc 6383static void translate_ftoi_s(DisasContext *dc, const OpcodeArg arg[],
c04e1692
MF
6384 const uint32_t par[])
6385{
582fef0f 6386 TCGv_i32 rounding_mode = tcg_const_i32(par[0]);
b0b24bdc 6387 TCGv_i32 scale = tcg_const_i32(arg[2].imm);
c04e1692 6388
582fef0f 6389 if (par[1]) {
5680f207
MF
6390 gen_helper_ftoui_s(arg[0].out, arg[1].in,
6391 rounding_mode, scale);
582fef0f 6392 } else {
5680f207
MF
6393 gen_helper_ftoi_s(arg[0].out, arg[1].in,
6394 rounding_mode, scale);
c04e1692 6395 }
582fef0f
MF
6396 tcg_temp_free(rounding_mode);
6397 tcg_temp_free(scale);
c04e1692
MF
6398}
6399
b0b24bdc 6400static void translate_ldsti(DisasContext *dc, const OpcodeArg arg[],
c04e1692
MF
6401 const uint32_t par[])
6402{
582fef0f 6403 TCGv_i32 addr = tcg_temp_new_i32();
c04e1692 6404
b0b24bdc 6405 tcg_gen_addi_i32(addr, arg[1].in, arg[2].imm);
582fef0f
MF
6406 gen_load_store_alignment(dc, 2, addr, false);
6407 if (par[0]) {
b0b24bdc 6408 tcg_gen_qemu_st32(arg[0].in, addr, dc->cring);
582fef0f 6409 } else {
b0b24bdc 6410 tcg_gen_qemu_ld32u(arg[0].out, addr, dc->cring);
c04e1692 6411 }
582fef0f 6412 if (par[1]) {
b0b24bdc 6413 tcg_gen_mov_i32(arg[1].out, addr);
582fef0f
MF
6414 }
6415 tcg_temp_free(addr);
c04e1692
MF
6416}
6417
b0b24bdc 6418static void translate_ldstx(DisasContext *dc, const OpcodeArg arg[],
c04e1692
MF
6419 const uint32_t par[])
6420{
582fef0f 6421 TCGv_i32 addr = tcg_temp_new_i32();
c04e1692 6422
b0b24bdc 6423 tcg_gen_add_i32(addr, arg[1].in, arg[2].in);
582fef0f
MF
6424 gen_load_store_alignment(dc, 2, addr, false);
6425 if (par[0]) {
b0b24bdc 6426 tcg_gen_qemu_st32(arg[0].in, addr, dc->cring);
582fef0f 6427 } else {
b0b24bdc 6428 tcg_gen_qemu_ld32u(arg[0].out, addr, dc->cring);
582fef0f
MF
6429 }
6430 if (par[1]) {
b0b24bdc 6431 tcg_gen_mov_i32(arg[1].out, addr);
c04e1692 6432 }
582fef0f 6433 tcg_temp_free(addr);
c04e1692
MF
6434}
6435
5680f207
MF
6436static void translate_fpu2k_madd_s(DisasContext *dc, const OpcodeArg arg[],
6437 const uint32_t par[])
c04e1692 6438{
5680f207
MF
6439 gen_helper_fpu2k_madd_s(arg[0].out, cpu_env,
6440 arg[0].in, arg[1].in, arg[2].in);
c04e1692
MF
6441}
6442
b0b24bdc 6443static void translate_mov_s(DisasContext *dc, const OpcodeArg arg[],
c04e1692
MF
6444 const uint32_t par[])
6445{
b0b24bdc 6446 tcg_gen_mov_i32(arg[0].out, arg[1].in);
c04e1692
MF
6447}
6448
b0b24bdc 6449static void translate_movcond_s(DisasContext *dc, const OpcodeArg arg[],
c04e1692
MF
6450 const uint32_t par[])
6451{
582fef0f 6452 TCGv_i32 zero = tcg_const_i32(0);
c04e1692 6453
b0b24bdc
MF
6454 tcg_gen_movcond_i32(par[0], arg[0].out,
6455 arg[2].in, zero,
6456 arg[1].in, arg[0].in);
582fef0f 6457 tcg_temp_free(zero);
c04e1692
MF
6458}
6459
b0b24bdc 6460static void translate_movp_s(DisasContext *dc, const OpcodeArg arg[],
c04e1692
MF
6461 const uint32_t par[])
6462{
582fef0f
MF
6463 TCGv_i32 zero = tcg_const_i32(0);
6464 TCGv_i32 tmp = tcg_temp_new_i32();
c04e1692 6465
575e962a 6466 tcg_gen_andi_i32(tmp, arg[2].in, 1 << arg[2].imm);
582fef0f 6467 tcg_gen_movcond_i32(par[0],
b0b24bdc
MF
6468 arg[0].out, tmp, zero,
6469 arg[1].in, arg[0].in);
582fef0f
MF
6470 tcg_temp_free(tmp);
6471 tcg_temp_free(zero);
c04e1692
MF
6472}
6473
5680f207
MF
6474static void translate_fpu2k_mul_s(DisasContext *dc, const OpcodeArg arg[],
6475 const uint32_t par[])
c04e1692 6476{
5680f207
MF
6477 gen_helper_fpu2k_mul_s(arg[0].out, cpu_env,
6478 arg[1].in, arg[2].in);
c04e1692
MF
6479}
6480
5680f207
MF
6481static void translate_fpu2k_msub_s(DisasContext *dc, const OpcodeArg arg[],
6482 const uint32_t par[])
c04e1692 6483{
5680f207
MF
6484 gen_helper_fpu2k_msub_s(arg[0].out, cpu_env,
6485 arg[0].in, arg[1].in, arg[2].in);
c04e1692
MF
6486}
6487
b0b24bdc 6488static void translate_neg_s(DisasContext *dc, const OpcodeArg arg[],
c04e1692
MF
6489 const uint32_t par[])
6490{
b0b24bdc 6491 gen_helper_neg_s(arg[0].out, arg[1].in);
c04e1692
MF
6492}
6493
b0b24bdc 6494static void translate_rfr_s(DisasContext *dc, const OpcodeArg arg[],
c04e1692
MF
6495 const uint32_t par[])
6496{
b0b24bdc 6497 tcg_gen_mov_i32(arg[0].out, arg[1].in);
c04e1692
MF
6498}
6499
5680f207
MF
6500static void translate_fpu2k_sub_s(DisasContext *dc, const OpcodeArg arg[],
6501 const uint32_t par[])
c04e1692 6502{
5680f207
MF
6503 gen_helper_fpu2k_sub_s(arg[0].out, cpu_env,
6504 arg[1].in, arg[2].in);
c04e1692
MF
6505}
6506
b0b24bdc 6507static void translate_wfr_s(DisasContext *dc, const OpcodeArg arg[],
c04e1692
MF
6508 const uint32_t par[])
6509{
b0b24bdc 6510 tcg_gen_mov_i32(arg[0].out, arg[1].in);
c04e1692
MF
6511}
6512
6513static const XtensaOpcodeOps fpu2000_ops[] = {
6514 {
6515 .name = "abs.s",
6516 .translate = translate_abs_s,
582fef0f 6517 .coprocessor = 0x1,
c04e1692
MF
6518 }, {
6519 .name = "add.s",
5680f207 6520 .translate = translate_fpu2k_add_s,
582fef0f 6521 .coprocessor = 0x1,
c04e1692
MF
6522 }, {
6523 .name = "ceil.s",
6524 .translate = translate_ftoi_s,
6525 .par = (const uint32_t[]){float_round_up, false},
582fef0f 6526 .coprocessor = 0x1,
c04e1692
MF
6527 }, {
6528 .name = "float.s",
6529 .translate = translate_float_s,
6530 .par = (const uint32_t[]){false},
582fef0f 6531 .coprocessor = 0x1,
c04e1692
MF
6532 }, {
6533 .name = "floor.s",
6534 .translate = translate_ftoi_s,
6535 .par = (const uint32_t[]){float_round_down, false},
582fef0f 6536 .coprocessor = 0x1,
c04e1692
MF
6537 }, {
6538 .name = "lsi",
6539 .translate = translate_ldsti,
6540 .par = (const uint32_t[]){false, false},
068e538a 6541 .op_flags = XTENSA_OP_LOAD,
582fef0f 6542 .coprocessor = 0x1,
c04e1692
MF
6543 }, {
6544 .name = "lsiu",
6545 .translate = translate_ldsti,
6546 .par = (const uint32_t[]){false, true},
068e538a 6547 .op_flags = XTENSA_OP_LOAD,
582fef0f 6548 .coprocessor = 0x1,
c04e1692
MF
6549 }, {
6550 .name = "lsx",
6551 .translate = translate_ldstx,
6552 .par = (const uint32_t[]){false, false},
068e538a 6553 .op_flags = XTENSA_OP_LOAD,
582fef0f 6554 .coprocessor = 0x1,
c04e1692
MF
6555 }, {
6556 .name = "lsxu",
6557 .translate = translate_ldstx,
6558 .par = (const uint32_t[]){false, true},
068e538a 6559 .op_flags = XTENSA_OP_LOAD,
582fef0f 6560 .coprocessor = 0x1,
c04e1692
MF
6561 }, {
6562 .name = "madd.s",
5680f207 6563 .translate = translate_fpu2k_madd_s,
582fef0f 6564 .coprocessor = 0x1,
c04e1692
MF
6565 }, {
6566 .name = "mov.s",
6567 .translate = translate_mov_s,
582fef0f 6568 .coprocessor = 0x1,
c04e1692
MF
6569 }, {
6570 .name = "moveqz.s",
6571 .translate = translate_movcond_s,
6572 .par = (const uint32_t[]){TCG_COND_EQ},
582fef0f 6573 .coprocessor = 0x1,
c04e1692
MF
6574 }, {
6575 .name = "movf.s",
6576 .translate = translate_movp_s,
6577 .par = (const uint32_t[]){TCG_COND_EQ},
582fef0f 6578 .coprocessor = 0x1,
c04e1692
MF
6579 }, {
6580 .name = "movgez.s",
6581 .translate = translate_movcond_s,
6582 .par = (const uint32_t[]){TCG_COND_GE},
582fef0f 6583 .coprocessor = 0x1,
c04e1692
MF
6584 }, {
6585 .name = "movltz.s",
6586 .translate = translate_movcond_s,
6587 .par = (const uint32_t[]){TCG_COND_LT},
582fef0f 6588 .coprocessor = 0x1,
c04e1692
MF
6589 }, {
6590 .name = "movnez.s",
6591 .translate = translate_movcond_s,
6592 .par = (const uint32_t[]){TCG_COND_NE},
582fef0f 6593 .coprocessor = 0x1,
c04e1692
MF
6594 }, {
6595 .name = "movt.s",
6596 .translate = translate_movp_s,
6597 .par = (const uint32_t[]){TCG_COND_NE},
582fef0f 6598 .coprocessor = 0x1,
c04e1692
MF
6599 }, {
6600 .name = "msub.s",
5680f207 6601 .translate = translate_fpu2k_msub_s,
582fef0f 6602 .coprocessor = 0x1,
c04e1692
MF
6603 }, {
6604 .name = "mul.s",
5680f207 6605 .translate = translate_fpu2k_mul_s,
582fef0f 6606 .coprocessor = 0x1,
c04e1692
MF
6607 }, {
6608 .name = "neg.s",
6609 .translate = translate_neg_s,
582fef0f 6610 .coprocessor = 0x1,
c04e1692
MF
6611 }, {
6612 .name = "oeq.s",
6613 .translate = translate_compare_s,
6614 .par = (const uint32_t[]){COMPARE_OEQ},
582fef0f 6615 .coprocessor = 0x1,
c04e1692
MF
6616 }, {
6617 .name = "ole.s",
6618 .translate = translate_compare_s,
6619 .par = (const uint32_t[]){COMPARE_OLE},
582fef0f 6620 .coprocessor = 0x1,
c04e1692
MF
6621 }, {
6622 .name = "olt.s",
6623 .translate = translate_compare_s,
6624 .par = (const uint32_t[]){COMPARE_OLT},
582fef0f 6625 .coprocessor = 0x1,
c04e1692 6626 }, {
e8e05fd4 6627 .name = "rfr",
c04e1692 6628 .translate = translate_rfr_s,
582fef0f 6629 .coprocessor = 0x1,
c04e1692
MF
6630 }, {
6631 .name = "round.s",
6632 .translate = translate_ftoi_s,
6633 .par = (const uint32_t[]){float_round_nearest_even, false},
582fef0f 6634 .coprocessor = 0x1,
c04e1692
MF
6635 }, {
6636 .name = "ssi",
6637 .translate = translate_ldsti,
6638 .par = (const uint32_t[]){true, false},
068e538a 6639 .op_flags = XTENSA_OP_STORE,
582fef0f 6640 .coprocessor = 0x1,
c04e1692
MF
6641 }, {
6642 .name = "ssiu",
6643 .translate = translate_ldsti,
6644 .par = (const uint32_t[]){true, true},
068e538a 6645 .op_flags = XTENSA_OP_STORE,
582fef0f 6646 .coprocessor = 0x1,
c04e1692
MF
6647 }, {
6648 .name = "ssx",
6649 .translate = translate_ldstx,
6650 .par = (const uint32_t[]){true, false},
068e538a 6651 .op_flags = XTENSA_OP_STORE,
582fef0f 6652 .coprocessor = 0x1,
c04e1692
MF
6653 }, {
6654 .name = "ssxu",
6655 .translate = translate_ldstx,
6656 .par = (const uint32_t[]){true, true},
068e538a 6657 .op_flags = XTENSA_OP_STORE,
582fef0f 6658 .coprocessor = 0x1,
c04e1692
MF
6659 }, {
6660 .name = "sub.s",
5680f207 6661 .translate = translate_fpu2k_sub_s,
582fef0f 6662 .coprocessor = 0x1,
c04e1692
MF
6663 }, {
6664 .name = "trunc.s",
6665 .translate = translate_ftoi_s,
6666 .par = (const uint32_t[]){float_round_to_zero, false},
582fef0f 6667 .coprocessor = 0x1,
c04e1692
MF
6668 }, {
6669 .name = "ueq.s",
6670 .translate = translate_compare_s,
6671 .par = (const uint32_t[]){COMPARE_UEQ},
582fef0f 6672 .coprocessor = 0x1,
c04e1692
MF
6673 }, {
6674 .name = "ufloat.s",
6675 .translate = translate_float_s,
6676 .par = (const uint32_t[]){true},
582fef0f 6677 .coprocessor = 0x1,
c04e1692
MF
6678 }, {
6679 .name = "ule.s",
6680 .translate = translate_compare_s,
6681 .par = (const uint32_t[]){COMPARE_ULE},
582fef0f 6682 .coprocessor = 0x1,
c04e1692
MF
6683 }, {
6684 .name = "ult.s",
6685 .translate = translate_compare_s,
6686 .par = (const uint32_t[]){COMPARE_ULT},
582fef0f 6687 .coprocessor = 0x1,
c04e1692
MF
6688 }, {
6689 .name = "un.s",
6690 .translate = translate_compare_s,
6691 .par = (const uint32_t[]){COMPARE_UN},
582fef0f 6692 .coprocessor = 0x1,
c04e1692
MF
6693 }, {
6694 .name = "utrunc.s",
6695 .translate = translate_ftoi_s,
6696 .par = (const uint32_t[]){float_round_to_zero, true},
582fef0f 6697 .coprocessor = 0x1,
c04e1692 6698 }, {
e8e05fd4 6699 .name = "wfr",
c04e1692 6700 .translate = translate_wfr_s,
582fef0f 6701 .coprocessor = 0x1,
c04e1692
MF
6702 },
6703};
6704
6705const XtensaOpcodeTranslators xtensa_fpu2000_opcodes = {
6706 .num_opcodes = ARRAY_SIZE(fpu2000_ops),
6707 .opcode = fpu2000_ops,
6708};
This page took 1.515115 seconds and 4 git commands to generate.