xref: /netbsd-src/external/gpl3/gdb.old/dist/sim/m32r/m32r.c (revision 8b657b0747480f8989760d71343d6dd33f8d4cf9)
1a5a4af3bSchristos /* m32r simulator support code
2*8b657b07Schristos    Copyright (C) 1996-2023 Free Software Foundation, Inc.
3a5a4af3bSchristos    Contributed by Cygnus Support.
4a5a4af3bSchristos 
5a5a4af3bSchristos    This file is part of GDB, the GNU debugger.
6a5a4af3bSchristos 
7a5a4af3bSchristos    This program is free software; you can redistribute it and/or modify
8a5a4af3bSchristos    it under the terms of the GNU General Public License as published by
9a5a4af3bSchristos    the Free Software Foundation; either version 3 of the License, or
10a5a4af3bSchristos    (at your option) any later version.
11a5a4af3bSchristos 
12a5a4af3bSchristos    This program is distributed in the hope that it will be useful,
13a5a4af3bSchristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
14a5a4af3bSchristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15a5a4af3bSchristos    GNU General Public License for more details.
16a5a4af3bSchristos 
17a5a4af3bSchristos    You should have received a copy of the GNU General Public License
18a5a4af3bSchristos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19a5a4af3bSchristos 
20*8b657b07Schristos /* This must come before any other includes.  */
21*8b657b07Schristos #include "defs.h"
22*8b657b07Schristos 
23a5a4af3bSchristos #define WANT_CPU m32rbf
24a5a4af3bSchristos #define WANT_CPU_M32RBF
25a5a4af3bSchristos 
26a5a4af3bSchristos #include "sim-main.h"
27a5a4af3bSchristos #include "cgen-mem.h"
28a5a4af3bSchristos #include "cgen-ops.h"
29*8b657b07Schristos #include <stdlib.h>
30*8b657b07Schristos 
31*8b657b07Schristos /* Return the size of REGNO in bytes.  */
32*8b657b07Schristos 
33*8b657b07Schristos static int
34*8b657b07Schristos m32rbf_register_size (int regno)
35*8b657b07Schristos {
36*8b657b07Schristos   return 4;
37*8b657b07Schristos }
38a5a4af3bSchristos 
39a5a4af3bSchristos /* Decode gdb ctrl register number.  */
40a5a4af3bSchristos 
41a5a4af3bSchristos int
42a5a4af3bSchristos m32r_decode_gdb_ctrl_regnum (int gdb_regnum)
43a5a4af3bSchristos {
44a5a4af3bSchristos   switch (gdb_regnum)
45a5a4af3bSchristos     {
46a5a4af3bSchristos       case PSW_REGNUM : return H_CR_PSW;
47a5a4af3bSchristos       case CBR_REGNUM : return H_CR_CBR;
48a5a4af3bSchristos       case SPI_REGNUM : return H_CR_SPI;
49a5a4af3bSchristos       case SPU_REGNUM : return H_CR_SPU;
50a5a4af3bSchristos       case BPC_REGNUM : return H_CR_BPC;
51a5a4af3bSchristos       case BBPSW_REGNUM : return H_CR_BBPSW;
52a5a4af3bSchristos       case BBPC_REGNUM : return H_CR_BBPC;
53a5a4af3bSchristos       case EVB_REGNUM : return H_CR_CR5;
54a5a4af3bSchristos     }
55a5a4af3bSchristos   abort ();
56a5a4af3bSchristos }
57a5a4af3bSchristos 
58a5a4af3bSchristos /* The contents of BUF are in target byte order.  */
59a5a4af3bSchristos 
60a5a4af3bSchristos int
61*8b657b07Schristos m32rbf_fetch_register (SIM_CPU *current_cpu, int rn, void *buf, int len)
62a5a4af3bSchristos {
63*8b657b07Schristos   int size = m32rbf_register_size (rn);
64*8b657b07Schristos   if (len != size)
65*8b657b07Schristos     return -1;
66*8b657b07Schristos 
67a5a4af3bSchristos   if (rn < 16)
68a5a4af3bSchristos     SETTWI (buf, m32rbf_h_gr_get (current_cpu, rn));
69a5a4af3bSchristos   else
70a5a4af3bSchristos     switch (rn)
71a5a4af3bSchristos       {
72a5a4af3bSchristos       case PSW_REGNUM :
73a5a4af3bSchristos       case CBR_REGNUM :
74a5a4af3bSchristos       case SPI_REGNUM :
75a5a4af3bSchristos       case SPU_REGNUM :
76a5a4af3bSchristos       case BPC_REGNUM :
77a5a4af3bSchristos       case BBPSW_REGNUM :
78a5a4af3bSchristos       case BBPC_REGNUM :
79a5a4af3bSchristos 	SETTWI (buf, m32rbf_h_cr_get (current_cpu,
80a5a4af3bSchristos 				      m32r_decode_gdb_ctrl_regnum (rn)));
81a5a4af3bSchristos 	break;
82a5a4af3bSchristos       case PC_REGNUM :
83a5a4af3bSchristos 	SETTWI (buf, m32rbf_h_pc_get (current_cpu));
84a5a4af3bSchristos 	break;
85a5a4af3bSchristos       case ACCL_REGNUM :
86a5a4af3bSchristos 	SETTWI (buf, GETLODI (m32rbf_h_accum_get (current_cpu)));
87a5a4af3bSchristos 	break;
88a5a4af3bSchristos       case ACCH_REGNUM :
89a5a4af3bSchristos 	SETTWI (buf, GETHIDI (m32rbf_h_accum_get (current_cpu)));
90a5a4af3bSchristos 	break;
91a5a4af3bSchristos       default :
92a5a4af3bSchristos 	return 0;
93a5a4af3bSchristos       }
94a5a4af3bSchristos 
95*8b657b07Schristos   return size;
96a5a4af3bSchristos }
97a5a4af3bSchristos 
98a5a4af3bSchristos /* The contents of BUF are in target byte order.  */
99a5a4af3bSchristos 
100a5a4af3bSchristos int
101*8b657b07Schristos m32rbf_store_register (SIM_CPU *current_cpu, int rn, const void *buf, int len)
102a5a4af3bSchristos {
103*8b657b07Schristos   int size = m32rbf_register_size (rn);
104*8b657b07Schristos   if (len != size)
105*8b657b07Schristos     return -1;
106*8b657b07Schristos 
107a5a4af3bSchristos   if (rn < 16)
108a5a4af3bSchristos     m32rbf_h_gr_set (current_cpu, rn, GETTWI (buf));
109a5a4af3bSchristos   else
110a5a4af3bSchristos     switch (rn)
111a5a4af3bSchristos       {
112a5a4af3bSchristos       case PSW_REGNUM :
113a5a4af3bSchristos       case CBR_REGNUM :
114a5a4af3bSchristos       case SPI_REGNUM :
115a5a4af3bSchristos       case SPU_REGNUM :
116a5a4af3bSchristos       case BPC_REGNUM :
117a5a4af3bSchristos       case BBPSW_REGNUM :
118a5a4af3bSchristos       case BBPC_REGNUM :
119a5a4af3bSchristos 	m32rbf_h_cr_set (current_cpu,
120a5a4af3bSchristos 			 m32r_decode_gdb_ctrl_regnum (rn),
121a5a4af3bSchristos 			 GETTWI (buf));
122a5a4af3bSchristos 	break;
123a5a4af3bSchristos       case PC_REGNUM :
124a5a4af3bSchristos 	m32rbf_h_pc_set (current_cpu, GETTWI (buf));
125a5a4af3bSchristos 	break;
126a5a4af3bSchristos       case ACCL_REGNUM :
127a5a4af3bSchristos 	{
128a5a4af3bSchristos 	  DI val = m32rbf_h_accum_get (current_cpu);
129a5a4af3bSchristos 	  SETLODI (val, GETTWI (buf));
130a5a4af3bSchristos 	  m32rbf_h_accum_set (current_cpu, val);
131a5a4af3bSchristos 	  break;
132a5a4af3bSchristos 	}
133a5a4af3bSchristos       case ACCH_REGNUM :
134a5a4af3bSchristos 	{
135a5a4af3bSchristos 	  DI val = m32rbf_h_accum_get (current_cpu);
136a5a4af3bSchristos 	  SETHIDI (val, GETTWI (buf));
137a5a4af3bSchristos 	  m32rbf_h_accum_set (current_cpu, val);
138a5a4af3bSchristos 	  break;
139a5a4af3bSchristos 	}
140a5a4af3bSchristos       default :
141a5a4af3bSchristos 	return 0;
142a5a4af3bSchristos       }
143a5a4af3bSchristos 
144*8b657b07Schristos   return size;
145a5a4af3bSchristos }
146a5a4af3bSchristos 
147a5a4af3bSchristos USI
148a5a4af3bSchristos m32rbf_h_cr_get_handler (SIM_CPU *current_cpu, UINT cr)
149a5a4af3bSchristos {
150a5a4af3bSchristos   switch (cr)
151a5a4af3bSchristos     {
152a5a4af3bSchristos     case H_CR_PSW : /* psw */
153a5a4af3bSchristos       return (((CPU (h_bpsw) & 0xc1) << 8)
154a5a4af3bSchristos 	      | ((CPU (h_psw) & 0xc0) << 0)
155a5a4af3bSchristos 	      | GET_H_COND ());
156a5a4af3bSchristos     case H_CR_BBPSW : /* backup backup psw */
157a5a4af3bSchristos       return CPU (h_bbpsw) & 0xc1;
158a5a4af3bSchristos     case H_CR_CBR : /* condition bit */
159a5a4af3bSchristos       return GET_H_COND ();
160a5a4af3bSchristos     case H_CR_SPI : /* interrupt stack pointer */
161a5a4af3bSchristos       if (! GET_H_SM ())
162a5a4af3bSchristos 	return CPU (h_gr[H_GR_SP]);
163a5a4af3bSchristos       else
164a5a4af3bSchristos 	return CPU (h_cr[H_CR_SPI]);
165a5a4af3bSchristos     case H_CR_SPU : /* user stack pointer */
166a5a4af3bSchristos       if (GET_H_SM ())
167a5a4af3bSchristos 	return CPU (h_gr[H_GR_SP]);
168a5a4af3bSchristos       else
169a5a4af3bSchristos 	return CPU (h_cr[H_CR_SPU]);
170a5a4af3bSchristos     case H_CR_BPC : /* backup pc */
171a5a4af3bSchristos       return CPU (h_cr[H_CR_BPC]) & 0xfffffffe;
172a5a4af3bSchristos     case H_CR_BBPC : /* backup backup pc */
173a5a4af3bSchristos       return CPU (h_cr[H_CR_BBPC]) & 0xfffffffe;
174a5a4af3bSchristos     case 4 : /* ??? unspecified, but apparently available */
175a5a4af3bSchristos     case 5 : /* ??? unspecified, but apparently available */
176a5a4af3bSchristos       return CPU (h_cr[cr]);
177a5a4af3bSchristos     default :
178a5a4af3bSchristos       return 0;
179a5a4af3bSchristos     }
180a5a4af3bSchristos }
181a5a4af3bSchristos 
182a5a4af3bSchristos void
183a5a4af3bSchristos m32rbf_h_cr_set_handler (SIM_CPU *current_cpu, UINT cr, USI newval)
184a5a4af3bSchristos {
185a5a4af3bSchristos   switch (cr)
186a5a4af3bSchristos     {
187a5a4af3bSchristos     case H_CR_PSW : /* psw */
188a5a4af3bSchristos       {
189a5a4af3bSchristos 	int old_sm = (CPU (h_psw) & 0x80) != 0;
190a5a4af3bSchristos 	int new_sm = (newval & 0x80) != 0;
191a5a4af3bSchristos 	CPU (h_bpsw) = (newval >> 8) & 0xff;
192a5a4af3bSchristos 	CPU (h_psw) = newval & 0xff;
193a5a4af3bSchristos 	SET_H_COND (newval & 1);
194a5a4af3bSchristos 	/* When switching stack modes, update the registers.  */
195a5a4af3bSchristos 	if (old_sm != new_sm)
196a5a4af3bSchristos 	  {
197a5a4af3bSchristos 	    if (old_sm)
198a5a4af3bSchristos 	      {
199a5a4af3bSchristos 		/* Switching user -> system.  */
200a5a4af3bSchristos 		CPU (h_cr[H_CR_SPU]) = CPU (h_gr[H_GR_SP]);
201a5a4af3bSchristos 		CPU (h_gr[H_GR_SP]) = CPU (h_cr[H_CR_SPI]);
202a5a4af3bSchristos 	      }
203a5a4af3bSchristos 	    else
204a5a4af3bSchristos 	      {
205a5a4af3bSchristos 		/* Switching system -> user.  */
206a5a4af3bSchristos 		CPU (h_cr[H_CR_SPI]) = CPU (h_gr[H_GR_SP]);
207a5a4af3bSchristos 		CPU (h_gr[H_GR_SP]) = CPU (h_cr[H_CR_SPU]);
208a5a4af3bSchristos 	      }
209a5a4af3bSchristos 	  }
210a5a4af3bSchristos 	break;
211a5a4af3bSchristos       }
212a5a4af3bSchristos     case H_CR_BBPSW : /* backup backup psw */
213a5a4af3bSchristos       CPU (h_bbpsw) = newval & 0xff;
214a5a4af3bSchristos       break;
215a5a4af3bSchristos     case H_CR_CBR : /* condition bit */
216a5a4af3bSchristos       SET_H_COND (newval & 1);
217a5a4af3bSchristos       break;
218a5a4af3bSchristos     case H_CR_SPI : /* interrupt stack pointer */
219a5a4af3bSchristos       if (! GET_H_SM ())
220a5a4af3bSchristos 	CPU (h_gr[H_GR_SP]) = newval;
221a5a4af3bSchristos       else
222a5a4af3bSchristos 	CPU (h_cr[H_CR_SPI]) = newval;
223a5a4af3bSchristos       break;
224a5a4af3bSchristos     case H_CR_SPU : /* user stack pointer */
225a5a4af3bSchristos       if (GET_H_SM ())
226a5a4af3bSchristos 	CPU (h_gr[H_GR_SP]) = newval;
227a5a4af3bSchristos       else
228a5a4af3bSchristos 	CPU (h_cr[H_CR_SPU]) = newval;
229a5a4af3bSchristos       break;
230a5a4af3bSchristos     case H_CR_BPC : /* backup pc */
231a5a4af3bSchristos       CPU (h_cr[H_CR_BPC]) = newval;
232a5a4af3bSchristos       break;
233a5a4af3bSchristos     case H_CR_BBPC : /* backup backup pc */
234a5a4af3bSchristos       CPU (h_cr[H_CR_BBPC]) = newval;
235a5a4af3bSchristos       break;
236a5a4af3bSchristos     case 4 : /* ??? unspecified, but apparently available */
237a5a4af3bSchristos     case 5 : /* ??? unspecified, but apparently available */
238a5a4af3bSchristos       CPU (h_cr[cr]) = newval;
239a5a4af3bSchristos       break;
240a5a4af3bSchristos     default :
241a5a4af3bSchristos       /* ignore */
242a5a4af3bSchristos       break;
243a5a4af3bSchristos     }
244a5a4af3bSchristos }
245a5a4af3bSchristos 
246a5a4af3bSchristos /* Cover fns to access h-psw.  */
247a5a4af3bSchristos 
248a5a4af3bSchristos UQI
249a5a4af3bSchristos m32rbf_h_psw_get_handler (SIM_CPU *current_cpu)
250a5a4af3bSchristos {
251a5a4af3bSchristos   return (CPU (h_psw) & 0xfe) | (CPU (h_cond) & 1);
252a5a4af3bSchristos }
253a5a4af3bSchristos 
254a5a4af3bSchristos void
255a5a4af3bSchristos m32rbf_h_psw_set_handler (SIM_CPU *current_cpu, UQI newval)
256a5a4af3bSchristos {
257a5a4af3bSchristos   CPU (h_psw) = newval;
258a5a4af3bSchristos   CPU (h_cond) = newval & 1;
259a5a4af3bSchristos }
260a5a4af3bSchristos 
261a5a4af3bSchristos /* Cover fns to access h-accum.  */
262a5a4af3bSchristos 
263a5a4af3bSchristos DI
264a5a4af3bSchristos m32rbf_h_accum_get_handler (SIM_CPU *current_cpu)
265a5a4af3bSchristos {
266a5a4af3bSchristos   /* Sign extend the top 8 bits.  */
267a5a4af3bSchristos   DI r;
268a5a4af3bSchristos #if 1
269a5a4af3bSchristos   r = ANDDI (CPU (h_accum), MAKEDI (0xffffff, 0xffffffff));
270a5a4af3bSchristos   r = XORDI (r, MAKEDI (0x800000, 0));
271a5a4af3bSchristos   r = SUBDI (r, MAKEDI (0x800000, 0));
272a5a4af3bSchristos #else
273a5a4af3bSchristos   SI hi,lo;
274a5a4af3bSchristos   r = CPU (h_accum);
275a5a4af3bSchristos   hi = GETHIDI (r);
276a5a4af3bSchristos   lo = GETLODI (r);
277a5a4af3bSchristos   hi = ((hi & 0xffffff) ^ 0x800000) - 0x800000;
278a5a4af3bSchristos   r = MAKEDI (hi, lo);
279a5a4af3bSchristos #endif
280a5a4af3bSchristos   return r;
281a5a4af3bSchristos }
282a5a4af3bSchristos 
283a5a4af3bSchristos void
284a5a4af3bSchristos m32rbf_h_accum_set_handler (SIM_CPU *current_cpu, DI newval)
285a5a4af3bSchristos {
286a5a4af3bSchristos   CPU (h_accum) = newval;
287a5a4af3bSchristos }
288a5a4af3bSchristos 
289a5a4af3bSchristos #if WITH_PROFILE_MODEL_P
290a5a4af3bSchristos 
291a5a4af3bSchristos /* FIXME: Some of these should be inline or macros.  Later.  */
292a5a4af3bSchristos 
293a5a4af3bSchristos /* Initialize cycle counting for an insn.
294a5a4af3bSchristos    FIRST_P is non-zero if this is the first insn in a set of parallel
295a5a4af3bSchristos    insns.  */
296a5a4af3bSchristos 
297a5a4af3bSchristos void
298a5a4af3bSchristos m32rbf_model_insn_before (SIM_CPU *cpu, int first_p)
299a5a4af3bSchristos {
300a5a4af3bSchristos   M32R_MISC_PROFILE *mp = CPU_M32R_MISC_PROFILE (cpu);
301a5a4af3bSchristos   mp->cti_stall = 0;
302a5a4af3bSchristos   mp->load_stall = 0;
303a5a4af3bSchristos   if (first_p)
304a5a4af3bSchristos     {
305a5a4af3bSchristos       mp->load_regs_pending = 0;
306a5a4af3bSchristos       mp->biggest_cycles = 0;
307a5a4af3bSchristos     }
308a5a4af3bSchristos }
309a5a4af3bSchristos 
310a5a4af3bSchristos /* Record the cycles computed for an insn.
311a5a4af3bSchristos    LAST_P is non-zero if this is the last insn in a set of parallel insns,
312a5a4af3bSchristos    and we update the total cycle count.
313a5a4af3bSchristos    CYCLES is the cycle count of the insn.  */
314a5a4af3bSchristos 
315a5a4af3bSchristos void
316a5a4af3bSchristos m32rbf_model_insn_after (SIM_CPU *cpu, int last_p, int cycles)
317a5a4af3bSchristos {
318a5a4af3bSchristos   PROFILE_DATA *p = CPU_PROFILE_DATA (cpu);
319a5a4af3bSchristos   M32R_MISC_PROFILE *mp = CPU_M32R_MISC_PROFILE (cpu);
320a5a4af3bSchristos   unsigned long total = cycles + mp->cti_stall + mp->load_stall;
321a5a4af3bSchristos 
322a5a4af3bSchristos   if (last_p)
323a5a4af3bSchristos     {
324a5a4af3bSchristos       unsigned long biggest = total > mp->biggest_cycles ? total : mp->biggest_cycles;
325a5a4af3bSchristos       PROFILE_MODEL_TOTAL_CYCLES (p) += biggest;
326a5a4af3bSchristos       PROFILE_MODEL_CUR_INSN_CYCLES (p) = total;
327a5a4af3bSchristos     }
328a5a4af3bSchristos   else
329a5a4af3bSchristos     {
330a5a4af3bSchristos       /* Here we take advantage of the fact that !last_p -> first_p.  */
331a5a4af3bSchristos       mp->biggest_cycles = total;
332a5a4af3bSchristos       PROFILE_MODEL_CUR_INSN_CYCLES (p) = total;
333a5a4af3bSchristos     }
334a5a4af3bSchristos 
335a5a4af3bSchristos   /* Branch and load stall counts are recorded independently of the
336a5a4af3bSchristos      total cycle count.  */
337a5a4af3bSchristos   PROFILE_MODEL_CTI_STALL_CYCLES (p) += mp->cti_stall;
338a5a4af3bSchristos   PROFILE_MODEL_LOAD_STALL_CYCLES (p) += mp->load_stall;
339a5a4af3bSchristos 
340a5a4af3bSchristos   mp->load_regs = mp->load_regs_pending;
341a5a4af3bSchristos }
342a5a4af3bSchristos 
343a5a4af3bSchristos static INLINE void
344a5a4af3bSchristos check_load_stall (SIM_CPU *cpu, int regno)
345a5a4af3bSchristos {
346a5a4af3bSchristos   UINT h_gr = CPU_M32R_MISC_PROFILE (cpu)->load_regs;
347a5a4af3bSchristos 
348a5a4af3bSchristos   if (regno != -1
349a5a4af3bSchristos       && (h_gr & (1 << regno)) != 0)
350a5a4af3bSchristos     {
351a5a4af3bSchristos       CPU_M32R_MISC_PROFILE (cpu)->load_stall += 2;
352a5a4af3bSchristos       if (TRACE_INSN_P (cpu))
353a5a4af3bSchristos 	cgen_trace_printf (cpu, " ; Load stall of 2 cycles.");
354a5a4af3bSchristos     }
355a5a4af3bSchristos }
356a5a4af3bSchristos 
357a5a4af3bSchristos int
358a5a4af3bSchristos m32rbf_model_m32r_d_u_exec (SIM_CPU *cpu, const IDESC *idesc,
359a5a4af3bSchristos 			    int unit_num, int referenced,
360a5a4af3bSchristos 			    INT sr, INT sr2, INT dr)
361a5a4af3bSchristos {
362a5a4af3bSchristos   check_load_stall (cpu, sr);
363a5a4af3bSchristos   check_load_stall (cpu, sr2);
364a5a4af3bSchristos   return idesc->timing->units[unit_num].done;
365a5a4af3bSchristos }
366a5a4af3bSchristos 
367a5a4af3bSchristos int
368a5a4af3bSchristos m32rbf_model_m32r_d_u_cmp (SIM_CPU *cpu, const IDESC *idesc,
369a5a4af3bSchristos 			   int unit_num, int referenced,
370a5a4af3bSchristos 			   INT src1, INT src2)
371a5a4af3bSchristos {
372a5a4af3bSchristos   check_load_stall (cpu, src1);
373a5a4af3bSchristos   check_load_stall (cpu, src2);
374a5a4af3bSchristos   return idesc->timing->units[unit_num].done;
375a5a4af3bSchristos }
376a5a4af3bSchristos 
377a5a4af3bSchristos int
378a5a4af3bSchristos m32rbf_model_m32r_d_u_mac (SIM_CPU *cpu, const IDESC *idesc,
379a5a4af3bSchristos 			   int unit_num, int referenced,
380a5a4af3bSchristos 			   INT src1, INT src2)
381a5a4af3bSchristos {
382a5a4af3bSchristos   check_load_stall (cpu, src1);
383a5a4af3bSchristos   check_load_stall (cpu, src2);
384a5a4af3bSchristos   return idesc->timing->units[unit_num].done;
385a5a4af3bSchristos }
386a5a4af3bSchristos 
387a5a4af3bSchristos int
388a5a4af3bSchristos m32rbf_model_m32r_d_u_cti (SIM_CPU *cpu, const IDESC *idesc,
389a5a4af3bSchristos 			   int unit_num, int referenced,
390a5a4af3bSchristos 			   INT sr)
391a5a4af3bSchristos {
392a5a4af3bSchristos   PROFILE_DATA *profile = CPU_PROFILE_DATA (cpu);
393a5a4af3bSchristos   int taken_p = (referenced & (1 << 1)) != 0;
394a5a4af3bSchristos 
395a5a4af3bSchristos   check_load_stall (cpu, sr);
396a5a4af3bSchristos   if (taken_p)
397a5a4af3bSchristos     {
398a5a4af3bSchristos       CPU_M32R_MISC_PROFILE (cpu)->cti_stall += 2;
399a5a4af3bSchristos       PROFILE_MODEL_TAKEN_COUNT (profile) += 1;
400a5a4af3bSchristos     }
401a5a4af3bSchristos   else
402a5a4af3bSchristos     PROFILE_MODEL_UNTAKEN_COUNT (profile) += 1;
403a5a4af3bSchristos   return idesc->timing->units[unit_num].done;
404a5a4af3bSchristos }
405a5a4af3bSchristos 
406a5a4af3bSchristos int
407a5a4af3bSchristos m32rbf_model_m32r_d_u_load (SIM_CPU *cpu, const IDESC *idesc,
408a5a4af3bSchristos 			    int unit_num, int referenced,
409a5a4af3bSchristos 			    INT sr, INT dr)
410a5a4af3bSchristos {
411a5a4af3bSchristos   CPU_M32R_MISC_PROFILE (cpu)->load_regs_pending |= (1 << dr);
412a5a4af3bSchristos   check_load_stall (cpu, sr);
413a5a4af3bSchristos   return idesc->timing->units[unit_num].done;
414a5a4af3bSchristos }
415a5a4af3bSchristos 
416a5a4af3bSchristos int
417a5a4af3bSchristos m32rbf_model_m32r_d_u_store (SIM_CPU *cpu, const IDESC *idesc,
418a5a4af3bSchristos 			     int unit_num, int referenced,
419a5a4af3bSchristos 			     INT src1, INT src2)
420a5a4af3bSchristos {
421a5a4af3bSchristos   check_load_stall (cpu, src1);
422a5a4af3bSchristos   check_load_stall (cpu, src2);
423a5a4af3bSchristos   return idesc->timing->units[unit_num].done;
424a5a4af3bSchristos }
425a5a4af3bSchristos 
426a5a4af3bSchristos int
427a5a4af3bSchristos m32rbf_model_test_u_exec (SIM_CPU *cpu, const IDESC *idesc,
428a5a4af3bSchristos 			  int unit_num, int referenced)
429a5a4af3bSchristos {
430a5a4af3bSchristos   return idesc->timing->units[unit_num].done;
431a5a4af3bSchristos }
432a5a4af3bSchristos 
433a5a4af3bSchristos #endif /* WITH_PROFILE_MODEL_P */
434