Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – tendra.SVN – Blame – /branches/tendra5/src/installers/mips/common/tempdecs.c – Rev 2

Subversion Repositories tendra.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
2
    		 Crown Copyright (c) 1997
3
 
4
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
12
 
13
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
15
 
16
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
19
 
20
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
22
        these conditions;
23
 
24
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
27
        it may be put.
28
*/
29
 
30
 
31
/**********************************************************************
32
$Author: release $
33
$Date: 1998/01/17 15:56:07 $
34
$Revision: 1.1.1.1 $
35
$Log: tempdecs.c,v $
36
 * Revision 1.1.1.1  1998/01/17  15:56:07  release
37
 * First version to be checked into rolling release.
38
 *
39
 * Revision 1.3  1995/10/02  10:30:34  currie
40
 * env_offset + -g (PIC)
41
 *
42
 * Revision 1.2  1995/07/07  09:52:40  currie
43
 * apply_general in tempdecs
44
 *
45
 * Revision 1.1  1995/04/13  09:08:06  currie
46
 * Initial revision
47
 *
48
***********************************************************************/
49
/*  tempdec.c - is the value in the declaration required over  proc calls ?
50
	if it isn't, declaration can be allocated in t-reg, rather than
51
	s-reg.
52
 
53
*/
54
 
55
#include "config.h"
56
#include "tags.h"
57
#include "common_types.h"
58
#include "exp.h"
59
#include "const.h"
60
#include "expmacs.h"
61
#include "bitsmacs.h"
62
#include "tempdecs.h"
63
 
64
 
65
static int nouses;
66
static bool useinpar;
67
 
68
int trace_uses
69
    PROTO_N ( (e, id) )
70
    PROTO_T ( exp e X exp id )
71
{
72
	/* reduces nouses for each non-assignment use of id encountered in e;
73
	    sets useinpar if use in actual parameter posn
74
	    terminates with 0 on applications or jumps
75
	    terminates with 2 on assignment to id
76
	    otherwise delivers 1
77
	*/
78
 
79
     switch(name(e)) {
80
	case name_tag: {
81
	    nouses -=(son(e)==id);
82
	    return (1);
83
	}
84
	case apply_tag: case apply_general_tag:{
85
	    int u = nouses;
86
	    int p = 1;
87
	    exp l = son(e);
88
	    while( p==1 ) {
89
	    	p = trace_uses(l, id);
90
	    	if (u!=nouses || p==2) { useinpar=1; }
91
	    	if (p==0) nouses = u;
92
	    	if (last(l)) break;
93
	    	l = bro(l);
94
	    }
95
 
96
	    return 0;
97
	}
98
 
99
	case ident_tag: {
100
	     exp f = son(e);
101
	     exp s = bro(f);
102
	     int a;
103
	     if ( ( props(e) & defer_bit) != 0 ) {
104
		exp t = f;
105
		f = s;
106
	  	s = t;
107
	     }
108
	     a = trace_uses(f, id);
109
	     if (a !=1) return a;
110
	     return trace_uses(s, id);
111
	}
112
 
113
 
114
	case case_tag: case res_tag: {
115
	      trace_uses(son(e), id);
116
	      return 0;
117
	}
118
 
119
	case labst_tag: return 0;
120
 
121
	case seq_tag: {
122
		exp s = son(son(e));
123
		for(;;) {
124
			int el = trace_uses(s, id);
125
			if (el!=1 ) return el;
126
			if (last(s)) return trace_uses(bro(son(e)),id);
127
			s = bro(s);
128
		}
129
 
130
	}
131
 
132
	case ass_tag: {
133
	    if (isvar(id) && name(son(e))==name_tag && son(son(e))==id) {
134
		trace_uses(bro(son(e)),id);
135
	 	return 2;
136
	    }
137
	    else {
138
		int nu = nouses;
139
		if (trace_uses(son(e),id) != 1 ||
140
				trace_uses(bro(son(e)), id) !=1 ){
141
			nouses = nu;
142
			return 0;
143
		}
144
		return 1;
145
	    }
146
	}
147
        case goto_lv_tag:{
148
		int nu = nouses;
149
		if (trace_uses(son(e),id) != 1) {
150
			nouses = nu;
151
		}
152
		return 0;
153
	}
154
	case test_tag:{
155
		int nu = nouses;
156
		if (trace_uses(son(e),id) != 1 ||
157
				trace_uses(bro(son(e)), id) !=1 ){
158
			nouses = nu;
159
		}
160
		return 0;
161
	}
162
	case solve_tag: case cond_tag: {
163
		return trace_uses(son(e), id);
164
	}
165
 
166
	case goto_tag: case rep_tag: case env_offset_tag: return 0;
167
 
168
	default: {
169
	     exp s = son(e);
170
	     int nu = nouses; /* s list can be done in any order ...*/
171
	     if (s == nilexp) return 1;
172
	     for(;;) {
173
		int el = trace_uses(s, id);
174
		if (el!=1 ) { /* ... so reset nouses if any terminate */
175
			 nouses = nu;
176
			 return el;
177
		};
178
		if (last(s)) return 1;
179
		s = bro(s);
180
	     }
181
	}
182
 
183
     }
184
}
185
 
