Subversion Repositories tendra.SVN

Rev

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

Rev 5 Rev 6
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
/*
61
/*
32
$Log: locate.c,v $
62
$Log: locate.c,v $
33
 * Revision 1.1.1.1  1998/01/17  15:56:03  release
63
 * Revision 1.1.1.1  1998/01/17  15:56:03  release
34
 * First version to be checked into rolling release.
64
 * First version to be checked into rolling release.
35
 *
65
 *
Line 48... Line 78...
48
 * Preperation for August 25 Glue release
78
 * Preperation for August 25 Glue release
49
 *
79
 *
50
 * Revision 3.4  1995/08/25  09:48:02  wfs
80
 * Revision 3.4  1995/08/25  09:48:02  wfs
51
 * register synonyms changed. additional cases in "boff" to deal
81
 * register synonyms changed. additional cases in "boff" to deal
52
 * with the offsets of callees
82
 * with the offsets of callees
53
 *
83
 *
54
 * Revision 3.4  1995/08/25  09:48:02  wfs
84
 * Revision 3.4  1995/08/25  09:48:02  wfs
55
 * register synonyms changed. additional cases in "boff" to deal
85
 * register synonyms changed. additional cases in "boff" to deal
56
 * with the offsets of callees
86
 * with the offsets of callees
57
 *
87
 *
58
 * Revision 3.1  95/04/10  16:27:08  16:27:08  wfs (William Simmonds)
88
 * Revision 3.1  95/04/10  16:27:08  16:27:08  wfs (William Simmonds)
59
 * Apr95 tape version.
89
 * Apr95 tape version.
60
 * 
90
 *
61
 * Revision 3.0  95/03/30  11:18:03  11:18:03  wfs (William Simmonds)
91
 * Revision 3.0  95/03/30  11:18:03  11:18:03  wfs (William Simmonds)
62
 * Mar95 tape version with CRCR95_178 bug fix.
92
 * Mar95 tape version with CRCR95_178 bug fix.
63
 * 
93
 *
64
 * Revision 2.0  95/03/15  15:27:51  15:27:51  wfs (William Simmonds)
94
 * Revision 2.0  95/03/15  15:27:51  15:27:51  wfs (William Simmonds)
65
 * spec 3.1 changes implemented, tests outstanding.
95
 * spec 3.1 changes implemented, tests outstanding.
66
 * 
96
 *
67
 * Revision 1.2  95/01/17  17:26:13  17:26:13  wfs (William Simmonds)
97
 * Revision 1.2  95/01/17  17:26:13  17:26:13  wfs (William Simmonds)
68
 * Changed name of an included header file
98
 * Changed name of an included header file
69
 * 
99
 *
70
 * Revision 1.1  95/01/11  13:11:08  13:11:08  wfs (William Simmonds)
100
 * Revision 1.1  95/01/11  13:11:08  13:11:08  wfs (William Simmonds)
71
 * Initial revision
101
 * Initial revision
72
 * 
102
 *
73
*/
103
*/
74
 
104
 
75
 
105
 
76
#define HPPATRANS_CODE
106
#define HPPATRANS_CODE
77
/* locate.c
107
/* locate.c
Line 107... Line 137...
107
 
137
 
108
#include "locate.h"
138
#include "locate.h"
109
 
139
 
110
 
140
 
111
/* decodes x to give a baseoff suitable for xxxx_ins functions */
141
/* decodes x to give a baseoff suitable for xxxx_ins functions */
112
baseoff boff 
142
baseoff boff
113
    PROTO_N ( ( e ) )
-
 
114
    PROTO_T ( exp e )
