import gdb-1999-10-18 snapshot
[platform/upstream/binutils.git] / sim / common / cgen-par.h
1 /* Simulator header for cgen parallel support.
2    Copyright (C) 1999 Free Software Foundation, Inc.
3    Contributed by Cygnus Solutions.
4
5 This file is part of the GNU instruction set simulator.
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_PAR_H
22 #define CGEN_PAR_H
23
24 /* Kinds of writes stored on the write queue.  */
25 enum cgen_write_queue_kind {
26   CGEN_BI_WRITE, CGEN_QI_WRITE, CGEN_SI_WRITE, CGEN_SF_WRITE,
27   CGEN_PC_WRITE,
28   CGEN_FN_HI_WRITE, CGEN_FN_SI_WRITE, CGEN_FN_DI_WRITE, CGEN_FN_DF_WRITE,
29   CGEN_MEM_QI_WRITE, CGEN_MEM_HI_WRITE, CGEN_MEM_SI_WRITE, CGEN_MEM_DI_WRITE,
30   CGEN_MEM_DF_WRITE,
31   CGEN_NUM_WRITE_KINDS
32 };
33
34 /* Element of the write queue.  */
35 typedef struct {
36   enum cgen_write_queue_kind kind; /* Used to select union member below.  */
37   union {
38     struct {
39       BI  *target;
40       BI   value;
41     } bi_write;
42     struct {
43       UQI *target;
44       QI   value;
45     } qi_write;
46     struct {
47       SI *target;
48       SI  value;
49     } si_write;
50     struct {
51       SI *target;
52       SF  value;
53     } sf_write;
54     struct {
55       USI value;
56     } pc_write;
57     struct {
58       UINT regno;
59       UHI   value;
60       void (*function)(SIM_CPU *, UINT, UHI);
61     } fn_hi_write;
62     struct {
63       UINT regno;
64       SI   value;
65       void (*function)(SIM_CPU *, UINT, USI);
66     } fn_si_write;
67     struct {
68       UINT regno;
69       DI   value;
70       void (*function)(SIM_CPU *, UINT, DI);
71     } fn_di_write;
72     struct {
73       UINT regno;
74       DI   value;
75       void (*function)(SIM_CPU *, UINT, DI);
76     } fn_df_write;
77     struct {
78       SI   address;
79       QI   value;
80     } mem_qi_write;
81     struct {
82       SI   address;
83       HI   value;
84     } mem_hi_write;
85     struct {
86       SI   address;
87       SI   value;
88     } mem_si_write;
89     struct {
90       SI   address;
91       DI   value;
92     } mem_di_write;
93     struct {
94       SI   address;
95       DI   value;
96     } mem_df_write;
97   } kinds;
98 } CGEN_WRITE_QUEUE_ELEMENT;
99
100 #define CGEN_WRITE_QUEUE_ELEMENT_KIND(element) ((element)->kind)
101
102 extern void cgen_write_queue_element_execute (
103   SIM_CPU *, CGEN_WRITE_QUEUE_ELEMENT *
104 );
105
106 /* Instance of the queue for parallel write-after support.  */
107 /* FIXME: Should be dynamic?  */
108 #define CGEN_WRITE_QUEUE_SIZE (4 * 4) /* 4 writes x 4 insns -- for now.  */
109
110 typedef struct {
111   int index;
112   CGEN_WRITE_QUEUE_ELEMENT q[CGEN_WRITE_QUEUE_SIZE];
113 } CGEN_WRITE_QUEUE;
114
115 #define CGEN_WRITE_QUEUE_CLEAR(queue)       ((queue)->index = 0)
116 #define CGEN_WRITE_QUEUE_INDEX(queue)       ((queue)->index)
117 #define CGEN_WRITE_QUEUE_ELEMENT(queue, ix) (&(queue)->q[(ix)])
118
119 #define CGEN_WRITE_QUEUE_NEXT(queue) (   \
120   (queue)->index < CGEN_WRITE_QUEUE_SIZE \
121     ? &(queue)->q[(queue)->index++]      \
122     : cgen_write_queue_overflow (queue)  \
123 )
124
125 extern CGEN_WRITE_QUEUE_ELEMENT *cgen_write_queue_overflow (CGEN_WRITE_QUEUE *);
126
127 /* Functions for queuing writes.  Used by semantic code.  */
128 extern void sim_queue_bi_write (SIM_CPU *, BI *, BI);
129 extern void sim_queue_qi_write (SIM_CPU *, UQI *, UQI);
130 extern void sim_queue_si_write (SIM_CPU *, SI *, SI);
131 extern void sim_queue_sf_write (SIM_CPU *, SI *, SF);
132
133 extern void sim_queue_pc_write (SIM_CPU *, USI);
134
135 extern void sim_queue_fn_hi_write (SIM_CPU *, void (*)(SIM_CPU *, UINT, UHI), UINT, UHI);
136 extern void sim_queue_fn_si_write (SIM_CPU *, void (*)(SIM_CPU *, UINT, USI), UINT, SI);
137 extern void sim_queue_fn_di_write (SIM_CPU *, void (*)(SIM_CPU *, UINT, DI), UINT, DI);
138 extern void sim_queue_fn_df_write (SIM_CPU *, void (*)(SIM_CPU *, UINT, DI), UINT, DF);
139
140 extern void sim_queue_mem_qi_write (SIM_CPU *, SI, QI);
141 extern void sim_queue_mem_hi_write (SIM_CPU *, SI, HI);
142 extern void sim_queue_mem_si_write (SIM_CPU *, SI, SI);
143 extern void sim_queue_mem_di_write (SIM_CPU *, SI, DI);
144 extern void sim_queue_mem_df_write (SIM_CPU *, SI, DF);
145
146 #endif /* CGEN_PAR_H */