1 /* $Id: ra_lifet.c,v 1.7 1994/06/24 10:27:50 ceriel Exp $ */
3 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
4 * See the copyright notice in the ACK home directory, in the file "Copyright".
6 /* R E G I S T E R A L L O C A T I O N
8 * R A _ L I F E T I M E . C
17 #include "../share/types.h"
18 #include "../share/debug.h"
19 #include "../share/def.h"
20 #include "../share/global.h"
21 #include "../share/lset.h"
22 #include "../share/aux.h"
23 #include "../share/alloc.h"
30 #define MSG_OFF(l) aoff(ARG(l),2)
31 #define is_livemsg(l) (INSTR(l) == ps_mes && aoff(ARG(l),0) == ms_ego && \
32 aoff(ARG(l),1) == ego_live)
33 #define is_deadmsg(l) (INSTR(l) == ps_mes && aoff(ARG(l),0) == ms_ego && \
34 aoff(ARG(l),1) == ego_dead)
36 build_lifetimes(items)
39 /* compute the it_lives attribute of every item; this is
40 * a list of intervals during which the item is live,
41 * i.e. its current value may be used.
42 * We traverse the EM text of the current procedure in
43 * lexical order. If we encounter a live-message, we store
44 * the number ('time') of the current instruction in the
45 * it_lastlive attribute of the concerning item. If we see
46 * a dead-message for that item, we know that the item is
47 * live in between these two pseudo's. If the first message
48 * appearing in the procedure is a dead-message, the item
49 * is live from time 0 (start of procedure) till now. (Note
50 * that it_lastlive is initially 0!).
51 * The lifetime ends on the last instruction before the
52 * dead-message that is not a live -or dead message.
61 for (now = 0; now < nrinstrs; now++) {
64 item = item_of(MSG_OFF(l),items);
65 /* A local variable that is never used is NOT an
66 * item; yet, there may be a register message for it...
68 if(item != (item_p) 0) {
69 item->it_lastlive = last_code + 1;
73 item = item_of(MSG_OFF(l),items);
74 if (item != (item_p) 0) {
75 add_interval(item->it_lastlive,
76 last_code, &item->it_lives);