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
    Copyright (c) 1993 Open Software Foundation, Inc.
32
    Copyright (c) 1993 Open Software Foundation, Inc.
3
 
33
 
4
 
34
 
5
    All Rights Reserved
35
    All Rights Reserved
6
 
36
 
7
 
37
 
8
    Permission to use, copy, modify, and distribute this software
38
    Permission to use, copy, modify, and distribute this software
9
    and its documentation for any purpose and without fee is hereby
39
    and its documentation for any purpose and without fee is hereby
10
    granted, provided that the above copyright notice appears in all
40
    granted, provided that the above copyright notice appears in all
11
    copies and that both the copyright notice and this permission
41
    copies and that both the copyright notice and this permission
12
    notice appear in supporting documentation.
42
    notice appear in supporting documentation.
Line 14... Line 44...
14
 
44
 
15
    OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING
45
    OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING
16
    ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
46
    ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
17
    PARTICULAR PURPOSE.
47
    PARTICULAR PURPOSE.
18
 
48
 
19
 
49
 
20
    IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
50
    IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
21
    CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
51
    CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
22
    LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
52
    LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
23
    NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
53
    NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
24
    WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
54
    WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25
*/
55
*/
26
 
56
 
27
/*
57
/*
28
    		 Crown Copyright (c) 1997
58
    		 Crown Copyright (c) 1997
29
    
59
 
30
    This TenDRA(r) Computer Program is subject to Copyright
60
    This TenDRA(r) Computer Program is subject to Copyright
31
    owned by the United Kingdom Secretary of State for Defence
61
    owned by the United Kingdom Secretary of State for Defence
32
    acting through the Defence Evaluation and Research Agency
62
    acting through the Defence Evaluation and Research Agency
33
    (DERA).  It is made available to Recipients with a
63
    (DERA).  It is made available to Recipients with a
34
    royalty-free licence for its use, reproduction, transfer
64
    royalty-free licence for its use, reproduction, transfer
35
    to other parties and amendment for any purpose not excluding
65
    to other parties and amendment for any purpose not excluding
36
    product development provided that any such use et cetera
66
    product development provided that any such use et cetera
37
    shall be deemed to be acceptance of the following conditions:-
67
    shall be deemed to be acceptance of the following conditions:-
38
    
68
 
39
        (1) Its Recipients shall ensure that this Notice is
69
        (1) Its Recipients shall ensure that this Notice is
40
        reproduced upon any copies or amended versions of it;
70
        reproduced upon any copies or amended versions of it;
41
    
71
 
42
        (2) Any amended version of it shall be clearly marked to
72
        (2) Any amended version of it shall be clearly marked to
43
        show both the nature of and the organisation responsible
73
        show both the nature of and the organisation responsible
44
        for the relevant amendment or amendments;
74
        for the relevant amendment or amendments;
45
    
75
 
46
        (3) Its onward transfer from a recipient to another
76
        (3) Its onward transfer from a recipient to another
47
        party shall be deemed to be that party's acceptance of
77
        party shall be deemed to be that party's acceptance of
48
        these conditions;
78
        these conditions;
49
    
79
 
50
        (4) DERA gives no warranty or assurance as to its
80
        (4) DERA gives no warranty or assurance as to its
51
        quality or suitability for any purpose and DERA accepts
81
        quality or suitability for any purpose and DERA accepts
52
        no liability whatsoever in relation to any use to which
82
        no liability whatsoever in relation to any use to which
53
        it may be put.
83
        it may be put.
54
*/
84
*/
Line 102... Line 132...
102
#define FR_OFFSET		KEPT_FREG_OFFSET	/* 32 */
132
#define FR_OFFSET		KEPT_FREG_OFFSET	/* 32 */
103
#define	LAST_ALL_REGS		(FR_OFFSET+FR_LAST)	/* 63 */
133
#define	LAST_ALL_REGS		(FR_OFFSET+FR_LAST)	/* 63 */
104
 
134
 
