Subversion Repositories tendra.SVN

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 7
Line -... Line 1...
-
 
1
/*
-
 
2
 * Copyright (c) 2002-2005 The TenDRA Project <http://www.tendra.org/>.
-
 
3
 * All rights reserved.
-
 
4
 *
-
 
5
 * Redistribution and use in source and binary forms, with or without
-
 
6
 * modification, are permitted provided that the following conditions are met:
-
 
7
 *
-
 
8
 * 1. Redistributions of source code must retain the above copyright notice,
-
 
9
 *    this list of conditions and the following disclaimer.
-
 
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
-
 
11
 *    this list of conditions and the following disclaimer in the documentation
-
 
12
 *    and/or other materials provided with the distribution.
-
 
13
 * 3. Neither the name of The TenDRA Project nor the names of its contributors
-
 
14
 *    may be used to endorse or promote products derived from this software
-
 
15
 *    without specific, prior written permission.
-
 
16
 *
-
 
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
-
 
18
 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-
 
19
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-
 
20
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
-
 
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-
 
22
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-
 
23
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-
 
24
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-
 
25
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-
 
26
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-
 
27
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
28
 *
-
 
29
 * $Id$
-
 
30
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
    
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
36
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
37
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
38
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
39
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
40
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
41
    shall be deemed to be acceptance of the following conditions:-
12
    
42
 
13
        (1) Its Recipients shall ensure that this Notice is
43
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
44
        reproduced upon any copies or amended versions of it;
15
    
45
 
16
        (2) Any amended version of it shall be clearly marked to
46
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
47
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
48
        for the relevant amendment or amendments;
19
    
49
 
20
        (3) Its onward transfer from a recipient to another
50
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
51
        party shall be deemed to be that party's acceptance of
22
        these conditions;
52
        these conditions;
23
    
53
 
24
        (4) DERA gives no warranty or assurance as to its
54
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
55
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
56
        no liability whatsoever in relation to any use to which
27
        it may be put.
57
        it may be put.
28
*/
58
*/
29
 
59
 
30
 
60
 
31
/* 	$Id: regexps.c,v 1.1.1.1 1998/01/17 15:56:01 release Exp $	 */
61
/* 	$Id$	 */
32
 
62
 
33
#ifndef lint
63
#ifndef lint
34
static char vcid[] = "$Id: regexps.c,v 1.1.1.1 1998/01/17 15:56:01 release Exp $";
64
static char vcid[] = "$Id$";
35
#endif /* lint */
65
#endif /* lint */
36
 
66
 
37
/*
67
/*
38
   regexps.c
68
   regexps.c
39
*/
69
*/
Line 46... Line 76...
46
 * Revision 1.7  1996/01/17  09:31:37  john
76
 * Revision 1.7  1996/01/17  09:31:37  john
47
 * Fix to support current_env dependancy
77
 * Fix to support current_env dependancy
48
 *
78
 *
49
 * Revision 1.6  1995/12/04  09:13:11  john
79
 * Revision 1.6  1995/12/04  09:13:11  john
50
 * Fix to dependancy check
80
 * Fix to dependancy check
51
 *
81
 *
52
 * Revision 1.5  1995/10/16  12:09:21  john
82
 * Revision 1.5  1995/10/16  12:09:21  john
53
 * Change to alignment calculation
83
 * Change to alignment calculation
54
 *
84
 *
55
 * Revision 1.4  1995/08/21  08:46:20  john
85
 * Revision 1.4  1995/08/21  08:46:20  john
56
 * Changed include files
86
 * Changed include files
57
 *
87
 *
58
 * Revision 1.3  1995/05/16  10:55:17  john
88
 * Revision 1.3  1995/05/16  10:55:17  john
59
 * Cosmetic change
89
 * Cosmetic change
60
 *
90
 *
61
 * Revision 1.2  1995/03/29  14:05:14  john
91
 * Revision 1.2  1995/03/29  14:05:14  john
62
 * Changes to keep tcheck happy
92
 * Changes to keep tcheck happy
63
 *
93
 *
64
 * Revision 1.1.1.1  1995/03/23  10:39:20  john
94
 * Revision 1.1.1.1  1995/03/23  10:39:20  john
65
 * Entered into CVS
95
 * Entered into CVS
