1 /* vm/jit/schedule/schedule.c - architecture independent instruction scheduler
3 Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4 R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5 C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6 Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 Contact: cacao@complang.tuwien.ac.at
27 Authors: Christian Thalinger
31 $Id: schedule.c 1961 2005-02-23 11:47:32Z twisti $
40 #include "mm/memory.h"
41 #include "vm/jit/schedule/schedule.h"
44 scheduledata *schedule_setup(registerdata *rd)
48 sd = DNEW(scheduledata);
50 sd->intregs_read_dep = DMNEW(minstruction*, rd->intregsnum);
51 sd->intregs_write_dep = DMNEW(minstruction*, rd->intregsnum);
53 sd->fltregs_read_dep = DMNEW(minstruction*, rd->fltregsnum);
54 sd->fltregs_write_dep = DMNEW(minstruction*, rd->fltregsnum);
56 /* XXX: memory is currently only one cell */
57 /* sd->memory_write_dep; */
59 /* clear all pointers */
61 MSET(sd->intregs_read_dep, 0, minstruction*, rd->intregsnum);
62 MSET(sd->intregs_write_dep, 0, minstruction*, rd->intregsnum);
64 MSET(sd->fltregs_read_dep, 0, minstruction*, rd->fltregsnum);
65 MSET(sd->fltregs_write_dep, 0, minstruction*, rd->fltregsnum);
67 sd->memory_write_dep = NULL;
73 minstruction *schedule_prepend_minstruction(minstruction *mi)
77 /* add new instruction in front of the list */
79 tmpmi = DNEW(minstruction);
83 tmpmi->opdep[0] = NULL;
84 tmpmi->opdep[1] = NULL;
85 tmpmi->opdep[2] = NULL;
86 tmpmi->sinknode = true;
88 tmpmi->next = mi; /* link to next instruction */
94 /* schedule_calc_priority ******************************************************
96 Calculates the current node's priority by getting highest priority
97 of the dependency nodes, adding this nodes latency plus 1 (for the
100 *******************************************************************************/
102 void schedule_calc_priority(minstruction *mi)
107 /* check all dependencies for their priority */
111 for (i = 0; i < 3; i++) {
113 if (mi->opdep[i]->priority > pathpriority)
114 pathpriority = mi->opdep[i]->priority;
116 /* depedent node is non-sink node */
118 mi->opdep[i]->sinknode = false;
122 mi->priority = pathpriority + mi->latency + 1;
126 /* schedule_do_schedule ********************************************************
130 *******************************************************************************/
132 void schedule_do_schedule(minstruction *mi)
134 minstruction *rootmi;
139 printf("bb start ---\n");
144 /* disassinstr(&tmpmi->instr); */
145 printf("%05x", mi->instr);
147 printf(" --> %d, %d, %d: op1=%p, op2=%p, op3=%p\n", mi->sinknode, mi->latency, mi->priority, mi->opdep[0], mi->opdep[1], mi->opdep[2]);
151 printf("bb end ---\n\n");
157 minstruction *schedule_append_minstruction(minstruction *mi)
161 /* add new instruction to the list */
163 tmpmi = DNEW(minstruction);
164 tmpmi->opdep[0] = NULL;
165 tmpmi->opdep[1] = NULL;
166 tmpmi->opdep[2] = NULL;
175 * These are local overrides for various environment variables in Emacs.
176 * Please do not remove this and leave it at the end of the file, where
177 * Emacs will automagically detect them.
178 * ---------------------------------------------------------------------
181 * indent-tabs-mode: t