14e98e3e1Schristos /* Simulator instruction semantics for lm32bf. 24e98e3e1Schristos 34e98e3e1Schristos THIS FILE IS MACHINE GENERATED WITH CGEN. 44e98e3e1Schristos 5*71f62182Schristos Copyright (C) 1996-2024 Free Software Foundation, Inc. 64e98e3e1Schristos 74e98e3e1Schristos This file is part of the GNU simulators. 84e98e3e1Schristos 94e98e3e1Schristos This file is free software; you can redistribute it and/or modify 104e98e3e1Schristos it under the terms of the GNU General Public License as published by 114e98e3e1Schristos the Free Software Foundation; either version 3, or (at your option) 124e98e3e1Schristos any later version. 134e98e3e1Schristos 144e98e3e1Schristos It is distributed in the hope that it will be useful, but WITHOUT 154e98e3e1Schristos ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 164e98e3e1Schristos or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 174e98e3e1Schristos License for more details. 184e98e3e1Schristos 194e98e3e1Schristos You should have received a copy of the GNU General Public License along 20*71f62182Schristos with this program; if not, write to the Free Software Foundation, Inc., 21*71f62182Schristos 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. 224e98e3e1Schristos 234e98e3e1Schristos */ 244e98e3e1Schristos 254e98e3e1Schristos #define WANT_CPU lm32bf 264e98e3e1Schristos #define WANT_CPU_LM32BF 274e98e3e1Schristos 284e98e3e1Schristos #include "sim-main.h" 294e98e3e1Schristos #include "cgen-mem.h" 304e98e3e1Schristos #include "cgen-ops.h" 314e98e3e1Schristos 324e98e3e1Schristos #undef GET_ATTR 334e98e3e1Schristos #define GET_ATTR(cpu, num, attr) CGEN_ATTR_VALUE (NULL, abuf->idesc->attrs, CGEN_INSN_##attr) 344e98e3e1Schristos 354e98e3e1Schristos /* This is used so that we can compile two copies of the semantic code, 364e98e3e1Schristos one with full feature support and one without that runs fast(er). 374e98e3e1Schristos FAST_P, when desired, is defined on the command line, -DFAST_P=1. */ 384e98e3e1Schristos #if FAST_P 394e98e3e1Schristos #define SEM_FN_NAME(cpu,fn) XCONCAT3 (cpu,_semf_,fn) 40212397c6Schristos #undef CGEN_TRACE_RESULT 41212397c6Schristos #define CGEN_TRACE_RESULT(cpu, abuf, name, type, val) 424e98e3e1Schristos #else 434e98e3e1Schristos #define SEM_FN_NAME(cpu,fn) XCONCAT3 (cpu,_sem_,fn) 444e98e3e1Schristos #endif 454e98e3e1Schristos 464e98e3e1Schristos /* x-invalid: --invalid-- */ 474e98e3e1Schristos 484e98e3e1Schristos static SEM_PC 494e98e3e1Schristos SEM_FN_NAME (lm32bf,x_invalid) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 504e98e3e1Schristos { 514e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_empty.f 524e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 534e98e3e1Schristos int UNUSED written = 0; 544e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 554e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 0); 564e98e3e1Schristos 574e98e3e1Schristos { 584e98e3e1Schristos /* Update the recorded pc in the cpu state struct. 594e98e3e1Schristos Only necessary for WITH_SCACHE case, but to avoid the 604e98e3e1Schristos conditional compilation .... */ 614e98e3e1Schristos SET_H_PC (pc); 624e98e3e1Schristos /* Virtual insns have zero size. Overwrite vpc with address of next insn 634e98e3e1Schristos using the default-insn-bitsize spec. When executing insns in parallel 644e98e3e1Schristos we may want to queue the fault and continue execution. */ 654e98e3e1Schristos vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 664e98e3e1Schristos vpc = sim_engine_invalid_insn (current_cpu, pc, vpc); 674e98e3e1Schristos } 684e98e3e1Schristos 694e98e3e1Schristos return vpc; 704e98e3e1Schristos #undef FLD 714e98e3e1Schristos } 724e98e3e1Schristos 734e98e3e1Schristos /* x-after: --after-- */ 744e98e3e1Schristos 754e98e3e1Schristos static SEM_PC 764e98e3e1Schristos SEM_FN_NAME (lm32bf,x_after) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 774e98e3e1Schristos { 784e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_empty.f 794e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 804e98e3e1Schristos int UNUSED written = 0; 814e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 824e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 0); 834e98e3e1Schristos 844e98e3e1Schristos { 854e98e3e1Schristos #if WITH_SCACHE_PBB_LM32BF 864e98e3e1Schristos lm32bf_pbb_after (current_cpu, sem_arg); 874e98e3e1Schristos #endif 884e98e3e1Schristos } 894e98e3e1Schristos 904e98e3e1Schristos return vpc; 914e98e3e1Schristos #undef FLD 924e98e3e1Schristos } 934e98e3e1Schristos 944e98e3e1Schristos /* x-before: --before-- */ 954e98e3e1Schristos 964e98e3e1Schristos static SEM_PC 974e98e3e1Schristos SEM_FN_NAME (lm32bf,x_before) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 984e98e3e1Schristos { 994e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_empty.f 1004e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 1014e98e3e1Schristos int UNUSED written = 0; 1024e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 1034e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 0); 1044e98e3e1Schristos 1054e98e3e1Schristos { 1064e98e3e1Schristos #if WITH_SCACHE_PBB_LM32BF 1074e98e3e1Schristos lm32bf_pbb_before (current_cpu, sem_arg); 1084e98e3e1Schristos #endif 1094e98e3e1Schristos } 1104e98e3e1Schristos 1114e98e3e1Schristos return vpc; 1124e98e3e1Schristos #undef FLD 1134e98e3e1Schristos } 1144e98e3e1Schristos 1154e98e3e1Schristos /* x-cti-chain: --cti-chain-- */ 1164e98e3e1Schristos 1174e98e3e1Schristos static SEM_PC 1184e98e3e1Schristos SEM_FN_NAME (lm32bf,x_cti_chain) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 1194e98e3e1Schristos { 1204e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_empty.f 1214e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 1224e98e3e1Schristos int UNUSED written = 0; 1234e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 1244e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 0); 1254e98e3e1Schristos 1264e98e3e1Schristos { 1274e98e3e1Schristos #if WITH_SCACHE_PBB_LM32BF 1284e98e3e1Schristos #ifdef DEFINE_SWITCH 1294e98e3e1Schristos vpc = lm32bf_pbb_cti_chain (current_cpu, sem_arg, 1304e98e3e1Schristos pbb_br_type, pbb_br_npc); 1314e98e3e1Schristos BREAK (sem); 1324e98e3e1Schristos #else 1334e98e3e1Schristos /* FIXME: Allow provision of explicit ifmt spec in insn spec. */ 1344e98e3e1Schristos vpc = lm32bf_pbb_cti_chain (current_cpu, sem_arg, 1354e98e3e1Schristos CPU_PBB_BR_TYPE (current_cpu), 1364e98e3e1Schristos CPU_PBB_BR_NPC (current_cpu)); 1374e98e3e1Schristos #endif 1384e98e3e1Schristos #endif 1394e98e3e1Schristos } 1404e98e3e1Schristos 1414e98e3e1Schristos return vpc; 1424e98e3e1Schristos #undef FLD 1434e98e3e1Schristos } 1444e98e3e1Schristos 1454e98e3e1Schristos /* x-chain: --chain-- */ 1464e98e3e1Schristos 1474e98e3e1Schristos static SEM_PC 1484e98e3e1Schristos SEM_FN_NAME (lm32bf,x_chain) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 1494e98e3e1Schristos { 1504e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_empty.f 1514e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 1524e98e3e1Schristos int UNUSED written = 0; 1534e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 1544e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 0); 1554e98e3e1Schristos 1564e98e3e1Schristos { 1574e98e3e1Schristos #if WITH_SCACHE_PBB_LM32BF 1584e98e3e1Schristos vpc = lm32bf_pbb_chain (current_cpu, sem_arg); 1594e98e3e1Schristos #ifdef DEFINE_SWITCH 1604e98e3e1Schristos BREAK (sem); 1614e98e3e1Schristos #endif 1624e98e3e1Schristos #endif 1634e98e3e1Schristos } 1644e98e3e1Schristos 1654e98e3e1Schristos return vpc; 1664e98e3e1Schristos #undef FLD 1674e98e3e1Schristos } 1684e98e3e1Schristos 1694e98e3e1Schristos /* x-begin: --begin-- */ 1704e98e3e1Schristos 1714e98e3e1Schristos static SEM_PC 1724e98e3e1Schristos SEM_FN_NAME (lm32bf,x_begin) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 1734e98e3e1Schristos { 1744e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_empty.f 1754e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 1764e98e3e1Schristos int UNUSED written = 0; 1774e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 1784e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 0); 1794e98e3e1Schristos 1804e98e3e1Schristos { 1814e98e3e1Schristos #if WITH_SCACHE_PBB_LM32BF 1824e98e3e1Schristos #if defined DEFINE_SWITCH || defined FAST_P 1834e98e3e1Schristos /* In the switch case FAST_P is a constant, allowing several optimizations 1844e98e3e1Schristos in any called inline functions. */ 1854e98e3e1Schristos vpc = lm32bf_pbb_begin (current_cpu, FAST_P); 1864e98e3e1Schristos #else 1874e98e3e1Schristos #if 0 /* cgen engine can't handle dynamic fast/full switching yet. */ 1884e98e3e1Schristos vpc = lm32bf_pbb_begin (current_cpu, STATE_RUN_FAST_P (CPU_STATE (current_cpu))); 1894e98e3e1Schristos #else 1904e98e3e1Schristos vpc = lm32bf_pbb_begin (current_cpu, 0); 1914e98e3e1Schristos #endif 1924e98e3e1Schristos #endif 1934e98e3e1Schristos #endif 1944e98e3e1Schristos } 1954e98e3e1Schristos 1964e98e3e1Schristos return vpc; 1974e98e3e1Schristos #undef FLD 1984e98e3e1Schristos } 1994e98e3e1Schristos 2004e98e3e1Schristos /* add: add $r2,$r0,$r1 */ 2014e98e3e1Schristos 2024e98e3e1Schristos static SEM_PC 2034e98e3e1Schristos SEM_FN_NAME (lm32bf,add) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 2044e98e3e1Schristos { 2054e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_user.f 2064e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 2074e98e3e1Schristos int UNUSED written = 0; 2084e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 2094e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 2104e98e3e1Schristos 2114e98e3e1Schristos { 2124e98e3e1Schristos SI opval = ADDSI (CPU (h_gr[FLD (f_r0)]), CPU (h_gr[FLD (f_r1)])); 2134e98e3e1Schristos CPU (h_gr[FLD (f_r2)]) = opval; 214212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 2154e98e3e1Schristos } 2164e98e3e1Schristos 2174e98e3e1Schristos return vpc; 2184e98e3e1Schristos #undef FLD 2194e98e3e1Schristos } 2204e98e3e1Schristos 2214e98e3e1Schristos /* addi: addi $r1,$r0,$imm */ 2224e98e3e1Schristos 2234e98e3e1Schristos static SEM_PC 2244e98e3e1Schristos SEM_FN_NAME (lm32bf,addi) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 2254e98e3e1Schristos { 2264e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_addi.f 2274e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 2284e98e3e1Schristos int UNUSED written = 0; 2294e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 2304e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 2314e98e3e1Schristos 2324e98e3e1Schristos { 2334e98e3e1Schristos SI opval = ADDSI (CPU (h_gr[FLD (f_r0)]), EXTHISI (TRUNCSIHI (FLD (f_imm)))); 2344e98e3e1Schristos CPU (h_gr[FLD (f_r1)]) = opval; 235212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 2364e98e3e1Schristos } 2374e98e3e1Schristos 2384e98e3e1Schristos return vpc; 2394e98e3e1Schristos #undef FLD 2404e98e3e1Schristos } 2414e98e3e1Schristos 2424e98e3e1Schristos /* and: and $r2,$r0,$r1 */ 2434e98e3e1Schristos 2444e98e3e1Schristos static SEM_PC 2454e98e3e1Schristos SEM_FN_NAME (lm32bf,and) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 2464e98e3e1Schristos { 2474e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_user.f 2484e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 2494e98e3e1Schristos int UNUSED written = 0; 2504e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 2514e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 2524e98e3e1Schristos 2534e98e3e1Schristos { 2544e98e3e1Schristos SI opval = ANDSI (CPU (h_gr[FLD (f_r0)]), CPU (h_gr[FLD (f_r1)])); 2554e98e3e1Schristos CPU (h_gr[FLD (f_r2)]) = opval; 256212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 2574e98e3e1Schristos } 2584e98e3e1Schristos 2594e98e3e1Schristos return vpc; 2604e98e3e1Schristos #undef FLD 2614e98e3e1Schristos } 2624e98e3e1Schristos 2634e98e3e1Schristos /* andi: andi $r1,$r0,$uimm */ 2644e98e3e1Schristos 2654e98e3e1Schristos static SEM_PC 2664e98e3e1Schristos SEM_FN_NAME (lm32bf,andi) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 2674e98e3e1Schristos { 2684e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_andi.f 2694e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 2704e98e3e1Schristos int UNUSED written = 0; 2714e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 2724e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 2734e98e3e1Schristos 2744e98e3e1Schristos { 2754e98e3e1Schristos SI opval = ANDSI (CPU (h_gr[FLD (f_r0)]), ZEXTSISI (FLD (f_uimm))); 2764e98e3e1Schristos CPU (h_gr[FLD (f_r1)]) = opval; 277212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 2784e98e3e1Schristos } 2794e98e3e1Schristos 2804e98e3e1Schristos return vpc; 2814e98e3e1Schristos #undef FLD 2824e98e3e1Schristos } 2834e98e3e1Schristos 2844e98e3e1Schristos /* andhii: andhi $r1,$r0,$hi16 */ 2854e98e3e1Schristos 2864e98e3e1Schristos static SEM_PC 2874e98e3e1Schristos SEM_FN_NAME (lm32bf,andhii) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 2884e98e3e1Schristos { 2894e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_andi.f 2904e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 2914e98e3e1Schristos int UNUSED written = 0; 2924e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 2934e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 2944e98e3e1Schristos 2954e98e3e1Schristos { 2964e98e3e1Schristos SI opval = ANDSI (CPU (h_gr[FLD (f_r0)]), SLLSI (FLD (f_uimm), 16)); 2974e98e3e1Schristos CPU (h_gr[FLD (f_r1)]) = opval; 298212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 2994e98e3e1Schristos } 3004e98e3e1Schristos 3014e98e3e1Schristos return vpc; 3024e98e3e1Schristos #undef FLD 3034e98e3e1Schristos } 3044e98e3e1Schristos 3054e98e3e1Schristos /* b: b $r0 */ 3064e98e3e1Schristos 3074e98e3e1Schristos static SEM_PC 3084e98e3e1Schristos SEM_FN_NAME (lm32bf,b) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 3094e98e3e1Schristos { 3104e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_be.f 3114e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 3124e98e3e1Schristos int UNUSED written = 0; 3134e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 3144e98e3e1Schristos SEM_BRANCH_INIT 3154e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 3164e98e3e1Schristos 3174e98e3e1Schristos { 3184e98e3e1Schristos USI opval = lm32bf_b_insn (current_cpu, CPU (h_gr[FLD (f_r0)]), FLD (f_r0)); 3194e98e3e1Schristos SEM_BRANCH_VIA_ADDR (current_cpu, sem_arg, opval, vpc); 320212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "pc", 'x', opval); 3214e98e3e1Schristos } 3224e98e3e1Schristos 3234e98e3e1Schristos SEM_BRANCH_FINI (vpc); 3244e98e3e1Schristos return vpc; 3254e98e3e1Schristos #undef FLD 3264e98e3e1Schristos } 3274e98e3e1Schristos 3284e98e3e1Schristos /* bi: bi $call */ 3294e98e3e1Schristos 3304e98e3e1Schristos static SEM_PC 3314e98e3e1Schristos SEM_FN_NAME (lm32bf,bi) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 3324e98e3e1Schristos { 3334e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_bi.f 3344e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 3354e98e3e1Schristos int UNUSED written = 0; 3364e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 3374e98e3e1Schristos SEM_BRANCH_INIT 3384e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 3394e98e3e1Schristos 3404e98e3e1Schristos { 3414e98e3e1Schristos USI opval = EXTSISI (FLD (i_call)); 3424e98e3e1Schristos SEM_BRANCH_VIA_ADDR (current_cpu, sem_arg, opval, vpc); 343212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "pc", 'x', opval); 3444e98e3e1Schristos } 3454e98e3e1Schristos 3464e98e3e1Schristos SEM_BRANCH_FINI (vpc); 3474e98e3e1Schristos return vpc; 3484e98e3e1Schristos #undef FLD 3494e98e3e1Schristos } 3504e98e3e1Schristos 3514e98e3e1Schristos /* be: be $r0,$r1,$branch */ 3524e98e3e1Schristos 3534e98e3e1Schristos static SEM_PC 3544e98e3e1Schristos SEM_FN_NAME (lm32bf,be) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 3554e98e3e1Schristos { 3564e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_be.f 3574e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 3584e98e3e1Schristos int UNUSED written = 0; 3594e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 3604e98e3e1Schristos SEM_BRANCH_INIT 3614e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 3624e98e3e1Schristos 3634e98e3e1Schristos if (EQSI (CPU (h_gr[FLD (f_r0)]), CPU (h_gr[FLD (f_r1)]))) { 3644e98e3e1Schristos { 3654e98e3e1Schristos USI opval = FLD (i_branch); 3664e98e3e1Schristos SEM_BRANCH_VIA_CACHE (current_cpu, sem_arg, opval, vpc); 3674e98e3e1Schristos written |= (1 << 3); 368212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "pc", 'x', opval); 3694e98e3e1Schristos } 3704e98e3e1Schristos } 3714e98e3e1Schristos 3724e98e3e1Schristos abuf->written = written; 3734e98e3e1Schristos SEM_BRANCH_FINI (vpc); 3744e98e3e1Schristos return vpc; 3754e98e3e1Schristos #undef FLD 3764e98e3e1Schristos } 3774e98e3e1Schristos 3784e98e3e1Schristos /* bg: bg $r0,$r1,$branch */ 3794e98e3e1Schristos 3804e98e3e1Schristos static SEM_PC 3814e98e3e1Schristos SEM_FN_NAME (lm32bf,bg) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 3824e98e3e1Schristos { 3834e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_be.f 3844e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 3854e98e3e1Schristos int UNUSED written = 0; 3864e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 3874e98e3e1Schristos SEM_BRANCH_INIT 3884e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 3894e98e3e1Schristos 3904e98e3e1Schristos if (GTSI (CPU (h_gr[FLD (f_r0)]), CPU (h_gr[FLD (f_r1)]))) { 3914e98e3e1Schristos { 3924e98e3e1Schristos USI opval = FLD (i_branch); 3934e98e3e1Schristos SEM_BRANCH_VIA_CACHE (current_cpu, sem_arg, opval, vpc); 3944e98e3e1Schristos written |= (1 << 3); 395212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "pc", 'x', opval); 3964e98e3e1Schristos } 3974e98e3e1Schristos } 3984e98e3e1Schristos 3994e98e3e1Schristos abuf->written = written; 4004e98e3e1Schristos SEM_BRANCH_FINI (vpc); 4014e98e3e1Schristos return vpc; 4024e98e3e1Schristos #undef FLD 4034e98e3e1Schristos } 4044e98e3e1Schristos 4054e98e3e1Schristos /* bge: bge $r0,$r1,$branch */ 4064e98e3e1Schristos 4074e98e3e1Schristos static SEM_PC 4084e98e3e1Schristos SEM_FN_NAME (lm32bf,bge) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 4094e98e3e1Schristos { 4104e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_be.f 4114e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 4124e98e3e1Schristos int UNUSED written = 0; 4134e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 4144e98e3e1Schristos SEM_BRANCH_INIT 4154e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 4164e98e3e1Schristos 4174e98e3e1Schristos if (GESI (CPU (h_gr[FLD (f_r0)]), CPU (h_gr[FLD (f_r1)]))) { 4184e98e3e1Schristos { 4194e98e3e1Schristos USI opval = FLD (i_branch); 4204e98e3e1Schristos SEM_BRANCH_VIA_CACHE (current_cpu, sem_arg, opval, vpc); 4214e98e3e1Schristos written |= (1 << 3); 422212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "pc", 'x', opval); 4234e98e3e1Schristos } 4244e98e3e1Schristos } 4254e98e3e1Schristos 4264e98e3e1Schristos abuf->written = written; 4274e98e3e1Schristos SEM_BRANCH_FINI (vpc); 4284e98e3e1Schristos return vpc; 4294e98e3e1Schristos #undef FLD 4304e98e3e1Schristos } 4314e98e3e1Schristos 4324e98e3e1Schristos /* bgeu: bgeu $r0,$r1,$branch */ 4334e98e3e1Schristos 4344e98e3e1Schristos static SEM_PC 4354e98e3e1Schristos SEM_FN_NAME (lm32bf,bgeu) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 4364e98e3e1Schristos { 4374e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_be.f 4384e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 4394e98e3e1Schristos int UNUSED written = 0; 4404e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 4414e98e3e1Schristos SEM_BRANCH_INIT 4424e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 4434e98e3e1Schristos 4444e98e3e1Schristos if (GEUSI (CPU (h_gr[FLD (f_r0)]), CPU (h_gr[FLD (f_r1)]))) { 4454e98e3e1Schristos { 4464e98e3e1Schristos USI opval = FLD (i_branch); 4474e98e3e1Schristos SEM_BRANCH_VIA_CACHE (current_cpu, sem_arg, opval, vpc); 4484e98e3e1Schristos written |= (1 << 3); 449212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "pc", 'x', opval); 4504e98e3e1Schristos } 4514e98e3e1Schristos } 4524e98e3e1Schristos 4534e98e3e1Schristos abuf->written = written; 4544e98e3e1Schristos SEM_BRANCH_FINI (vpc); 4554e98e3e1Schristos return vpc; 4564e98e3e1Schristos #undef FLD 4574e98e3e1Schristos } 4584e98e3e1Schristos 4594e98e3e1Schristos /* bgu: bgu $r0,$r1,$branch */ 4604e98e3e1Schristos 4614e98e3e1Schristos static SEM_PC 4624e98e3e1Schristos SEM_FN_NAME (lm32bf,bgu) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 4634e98e3e1Schristos { 4644e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_be.f 4654e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 4664e98e3e1Schristos int UNUSED written = 0; 4674e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 4684e98e3e1Schristos SEM_BRANCH_INIT 4694e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 4704e98e3e1Schristos 4714e98e3e1Schristos if (GTUSI (CPU (h_gr[FLD (f_r0)]), CPU (h_gr[FLD (f_r1)]))) { 4724e98e3e1Schristos { 4734e98e3e1Schristos USI opval = FLD (i_branch); 4744e98e3e1Schristos SEM_BRANCH_VIA_CACHE (current_cpu, sem_arg, opval, vpc); 4754e98e3e1Schristos written |= (1 << 3); 476212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "pc", 'x', opval); 4774e98e3e1Schristos } 4784e98e3e1Schristos } 4794e98e3e1Schristos 4804e98e3e1Schristos abuf->written = written; 4814e98e3e1Schristos SEM_BRANCH_FINI (vpc); 4824e98e3e1Schristos return vpc; 4834e98e3e1Schristos #undef FLD 4844e98e3e1Schristos } 4854e98e3e1Schristos 4864e98e3e1Schristos /* bne: bne $r0,$r1,$branch */ 4874e98e3e1Schristos 4884e98e3e1Schristos static SEM_PC 4894e98e3e1Schristos SEM_FN_NAME (lm32bf,bne) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 4904e98e3e1Schristos { 4914e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_be.f 4924e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 4934e98e3e1Schristos int UNUSED written = 0; 4944e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 4954e98e3e1Schristos SEM_BRANCH_INIT 4964e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 4974e98e3e1Schristos 4984e98e3e1Schristos if (NESI (CPU (h_gr[FLD (f_r0)]), CPU (h_gr[FLD (f_r1)]))) { 4994e98e3e1Schristos { 5004e98e3e1Schristos USI opval = FLD (i_branch); 5014e98e3e1Schristos SEM_BRANCH_VIA_CACHE (current_cpu, sem_arg, opval, vpc); 5024e98e3e1Schristos written |= (1 << 3); 503212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "pc", 'x', opval); 5044e98e3e1Schristos } 5054e98e3e1Schristos } 5064e98e3e1Schristos 5074e98e3e1Schristos abuf->written = written; 5084e98e3e1Schristos SEM_BRANCH_FINI (vpc); 5094e98e3e1Schristos return vpc; 5104e98e3e1Schristos #undef FLD 5114e98e3e1Schristos } 5124e98e3e1Schristos 5134e98e3e1Schristos /* call: call $r0 */ 5144e98e3e1Schristos 5154e98e3e1Schristos static SEM_PC 5164e98e3e1Schristos SEM_FN_NAME (lm32bf,call) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 5174e98e3e1Schristos { 5184e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_be.f 5194e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 5204e98e3e1Schristos int UNUSED written = 0; 5214e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 5224e98e3e1Schristos SEM_BRANCH_INIT 5234e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 5244e98e3e1Schristos 5254e98e3e1Schristos { 5264e98e3e1Schristos { 5274e98e3e1Schristos SI opval = ADDSI (pc, 4); 5284e98e3e1Schristos CPU (h_gr[((UINT) 29)]) = opval; 529212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 5304e98e3e1Schristos } 5314e98e3e1Schristos { 5324e98e3e1Schristos USI opval = CPU (h_gr[FLD (f_r0)]); 5334e98e3e1Schristos SEM_BRANCH_VIA_ADDR (current_cpu, sem_arg, opval, vpc); 534212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "pc", 'x', opval); 5354e98e3e1Schristos } 5364e98e3e1Schristos } 5374e98e3e1Schristos 5384e98e3e1Schristos SEM_BRANCH_FINI (vpc); 5394e98e3e1Schristos return vpc; 5404e98e3e1Schristos #undef FLD 5414e98e3e1Schristos } 5424e98e3e1Schristos 5434e98e3e1Schristos /* calli: calli $call */ 5444e98e3e1Schristos 5454e98e3e1Schristos static SEM_PC 5464e98e3e1Schristos SEM_FN_NAME (lm32bf,calli) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 5474e98e3e1Schristos { 5484e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_bi.f 5494e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 5504e98e3e1Schristos int UNUSED written = 0; 5514e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 5524e98e3e1Schristos SEM_BRANCH_INIT 5534e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 5544e98e3e1Schristos 5554e98e3e1Schristos { 5564e98e3e1Schristos { 5574e98e3e1Schristos SI opval = ADDSI (pc, 4); 5584e98e3e1Schristos CPU (h_gr[((UINT) 29)]) = opval; 559212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 5604e98e3e1Schristos } 5614e98e3e1Schristos { 5624e98e3e1Schristos USI opval = EXTSISI (FLD (i_call)); 5634e98e3e1Schristos SEM_BRANCH_VIA_ADDR (current_cpu, sem_arg, opval, vpc); 564212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "pc", 'x', opval); 5654e98e3e1Schristos } 5664e98e3e1Schristos } 5674e98e3e1Schristos 5684e98e3e1Schristos SEM_BRANCH_FINI (vpc); 5694e98e3e1Schristos return vpc; 5704e98e3e1Schristos #undef FLD 5714e98e3e1Schristos } 5724e98e3e1Schristos 5734e98e3e1Schristos /* cmpe: cmpe $r2,$r0,$r1 */ 5744e98e3e1Schristos 5754e98e3e1Schristos static SEM_PC 5764e98e3e1Schristos SEM_FN_NAME (lm32bf,cmpe) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 5774e98e3e1Schristos { 5784e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_user.f 5794e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 5804e98e3e1Schristos int UNUSED written = 0; 5814e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 5824e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 5834e98e3e1Schristos 5844e98e3e1Schristos { 5854e98e3e1Schristos SI opval = EQSI (CPU (h_gr[FLD (f_r0)]), CPU (h_gr[FLD (f_r1)])); 5864e98e3e1Schristos CPU (h_gr[FLD (f_r2)]) = opval; 587212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 5884e98e3e1Schristos } 5894e98e3e1Schristos 5904e98e3e1Schristos return vpc; 5914e98e3e1Schristos #undef FLD 5924e98e3e1Schristos } 5934e98e3e1Schristos 5944e98e3e1Schristos /* cmpei: cmpei $r1,$r0,$imm */ 5954e98e3e1Schristos 5964e98e3e1Schristos static SEM_PC 5974e98e3e1Schristos SEM_FN_NAME (lm32bf,cmpei) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 5984e98e3e1Schristos { 5994e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_addi.f 6004e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 6014e98e3e1Schristos int UNUSED written = 0; 6024e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 6034e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 6044e98e3e1Schristos 6054e98e3e1Schristos { 6064e98e3e1Schristos SI opval = EQSI (CPU (h_gr[FLD (f_r0)]), EXTHISI (TRUNCSIHI (FLD (f_imm)))); 6074e98e3e1Schristos CPU (h_gr[FLD (f_r1)]) = opval; 608212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 6094e98e3e1Schristos } 6104e98e3e1Schristos 6114e98e3e1Schristos return vpc; 6124e98e3e1Schristos #undef FLD 6134e98e3e1Schristos } 6144e98e3e1Schristos 6154e98e3e1Schristos /* cmpg: cmpg $r2,$r0,$r1 */ 6164e98e3e1Schristos 6174e98e3e1Schristos static SEM_PC 6184e98e3e1Schristos SEM_FN_NAME (lm32bf,cmpg) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 6194e98e3e1Schristos { 6204e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_user.f 6214e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 6224e98e3e1Schristos int UNUSED written = 0; 6234e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 6244e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 6254e98e3e1Schristos 6264e98e3e1Schristos { 6274e98e3e1Schristos SI opval = GTSI (CPU (h_gr[FLD (f_r0)]), CPU (h_gr[FLD (f_r1)])); 6284e98e3e1Schristos CPU (h_gr[FLD (f_r2)]) = opval; 629212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 6304e98e3e1Schristos } 6314e98e3e1Schristos 6324e98e3e1Schristos return vpc; 6334e98e3e1Schristos #undef FLD 6344e98e3e1Schristos } 6354e98e3e1Schristos 6364e98e3e1Schristos /* cmpgi: cmpgi $r1,$r0,$imm */ 6374e98e3e1Schristos 6384e98e3e1Schristos static SEM_PC 6394e98e3e1Schristos SEM_FN_NAME (lm32bf,cmpgi) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 6404e98e3e1Schristos { 6414e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_addi.f 6424e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 6434e98e3e1Schristos int UNUSED written = 0; 6444e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 6454e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 6464e98e3e1Schristos 6474e98e3e1Schristos { 6484e98e3e1Schristos SI opval = GTSI (CPU (h_gr[FLD (f_r0)]), EXTHISI (TRUNCSIHI (FLD (f_imm)))); 6494e98e3e1Schristos CPU (h_gr[FLD (f_r1)]) = opval; 650212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 6514e98e3e1Schristos } 6524e98e3e1Schristos 6534e98e3e1Schristos return vpc; 6544e98e3e1Schristos #undef FLD 6554e98e3e1Schristos } 6564e98e3e1Schristos 6574e98e3e1Schristos /* cmpge: cmpge $r2,$r0,$r1 */ 6584e98e3e1Schristos 6594e98e3e1Schristos static SEM_PC 6604e98e3e1Schristos SEM_FN_NAME (lm32bf,cmpge) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 6614e98e3e1Schristos { 6624e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_user.f 6634e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 6644e98e3e1Schristos int UNUSED written = 0; 6654e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 6664e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 6674e98e3e1Schristos 6684e98e3e1Schristos { 6694e98e3e1Schristos SI opval = GESI (CPU (h_gr[FLD (f_r0)]), CPU (h_gr[FLD (f_r1)])); 6704e98e3e1Schristos CPU (h_gr[FLD (f_r2)]) = opval; 671212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 6724e98e3e1Schristos } 6734e98e3e1Schristos 6744e98e3e1Schristos return vpc; 6754e98e3e1Schristos #undef FLD 6764e98e3e1Schristos } 6774e98e3e1Schristos 6784e98e3e1Schristos /* cmpgei: cmpgei $r1,$r0,$imm */ 6794e98e3e1Schristos 6804e98e3e1Schristos static SEM_PC 6814e98e3e1Schristos SEM_FN_NAME (lm32bf,cmpgei) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 6824e98e3e1Schristos { 6834e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_addi.f 6844e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 6854e98e3e1Schristos int UNUSED written = 0; 6864e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 6874e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 6884e98e3e1Schristos 6894e98e3e1Schristos { 6904e98e3e1Schristos SI opval = GESI (CPU (h_gr[FLD (f_r0)]), EXTHISI (TRUNCSIHI (FLD (f_imm)))); 6914e98e3e1Schristos CPU (h_gr[FLD (f_r1)]) = opval; 692212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 6934e98e3e1Schristos } 6944e98e3e1Schristos 6954e98e3e1Schristos return vpc; 6964e98e3e1Schristos #undef FLD 6974e98e3e1Schristos } 6984e98e3e1Schristos 6994e98e3e1Schristos /* cmpgeu: cmpgeu $r2,$r0,$r1 */ 7004e98e3e1Schristos 7014e98e3e1Schristos static SEM_PC 7024e98e3e1Schristos SEM_FN_NAME (lm32bf,cmpgeu) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 7034e98e3e1Schristos { 7044e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_user.f 7054e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 7064e98e3e1Schristos int UNUSED written = 0; 7074e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 7084e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 7094e98e3e1Schristos 7104e98e3e1Schristos { 7114e98e3e1Schristos SI opval = GEUSI (CPU (h_gr[FLD (f_r0)]), CPU (h_gr[FLD (f_r1)])); 7124e98e3e1Schristos CPU (h_gr[FLD (f_r2)]) = opval; 713212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 7144e98e3e1Schristos } 7154e98e3e1Schristos 7164e98e3e1Schristos return vpc; 7174e98e3e1Schristos #undef FLD 7184e98e3e1Schristos } 7194e98e3e1Schristos 7204e98e3e1Schristos /* cmpgeui: cmpgeui $r1,$r0,$uimm */ 7214e98e3e1Schristos 7224e98e3e1Schristos static SEM_PC 7234e98e3e1Schristos SEM_FN_NAME (lm32bf,cmpgeui) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 7244e98e3e1Schristos { 7254e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_andi.f 7264e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 7274e98e3e1Schristos int UNUSED written = 0; 7284e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 7294e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 7304e98e3e1Schristos 7314e98e3e1Schristos { 7324e98e3e1Schristos SI opval = GEUSI (CPU (h_gr[FLD (f_r0)]), ZEXTSISI (FLD (f_uimm))); 7334e98e3e1Schristos CPU (h_gr[FLD (f_r1)]) = opval; 734212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 7354e98e3e1Schristos } 7364e98e3e1Schristos 7374e98e3e1Schristos return vpc; 7384e98e3e1Schristos #undef FLD 7394e98e3e1Schristos } 7404e98e3e1Schristos 7414e98e3e1Schristos /* cmpgu: cmpgu $r2,$r0,$r1 */ 7424e98e3e1Schristos 7434e98e3e1Schristos static SEM_PC 7444e98e3e1Schristos SEM_FN_NAME (lm32bf,cmpgu) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 7454e98e3e1Schristos { 7464e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_user.f 7474e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 7484e98e3e1Schristos int UNUSED written = 0; 7494e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 7504e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 7514e98e3e1Schristos 7524e98e3e1Schristos { 7534e98e3e1Schristos SI opval = GTUSI (CPU (h_gr[FLD (f_r0)]), CPU (h_gr[FLD (f_r1)])); 7544e98e3e1Schristos CPU (h_gr[FLD (f_r2)]) = opval; 755212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 7564e98e3e1Schristos } 7574e98e3e1Schristos 7584e98e3e1Schristos return vpc; 7594e98e3e1Schristos #undef FLD 7604e98e3e1Schristos } 7614e98e3e1Schristos 7624e98e3e1Schristos /* cmpgui: cmpgui $r1,$r0,$uimm */ 7634e98e3e1Schristos 7644e98e3e1Schristos static SEM_PC 7654e98e3e1Schristos SEM_FN_NAME (lm32bf,cmpgui) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 7664e98e3e1Schristos { 7674e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_andi.f 7684e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 7694e98e3e1Schristos int UNUSED written = 0; 7704e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 7714e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 7724e98e3e1Schristos 7734e98e3e1Schristos { 7744e98e3e1Schristos SI opval = GTUSI (CPU (h_gr[FLD (f_r0)]), ZEXTSISI (FLD (f_uimm))); 7754e98e3e1Schristos CPU (h_gr[FLD (f_r1)]) = opval; 776212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 7774e98e3e1Schristos } 7784e98e3e1Schristos 7794e98e3e1Schristos return vpc; 7804e98e3e1Schristos #undef FLD 7814e98e3e1Schristos } 7824e98e3e1Schristos 7834e98e3e1Schristos /* cmpne: cmpne $r2,$r0,$r1 */ 7844e98e3e1Schristos 7854e98e3e1Schristos static SEM_PC 7864e98e3e1Schristos SEM_FN_NAME (lm32bf,cmpne) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 7874e98e3e1Schristos { 7884e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_user.f 7894e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 7904e98e3e1Schristos int UNUSED written = 0; 7914e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 7924e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 7934e98e3e1Schristos 7944e98e3e1Schristos { 7954e98e3e1Schristos SI opval = NESI (CPU (h_gr[FLD (f_r0)]), CPU (h_gr[FLD (f_r1)])); 7964e98e3e1Schristos CPU (h_gr[FLD (f_r2)]) = opval; 797212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 7984e98e3e1Schristos } 7994e98e3e1Schristos 8004e98e3e1Schristos return vpc; 8014e98e3e1Schristos #undef FLD 8024e98e3e1Schristos } 8034e98e3e1Schristos 8044e98e3e1Schristos /* cmpnei: cmpnei $r1,$r0,$imm */ 8054e98e3e1Schristos 8064e98e3e1Schristos static SEM_PC 8074e98e3e1Schristos SEM_FN_NAME (lm32bf,cmpnei) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 8084e98e3e1Schristos { 8094e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_addi.f 8104e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 8114e98e3e1Schristos int UNUSED written = 0; 8124e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 8134e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 8144e98e3e1Schristos 8154e98e3e1Schristos { 8164e98e3e1Schristos SI opval = NESI (CPU (h_gr[FLD (f_r0)]), EXTHISI (TRUNCSIHI (FLD (f_imm)))); 8174e98e3e1Schristos CPU (h_gr[FLD (f_r1)]) = opval; 818212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 8194e98e3e1Schristos } 8204e98e3e1Schristos 8214e98e3e1Schristos return vpc; 8224e98e3e1Schristos #undef FLD 8234e98e3e1Schristos } 8244e98e3e1Schristos 8254e98e3e1Schristos /* divu: divu $r2,$r0,$r1 */ 8264e98e3e1Schristos 8274e98e3e1Schristos static SEM_PC 8284e98e3e1Schristos SEM_FN_NAME (lm32bf,divu) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 8294e98e3e1Schristos { 8304e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_user.f 8314e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 8324e98e3e1Schristos int UNUSED written = 0; 8334e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 8344e98e3e1Schristos SEM_BRANCH_INIT 8354e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 8364e98e3e1Schristos 8374e98e3e1Schristos { 8384e98e3e1Schristos USI opval = lm32bf_divu_insn (current_cpu, pc, FLD (f_r0), FLD (f_r1), FLD (f_r2)); 8394e98e3e1Schristos SEM_BRANCH_VIA_ADDR (current_cpu, sem_arg, opval, vpc); 840212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "pc", 'x', opval); 8414e98e3e1Schristos } 8424e98e3e1Schristos 8434e98e3e1Schristos SEM_BRANCH_FINI (vpc); 8444e98e3e1Schristos return vpc; 8454e98e3e1Schristos #undef FLD 8464e98e3e1Schristos } 8474e98e3e1Schristos 8484e98e3e1Schristos /* lb: lb $r1,($r0+$imm) */ 8494e98e3e1Schristos 8504e98e3e1Schristos static SEM_PC 8514e98e3e1Schristos SEM_FN_NAME (lm32bf,lb) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 8524e98e3e1Schristos { 8534e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_addi.f 8544e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 8554e98e3e1Schristos int UNUSED written = 0; 8564e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 8574e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 8584e98e3e1Schristos 8594e98e3e1Schristos { 8604e98e3e1Schristos SI opval = EXTQISI (GETMEMQI (current_cpu, pc, ADDSI (CPU (h_gr[FLD (f_r0)]), EXTHISI (TRUNCSIHI (FLD (f_imm)))))); 8614e98e3e1Schristos CPU (h_gr[FLD (f_r1)]) = opval; 862212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 8634e98e3e1Schristos } 8644e98e3e1Schristos 8654e98e3e1Schristos return vpc; 8664e98e3e1Schristos #undef FLD 8674e98e3e1Schristos } 8684e98e3e1Schristos 8694e98e3e1Schristos /* lbu: lbu $r1,($r0+$imm) */ 8704e98e3e1Schristos 8714e98e3e1Schristos static SEM_PC 8724e98e3e1Schristos SEM_FN_NAME (lm32bf,lbu) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 8734e98e3e1Schristos { 8744e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_addi.f 8754e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 8764e98e3e1Schristos int UNUSED written = 0; 8774e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 8784e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 8794e98e3e1Schristos 8804e98e3e1Schristos { 8814e98e3e1Schristos SI opval = ZEXTQISI (GETMEMQI (current_cpu, pc, ADDSI (CPU (h_gr[FLD (f_r0)]), EXTHISI (TRUNCSIHI (FLD (f_imm)))))); 8824e98e3e1Schristos CPU (h_gr[FLD (f_r1)]) = opval; 883212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 8844e98e3e1Schristos } 8854e98e3e1Schristos 8864e98e3e1Schristos return vpc; 8874e98e3e1Schristos #undef FLD 8884e98e3e1Schristos } 8894e98e3e1Schristos 8904e98e3e1Schristos /* lh: lh $r1,($r0+$imm) */ 8914e98e3e1Schristos 8924e98e3e1Schristos static SEM_PC 8934e98e3e1Schristos SEM_FN_NAME (lm32bf,lh) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 8944e98e3e1Schristos { 8954e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_addi.f 8964e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 8974e98e3e1Schristos int UNUSED written = 0; 8984e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 8994e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 9004e98e3e1Schristos 9014e98e3e1Schristos { 9024e98e3e1Schristos SI opval = EXTHISI (GETMEMHI (current_cpu, pc, ADDSI (CPU (h_gr[FLD (f_r0)]), EXTHISI (TRUNCSIHI (FLD (f_imm)))))); 9034e98e3e1Schristos CPU (h_gr[FLD (f_r1)]) = opval; 904212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 9054e98e3e1Schristos } 9064e98e3e1Schristos 9074e98e3e1Schristos return vpc; 9084e98e3e1Schristos #undef FLD 9094e98e3e1Schristos } 9104e98e3e1Schristos 9114e98e3e1Schristos /* lhu: lhu $r1,($r0+$imm) */ 9124e98e3e1Schristos 9134e98e3e1Schristos static SEM_PC 9144e98e3e1Schristos SEM_FN_NAME (lm32bf,lhu) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 9154e98e3e1Schristos { 9164e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_addi.f 9174e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 9184e98e3e1Schristos int UNUSED written = 0; 9194e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 9204e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 9214e98e3e1Schristos 9224e98e3e1Schristos { 9234e98e3e1Schristos SI opval = ZEXTHISI (GETMEMHI (current_cpu, pc, ADDSI (CPU (h_gr[FLD (f_r0)]), EXTHISI (TRUNCSIHI (FLD (f_imm)))))); 9244e98e3e1Schristos CPU (h_gr[FLD (f_r1)]) = opval; 925212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 9264e98e3e1Schristos } 9274e98e3e1Schristos 9284e98e3e1Schristos return vpc; 9294e98e3e1Schristos #undef FLD 9304e98e3e1Schristos } 9314e98e3e1Schristos 9324e98e3e1Schristos /* lw: lw $r1,($r0+$imm) */ 9334e98e3e1Schristos 9344e98e3e1Schristos static SEM_PC 9354e98e3e1Schristos SEM_FN_NAME (lm32bf,lw) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 9364e98e3e1Schristos { 9374e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_addi.f 9384e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 9394e98e3e1Schristos int UNUSED written = 0; 9404e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 9414e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 9424e98e3e1Schristos 9434e98e3e1Schristos { 9444e98e3e1Schristos SI opval = GETMEMSI (current_cpu, pc, ADDSI (CPU (h_gr[FLD (f_r0)]), EXTHISI (TRUNCSIHI (FLD (f_imm))))); 9454e98e3e1Schristos CPU (h_gr[FLD (f_r1)]) = opval; 946212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 9474e98e3e1Schristos } 9484e98e3e1Schristos 9494e98e3e1Schristos return vpc; 9504e98e3e1Schristos #undef FLD 9514e98e3e1Schristos } 9524e98e3e1Schristos 9534e98e3e1Schristos /* modu: modu $r2,$r0,$r1 */ 9544e98e3e1Schristos 9554e98e3e1Schristos static SEM_PC 9564e98e3e1Schristos SEM_FN_NAME (lm32bf,modu) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 9574e98e3e1Schristos { 9584e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_user.f 9594e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 9604e98e3e1Schristos int UNUSED written = 0; 9614e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 9624e98e3e1Schristos SEM_BRANCH_INIT 9634e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 9644e98e3e1Schristos 9654e98e3e1Schristos { 9664e98e3e1Schristos USI opval = lm32bf_modu_insn (current_cpu, pc, FLD (f_r0), FLD (f_r1), FLD (f_r2)); 9674e98e3e1Schristos SEM_BRANCH_VIA_ADDR (current_cpu, sem_arg, opval, vpc); 968212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "pc", 'x', opval); 9694e98e3e1Schristos } 9704e98e3e1Schristos 9714e98e3e1Schristos SEM_BRANCH_FINI (vpc); 9724e98e3e1Schristos return vpc; 9734e98e3e1Schristos #undef FLD 9744e98e3e1Schristos } 9754e98e3e1Schristos 9764e98e3e1Schristos /* mul: mul $r2,$r0,$r1 */ 9774e98e3e1Schristos 9784e98e3e1Schristos static SEM_PC 9794e98e3e1Schristos SEM_FN_NAME (lm32bf,mul) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 9804e98e3e1Schristos { 9814e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_user.f 9824e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 9834e98e3e1Schristos int UNUSED written = 0; 9844e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 9854e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 9864e98e3e1Schristos 9874e98e3e1Schristos { 9884e98e3e1Schristos SI opval = MULSI (CPU (h_gr[FLD (f_r0)]), CPU (h_gr[FLD (f_r1)])); 9894e98e3e1Schristos CPU (h_gr[FLD (f_r2)]) = opval; 990212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 9914e98e3e1Schristos } 9924e98e3e1Schristos 9934e98e3e1Schristos return vpc; 9944e98e3e1Schristos #undef FLD 9954e98e3e1Schristos } 9964e98e3e1Schristos 9974e98e3e1Schristos /* muli: muli $r1,$r0,$imm */ 9984e98e3e1Schristos 9994e98e3e1Schristos static SEM_PC 10004e98e3e1Schristos SEM_FN_NAME (lm32bf,muli) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 10014e98e3e1Schristos { 10024e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_addi.f 10034e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 10044e98e3e1Schristos int UNUSED written = 0; 10054e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 10064e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 10074e98e3e1Schristos 10084e98e3e1Schristos { 10094e98e3e1Schristos SI opval = MULSI (CPU (h_gr[FLD (f_r0)]), EXTHISI (TRUNCSIHI (FLD (f_imm)))); 10104e98e3e1Schristos CPU (h_gr[FLD (f_r1)]) = opval; 1011212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 10124e98e3e1Schristos } 10134e98e3e1Schristos 10144e98e3e1Schristos return vpc; 10154e98e3e1Schristos #undef FLD 10164e98e3e1Schristos } 10174e98e3e1Schristos 10184e98e3e1Schristos /* nor: nor $r2,$r0,$r1 */ 10194e98e3e1Schristos 10204e98e3e1Schristos static SEM_PC 10214e98e3e1Schristos SEM_FN_NAME (lm32bf,nor) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 10224e98e3e1Schristos { 10234e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_user.f 10244e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 10254e98e3e1Schristos int UNUSED written = 0; 10264e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 10274e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 10284e98e3e1Schristos 10294e98e3e1Schristos { 10304e98e3e1Schristos SI opval = INVSI (ORSI (CPU (h_gr[FLD (f_r0)]), CPU (h_gr[FLD (f_r1)]))); 10314e98e3e1Schristos CPU (h_gr[FLD (f_r2)]) = opval; 1032212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 10334e98e3e1Schristos } 10344e98e3e1Schristos 10354e98e3e1Schristos return vpc; 10364e98e3e1Schristos #undef FLD 10374e98e3e1Schristos } 10384e98e3e1Schristos 10394e98e3e1Schristos /* nori: nori $r1,$r0,$uimm */ 10404e98e3e1Schristos 10414e98e3e1Schristos static SEM_PC 10424e98e3e1Schristos SEM_FN_NAME (lm32bf,nori) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 10434e98e3e1Schristos { 10444e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_andi.f 10454e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 10464e98e3e1Schristos int UNUSED written = 0; 10474e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 10484e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 10494e98e3e1Schristos 10504e98e3e1Schristos { 10514e98e3e1Schristos SI opval = INVSI (ORSI (CPU (h_gr[FLD (f_r0)]), ZEXTSISI (FLD (f_uimm)))); 10524e98e3e1Schristos CPU (h_gr[FLD (f_r1)]) = opval; 1053212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 10544e98e3e1Schristos } 10554e98e3e1Schristos 10564e98e3e1Schristos return vpc; 10574e98e3e1Schristos #undef FLD 10584e98e3e1Schristos } 10594e98e3e1Schristos 10604e98e3e1Schristos /* or: or $r2,$r0,$r1 */ 10614e98e3e1Schristos 10624e98e3e1Schristos static SEM_PC 10634e98e3e1Schristos SEM_FN_NAME (lm32bf,or) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 10644e98e3e1Schristos { 10654e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_user.f 10664e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 10674e98e3e1Schristos int UNUSED written = 0; 10684e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 10694e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 10704e98e3e1Schristos 10714e98e3e1Schristos { 10724e98e3e1Schristos SI opval = ORSI (CPU (h_gr[FLD (f_r0)]), CPU (h_gr[FLD (f_r1)])); 10734e98e3e1Schristos CPU (h_gr[FLD (f_r2)]) = opval; 1074212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 10754e98e3e1Schristos } 10764e98e3e1Schristos 10774e98e3e1Schristos return vpc; 10784e98e3e1Schristos #undef FLD 10794e98e3e1Schristos } 10804e98e3e1Schristos 10814e98e3e1Schristos /* ori: ori $r1,$r0,$lo16 */ 10824e98e3e1Schristos 10834e98e3e1Schristos static SEM_PC 10844e98e3e1Schristos SEM_FN_NAME (lm32bf,ori) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 10854e98e3e1Schristos { 10864e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_andi.f 10874e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 10884e98e3e1Schristos int UNUSED written = 0; 10894e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 10904e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 10914e98e3e1Schristos 10924e98e3e1Schristos { 10934e98e3e1Schristos SI opval = ORSI (CPU (h_gr[FLD (f_r0)]), ZEXTSISI (FLD (f_uimm))); 10944e98e3e1Schristos CPU (h_gr[FLD (f_r1)]) = opval; 1095212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 10964e98e3e1Schristos } 10974e98e3e1Schristos 10984e98e3e1Schristos return vpc; 10994e98e3e1Schristos #undef FLD 11004e98e3e1Schristos } 11014e98e3e1Schristos 11024e98e3e1Schristos /* orhii: orhi $r1,$r0,$hi16 */ 11034e98e3e1Schristos 11044e98e3e1Schristos static SEM_PC 11054e98e3e1Schristos SEM_FN_NAME (lm32bf,orhii) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 11064e98e3e1Schristos { 11074e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_andi.f 11084e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 11094e98e3e1Schristos int UNUSED written = 0; 11104e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 11114e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 11124e98e3e1Schristos 11134e98e3e1Schristos { 11144e98e3e1Schristos SI opval = ORSI (CPU (h_gr[FLD (f_r0)]), SLLSI (FLD (f_uimm), 16)); 11154e98e3e1Schristos CPU (h_gr[FLD (f_r1)]) = opval; 1116212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 11174e98e3e1Schristos } 11184e98e3e1Schristos 11194e98e3e1Schristos return vpc; 11204e98e3e1Schristos #undef FLD 11214e98e3e1Schristos } 11224e98e3e1Schristos 11234e98e3e1Schristos /* rcsr: rcsr $r2,$csr */ 11244e98e3e1Schristos 11254e98e3e1Schristos static SEM_PC 11264e98e3e1Schristos SEM_FN_NAME (lm32bf,rcsr) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 11274e98e3e1Schristos { 11284e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_rcsr.f 11294e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 11304e98e3e1Schristos int UNUSED written = 0; 11314e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 11324e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 11334e98e3e1Schristos 11344e98e3e1Schristos { 11354e98e3e1Schristos SI opval = CPU (h_csr[FLD (f_csr)]); 11364e98e3e1Schristos CPU (h_gr[FLD (f_r2)]) = opval; 1137212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 11384e98e3e1Schristos } 11394e98e3e1Schristos 11404e98e3e1Schristos return vpc; 11414e98e3e1Schristos #undef FLD 11424e98e3e1Schristos } 11434e98e3e1Schristos 11444e98e3e1Schristos /* sb: sb ($r0+$imm),$r1 */ 11454e98e3e1Schristos 11464e98e3e1Schristos static SEM_PC 11474e98e3e1Schristos SEM_FN_NAME (lm32bf,sb) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 11484e98e3e1Schristos { 11494e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_addi.f 11504e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 11514e98e3e1Schristos int UNUSED written = 0; 11524e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 11534e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 11544e98e3e1Schristos 11554e98e3e1Schristos { 11564e98e3e1Schristos QI opval = CPU (h_gr[FLD (f_r1)]); 11574e98e3e1Schristos SETMEMQI (current_cpu, pc, ADDSI (CPU (h_gr[FLD (f_r0)]), EXTHISI (TRUNCSIHI (FLD (f_imm)))), opval); 1158212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "memory", 'x', opval); 11594e98e3e1Schristos } 11604e98e3e1Schristos 11614e98e3e1Schristos return vpc; 11624e98e3e1Schristos #undef FLD 11634e98e3e1Schristos } 11644e98e3e1Schristos 11654e98e3e1Schristos /* sextb: sextb $r2,$r0 */ 11664e98e3e1Schristos 11674e98e3e1Schristos static SEM_PC 11684e98e3e1Schristos SEM_FN_NAME (lm32bf,sextb) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 11694e98e3e1Schristos { 11704e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_user.f 11714e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 11724e98e3e1Schristos int UNUSED written = 0; 11734e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 11744e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 11754e98e3e1Schristos 11764e98e3e1Schristos { 11774e98e3e1Schristos SI opval = EXTQISI (TRUNCSIQI (CPU (h_gr[FLD (f_r0)]))); 11784e98e3e1Schristos CPU (h_gr[FLD (f_r2)]) = opval; 1179212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 11804e98e3e1Schristos } 11814e98e3e1Schristos 11824e98e3e1Schristos return vpc; 11834e98e3e1Schristos #undef FLD 11844e98e3e1Schristos } 11854e98e3e1Schristos 11864e98e3e1Schristos /* sexth: sexth $r2,$r0 */ 11874e98e3e1Schristos 11884e98e3e1Schristos static SEM_PC 11894e98e3e1Schristos SEM_FN_NAME (lm32bf,sexth) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 11904e98e3e1Schristos { 11914e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_user.f 11924e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 11934e98e3e1Schristos int UNUSED written = 0; 11944e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 11954e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 11964e98e3e1Schristos 11974e98e3e1Schristos { 11984e98e3e1Schristos SI opval = EXTHISI (TRUNCSIHI (CPU (h_gr[FLD (f_r0)]))); 11994e98e3e1Schristos CPU (h_gr[FLD (f_r2)]) = opval; 1200212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 12014e98e3e1Schristos } 12024e98e3e1Schristos 12034e98e3e1Schristos return vpc; 12044e98e3e1Schristos #undef FLD 12054e98e3e1Schristos } 12064e98e3e1Schristos 12074e98e3e1Schristos /* sh: sh ($r0+$imm),$r1 */ 12084e98e3e1Schristos 12094e98e3e1Schristos static SEM_PC 12104e98e3e1Schristos SEM_FN_NAME (lm32bf,sh) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 12114e98e3e1Schristos { 12124e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_addi.f 12134e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 12144e98e3e1Schristos int UNUSED written = 0; 12154e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 12164e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 12174e98e3e1Schristos 12184e98e3e1Schristos { 12194e98e3e1Schristos HI opval = CPU (h_gr[FLD (f_r1)]); 12204e98e3e1Schristos SETMEMHI (current_cpu, pc, ADDSI (CPU (h_gr[FLD (f_r0)]), EXTHISI (TRUNCSIHI (FLD (f_imm)))), opval); 1221212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "memory", 'x', opval); 12224e98e3e1Schristos } 12234e98e3e1Schristos 12244e98e3e1Schristos return vpc; 12254e98e3e1Schristos #undef FLD 12264e98e3e1Schristos } 12274e98e3e1Schristos 12284e98e3e1Schristos /* sl: sl $r2,$r0,$r1 */ 12294e98e3e1Schristos 12304e98e3e1Schristos static SEM_PC 12314e98e3e1Schristos SEM_FN_NAME (lm32bf,sl) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 12324e98e3e1Schristos { 12334e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_user.f 12344e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 12354e98e3e1Schristos int UNUSED written = 0; 12364e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 12374e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 12384e98e3e1Schristos 12394e98e3e1Schristos { 12404e98e3e1Schristos SI opval = SLLSI (CPU (h_gr[FLD (f_r0)]), CPU (h_gr[FLD (f_r1)])); 12414e98e3e1Schristos CPU (h_gr[FLD (f_r2)]) = opval; 1242212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 12434e98e3e1Schristos } 12444e98e3e1Schristos 12454e98e3e1Schristos return vpc; 12464e98e3e1Schristos #undef FLD 12474e98e3e1Schristos } 12484e98e3e1Schristos 12494e98e3e1Schristos /* sli: sli $r1,$r0,$imm */ 12504e98e3e1Schristos 12514e98e3e1Schristos static SEM_PC 12524e98e3e1Schristos SEM_FN_NAME (lm32bf,sli) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 12534e98e3e1Schristos { 12544e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_addi.f 12554e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 12564e98e3e1Schristos int UNUSED written = 0; 12574e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 12584e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 12594e98e3e1Schristos 12604e98e3e1Schristos { 12614e98e3e1Schristos SI opval = SLLSI (CPU (h_gr[FLD (f_r0)]), FLD (f_imm)); 12624e98e3e1Schristos CPU (h_gr[FLD (f_r1)]) = opval; 1263212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 12644e98e3e1Schristos } 12654e98e3e1Schristos 12664e98e3e1Schristos return vpc; 12674e98e3e1Schristos #undef FLD 12684e98e3e1Schristos } 12694e98e3e1Schristos 12704e98e3e1Schristos /* sr: sr $r2,$r0,$r1 */ 12714e98e3e1Schristos 12724e98e3e1Schristos static SEM_PC 12734e98e3e1Schristos SEM_FN_NAME (lm32bf,sr) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 12744e98e3e1Schristos { 12754e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_user.f 12764e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 12774e98e3e1Schristos int UNUSED written = 0; 12784e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 12794e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 12804e98e3e1Schristos 12814e98e3e1Schristos { 12824e98e3e1Schristos SI opval = SRASI (CPU (h_gr[FLD (f_r0)]), CPU (h_gr[FLD (f_r1)])); 12834e98e3e1Schristos CPU (h_gr[FLD (f_r2)]) = opval; 1284212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 12854e98e3e1Schristos } 12864e98e3e1Schristos 12874e98e3e1Schristos return vpc; 12884e98e3e1Schristos #undef FLD 12894e98e3e1Schristos } 12904e98e3e1Schristos 12914e98e3e1Schristos /* sri: sri $r1,$r0,$imm */ 12924e98e3e1Schristos 12934e98e3e1Schristos static SEM_PC 12944e98e3e1Schristos SEM_FN_NAME (lm32bf,sri) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 12954e98e3e1Schristos { 12964e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_addi.f 12974e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 12984e98e3e1Schristos int UNUSED written = 0; 12994e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 13004e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 13014e98e3e1Schristos 13024e98e3e1Schristos { 13034e98e3e1Schristos SI opval = SRASI (CPU (h_gr[FLD (f_r0)]), FLD (f_imm)); 13044e98e3e1Schristos CPU (h_gr[FLD (f_r1)]) = opval; 1305212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 13064e98e3e1Schristos } 13074e98e3e1Schristos 13084e98e3e1Schristos return vpc; 13094e98e3e1Schristos #undef FLD 13104e98e3e1Schristos } 13114e98e3e1Schristos 13124e98e3e1Schristos /* sru: sru $r2,$r0,$r1 */ 13134e98e3e1Schristos 13144e98e3e1Schristos static SEM_PC 13154e98e3e1Schristos SEM_FN_NAME (lm32bf,sru) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 13164e98e3e1Schristos { 13174e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_user.f 13184e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 13194e98e3e1Schristos int UNUSED written = 0; 13204e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 13214e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 13224e98e3e1Schristos 13234e98e3e1Schristos { 13244e98e3e1Schristos SI opval = SRLSI (CPU (h_gr[FLD (f_r0)]), CPU (h_gr[FLD (f_r1)])); 13254e98e3e1Schristos CPU (h_gr[FLD (f_r2)]) = opval; 1326212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 13274e98e3e1Schristos } 13284e98e3e1Schristos 13294e98e3e1Schristos return vpc; 13304e98e3e1Schristos #undef FLD 13314e98e3e1Schristos } 13324e98e3e1Schristos 13334e98e3e1Schristos /* srui: srui $r1,$r0,$imm */ 13344e98e3e1Schristos 13354e98e3e1Schristos static SEM_PC 13364e98e3e1Schristos SEM_FN_NAME (lm32bf,srui) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 13374e98e3e1Schristos { 13384e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_addi.f 13394e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 13404e98e3e1Schristos int UNUSED written = 0; 13414e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 13424e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 13434e98e3e1Schristos 13444e98e3e1Schristos { 13454e98e3e1Schristos SI opval = SRLSI (CPU (h_gr[FLD (f_r0)]), FLD (f_imm)); 13464e98e3e1Schristos CPU (h_gr[FLD (f_r1)]) = opval; 1347212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 13484e98e3e1Schristos } 13494e98e3e1Schristos 13504e98e3e1Schristos return vpc; 13514e98e3e1Schristos #undef FLD 13524e98e3e1Schristos } 13534e98e3e1Schristos 13544e98e3e1Schristos /* sub: sub $r2,$r0,$r1 */ 13554e98e3e1Schristos 13564e98e3e1Schristos static SEM_PC 13574e98e3e1Schristos SEM_FN_NAME (lm32bf,sub) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 13584e98e3e1Schristos { 13594e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_user.f 13604e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 13614e98e3e1Schristos int UNUSED written = 0; 13624e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 13634e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 13644e98e3e1Schristos 13654e98e3e1Schristos { 13664e98e3e1Schristos SI opval = SUBSI (CPU (h_gr[FLD (f_r0)]), CPU (h_gr[FLD (f_r1)])); 13674e98e3e1Schristos CPU (h_gr[FLD (f_r2)]) = opval; 1368212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 13694e98e3e1Schristos } 13704e98e3e1Schristos 13714e98e3e1Schristos return vpc; 13724e98e3e1Schristos #undef FLD 13734e98e3e1Schristos } 13744e98e3e1Schristos 13754e98e3e1Schristos /* sw: sw ($r0+$imm),$r1 */ 13764e98e3e1Schristos 13774e98e3e1Schristos static SEM_PC 13784e98e3e1Schristos SEM_FN_NAME (lm32bf,sw) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 13794e98e3e1Schristos { 13804e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_addi.f 13814e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 13824e98e3e1Schristos int UNUSED written = 0; 13834e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 13844e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 13854e98e3e1Schristos 13864e98e3e1Schristos { 13874e98e3e1Schristos SI opval = CPU (h_gr[FLD (f_r1)]); 13884e98e3e1Schristos SETMEMSI (current_cpu, pc, ADDSI (CPU (h_gr[FLD (f_r0)]), EXTHISI (TRUNCSIHI (FLD (f_imm)))), opval); 1389212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "memory", 'x', opval); 13904e98e3e1Schristos } 13914e98e3e1Schristos 13924e98e3e1Schristos return vpc; 13934e98e3e1Schristos #undef FLD 13944e98e3e1Schristos } 13954e98e3e1Schristos 13964e98e3e1Schristos /* user: user $r2,$r0,$r1,$user */ 13974e98e3e1Schristos 13984e98e3e1Schristos static SEM_PC 13994e98e3e1Schristos SEM_FN_NAME (lm32bf,user) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 14004e98e3e1Schristos { 14014e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_user.f 14024e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 14034e98e3e1Schristos int UNUSED written = 0; 14044e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 14054e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 14064e98e3e1Schristos 14074e98e3e1Schristos { 14084e98e3e1Schristos SI opval = lm32bf_user_insn (current_cpu, CPU (h_gr[FLD (f_r0)]), CPU (h_gr[FLD (f_r1)]), FLD (f_user)); 14094e98e3e1Schristos CPU (h_gr[FLD (f_r2)]) = opval; 1410212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 14114e98e3e1Schristos } 14124e98e3e1Schristos 14134e98e3e1Schristos return vpc; 14144e98e3e1Schristos #undef FLD 14154e98e3e1Schristos } 14164e98e3e1Schristos 14174e98e3e1Schristos /* wcsr: wcsr $csr,$r1 */ 14184e98e3e1Schristos 14194e98e3e1Schristos static SEM_PC 14204e98e3e1Schristos SEM_FN_NAME (lm32bf,wcsr) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 14214e98e3e1Schristos { 14224e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_wcsr.f 14234e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 14244e98e3e1Schristos int UNUSED written = 0; 14254e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 14264e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 14274e98e3e1Schristos 14284e98e3e1Schristos lm32bf_wcsr_insn (current_cpu, FLD (f_csr), CPU (h_gr[FLD (f_r1)])); 14294e98e3e1Schristos 14304e98e3e1Schristos return vpc; 14314e98e3e1Schristos #undef FLD 14324e98e3e1Schristos } 14334e98e3e1Schristos 14344e98e3e1Schristos /* xor: xor $r2,$r0,$r1 */ 14354e98e3e1Schristos 14364e98e3e1Schristos static SEM_PC 14374e98e3e1Schristos SEM_FN_NAME (lm32bf,xor) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 14384e98e3e1Schristos { 14394e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_user.f 14404e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 14414e98e3e1Schristos int UNUSED written = 0; 14424e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 14434e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 14444e98e3e1Schristos 14454e98e3e1Schristos { 14464e98e3e1Schristos SI opval = XORSI (CPU (h_gr[FLD (f_r0)]), CPU (h_gr[FLD (f_r1)])); 14474e98e3e1Schristos CPU (h_gr[FLD (f_r2)]) = opval; 1448212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 14494e98e3e1Schristos } 14504e98e3e1Schristos 14514e98e3e1Schristos return vpc; 14524e98e3e1Schristos #undef FLD 14534e98e3e1Schristos } 14544e98e3e1Schristos 14554e98e3e1Schristos /* xori: xori $r1,$r0,$uimm */ 14564e98e3e1Schristos 14574e98e3e1Schristos static SEM_PC 14584e98e3e1Schristos SEM_FN_NAME (lm32bf,xori) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 14594e98e3e1Schristos { 14604e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_andi.f 14614e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 14624e98e3e1Schristos int UNUSED written = 0; 14634e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 14644e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 14654e98e3e1Schristos 14664e98e3e1Schristos { 14674e98e3e1Schristos SI opval = XORSI (CPU (h_gr[FLD (f_r0)]), ZEXTSISI (FLD (f_uimm))); 14684e98e3e1Schristos CPU (h_gr[FLD (f_r1)]) = opval; 1469212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 14704e98e3e1Schristos } 14714e98e3e1Schristos 14724e98e3e1Schristos return vpc; 14734e98e3e1Schristos #undef FLD 14744e98e3e1Schristos } 14754e98e3e1Schristos 14764e98e3e1Schristos /* xnor: xnor $r2,$r0,$r1 */ 14774e98e3e1Schristos 14784e98e3e1Schristos static SEM_PC 14794e98e3e1Schristos SEM_FN_NAME (lm32bf,xnor) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 14804e98e3e1Schristos { 14814e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_user.f 14824e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 14834e98e3e1Schristos int UNUSED written = 0; 14844e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 14854e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 14864e98e3e1Schristos 14874e98e3e1Schristos { 14884e98e3e1Schristos SI opval = INVSI (XORSI (CPU (h_gr[FLD (f_r0)]), CPU (h_gr[FLD (f_r1)]))); 14894e98e3e1Schristos CPU (h_gr[FLD (f_r2)]) = opval; 1490212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 14914e98e3e1Schristos } 14924e98e3e1Schristos 14934e98e3e1Schristos return vpc; 14944e98e3e1Schristos #undef FLD 14954e98e3e1Schristos } 14964e98e3e1Schristos 14974e98e3e1Schristos /* xnori: xnori $r1,$r0,$uimm */ 14984e98e3e1Schristos 14994e98e3e1Schristos static SEM_PC 15004e98e3e1Schristos SEM_FN_NAME (lm32bf,xnori) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 15014e98e3e1Schristos { 15024e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_andi.f 15034e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 15044e98e3e1Schristos int UNUSED written = 0; 15054e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 15064e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 15074e98e3e1Schristos 15084e98e3e1Schristos { 15094e98e3e1Schristos SI opval = INVSI (XORSI (CPU (h_gr[FLD (f_r0)]), ZEXTSISI (FLD (f_uimm)))); 15104e98e3e1Schristos CPU (h_gr[FLD (f_r1)]) = opval; 1511212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "gr", 'x', opval); 15124e98e3e1Schristos } 15134e98e3e1Schristos 15144e98e3e1Schristos return vpc; 15154e98e3e1Schristos #undef FLD 15164e98e3e1Schristos } 15174e98e3e1Schristos 15184e98e3e1Schristos /* break: break */ 15194e98e3e1Schristos 15204e98e3e1Schristos static SEM_PC 15214e98e3e1Schristos SEM_FN_NAME (lm32bf,break) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 15224e98e3e1Schristos { 15234e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_empty.f 15244e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 15254e98e3e1Schristos int UNUSED written = 0; 15264e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 15274e98e3e1Schristos SEM_BRANCH_INIT 15284e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 15294e98e3e1Schristos 15304e98e3e1Schristos { 15314e98e3e1Schristos USI opval = lm32bf_break_insn (current_cpu, pc); 15324e98e3e1Schristos SEM_BRANCH_VIA_ADDR (current_cpu, sem_arg, opval, vpc); 1533212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "pc", 'x', opval); 15344e98e3e1Schristos } 15354e98e3e1Schristos 15364e98e3e1Schristos SEM_BRANCH_FINI (vpc); 15374e98e3e1Schristos return vpc; 15384e98e3e1Schristos #undef FLD 15394e98e3e1Schristos } 15404e98e3e1Schristos 15414e98e3e1Schristos /* scall: scall */ 15424e98e3e1Schristos 15434e98e3e1Schristos static SEM_PC 15444e98e3e1Schristos SEM_FN_NAME (lm32bf,scall) (SIM_CPU *current_cpu, SEM_ARG sem_arg) 15454e98e3e1Schristos { 15464e98e3e1Schristos #define FLD(f) abuf->fields.sfmt_empty.f 15474e98e3e1Schristos ARGBUF *abuf = SEM_ARGBUF (sem_arg); 15484e98e3e1Schristos int UNUSED written = 0; 15494e98e3e1Schristos IADDR UNUSED pc = abuf->addr; 15504e98e3e1Schristos SEM_BRANCH_INIT 15514e98e3e1Schristos SEM_PC vpc = SEM_NEXT_VPC (sem_arg, pc, 4); 15524e98e3e1Schristos 15534e98e3e1Schristos { 15544e98e3e1Schristos USI opval = lm32bf_scall_insn (current_cpu, pc); 15554e98e3e1Schristos SEM_BRANCH_VIA_ADDR (current_cpu, sem_arg, opval, vpc); 1556212397c6Schristos CGEN_TRACE_RESULT (current_cpu, abuf, "pc", 'x', opval); 15574e98e3e1Schristos } 15584e98e3e1Schristos 15594e98e3e1Schristos SEM_BRANCH_FINI (vpc); 15604e98e3e1Schristos return vpc; 15614e98e3e1Schristos #undef FLD 15624e98e3e1Schristos } 15634e98e3e1Schristos 15644e98e3e1Schristos /* Table of all semantic fns. */ 15654e98e3e1Schristos 15664e98e3e1Schristos static const struct sem_fn_desc sem_fns[] = { 15674e98e3e1Schristos { LM32BF_INSN_X_INVALID, SEM_FN_NAME (lm32bf,x_invalid) }, 15684e98e3e1Schristos { LM32BF_INSN_X_AFTER, SEM_FN_NAME (lm32bf,x_after) }, 15694e98e3e1Schristos { LM32BF_INSN_X_BEFORE, SEM_FN_NAME (lm32bf,x_before) }, 15704e98e3e1Schristos { LM32BF_INSN_X_CTI_CHAIN, SEM_FN_NAME (lm32bf,x_cti_chain) }, 15714e98e3e1Schristos { LM32BF_INSN_X_CHAIN, SEM_FN_NAME (lm32bf,x_chain) }, 15724e98e3e1Schristos { LM32BF_INSN_X_BEGIN, SEM_FN_NAME (lm32bf,x_begin) }, 15734e98e3e1Schristos { LM32BF_INSN_ADD, SEM_FN_NAME (lm32bf,add) }, 15744e98e3e1Schristos { LM32BF_INSN_ADDI, SEM_FN_NAME (lm32bf,addi) }, 15754e98e3e1Schristos { LM32BF_INSN_AND, SEM_FN_NAME (lm32bf,and) }, 15764e98e3e1Schristos { LM32BF_INSN_ANDI, SEM_FN_NAME (lm32bf,andi) }, 15774e98e3e1Schristos { LM32BF_INSN_ANDHII, SEM_FN_NAME (lm32bf,andhii) }, 15784e98e3e1Schristos { LM32BF_INSN_B, SEM_FN_NAME (lm32bf,b) }, 15794e98e3e1Schristos { LM32BF_INSN_BI, SEM_FN_NAME (lm32bf,bi) }, 15804e98e3e1Schristos { LM32BF_INSN_BE, SEM_FN_NAME (lm32bf,be) }, 15814e98e3e1Schristos { LM32BF_INSN_BG, SEM_FN_NAME (lm32bf,bg) }, 15824e98e3e1Schristos { LM32BF_INSN_BGE, SEM_FN_NAME (lm32bf,bge) }, 15834e98e3e1Schristos { LM32BF_INSN_BGEU, SEM_FN_NAME (lm32bf,bgeu) }, 15844e98e3e1Schristos { LM32BF_INSN_BGU, SEM_FN_NAME (lm32bf,bgu) }, 15854e98e3e1Schristos { LM32BF_INSN_BNE, SEM_FN_NAME (lm32bf,bne) }, 15864e98e3e1Schristos { LM32BF_INSN_CALL, SEM_FN_NAME (lm32bf,call) }, 15874e98e3e1Schristos { LM32BF_INSN_CALLI, SEM_FN_NAME (lm32bf,calli) }, 15884e98e3e1Schristos { LM32BF_INSN_CMPE, SEM_FN_NAME (lm32bf,cmpe) }, 15894e98e3e1Schristos { LM32BF_INSN_CMPEI, SEM_FN_NAME (lm32bf,cmpei) }, 15904e98e3e1Schristos { LM32BF_INSN_CMPG, SEM_FN_NAME (lm32bf,cmpg) }, 15914e98e3e1Schristos { LM32BF_INSN_CMPGI, SEM_FN_NAME (lm32bf,cmpgi) }, 15924e98e3e1Schristos { LM32BF_INSN_CMPGE, SEM_FN_NAME (lm32bf,cmpge) }, 15934e98e3e1Schristos { LM32BF_INSN_CMPGEI, SEM_FN_NAME (lm32bf,cmpgei) }, 15944e98e3e1Schristos { LM32BF_INSN_CMPGEU, SEM_FN_NAME (lm32bf,cmpgeu) }, 15954e98e3e1Schristos { LM32BF_INSN_CMPGEUI, SEM_FN_NAME (lm32bf,cmpgeui) }, 15964e98e3e1Schristos { LM32BF_INSN_CMPGU, SEM_FN_NAME (lm32bf,cmpgu) }, 15974e98e3e1Schristos { LM32BF_INSN_CMPGUI, SEM_FN_NAME (lm32bf,cmpgui) }, 15984e98e3e1Schristos { LM32BF_INSN_CMPNE, SEM_FN_NAME (lm32bf,cmpne) }, 15994e98e3e1Schristos { LM32BF_INSN_CMPNEI, SEM_FN_NAME (lm32bf,cmpnei) }, 16004e98e3e1Schristos { LM32BF_INSN_DIVU, SEM_FN_NAME (lm32bf,divu) }, 16014e98e3e1Schristos { LM32BF_INSN_LB, SEM_FN_NAME (lm32bf,lb) }, 16024e98e3e1Schristos { LM32BF_INSN_LBU, SEM_FN_NAME (lm32bf,lbu) }, 16034e98e3e1Schristos { LM32BF_INSN_LH, SEM_FN_NAME (lm32bf,lh) }, 16044e98e3e1Schristos { LM32BF_INSN_LHU, SEM_FN_NAME (lm32bf,lhu) }, 16054e98e3e1Schristos { LM32BF_INSN_LW, SEM_FN_NAME (lm32bf,lw) }, 16064e98e3e1Schristos { LM32BF_INSN_MODU, SEM_FN_NAME (lm32bf,modu) }, 16074e98e3e1Schristos { LM32BF_INSN_MUL, SEM_FN_NAME (lm32bf,mul) }, 16084e98e3e1Schristos { LM32BF_INSN_MULI, SEM_FN_NAME (lm32bf,muli) }, 16094e98e3e1Schristos { LM32BF_INSN_NOR, SEM_FN_NAME (lm32bf,nor) }, 16104e98e3e1Schristos { LM32BF_INSN_NORI, SEM_FN_NAME (lm32bf,nori) }, 16114e98e3e1Schristos { LM32BF_INSN_OR, SEM_FN_NAME (lm32bf,or) }, 16124e98e3e1Schristos { LM32BF_INSN_ORI, SEM_FN_NAME (lm32bf,ori) }, 16134e98e3e1Schristos { LM32BF_INSN_ORHII, SEM_FN_NAME (lm32bf,orhii) }, 16144e98e3e1Schristos { LM32BF_INSN_RCSR, SEM_FN_NAME (lm32bf,rcsr) }, 16154e98e3e1Schristos { LM32BF_INSN_SB, SEM_FN_NAME (lm32bf,sb) }, 16164e98e3e1Schristos { LM32BF_INSN_SEXTB, SEM_FN_NAME (lm32bf,sextb) }, 16174e98e3e1Schristos { LM32BF_INSN_SEXTH, SEM_FN_NAME (lm32bf,sexth) }, 16184e98e3e1Schristos { LM32BF_INSN_SH, SEM_FN_NAME (lm32bf,sh) }, 16194e98e3e1Schristos { LM32BF_INSN_SL, SEM_FN_NAME (lm32bf,sl) }, 16204e98e3e1Schristos { LM32BF_INSN_SLI, SEM_FN_NAME (lm32bf,sli) }, 16214e98e3e1Schristos { LM32BF_INSN_SR, SEM_FN_NAME (lm32bf,sr) }, 16224e98e3e1Schristos { LM32BF_INSN_SRI, SEM_FN_NAME (lm32bf,sri) }, 16234e98e3e1Schristos { LM32BF_INSN_SRU, SEM_FN_NAME (lm32bf,sru) }, 16244e98e3e1Schristos { LM32BF_INSN_SRUI, SEM_FN_NAME (lm32bf,srui) }, 16254e98e3e1Schristos { LM32BF_INSN_SUB, SEM_FN_NAME (lm32bf,sub) }, 16264e98e3e1Schristos { LM32BF_INSN_SW, SEM_FN_NAME (lm32bf,sw) }, 16274e98e3e1Schristos { LM32BF_INSN_USER, SEM_FN_NAME (lm32bf,user) }, 16284e98e3e1Schristos { LM32BF_INSN_WCSR, SEM_FN_NAME (lm32bf,wcsr) }, 16294e98e3e1Schristos { LM32BF_INSN_XOR, SEM_FN_NAME (lm32bf,xor) }, 16304e98e3e1Schristos { LM32BF_INSN_XORI, SEM_FN_NAME (lm32bf,xori) }, 16314e98e3e1Schristos { LM32BF_INSN_XNOR, SEM_FN_NAME (lm32bf,xnor) }, 16324e98e3e1Schristos { LM32BF_INSN_XNORI, SEM_FN_NAME (lm32bf,xnori) }, 16334e98e3e1Schristos { LM32BF_INSN_BREAK, SEM_FN_NAME (lm32bf,break) }, 16344e98e3e1Schristos { LM32BF_INSN_SCALL, SEM_FN_NAME (lm32bf,scall) }, 16354e98e3e1Schristos { 0, 0 } 16364e98e3e1Schristos }; 16374e98e3e1Schristos 16384e98e3e1Schristos /* Add the semantic fns to IDESC_TABLE. */ 16394e98e3e1Schristos 16404e98e3e1Schristos void 16414e98e3e1Schristos SEM_FN_NAME (lm32bf,init_idesc_table) (SIM_CPU *current_cpu) 16424e98e3e1Schristos { 16434e98e3e1Schristos IDESC *idesc_table = CPU_IDESC (current_cpu); 16444e98e3e1Schristos const struct sem_fn_desc *sf; 16454e98e3e1Schristos int mach_num = MACH_NUM (CPU_MACH (current_cpu)); 16464e98e3e1Schristos 16474e98e3e1Schristos for (sf = &sem_fns[0]; sf->fn != 0; ++sf) 16484e98e3e1Schristos { 16494e98e3e1Schristos const CGEN_INSN *insn = idesc_table[sf->index].idata; 16504e98e3e1Schristos int valid_p = (CGEN_INSN_VIRTUAL_P (insn) 16514e98e3e1Schristos || CGEN_INSN_MACH_HAS_P (insn, mach_num)); 16524e98e3e1Schristos #if FAST_P 16534e98e3e1Schristos if (valid_p) 16544e98e3e1Schristos idesc_table[sf->index].sem_fast = sf->fn; 16554e98e3e1Schristos else 16564e98e3e1Schristos idesc_table[sf->index].sem_fast = SEM_FN_NAME (lm32bf,x_invalid); 16574e98e3e1Schristos #else 16584e98e3e1Schristos if (valid_p) 16594e98e3e1Schristos idesc_table[sf->index].sem_full = sf->fn; 16604e98e3e1Schristos else 16614e98e3e1Schristos idesc_table[sf->index].sem_full = SEM_FN_NAME (lm32bf,x_invalid); 16624e98e3e1Schristos #endif 16634e98e3e1Schristos } 16644e98e3e1Schristos } 16654e98e3e1Schristos 1666