Line 84... Line 114...
84
#include "extratags.h"
114
#include "extratags.h"
85
#include "reg_defs.h"
115
#include "reg_defs.h"
86
#include "regexps.h"
116
#include "regexps.h"
87
#include "fail.h"
117
#include "fail.h"
88
 
118
 
89
regpeep regexps[64];		
119
regpeep regexps[64];
90
 
120
 
91
bool eq_size
121
bool eq_size
92
    PROTO_N ( ( as, bs ) )
-
 
93
    PROTO_T ( shape as X shape bs )
122
(shape as, shape bs)
94
{
123
{
95
  return (shape_size(as) == shape_size(bs));
124
  return(shape_size(as) == shape_size(bs));
96
}
125
}
97
 
126
 
98
bool sim_exp PROTO_S ((exp a, exp b));
127
bool sim_exp(exp a, exp b);
99
 
128
 
100
bool eq_sze
129
bool eq_sze
101
    PROTO_N ( ( as, bs ) )
-
 
102
    PROTO_T ( shape as X shape bs )
130
(shape as, shape bs)
103
{
131
{
104
  if (is_floating(name(as))) return(name(as)==name(bs));
132
  if (is_floating(name(as))) return(name(as) ==name(bs));
105
  if (is_floating(name(bs))) return 0;
133
  if (is_floating(name(bs))) return 0;
106
  return (shape_size(as) == shape_size(bs) && shape_align(as)==shape_align(bs));
134
  return(shape_size(as) == shape_size(bs) && shape_align(as) ==shape_align(bs));
107
}
135
}
108
 
136
 
109
#define is_volatile(X) ((X<9)||(X>15))
137
#define is_volatile(X)((X<9) || (X>15))
110
 
138
 
111
 
139
 
112
bool sim_explist
140
bool sim_explist
113
    PROTO_N ( ( al, bl ) )
-
 
114
    PROTO_T ( exp al X exp bl )
141
(exp al, exp bl)
115
{
142
{
116
  if (al == nilexp && bl == nilexp)
143
  if (al == nilexp && bl == nilexp)
117
    return (1);
144
    return(1);
118
  if (al == nilexp || bl == nilexp)
145
  if (al == nilexp || bl == nilexp)
119
    return (0);
146
    return(0);
120
  if (!sim_exp (al, bl))
147
  if (!sim_exp(al, bl))
121
    return (0);
148
    return(0);
122
  if (last (al) && last (bl))
149
  if (last(al) && last(bl))
123
    return (1);
150
    return(1);
124
  if (last (al) || last (bl))
151
  if (last(al) || last(bl))
125
    return (0);
152
    return(0);
126
  return (sim_explist (bro (al), bro (bl)));
153
  return(sim_explist(bro(al), bro(bl)));
127
}
154
}
128
 
155
 
129
 
156
 
130
 
157
 
131
bool sim_exp
158
bool sim_exp
132
    PROTO_N ( ( a,b ) )
-
 
133
    PROTO_T ( exp a X exp b )
159
(exp a, exp b)
134
{
160
{
135
  /* basically eq_exp except equal shapes
161
  /* basically eq_exp except equal shapes
136
     requirement  is weakened to equal sizes
162
     requirement  is weakened to equal sizes
137
     and alignments */
163
     and alignments */
138
  if (name (a) == name (b)) {
164
  if (name(a) == name(b)) {
139
    if (name (a) == name_tag)
165
    if (name(a) == name_tag)
140
      return (son (a) == son (b) && no (a) == no (b) &&
166
      return(son(a) == son(b) && no(a) == no(b) &&
141
	      eq_sze (sh (a), sh (b)));
167
	      eq_sze(sh(a), sh(b)));
142
    if (name(a)==maxlike_tag || name(a)==minlike_tag || name(a)==abslike_tag) {
168
    if (name(a) ==maxlike_tag || name(a) ==minlike_tag || name(a) ==abslike_tag) {
143
    	return (props(son(a))==props(son(b)) && eq_size(sh(a), sh(b)) &&
169
    	return(props(son(a)) ==props(son(b)) && eq_size(sh(a), sh(b)) &&
144
    			sim_explist(son(son(a)),son(son(b)) ) );
170
    			sim_explist(son(son(a)),son(son(b))));
145
    }
171
    }
146
    if (!is_a (name (a)) || !eq_sze (sh (a), sh (b)))
172
    if (!is_a(name(a)) || !eq_sze(sh(a), sh(b)))
147
      return (0);
173
      return(0);
148
    return (no (a) == no (b) &&
174
    return(no(a) == no(b) &&
149
	sim_explist (son (a), son (b)));
175
	sim_explist(son(a), son(b)));
150
  };
176
  };
151
  return (0);
177
  return(0);
152
}
178
}
153
 
