This commit was generated by cvs2svn to track changes on a CVS vendor
[deliverable/binutils-gdb.git] / sim / common / cgen-mem.h
1 /* Memory ops header for CGEN-based simlators.
2 Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
3 Contributed by Cygnus Solutions.
4
5 This file is part of the GNU Simulators.
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 #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 #if defined (__GNUC__) || defined (MEMOPS_DEFINE_INLINE)
31 #define DECLARE_GETMEM(mode, size) \
32 MEMOPS_INLINE mode \
33 XCONCAT2 (GETMEM,mode) (SIM_CPU *cpu, ADDR a) \
34 { \
35 PROFILE_COUNT_READ (cpu, a, XCONCAT2 (MODE_,mode)); \
36 /* Don't read anything into "unaligned" here. Bad name choice. */\
37 return XCONCAT2 (sim_core_read_unaligned_,size) (cpu, NULL_CIA, sim_core_read_map, a); \
38 }
39 #else
40 #define DECLARE_GETMEM(mode, size) \
41 extern mode XCONCAT2 (GETMEM,mode) (SIM_CPU *, ADDR);
42 #endif
43
44 DECLARE_GETMEM (QI, 1)
45 DECLARE_GETMEM (UQI, 1)
46 DECLARE_GETMEM (HI, 2)
47 DECLARE_GETMEM (UHI, 2)
48 DECLARE_GETMEM (SI, 4)
49 DECLARE_GETMEM (USI, 4)
50 DECLARE_GETMEM (DI, 8)
51 DECLARE_GETMEM (UDI, 8)
52
53 #undef DECLARE_GETMEM
54
55 #if defined (__GNUC__) || defined (MEMOPS_DEFINE_INLINE)
56 #define DECLARE_SETMEM(mode, size) \
57 MEMOPS_INLINE void \
58 XCONCAT2 (SETMEM,mode) (SIM_CPU *cpu, ADDR a, mode val) \
59 { \
60 PROFILE_COUNT_WRITE (cpu, a, XCONCAT2 (MODE_,mode)); \
61 /* Don't read anything into "unaligned" here. Bad name choice. */ \
62 XCONCAT2 (sim_core_write_unaligned_,size) (cpu, NULL_CIA, sim_core_write_map, a, val); \
63 }
64 #else
65 #define DECLARE_SETMEM(mode, size) \
66 extern void XCONCAT2 (SETMEM,mode) (SIM_CPU *, ADDR, mode);
67 #endif
68
69 DECLARE_SETMEM (QI, 1)
70 DECLARE_SETMEM (UQI, 1)
71 DECLARE_SETMEM (HI, 2)
72 DECLARE_SETMEM (UHI, 2)
73 DECLARE_SETMEM (SI, 4)
74 DECLARE_SETMEM (USI, 4)
75 DECLARE_SETMEM (DI, 8)
76 DECLARE_SETMEM (UDI, 8)
77
78 #undef DECLARE_SETMEM
79
80 #if defined (__GNUC__) || defined (MEMOPS_DEFINE_INLINE)
81 #define DECLARE_GETIMEM(mode, size) \
82 MEMOPS_INLINE mode \
83 XCONCAT2 (GETIMEM,mode) (SIM_CPU *cpu, ADDR a) \
84 { \
85 /*PROFILE_COUNT_READ (cpu, a, XCONCAT2 (MODE_,mode));*/ \
86 /* Don't read anything into "unaligned" here. Bad name choice. */\
87 return XCONCAT2 (sim_core_read_unaligned_,size) (cpu, NULL_CIA, sim_core_execute_map, a); \
88 }
89 #else
90 #define DECLARE_GETIMEM(mode, size) \
91 extern mode XCONCAT2 (GETIMEM,mode) (SIM_CPU *, ADDR);
92 #endif
93
94 DECLARE_GETIMEM (UQI, 1)
95 DECLARE_GETIMEM (UHI, 2)
96 DECLARE_GETIMEM (USI, 4)
97 DECLARE_GETIMEM (UDI, 8)
98
99 #undef DECLARE_GETIMEM
100
101 /* GETT<mode>: translate target value at P to host value.
102 ??? How inefficient is the current implementation? */
103
104 #if defined (__GNUC__) || defined (MEMOPS_DEFINE_INLINE)
105 #define DECLARE_GETT(mode, size) \
106 MEMOPS_INLINE mode \
107 XCONCAT2 (GETT,mode) (unsigned char *p) \
108 { \
109 mode tmp; \
110 memcpy (&tmp, p, sizeof (mode)); \
111 return XCONCAT2 (T2H_,size) (tmp); \
112 }
113 #else
114 #define DECLARE_GETT(mode, size) \
115 extern mode XCONCAT2 (GETT,mode) (unsigned char *);
116 #endif
117
118 DECLARE_GETT (QI, 1)
119 DECLARE_GETT (UQI, 1)
120 DECLARE_GETT (HI, 2)
121 DECLARE_GETT (UHI, 2)
122 DECLARE_GETT (SI, 4)
123 DECLARE_GETT (USI, 4)
124 DECLARE_GETT (DI, 8)
125 DECLARE_GETT (UDI, 8)
126
127 #undef DECLARE_GETT
128
129 /* SETT<mode>: translate host value to target value and store at P.
130 ??? How inefficient is the current implementation? */
131
132 #if defined (__GNUC__) || defined (MEMOPS_DEFINE_INLINE)
133 #define DECLARE_SETT(mode, size) \
134 MEMOPS_INLINE mode \
135 XCONCAT2 (SETT,mode) (unsigned char *buf, mode val) \
136 { \
137 mode tmp; \
138 tmp = XCONCAT2 (H2T_,size) (val); \
139 memcpy (buf, &tmp, sizeof (mode)); \
140 }
141 #else
142 #define DECLARE_SETT(mode, size) \
143 extern mode XCONCAT2 (GETT,mode) (unsigned char *, mode);
144 #endif
145
146 DECLARE_SETT (QI, 1)
147 DECLARE_SETT (UQI, 1)
148 DECLARE_SETT (HI, 2)
149 DECLARE_SETT (UHI, 2)
150 DECLARE_SETT (SI, 4)
151 DECLARE_SETT (USI, 4)
152 DECLARE_SETT (DI, 8)
153 DECLARE_SETT (UDI, 8)
154
155 #undef DECLARE_SETT
156
157 #endif /* CGEN_MEM_H */
This page took 0.033875 seconds and 5 git commands to generate.