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