179
 
154
void clear_all
180
void clear_all
155
    PROTO_Z ()
181
(void)
156
{
182
{
157
  /* forget all register - exp associations 
183
  /* forget all register - exp associations
158
   */
184
   */
159
  int   i;
185
  int   i;
160
  for (i = 0; i < 64; i++) {
186
  for (i = 0; i < 64; i++) {
161
/*    if(is_volatile(i)){*/
187
/*    if(is_volatile(i)){*/
162
      regexps[i].keptexp = nilexp;
188
      regexps[i].keptexp = nilexp;
163
      regexps[i].alignment = 0;
189
      regexps[i].alignment = 0;
164
      setregalt (regexps[i].inans, NO_REG);
190
      setregalt(regexps[i].inans, NO_REG);
165
/*    }*/
191
/*    }*/
166
  }
192
  }
167
}
193
}
168
 
194
 
169
 
195
 
170
 
196
 
171
   
197
 
172
  
198
 
173
 
199
 
174
 
200
 
175
 
201
 
176
void clear_reg
202
void clear_reg
177
    PROTO_N ( ( i ) )
-
 
178
    PROTO_T ( int i )
203
(int i)
179
{
204
{
180
  /* forget reg i - exp association */
205
  /* forget reg i - exp association */
181
  i = abs (i);
206
  i = abs(i);
182
  if (i >= 0 && i < 64) {
207
  if (i >= 0 && i < 64) {
183
    regexps[i].keptexp = nilexp;
208
    regexps[i].keptexp = nilexp;
184
    regexps[i].alignment = 0;
209
    regexps[i].alignment = 0;
185
    setregalt (regexps[i].inans, NO_REG);
210
    setregalt(regexps[i].inans, NO_REG);
186
  }
211
  }
187
}
212
}
188
 
213
 
189
void clear_freg
214
void clear_freg
190
    PROTO_N ( ( i ) )
-
 
191
    PROTO_T ( int i )
215
(int i)
192
{
216
{
193
  i=abs(i)+32;
217
  i=abs(i) +32;
194
  if(i<64)
218
  if (i<64)
195
  {
219
  {
196
    regexps[i].keptexp=nilexp;
220
    regexps[i].keptexp=nilexp;
197
    setregalt(regexps[i].inans,NO_REG);	/* ?? */
221
    setregalt(regexps[i].inans,NO_REG);	/* ?? */
198
  }
222
  }
199
}
223
}
200
 
224
 
201
 
225
 
202
 
226
 
203
ans iskept
227
ans iskept
204
    PROTO_N ( ( e ) )
-
 
205
    PROTO_T ( exp e )