105
regpeep regexps[LAST_ALL_REGS+1];	/* [0:31] fix pt - [32:63] floating pt */
135
regpeep regexps[LAST_ALL_REGS+1];	/* [0:31] fix pt - [32:63] floating pt */
106
 
136
 
107
static bool sim_exp PROTO_S ((exp, exp));
137
static bool sim_exp(exp, exp);
108
 
138
 
109
 
139
 
110
/* both either floating or fixed and same size and alignment */
140
/* both either floating or fixed and same size and alignment */
111
bool keep_eq_size PROTO_N ((as,bs)) PROTO_T (shape as X shape bs)
141
bool keep_eq_size(shape as, shape bs)
112
{
142
{
113
  bool as_flt = is_floating(name(as));
143
  bool as_flt = is_floating(name(as));
114
  bool bs_flt = is_floating(name(bs));
144
  bool bs_flt = is_floating(name(bs));
115
 
145
 
116
  if (as_flt != bs_flt)
146
  if (as_flt != bs_flt)
117
    return 0;			/* dissimilar float/fixed */
147
    return 0;			/* dissimilar float/fixed */
118
 
148
 
119
  return (shape_size(as) == shape_size(bs) && shape_align(as) == shape_align(bs));
149
  return(shape_size(as) == shape_size(bs) && shape_align(as) == shape_align(bs));
120
}
150
}
121
 
151
 
122
 
152
 
123
static bool sim_explist PROTO_N ((al,bl)) PROTO_T (exp al X exp bl)
153
static bool sim_explist(exp al, exp bl)
124
{
154
{
125
  if (al == nilexp && bl == nilexp)
155
  if (al == nilexp && bl == nilexp)
126
    return (1);
156
    return(1);
127
  if (al == nilexp || bl == nilexp)
157
  if (al == nilexp || bl == nilexp)
128
    return (0);
158
    return(0);
129
  if (!sim_exp(al, bl))
159
  if (!sim_exp(al, bl))
130
    return (0);
160
    return(0);
131
  if (last(al) && last(bl))
161
  if (last(al) && last(bl))
132
    return (1);
162
    return(1);
133
  if (last(al) || last(bl))
163
  if (last(al) || last(bl))
134
    return (0);
164
    return(0);
135
  return (sim_explist(bro(al), bro(bl)));
165
  return(sim_explist(bro(al), bro(bl)));
136
}
166
}
137
 
167
 
138
 
168
 
139
static bool sim_exp PROTO_N ((a,b)) PROTO_T (exp a X exp b)
169
static bool sim_exp(exp a, exp b)
140
{
170
{
141
  
171
 
142
  /*
172
  /*
143
   * basically eq_exp except equal shapes requirement is weakened to equal
173
   * basically eq_exp except equal shapes requirement is weakened to equal
144
   * sizes and alignments
174
   * sizes and alignments
145
   */
175
   */
146
  if (name(a) == name(b))
176
  if (name(a) == name(b))
147
  {
177
  {
148
    if (name(a) == name_tag)
178
    if (name(a) == name_tag)
149
    {
179
    {
150
      /* See if both are name_tags for same ident
180
      /* See if both are name_tags for same ident
151
	 with same offsets and same size and alignment */
181
	 with same offsets and same size and alignment */
152
      return (son(a) == son(b) && no(a) == no(b) &&
182
      return(son(a) == son(b) && no(a) == no(b) &&
153
	      keep_eq_size(sh(a), sh(b)));
183
	      keep_eq_size(sh(a), sh(b)));
154
    }
184
    }
155
    /* If it is not is_a 
185
    /* If it is not is_a
156
       OR 
186
       OR
157
       if they are not the same size and alignment and same
187
       if they are not the same size and alignment and same
158
     register type 
188
     register type
159
     */
189
     */
160
    if (!is_a(name(a)) || !keep_eq_size(sh(a), sh(b)))
190
    if (!is_a(name(a)) || !keep_eq_size(sh(a), sh(b)))
161
    {
191
    {
162
      return (0);
192
      return(0);
163
    }
193
    }
164
    if(name(a)==float_tag)
194
    if (name(a) ==float_tag)
165
    {
195
    {
166
      return eq_exp(son(a),son(b));
196
      return eq_exp(son(a),son(b));
167
      /* float_tag is special since we could have e.g float (-1 slongsh) float (-1 ulongsh) */
197
      /* float_tag is special since we could have e.g float (-1 slongsh) float (-1 ulongsh) */
168
    }
198
    }
169
    
199
 
170
    return (no(a) == no(b) && sim_explist(son(a), son(b)));
200
    return(no(a) == no(b) && sim_explist(son(a), son(b)));
171
  }
201
  }
172
  return (0);
202
  return(0);
173
}
203
}
174
 
