1 /* Simulator instruction semantics for lm32bf.
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)
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, see <http://www.gnu.org/licenses/>.
24 #define WANT_CPU lm32bf
25 #define WANT_CPU_LM32BF
32 #define GET_ATTR(cpu, num, attr) CGEN_ATTR_VALUE (NULL, abuf->idesc->attrs, CGEN_INSN_##attr)
34 /* This is used so that we can compile two copies of the semantic code,
35 one with full feature support and one without that runs fast(er).
36 FAST_P, when desired, is defined on the command line, -DFAST_P=1. */
38 #define SEM_FN_NAME(cpu,fn) XCONCAT3 (cpu,_semf_,fn)
39 #undef CGEN_TRACE_RESULT
40 #define CGEN_TRACE_RESULT(cpu, abuf, name, type, val)
42 #define SEM_FN_NAME(cpu,fn) XCONCAT3 (cpu,_sem_,fn)
45 /* x-invalid: --invalid-- */
48 SEM_FN_NAME (lm32bf
,x_invalid
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
50 #define FLD(f) abuf->fields.sfmt_empty.f
51 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
52 int UNUSED written
= 0;
53 IADDR UNUSED pc
= abuf
->addr
;
54 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 0);
57 /* Update the recorded pc in the cpu state struct.
58 Only necessary for WITH_SCACHE case, but to avoid the
59 conditional compilation .... */
61 /* Virtual insns have zero size. Overwrite vpc with address of next insn
62 using the default-insn-bitsize spec. When executing insns in parallel
63 we may want to queue the fault and continue execution. */
64 vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
65 vpc
= sim_engine_invalid_insn (current_cpu
, pc
, vpc
);
72 /* x-after: --after-- */
75 SEM_FN_NAME (lm32bf
,x_after
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
77 #define FLD(f) abuf->fields.sfmt_empty.f
78 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
79 int UNUSED written
= 0;
80 IADDR UNUSED pc
= abuf
->addr
;
81 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 0);
84 #if WITH_SCACHE_PBB_LM32BF
85 lm32bf_pbb_after (current_cpu
, sem_arg
);
93 /* x-before: --before-- */
96 SEM_FN_NAME (lm32bf
,x_before
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
98 #define FLD(f) abuf->fields.sfmt_empty.f
99 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
100 int UNUSED written
= 0;
101 IADDR UNUSED pc
= abuf
->addr
;
102 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 0);
105 #if WITH_SCACHE_PBB_LM32BF
106 lm32bf_pbb_before (current_cpu
, sem_arg
);
114 /* x-cti-chain: --cti-chain-- */
117 SEM_FN_NAME (lm32bf
,x_cti_chain
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
119 #define FLD(f) abuf->fields.sfmt_empty.f
120 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
121 int UNUSED written
= 0;
122 IADDR UNUSED pc
= abuf
->addr
;
123 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 0);
126 #if WITH_SCACHE_PBB_LM32BF
128 vpc
= lm32bf_pbb_cti_chain (current_cpu
, sem_arg
,
129 pbb_br_type
, pbb_br_npc
);
132 /* FIXME: Allow provision of explicit ifmt spec in insn spec. */
133 vpc
= lm32bf_pbb_cti_chain (current_cpu
, sem_arg
,
134 CPU_PBB_BR_TYPE (current_cpu
),
135 CPU_PBB_BR_NPC (current_cpu
));
144 /* x-chain: --chain-- */
147 SEM_FN_NAME (lm32bf
,x_chain
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
149 #define FLD(f) abuf->fields.sfmt_empty.f
150 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
151 int UNUSED written
= 0;
152 IADDR UNUSED pc
= abuf
->addr
;
153 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 0);
156 #if WITH_SCACHE_PBB_LM32BF
157 vpc
= lm32bf_pbb_chain (current_cpu
, sem_arg
);
168 /* x-begin: --begin-- */
171 SEM_FN_NAME (lm32bf
,x_begin
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
173 #define FLD(f) abuf->fields.sfmt_empty.f
174 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
175 int UNUSED written
= 0;
176 IADDR UNUSED pc
= abuf
->addr
;
177 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 0);
180 #if WITH_SCACHE_PBB_LM32BF
181 #if defined DEFINE_SWITCH || defined FAST_P
182 /* In the switch case FAST_P is a constant, allowing several optimizations
183 in any called inline functions. */
184 vpc
= lm32bf_pbb_begin (current_cpu
, FAST_P
);
186 #if 0 /* cgen engine can't handle dynamic fast/full switching yet. */
187 vpc
= lm32bf_pbb_begin (current_cpu
, STATE_RUN_FAST_P (CPU_STATE (current_cpu
)));
189 vpc
= lm32bf_pbb_begin (current_cpu
, 0);
199 /* add: add $r2,$r0,$r1 */
202 SEM_FN_NAME (lm32bf
,add
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
204 #define FLD(f) abuf->fields.sfmt_user.f
205 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
206 int UNUSED written
= 0;
207 IADDR UNUSED pc
= abuf
->addr
;
208 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
211 SI opval
= ADDSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]));
212 CPU (h_gr
[FLD (f_r2
)]) = opval
;
213 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
220 /* addi: addi $r1,$r0,$imm */
223 SEM_FN_NAME (lm32bf
,addi
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
225 #define FLD(f) abuf->fields.sfmt_addi.f
226 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
227 int UNUSED written
= 0;
228 IADDR UNUSED pc
= abuf
->addr
;
229 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
232 SI opval
= ADDSI (CPU (h_gr
[FLD (f_r0
)]), EXTHISI (TRUNCSIHI (FLD (f_imm
))));
233 CPU (h_gr
[FLD (f_r1
)]) = opval
;
234 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
241 /* and: and $r2,$r0,$r1 */
244 SEM_FN_NAME (lm32bf
,and) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
246 #define FLD(f) abuf->fields.sfmt_user.f
247 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
248 int UNUSED written
= 0;
249 IADDR UNUSED pc
= abuf
->addr
;
250 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
253 SI opval
= ANDSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]));
254 CPU (h_gr
[FLD (f_r2
)]) = opval
;
255 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
262 /* andi: andi $r1,$r0,$uimm */
265 SEM_FN_NAME (lm32bf
,andi
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
267 #define FLD(f) abuf->fields.sfmt_andi.f
268 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
269 int UNUSED written
= 0;
270 IADDR UNUSED pc
= abuf
->addr
;
271 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
274 SI opval
= ANDSI (CPU (h_gr
[FLD (f_r0
)]), ZEXTSISI (FLD (f_uimm
)));
275 CPU (h_gr
[FLD (f_r1
)]) = opval
;
276 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
283 /* andhii: andhi $r1,$r0,$hi16 */
286 SEM_FN_NAME (lm32bf
,andhii
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
288 #define FLD(f) abuf->fields.sfmt_andi.f
289 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
290 int UNUSED written
= 0;
291 IADDR UNUSED pc
= abuf
->addr
;
292 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
295 SI opval
= ANDSI (CPU (h_gr
[FLD (f_r0
)]), SLLSI (FLD (f_uimm
), 16));
296 CPU (h_gr
[FLD (f_r1
)]) = opval
;
297 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
307 SEM_FN_NAME (lm32bf
,b
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
309 #define FLD(f) abuf->fields.sfmt_be.f
310 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
311 int UNUSED written
= 0;
312 IADDR UNUSED pc
= abuf
->addr
;
314 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
317 USI opval
= lm32bf_b_insn (current_cpu
, CPU (h_gr
[FLD (f_r0
)]), FLD (f_r0
));
318 SEM_BRANCH_VIA_ADDR (current_cpu
, sem_arg
, opval
, vpc
);
319 CGEN_TRACE_RESULT (current_cpu
, abuf
, "pc", 'x', opval
);
322 SEM_BRANCH_FINI (vpc
);
330 SEM_FN_NAME (lm32bf
,bi
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
332 #define FLD(f) abuf->fields.sfmt_bi.f
333 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
334 int UNUSED written
= 0;
335 IADDR UNUSED pc
= abuf
->addr
;
337 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
340 USI opval
= EXTSISI (FLD (i_call
));
341 SEM_BRANCH_VIA_ADDR (current_cpu
, sem_arg
, opval
, vpc
);
342 CGEN_TRACE_RESULT (current_cpu
, abuf
, "pc", 'x', opval
);
345 SEM_BRANCH_FINI (vpc
);
350 /* be: be $r0,$r1,$branch */
353 SEM_FN_NAME (lm32bf
,be
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
355 #define FLD(f) abuf->fields.sfmt_be.f
356 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
357 int UNUSED written
= 0;
358 IADDR UNUSED pc
= abuf
->addr
;
360 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
362 if (EQSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]))) {
364 USI opval
= FLD (i_branch
);
365 SEM_BRANCH_VIA_CACHE (current_cpu
, sem_arg
, opval
, vpc
);
367 CGEN_TRACE_RESULT (current_cpu
, abuf
, "pc", 'x', opval
);
371 abuf
->written
= written
;
372 SEM_BRANCH_FINI (vpc
);
377 /* bg: bg $r0,$r1,$branch */
380 SEM_FN_NAME (lm32bf
,bg
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
382 #define FLD(f) abuf->fields.sfmt_be.f
383 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
384 int UNUSED written
= 0;
385 IADDR UNUSED pc
= abuf
->addr
;
387 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
389 if (GTSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]))) {
391 USI opval
= FLD (i_branch
);
392 SEM_BRANCH_VIA_CACHE (current_cpu
, sem_arg
, opval
, vpc
);
394 CGEN_TRACE_RESULT (current_cpu
, abuf
, "pc", 'x', opval
);
398 abuf
->written
= written
;
399 SEM_BRANCH_FINI (vpc
);
404 /* bge: bge $r0,$r1,$branch */
407 SEM_FN_NAME (lm32bf
,bge
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
409 #define FLD(f) abuf->fields.sfmt_be.f
410 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
411 int UNUSED written
= 0;
412 IADDR UNUSED pc
= abuf
->addr
;
414 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
416 if (GESI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]))) {
418 USI opval
= FLD (i_branch
);
419 SEM_BRANCH_VIA_CACHE (current_cpu
, sem_arg
, opval
, vpc
);
421 CGEN_TRACE_RESULT (current_cpu
, abuf
, "pc", 'x', opval
);
425 abuf
->written
= written
;
426 SEM_BRANCH_FINI (vpc
);
431 /* bgeu: bgeu $r0,$r1,$branch */
434 SEM_FN_NAME (lm32bf
,bgeu
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
436 #define FLD(f) abuf->fields.sfmt_be.f
437 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
438 int UNUSED written
= 0;
439 IADDR UNUSED pc
= abuf
->addr
;
441 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
443 if (GEUSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]))) {
445 USI opval
= FLD (i_branch
);
446 SEM_BRANCH_VIA_CACHE (current_cpu
, sem_arg
, opval
, vpc
);
448 CGEN_TRACE_RESULT (current_cpu
, abuf
, "pc", 'x', opval
);
452 abuf
->written
= written
;
453 SEM_BRANCH_FINI (vpc
);
458 /* bgu: bgu $r0,$r1,$branch */
461 SEM_FN_NAME (lm32bf
,bgu
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
463 #define FLD(f) abuf->fields.sfmt_be.f
464 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
465 int UNUSED written
= 0;
466 IADDR UNUSED pc
= abuf
->addr
;
468 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
470 if (GTUSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]))) {
472 USI opval
= FLD (i_branch
);
473 SEM_BRANCH_VIA_CACHE (current_cpu
, sem_arg
, opval
, vpc
);
475 CGEN_TRACE_RESULT (current_cpu
, abuf
, "pc", 'x', opval
);
479 abuf
->written
= written
;
480 SEM_BRANCH_FINI (vpc
);
485 /* bne: bne $r0,$r1,$branch */
488 SEM_FN_NAME (lm32bf
,bne
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
490 #define FLD(f) abuf->fields.sfmt_be.f
491 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
492 int UNUSED written
= 0;
493 IADDR UNUSED pc
= abuf
->addr
;
495 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
497 if (NESI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]))) {
499 USI opval
= FLD (i_branch
);
500 SEM_BRANCH_VIA_CACHE (current_cpu
, sem_arg
, opval
, vpc
);
502 CGEN_TRACE_RESULT (current_cpu
, abuf
, "pc", 'x', opval
);
506 abuf
->written
= written
;
507 SEM_BRANCH_FINI (vpc
);
515 SEM_FN_NAME (lm32bf
,call
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
517 #define FLD(f) abuf->fields.sfmt_be.f
518 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
519 int UNUSED written
= 0;
520 IADDR UNUSED pc
= abuf
->addr
;
522 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
526 SI opval
= ADDSI (pc
, 4);
527 CPU (h_gr
[((UINT
) 29)]) = opval
;
528 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
531 USI opval
= CPU (h_gr
[FLD (f_r0
)]);
532 SEM_BRANCH_VIA_ADDR (current_cpu
, sem_arg
, opval
, vpc
);
533 CGEN_TRACE_RESULT (current_cpu
, abuf
, "pc", 'x', opval
);
537 SEM_BRANCH_FINI (vpc
);
542 /* calli: calli $call */
545 SEM_FN_NAME (lm32bf
,calli
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
547 #define FLD(f) abuf->fields.sfmt_bi.f
548 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
549 int UNUSED written
= 0;
550 IADDR UNUSED pc
= abuf
->addr
;
552 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
556 SI opval
= ADDSI (pc
, 4);
557 CPU (h_gr
[((UINT
) 29)]) = opval
;
558 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
561 USI opval
= EXTSISI (FLD (i_call
));
562 SEM_BRANCH_VIA_ADDR (current_cpu
, sem_arg
, opval
, vpc
);
563 CGEN_TRACE_RESULT (current_cpu
, abuf
, "pc", 'x', opval
);
567 SEM_BRANCH_FINI (vpc
);
572 /* cmpe: cmpe $r2,$r0,$r1 */
575 SEM_FN_NAME (lm32bf
,cmpe
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
577 #define FLD(f) abuf->fields.sfmt_user.f
578 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
579 int UNUSED written
= 0;
580 IADDR UNUSED pc
= abuf
->addr
;
581 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
584 SI opval
= EQSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]));
585 CPU (h_gr
[FLD (f_r2
)]) = opval
;
586 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
593 /* cmpei: cmpei $r1,$r0,$imm */
596 SEM_FN_NAME (lm32bf
,cmpei
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
598 #define FLD(f) abuf->fields.sfmt_addi.f
599 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
600 int UNUSED written
= 0;
601 IADDR UNUSED pc
= abuf
->addr
;
602 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
605 SI opval
= EQSI (CPU (h_gr
[FLD (f_r0
)]), EXTHISI (TRUNCSIHI (FLD (f_imm
))));
606 CPU (h_gr
[FLD (f_r1
)]) = opval
;
607 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
614 /* cmpg: cmpg $r2,$r0,$r1 */
617 SEM_FN_NAME (lm32bf
,cmpg
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
619 #define FLD(f) abuf->fields.sfmt_user.f
620 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
621 int UNUSED written
= 0;
622 IADDR UNUSED pc
= abuf
->addr
;
623 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
626 SI opval
= GTSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]));
627 CPU (h_gr
[FLD (f_r2
)]) = opval
;
628 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
635 /* cmpgi: cmpgi $r1,$r0,$imm */
638 SEM_FN_NAME (lm32bf
,cmpgi
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
640 #define FLD(f) abuf->fields.sfmt_addi.f
641 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
642 int UNUSED written
= 0;
643 IADDR UNUSED pc
= abuf
->addr
;
644 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
647 SI opval
= GTSI (CPU (h_gr
[FLD (f_r0
)]), EXTHISI (TRUNCSIHI (FLD (f_imm
))));
648 CPU (h_gr
[FLD (f_r1
)]) = opval
;
649 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
656 /* cmpge: cmpge $r2,$r0,$r1 */
659 SEM_FN_NAME (lm32bf
,cmpge
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
661 #define FLD(f) abuf->fields.sfmt_user.f
662 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
663 int UNUSED written
= 0;
664 IADDR UNUSED pc
= abuf
->addr
;
665 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
668 SI opval
= GESI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]));
669 CPU (h_gr
[FLD (f_r2
)]) = opval
;
670 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
677 /* cmpgei: cmpgei $r1,$r0,$imm */
680 SEM_FN_NAME (lm32bf
,cmpgei
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
682 #define FLD(f) abuf->fields.sfmt_addi.f
683 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
684 int UNUSED written
= 0;
685 IADDR UNUSED pc
= abuf
->addr
;
686 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
689 SI opval
= GESI (CPU (h_gr
[FLD (f_r0
)]), EXTHISI (TRUNCSIHI (FLD (f_imm
))));
690 CPU (h_gr
[FLD (f_r1
)]) = opval
;
691 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
698 /* cmpgeu: cmpgeu $r2,$r0,$r1 */
701 SEM_FN_NAME (lm32bf
,cmpgeu
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
703 #define FLD(f) abuf->fields.sfmt_user.f
704 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
705 int UNUSED written
= 0;
706 IADDR UNUSED pc
= abuf
->addr
;
707 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
710 SI opval
= GEUSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]));
711 CPU (h_gr
[FLD (f_r2
)]) = opval
;
712 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
719 /* cmpgeui: cmpgeui $r1,$r0,$uimm */
722 SEM_FN_NAME (lm32bf
,cmpgeui
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
724 #define FLD(f) abuf->fields.sfmt_andi.f
725 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
726 int UNUSED written
= 0;
727 IADDR UNUSED pc
= abuf
->addr
;
728 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
731 SI opval
= GEUSI (CPU (h_gr
[FLD (f_r0
)]), ZEXTSISI (FLD (f_uimm
)));
732 CPU (h_gr
[FLD (f_r1
)]) = opval
;
733 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
740 /* cmpgu: cmpgu $r2,$r0,$r1 */
743 SEM_FN_NAME (lm32bf
,cmpgu
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
745 #define FLD(f) abuf->fields.sfmt_user.f
746 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
747 int UNUSED written
= 0;
748 IADDR UNUSED pc
= abuf
->addr
;
749 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
752 SI opval
= GTUSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]));
753 CPU (h_gr
[FLD (f_r2
)]) = opval
;
754 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
761 /* cmpgui: cmpgui $r1,$r0,$uimm */
764 SEM_FN_NAME (lm32bf
,cmpgui
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
766 #define FLD(f) abuf->fields.sfmt_andi.f
767 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
768 int UNUSED written
= 0;
769 IADDR UNUSED pc
= abuf
->addr
;
770 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
773 SI opval
= GTUSI (CPU (h_gr
[FLD (f_r0
)]), ZEXTSISI (FLD (f_uimm
)));
774 CPU (h_gr
[FLD (f_r1
)]) = opval
;
775 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
782 /* cmpne: cmpne $r2,$r0,$r1 */
785 SEM_FN_NAME (lm32bf
,cmpne
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
787 #define FLD(f) abuf->fields.sfmt_user.f
788 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
789 int UNUSED written
= 0;
790 IADDR UNUSED pc
= abuf
->addr
;
791 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
794 SI opval
= NESI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]));
795 CPU (h_gr
[FLD (f_r2
)]) = opval
;
796 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
803 /* cmpnei: cmpnei $r1,$r0,$imm */
806 SEM_FN_NAME (lm32bf
,cmpnei
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
808 #define FLD(f) abuf->fields.sfmt_addi.f
809 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
810 int UNUSED written
= 0;
811 IADDR UNUSED pc
= abuf
->addr
;
812 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
815 SI opval
= NESI (CPU (h_gr
[FLD (f_r0
)]), EXTHISI (TRUNCSIHI (FLD (f_imm
))));
816 CPU (h_gr
[FLD (f_r1
)]) = opval
;
817 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
824 /* divu: divu $r2,$r0,$r1 */
827 SEM_FN_NAME (lm32bf
,divu
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
829 #define FLD(f) abuf->fields.sfmt_user.f
830 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
831 int UNUSED written
= 0;
832 IADDR UNUSED pc
= abuf
->addr
;
834 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
837 USI opval
= lm32bf_divu_insn (current_cpu
, pc
, FLD (f_r0
), FLD (f_r1
), FLD (f_r2
));
838 SEM_BRANCH_VIA_ADDR (current_cpu
, sem_arg
, opval
, vpc
);
839 CGEN_TRACE_RESULT (current_cpu
, abuf
, "pc", 'x', opval
);
842 SEM_BRANCH_FINI (vpc
);
847 /* lb: lb $r1,($r0+$imm) */
850 SEM_FN_NAME (lm32bf
,lb
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
852 #define FLD(f) abuf->fields.sfmt_addi.f
853 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
854 int UNUSED written
= 0;
855 IADDR UNUSED pc
= abuf
->addr
;
856 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
859 SI opval
= EXTQISI (GETMEMQI (current_cpu
, pc
, ADDSI (CPU (h_gr
[FLD (f_r0
)]), EXTHISI (TRUNCSIHI (FLD (f_imm
))))));
860 CPU (h_gr
[FLD (f_r1
)]) = opval
;
861 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
868 /* lbu: lbu $r1,($r0+$imm) */
871 SEM_FN_NAME (lm32bf
,lbu
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
873 #define FLD(f) abuf->fields.sfmt_addi.f
874 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
875 int UNUSED written
= 0;
876 IADDR UNUSED pc
= abuf
->addr
;
877 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
880 SI opval
= ZEXTQISI (GETMEMQI (current_cpu
, pc
, ADDSI (CPU (h_gr
[FLD (f_r0
)]), EXTHISI (TRUNCSIHI (FLD (f_imm
))))));
881 CPU (h_gr
[FLD (f_r1
)]) = opval
;
882 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
889 /* lh: lh $r1,($r0+$imm) */
892 SEM_FN_NAME (lm32bf
,lh
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
894 #define FLD(f) abuf->fields.sfmt_addi.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 opval
= EXTHISI (GETMEMHI (current_cpu
, pc
, ADDSI (CPU (h_gr
[FLD (f_r0
)]), EXTHISI (TRUNCSIHI (FLD (f_imm
))))));
902 CPU (h_gr
[FLD (f_r1
)]) = opval
;
903 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
910 /* lhu: lhu $r1,($r0+$imm) */
913 SEM_FN_NAME (lm32bf
,lhu
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
915 #define FLD(f) abuf->fields.sfmt_addi.f
916 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
917 int UNUSED written
= 0;
918 IADDR UNUSED pc
= abuf
->addr
;
919 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
922 SI opval
= ZEXTHISI (GETMEMHI (current_cpu
, pc
, ADDSI (CPU (h_gr
[FLD (f_r0
)]), EXTHISI (TRUNCSIHI (FLD (f_imm
))))));
923 CPU (h_gr
[FLD (f_r1
)]) = opval
;
924 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
931 /* lw: lw $r1,($r0+$imm) */
934 SEM_FN_NAME (lm32bf
,lw
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
936 #define FLD(f) abuf->fields.sfmt_addi.f
937 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
938 int UNUSED written
= 0;
939 IADDR UNUSED pc
= abuf
->addr
;
940 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
943 SI opval
= GETMEMSI (current_cpu
, pc
, ADDSI (CPU (h_gr
[FLD (f_r0
)]), EXTHISI (TRUNCSIHI (FLD (f_imm
)))));
944 CPU (h_gr
[FLD (f_r1
)]) = opval
;
945 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
952 /* modu: modu $r2,$r0,$r1 */
955 SEM_FN_NAME (lm32bf
,modu
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
957 #define FLD(f) abuf->fields.sfmt_user.f
958 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
959 int UNUSED written
= 0;
960 IADDR UNUSED pc
= abuf
->addr
;
962 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
965 USI opval
= lm32bf_modu_insn (current_cpu
, pc
, FLD (f_r0
), FLD (f_r1
), FLD (f_r2
));
966 SEM_BRANCH_VIA_ADDR (current_cpu
, sem_arg
, opval
, vpc
);
967 CGEN_TRACE_RESULT (current_cpu
, abuf
, "pc", 'x', opval
);
970 SEM_BRANCH_FINI (vpc
);
975 /* mul: mul $r2,$r0,$r1 */
978 SEM_FN_NAME (lm32bf
,mul
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
980 #define FLD(f) abuf->fields.sfmt_user.f
981 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
982 int UNUSED written
= 0;
983 IADDR UNUSED pc
= abuf
->addr
;
984 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
987 SI opval
= MULSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]));
988 CPU (h_gr
[FLD (f_r2
)]) = opval
;
989 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
996 /* muli: muli $r1,$r0,$imm */
999 SEM_FN_NAME (lm32bf
,muli
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1001 #define FLD(f) abuf->fields.sfmt_addi.f
1002 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1003 int UNUSED written
= 0;
1004 IADDR UNUSED pc
= abuf
->addr
;
1005 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1008 SI opval
= MULSI (CPU (h_gr
[FLD (f_r0
)]), EXTHISI (TRUNCSIHI (FLD (f_imm
))));
1009 CPU (h_gr
[FLD (f_r1
)]) = opval
;
1010 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1017 /* nor: nor $r2,$r0,$r1 */
1020 SEM_FN_NAME (lm32bf
,nor
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1022 #define FLD(f) abuf->fields.sfmt_user.f
1023 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1024 int UNUSED written
= 0;
1025 IADDR UNUSED pc
= abuf
->addr
;
1026 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1029 SI opval
= INVSI (ORSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)])));
1030 CPU (h_gr
[FLD (f_r2
)]) = opval
;
1031 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1038 /* nori: nori $r1,$r0,$uimm */
1041 SEM_FN_NAME (lm32bf
,nori
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1043 #define FLD(f) abuf->fields.sfmt_andi.f
1044 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1045 int UNUSED written
= 0;
1046 IADDR UNUSED pc
= abuf
->addr
;
1047 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1050 SI opval
= INVSI (ORSI (CPU (h_gr
[FLD (f_r0
)]), ZEXTSISI (FLD (f_uimm
))));
1051 CPU (h_gr
[FLD (f_r1
)]) = opval
;
1052 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1059 /* or: or $r2,$r0,$r1 */
1062 SEM_FN_NAME (lm32bf
,or) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1064 #define FLD(f) abuf->fields.sfmt_user.f
1065 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1066 int UNUSED written
= 0;
1067 IADDR UNUSED pc
= abuf
->addr
;
1068 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1071 SI opval
= ORSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]));
1072 CPU (h_gr
[FLD (f_r2
)]) = opval
;
1073 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1080 /* ori: ori $r1,$r0,$lo16 */
1083 SEM_FN_NAME (lm32bf
,ori
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1085 #define FLD(f) abuf->fields.sfmt_andi.f
1086 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1087 int UNUSED written
= 0;
1088 IADDR UNUSED pc
= abuf
->addr
;
1089 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1092 SI opval
= ORSI (CPU (h_gr
[FLD (f_r0
)]), ZEXTSISI (FLD (f_uimm
)));
1093 CPU (h_gr
[FLD (f_r1
)]) = opval
;
1094 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1101 /* orhii: orhi $r1,$r0,$hi16 */
1104 SEM_FN_NAME (lm32bf
,orhii
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1106 #define FLD(f) abuf->fields.sfmt_andi.f
1107 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1108 int UNUSED written
= 0;
1109 IADDR UNUSED pc
= abuf
->addr
;
1110 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1113 SI opval
= ORSI (CPU (h_gr
[FLD (f_r0
)]), SLLSI (FLD (f_uimm
), 16));
1114 CPU (h_gr
[FLD (f_r1
)]) = opval
;
1115 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1122 /* rcsr: rcsr $r2,$csr */
1125 SEM_FN_NAME (lm32bf
,rcsr
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1127 #define FLD(f) abuf->fields.sfmt_rcsr.f
1128 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1129 int UNUSED written
= 0;
1130 IADDR UNUSED pc
= abuf
->addr
;
1131 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1134 SI opval
= CPU (h_csr
[FLD (f_csr
)]);
1135 CPU (h_gr
[FLD (f_r2
)]) = opval
;
1136 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1143 /* sb: sb ($r0+$imm),$r1 */
1146 SEM_FN_NAME (lm32bf
,sb
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1148 #define FLD(f) abuf->fields.sfmt_addi.f
1149 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1150 int UNUSED written
= 0;
1151 IADDR UNUSED pc
= abuf
->addr
;
1152 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1155 QI opval
= CPU (h_gr
[FLD (f_r1
)]);
1156 SETMEMQI (current_cpu
, pc
, ADDSI (CPU (h_gr
[FLD (f_r0
)]), EXTHISI (TRUNCSIHI (FLD (f_imm
)))), opval
);
1157 CGEN_TRACE_RESULT (current_cpu
, abuf
, "memory", 'x', opval
);
1164 /* sextb: sextb $r2,$r0 */
1167 SEM_FN_NAME (lm32bf
,sextb
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1169 #define FLD(f) abuf->fields.sfmt_user.f
1170 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1171 int UNUSED written
= 0;
1172 IADDR UNUSED pc
= abuf
->addr
;
1173 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1176 SI opval
= EXTQISI (TRUNCSIQI (CPU (h_gr
[FLD (f_r0
)])));
1177 CPU (h_gr
[FLD (f_r2
)]) = opval
;
1178 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1185 /* sexth: sexth $r2,$r0 */
1188 SEM_FN_NAME (lm32bf
,sexth
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1190 #define FLD(f) abuf->fields.sfmt_user.f
1191 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1192 int UNUSED written
= 0;
1193 IADDR UNUSED pc
= abuf
->addr
;
1194 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1197 SI opval
= EXTHISI (TRUNCSIHI (CPU (h_gr
[FLD (f_r0
)])));
1198 CPU (h_gr
[FLD (f_r2
)]) = opval
;
1199 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1206 /* sh: sh ($r0+$imm),$r1 */
1209 SEM_FN_NAME (lm32bf
,sh
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1211 #define FLD(f) abuf->fields.sfmt_addi.f
1212 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1213 int UNUSED written
= 0;
1214 IADDR UNUSED pc
= abuf
->addr
;
1215 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1218 HI opval
= CPU (h_gr
[FLD (f_r1
)]);
1219 SETMEMHI (current_cpu
, pc
, ADDSI (CPU (h_gr
[FLD (f_r0
)]), EXTHISI (TRUNCSIHI (FLD (f_imm
)))), opval
);
1220 CGEN_TRACE_RESULT (current_cpu
, abuf
, "memory", 'x', opval
);
1227 /* sl: sl $r2,$r0,$r1 */
1230 SEM_FN_NAME (lm32bf
,sl
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1232 #define FLD(f) abuf->fields.sfmt_user.f
1233 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1234 int UNUSED written
= 0;
1235 IADDR UNUSED pc
= abuf
->addr
;
1236 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1239 SI opval
= SLLSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]));
1240 CPU (h_gr
[FLD (f_r2
)]) = opval
;
1241 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1248 /* sli: sli $r1,$r0,$imm */
1251 SEM_FN_NAME (lm32bf
,sli
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1253 #define FLD(f) abuf->fields.sfmt_addi.f
1254 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1255 int UNUSED written
= 0;
1256 IADDR UNUSED pc
= abuf
->addr
;
1257 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1260 SI opval
= SLLSI (CPU (h_gr
[FLD (f_r0
)]), FLD (f_imm
));
1261 CPU (h_gr
[FLD (f_r1
)]) = opval
;
1262 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1269 /* sr: sr $r2,$r0,$r1 */
1272 SEM_FN_NAME (lm32bf
,sr
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1274 #define FLD(f) abuf->fields.sfmt_user.f
1275 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1276 int UNUSED written
= 0;
1277 IADDR UNUSED pc
= abuf
->addr
;
1278 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1281 SI opval
= SRASI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]));
1282 CPU (h_gr
[FLD (f_r2
)]) = opval
;
1283 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1290 /* sri: sri $r1,$r0,$imm */
1293 SEM_FN_NAME (lm32bf
,sri
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1295 #define FLD(f) abuf->fields.sfmt_addi.f
1296 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1297 int UNUSED written
= 0;
1298 IADDR UNUSED pc
= abuf
->addr
;
1299 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1302 SI opval
= SRASI (CPU (h_gr
[FLD (f_r0
)]), FLD (f_imm
));
1303 CPU (h_gr
[FLD (f_r1
)]) = opval
;
1304 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1311 /* sru: sru $r2,$r0,$r1 */
1314 SEM_FN_NAME (lm32bf
,sru
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1316 #define FLD(f) abuf->fields.sfmt_user.f
1317 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1318 int UNUSED written
= 0;
1319 IADDR UNUSED pc
= abuf
->addr
;
1320 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1323 SI opval
= SRLSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]));
1324 CPU (h_gr
[FLD (f_r2
)]) = opval
;
1325 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1332 /* srui: srui $r1,$r0,$imm */
1335 SEM_FN_NAME (lm32bf
,srui
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1337 #define FLD(f) abuf->fields.sfmt_addi.f
1338 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1339 int UNUSED written
= 0;
1340 IADDR UNUSED pc
= abuf
->addr
;
1341 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1344 SI opval
= SRLSI (CPU (h_gr
[FLD (f_r0
)]), FLD (f_imm
));
1345 CPU (h_gr
[FLD (f_r1
)]) = opval
;
1346 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1353 /* sub: sub $r2,$r0,$r1 */
1356 SEM_FN_NAME (lm32bf
,sub
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1358 #define FLD(f) abuf->fields.sfmt_user.f
1359 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1360 int UNUSED written
= 0;
1361 IADDR UNUSED pc
= abuf
->addr
;
1362 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1365 SI opval
= SUBSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]));
1366 CPU (h_gr
[FLD (f_r2
)]) = opval
;
1367 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1374 /* sw: sw ($r0+$imm),$r1 */
1377 SEM_FN_NAME (lm32bf
,sw
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1379 #define FLD(f) abuf->fields.sfmt_addi.f
1380 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1381 int UNUSED written
= 0;
1382 IADDR UNUSED pc
= abuf
->addr
;
1383 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1386 SI opval
= CPU (h_gr
[FLD (f_r1
)]);
1387 SETMEMSI (current_cpu
, pc
, ADDSI (CPU (h_gr
[FLD (f_r0
)]), EXTHISI (TRUNCSIHI (FLD (f_imm
)))), opval
);
1388 CGEN_TRACE_RESULT (current_cpu
, abuf
, "memory", 'x', opval
);
1395 /* user: user $r2,$r0,$r1,$user */
1398 SEM_FN_NAME (lm32bf
,user
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1400 #define FLD(f) abuf->fields.sfmt_user.f
1401 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1402 int UNUSED written
= 0;
1403 IADDR UNUSED pc
= abuf
->addr
;
1404 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1407 SI opval
= lm32bf_user_insn (current_cpu
, CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]), FLD (f_user
));
1408 CPU (h_gr
[FLD (f_r2
)]) = opval
;
1409 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1416 /* wcsr: wcsr $csr,$r1 */
1419 SEM_FN_NAME (lm32bf
,wcsr
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1421 #define FLD(f) abuf->fields.sfmt_wcsr.f
1422 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1423 int UNUSED written
= 0;
1424 IADDR UNUSED pc
= abuf
->addr
;
1425 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1427 lm32bf_wcsr_insn (current_cpu
, FLD (f_csr
), CPU (h_gr
[FLD (f_r1
)]));
1433 /* xor: xor $r2,$r0,$r1 */
1436 SEM_FN_NAME (lm32bf
,xor) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1438 #define FLD(f) abuf->fields.sfmt_user.f
1439 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1440 int UNUSED written
= 0;
1441 IADDR UNUSED pc
= abuf
->addr
;
1442 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1445 SI opval
= XORSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)]));
1446 CPU (h_gr
[FLD (f_r2
)]) = opval
;
1447 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1454 /* xori: xori $r1,$r0,$uimm */
1457 SEM_FN_NAME (lm32bf
,xori
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1459 #define FLD(f) abuf->fields.sfmt_andi.f
1460 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1461 int UNUSED written
= 0;
1462 IADDR UNUSED pc
= abuf
->addr
;
1463 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1466 SI opval
= XORSI (CPU (h_gr
[FLD (f_r0
)]), ZEXTSISI (FLD (f_uimm
)));
1467 CPU (h_gr
[FLD (f_r1
)]) = opval
;
1468 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1475 /* xnor: xnor $r2,$r0,$r1 */
1478 SEM_FN_NAME (lm32bf
,xnor
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1480 #define FLD(f) abuf->fields.sfmt_user.f
1481 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1482 int UNUSED written
= 0;
1483 IADDR UNUSED pc
= abuf
->addr
;
1484 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1487 SI opval
= INVSI (XORSI (CPU (h_gr
[FLD (f_r0
)]), CPU (h_gr
[FLD (f_r1
)])));
1488 CPU (h_gr
[FLD (f_r2
)]) = opval
;
1489 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1496 /* xnori: xnori $r1,$r0,$uimm */
1499 SEM_FN_NAME (lm32bf
,xnori
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1501 #define FLD(f) abuf->fields.sfmt_andi.f
1502 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1503 int UNUSED written
= 0;
1504 IADDR UNUSED pc
= abuf
->addr
;
1505 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1508 SI opval
= INVSI (XORSI (CPU (h_gr
[FLD (f_r0
)]), ZEXTSISI (FLD (f_uimm
))));
1509 CPU (h_gr
[FLD (f_r1
)]) = opval
;
1510 CGEN_TRACE_RESULT (current_cpu
, abuf
, "gr", 'x', opval
);
1520 SEM_FN_NAME (lm32bf
,break) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1522 #define FLD(f) abuf->fields.sfmt_empty.f
1523 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1524 int UNUSED written
= 0;
1525 IADDR UNUSED pc
= abuf
->addr
;
1527 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1530 USI opval
= lm32bf_break_insn (current_cpu
, pc
);
1531 SEM_BRANCH_VIA_ADDR (current_cpu
, sem_arg
, opval
, vpc
);
1532 CGEN_TRACE_RESULT (current_cpu
, abuf
, "pc", 'x', opval
);
1535 SEM_BRANCH_FINI (vpc
);
1543 SEM_FN_NAME (lm32bf
,scall
) (SIM_CPU
*current_cpu
, SEM_ARG sem_arg
)
1545 #define FLD(f) abuf->fields.sfmt_empty.f
1546 ARGBUF
*abuf
= SEM_ARGBUF (sem_arg
);
1547 int UNUSED written
= 0;
1548 IADDR UNUSED pc
= abuf
->addr
;
1550 SEM_PC vpc
= SEM_NEXT_VPC (sem_arg
, pc
, 4);
1553 USI opval
= lm32bf_scall_insn (current_cpu
, pc
);
1554 SEM_BRANCH_VIA_ADDR (current_cpu
, sem_arg
, opval
, vpc
);
1555 CGEN_TRACE_RESULT (current_cpu
, abuf
, "pc", 'x', opval
);
1558 SEM_BRANCH_FINI (vpc
);
1563 /* Table of all semantic fns. */
1565 static const struct sem_fn_desc sem_fns
[] = {
1566 { LM32BF_INSN_X_INVALID
, SEM_FN_NAME (lm32bf
,x_invalid
) },
1567 { LM32BF_INSN_X_AFTER
, SEM_FN_NAME (lm32bf
,x_after
) },
1568 { LM32BF_INSN_X_BEFORE
, SEM_FN_NAME (lm32bf
,x_before
) },
1569 { LM32BF_INSN_X_CTI_CHAIN
, SEM_FN_NAME (lm32bf
,x_cti_chain
) },
1570 { LM32BF_INSN_X_CHAIN
, SEM_FN_NAME (lm32bf
,x_chain
) },
1571 { LM32BF_INSN_X_BEGIN
, SEM_FN_NAME (lm32bf
,x_begin
) },
1572 { LM32BF_INSN_ADD
, SEM_FN_NAME (lm32bf
,add
) },
1573 { LM32BF_INSN_ADDI
, SEM_FN_NAME (lm32bf
,addi
) },
1574 { LM32BF_INSN_AND
, SEM_FN_NAME (lm32bf
,and) },
1575 { LM32BF_INSN_ANDI
, SEM_FN_NAME (lm32bf
,andi
) },
1576 { LM32BF_INSN_ANDHII
, SEM_FN_NAME (lm32bf
,andhii
) },
1577 { LM32BF_INSN_B
, SEM_FN_NAME (lm32bf
,b
) },
1578 { LM32BF_INSN_BI
, SEM_FN_NAME (lm32bf
,bi
) },
1579 { LM32BF_INSN_BE
, SEM_FN_NAME (lm32bf
,be
) },
1580 { LM32BF_INSN_BG
, SEM_FN_NAME (lm32bf
,bg
) },
1581 { LM32BF_INSN_BGE
, SEM_FN_NAME (lm32bf
,bge
) },
1582 { LM32BF_INSN_BGEU
, SEM_FN_NAME (lm32bf
,bgeu
) },
1583 { LM32BF_INSN_BGU
, SEM_FN_NAME (lm32bf
,bgu
) },
1584 { LM32BF_INSN_BNE
, SEM_FN_NAME (lm32bf
,bne
) },
1585 { LM32BF_INSN_CALL
, SEM_FN_NAME (lm32bf
,call
) },
1586 { LM32BF_INSN_CALLI
, SEM_FN_NAME (lm32bf
,calli
) },
1587 { LM32BF_INSN_CMPE
, SEM_FN_NAME (lm32bf
,cmpe
) },
1588 { LM32BF_INSN_CMPEI
, SEM_FN_NAME (lm32bf
,cmpei
) },
1589 { LM32BF_INSN_CMPG
, SEM_FN_NAME (lm32bf
,cmpg
) },
1590 { LM32BF_INSN_CMPGI
, SEM_FN_NAME (lm32bf
,cmpgi
) },
1591 { LM32BF_INSN_CMPGE
, SEM_FN_NAME (lm32bf
,cmpge
) },
1592 { LM32BF_INSN_CMPGEI
, SEM_FN_NAME (lm32bf
,cmpgei
) },
1593 { LM32BF_INSN_CMPGEU
, SEM_FN_NAME (lm32bf
,cmpgeu
) },
1594 { LM32BF_INSN_CMPGEUI
, SEM_FN_NAME (lm32bf
,cmpgeui
) },
1595 { LM32BF_INSN_CMPGU
, SEM_FN_NAME (lm32bf
,cmpgu
) },
1596 { LM32BF_INSN_CMPGUI
, SEM_FN_NAME (lm32bf
,cmpgui
) },
1597 { LM32BF_INSN_CMPNE
, SEM_FN_NAME (lm32bf
,cmpne
) },
1598 { LM32BF_INSN_CMPNEI
, SEM_FN_NAME (lm32bf
,cmpnei
) },
1599 { LM32BF_INSN_DIVU
, SEM_FN_NAME (lm32bf
,divu
) },
1600 { LM32BF_INSN_LB
, SEM_FN_NAME (lm32bf
,lb
) },
1601 { LM32BF_INSN_LBU
, SEM_FN_NAME (lm32bf
,lbu
) },
1602 { LM32BF_INSN_LH
, SEM_FN_NAME (lm32bf
,lh
) },
1603 { LM32BF_INSN_LHU
, SEM_FN_NAME (lm32bf
,lhu
) },
1604 { LM32BF_INSN_LW
, SEM_FN_NAME (lm32bf
,lw
) },
1605 { LM32BF_INSN_MODU
, SEM_FN_NAME (lm32bf
,modu
) },
1606 { LM32BF_INSN_MUL
, SEM_FN_NAME (lm32bf
,mul
) },
1607 { LM32BF_INSN_MULI
, SEM_FN_NAME (lm32bf
,muli
) },
1608 { LM32BF_INSN_NOR
, SEM_FN_NAME (lm32bf
,nor
) },
1609 { LM32BF_INSN_NORI
, SEM_FN_NAME (lm32bf
,nori
) },
1610 { LM32BF_INSN_OR
, SEM_FN_NAME (lm32bf
,or) },
1611 { LM32BF_INSN_ORI
, SEM_FN_NAME (lm32bf
,ori
) },
1612 { LM32BF_INSN_ORHII
, SEM_FN_NAME (lm32bf
,orhii
) },
1613 { LM32BF_INSN_RCSR
, SEM_FN_NAME (lm32bf
,rcsr
) },
1614 { LM32BF_INSN_SB
, SEM_FN_NAME (lm32bf
,sb
) },
1615 { LM32BF_INSN_SEXTB
, SEM_FN_NAME (lm32bf
,sextb
) },
1616 { LM32BF_INSN_SEXTH
, SEM_FN_NAME (lm32bf
,sexth
) },
1617 { LM32BF_INSN_SH
, SEM_FN_NAME (lm32bf
,sh
) },
1618 { LM32BF_INSN_SL
, SEM_FN_NAME (lm32bf
,sl
) },
1619 { LM32BF_INSN_SLI
, SEM_FN_NAME (lm32bf
,sli
) },
1620 { LM32BF_INSN_SR
, SEM_FN_NAME (lm32bf
,sr
) },
1621 { LM32BF_INSN_SRI
, SEM_FN_NAME (lm32bf
,sri
) },
1622 { LM32BF_INSN_SRU
, SEM_FN_NAME (lm32bf
,sru
) },
1623 { LM32BF_INSN_SRUI
, SEM_FN_NAME (lm32bf
,srui
) },
1624 { LM32BF_INSN_SUB
, SEM_FN_NAME (lm32bf
,sub
) },
1625 { LM32BF_INSN_SW
, SEM_FN_NAME (lm32bf
,sw
) },
1626 { LM32BF_INSN_USER
, SEM_FN_NAME (lm32bf
,user
) },
1627 { LM32BF_INSN_WCSR
, SEM_FN_NAME (lm32bf
,wcsr
) },
1628 { LM32BF_INSN_XOR
, SEM_FN_NAME (lm32bf
,xor) },
1629 { LM32BF_INSN_XORI
, SEM_FN_NAME (lm32bf
,xori
) },
1630 { LM32BF_INSN_XNOR
, SEM_FN_NAME (lm32bf
,xnor
) },
1631 { LM32BF_INSN_XNORI
, SEM_FN_NAME (lm32bf
,xnori
) },
1632 { LM32BF_INSN_BREAK
, SEM_FN_NAME (lm32bf
,break) },
1633 { LM32BF_INSN_SCALL
, SEM_FN_NAME (lm32bf
,scall
) },
1637 /* Add the semantic fns to IDESC_TABLE. */
1640 SEM_FN_NAME (lm32bf
,init_idesc_table
) (SIM_CPU
*current_cpu
)
1642 IDESC
*idesc_table
= CPU_IDESC (current_cpu
);
1643 const struct sem_fn_desc
*sf
;
1644 int mach_num
= MACH_NUM (CPU_MACH (current_cpu
));
1646 for (sf
= &sem_fns
[0]; sf
->fn
!= 0; ++sf
)
1648 const CGEN_INSN
*insn
= idesc_table
[sf
->index
].idata
;
1649 int valid_p
= (CGEN_INSN_VIRTUAL_P (insn
)
1650 || CGEN_INSN_MACH_HAS_P (insn
, mach_num
));
1653 idesc_table
[sf
->index
].sem_fast
= sf
->fn
;
1655 idesc_table
[sf
->index
].sem_fast
= SEM_FN_NAME (lm32bf
,x_invalid
);
1658 idesc_table
[sf
->index
].sem_full
= sf
->fn
;
1660 idesc_table
[sf
->index
].sem_full
= SEM_FN_NAME (lm32bf
,x_invalid
);