228
(exp e)
206
{
229
{
207
  /* find if e has already been evaluated
230
  /* find if e has already been evaluated
208
     into a register */
231
     into a register */
209
  int   i;
232
  int   i;
210
  ans nilans;
233
  ans nilans;
211
  ans aa;
234
  ans aa;
212
  setregalt (nilans, 32);
235
  setregalt(nilans, 32);
213
  aa = nilans;
236
  aa = nilans;
214
  for (i = 0; i < 48; i++) {
237
  for (i = 0; i < 48; i++) {
215
    exp ke = regexps[i].keptexp;
238
    exp ke = regexps[i].keptexp;
216
    bool isc = regexps[i].iscont;
239
    bool isc = regexps[i].iscont;
217
    if (ke != nilexp) {		/* there is an accociation with reg i */
240
    if (ke != nilexp) {		/* there is an accociation with reg i */
218
      if (
241
      if (
219
	  ((!isc && sim_exp (ke, e)) ||
242
	 ((!isc && sim_exp(ke, e)) ||
220
	   (name (e) == cont_tag && isc && eq_sze (sh (ke), sh (e))
243
	  (name(e) == cont_tag && isc && eq_sze(sh(ke), sh(e))
221
	    && sim_exp (ke, son (e)))
244
	    && sim_exp(ke, son(e)))
222
	   )
245
	  )
223
	  ) {
246
	 ) {
224
	aa = (regexps[i].inans);
247
	aa = (regexps[i].inans);
225
	switch (aa.discrim) {
248
	switch (aa.discrim) {
226
	 case notinreg: 
249
	 case notinreg:
227
	  {
250
	  {
228
	    if (!aa.val.instoreans.adval) {
251
	    if (!aa.val.instoreans.adval) {
229
	      /* the expression is given indirectly - it
252
	      /* the expression is given indirectly - it
230
		 may have also been loaded into a
253
		 may have also been loaded into a
231
		 register */
254
		 register */
232
	      continue;
255
	      continue;
233
	    }
256
	    }
234
	    /* else ... */
257
	    /* else ... */
235
	  }
258
	  }
236
	  FALL_THROUGH
259
	  FALL_THROUGH
237
	 default: 
260
	 default:
238
	  return aa;
261
	  return aa;
239
	}
262
	}
240
      }
263
      }
241
      else
264
      else
242
	if (name (ke) == cont_tag && !isc) {
265
	if (name(ke) == cont_tag && !isc) {
243
	  ans aq;
266
	  ans aq;
244
	  aq = regexps[i].inans;
267
	  aq = regexps[i].inans;
245
	  if (aq.discrim == notinreg) {
268
	  if (aq.discrim == notinreg) {
246
	    instore is;
269
	    instore is;
247
	    is = insalt (aq);
270
	    is = insalt(aq);
248
	    if (!is.adval && is.b.offset == 0 && is.b.base > 0 && is.b.base < 31
271
	    if (!is.adval && is.b.offset == 0 && is.b.base > 0 && is.b.base < 31
249
		&& sim_exp (son (ke), e)) {
272
		&& sim_exp(son(ke), e)) {
250
	      /* the contents of req expression is here
273
	      /* the contents of req expression is here
251
		 as a reg-offset */
274
		 as a reg-offset */
252
	      is.adval = 1;
275
	      is.adval = 1;
253
	      setinsalt (aq, is);
276
	      setinsalt(aq, is);
254
	      return aq;
277
	      return aq;
255
	    }
278
	    }
256
	  }
279
	  }
257
	}
280
	}
258
	else
281
	else
259
	  if (name (ke) == reff_tag && !isc) {
282
	  if (name(ke) == reff_tag && !isc) {
260
	    ans aq;
283
	    ans aq;
261
	    aq = regexps[i].inans;
284
	    aq = regexps[i].inans;
262
	    if (aq.discrim == notinreg) {
285
	    if (aq.discrim == notinreg) {
263
	      instore is;
286
	      instore is;
264
	      is = insalt (aq);
287
	      is = insalt(aq);
265
	      if (is.adval && is.b.offset == (no (ke) / 8)
288
	      if (is.adval && is.b.offset == (no(ke) / 8)
266
		  && is.b.base > 0 && is.b.base < 31
289
		  && is.b.base > 0 && is.b.base < 31
267
		  && sim_exp (son (ke), e)) {
290
		  && sim_exp(son(ke), e)) {
268
		/* a ref select of req expression is here
291
		/* a ref select of req expression is here
269
		   as a reg-offset */
292
		   as a reg-offset */
270
		is.adval = 1;
293
		is.adval = 1;
271
		is.b.offset = 0;
294
		is.b.offset = 0;
272
		setinsalt (aq, is);
295
		setinsalt(aq, is);
273
		return aq;
296
		return aq;
274
	      }
297
	      }
275
	    }
298
	    }
276
	  }
299
	  }
277
    }
300
    }
278
  }
301
  }
279
  return aa;
302
  return aa;
280
}
303
}
281
 
304
 
282
void keepexp
305
void keepexp
283
    PROTO_N ( ( e, loc ) )
-
 
284
    PROTO_T ( exp e X ans loc )