204
 
175
 
205
 
176
void clear_all PROTO_Z ()
206
void clear_all(void)
177
{
207
{
178
  /* forget all register<->exp associations */
208
  /* forget all register<->exp associations */
179
  int i;
209
  int i;
180
 
210
 
181
  for (i = 0; i <= LAST_ALL_REGS; i++)
211
  for (i = 0; i <= LAST_ALL_REGS; i++)
Line 184... Line 214...
184
    setregalt(regexps[i].inans, 0);
214
    setregalt(regexps[i].inans, 0);
185
  }
215
  }
186
}
216
}
187
 
217
 
188
 
218
 
189
void clear_reg PROTO_N ((i)) PROTO_T (int i)
219
void clear_reg(int i)
190
{
220
{
191
  /* forget reg i - exp association */
221
  /* forget reg i - exp association */
192
  i = absval(i);
222
  i = absval(i);
193
  if (i >= 0 && i <= LAST_ALL_REGS)
223
  if (i >= 0 && i <= LAST_ALL_REGS)
194
  {
224
  {
Line 196... Line 226...
196
    setregalt(regexps[i].inans, 0);
226
    setregalt(regexps[i].inans, 0);
197
  }
227
  }
198
}
228
}
199
 
229
 
200
 
230
 
201
/* find if e has already been evaluated into a register low_reg..hi_reg 
231
/* find if e has already been evaluated into a register low_reg..hi_reg
202
   
232
 
203
   Register tracking:
233
   Register tracking:
204
   The array regexps[] is an array of regpeep structures
234
   The array regexps[] is an array of regpeep structures
205
   The elements of the structure regpeep are :
235
   The elements of the structure regpeep are :
206
   
236
 
207
   ans inans;     This helps specify where the exp came from 
237
   ans inans;     This helps specify where the exp came from
208
   exp keptexp;   The exp 
238
   exp keptexp;   The exp
209
   bool iscont;   This specifies whether or not
239
   bool iscont;   This specifies whether or not
210
   
240
 
211
   */
241
   */
