]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - sim/common/cgen-types.h
* config/sh/tm-sh.h (BELIEVE_PCC_PROMOTION): Define, so that
[thirdparty/binutils-gdb.git] / sim / common / cgen-types.h
1 /* Types for Cpu tools GENerated simulators.
2 Copyright (C) 1996, 1997 Free Software Foundation, Inc.
3 Contributed by Cygnus Support.
4
5 This file is part of GDB, the GNU debugger.
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_TYPES_H
22 #define CGEN_TYPES_H
23
24 #ifdef __GNUC__
25 #define HAVE_LONGLONG
26 #undef DI_FN_SUPPORT
27 #define SIM_INLINE extern inline
28 #else
29 #undef HAVE_LONGLONG
30 #define DI_FN_SUPPORT
31 #define SIM_INLINE
32 #endif
33
34 #ifndef CGEN_CAT3
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)
38 #else
39 #define CGEN_CAT3(a,b,c) a/**/b/**/c
40 #endif
41 #endif
42 \f
43 extern const char *mode_names[];
44 #define MODE_NAME(m) (mode_names[m])
45
46 #ifdef __STDC__
47 typedef /*FIXME*/ signed char BI;
48 typedef /*FIXME*/ signed char QI;
49 #else
50 typedef /*FIXME*/ char BI;
51 typedef /*FIXME*/ char QI;
52 #endif
53 typedef short HI;
54 typedef int SI;
55 typedef unsigned char UBI;
56 typedef unsigned char UQI;
57 typedef unsigned short UHI;
58 typedef unsigned int USI;
59
60 #ifdef HAVE_LONGLONG
61 typedef long long DI;
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)))
69 #else
70 typedef struct { SI hi,lo; } DI;
71 typedef DI UDI;
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)))
79 #endif
80
81 /* FIXME: Need to provide libraries if these aren't appropriate for target,
82 or user's needs. */
83 typedef float SF;
84 typedef double DF;
85 typedef double XF; /* FIXME: configure, provide library */
86 typedef double TF; /* FIXME: configure, provide library */
87
88 struct argbuf;
89 struct cgen_insn;
90 struct scache;
91
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
94 inappropriate. */
95 typedef unsigned int UINT;
96
97 typedef unsigned long PCADDR;
98 typedef unsigned long ADDR;
99 typedef /*FIXME*/ unsigned long insn_t;
100
101 /* Forward declaration of STATE.
102 Must be defined before profile.h and other module headers. */
103 typedef struct sim_state *STATE;
104 \f
105 /* Execution support.
106
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
110 something else. */
111
112 /* ??? The cache stuff is still wip, but it at least works. */
113
114 #ifdef SCACHE_P
115
116 /* iaddr: instruction address */
117 typedef PCADDR IADDR;
118 /* cia: current instruction address */
119 typedef PCADDR CIA;
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)
124
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)
132
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)
141
142 #else /* ! SCACHE_P */
143
144 typedef PCADDR IADDR;
145 typedef PCADDR CIA;
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)
150
151 /* extract.c support */
152 #define RECORD_IADDR(fld, val) \
153 do { (fld) = (val); } while (0)
154
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)
161
162 #endif /* ! SCACHE_P */
163 \f
164 #define EXTRACT_SIGNED(val, total, start, length) \
165 (((((val) >> ((total) - ((start) + (length)))) & ((1 << (length)) - 1)) \
166 ^ (1 << ((length) - 1))) \
167 - (1 << ((length) - 1)))
168
169 #define EXTRACT_UNSIGNED(val, total, start, length) \
170 (((val) >> ((total) - ((start) + (length)))) & ((1 << (length)) - 1))
171
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)
175
176 #endif /* CGEN_TYPES_H */