306
(exp e, ans loc)
285
{
307
{
286
  /* set up exp - address association */
308
  /* set up exp - address association */
287
  int   pos;
309
  int   pos;
288
  switch (loc.discrim) {
310
  switch (loc.discrim) {
289
   case insomereg: 
311
   case insomereg:
290
   case insomefreg: {
312
   case insomefreg: {
291
     failer ("Keep ? reg");
313
     failer("Keep ? reg");
292
     break;
314
     break;
293
   }
315
   }
294
   case inreg: 
316
   case inreg:
295
    {
317
    {
296
      pos = regalt (loc);
318
      pos = regalt(loc);
297
      break;
319
      break;
298
    }
320
    }
299
   case infreg: 
321
   case infreg:
300
    {
322
    {
301
      pos = fregalt (loc).fr + 32;
323
      pos = fregalt(loc).fr + 32;
302
      break;
324
      break;
303
    }
325
    }
304
   case notinreg: 
326
   case notinreg:
305
    {
327
    {
306
      pos = insalt (loc).b.base;
328
      pos = insalt(loc).b.base;
307
      if (pos < 0 || pos > 30)
329
      if (pos < 0 || pos > 30)
308
	return;
330
	return;
309
    }	
331
    }
310
 
332
 
311
  };
333
  };
312
  if (pos==0 || pos == 32) return;
334
  if (pos==0 || pos == 32) return;
313
  regexps[pos].keptexp = e;
335
  regexps[pos].keptexp = e;
314
  regexps[pos].inans = loc;
336
  regexps[pos].inans = loc;
315
  regexps[pos].iscont = 0;
337
  regexps[pos].iscont = 0;
316
}	
338
}
317
 
339
 
318
void keepcont
340
void keepcont
319
    PROTO_N ( ( e, reg ) )
-
 
320
    PROTO_T ( exp e X int reg )
341
(exp e, int reg)
321
{
342
{
322
  /* set up cont(e)-reg association */
343
  /* set up cont(e)-reg association */
323
  freg fr;
344
  freg fr;
324
  int   z = abs (reg);
345
  int   z = abs(reg);
325
  /*  if (z==2|| z==32) return;*/
346
  /*  if (z==2|| z==32) return;*/
326
  if (z > 31) {
347
  if (z > 31) {
327
    if(reg<0) 
348
    if (reg<0)
328
      fr.type = IEEE_double;
349
      fr.type = IEEE_double;
329
    else
350
    else
330
      fr.type = IEEE_single;
351
      fr.type = IEEE_single;
331
    fr.fr = z - 32;
352
    fr.fr = z - 32;
332
    setfregalt (regexps[z].inans, fr);
353
    setfregalt(regexps[z].inans, fr);
333
  }
354
  }
334
  else {
355
  else {
335
    instore is;
356
    instore is;
336
    is.b.base = reg;
357
    is.b.base = reg;
337
    is.b.offset = 0;
358
    is.b.offset = 0;
338
    is.adval = 1;
359
    is.adval = 1;
339
    setinsalt (regexps[z].inans, is);
360
    setinsalt(regexps[z].inans, is);
340
  }
361
  }
341
 
362
 
342
  regexps[z].keptexp = e;
363
  regexps[z].keptexp = e;
343
 
364
 
344
  regexps[z].iscont = 1;
365
  regexps[z].iscont = 1;
345
 
366
 
346
}
367
}
347
 
368
 
348
void keepreg
369
void keepreg
349
    PROTO_N ( ( e, reg ) )
-
 
350
    PROTO_T ( exp e X int reg )
370
(exp e, int reg)
351
{
371
{
352
  /* set up e-reg association */
372
  /* set up e-reg association */
353
  freg fr;
373
  freg fr;
354
  int   z = abs (reg);
374
  int   z = abs(reg);
355
  if(z==0) return;
375
  if (z==0) return;
356
/*  if (z==2 || z==32) return;*/
376
/*  if (z==2 || z==32) return;*/
357
  if (z > 31) {
377
  if (z > 31) {
358
    if(reg<0)
378
    if (reg<0)
359
      fr.type = IEEE_double;
379
      fr.type = IEEE_double;
360
    else
380
    else
361
      fr.type = IEEE_single;
381
      fr.type = IEEE_single;
362
    fr.fr = z - 32;
382
    fr.fr = z - 32;
363
    setfregalt (regexps[z].inans, fr);
383
    setfregalt(regexps[z].inans, fr);
364
  }
384
  }
365
  else {
385
  else {
366
    instore is;
386
    instore is;
367
    is.b.base = reg;
387
    is.b.base = reg;
368
    is.b.offset = 0;
388
    is.b.offset = 0;
369
    is.adval = 1;
389
    is.adval = 1;
370
    setinsalt (regexps[z].inans, is);
390
    setinsalt(regexps[z].inans, is);
371
  }
391
  }
372
 
392
 
373
  regexps[z].keptexp = e;
393
  regexps[z].keptexp = e;
374
  regexps[z].iscont = 0;
394
  regexps[z].iscont = 0;
375
}
395
}
376
 