143
(exp e)
115
{
144
{
116
 
145
 
117
  int n = no(e);
146
  int n = no(e);
118
  int b = n & 0x3f;
147
  int b = n & 0x3f;
119
  baseoff an;
148
  baseoff an;
Line 121... Line 150...
121
  if (isglob(e))
150
  if (isglob(e))
122
  {
151
  {
123
    /* bro() is index in main_globals */
152
    /* bro() is index in main_globals */
124
    dec *gl = brog(e);
153
    dec *gl = brog(e);
125
    long sno = gl->dec_u.dec_val.sym_number;
154
    long sno = gl->dec_u.dec_val.sym_number;
126
    an.base = -(sno + 1);
155
    an.base = - (sno + 1);
127
    an.offset = 0;
156
    an.offset = 0;
128
  }
157
  }
129
  else if (name(son(e))==caller_name_tag)
158
  else if (name(son(e)) ==caller_name_tag)
130
  {
159
  {
131
     int n = no(e);
160
     int n = no(e);
132
     an.base = SP;
161
     an.base = SP;
133
     an.offset = -(n>>3);
162
     an.offset = - (n>>3);
134
  }
163
  }
135
  else if (isparam(e))
164
  else if (isparam(e))
136
  {
165
  {
137
     /* parameter */
166
     /* parameter */
138
     assert(name(son(e)) == clear_tag);
167
     assert(name(son(e)) == clear_tag);
Line 142... Line 171...
142
     }
171
     }
143
     else
172
     else
144
     {
173
     {
145
	an.base = EP;
174
	an.base = EP;
146
     }
175
     }
147
     if (name(son(e))==formal_callee_tag)
176
     if (name(son(e)) ==formal_callee_tag)
148
     {
177
     {
149
	an.offset=(no(son(e))-callees_offset)>>3;/* outermost ()'s for gcc */
178
	an.offset=(no(son(e))-callees_offset)>>3;/* outermost ()'s for gcc */
150
     }
179
     }
151
     else
180
     else
152
     {
181
     {
Line 154... Line 183...
154
     }
183
     }
155
  }
184
  }
156
  else if (b == GR17)
185
  else if (b == GR17)
157
  {
186
  {
158
     /* locally declared */
187
     /* locally declared */
159
     an.base = EP; 
188
     an.base = EP;
160
     an.offset = ((n-b)>>4)-(locals_offset>>3); 
189
     an.offset = ((n-b) >>4) - (locals_offset>>3);
161
  }
190
  }
162
  else if (b == EP)
191
  else if (b == EP)
