[src/erc32] Use ncurses instead of termcap on Cygwin too
[binutils-gdb.git] / sim / or1k / sem.c
blobf67e50e5f5a81abcd4fb533076d5d5238859035c
1 /* Simulator instruction semantics for or1k32bf.
3 THIS FILE IS MACHINE GENERATED WITH CGEN.
5 Copyright 1996-2018 Free Software Foundation, Inc.
7 This file is part of the GNU simulators.
9 This file is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3, or (at your option)
12 any later version.
14 It is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
17 License for more details.
19 You should have received a copy of the GNU General Public License along
20 with this program; if not, write to the Free Software Foundation, Inc.,
21 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
25 #define WANT_CPU or1k32bf
26 #define WANT_CPU_OR1K32BF
28 #include "sim-main.h"
29 #include "cgen-mem.h"
30 #include "cgen-ops.h"
32 #undef GET_ATTR
33 #define GET_ATTR(cpu, num, attr) CGEN_ATTR_VALUE (NULL, abuf->idesc->attrs, CGEN_INSN_##attr)
35 /* This is used so that we can compile two copies of the semantic code,
36 one with full feature support and one without that runs fast(er).
37 FAST_P, when desired, is defined on the command line, -DFAST_P=1. */
38 #if FAST_P
39 #define SEM_FN_NAME(cpu,fn) XCONCAT3 (cpu,_semf_,fn)
40 #undef CGEN_TRACE_RESULT
41 #define CGEN_TRACE_RESULT(cpu, abuf, name, type, val)
42 #else
43 #define SEM_FN_NAME(cpu,fn) XCONCAT3 (cpu,_sem_,fn)
44 #endif
46 /* x-invalid: --invalid-- */
48 static SEM_PC
49 SEM_FN_NAME (or1k32bf,x_invalid) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
51 #define FLD(f) abuf->fields.sfmt_empty.f
52 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
53 int UNUSED written = 0;
54 IADDR UNUSED pc = abuf->addr;
55 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 0);
58 /* Update the recorded pc in the cpu state struct.
59 Only necessary for WITH_SCACHE case, but to avoid the
60 conditional compilation .... */
61 SET_H_PC (pc);
62 /* Virtual insns have zero size. Overwrite vpc with address of next insn
63 using the default-insn-bitsize spec. When executing insns in parallel
64 we may want to queue the fault and continue execution. */
65 vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
66 vpc = sim_engine_invalid_insn (current_cpu, pc, vpc);
69 return vpc;
70 #undef FLD
73 /* x-after: --after-- */
75 static SEM_PC
76 SEM_FN_NAME (or1k32bf,x_after) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
78 #define FLD(f) abuf->fields.sfmt_empty.f
79 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
80 int UNUSED written = 0;
81 IADDR UNUSED pc = abuf->addr;
82 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 0);
85 #if WITH_SCACHE_PBB_OR1K32BF
86 or1k32bf_pbb_after (current_cpu, sem_arg);
87 #endif
90 return vpc;
91 #undef FLD
94 /* x-before: --before-- */
96 static SEM_PC
97 SEM_FN_NAME (or1k32bf,x_before) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
99 #define FLD(f) abuf->fields.sfmt_empty.f
100 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
101 int UNUSED written = 0;
102 IADDR UNUSED pc = abuf->addr;
103 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 0);
106 #if WITH_SCACHE_PBB_OR1K32BF
107 or1k32bf_pbb_before (current_cpu, sem_arg);
108 #endif
111 return vpc;
112 #undef FLD
115 /* x-cti-chain: --cti-chain-- */
117 static SEM_PC
118 SEM_FN_NAME (or1k32bf,x_cti_chain) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
120 #define FLD(f) abuf->fields.sfmt_empty.f
121 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
122 int UNUSED written = 0;
123 IADDR UNUSED pc = abuf->addr;
124 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 0);
127 #if WITH_SCACHE_PBB_OR1K32BF
128 #ifdef DEFINE_SWITCH
129 vpc = or1k32bf_pbb_cti_chain (current_cpu, sem_arg,
130 pbb_br_type, pbb_br_npc);
131 BREAK (sem);
132 #else
133 /* FIXME: Allow provision of explicit ifmt spec in insn spec. */
134 vpc = or1k32bf_pbb_cti_chain (current_cpu, sem_arg,
135 CPU_PBB_BR_TYPE (current_cpu),
136 CPU_PBB_BR_NPC (current_cpu));
137 #endif
138 #endif
141 return vpc;
142 #undef FLD
145 /* x-chain: --chain-- */
147 static SEM_PC
148 SEM_FN_NAME (or1k32bf,x_chain) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
150 #define FLD(f) abuf->fields.sfmt_empty.f
151 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
152 int UNUSED written = 0;
153 IADDR UNUSED pc = abuf->addr;
154 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 0);
157 #if WITH_SCACHE_PBB_OR1K32BF
158 vpc = or1k32bf_pbb_chain (current_cpu, sem_arg);
159 #ifdef DEFINE_SWITCH
160 BREAK (sem);
161 #endif
162 #endif
165 return vpc;
166 #undef FLD
169 /* x-begin: --begin-- */
171 static SEM_PC
172 SEM_FN_NAME (or1k32bf,x_begin) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
174 #define FLD(f) abuf->fields.sfmt_empty.f
175 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
176 int UNUSED written = 0;
177 IADDR UNUSED pc = abuf->addr;
178 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 0);
181 #if WITH_SCACHE_PBB_OR1K32BF
182 #if defined DEFINE_SWITCH || defined FAST_P
183 /* In the switch case FAST_P is a constant, allowing several optimizations
184 in any called inline functions. */
185 vpc = or1k32bf_pbb_begin (current_cpu, FAST_P);
186 #else
187 #if 0 /* cgen engine can't handle dynamic fast/full switching yet. */
188 vpc = or1k32bf_pbb_begin (current_cpu, STATE_RUN_FAST_P (CPU_STATE (current_cpu)));
189 #else
190 vpc = or1k32bf_pbb_begin (current_cpu, 0);
191 #endif
192 #endif
193 #endif
196 return vpc;
197 #undef FLD
200 /* l-j: l.j ${disp26} */
202 static SEM_PC
203 SEM_FN_NAME (or1k32bf,l_j) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
205 #define FLD(f) abuf->fields.sfmt_l_j.f
206 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
207 int UNUSED written = 0;
208 IADDR UNUSED pc = abuf->addr;
209 SEM_BRANCH_INIT
210 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
215 USI opval = FLD (i_disp26);
216 SEM_BRANCH_VIA_CACHE (current_cpu, sem_arg, opval, vpc);
217 CGEN_TRACE_RESULT (current_cpu, abuf, "pc", 'x', opval);
220 if (GET_H_SYS_CPUCFGR_ND ()) {
221 if (1)
222 SEM_SKIP_INSN (current_cpu, sem_arg, vpc);
226 SEM_BRANCH_FINI (vpc);
227 return vpc;
228 #undef FLD
231 /* l-adrp: l.adrp $rD,${disp21} */
233 static SEM_PC
234 SEM_FN_NAME (or1k32bf,l_adrp) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
236 #define FLD(f) abuf->fields.sfmt_l_adrp.f
237 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
238 int UNUSED written = 0;
239 IADDR UNUSED pc = abuf->addr;
240 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
243 USI opval = FLD (i_disp21);
244 SET_H_GPR (FLD (f_r1), opval);
245 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
248 return vpc;
249 #undef FLD
252 /* l-jal: l.jal ${disp26} */
254 static SEM_PC
255 SEM_FN_NAME (or1k32bf,l_jal) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
257 #define FLD(f) abuf->fields.sfmt_l_j.f
258 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
259 int UNUSED written = 0;
260 IADDR UNUSED pc = abuf->addr;
261 SEM_BRANCH_INIT
262 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
266 USI opval = ADDSI (pc, ((GET_H_SYS_CPUCFGR_ND ()) ? (4) : (8)));
267 SET_H_GPR (((UINT) 9), opval);
268 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
273 USI opval = FLD (i_disp26);
274 SEM_BRANCH_VIA_CACHE (current_cpu, sem_arg, opval, vpc);
275 CGEN_TRACE_RESULT (current_cpu, abuf, "pc", 'x', opval);
278 if (GET_H_SYS_CPUCFGR_ND ()) {
279 if (1)
280 SEM_SKIP_INSN (current_cpu, sem_arg, vpc);
285 SEM_BRANCH_FINI (vpc);
286 return vpc;
287 #undef FLD
290 /* l-jr: l.jr $rB */
292 static SEM_PC
293 SEM_FN_NAME (or1k32bf,l_jr) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
295 #define FLD(f) abuf->fields.sfmt_l_sll.f
296 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
297 int UNUSED written = 0;
298 IADDR UNUSED pc = abuf->addr;
299 SEM_BRANCH_INIT
300 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
305 USI opval = GET_H_GPR (FLD (f_r3));
306 SEM_BRANCH_VIA_ADDR (current_cpu, sem_arg, opval, vpc);
307 CGEN_TRACE_RESULT (current_cpu, abuf, "pc", 'x', opval);
310 if (GET_H_SYS_CPUCFGR_ND ()) {
311 if (1)
312 SEM_SKIP_INSN (current_cpu, sem_arg, vpc);
316 SEM_BRANCH_FINI (vpc);
317 return vpc;
318 #undef FLD
321 /* l-jalr: l.jalr $rB */
323 static SEM_PC
324 SEM_FN_NAME (or1k32bf,l_jalr) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
326 #define FLD(f) abuf->fields.sfmt_l_sll.f
327 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
328 int UNUSED written = 0;
329 IADDR UNUSED pc = abuf->addr;
330 SEM_BRANCH_INIT
331 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
335 USI opval = ADDSI (pc, ((GET_H_SYS_CPUCFGR_ND ()) ? (4) : (8)));
336 SET_H_GPR (((UINT) 9), opval);
337 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
342 USI opval = GET_H_GPR (FLD (f_r3));
343 SEM_BRANCH_VIA_ADDR (current_cpu, sem_arg, opval, vpc);
344 CGEN_TRACE_RESULT (current_cpu, abuf, "pc", 'x', opval);
347 if (GET_H_SYS_CPUCFGR_ND ()) {
348 if (1)
349 SEM_SKIP_INSN (current_cpu, sem_arg, vpc);
354 SEM_BRANCH_FINI (vpc);
355 return vpc;
356 #undef FLD
359 /* l-bnf: l.bnf ${disp26} */
361 static SEM_PC
362 SEM_FN_NAME (or1k32bf,l_bnf) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
364 #define FLD(f) abuf->fields.sfmt_l_j.f
365 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
366 int UNUSED written = 0;
367 IADDR UNUSED pc = abuf->addr;
368 SEM_BRANCH_INIT
369 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
372 if (NOTSI (GET_H_SYS_SR_F ())) {
375 USI opval = FLD (i_disp26);
376 SEM_BRANCH_VIA_CACHE (current_cpu, sem_arg, opval, vpc);
377 written |= (1 << 4);
378 CGEN_TRACE_RESULT (current_cpu, abuf, "pc", 'x', opval);
381 } else {
382 if (GET_H_SYS_CPUCFGR_ND ()) {
385 USI opval = ADDSI (pc, 4);
386 SEM_BRANCH_VIA_ADDR (current_cpu, sem_arg, opval, vpc);
387 written |= (1 << 4);
388 CGEN_TRACE_RESULT (current_cpu, abuf, "pc", 'x', opval);
393 if (GET_H_SYS_CPUCFGR_ND ()) {
394 if (1)
395 SEM_SKIP_INSN (current_cpu, sem_arg, vpc);
399 abuf->written = written;
400 SEM_BRANCH_FINI (vpc);
401 return vpc;
402 #undef FLD
405 /* l-bf: l.bf ${disp26} */
407 static SEM_PC
408 SEM_FN_NAME (or1k32bf,l_bf) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
410 #define FLD(f) abuf->fields.sfmt_l_j.f
411 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
412 int UNUSED written = 0;
413 IADDR UNUSED pc = abuf->addr;
414 SEM_BRANCH_INIT
415 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
418 if (GET_H_SYS_SR_F ()) {
421 USI opval = FLD (i_disp26);
422 SEM_BRANCH_VIA_CACHE (current_cpu, sem_arg, opval, vpc);
423 written |= (1 << 4);
424 CGEN_TRACE_RESULT (current_cpu, abuf, "pc", 'x', opval);
427 } else {
428 if (GET_H_SYS_CPUCFGR_ND ()) {
431 USI opval = ADDSI (pc, 4);
432 SEM_BRANCH_VIA_ADDR (current_cpu, sem_arg, opval, vpc);
433 written |= (1 << 4);
434 CGEN_TRACE_RESULT (current_cpu, abuf, "pc", 'x', opval);
439 if (GET_H_SYS_CPUCFGR_ND ()) {
440 if (1)
441 SEM_SKIP_INSN (current_cpu, sem_arg, vpc);
445 abuf->written = written;
446 SEM_BRANCH_FINI (vpc);
447 return vpc;
448 #undef FLD
451 /* l-trap: l.trap ${uimm16} */
453 static SEM_PC
454 SEM_FN_NAME (or1k32bf,l_trap) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
456 #define FLD(f) abuf->fields.sfmt_empty.f
457 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
458 int UNUSED written = 0;
459 IADDR UNUSED pc = abuf->addr;
460 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
462 or1k32bf_exception (current_cpu, pc, EXCEPT_TRAP);
464 return vpc;
465 #undef FLD
468 /* l-sys: l.sys ${uimm16} */
470 static SEM_PC
471 SEM_FN_NAME (or1k32bf,l_sys) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
473 #define FLD(f) abuf->fields.sfmt_empty.f
474 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
475 int UNUSED written = 0;
476 IADDR UNUSED pc = abuf->addr;
477 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
479 or1k32bf_exception (current_cpu, pc, EXCEPT_SYSCALL);
481 return vpc;
482 #undef FLD
485 /* l-msync: l.msync */
487 static SEM_PC
488 SEM_FN_NAME (or1k32bf,l_msync) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
490 #define FLD(f) abuf->fields.sfmt_empty.f
491 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
492 int UNUSED written = 0;
493 IADDR UNUSED pc = abuf->addr;
494 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
496 ((void) 0); /*nop*/
498 return vpc;
499 #undef FLD
502 /* l-psync: l.psync */
504 static SEM_PC
505 SEM_FN_NAME (or1k32bf,l_psync) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
507 #define FLD(f) abuf->fields.sfmt_empty.f
508 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
509 int UNUSED written = 0;
510 IADDR UNUSED pc = abuf->addr;
511 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
513 ((void) 0); /*nop*/
515 return vpc;
516 #undef FLD
519 /* l-csync: l.csync */
521 static SEM_PC
522 SEM_FN_NAME (or1k32bf,l_csync) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
524 #define FLD(f) abuf->fields.sfmt_empty.f
525 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
526 int UNUSED written = 0;
527 IADDR UNUSED pc = abuf->addr;
528 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
530 ((void) 0); /*nop*/
532 return vpc;
533 #undef FLD
536 /* l-rfe: l.rfe */
538 static SEM_PC
539 SEM_FN_NAME (or1k32bf,l_rfe) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
541 #define FLD(f) abuf->fields.sfmt_empty.f
542 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
543 int UNUSED written = 0;
544 IADDR UNUSED pc = abuf->addr;
545 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
547 or1k32bf_rfe (current_cpu);
549 return vpc;
550 #undef FLD
553 /* l-nop-imm: l.nop ${uimm16} */
555 static SEM_PC
556 SEM_FN_NAME (or1k32bf,l_nop_imm) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
558 #define FLD(f) abuf->fields.sfmt_l_mfspr.f
559 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
560 int UNUSED written = 0;
561 IADDR UNUSED pc = abuf->addr;
562 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
564 or1k32bf_nop (current_cpu, ZEXTSISI (FLD (f_uimm16)));
566 return vpc;
567 #undef FLD
570 /* l-movhi: l.movhi $rD,$uimm16 */
572 static SEM_PC
573 SEM_FN_NAME (or1k32bf,l_movhi) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
575 #define FLD(f) abuf->fields.sfmt_l_mfspr.f
576 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
577 int UNUSED written = 0;
578 IADDR UNUSED pc = abuf->addr;
579 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
582 USI opval = SLLSI (ZEXTSISI (FLD (f_uimm16)), 16);
583 SET_H_GPR (FLD (f_r1), opval);
584 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
587 return vpc;
588 #undef FLD
591 /* l-macrc: l.macrc $rD */
593 static SEM_PC
594 SEM_FN_NAME (or1k32bf,l_macrc) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
596 #define FLD(f) abuf->fields.sfmt_l_adrp.f
597 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
598 int UNUSED written = 0;
599 IADDR UNUSED pc = abuf->addr;
600 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
604 USI opval = GET_H_MAC_MACLO ();
605 SET_H_GPR (FLD (f_r1), opval);
606 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
609 USI opval = 0;
610 SET_H_MAC_MACLO (opval);
611 CGEN_TRACE_RESULT (current_cpu, abuf, "mac-maclo", 'x', opval);
614 USI opval = 0;
615 SET_H_MAC_MACHI (opval);
616 CGEN_TRACE_RESULT (current_cpu, abuf, "mac-machi", 'x', opval);
620 return vpc;
621 #undef FLD
624 /* l-mfspr: l.mfspr $rD,$rA,${uimm16} */
626 static SEM_PC
627 SEM_FN_NAME (or1k32bf,l_mfspr) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
629 #define FLD(f) abuf->fields.sfmt_l_mfspr.f
630 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
631 int UNUSED written = 0;
632 IADDR UNUSED pc = abuf->addr;
633 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
636 USI opval = or1k32bf_mfspr (current_cpu, ORSI (GET_H_GPR (FLD (f_r2)), ZEXTSISI (FLD (f_uimm16))));
637 SET_H_GPR (FLD (f_r1), opval);
638 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
641 return vpc;
642 #undef FLD
645 /* l-mtspr: l.mtspr $rA,$rB,${uimm16-split} */
647 static SEM_PC
648 SEM_FN_NAME (or1k32bf,l_mtspr) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
650 #define FLD(f) abuf->fields.sfmt_l_mtspr.f
651 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
652 int UNUSED written = 0;
653 IADDR UNUSED pc = abuf->addr;
654 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
656 or1k32bf_mtspr (current_cpu, ORSI (GET_H_GPR (FLD (f_r2)), ZEXTSISI (FLD (f_uimm16_split))), GET_H_GPR (FLD (f_r3)));
658 return vpc;
659 #undef FLD
662 /* l-lwz: l.lwz $rD,${simm16}($rA) */
664 static SEM_PC
665 SEM_FN_NAME (or1k32bf,l_lwz) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
667 #define FLD(f) abuf->fields.sfmt_l_lwz.f
668 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
669 int UNUSED written = 0;
670 IADDR UNUSED pc = abuf->addr;
671 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
674 USI opval = ZEXTSISI (GETMEMUSI (current_cpu, pc, or1k32bf_make_load_store_addr (current_cpu, GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16)), 4)));
675 SET_H_GPR (FLD (f_r1), opval);
676 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
679 return vpc;
680 #undef FLD
683 /* l-lws: l.lws $rD,${simm16}($rA) */
685 static SEM_PC
686 SEM_FN_NAME (or1k32bf,l_lws) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
688 #define FLD(f) abuf->fields.sfmt_l_lwz.f
689 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
690 int UNUSED written = 0;
691 IADDR UNUSED pc = abuf->addr;
692 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
695 SI opval = EXTSISI (GETMEMSI (current_cpu, pc, or1k32bf_make_load_store_addr (current_cpu, GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16)), 4)));
696 SET_H_GPR (FLD (f_r1), opval);
697 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
700 return vpc;
701 #undef FLD
704 /* l-lwa: l.lwa $rD,${simm16}($rA) */
706 static SEM_PC
707 SEM_FN_NAME (or1k32bf,l_lwa) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
709 #define FLD(f) abuf->fields.sfmt_l_lwz.f
710 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
711 int UNUSED written = 0;
712 IADDR UNUSED pc = abuf->addr;
713 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
717 USI opval = ZEXTSISI (GETMEMUSI (current_cpu, pc, or1k32bf_make_load_store_addr (current_cpu, GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16)), 4)));
718 SET_H_GPR (FLD (f_r1), opval);
719 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
722 BI opval = 1;
723 CPU (h_atomic_reserve) = opval;
724 CGEN_TRACE_RESULT (current_cpu, abuf, "atomic-reserve", 'x', opval);
727 SI opval = or1k32bf_make_load_store_addr (current_cpu, GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16)), 4);
728 CPU (h_atomic_address) = opval;
729 CGEN_TRACE_RESULT (current_cpu, abuf, "atomic-address", 'x', opval);
733 return vpc;
734 #undef FLD
737 /* l-lbz: l.lbz $rD,${simm16}($rA) */
739 static SEM_PC
740 SEM_FN_NAME (or1k32bf,l_lbz) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
742 #define FLD(f) abuf->fields.sfmt_l_lwz.f
743 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
744 int UNUSED written = 0;
745 IADDR UNUSED pc = abuf->addr;
746 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
749 USI opval = ZEXTQISI (GETMEMUQI (current_cpu, pc, or1k32bf_make_load_store_addr (current_cpu, GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16)), 1)));
750 SET_H_GPR (FLD (f_r1), opval);
751 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
754 return vpc;
755 #undef FLD
758 /* l-lbs: l.lbs $rD,${simm16}($rA) */
760 static SEM_PC
761 SEM_FN_NAME (or1k32bf,l_lbs) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
763 #define FLD(f) abuf->fields.sfmt_l_lwz.f
764 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
765 int UNUSED written = 0;
766 IADDR UNUSED pc = abuf->addr;
767 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
770 SI opval = EXTQISI (GETMEMQI (current_cpu, pc, or1k32bf_make_load_store_addr (current_cpu, GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16)), 1)));
771 SET_H_GPR (FLD (f_r1), opval);
772 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
775 return vpc;
776 #undef FLD
779 /* l-lhz: l.lhz $rD,${simm16}($rA) */
781 static SEM_PC
782 SEM_FN_NAME (or1k32bf,l_lhz) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
784 #define FLD(f) abuf->fields.sfmt_l_lwz.f
785 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
786 int UNUSED written = 0;
787 IADDR UNUSED pc = abuf->addr;
788 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
791 USI opval = ZEXTHISI (GETMEMUHI (current_cpu, pc, or1k32bf_make_load_store_addr (current_cpu, GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16)), 2)));
792 SET_H_GPR (FLD (f_r1), opval);
793 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
796 return vpc;
797 #undef FLD
800 /* l-lhs: l.lhs $rD,${simm16}($rA) */
802 static SEM_PC
803 SEM_FN_NAME (or1k32bf,l_lhs) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
805 #define FLD(f) abuf->fields.sfmt_l_lwz.f
806 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
807 int UNUSED written = 0;
808 IADDR UNUSED pc = abuf->addr;
809 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
812 SI opval = EXTHISI (GETMEMHI (current_cpu, pc, or1k32bf_make_load_store_addr (current_cpu, GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16)), 2)));
813 SET_H_GPR (FLD (f_r1), opval);
814 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
817 return vpc;
818 #undef FLD
821 /* l-sw: l.sw ${simm16-split}($rA),$rB */
823 static SEM_PC
824 SEM_FN_NAME (or1k32bf,l_sw) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
826 #define FLD(f) abuf->fields.sfmt_l_sw.f
827 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
828 int UNUSED written = 0;
829 IADDR UNUSED pc = abuf->addr;
830 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
833 SI tmp_addr;
834 tmp_addr = or1k32bf_make_load_store_addr (current_cpu, GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16_split)), 4);
836 USI opval = TRUNCSISI (GET_H_GPR (FLD (f_r3)));
837 SETMEMUSI (current_cpu, pc, tmp_addr, opval);
838 CGEN_TRACE_RESULT (current_cpu, abuf, "memory", 'x', opval);
840 if (EQSI (ANDSI (tmp_addr, 268435452), CPU (h_atomic_address))) {
842 BI opval = 0;
843 CPU (h_atomic_reserve) = opval;
844 written |= (1 << 4);
845 CGEN_TRACE_RESULT (current_cpu, abuf, "atomic-reserve", 'x', opval);
850 abuf->written = written;
851 return vpc;
852 #undef FLD
855 /* l-sb: l.sb ${simm16-split}($rA),$rB */
857 static SEM_PC
858 SEM_FN_NAME (or1k32bf,l_sb) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
860 #define FLD(f) abuf->fields.sfmt_l_sw.f
861 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
862 int UNUSED written = 0;
863 IADDR UNUSED pc = abuf->addr;
864 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
867 SI tmp_addr;
868 tmp_addr = or1k32bf_make_load_store_addr (current_cpu, GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16_split)), 1);
870 UQI opval = TRUNCSIQI (GET_H_GPR (FLD (f_r3)));
871 SETMEMUQI (current_cpu, pc, tmp_addr, opval);
872 CGEN_TRACE_RESULT (current_cpu, abuf, "memory", 'x', opval);
874 if (EQSI (ANDSI (tmp_addr, 268435452), CPU (h_atomic_address))) {
876 BI opval = 0;
877 CPU (h_atomic_reserve) = opval;
878 written |= (1 << 4);
879 CGEN_TRACE_RESULT (current_cpu, abuf, "atomic-reserve", 'x', opval);
884 abuf->written = written;
885 return vpc;
886 #undef FLD
889 /* l-sh: l.sh ${simm16-split}($rA),$rB */
891 static SEM_PC
892 SEM_FN_NAME (or1k32bf,l_sh) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
894 #define FLD(f) abuf->fields.sfmt_l_sw.f
895 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
896 int UNUSED written = 0;
897 IADDR UNUSED pc = abuf->addr;
898 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
901 SI tmp_addr;
902 tmp_addr = or1k32bf_make_load_store_addr (current_cpu, GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16_split)), 2);
904 UHI opval = TRUNCSIHI (GET_H_GPR (FLD (f_r3)));
905 SETMEMUHI (current_cpu, pc, tmp_addr, opval);
906 CGEN_TRACE_RESULT (current_cpu, abuf, "memory", 'x', opval);
908 if (EQSI (ANDSI (tmp_addr, 268435452), CPU (h_atomic_address))) {
910 BI opval = 0;
911 CPU (h_atomic_reserve) = opval;
912 written |= (1 << 4);
913 CGEN_TRACE_RESULT (current_cpu, abuf, "atomic-reserve", 'x', opval);
918 abuf->written = written;
919 return vpc;
920 #undef FLD
923 /* l-swa: l.swa ${simm16-split}($rA),$rB */
925 static SEM_PC
926 SEM_FN_NAME (or1k32bf,l_swa) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
928 #define FLD(f) abuf->fields.sfmt_l_sw.f
929 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
930 int UNUSED written = 0;
931 IADDR UNUSED pc = abuf->addr;
932 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
935 SI tmp_addr;
936 BI tmp_flag;
937 tmp_addr = or1k32bf_make_load_store_addr (current_cpu, GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16_split)), 4);
939 USI opval = ANDBI (CPU (h_atomic_reserve), EQSI (tmp_addr, CPU (h_atomic_address)));
940 SET_H_SYS_SR_F (opval);
941 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-f", 'x', opval);
943 if (GET_H_SYS_SR_F ()) {
945 USI opval = TRUNCSISI (GET_H_GPR (FLD (f_r3)));
946 SETMEMUSI (current_cpu, pc, tmp_addr, opval);
947 written |= (1 << 7);
948 CGEN_TRACE_RESULT (current_cpu, abuf, "memory", 'x', opval);
952 BI opval = 0;
953 CPU (h_atomic_reserve) = opval;
954 CGEN_TRACE_RESULT (current_cpu, abuf, "atomic-reserve", 'x', opval);
958 abuf->written = written;
959 return vpc;
960 #undef FLD
963 /* l-sll: l.sll $rD,$rA,$rB */
965 static SEM_PC
966 SEM_FN_NAME (or1k32bf,l_sll) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
968 #define FLD(f) abuf->fields.sfmt_l_sll.f
969 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
970 int UNUSED written = 0;
971 IADDR UNUSED pc = abuf->addr;
972 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
975 USI opval = SLLSI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)));
976 SET_H_GPR (FLD (f_r1), opval);
977 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
980 return vpc;
981 #undef FLD
984 /* l-slli: l.slli $rD,$rA,${uimm6} */
986 static SEM_PC
987 SEM_FN_NAME (or1k32bf,l_slli) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
989 #define FLD(f) abuf->fields.sfmt_l_slli.f
990 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
991 int UNUSED written = 0;
992 IADDR UNUSED pc = abuf->addr;
993 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
996 USI opval = SLLSI (GET_H_GPR (FLD (f_r2)), FLD (f_uimm6));
997 SET_H_GPR (FLD (f_r1), opval);
998 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1001 return vpc;
1002 #undef FLD
1005 /* l-srl: l.srl $rD,$rA,$rB */
1007 static SEM_PC
1008 SEM_FN_NAME (or1k32bf,l_srl) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1010 #define FLD(f) abuf->fields.sfmt_l_sll.f
1011 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1012 int UNUSED written = 0;
1013 IADDR UNUSED pc = abuf->addr;
1014 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1017 USI opval = SRLSI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)));
1018 SET_H_GPR (FLD (f_r1), opval);
1019 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1022 return vpc;
1023 #undef FLD
1026 /* l-srli: l.srli $rD,$rA,${uimm6} */
1028 static SEM_PC
1029 SEM_FN_NAME (or1k32bf,l_srli) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1031 #define FLD(f) abuf->fields.sfmt_l_slli.f
1032 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1033 int UNUSED written = 0;
1034 IADDR UNUSED pc = abuf->addr;
1035 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1038 USI opval = SRLSI (GET_H_GPR (FLD (f_r2)), FLD (f_uimm6));
1039 SET_H_GPR (FLD (f_r1), opval);
1040 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1043 return vpc;
1044 #undef FLD
1047 /* l-sra: l.sra $rD,$rA,$rB */
1049 static SEM_PC
1050 SEM_FN_NAME (or1k32bf,l_sra) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1052 #define FLD(f) abuf->fields.sfmt_l_sll.f
1053 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1054 int UNUSED written = 0;
1055 IADDR UNUSED pc = abuf->addr;
1056 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1059 USI opval = SRASI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)));
1060 SET_H_GPR (FLD (f_r1), opval);
1061 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1064 return vpc;
1065 #undef FLD
1068 /* l-srai: l.srai $rD,$rA,${uimm6} */
1070 static SEM_PC
1071 SEM_FN_NAME (or1k32bf,l_srai) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1073 #define FLD(f) abuf->fields.sfmt_l_slli.f
1074 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1075 int UNUSED written = 0;
1076 IADDR UNUSED pc = abuf->addr;
1077 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1080 USI opval = SRASI (GET_H_GPR (FLD (f_r2)), FLD (f_uimm6));
1081 SET_H_GPR (FLD (f_r1), opval);
1082 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1085 return vpc;
1086 #undef FLD
1089 /* l-ror: l.ror $rD,$rA,$rB */
1091 static SEM_PC
1092 SEM_FN_NAME (or1k32bf,l_ror) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1094 #define FLD(f) abuf->fields.sfmt_l_sll.f
1095 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1096 int UNUSED written = 0;
1097 IADDR UNUSED pc = abuf->addr;
1098 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1101 USI opval = RORSI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)));
1102 SET_H_GPR (FLD (f_r1), opval);
1103 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1106 return vpc;
1107 #undef FLD
1110 /* l-rori: l.rori $rD,$rA,${uimm6} */
1112 static SEM_PC
1113 SEM_FN_NAME (or1k32bf,l_rori) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1115 #define FLD(f) abuf->fields.sfmt_l_slli.f
1116 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1117 int UNUSED written = 0;
1118 IADDR UNUSED pc = abuf->addr;
1119 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1122 USI opval = RORSI (GET_H_GPR (FLD (f_r2)), FLD (f_uimm6));
1123 SET_H_GPR (FLD (f_r1), opval);
1124 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1127 return vpc;
1128 #undef FLD
1131 /* l-and: l.and $rD,$rA,$rB */
1133 static SEM_PC
1134 SEM_FN_NAME (or1k32bf,l_and) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1136 #define FLD(f) abuf->fields.sfmt_l_sll.f
1137 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1138 int UNUSED written = 0;
1139 IADDR UNUSED pc = abuf->addr;
1140 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1143 USI opval = ANDSI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)));
1144 SET_H_GPR (FLD (f_r1), opval);
1145 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1148 return vpc;
1149 #undef FLD
1152 /* l-or: l.or $rD,$rA,$rB */
1154 static SEM_PC
1155 SEM_FN_NAME (or1k32bf,l_or) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1157 #define FLD(f) abuf->fields.sfmt_l_sll.f
1158 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1159 int UNUSED written = 0;
1160 IADDR UNUSED pc = abuf->addr;
1161 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1164 USI opval = ORSI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)));
1165 SET_H_GPR (FLD (f_r1), opval);
1166 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1169 return vpc;
1170 #undef FLD
1173 /* l-xor: l.xor $rD,$rA,$rB */
1175 static SEM_PC
1176 SEM_FN_NAME (or1k32bf,l_xor) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1178 #define FLD(f) abuf->fields.sfmt_l_sll.f
1179 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1180 int UNUSED written = 0;
1181 IADDR UNUSED pc = abuf->addr;
1182 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1185 USI opval = XORSI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)));
1186 SET_H_GPR (FLD (f_r1), opval);
1187 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1190 return vpc;
1191 #undef FLD
1194 /* l-add: l.add $rD,$rA,$rB */
1196 static SEM_PC
1197 SEM_FN_NAME (or1k32bf,l_add) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1199 #define FLD(f) abuf->fields.sfmt_l_sll.f
1200 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1201 int UNUSED written = 0;
1202 IADDR UNUSED pc = abuf->addr;
1203 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1208 BI opval = ADDCFSI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)), 0);
1209 SET_H_SYS_SR_CY (opval);
1210 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-cy", 'x', opval);
1213 BI opval = ADDOFSI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)), 0);
1214 SET_H_SYS_SR_OV (opval);
1215 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-ov", 'x', opval);
1218 USI opval = ADDSI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)));
1219 SET_H_GPR (FLD (f_r1), opval);
1220 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1223 if (ANDIF (GET_H_SYS_SR_OV (), GET_H_SYS_SR_OVE ())) {
1224 or1k32bf_exception (current_cpu, pc, EXCEPT_RANGE);
1228 return vpc;
1229 #undef FLD
1232 /* l-sub: l.sub $rD,$rA,$rB */
1234 static SEM_PC
1235 SEM_FN_NAME (or1k32bf,l_sub) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1237 #define FLD(f) abuf->fields.sfmt_l_sll.f
1238 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1239 int UNUSED written = 0;
1240 IADDR UNUSED pc = abuf->addr;
1241 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1246 BI opval = SUBCFSI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)), 0);
1247 SET_H_SYS_SR_CY (opval);
1248 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-cy", 'x', opval);
1251 BI opval = SUBOFSI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)), 0);
1252 SET_H_SYS_SR_OV (opval);
1253 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-ov", 'x', opval);
1256 USI opval = SUBSI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)));
1257 SET_H_GPR (FLD (f_r1), opval);
1258 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1261 if (ANDIF (GET_H_SYS_SR_OV (), GET_H_SYS_SR_OVE ())) {
1262 or1k32bf_exception (current_cpu, pc, EXCEPT_RANGE);
1266 return vpc;
1267 #undef FLD
1270 /* l-addc: l.addc $rD,$rA,$rB */
1272 static SEM_PC
1273 SEM_FN_NAME (or1k32bf,l_addc) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1275 #define FLD(f) abuf->fields.sfmt_l_sll.f
1276 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1277 int UNUSED written = 0;
1278 IADDR UNUSED pc = abuf->addr;
1279 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1283 BI tmp_tmp_sys_sr_cy;
1284 tmp_tmp_sys_sr_cy = GET_H_SYS_SR_CY ();
1286 BI opval = ADDCFSI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)), tmp_tmp_sys_sr_cy);
1287 SET_H_SYS_SR_CY (opval);
1288 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-cy", 'x', opval);
1291 BI opval = ADDOFSI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)), tmp_tmp_sys_sr_cy);
1292 SET_H_SYS_SR_OV (opval);
1293 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-ov", 'x', opval);
1296 USI opval = ADDCSI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)), tmp_tmp_sys_sr_cy);
1297 SET_H_GPR (FLD (f_r1), opval);
1298 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1301 if (ANDIF (GET_H_SYS_SR_OV (), GET_H_SYS_SR_OVE ())) {
1302 or1k32bf_exception (current_cpu, pc, EXCEPT_RANGE);
1306 return vpc;
1307 #undef FLD
1310 /* l-mul: l.mul $rD,$rA,$rB */
1312 static SEM_PC
1313 SEM_FN_NAME (or1k32bf,l_mul) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1315 #define FLD(f) abuf->fields.sfmt_l_sll.f
1316 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1317 int UNUSED written = 0;
1318 IADDR UNUSED pc = abuf->addr;
1319 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1324 BI opval = MUL2OFSI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)));
1325 SET_H_SYS_SR_OV (opval);
1326 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-ov", 'x', opval);
1329 USI opval = MULSI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)));
1330 SET_H_GPR (FLD (f_r1), opval);
1331 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1334 if (ANDIF (GET_H_SYS_SR_OV (), GET_H_SYS_SR_OVE ())) {
1335 or1k32bf_exception (current_cpu, pc, EXCEPT_RANGE);
1339 return vpc;
1340 #undef FLD
1343 /* l-muld: l.muld $rA,$rB */
1345 static SEM_PC
1346 SEM_FN_NAME (or1k32bf,l_muld) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1348 #define FLD(f) abuf->fields.sfmt_l_sll.f
1349 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1350 int UNUSED written = 0;
1351 IADDR UNUSED pc = abuf->addr;
1352 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1355 DI tmp_result;
1356 tmp_result = MULDI (EXTSIDI (GET_H_GPR (FLD (f_r2))), EXTSIDI (GET_H_GPR (FLD (f_r3))));
1358 SI opval = SUBWORDDISI (tmp_result, 0);
1359 SET_H_MAC_MACHI (opval);
1360 CGEN_TRACE_RESULT (current_cpu, abuf, "mac-machi", 'x', opval);
1363 SI opval = SUBWORDDISI (tmp_result, 1);
1364 SET_H_MAC_MACLO (opval);
1365 CGEN_TRACE_RESULT (current_cpu, abuf, "mac-maclo", 'x', opval);
1369 return vpc;
1370 #undef FLD
1373 /* l-mulu: l.mulu $rD,$rA,$rB */
1375 static SEM_PC
1376 SEM_FN_NAME (or1k32bf,l_mulu) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1378 #define FLD(f) abuf->fields.sfmt_l_sll.f
1379 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1380 int UNUSED written = 0;
1381 IADDR UNUSED pc = abuf->addr;
1382 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1387 BI opval = MUL1OFSI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)));
1388 SET_H_SYS_SR_CY (opval);
1389 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-cy", 'x', opval);
1392 USI opval = MULSI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)));
1393 SET_H_GPR (FLD (f_r1), opval);
1394 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1397 if (ANDIF (GET_H_SYS_SR_CY (), GET_H_SYS_SR_OVE ())) {
1398 or1k32bf_exception (current_cpu, pc, EXCEPT_RANGE);
1402 return vpc;
1403 #undef FLD
1406 /* l-muldu: l.muldu $rA,$rB */
1408 static SEM_PC
1409 SEM_FN_NAME (or1k32bf,l_muldu) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1411 #define FLD(f) abuf->fields.sfmt_l_sll.f
1412 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1413 int UNUSED written = 0;
1414 IADDR UNUSED pc = abuf->addr;
1415 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1418 DI tmp_result;
1419 tmp_result = MULDI (ZEXTSIDI (GET_H_GPR (FLD (f_r2))), ZEXTSIDI (GET_H_GPR (FLD (f_r3))));
1421 SI opval = SUBWORDDISI (tmp_result, 0);
1422 SET_H_MAC_MACHI (opval);
1423 CGEN_TRACE_RESULT (current_cpu, abuf, "mac-machi", 'x', opval);
1426 SI opval = SUBWORDDISI (tmp_result, 1);
1427 SET_H_MAC_MACLO (opval);
1428 CGEN_TRACE_RESULT (current_cpu, abuf, "mac-maclo", 'x', opval);
1432 return vpc;
1433 #undef FLD
1436 /* l-div: l.div $rD,$rA,$rB */
1438 static SEM_PC
1439 SEM_FN_NAME (or1k32bf,l_div) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1441 #define FLD(f) abuf->fields.sfmt_l_sll.f
1442 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1443 int UNUSED written = 0;
1444 IADDR UNUSED pc = abuf->addr;
1445 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1447 if (NESI (GET_H_GPR (FLD (f_r3)), 0)) {
1450 BI opval = 0;
1451 SET_H_SYS_SR_OV (opval);
1452 written |= (1 << 5);
1453 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-ov", 'x', opval);
1456 SI opval = DIVSI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)));
1457 SET_H_GPR (FLD (f_r1), opval);
1458 written |= (1 << 4);
1459 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1462 } else {
1465 BI opval = 1;
1466 SET_H_SYS_SR_OV (opval);
1467 written |= (1 << 5);
1468 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-ov", 'x', opval);
1470 if (GET_H_SYS_SR_OVE ()) {
1471 or1k32bf_exception (current_cpu, pc, EXCEPT_RANGE);
1476 abuf->written = written;
1477 return vpc;
1478 #undef FLD
1481 /* l-divu: l.divu $rD,$rA,$rB */
1483 static SEM_PC
1484 SEM_FN_NAME (or1k32bf,l_divu) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1486 #define FLD(f) abuf->fields.sfmt_l_sll.f
1487 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1488 int UNUSED written = 0;
1489 IADDR UNUSED pc = abuf->addr;
1490 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1492 if (NESI (GET_H_GPR (FLD (f_r3)), 0)) {
1495 BI opval = 0;
1496 SET_H_SYS_SR_CY (opval);
1497 written |= (1 << 5);
1498 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-cy", 'x', opval);
1501 USI opval = UDIVSI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)));
1502 SET_H_GPR (FLD (f_r1), opval);
1503 written |= (1 << 4);
1504 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1507 } else {
1510 BI opval = 1;
1511 SET_H_SYS_SR_CY (opval);
1512 written |= (1 << 5);
1513 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-cy", 'x', opval);
1515 if (GET_H_SYS_SR_OVE ()) {
1516 or1k32bf_exception (current_cpu, pc, EXCEPT_RANGE);
1521 abuf->written = written;
1522 return vpc;
1523 #undef FLD
1526 /* l-ff1: l.ff1 $rD,$rA */
1528 static SEM_PC
1529 SEM_FN_NAME (or1k32bf,l_ff1) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1531 #define FLD(f) abuf->fields.sfmt_l_slli.f
1532 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1533 int UNUSED written = 0;
1534 IADDR UNUSED pc = abuf->addr;
1535 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1538 USI opval = or1k32bf_ff1 (current_cpu, GET_H_GPR (FLD (f_r2)));
1539 SET_H_GPR (FLD (f_r1), opval);
1540 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1543 return vpc;
1544 #undef FLD
1547 /* l-fl1: l.fl1 $rD,$rA */
1549 static SEM_PC
1550 SEM_FN_NAME (or1k32bf,l_fl1) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1552 #define FLD(f) abuf->fields.sfmt_l_slli.f
1553 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1554 int UNUSED written = 0;
1555 IADDR UNUSED pc = abuf->addr;
1556 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1559 USI opval = or1k32bf_fl1 (current_cpu, GET_H_GPR (FLD (f_r2)));
1560 SET_H_GPR (FLD (f_r1), opval);
1561 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1564 return vpc;
1565 #undef FLD
1568 /* l-andi: l.andi $rD,$rA,$uimm16 */
1570 static SEM_PC
1571 SEM_FN_NAME (or1k32bf,l_andi) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1573 #define FLD(f) abuf->fields.sfmt_l_mfspr.f
1574 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1575 int UNUSED written = 0;
1576 IADDR UNUSED pc = abuf->addr;
1577 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1580 USI opval = ANDSI (GET_H_GPR (FLD (f_r2)), ZEXTSISI (FLD (f_uimm16)));
1581 SET_H_GPR (FLD (f_r1), opval);
1582 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1585 return vpc;
1586 #undef FLD
1589 /* l-ori: l.ori $rD,$rA,$uimm16 */
1591 static SEM_PC
1592 SEM_FN_NAME (or1k32bf,l_ori) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1594 #define FLD(f) abuf->fields.sfmt_l_mfspr.f
1595 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1596 int UNUSED written = 0;
1597 IADDR UNUSED pc = abuf->addr;
1598 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1601 USI opval = ORSI (GET_H_GPR (FLD (f_r2)), ZEXTSISI (FLD (f_uimm16)));
1602 SET_H_GPR (FLD (f_r1), opval);
1603 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1606 return vpc;
1607 #undef FLD
1610 /* l-xori: l.xori $rD,$rA,$simm16 */
1612 static SEM_PC
1613 SEM_FN_NAME (or1k32bf,l_xori) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1615 #define FLD(f) abuf->fields.sfmt_l_lwz.f
1616 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1617 int UNUSED written = 0;
1618 IADDR UNUSED pc = abuf->addr;
1619 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1622 USI opval = XORSI (GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16)));
1623 SET_H_GPR (FLD (f_r1), opval);
1624 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1627 return vpc;
1628 #undef FLD
1631 /* l-addi: l.addi $rD,$rA,$simm16 */
1633 static SEM_PC
1634 SEM_FN_NAME (or1k32bf,l_addi) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1636 #define FLD(f) abuf->fields.sfmt_l_lwz.f
1637 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1638 int UNUSED written = 0;
1639 IADDR UNUSED pc = abuf->addr;
1640 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1645 BI opval = ADDCFSI (GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16)), 0);
1646 SET_H_SYS_SR_CY (opval);
1647 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-cy", 'x', opval);
1650 BI opval = ADDOFSI (GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16)), 0);
1651 SET_H_SYS_SR_OV (opval);
1652 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-ov", 'x', opval);
1655 USI opval = ADDSI (GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16)));
1656 SET_H_GPR (FLD (f_r1), opval);
1657 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1660 if (ANDIF (GET_H_SYS_SR_OV (), GET_H_SYS_SR_OVE ())) {
1661 or1k32bf_exception (current_cpu, pc, EXCEPT_RANGE);
1665 return vpc;
1666 #undef FLD
1669 /* l-addic: l.addic $rD,$rA,$simm16 */
1671 static SEM_PC
1672 SEM_FN_NAME (or1k32bf,l_addic) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1674 #define FLD(f) abuf->fields.sfmt_l_lwz.f
1675 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1676 int UNUSED written = 0;
1677 IADDR UNUSED pc = abuf->addr;
1678 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1682 BI tmp_tmp_sys_sr_cy;
1683 tmp_tmp_sys_sr_cy = GET_H_SYS_SR_CY ();
1685 BI opval = ADDCFSI (GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16)), tmp_tmp_sys_sr_cy);
1686 SET_H_SYS_SR_CY (opval);
1687 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-cy", 'x', opval);
1690 BI opval = ADDOFSI (GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16)), tmp_tmp_sys_sr_cy);
1691 SET_H_SYS_SR_OV (opval);
1692 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-ov", 'x', opval);
1695 SI opval = ADDCSI (GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16)), tmp_tmp_sys_sr_cy);
1696 SET_H_GPR (FLD (f_r1), opval);
1697 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1700 if (ANDIF (GET_H_SYS_SR_OV (), GET_H_SYS_SR_OVE ())) {
1701 or1k32bf_exception (current_cpu, pc, EXCEPT_RANGE);
1705 return vpc;
1706 #undef FLD
1709 /* l-muli: l.muli $rD,$rA,$simm16 */
1711 static SEM_PC
1712 SEM_FN_NAME (or1k32bf,l_muli) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1714 #define FLD(f) abuf->fields.sfmt_l_lwz.f
1715 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1716 int UNUSED written = 0;
1717 IADDR UNUSED pc = abuf->addr;
1718 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1723 USI opval = MUL2OFSI (GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16)));
1724 SET_H_SYS_SR_OV (opval);
1725 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-ov", 'x', opval);
1728 USI opval = MULSI (GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16)));
1729 SET_H_GPR (FLD (f_r1), opval);
1730 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1733 if (ANDIF (GET_H_SYS_SR_OV (), GET_H_SYS_SR_OVE ())) {
1734 or1k32bf_exception (current_cpu, pc, EXCEPT_RANGE);
1738 return vpc;
1739 #undef FLD
1742 /* l-exths: l.exths $rD,$rA */
1744 static SEM_PC
1745 SEM_FN_NAME (or1k32bf,l_exths) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1747 #define FLD(f) abuf->fields.sfmt_l_slli.f
1748 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1749 int UNUSED written = 0;
1750 IADDR UNUSED pc = abuf->addr;
1751 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1754 USI opval = EXTHISI (TRUNCSIHI (GET_H_GPR (FLD (f_r2))));
1755 SET_H_GPR (FLD (f_r1), opval);
1756 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1759 return vpc;
1760 #undef FLD
1763 /* l-extbs: l.extbs $rD,$rA */
1765 static SEM_PC
1766 SEM_FN_NAME (or1k32bf,l_extbs) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1768 #define FLD(f) abuf->fields.sfmt_l_slli.f
1769 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1770 int UNUSED written = 0;
1771 IADDR UNUSED pc = abuf->addr;
1772 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1775 USI opval = EXTQISI (TRUNCSIQI (GET_H_GPR (FLD (f_r2))));
1776 SET_H_GPR (FLD (f_r1), opval);
1777 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1780 return vpc;
1781 #undef FLD
1784 /* l-exthz: l.exthz $rD,$rA */
1786 static SEM_PC
1787 SEM_FN_NAME (or1k32bf,l_exthz) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1789 #define FLD(f) abuf->fields.sfmt_l_slli.f
1790 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1791 int UNUSED written = 0;
1792 IADDR UNUSED pc = abuf->addr;
1793 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1796 USI opval = ZEXTHISI (TRUNCSIHI (GET_H_GPR (FLD (f_r2))));
1797 SET_H_GPR (FLD (f_r1), opval);
1798 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1801 return vpc;
1802 #undef FLD
1805 /* l-extbz: l.extbz $rD,$rA */
1807 static SEM_PC
1808 SEM_FN_NAME (or1k32bf,l_extbz) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1810 #define FLD(f) abuf->fields.sfmt_l_slli.f
1811 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1812 int UNUSED written = 0;
1813 IADDR UNUSED pc = abuf->addr;
1814 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1817 USI opval = ZEXTQISI (TRUNCSIQI (GET_H_GPR (FLD (f_r2))));
1818 SET_H_GPR (FLD (f_r1), opval);
1819 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1822 return vpc;
1823 #undef FLD
1826 /* l-extws: l.extws $rD,$rA */
1828 static SEM_PC
1829 SEM_FN_NAME (or1k32bf,l_extws) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1831 #define FLD(f) abuf->fields.sfmt_l_slli.f
1832 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1833 int UNUSED written = 0;
1834 IADDR UNUSED pc = abuf->addr;
1835 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1838 USI opval = EXTSISI (TRUNCSISI (GET_H_GPR (FLD (f_r2))));
1839 SET_H_GPR (FLD (f_r1), opval);
1840 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1843 return vpc;
1844 #undef FLD
1847 /* l-extwz: l.extwz $rD,$rA */
1849 static SEM_PC
1850 SEM_FN_NAME (or1k32bf,l_extwz) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1852 #define FLD(f) abuf->fields.sfmt_l_slli.f
1853 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1854 int UNUSED written = 0;
1855 IADDR UNUSED pc = abuf->addr;
1856 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1859 USI opval = ZEXTSISI (TRUNCSISI (GET_H_GPR (FLD (f_r2))));
1860 SET_H_GPR (FLD (f_r1), opval);
1861 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1864 return vpc;
1865 #undef FLD
1868 /* l-cmov: l.cmov $rD,$rA,$rB */
1870 static SEM_PC
1871 SEM_FN_NAME (or1k32bf,l_cmov) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1873 #define FLD(f) abuf->fields.sfmt_l_sll.f
1874 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1875 int UNUSED written = 0;
1876 IADDR UNUSED pc = abuf->addr;
1877 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1879 if (GET_H_SYS_SR_F ()) {
1881 USI opval = GET_H_GPR (FLD (f_r2));
1882 SET_H_GPR (FLD (f_r1), opval);
1883 written |= (1 << 3);
1884 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1886 } else {
1888 USI opval = GET_H_GPR (FLD (f_r3));
1889 SET_H_GPR (FLD (f_r1), opval);
1890 written |= (1 << 3);
1891 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
1895 abuf->written = written;
1896 return vpc;
1897 #undef FLD
1900 /* l-sfgts: l.sfgts $rA,$rB */
1902 static SEM_PC
1903 SEM_FN_NAME (or1k32bf,l_sfgts) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1905 #define FLD(f) abuf->fields.sfmt_l_sll.f
1906 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1907 int UNUSED written = 0;
1908 IADDR UNUSED pc = abuf->addr;
1909 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1912 USI opval = GTSI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)));
1913 SET_H_SYS_SR_F (opval);
1914 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-f", 'x', opval);
1917 return vpc;
1918 #undef FLD
1921 /* l-sfgtsi: l.sfgtsi $rA,$simm16 */
1923 static SEM_PC
1924 SEM_FN_NAME (or1k32bf,l_sfgtsi) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1926 #define FLD(f) abuf->fields.sfmt_l_lwz.f
1927 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1928 int UNUSED written = 0;
1929 IADDR UNUSED pc = abuf->addr;
1930 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1933 USI opval = GTSI (GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16)));
1934 SET_H_SYS_SR_F (opval);
1935 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-f", 'x', opval);
1938 return vpc;
1939 #undef FLD
1942 /* l-sfgtu: l.sfgtu $rA,$rB */
1944 static SEM_PC
1945 SEM_FN_NAME (or1k32bf,l_sfgtu) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1947 #define FLD(f) abuf->fields.sfmt_l_sll.f
1948 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1949 int UNUSED written = 0;
1950 IADDR UNUSED pc = abuf->addr;
1951 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1954 USI opval = GTUSI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)));
1955 SET_H_SYS_SR_F (opval);
1956 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-f", 'x', opval);
1959 return vpc;
1960 #undef FLD
1963 /* l-sfgtui: l.sfgtui $rA,$simm16 */
1965 static SEM_PC
1966 SEM_FN_NAME (or1k32bf,l_sfgtui) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1968 #define FLD(f) abuf->fields.sfmt_l_lwz.f
1969 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1970 int UNUSED written = 0;
1971 IADDR UNUSED pc = abuf->addr;
1972 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1975 USI opval = GTUSI (GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16)));
1976 SET_H_SYS_SR_F (opval);
1977 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-f", 'x', opval);
1980 return vpc;
1981 #undef FLD
1984 /* l-sfges: l.sfges $rA,$rB */
1986 static SEM_PC
1987 SEM_FN_NAME (or1k32bf,l_sfges) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
1989 #define FLD(f) abuf->fields.sfmt_l_sll.f
1990 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
1991 int UNUSED written = 0;
1992 IADDR UNUSED pc = abuf->addr;
1993 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
1996 USI opval = GESI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)));
1997 SET_H_SYS_SR_F (opval);
1998 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-f", 'x', opval);
2001 return vpc;
2002 #undef FLD
2005 /* l-sfgesi: l.sfgesi $rA,$simm16 */
2007 static SEM_PC
2008 SEM_FN_NAME (or1k32bf,l_sfgesi) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2010 #define FLD(f) abuf->fields.sfmt_l_lwz.f
2011 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2012 int UNUSED written = 0;
2013 IADDR UNUSED pc = abuf->addr;
2014 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2017 USI opval = GESI (GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16)));
2018 SET_H_SYS_SR_F (opval);
2019 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-f", 'x', opval);
2022 return vpc;
2023 #undef FLD
2026 /* l-sfgeu: l.sfgeu $rA,$rB */
2028 static SEM_PC
2029 SEM_FN_NAME (or1k32bf,l_sfgeu) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2031 #define FLD(f) abuf->fields.sfmt_l_sll.f
2032 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2033 int UNUSED written = 0;
2034 IADDR UNUSED pc = abuf->addr;
2035 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2038 USI opval = GEUSI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)));
2039 SET_H_SYS_SR_F (opval);
2040 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-f", 'x', opval);
2043 return vpc;
2044 #undef FLD
2047 /* l-sfgeui: l.sfgeui $rA,$simm16 */
2049 static SEM_PC
2050 SEM_FN_NAME (or1k32bf,l_sfgeui) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2052 #define FLD(f) abuf->fields.sfmt_l_lwz.f
2053 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2054 int UNUSED written = 0;
2055 IADDR UNUSED pc = abuf->addr;
2056 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2059 USI opval = GEUSI (GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16)));
2060 SET_H_SYS_SR_F (opval);
2061 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-f", 'x', opval);
2064 return vpc;
2065 #undef FLD
2068 /* l-sflts: l.sflts $rA,$rB */
2070 static SEM_PC
2071 SEM_FN_NAME (or1k32bf,l_sflts) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2073 #define FLD(f) abuf->fields.sfmt_l_sll.f
2074 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2075 int UNUSED written = 0;
2076 IADDR UNUSED pc = abuf->addr;
2077 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2080 USI opval = LTSI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)));
2081 SET_H_SYS_SR_F (opval);
2082 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-f", 'x', opval);
2085 return vpc;
2086 #undef FLD
2089 /* l-sfltsi: l.sfltsi $rA,$simm16 */
2091 static SEM_PC
2092 SEM_FN_NAME (or1k32bf,l_sfltsi) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2094 #define FLD(f) abuf->fields.sfmt_l_lwz.f
2095 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2096 int UNUSED written = 0;
2097 IADDR UNUSED pc = abuf->addr;
2098 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2101 USI opval = LTSI (GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16)));
2102 SET_H_SYS_SR_F (opval);
2103 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-f", 'x', opval);
2106 return vpc;
2107 #undef FLD
2110 /* l-sfltu: l.sfltu $rA,$rB */
2112 static SEM_PC
2113 SEM_FN_NAME (or1k32bf,l_sfltu) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2115 #define FLD(f) abuf->fields.sfmt_l_sll.f
2116 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2117 int UNUSED written = 0;
2118 IADDR UNUSED pc = abuf->addr;
2119 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2122 USI opval = LTUSI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)));
2123 SET_H_SYS_SR_F (opval);
2124 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-f", 'x', opval);
2127 return vpc;
2128 #undef FLD
2131 /* l-sfltui: l.sfltui $rA,$simm16 */
2133 static SEM_PC
2134 SEM_FN_NAME (or1k32bf,l_sfltui) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2136 #define FLD(f) abuf->fields.sfmt_l_lwz.f
2137 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2138 int UNUSED written = 0;
2139 IADDR UNUSED pc = abuf->addr;
2140 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2143 USI opval = LTUSI (GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16)));
2144 SET_H_SYS_SR_F (opval);
2145 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-f", 'x', opval);
2148 return vpc;
2149 #undef FLD
2152 /* l-sfles: l.sfles $rA,$rB */
2154 static SEM_PC
2155 SEM_FN_NAME (or1k32bf,l_sfles) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2157 #define FLD(f) abuf->fields.sfmt_l_sll.f
2158 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2159 int UNUSED written = 0;
2160 IADDR UNUSED pc = abuf->addr;
2161 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2164 USI opval = LESI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)));
2165 SET_H_SYS_SR_F (opval);
2166 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-f", 'x', opval);
2169 return vpc;
2170 #undef FLD
2173 /* l-sflesi: l.sflesi $rA,$simm16 */
2175 static SEM_PC
2176 SEM_FN_NAME (or1k32bf,l_sflesi) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2178 #define FLD(f) abuf->fields.sfmt_l_lwz.f
2179 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2180 int UNUSED written = 0;
2181 IADDR UNUSED pc = abuf->addr;
2182 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2185 USI opval = LESI (GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16)));
2186 SET_H_SYS_SR_F (opval);
2187 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-f", 'x', opval);
2190 return vpc;
2191 #undef FLD
2194 /* l-sfleu: l.sfleu $rA,$rB */
2196 static SEM_PC
2197 SEM_FN_NAME (or1k32bf,l_sfleu) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2199 #define FLD(f) abuf->fields.sfmt_l_sll.f
2200 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2201 int UNUSED written = 0;
2202 IADDR UNUSED pc = abuf->addr;
2203 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2206 USI opval = LEUSI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)));
2207 SET_H_SYS_SR_F (opval);
2208 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-f", 'x', opval);
2211 return vpc;
2212 #undef FLD
2215 /* l-sfleui: l.sfleui $rA,$simm16 */
2217 static SEM_PC
2218 SEM_FN_NAME (or1k32bf,l_sfleui) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2220 #define FLD(f) abuf->fields.sfmt_l_lwz.f
2221 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2222 int UNUSED written = 0;
2223 IADDR UNUSED pc = abuf->addr;
2224 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2227 USI opval = LEUSI (GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16)));
2228 SET_H_SYS_SR_F (opval);
2229 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-f", 'x', opval);
2232 return vpc;
2233 #undef FLD
2236 /* l-sfeq: l.sfeq $rA,$rB */
2238 static SEM_PC
2239 SEM_FN_NAME (or1k32bf,l_sfeq) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2241 #define FLD(f) abuf->fields.sfmt_l_sll.f
2242 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2243 int UNUSED written = 0;
2244 IADDR UNUSED pc = abuf->addr;
2245 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2248 USI opval = EQSI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)));
2249 SET_H_SYS_SR_F (opval);
2250 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-f", 'x', opval);
2253 return vpc;
2254 #undef FLD
2257 /* l-sfeqi: l.sfeqi $rA,$simm16 */
2259 static SEM_PC
2260 SEM_FN_NAME (or1k32bf,l_sfeqi) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2262 #define FLD(f) abuf->fields.sfmt_l_lwz.f
2263 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2264 int UNUSED written = 0;
2265 IADDR UNUSED pc = abuf->addr;
2266 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2269 USI opval = EQSI (GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16)));
2270 SET_H_SYS_SR_F (opval);
2271 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-f", 'x', opval);
2274 return vpc;
2275 #undef FLD
2278 /* l-sfne: l.sfne $rA,$rB */
2280 static SEM_PC
2281 SEM_FN_NAME (or1k32bf,l_sfne) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2283 #define FLD(f) abuf->fields.sfmt_l_sll.f
2284 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2285 int UNUSED written = 0;
2286 IADDR UNUSED pc = abuf->addr;
2287 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2290 USI opval = NESI (GET_H_GPR (FLD (f_r2)), GET_H_GPR (FLD (f_r3)));
2291 SET_H_SYS_SR_F (opval);
2292 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-f", 'x', opval);
2295 return vpc;
2296 #undef FLD
2299 /* l-sfnei: l.sfnei $rA,$simm16 */
2301 static SEM_PC
2302 SEM_FN_NAME (or1k32bf,l_sfnei) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2304 #define FLD(f) abuf->fields.sfmt_l_lwz.f
2305 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2306 int UNUSED written = 0;
2307 IADDR UNUSED pc = abuf->addr;
2308 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2311 USI opval = NESI (GET_H_GPR (FLD (f_r2)), EXTSISI (FLD (f_simm16)));
2312 SET_H_SYS_SR_F (opval);
2313 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-f", 'x', opval);
2316 return vpc;
2317 #undef FLD
2320 /* l-mac: l.mac $rA,$rB */
2322 static SEM_PC
2323 SEM_FN_NAME (or1k32bf,l_mac) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2325 #define FLD(f) abuf->fields.sfmt_l_sll.f
2326 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2327 int UNUSED written = 0;
2328 IADDR UNUSED pc = abuf->addr;
2329 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2333 DI tmp_prod;
2334 DI tmp_mac;
2335 DI tmp_result;
2336 tmp_prod = MULDI (EXTSIDI (GET_H_GPR (FLD (f_r2))), EXTSIDI (GET_H_GPR (FLD (f_r3))));
2337 tmp_mac = JOINSIDI (GET_H_MAC_MACHI (), GET_H_MAC_MACLO ());
2338 tmp_result = ADDDI (tmp_prod, tmp_mac);
2340 SI opval = SUBWORDDISI (tmp_result, 0);
2341 SET_H_MAC_MACHI (opval);
2342 CGEN_TRACE_RESULT (current_cpu, abuf, "mac-machi", 'x', opval);
2345 SI opval = SUBWORDDISI (tmp_result, 1);
2346 SET_H_MAC_MACLO (opval);
2347 CGEN_TRACE_RESULT (current_cpu, abuf, "mac-maclo", 'x', opval);
2350 BI opval = ADDOFDI (tmp_prod, tmp_mac, 0);
2351 SET_H_SYS_SR_OV (opval);
2352 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-ov", 'x', opval);
2355 if (ANDIF (GET_H_SYS_SR_OV (), GET_H_SYS_SR_OVE ())) {
2356 or1k32bf_exception (current_cpu, pc, EXCEPT_RANGE);
2360 return vpc;
2361 #undef FLD
2364 /* l-maci: l.maci $rA,${simm16} */
2366 static SEM_PC
2367 SEM_FN_NAME (or1k32bf,l_maci) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2369 #define FLD(f) abuf->fields.sfmt_l_lwz.f
2370 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2371 int UNUSED written = 0;
2372 IADDR UNUSED pc = abuf->addr;
2373 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2377 DI tmp_prod;
2378 DI tmp_mac;
2379 DI tmp_result;
2380 tmp_prod = MULDI (EXTSIDI (GET_H_GPR (FLD (f_r2))), EXTSIDI (FLD (f_simm16)));
2381 tmp_mac = JOINSIDI (GET_H_MAC_MACHI (), GET_H_MAC_MACLO ());
2382 tmp_result = ADDDI (tmp_mac, tmp_prod);
2384 SI opval = SUBWORDDISI (tmp_result, 0);
2385 SET_H_MAC_MACHI (opval);
2386 CGEN_TRACE_RESULT (current_cpu, abuf, "mac-machi", 'x', opval);
2389 SI opval = SUBWORDDISI (tmp_result, 1);
2390 SET_H_MAC_MACLO (opval);
2391 CGEN_TRACE_RESULT (current_cpu, abuf, "mac-maclo", 'x', opval);
2394 BI opval = ADDOFDI (tmp_prod, tmp_mac, 0);
2395 SET_H_SYS_SR_OV (opval);
2396 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-ov", 'x', opval);
2399 if (ANDIF (GET_H_SYS_SR_OV (), GET_H_SYS_SR_OVE ())) {
2400 or1k32bf_exception (current_cpu, pc, EXCEPT_RANGE);
2404 return vpc;
2405 #undef FLD
2408 /* l-macu: l.macu $rA,$rB */
2410 static SEM_PC
2411 SEM_FN_NAME (or1k32bf,l_macu) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2413 #define FLD(f) abuf->fields.sfmt_l_sll.f
2414 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2415 int UNUSED written = 0;
2416 IADDR UNUSED pc = abuf->addr;
2417 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2421 DI tmp_prod;
2422 DI tmp_mac;
2423 DI tmp_result;
2424 tmp_prod = MULDI (ZEXTSIDI (GET_H_GPR (FLD (f_r2))), ZEXTSIDI (GET_H_GPR (FLD (f_r3))));
2425 tmp_mac = JOINSIDI (GET_H_MAC_MACHI (), GET_H_MAC_MACLO ());
2426 tmp_result = ADDDI (tmp_prod, tmp_mac);
2428 SI opval = SUBWORDDISI (tmp_result, 0);
2429 SET_H_MAC_MACHI (opval);
2430 CGEN_TRACE_RESULT (current_cpu, abuf, "mac-machi", 'x', opval);
2433 SI opval = SUBWORDDISI (tmp_result, 1);
2434 SET_H_MAC_MACLO (opval);
2435 CGEN_TRACE_RESULT (current_cpu, abuf, "mac-maclo", 'x', opval);
2438 BI opval = ADDCFDI (tmp_prod, tmp_mac, 0);
2439 SET_H_SYS_SR_CY (opval);
2440 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-cy", 'x', opval);
2443 if (ANDIF (GET_H_SYS_SR_CY (), GET_H_SYS_SR_OVE ())) {
2444 or1k32bf_exception (current_cpu, pc, EXCEPT_RANGE);
2448 return vpc;
2449 #undef FLD
2452 /* l-msb: l.msb $rA,$rB */
2454 static SEM_PC
2455 SEM_FN_NAME (or1k32bf,l_msb) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2457 #define FLD(f) abuf->fields.sfmt_l_sll.f
2458 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2459 int UNUSED written = 0;
2460 IADDR UNUSED pc = abuf->addr;
2461 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2465 DI tmp_prod;
2466 DI tmp_mac;
2467 DI tmp_result;
2468 tmp_prod = MULDI (EXTSIDI (GET_H_GPR (FLD (f_r2))), EXTSIDI (GET_H_GPR (FLD (f_r3))));
2469 tmp_mac = JOINSIDI (GET_H_MAC_MACHI (), GET_H_MAC_MACLO ());
2470 tmp_result = SUBDI (tmp_mac, tmp_prod);
2472 SI opval = SUBWORDDISI (tmp_result, 0);
2473 SET_H_MAC_MACHI (opval);
2474 CGEN_TRACE_RESULT (current_cpu, abuf, "mac-machi", 'x', opval);
2477 SI opval = SUBWORDDISI (tmp_result, 1);
2478 SET_H_MAC_MACLO (opval);
2479 CGEN_TRACE_RESULT (current_cpu, abuf, "mac-maclo", 'x', opval);
2482 BI opval = SUBOFDI (tmp_mac, tmp_result, 0);
2483 SET_H_SYS_SR_OV (opval);
2484 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-ov", 'x', opval);
2487 if (ANDIF (GET_H_SYS_SR_OV (), GET_H_SYS_SR_OVE ())) {
2488 or1k32bf_exception (current_cpu, pc, EXCEPT_RANGE);
2492 return vpc;
2493 #undef FLD
2496 /* l-msbu: l.msbu $rA,$rB */
2498 static SEM_PC
2499 SEM_FN_NAME (or1k32bf,l_msbu) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2501 #define FLD(f) abuf->fields.sfmt_l_sll.f
2502 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2503 int UNUSED written = 0;
2504 IADDR UNUSED pc = abuf->addr;
2505 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2509 DI tmp_prod;
2510 DI tmp_mac;
2511 DI tmp_result;
2512 tmp_prod = MULDI (ZEXTSIDI (GET_H_GPR (FLD (f_r2))), ZEXTSIDI (GET_H_GPR (FLD (f_r3))));
2513 tmp_mac = JOINSIDI (GET_H_MAC_MACHI (), GET_H_MAC_MACLO ());
2514 tmp_result = SUBDI (tmp_mac, tmp_prod);
2516 SI opval = SUBWORDDISI (tmp_result, 0);
2517 SET_H_MAC_MACHI (opval);
2518 CGEN_TRACE_RESULT (current_cpu, abuf, "mac-machi", 'x', opval);
2521 SI opval = SUBWORDDISI (tmp_result, 1);
2522 SET_H_MAC_MACLO (opval);
2523 CGEN_TRACE_RESULT (current_cpu, abuf, "mac-maclo", 'x', opval);
2526 BI opval = SUBCFDI (tmp_mac, tmp_result, 0);
2527 SET_H_SYS_SR_CY (opval);
2528 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-cy", 'x', opval);
2531 if (ANDIF (GET_H_SYS_SR_CY (), GET_H_SYS_SR_OVE ())) {
2532 or1k32bf_exception (current_cpu, pc, EXCEPT_RANGE);
2536 return vpc;
2537 #undef FLD
2540 /* l-cust1: l.cust1 */
2542 static SEM_PC
2543 SEM_FN_NAME (or1k32bf,l_cust1) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2545 #define FLD(f) abuf->fields.sfmt_empty.f
2546 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2547 int UNUSED written = 0;
2548 IADDR UNUSED pc = abuf->addr;
2549 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2551 ((void) 0); /*nop*/
2553 return vpc;
2554 #undef FLD
2557 /* l-cust2: l.cust2 */
2559 static SEM_PC
2560 SEM_FN_NAME (or1k32bf,l_cust2) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2562 #define FLD(f) abuf->fields.sfmt_empty.f
2563 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2564 int UNUSED written = 0;
2565 IADDR UNUSED pc = abuf->addr;
2566 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2568 ((void) 0); /*nop*/
2570 return vpc;
2571 #undef FLD
2574 /* l-cust3: l.cust3 */
2576 static SEM_PC
2577 SEM_FN_NAME (or1k32bf,l_cust3) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2579 #define FLD(f) abuf->fields.sfmt_empty.f
2580 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2581 int UNUSED written = 0;
2582 IADDR UNUSED pc = abuf->addr;
2583 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2585 ((void) 0); /*nop*/
2587 return vpc;
2588 #undef FLD
2591 /* l-cust4: l.cust4 */
2593 static SEM_PC
2594 SEM_FN_NAME (or1k32bf,l_cust4) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2596 #define FLD(f) abuf->fields.sfmt_empty.f
2597 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2598 int UNUSED written = 0;
2599 IADDR UNUSED pc = abuf->addr;
2600 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2602 ((void) 0); /*nop*/
2604 return vpc;
2605 #undef FLD
2608 /* l-cust5: l.cust5 */
2610 static SEM_PC
2611 SEM_FN_NAME (or1k32bf,l_cust5) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2613 #define FLD(f) abuf->fields.sfmt_empty.f
2614 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2615 int UNUSED written = 0;
2616 IADDR UNUSED pc = abuf->addr;
2617 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2619 ((void) 0); /*nop*/
2621 return vpc;
2622 #undef FLD
2625 /* l-cust6: l.cust6 */
2627 static SEM_PC
2628 SEM_FN_NAME (or1k32bf,l_cust6) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2630 #define FLD(f) abuf->fields.sfmt_empty.f
2631 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2632 int UNUSED written = 0;
2633 IADDR UNUSED pc = abuf->addr;
2634 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2636 ((void) 0); /*nop*/
2638 return vpc;
2639 #undef FLD
2642 /* l-cust7: l.cust7 */
2644 static SEM_PC
2645 SEM_FN_NAME (or1k32bf,l_cust7) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2647 #define FLD(f) abuf->fields.sfmt_empty.f
2648 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2649 int UNUSED written = 0;
2650 IADDR UNUSED pc = abuf->addr;
2651 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2653 ((void) 0); /*nop*/
2655 return vpc;
2656 #undef FLD
2659 /* l-cust8: l.cust8 */
2661 static SEM_PC
2662 SEM_FN_NAME (or1k32bf,l_cust8) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2664 #define FLD(f) abuf->fields.sfmt_empty.f
2665 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2666 int UNUSED written = 0;
2667 IADDR UNUSED pc = abuf->addr;
2668 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2670 ((void) 0); /*nop*/
2672 return vpc;
2673 #undef FLD
2676 /* lf-add-s: lf.add.s $rDSF,$rASF,$rBSF */
2678 static SEM_PC
2679 SEM_FN_NAME (or1k32bf,lf_add_s) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2681 #define FLD(f) abuf->fields.sfmt_l_sll.f
2682 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2683 int UNUSED written = 0;
2684 IADDR UNUSED pc = abuf->addr;
2685 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2688 SF opval = CGEN_CPU_FPU (current_cpu)->ops->addsf (CGEN_CPU_FPU (current_cpu), GET_H_FSR (FLD (f_r2)), GET_H_FSR (FLD (f_r3)));
2689 SET_H_FSR (FLD (f_r1), opval);
2690 CGEN_TRACE_RESULT (current_cpu, abuf, "fsr", 'f', opval);
2693 return vpc;
2694 #undef FLD
2697 /* lf-sub-s: lf.sub.s $rDSF,$rASF,$rBSF */
2699 static SEM_PC
2700 SEM_FN_NAME (or1k32bf,lf_sub_s) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2702 #define FLD(f) abuf->fields.sfmt_l_sll.f
2703 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2704 int UNUSED written = 0;
2705 IADDR UNUSED pc = abuf->addr;
2706 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2709 SF opval = CGEN_CPU_FPU (current_cpu)->ops->subsf (CGEN_CPU_FPU (current_cpu), GET_H_FSR (FLD (f_r2)), GET_H_FSR (FLD (f_r3)));
2710 SET_H_FSR (FLD (f_r1), opval);
2711 CGEN_TRACE_RESULT (current_cpu, abuf, "fsr", 'f', opval);
2714 return vpc;
2715 #undef FLD
2718 /* lf-mul-s: lf.mul.s $rDSF,$rASF,$rBSF */
2720 static SEM_PC
2721 SEM_FN_NAME (or1k32bf,lf_mul_s) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2723 #define FLD(f) abuf->fields.sfmt_l_sll.f
2724 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2725 int UNUSED written = 0;
2726 IADDR UNUSED pc = abuf->addr;
2727 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2730 SF opval = CGEN_CPU_FPU (current_cpu)->ops->mulsf (CGEN_CPU_FPU (current_cpu), GET_H_FSR (FLD (f_r2)), GET_H_FSR (FLD (f_r3)));
2731 SET_H_FSR (FLD (f_r1), opval);
2732 CGEN_TRACE_RESULT (current_cpu, abuf, "fsr", 'f', opval);
2735 return vpc;
2736 #undef FLD
2739 /* lf-div-s: lf.div.s $rDSF,$rASF,$rBSF */
2741 static SEM_PC
2742 SEM_FN_NAME (or1k32bf,lf_div_s) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2744 #define FLD(f) abuf->fields.sfmt_l_sll.f
2745 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2746 int UNUSED written = 0;
2747 IADDR UNUSED pc = abuf->addr;
2748 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2751 SF opval = CGEN_CPU_FPU (current_cpu)->ops->divsf (CGEN_CPU_FPU (current_cpu), GET_H_FSR (FLD (f_r2)), GET_H_FSR (FLD (f_r3)));
2752 SET_H_FSR (FLD (f_r1), opval);
2753 CGEN_TRACE_RESULT (current_cpu, abuf, "fsr", 'f', opval);
2756 return vpc;
2757 #undef FLD
2760 /* lf-rem-s: lf.rem.s $rDSF,$rASF,$rBSF */
2762 static SEM_PC
2763 SEM_FN_NAME (or1k32bf,lf_rem_s) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2765 #define FLD(f) abuf->fields.sfmt_l_sll.f
2766 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2767 int UNUSED written = 0;
2768 IADDR UNUSED pc = abuf->addr;
2769 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2772 SF opval = CGEN_CPU_FPU (current_cpu)->ops->remsf (CGEN_CPU_FPU (current_cpu), GET_H_FSR (FLD (f_r2)), GET_H_FSR (FLD (f_r3)));
2773 SET_H_FSR (FLD (f_r1), opval);
2774 CGEN_TRACE_RESULT (current_cpu, abuf, "fsr", 'f', opval);
2777 return vpc;
2778 #undef FLD
2781 /* lf-itof-s: lf.itof.s $rDSF,$rA */
2783 static SEM_PC
2784 SEM_FN_NAME (or1k32bf,lf_itof_s) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2786 #define FLD(f) abuf->fields.sfmt_l_slli.f
2787 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2788 int UNUSED written = 0;
2789 IADDR UNUSED pc = abuf->addr;
2790 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2793 SF opval = CGEN_CPU_FPU (current_cpu)->ops->floatsisf (CGEN_CPU_FPU (current_cpu), (GET_H_SYS_FPCSR_RM () == 0) ? (1) : (GET_H_SYS_FPCSR_RM () == 1) ? (3) : (GET_H_SYS_FPCSR_RM () == 2) ? (4) : (5), TRUNCSISI (GET_H_GPR (FLD (f_r2))));
2794 SET_H_FSR (FLD (f_r1), opval);
2795 CGEN_TRACE_RESULT (current_cpu, abuf, "fsr", 'f', opval);
2798 return vpc;
2799 #undef FLD
2802 /* lf-ftoi-s: lf.ftoi.s $rD,$rASF */
2804 static SEM_PC
2805 SEM_FN_NAME (or1k32bf,lf_ftoi_s) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2807 #define FLD(f) abuf->fields.sfmt_l_slli.f
2808 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2809 int UNUSED written = 0;
2810 IADDR UNUSED pc = abuf->addr;
2811 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2814 SI opval = EXTSISI (CGEN_CPU_FPU (current_cpu)->ops->fixsfsi (CGEN_CPU_FPU (current_cpu), (GET_H_SYS_FPCSR_RM () == 0) ? (1) : (GET_H_SYS_FPCSR_RM () == 1) ? (3) : (GET_H_SYS_FPCSR_RM () == 2) ? (4) : (5), GET_H_FSR (FLD (f_r2))));
2815 SET_H_GPR (FLD (f_r1), opval);
2816 CGEN_TRACE_RESULT (current_cpu, abuf, "gpr", 'x', opval);
2819 return vpc;
2820 #undef FLD
2823 /* lf-eq-s: lf.sfeq.s $rASF,$rBSF */
2825 static SEM_PC
2826 SEM_FN_NAME (or1k32bf,lf_eq_s) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2828 #define FLD(f) abuf->fields.sfmt_l_sll.f
2829 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2830 int UNUSED written = 0;
2831 IADDR UNUSED pc = abuf->addr;
2832 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2835 BI opval = CGEN_CPU_FPU (current_cpu)->ops->eqsf (CGEN_CPU_FPU (current_cpu), GET_H_FSR (FLD (f_r2)), GET_H_FSR (FLD (f_r3)));
2836 SET_H_SYS_SR_F (opval);
2837 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-f", 'x', opval);
2840 return vpc;
2841 #undef FLD
2844 /* lf-ne-s: lf.sfne.s $rASF,$rBSF */
2846 static SEM_PC
2847 SEM_FN_NAME (or1k32bf,lf_ne_s) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2849 #define FLD(f) abuf->fields.sfmt_l_sll.f
2850 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2851 int UNUSED written = 0;
2852 IADDR UNUSED pc = abuf->addr;
2853 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2856 BI opval = CGEN_CPU_FPU (current_cpu)->ops->nesf (CGEN_CPU_FPU (current_cpu), GET_H_FSR (FLD (f_r2)), GET_H_FSR (FLD (f_r3)));
2857 SET_H_SYS_SR_F (opval);
2858 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-f", 'x', opval);
2861 return vpc;
2862 #undef FLD
2865 /* lf-ge-s: lf.sfge.s $rASF,$rBSF */
2867 static SEM_PC
2868 SEM_FN_NAME (or1k32bf,lf_ge_s) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2870 #define FLD(f) abuf->fields.sfmt_l_sll.f
2871 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2872 int UNUSED written = 0;
2873 IADDR UNUSED pc = abuf->addr;
2874 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2877 BI opval = CGEN_CPU_FPU (current_cpu)->ops->gesf (CGEN_CPU_FPU (current_cpu), GET_H_FSR (FLD (f_r2)), GET_H_FSR (FLD (f_r3)));
2878 SET_H_SYS_SR_F (opval);
2879 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-f", 'x', opval);
2882 return vpc;
2883 #undef FLD
2886 /* lf-gt-s: lf.sfgt.s $rASF,$rBSF */
2888 static SEM_PC
2889 SEM_FN_NAME (or1k32bf,lf_gt_s) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2891 #define FLD(f) abuf->fields.sfmt_l_sll.f
2892 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2893 int UNUSED written = 0;
2894 IADDR UNUSED pc = abuf->addr;
2895 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2898 BI opval = CGEN_CPU_FPU (current_cpu)->ops->gtsf (CGEN_CPU_FPU (current_cpu), GET_H_FSR (FLD (f_r2)), GET_H_FSR (FLD (f_r3)));
2899 SET_H_SYS_SR_F (opval);
2900 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-f", 'x', opval);
2903 return vpc;
2904 #undef FLD
2907 /* lf-lt-s: lf.sflt.s $rASF,$rBSF */
2909 static SEM_PC
2910 SEM_FN_NAME (or1k32bf,lf_lt_s) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2912 #define FLD(f) abuf->fields.sfmt_l_sll.f
2913 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2914 int UNUSED written = 0;
2915 IADDR UNUSED pc = abuf->addr;
2916 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2919 BI opval = CGEN_CPU_FPU (current_cpu)->ops->ltsf (CGEN_CPU_FPU (current_cpu), GET_H_FSR (FLD (f_r2)), GET_H_FSR (FLD (f_r3)));
2920 SET_H_SYS_SR_F (opval);
2921 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-f", 'x', opval);
2924 return vpc;
2925 #undef FLD
2928 /* lf-le-s: lf.sfle.s $rASF,$rBSF */
2930 static SEM_PC
2931 SEM_FN_NAME (or1k32bf,lf_le_s) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2933 #define FLD(f) abuf->fields.sfmt_l_sll.f
2934 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2935 int UNUSED written = 0;
2936 IADDR UNUSED pc = abuf->addr;
2937 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2940 BI opval = CGEN_CPU_FPU (current_cpu)->ops->lesf (CGEN_CPU_FPU (current_cpu), GET_H_FSR (FLD (f_r2)), GET_H_FSR (FLD (f_r3)));
2941 SET_H_SYS_SR_F (opval);
2942 CGEN_TRACE_RESULT (current_cpu, abuf, "sys-sr-f", 'x', opval);
2945 return vpc;
2946 #undef FLD
2949 /* lf-madd-s: lf.madd.s $rDSF,$rASF,$rBSF */
2951 static SEM_PC
2952 SEM_FN_NAME (or1k32bf,lf_madd_s) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2954 #define FLD(f) abuf->fields.sfmt_l_sll.f
2955 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2956 int UNUSED written = 0;
2957 IADDR UNUSED pc = abuf->addr;
2958 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2961 SF opval = CGEN_CPU_FPU (current_cpu)->ops->addsf (CGEN_CPU_FPU (current_cpu), CGEN_CPU_FPU (current_cpu)->ops->mulsf (CGEN_CPU_FPU (current_cpu), GET_H_FSR (FLD (f_r2)), GET_H_FSR (FLD (f_r3))), GET_H_FSR (FLD (f_r1)));
2962 SET_H_FSR (FLD (f_r1), opval);
2963 CGEN_TRACE_RESULT (current_cpu, abuf, "fsr", 'f', opval);
2966 return vpc;
2967 #undef FLD
2970 /* lf-cust1-s: lf.cust1.s $rASF,$rBSF */
2972 static SEM_PC
2973 SEM_FN_NAME (or1k32bf,lf_cust1_s) (SIM_CPU *current_cpu, SEM_ARG sem_arg)
2975 #define FLD(f) abuf->fields.sfmt_empty.f
2976 ARGBUF *abuf = SEM_ARGBUF (sem_arg);
2977 int UNUSED written = 0;
2978 IADDR UNUSED pc = abuf->addr;
2979 SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4);
2981 ((void) 0); /*nop*/
2983 return vpc;
2984 #undef FLD
2987 /* Table of all semantic fns. */
2989 static const struct sem_fn_desc sem_fns[] = {
2990 { OR1K32BF_INSN_X_INVALID, SEM_FN_NAME (or1k32bf,x_invalid) },
2991 { OR1K32BF_INSN_X_AFTER, SEM_FN_NAME (or1k32bf,x_after) },
2992 { OR1K32BF_INSN_X_BEFORE, SEM_FN_NAME (or1k32bf,x_before) },
2993 { OR1K32BF_INSN_X_CTI_CHAIN, SEM_FN_NAME (or1k32bf,x_cti_chain) },
2994 { OR1K32BF_INSN_X_CHAIN, SEM_FN_NAME (or1k32bf,x_chain) },
2995 { OR1K32BF_INSN_X_BEGIN, SEM_FN_NAME (or1k32bf,x_begin) },
2996 { OR1K32BF_INSN_L_J, SEM_FN_NAME (or1k32bf,l_j) },
2997 { OR1K32BF_INSN_L_ADRP, SEM_FN_NAME (or1k32bf,l_adrp) },
2998 { OR1K32BF_INSN_L_JAL, SEM_FN_NAME (or1k32bf,l_jal) },
2999 { OR1K32BF_INSN_L_JR, SEM_FN_NAME (or1k32bf,l_jr) },
3000 { OR1K32BF_INSN_L_JALR, SEM_FN_NAME (or1k32bf,l_jalr) },
3001 { OR1K32BF_INSN_L_BNF, SEM_FN_NAME (or1k32bf,l_bnf) },
3002 { OR1K32BF_INSN_L_BF, SEM_FN_NAME (or1k32bf,l_bf) },
3003 { OR1K32BF_INSN_L_TRAP, SEM_FN_NAME (or1k32bf,l_trap) },
3004 { OR1K32BF_INSN_L_SYS, SEM_FN_NAME (or1k32bf,l_sys) },
3005 { OR1K32BF_INSN_L_MSYNC, SEM_FN_NAME (or1k32bf,l_msync) },
3006 { OR1K32BF_INSN_L_PSYNC, SEM_FN_NAME (or1k32bf,l_psync) },
3007 { OR1K32BF_INSN_L_CSYNC, SEM_FN_NAME (or1k32bf,l_csync) },
3008 { OR1K32BF_INSN_L_RFE, SEM_FN_NAME (or1k32bf,l_rfe) },
3009 { OR1K32BF_INSN_L_NOP_IMM, SEM_FN_NAME (or1k32bf,l_nop_imm) },
3010 { OR1K32BF_INSN_L_MOVHI, SEM_FN_NAME (or1k32bf,l_movhi) },
3011 { OR1K32BF_INSN_L_MACRC, SEM_FN_NAME (or1k32bf,l_macrc) },
3012 { OR1K32BF_INSN_L_MFSPR, SEM_FN_NAME (or1k32bf,l_mfspr) },
3013 { OR1K32BF_INSN_L_MTSPR, SEM_FN_NAME (or1k32bf,l_mtspr) },
3014 { OR1K32BF_INSN_L_LWZ, SEM_FN_NAME (or1k32bf,l_lwz) },
3015 { OR1K32BF_INSN_L_LWS, SEM_FN_NAME (or1k32bf,l_lws) },
3016 { OR1K32BF_INSN_L_LWA, SEM_FN_NAME (or1k32bf,l_lwa) },
3017 { OR1K32BF_INSN_L_LBZ, SEM_FN_NAME (or1k32bf,l_lbz) },
3018 { OR1K32BF_INSN_L_LBS, SEM_FN_NAME (or1k32bf,l_lbs) },
3019 { OR1K32BF_INSN_L_LHZ, SEM_FN_NAME (or1k32bf,l_lhz) },
3020 { OR1K32BF_INSN_L_LHS, SEM_FN_NAME (or1k32bf,l_lhs) },
3021 { OR1K32BF_INSN_L_SW, SEM_FN_NAME (or1k32bf,l_sw) },
3022 { OR1K32BF_INSN_L_SB, SEM_FN_NAME (or1k32bf,l_sb) },
3023 { OR1K32BF_INSN_L_SH, SEM_FN_NAME (or1k32bf,l_sh) },
3024 { OR1K32BF_INSN_L_SWA, SEM_FN_NAME (or1k32bf,l_swa) },
3025 { OR1K32BF_INSN_L_SLL, SEM_FN_NAME (or1k32bf,l_sll) },
3026 { OR1K32BF_INSN_L_SLLI, SEM_FN_NAME (or1k32bf,l_slli) },
3027 { OR1K32BF_INSN_L_SRL, SEM_FN_NAME (or1k32bf,l_srl) },
3028 { OR1K32BF_INSN_L_SRLI, SEM_FN_NAME (or1k32bf,l_srli) },
3029 { OR1K32BF_INSN_L_SRA, SEM_FN_NAME (or1k32bf,l_sra) },
3030 { OR1K32BF_INSN_L_SRAI, SEM_FN_NAME (or1k32bf,l_srai) },
3031 { OR1K32BF_INSN_L_ROR, SEM_FN_NAME (or1k32bf,l_ror) },
3032 { OR1K32BF_INSN_L_RORI, SEM_FN_NAME (or1k32bf,l_rori) },
3033 { OR1K32BF_INSN_L_AND, SEM_FN_NAME (or1k32bf,l_and) },
3034 { OR1K32BF_INSN_L_OR, SEM_FN_NAME (or1k32bf,l_or) },
3035 { OR1K32BF_INSN_L_XOR, SEM_FN_NAME (or1k32bf,l_xor) },
3036 { OR1K32BF_INSN_L_ADD, SEM_FN_NAME (or1k32bf,l_add) },
3037 { OR1K32BF_INSN_L_SUB, SEM_FN_NAME (or1k32bf,l_sub) },
3038 { OR1K32BF_INSN_L_ADDC, SEM_FN_NAME (or1k32bf,l_addc) },
3039 { OR1K32BF_INSN_L_MUL, SEM_FN_NAME (or1k32bf,l_mul) },
3040 { OR1K32BF_INSN_L_MULD, SEM_FN_NAME (or1k32bf,l_muld) },
3041 { OR1K32BF_INSN_L_MULU, SEM_FN_NAME (or1k32bf,l_mulu) },
3042 { OR1K32BF_INSN_L_MULDU, SEM_FN_NAME (or1k32bf,l_muldu) },
3043 { OR1K32BF_INSN_L_DIV, SEM_FN_NAME (or1k32bf,l_div) },
3044 { OR1K32BF_INSN_L_DIVU, SEM_FN_NAME (or1k32bf,l_divu) },
3045 { OR1K32BF_INSN_L_FF1, SEM_FN_NAME (or1k32bf,l_ff1) },
3046 { OR1K32BF_INSN_L_FL1, SEM_FN_NAME (or1k32bf,l_fl1) },
3047 { OR1K32BF_INSN_L_ANDI, SEM_FN_NAME (or1k32bf,l_andi) },
3048 { OR1K32BF_INSN_L_ORI, SEM_FN_NAME (or1k32bf,l_ori) },
3049 { OR1K32BF_INSN_L_XORI, SEM_FN_NAME (or1k32bf,l_xori) },
3050 { OR1K32BF_INSN_L_ADDI, SEM_FN_NAME (or1k32bf,l_addi) },
3051 { OR1K32BF_INSN_L_ADDIC, SEM_FN_NAME (or1k32bf,l_addic) },
3052 { OR1K32BF_INSN_L_MULI, SEM_FN_NAME (or1k32bf,l_muli) },
3053 { OR1K32BF_INSN_L_EXTHS, SEM_FN_NAME (or1k32bf,l_exths) },
3054 { OR1K32BF_INSN_L_EXTBS, SEM_FN_NAME (or1k32bf,l_extbs) },
3055 { OR1K32BF_INSN_L_EXTHZ, SEM_FN_NAME (or1k32bf,l_exthz) },
3056 { OR1K32BF_INSN_L_EXTBZ, SEM_FN_NAME (or1k32bf,l_extbz) },
3057 { OR1K32BF_INSN_L_EXTWS, SEM_FN_NAME (or1k32bf,l_extws) },
3058 { OR1K32BF_INSN_L_EXTWZ, SEM_FN_NAME (or1k32bf,l_extwz) },
3059 { OR1K32BF_INSN_L_CMOV, SEM_FN_NAME (or1k32bf,l_cmov) },
3060 { OR1K32BF_INSN_L_SFGTS, SEM_FN_NAME (or1k32bf,l_sfgts) },
3061 { OR1K32BF_INSN_L_SFGTSI, SEM_FN_NAME (or1k32bf,l_sfgtsi) },
3062 { OR1K32BF_INSN_L_SFGTU, SEM_FN_NAME (or1k32bf,l_sfgtu) },
3063 { OR1K32BF_INSN_L_SFGTUI, SEM_FN_NAME (or1k32bf,l_sfgtui) },
3064 { OR1K32BF_INSN_L_SFGES, SEM_FN_NAME (or1k32bf,l_sfges) },
3065 { OR1K32BF_INSN_L_SFGESI, SEM_FN_NAME (or1k32bf,l_sfgesi) },
3066 { OR1K32BF_INSN_L_SFGEU, SEM_FN_NAME (or1k32bf,l_sfgeu) },
3067 { OR1K32BF_INSN_L_SFGEUI, SEM_FN_NAME (or1k32bf,l_sfgeui) },
3068 { OR1K32BF_INSN_L_SFLTS, SEM_FN_NAME (or1k32bf,l_sflts) },
3069 { OR1K32BF_INSN_L_SFLTSI, SEM_FN_NAME (or1k32bf,l_sfltsi) },
3070 { OR1K32BF_INSN_L_SFLTU, SEM_FN_NAME (or1k32bf,l_sfltu) },
3071 { OR1K32BF_INSN_L_SFLTUI, SEM_FN_NAME (or1k32bf,l_sfltui) },
3072 { OR1K32BF_INSN_L_SFLES, SEM_FN_NAME (or1k32bf,l_sfles) },
3073 { OR1K32BF_INSN_L_SFLESI, SEM_FN_NAME (or1k32bf,l_sflesi) },
3074 { OR1K32BF_INSN_L_SFLEU, SEM_FN_NAME (or1k32bf,l_sfleu) },
3075 { OR1K32BF_INSN_L_SFLEUI, SEM_FN_NAME (or1k32bf,l_sfleui) },
3076 { OR1K32BF_INSN_L_SFEQ, SEM_FN_NAME (or1k32bf,l_sfeq) },
3077 { OR1K32BF_INSN_L_SFEQI, SEM_FN_NAME (or1k32bf,l_sfeqi) },
3078 { OR1K32BF_INSN_L_SFNE, SEM_FN_NAME (or1k32bf,l_sfne) },
3079 { OR1K32BF_INSN_L_SFNEI, SEM_FN_NAME (or1k32bf,l_sfnei) },
3080 { OR1K32BF_INSN_L_MAC, SEM_FN_NAME (or1k32bf,l_mac) },
3081 { OR1K32BF_INSN_L_MACI, SEM_FN_NAME (or1k32bf,l_maci) },
3082 { OR1K32BF_INSN_L_MACU, SEM_FN_NAME (or1k32bf,l_macu) },
3083 { OR1K32BF_INSN_L_MSB, SEM_FN_NAME (or1k32bf,l_msb) },
3084 { OR1K32BF_INSN_L_MSBU, SEM_FN_NAME (or1k32bf,l_msbu) },
3085 { OR1K32BF_INSN_L_CUST1, SEM_FN_NAME (or1k32bf,l_cust1) },
3086 { OR1K32BF_INSN_L_CUST2, SEM_FN_NAME (or1k32bf,l_cust2) },
3087 { OR1K32BF_INSN_L_CUST3, SEM_FN_NAME (or1k32bf,l_cust3) },
3088 { OR1K32BF_INSN_L_CUST4, SEM_FN_NAME (or1k32bf,l_cust4) },
3089 { OR1K32BF_INSN_L_CUST5, SEM_FN_NAME (or1k32bf,l_cust5) },
3090 { OR1K32BF_INSN_L_CUST6, SEM_FN_NAME (or1k32bf,l_cust6) },
3091 { OR1K32BF_INSN_L_CUST7, SEM_FN_NAME (or1k32bf,l_cust7) },
3092 { OR1K32BF_INSN_L_CUST8, SEM_FN_NAME (or1k32bf,l_cust8) },
3093 { OR1K32BF_INSN_LF_ADD_S, SEM_FN_NAME (or1k32bf,lf_add_s) },
3094 { OR1K32BF_INSN_LF_SUB_S, SEM_FN_NAME (or1k32bf,lf_sub_s) },
3095 { OR1K32BF_INSN_LF_MUL_S, SEM_FN_NAME (or1k32bf,lf_mul_s) },
3096 { OR1K32BF_INSN_LF_DIV_S, SEM_FN_NAME (or1k32bf,lf_div_s) },
3097 { OR1K32BF_INSN_LF_REM_S, SEM_FN_NAME (or1k32bf,lf_rem_s) },
3098 { OR1K32BF_INSN_LF_ITOF_S, SEM_FN_NAME (or1k32bf,lf_itof_s) },
3099 { OR1K32BF_INSN_LF_FTOI_S, SEM_FN_NAME (or1k32bf,lf_ftoi_s) },
3100 { OR1K32BF_INSN_LF_EQ_S, SEM_FN_NAME (or1k32bf,lf_eq_s) },
3101 { OR1K32BF_INSN_LF_NE_S, SEM_FN_NAME (or1k32bf,lf_ne_s) },
3102 { OR1K32BF_INSN_LF_GE_S, SEM_FN_NAME (or1k32bf,lf_ge_s) },
3103 { OR1K32BF_INSN_LF_GT_S, SEM_FN_NAME (or1k32bf,lf_gt_s) },
3104 { OR1K32BF_INSN_LF_LT_S, SEM_FN_NAME (or1k32bf,lf_lt_s) },
3105 { OR1K32BF_INSN_LF_LE_S, SEM_FN_NAME (or1k32bf,lf_le_s) },
3106 { OR1K32BF_INSN_LF_MADD_S, SEM_FN_NAME (or1k32bf,lf_madd_s) },
3107 { OR1K32BF_INSN_LF_CUST1_S, SEM_FN_NAME (or1k32bf,lf_cust1_s) },
3108 { 0, 0 }
3111 /* Add the semantic fns to IDESC_TABLE. */
3113 void
3114 SEM_FN_NAME (or1k32bf,init_idesc_table) (SIM_CPU *current_cpu)
3116 IDESC *idesc_table = CPU_IDESC (current_cpu);
3117 const struct sem_fn_desc *sf;
3118 int mach_num = MACH_NUM (CPU_MACH (current_cpu));
3120 for (sf = &sem_fns[0]; sf->fn != 0; ++sf)
3122 const CGEN_INSN *insn = idesc_table[sf->index].idata;
3123 int valid_p = (CGEN_INSN_VIRTUAL_P (insn)
3124 || CGEN_INSN_MACH_HAS_P (insn, mach_num));
3125 #if FAST_P
3126 if (valid_p)
3127 idesc_table[sf->index].sem_fast = sf->fn;
3128 else
3129 idesc_table[sf->index].sem_fast = SEM_FN_NAME (or1k32bf,x_invalid);
3130 #else
3131 if (valid_p)
3132 idesc_table[sf->index].sem_full = sf->fn;
3133 else
3134 idesc_table[sf->index].sem_full = SEM_FN_NAME (or1k32bf,x_invalid);
3135 #endif