396
 
377
bool couldeffect PROTO_S ((exp e, exp z));
397
bool couldeffect(exp e, exp z);
378
 
398
 
379
bool couldbe
399
bool couldbe
380
    PROTO_N ( ( e, lhs ) )
-
 
381
    PROTO_T ( exp e X exp lhs )
400
(exp e, exp lhs)
382
{
401
{
383
  /* could e be lhs? */ 			
402
  /* could e be lhs? */
384
  int   ne = name (e);
403
  int   ne = name(e);
385
  exp s = son (e);
404
  exp s = son(e);
386
 
405
 
387
  if (ne == name_tag) {
406
  if (ne == name_tag) {
388
    if (lhs != 0 && s == son (lhs)) {
407
    if (lhs != 0 && s == son(lhs)) {
389
      return 1;
408
      return 1;
390
    }
409
    }
391
    if (isvar (s)) {
410
    if (isvar(s)) {
392
      return (lhs == 0 && isvis(s));
411
      return(lhs == 0 && isvis(s));
393
      /*
412
      /*
394
      return (lhs == 0 && (isvis (s) || isglob(s) ));*/
413
      return (lhs == 0 && (isvis (s) || isglob(s) ));*/
395
    }
414
    }
396
    if (name (s) == proc_tag)
415
    if (name(s) == proc_tag)
397
      return (lhs == 0);
416
      return(lhs == 0);
398
    if (son (s) == nilexp)
417
    if (son(s) == nilexp)
399
      return 1;
418
      return 1;
400
    return couldbe (son (s), lhs);
419
    return couldbe(son(s), lhs);
401
  }
420
  }
402
  if (ne == cont_tag) {
421
  if (ne == cont_tag) {
403
    if (lhs != 0 && name (s) == name_tag && son (s) != nilexp) {
422
    if (lhs != 0 && name(s) == name_tag && son(s)!= nilexp) {
404
      return (son (s) == son (lhs) || isvis (son (lhs)) || isvis (son (s)));
423
      return(son(s) == son(lhs) || isvis(son(lhs)) || isvis(son(s)));
405
    }
424
    }
406
    return 1;
425
    return 1;
407
  }
426
  }
408
  if (ne == reff_tag || ne == field_tag) {
427
  if (ne == reff_tag || ne == field_tag) {
409
    return couldbe (s, lhs);
428
    return couldbe(s, lhs);
410
  }
429
  }
411
  if (ne == addptr_tag || ne == subptr_tag) {
430
  if (ne == addptr_tag || ne == subptr_tag) {
412
    return (couldbe (s, lhs) || couldeffect (bro (s), lhs));
431
    return(couldbe(s, lhs) || couldeffect(bro(s), lhs));
413
  }
432
  }
414
 
433
 
415
  return 1;
434
  return 1;
416
 
435
 
417
}
436
}
418
 
437
 
419
bool couldeffect
438
bool couldeffect
420
    PROTO_N ( ( e, z ) )
-
 
421
    PROTO_T ( exp e X exp z )
439
(exp e, exp z)
422
{
440
{
423
  /* could alteration to z effect e? */
441
  /* could alteration to z effect e? */
424
  int   ne = name (e);
442
  int   ne = name(e);
425
  if (ne == cont_tag) {
443
  if (ne == cont_tag) {
426
    return couldbe (son (e), z);
444
    return couldbe(son(e), z);
427
  }
445
  }
428
  if (ne == name_tag) {
446
  if (ne == name_tag) {
429
    if (isvar (son (e)))
447
    if (isvar(son(e)))
430
      return (z == 0 && isvis (son (e)));
448
      return(z == 0 && isvis(son(e)));
431
    if (name (son (e)) == proc_tag)
449
    if (name(son(e)) == proc_tag)
432
      return 0;
450
      return 0;
433
    if (son (son (e)) == nilexp)
451
    if (son(son(e)) == nilexp)
434
      return 1 /* could it happen? */ ;
452
      return 1 /* could it happen? */ ;
435
 
453
 
436
    return couldeffect (son (son (e)), z);
454
    return couldeffect(son(son(e)), z);
437
 
455
 
438
  }
456
  }
439
  if (ne < plus_tag || ne == contvol_tag)
457
  if (ne < plus_tag || ne == contvol_tag)
440
    return 1;
458
    return 1;
441
 
459
 
442
  e = son (e);
460
  e = son(e);
443
 
461
 
444
  while (e != nilexp) {
462
  while (e != nilexp) {
445
    if (couldeffect (e, z))
463
    if (couldeffect(e, z))
446
      return 1;
464
      return 1;
447
    if (last (e))
465
    if (last(e))
448
      return 0;
466
      return 0;
449
    e = bro (e);
467
    e = bro(e);
450
  }
468
  }
451
  return 0;
469
  return 0;
452
}
470
}
453
 
