Commit | Line | Data |
---|---|---|
646c6f2b DE |
1 | /* Simulator instruction semantics for m32r. |
2 | ||
9d70630e | 3 | Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. |
646c6f2b | 4 | |
9d70630e | 5 | This file is part of the GNU Simulators. |
646c6f2b DE |
6 | |
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2, or (at your option) | |
10 | any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License along | |
18 | with this program; if not, write to the Free Software Foundation, Inc., | |
19 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
20 | ||
21 | */ | |
22 | ||
9d70630e DE |
23 | #define WANT_CPU |
24 | #define WANT_CPU_M32R | |
25 | ||
646c6f2b | 26 | #include "sim-main.h" |
9d70630e DE |
27 | #include "cgen-mem.h" |
28 | #include "cgen-ops.h" | |
646c6f2b DE |
29 | #include "cpu-sim.h" |
30 | ||
9d70630e DE |
31 | #if ! defined (SCACHE_P) || (defined (SCACHE_P) && WITH_SCACHE) |
32 | ||
33 | #undef GET_ATTR | |
34 | #define GET_ATTR(cpu, num, attr) CGEN_INSN_ATTR (abuf->opcode, CGEN_INSN_##attr) | |
35 | ||
646c6f2b DE |
36 | /* Perform add: add $dr,$sr. */ |
37 | CIA | |
9d70630e | 38 | SEM_FN_NAME (m32r,add) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 39 | { |
9d70630e | 40 | #define FLD(f) abuf->fields.fmt_0_add.f |
646c6f2b DE |
41 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
42 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
43 | * FLD (f_r1) = ADDSI (* FLD (f_r1), * FLD (f_r2)); | |
44 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
45 | #if WITH_PROFILE_MODEL_P | |
46 | if (PROFILE_MODEL_P (current_cpu)) | |
47 | { | |
9d70630e DE |
48 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
49 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
50 | model_profile_insn (current_cpu, abuf); |
51 | } | |
52 | #endif | |
53 | return new_pc; | |
54 | #undef FLD | |
55 | } | |
56 | ||
57 | /* Perform add3: add3 $dr,$sr,$slo16. */ | |
58 | CIA | |
9d70630e | 59 | SEM_FN_NAME (m32r,add3) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 60 | { |
9d70630e | 61 | #define FLD(f) abuf->fields.fmt_1_add3.f |
646c6f2b DE |
62 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
63 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
64 | * FLD (f_r1) = ADDSI (* FLD (f_r2), FLD (f_simm16)); | |
65 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
66 | #if WITH_PROFILE_MODEL_P | |
67 | if (PROFILE_MODEL_P (current_cpu)) | |
68 | { | |
9d70630e DE |
69 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
70 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
71 | model_profile_insn (current_cpu, abuf); |
72 | } | |
73 | #endif | |
74 | return new_pc; | |
75 | #undef FLD | |
76 | } | |
77 | ||
78 | /* Perform and: and $dr,$sr. */ | |
79 | CIA | |
9d70630e | 80 | SEM_FN_NAME (m32r,and) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 81 | { |
9d70630e | 82 | #define FLD(f) abuf->fields.fmt_0_add.f |
646c6f2b DE |
83 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
84 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
85 | * FLD (f_r1) = ANDSI (* FLD (f_r1), * FLD (f_r2)); | |
86 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
87 | #if WITH_PROFILE_MODEL_P | |
88 | if (PROFILE_MODEL_P (current_cpu)) | |
89 | { | |
9d70630e DE |
90 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
91 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
92 | model_profile_insn (current_cpu, abuf); |
93 | } | |
94 | #endif | |
95 | return new_pc; | |
96 | #undef FLD | |
97 | } | |
98 | ||
99 | /* Perform and3: and3 $dr,$sr,$uimm16. */ | |
100 | CIA | |
9d70630e | 101 | SEM_FN_NAME (m32r,and3) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 102 | { |
9d70630e | 103 | #define FLD(f) abuf->fields.fmt_2_and3.f |
646c6f2b DE |
104 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
105 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
106 | * FLD (f_r1) = ANDSI (* FLD (f_r2), FLD (f_uimm16)); | |
107 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
108 | #if WITH_PROFILE_MODEL_P | |
109 | if (PROFILE_MODEL_P (current_cpu)) | |
110 | { | |
9d70630e DE |
111 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
112 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
113 | model_profile_insn (current_cpu, abuf); |
114 | } | |
115 | #endif | |
116 | return new_pc; | |
117 | #undef FLD | |
118 | } | |
119 | ||
120 | /* Perform or: or $dr,$sr. */ | |
121 | CIA | |
9d70630e | 122 | SEM_FN_NAME (m32r,or) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 123 | { |
9d70630e | 124 | #define FLD(f) abuf->fields.fmt_0_add.f |
646c6f2b DE |
125 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
126 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
127 | * FLD (f_r1) = ORSI (* FLD (f_r1), * FLD (f_r2)); | |
128 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
129 | #if WITH_PROFILE_MODEL_P | |
130 | if (PROFILE_MODEL_P (current_cpu)) | |
131 | { | |
9d70630e DE |
132 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
133 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
134 | model_profile_insn (current_cpu, abuf); |
135 | } | |
136 | #endif | |
137 | return new_pc; | |
138 | #undef FLD | |
139 | } | |
140 | ||
141 | /* Perform or3: or3 $dr,$sr,$ulo16. */ | |
142 | CIA | |
9d70630e | 143 | SEM_FN_NAME (m32r,or3) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 144 | { |
9d70630e | 145 | #define FLD(f) abuf->fields.fmt_3_or3.f |
646c6f2b DE |
146 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
147 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
148 | * FLD (f_r1) = ORSI (* FLD (f_r2), FLD (f_uimm16)); | |
149 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
150 | #if WITH_PROFILE_MODEL_P | |
151 | if (PROFILE_MODEL_P (current_cpu)) | |
152 | { | |
9d70630e DE |
153 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
154 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
155 | model_profile_insn (current_cpu, abuf); |
156 | } | |
157 | #endif | |
158 | return new_pc; | |
159 | #undef FLD | |
160 | } | |
161 | ||
162 | /* Perform xor: xor $dr,$sr. */ | |
163 | CIA | |
9d70630e | 164 | SEM_FN_NAME (m32r,xor) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 165 | { |
9d70630e | 166 | #define FLD(f) abuf->fields.fmt_0_add.f |
646c6f2b DE |
167 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
168 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
169 | * FLD (f_r1) = XORSI (* FLD (f_r1), * FLD (f_r2)); | |
170 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
171 | #if WITH_PROFILE_MODEL_P | |
172 | if (PROFILE_MODEL_P (current_cpu)) | |
173 | { | |
9d70630e DE |
174 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
175 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
176 | model_profile_insn (current_cpu, abuf); |
177 | } | |
178 | #endif | |
179 | return new_pc; | |
180 | #undef FLD | |
181 | } | |
182 | ||
183 | /* Perform xor3: xor3 $dr,$sr,$uimm16. */ | |
184 | CIA | |
9d70630e | 185 | SEM_FN_NAME (m32r,xor3) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 186 | { |
9d70630e | 187 | #define FLD(f) abuf->fields.fmt_2_and3.f |
646c6f2b DE |
188 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
189 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
190 | * FLD (f_r1) = XORSI (* FLD (f_r2), FLD (f_uimm16)); | |
191 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
192 | #if WITH_PROFILE_MODEL_P | |
193 | if (PROFILE_MODEL_P (current_cpu)) | |
194 | { | |
9d70630e DE |
195 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
196 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
197 | model_profile_insn (current_cpu, abuf); |
198 | } | |
199 | #endif | |
200 | return new_pc; | |
201 | #undef FLD | |
202 | } | |
203 | ||
204 | /* Perform addi: addi $dr,$simm8. */ | |
205 | CIA | |
9d70630e | 206 | SEM_FN_NAME (m32r,addi) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 207 | { |
9d70630e | 208 | #define FLD(f) abuf->fields.fmt_4_addi.f |
646c6f2b DE |
209 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
210 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
211 | * FLD (f_r1) = ADDSI (* FLD (f_r1), FLD (f_simm8)); | |
212 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
213 | #if WITH_PROFILE_MODEL_P | |
214 | if (PROFILE_MODEL_P (current_cpu)) | |
215 | { | |
9d70630e DE |
216 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
217 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
218 | model_profile_insn (current_cpu, abuf); |
219 | } | |
220 | #endif | |
221 | return new_pc; | |
222 | #undef FLD | |
223 | } | |
224 | ||
225 | /* Perform addv: addv $dr,$sr. */ | |
226 | CIA | |
9d70630e | 227 | SEM_FN_NAME (m32r,addv) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 228 | { |
9d70630e | 229 | #define FLD(f) abuf->fields.fmt_0_add.f |
646c6f2b DE |
230 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
231 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
232 | do { | |
233 | BI temp1;SI temp0; | |
9d70630e DE |
234 | temp0 = ADDSI (* FLD (f_r1), * FLD (f_r2)); |
235 | temp1 = ADDOFSI (* FLD (f_r1), * FLD (f_r2), 0); | |
646c6f2b DE |
236 | * FLD (f_r1) = temp0; |
237 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
9d70630e DE |
238 | CPU (h_cond) = temp1; |
239 | TRACE_RESULT (current_cpu, "condbit", 'x', CPU (h_cond)); | |
646c6f2b DE |
240 | } while (0); |
241 | #if WITH_PROFILE_MODEL_P | |
242 | if (PROFILE_MODEL_P (current_cpu)) | |
243 | { | |
9d70630e DE |
244 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
245 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
246 | model_profile_insn (current_cpu, abuf); |
247 | } | |
248 | #endif | |
249 | return new_pc; | |
250 | #undef FLD | |
251 | } | |
252 | ||
253 | /* Perform addv3: addv3 $dr,$sr,$simm16. */ | |
254 | CIA | |
9d70630e | 255 | SEM_FN_NAME (m32r,addv3) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 256 | { |
9d70630e | 257 | #define FLD(f) abuf->fields.fmt_5_addv3.f |
646c6f2b DE |
258 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
259 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
260 | do { | |
261 | BI temp1;SI temp0; | |
9d70630e DE |
262 | temp0 = ADDSI (* FLD (f_r2), FLD (f_simm16)); |
263 | temp1 = ADDOFSI (* FLD (f_r2), FLD (f_simm16), 0); | |
646c6f2b DE |
264 | * FLD (f_r1) = temp0; |
265 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
9d70630e DE |
266 | CPU (h_cond) = temp1; |
267 | TRACE_RESULT (current_cpu, "condbit", 'x', CPU (h_cond)); | |
646c6f2b DE |
268 | } while (0); |
269 | #if WITH_PROFILE_MODEL_P | |
270 | if (PROFILE_MODEL_P (current_cpu)) | |
271 | { | |
9d70630e DE |
272 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
273 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
274 | model_profile_insn (current_cpu, abuf); |
275 | } | |
276 | #endif | |
277 | return new_pc; | |
278 | #undef FLD | |
279 | } | |
280 | ||
281 | /* Perform addx: addx $dr,$sr. */ | |
282 | CIA | |
9d70630e | 283 | SEM_FN_NAME (m32r,addx) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 284 | { |
9d70630e | 285 | #define FLD(f) abuf->fields.fmt_6_addx.f |
646c6f2b DE |
286 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
287 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
288 | do { | |
289 | BI temp1;SI temp0; | |
9d70630e DE |
290 | temp0 = ADDCSI (* FLD (f_r1), * FLD (f_r2), CPU (h_cond)); |
291 | temp1 = ADDCFSI (* FLD (f_r1), * FLD (f_r2), CPU (h_cond)); | |
646c6f2b DE |
292 | * FLD (f_r1) = temp0; |
293 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
9d70630e DE |
294 | CPU (h_cond) = temp1; |
295 | TRACE_RESULT (current_cpu, "condbit", 'x', CPU (h_cond)); | |
646c6f2b DE |
296 | } while (0); |
297 | #if WITH_PROFILE_MODEL_P | |
298 | if (PROFILE_MODEL_P (current_cpu)) | |
299 | { | |
9d70630e DE |
300 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
301 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
302 | model_profile_insn (current_cpu, abuf); |
303 | } | |
304 | #endif | |
305 | return new_pc; | |
306 | #undef FLD | |
307 | } | |
308 | ||
309 | /* Perform bc8: bc $disp8. */ | |
310 | CIA | |
9d70630e | 311 | SEM_FN_NAME (m32r,bc8) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 312 | { |
9d70630e | 313 | #define FLD(f) abuf->fields.fmt_7_bc8.f |
646c6f2b DE |
314 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
315 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
316 | int taken_p = 0; | |
9d70630e DE |
317 | if (CPU (h_cond)) { |
318 | BRANCH_NEW_PC (current_cpu, new_pc, SEM_BRANCH_VIA_CACHE (sem_arg, FLD (f_disp8))); | |
646c6f2b DE |
319 | taken_p = 1; |
320 | } | |
321 | #if WITH_PROFILE_MODEL_P | |
322 | if (PROFILE_MODEL_P (current_cpu)) | |
323 | { | |
324 | model_profile_cti_insn (current_cpu, abuf, taken_p); | |
325 | } | |
326 | #endif | |
327 | return new_pc; | |
328 | #undef FLD | |
329 | } | |
330 | ||
331 | /* Perform bc24: bc $disp24. */ | |
332 | CIA | |
9d70630e | 333 | SEM_FN_NAME (m32r,bc24) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 334 | { |
9d70630e | 335 | #define FLD(f) abuf->fields.fmt_8_bc24.f |
646c6f2b DE |
336 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
337 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
338 | int taken_p = 0; | |
9d70630e DE |
339 | if (CPU (h_cond)) { |
340 | BRANCH_NEW_PC (current_cpu, new_pc, SEM_BRANCH_VIA_CACHE (sem_arg, FLD (f_disp24))); | |
646c6f2b DE |
341 | taken_p = 1; |
342 | } | |
343 | #if WITH_PROFILE_MODEL_P | |
344 | if (PROFILE_MODEL_P (current_cpu)) | |
345 | { | |
346 | model_profile_cti_insn (current_cpu, abuf, taken_p); | |
347 | } | |
348 | #endif | |
349 | return new_pc; | |
350 | #undef FLD | |
351 | } | |
352 | ||
353 | /* Perform beq: beq $src1,$src2,$disp16. */ | |
354 | CIA | |
9d70630e | 355 | SEM_FN_NAME (m32r,beq) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 356 | { |
9d70630e | 357 | #define FLD(f) abuf->fields.fmt_9_beq.f |
646c6f2b DE |
358 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
359 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
360 | int taken_p = 0; | |
9d70630e DE |
361 | if (EQSI (* FLD (f_r1), * FLD (f_r2))) { |
362 | BRANCH_NEW_PC (current_cpu, new_pc, SEM_BRANCH_VIA_CACHE (sem_arg, FLD (f_disp16))); | |
646c6f2b DE |
363 | taken_p = 1; |
364 | } | |
365 | #if WITH_PROFILE_MODEL_P | |
366 | if (PROFILE_MODEL_P (current_cpu)) | |
367 | { | |
9d70630e | 368 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
369 | model_profile_cti_insn (current_cpu, abuf, taken_p); |
370 | } | |
371 | #endif | |
372 | return new_pc; | |
373 | #undef FLD | |
374 | } | |
375 | ||
376 | /* Perform beqz: beqz $src2,$disp16. */ | |
377 | CIA | |
9d70630e | 378 | SEM_FN_NAME (m32r,beqz) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 379 | { |
9d70630e | 380 | #define FLD(f) abuf->fields.fmt_10_beqz.f |
646c6f2b DE |
381 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
382 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
383 | int taken_p = 0; | |
9d70630e DE |
384 | if (EQSI (* FLD (f_r2), 0)) { |
385 | BRANCH_NEW_PC (current_cpu, new_pc, SEM_BRANCH_VIA_CACHE (sem_arg, FLD (f_disp16))); | |
646c6f2b DE |
386 | taken_p = 1; |
387 | } | |
388 | #if WITH_PROFILE_MODEL_P | |
389 | if (PROFILE_MODEL_P (current_cpu)) | |
390 | { | |
9d70630e | 391 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
392 | model_profile_cti_insn (current_cpu, abuf, taken_p); |
393 | } | |
394 | #endif | |
395 | return new_pc; | |
396 | #undef FLD | |
397 | } | |
398 | ||
399 | /* Perform bgez: bgez $src2,$disp16. */ | |
400 | CIA | |
9d70630e | 401 | SEM_FN_NAME (m32r,bgez) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 402 | { |
9d70630e | 403 | #define FLD(f) abuf->fields.fmt_10_beqz.f |
646c6f2b DE |
404 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
405 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
406 | int taken_p = 0; | |
9d70630e DE |
407 | if (GESI (* FLD (f_r2), 0)) { |
408 | BRANCH_NEW_PC (current_cpu, new_pc, SEM_BRANCH_VIA_CACHE (sem_arg, FLD (f_disp16))); | |
646c6f2b DE |
409 | taken_p = 1; |
410 | } | |
411 | #if WITH_PROFILE_MODEL_P | |
412 | if (PROFILE_MODEL_P (current_cpu)) | |
413 | { | |
9d70630e | 414 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
415 | model_profile_cti_insn (current_cpu, abuf, taken_p); |
416 | } | |
417 | #endif | |
418 | return new_pc; | |
419 | #undef FLD | |
420 | } | |
421 | ||
422 | /* Perform bgtz: bgtz $src2,$disp16. */ | |
423 | CIA | |
9d70630e | 424 | SEM_FN_NAME (m32r,bgtz) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 425 | { |
9d70630e | 426 | #define FLD(f) abuf->fields.fmt_10_beqz.f |
646c6f2b DE |
427 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
428 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
429 | int taken_p = 0; | |
9d70630e DE |
430 | if (GTSI (* FLD (f_r2), 0)) { |
431 | BRANCH_NEW_PC (current_cpu, new_pc, SEM_BRANCH_VIA_CACHE (sem_arg, FLD (f_disp16))); | |
646c6f2b DE |
432 | taken_p = 1; |
433 | } | |
434 | #if WITH_PROFILE_MODEL_P | |
435 | if (PROFILE_MODEL_P (current_cpu)) | |
436 | { | |
9d70630e | 437 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
438 | model_profile_cti_insn (current_cpu, abuf, taken_p); |
439 | } | |
440 | #endif | |
441 | return new_pc; | |
442 | #undef FLD | |
443 | } | |
444 | ||
445 | /* Perform blez: blez $src2,$disp16. */ | |
446 | CIA | |
9d70630e | 447 | SEM_FN_NAME (m32r,blez) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 448 | { |
9d70630e | 449 | #define FLD(f) abuf->fields.fmt_10_beqz.f |
646c6f2b DE |
450 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
451 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
452 | int taken_p = 0; | |
9d70630e DE |
453 | if (LESI (* FLD (f_r2), 0)) { |
454 | BRANCH_NEW_PC (current_cpu, new_pc, SEM_BRANCH_VIA_CACHE (sem_arg, FLD (f_disp16))); | |
646c6f2b DE |
455 | taken_p = 1; |
456 | } | |
457 | #if WITH_PROFILE_MODEL_P | |
458 | if (PROFILE_MODEL_P (current_cpu)) | |
459 | { | |
9d70630e | 460 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
461 | model_profile_cti_insn (current_cpu, abuf, taken_p); |
462 | } | |
463 | #endif | |
464 | return new_pc; | |
465 | #undef FLD | |
466 | } | |
467 | ||
468 | /* Perform bltz: bltz $src2,$disp16. */ | |
469 | CIA | |
9d70630e | 470 | SEM_FN_NAME (m32r,bltz) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 471 | { |
9d70630e | 472 | #define FLD(f) abuf->fields.fmt_10_beqz.f |
646c6f2b DE |
473 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
474 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
475 | int taken_p = 0; | |
9d70630e DE |
476 | if (LTSI (* FLD (f_r2), 0)) { |
477 | BRANCH_NEW_PC (current_cpu, new_pc, SEM_BRANCH_VIA_CACHE (sem_arg, FLD (f_disp16))); | |
646c6f2b DE |
478 | taken_p = 1; |
479 | } | |
480 | #if WITH_PROFILE_MODEL_P | |
481 | if (PROFILE_MODEL_P (current_cpu)) | |
482 | { | |
9d70630e | 483 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
484 | model_profile_cti_insn (current_cpu, abuf, taken_p); |
485 | } | |
486 | #endif | |
487 | return new_pc; | |
488 | #undef FLD | |
489 | } | |
490 | ||
491 | /* Perform bnez: bnez $src2,$disp16. */ | |
492 | CIA | |
9d70630e | 493 | SEM_FN_NAME (m32r,bnez) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 494 | { |
9d70630e | 495 | #define FLD(f) abuf->fields.fmt_10_beqz.f |
646c6f2b DE |
496 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
497 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
498 | int taken_p = 0; | |
9d70630e DE |
499 | if (NESI (* FLD (f_r2), 0)) { |
500 | BRANCH_NEW_PC (current_cpu, new_pc, SEM_BRANCH_VIA_CACHE (sem_arg, FLD (f_disp16))); | |
646c6f2b DE |
501 | taken_p = 1; |
502 | } | |
503 | #if WITH_PROFILE_MODEL_P | |
504 | if (PROFILE_MODEL_P (current_cpu)) | |
505 | { | |
9d70630e | 506 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
507 | model_profile_cti_insn (current_cpu, abuf, taken_p); |
508 | } | |
509 | #endif | |
510 | return new_pc; | |
511 | #undef FLD | |
512 | } | |
513 | ||
514 | /* Perform bl8: bl $disp8. */ | |
515 | CIA | |
9d70630e | 516 | SEM_FN_NAME (m32r,bl8) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 517 | { |
9d70630e | 518 | #define FLD(f) abuf->fields.fmt_11_bl8.f |
646c6f2b DE |
519 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
520 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
521 | int taken_p = 0; | |
9d70630e DE |
522 | do { |
523 | CPU (h_gr[14]) = ADDSI (ANDSI (CPU (h_pc), -4), 4); | |
524 | TRACE_RESULT (current_cpu, "h-gr", 'x', CPU (h_gr[14])); | |
525 | BRANCH_NEW_PC (current_cpu, new_pc, SEM_BRANCH_VIA_CACHE (sem_arg, FLD (f_disp8))); | |
646c6f2b | 526 | taken_p = 1; |
9d70630e | 527 | } while (0); |
646c6f2b DE |
528 | #if WITH_PROFILE_MODEL_P |
529 | if (PROFILE_MODEL_P (current_cpu)) | |
530 | { | |
646c6f2b DE |
531 | model_profile_cti_insn (current_cpu, abuf, taken_p); |
532 | } | |
533 | #endif | |
534 | return new_pc; | |
535 | #undef FLD | |
536 | } | |
537 | ||
538 | /* Perform bl24: bl $disp24. */ | |
539 | CIA | |
9d70630e | 540 | SEM_FN_NAME (m32r,bl24) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 541 | { |
9d70630e | 542 | #define FLD(f) abuf->fields.fmt_12_bl24.f |
646c6f2b DE |
543 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
544 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
545 | int taken_p = 0; | |
9d70630e DE |
546 | do { |
547 | CPU (h_gr[14]) = ADDSI (CPU (h_pc), 4); | |
548 | TRACE_RESULT (current_cpu, "h-gr", 'x', CPU (h_gr[14])); | |
549 | BRANCH_NEW_PC (current_cpu, new_pc, SEM_BRANCH_VIA_CACHE (sem_arg, FLD (f_disp24))); | |
646c6f2b | 550 | taken_p = 1; |
9d70630e | 551 | } while (0); |
646c6f2b DE |
552 | #if WITH_PROFILE_MODEL_P |
553 | if (PROFILE_MODEL_P (current_cpu)) | |
554 | { | |
646c6f2b DE |
555 | model_profile_cti_insn (current_cpu, abuf, taken_p); |
556 | } | |
557 | #endif | |
558 | return new_pc; | |
559 | #undef FLD | |
560 | } | |
561 | ||
562 | /* Perform bnc8: bnc $disp8. */ | |
563 | CIA | |
9d70630e | 564 | SEM_FN_NAME (m32r,bnc8) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 565 | { |
9d70630e | 566 | #define FLD(f) abuf->fields.fmt_7_bc8.f |
646c6f2b DE |
567 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
568 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
569 | int taken_p = 0; | |
9d70630e DE |
570 | if (NOTBI (CPU (h_cond))) { |
571 | BRANCH_NEW_PC (current_cpu, new_pc, SEM_BRANCH_VIA_CACHE (sem_arg, FLD (f_disp8))); | |
646c6f2b DE |
572 | taken_p = 1; |
573 | } | |
574 | #if WITH_PROFILE_MODEL_P | |
575 | if (PROFILE_MODEL_P (current_cpu)) | |
576 | { | |
577 | model_profile_cti_insn (current_cpu, abuf, taken_p); | |
578 | } | |
579 | #endif | |
580 | return new_pc; | |
581 | #undef FLD | |
582 | } | |
583 | ||
584 | /* Perform bnc24: bnc $disp24. */ | |
585 | CIA | |
9d70630e | 586 | SEM_FN_NAME (m32r,bnc24) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 587 | { |
9d70630e | 588 | #define FLD(f) abuf->fields.fmt_8_bc24.f |
646c6f2b DE |
589 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
590 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
591 | int taken_p = 0; | |
9d70630e DE |
592 | if (NOTBI (CPU (h_cond))) { |
593 | BRANCH_NEW_PC (current_cpu, new_pc, SEM_BRANCH_VIA_CACHE (sem_arg, FLD (f_disp24))); | |
646c6f2b DE |
594 | taken_p = 1; |
595 | } | |
596 | #if WITH_PROFILE_MODEL_P | |
597 | if (PROFILE_MODEL_P (current_cpu)) | |
598 | { | |
599 | model_profile_cti_insn (current_cpu, abuf, taken_p); | |
600 | } | |
601 | #endif | |
602 | return new_pc; | |
603 | #undef FLD | |
604 | } | |
605 | ||
606 | /* Perform bne: bne $src1,$src2,$disp16. */ | |
607 | CIA | |
9d70630e | 608 | SEM_FN_NAME (m32r,bne) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 609 | { |
9d70630e | 610 | #define FLD(f) abuf->fields.fmt_9_beq.f |
646c6f2b DE |
611 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
612 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
613 | int taken_p = 0; | |
9d70630e DE |
614 | if (NESI (* FLD (f_r1), * FLD (f_r2))) { |
615 | BRANCH_NEW_PC (current_cpu, new_pc, SEM_BRANCH_VIA_CACHE (sem_arg, FLD (f_disp16))); | |
646c6f2b DE |
616 | taken_p = 1; |
617 | } | |
618 | #if WITH_PROFILE_MODEL_P | |
619 | if (PROFILE_MODEL_P (current_cpu)) | |
620 | { | |
9d70630e | 621 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
622 | model_profile_cti_insn (current_cpu, abuf, taken_p); |
623 | } | |
624 | #endif | |
625 | return new_pc; | |
626 | #undef FLD | |
627 | } | |
628 | ||
629 | /* Perform bra8: bra $disp8. */ | |
630 | CIA | |
9d70630e | 631 | SEM_FN_NAME (m32r,bra8) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 632 | { |
9d70630e | 633 | #define FLD(f) abuf->fields.fmt_13_bra8.f |
646c6f2b DE |
634 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
635 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
636 | int taken_p = 0; | |
9d70630e | 637 | BRANCH_NEW_PC (current_cpu, new_pc, SEM_BRANCH_VIA_CACHE (sem_arg, FLD (f_disp8))); |
646c6f2b DE |
638 | taken_p = 1; |
639 | #if WITH_PROFILE_MODEL_P | |
640 | if (PROFILE_MODEL_P (current_cpu)) | |
641 | { | |
642 | model_profile_cti_insn (current_cpu, abuf, taken_p); | |
643 | } | |
644 | #endif | |
645 | return new_pc; | |
646 | #undef FLD | |
647 | } | |
648 | ||
649 | /* Perform bra24: bra $disp24. */ | |
650 | CIA | |
9d70630e | 651 | SEM_FN_NAME (m32r,bra24) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 652 | { |
9d70630e | 653 | #define FLD(f) abuf->fields.fmt_14_bra24.f |
646c6f2b DE |
654 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
655 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
656 | int taken_p = 0; | |
9d70630e | 657 | BRANCH_NEW_PC (current_cpu, new_pc, SEM_BRANCH_VIA_CACHE (sem_arg, FLD (f_disp24))); |
646c6f2b DE |
658 | taken_p = 1; |
659 | #if WITH_PROFILE_MODEL_P | |
660 | if (PROFILE_MODEL_P (current_cpu)) | |
661 | { | |
662 | model_profile_cti_insn (current_cpu, abuf, taken_p); | |
663 | } | |
664 | #endif | |
665 | return new_pc; | |
666 | #undef FLD | |
667 | } | |
668 | ||
669 | /* Perform cmp: cmp $src1,$src2. */ | |
670 | CIA | |
9d70630e | 671 | SEM_FN_NAME (m32r,cmp) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 672 | { |
9d70630e | 673 | #define FLD(f) abuf->fields.fmt_15_cmp.f |
646c6f2b DE |
674 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
675 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
9d70630e DE |
676 | CPU (h_cond) = LTSI (* FLD (f_r1), * FLD (f_r2)); |
677 | TRACE_RESULT (current_cpu, "condbit", 'x', CPU (h_cond)); | |
646c6f2b DE |
678 | #if WITH_PROFILE_MODEL_P |
679 | if (PROFILE_MODEL_P (current_cpu)) | |
680 | { | |
9d70630e | 681 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
682 | model_profile_insn (current_cpu, abuf); |
683 | } | |
684 | #endif | |
685 | return new_pc; | |
686 | #undef FLD | |
687 | } | |
688 | ||
689 | /* Perform cmpi: cmpi $src2,$simm16. */ | |
690 | CIA | |
9d70630e | 691 | SEM_FN_NAME (m32r,cmpi) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 692 | { |
9d70630e | 693 | #define FLD(f) abuf->fields.fmt_16_cmpi.f |
646c6f2b DE |
694 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
695 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
9d70630e DE |
696 | CPU (h_cond) = LTSI (* FLD (f_r2), FLD (f_simm16)); |
697 | TRACE_RESULT (current_cpu, "condbit", 'x', CPU (h_cond)); | |
646c6f2b DE |
698 | #if WITH_PROFILE_MODEL_P |
699 | if (PROFILE_MODEL_P (current_cpu)) | |
700 | { | |
9d70630e | 701 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
702 | model_profile_insn (current_cpu, abuf); |
703 | } | |
704 | #endif | |
705 | return new_pc; | |
706 | #undef FLD | |
707 | } | |
708 | ||
709 | /* Perform cmpu: cmpu $src1,$src2. */ | |
710 | CIA | |
9d70630e | 711 | SEM_FN_NAME (m32r,cmpu) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 712 | { |
9d70630e | 713 | #define FLD(f) abuf->fields.fmt_15_cmp.f |
646c6f2b DE |
714 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
715 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
9d70630e DE |
716 | CPU (h_cond) = LTUSI (* FLD (f_r1), * FLD (f_r2)); |
717 | TRACE_RESULT (current_cpu, "condbit", 'x', CPU (h_cond)); | |
646c6f2b DE |
718 | #if WITH_PROFILE_MODEL_P |
719 | if (PROFILE_MODEL_P (current_cpu)) | |
720 | { | |
9d70630e | 721 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
722 | model_profile_insn (current_cpu, abuf); |
723 | } | |
724 | #endif | |
725 | return new_pc; | |
726 | #undef FLD | |
727 | } | |
728 | ||
729 | /* Perform cmpui: cmpui $src2,$uimm16. */ | |
730 | CIA | |
9d70630e | 731 | SEM_FN_NAME (m32r,cmpui) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 732 | { |
9d70630e | 733 | #define FLD(f) abuf->fields.fmt_17_cmpui.f |
646c6f2b DE |
734 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
735 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
9d70630e DE |
736 | CPU (h_cond) = LTUSI (* FLD (f_r2), FLD (f_uimm16)); |
737 | TRACE_RESULT (current_cpu, "condbit", 'x', CPU (h_cond)); | |
646c6f2b DE |
738 | #if WITH_PROFILE_MODEL_P |
739 | if (PROFILE_MODEL_P (current_cpu)) | |
740 | { | |
9d70630e | 741 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
742 | model_profile_insn (current_cpu, abuf); |
743 | } | |
744 | #endif | |
745 | return new_pc; | |
746 | #undef FLD | |
747 | } | |
748 | ||
749 | /* Perform div: div $dr,$sr. */ | |
750 | CIA | |
9d70630e | 751 | SEM_FN_NAME (m32r,div) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 752 | { |
9d70630e | 753 | #define FLD(f) abuf->fields.fmt_18_div.f |
646c6f2b DE |
754 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
755 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
9d70630e | 756 | if (NESI (* FLD (f_r2), 0)) { |
646c6f2b DE |
757 | * FLD (f_r1) = DIVSI (* FLD (f_r1), * FLD (f_r2)); |
758 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
759 | } | |
760 | #if WITH_PROFILE_MODEL_P | |
761 | if (PROFILE_MODEL_P (current_cpu)) | |
762 | { | |
9d70630e DE |
763 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
764 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
765 | model_profile_insn (current_cpu, abuf); |
766 | } | |
767 | #endif | |
768 | return new_pc; | |
769 | #undef FLD | |
770 | } | |
771 | ||
772 | /* Perform divu: divu $dr,$sr. */ | |
773 | CIA | |
9d70630e | 774 | SEM_FN_NAME (m32r,divu) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 775 | { |
9d70630e | 776 | #define FLD(f) abuf->fields.fmt_18_div.f |
646c6f2b DE |
777 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
778 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
9d70630e | 779 | if (NESI (* FLD (f_r2), 0)) { |
646c6f2b DE |
780 | * FLD (f_r1) = UDIVSI (* FLD (f_r1), * FLD (f_r2)); |
781 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
782 | } | |
783 | #if WITH_PROFILE_MODEL_P | |
784 | if (PROFILE_MODEL_P (current_cpu)) | |
785 | { | |
9d70630e DE |
786 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
787 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
788 | model_profile_insn (current_cpu, abuf); |
789 | } | |
790 | #endif | |
791 | return new_pc; | |
792 | #undef FLD | |
793 | } | |
794 | ||
795 | /* Perform rem: rem $dr,$sr. */ | |
796 | CIA | |
9d70630e | 797 | SEM_FN_NAME (m32r,rem) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 798 | { |
9d70630e | 799 | #define FLD(f) abuf->fields.fmt_18_div.f |
646c6f2b DE |
800 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
801 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
9d70630e | 802 | if (NESI (* FLD (f_r2), 0)) { |
646c6f2b DE |
803 | * FLD (f_r1) = MODSI (* FLD (f_r1), * FLD (f_r2)); |
804 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
805 | } | |
806 | #if WITH_PROFILE_MODEL_P | |
807 | if (PROFILE_MODEL_P (current_cpu)) | |
808 | { | |
9d70630e DE |
809 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
810 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
811 | model_profile_insn (current_cpu, abuf); |
812 | } | |
813 | #endif | |
814 | return new_pc; | |
815 | #undef FLD | |
816 | } | |
817 | ||
818 | /* Perform remu: remu $dr,$sr. */ | |
819 | CIA | |
9d70630e | 820 | SEM_FN_NAME (m32r,remu) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 821 | { |
9d70630e | 822 | #define FLD(f) abuf->fields.fmt_18_div.f |
646c6f2b DE |
823 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
824 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
9d70630e | 825 | if (NESI (* FLD (f_r2), 0)) { |
646c6f2b DE |
826 | * FLD (f_r1) = UMODSI (* FLD (f_r1), * FLD (f_r2)); |
827 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
828 | } | |
829 | #if WITH_PROFILE_MODEL_P | |
830 | if (PROFILE_MODEL_P (current_cpu)) | |
831 | { | |
9d70630e DE |
832 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
833 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
834 | model_profile_insn (current_cpu, abuf); |
835 | } | |
836 | #endif | |
837 | return new_pc; | |
838 | #undef FLD | |
839 | } | |
840 | ||
841 | /* Perform jl: jl $sr. */ | |
842 | CIA | |
9d70630e | 843 | SEM_FN_NAME (m32r,jl) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 844 | { |
9d70630e | 845 | #define FLD(f) abuf->fields.fmt_19_jl.f |
646c6f2b DE |
846 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
847 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
848 | int taken_p = 0; | |
849 | do { | |
9d70630e DE |
850 | USI temp1;SI temp0; |
851 | temp0 = ADDSI (ANDSI (CPU (h_pc), -4), 4); | |
852 | temp1 = * FLD (f_r2); | |
853 | CPU (h_gr[14]) = temp0; | |
854 | TRACE_RESULT (current_cpu, "h-gr", 'x', CPU (h_gr[14])); | |
855 | BRANCH_NEW_PC (current_cpu, new_pc, SEM_BRANCH_VIA_ADDR (sem_arg, temp1)); | |
646c6f2b DE |
856 | taken_p = 1; |
857 | } while (0); | |
858 | #if WITH_PROFILE_MODEL_P | |
859 | if (PROFILE_MODEL_P (current_cpu)) | |
860 | { | |
9d70630e | 861 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
862 | model_profile_cti_insn (current_cpu, abuf, taken_p); |
863 | } | |
864 | #endif | |
865 | return new_pc; | |
866 | #undef FLD | |
867 | } | |
868 | ||
869 | /* Perform jmp: jmp $sr. */ | |
870 | CIA | |
9d70630e | 871 | SEM_FN_NAME (m32r,jmp) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 872 | { |
9d70630e | 873 | #define FLD(f) abuf->fields.fmt_20_jmp.f |
646c6f2b DE |
874 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
875 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
876 | int taken_p = 0; | |
9d70630e | 877 | BRANCH_NEW_PC (current_cpu, new_pc, SEM_BRANCH_VIA_ADDR (sem_arg, * FLD (f_r2))); |
646c6f2b DE |
878 | taken_p = 1; |
879 | #if WITH_PROFILE_MODEL_P | |
880 | if (PROFILE_MODEL_P (current_cpu)) | |
881 | { | |
9d70630e | 882 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
883 | model_profile_cti_insn (current_cpu, abuf, taken_p); |
884 | } | |
885 | #endif | |
886 | return new_pc; | |
887 | #undef FLD | |
888 | } | |
889 | ||
890 | /* Perform ld: ld $dr,@$sr. */ | |
891 | CIA | |
9d70630e | 892 | SEM_FN_NAME (m32r,ld) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 893 | { |
9d70630e | 894 | #define FLD(f) abuf->fields.fmt_21_ld.f |
646c6f2b DE |
895 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
896 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
897 | * FLD (f_r1) = GETMEMSI (current_cpu, * FLD (f_r2)); | |
898 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
899 | #if WITH_PROFILE_MODEL_P | |
900 | if (PROFILE_MODEL_P (current_cpu)) | |
901 | { | |
9d70630e DE |
902 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
903 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
904 | model_profile_insn (current_cpu, abuf); |
905 | } | |
906 | #endif | |
907 | return new_pc; | |
908 | #undef FLD | |
909 | } | |
910 | ||
911 | /* Perform ld-d: ld $dr,@($slo16,$sr). */ | |
912 | CIA | |
9d70630e | 913 | SEM_FN_NAME (m32r,ld_d) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 914 | { |
9d70630e | 915 | #define FLD(f) abuf->fields.fmt_22_ld_d.f |
646c6f2b DE |
916 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
917 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
918 | * FLD (f_r1) = GETMEMSI (current_cpu, ADDSI (* FLD (f_r2), FLD (f_simm16))); | |
919 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
920 | #if WITH_PROFILE_MODEL_P | |
921 | if (PROFILE_MODEL_P (current_cpu)) | |
922 | { | |
9d70630e DE |
923 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
924 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
925 | model_profile_insn (current_cpu, abuf); |
926 | } | |
927 | #endif | |
928 | return new_pc; | |
929 | #undef FLD | |
930 | } | |
931 | ||
932 | /* Perform ldb: ldb $dr,@$sr. */ | |
933 | CIA | |
9d70630e | 934 | SEM_FN_NAME (m32r,ldb) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 935 | { |
9d70630e | 936 | #define FLD(f) abuf->fields.fmt_23_ldb.f |
646c6f2b DE |
937 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
938 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
939 | * FLD (f_r1) = EXTQISI (GETMEMQI (current_cpu, * FLD (f_r2))); | |
940 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
941 | #if WITH_PROFILE_MODEL_P | |
942 | if (PROFILE_MODEL_P (current_cpu)) | |
943 | { | |
9d70630e DE |
944 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
945 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
946 | model_profile_insn (current_cpu, abuf); |
947 | } | |
948 | #endif | |
949 | return new_pc; | |
950 | #undef FLD | |
951 | } | |
952 | ||
953 | /* Perform ldb-d: ldb $dr,@($slo16,$sr). */ | |
954 | CIA | |
9d70630e | 955 | SEM_FN_NAME (m32r,ldb_d) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 956 | { |
9d70630e | 957 | #define FLD(f) abuf->fields.fmt_24_ldb_d.f |
646c6f2b DE |
958 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
959 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
960 | * FLD (f_r1) = EXTQISI (GETMEMQI (current_cpu, ADDSI (* FLD (f_r2), FLD (f_simm16)))); | |
961 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
962 | #if WITH_PROFILE_MODEL_P | |
963 | if (PROFILE_MODEL_P (current_cpu)) | |
964 | { | |
9d70630e DE |
965 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
966 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
967 | model_profile_insn (current_cpu, abuf); |
968 | } | |
969 | #endif | |
970 | return new_pc; | |
971 | #undef FLD | |
972 | } | |
973 | ||
974 | /* Perform ldh: ldh $dr,@$sr. */ | |
975 | CIA | |
9d70630e | 976 | SEM_FN_NAME (m32r,ldh) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 977 | { |
9d70630e | 978 | #define FLD(f) abuf->fields.fmt_25_ldh.f |
646c6f2b DE |
979 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
980 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
981 | * FLD (f_r1) = EXTHISI (GETMEMHI (current_cpu, * FLD (f_r2))); | |
982 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
983 | #if WITH_PROFILE_MODEL_P | |
984 | if (PROFILE_MODEL_P (current_cpu)) | |
985 | { | |
9d70630e DE |
986 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
987 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
988 | model_profile_insn (current_cpu, abuf); |
989 | } | |
990 | #endif | |
991 | return new_pc; | |
992 | #undef FLD | |
993 | } | |
994 | ||
995 | /* Perform ldh-d: ldh $dr,@($slo16,$sr). */ | |
996 | CIA | |
9d70630e | 997 | SEM_FN_NAME (m32r,ldh_d) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 998 | { |
9d70630e | 999 | #define FLD(f) abuf->fields.fmt_26_ldh_d.f |
646c6f2b DE |
1000 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1001 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
1002 | * FLD (f_r1) = EXTHISI (GETMEMHI (current_cpu, ADDSI (* FLD (f_r2), FLD (f_simm16)))); | |
1003 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
1004 | #if WITH_PROFILE_MODEL_P | |
1005 | if (PROFILE_MODEL_P (current_cpu)) | |
1006 | { | |
9d70630e DE |
1007 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
1008 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
1009 | model_profile_insn (current_cpu, abuf); |
1010 | } | |
1011 | #endif | |
1012 | return new_pc; | |
1013 | #undef FLD | |
1014 | } | |
1015 | ||
1016 | /* Perform ldub: ldub $dr,@$sr. */ | |
1017 | CIA | |
9d70630e | 1018 | SEM_FN_NAME (m32r,ldub) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1019 | { |
9d70630e | 1020 | #define FLD(f) abuf->fields.fmt_23_ldb.f |
646c6f2b DE |
1021 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1022 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
1023 | * FLD (f_r1) = ZEXTQISI (GETMEMQI (current_cpu, * FLD (f_r2))); | |
1024 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
1025 | #if WITH_PROFILE_MODEL_P | |
1026 | if (PROFILE_MODEL_P (current_cpu)) | |
1027 | { | |
9d70630e DE |
1028 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
1029 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
1030 | model_profile_insn (current_cpu, abuf); |
1031 | } | |
1032 | #endif | |
1033 | return new_pc; | |
1034 | #undef FLD | |
1035 | } | |
1036 | ||
1037 | /* Perform ldub-d: ldub $dr,@($slo16,$sr). */ | |
1038 | CIA | |
9d70630e | 1039 | SEM_FN_NAME (m32r,ldub_d) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1040 | { |
9d70630e | 1041 | #define FLD(f) abuf->fields.fmt_24_ldb_d.f |
646c6f2b DE |
1042 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1043 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
1044 | * FLD (f_r1) = ZEXTQISI (GETMEMQI (current_cpu, ADDSI (* FLD (f_r2), FLD (f_simm16)))); | |
1045 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
1046 | #if WITH_PROFILE_MODEL_P | |
1047 | if (PROFILE_MODEL_P (current_cpu)) | |
1048 | { | |
9d70630e DE |
1049 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
1050 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
1051 | model_profile_insn (current_cpu, abuf); |
1052 | } | |
1053 | #endif | |
1054 | return new_pc; | |
1055 | #undef FLD | |
1056 | } | |
1057 | ||
1058 | /* Perform lduh: lduh $dr,@$sr. */ | |
1059 | CIA | |
9d70630e | 1060 | SEM_FN_NAME (m32r,lduh) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1061 | { |
9d70630e | 1062 | #define FLD(f) abuf->fields.fmt_25_ldh.f |
646c6f2b DE |
1063 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1064 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
1065 | * FLD (f_r1) = ZEXTHISI (GETMEMHI (current_cpu, * FLD (f_r2))); | |
1066 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
1067 | #if WITH_PROFILE_MODEL_P | |
1068 | if (PROFILE_MODEL_P (current_cpu)) | |
1069 | { | |
9d70630e DE |
1070 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
1071 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
1072 | model_profile_insn (current_cpu, abuf); |
1073 | } | |
1074 | #endif | |
1075 | return new_pc; | |
1076 | #undef FLD | |
1077 | } | |
1078 | ||
1079 | /* Perform lduh-d: lduh $dr,@($slo16,$sr). */ | |
1080 | CIA | |
9d70630e | 1081 | SEM_FN_NAME (m32r,lduh_d) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1082 | { |
9d70630e | 1083 | #define FLD(f) abuf->fields.fmt_26_ldh_d.f |
646c6f2b DE |
1084 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1085 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
1086 | * FLD (f_r1) = ZEXTHISI (GETMEMHI (current_cpu, ADDSI (* FLD (f_r2), FLD (f_simm16)))); | |
1087 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
1088 | #if WITH_PROFILE_MODEL_P | |
1089 | if (PROFILE_MODEL_P (current_cpu)) | |
1090 | { | |
9d70630e DE |
1091 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
1092 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
1093 | model_profile_insn (current_cpu, abuf); |
1094 | } | |
1095 | #endif | |
1096 | return new_pc; | |
1097 | #undef FLD | |
1098 | } | |
1099 | ||
1100 | /* Perform ld-plus: ld $dr,@$sr+. */ | |
1101 | CIA | |
9d70630e | 1102 | SEM_FN_NAME (m32r,ld_plus) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1103 | { |
9d70630e | 1104 | #define FLD(f) abuf->fields.fmt_21_ld.f |
646c6f2b DE |
1105 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1106 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
1107 | do { | |
1108 | SI temp1;SI temp0; | |
9d70630e DE |
1109 | temp0 = GETMEMSI (current_cpu, * FLD (f_r2)); |
1110 | temp1 = ADDSI (* FLD (f_r2), 4); | |
646c6f2b DE |
1111 | * FLD (f_r1) = temp0; |
1112 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
1113 | * FLD (f_r2) = temp1; | |
1114 | TRACE_RESULT (current_cpu, "sr", 'x', * FLD (f_r2)); | |
1115 | } while (0); | |
1116 | #if WITH_PROFILE_MODEL_P | |
1117 | if (PROFILE_MODEL_P (current_cpu)) | |
1118 | { | |
9d70630e DE |
1119 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
1120 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
1121 | model_profile_insn (current_cpu, abuf); |
1122 | } | |
1123 | #endif | |
1124 | return new_pc; | |
1125 | #undef FLD | |
1126 | } | |
1127 | ||
1128 | /* Perform ld24: ld24 $dr,$uimm24. */ | |
1129 | CIA | |
9d70630e | 1130 | SEM_FN_NAME (m32r,ld24) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1131 | { |
9d70630e | 1132 | #define FLD(f) abuf->fields.fmt_27_ld24.f |
646c6f2b DE |
1133 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1134 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
1135 | * FLD (f_r1) = FLD (f_uimm24); | |
1136 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
1137 | #if WITH_PROFILE_MODEL_P | |
1138 | if (PROFILE_MODEL_P (current_cpu)) | |
1139 | { | |
9d70630e | 1140 | m32r_model_mark_set_h_gr (current_cpu, abuf); |
646c6f2b DE |
1141 | model_profile_insn (current_cpu, abuf); |
1142 | } | |
1143 | #endif | |
1144 | return new_pc; | |
1145 | #undef FLD | |
1146 | } | |
1147 | ||
1148 | /* Perform ldi8: ldi $dr,$simm8. */ | |
1149 | CIA | |
9d70630e | 1150 | SEM_FN_NAME (m32r,ldi8) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1151 | { |
9d70630e | 1152 | #define FLD(f) abuf->fields.fmt_28_ldi8.f |
646c6f2b DE |
1153 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1154 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
1155 | * FLD (f_r1) = FLD (f_simm8); | |
1156 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
1157 | #if WITH_PROFILE_MODEL_P | |
1158 | if (PROFILE_MODEL_P (current_cpu)) | |
1159 | { | |
9d70630e | 1160 | m32r_model_mark_set_h_gr (current_cpu, abuf); |
646c6f2b DE |
1161 | model_profile_insn (current_cpu, abuf); |
1162 | } | |
1163 | #endif | |
1164 | return new_pc; | |
1165 | #undef FLD | |
1166 | } | |
1167 | ||
1168 | /* Perform ldi16: ldi $dr,$slo16. */ | |
1169 | CIA | |
9d70630e | 1170 | SEM_FN_NAME (m32r,ldi16) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1171 | { |
9d70630e | 1172 | #define FLD(f) abuf->fields.fmt_29_ldi16.f |
646c6f2b DE |
1173 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1174 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
1175 | * FLD (f_r1) = FLD (f_simm16); | |
1176 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
1177 | #if WITH_PROFILE_MODEL_P | |
1178 | if (PROFILE_MODEL_P (current_cpu)) | |
1179 | { | |
9d70630e | 1180 | m32r_model_mark_set_h_gr (current_cpu, abuf); |
646c6f2b DE |
1181 | model_profile_insn (current_cpu, abuf); |
1182 | } | |
1183 | #endif | |
1184 | return new_pc; | |
1185 | #undef FLD | |
1186 | } | |
1187 | ||
1188 | /* Perform lock: lock $dr,@$sr. */ | |
1189 | CIA | |
9d70630e | 1190 | SEM_FN_NAME (m32r,lock) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1191 | { |
9d70630e | 1192 | #define FLD(f) abuf->fields.fmt_0_add.f |
646c6f2b DE |
1193 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1194 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
1195 | do_lock (current_cpu, * FLD (f_r1), * FLD (f_r2)); | |
1196 | #if WITH_PROFILE_MODEL_P | |
1197 | if (PROFILE_MODEL_P (current_cpu)) | |
1198 | { | |
9d70630e DE |
1199 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
1200 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
1201 | model_profile_insn (current_cpu, abuf); |
1202 | } | |
1203 | #endif | |
1204 | return new_pc; | |
1205 | #undef FLD | |
1206 | } | |
1207 | ||
1208 | /* Perform machi: machi $src1,$src2. */ | |
1209 | CIA | |
9d70630e | 1210 | SEM_FN_NAME (m32r,machi) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1211 | { |
9d70630e | 1212 | #define FLD(f) abuf->fields.fmt_30_machi.f |
646c6f2b DE |
1213 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1214 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
9d70630e DE |
1215 | CPU (h_accum) = SRADI (SLLDI (ADDDI (CPU (h_accum), MULDI (EXTSIDI (ANDSI (* FLD (f_r1), 0xffff0000)), EXTHIDI (TRUNCSIHI (SRASI (* FLD (f_r2), 16))))), 8), 8); |
1216 | TRACE_RESULT (current_cpu, "accum", 'D', CPU (h_accum)); | |
646c6f2b DE |
1217 | #if WITH_PROFILE_MODEL_P |
1218 | if (PROFILE_MODEL_P (current_cpu)) | |
1219 | { | |
9d70630e | 1220 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
1221 | model_profile_insn (current_cpu, abuf); |
1222 | } | |
1223 | #endif | |
1224 | return new_pc; | |
1225 | #undef FLD | |
1226 | } | |
1227 | ||
1228 | /* Perform maclo: maclo $src1,$src2. */ | |
1229 | CIA | |
9d70630e | 1230 | SEM_FN_NAME (m32r,maclo) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1231 | { |
9d70630e | 1232 | #define FLD(f) abuf->fields.fmt_30_machi.f |
646c6f2b DE |
1233 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1234 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
9d70630e DE |
1235 | CPU (h_accum) = SRADI (SLLDI (ADDDI (CPU (h_accum), MULDI (EXTSIDI (SLLSI (* FLD (f_r1), 16)), EXTHIDI (TRUNCSIHI (* FLD (f_r2))))), 8), 8); |
1236 | TRACE_RESULT (current_cpu, "accum", 'D', CPU (h_accum)); | |
646c6f2b DE |
1237 | #if WITH_PROFILE_MODEL_P |
1238 | if (PROFILE_MODEL_P (current_cpu)) | |
1239 | { | |
9d70630e | 1240 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
1241 | model_profile_insn (current_cpu, abuf); |
1242 | } | |
1243 | #endif | |
1244 | return new_pc; | |
1245 | #undef FLD | |
1246 | } | |
1247 | ||
1248 | /* Perform macwhi: macwhi $src1,$src2. */ | |
1249 | CIA | |
9d70630e | 1250 | SEM_FN_NAME (m32r,macwhi) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1251 | { |
9d70630e | 1252 | #define FLD(f) abuf->fields.fmt_30_machi.f |
646c6f2b DE |
1253 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1254 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
9d70630e DE |
1255 | CPU (h_accum) = SRADI (SLLDI (ADDDI (CPU (h_accum), MULDI (EXTSIDI (* FLD (f_r1)), EXTHIDI (TRUNCSIHI (SRASI (* FLD (f_r2), 16))))), 8), 8); |
1256 | TRACE_RESULT (current_cpu, "accum", 'D', CPU (h_accum)); | |
646c6f2b DE |
1257 | #if WITH_PROFILE_MODEL_P |
1258 | if (PROFILE_MODEL_P (current_cpu)) | |
1259 | { | |
9d70630e | 1260 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
1261 | model_profile_insn (current_cpu, abuf); |
1262 | } | |
1263 | #endif | |
1264 | return new_pc; | |
1265 | #undef FLD | |
1266 | } | |
1267 | ||
1268 | /* Perform macwlo: macwlo $src1,$src2. */ | |
1269 | CIA | |
9d70630e | 1270 | SEM_FN_NAME (m32r,macwlo) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1271 | { |
9d70630e | 1272 | #define FLD(f) abuf->fields.fmt_30_machi.f |
646c6f2b DE |
1273 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1274 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
9d70630e DE |
1275 | CPU (h_accum) = SRADI (SLLDI (ADDDI (CPU (h_accum), MULDI (EXTSIDI (* FLD (f_r1)), EXTHIDI (TRUNCSIHI (* FLD (f_r2))))), 8), 8); |
1276 | TRACE_RESULT (current_cpu, "accum", 'D', CPU (h_accum)); | |
646c6f2b DE |
1277 | #if WITH_PROFILE_MODEL_P |
1278 | if (PROFILE_MODEL_P (current_cpu)) | |
1279 | { | |
9d70630e | 1280 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
1281 | model_profile_insn (current_cpu, abuf); |
1282 | } | |
1283 | #endif | |
1284 | return new_pc; | |
1285 | #undef FLD | |
1286 | } | |
1287 | ||
1288 | /* Perform mul: mul $dr,$sr. */ | |
1289 | CIA | |
9d70630e | 1290 | SEM_FN_NAME (m32r,mul) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1291 | { |
9d70630e | 1292 | #define FLD(f) abuf->fields.fmt_0_add.f |
646c6f2b DE |
1293 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1294 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
1295 | * FLD (f_r1) = MULSI (* FLD (f_r1), * FLD (f_r2)); | |
1296 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
1297 | #if WITH_PROFILE_MODEL_P | |
1298 | if (PROFILE_MODEL_P (current_cpu)) | |
1299 | { | |
9d70630e DE |
1300 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
1301 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
1302 | model_profile_insn (current_cpu, abuf); |
1303 | } | |
1304 | #endif | |
1305 | return new_pc; | |
1306 | #undef FLD | |
1307 | } | |
1308 | ||
1309 | /* Perform mulhi: mulhi $src1,$src2. */ | |
1310 | CIA | |
9d70630e | 1311 | SEM_FN_NAME (m32r,mulhi) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1312 | { |
9d70630e | 1313 | #define FLD(f) abuf->fields.fmt_15_cmp.f |
646c6f2b DE |
1314 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1315 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
9d70630e DE |
1316 | CPU (h_accum) = SRADI (SLLDI (MULDI (EXTSIDI (ANDSI (* FLD (f_r1), 0xffff0000)), EXTHIDI (TRUNCSIHI (SRASI (* FLD (f_r2), 16)))), 16), 16); |
1317 | TRACE_RESULT (current_cpu, "accum", 'D', CPU (h_accum)); | |
646c6f2b DE |
1318 | #if WITH_PROFILE_MODEL_P |
1319 | if (PROFILE_MODEL_P (current_cpu)) | |
1320 | { | |
9d70630e | 1321 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
1322 | model_profile_insn (current_cpu, abuf); |
1323 | } | |
1324 | #endif | |
1325 | return new_pc; | |
1326 | #undef FLD | |
1327 | } | |
1328 | ||
1329 | /* Perform mullo: mullo $src1,$src2. */ | |
1330 | CIA | |
9d70630e | 1331 | SEM_FN_NAME (m32r,mullo) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1332 | { |
9d70630e | 1333 | #define FLD(f) abuf->fields.fmt_15_cmp.f |
646c6f2b DE |
1334 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1335 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
9d70630e DE |
1336 | CPU (h_accum) = SRADI (SLLDI (MULDI (EXTSIDI (SLLSI (* FLD (f_r1), 16)), EXTHIDI (TRUNCSIHI (* FLD (f_r2)))), 16), 16); |
1337 | TRACE_RESULT (current_cpu, "accum", 'D', CPU (h_accum)); | |
646c6f2b DE |
1338 | #if WITH_PROFILE_MODEL_P |
1339 | if (PROFILE_MODEL_P (current_cpu)) | |
1340 | { | |
9d70630e | 1341 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
1342 | model_profile_insn (current_cpu, abuf); |
1343 | } | |
1344 | #endif | |
1345 | return new_pc; | |
1346 | #undef FLD | |
1347 | } | |
1348 | ||
1349 | /* Perform mulwhi: mulwhi $src1,$src2. */ | |
1350 | CIA | |
9d70630e | 1351 | SEM_FN_NAME (m32r,mulwhi) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1352 | { |
9d70630e | 1353 | #define FLD(f) abuf->fields.fmt_15_cmp.f |
646c6f2b DE |
1354 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1355 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
9d70630e DE |
1356 | CPU (h_accum) = SRADI (SLLDI (MULDI (EXTSIDI (* FLD (f_r1)), EXTHIDI (TRUNCSIHI (SRASI (* FLD (f_r2), 16)))), 8), 8); |
1357 | TRACE_RESULT (current_cpu, "accum", 'D', CPU (h_accum)); | |
646c6f2b DE |
1358 | #if WITH_PROFILE_MODEL_P |
1359 | if (PROFILE_MODEL_P (current_cpu)) | |
1360 | { | |
9d70630e | 1361 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
1362 | model_profile_insn (current_cpu, abuf); |
1363 | } | |
1364 | #endif | |
1365 | return new_pc; | |
1366 | #undef FLD | |
1367 | } | |
1368 | ||
1369 | /* Perform mulwlo: mulwlo $src1,$src2. */ | |
1370 | CIA | |
9d70630e | 1371 | SEM_FN_NAME (m32r,mulwlo) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1372 | { |
9d70630e | 1373 | #define FLD(f) abuf->fields.fmt_15_cmp.f |
646c6f2b DE |
1374 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1375 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
9d70630e DE |
1376 | CPU (h_accum) = SRADI (SLLDI (MULDI (EXTSIDI (* FLD (f_r1)), EXTHIDI (TRUNCSIHI (* FLD (f_r2)))), 8), 8); |
1377 | TRACE_RESULT (current_cpu, "accum", 'D', CPU (h_accum)); | |
646c6f2b DE |
1378 | #if WITH_PROFILE_MODEL_P |
1379 | if (PROFILE_MODEL_P (current_cpu)) | |
1380 | { | |
9d70630e | 1381 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
1382 | model_profile_insn (current_cpu, abuf); |
1383 | } | |
1384 | #endif | |
1385 | return new_pc; | |
1386 | #undef FLD | |
1387 | } | |
1388 | ||
1389 | /* Perform mv: mv $dr,$sr. */ | |
1390 | CIA | |
9d70630e | 1391 | SEM_FN_NAME (m32r,mv) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1392 | { |
9d70630e | 1393 | #define FLD(f) abuf->fields.fmt_31_mv.f |
646c6f2b DE |
1394 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1395 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
1396 | * FLD (f_r1) = * FLD (f_r2); | |
1397 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
1398 | #if WITH_PROFILE_MODEL_P | |
1399 | if (PROFILE_MODEL_P (current_cpu)) | |
1400 | { | |
9d70630e DE |
1401 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
1402 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
1403 | model_profile_insn (current_cpu, abuf); |
1404 | } | |
1405 | #endif | |
1406 | return new_pc; | |
1407 | #undef FLD | |
1408 | } | |
1409 | ||
1410 | /* Perform mvfachi: mvfachi $dr. */ | |
1411 | CIA | |
9d70630e | 1412 | SEM_FN_NAME (m32r,mvfachi) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1413 | { |
9d70630e | 1414 | #define FLD(f) abuf->fields.fmt_32_mvfachi.f |
646c6f2b DE |
1415 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1416 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
1417 | * FLD (f_r1) = TRUNCDISI (SRADI (CPU (h_accum), 32)); | |
1418 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
1419 | #if WITH_PROFILE_MODEL_P | |
1420 | if (PROFILE_MODEL_P (current_cpu)) | |
1421 | { | |
9d70630e | 1422 | m32r_model_mark_set_h_gr (current_cpu, abuf); |
646c6f2b DE |
1423 | model_profile_insn (current_cpu, abuf); |
1424 | } | |
1425 | #endif | |
1426 | return new_pc; | |
1427 | #undef FLD | |
1428 | } | |
1429 | ||
1430 | /* Perform mvfaclo: mvfaclo $dr. */ | |
1431 | CIA | |
9d70630e | 1432 | SEM_FN_NAME (m32r,mvfaclo) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1433 | { |
9d70630e | 1434 | #define FLD(f) abuf->fields.fmt_32_mvfachi.f |
646c6f2b DE |
1435 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1436 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
1437 | * FLD (f_r1) = TRUNCDISI (CPU (h_accum)); | |
1438 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
1439 | #if WITH_PROFILE_MODEL_P | |
1440 | if (PROFILE_MODEL_P (current_cpu)) | |
1441 | { | |
9d70630e | 1442 | m32r_model_mark_set_h_gr (current_cpu, abuf); |
646c6f2b DE |
1443 | model_profile_insn (current_cpu, abuf); |
1444 | } | |
1445 | #endif | |
1446 | return new_pc; | |
1447 | #undef FLD | |
1448 | } | |
1449 | ||
1450 | /* Perform mvfacmi: mvfacmi $dr. */ | |
1451 | CIA | |
9d70630e | 1452 | SEM_FN_NAME (m32r,mvfacmi) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1453 | { |
9d70630e | 1454 | #define FLD(f) abuf->fields.fmt_32_mvfachi.f |
646c6f2b DE |
1455 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1456 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
1457 | * FLD (f_r1) = TRUNCDISI (SRADI (CPU (h_accum), 16)); | |
1458 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
1459 | #if WITH_PROFILE_MODEL_P | |
1460 | if (PROFILE_MODEL_P (current_cpu)) | |
1461 | { | |
9d70630e | 1462 | m32r_model_mark_set_h_gr (current_cpu, abuf); |
646c6f2b DE |
1463 | model_profile_insn (current_cpu, abuf); |
1464 | } | |
1465 | #endif | |
1466 | return new_pc; | |
1467 | #undef FLD | |
1468 | } | |
1469 | ||
1470 | /* Perform mvfc: mvfc $dr,$scr. */ | |
1471 | CIA | |
9d70630e | 1472 | SEM_FN_NAME (m32r,mvfc) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1473 | { |
9d70630e | 1474 | #define FLD(f) abuf->fields.fmt_33_mvfc.f |
646c6f2b DE |
1475 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1476 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
9d70630e | 1477 | * FLD (f_r1) = m32r_h_cr_get (current_cpu, FLD (f_r2)); |
646c6f2b DE |
1478 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); |
1479 | #if WITH_PROFILE_MODEL_P | |
1480 | if (PROFILE_MODEL_P (current_cpu)) | |
1481 | { | |
9d70630e | 1482 | m32r_model_mark_set_h_gr (current_cpu, abuf); |
646c6f2b DE |
1483 | model_profile_insn (current_cpu, abuf); |
1484 | } | |
1485 | #endif | |
1486 | return new_pc; | |
1487 | #undef FLD | |
1488 | } | |
1489 | ||
1490 | /* Perform mvtachi: mvtachi $src1. */ | |
1491 | CIA | |
9d70630e | 1492 | SEM_FN_NAME (m32r,mvtachi) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1493 | { |
9d70630e | 1494 | #define FLD(f) abuf->fields.fmt_34_mvtachi.f |
646c6f2b DE |
1495 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1496 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
9d70630e DE |
1497 | CPU (h_accum) = ORDI (ANDDI (CPU (h_accum), MAKEDI (0, 0xffffffff)), SLLDI (EXTSIDI (* FLD (f_r1)), 32)); |
1498 | TRACE_RESULT (current_cpu, "accum", 'D', CPU (h_accum)); | |
646c6f2b DE |
1499 | #if WITH_PROFILE_MODEL_P |
1500 | if (PROFILE_MODEL_P (current_cpu)) | |
1501 | { | |
9d70630e | 1502 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
1503 | model_profile_insn (current_cpu, abuf); |
1504 | } | |
1505 | #endif | |
1506 | return new_pc; | |
1507 | #undef FLD | |
1508 | } | |
1509 | ||
1510 | /* Perform mvtaclo: mvtaclo $src1. */ | |
1511 | CIA | |
9d70630e | 1512 | SEM_FN_NAME (m32r,mvtaclo) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1513 | { |
9d70630e | 1514 | #define FLD(f) abuf->fields.fmt_34_mvtachi.f |
646c6f2b DE |
1515 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1516 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
9d70630e DE |
1517 | CPU (h_accum) = ORDI (ANDDI (CPU (h_accum), MAKEDI (0xffffffff, 0)), EXTSIDI (* FLD (f_r1))); |
1518 | TRACE_RESULT (current_cpu, "accum", 'D', CPU (h_accum)); | |
646c6f2b DE |
1519 | #if WITH_PROFILE_MODEL_P |
1520 | if (PROFILE_MODEL_P (current_cpu)) | |
1521 | { | |
9d70630e | 1522 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
1523 | model_profile_insn (current_cpu, abuf); |
1524 | } | |
1525 | #endif | |
1526 | return new_pc; | |
1527 | #undef FLD | |
1528 | } | |
1529 | ||
1530 | /* Perform mvtc: mvtc $sr,$dcr. */ | |
1531 | CIA | |
9d70630e | 1532 | SEM_FN_NAME (m32r,mvtc) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1533 | { |
9d70630e | 1534 | #define FLD(f) abuf->fields.fmt_35_mvtc.f |
646c6f2b DE |
1535 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1536 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
9d70630e DE |
1537 | m32r_h_cr_set (current_cpu, FLD (f_r1), * FLD (f_r2)); |
1538 | TRACE_RESULT (current_cpu, "dcr", 'x', m32r_h_cr_get (current_cpu, FLD (f_r1))); | |
646c6f2b DE |
1539 | #if WITH_PROFILE_MODEL_P |
1540 | if (PROFILE_MODEL_P (current_cpu)) | |
1541 | { | |
9d70630e | 1542 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
1543 | model_profile_insn (current_cpu, abuf); |
1544 | } | |
1545 | #endif | |
1546 | return new_pc; | |
1547 | #undef FLD | |
1548 | } | |
1549 | ||
1550 | /* Perform neg: neg $dr,$sr. */ | |
1551 | CIA | |
9d70630e | 1552 | SEM_FN_NAME (m32r,neg) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1553 | { |
9d70630e | 1554 | #define FLD(f) abuf->fields.fmt_31_mv.f |
646c6f2b DE |
1555 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1556 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
1557 | * FLD (f_r1) = NEGSI (* FLD (f_r2)); | |
1558 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
1559 | #if WITH_PROFILE_MODEL_P | |
1560 | if (PROFILE_MODEL_P (current_cpu)) | |
1561 | { | |
9d70630e DE |
1562 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
1563 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
1564 | model_profile_insn (current_cpu, abuf); |
1565 | } | |
1566 | #endif | |
1567 | return new_pc; | |
1568 | #undef FLD | |
1569 | } | |
1570 | ||
1571 | /* Perform nop: nop. */ | |
1572 | CIA | |
9d70630e | 1573 | SEM_FN_NAME (m32r,nop) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1574 | { |
9d70630e | 1575 | #define FLD(f) abuf->fields.fmt_36_nop.f |
646c6f2b DE |
1576 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1577 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
1578 | PROFILE_COUNT_FILLNOPS (current_cpu, abuf->addr); | |
1579 | #if WITH_PROFILE_MODEL_P | |
1580 | if (PROFILE_MODEL_P (current_cpu)) | |
1581 | { | |
1582 | model_profile_insn (current_cpu, abuf); | |
1583 | } | |
1584 | #endif | |
1585 | return new_pc; | |
1586 | #undef FLD | |
1587 | } | |
1588 | ||
1589 | /* Perform not: not $dr,$sr. */ | |
1590 | CIA | |
9d70630e | 1591 | SEM_FN_NAME (m32r,not) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1592 | { |
9d70630e | 1593 | #define FLD(f) abuf->fields.fmt_31_mv.f |
646c6f2b DE |
1594 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1595 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
1596 | * FLD (f_r1) = INVSI (* FLD (f_r2)); | |
1597 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
1598 | #if WITH_PROFILE_MODEL_P | |
1599 | if (PROFILE_MODEL_P (current_cpu)) | |
1600 | { | |
9d70630e DE |
1601 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
1602 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
1603 | model_profile_insn (current_cpu, abuf); |
1604 | } | |
1605 | #endif | |
1606 | return new_pc; | |
1607 | #undef FLD | |
1608 | } | |
1609 | ||
1610 | /* Perform rac: rac. */ | |
1611 | CIA | |
9d70630e | 1612 | SEM_FN_NAME (m32r,rac) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1613 | { |
9d70630e | 1614 | #define FLD(f) abuf->fields.fmt_37_rac.f |
646c6f2b DE |
1615 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1616 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
9d70630e | 1617 | do { |
646c6f2b | 1618 | DI tmp_tmp1; |
9d70630e DE |
1619 | tmp_tmp1 = ANDDI (CPU (h_accum), MAKEDI (16777215, 0xffffffff)); |
1620 | if (ANDIFSI (GEDI (tmp_tmp1, MAKEDI (16383, 0xffff8000)), LEDI (tmp_tmp1, MAKEDI (8388607, 0xffffffff)))) { | |
646c6f2b DE |
1621 | tmp_tmp1 = MAKEDI (16383, 0xffff8000); |
1622 | } else { | |
9d70630e | 1623 | if (ANDIFSI (GEDI (tmp_tmp1, MAKEDI (8388608, 0)), LEDI (tmp_tmp1, MAKEDI (16760832, 0)))) { |
646c6f2b DE |
1624 | tmp_tmp1 = MAKEDI (16760832, 0); |
1625 | } else { | |
1626 | tmp_tmp1 = ANDDI (ADDDI (CPU (h_accum), MAKEDI (0, 16384)), MAKEDI (16777215, 0xffff8000)); | |
1627 | } | |
1628 | } | |
9d70630e DE |
1629 | tmp_tmp1 = SLLDI (tmp_tmp1, 1); |
1630 | CPU (h_accum) = SRADI (SLLDI (tmp_tmp1, 7), 7); | |
1631 | TRACE_RESULT (current_cpu, "accum", 'D', CPU (h_accum)); | |
1632 | } while (0); | |
646c6f2b DE |
1633 | #if WITH_PROFILE_MODEL_P |
1634 | if (PROFILE_MODEL_P (current_cpu)) | |
1635 | { | |
1636 | model_profile_insn (current_cpu, abuf); | |
1637 | } | |
1638 | #endif | |
1639 | return new_pc; | |
1640 | #undef FLD | |
1641 | } | |
1642 | ||
1643 | /* Perform rach: rach. */ | |
1644 | CIA | |
9d70630e | 1645 | SEM_FN_NAME (m32r,rach) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1646 | { |
9d70630e | 1647 | #define FLD(f) abuf->fields.fmt_37_rac.f |
646c6f2b DE |
1648 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1649 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
9d70630e | 1650 | do { |
646c6f2b | 1651 | DI tmp_tmp1; |
9d70630e DE |
1652 | tmp_tmp1 = ANDDI (CPU (h_accum), MAKEDI (16777215, 0xffffffff)); |
1653 | if (ANDIFSI (GEDI (tmp_tmp1, MAKEDI (16383, 0x80000000)), LEDI (tmp_tmp1, MAKEDI (8388607, 0xffffffff)))) { | |
646c6f2b DE |
1654 | tmp_tmp1 = MAKEDI (16383, 0x80000000); |
1655 | } else { | |
9d70630e | 1656 | if (ANDIFSI (GEDI (tmp_tmp1, MAKEDI (8388608, 0)), LEDI (tmp_tmp1, MAKEDI (16760832, 0)))) { |
646c6f2b DE |
1657 | tmp_tmp1 = MAKEDI (16760832, 0); |
1658 | } else { | |
1659 | tmp_tmp1 = ANDDI (ADDDI (CPU (h_accum), MAKEDI (0, 1073741824)), MAKEDI (0xffffffff, 0x80000000)); | |
1660 | } | |
1661 | } | |
9d70630e DE |
1662 | tmp_tmp1 = SLLDI (tmp_tmp1, 1); |
1663 | CPU (h_accum) = SRADI (SLLDI (tmp_tmp1, 7), 7); | |
1664 | TRACE_RESULT (current_cpu, "accum", 'D', CPU (h_accum)); | |
1665 | } while (0); | |
646c6f2b DE |
1666 | #if WITH_PROFILE_MODEL_P |
1667 | if (PROFILE_MODEL_P (current_cpu)) | |
1668 | { | |
1669 | model_profile_insn (current_cpu, abuf); | |
1670 | } | |
1671 | #endif | |
1672 | return new_pc; | |
1673 | #undef FLD | |
1674 | } | |
1675 | ||
1676 | /* Perform rte: rte. */ | |
1677 | CIA | |
9d70630e | 1678 | SEM_FN_NAME (m32r,rte) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1679 | { |
9d70630e | 1680 | #define FLD(f) abuf->fields.fmt_36_nop.f |
646c6f2b DE |
1681 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1682 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
1683 | int taken_p = 0; | |
9d70630e DE |
1684 | do { |
1685 | CPU (h_sm) = CPU (h_bsm); | |
1686 | TRACE_RESULT (current_cpu, "h-sm", 'x', CPU (h_sm)); | |
1687 | CPU (h_ie) = CPU (h_bie); | |
1688 | TRACE_RESULT (current_cpu, "h-ie", 'x', CPU (h_ie)); | |
1689 | CPU (h_cond) = CPU (h_bcond); | |
1690 | TRACE_RESULT (current_cpu, "condbit", 'x', CPU (h_cond)); | |
1691 | BRANCH_NEW_PC (current_cpu, new_pc, SEM_BRANCH_VIA_ADDR (sem_arg, CPU (h_bpc))); | |
646c6f2b | 1692 | taken_p = 1; |
9d70630e DE |
1693 | TRACE_RESULT (current_cpu, "pc", 'x', CPU (h_pc)); |
1694 | } while (0); | |
646c6f2b DE |
1695 | #if WITH_PROFILE_MODEL_P |
1696 | if (PROFILE_MODEL_P (current_cpu)) | |
1697 | { | |
1698 | model_profile_cti_insn (current_cpu, abuf, taken_p); | |
1699 | } | |
1700 | #endif | |
1701 | return new_pc; | |
1702 | #undef FLD | |
1703 | } | |
1704 | ||
1705 | /* Perform seth: seth $dr,$hi16. */ | |
1706 | CIA | |
9d70630e | 1707 | SEM_FN_NAME (m32r,seth) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1708 | { |
9d70630e | 1709 | #define FLD(f) abuf->fields.fmt_38_seth.f |
646c6f2b DE |
1710 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1711 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
9d70630e | 1712 | * FLD (f_r1) = SLLSI (FLD (f_hi16), 16); |
646c6f2b DE |
1713 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); |
1714 | #if WITH_PROFILE_MODEL_P | |
1715 | if (PROFILE_MODEL_P (current_cpu)) | |
1716 | { | |
9d70630e | 1717 | m32r_model_mark_set_h_gr (current_cpu, abuf); |
646c6f2b DE |
1718 | model_profile_insn (current_cpu, abuf); |
1719 | } | |
1720 | #endif | |
1721 | return new_pc; | |
1722 | #undef FLD | |
1723 | } | |
1724 | ||
1725 | /* Perform sll: sll $dr,$sr. */ | |
1726 | CIA | |
9d70630e | 1727 | SEM_FN_NAME (m32r,sll) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1728 | { |
9d70630e | 1729 | #define FLD(f) abuf->fields.fmt_0_add.f |
646c6f2b DE |
1730 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1731 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
9d70630e | 1732 | * FLD (f_r1) = SLLSI (* FLD (f_r1), ANDSI (* FLD (f_r2), 31)); |
646c6f2b DE |
1733 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); |
1734 | #if WITH_PROFILE_MODEL_P | |
1735 | if (PROFILE_MODEL_P (current_cpu)) | |
1736 | { | |
9d70630e DE |
1737 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
1738 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
1739 | model_profile_insn (current_cpu, abuf); |
1740 | } | |
1741 | #endif | |
1742 | return new_pc; | |
1743 | #undef FLD | |
1744 | } | |
1745 | ||
1746 | /* Perform sll3: sll3 $dr,$sr,$simm16. */ | |
1747 | CIA | |
9d70630e | 1748 | SEM_FN_NAME (m32r,sll3) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1749 | { |
9d70630e | 1750 | #define FLD(f) abuf->fields.fmt_5_addv3.f |
646c6f2b DE |
1751 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1752 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
9d70630e | 1753 | * FLD (f_r1) = SLLSI (* FLD (f_r2), ANDSI (FLD (f_simm16), 31)); |
646c6f2b DE |
1754 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); |
1755 | #if WITH_PROFILE_MODEL_P | |
1756 | if (PROFILE_MODEL_P (current_cpu)) | |
1757 | { | |
9d70630e DE |
1758 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
1759 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
1760 | model_profile_insn (current_cpu, abuf); |
1761 | } | |
1762 | #endif | |
1763 | return new_pc; | |
1764 | #undef FLD | |
1765 | } | |
1766 | ||
1767 | /* Perform slli: slli $dr,$uimm5. */ | |
1768 | CIA | |
9d70630e | 1769 | SEM_FN_NAME (m32r,slli) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1770 | { |
9d70630e | 1771 | #define FLD(f) abuf->fields.fmt_39_slli.f |
646c6f2b DE |
1772 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1773 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
9d70630e | 1774 | * FLD (f_r1) = SLLSI (* FLD (f_r1), FLD (f_uimm5)); |
646c6f2b DE |
1775 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); |
1776 | #if WITH_PROFILE_MODEL_P | |
1777 | if (PROFILE_MODEL_P (current_cpu)) | |
1778 | { | |
9d70630e DE |
1779 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
1780 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
1781 | model_profile_insn (current_cpu, abuf); |
1782 | } | |
1783 | #endif | |
1784 | return new_pc; | |
1785 | #undef FLD | |
1786 | } | |
1787 | ||
1788 | /* Perform sra: sra $dr,$sr. */ | |
1789 | CIA | |
9d70630e | 1790 | SEM_FN_NAME (m32r,sra) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1791 | { |
9d70630e | 1792 | #define FLD(f) abuf->fields.fmt_0_add.f |
646c6f2b DE |
1793 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1794 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
1795 | * FLD (f_r1) = SRASI (* FLD (f_r1), ANDSI (* FLD (f_r2), 31)); | |
1796 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
1797 | #if WITH_PROFILE_MODEL_P | |
1798 | if (PROFILE_MODEL_P (current_cpu)) | |
1799 | { | |
9d70630e DE |
1800 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
1801 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
1802 | model_profile_insn (current_cpu, abuf); |
1803 | } | |
1804 | #endif | |
1805 | return new_pc; | |
1806 | #undef FLD | |
1807 | } | |
1808 | ||
1809 | /* Perform sra3: sra3 $dr,$sr,$simm16. */ | |
1810 | CIA | |
9d70630e | 1811 | SEM_FN_NAME (m32r,sra3) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1812 | { |
9d70630e | 1813 | #define FLD(f) abuf->fields.fmt_5_addv3.f |
646c6f2b DE |
1814 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1815 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
1816 | * FLD (f_r1) = SRASI (* FLD (f_r2), ANDSI (FLD (f_simm16), 31)); | |
1817 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
1818 | #if WITH_PROFILE_MODEL_P | |
1819 | if (PROFILE_MODEL_P (current_cpu)) | |
1820 | { | |
9d70630e DE |
1821 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
1822 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
1823 | model_profile_insn (current_cpu, abuf); |
1824 | } | |
1825 | #endif | |
1826 | return new_pc; | |
1827 | #undef FLD | |
1828 | } | |
1829 | ||
1830 | /* Perform srai: srai $dr,$uimm5. */ | |
1831 | CIA | |
9d70630e | 1832 | SEM_FN_NAME (m32r,srai) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1833 | { |
9d70630e | 1834 | #define FLD(f) abuf->fields.fmt_39_slli.f |
646c6f2b DE |
1835 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1836 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
1837 | * FLD (f_r1) = SRASI (* FLD (f_r1), FLD (f_uimm5)); | |
1838 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
1839 | #if WITH_PROFILE_MODEL_P | |
1840 | if (PROFILE_MODEL_P (current_cpu)) | |
1841 | { | |
9d70630e DE |
1842 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
1843 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
1844 | model_profile_insn (current_cpu, abuf); |
1845 | } | |
1846 | #endif | |
1847 | return new_pc; | |
1848 | #undef FLD | |
1849 | } | |
1850 | ||
1851 | /* Perform srl: srl $dr,$sr. */ | |
1852 | CIA | |
9d70630e | 1853 | SEM_FN_NAME (m32r,srl) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1854 | { |
9d70630e | 1855 | #define FLD(f) abuf->fields.fmt_0_add.f |
646c6f2b DE |
1856 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1857 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
1858 | * FLD (f_r1) = SRLSI (* FLD (f_r1), ANDSI (* FLD (f_r2), 31)); | |
1859 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
1860 | #if WITH_PROFILE_MODEL_P | |
1861 | if (PROFILE_MODEL_P (current_cpu)) | |
1862 | { | |
9d70630e DE |
1863 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
1864 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
1865 | model_profile_insn (current_cpu, abuf); |
1866 | } | |
1867 | #endif | |
1868 | return new_pc; | |
1869 | #undef FLD | |
1870 | } | |
1871 | ||
1872 | /* Perform srl3: srl3 $dr,$sr,$simm16. */ | |
1873 | CIA | |
9d70630e | 1874 | SEM_FN_NAME (m32r,srl3) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1875 | { |
9d70630e | 1876 | #define FLD(f) abuf->fields.fmt_5_addv3.f |
646c6f2b DE |
1877 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1878 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
1879 | * FLD (f_r1) = SRLSI (* FLD (f_r2), ANDSI (FLD (f_simm16), 31)); | |
1880 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
1881 | #if WITH_PROFILE_MODEL_P | |
1882 | if (PROFILE_MODEL_P (current_cpu)) | |
1883 | { | |
9d70630e DE |
1884 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
1885 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
1886 | model_profile_insn (current_cpu, abuf); |
1887 | } | |
1888 | #endif | |
1889 | return new_pc; | |
1890 | #undef FLD | |
1891 | } | |
1892 | ||
1893 | /* Perform srli: srli $dr,$uimm5. */ | |
1894 | CIA | |
9d70630e | 1895 | SEM_FN_NAME (m32r,srli) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1896 | { |
9d70630e | 1897 | #define FLD(f) abuf->fields.fmt_39_slli.f |
646c6f2b DE |
1898 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1899 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
1900 | * FLD (f_r1) = SRLSI (* FLD (f_r1), FLD (f_uimm5)); | |
1901 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
1902 | #if WITH_PROFILE_MODEL_P | |
1903 | if (PROFILE_MODEL_P (current_cpu)) | |
1904 | { | |
9d70630e DE |
1905 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
1906 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
1907 | model_profile_insn (current_cpu, abuf); |
1908 | } | |
1909 | #endif | |
1910 | return new_pc; | |
1911 | #undef FLD | |
1912 | } | |
1913 | ||
1914 | /* Perform st: st $src1,@$src2. */ | |
1915 | CIA | |
9d70630e | 1916 | SEM_FN_NAME (m32r,st) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1917 | { |
9d70630e | 1918 | #define FLD(f) abuf->fields.fmt_15_cmp.f |
646c6f2b DE |
1919 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1920 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
1921 | SETMEMSI (current_cpu, * FLD (f_r2), * FLD (f_r1)); | |
9d70630e | 1922 | TRACE_RESULT (current_cpu, "h-memory", 'x', GETMEMSI (current_cpu, * FLD (f_r2))); |
646c6f2b DE |
1923 | #if WITH_PROFILE_MODEL_P |
1924 | if (PROFILE_MODEL_P (current_cpu)) | |
1925 | { | |
9d70630e | 1926 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
1927 | model_profile_insn (current_cpu, abuf); |
1928 | } | |
1929 | #endif | |
1930 | return new_pc; | |
1931 | #undef FLD | |
1932 | } | |
1933 | ||
1934 | /* Perform st-d: st $src1,@($slo16,$src2). */ | |
1935 | CIA | |
9d70630e | 1936 | SEM_FN_NAME (m32r,st_d) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1937 | { |
9d70630e | 1938 | #define FLD(f) abuf->fields.fmt_40_st_d.f |
646c6f2b DE |
1939 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1940 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
1941 | SETMEMSI (current_cpu, ADDSI (* FLD (f_r2), FLD (f_simm16)), * FLD (f_r1)); | |
9d70630e | 1942 | TRACE_RESULT (current_cpu, "h-memory", 'x', GETMEMSI (current_cpu, ADDSI (* FLD (f_r2), FLD (f_simm16)))); |
646c6f2b DE |
1943 | #if WITH_PROFILE_MODEL_P |
1944 | if (PROFILE_MODEL_P (current_cpu)) | |
1945 | { | |
9d70630e | 1946 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
1947 | model_profile_insn (current_cpu, abuf); |
1948 | } | |
1949 | #endif | |
1950 | return new_pc; | |
1951 | #undef FLD | |
1952 | } | |
1953 | ||
1954 | /* Perform stb: stb $src1,@$src2. */ | |
1955 | CIA | |
9d70630e | 1956 | SEM_FN_NAME (m32r,stb) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1957 | { |
9d70630e | 1958 | #define FLD(f) abuf->fields.fmt_15_cmp.f |
646c6f2b DE |
1959 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1960 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
1961 | SETMEMQI (current_cpu, * FLD (f_r2), * FLD (f_r1)); | |
9d70630e | 1962 | TRACE_RESULT (current_cpu, "h-memory", 'x', GETMEMQI (current_cpu, * FLD (f_r2))); |
646c6f2b DE |
1963 | #if WITH_PROFILE_MODEL_P |
1964 | if (PROFILE_MODEL_P (current_cpu)) | |
1965 | { | |
9d70630e | 1966 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
1967 | model_profile_insn (current_cpu, abuf); |
1968 | } | |
1969 | #endif | |
1970 | return new_pc; | |
1971 | #undef FLD | |
1972 | } | |
1973 | ||
1974 | /* Perform stb-d: stb $src1,@($slo16,$src2). */ | |
1975 | CIA | |
9d70630e | 1976 | SEM_FN_NAME (m32r,stb_d) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1977 | { |
9d70630e | 1978 | #define FLD(f) abuf->fields.fmt_40_st_d.f |
646c6f2b DE |
1979 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
1980 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
1981 | SETMEMQI (current_cpu, ADDSI (* FLD (f_r2), FLD (f_simm16)), * FLD (f_r1)); | |
9d70630e | 1982 | TRACE_RESULT (current_cpu, "h-memory", 'x', GETMEMQI (current_cpu, ADDSI (* FLD (f_r2), FLD (f_simm16)))); |
646c6f2b DE |
1983 | #if WITH_PROFILE_MODEL_P |
1984 | if (PROFILE_MODEL_P (current_cpu)) | |
1985 | { | |
9d70630e | 1986 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
1987 | model_profile_insn (current_cpu, abuf); |
1988 | } | |
1989 | #endif | |
1990 | return new_pc; | |
1991 | #undef FLD | |
1992 | } | |
1993 | ||
1994 | /* Perform sth: sth $src1,@$src2. */ | |
1995 | CIA | |
9d70630e | 1996 | SEM_FN_NAME (m32r,sth) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 1997 | { |
9d70630e | 1998 | #define FLD(f) abuf->fields.fmt_15_cmp.f |
646c6f2b DE |
1999 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
2000 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
2001 | SETMEMHI (current_cpu, * FLD (f_r2), * FLD (f_r1)); | |
9d70630e | 2002 | TRACE_RESULT (current_cpu, "h-memory", 'x', GETMEMHI (current_cpu, * FLD (f_r2))); |
646c6f2b DE |
2003 | #if WITH_PROFILE_MODEL_P |
2004 | if (PROFILE_MODEL_P (current_cpu)) | |
2005 | { | |
9d70630e | 2006 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
2007 | model_profile_insn (current_cpu, abuf); |
2008 | } | |
2009 | #endif | |
2010 | return new_pc; | |
2011 | #undef FLD | |
2012 | } | |
2013 | ||
2014 | /* Perform sth-d: sth $src1,@($slo16,$src2). */ | |
2015 | CIA | |
9d70630e | 2016 | SEM_FN_NAME (m32r,sth_d) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 2017 | { |
9d70630e | 2018 | #define FLD(f) abuf->fields.fmt_40_st_d.f |
646c6f2b DE |
2019 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
2020 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
2021 | SETMEMHI (current_cpu, ADDSI (* FLD (f_r2), FLD (f_simm16)), * FLD (f_r1)); | |
9d70630e | 2022 | TRACE_RESULT (current_cpu, "h-memory", 'x', GETMEMHI (current_cpu, ADDSI (* FLD (f_r2), FLD (f_simm16)))); |
646c6f2b DE |
2023 | #if WITH_PROFILE_MODEL_P |
2024 | if (PROFILE_MODEL_P (current_cpu)) | |
2025 | { | |
9d70630e | 2026 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
2027 | model_profile_insn (current_cpu, abuf); |
2028 | } | |
2029 | #endif | |
2030 | return new_pc; | |
2031 | #undef FLD | |
2032 | } | |
2033 | ||
2034 | /* Perform st-plus: st $src1,@+$src2. */ | |
2035 | CIA | |
9d70630e | 2036 | SEM_FN_NAME (m32r,st_plus) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 2037 | { |
9d70630e | 2038 | #define FLD(f) abuf->fields.fmt_15_cmp.f |
646c6f2b DE |
2039 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
2040 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
9d70630e | 2041 | do { |
646c6f2b DE |
2042 | * FLD (f_r2) = ADDSI (* FLD (f_r2), 4); |
2043 | TRACE_RESULT (current_cpu, "src2", 'x', * FLD (f_r2)); | |
2044 | SETMEMSI (current_cpu, * FLD (f_r2), * FLD (f_r1)); | |
9d70630e DE |
2045 | TRACE_RESULT (current_cpu, "h-memory", 'x', GETMEMSI (current_cpu, * FLD (f_r2))); |
2046 | } while (0); | |
646c6f2b DE |
2047 | #if WITH_PROFILE_MODEL_P |
2048 | if (PROFILE_MODEL_P (current_cpu)) | |
2049 | { | |
9d70630e | 2050 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
2051 | model_profile_insn (current_cpu, abuf); |
2052 | } | |
2053 | #endif | |
2054 | return new_pc; | |
2055 | #undef FLD | |
2056 | } | |
2057 | ||
2058 | /* Perform st-minus: st $src1,@-$src2. */ | |
2059 | CIA | |
9d70630e | 2060 | SEM_FN_NAME (m32r,st_minus) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 2061 | { |
9d70630e | 2062 | #define FLD(f) abuf->fields.fmt_15_cmp.f |
646c6f2b DE |
2063 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
2064 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
9d70630e | 2065 | do { |
646c6f2b DE |
2066 | * FLD (f_r2) = SUBSI (* FLD (f_r2), 4); |
2067 | TRACE_RESULT (current_cpu, "src2", 'x', * FLD (f_r2)); | |
2068 | SETMEMSI (current_cpu, * FLD (f_r2), * FLD (f_r1)); | |
9d70630e DE |
2069 | TRACE_RESULT (current_cpu, "h-memory", 'x', GETMEMSI (current_cpu, * FLD (f_r2))); |
2070 | } while (0); | |
646c6f2b DE |
2071 | #if WITH_PROFILE_MODEL_P |
2072 | if (PROFILE_MODEL_P (current_cpu)) | |
2073 | { | |
9d70630e | 2074 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
2075 | model_profile_insn (current_cpu, abuf); |
2076 | } | |
2077 | #endif | |
2078 | return new_pc; | |
2079 | #undef FLD | |
2080 | } | |
2081 | ||
2082 | /* Perform sub: sub $dr,$sr. */ | |
2083 | CIA | |
9d70630e | 2084 | SEM_FN_NAME (m32r,sub) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 2085 | { |
9d70630e | 2086 | #define FLD(f) abuf->fields.fmt_0_add.f |
646c6f2b DE |
2087 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
2088 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
2089 | * FLD (f_r1) = SUBSI (* FLD (f_r1), * FLD (f_r2)); | |
2090 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
2091 | #if WITH_PROFILE_MODEL_P | |
2092 | if (PROFILE_MODEL_P (current_cpu)) | |
2093 | { | |
9d70630e DE |
2094 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
2095 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
2096 | model_profile_insn (current_cpu, abuf); |
2097 | } | |
2098 | #endif | |
2099 | return new_pc; | |
2100 | #undef FLD | |
2101 | } | |
2102 | ||
2103 | /* Perform subv: subv $dr,$sr. */ | |
2104 | CIA | |
9d70630e | 2105 | SEM_FN_NAME (m32r,subv) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 2106 | { |
9d70630e | 2107 | #define FLD(f) abuf->fields.fmt_0_add.f |
646c6f2b DE |
2108 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
2109 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
2110 | do { | |
2111 | BI temp1;SI temp0; | |
9d70630e DE |
2112 | temp0 = SUBSI (* FLD (f_r1), * FLD (f_r2)); |
2113 | temp1 = SUBOFSI (* FLD (f_r1), * FLD (f_r2), 0); | |
646c6f2b DE |
2114 | * FLD (f_r1) = temp0; |
2115 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
9d70630e DE |
2116 | CPU (h_cond) = temp1; |
2117 | TRACE_RESULT (current_cpu, "condbit", 'x', CPU (h_cond)); | |
646c6f2b DE |
2118 | } while (0); |
2119 | #if WITH_PROFILE_MODEL_P | |
2120 | if (PROFILE_MODEL_P (current_cpu)) | |
2121 | { | |
9d70630e DE |
2122 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
2123 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
2124 | model_profile_insn (current_cpu, abuf); |
2125 | } | |
2126 | #endif | |
2127 | return new_pc; | |
2128 | #undef FLD | |
2129 | } | |
2130 | ||
2131 | /* Perform subx: subx $dr,$sr. */ | |
2132 | CIA | |
9d70630e | 2133 | SEM_FN_NAME (m32r,subx) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 2134 | { |
9d70630e | 2135 | #define FLD(f) abuf->fields.fmt_6_addx.f |
646c6f2b DE |
2136 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
2137 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
2138 | do { | |
2139 | BI temp1;SI temp0; | |
9d70630e DE |
2140 | temp0 = SUBCSI (* FLD (f_r1), * FLD (f_r2), CPU (h_cond)); |
2141 | temp1 = SUBCFSI (* FLD (f_r1), * FLD (f_r2), CPU (h_cond)); | |
646c6f2b DE |
2142 | * FLD (f_r1) = temp0; |
2143 | TRACE_RESULT (current_cpu, "dr", 'x', * FLD (f_r1)); | |
9d70630e DE |
2144 | CPU (h_cond) = temp1; |
2145 | TRACE_RESULT (current_cpu, "condbit", 'x', CPU (h_cond)); | |
646c6f2b DE |
2146 | } while (0); |
2147 | #if WITH_PROFILE_MODEL_P | |
2148 | if (PROFILE_MODEL_P (current_cpu)) | |
2149 | { | |
9d70630e DE |
2150 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
2151 | m32r_model_mark_set_h_gr (current_cpu, abuf); | |
646c6f2b DE |
2152 | model_profile_insn (current_cpu, abuf); |
2153 | } | |
2154 | #endif | |
2155 | return new_pc; | |
2156 | #undef FLD | |
2157 | } | |
2158 | ||
2159 | /* Perform trap: trap $uimm4. */ | |
2160 | CIA | |
9d70630e | 2161 | SEM_FN_NAME (m32r,trap) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 2162 | { |
9d70630e | 2163 | #define FLD(f) abuf->fields.fmt_41_trap.f |
646c6f2b DE |
2164 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
2165 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
2166 | int taken_p = 0; | |
2167 | do_trap (current_cpu, FLD (f_uimm4)); | |
2168 | #if WITH_PROFILE_MODEL_P | |
2169 | if (PROFILE_MODEL_P (current_cpu)) | |
2170 | { | |
2171 | model_profile_cti_insn (current_cpu, abuf, taken_p); | |
2172 | } | |
2173 | #endif | |
2174 | return new_pc; | |
2175 | #undef FLD | |
2176 | } | |
2177 | ||
2178 | /* Perform unlock: unlock $src1,@$src2. */ | |
2179 | CIA | |
9d70630e | 2180 | SEM_FN_NAME (m32r,unlock) (SIM_CPU *current_cpu, SEM_ARG sem_arg) |
646c6f2b | 2181 | { |
9d70630e | 2182 | #define FLD(f) abuf->fields.fmt_15_cmp.f |
646c6f2b DE |
2183 | ARGBUF *abuf = SEM_ARGBUF (sem_arg); |
2184 | CIA new_pc = SEM_NEXT_PC (sem_arg); | |
2185 | do_unlock (current_cpu, * FLD (f_r1), * FLD (f_r2)); | |
2186 | #if WITH_PROFILE_MODEL_P | |
2187 | if (PROFILE_MODEL_P (current_cpu)) | |
2188 | { | |
9d70630e | 2189 | m32r_model_mark_get_h_gr (current_cpu, abuf); |
646c6f2b DE |
2190 | model_profile_insn (current_cpu, abuf); |
2191 | } | |
2192 | #endif | |
2193 | return new_pc; | |
2194 | #undef FLD | |
2195 | } | |
2196 | ||
9d70630e DE |
2197 | /* FIXME: Add "no return" attribute to illegal insn handlers. |
2198 | They all call longjmp. */ | |
2199 | ||
2200 | PCADDR | |
2201 | SEM_FN_NAME (m32r,illegal) (SIM_CPU *current_cpu, SEM_ARG sem_arg) | |
2202 | { | |
2203 | sim_engine_illegal_insn (current_cpu, NULL_CIA /*FIXME*/); | |
2204 | return 0; | |
2205 | } | |
2206 | ||
2207 | #endif /* ! defined (SCACHE_P) || (defined (SCACHE_P) && WITH_SCACHE) */ |