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/alpha/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
/* 	$Id: tempdecs.c,v 1.1.1.1 1998/01/17 15:56:01 release Exp $	 */
32
 
33
#ifndef lint
34
static char vcid[] = "$Id: tempdecs.c,v 1.1.1.1 1998/01/17 15:56:01 release Exp $";
35
#endif /* lint */
36
 
37
 
38
/*  
39
  tempdec.c - is the value in the declaration required over  
40
  proc calls ?  If it isn't, declaration can be allocated 
41
  in t-reg, rather than s-reg.
42
*/
43
 
44
#include "config.h"
45
#include "tags.h"
46
#include "common_types.h"
47
#include "exp.h"
48
#include "const.h"
49
#include "expmacs.h"
50
#include "bitsmacs.h"
51
#include "tempdecs.h"
52
 
53
 
54
static int nouses;
55
static bool useinpar;
56
 
57
/* 
58
   reduces nouses for each non-assignment use of id encountered 
59
   in e; sets useinpar if use in actual parameter posn 
60
   terminates with 0 on applications or jumps terminates with 2 
61
   on assignment to id otherwise delivers 1
62
*/
63
int trace_uses
64
    PROTO_N ( ( e, id ) )
65
    PROTO_T ( exp e X exp id )
66
{
67
  Assert(e!=(exp)0);
68
  Assert(id!=(exp)0);
69
  switch(name(e)) {
70
    case name_tag: {
71
      nouses -=(son(e)==id);
72
      return (1);
73
    }	
74
    case apply_general_tag :
75
    case apply_tag :{
76
    int u = nouses;
77
    int p = 1;
78
    exp l = son(e);
79
    while( p==1 ) {
80
      p = trace_uses(l, id);	    	
81
      if (u!=nouses || p==2) { useinpar=1; }
82
      if (p==0) nouses = u;
83
      if (last(l)) break;
84
      l = bro(l);
85
    }
86
    return 0;
87
    }	
88
 
89
  case ident_tag: {
90
    exp f = son(e);
91
    exp s = bro(f);
92
    int a;
93
    if ( ( props(e) & defer_bit) != 0 ) {
94
      exp t = f;
95
      f = s;
96
      s = t;
97
    }
98
    a = trace_uses(f, id);
99
    if (a !=1) return a;
100
    return trace_uses(s, id);
101
  }	
102
 
103
 
104
  case case_tag:  {
105
    trace_uses(son(e), id);
106
    return 0;
107
  }
108
 
109
  case labst_tag: return 0;
110
 
111
  case seq_tag: {
112
     exp s = son(son(e));
113
     for(;;) {
114
       int el = trace_uses(s, id);
115
       if (el!=1 ) return el;
116
       if (last(s)) return trace_uses(bro(son(e)),id);
117
       s = bro(s);		
118
     }
119
   }
120
  case ass_tag: {
121
    if (isvar(id) && name(son(e))==name_tag && son(son(e))==id) {
122
      trace_uses(bro(son(e)),id);
123
      return 2;
124
    }
125
    else{
126
      int nu = nouses;
127
      if (trace_uses(son(e),id) != 1 ||
128
	  trace_uses(bro(son(e)), id) !=1 ){
129
	nouses = nu;
130
	return 0;
131
      }
132
      return 1;
133
    }
134
  }
135
  case goto_lv_tag:
136
  {
137
    int nu = nouses;
138
    if(trace_uses(son(e),id) != 1){
139
      nouses = nu;
140
    }
141
    return 0;
142
  }
143
  case test_tag:{
144
    int nu = nouses;
145
    if((trace_uses(son(e),id) != 1) || (trace_uses(bro(son(e)),id)!= 1)){
146
      nouses = nu;
147
    }	
148
    return 0;
149
   }
150
   case solve_tag:case cond_tag: {
151
     return trace_uses(son(e),id);
152
   }
153
   case goto_tag:case rep_tag:
154
     return 0;
155
   case current_env_tag:
156
     return 0;
157
   default: {
158
     exp s = son(e);
159
     int nu = nouses; /* s list can be done in any order ...*/
160
     if (s == nilexp) return 1;
161
     for(;;) {
162
       int el = trace_uses(s, id);
163
       if (el!=1 ) { /* ... so reset nouses if any terminate */
164
	 nouses = nu; 
165
	 return el; 
166
       }
167
       if (last(s)) return 1;
168
       s = bro(s);
169
     }
170
   }
171
 
172
  }
173
}
174
 
175
 
176
void after_a
177
    PROTO_N ( ( a, id ) )
178
    PROTO_T ( exp a X exp id )
179
{
180
  /* apply trace_uses to dynamic successors of a */
181
  exp dad ;
182
  exp l;
183
 tailrec: dad = father(a);
184
  if (nouses == 0) return;
185
  if (name(dad)==cond_tag || name(dad)==rep_tag || name(dad) == res_tag
186
      || name(dad) == solve_tag || name(dad) == labst_tag
187
      || name(dad) == case_tag || name(dad)== goto_lv_tag
188
      || name(dad) == test_tag ||  name(dad) == apply_tag) {
189
    /* dont try too hard ! */
190
    while (name(dad) != apply_tag && dad !=id) dad = father(dad);
191
    if (name(dad) == apply_tag) { useinpar =1;}
192
    return;
193
  }
194
 
195
 
196
  for (l=a; !last(l); l=bro(l)) {
197
    int u = trace_uses(bro(l), id);
198
    if (u!=1|| nouses==0) return;
199
  }
200
  a = dad;
201
  if (dad!=id) goto tailrec;	     
202
}
203
 
204
 
205
 
206
bool simple_seq
207
    PROTO_N ( ( e, id ) )
208
    PROTO_T ( exp e X exp id )
209
{
210
  exp dad = father(e);
211
  for(;;) {
212
    if (dad == id) return 1;
213
    if (name(dad)==seq_tag || name(dad)==0
214
	|| name(dad) == ident_tag) { dad = father(dad);}
215
    else return 0;
216
  }
217
}
218
 
219
bool tempdecopt = 0;		/* flag to allow this optimisation; -Tt
220
				   sets to 0 */
221
 
222
bool tempdec
223
    PROTO_N ( ( e, enoughs ) )
224
    PROTO_T ( exp e X bool enoughs )
225
{
226
  /* e is a local declaration; 'enoughs'
227
     is a misnomer to say whether there are
228
     t-regs available delivers 1 if e can be
229
     allocated into t-reg or par reg */
230
  exp p;
231
  if (!tempdecopt ) return 0;
232
  nouses = 0;
233
  useinpar = 0;
234
  if (isvar(e) ) {
235
    for (p=pt(e); p!=nilexp; p =pt(p)) {
236
      /* find no of uses which are not assignments to id ... */
237
      if (!last(p) && last(bro(p)) 
238
	  && name(bro(bro(p))) == ass_tag ) {
239
/*	if (!simple_seq(bro(bro(p)), e) ) return 0;*/
240
	/* ... in simple sequence */		 
241
	continue;
242
      }
243
      nouses++;
244
    }
245
  }
246
  else nouses = no(e);
247
 
248
  /* trace simple successors to assignmnts or init to id to find 
249
     if all uses occur before unpredictable change of control 
250
     (or another assignment to id) */
251
  if (name(son(e)) != clear_tag || isparam(e)) { after_a(son(e), e); }
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; 
263
    /* don't allocate this into par reg */
264
    return 1;
265
  }
266
  return 0;
267
}
268
 
269
 
270
 
271
 
272
 
273