Initial creation of sourceware repository
[deliverable/binutils-gdb.git] / sim / common / cgen-mem.h
CommitLineData
c906108c
SS
1/* Memory ops header for CGEN-based simulators.
2 Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
3 Contributed by Cygnus Solutions.
4
5This file is part of the GNU Simulators.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License along
18with this program; if not, write to the Free Software Foundation, Inc.,
1959 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20
21#ifndef CGEN_MEM_H
22#define CGEN_MEM_H
23
24#ifdef MEMOPS_DEFINE_INLINE
25#define MEMOPS_INLINE
26#else
27#define MEMOPS_INLINE extern inline
28#endif
29
30/* Memory read support. */
31
32#if defined (__GNUC__) || defined (MEMOPS_DEFINE_INLINE)
33#define DECLARE_GETMEM(mode, size) \
34MEMOPS_INLINE mode \
35XCONCAT2 (GETMEM,mode) (SIM_CPU *cpu, IADDR pc, ADDR a) \
36{ \
37 PROFILE_COUNT_READ (cpu, a, XCONCAT2 (MODE_,mode)); \
38 /* Don't read anything into "unaligned" here. Bad name choice. */\
39 return XCONCAT2 (sim_core_read_unaligned_,size) (cpu, pc, read_map, a); \
40}
41#else
42#define DECLARE_GETMEM(mode, size) \
43extern mode XCONCAT2 (GETMEM,mode) (SIM_CPU *, IADDR, ADDR);
44#endif
45
46DECLARE_GETMEM (QI, 1)
47DECLARE_GETMEM (UQI, 1)
48DECLARE_GETMEM (HI, 2)
49DECLARE_GETMEM (UHI, 2)
50DECLARE_GETMEM (SI, 4)
51DECLARE_GETMEM (USI, 4)
52DECLARE_GETMEM (DI, 8)
53DECLARE_GETMEM (UDI, 8)
54
55#undef DECLARE_GETMEM
56
57#if defined (__GNUC__) || defined (MEMOPS_DEFINE_INLINE)
58#define DECLARE_GETMEM(mode, size) \
59MEMOPS_INLINE mode \
60XCONCAT2 (GETMEM,mode) (SIM_CPU *cpu, IADDR pc, ADDR a) \
61{ \
62 PROFILE_COUNT_READ (cpu, a, XCONCAT2 (MODE_,mode)); \
63 /* Don't read anything into "unaligned" here. Bad name choice. */\
64 return XCONCAT2 (sim_core_read_unaligned_,size) (cpu, pc, read_map, a); \
65}
66#else
67#define DECLARE_GETMEM(mode, size) \
68extern mode XCONCAT2 (GETMEM,mode) (SIM_CPU *, IADDR, ADDR);
69#endif
70
71DECLARE_GETMEM (SF, 4)
72DECLARE_GETMEM (DF, 8)
73/*DECLARE_GETMEM (TF, 16)*/
74
75#undef DECLARE_GETMEM
76\f
77/* Memory write support. */
78
79#if defined (__GNUC__) || defined (MEMOPS_DEFINE_INLINE)
80#define DECLARE_SETMEM(mode, size) \
81MEMOPS_INLINE void \
82XCONCAT2 (SETMEM,mode) (SIM_CPU *cpu, IADDR pc, ADDR a, mode val) \
83{ \
84 PROFILE_COUNT_WRITE (cpu, a, XCONCAT2 (MODE_,mode)); \
85 /* Don't read anything into "unaligned" here. Bad name choice. */ \
86 XCONCAT2 (sim_core_write_unaligned_,size) (cpu, pc, write_map, a, val); \
87}
88#else
89#define DECLARE_SETMEM(mode, size) \
90extern void XCONCAT2 (SETMEM,mode) (SIM_CPU *, IADDR, ADDR, mode);
91#endif
92
93DECLARE_SETMEM (QI, 1)
94DECLARE_SETMEM (UQI, 1)
95DECLARE_SETMEM (HI, 2)
96DECLARE_SETMEM (UHI, 2)
97DECLARE_SETMEM (SI, 4)
98DECLARE_SETMEM (USI, 4)
99DECLARE_SETMEM (DI, 8)
100DECLARE_SETMEM (UDI, 8)
101
102/*
103DECLARE_SETMEM (SF, 4)
104DECLARE_SETMEM (DF, 8)
105DECLARE_SETMEM (TF, 16)
106*/
107
108#undef DECLARE_SETMEM
109\f
110/* Instruction read support. */
111
112#if defined (__GNUC__) || defined (MEMOPS_DEFINE_INLINE)
113#define DECLARE_GETIMEM(mode, size) \
114MEMOPS_INLINE mode \
115XCONCAT2 (GETIMEM,mode) (SIM_CPU *cpu, IADDR a) \
116{ \
117 /*PROFILE_COUNT_READ (cpu, a, XCONCAT2 (MODE_,mode));*/ \
118 /* Don't read anything into "unaligned" here. Bad name choice. */\
119 return XCONCAT2 (sim_core_read_unaligned_,size) (cpu, a, exec_map, a); \
120}
121#else
122#define DECLARE_GETIMEM(mode, size) \
123extern mode XCONCAT2 (GETIMEM,mode) (SIM_CPU *, ADDR);
124#endif
125
126DECLARE_GETIMEM (UQI, 1)
127DECLARE_GETIMEM (UHI, 2)
128DECLARE_GETIMEM (USI, 4)
129DECLARE_GETIMEM (UDI, 8)
130
131#undef DECLARE_GETIMEM
132\f
133/* GETT<mode>: translate target value at P to host value.
134 This needn't be very efficient (i.e. can call memcpy) as this is
135 only used when interfacing with the outside world (e.g. gdb). */
136
137#if defined (__GNUC__) || defined (MEMOPS_DEFINE_INLINE)
138#define DECLARE_GETT(mode, size) \
139MEMOPS_INLINE mode \
140XCONCAT2 (GETT,mode) (unsigned char *p) \
141{ \
142 mode tmp; \
143 memcpy (&tmp, p, sizeof (mode)); \
144 return XCONCAT2 (T2H_,size) (tmp); \
145}
146#else
147#define DECLARE_GETT(mode, size) \
148extern mode XCONCAT2 (GETT,mode) (unsigned char *);
149#endif
150
151DECLARE_GETT (QI, 1)
152DECLARE_GETT (UQI, 1)
153DECLARE_GETT (HI, 2)
154DECLARE_GETT (UHI, 2)
155DECLARE_GETT (SI, 4)
156DECLARE_GETT (USI, 4)
157DECLARE_GETT (DI, 8)
158DECLARE_GETT (UDI, 8)
159
160/*
161DECLARE_GETT (SF, 4)
162DECLARE_GETT (DF, 8)
163DECLARE_GETT (TF, 16)
164*/
165
166#undef DECLARE_GETT
167\f
168/* SETT<mode>: translate host value to target value and store at P.
169 This needn't be very efficient (i.e. can call memcpy) as this is
170 only used when interfacing with the outside world (e.g. gdb). */
171
172#if defined (__GNUC__) || defined (MEMOPS_DEFINE_INLINE)
173#define DECLARE_SETT(mode, size) \
174MEMOPS_INLINE void \
175XCONCAT2 (SETT,mode) (unsigned char *buf, mode val) \
176{ \
177 mode tmp; \
178 tmp = XCONCAT2 (H2T_,size) (val); \
179 memcpy (buf, &tmp, sizeof (mode)); \
180}
181#else
182#define DECLARE_SETT(mode, size) \
183extern mode XCONCAT2 (GETT,mode) (unsigned char *, mode);
184#endif
185
186DECLARE_SETT (QI, 1)
187DECLARE_SETT (UQI, 1)
188DECLARE_SETT (HI, 2)
189DECLARE_SETT (UHI, 2)
190DECLARE_SETT (SI, 4)
191DECLARE_SETT (USI, 4)
192DECLARE_SETT (DI, 8)
193DECLARE_SETT (UDI, 8)
194
195/*
196DECLARE_SETT (SF, 4)
197DECLARE_SETT (DF, 8)
198DECLARE_SETT (TF, 16)
199*/
200
201#undef DECLARE_SETT
202
203#endif /* CGEN_MEM_H */
This page took 0.029975 seconds and 4 git commands to generate.