cgen-par.h revision 1.1.1.5 1 1.1 christos /* Simulator header for cgen parallel support.
2 1.1.1.5 christos Copyright (C) 1999-2016 Free Software Foundation, Inc.
3 1.1 christos Contributed by Cygnus Solutions.
4 1.1 christos
5 1.1 christos This file is part of the GNU instruction set simulator.
6 1.1 christos
7 1.1 christos This program is free software; you can redistribute it and/or modify
8 1.1 christos it under the terms of the GNU General Public License as published by
9 1.1 christos the Free Software Foundation; either version 3 of the License, or
10 1.1 christos (at your option) any later version.
11 1.1 christos
12 1.1 christos This program is distributed in the hope that it will be useful,
13 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of
14 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 1.1 christos GNU General Public License for more details.
16 1.1 christos
17 1.1 christos You should have received a copy of the GNU General Public License
18 1.1 christos along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 1.1 christos
20 1.1 christos #ifndef CGEN_PAR_H
21 1.1 christos #define CGEN_PAR_H
22 1.1 christos
23 1.1 christos /* Kinds of writes stored on the write queue. */
24 1.1 christos enum cgen_write_queue_kind {
25 1.1 christos CGEN_BI_WRITE, CGEN_QI_WRITE, CGEN_SI_WRITE, CGEN_SF_WRITE,
26 1.1 christos CGEN_PC_WRITE,
27 1.1 christos CGEN_FN_HI_WRITE, CGEN_FN_SI_WRITE, CGEN_FN_SF_WRITE,
28 1.1 christos CGEN_FN_DI_WRITE, CGEN_FN_DF_WRITE,
29 1.1 christos CGEN_FN_XI_WRITE, CGEN_FN_PC_WRITE,
30 1.1 christos CGEN_MEM_QI_WRITE, CGEN_MEM_HI_WRITE, CGEN_MEM_SI_WRITE, CGEN_MEM_DI_WRITE,
31 1.1 christos CGEN_MEM_DF_WRITE, CGEN_MEM_XI_WRITE,
32 1.1 christos CGEN_FN_MEM_QI_WRITE, CGEN_FN_MEM_HI_WRITE, CGEN_FN_MEM_SI_WRITE,
33 1.1 christos CGEN_FN_MEM_DI_WRITE, CGEN_FN_MEM_DF_WRITE, CGEN_FN_MEM_XI_WRITE,
34 1.1 christos CGEN_NUM_WRITE_KINDS
35 1.1 christos };
36 1.1 christos
37 1.1 christos /* Element of the write queue. */
38 1.1 christos typedef struct {
39 1.1 christos enum cgen_write_queue_kind kind; /* Used to select union member below. */
40 1.1 christos IADDR insn_address; /* Address of the insn performing the write. */
41 1.1 christos unsigned32 flags; /* Target specific flags. */
42 1.1 christos long word1; /* Target specific field. */
43 1.1 christos union {
44 1.1 christos struct {
45 1.1 christos BI *target;
46 1.1 christos BI value;
47 1.1 christos } bi_write;
48 1.1 christos struct {
49 1.1 christos UQI *target;
50 1.1 christos QI value;
51 1.1 christos } qi_write;
52 1.1 christos struct {
53 1.1 christos SI *target;
54 1.1 christos SI value;
55 1.1 christos } si_write;
56 1.1 christos struct {
57 1.1 christos SI *target;
58 1.1 christos SF value;
59 1.1 christos } sf_write;
60 1.1 christos struct {
61 1.1 christos USI value;
62 1.1 christos } pc_write;
63 1.1 christos struct {
64 1.1 christos UINT regno;
65 1.1 christos UHI value;
66 1.1 christos void (*function)(SIM_CPU *, UINT, UHI);
67 1.1 christos } fn_hi_write;
68 1.1 christos struct {
69 1.1 christos UINT regno;
70 1.1 christos SI value;
71 1.1 christos void (*function)(SIM_CPU *, UINT, USI);
72 1.1 christos } fn_si_write;
73 1.1 christos struct {
74 1.1 christos UINT regno;
75 1.1 christos SF value;
76 1.1 christos void (*function)(SIM_CPU *, UINT, SF);
77 1.1 christos } fn_sf_write;
78 1.1 christos struct {
79 1.1 christos UINT regno;
80 1.1 christos DI value;
81 1.1 christos void (*function)(SIM_CPU *, UINT, DI);
82 1.1 christos } fn_di_write;
83 1.1 christos struct {
84 1.1 christos UINT regno;
85 1.1 christos DF value;
86 1.1 christos void (*function)(SIM_CPU *, UINT, DF);
87 1.1 christos } fn_df_write;
88 1.1 christos struct {
89 1.1 christos UINT regno;
90 1.1 christos SI value[4];
91 1.1 christos void (*function)(SIM_CPU *, UINT, SI *);
92 1.1 christos } fn_xi_write;
93 1.1 christos struct {
94 1.1 christos USI value;
95 1.1 christos void (*function)(SIM_CPU *, USI);
96 1.1 christos } fn_pc_write;
97 1.1 christos struct {
98 1.1 christos SI address;
99 1.1 christos QI value;
100 1.1 christos } mem_qi_write;
101 1.1 christos struct {
102 1.1 christos SI address;
103 1.1 christos HI value;
104 1.1 christos } mem_hi_write;
105 1.1 christos struct {
106 1.1 christos SI address;
107 1.1 christos SI value;
108 1.1 christos } mem_si_write;
109 1.1 christos struct {
110 1.1 christos SI address;
111 1.1 christos DI value;
112 1.1 christos } mem_di_write;
113 1.1 christos struct {
114 1.1 christos SI address;
115 1.1 christos DF value;
116 1.1 christos } mem_df_write;
117 1.1 christos struct {
118 1.1 christos SI address;
119 1.1 christos SI value[4];
120 1.1 christos } mem_xi_write;
121 1.1 christos struct {
122 1.1 christos SI address;
123 1.1 christos QI value;
124 1.1 christos void (*function)(SIM_CPU *, IADDR, SI, QI);
125 1.1 christos } fn_mem_qi_write;
126 1.1 christos struct {
127 1.1 christos SI address;
128 1.1 christos HI value;
129 1.1 christos void (*function)(SIM_CPU *, IADDR, SI, HI);
130 1.1 christos } fn_mem_hi_write;
131 1.1 christos struct {
132 1.1 christos SI address;
133 1.1 christos SI value;
134 1.1 christos void (*function)(SIM_CPU *, IADDR, SI, SI);
135 1.1 christos } fn_mem_si_write;
136 1.1 christos struct {
137 1.1 christos SI address;
138 1.1 christos DI value;
139 1.1 christos void (*function)(SIM_CPU *, IADDR, SI, DI);
140 1.1 christos } fn_mem_di_write;
141 1.1 christos struct {
142 1.1 christos SI address;
143 1.1 christos DF value;
144 1.1 christos void (*function)(SIM_CPU *, IADDR, SI, DF);
145 1.1 christos } fn_mem_df_write;
146 1.1 christos struct {
147 1.1 christos SI address;
148 1.1 christos SI value[4];
149 1.1 christos void (*function)(SIM_CPU *, IADDR, SI, SI *);
150 1.1 christos } fn_mem_xi_write;
151 1.1 christos } kinds;
152 1.1 christos } CGEN_WRITE_QUEUE_ELEMENT;
153 1.1 christos
154 1.1 christos #define CGEN_WRITE_QUEUE_ELEMENT_KIND(element) ((element)->kind)
155 1.1 christos #define CGEN_WRITE_QUEUE_ELEMENT_IADDR(element) ((element)->insn_address)
156 1.1 christos #define CGEN_WRITE_QUEUE_ELEMENT_FLAGS(element) ((element)->flags)
157 1.1 christos #define CGEN_WRITE_QUEUE_ELEMENT_WORD1(element) ((element)->word1)
158 1.1 christos
159 1.1 christos extern void cgen_write_queue_element_execute (
160 1.1 christos SIM_CPU *, CGEN_WRITE_QUEUE_ELEMENT *
161 1.1 christos );
162 1.1 christos
163 1.1 christos /* Instance of the queue for parallel write-after support. */
164 1.1 christos /* FIXME: Should be dynamic? */
165 1.1 christos #define CGEN_WRITE_QUEUE_SIZE (64 * 4) /* 64 writes x 4 insns -- for now. */
166 1.1 christos
167 1.1 christos typedef struct {
168 1.1 christos int index;
169 1.1 christos CGEN_WRITE_QUEUE_ELEMENT q[CGEN_WRITE_QUEUE_SIZE];
170 1.1 christos } CGEN_WRITE_QUEUE;
171 1.1 christos
172 1.1 christos #define CGEN_WRITE_QUEUE_CLEAR(queue) ((queue)->index = 0)
173 1.1 christos #define CGEN_WRITE_QUEUE_INDEX(queue) ((queue)->index)
174 1.1 christos #define CGEN_WRITE_QUEUE_ELEMENT(queue, ix) (&(queue)->q[(ix)])
175 1.1 christos
176 1.1 christos #define CGEN_WRITE_QUEUE_NEXT(queue) ( \
177 1.1 christos (queue)->index < CGEN_WRITE_QUEUE_SIZE \
178 1.1 christos ? &(queue)->q[(queue)->index++] \
179 1.1 christos : cgen_write_queue_overflow (queue) \
180 1.1 christos )
181 1.1 christos
182 1.1 christos extern CGEN_WRITE_QUEUE_ELEMENT *cgen_write_queue_overflow (CGEN_WRITE_QUEUE *);
183 1.1 christos
184 1.1 christos /* Functions for queuing writes. Used by semantic code. */
185 1.1 christos extern void sim_queue_bi_write (SIM_CPU *, BI *, BI);
186 1.1 christos extern void sim_queue_qi_write (SIM_CPU *, UQI *, UQI);
187 1.1 christos extern void sim_queue_si_write (SIM_CPU *, SI *, SI);
188 1.1 christos extern void sim_queue_sf_write (SIM_CPU *, SI *, SF);
189 1.1 christos
190 1.1 christos extern void sim_queue_pc_write (SIM_CPU *, USI);
191 1.1 christos
192 1.1 christos extern void sim_queue_fn_hi_write (SIM_CPU *, void (*)(SIM_CPU *, UINT, UHI), UINT, UHI);
193 1.1 christos extern void sim_queue_fn_si_write (SIM_CPU *, void (*)(SIM_CPU *, UINT, USI), UINT, USI);
194 1.1 christos extern void sim_queue_fn_sf_write (SIM_CPU *, void (*)(SIM_CPU *, UINT, SF), UINT, SF);
195 1.1 christos extern void sim_queue_fn_di_write (SIM_CPU *, void (*)(SIM_CPU *, UINT, DI), UINT, DI);
196 1.1 christos extern void sim_queue_fn_df_write (SIM_CPU *, void (*)(SIM_CPU *, UINT, DF), UINT, DF);
197 1.1 christos extern void sim_queue_fn_xi_write (SIM_CPU *, void (*)(SIM_CPU *, UINT, SI *), UINT, SI *);
198 1.1 christos extern void sim_queue_fn_pc_write (SIM_CPU *, void (*)(SIM_CPU *, USI), USI);
199 1.1 christos
200 1.1 christos extern void sim_queue_mem_qi_write (SIM_CPU *, SI, QI);
201 1.1 christos extern void sim_queue_mem_hi_write (SIM_CPU *, SI, HI);
202 1.1 christos extern void sim_queue_mem_si_write (SIM_CPU *, SI, SI);
203 1.1 christos extern void sim_queue_mem_di_write (SIM_CPU *, SI, DI);
204 1.1 christos extern void sim_queue_mem_df_write (SIM_CPU *, SI, DF);
205 1.1 christos extern void sim_queue_mem_xi_write (SIM_CPU *, SI, SI *);
206 1.1 christos
207 1.1 christos extern void sim_queue_fn_mem_qi_write (SIM_CPU *, void (*)(SIM_CPU *, IADDR, SI, QI), SI, QI);
208 1.1 christos extern void sim_queue_fn_mem_hi_write (SIM_CPU *, void (*)(SIM_CPU *, IADDR, SI, HI), SI, HI);
209 1.1 christos extern void sim_queue_fn_mem_si_write (SIM_CPU *, void (*)(SIM_CPU *, IADDR, SI, SI), SI, SI);
210 1.1 christos extern void sim_queue_fn_mem_di_write (SIM_CPU *, void (*)(SIM_CPU *, IADDR, SI, DI), SI, DI);
211 1.1 christos extern void sim_queue_fn_mem_df_write (SIM_CPU *, void (*)(SIM_CPU *, IADDR, SI, DF), SI, DF);
212 1.1 christos extern void sim_queue_fn_mem_xi_write (SIM_CPU *, void (*)(SIM_CPU *, IADDR, SI, SI *), SI, SI *);
213 1.1 christos
214 1.1 christos #endif /* CGEN_PAR_H */
215