212
static ans iskept_regrange PROTO_N ((e,low_reg,hi_reg)) PROTO_T (exp e X int low_reg X int hi_reg)
242
static ans iskept_regrange(exp e, int low_reg, int hi_reg)
213
{
243
{
214
  int i;
244
  int i;
215
  ans aa;
245
  ans aa;
216
  setregalt(aa, 0);		/* nilans until we know better */
246
  setregalt(aa, 0);		/* nilans until we know better */
217
 
247
 
218
  /* reg tracking of unions unsafe, as views of location can differ */
248
  /* reg tracking of unions unsafe, as views of location can differ */
219
  /* +++ improve this */
249
  /* +++ improve this */
220
  if (name(sh(e)) == cpdhd)
250
  if (name(sh(e)) == cpdhd)
221
  {
251
  {
222
    return aa;
252
    return aa;
223
  }
253
  }
224
  
254
 
225
 
255
 
226
  for (i = low_reg; i <= hi_reg; i++)
256
  for (i = low_reg; i <= hi_reg; i++)
227
  {
257
  {
228
    exp ke = regexps[i].keptexp;
258
    exp ke = regexps[i].keptexp;
229
 
259
 
Line 233... Line 263...
233
      bool isc = regexps[i].iscont;
263
      bool isc = regexps[i].iscont;
234
 
264
 
235
      ASSERT(!IS_R_TMP(i));	/* should not track R_TMP */
265
      ASSERT(!IS_R_TMP(i));	/* should not track R_TMP */
236
 
266
 
237
      if (
267
      if (
238
	  ((!isc && sim_exp(ke, e)) ||
268
	 ((!isc && sim_exp(ke, e)) ||
239
	   (name(e) == cont_tag && isc && keep_eq_size(sh(ke), sh(e))
269
	  (name(e) == cont_tag && isc && keep_eq_size(sh(ke), sh(e))
240
	    && sim_exp(ke, son(e)) && al1(sh(son(e))) == al1(sh(ke)))
270
	    && sim_exp(ke, son(e)) && al1(sh(son(e))) == al1(sh(ke)))
241
	   )
271
	  )
242
	)
272
	)
243
      {
273
      {
244
	aa = (regexps[i].inans);
274
	aa = (regexps[i].inans);
245
 
275
 
246
	FULLCOMMENT4("iskept found 1: reg=%d isc=%d name(e)=%d name(son(e))=%d",
276
	FULLCOMMENT4("iskept found 1: reg=%d isc=%d name(e) =%d name(son(e)) =%d",
247
		     i, isc, name(e), name(son(e)));
277
		     i, isc, name(e), name(son(e)));
248
	COMMENT1("iskept found: no = %d",no(e));
278
	COMMENT1("iskept found: no = %d",no(e));
249
	
279
 
250
 
280
 
251
	switch (aa.discrim)
281
	switch (aa.discrim)
252
	{
282
	{
253
	case notinreg:
283
	case notinreg:
254
	  {
284
	  {
Line 286... Line 316...
286
	     * the contents of req expression is here as a reg-offset
316
	     * the contents of req expression is here as a reg-offset
287
	     */
317
	     */
288
	    is.adval = 1;
318
	    is.adval = 1;
289
	    setinsalt(aq, is);
319
	    setinsalt(aq, is);
290
 
320
 
291
	    FULLCOMMENT4("iskept found 2: reg=%d isc=%d name(e)=%d name(son(e))=%d",
321
	    FULLCOMMENT4("iskept found 2: reg=%d isc=%d name(e) =%d name(son(e)) =%d",
292
			 i, isc, name(e), name(son(e)));
322
			 i, isc, name(e), name(son(e)));
293
 
323
 
294
	    return aq;
324
	    return aq;
295
	  }
325
	  }
296
	}
326
	}
Line 315... Line 345...
315
	     */
345
	     */
316
	    is.adval = 1;
346
	    is.adval = 1;
317
	    is.b.offset = 0;
347
	    is.b.offset = 0;
318
	    setinsalt(aq, is);
348
	    setinsalt(aq, is);
319
 
349
 
320
	    FULLCOMMENT4("iskept found 3: reg=%d isc=%d name(e)=%d name(son(e))=%d",
350
	    FULLCOMMENT4("iskept found 3: reg=%d isc=%d name(e) =%d name(son(e)) =%d",
321
			 i, isc, name(e), name(son(e)));
351
			 i, isc, name(e), name(son(e)));
322
 
352
 
323
	    return aq;
353
	    return aq;
324
	  }
354
	  }
325
	}
355
	}
326
      }
356
      }
327
    }
357
    }
328
  }
358
  }
329
  return aa;
359
  return aa;
330
}
360
}
331
 
361
 
332
 
362
 
333
/* find if e has already been evaluated into register 'reg' */
363
/* find if e has already been evaluated into register 'reg' */
334
ans iskept_inreg PROTO_N ((e,reg)) PROTO_T (exp e X int reg)
364
ans iskept_inreg(exp e, int reg)
335
{
365
{
336
  return iskept_regrange(e, reg, reg);
366
  return iskept_regrange(e, reg, reg);
337
}
367
}
338
 