163
  {
192
  {
164
    /* on stack temps (should not happen) */
193
    /* on stack temps (should not happen) */
165
    an.base = EP;
194
    an.base = EP;
Line 174... Line 203...
174
#if 1
203
#if 1
175
  /* +++ obsolete */
204
  /* +++ obsolete */
176
  else if (b == 32)
205
  else if (b == 32)
177
  {
206
  {
178
    /* global names */
207
    /* global names */
179
    an.base = -((n - b) >> 6);
208
    an.base = - ((n - b) >> 6);
180
    an.offset = 0;
209
    an.offset = 0;
181
  }
210
  }
182
  else if (b == 33)
211
  else if (b == 33)
183
  {
212
  {
184
    /* local data label: LDNNNN */
213
    /* local data label: LDNNNN */
Line 198... Line 227...
198
 
227
 
199
 /*
228
 /*
200
  * locate differs from locate1 only in that it looks to see e has already
229
  * locate differs from locate1 only in that it looks to see e has already
201
  * been evaluated somehow
230
  * been evaluated somehow
202
  */
231
  */
203
where locate PROTO_S ( ( exp, space, shape, int ) ) ;
232
where locate(exp, space, shape, int);
204
 
233
 
205
 
234
 
206
 /*
235
 /*
207
  * finds the address of e using shape s; sp gives available t-regs for any
236
  * finds the address of e using shape s; sp gives available t-regs for any
208
  * inner evaluation. dreg is historical.
237
  * inner evaluation. dreg is historical.
209
  */
238
  */
210
where locate1 
239
where locate1
211
    PROTO_N ( ( e, sp, s, dreg ) )
-
 
212
    PROTO_T ( exp e X space sp X shape s X int dreg )
240
(exp e, space sp, shape s, int dreg)
213
{
241
{
214
  ash a;
242
  ash a;
215
  ans aa;
243
  ans aa;
216
  where wans;
244
  where wans;
217
#if 0				/* causes core dump spec/espresso/set.c */
245
#if 0				/* causes core dump spec/espresso/set.c */
218
  FULLCOMMENT3("locate1: %s, %s, dreg=%d", (int)tag_name(name(e)), (int)sh_name(name(s)), dreg);
246
  FULLCOMMENT3("locate1: %s, %s, dreg=%d",(int)tag_name(name(e)), (int)sh_name(name(s)), dreg);
219
  FULLCOMMENT4("        space=(%ld,%ld) no(e)=%d no(son(e))=%d", sp.fixed, sp.flt, no(e), no(son(e)));
247
  FULLCOMMENT4("        space= (%ld,%ld) no(e) =%d no(son(e)) =%d", sp.fixed, sp.flt, no(e), no(son(e)));
220
#endif
248
#endif
221
  
249
 
222
  a = ashof(s);
250
  a = ashof(s);
223
 
251
 
224
/*
252
/*
225
  while (name(e) == diag_tag || name(e) == fscope_tag || name(e) == cscope_tag)
253
  while (name(e) == diag_tag || name(e) == fscope_tag || name(e) == cscope_tag)
226
  {
254
  {
227
    e = son(e);
255
    e = son(e);
228
  }
256
  }
229
*/
257
*/
230
  switch (name(e))
258
  switch (name(e))
231
  {
259
  {
Line 235... Line 263...
235
      bool var = isvar(dc);
263
      bool var = isvar(dc);
236
 
264
 
237
      /* this a locally declared name ... */
265
      /* this a locally declared name ... */
238
      if (props(dc) & defer_bit)
266
      if (props(dc) & defer_bit)
239
      {
267
      {
240
	
268
 
241
	/*
269
	/*
242
	 * ... it has been identified with a simple expression which is better
270
	 * ... it has been identified with a simple expression which is better
243
	 * evaluated every time
271
	 * evaluated every time
244
	 */
272
	 */
245
	where w;
273
	where w;
Line 254... Line 282...
254
	}
282
	}
255
	else
283
	else
256
	{
284
	{
257
	  instore is;
285
	  instore is;
258
 
286
 
259
	  switch ( discrim ( w.answhere ) )
287
	  switch (discrim(w.answhere))
260
	  {
288
	  {
261
	  case notinreg:
289
	  case notinreg:
262
	    {
290
	    {
263
	      is = insalt(w.answhere);
291
	      is = insalt(w.answhere);
264
	      is.b.offset += (no(e) / 8);
292
	      is.b.offset += (no(e) / 8);
Line 273... Line 301...
273
      }
301
      }
274
      else if (props(dc) & inreg_bits)
302
      else if (props(dc) & inreg_bits)
275
      {
303
      {
276
	/* ... it has been allocated in a fixed point reg */
304
	/* ... it has been allocated in a fixed point reg */
277
 
305
 
278
	FULLCOMMENT1("locate1: name_tag: fixed point reg%s", (int) (var?" var":""));
306
	FULLCOMMENT1("locate1: name_tag: fixed point reg%s",(int)(var?" var":""));
279
 
307
 
280
	if (var)
308
	if (var)
281
	{
309
	{
282
	  setregalt(aa, no(dc));
310
	  setregalt(aa, no(dc));
283
	}
311
	}
Line 298... Line 326...
298
	freg fr;
326
	freg fr;
299
 
327
 
300
	FULLCOMMENT("locate1: name_tag: fixed point reg");
328
	FULLCOMMENT("locate1: name_tag: fixed point reg");
301
 
329
 
302
	fr.fr = no(dc);
330
	fr.fr = no(dc);
303
	fr.dble = ( a.ashsize==64 ? 1 : 0 );
331
	fr.dble = (a.ashsize==64 ? 1 : 0);
304
	setfregalt(aa, fr);
332
	setfregalt(aa, fr);
305
      }
333
      }
306
      else
334
      else
307
      {
335
      {
308
	/* ... it is in memory */
336
	/* ... it is in memory */
309
	instore is;
337
	instore is;
310
 
338
 
311
	if ( var || (name(sh(e)) == prokhd &&
339
	if (var || (name(sh(e)) == prokhd &&
312
		    (son(dc) == nilexp || IS_A_PROC(son(dc)) )))
340
		   (son(dc) == nilexp || IS_A_PROC(son(dc)))))
313
	{
341
	{
314
	  is.adval = 1;
342
	  is.adval = 1;
315
	}
343
	}
316
	else
344
	else
317
	{
345
	{
318
	  is.adval = 0;
346
	  is.adval = 0;
319
	}
347
	}
320
	is.b = boff(dc);
348
	is.b = boff(dc);
321
#if USE_BITAD
349
#if USE_BITAD
322
	if (a.ashalign == 1 && (var || name(sh(e)) != ptrhd))
350
	if (a.ashalign == 1 && (var || name(sh(e))!= ptrhd))
323
	  /* some bit field */
351
	  /* some bit field */
324
	{
352
	{
325
	  is.b.offset = (is.b.offset << 3) + no(e);
353
	  is.b.offset = (is.b.offset << 3) + no(e);
326
	  setbitadalt(aa, is);
354
	  setbitadalt(aa, is);
327
	}
355
	}
Line 355... Line 383...
355
      /*
383
      /*
356
       * answer is going to be wsum displaced by integer result of evaluating
384
       * answer is going to be wsum displaced by integer result of evaluating
357
       * bro(sum)
385
       * bro(sum)
358
       */
386
       */
359
 
387
 
360
      switch (discrim ( asum ) )
388
      switch (discrim(asum))
361
      {
389
      {
362
      case notinreg:
390
      case notinreg:
363
	{
391
	{
364
	  is = insalt(asum);
392
	  is = insalt(asum);
365
	  if (is.adval)
393
	  if (is.adval)
Line 381... Line 409...
381
	    }
409
	    }
382
 
410
 
383
	    nsp = guardreg(b.base, sp);
411
	    nsp = guardreg(b.base, sp);
384
 
412
 
385
	    shift=no(bro(son(bro(sum))));
413
	    shift=no(bro(son(bro(sum))));
386
	    if ( name(bro(sum))==offset_mult_tag && name(bro(son(bro(sum))))==val_tag && ( shift==0 || shift==2 || shift==4 ) )
414
	    if (name(bro(sum)) ==offset_mult_tag && name(bro(son(bro(sum)))) ==val_tag && (shift==0 || shift==2 || shift==4))
387
	    {
415
	    {
388
	       addend=reg_operand(son(bro(sum)),nsp);
416
	       addend=reg_operand(son(bro(sum)),nsp);
389
	       if (dreg == 0)
417
	       if (dreg == 0)
390
		  dreg = getreg(nsp.fixed);
418
		  dreg = getreg(nsp.fixed);
391
	       rrr_ins(shift==0 ? i_add : (shift==2 ? i_sh1add : i_sh2add),                           c_,addend,b.base,dreg);
419
	       rrr_ins(shift==0 ? i_add :(shift==2 ? i_sh1add : i_sh2add),                           c_,addend,b.base,dreg);
392
	    }
420
	    }
393
	    else
421
	    else
394
	    {
422
	    {
395
	       addend = reg_operand(bro(sum), nsp);
423
	       addend = reg_operand(bro(sum), nsp);
396
	       /* evaluate the displacement ... */
424
	       /* evaluate the displacement ... */
Line 441... Line 469...
441
      if (name(bro(sum)) == env_offset_tag ||
469
      if (name(bro(sum)) == env_offset_tag ||
442
	  name(bro(sum)) == general_env_offset_tag)
470
	  name(bro(sum)) == general_env_offset_tag)
443
      {
471
      {
444
	  is.b.base = ind;
472
	  is.b.base = ind;
445
	  is.b.offset = frame_offset(son(bro(sum)));
473
	  is.b.offset = frame_offset(son(bro(sum)));
446
      } 
474
      }
447
      else
475
      else
448
      {
476
      {
449
	 shift=no(bro(son(bro(sum))));
477
	 shift=no(bro(son(bro(sum))));
450
	 if ( name(bro(sum))==offset_mult_tag && name(bro(son(bro(sum))))==val_tag && ( shift==0 || shift==2 || shift==4 ) )
478
	 if (name(bro(sum)) ==offset_mult_tag && name(bro(son(bro(sum)))) ==val_tag && (shift==0 || shift==2 || shift==4))
451
	 {
479
	 {
452
	    addend=reg_operand(son(bro(sum)),nsp);
480
	    addend=reg_operand(son(bro(sum)),nsp);
453
	    if (dreg == 0)
481
	    if (dreg == 0)
454
	       dreg = getreg(nsp.fixed);
482
	       dreg = getreg(nsp.fixed);
455
	    rrr_ins(shift==0 ? i_add : (shift==2 ? i_sh1add : i_sh2add),                           c_,addend,ind,dreg);
483
	    rrr_ins(shift==0 ? i_add :(shift==2 ? i_sh1add : i_sh2add),                           c_,addend,ind,dreg);
456
	 }
484
	 }
457
	 else
485
	 else
458
	 {
486
	 {
459
	    addend = reg_operand(bro(sum), nsp);
487
	    addend = reg_operand(bro(sum), nsp);
460
 
488
 
461
	    if (dreg == 0)
489
	    if (dreg == 0)
Line 465... Line 493...
465
	 is.b.base = dreg;
493
	 is.b.base = dreg;
466
	 is.b.offset = 0;
494
	 is.b.offset = 0;
467
      }
495
      }
468
      is.adval = 1;
496
      is.adval = 1;
469
      setinsalt(aa, is);
497
      setinsalt(aa, is);
470
      wans.answhere = aa;
498
      wans.answhere = aa;
471
      wans.ashwhere = a;
499
      wans.ashwhere = a;
472
      /* ... and deliver literal base_offset */
500
      /* ... and deliver literal base_offset */
473
      keepexp(e, aa);
501
      keepexp(e, aa);
474
      return wans;
502
      return wans;
475
    }				/* end add_ptr */
503
    }				/* end add_ptr */
476
 
504
 
Line 482... Line 510...
482
      instore isa;
510
      instore isa;
483
 
511
 
484
      isa.adval = 1;
512
      isa.adval = 1;
485
      sum = bro(sum);
513
      sum = bro(sum);
486
      if (name(sum) == val_tag)
514
      if (name(sum) == val_tag)
487
      {
515
      {
488
	instore isa;
516
	instore isa;
489
 
517
 
490
	isa.b.base = ind;
518
	isa.b.base = ind;
491
	isa.b.offset = -no(e);
519
	isa.b.offset = -no(e);
492
	setinsalt(aa, isa);
520
	setinsalt(aa, isa);
493
      }
521
      }
494
      else
522
      else
495
      {
523
      {
496
	if (dreg == 0)
524
	if (dreg == 0)
497
	   dreg = getreg(sp.fixed);
525
	   dreg = getreg(sp.fixed);
498
	rrr_ins(i_sub,c_,ind,reg_operand(sum,guardreg(ind,sp)),dreg);
526
	rrr_ins(i_sub,c_,ind,reg_operand(sum,guardreg(ind,sp)),dreg);
499
	isa.b.base = dreg;
527
	isa.b.base = dreg;
500
	isa.b.offset = 0;
528
	isa.b.offset = 0;
Line 517... Line 545...
517
      wans = locate(son(e), sp, sh(son(e)), 0);
545
      wans = locate(son(e), sp, sh(son(e)), 0);
518
 
546
 
519
#if USE_BITAD
547
#if USE_BITAD
520
      bitfield = ((name(sh(e)) == ptrhd) && (al1(sh(e)) == 1));
548
      bitfield = ((name(sh(e)) == ptrhd) && (al1(sh(e)) == 1));
521
#endif
549
#endif
522
      switch ( discrim ( wans.answhere ) )
550
      switch (discrim(wans.answhere))
523
      {
551
      {
524
      case notinreg:
552
      case notinreg:
525
	{
553
	{
526
	  isa = insalt(wans.answhere);
554
	  isa = insalt(wans.answhere);
527
	  if (!isa.adval)
555
	  if (!isa.adval)
Line 535... Line 563...
535
 
563
 
536
	    ld_ins(i_lw,0,isa.b,reg);
564
	    ld_ins(i_lw,0,isa.b,reg);
537
	    isa.b.offset = 0;
565
	    isa.b.offset = 0;
538
	    isa.b.base = reg;
566
	    isa.b.base = reg;
539
	    isa.adval = 1;
567
	    isa.adval = 1;
540
	  }
568
	  }
541
 
569
 
542
	  /*  ... and add appropriate displacement to give result  */
570
	  /*  ... and add appropriate displacement to give result  */
543
 
571
 
544
#if USE_BITAD
572
#if USE_BITAD
545
	  if (bitfield)
573
	  if (bitfield)
546
	  {
574
	  {
547
	    isa.b.offset <<= 3;
575
	    isa.b.offset <<= 3;
548
	    isa.b.offset += no(e);
576
	    isa.b.offset += no(e);
549
	    setbitadalt(wans.answhere, isa);
577
	    setbitadalt(wans.answhere, isa);
550
	  }
578
	  }
551
	  else
579
	  else
552
#endif
580
#endif
553
	  {
581
	  {
554
	    isa.b.offset += no(e) / 8;
582
	    isa.b.offset += no(e) / 8;
555
	    setinsalt(wans.answhere, isa);
583
	    setinsalt(wans.answhere, isa);
556
	    keepexp(e, wans.answhere);
584
	    keepexp(e, wans.answhere);
557
	  }
585
	  }
558
       	  break ;
586
       	  break;
559
	}
587
	}
560
#if USE_BITAD
588
#if USE_BITAD
561
      case bitad:
589
      case bitad:
562
	{
590
	{
563
	  isa = bitadalt(wans.answhere);
591
	  isa = bitadalt(wans.answhere);
Line 566... Line 594...
566
	    fail("no var bit selection");
594
	    fail("no var bit selection");
567
	  }
595
	  }
568
	  /* wans is a literal bit address */
596
	  /* wans is a literal bit address */
569
	  isa.b.offset += no(e);
597
	  isa.b.offset += no(e);
570
	  setbitadalt(wans.answhere, isa);
598
	  setbitadalt(wans.answhere, isa);
571
	  break;
599
	  break;
572
	}
600
	}
573
#endif
601
#endif
574
      case inreg:
602
      case inreg:
575
	{
603
	{
576
	  /* wans is a pointer in a register */
604
	  /* wans is a pointer in a register */
577
	  isa.b.base = regalt(wans.answhere);
605
	  isa.b.base = regalt(wans.answhere);
578
	  isa.adval = 1;
606
	  isa.adval = 1;
579
#if USE_BITAD
607
#if USE_BITAD
580
	  if (bitfield)
608
	  if (bitfield)
581
	  {
609
	  {
582
	    isa.b.offset = no(e);
610
	    isa.b.offset = no(e);
583
	    setbitadalt(wans.answhere, isa);
611
	    setbitadalt(wans.answhere, isa);
584
	  }
612
	  }
585
	  else
613
	  else
586
#endif
614
#endif
Line 613... Line 641...
613
 
641
 
614
      /*
642
      /*
615
       * answer is going to be the contents of address represented by fc
643
       * answer is going to be the contents of address represented by fc
616
       */
644
       */
617
 
645
 
618
      FULLCOMMENT1("locate1: cont[vol]_tag: %s", (int)ANSDISCRIM_NAME( discrim ( ason ) ));
646
      FULLCOMMENT1("locate1: cont[vol]_tag: %s",(int)ANSDISCRIM_NAME(discrim(ason)));
619
      
647
 
620
      switch ( discrim ( ason ) )
648
      switch (discrim(ason))
621
      {
649
      {
622
      case notinreg:
650
      case notinreg:
623
	{
651
	{
624
	  isa = insalt(ason);
652
	  isa = insalt(ason);
625
	  if (isa.adval)
653
	  if (isa.adval)
Line 640... Line 668...
640
	    reg = getreg(sp.fixed);
668
	    reg = getreg(sp.fixed);
641
	    ld_ins(i_lw,1,isa.b,reg);
669
	    ld_ins(i_lw,1,isa.b,reg);
642
	    isa.b.base = reg;
670
	    isa.b.base = reg;
643
	    isa.b.offset = 0;
671
	    isa.b.offset = 0;
644
	    setinsalt(aa, isa);
672
	    setinsalt(aa, isa);
645
	    if (name(e) != contvol_tag && fc.ashwhere.ashalign != 1)
673
	    if (name(e)!= contvol_tag && fc.ashwhere.ashalign != 1)
646
	      keepexp(e, aa);
674
	      keepexp(e, aa);
647
	  }
675
	  }
648
#if USE_BITAD
676
#if USE_BITAD
649
	  if (fc.ashwhere.ashalign == 1)	/* ... adjust for bit contents */
677
	  if (fc.ashwhere.ashalign == 1)	/* ... adjust for bit contents */
650
	  {
678
	  {
Line 729... Line 757...
729
      /*
757
      /*
730
       * answer is wans displace literally by no(e); it should always be a
758
       * answer is wans displace literally by no(e); it should always be a
731
       * literal store address
759
       * literal store address
732
       */
760
       */
733
 
761
 
734
      switch ( discrim ( wans.answhere ) )
762
      switch (discrim(wans.answhere))
735
      {
763
      {
736
      case notinreg:
764
      case notinreg:
737
	{
765
	{
738
	  isa = insalt(wans.answhere);
766
	  isa = insalt(wans.answhere);
739
#if USE_BITAD
767
#if USE_BITAD
Line 791... Line 819...
791
      return wans;
819
      return wans;
792
    }
820
    }
793
  }
821
  }
794
}
822
}
795
 
823
 
796
where locate 
824
where locate
797
    PROTO_N ( ( e, sp, s, dreg ) )
-
 
798
    PROTO_T ( exp e X space sp X shape s X int dreg )
825
(exp e, space sp, shape s, int dreg)
799
{
826
{
800
  ans ak;
827
  ans ak;
801
  where w;
828
  where w;
802
 
829
 
803
  ak = iskept(e);
830
  ak = iskept(e);
804
  if ( discrim ( ak ) == inreg && (regalt(ak) == 0))
831
  if (discrim(ak) == inreg && (regalt(ak) == 0))
805
  {
832
  {
806
    w = locate1(e, sp, s, dreg);
833
    w = locate1(e, sp, s, dreg);
807
  }
834
  }
808
  else
835
  else
809
  {
836
  {