* Removed all Id tags.
[cacao.git] / src / vm / jit / schedule / schedule.h
1 /* src/vm/jit/schedule/schedule.h - architecture independent instruction
2                                     scheduler
3
4    Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
5    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
6    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
7    J. Wenninger, Institut f. Computersprachen - TU Wien
8
9    This file is part of CACAO.
10
11    This program is free software; you can redistribute it and/or
12    modify it under the terms of the GNU General Public License as
13    published by the Free Software Foundation; either version 2, or (at
14    your option) any later version.
15
16    This program is distributed in the hope that it will be useful, but
17    WITHOUT ANY WARRANTY; without even the implied warranty of
18    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19    General Public License for more details.
20
21    You should have received a copy of the GNU General Public License
22    along with this program; if not, write to the Free Software
23    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24    02110-1301, USA.
25
26    Contact: cacao@cacaojvm.org
27
28    Authors: Christian Thalinger
29
30    Changes:
31
32 */
33
34
35 #ifndef _SCHEDULE_H
36 #define _SCHEDULE_H
37
38 #include "arch.h"
39 #include "types.h"
40 #include "vm/jit/reg.h"
41
42
43 typedef struct scheduledata scheduledata;
44 typedef struct minstruction minstruction;
45 typedef struct edgenode edgenode;
46 typedef struct opcycles opcycles;
47
48
49 /* machine instruction flags **************************************************/
50
51 #define SCHEDULE_LEADER         0x01
52 #define SCHEDULE_SINK           0x02
53
54 #define SCHEDULE_UNIT_ALU       0x04
55 #define SCHEDULE_UNIT_MEM       0x08
56 #define SCHEDULE_UNIT_BRANCH    0x10
57
58
59 #define M_SCHEDULE_SET_EXCEPTION_POINT    /*  if (jd->exceptiontablelength > 0) { schedule_do_schedule(sd); schedule_reset(sd, rd); } */
60
61
62 struct opcycles {
63         s1 firstcycle;
64         s1 lastcycle;
65 };
66
67
68 /* scheduledata ****************************************************************
69
70    XXX
71
72 *******************************************************************************/
73
74 struct scheduledata {
75         minstruction  *mi;                  /* machine instruction array          */
76         s4             micount;             /* number of machine instructions     */
77         edgenode      *leaders;             /* list containing leader nodes       */
78
79         edgenode     **intregs_define_dep;
80         edgenode     **fltregs_define_dep;
81     edgenode     **memory_define_dep;
82
83         edgenode     **intregs_use_dep;
84         edgenode     **fltregs_use_dep;
85         edgenode     **memory_use_dep;
86
87         FILE *file;
88 };
89
90
91 /* minstruction ****************************************************************
92
93    This structure contains all information for one machine instruction
94    required to schedule it.
95
96 *******************************************************************************/
97
98 struct minstruction {
99         u4             instr[2];            /* machine instruction word           */
100         u1             flags;
101 #if 1
102         s1             startcycle;          /* start pipeline cycle               */
103         s1             endcycle;            /* end pipeline cycle                 */
104 #endif
105         opcycles       op[4];
106         s4             priority;            /* priority of this instruction node  */
107         s4             starttime;
108         edgenode      *deps;                /* operand dependencies               */
109         minstruction  *next;                /* link to next machine instruction   */
110 };
111
112
113 /* edgenode ********************************************************************
114
115    XXX
116
117 *******************************************************************************/
118
119 /* TODO rename to edgenode */
120 struct edgenode {
121         s4        minum;                    /* machine instruction number         */
122         s1        opnum;                    /* dependency operand number          */
123         s1        opnum2;
124         s1        latency;
125         edgenode *next;                     /* link to next node                  */
126 };
127
128
129 /* function prototypes ********************************************************/
130
131 scheduledata *schedule_init(methodinfo *m, registerdata *rd);
132 void schedule_reset(scheduledata *sd, registerdata *rd);
133 void schedule_close(scheduledata *sd);
134
135 void schedule_calc_priority(minstruction *mi);
136
137 /*  void schedule_add_define_dep(scheduledata *sd, s1 operand, s4 *define_dep, edgenode **use_dep); */
138 /*  void schedule_add_use_dep(scheduledata *sd, s1 operand, s4 *define_dep, edgenode **use_dep); */
139 void schedule_add_define_dep(scheduledata *sd, s1 opnum, edgenode **define_dep, edgenode **use_dep);
140 void schedule_add_use_dep(scheduledata *sd, s1 opnum, edgenode **define_dep, edgenode **use_dep);
141
142 void schedule_do_schedule(scheduledata *sd);
143
144 #endif /* _SCHEDULE_H */
145
146
147 /*
148  * These are local overrides for various environment variables in Emacs.
149  * Please do not remove this and leave it at the end of the file, where
150  * Emacs will automagically detect them.
151  * ---------------------------------------------------------------------
152  * Local variables:
153  * mode: c
154  * indent-tabs-mode: t
155  * c-basic-offset: 4
156  * tab-width: 4
157  * End:
158  */