368
 
339
 
369
 
340
/* find if e has already been evaluated into a fixed point register */
370
/* find if e has already been evaluated into a fixed point register */
341
ans iskept_reg PROTO_N ((e)) PROTO_T (exp e)
371
ans iskept_reg(exp e)
342
{
372
{
343
  return iskept_regrange(e, 0, R_LAST);
373
  return iskept_regrange(e, 0, R_LAST);
344
}
374
}
345
 
375
 
346
 
376
 
347
/* find if e has already been evaluated into a floating point register */
377
/* find if e has already been evaluated into a floating point register */
348
ans iskept_freg PROTO_N ((e)) PROTO_T (exp e)
378
ans iskept_freg(exp e)
349
{
379
{
350
  return iskept_regrange(e, FR_OFFSET, LAST_ALL_REGS);
380
  return iskept_regrange(e, FR_OFFSET, LAST_ALL_REGS);
351
}
381
}
352
 
382
 
353
 
383
 
354
/* find if e has already been evaluated into any register */
384
/* find if e has already been evaluated into any register */
355
ans iskept PROTO_N ((e)) PROTO_T (exp e)
385
ans iskept(exp e)
356
{
386
{
357
  return iskept_regrange(e, 0, LAST_ALL_REGS);
387
  return iskept_regrange(e, 0, LAST_ALL_REGS);
358
}
388
}
359
 
389
 
360
 
390
 
361
/* return reg if 'a' can is in fixed reg */
391
/* return reg if 'a' can is in fixed reg */
362
int ans_reg PROTO_N ((aa)) PROTO_T (ans aa)
392
int ans_reg(ans aa)
363
{
393
{
364
  if (aa.discrim == inreg && regalt(aa) != 0)
394
  if (aa.discrim == inreg && regalt(aa)!= 0)
365
  {
395
  {
366
    /* the same expression has already been evaluated into a reg */
396
    /* the same expression has already been evaluated into a reg */
367
    return regalt(aa);
397
    return regalt(aa);
368
  }
398
  }
369
 
399
 
370
  if (aa.discrim == notinreg)
400
  if (aa.discrim == notinreg)
371
  {
401
  {
372
    instore is; is = insalt(aa);	/* no init to avoid IBM cc bug */
402
    instore is; is = insalt(aa);	/* no init to avoid IBM cc bug */
373
 
403
 
Line 377... Line 407...
377
      return is.b.base;
407
      return is.b.base;
378
    }
408
    }
379
  }
409
  }
380
 
410
 
381
  return R_NO_REG;
411
  return R_NO_REG;
382
}
412
}
383
 
413
 
384
 
414
 