186
 
187
void after_a
188
    PROTO_N ( (a, id) )
189
    PROTO_T ( exp a X exp id )
190
{
191
	/* apply trace_uses to dynamic successors of a */
192
           	exp dad ;
193
	exp l;
194
         tailrec: dad = father(a);
195
	if (nouses == 0) return;
196
	if (name(dad)==cond_tag || name(dad)==rep_tag || name(dad)==res_tag
197
	      || name(dad) == solve_tag || name(dad) == labst_tag
198
	      || name(dad) == case_tag || name(dad)== goto_lv_tag
199
	      || name(dad) == test_tag ||  name(dad) == apply_tag) {
200
		 /* dont try too hard ! */
201
		while (name(dad) != apply_tag && dad !=id) dad = father(dad);
202
		if (name(dad) == apply_tag) { useinpar =1;}
203
		return;
204
	}
205
 
206
 
207
	for (l=a; !last(l); l=bro(l)) {
208
	    int u = trace_uses(bro(l), id);
209
	    if (u!=1|| nouses==0) return;
210
	}
211
	a = dad;
212
	if (dad!=id) goto tailrec;
213
}
214
 
215
 
216
 
217
bool tempdecopt = 1;		/* flag to allow this optimisation; -Tt
218
				   sets to 0 */
219
 
220
bool tempdec
221
    PROTO_N ( (e, enoughs) )
222
    PROTO_T ( exp e X bool enoughs )
223
{
224
				/* e is a local declaration; 'enoughs'
225
				   is a misnomer to say whether there are
226
				   t-regs available delivers 1 if e can be
227
				   allocated into t-reg or par reg */
228
	exp p;
229
	if (!tempdecopt ) return 0;
230
	nouses = 0;
231
	useinpar = 0;
232
	if (isvar(e) ) {
233
	   for (p=pt(e); p!=nilexp; p =pt(p)) {
234
	    /* find no of uses which are not assignments to id ... */
235
	    if (!last(p) && last(bro(p))
236
		 && name(bro(bro(p))) == ass_tag ) {
237
		continue;
238
	    }
239
	    nouses++;
240
	  }
241
	}
242
	else nouses = no(e);
243
 
244
	/* trace simple successors to assignmnts or init to id to find if
245
		all uses occur before unpredictable change of control
246
			(or another assignment to id) */
247
 
248
	if (nouses>30) return 0; /* takes too long */
249
 
250
	if (name(son(e)) != clear_tag || isparam(e)) { after_a(son(e), e); }
251
 
252
	if (isvar(e)) {
253
	  for (p=pt(e); p!=nilexp; p =pt(p)) {
254
	    if (!last(p) && last(bro(p))
255
		 && name(bro(bro(p))) == ass_tag ) {
256
		after_a(bro(bro(p)), e);
257
	    }
258
	  }
259
	}
260
 
261
	if (nouses ==0 &&(enoughs || !useinpar) ) {
262
	     if (useinpar) props(e) |= notparreg; /* don't allocate this into par reg */
263
	     return 1;
264
	}
265
	return 0;
266
}