1 /* Simulator instruction semantics for lm32bf.
3 THIS FILE IS MACHINE GENERATED WITH CGEN.
5 Copyright 1996-2010 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)
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 lm32bf
26 #define WANT_CPU_LM32BF
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. */
39 #define SEM_FN_NAME(cpu,fn) XCONCAT3 (cpu,_semf_,fn)
41 #define TRACE_RESULT(cpu, abuf, name, type, val)
43 #define SEM_FN_NAME(cpu,fn) XCONCAT3 (cpu,_sem_,fn)
46 /* x-invalid: --invalid-- */
49 SEM_FN_NAME (lm32bf
,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 .... */
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
);
73 /* x-after: --after-- */
76 SEM_FN_NAME (lm32bf
,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_LM32BF
86 lm32bf_pbb_after (current_cpu
, sem_arg
);
94 /* x-before: --before-- */
97 SEM_FN_NAME (lm32bf
,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_LM32BF
107 lm32bf_pbb_before (current_cpu
, sem_arg
);
115 /* x-cti-chain: --cti-chain-- */
118 SEM_FN_NAME (lm32bf
,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_LM32BF
129 vpc
= lm32bf_pbb_cti_chain (current_cpu
, sem_arg
,
130 pbb_br_type
, pbb_br_npc
);
133 /* FIXME: Allow provision of explicit ifmt spec in insn spec. */
134 vpc
= lm32bf_pbb_cti_chain (current_cpu
, sem_arg
,
135 CPU_PBB_BR_TYPE (current_cpu
),
136 CPU_PBB_BR_NPC (current_cpu
));
145 /* x-chain: --chain-- */
148 SEM_FN_NAME (lm32bf
,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_LM32BF
158 vpc
= lm32bf_pbb_chain (current_cpu
, sem_arg
);
169 /* x-begin: --begin-- */
172 SEM_FN_NAME (lm32bf
,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_LM32BF
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
= lm32bf_pbb_begin (current_cpu
, FAST_P
);
187 #if 0 /* cgen engine can't handle dynamic fast/full switching yet. */
188 vpc
= lm32bf_pbb_begin (current_cpu
, STATE_RUN_FAST_P (CPU_STATE (current_cpu
)));
190 vpc
= lm32bf_pbb_begin (current_cpu
, 0);
200 /* add: add $r2,$r0,$r1 */
203 SEM_FN_NAME (lm32bf
,add
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
205 #define FLD(f) abuf->fields.sfmt_user.f
206 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
207 int UNUSED written
= 0;
208 IADDR UNUSED pc
= abuf
->addr
;
209 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
212 SI opval
= ADDSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]));
213 CPU (h_gr
[FLD (f_r2
)]) = opval
;
214 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
221 /* addi: addi $r1,$r0,$imm */
224 SEM_FN_NAME (lm32bf
,addi
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
226 #define FLD(f) abuf->fields.sfmt_addi.f
227 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
228 int UNUSED written
= 0;
229 IADDR UNUSED pc
= abuf
->addr
;
230 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
233 SI opval
= ADDSI (CPU (h_gr
[FLD (f_r0
)]), EXTHISI (TRUNCSIHI (FLD (f_imm
))));
234 CPU (h_gr
[FLD (f_r1
)]) = opval
;
235 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
242 /* and: and $r2,$r0,$r1 */
245 SEM_FN_NAME (lm32bf
,and) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
247 #define FLD(f) abuf->fields.sfmt_user.f
248 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
249 int UNUSED written
= 0;
250 IADDR UNUSED pc
= abuf
->addr
;
251 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
254 SI opval
= ANDSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]));
255 CPU (h_gr
[FLD (f_r2
)]) = opval
;
256 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
263 /* andi: andi $r1,$r0,$uimm */
266 SEM_FN_NAME (lm32bf
,andi
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
268 #define FLD(f) abuf->fields.sfmt_andi.f
269 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
270 int UNUSED written
= 0;
271 IADDR UNUSED pc
= abuf
->addr
;
272 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
275 SI opval
= ANDSI (CPU (h_gr
[FLD (f_r0
)]), ZEXTSISI (FLD (f_uimm
)));
276 CPU (h_gr
[FLD (f_r1
)]) = opval
;
277 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
284 /* andhii: andhi $r1,$r0,$hi16 */
287 SEM_FN_NAME (lm32bf
,andhii
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
289 #define FLD(f) abuf->fields.sfmt_andi.f
290 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
291 int UNUSED written
= 0;
292 IADDR UNUSED pc
= abuf
->addr
;
293 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
296 SI opval
= ANDSI (CPU (h_gr
[FLD (f_r0
)]), SLLSI (FLD (f_uimm
), 16));
297 CPU (h_gr
[FLD (f_r1
)]) = opval
;
298 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
308 SEM_FN_NAME (lm32bf
,b
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
310 #define FLD(f) abuf->fields.sfmt_be.f
311 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
312 int UNUSED written
= 0;
313 IADDR UNUSED pc
= abuf
->addr
;
315 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
318 USI opval
= lm32bf_b_insn (current_cpu
, CPU (h_gr
[FLD (f_r0
)]), FLD (f_r0
));
319 SEM_BRANCH_VIA_ADDR (current_cpu
, sem_arg
, opval
, vpc
);
320 TRACE_RESULT (current_cpu
, abuf
, "pc", 'x', opval
);
323 SEM_BRANCH_FINI (vpc
);
331 SEM_FN_NAME (lm32bf
,bi
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
333 #define FLD(f) abuf->fields.sfmt_bi.f
334 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
335 int UNUSED written
= 0;
336 IADDR UNUSED pc
= abuf
->addr
;
338 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
341 USI opval
= EXTSISI (FLD (i_call
));
342 SEM_BRANCH_VIA_ADDR (current_cpu
, sem_arg
, opval
, vpc
);
343 TRACE_RESULT (current_cpu
, abuf
, "pc", 'x', opval
);
346 SEM_BRANCH_FINI (vpc
);
351 /* be: be $r0,$r1,$branch */
354 SEM_FN_NAME (lm32bf
,be
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
356 #define FLD(f) abuf->fields.sfmt_be.f
357 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
358 int UNUSED written
= 0;
359 IADDR UNUSED pc
= abuf
->addr
;
361 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
363 if (EQSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]))) {
365 USI opval
= FLD (i_branch
);
366 SEM_BRANCH_VIA_CACHE (current_cpu
, sem_arg
, opval
, vpc
);
368 TRACE_RESULT (current_cpu
, abuf
, "pc", 'x', opval
);
372 abuf
->written
= written
;
373 SEM_BRANCH_FINI (vpc
);
378 /* bg: bg $r0,$r1,$branch */
381 SEM_FN_NAME (lm32bf
,bg
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
383 #define FLD(f) abuf->fields.sfmt_be.f
384 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
385 int UNUSED written
= 0;
386 IADDR UNUSED pc
= abuf
->addr
;
388 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
390 if (GTSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]))) {
392 USI opval
= FLD (i_branch
);
393 SEM_BRANCH_VIA_CACHE (current_cpu
, sem_arg
, opval
, vpc
);
395 TRACE_RESULT (current_cpu
, abuf
, "pc", 'x', opval
);
399 abuf
->written
= written
;
400 SEM_BRANCH_FINI (vpc
);
405 /* bge: bge $r0,$r1,$branch */
408 SEM_FN_NAME (lm32bf
,bge
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
410 #define FLD(f) abuf->fields.sfmt_be.f
411 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
412 int UNUSED written
= 0;
413 IADDR UNUSED pc
= abuf
->addr
;
415 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
417 if (GESI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]))) {
419 USI opval
= FLD (i_branch
);
420 SEM_BRANCH_VIA_CACHE (current_cpu
, sem_arg
, opval
, vpc
);
422 TRACE_RESULT (current_cpu
, abuf
, "pc", 'x', opval
);
426 abuf
->written
= written
;
427 SEM_BRANCH_FINI (vpc
);
432 /* bgeu: bgeu $r0,$r1,$branch */
435 SEM_FN_NAME (lm32bf
,bgeu
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
437 #define FLD(f) abuf->fields.sfmt_be.f
438 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
439 int UNUSED written
= 0;
440 IADDR UNUSED pc
= abuf
->addr
;
442 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
444 if (GEUSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]))) {
446 USI opval
= FLD (i_branch
);
447 SEM_BRANCH_VIA_CACHE (current_cpu
, sem_arg
, opval
, vpc
);
449 TRACE_RESULT (current_cpu
, abuf
, "pc", 'x', opval
);
453 abuf
->written
= written
;
454 SEM_BRANCH_FINI (vpc
);
459 /* bgu: bgu $r0,$r1,$branch */
462 SEM_FN_NAME (lm32bf
,bgu
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
464 #define FLD(f) abuf->fields.sfmt_be.f
465 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
466 int UNUSED written
= 0;
467 IADDR UNUSED pc
= abuf
->addr
;
469 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
471 if (GTUSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]))) {
473 USI opval
= FLD (i_branch
);
474 SEM_BRANCH_VIA_CACHE (current_cpu
, sem_arg
, opval
, vpc
);
476 TRACE_RESULT (current_cpu
, abuf
, "pc", 'x', opval
);
480 abuf
->written
= written
;
481 SEM_BRANCH_FINI (vpc
);
486 /* bne: bne $r0,$r1,$branch */
489 SEM_FN_NAME (lm32bf
,bne
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
491 #define FLD(f) abuf->fields.sfmt_be.f
492 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
493 int UNUSED written
= 0;
494 IADDR UNUSED pc
= abuf
->addr
;
496 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
498 if (NESI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]))) {
500 USI opval
= FLD (i_branch
);
501 SEM_BRANCH_VIA_CACHE (current_cpu
, sem_arg
, opval
, vpc
);
503 TRACE_RESULT (current_cpu
, abuf
, "pc", 'x', opval
);
507 abuf
->written
= written
;
508 SEM_BRANCH_FINI (vpc
);
516 SEM_FN_NAME (lm32bf
,call
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
518 #define FLD(f) abuf->fields.sfmt_be.f
519 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
520 int UNUSED written
= 0;
521 IADDR UNUSED pc
= abuf
->addr
;
523 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
527 SI opval
= ADDSI (pc
, 4);
528 CPU (h_gr
[((UINT
) 29)]) = opval
;
529 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
532 USI opval
= CPU (h_gr
[FLD (f_r0
)]);
533 SEM_BRANCH_VIA_ADDR (current_cpu
, sem_arg
, opval
, vpc
);
534 TRACE_RESULT (current_cpu
, abuf
, "pc", 'x', opval
);
538 SEM_BRANCH_FINI (vpc
);
543 /* calli: calli $call */
546 SEM_FN_NAME (lm32bf
,calli
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
548 #define FLD(f) abuf->fields.sfmt_bi.f
549 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
550 int UNUSED written
= 0;
551 IADDR UNUSED pc
= abuf
->addr
;
553 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
557 SI opval
= ADDSI (pc
, 4);
558 CPU (h_gr
[((UINT
) 29)]) = opval
;
559 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
562 USI opval
= EXTSISI (FLD (i_call
));
563 SEM_BRANCH_VIA_ADDR (current_cpu
, sem_arg
, opval
, vpc
);
564 TRACE_RESULT (current_cpu
, abuf
, "pc", 'x', opval
);
568 SEM_BRANCH_FINI (vpc
);
573 /* cmpe: cmpe $r2,$r0,$r1 */
576 SEM_FN_NAME (lm32bf
,cmpe
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
578 #define FLD(f) abuf->fields.sfmt_user.f
579 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
580 int UNUSED written
= 0;
581 IADDR UNUSED pc
= abuf
->addr
;
582 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
585 SI opval
= EQSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]));
586 CPU (h_gr
[FLD (f_r2
)]) = opval
;
587 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
594 /* cmpei: cmpei $r1,$r0,$imm */
597 SEM_FN_NAME (lm32bf
,cmpei
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
599 #define FLD(f) abuf->fields.sfmt_addi.f
600 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
601 int UNUSED written
= 0;
602 IADDR UNUSED pc
= abuf
->addr
;
603 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
606 SI opval
= EQSI (CPU (h_gr
[FLD (f_r0
)]), EXTHISI (TRUNCSIHI (FLD (f_imm
))));
607 CPU (h_gr
[FLD (f_r1
)]) = opval
;
608 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
615 /* cmpg: cmpg $r2,$r0,$r1 */
618 SEM_FN_NAME (lm32bf
,cmpg
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
620 #define FLD(f) abuf->fields.sfmt_user.f
621 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
622 int UNUSED written
= 0;
623 IADDR UNUSED pc
= abuf
->addr
;
624 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
627 SI opval
= GTSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]));
628 CPU (h_gr
[FLD (f_r2
)]) = opval
;
629 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
636 /* cmpgi: cmpgi $r1,$r0,$imm */
639 SEM_FN_NAME (lm32bf
,cmpgi
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
641 #define FLD(f) abuf->fields.sfmt_addi.f
642 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
643 int UNUSED written
= 0;
644 IADDR UNUSED pc
= abuf
->addr
;
645 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
648 SI opval
= GTSI (CPU (h_gr
[FLD (f_r0
)]), EXTHISI (TRUNCSIHI (FLD (f_imm
))));
649 CPU (h_gr
[FLD (f_r1
)]) = opval
;
650 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
657 /* cmpge: cmpge $r2,$r0,$r1 */
660 SEM_FN_NAME (lm32bf
,cmpge
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
662 #define FLD(f) abuf->fields.sfmt_user.f
663 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
664 int UNUSED written
= 0;
665 IADDR UNUSED pc
= abuf
->addr
;
666 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
669 SI opval
= GESI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]));
670 CPU (h_gr
[FLD (f_r2
)]) = opval
;
671 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
678 /* cmpgei: cmpgei $r1,$r0,$imm */
681 SEM_FN_NAME (lm32bf
,cmpgei
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
683 #define FLD(f) abuf->fields.sfmt_addi.f
684 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
685 int UNUSED written
= 0;
686 IADDR UNUSED pc
= abuf
->addr
;
687 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
690 SI opval
= GESI (CPU (h_gr
[FLD (f_r0
)]), EXTHISI (TRUNCSIHI (FLD (f_imm
))));
691 CPU (h_gr
[FLD (f_r1
)]) = opval
;
692 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
699 /* cmpgeu: cmpgeu $r2,$r0,$r1 */
702 SEM_FN_NAME (lm32bf
,cmpgeu
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
704 #define FLD(f) abuf->fields.sfmt_user.f
705 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
706 int UNUSED written
= 0;
707 IADDR UNUSED pc
= abuf
->addr
;
708 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
711 SI opval
= GEUSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]));
712 CPU (h_gr
[FLD (f_r2
)]) = opval
;
713 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
720 /* cmpgeui: cmpgeui $r1,$r0,$uimm */
723 SEM_FN_NAME (lm32bf
,cmpgeui
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
725 #define FLD(f) abuf->fields.sfmt_andi.f
726 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
727 int UNUSED written
= 0;
728 IADDR UNUSED pc
= abuf
->addr
;
729 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
732 SI opval
= GEUSI (CPU (h_gr
[FLD (f_r0
)]), ZEXTSISI (FLD (f_uimm
)));
733 CPU (h_gr
[FLD (f_r1
)]) = opval
;
734 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
741 /* cmpgu: cmpgu $r2,$r0,$r1 */
744 SEM_FN_NAME (lm32bf
,cmpgu
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
746 #define FLD(f) abuf->fields.sfmt_user.f
747 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
748 int UNUSED written
= 0;
749 IADDR UNUSED pc
= abuf
->addr
;
750 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
753 SI opval
= GTUSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]));
754 CPU (h_gr
[FLD (f_r2
)]) = opval
;
755 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
762 /* cmpgui: cmpgui $r1,$r0,$uimm */
765 SEM_FN_NAME (lm32bf
,cmpgui
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
767 #define FLD(f) abuf->fields.sfmt_andi.f
768 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
769 int UNUSED written
= 0;
770 IADDR UNUSED pc
= abuf
->addr
;
771 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
774 SI opval
= GTUSI (CPU (h_gr
[FLD (f_r0
)]), ZEXTSISI (FLD (f_uimm
)));
775 CPU (h_gr
[FLD (f_r1
)]) = opval
;
776 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
783 /* cmpne: cmpne $r2,$r0,$r1 */
786 SEM_FN_NAME (lm32bf
,cmpne
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
788 #define FLD(f) abuf->fields.sfmt_user.f
789 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
790 int UNUSED written
= 0;
791 IADDR UNUSED pc
= abuf
->addr
;
792 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
795 SI opval
= NESI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]));
796 CPU (h_gr
[FLD (f_r2
)]) = opval
;
797 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
804 /* cmpnei: cmpnei $r1,$r0,$imm */
807 SEM_FN_NAME (lm32bf
,cmpnei
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
809 #define FLD(f) abuf->fields.sfmt_addi.f
810 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
811 int UNUSED written
= 0;
812 IADDR UNUSED pc
= abuf
->addr
;
813 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
816 SI opval
= NESI (CPU (h_gr
[FLD (f_r0
)]), EXTHISI (TRUNCSIHI (FLD (f_imm
))));
817 CPU (h_gr
[FLD (f_r1
)]) = opval
;
818 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
825 /* divu: divu $r2,$r0,$r1 */
828 SEM_FN_NAME (lm32bf
,divu
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
830 #define FLD(f) abuf->fields.sfmt_user.f
831 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
832 int UNUSED written
= 0;
833 IADDR UNUSED pc
= abuf
->addr
;
835 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
838 USI opval
= lm32bf_divu_insn (current_cpu
, pc
, FLD (f_r0
), FLD (f_r1
), FLD (f_r2
));
839 SEM_BRANCH_VIA_ADDR (current_cpu
, sem_arg
, opval
, vpc
);
840 TRACE_RESULT (current_cpu
, abuf
, "pc", 'x', opval
);
843 SEM_BRANCH_FINI (vpc
);
848 /* lb: lb $r1,($r0+$imm) */
851 SEM_FN_NAME (lm32bf
,lb
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
853 #define FLD(f) abuf->fields.sfmt_addi.f
854 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
855 int UNUSED written
= 0;
856 IADDR UNUSED pc
= abuf
->addr
;
857 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
860 SI opval
= EXTQISI (GETMEMQI (current_cpu
, pc
, ADDSI (CPU (h_gr
[FLD (f_r0
)]), EXTHISI (TRUNCSIHI (FLD (f_imm
))))));
861 CPU (h_gr
[FLD (f_r1
)]) = opval
;
862 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
869 /* lbu: lbu $r1,($r0+$imm) */
872 SEM_FN_NAME (lm32bf
,lbu
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
874 #define FLD(f) abuf->fields.sfmt_addi.f
875 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
876 int UNUSED written
= 0;
877 IADDR UNUSED pc
= abuf
->addr
;
878 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
881 SI opval
= ZEXTQISI (GETMEMQI (current_cpu
, pc
, ADDSI (CPU (h_gr
[FLD (f_r0
)]), EXTHISI (TRUNCSIHI (FLD (f_imm
))))));
882 CPU (h_gr
[FLD (f_r1
)]) = opval
;
883 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
890 /* lh: lh $r1,($r0+$imm) */
893 SEM_FN_NAME (lm32bf
,lh
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
895 #define FLD(f) abuf->fields.sfmt_addi.f
896 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
897 int UNUSED written
= 0;
898 IADDR UNUSED pc
= abuf
->addr
;
899 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
902 SI opval
= EXTHISI (GETMEMHI (current_cpu
, pc
, ADDSI (CPU (h_gr
[FLD (f_r0
)]), EXTHISI (TRUNCSIHI (FLD (f_imm
))))));
903 CPU (h_gr
[FLD (f_r1
)]) = opval
;
904 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
911 /* lhu: lhu $r1,($r0+$imm) */
914 SEM_FN_NAME (lm32bf
,lhu
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
916 #define FLD(f) abuf->fields.sfmt_addi.f
917 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
918 int UNUSED written
= 0;
919 IADDR UNUSED pc
= abuf
->addr
;
920 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
923 SI opval
= ZEXTHISI (GETMEMHI (current_cpu
, pc
, ADDSI (CPU (h_gr
[FLD (f_r0
)]), EXTHISI (TRUNCSIHI (FLD (f_imm
))))));
924 CPU (h_gr
[FLD (f_r1
)]) = opval
;
925 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
932 /* lw: lw $r1,($r0+$imm) */
935 SEM_FN_NAME (lm32bf
,lw
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
937 #define FLD(f) abuf->fields.sfmt_addi.f
938 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
939 int UNUSED written
= 0;
940 IADDR UNUSED pc
= abuf
->addr
;
941 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
944 SI opval
= GETMEMSI (current_cpu
, pc
, ADDSI (CPU (h_gr
[FLD (f_r0
)]), EXTHISI (TRUNCSIHI (FLD (f_imm
)))));
945 CPU (h_gr
[FLD (f_r1
)]) = opval
;
946 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
953 /* modu: modu $r2,$r0,$r1 */
956 SEM_FN_NAME (lm32bf
,modu
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
958 #define FLD(f) abuf->fields.sfmt_user.f
959 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
960 int UNUSED written
= 0;
961 IADDR UNUSED pc
= abuf
->addr
;
963 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
966 USI opval
= lm32bf_modu_insn (current_cpu
, pc
, FLD (f_r0
), FLD (f_r1
), FLD (f_r2
));
967 SEM_BRANCH_VIA_ADDR (current_cpu
, sem_arg
, opval
, vpc
);
968 TRACE_RESULT (current_cpu
, abuf
, "pc", 'x', opval
);
971 SEM_BRANCH_FINI (vpc
);
976 /* mul: mul $r2,$r0,$r1 */
979 SEM_FN_NAME (lm32bf
,mul
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
981 #define FLD(f) abuf->fields.sfmt_user.f
982 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
983 int UNUSED written
= 0;
984 IADDR UNUSED pc
= abuf
->addr
;
985 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
988 SI opval
= MULSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]));
989 CPU (h_gr
[FLD (f_r2
)]) = opval
;
990 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
997 /* muli: muli $r1,$r0,$imm */
1000 SEM_FN_NAME (lm32bf
,muli
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1002 #define FLD(f) abuf->fields.sfmt_addi.f
1003 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1004 int UNUSED written
= 0;
1005 IADDR UNUSED pc
= abuf
->addr
;
1006 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1009 SI opval
= MULSI (CPU (h_gr
[FLD (f_r0
)]), EXTHISI (TRUNCSIHI (FLD (f_imm
))));
1010 CPU (h_gr
[FLD (f_r1
)]) = opval
;
1011 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1018 /* nor: nor $r2,$r0,$r1 */
1021 SEM_FN_NAME (lm32bf
,nor
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1023 #define FLD(f) abuf->fields.sfmt_user.f
1024 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1025 int UNUSED written
= 0;
1026 IADDR UNUSED pc
= abuf
->addr
;
1027 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1030 SI opval
= INVSI (ORSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)])));
1031 CPU (h_gr
[FLD (f_r2
)]) = opval
;
1032 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1039 /* nori: nori $r1,$r0,$uimm */
1042 SEM_FN_NAME (lm32bf
,nori
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1044 #define FLD(f) abuf->fields.sfmt_andi.f
1045 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1046 int UNUSED written
= 0;
1047 IADDR UNUSED pc
= abuf
->addr
;
1048 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1051 SI opval
= INVSI (ORSI (CPU (h_gr
[FLD (f_r0
)]), ZEXTSISI (FLD (f_uimm
))));
1052 CPU (h_gr
[FLD (f_r1
)]) = opval
;
1053 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1060 /* or: or $r2,$r0,$r1 */
1063 SEM_FN_NAME (lm32bf
,or) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1065 #define FLD(f) abuf->fields.sfmt_user.f
1066 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1067 int UNUSED written
= 0;
1068 IADDR UNUSED pc
= abuf
->addr
;
1069 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1072 SI opval
= ORSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]));
1073 CPU (h_gr
[FLD (f_r2
)]) = opval
;
1074 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1081 /* ori: ori $r1,$r0,$lo16 */
1084 SEM_FN_NAME (lm32bf
,ori
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1086 #define FLD(f) abuf->fields.sfmt_andi.f
1087 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1088 int UNUSED written
= 0;
1089 IADDR UNUSED pc
= abuf
->addr
;
1090 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1093 SI opval
= ORSI (CPU (h_gr
[FLD (f_r0
)]), ZEXTSISI (FLD (f_uimm
)));
1094 CPU (h_gr
[FLD (f_r1
)]) = opval
;
1095 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1102 /* orhii: orhi $r1,$r0,$hi16 */
1105 SEM_FN_NAME (lm32bf
,orhii
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1107 #define FLD(f) abuf->fields.sfmt_andi.f
1108 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1109 int UNUSED written
= 0;
1110 IADDR UNUSED pc
= abuf
->addr
;
1111 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1114 SI opval
= ORSI (CPU (h_gr
[FLD (f_r0
)]), SLLSI (FLD (f_uimm
), 16));
1115 CPU (h_gr
[FLD (f_r1
)]) = opval
;
1116 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1123 /* rcsr: rcsr $r2,$csr */
1126 SEM_FN_NAME (lm32bf
,rcsr
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1128 #define FLD(f) abuf->fields.sfmt_rcsr.f
1129 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1130 int UNUSED written
= 0;
1131 IADDR UNUSED pc
= abuf
->addr
;
1132 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1135 SI opval
= CPU (h_csr
[FLD (f_csr
)]);
1136 CPU (h_gr
[FLD (f_r2
)]) = opval
;
1137 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1144 /* sb: sb ($r0+$imm),$r1 */
1147 SEM_FN_NAME (lm32bf
,sb
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1149 #define FLD(f) abuf->fields.sfmt_addi.f
1150 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1151 int UNUSED written
= 0;
1152 IADDR UNUSED pc
= abuf
->addr
;
1153 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1156 QI opval
= CPU (h_gr
[FLD (f_r1
)]);
1157 SETMEMQI (current_cpu
, pc
, ADDSI (CPU (h_gr
[FLD (f_r0
)]), EXTHISI (TRUNCSIHI (FLD (f_imm
)))), opval
);
1158 TRACE_RESULT (current_cpu
, abuf
, "memory", 'x', opval
);
1165 /* sextb: sextb $r2,$r0 */
1168 SEM_FN_NAME (lm32bf
,sextb
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1170 #define FLD(f) abuf->fields.sfmt_user.f
1171 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1172 int UNUSED written
= 0;
1173 IADDR UNUSED pc
= abuf
->addr
;
1174 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1177 SI opval
= EXTQISI (TRUNCSIQI (CPU (h_gr
[FLD (f_r0
)])));
1178 CPU (h_gr
[FLD (f_r2
)]) = opval
;
1179 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1186 /* sexth: sexth $r2,$r0 */
1189 SEM_FN_NAME (lm32bf
,sexth
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1191 #define FLD(f) abuf->fields.sfmt_user.f
1192 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1193 int UNUSED written
= 0;
1194 IADDR UNUSED pc
= abuf
->addr
;
1195 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1198 SI opval
= EXTHISI (TRUNCSIHI (CPU (h_gr
[FLD (f_r0
)])));
1199 CPU (h_gr
[FLD (f_r2
)]) = opval
;
1200 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1207 /* sh: sh ($r0+$imm),$r1 */
1210 SEM_FN_NAME (lm32bf
,sh
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1212 #define FLD(f) abuf->fields.sfmt_addi.f
1213 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1214 int UNUSED written
= 0;
1215 IADDR UNUSED pc
= abuf
->addr
;
1216 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1219 HI opval
= CPU (h_gr
[FLD (f_r1
)]);
1220 SETMEMHI (current_cpu
, pc
, ADDSI (CPU (h_gr
[FLD (f_r0
)]), EXTHISI (TRUNCSIHI (FLD (f_imm
)))), opval
);
1221 TRACE_RESULT (current_cpu
, abuf
, "memory", 'x', opval
);
1228 /* sl: sl $r2,$r0,$r1 */
1231 SEM_FN_NAME (lm32bf
,sl
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1233 #define FLD(f) abuf->fields.sfmt_user.f
1234 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1235 int UNUSED written
= 0;
1236 IADDR UNUSED pc
= abuf
->addr
;
1237 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1240 SI opval
= SLLSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]));
1241 CPU (h_gr
[FLD (f_r2
)]) = opval
;
1242 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1249 /* sli: sli $r1,$r0,$imm */
1252 SEM_FN_NAME (lm32bf
,sli
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1254 #define FLD(f) abuf->fields.sfmt_addi.f
1255 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1256 int UNUSED written
= 0;
1257 IADDR UNUSED pc
= abuf
->addr
;
1258 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1261 SI opval
= SLLSI (CPU (h_gr
[FLD (f_r0
)]), FLD (f_imm
));
1262 CPU (h_gr
[FLD (f_r1
)]) = opval
;
1263 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1270 /* sr: sr $r2,$r0,$r1 */
1273 SEM_FN_NAME (lm32bf
,sr
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1275 #define FLD(f) abuf->fields.sfmt_user.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);
1282 SI opval
= SRASI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]));
1283 CPU (h_gr
[FLD (f_r2
)]) = opval
;
1284 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1291 /* sri: sri $r1,$r0,$imm */
1294 SEM_FN_NAME (lm32bf
,sri
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1296 #define FLD(f) abuf->fields.sfmt_addi.f
1297 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1298 int UNUSED written
= 0;
1299 IADDR UNUSED pc
= abuf
->addr
;
1300 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1303 SI opval
= SRASI (CPU (h_gr
[FLD (f_r0
)]), FLD (f_imm
));
1304 CPU (h_gr
[FLD (f_r1
)]) = opval
;
1305 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1312 /* sru: sru $r2,$r0,$r1 */
1315 SEM_FN_NAME (lm32bf
,sru
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1317 #define FLD(f) abuf->fields.sfmt_user.f
1318 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1319 int UNUSED written
= 0;
1320 IADDR UNUSED pc
= abuf
->addr
;
1321 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1324 SI opval
= SRLSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]));
1325 CPU (h_gr
[FLD (f_r2
)]) = opval
;
1326 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1333 /* srui: srui $r1,$r0,$imm */
1336 SEM_FN_NAME (lm32bf
,srui
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1338 #define FLD(f) abuf->fields.sfmt_addi.f
1339 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1340 int UNUSED written
= 0;
1341 IADDR UNUSED pc
= abuf
->addr
;
1342 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1345 SI opval
= SRLSI (CPU (h_gr
[FLD (f_r0
)]), FLD (f_imm
));
1346 CPU (h_gr
[FLD (f_r1
)]) = opval
;
1347 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1354 /* sub: sub $r2,$r0,$r1 */
1357 SEM_FN_NAME (lm32bf
,sub
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1359 #define FLD(f) abuf->fields.sfmt_user.f
1360 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1361 int UNUSED written
= 0;
1362 IADDR UNUSED pc
= abuf
->addr
;
1363 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1366 SI opval
= SUBSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]));
1367 CPU (h_gr
[FLD (f_r2
)]) = opval
;
1368 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1375 /* sw: sw ($r0+$imm),$r1 */
1378 SEM_FN_NAME (lm32bf
,sw
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1380 #define FLD(f) abuf->fields.sfmt_addi.f
1381 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1382 int UNUSED written
= 0;
1383 IADDR UNUSED pc
= abuf
->addr
;
1384 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1387 SI opval
= CPU (h_gr
[FLD (f_r1
)]);
1388 SETMEMSI (current_cpu
, pc
, ADDSI (CPU (h_gr
[FLD (f_r0
)]), EXTHISI (TRUNCSIHI (FLD (f_imm
)))), opval
);
1389 TRACE_RESULT (current_cpu
, abuf
, "memory", 'x', opval
);
1396 /* user: user $r2,$r0,$r1,$user */
1399 SEM_FN_NAME (lm32bf
,user
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1401 #define FLD(f) abuf->fields.sfmt_user.f
1402 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1403 int UNUSED written
= 0;
1404 IADDR UNUSED pc
= abuf
->addr
;
1405 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1408 SI opval
= lm32bf_user_insn (current_cpu
, CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]), FLD (f_user
));
1409 CPU (h_gr
[FLD (f_r2
)]) = opval
;
1410 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1417 /* wcsr: wcsr $csr,$r1 */
1420 SEM_FN_NAME (lm32bf
,wcsr
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1422 #define FLD(f) abuf->fields.sfmt_wcsr.f
1423 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1424 int UNUSED written
= 0;
1425 IADDR UNUSED pc
= abuf
->addr
;
1426 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1428 lm32bf_wcsr_insn (current_cpu
, FLD (f_csr
), CPU (h_gr
[FLD (f_r1
)]));
1434 /* xor: xor $r2,$r0,$r1 */
1437 SEM_FN_NAME (lm32bf
,xor) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1439 #define FLD(f) abuf->fields.sfmt_user.f
1440 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1441 int UNUSED written
= 0;
1442 IADDR UNUSED pc
= abuf
->addr
;
1443 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1446 SI opval
= XORSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]));
1447 CPU (h_gr
[FLD (f_r2
)]) = opval
;
1448 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1455 /* xori: xori $r1,$r0,$uimm */
1458 SEM_FN_NAME (lm32bf
,xori
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1460 #define FLD(f) abuf->fields.sfmt_andi.f
1461 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1462 int UNUSED written
= 0;
1463 IADDR UNUSED pc
= abuf
->addr
;
1464 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1467 SI opval
= XORSI (CPU (h_gr
[FLD (f_r0
)]), ZEXTSISI (FLD (f_uimm
)));
1468 CPU (h_gr
[FLD (f_r1
)]) = opval
;
1469 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1476 /* xnor: xnor $r2,$r0,$r1 */
1479 SEM_FN_NAME (lm32bf
,xnor
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1481 #define FLD(f) abuf->fields.sfmt_user.f
1482 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1483 int UNUSED written
= 0;
1484 IADDR UNUSED pc
= abuf
->addr
;
1485 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1488 SI opval
= INVSI (XORSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)])));
1489 CPU (h_gr
[FLD (f_r2
)]) = opval
;
1490 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1497 /* xnori: xnori $r1,$r0,$uimm */
1500 SEM_FN_NAME (lm32bf
,xnori
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1502 #define FLD(f) abuf->fields.sfmt_andi.f
1503 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1504 int UNUSED written
= 0;
1505 IADDR UNUSED pc
= abuf
->addr
;
1506 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1509 SI opval
= INVSI (XORSI (CPU (h_gr
[FLD (f_r0
)]), ZEXTSISI (FLD (f_uimm
))));
1510 CPU (h_gr
[FLD (f_r1
)]) = opval
;
1511 TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1521 SEM_FN_NAME (lm32bf
,break) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1523 #define FLD(f) abuf->fields.sfmt_empty.f
1524 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1525 int UNUSED written
= 0;
1526 IADDR UNUSED pc
= abuf
->addr
;
1528 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1531 USI opval
= lm32bf_break_insn (current_cpu
, pc
);
1532 SEM_BRANCH_VIA_ADDR (current_cpu
, sem_arg
, opval
, vpc
);
1533 TRACE_RESULT (current_cpu
, abuf
, "pc", 'x', opval
);
1536 SEM_BRANCH_FINI (vpc
);
1544 SEM_FN_NAME (lm32bf
,scall
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1546 #define FLD(f) abuf->fields.sfmt_empty.f
1547 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1548 int UNUSED written
= 0;
1549 IADDR UNUSED pc
= abuf
->addr
;
1551 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1554 USI opval
= lm32bf_scall_insn (current_cpu
, pc
);
1555 SEM_BRANCH_VIA_ADDR (current_cpu
, sem_arg
, opval
, vpc
);
1556 TRACE_RESULT (current_cpu
, abuf
, "pc", 'x', opval
);
1559 SEM_BRANCH_FINI (vpc
);
1564 /* Table of all semantic fns. */
1566 static const struct sem_fn_desc sem_fns
[] = {
1567 { LM32BF_INSN_X_INVALID
, SEM_FN_NAME (lm32bf
,x_invalid
) },
1568 { LM32BF_INSN_X_AFTER
, SEM_FN_NAME (lm32bf
,x_after
) },
1569 { LM32BF_INSN_X_BEFORE
, SEM_FN_NAME (lm32bf
,x_before
) },
1570 { LM32BF_INSN_X_CTI_CHAIN
, SEM_FN_NAME (lm32bf
,x_cti_chain
) },
1571 { LM32BF_INSN_X_CHAIN
, SEM_FN_NAME (lm32bf
,x_chain
) },
1572 { LM32BF_INSN_X_BEGIN
, SEM_FN_NAME (lm32bf
,x_begin
) },
1573 { LM32BF_INSN_ADD
, SEM_FN_NAME (lm32bf
,add
) },
1574 { LM32BF_INSN_ADDI
, SEM_FN_NAME (lm32bf
,addi
) },
1575 { LM32BF_INSN_AND
, SEM_FN_NAME (lm32bf
,and) },
1576 { LM32BF_INSN_ANDI
, SEM_FN_NAME (lm32bf
,andi
) },
1577 { LM32BF_INSN_ANDHII
, SEM_FN_NAME (lm32bf
,andhii
) },
1578 { LM32BF_INSN_B
, SEM_FN_NAME (lm32bf
,b
) },
1579 { LM32BF_INSN_BI
, SEM_FN_NAME (lm32bf
,bi
) },
1580 { LM32BF_INSN_BE
, SEM_FN_NAME (lm32bf
,be
) },
1581 { LM32BF_INSN_BG
, SEM_FN_NAME (lm32bf
,bg
) },
1582 { LM32BF_INSN_BGE
, SEM_FN_NAME (lm32bf
,bge
) },
1583 { LM32BF_INSN_BGEU
, SEM_FN_NAME (lm32bf
,bgeu
) },
1584 { LM32BF_INSN_BGU
, SEM_FN_NAME (lm32bf
,bgu
) },
1585 { LM32BF_INSN_BNE
, SEM_FN_NAME (lm32bf
,bne
) },
1586 { LM32BF_INSN_CALL
, SEM_FN_NAME (lm32bf
,call
) },
1587 { LM32BF_INSN_CALLI
, SEM_FN_NAME (lm32bf
,calli
) },
1588 { LM32BF_INSN_CMPE
, SEM_FN_NAME (lm32bf
,cmpe
) },
1589 { LM32BF_INSN_CMPEI
, SEM_FN_NAME (lm32bf
,cmpei
) },
1590 { LM32BF_INSN_CMPG
, SEM_FN_NAME (lm32bf
,cmpg
) },
1591 { LM32BF_INSN_CMPGI
, SEM_FN_NAME (lm32bf
,cmpgi
) },
1592 { LM32BF_INSN_CMPGE
, SEM_FN_NAME (lm32bf
,cmpge
) },
1593 { LM32BF_INSN_CMPGEI
, SEM_FN_NAME (lm32bf
,cmpgei
) },
1594 { LM32BF_INSN_CMPGEU
, SEM_FN_NAME (lm32bf
,cmpgeu
) },
1595 { LM32BF_INSN_CMPGEUI
, SEM_FN_NAME (lm32bf
,cmpgeui
) },
1596 { LM32BF_INSN_CMPGU
, SEM_FN_NAME (lm32bf
,cmpgu
) },
1597 { LM32BF_INSN_CMPGUI
, SEM_FN_NAME (lm32bf
,cmpgui
) },
1598 { LM32BF_INSN_CMPNE
, SEM_FN_NAME (lm32bf
,cmpne
) },
1599 { LM32BF_INSN_CMPNEI
, SEM_FN_NAME (lm32bf
,cmpnei
) },
1600 { LM32BF_INSN_DIVU
, SEM_FN_NAME (lm32bf
,divu
) },
1601 { LM32BF_INSN_LB
, SEM_FN_NAME (lm32bf
,lb
) },
1602 { LM32BF_INSN_LBU
, SEM_FN_NAME (lm32bf
,lbu
) },
1603 { LM32BF_INSN_LH
, SEM_FN_NAME (lm32bf
,lh
) },
1604 { LM32BF_INSN_LHU
, SEM_FN_NAME (lm32bf
,lhu
) },
1605 { LM32BF_INSN_LW
, SEM_FN_NAME (lm32bf
,lw
) },
1606 { LM32BF_INSN_MODU
, SEM_FN_NAME (lm32bf
,modu
) },
1607 { LM32BF_INSN_MUL
, SEM_FN_NAME (lm32bf
,mul
) },
1608 { LM32BF_INSN_MULI
, SEM_FN_NAME (lm32bf
,muli
) },
1609 { LM32BF_INSN_NOR
, SEM_FN_NAME (lm32bf
,nor
) },
1610 { LM32BF_INSN_NORI
, SEM_FN_NAME (lm32bf
,nori
) },
1611 { LM32BF_INSN_OR
, SEM_FN_NAME (lm32bf
,or) },
1612 { LM32BF_INSN_ORI
, SEM_FN_NAME (lm32bf
,ori
) },
1613 { LM32BF_INSN_ORHII
, SEM_FN_NAME (lm32bf
,orhii
) },
1614 { LM32BF_INSN_RCSR
, SEM_FN_NAME (lm32bf
,rcsr
) },
1615 { LM32BF_INSN_SB
, SEM_FN_NAME (lm32bf
,sb
) },
1616 { LM32BF_INSN_SEXTB
, SEM_FN_NAME (lm32bf
,sextb
) },
1617 { LM32BF_INSN_SEXTH
, SEM_FN_NAME (lm32bf
,sexth
) },
1618 { LM32BF_INSN_SH
, SEM_FN_NAME (lm32bf
,sh
) },
1619 { LM32BF_INSN_SL
, SEM_FN_NAME (lm32bf
,sl
) },
1620 { LM32BF_INSN_SLI
, SEM_FN_NAME (lm32bf
,sli
) },
1621 { LM32BF_INSN_SR
, SEM_FN_NAME (lm32bf
,sr
) },
1622 { LM32BF_INSN_SRI
, SEM_FN_NAME (lm32bf
,sri
) },
1623 { LM32BF_INSN_SRU
, SEM_FN_NAME (lm32bf
,sru
) },
1624 { LM32BF_INSN_SRUI
, SEM_FN_NAME (lm32bf
,srui
) },
1625 { LM32BF_INSN_SUB
, SEM_FN_NAME (lm32bf
,sub
) },
1626 { LM32BF_INSN_SW
, SEM_FN_NAME (lm32bf
,sw
) },
1627 { LM32BF_INSN_USER
, SEM_FN_NAME (lm32bf
,user
) },
1628 { LM32BF_INSN_WCSR
, SEM_FN_NAME (lm32bf
,wcsr
) },
1629 { LM32BF_INSN_XOR
, SEM_FN_NAME (lm32bf
,xor) },
1630 { LM32BF_INSN_XORI
, SEM_FN_NAME (lm32bf
,xori
) },
1631 { LM32BF_INSN_XNOR
, SEM_FN_NAME (lm32bf
,xnor
) },
1632 { LM32BF_INSN_XNORI
, SEM_FN_NAME (lm32bf
,xnori
) },
1633 { LM32BF_INSN_BREAK
, SEM_FN_NAME (lm32bf
,break) },
1634 { LM32BF_INSN_SCALL
, SEM_FN_NAME (lm32bf
,scall
) },
1638 /* Add the semantic fns to IDESC_TABLE. */
1641 SEM_FN_NAME (lm32bf
,init_idesc_table
) (SIM_CPU
*current_cpu
)
1643 IDESC
*idesc_table
= CPU_IDESC (current_cpu
);
1644 const struct sem_fn_desc
*sf
;
1645 int mach_num
= MACH_NUM (CPU_MACH (current_cpu
));
1647 for (sf
= &sem_fns
[0]; sf
->fn
!= 0; ++sf
)
1649 const CGEN_INSN
*insn
= idesc_table
[sf
->index
].idata
;
1650 int valid_p
= (CGEN_INSN_VIRTUAL_P (insn
)
1651 || CGEN_INSN_MACH_HAS_P (insn
, mach_num
));
1654 idesc_table
[sf
->index
].sem_fast
= sf
->fn
;
1656 idesc_table
[sf
->index
].sem_fast
= SEM_FN_NAME (lm32bf
,x_invalid
);
1659 idesc_table
[sf
->index
].sem_full
= sf
->fn
;
1661 idesc_table
[sf
->index
].sem_full
= SEM_FN_NAME (lm32bf
,x_invalid
);