385
/* set up exp - address association */
415
/* set up exp - address association */
386
void keepexp PROTO_N ((e,loc)) PROTO_T (exp e X ans loc)
416
void keepexp(exp e, ans loc)
387
{
417
{
388
  int pos=0;
418
  int pos=0;
389
 
419
 
390
  switch (loc.discrim)
420
  switch (loc.discrim)
391
  {
421
  {
392
  case insomereg:
422
  case insomereg:
393
  case insomefreg:
423
  case insomefreg:
394
    {
424
    {
395
      fail("Keep ? reg");
425
      fail("Keep ? reg");
396
    }
426
    }
397
  case inreg:
427
  case inreg:
398
    {
428
    {
399
      pos = regalt(loc);
429
      pos = regalt(loc);
400
      break;
430
      break;
401
    }
431
    }
402
  case infreg:
432
  case infreg:
403
    {
433
    {
404
      pos = fregalt(loc).fr + FR_OFFSET;
434
      pos = fregalt(loc).fr + FR_OFFSET;
405
      break;
435
      break;
406
    }
436
    }
407
  case notinreg:
437
  case notinreg:
408
    {
438
    {
409
      pos = insalt(loc).b.base;
439
      pos = insalt(loc).b.base;
410
      if (!IS_FIXREG(pos))
440
      if (!IS_FIXREG(pos))
411
	return;
441
	return;
Line 425... Line 455...
425
  COMMENT2("keepexp : reg %d kept name is %d",pos,name(e));
455
  COMMENT2("keepexp : reg %d kept name is %d",pos,name(e));
426
}
456
}
427
 
457
 
428
 
458
 
429
/* set up cont(e)-reg association */
459
/* set up cont(e)-reg association */
430
/* if 0=<reg<=31  this means a fixed point register
460
/* if 0=<reg<=31  this means a fixed point register
431
   if 31<reg<=63  this means a float point register single precision
461
   if 31<reg<=63  this means a float point register single precision
432
   if -63<=reg<-31 this means a float point register double precision
462
   if -63<=reg<-31 this means a float point register double precision
433
   */
463
   */
434
void keepcont PROTO_N ((e,reg)) PROTO_T (exp e X int reg)
464
void keepcont(exp e, int reg)
435
{
465
{
436
  freg fr;
466
  freg fr;
437
  int z = absval(reg);
467
  int z = absval(reg);
438
 
468
 
439
  if (z >= FR_OFFSET)
469
  if (z >= FR_OFFSET)
440
  {
470
  {
441
    fr.dble = (reg < 0);
471
    fr.dble = (reg < 0);
442
    fr.fr = z - FR_OFFSET;
472
    fr.fr = z - FR_OFFSET;
443
    setfregalt(regexps[z].inans, fr);
473
    setfregalt(regexps[z].inans, fr);
444
  }
474
  }
445
  else
475
  else
446
  {
476
  {
447
    instore is;
477
    instore is;
448
 
478
 
449
    if (IS_R_TMP(z))
479
    if (IS_R_TMP(z))
450
      return;			/* don't track R_TMP which is used outside
480
      return;			/* don't track R_TMP which is used outside
451
				 * tracking scheme */
481
				 * tracking scheme */
452
 
482
 
453
    is.b.base = reg;
483
    is.b.base = reg;
454
    is.b.offset = 0;
484
    is.b.offset = 0;
455
    is.adval = 1;
485
    is.adval = 1;
456
    setinsalt(regexps[z].inans, is);
486
    setinsalt(regexps[z].inans, is);
457
  }
487
  }
458
 
488
 
459
  ASSERT(z >= 0 && z <= LAST_ALL_REGS);
489
  ASSERT(z >= 0 && z <= LAST_ALL_REGS);
460
  regexps[z].keptexp = e;
490
  regexps[z].keptexp = e;
461
  regexps[z].iscont = 1;
491
  regexps[z].iscont = 1;
462
  COMMENT2("keepcont : reg %d kept name is %d",z,name(e));
492
  COMMENT2("keepcont : reg %d kept name is %d",z,name(e));
463
 
493
 
464
}
494
}
465
 
495
 
466
 
496
 
467
/* keepreg keeps the exp e */
497
/* keepreg keeps the exp e */
468
/* if 0=<reg<=31  this means a fixed point register
498
/* if 0=<reg<=31  this means a fixed point register
469
   if 31<reg<=63  this means a float point register single precision
499
   if 31<reg<=63  this means a float point register single precision
470
   if -63<=reg<-31 this means a float point register double precision
500
   if -63<=reg<-31 this means a float point register double precision
471
   */
501
   */
472
void keepreg PROTO_N ((e,reg)) PROTO_T (exp e X int reg)
502
void keepreg(exp e, int reg)
473
{
503
{
474
  freg fr;
504
  freg fr;
475
  int z = absval(reg);
505
  int z = absval(reg);
476
 
506
 
477
  if (z >= FR_OFFSET)
507
  if (z >= FR_OFFSET)
478
  {
508
  {
479
    /* It is a float register */
509
    /* It is a float register */
480
    /* HACK: if reg <0 then it is double 
510
    /* HACK: if reg <0 then it is double
481
       otherwise it is single precision */
511
       otherwise it is single precision */
482
    fr.dble = (reg < 0);
512
    fr.dble = (reg < 0);
483
    fr.fr = z - FR_OFFSET;
513
    fr.fr = z - FR_OFFSET;
484
    setfregalt(regexps[z].inans, fr);
514
    setfregalt(regexps[z].inans, fr);
485
  }
515
  }
486
  else
516
  else
487
  {
517
  {
488
    instore is;
518
    instore is;
489
    if (IS_R_TMP(z))
519
    if (IS_R_TMP(z))
490
    {
520
    {
Line 494... Line 524...
494
    is.b.base = reg;
524
    is.b.base = reg;
495
    is.b.offset = 0;
525
    is.b.offset = 0;
496
    is.adval = 1;
526
    is.adval = 1;
497
    setinsalt(regexps[z].inans, is);
527
    setinsalt(regexps[z].inans, is);
498
  }
528
  }
499
  
529
 
500
  ASSERT(z >= 0 && z <= LAST_ALL_REGS);
530
  ASSERT(z >= 0 && z <= LAST_ALL_REGS);
501
  regexps[z].keptexp = e;
531
  regexps[z].keptexp = e;
502
  regexps[z].iscont = 0;
532
  regexps[z].iscont = 0;
503
  COMMENT3("keepreg : reg %d kept name is %d no %d",z,name(e),no(e));
533
  COMMENT3("keepreg : reg %d kept name is %d no %d",z,name(e),no(e));
504
}
534
}
505
 
535
 
506
bool couldeffect PROTO_S ((exp , exp ));
536
bool couldeffect(exp , exp);
507
 
537
 
508
/* could 'e' be 'lhs' */
538
/* could 'e' be 'lhs' */
509
bool couldbe PROTO_N ((e,lhs)) PROTO_T (exp e X exp lhs )/* is var name_tag exp or 0 meaning cont */
539
bool couldbe PROTO_N ((e,lhs)) PROTO_T (exp e X exp lhs )/* is var name_tag exp or 0 meaning cont */
510
{
540
{
511
  int ne = name(e);
541
  int ne = name(e);
Line 517... Line 547...
517
    {
547
    {
518
      return 1;
548
      return 1;
519
    }
549
    }
520
    if (isvar(s))
550
    if (isvar(s))
521
    {
551
    {
522
      return (lhs == 0 && ( isglob(s) || isvis(s) ) );
552
      return(lhs == 0 && (isglob(s) || isvis(s)));
523
    }
553
    }
524
    if (IS_A_PROC(s))
554
    if (IS_A_PROC(s))
525
      return (lhs == 0);
555
      return(lhs == 0);
526
    if (son(s) == nilexp)
556
    if (son(s) == nilexp)
527
      return 1;
557
      return 1;
528
    return couldbe(son(s), lhs);
558
    return couldbe(son(s), lhs);
529
  }
559
  }
530
  if (ne == cont_tag)
560
  if (ne == cont_tag)
531
  {
561
  {
532
    if (lhs != 0 && name(s) == name_tag && son(s) != nilexp)
562
    if (lhs != 0 && name(s) == name_tag && son(s)!= nilexp)
533
    {
563
    {
534
      return (son(s) == son(lhs) || isvis(son(lhs)) || isvis(son(s)));
564
      return(son(s) == son(lhs) || isvis(son(lhs)) || isvis(son(s)));
535
    }
565
    }
536
    return 1;
566
    return 1;
537
  }
567
  }
538
  if (ne == reff_tag || ne == field_tag)
568
  if (ne == reff_tag || ne == field_tag)
539
  {
569
  {
540
    return couldbe(s, lhs);
570
    return couldbe(s, lhs);
541
  }
571
  }
542
  if (ne == addptr_tag || ne == subptr_tag)
572
  if (ne == addptr_tag || ne == subptr_tag)
543
  {
573
  {
544
    return (couldbe(s, lhs) || couldeffect(bro(s), lhs));
574
    return(couldbe(s, lhs) || couldeffect(bro(s), lhs));
545
  }
575
  }
546
 
576
 
547
  return 1;
577
  return 1;
548
 
578
 
549
}
579
}
550
 
580
 
551
 
581
 
552
/* could alteration to z effect e? */
582
/* could alteration to z effect e? */
553
bool couldeffect PROTO_N ((e,z)) PROTO_T (exp e X exp z )/* a name or zero */ 
583
bool couldeffect PROTO_N ((e,z)) PROTO_T (exp e X exp z )/* a name or zero */
554
{
584
{
555
  int ne = name(e);
585
  int ne = name(e);
556
 
586
 
557
  if (ne == cont_tag)
587
  if (ne == cont_tag)
558
  {
588
  {
559
    return couldbe(son(e), z);
589
    return couldbe(son(e), z);
560
  }
590
  }
561
  if (ne == name_tag)
591
  if (ne == name_tag)
562
  {
592
  {
563
    if (isvar(son(e)))
593
    if (isvar(son(e)))
564
      return (z == 0 && isvis(son(e)));
594
      return(z == 0 && isvis(son(e)));
565
    if (IS_A_PROC(son(e)))
595
    if (IS_A_PROC(son(e)))
566
      return 0;
596
      return 0;
567
    if (son(son(e)) == nilexp)
597
    if (son(son(e)) == nilexp)
568
      return 1 /* could it happen? */ ;
598
      return 1 /* could it happen? */ ;
569
 
599
 
Line 586... Line 616...
586
  return 0;
616
  return 0;
587
}
617
}
588
 
618
 
589
 
619
 
590
/* does e depend on z */
620
/* does e depend on z */
591
bool dependson PROTO_N ((e,isc,z)) PROTO_T (exp e X bool isc X exp z)
621
bool dependson(exp e, bool isc, exp z)
592
{
622
{
593
  if (e == nilexp)
623
  if (e == nilexp)
594
  {
624
  {
595
    return 0;
625
    return 0;
596
  }
626
  }
Line 600... Line 630...
600
	name(z) == subptr_tag)
630
	name(z) == subptr_tag)
601
    {
631
    {
602
      z = son(z);
632
      z = son(z);
603
    }
633
    }
604
 
634
 
605
    if (name(z) != name_tag)
635
    if (name(z)!= name_tag)
606
    {
636
    {
607
      if (name(z) != cont_tag)
637
      if (name(z)!= cont_tag)
608
	return 1;
638
	return 1;
609
      z = 0;
639
      z = 0;
610
      break;
640
      break;
611
    }
641
    }
612
 
642
 
Line 622... Line 652...
622
    z = son(son(z));
652
    z = son(son(z));
623
  }
653
  }
624
 
654
 
625
  /* z is now unambiguous variable name or 0 meaning some contents */
655
  /* z is now unambiguous variable name or 0 meaning some contents */
626
 
656
 
627
  return ((isc) ? couldbe(e, z) : couldeffect(e, z));
657
  return((isc)? couldbe(e, z): couldeffect(e, z));
628
}
658
}
629
 
659
 
630
 
660
 
631
/* remove association of any register which depends on lhs */
661
/* remove association of any register which depends on lhs */
632
void clear_dep_reg PROTO_N ((lhs)) PROTO_T (exp lhs)
662
void clear_dep_reg(exp lhs)
633
{
663
{
634
  int i;
664
  int i;
635
 
665
 
636
  for (i = 0; i <= LAST_ALL_REGS; i++)
666
  for (i = 0; i <= LAST_ALL_REGS; i++)
637
  {
667
  {
638
    if (regexps[i].keptexp != nilexp)
668
    if (regexps[i].keptexp != nilexp)
639
    {
669
    {
640
      switch(name(regexps[i].keptexp))
670
      switch (name(regexps[i].keptexp))
641
      {
671
      {
642
      case val_tag:
672
      case val_tag:
643
      case null_tag:
673
      case null_tag:
644
      case real_tag:
674
      case real_tag:
645
      case string_tag:
675
      case string_tag: