1 /* Types for Cpu tools GENerated simulators.
2 Copyright (C) 1996, 1997 Free Software Foundation, Inc.
3 Contributed by Cygnus Support.
5 This file is part of GDB, the GNU debugger.
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)
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.
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. */
27 #define SIM_INLINE extern inline
35 #if defined(__STDC__) || defined(ALMOST_STDC)
36 #define CGEN_XCAT3(a,b,c) a ## b ## c
37 #define CGEN_CAT3(a,b,c) CGEN_XCAT3 (a, b, c)
39 #define CGEN_CAT3(a,b,c) a/**/b/**/c
43 extern const char *mode_names
[];
44 #define MODE_NAME(m) (mode_names[m])
47 typedef /*FIXME*/ signed char BI
;
48 typedef /*FIXME*/ signed char QI
;
50 typedef /*FIXME*/ char BI
;
51 typedef /*FIXME*/ char QI
;
55 typedef unsigned char UBI
;
56 typedef unsigned char UQI
;
57 typedef unsigned short UHI
;
58 typedef unsigned int USI
;
62 typedef unsigned long long UDI
;
63 #define GETLODI(di) ((SI) (di))
64 #define GETHIDI(di) ((SI) ((di) >> 32))
65 #define SETLODI(di, val) ((di) = (((di) & 0xffffffff00000000LL) | (val)))
66 #define SETHIDI(di, val) ((di) = (((di) & 0xffffffffLL) | (((DI) (val)) << 32)))
67 #define SETDI(di, hi, lo) ((di) = MAKEDI (hi, lo))
68 #define MAKEDI(hi, lo) ((((DI) (hi)) << 32) | ((DI) (lo)))
70 typedef struct { SI hi
,lo
; } DI
;
72 #define GETLODI(di) ((di).lo)
73 #define GETHIDI(di) ((di).hi)
74 #define SETLODI(di, val) ((di).lo = (val))
75 #define SETHIDI(di, val) ((di).hi = (val))
76 #define SETDI(di, hi, lo) ((di) = MAKEDI (hi, lo))
77 extern DI
make_struct_di (SI
, SI
);
78 #define MAKEDI(hi, lo) (make_struct_di ((hi), (lo)))
81 /* FIXME: Need to provide libraries if these aren't appropriate for target,
85 typedef double XF
; /* FIXME: configure, provide library */
86 typedef double TF
; /* FIXME: configure, provide library */
92 /* This is used to record extracted raw data from an instruction, among other
93 things. It must be a host data type, and not a target one so USI is
95 typedef unsigned int UINT
;
97 typedef unsigned long PCADDR
;
98 typedef unsigned long ADDR
;
99 typedef /*FIXME*/ unsigned long insn_t
;
101 /* Forward declaration of STATE.
102 Must be defined before profile.h and other module headers. */
103 typedef struct sim_state
*STATE
;
105 /* Execution support.
107 Semantic functions come in two versions.
108 One that uses the cache, and one that doesn't.
109 The one that doesn't may eventually be thrown away or replaced with
112 /* ??? The cache stuff is still wip, but it at least works. */
116 /* iaddr: instruction address */
117 typedef PCADDR IADDR
;
118 /* cia: current instruction address */
120 #define CIA_ADDR(cia) (cia)
121 typedef struct scache
*SEM_ARG
;
122 #define EX_FN_NAME(fn) CGEN_CAT3 (exc,_,fn)
123 #define SEM_FN_NAME(fn) CGEN_CAT3 (semc,_,fn)
125 /* extract.c support */
126 /* scache_unset is a cache entry that is never used.
127 It's raison d'etre is so BRANCH_VIA_CACHE doesn't have to test for
128 newval.cache == NULL. */
129 extern struct scache scache_unset
;
130 #define RECORD_IADDR(fld, val) \
131 do { (fld) = (val); } while (0)
133 /* semantics.c support */
134 #define SEM_ARGBUF(sem_arg) (&(sem_arg)->argbuf)
135 #define SEM_NEXT_PC(sc) ((sc)->next)
136 #define SEM_BRANCH_VIA_CACHE(sc, newval) (newval)
137 #define SEM_BRANCH_VIA_ADDR(sc, newval) (newval)
138 /* Return address a branch insn will branch to.
139 This is only used during tracing. */
140 #define SEM_NEW_PC_ADDR(new_pc) (new_pc)
142 #else /* ! SCACHE_P */
144 typedef PCADDR IADDR
;
146 #define CIA_ADDR(cia) (cia)
147 typedef struct argbuf
*SEM_ARG
;
148 #define EX_FN_NAME(fn) CGEN_CAT3 (ex,_,fn)
149 #define SEM_FN_NAME(fn) CGEN_CAT3 (sem,_,fn)
151 /* extract.c support */
152 #define RECORD_IADDR(fld, val) \
153 do { (fld) = (val); } while (0)
155 /* semantics.c support */
156 #define SEM_ARGBUF(sem_arg) (sem_arg)
157 #define SEM_NEXT_PC(abuf) (abuf->addr + abuf->length)
158 #define SEM_BRANCH_VIA_CACHE(abuf, newval) (newval)
159 #define SEM_BRANCH_VIA_ADDR(abuf, newval) (newval)
160 #define SEM_NEW_PC_ADDR(new_pc) (new_pc)
162 #endif /* ! SCACHE_P */
164 #define EXTRACT_SIGNED(val, total, start, length) \
165 (((((val) >> ((total) - ((start) + (length)))) & ((1 << (length)) - 1)) \
166 ^ (1 << ((length) - 1))) \
167 - (1 << ((length) - 1)))
169 #define EXTRACT_UNSIGNED(val, total, start, length) \
170 (((val) >> ((total) - ((start) + (length)))) & ((1 << (length)) - 1))
172 /* Compute number of longs required to hold N bits. */
173 #define HOST_LONGS_FOR_BITS(n) \
174 (((n) + sizeof (long) * 8 - 1) / sizeof (long) * 8)
176 #endif /* CGEN_TYPES_H */