471
 
454
 
472
 
455
 
473
 
456
bool dependson
474
bool dependson
457
    PROTO_N ( ( e, isc, z ) )
-
 
458
    PROTO_T ( exp e X bool isc X exp z )
475
(exp e, bool isc, exp z)
459
{
476
{
460
  /* does e depend on z */
477
  /* does e depend on z */
461
  if (e == nilexp) {
478
  if (e == nilexp) {
462
    return 0;
479
    return 0;
463
  }
480
  }
464
  for (;;) {
481
  for (;;) {
465
    if (name (z) == reff_tag || name (z) == addptr_tag ||
482
    if (name(z) == reff_tag || name(z) == addptr_tag ||
466
	name (z) == subptr_tag) {
483
	name(z) == subptr_tag) {
467
      z = son (z);
484
      z = son(z);
468
      if(name(z) == null_tag) return 0;
485
      if (name(z) == null_tag) return 0;
469
    }
486
    }
470
    else
487
    else
471
      if (name (z) != name_tag) {
488
      if (name(z)!= name_tag) {
472
	if (name (z) != cont_tag)
489
	if (name(z)!= cont_tag)
473
	  return 1;
490
	  return 1;
474
	z = 0;
491
	z = 0;
475
	break;
492
	break;
476
    }
493
    }
477
      if(name(z) == current_env_tag) {
494
      if (name(z) == current_env_tag) {
478
	return 0;
495
	return 0;
479
      }
496
      }
480
            
497
 
481
    if (isvar (son (z)))
498
    if (isvar(son(z)))
482
      break;
499
      break;
483
    if (name (son (z)) == proc_tag) {
500
    if (name(son(z)) == proc_tag) {
484
      z = 0;
501
      z = 0;
485
      break;
502
      break;
486
    }
503
    }
487
    if (son (son (z)) == nilexp)
504
    if (son(son(z)) == nilexp)
488
      return 1;			/* can it happen? */
505
      return 1;			/* can it happen? */
489
    z = son (son (z));
506
    z = son(son(z));
490
  }
507
  }
491
 
508
 
492
  /* z is now unambiguous variable name or 0 meaning some contents */
509
  /* z is now unambiguous variable name or 0 meaning some contents */
493
 
510
 
494
  return ((isc) ? couldbe (e, z) : couldeffect (e, z));
511
  return((isc)? couldbe(e, z): couldeffect(e, z));
495
}
512
}
496
 
513
 
497
 
514
 
498
 
515
 
499
 
516
 
500
 
517
 
501
void clear_dep_reg
518
void clear_dep_reg
502
    PROTO_N ( ( lhs ) )
-
 
503
    PROTO_T ( exp lhs )
519
(exp lhs)
504
{
520
{
505
  /* remove association of any register
521
  /* remove association of any register
506
     which depends on lhs */
522
     which depends on lhs */
507
  int   i;
523
  int   i;
508
  for (i = 0; i < 64; i++) {
524
  for (i = 0; i < 64; i++) {
509
    if (dependson (regexps[i].keptexp, regexps[i].iscont, lhs)) {
525
    if (dependson(regexps[i].keptexp, regexps[i].iscont, lhs)) {
510
      regexps[i].keptexp = nilexp;
526
      regexps[i].keptexp = nilexp;
511
      setregalt (regexps[i].inans, NO_REG);
527
      setregalt(regexps[i].inans, NO_REG);
512
    }
528
    }
513
  }
529
  }
514
}
530
}
515
 
531