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
Line 8... Line 38...
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.
13
 
43
 
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
*/
55
 
85
 
56
 
86
 
57
 
87
 
58
/**********************************************************************
88
/**********************************************************************
59
$Author: release $
89
$Author: release $
60
$Date: 1998/02/04 15:48:56 $
90
$Date: 1998/02/04 15:48:56 $
61
$Revision: 1.2 $
91
$Revision: 1.2 $
62
$Log: makecode.c,v $
92
$Log: makecode.c,v $
Line 117... Line 147...
117
where nowhere;	/* no particular destination, init in translat.c */
147
where nowhere;	/* no particular destination, init in translat.c */
118
 
148
 
119
/* Function declarations */
149
/* Function declarations */
120
void move_dlts PROTO_S ((int,int,int,int));/* Used by movecont_tag */
150
void move_dlts PROTO_S ((int,int,int,int));/* Used by movecont_tag */
121
void move_dgts PROTO_S ((int,int,int,int));/* Used by movecont_tag */
151
void move_dgts PROTO_S ((int,int,int,int));/* Used by movecont_tag */
122
int regfrmdest PROTO_S ((where *,space));
152
int regfrmdest(where *,space);
123
freg fregfrmdest PROTO_S ((bool,where *,space));
153
freg fregfrmdest(bool,where *,space);
124
 
154
 
125
static int get_next_mlv_number PROTO_S ((void));
155
static int get_next_mlv_number(void);
126
void adjust_to_size PROTO_S ((int,int,int,int,int));
156
void adjust_to_size(int,int,int,int,int);
127
 
157
 
128
 
158
 
129
 
159
 
130
/* branch table, branch code to instruction */
160
/* branch table, branch code to instruction */
131
 
161
 
Line 144... Line 174...
144
#define branches(i)	(branch_tab[i])
174
#define branches(i)	(branch_tab[i])
145
 
175
 
146
 
176
 
147
						    /*  1  2  3  4  5  6 */
177
						    /*  1  2  3  4  5  6 */
148
/* used to invert TDF tests */			    /* le lt ge gt ne eq */
178
/* used to invert TDF tests */			    /* le lt ge gt ne eq */
149
prop notbranch[] = 
179
prop notbranch[] =
150
{
180
{
151
  0,				/* NOT USED */
181
  0,				/* NOT USED */
152
  4,				/* opposite of le is gt */
182
  4,				/* opposite of le is gt */
153
  3,				/* opposite of lt is ge */
183
  3,				/* opposite of lt is ge */
154
  2,				/* opposite of ge is lt */
184
  2,				/* opposite of ge is lt */
Line 156... Line 186...
156
  6,				/* opposite of ne is eq */
186
  6,				/* opposite of ne is eq */
157
  5				/* opposite of eq is ne */
187
  5				/* opposite of eq is ne */
158
};
188
};
159
						    /*  1  2  3  4  5  6 */
189
						    /*  1  2  3  4  5  6 */
160
/* used to change TDF test when args commuted */    /* le lt ge gt ne eq */
190
/* used to change TDF test when args commuted */    /* le lt ge gt ne eq */
161
prop combranch[] = 
191
prop combranch[] =
162
{ 
192
{
163
  0,				/* NOT USED */
193
  0,				/* NOT USED */
164
  3,				/* reverse of le is ge */
194
  3,				/* reverse of le is ge */
165
  4,				/* reverse of lt is gt */
195
  4,				/* reverse of lt is gt */
166
  1,				/* reverse of ge is le */
196
  1,				/* reverse of ge is le */
167
  2,				/* reverse of gt is lt */
197
  2,				/* reverse of gt is lt */
168
  5,				/* reverse of ne is ne */
198
  5,				/* reverse of ne is ne */
169
  6				/* reverse of eq is eq */
199
  6				/* reverse of eq is eq */
170
};
200
};
171
 
201
 
172
 
202
 
173
static void testsigned PROTO_N ((r,lower,upper,lab)) PROTO_T (int r X long lower X long upper X long lab)
203
static void testsigned(int r, long lower, long upper, long lab)
174
{
204
{
175
  int creg1=next_creg();
205
  int creg1=next_creg();
176
  int creg2=next_creg();
206
  int creg2=next_creg();
177
  cmp_ri_ins(i_cmp,r,lower,creg1);
207
  cmp_ri_ins(i_cmp,r,lower,creg1);
178
  bc_ins(i_blt,creg1,lab,UNLIKELY_TO_JUMP);
208
  bc_ins(i_blt,creg1,lab,UNLIKELY_TO_JUMP);
179
  cmp_ri_ins(i_cmp,r,upper,creg2);
209
  cmp_ri_ins(i_cmp,r,upper,creg2);
180
  bc_ins(i_bgt,creg2,lab,UNLIKELY_TO_JUMP);
210
  bc_ins(i_bgt,creg2,lab,UNLIKELY_TO_JUMP);
181
  return;
211
  return;
182
}
212
}
183
static void testusigned PROTO_N ((r,maxval,lab)) PROTO_T (int r X long maxval X long lab)
213
static void testusigned(int r, long maxval, long lab)
184
{
214
{
185
  int creg=next_creg();
215
  int creg=next_creg();
186
  cmp_ri_ins(i_cmpl,r,maxval,creg);
216
  cmp_ri_ins(i_cmpl,r,maxval,creg);
187
  bc_ins(i_bgt,creg,lab,UNLIKELY_TO_JUMP);
217
  bc_ins(i_bgt,creg,lab,UNLIKELY_TO_JUMP);
188
  return;
218
  return;
189
}
219
}
190
 
220
 
191
 
221
 
192
/* find the last test in sequence e which is a branch to second, if any, otherwise nil */
222
/* find the last test in sequence e which is a branch to second, if any, otherwise nil */
193
static exp testlast PROTO_N ((e,second)) PROTO_T (exp e X exp second)
223
static exp testlast(exp e, exp second)
194
{
224
{
195
  if (name(e) == test_tag && pt(e) == second)
225
  if (name(e) == test_tag && pt(e) == second)
196
  {
226
  {
197
    return (e);
227
    return(e);
198
  }
228
  }
199
  if (name(e) == seq_tag)
229
  if (name(e) == seq_tag)
200
  {
230
  {
201
    
231
 
202
    if (name(bro(son(e))) == test_tag && pt(bro(son(e))) == second)
232
    if (name(bro(son(e))) == test_tag && pt(bro(son(e))) == second)
203
    {
233
    {
204
      /* is the last one of the sequence a test_tag pointing to second */
234
      /* is the last one of the sequence a test_tag pointing to second */
205
      return bro(son(e));
235
      return bro(son(e));
206
    }
236
    }
Line 233... Line 263...
233
 
263
 
234
 
264
 
235
 
265
 
236
/* Does e, or components of e contain a bitfield? */
266
/* Does e, or components of e contain a bitfield? */
237
/* +++ should detect this earlier and record in props(e) once-and-for-all */
267
/* +++ should detect this earlier and record in props(e) once-and-for-all */
238
static int has_bitfield PROTO_N ((e)) PROTO_T (exp e)
268
static int has_bitfield(exp e)
239
{
269
{
240
  if (e == nilexp)
270
  if (e == nilexp)
241
    return 0;
271
    return 0;
242
 
272
 
243
  switch (name(e))
273
  switch (name(e))
Line 265... Line 295...
265
      {
295
      {
266
	shape s = sh(e);
296
	shape s = sh(e);
267
 
297
 
268
	FULLCOMMENT4("has_bitfield: compound field sz=%d als=%d,%d,%d",
298
	FULLCOMMENT4("has_bitfield: compound field sz=%d als=%d,%d,%d",
269
		shape_size(s), shape_align(s), al1(s), al2(s));
299
		shape_size(s), shape_align(s), al1(s), al2(s));
270
	return shape_size(s) != 0 && (shape_align(s) == 1 || al1(s) == 1 || al2(s) == 1);
300
	return shape_size(s)!= 0 && (shape_align(s) == 1 || al1(s) == 1 || al2(s) == 1);
271
      }
301
      }
272
    }
302
    }
273
  }
303
  }
274
  /*NOTREACHED*/
304
  /*NOTREACHED*/
275
}
305
}
Line 279... Line 309...
279
 * the compound can be output correctly by eval().
309
 * the compound can be output correctly by eval().
280
 * Permanently undoes the needscan.c:scan() case val_tag:.
310
 * Permanently undoes the needscan.c:scan() case val_tag:.
281
 *
311
 *
282
 * NB must do this EXACTLY ONCE.
312
 * NB must do this EXACTLY ONCE.
283
 */
313
 */
284
static void fix_nonbitfield PROTO_N ((e)) PROTO_T (exp e)
314
static void fix_nonbitfield(exp e)
285
{
315
{
286
  if (name(e) == compound_tag)
316
  if (name(e) == compound_tag)
287
  {
317
  {
288
    e = son(e);
318
    e = son(e);
289
    while (1)
319
    while (1)
290
    {
320
    {
291
      if (name(e) == val_tag && name(sh(e)) == offsethd && al2(sh(e)) >= 8)
321
      if (name(e) == val_tag && name(sh(e)) == offsethd && al2(sh(e)) >= 8)
292
	  no(e) = no(e) << 3;	/* fix it */
322
	  no(e) = no(e) << 3;	/* fix it */
293
      
323
 
294
      fix_nonbitfield(bro(e));	/* recursively fix the rest of the struct */
324
      fix_nonbitfield(bro(e));	/* recursively fix the rest of the struct */
295
      
325
 
296
      if (last(bro(e)))
326
      if (last(bro(e)))
297
	  return;		/* all done */
327
	  return;		/* all done */
298
      
328
 
299
      e = bro(bro(e));		/* next offset */
329
      e = bro(bro(e));		/* next offset */
300
    }
330
    }
301
  }
331
  }
302
  /*NOTREACHED*/
332
  /*NOTREACHED*/
303
}
333
}
Line 314... Line 344...
314
 */
344
 */
315
 
345
 
316
/* params of bc_ins() */
346
/* params of bc_ins() */
317
typedef struct
347
typedef struct
318
{
348
{
319
  Instruction_P branch;	
349
  Instruction_P branch;
320
  int	creg;
350
  int	creg;
321
  int	lab;
351
  int	lab;
322
} bc_info;
352
} bc_info;
323
 
353
 
324
 
354
 
Line 329... Line 359...
329
static bc_info bqueue[NQUEUE];
359
static bc_info bqueue[NQUEUE];
330
 
360
 
331
static int bqueuepos;		/* next free slot in queue */
361
static int bqueuepos;		/* next free slot in queue */
332
 
362
 
333
 
363
 
334
static void clear_branch_queue PROTO_Z ()
364
static void clear_branch_queue(void)
335
{
365
{
336
  int i;
366
  int i;
337
 
367
 
338
  bqueuepos = 0;
368
  bqueuepos = 0;
339
 
369
 
Line 343... Line 373...
343
    bqueue[i].creg = -1;
373
    bqueue[i].creg = -1;
344
  }
374
  }
345
}
375
}
346
 
376
 
347
 
377
 
348
static void issue_bc_ins PROTO_N ((i)) PROTO_T (int i)
378
static void issue_bc_ins(int i)
349
{
379
{
350
  ASSERT(i >= 0 && i < NQUEUE);
380
  ASSERT(i >= 0 && i < NQUEUE);
351
  bc_ins(bqueue[i].branch, bqueue[i].creg, bqueue[i].lab,LIKELY_TO_JUMP);
381
  bc_ins(bqueue[i].branch, bqueue[i].creg, bqueue[i].lab,LIKELY_TO_JUMP);
352
}
382
}
353
 
383
 
354
 
384
 
355
static void queue_bc_ins PROTO_N ((ins,creg,lab)) PROTO_T (Instruction_P ins X int creg X int lab)
385
static void queue_bc_ins(Instruction_P ins, int creg, int lab)
356
{
386
{
357
  int i;
387
  int i;
358
 
388
 
359
  COMMENT2("queue_bc_ins(%s,%d,lab)", (int)ins, creg);
389
  COMMENT2("queue_bc_ins(%s,%d,lab)",(int)ins, creg);
360
 
390
 
361
#ifdef DO_ASSERT
391
#ifdef DO_ASSERT
362
  /* check there is not a queued instruction using same creg (now corrupted) */
392
  /* check there is not a queued instruction using same creg (now corrupted) */
363
  for (i = 0; i < NQUEUE; i++)
393
  for (i = 0; i < NQUEUE; i++)
364
    ASSERT(bqueue[i].creg != creg);
394
    ASSERT(bqueue[i].creg != creg);
Line 369... Line 399...
369
  ASSERT(i >= 0 && i < NQUEUE);
399
  ASSERT(i >= 0 && i < NQUEUE);
370
 
400
 
371
  /* if queue full, clear one entry */
401
  /* if queue full, clear one entry */
372
  if (bqueue[i].branch != I_NIL)
402
  if (bqueue[i].branch != I_NIL)
373
    issue_bc_ins(i);
403
    issue_bc_ins(i);
374
 
404
 
375
  bqueue[i].branch = ins;
405
  bqueue[i].branch = ins;
376
  bqueue[i].creg = creg;
406
  bqueue[i].creg = creg;
377
  bqueue[i].lab = lab;
407
  bqueue[i].lab = lab;
378
 
408
 
379
  bqueuepos++;
409
  bqueuepos++;
380
  if (bqueuepos == NQUEUE)
410
  if (bqueuepos == NQUEUE)
381
    bqueuepos = 0;		/* roll around to zero */
411
    bqueuepos = 0;		/* roll around to zero */
382
}
412
}
383
 
413
 
384
static void flush_branch_queue PROTO_Z ()
414
static void flush_branch_queue(void)
385
{
415
{
386
  int i;
416
  int i;
387
 
417
 
388
  i = bqueuepos;
418
  i = bqueuepos;
389
 
419
 
390
  do
420
  do
391
  {
421
  {
392
    if (bqueue[i].branch != I_NIL)
422
    if (bqueue[i].branch != I_NIL)
393
      issue_bc_ins(i);
423
      issue_bc_ins(i);
394
 
424
 
395
    i++;
425
    i++;
396
    if (i == NQUEUE)
426
    if (i == NQUEUE)
397
      i = 0;			/* roll around to zero */
427
      i = 0;			/* roll around to zero */
398
  } while (i != bqueuepos);
428
  } while (i != bqueuepos);
399
 
429
 
400
  clear_branch_queue();
430
  clear_branch_queue();
401
}
431
}
402
#endif
432
#endif
403
 
433
 
404
#if do_case_transforms
434
#if do_case_transforms
405
static void case_tag_code PROTO_N ((caseint_reg,e,sp)) PROTO_T (int caseint_reg X exp e X space sp)
435
static void case_tag_code(int caseint_reg, exp e, space sp)
406
{
436
{
407
 
437
 
408
  long u;
438
  long u;
409
  long l;
439
  long l;
410
  long n;
440
  long n;
411
  exp z=bro(son(e));
441
  exp z=bro(son(e));
412
  exp zt=z;
442
  exp zt=z;
Line 414... Line 444...
414
  int veclab = next_data_lab();
444
  int veclab = next_data_lab();
415
  char *veclabname;
445
  char *veclabname;
416
  baseoff zeroveclab;
446
  baseoff zeroveclab;
417
  int mr = getreg(sp.fixed);	/* no need to guardreg(caseint_reg) as mr not
447
  int mr = getreg(sp.fixed);	/* no need to guardreg(caseint_reg) as mr not
418
				 * used until after lase use of caseint_reg */
448
				 * used until after lase use of caseint_reg */
419
    
449
 
420
  l=no(zt);
450
  l=no(zt);
421
  while(bro(zt)!=nilexp)
451
  while (bro(zt)!=nilexp)
422
  {
452
  {
423
    zt=bro(zt);
453
    zt=bro(zt);
424
  }
454
  }
425
  u = (son(zt)==nilexp) ? no(zt) : no(son(zt));
455
  u = (son(zt) ==nilexp)? no(zt): no(son(zt));
426
  
456
 
427
 
457
 
428
  zeroveclab.offset = 0;
458
  zeroveclab.offset = 0;
429
  zeroveclab.base = veclab;
459
  zeroveclab.base = veclab;
430
  
460
 
431
  if (l >= 0 && l <= 4)
461
  if (l >= 0 && l <= 4)
432
  {
462
  {
433
    /* between 0 and 4 dummy table entries used to avoid subtract */
463
    /* between 0 and 4 dummy table entries used to avoid subtract */
434
    rir_ins(i_sl, caseint_reg, 2, mr);
464
    rir_ins(i_sl, caseint_reg, 2, mr);
435
    n = 0;
465
    n = 0;
Line 451... Line 481...
451
  /* .toc entry for veclab */
481
  /* .toc entry for veclab */
452
  fprintf(as_file, "\t.toc\n");
482
  fprintf(as_file, "\t.toc\n");
453
  veclabname = ext_name(veclab);
483
  veclabname = ext_name(veclab);
454
  fprintf(as_file, "T.%s:\t.tc\t%s[TC],%s\n", veclabname, veclabname, veclabname);
484
  fprintf(as_file, "T.%s:\t.tc\t%s[TC],%s\n", veclabname, veclabname, veclabname);
455
  fprintf(as_file, "\t.csect\t[PR]\n");
485
  fprintf(as_file, "\t.csect\t[PR]\n");
456
  
486
 
457
  /* build the jump vector, can be to .text or .data */
487
  /* build the jump vector, can be to .text or .data */
458
  fprintf(as_file, "%s:\n", veclabname);
488
  fprintf(as_file, "%s:\n", veclabname);
459
  for (;;)
489
  for (;;)
460
  {
490
  {
461
    for (; no(z) != n; n++)
491
    for (; no(z)!= n; n++)
462
    {
492
    {
463
      fprintf(as_file, "\t.long\tL.%d-%s\n", endlab, veclabname);
493
      fprintf(as_file, "\t.long\tL.%d-%s\n", endlab, veclabname);
464
    }
494
    }
465
    u = (son(z) == nilexp) ? n : no(son(z));
495
    u = (son(z) == nilexp)? n : no(son(z));
466
    for (; u+1 != n; n++)	/* comparison independent of sign */
496
    for (; u+1 != n; n++)	/* comparison independent of sign */
467
    {
497
    {
468
	fprintf(as_file, "\t.long\tL.%d-%s\n", no(son(pt(z))), veclabname);
498
	fprintf(as_file, "\t.long\tL.%d-%s\n", no(son(pt(z))), veclabname);
469
      }
499
      }
470
    if (last(z))
500
    if (last(z))
Line 476... Line 506...
476
  set_label(endlab);
506
  set_label(endlab);
477
  return;
507
  return;
478
}
508
}
479
 
509
 
480
 
510
 
481
  
511
 
482
#else
512
#else
483
static void case_tag_code PROTO_N ((caseint_reg,e,sp)) PROTO_T (int caseint_reg X exp e X space sp)
513
static void case_tag_code(int caseint_reg, exp e, space sp)
484
{
514
{
485
  mm lims;
515
  mm lims;
486
  exp z = bro(son(e));
516
  exp z = bro(son(e));
487
  exp zt = z;
517
  exp zt = z;
488
  long n;
518
  long n;
Line 495... Line 525...
495
 
525
 
496
  /* calculate crude criterion for using jump vector or branches */
526
  /* calculate crude criterion for using jump vector or branches */
497
  l = no(zt);
527
  l = no(zt);
498
  for (n = 1;; n++)
528
  for (n = 1;; n++)
499
  {
529
  {
500
    if (u + 1 != no(zt) && son(zt) != nilexp)
530
    if (u + 1 != no(zt) && son(zt)!= nilexp)
501
    {
531
    {
502
      n++;
532
      n++;
503
    }
533
    }
504
    if (last(zt))
534
    if (last(zt))
505
    {
535
    {
506
      u = (son(zt) != nilexp) ? no(son(zt)) : no(zt);
536
      u = (son(zt)!= nilexp)? no(son(zt)): no(zt);
507
      break;
537
      break;
508
    }
538
    }
509
    if (son(zt) != nilexp)
539
    if (son(zt)!= nilexp)
510
    {
540
    {
511
      u = no(son(zt));
541
      u = no(son(zt));
512
    }
542
    }
513
    else
543
    else
514
    {
544
    {
Line 523... Line 553...
523
  /* now l is lowest controlling value, u is highest and n is number of cases */
553
  /* now l is lowest controlling value, u is highest and n is number of cases */
524
 
554
 
525
  if (u - l < 0)
555
  if (u - l < 0)
526
    approx_range = 0x7fffffff;	/* u-l overflowed into -ve, use huge */
556
    approx_range = 0x7fffffff;	/* u-l overflowed into -ve, use huge */
527
  else
557
  else
528
    approx_range = ( unsigned long ) ( u - l );
558
    approx_range = (unsigned long)(u - l);
529
 
559
 
530
  if (approx_range < 16)
560
  if (approx_range < 16)
531
  {
561
  {
532
    /* small jump vector needed, decide on instuctions executed only */
562
    /* small jump vector needed, decide on instuctions executed only */
533
#define	MTCR_B_DELAY		4	/* fixed point mtctr..bctr delay */
563
#define	MTCR_B_DELAY		4	/* fixed point mtctr..bctr delay */
534
#define	BR_TAKEN_DELAY		3	/* fixed point branch taken delay */
564
#define	BR_TAKEN_DELAY		3	/* fixed point branch taken delay */
535
    unsigned jump_vector_cnt = ((l >= 0 && l <= 4) ? 8 + MTCR_B_DELAY : 9 + MTCR_B_DELAY);
565
    unsigned jump_vector_cnt = ((l >= 0 && l <= 4)? 8 + MTCR_B_DELAY : 9 + MTCR_B_DELAY);
536
 
566
 
537
    unsigned cmp_jmp_step_cnt = 2 + (!IMM_SIZE(l)) + (!IMM_SIZE(u));
567
    unsigned cmp_jmp_step_cnt = 2 + (!IMM_SIZE(l)) + (!IMM_SIZE(u));
538
 
568
 
539
    /* cmp & jmp, delay slot filled plus possibly load of large consts */
569
    /* cmp & jmp, delay slot filled plus possibly load of large consts */
540
    /* +++ assume default used as often as case, is this good ??? */
570
    /* +++ assume default used as often as case, is this good ??? */
541
    unsigned default_weight = 1;/* likelyhood of default against single case */
571
    unsigned default_weight = 1;/* likelyhood of default against single case */
542
    unsigned total_case_test_chain_cnt =
572
    unsigned total_case_test_chain_cnt =
543
	((((n + 1) * cmp_jmp_step_cnt) * n) / 2) + BR_TAKEN_DELAY;
573
	((((n + 1)* cmp_jmp_step_cnt)* n) / 2) + BR_TAKEN_DELAY;
544
    unsigned default_test_chain_cnt =
574
    unsigned default_test_chain_cnt =
545
	(n * cmp_jmp_step_cnt);
575
	(n * cmp_jmp_step_cnt);
546
    unsigned average_test_chain_cnt =
576
    unsigned average_test_chain_cnt =
547
	(total_case_test_chain_cnt + (default_test_chain_cnt * default_weight)) / (n + default_weight);
577
	(total_case_test_chain_cnt + (default_test_chain_cnt * default_weight)) / (n + default_weight);
548
 
578
 
Line 556... Line 586...
556
    /*
586
    /*
557
     * space-time product criterion for jump vector instead of tests and
587
     * space-time product criterion for jump vector instead of tests and
558
     * branches
588
     * branches
559
     */
589
     */
560
    unsigned long range_factor = approx_range + 9;
590
    unsigned long range_factor = approx_range + 9;
561
    unsigned long n_factor = ((unsigned long) n * n) / 2;
591
    unsigned long n_factor = ((unsigned long)n * n) / 2;
562
 
592
 
563
    use_jump_vector = range_factor <= n_factor;
593
    use_jump_vector = range_factor <= n_factor;
564
  }
594
  }
565
 
595
 
566
  COMMENT4("case_tag: n=%d l,u=%d,%d approx_range=%d", n, l, u, approx_range);
596
  COMMENT4("case_tag: n=%d l,u=%d,%d approx_range=%d", n, l, u, approx_range);
567
  if (is_signed(sh(son(e)))) {
597
  if (is_signed(sh(son(e)))) {
568
    ASSERT ( l <= u ) ;
598
    ASSERT(l <= u);
569
  } else {
599
  } else {
570
    ASSERT ( (unsigned long) l <= (unsigned long) u ) ;
600
    ASSERT((unsigned long)l <= (unsigned long)u);
571
  }
601
  }
572
  ASSERT(n >= 0);
602
  ASSERT(n >= 0);
573
 
603
 
574
  if (use_jump_vector)
604
  if (use_jump_vector)
575
  {
605
  {
Line 622... Line 652...
622
 
652
 
623
    /* build the jump vector, can be to .text or .data */
653
    /* build the jump vector, can be to .text or .data */
624
    fprintf(as_file, "%s:\n", veclabname);
654
    fprintf(as_file, "%s:\n", veclabname);
625
    for (;;)
655
    for (;;)
626
    {
656
    {
627
      for (; no(z) != n; n++)
657
      for (; no(z)!= n; n++)
628
      {
658
      {
629
	fprintf(as_file, "\t.long\tL.%d-%s\n", endlab, veclabname);
659
	fprintf(as_file, "\t.long\tL.%d-%s\n", endlab, veclabname);
630
      }
660
      }
631
      u = (son(z) == nilexp) ? n : no(son(z));
661
      u = (son(z) == nilexp)? n : no(son(z));
632
      for (; u+1 != n; n++)
662
      for (; u+1 != n; n++)
633
      {
663
      {
634
	fprintf(as_file, "\t.long\tL.%d-%s\n", no(son(pt(z))), veclabname);
664
	fprintf(as_file, "\t.long\tL.%d-%s\n", no(son(pt(z))), veclabname);
635
      }
665
      }
636
      if (last(z))
666
      if (last(z))
Line 698... Line 728...
698
      {
728
      {
699
	/* lower is <= lower limit of shape */
729
	/* lower is <= lower limit of shape */
700
	cmp_ri_ins(i_cmp, caseint_reg, u, creg);
730
	cmp_ri_ins(i_cmp, caseint_reg, u, creg);
701
	queue_bc_ins(i_ble, creg, lab);
731
	queue_bc_ins(i_ble, creg, lab);
702
	lims.mini = u + 1;
732
	lims.mini = u + 1;
703
      }
733
      }
704
      else
734
      else
705
      {
735
      {
706
	/* upper is >= upper limit of shape */
736
	/* upper is >= upper limit of shape */
707
	flush_branch_queue();
737
	flush_branch_queue();
708
	uncond_ins(i_b, lab);
738
	uncond_ins(i_b, lab);
709
      }
739
      }
710
      if (last(z))
740
      if (last(z))
711
      {
741
      {
712
	flush_branch_queue();
742
	flush_branch_queue();
Line 796... Line 826...
796
	  set_label(endlab);
826
	  set_label(endlab);
797
	}
827
	}
798
	return;
828
	return;
799
      }
829
      }
800
      z = bro(z);
830
      z = bro(z);
801
    }
831
    }
802
  }
832
  }
803
}
833
}
804
#endif
834
#endif
805
 
835
 
806
/*
836
/*
807
 * Evaluate and generate the compare instruction for a test_tag,
837
 * Evaluate and generate the compare instruction for a test_tag,
808
 * and return a bcinfo describing the conditional branch required.
838
 * and return a bcinfo describing the conditional branch required.
809
 */
839
 */
810
static bc_info make_test_tag_cmp PROTO_N ((e,sp)) PROTO_T (exp e X space sp)
840
static bc_info make_test_tag_cmp(exp e, space sp)
811
{
841
{
812
  exp l = son(e);
842
  exp l = son(e);
813
  exp r = bro(l);
843
  exp r = bro(l);
814
  shape shl = sh(l);
844
  shape shl = sh(l);
815
  bc_info bcinfo;
845
  bc_info bcinfo;
816
 
846
 
817
  bcinfo.lab = (ptno(e) < 0) ? -ptno(e) : no(son(pt(e)));
847
  bcinfo.lab = (ptno(e) < 0)? -ptno(e): no(son(pt(e)));
818
					/* see frig in cond_tag */
848
					/* see frig in cond_tag */
819
  /* generate compare */
849
  /* generate compare */
820
  if (is_floating(name(sh(l))))
850
  if (is_floating(name(sh(l))))
821
  {
851
  {
822
    /* float test */
852
    /* float test */
823
    int a1;
853
    int a1;
824
    int a2;
854
    int a2;
825
    space nsp;
855
    space nsp;
826
 
856
 
Line 834... Line 864...
834
    {
864
    {
835
      a1 = freg_operand(l, sp, getfreg(sp.flt));
865
      a1 = freg_operand(l, sp, getfreg(sp.flt));
836
      nsp = guardfreg(a1, sp);
866
      nsp = guardfreg(a1, sp);
837
      a2 = freg_operand(r, nsp, getfreg(nsp.flt));
867
      a2 = freg_operand(r, nsp, getfreg(nsp.flt));
838
    }
868
    }
839
 
869
 
840
    bcinfo.creg = next_creg();
870
    bcinfo.creg = next_creg();
841
    rrf_cmp_ins(i_fcmpo, a1, a2, bcinfo.creg);
871
    rrf_cmp_ins(i_fcmpo, a1, a2, bcinfo.creg);
842
  }
872
  }
843
  else
873
  else
844
  {
874
  {
845
    /* int test */
875
    /* int test */
846
    bool sgned = is_signed(shl);
876
    bool sgned = is_signed(shl);
847
    int a1;
877
    int a1;
848
    int a2;
878
    int a2;
849
    Instruction_P cmp;
879
    Instruction_P cmp;
850
    
880
 
851
    cmp = sgned ? i_cmp : i_cmpl;
881
    cmp = sgned ? i_cmp : i_cmpl;
852
    
882
 
853
    cr0_set = 0;
883
    cr0_set = 0;
854
    /* cr0_set is needed since l could be tracked by reg tracking and there
884
    /* cr0_set is needed since l could be tracked by reg tracking and there
855
       fore not coded. In this case cr0_set should remain 0 */
885
       fore not coded. In this case cr0_set should remain 0 */
856
    a1 = reg_operand(l, sp);
886
    a1 = reg_operand(l, sp);
857
    if (record_bit_set(l) && cr0_set==1)
887
    if (record_bit_set(l) && cr0_set==1)
Line 884... Line 914...
884
/*
914
/*
885
 * Produce code for expression e, putting its result in dest using t-regs
915
 * Produce code for expression e, putting its result in dest using t-regs
886
 * given by sp. If non-zero, exitlab is the label of where the code is to
916
 * given by sp. If non-zero, exitlab is the label of where the code is to
887
 * continue.
917
 * continue.
888
 */
918
 */
889
makeans make_code PROTO_N ((e,sp,dest,exitlab)) PROTO_T (exp e X space sp X where dest X int exitlab)
919
makeans make_code(exp e, space sp, where dest, int exitlab)
890
{
920
{
891
  long constval=0;
921
  long constval=0;
892
  makeans mka;
922
  makeans mka;
893
  static long exp_num = 0;  /* count of exps in order of evaluation */
923
  static long exp_num = 0;  /* count of exps in order of evaluation */
894
 
924
 
Line 896... Line 926...
896
   * A heuristic to estimate if conditional branch is close enough for
926
   * A heuristic to estimate if conditional branch is close enough for
897
   * bc instruction, which can branch +-8k words.  Tests indicate
927
   * bc instruction, which can branch +-8k words.  Tests indicate
898
   * 13500 exp nodes generate 8k words of instructions.
928
   * 13500 exp nodes generate 8k words of instructions.
899
   * We play safe and allow 1 instruction per exp.
929
   * We play safe and allow 1 instruction per exp.
900
   */
930
   */
901
#define TEST_TAG_NEAR_BRANCH(e)	(ptno(e) < 0 || absval(ptno(son(pt(e)))-exp_num) < 8192)
931
#define TEST_TAG_NEAR_BRANCH(e)	(ptno(e) < 0 || absval(ptno(son(pt(e))) -exp_num) < 8192)
902
  
932
 
903
 tailrecurse:
933
 tailrecurse:
904
  exp_num++;
934
  exp_num++;
905
  mka.lab = exitlab;
935
  mka.lab = exitlab;
906
  mka.regmove = NOREG;
936
  mka.regmove = NOREG;
907
 
937
 
Line 911... Line 941...
911
   * Procedure related code selection is handled by make_XXX_tag_code()
941
   * Procedure related code selection is handled by make_XXX_tag_code()
912
   * functions in proc.c.
942
   * functions in proc.c.
913
   */
943
   */
914
   case proc_tag:		/* procedure definition */
944
   case proc_tag:		/* procedure definition */
915
   case general_proc_tag:
945
   case general_proc_tag:
916
    {
946
    {
917
      exp_num = 0;
947
      exp_num = 0;
918
      make_proc_tag_code(e, sp);
948
      make_proc_tag_code(e, sp);
919
      return mka;
949
      return mka;
920
    }
950
    }
921
/*****************************************************************************/
951
/*****************************************************************************/
922
   case ident_tag:		/* ident/param definition within proc */
952
   case ident_tag:		/* ident/param definition within proc */
923
    {
953
    {
924
      return make_ident_tag_code(e, sp, dest, exitlab);
954
      return make_ident_tag_code(e, sp, dest, exitlab);
925
    }
955
    }
926
/*****************************************************************************/
956
/*****************************************************************************/
927
   case untidy_return_tag:
957
   case untidy_return_tag:
928
   case res_tag:			/* procedure result */
958
   case res_tag:			/* procedure result */
929
    {
959
    {
930
      make_res_tag_code(e, sp);
960
      make_res_tag_code(e, sp);
931
      return mka;
961
      return mka;
Line 937... Line 967...
937
    }
967
    }
938
/*****************************************************************************/
968
/*****************************************************************************/
939
   case clear_tag:
969
   case clear_tag:
940
    {
970
    {
941
      if (dest.answhere.discrim == insomereg)
971
      if (dest.answhere.discrim == insomereg)
942
      {
972
      {
943
	/*
973
	/*
944
	 * Must choose a fixed register to contain answer to clear
974
	 * Must choose a fixed register to contain answer to clear
945
	 */
975
	 */
946
	int *sr = someregalt(dest.answhere);
976
	int *sr = someregalt(dest.answhere);
947
	
977
 
948
	if (*sr != -1){fail("somereg *2");}
978
	if (*sr != -1) {fail("somereg *2");}
949
	*sr = getreg(sp.fixed);
979
	*sr = getreg(sp.fixed);
950
	setregalt(dest.answhere, *sr);
980
	setregalt(dest.answhere, *sr);
951
      }
981
      }
952
      else if(dest.answhere.discrim==insomefreg)
982
      else if (dest.answhere.discrim==insomefreg)
953
      {
983
      {
954
	/*
984
	/*
955
	 * Must choose a float register to contain answer to clear
985
	 * Must choose a float register to contain answer to clear
956
	 */
986
	 */
957
	somefreg sfr;
987
	somefreg sfr;
958
	freg fr;
988
	freg fr;
959
	
989
 
960
	sfr = somefregalt(dest.answhere);
990
	sfr = somefregalt(dest.answhere);
961
	if (*sfr.fr != -1){fail("somefreg *2");}
991
	if (*sfr.fr != -1) {fail("somefreg *2");}
962
	*sfr.fr = getfreg(sp.flt);
992
	*sfr.fr = getfreg(sp.flt);
963
	fr.fr = *sfr.fr;
993
	fr.fr = *sfr.fr;
964
	fr.dble = sfr.dble;
994
	fr.dble = sfr.dble;
965
	setfregalt(dest.answhere, fr);
995
	setfregalt(dest.answhere, fr);
966
      }
996
      }
Line 969... Line 999...
969
    }
999
    }
970
/*****************************************************************************/
1000
/*****************************************************************************/
971
   case seq_tag:
1001
   case seq_tag:
972
    {
1002
    {
973
      exp t = son(son(e));
1003
      exp t = son(son(e));
974
      
1004
 
975
      for (;;)
1005
      for (;;)
976
      {
1006
      {
977
	exp next = (last(t)) ? (bro(son(e))) : bro(t);
1007
	exp next = (last(t))?(bro(son(e))): bro(t);
978
 
1008
 
979
	if (name(next) == goto_tag)	/* gotos end sequences */
1009
	if (name(next) == goto_tag)	/* gotos end sequences */
980
	{
1010
	{
981
	  make_code(t, sp, nowhere, no(son(pt(next))));
1011
	  make_code(t, sp, nowhere, no(son(pt(next))));
982
	}
1012
	}
983
	else
1013
	else
984
	{
1014
	{
985
	  code_here(t, sp, nowhere);
1015
	  code_here(t, sp, nowhere);
986
	}
1016
	}
987
	if (last(t))
1017
	if (last(t))
988
	{
1018
	{
989
	  exp l = bro(son(e));		/* last exp of sequence */
1019
	  exp l = bro(son(e));		/* last exp of sequence */
990
 
1020
 
991
	  if (name(sh(t)) == bothd && name(l) == res_tag &&
1021
	  if (name(sh(t)) == bothd && name(l) == res_tag &&
992
	      (name(son(l)) == clear_tag || name(son(l)) == top_tag))
1022
	     (name(son(l)) == clear_tag || name(son(l)) == top_tag))
993
	  {
1023
	  {
994
	    /*
1024
	    /*
995
	     * res_tag that cannot be reached.  Eg an extra one inserted at
1025
	     * res_tag that cannot be reached.  Eg an extra one inserted at
996
	     * end of proc.  Skip it.
1026
	     * end of proc.  Skip it.
997
	     */
1027
	     */
Line 1010... Line 1040...
1010
   case cond_tag:
1040
   case cond_tag:
1011
    {
1041
    {
1012
      exp first = son(e);
1042
      exp first = son(e);
1013
      exp second = bro(son(e));
1043
      exp second = bro(son(e));
1014
      exp test;
1044
      exp test;
1015
      
1045
 
1016
      if (dest.answhere.discrim==insomereg)
1046
      if (dest.answhere.discrim==insomereg)
1017
      {
1047
      {
1018
	/*
1048
	/*
1019
	 * Must choose a fixed register to contain answer to cond 
1049
	 * Must choose a fixed register to contain answer to cond
1020
	 */
1050
	 */
1021
	int *sr = someregalt(dest.answhere);
1051
	int *sr = someregalt(dest.answhere);
1022
	
1052
 
1023
	if (*sr != -1){fail("somereg *2");}
1053
	if (*sr != -1) {fail("somereg *2");}
1024
	*sr = getreg(sp.fixed);
1054
	*sr = getreg(sp.fixed);
1025
	setregalt(dest.answhere, *sr);
1055
	setregalt(dest.answhere, *sr);
1026
      }
1056
      }
1027
      else if (dest.answhere.discrim==insomefreg)
1057
      else if (dest.answhere.discrim==insomefreg)
1028
      {
1058
      {
1029
	/*
1059
	/*
1030
	 * Must choose a float register to contain answer to cond 
1060
	 * Must choose a float register to contain answer to cond
1031
	 */
1061
	 */
1032
	somefreg sfr;
1062
	somefreg sfr;
1033
	freg fr;
1063
	freg fr;
1034
	
1064
 
1035
	sfr = somefregalt(dest.answhere);
1065
	sfr = somefregalt(dest.answhere);
1036
	if (*sfr.fr != -1){fail("somefreg *2");}
1066
	if (*sfr.fr != -1) {fail("somefreg *2");}
1037
	*sfr.fr = getfreg(sp.flt);
1067
	*sfr.fr = getfreg(sp.flt);
1038
	fr.fr = *sfr.fr;
1068
	fr.fr = *sfr.fr;
1039
	fr.dble = sfr.dble;
1069
	fr.dble = sfr.dble;
1040
	setfregalt(dest.answhere, fr);
1070
	setfregalt(dest.answhere, fr);
1041
      }
1071
      }
1042
 
1072
 
1043
      /* 
1073
      /*
1044
       * A few optimisations for cond_tag 
1074
       * A few optimisations for cond_tag
1045
       */
1075
       */
1046
      if (name(first) == goto_tag && pt(first) == second)
1076
      if (name(first) == goto_tag && pt(first) == second)
1047
      {
1077
      {
1048
	/* first is goto second */
1078
	/* first is goto second */
1049
	no(son(second)) = 0;
1079
	no(son(second)) = 0;
1050
	return make_code(second, sp, dest, exitlab);
1080
	return make_code(second, sp, dest, exitlab);
1051
      }
1081
      }
1052
#if 0 /* could we do this better to prevent long branch problem?*/
1082
#if 0 /* could we do this better to prevent long branch problem?*/
1053
      else if (name(second) == labst_tag && name(bro(son(second))) == top_tag)
1083
      else if (name(second) == labst_tag && name(bro(son(second))) == top_tag)
1054
      {
1084
      {
1055
	/* second is empty */
1085
	/* second is empty */
1056
 
1086
 
1057
	int endl = (exitlab == 0) ? new_label() : exitlab;
1087
	int endl = (exitlab == 0)? new_label(): exitlab;
1058
 
1088
 
1059
	no(son(second)) = endl;
1089
	no(son(second)) = endl;
1060
	make_code(first, sp, dest, endl);
1090
	make_code(first, sp, dest, endl);
1061
	mka.lab = endl;
1091
	mka.lab = endl;
1062
	return mka;
1092
	return mka;
Line 1064... Line 1094...
1064
#endif
1094
#endif
1065
      else if (name(second) == labst_tag && name(bro(son(second))) == goto_tag)
1095
      else if (name(second) == labst_tag && name(bro(son(second))) == goto_tag)
1066
      {
1096
      {
1067
	/* second is goto */
1097
	/* second is goto */
1068
	exp g = bro(son(second));
1098
	exp g = bro(son(second));
1069
 
1099
 
1070
	no(son(second)) = no(son(pt(g)));
1100
	no(son(second)) = no(son(pt(g)));
1071
	return make_code(first, sp, dest, exitlab);
1101
	return make_code(first, sp, dest, exitlab);
1072
      }
1102
      }
1073
 
1103
 
1074
      test = testlast(first, second);
1104
      test = testlast(first, second);
1075
      if (test != nilexp && TEST_TAG_NEAR_BRANCH(test))
1105
      if (test != nilexp && TEST_TAG_NEAR_BRANCH(test))
1076
      {
1106
      {
1077
	/* effectively an empty then part */
1107
	/* effectively an empty then part */
1078
	int l = (exitlab != 0) ? exitlab : new_label();
1108
	int l = (exitlab != 0)? exitlab : new_label();
1079
 
1109
 
1080
	ptno(test) = -l;	/* make test jump to exitlab - see test_tag: */
1110
	ptno(test) = -l;	/* make test jump to exitlab - see test_tag: */
1081
	settest_number(test,obranch(test_number(test)));
1111
	settest_number(test,obranch(test_number(test)));
1082
	/* settest_number preserves the Rev bit */
1112
	/* settest_number preserves the Rev bit */
1083
	no(son(second)) = new_label();
1113
	no(son(second)) = new_label();
1084
	make_code(first, sp, dest, l);
1114
	make_code(first, sp, dest, l);
1085
	make_code(second, sp, dest, l);
1115
	make_code(second, sp, dest, l);
1086
	mka.lab = l;
1116
	mka.lab = l;
1087
	return mka;
1117
	return mka;
1088
      }
1118
      }
1089
      else
1119
      else
1090
      {
1120
      {
1091
	int fl;
1121
	int fl;
1092
	int l;
1122
	int l;
1093
	
1123
 
1094
	no(son(second)) = new_label();
1124
	no(son(second)) = new_label();
1095
	fl = make_code(first, sp, dest, exitlab).lab;
1125
	fl = make_code(first, sp, dest, exitlab).lab;
1096
	l = (fl != 0) ? fl : ((exitlab != 0) ? exitlab : new_label());
1126
	l = (fl != 0)? fl :((exitlab != 0)? exitlab : new_label());
1097
	if (name(sh(first)) != bothd)
1127
	if (name(sh(first))!= bothd)
1098
	{
1128
	{
1099
	  uncond_ins(i_b, l);
1129
	  uncond_ins(i_b, l);
1100
	}
1130
	}
1101
	make_code(second, sp, dest, l);
1131
	make_code(second, sp, dest, l);
1102
	clear_all();
1132
	clear_all();
1103
	mka.lab = l;
1133
	mka.lab = l;
1104
	return mka;
1134
	return mka;
1105
      }
1135
      }
1106
    }	
1136
    }
1107
/*****************************************************************************/
1137
/*****************************************************************************/
1108
   case labst_tag:
1138
   case labst_tag:
1109
    {
1139
    {
1110
      ptno(son(e)) = exp_num;	/* update estimate made in scan() */
1140
      ptno(son(e)) = exp_num;	/* update estimate made in scan() */
1111
      if (no(son(e)) != 0)
1141
      if (no(son(e))!= 0)
1112
      {
1142
      {
1113
	clear_all();
1143
	clear_all();
1114
	set_label(no(son(e)));
1144
	set_label(no(son(e)));
1115
	
1145
 
1116
	if (is_loaded_lv(e) && p_save_all_sregs)
1146
	if (is_loaded_lv(e) && p_save_all_sregs)
1117
	{
1147
	{
1118
	  /* It is long jumpabble to (potentially)*/
1148
	  /* It is long jumpabble to (potentially)*/
1119
	  if(p_has_tp)
1149
	  if (p_has_tp)
1120
	  {
1150
	  {
1121
	    /* restore tp */
1151
	    /* restore tp */
1122
	    baseoff saved_tp;
1152
	    baseoff saved_tp;
1123
	    saved_tp.base = R_FP;
1153
	    saved_tp.base = R_FP;
1124
	    saved_tp.offset = 0;
1154
	    saved_tp.offset = 0;
Line 1127... Line 1157...
1127
	  if (p_has_saved_sp)
1157
	  if (p_has_saved_sp)
1128
	  {
1158
	  {
1129
	    /* Variable frame size */
1159
	    /* Variable frame size */
1130
	    get_sp_from_stack();
1160
	    get_sp_from_stack();
1131
	  }
1161
	  }
1132
	  else 
1162
	  else
1133
	  {
1163
	  {
1134
	    /* Fixed frame size */
1164
	    /* Fixed frame size */
1135
	    rir_ins(i_a,R_FP, - p_frame_size , R_SP);
1165
	    rir_ins(i_a,R_FP, - p_frame_size , R_SP);
1136
	  }
1166
	  }
1137
	}
1167
	}
1138
	
1168
 
1139
      }
1169
      }
1140
      return make_code(bro(son(e)), sp, dest, exitlab);
1170
      return make_code(bro(son(e)), sp, dest, exitlab);
1141
    }				/* end labst */
1171
    }				/* end labst */
1142
/*****************************************************************************/
1172
/*****************************************************************************/
1143
  case rep_tag:
1173
  case rep_tag:
1144
    {
1174
    {
1145
      exp first = son(e);
1175
      exp first = son(e);
1146
      exp second = bro(first);
1176
      exp second = bro(first);
1147
      
1177
 
1148
      code_here(first,sp,nowhere);
1178
      code_here(first,sp,nowhere);
1149
      ASSERT(name(second)==labst_tag);
1179
      ASSERT(name(second) ==labst_tag);
1150
      no(son(second)) = new_label();
1180
      no(son(second)) = new_label();
1151
#if 1
1181
#if 1
1152
      if (architecture != POWERPC_CODE)
1182
      if (architecture != POWERPC_CODE)
1153
      {
1183
      {
1154
	exp last_test;      
1184
	exp last_test;
1155
	/*
1185
	/*
1156
	 * Rearrange test and branch instructions
1186
	 * Rearrange test and branch instructions
1157
	 * to reduce RS/6000 branch delays 
1187
	 * to reduce RS/6000 branch delays
1158
	 */
1188
	 */
1159
	/* look for last test_tag of repeat exp */
1189
	/* look for last test_tag of repeat exp */
1160
	last_test = bro(son(second));	/* under labst_tag */
1190
	last_test = bro(son(second));	/* under labst_tag */
1161
	/* dive down sequences */
1191
	/* dive down sequences */
1162
	while (name(last_test) == seq_tag)
1192
	while (name(last_test) == seq_tag)
1163
	{
1193
	{
1164
	  last_test = bro(son(last_test));
1194
	  last_test = bro(son(last_test));
1165
	}
1195
	}
1166
	
1196
 
1167
	
1197
 
1168
	if (!diagnose && name(last_test) == test_tag)
1198
	if (!diagnose && name(last_test) == test_tag)
1169
	{
1199
	{
1170
	  /* we found a test_tag, is it simple and jumps to rep_tag? */
1200
	  /* we found a test_tag, is it simple and jumps to rep_tag? */
1171
	  
1201
 
1172
	  if (ptno(last_test) >= 0 && pt(last_test) == second 
1202
	  if (ptno(last_test) >= 0 && pt(last_test) == second
1173
	      && TEST_TAG_NEAR_BRANCH(last_test))
1203
	      && TEST_TAG_NEAR_BRANCH(last_test))
1174
	  {
1204
	  {
1175
	    /*
1205
	    /*
1176
	     * It jumps to head of repeat.  Generate code out of
1206
	     * It jumps to head of repeat.  Generate code out of
1177
	     * order to reduce RS/6000 branch delays.  RS/6000
1207
	     * order to reduce RS/6000 branch delays.  RS/6000
Line 1190... Line 1220...
1190
	     */
1220
	     */
1191
	    static int rep_org_labnos = 0;
1221
	    static int rep_org_labnos = 0;
1192
	    int rep_org_lab = 0;
1222
	    int rep_org_lab = 0;
1193
	    int end_rep_test_lab = new_label();
1223
	    int end_rep_test_lab = new_label();
1194
	    int start_of_rep_lab = no(son(second));	/* labst_tag label */
1224
	    int start_of_rep_lab = no(son(second));	/* labst_tag label */
1195
	    int end_rep_lab = (exitlab == 0) ? new_label() : exitlab;
1225
	    int end_rep_lab = (exitlab == 0)? new_label(): exitlab;
1196
	    bc_info bcinfo;
1226
	    bc_info bcinfo;
1197
	    
1227
 
1198
	    COMMENT("make_code rep_tag: last exp is rep_tag test_tag - evaluate out of order");
1228
	    COMMENT("make_code rep_tag: last exp is rep_tag test_tag - evaluate out of order");
1199
	    
1229
 
1200
	    /* labst_tag label should be in use */
1230
	    /* labst_tag label should be in use */
1201
	    ASSERT(start_of_rep_lab!=0);
1231
	    ASSERT(start_of_rep_lab!=0);
1202
	    
1232
 
1203
	    /* allocate new label number for use with .org: L.R%d and L.S%d */
1233
	    /* allocate new label number for use with .org: L.R%d and L.S%d */
1204
	    rep_org_lab = ++rep_org_labnos;
1234
	    rep_org_lab = ++rep_org_labnos;
1205
	    
1235
 
1206
	    uncond_ins(i_b, start_of_rep_lab);
1236
	    uncond_ins(i_b, start_of_rep_lab);
1207
	    
1237
 
1208
	    set_label(end_rep_test_lab);
1238
	    set_label(end_rep_test_lab);
1209
	    
1239
 
1210
	    /* use .org to leave gap for brought forward bc ins */
1240
	    /* use .org to leave gap for brought forward bc ins */
1211
	    fprintf(as_file, "L.R%d:\n", rep_org_lab);
1241
	    fprintf(as_file, "L.R%d:\n", rep_org_lab);
1212
	    fprintf(as_file, "\t.org\t$+4\t# loop bc ins\n");
1242
	    fprintf(as_file, "\t.org\t$+4\t# loop bc ins\n");
1213
	    
1243
 
1214
	    /* we will do test_tag ourselves, nuke it out of loop */
1244
	    /* we will do test_tag ourselves, nuke it out of loop */
1215
	    name(last_test) = top_tag;
1245
	    name(last_test) = top_tag;
1216
	    
1246
 
1217
	    /* set_label(start_of_rep_lab) done by labst_tag */
1247
	    /* set_label(start_of_rep_lab) done by labst_tag */
1218
	    
1248
 
1219
	    mka = make_code(second, sp, dest, exitlab);
1249
	    mka = make_code(second, sp, dest, exitlab);
1220
	    
1250
 
1221
	    /* reverse test, jump to end_rep_lab */
1251
	    /* reverse test, jump to end_rep_lab */
1222
	    ptno(last_test) = -end_rep_lab;
1252
	    ptno(last_test) = -end_rep_lab;
1223
	    settest_number(last_test,obranch(test_number(last_test)));
1253
	    settest_number(last_test,obranch(test_number(last_test)));
1224
	    /* generate compare */
1254
	    /* generate compare */
1225
	    bcinfo = make_test_tag_cmp(last_test, sp);
1255
	    bcinfo = make_test_tag_cmp(last_test, sp);
1226
	    
1256
 
1227
	    uncond_ins(i_b, end_rep_test_lab);
1257
	    uncond_ins(i_b, end_rep_test_lab);
1228
	    
1258
 
1229
	    if (end_rep_lab != exitlab)
1259
	    if (end_rep_lab != exitlab)
1230
	      set_label(end_rep_lab);
1260
	      set_label(end_rep_lab);
1231
	    
1261
 
1232
	    /* fill in gap above with bc_ins */
1262
	    /* fill in gap above with bc_ins */
1233
	    fprintf(as_file, "L.S%d:\n", rep_org_lab);
1263
	    fprintf(as_file, "L.S%d:\n", rep_org_lab);
1234
	    fprintf(as_file, ".org\tL.R%d\t# loop bc ins\n", rep_org_lab);
1264
	    fprintf(as_file, ".org\tL.R%d\t# loop bc ins\n", rep_org_lab);
1235
	    bc_ins(bcinfo.branch, bcinfo.creg, bcinfo.lab,UNLIKELY_TO_JUMP);
1265
	    bc_ins(bcinfo.branch, bcinfo.creg, bcinfo.lab,UNLIKELY_TO_JUMP);
1236
	    
1266
 
1237
	    /* .org back */
1267
	    /* .org back */
1238
	    fprintf(as_file, ".org\tL.S%d\n", rep_org_lab);
1268
	    fprintf(as_file, ".org\tL.S%d\n", rep_org_lab);
1239
	    
1269
 
1240
	    return mka;
1270
	    return mka;
1241
	  }
1271
	  }
1242
	  
1272
 
1243
	}
1273
	}
1244
      }
1274
      }
1245
#endif 
1275
#endif
1246
      /*
1276
      /*
1247
       * We could not find last simple test_tag, must be complicated.
1277
       * We could not find last simple test_tag, must be complicated.
1248
       * Don't bother to move tests around.
1278
       * Don't bother to move tests around.
1249
       * +++ handle cond_tag for more complex terminating condition.
1279
       * +++ handle cond_tag for more complex terminating condition.
1250
       */
1280
       */
Line 1253... Line 1283...
1253
/*****************************************************************************/
1283
/*****************************************************************************/
1254
  case goto_tag:
1284
  case goto_tag:
1255
    {
1285
    {
1256
      exp gotodest = pt(e);
1286
      exp gotodest = pt(e);
1257
      int lab;
1287
      int lab;
1258
#if 0 
1288
#if 0
1259
/* This would be a lovely optimisation, however silly people give me test
1289
/* This would be a lovely optimisation, however silly people give me test
1260
   programs with L1:goto L1 so I despair */
1290
   programs with L1:goto L1 so I despair */
1261
      while (name(bro(son(gotodest)))==goto_tag)
1291
      while (name(bro(son(gotodest))) ==goto_tag)
1262
      {
1292
      {
1263
	/* goto to goto optimisation */
1293
	/* goto to goto optimisation */
1264
	gotodest = pt(bro(son(gotodest)));
1294
	gotodest = pt(bro(son(gotodest)));
1265
      }
1295
      }
1266
#endif	    
1296
#endif
1267
      lab = no(son(gotodest));
1297
      lab = no(son(gotodest));
1268
      clear_all();
1298
      clear_all();
1269
      if (last(e)==0 || name(bro(e))!=seq_tag || last(bro(e)) ||
1299
      if (last(e) ==0 || name(bro(e))!=seq_tag || last(bro(e)) ||
1270
	  bro(bro(e)) != gotodest) 
1300
	  bro(bro(e))!= gotodest)
1271
      {
1301
      {
1272
	uncond_ins (i_b, lab);
1302
	uncond_ins(i_b, lab);
1273
      }/* otherwise dest is next in sequence */
1303
      }/* otherwise dest is next in sequence */
1274
      return mka;
1304
      return mka;
1275
    }				/* end goto */
1305
    }				/* end goto */
1276
/*****************************************************************************/
1306
/*****************************************************************************/
1277
  case test_tag:
1307
  case test_tag:
1278
    {
1308
    {
1279
      bc_info bcinfo;
1309
      bc_info bcinfo;
1280
      int branch_prediction=LIKELY_TO_JUMP;
1310
      int branch_prediction=LIKELY_TO_JUMP;
1281
      
1311
 
1282
      if(no(e)!=1000 && no(e)>=0 && no(e)<=100)
1312
      if (no(e)!=1000 && no(e) >=0 && no(e) <=100)
1283
      {
1313
      {
1284
	branch_prediction = (no(e)>=50)?UNLIKELY_TO_JUMP:LIKELY_TO_JUMP;
1314
	branch_prediction = (no(e) >=50)?UNLIKELY_TO_JUMP:LIKELY_TO_JUMP;
1285
      }
1315
      }
1286
      try_record_bit(e);
1316
      try_record_bit(e);
1287
      if (TEST_TAG_NEAR_BRANCH(e))
1317
      if (TEST_TAG_NEAR_BRANCH(e))
1288
      {
1318
      {
1289
	/* 
1319
	/*
1290
	 * Estimate close enough for bc_ins
1320
	 * Estimate close enough for bc_ins
1291
	 */
1321
	 */
1292
	bcinfo = make_test_tag_cmp(e, sp);
1322
	bcinfo = make_test_tag_cmp(e, sp);
1293
	bc_ins(bcinfo.branch, bcinfo.creg, bcinfo.lab,branch_prediction);
1323
	bc_ins(bcinfo.branch, bcinfo.creg, bcinfo.lab,branch_prediction);
1294
      }
1324
      }
Line 1296... Line 1326...
1296
      {
1326
      {
1297
	int newlab = new_label();
1327
	int newlab = new_label();
1298
	int oldlab = no(son(pt(e)));
1328
	int oldlab = no(son(pt(e)));
1299
 
1329
 
1300
	/*
1330
	/*
1301
	 * Branch is too far away so we reverse branch to new label 
1331
	 * Branch is too far away so we reverse branch to new label
1302
	 * and use an unconditional branch to the target destination
1332
	 * and use an unconditional branch to the target destination
1303
	 */
1333
	 */
1304
	ptno(e) = -newlab;
1334
	ptno(e) = -newlab;
1305
	settest_number(e,obranch(test_number(e)));
1335
	settest_number(e,obranch(test_number(e)));
1306
	bcinfo = make_test_tag_cmp(e, sp);
1336
	bcinfo = make_test_tag_cmp(e, sp);
Line 1335... Line 1365...
1335
	COMMENT("make_code: Assign to volatile");
1365
	COMMENT("make_code: Assign to volatile");
1336
	clear_all();
1366
	clear_all();
1337
      }
1367
      }
1338
 
1368
 
1339
      if (name(e) == ass_tag && APPLYLIKE(rhs) &&
1369
      if (name(e) == ass_tag && APPLYLIKE(rhs) &&
1340
	  ((is_float) || valregable(sh(rhs))))
1370
	 ((is_float) || valregable(sh(rhs))))
1341
      {
1371
      {
1342
	where apply_res;
1372
	where apply_res;
1343
	/* This is not an optimisation this is necessary */
1373
	/* This is not an optimisation this is necessary */
1344
	/* Since if we have a procedure call doing the locate will make a pointer which
1374
	/* Since if we have a procedure call doing the locate will make a pointer which
1345
	   will be trashed in the call*/
1375
	   will be trashed in the call*/
Line 1358... Line 1388...
1358
	}
1388
	}
1359
	apply_res.ashwhere = ashof(sh(rhs));
1389
	apply_res.ashwhere = ashof(sh(rhs));
1360
 
1390
 
1361
	code_here(rhs, sp, apply_res);
1391
	code_here(rhs, sp, apply_res);
1362
	nsp = guard(apply_res, sp);
1392
	nsp = guard(apply_res, sp);
1363
	
1393
 
1364
	assdest = locate(lhs, nsp, sh(rhs), 0);
1394
	assdest = locate(lhs, nsp, sh(rhs), 0);
1365
 
1395
 
1366
	move(apply_res.answhere, assdest, nsp.fixed, 1);
1396
	move(apply_res.answhere, assdest, nsp.fixed, 1);
1367
	/* The evaluation of an assignment is the rhs so 
1397
	/* The evaluation of an assignment is the rhs so
1368
	   we move the rhs to dest as well */
1398
	   we move the rhs to dest as well */
1369
	move(apply_res.answhere, dest, nsp.fixed, 1);
1399
	move(apply_res.answhere, dest, nsp.fixed, 1);
1370
	clear_dep_reg(lhs);
1400
	clear_dep_reg(lhs);
1371
	
1401
 
1372
#if 0
1402
#if 0
1373
	/* +++ remember that R_RESULT is lhs */
1403
	/* +++ remember that R_RESULT is lhs */
1374
	if (!is_float)
1404
	if (!is_float)
1375
	{
1405
	{
1376
	  keepcont(lhs,R_RESULT);
1406
	  keepcont(lhs,R_RESULT);
Line 1415... Line 1445...
1415
	    setfregalt(aa, dfreg);
1445
	    setfregalt(aa, dfreg);
1416
	  }
1446
	  }
1417
	  else
1447
	  else
1418
	  {
1448
	  {
1419
	    int assreg;
1449
	    int assreg;
1420
	    if(dest.answhere.discrim==inreg && 
1450
	    if (dest.answhere.discrim==inreg &&
1421
	       !IS_R_NO_REG(regalt(dest.answhere)))
1451
	       !IS_R_NO_REG(regalt(dest.answhere)))
1422
	    {
1452
	    {
1423
	      assreg = regalt(dest.answhere);
1453
	      assreg = regalt(dest.answhere);
1424
	      reg_operand_here(rhs,nsp,assreg);
1454
	      reg_operand_here(rhs,nsp,assreg);
1425
	    }
1455
	    }
Line 1461... Line 1491...
1461
	  is.adval = 1;
1491
	  is.adval = 1;
1462
	  is.b.base = r;
1492
	  is.b.base = r;
1463
	  is.b.offset = 0;
1493
	  is.b.offset = 0;
1464
	  setinsalt(assdest.answhere, is);
1494
	  setinsalt(assdest.answhere, is);
1465
	  keepexp(lhs, assdest.answhere);
1495
	  keepexp(lhs, assdest.answhere);
1466
	}
1496
	}
1467
      }
1497
      }
1468
 
1498
 
1469
#if 1
1499
#if 1
1470
      if (name(e) == ass_tag && is_float && assdest.answhere.discrim == notinreg)
1500
      if (name(e) == ass_tag && is_float && assdest.answhere.discrim == notinreg)
1471
      {
1501
      {
Line 1559... Line 1589...
1559
	       * remember that dest contains source, provided that it is not
1589
	       * remember that dest contains source, provided that it is not
1560
	       * dependent on it
1590
	       * dependent on it
1561
	       */
1591
	       */
1562
#endif
1592
#endif
1563
#if 1
1593
#if 1
1564
	    if ( name ( lhs ) == name_tag ) {
1594
	    if (name(lhs) == name_tag) {
1565
	      exp dc = son ( lhs ) ;
1595
	      exp dc = son(lhs);
1566
	      if ( son ( dc ) != nilexp ) dc = son ( dc ) ;
1596
	      if (son(dc)!= nilexp)dc = son(dc);
1567
	      if ( shape_size ( sh ( dc ) ) ==
1597
	      if (shape_size(sh(dc)) ==
1568
		  shape_size ( sh ( rhs ) ) ) {
1598
		  shape_size(sh(rhs))) {
1569
		keepcont ( lhs, contreg ) ;
1599
		keepcont(lhs, contreg);
1570
	      }
1600
	      }
1571
	    } else if ( !dependson ( lhs, 0, lhs ) )
1601
	    } else if (!dependson(lhs, 0, lhs))
1572
#endif	
1602
#endif
1573
	    {
1603
	    {
1574
	      keepcont(lhs, contreg);
1604
	      keepcont(lhs, contreg);
1575
	    }
1605
	    }
1576
	    return mka;
1606
	    return mka;
1577
	  }
1607
	  }
1578
	  clear_dep_reg(lhs);
1608
	  clear_dep_reg(lhs);
Line 1617... Line 1647...
1617
	fix_nonbitfield(e);		/* ensure all offsets are bit-offsets,
1647
	fix_nonbitfield(e);		/* ensure all offsets are bit-offsets,
1618
					 * as evaluated_const() expects */
1648
					 * as evaluated_const() expects */
1619
 
1649
 
1620
	setinsalt(aa, evaluated_const(e));
1650
	setinsalt(aa, evaluated_const(e));
1621
	mka.regmove = move(aa, dest, sp.fixed, 0);
1651
	mka.regmove = move(aa, dest, sp.fixed, 0);
1622
 
1652
 
1623
	return mka;
1653
	return mka;
1624
      }
1654
      }
1625
 
1655
 
1626
      nsp = sp;
1656
      nsp = sp;
1627
      t = son(e);
1657
      t = son(e);
1628
      switch (dest.answhere.discrim)
1658
      switch (dest.answhere.discrim)
Line 1646... Line 1676...
1646
	    instore newis;
1676
	    instore newis;
1647
 
1677
 
1648
	    newis = str;
1678
	    newis = str;
1649
	    newis.b.offset += no(t);
1679
	    newis.b.offset += no(t);
1650
 
1680
 
1651
	    FULLCOMMENT4("make_code compound_tag: name(t)=%d no(t)=%d al2=%d offset=%d",
1681
	    FULLCOMMENT4("make_code compound_tag: name(t) =%d no(t) =%d al2=%d offset=%d",
1652
		name(t), no(t), al2(sh(t)), newis.b.offset);
1682
		name(t), no(t), al2(sh(t)), newis.b.offset);
1653
	    ASSERT(name(t) == val_tag && al2(sh(t)) >= 8);
1683
	    ASSERT(name(t) == val_tag && al2(sh(t)) >= 8);
1654
 
1684
 
1655
	    setinsalt(newdest.answhere, newis);
1685
	    setinsalt(newdest.answhere, newis);
1656
	    newdest.ashwhere = ashof(sh(bro(t)));
1686
	    newdest.ashwhere = ashof(sh(bro(t)));
Line 1662... Line 1692...
1662
 
1692
 
1663
	    t = bro(bro(t));
1693
	    t = bro(bro(t));
1664
	  }
1694
	  }
1665
	}
1695
	}
1666
#if 1	/* we need in reg compound for ptr type conversion via regs */
1696
#if 1	/* we need in reg compound for ptr type conversion via regs */
1667
      case insomereg:
1697
      case insomereg:
1668
	{
1698
	{
1669
	  int *sr = someregalt(dest.answhere);
1699
	  int *sr = someregalt(dest.answhere);
1670
 
1700
 
1671
	  if (*sr != -1)
1701
	  if (*sr != -1)
1672
	  {
1702
	  {
1673
	    fail("Somereg *2");
1703
	    fail("Somereg *2");
1674
	  }
1704
	  }
1675
	  *sr = getreg(sp.fixed);
1705
	  *sr = getreg(sp.fixed);
1676
	  setregalt(dest.answhere, *sr);
1706
	  setregalt(dest.answhere, *sr);
1677
	  /* FALLTHROUGH */
1707
	  /* FALLTHROUGH */
1678
	}
1708
	}
1679
      case inreg:
1709
      case inreg:
1680
	{
1710
	{
1681
	  code_here(bro(t), sp, dest);
1711
	  code_here(bro(t), sp, dest);
1682
	  r = regalt(dest.answhere);
1712
	  r = regalt(dest.answhere);
1683
	  ASSERT(name(t) == val_tag);
1713
	  ASSERT(name(t) == val_tag);
1684
	  if (no(t) != 0)
1714
	  if (no(t)!= 0)
1685
	    rir_ins(i_sl, r, ((al2(sh(t)) >= 8) ? (no(t) << 3) : no(t)), r);
1715
	    rir_ins(i_sl, r,((al2(sh(t)) >= 8)?(no(t) << 3): no(t)), r);
1686
	  nsp = guardreg(r, sp);
1716
	  nsp = guardreg(r, sp);
1687
	  while (!last(bro(t)))
1717
	  while (!last(bro(t)))
1688
	  {
1718
	  {
1689
	    int z;
1719
	    int z;
1690
 
1720
 
1691
	    t = bro(bro(t));
1721
	    t = bro(bro(t));
1692
	    ASSERT(name(t) == val_tag);
1722
	    ASSERT(name(t) == val_tag);
1693
	    z = reg_operand(bro(t), nsp);
1723
	    z = reg_operand(bro(t), nsp);
1694
	    if (no(t) != 0)
1724
	    if (no(t)!= 0)
1695
	    {
1725
	    {
1696
	      rir_ins(i_sl, z, ((al2(sh(t)) >= 8) ? (no(t) << 3) : no(t)), z);
1726
	      rir_ins(i_sl, z,((al2(sh(t)) >= 8)?(no(t) << 3): no(t)), z);
1697
	    }
1727
	    }
1698
	    rrr_ins(i_or, r, z, r);
1728
	    rrr_ins(i_or, r, z, r);
1699
	  }
1729
	  }
1700
	  return mka;
1730
	  return mka;
1701
	}
1731
	}
1702
#endif
1732
#endif
1703
      default:
1733
      default:
1704
	fail("no compounds in float reg");
1734
	fail("no compounds in float reg");
1705
      }
1735
      }
1706
    }				/* end tup */
1736
    }				/* end tup */
1707
/*****************************************************************************/
1737
/*****************************************************************************/
Line 1711... Line 1741...
1711
      exp t = son(e);
1741
      exp t = son(e);
1712
      space nsp;
1742
      space nsp;
1713
      instore str;
1743
      instore str;
1714
      int r, disp = 0;
1744
      int r, disp = 0;
1715
#if 1
1745
#if 1
1716
      if(t==nilexp)
1746
      if (t==nilexp)
1717
	return mka;
1747
	return mka;
1718
#endif
1748
#endif
1719
      nsp = sp;
1749
      nsp = sp;
1720
      switch (dest.answhere.discrim)
1750
      switch (dest.answhere.discrim)
1721
      {
1751
      {
Line 1723... Line 1753...
1723
	{
1753
	{
1724
	  str = insalt(dest.answhere);	/* it should be !! */
1754
	  str = insalt(dest.answhere);	/* it should be !! */
1725
	  if (!str.adval)
1755
	  if (!str.adval)
1726
	  {
1756
	  {
1727
	    int r = getreg(sp.fixed);
1757
	    int r = getreg(sp.fixed);
1728
 
1758
 
1729
	    nsp = guardreg(r, sp);
1759
	    nsp = guardreg(r, sp);
1730
	    ld_ins(i_l, str.b, r);
1760
	    ld_ins(i_l, str.b, r);
1731
	    str.adval = 1;
1761
	    str.adval = 1;
1732
	    str.b.base = r;
1762
	    str.b.base = r;
1733
	    str.b.offset = 0;
1763
	    str.b.offset = 0;
1734
	  }
1764
	  }
1735
	  for (;;)
1765
	  for (;;)
1736
	  {
1766
	  {
1737
	    where newdest;
1767
	    where newdest;
1738
	    instore newis;
1768
	    instore newis;
1739
 
1769
 
1740
	    newis = str;
1770
	    newis = str;
1741
	    newis.b.offset += disp;
1771
	    newis.b.offset += disp;
1742
	    setinsalt(newdest.answhere, newis);
1772
	    setinsalt(newdest.answhere, newis);
1743
	    newdest.ashwhere = ashof(sh(t));
1773
	    newdest.ashwhere = ashof(sh(t));
1744
	    code_here(t, nsp, newdest);
1774
	    code_here(t, nsp, newdest);
1745
	    if (last(t))
1775
	    if (last(t))
1746
	    {
1776
	    {
1747
	      return mka;
1777
	      return mka;
1748
	    }
1778
	    }
1749
	    disp += (rounder(shape_size(sh(t)), shape_align(sh(bro(t)))) >> 3);
1779
	    disp += (rounder(shape_size(sh(t)), shape_align(sh(bro(t)))) >> 3);
1750
	    t = bro(t);
1780
	    t = bro(t);
1751
	  }
1781
	  }
1752
	}
1782
	}
1753
      case insomereg:
1783
      case insomereg:
1754
	{
1784
	{
1755
	  int *sr = someregalt(dest.answhere);
1785
	  int *sr = someregalt(dest.answhere);
1756
 
1786
 
Line 1771... Line 1801...
1771
	  {
1801
	  {
1772
	    int z;
1802
	    int z;
1773
 
1803
 
1774
	    disp += rounder(shape_size(sh(t)), shape_align(sh(bro(t))));
1804
	    disp += rounder(shape_size(sh(t)), shape_align(sh(bro(t))));
1775
	    t = bro(t);
1805
	    t = bro(t);
1776
	    z = reg_operand(t, nsp);
1806
	    z = reg_operand(t, nsp);
1777
	    if (disp != 0)
1807
	    if (disp != 0)
1778
	    {
1808
	    {
1779
	      rir_ins(i_sl, z, disp, z);
1809
	      rir_ins(i_sl, z, disp, z);
1780
	    }
1810
	    }
1781
	    rrr_ins(i_or, r, z, r);
1811
	    rrr_ins(i_or, r, z, r);
1782
	  }
1812
	  }
Line 1802... Line 1832...
1802
	{
1832
	{
1803
	  str = insalt(dest.answhere);	/* it should be !! */
1833
	  str = insalt(dest.answhere);	/* it should be !! */
1804
	  if (!str.adval)
1834
	  if (!str.adval)
1805
	  {
1835
	  {
1806
	    int r = getreg(sp.fixed);
1836
	    int r = getreg(sp.fixed);
1807
	    
1837
 
1808
	    nsp = guardreg(r, sp);
1838
	    nsp = guardreg(r, sp);
1809
	    ld_ins(i_l, str.b, r);
1839
	    ld_ins(i_l, str.b, r);
1810
	    str.adval = 1;
1840
	    str.adval = 1;
1811
	    str.b.base = r;
1841
	    str.b.base = r;
1812
	    str.b.offset = 0;
1842
	    str.b.offset = 0;
1813
	  }
1843
	  }
1814
	  for (i = 1; i <= no_of_copies; i++)
1844
	  for (i = 1; i <= no_of_copies; i++)
1815
	  {
1845
	  {
1816
	    where newdest;
1846
	    where newdest;
1817
	    instore newis;
1847
	    instore newis;
1818
	    
1848
 
1819
	    newis = str;
1849
	    newis = str;
1820
	    newis.b.offset += disp;
1850
	    newis.b.offset += disp;
1821
	    setinsalt(newdest.answhere, newis);
1851
	    setinsalt(newdest.answhere, newis);
1822
	    newdest.ashwhere = ashof(sh(t));
1852
	    newdest.ashwhere = ashof(sh(t));
1823
	    code_here(t, nsp, newdest);
1853
	    code_here(t, nsp, newdest);
1824
	    disp += (rounder(shape_size(sh(t)), shape_align(sh(t))) >> 3);
1854
	    disp += (rounder(shape_size(sh(t)), shape_align(sh(t))) >> 3);
1825
	  }
1855
	  }
1826
	  return mka;
1856
	  return mka;
1827
	}
1857
	}
1828
      case insomereg:
1858
      case insomereg:
1829
	{
1859
	{
1830
	  int *sr = someregalt(dest.answhere);
1860
	  int *sr = someregalt(dest.answhere);
1831
 
1861
 
1832
	  if (*sr != -1)
1862
	  if (*sr != -1)
1833
	  {
1863
	  {
Line 1871... Line 1901...
1871
/*****************************************************************************/
1901
/*****************************************************************************/
1872
  case solve_tag:
1902
  case solve_tag:
1873
    {
1903
    {
1874
      exp m = bro(son(e));
1904
      exp m = bro(son(e));
1875
      int l = exitlab;
1905
      int l = exitlab;
1876
      
1906
 
1877
      if(dest.answhere.discrim==insomereg)
1907
      if (dest.answhere.discrim==insomereg)
1878
      {
1908
      {
1879
	/* Choose register for fixed result */
1909
	/* Choose register for fixed result */
1880
	int *sr = someregalt(dest.answhere);
1910
	int *sr = someregalt(dest.answhere);
1881
	if (*sr != -1){fail("somereg *2");}
1911
	if (*sr != -1) {fail("somereg *2");}
1882
	*sr = getreg(sp.fixed);
1912
	*sr = getreg(sp.fixed);
1883
	setregalt(dest.answhere, *sr);
1913
	setregalt(dest.answhere, *sr);
1884
      }
1914
      }
1885
      else if (dest.answhere.discrim==insomefreg)
1915
      else if (dest.answhere.discrim==insomefreg)
1886
      {
1916
      {
1887
	/* Choose register for float result */
1917
	/* Choose register for float result */
1888
	somefreg sfr;
1918
	somefreg sfr;
1889
	freg fr;
1919
	freg fr;
1890
	sfr = somefregalt(dest.answhere);
1920
	sfr = somefregalt(dest.answhere);
1891
	if (*sfr.fr != -1) { fail ("somefreg *2"); }
1921
	if (*sfr.fr != -1) { fail("somefreg *2"); }
1892
	*sfr.fr = getfreg(sp.flt);
1922
	*sfr.fr = getfreg(sp.flt);
1893
	fr.fr = *sfr.fr;
1923
	fr.fr = *sfr.fr;
1894
	fr.dble = sfr.dble;
1924
	fr.dble = sfr.dble;
1895
	setfregalt(dest.answhere, fr);
1925
	setfregalt(dest.answhere, fr);
1896
      }
1926
      }
1897
      
1927
 
1898
      /* Set up all the labels in the component labst_tags */
1928
      /* Set up all the labels in the component labst_tags */
1899
      for (;;)
1929
      for (;;)
1900
      {
1930
      {
1901
	no(son(m)) = new_label();
1931
	no(son(m)) = new_label();
1902
	if (last(m))
1932
	if (last(m))
1903
	{
1933
	{
1904
	  break;
1934
	  break;
1905
	}
1935
	}
Line 1919... Line 1949...
1919
	}
1949
	}
1920
	if (!last(m))
1950
	if (!last(m))
1921
	{
1951
	{
1922
	  /* jump to end of solve */
1952
	  /* jump to end of solve */
1923
	  if (l == 0)
1953
	  if (l == 0)
1924
	  {
1954
	  {
1925
	    l = new_label();
1955
	    l = new_label();
1926
	  }
1956
	  }
1927
	  if (name(sh(m)) != bothd)
1957
	  if (name(sh(m))!= bothd)
1928
	  {
1958
	  {
1929
	    uncond_ins(i_b, l);
1959
	    uncond_ins(i_b, l);
1930
	  }
1960
	  }
1931
	}
1961
	}
1932
	if (last(m))
1962
	if (last(m))
1933
	{
1963
	{
1934
	  mka.lab = l;
1964
	  mka.lab = l;
1935
	  return mka;
1965
	  return mka;
1936
	};
1966
	};
Line 1944... Line 1974...
1944
      int control_reg;
1974
      int control_reg;
1945
      control_reg = reg_operand(control,sp);
1975
      control_reg = reg_operand(control,sp);
1946
      case_tag_code(control_reg, e, sp);
1976
      case_tag_code(control_reg, e, sp);
1947
      return mka;
1977
      return mka;
1948
    }				/* end case */
1978
    }				/* end case */
1949
/*****************************************************************************/
1979
/*****************************************************************************/
1950
  case plus_tag:
1980
  case plus_tag:
1951
    {
1981
    {
1952
      if (!optop(e))
1982
      if (!optop(e))
1953
      {
1983
      {
1954
	mka.regmove = plus_error_treatment(e,sp,dest);
1984
	mka.regmove = plus_error_treatment(e,sp,dest);
1955
      }  
1985
      }
1956
      else
1986
      else
1957
      {
1987
      {
1958
	if (isrecordbit(e))
1988
	if (isrecordbit(e))
1959
	{
1989
	{
1960
	  mka.regmove = comm_op(e, sp, dest, i_a_cr);
1990
	  mka.regmove = comm_op(e, sp, dest, i_a_cr);
1961
	  cr0_set = 1;
1991
	  cr0_set = 1;
1962
	}
1992
	}
1963
	else
1993
	else
1964
	{
1994
	{
1965
	  mka.regmove = comm_op(e, sp, dest, i_a);
1995
	  mka.regmove = comm_op(e, sp, dest, i_a);
1966
	}
1996
	}
1967
      }
1997
      }
Line 1975... Line 2005...
1975
      int to = name(sh(e));		/* to hd                             */
2005
      int to = name(sh(e));		/* to hd                             */
1976
      int from;				/* from hd                           */
2006
      int from;				/* from hd                           */
1977
      int sreg;			        /* source reg                        */
2007
      int sreg;			        /* source reg                        */
1978
      int dreg;  			/* dest reg, or temp for memory dest */
2008
      int dreg;  			/* dest reg, or temp for memory dest */
1979
      bool inmem_dest;		        /* is dest in memory ? */
2009
      bool inmem_dest;		        /* is dest in memory ? */
1980
      
2010
 
1981
 
2011
 
1982
      /*
2012
      /*
1983
       * For a series of chvar_tags, do large to small in one go 
2013
       * For a series of chvar_tags, do large to small in one go
1984
       */
2014
       */
1985
      while (name(arg) == chvar_tag && 
2015
      while (name(arg) == chvar_tag &&
1986
	     ashof(sh(arg)).ashsize >= size_e && NO_ERROR_TREATMENT(arg))
2016
	     ashof(sh(arg)).ashsize >= size_e && NO_ERROR_TREATMENT(arg))
1987
      {
2017
      {
1988
	COMMENT1("make_code chvar_tag: skipping intermediate shape %d",name(sh(arg)));
2018
	COMMENT1("make_code chvar_tag: skipping intermediate shape %d",name(sh(arg)));
1989
	arg = son(arg);
2019
	arg = son(arg);
1990
      }
2020
      }
1991
      
2021
 
1992
      if (ERROR_TREATMENT(e))
2022
      if (ERROR_TREATMENT(e))
1993
      {
2023
      {
1994
	mka.regmove = chvar_error_treatment(e,sp,dest);
2024
	mka.regmove = chvar_error_treatment(e,sp,dest);
1995
	return mka;
2025
	return mka;
1996
      }
2026
      }
1997
      
2027
 
1998
 
2028
 
1999
      from = name(sh(arg));
2029
      from = name(sh(arg));
2000
      if ( from == to ||
2030
      if (from == to ||
2001
	  to == slonghd ||
2031
	  to == slonghd ||
2002
	  to == ulonghd ||
2032
	  to == ulonghd ||
2003
	  (to == uwordhd && from == ucharhd) ||
2033
	 (to == uwordhd && from == ucharhd) ||
2004
	  (to == swordhd && (from == scharhd || from == ucharhd)) ||
2034
	 (to == swordhd && (from == scharhd || from == ucharhd)) ||
2005
	  (to>=slonghd)
2035
	 (to>=slonghd)
2006
	  )
2036
	 )
2007
      {
2037
      {
2008
	/* 
2038
	/*
2009
	 * No changes required, so just move handling dest insomereg well 
2039
	 * No changes required, so just move handling dest insomereg well
2010
	 */
2040
	 */
2011
	ans aa;
2041
	ans aa;
2012
	
2042
 
2013
	COMMENT("make_code chvar_tag: no change");
2043
	COMMENT("make_code chvar_tag: no change");
2014
	switch (dest.answhere.discrim)
2044
	switch (dest.answhere.discrim)
2015
	{
2045
	{
2016
	 case inreg:
2046
	 case inreg:
2017
	  sreg = regalt(dest.answhere);
2047
	  sreg = regalt(dest.answhere);
Line 2020... Line 2050...
2020
	    reg_operand_here(arg, sp, sreg);
2050
	    reg_operand_here(arg, sp, sreg);
2021
	    break;
2051
	    break;
2022
	  }
2052
	  }
2023
	  /* result being voided, treat as default */
2053
	  /* result being voided, treat as default */
2024
	  /*FALLTHROUGH*/
2054
	  /*FALLTHROUGH*/
2025
	  
2055
 
2026
	 default:
2056
	 default:
2027
	  sreg = reg_operand(arg, sp);
2057
	  sreg = reg_operand(arg, sp);
2028
	}
2058
	}
2029
	
2059
 
2030
	setregalt(aa, sreg);
2060
	setregalt(aa, sreg);
2031
	mka.regmove = move(aa, dest, sp.fixed, is_signed(sh(e)) );
2061
	mka.regmove = move(aa, dest, sp.fixed, is_signed(sh(e)));
2032
	return mka;
2062
	return mka;
2033
      }
2063
      }
2034
 
2064
 
2035
      switch (dest.answhere.discrim)
2065
      switch (dest.answhere.discrim)
2036
      {
2066
      {
Line 2101... Line 2131...
2101
      return mka;
2131
      return mka;
2102
    }				/* end chvar */
2132
    }				/* end chvar */
2103
/*****************************************************************************/
2133
/*****************************************************************************/
2104
   case minus_tag:
2134
   case minus_tag:
2105
    {
2135
    {
2106
      if(ERROR_TREATMENT(e))
2136
      if (ERROR_TREATMENT(e))
2107
      {
2137
      {
2108
	mka.regmove = minus_error_treatment(e,sp,dest);
2138
	mka.regmove = minus_error_treatment(e,sp,dest);
2109
      }
2139
      }
2110
      else
2140
      else
2111
      {
2141
      {
Line 2144... Line 2174...
2144
   case mod_tag:
2174
   case mod_tag:
2145
   case rem0_tag:
2175
   case rem0_tag:
2146
   case rem2_tag:
2176
   case rem2_tag:
2147
    {
2177
    {
2148
      bool sgned = is_signed(sh(e));
2178
      bool sgned = is_signed(sh(e));
2149
      
2179
 
2150
      mka.regmove = do_rem_op(e, sp, dest, sgned);
2180
      mka.regmove = do_rem_op(e, sp, dest, sgned);
2151
      return mka;
2181
      return mka;
2152
    }				/* end rem */
2182
    }				/* end rem */
2153
/*****************************************************************************/
2183
/*****************************************************************************/
2154
  case neg_tag:
2184
  case neg_tag:
2155
  case offset_negate_tag:
2185
  case offset_negate_tag:
2156
    {
2186
    {
2157
      if (ERROR_TREATMENT(e))
2187
      if (ERROR_TREATMENT(e))
2158
      {
2188
      {
2159
	mka.regmove = neg_error_treatment(e,sp,dest);
2189
	mka.regmove = neg_error_treatment(e,sp,dest);
2160
      }
2190
      }
2161
      else
2191
      else
2162
      {
2192
      {
2163
	int r = reg_operand(son(e),sp);
2193
	int r = reg_operand(son(e),sp);
2164
	int destr = regfrmdest(&dest,sp);
2194
	int destr = regfrmdest(&dest,sp);
2165
	space nsp;
2195
	space nsp;
2166
	ans aa;
2196
	ans aa;
2167
	
2197
 
2168
	nsp = guardreg(destr,sp);
2198
	nsp = guardreg(destr,sp);
2169
	rr_ins(i_neg, r, destr);
2199
	rr_ins(i_neg, r, destr);
2170
#if 0
2200
#if 0
2171
  tidyshort(destr, e);
2201
  tidyshort(destr, e);
2172
#endif
2202
#endif
Line 2188... Line 2218...
2188
      {
2218
      {
2189
	int r = reg_operand(son(e),sp);
2219
	int r = reg_operand(son(e),sp);
2190
	int destr = regfrmdest(&dest,sp);
2220
	int destr = regfrmdest(&dest,sp);
2191
	space nsp;
2221
	space nsp;
2192
	ans aa;
2222
	ans aa;
2193
	
2223
 
2194
	nsp = guardreg(destr,sp);
2224
	nsp = guardreg(destr,sp);
2195
	rr_ins(i_abs, r, destr);
2225
	rr_ins(i_abs, r, destr);
2196
#if 0
2226
#if 0
2197
  tidyshort(destr, e);
2227
  tidyshort(destr, e);
2198
#endif
2228
#endif
Line 2212... Line 2242...
2212
      ans aa;
2242
      ans aa;
2213
      space nsp;
2243
      space nsp;
2214
      bool sgned = is_signed(sh(e));
2244
      bool sgned = is_signed(sh(e));
2215
      Instruction_P shift_ins;
2245
      Instruction_P shift_ins;
2216
      bool record_bit = isrecordbit(e);
2246
      bool record_bit = isrecordbit(e);
2217
      
2247
 
2218
 
2248
 
2219
#if 1
2249
#if 1
2220
      int sz = shape_size(sh(s));
2250
      int sz = shape_size(sh(s));
2221
#if 0
2251
#if 0
2222
      bool lded = ((name (s) == name_tag && regofval (s) >= 100)
2252
      bool lded = ((name(s) == name_tag && regofval(s) >= 100)
2223
		   || (name (s) == cont_tag &&
2253
		   || (name(s) == cont_tag &&
2224
		       (name (son (s)) != name_tag || regofval (son (s)) > 0)
2254
		      (name(son(s))!= name_tag || regofval(son(s)) > 0)
2225
		       )
2255
		      )
2226
		   ); 
2256
		  );
2227
#endif
2257
#endif
2228
      bool signok = (sz == 32); /* better safe than sorry for the time being */
2258
      bool signok = (sz == 32); /* better safe than sorry for the time being */
2229
      if(name(son(e))==shl_tag && shape_size(sh(son(s)))!=32)
2259
      if (name(son(e)) ==shl_tag && shape_size(sh(son(s)))!=32)
2230
      {
2260
      {
2231
	signok=1;
2261
	signok=1;
2232
      }
2262
      }
2233
#endif
2263
#endif
2234
      if (ERROR_TREATMENT(e))
2264
      if (ERROR_TREATMENT(e))
2235
      {
2265
      {
2236
	fail("Unexpected error treatment for shl");
2266
	fail("Unexpected error treatment for shl");
2237
      }
2267
      }
2238
      if(name(s)==and_tag && name(b)==val_tag &&
2268
      if (name(s) ==and_tag && name(b) ==val_tag &&
2239
	 name(bro(son(s)))==val_tag &&
2269
	 name(bro(son(s))) ==val_tag &&
2240
	 is_a_mask(no(bro(son(s)))) &&
2270
	 is_a_mask(no(bro(son(s)))) &&
2241
	 shape_size(sh(e))==32)
2271
	 shape_size(sh(e)) ==32)
2242
      {
2272
      {
2243
	unsigned int mask= (unsigned int)no(bro(son(s)));
2273
	unsigned int mask= (unsigned int)no(bro(son(s)));
2244
	int mask_left = left_of_mask(mask);
2274
	int mask_left = left_of_mask(mask);
2245
	int rotation_left;
2275
	int rotation_left;
2246
	bool use_rlinm_ins = 0;
2276
	bool use_rlinm_ins = 0;
2247
	
2277
 
2248
	if (name(e)==shl_tag)
2278
	if (name(e) ==shl_tag)
2249
	{
2279
	{
2250
	  int shift_left = no(b);
2280
	  int shift_left = no(b);
2251
	  mask = mask<<shift_left;
2281
	  mask = mask<<shift_left;
2252
	  rotation_left = shift_left;
2282
	  rotation_left = shift_left;
2253
	  use_rlinm_ins = 1;
2283
	  use_rlinm_ins = 1;
Line 2264... Line 2294...
2264
	    int shift_right = no(b);
2294
	    int shift_right = no(b);
2265
	    mask = mask>>shift_right;
2295
	    mask = mask>>shift_right;
2266
	    rotation_left = 32 - shift_right;
2296
	    rotation_left = 32 - shift_right;
2267
	  }
2297
	  }
2268
	}
2298
	}
2269
	
2299
 
2270
	if (use_rlinm_ins==1)
2300
	if (use_rlinm_ins==1)
2271
	{
2301
	{
2272
	  a = reg_operand(son(s),sp);
2302
	  a = reg_operand(son(s),sp);
2273
	  d = regfrmdest(&dest,sp);
2303
	  d = regfrmdest(&dest,sp);
2274
 
2304
 
2275
	  if(isrecordbit(e))
2305
	  if (isrecordbit(e))
2276
	  {
2306
	  {
2277
	    rlinm_ins(i_rlinm_cr,a,rotation_left,mask,d);
2307
	    rlinm_ins(i_rlinm_cr,a,rotation_left,mask,d);
2278
	  }
2308
	  }
2279
	  else
2309
	  else
2280
	  {
2310
	  {
2281
	    rlinm_ins(i_rlinm,a,rotation_left,mask,d);
2311
	    rlinm_ins(i_rlinm,a,rotation_left,mask,d);
2282
	  }
2312
	  }
2283
	  setregalt(aa,d);
2313
	  setregalt(aa,d);
2284
	  move(aa,dest,sp.fixed,0);
2314
	  move(aa,dest,sp.fixed,0);
2285
	  return mka; 
2315
	  return mka;
2286
	}
2316
	}
2287
      }
2317
      }
2288
      
2318
 
2289
      a = reg_operand(s, sp);
2319
      a = reg_operand(s, sp);
2290
 
2320
 
2291
      if (!signok && name(e)==shr_tag) 
2321
      if (!signok && name(e) ==shr_tag)
2292
      {
2322
      {
2293
	/* 
2323
	/*
2294
	 * If doing a shift right we must sign extend 
2324
	 * If doing a shift right we must sign extend
2295
	 * or truncate prior to shifting
2325
	 * or truncate prior to shifting
2296
	 */
2326
	 */
2297
	adjust_to_size(ulonghd,a,name(sh(e)),a,NO_ERROR_JUMP);
2327
	adjust_to_size(ulonghd,a,name(sh(e)),a,NO_ERROR_JUMP);
2298
      }
2328
      }
2299
      if (name(e) == shr_tag)
2329
      if (name(e) == shr_tag)
2300
      {
2330
      {
2301
	if(record_bit==1)
2331
	if (record_bit==1)
2302
	{
2332
	{
2303
	  shift_ins = (sgned) ? i_sra_cr : i_sr_cr;
2333
	  shift_ins = (sgned)? i_sra_cr : i_sr_cr;
2304
	  cr0_set = 1;
2334
	  cr0_set = 1;
2305
	}
2335
	}
2306
	else
2336
	else
2307
	{
2337
	{
2308
	  shift_ins = (sgned) ? i_sra : i_sr;
2338
	  shift_ins = (sgned)? i_sra : i_sr;
2309
	}
2339
	}
2310
      }
2340
      }
2311
      else
2341
      else
2312
      {
2342
      {
2313
	shift_ins = i_sl;
2343
	shift_ins = i_sl;
2314
      }
2344
      }
2315
      nsp = guardreg(a, sp);
2345
      nsp = guardreg(a, sp);
2316
      d = regfrmdest(&dest,nsp);
2346
      d = regfrmdest(&dest,nsp);
2317
      
2347
 
2318
      if (name(b) == val_tag)
2348
      if (name(b) == val_tag)
2319
      {
2349
      {
2320
	/* Only defined for shifts by 0..31 */
2350
	/* Only defined for shifts by 0..31 */
2321
	int n = no(b);
2351
	int n = no(b);
2322
	int n31 = n & 31;
2352
	int n31 = n & 31;
Line 2330... Line 2360...
2330
	  rir_ins(shift_ins, a, n, d);	/* usual case */
2360
	  rir_ins(shift_ins, a, n, d);	/* usual case */
2331
	}
2361
	}
2332
	else
2362
	else
2333
	{			/* Undefined, produce same effect as if */
2363
	{			/* Undefined, produce same effect as if */
2334
	  ld_const_ins(0, d);	/* not a constant,0 */
2364
	  ld_const_ins(0, d);	/* not a constant,0 */
2335
	}				
2365
	}
2336
      }
2366
      }
2337
      else
2367
      else
2338
      {
2368
      {
2339
	int ar = reg_operand(b, nsp);
2369
	int ar = reg_operand(b, nsp);
2340
	rrr_ins(shift_ins, a, ar, d);
2370
	rrr_ins(shift_ins, a, ar, d);
2341
      }
2371
      }
2342
      if(!signok && name(e)==shl_tag)
2372
      if (!signok && name(e) ==shl_tag)
2343
      {
2373
      {
2344
	/* 
2374
	/*
2345
	 * If doing a shift left we must sign extend 
2375
	 * If doing a shift left we must sign extend
2346
	 * or truncate after the shift
2376
	 * or truncate after the shift
2347
	 */
2377
	 */
2348
	adjust_to_size(ulonghd,d,name(sh(e)),d,NO_ERROR_JUMP);
2378
	adjust_to_size(ulonghd,d,name(sh(e)),d,NO_ERROR_JUMP);
2349
      }
2379
      }
2350
      setregalt(aa, d);
2380
      setregalt(aa, d);
2351
      move(aa, dest, nsp.fixed, 1);
2381
      move(aa, dest, nsp.fixed, 1);
2352
      mka.regmove = d;
2382
      mka.regmove = d;
2353
      return mka;
2383
      return mka;
2354
    }				/* end shl, shr */
2384
    }				/* end shl, shr */
2355
/*****************************************************************************/
2385
/*****************************************************************************/
2356
   case minptr_tag:
2386
   case minptr_tag:
2357
   case make_stack_limit_tag:
2387
   case make_stack_limit_tag:
2358
    {
2388
    {
2359
      mka.regmove = non_comm_op(e, sp, dest, i_s);
2389
      mka.regmove = non_comm_op(e, sp, dest, i_s);
2360
      return mka;
2390
      return mka;
2361
    }
2391
    }
2362
/*****************************************************************************/
2392
/*****************************************************************************/
2363
   case fplus_tag:
2393
   case fplus_tag:
2364
    {
2394
    {
2365
      mka.regmove =
2395
      mka.regmove =
2366
	fop(e, sp, dest, is_single_precision(sh(e)) ? i_fa : i_fa);
2396
	fop(e, sp, dest, is_single_precision(sh(e))? i_fa : i_fa);
2367
      return mka;
2397
      return mka;
2368
    }
2398
    }
2369
/*****************************************************************************/
2399
/*****************************************************************************/
2370
  case fminus_tag:
2400
  case fminus_tag:
2371
    {
2401
    {
2372
      mka.regmove =
-
 
2373
	fop(e, sp, dest, is_single_precision(sh(e)) ? i_fs : i_fs);
-
 
2374
      return mka;
-
 
2375
    }
-
 
2376
/*****************************************************************************/
-
 
2377
  case fmult_tag:
-
 
2378
    {
-
 
2379
      mka.regmove =
2402
      mka.regmove =
2380
	fop(e, sp, dest, is_single_precision(sh(e)) ? i_fm : i_fm);
2403
	fop(e, sp, dest, is_single_precision(sh(e))? i_fs : i_fs);
2381
      return mka;
2404
      return mka;
2382
    }
2405
    }
2383
/*****************************************************************************/
2406
/*****************************************************************************/
2384
  case fdiv_tag:
2407
  case fmult_tag:
2385
    {
2408
    {
2386
      mka.regmove =
2409
      mka.regmove =
-
 
2410
	fop(e, sp, dest, is_single_precision(sh(e))? i_fm : i_fm);
-
 
2411
      return mka;
-
 
2412
    }
-
 
2413
/*****************************************************************************/
-
 
2414
  case fdiv_tag:
-
 
2415
    {
-
 
2416
      mka.regmove =
2387
	fop(e, sp, dest, is_single_precision(sh(e)) ? i_fd : i_fd);
2417
	fop(e, sp, dest, is_single_precision(sh(e))? i_fd : i_fd);
2388
      return mka;
2418
      return mka;
2389
    }
2419
    }
2390
/*****************************************************************************/
2420
/*****************************************************************************/
2391
  case fneg_tag:
2421
  case fneg_tag:
2392
    {
2422
    {
2393
      mka.regmove =
2423
      mka.regmove =
2394
	fmop(e, sp, dest, is_single_precision(sh(e)) ? i_fneg : i_fneg);
2424
	fmop(e, sp, dest, is_single_precision(sh(e))? i_fneg : i_fneg);
2395
      return mka;
2425
      return mka;
2396
    }
2426
    }
2397
/*****************************************************************************/
2427
/*****************************************************************************/
2398
  case fabs_tag:
2428
  case fabs_tag:
2399
    {
2429
    {
2400
      mka.regmove =
2430
      mka.regmove =
2401
	fmop(e, sp, dest, is_single_precision(sh(e)) ? i_fabs : i_fabs);
2431
	fmop(e, sp, dest, is_single_precision(sh(e))? i_fabs : i_fabs);
2402
      return mka;
2432
      return mka;
2403
    }
2433
    }
2404
/*****************************************************************************/
2434
/*****************************************************************************/
2405
  case float_tag:
2435
  case float_tag:
2406
    {
2436
    {
2407
      exp in = son(e);
2437
      exp in = son(e);
2408
      int f = (dest.answhere.discrim == infreg) ?
2438
      int f = (dest.answhere.discrim == infreg)?
2409
		fregalt(dest.answhere).fr :
2439
		fregalt(dest.answhere).fr :
2410
		getfreg(sp.flt);
2440
		getfreg(sp.flt);
2411
      freg frg;
2441
      freg frg;
2412
      ans aa;
2442
      ans aa;
2413
      bool from_sgned = is_signed(sh(in));
2443
      bool from_sgned = is_signed(sh(in));
Line 2447... Line 2477...
2447
	rrrf_ins(i_fs, f1, f, f);
2477
	rrrf_ins(i_fs, f1, f, f);
2448
      }
2478
      }
2449
 
2479
 
2450
      setfregalt(aa, frg);
2480
      setfregalt(aa, frg);
2451
      move(aa, dest, sp.fixed, 1);
2481
      move(aa, dest, sp.fixed, 1);
2452
      mka.regmove = (frg.dble) ? -(f + 32) : (f + 32);
2482
      mka.regmove = (frg.dble)? - (f + 32):(f + 32);
2453
      return mka;
2483
      return mka;
2454
    }
2484
    }
2455
/*****************************************************************************/
2485
/*****************************************************************************/
2456
  case chfl_tag:
2486
  case chfl_tag:
2457
    {
2487
    {
2458
      int to = name(sh(e));
2488
      int to = name(sh(e));
2459
      int from = name(sh(son(e)));
2489
      int from = name(sh(son(e)));
2460
      bool dto = (to != shrealhd);
2490
      bool dto = (to != shrealhd);
2461
      bool dfrom = (from != shrealhd);
2491
      bool dfrom = (from != shrealhd);
2462
      
2492
 
2463
      if (dto==dfrom)
2493
      if (dto==dfrom)
2464
      {
2494
      {
2465
	/* no change in representation */
2495
	/* no change in representation */
2466
	return make_code(son(e), sp, dest, exitlab);
2496
	return make_code(son(e), sp, dest, exitlab);
2467
      }
2497
      }
Line 2474... Line 2504...
2474
	frg = fregfrmdest(dfrom,&dest,sp);
2504
	frg = fregfrmdest(dfrom,&dest,sp);
2475
	setfregalt(aa, frg);
2505
	setfregalt(aa, frg);
2476
	w.answhere = aa;
2506
	w.answhere = aa;
2477
	w.ashwhere = ashof(sh(son(e)));
2507
	w.ashwhere = ashof(sh(son(e)));
2478
	code_here(son(e), sp, w);
2508
	code_here(son(e), sp, w);
2479
	if ( to==shrealhd )
2509
	if (to==shrealhd)
2480
	{
2510
	{
2481
	  if (ERROR_TREATMENT(e))
2511
	  if (ERROR_TREATMENT(e))
2482
	  {
2512
	  {
2483
	    chfl_error_treatment(e,frg.fr);
2513
	    chfl_error_treatment(e,frg.fr);
2484
	  }
2514
	  }
Line 2488... Line 2518...
2488
	  }
2518
	  }
2489
	}
2519
	}
2490
	frg.dble = dto;
2520
	frg.dble = dto;
2491
	setfregalt(aa, frg);
2521
	setfregalt(aa, frg);
2492
	move(aa, dest, sp.fixed, 1);
2522
	move(aa, dest, sp.fixed, 1);
2493
	mka.regmove = (frg.dble) ? -(frg.fr + 32) : (frg.fr + 32);
2523
	mka.regmove = (frg.dble)? - (frg.fr + 32):(frg.fr + 32);
2494
	return mka;
2524
	return mka;
2495
      }
2525
      }
2496
    }
2526
    }
2497
/*****************************************************************************/
2527
/*****************************************************************************/
2498
  case and_tag:
2528
  case and_tag:
2499
    {
2529
    {
2500
      exp arg1 = son(e);
2530
      exp arg1 = son(e);
2501
      exp arg2 = bro(arg1);
2531
      exp arg2 = bro(arg1);
2502
      
2532
 
2503
      if (name(arg2)==val_tag &&
2533
      if (name(arg2) ==val_tag &&
2504
	  is_a_mask(no(arg2)) &&
2534
	  is_a_mask(no(arg2)) &&
2505
	  shape_size(sh(e))==32 &&
2535
	  shape_size(sh(e)) ==32 &&
2506
	  (name(arg1)==shl_tag || name(arg1)==shr_tag) &&
2536
	 (name(arg1) ==shl_tag || name(arg1) ==shr_tag) &&
2507
	  name(bro(son(arg1)))==val_tag)
2537
	  name(bro(son(arg1))) ==val_tag)
2508
      {
2538
      {
2509
	unsigned int mask = (unsigned int)no(arg2);
2539
	unsigned int mask = (unsigned int)no(arg2);
2510
	int mask_left = left_of_mask(mask);
2540
	int mask_left = left_of_mask(mask);
2511
	int mask_right = right_of_mask(mask);
2541
	int mask_right = right_of_mask(mask);
2512
	bool use_rlinm_ins = 0;
2542
	bool use_rlinm_ins = 0;
2513
	long rotation_left;
2543
	long rotation_left;
2514
	
2544
 
2515
	if (name(arg1)==shl_tag)
2545
	if (name(arg1) ==shl_tag)
2516
	{
2546
	{
2517
	  int shift_left = no(bro(son(arg1)));
2547
	  int shift_left = no(bro(son(arg1)));
2518
	  if (shift_left<=mask_right)
2548
	  if (shift_left<=mask_right)
2519
	  {
2549
	  {
2520
	    rotation_left = shift_left;
2550
	    rotation_left = shift_left;
2521
	    use_rlinm_ins=1;
2551
	    use_rlinm_ins=1;
2522
	  }
2552
	  }
2523
	}
2553
	}
2524
	else if (name(arg1)==shr_tag )
2554
	else if (name(arg1) ==shr_tag)
2525
	{
2555
	{
2526
	  int shift_right = no(bro(son(arg1)));
2556
	  int shift_right = no(bro(son(arg1)));
2527
	  if (shift_right<=(31-mask_left))
2557
	  if (shift_right<= (31-mask_left))
2528
	  {
2558
	  {
2529
	    rotation_left = 32 - shift_right;
2559
	    rotation_left = 32 - shift_right;
2530
	    use_rlinm_ins=1;
2560
	    use_rlinm_ins=1;
2531
	  }
2561
	  }
2532
	}
2562
	}
2533
	
2563
 
2534
	if (use_rlinm_ins==1)
2564
	if (use_rlinm_ins==1)
2535
	{
2565
	{
2536
	  int r = reg_operand(son(arg1),sp);
2566
	  int r = reg_operand(son(arg1),sp);
2537
	  int dr = regfrmdest(&dest,sp);
2567
	  int dr = regfrmdest(&dest,sp);
2538
	  ans aa;
2568
	  ans aa;
2539
	  
2569
 
2540
	  if(isrecordbit(e))
2570
	  if (isrecordbit(e))
2541
	  {
2571
	  {
2542
	    rlinm_ins(i_rlinm_cr,r,rotation_left,mask,dr);
2572
	    rlinm_ins(i_rlinm_cr,r,rotation_left,mask,dr);
2543
	  }
2573
	  }
2544
	  else
2574
	  else
2545
	  {
2575
	  {
Line 2548... Line 2578...
2548
	  setregalt(aa,dr);
2578
	  setregalt(aa,dr);
2549
	  move(aa,dest,sp.fixed,0);
2579
	  move(aa,dest,sp.fixed,0);
2550
	  return mka;
2580
	  return mka;
2551
	}
2581
	}
2552
      }
2582
      }
2553
      
2583
 
2554
	
2584
 
2555
	  
2585
 
2556
      if(isrecordbit(e))
2586
      if (isrecordbit(e))
2557
      {
2587
      {
2558
	mka.regmove = comm_op(e, sp, dest, i_and_cr);
2588
	mka.regmove = comm_op(e, sp, dest, i_and_cr);
2559
	cr0_set = 1;
2589
	cr0_set = 1;
2560
      }
2590
      }
2561
      else
2591
      else
2562
      {
2592
      {
2563
	mka.regmove = comm_op(e, sp, dest, i_and);
2593
	mka.regmove = comm_op(e, sp, dest, i_and);
2564
      }
2594
      }
2565
      
2595
 
2566
      return mka;
2596
      return mka;
2567
    }
2597
    }
2568
/*****************************************************************************/
2598
/*****************************************************************************/
2569
  case or_tag:
2599
  case or_tag:
2570
    {
2600
    {
2571
      mka.regmove = comm_op(e, sp, dest, i_or);
2601
      mka.regmove = comm_op(e, sp, dest, i_or);
2572
      return mka;
2602
      return mka;
2573
    }
2603
    }
2574
/*****************************************************************************/
2604
/*****************************************************************************/
2575
  case xor_tag:
2605
  case xor_tag:
2576
    {
2606
    {
2577
      mka.regmove = comm_op(e, sp, dest, i_xor);
2607
      mka.regmove = comm_op(e, sp, dest, i_xor);
2578
      return mka;
2608
      return mka;
2579
    }
2609
    }
Line 2582... Line 2612...
2582
    {
2612
    {
2583
      /* i_not is a pseudo instruction expanded to sfi dest,-1,src */
2613
      /* i_not is a pseudo instruction expanded to sfi dest,-1,src */
2584
      int a1=reg_operand(son(e),sp);
2614
      int a1=reg_operand(son(e),sp);
2585
      ans aa;
2615
      ans aa;
2586
      int d=regfrmdest(&dest,sp);
2616
      int d=regfrmdest(&dest,sp);
2587
 
2617
 
2588
      rr_ins(i_not,a1,d);
2618
      rr_ins(i_not,a1,d);
2589
      adjust_to_size(ulonghd,d,name(sh(e)),d,NO_ERROR_JUMP);
2619
      adjust_to_size(ulonghd,d,name(sh(e)),d,NO_ERROR_JUMP);
2590
      setregalt(aa,d);
2620
      setregalt(aa,d);
2591
      move(aa,dest,guardreg(d,sp).fixed,1);
2621
      move(aa,dest,guardreg(d,sp).fixed,1);
2592
      mka.regmove =d ;
2622
      mka.regmove =d;
2593
      
2623
 
2594
      return mka;
2624
      return mka;
2595
    }
2625
    }
2596
/*****************************************************************************/
2626
/*****************************************************************************/
2597
  case cont_tag:
2627
  case cont_tag:
2598
  case contvol_tag:
2628
  case contvol_tag:
Line 2606... Line 2636...
2606
	 */
2636
	 */
2607
	COMMENT("make_code: Load volatile");
2637
	COMMENT("make_code: Load volatile");
2608
	clear_all();
2638
	clear_all();
2609
      }
2639
      }
2610
      /*
2640
      /*
2611
       * Check to see if we can use 
2641
       * Check to see if we can use
2612
       * [reg+reg] addressing for this load 
2642
       * [reg+reg] addressing for this load
2613
       */
2643
       */
2614
      if (name(son(e)) == addptr_tag)
2644
      if (name(son(e)) == addptr_tag)
2615
      {
2645
      {
2616
	shape cont_shape = sh(e);
2646
	shape cont_shape = sh(e);
2617
	int cont_size = shape_size(cont_shape);
2647
	int cont_size = shape_size(cont_shape);
Line 2650... Line 2680...
2650
	    setfregalt(aa, dfreg);
2680
	    setfregalt(aa, dfreg);
2651
	  }
2681
	  }
2652
	  else
2682
	  else
2653
	  {
2683
	  {
2654
	    int dreg = regfrmdest(&dest,sp);
2684
	    int dreg = regfrmdest(&dest,sp);
2655
	    
2685
 
2656
	    ld_rr_ins(i_ld_sz(cont_size,sgned), lhsreg, rhsreg, dreg);
2686
	    ld_rr_ins(i_ld_sz(cont_size,sgned), lhsreg, rhsreg, dreg);
2657
	    if (sgned && cont_size==8)
2687
	    if (sgned && cont_size==8)
2658
	    {
2688
	    {
2659
	      /* No load signed byte instruction, so propagate sign
2689
	      /* No load signed byte instruction, so propagate sign
2660
	       */
2690
	       */
Line 2677... Line 2707...
2677
   case addptr_tag:
2707
   case addptr_tag:
2678
   case subptr_tag:
2708
   case subptr_tag:
2679
    {
2709
    {
2680
      where w;
2710
      where w;
2681
      bool sgned;
2711
      bool sgned;
2682
      int dr = (dest.answhere.discrim == inreg) ? dest.answhere.val.regans : 0;
2712
      int dr = (dest.answhere.discrim == inreg)? dest.answhere.val.regans : 0;
2683
      w = locate(e, sp, sh(e), dr);		/* address of arg */
2713
      w = locate(e, sp, sh(e), dr);		/* address of arg */
2684
      sgned = (w.ashwhere.ashsize >= 32) || is_signed(sh(e));
2714
      sgned = (w.ashwhere.ashsize >= 32) || is_signed(sh(e));
2685
      /* +++ load real into float reg, move uses fixed reg */
2715
      /* +++ load real into float reg, move uses fixed reg */
2686
      mka.regmove = move(w.answhere, dest, (guard(w, sp)).fixed, sgned);
2716
      mka.regmove = move(w.answhere, dest,(guard(w, sp)).fixed, sgned);
2687
      if (name(e) == contvol_tag)
2717
      if (name(e) == contvol_tag)
2688
	mka.regmove = NOREG;
2718
	mka.regmove = NOREG;
2689
      return mka;
2719
      return mka;
2690
    }				/* end cont */
2720
    }				/* end cont */
2691
/*****************************************************************************/
2721
/*****************************************************************************/
Line 2693... Line 2723...
2693
  case real_tag:
2723
  case real_tag:
2694
    {
2724
    {
2695
      instore isa;
2725
      instore isa;
2696
      ans aa;
2726
      ans aa;
2697
      bool sgned = ((ashof(sh(e)).ashsize >= 32) || is_signed(sh(e)));
2727
      bool sgned = ((ashof(sh(e)).ashsize >= 32) || is_signed(sh(e)));
2698
      
2728
 
2699
      /*
2729
      /*
2700
       * Place constant in appropriate data segment 
2730
       * Place constant in appropriate data segment
2701
       */
2731
       */
2702
      isa = evaluated_const(e);
2732
      isa = evaluated_const(e);
2703
      setinsalt(aa, isa);
2733
      setinsalt(aa, isa);
2704
      mka.regmove = move(aa, dest, sp.fixed, sgned);
2734
      mka.regmove = move(aa, dest, sp.fixed, sgned);
2705
      return mka;
2735
      return mka;
2706
    }				/* end eval */
2736
    }				/* end eval */
2707
/*****************************************************************************/
2737
/*****************************************************************************/
2708
  case val_tag:
2738
  case val_tag:
2709
    {
2739
    {
2710
      int size = shape_size(sh(e));
2740
      int size = shape_size(sh(e));
2711
 
2741
 
2712
      
2742
 
2713
      if ( size == 64 )
2743
      if (size == 64)
2714
      {
2744
      {
2715
        /* could be evaluating into nowhere so check
2745
        /* could be evaluating into nowhere so check
2716
           to see it is trying to evaluate into a genuine place */
2746
           to see it is trying to evaluate into a genuine place */
2717
        if(dest.answhere.discrim==notinreg)
2747
        if (dest.answhere.discrim==notinreg)
2718
        {
2748
        {
2719
          flt64 temp;
2749
          flt64 temp;
2720
          int ov;
2750
          int ov;
2721
          int r = getreg(sp.fixed);
2751
          int r = getreg(sp.fixed);
2722
          space nsp;
2752
          space nsp;
2723
          ans aa;
2753
          ans aa;
2724
          if (isbigval(e)) {
2754
          if (isbigval(e)) {
2725
	  temp = flt_to_f64(no(e), 0, &ov);
2755
	  temp = flt_to_f64(no(e), 0, &ov);
2726
          }
2756
          }
2727
          else {
2757
          else {
2728
            temp.big = (is_signed(sh(e)) && no(e)<0)?-1:0;
2758
            temp.big = (is_signed(sh(e)) && no(e) <0)?-1:0;
2729
            temp.small = no(e);
2759
            temp.small = no(e);
2730
          }
2760
          }
2731
          nsp = guardreg(r, sp);
2761
          nsp = guardreg(r, sp);
2732
          ld_const_ins(temp.small,r);
2762
          ld_const_ins(temp.small,r);
2733
          setregalt(aa,r);
2763
          setregalt(aa,r);
Line 2737... Line 2767...
2737
          ld_const_ins(temp.big,r);
2767
          ld_const_ins(temp.big,r);
2738
          ASSERT(dest.answhere.discrim==notinreg);
2768
          ASSERT(dest.answhere.discrim==notinreg);
2739
          dest.answhere.val.instoreans.b.offset+=4;
2769
          dest.answhere.val.instoreans.b.offset+=4;
2740
          move(aa,dest,nsp.fixed,1);
2770
          move(aa,dest,nsp.fixed,1);
2741
        }
2771
        }
2742
        
2772
 
2743
	return mka; 	
2773
	return mka;
2744
      }
2774
      }
2745
      else  if (no(e) == 0)
2775
      else  if (no(e) == 0)
2746
      {
2776
      {
2747
	goto moveconst_zero;
2777
	goto moveconst_zero;
2748
      }
2778
      }
Line 2750... Line 2780...
2750
      {
2780
      {
2751
	if (size == 32 || !is_signed(sh(e)))
2781
	if (size == 32 || !is_signed(sh(e)))
2752
	{
2782
	{
2753
	  /* 32 bit size or unsigned */
2783
	  /* 32 bit size or unsigned */
2754
	  constval = no(e);
2784
	  constval = no(e);
2755
	}
2785
	}
2756
	else if (size == 8)
2786
	else if (size == 8)
2757
	{
2787
	{
2758
	  constval = no(e) & 255;
2788
	  constval = no(e) & 255;
2759
	  constval -= (constval & 128) << 1;
2789
	  constval -= (constval & 128) << 1;
2760
	}
2790
	}
Line 2791... Line 2821...
2791
      bool call_fctiwz =0;
2821
      bool call_fctiwz =0;
2792
      int ifr = getfreg(sp.flt);
2822
      int ifr = getfreg(sp.flt);
2793
 
2823
 
2794
      sfr = freg_operand(son(e), sp, getfreg(sp.flt));
2824
      sfr = freg_operand(son(e), sp, getfreg(sp.flt));
2795
      /* Doesn't matter if sfr and ifr same */
2825
      /* Doesn't matter if sfr and ifr same */
2796
      switch(round_number(e))
2826
      switch (round_number(e))
2797
      {
2827
      {
2798
        case R2ZERO:call_fctiwz=1;break;
2828
        case R2ZERO:call_fctiwz=1;break;
2799
        case R2NEAR:break;
2829
        case R2NEAR:break;
2800
        case R2PINF:mtfsb1_ins(30);mtfsb0_ins(31);changed_mode=1;break;
2830
        case R2PINF:mtfsb1_ins(30);mtfsb0_ins(31);changed_mode=1;break;
2801
        case R2NINF:mtfsb1_ins(30);mtfsb1_ins(31);changed_mode=1;break;
2831
        case R2NINF:mtfsb1_ins(30);mtfsb1_ins(31);changed_mode=1;break;
2802
        case 4: break;
2832
        case 4: break;
2803
        default: fail("Unknown rounding mode");break;
2833
        default: fail("Unknown rounding mode");break;
2804
      }
2834
      }
2805
      /* can use fctiw command */
2835
      /* can use fctiw command */
2806
	
2836
 
2807
      destr=regfrmdest(&dest,sp);
2837
      destr=regfrmdest(&dest,sp);
2808
      rrf_ins(call_fctiwz?i_fctiwz:i_fctiw,sfr,ifr);
2838
      rrf_ins(call_fctiwz?i_fctiwz:i_fctiw,sfr,ifr);
2809
      stf_ins(i_stfd,ifr,mem_temp(0));
2839
      stf_ins(i_stfd,ifr,mem_temp(0));
2810
      ld_ro_ins(i_l,mem_temp(4),destr);comment(NIL);
2840
      ld_ro_ins(i_l,mem_temp(4),destr);comment(NIL);
2811
 
2841
 
2812
      if(changed_mode)
2842
      if (changed_mode)
2813
      {
2843
      {
2814
	/* put it back to round_to_nearest */
2844
	/* put it back to round_to_nearest */
2815
	mtfsb0_ins(30);mtfsb0_ins(31);
2845
	mtfsb0_ins(30);mtfsb0_ins(31);
2816
      }
2846
      }
2817
      adjust_to_size(ulonghd,destr,name(sh(e)),destr,NO_ERROR_JUMP);
2847
      adjust_to_size(ulonghd,destr,name(sh(e)),destr,NO_ERROR_JUMP);
2818
      setregalt(aa, destr);     
2848
      setregalt(aa, destr);
2819
      mka.regmove = move(aa, dest, sp.fixed, 1);
2849
      mka.regmove = move(aa, dest, sp.fixed, 1);
2820
      return mka;
2850
      return mka;
2821
    }
2851
    }
2822
/*****************************************************************************/
2852
/*****************************************************************************/
2823
     case int_to_bitf_tag:
2853
     case int_to_bitf_tag:
Line 2848... Line 2878...
2848
	  {
2878
	  {
2849
	    destr = getreg(sp.fixed);
2879
	    destr = getreg(sp.fixed);
2850
	  }
2880
	  }
2851
	}
2881
	}
2852
 
2882
 
2853
	rir_ins(i_and, r, (1 << size_res) - 1, destr);
2883
	rir_ins(i_and, r,(1 << size_res) - 1, destr);
2854
	r = destr;
2884
	r = destr;
2855
      }
2885
      }
2856
 
2886
 
2857
      /* r is appropriately truncated operand */
2887
      /* r is appropriately truncated operand */
2858
 
2888
 
Line 2913... Line 2943...
2913
	    rir_ins(i_sra, r, 32 - a.ashsize, r);
2943
	    rir_ins(i_sra, r, 32 - a.ashsize, r);
2914
	  }
2944
	  }
2915
	}
2945
	}
2916
	else
2946
	else
2917
	{
2947
	{
2918
	  rir_ins(i_and, r, ((1 << a.ashsize) - 1), r);
2948
	  rir_ins(i_and, r,((1 << a.ashsize) - 1), r);
2919
	}
2949
	}
2920
      }
2950
      }
2921
 
2951
 
2922
      move(w.answhere, dest, guardreg(r, sp).fixed, 0);
2952
      move(w.answhere, dest, guardreg(r, sp).fixed, 0);
2923
      keepreg(e, r);
2953
      keepreg(e, r);
Line 2931... Line 2961...
2931
      int lout=new_label();
2961
      int lout=new_label();
2932
      int creg=next_creg();
2962
      int creg=next_creg();
2933
      space nsp;
2963
      space nsp;
2934
      int bytemove;
2964
      int bytemove;
2935
      where w;
2965
      where w;
2936
            
2966
 
2937
      sr = getreg(sp.fixed);
2967
      sr = getreg(sp.fixed);
2938
      setregalt(w.answhere, sr);
2968
      setregalt(w.answhere, sr);
2939
      w.ashwhere = ashof(sh(son(e)));
2969
      w.ashwhere = ashof(sh(son(e)));
2940
      make_code( son(e), sp, w, 0);
2970
      make_code(son(e), sp, w, 0);
2941
      nsp = guardreg(sr,sp);
2971
      nsp = guardreg(sr,sp);
2942
      dr = getreg(nsp.fixed);
2972
      dr = getreg(nsp.fixed);
2943
      setregalt(w.answhere, dr);
2973
      setregalt(w.answhere, dr);
2944
      make_code( bro(son(e)), nsp, w, 0);
2974
      make_code(bro(son(e)), nsp, w, 0);
2945
      nsp = guardreg(dr,nsp);
2975
      nsp = guardreg(dr,nsp);
2946
      w.ashwhere = ashof(sh(bro(bro(son(e)))));
2976
      w.ashwhere = ashof(sh(bro(bro(son(e)))));
2947
      szr = getreg(nsp.fixed);
2977
      szr = getreg(nsp.fixed);
2948
      setregalt(w.answhere, szr);
2978
      setregalt(w.answhere, szr);
2949
      (void)make_code(szarg, nsp, w, 0);
2979
     (void)make_code(szarg, nsp, w, 0);
2950
      nsp = guardreg(szr, nsp);
2980
      nsp = guardreg(szr, nsp);
2951
      bytemove = (al2(sh(szarg))>>3);
2981
      bytemove = (al2(sh(szarg)) >>3);
2952
#if 0
2982
#if 0
2953
      clear_dep_reg(son(e));
2983
      clear_dep_reg(son(e));
2954
      clear_dep_reg(bro(son(e)));
2984
      clear_dep_reg(bro(son(e)));
2955
#else
2985
#else
2956
      clear_all();
2986
      clear_all();
2957
#endif
2987
#endif
2958
      if(name(szarg) != val_tag || no(szarg) == 0) {
2988
      if (name(szarg)!= val_tag || no(szarg) == 0) {
2959
	cmp_ri_ins(i_cmp, szr, 0, creg);
2989
	cmp_ri_ins(i_cmp, szr, 0, creg);
2960
	bc_ins(i_beq, creg, lout,UNLIKELY_TO_JUMP);
2990
	bc_ins(i_beq, creg, lout,UNLIKELY_TO_JUMP);
2961
      }	
2991
      }
2962
      if (isnooverlap(e)) {
2992
      if (isnooverlap(e)) {
2963
	move_dlts(dr,sr,szr, bytemove);
2993
	move_dlts(dr,sr,szr, bytemove);
2964
      }
2994
      }
2965
      else {
2995
      else {
2966
	int gtlab = new_label();
2996
	int gtlab = new_label();
Line 2969... Line 2999...
2969
	bc_ins(i_bgt, creg2, gtlab,LIKELY_TO_JUMP);
2999
	bc_ins(i_bgt, creg2, gtlab,LIKELY_TO_JUMP);
2970
	move_dlts(dr,sr,szr, bytemove);
3000
	move_dlts(dr,sr,szr, bytemove);
2971
	uncond_ins(i_b, lout);
3001
	uncond_ins(i_b, lout);
2972
	set_label(gtlab);
3002
	set_label(gtlab);
2973
	move_dgts(dr,sr,szr, bytemove);
3003
	move_dgts(dr,sr,szr, bytemove);
2974
      }  	
3004
      }
2975
      set_label(lout);
3005
      set_label(lout);
2976
      return mka;
3006
      return mka;
2977
    }
3007
    }
2978
 
3008
 
2979
/*****************************************************************************/
3009
/*****************************************************************************/
2980
   case offset_pad_tag:
3010
   case offset_pad_tag:
2981
    {
3011
    {
2982
      int r;
3012
      int r;
2983
      int v;
3013
      int v;
2984
      ans aa;	
3014
      ans aa;
2985
      if (al2(sh(son(e))) >= al2(sh(e))) 
3015
      if (al2(sh(son(e))) >= al2(sh(e)))
2986
      {
3016
      {
2987
	if (al2(sh(e)) != 1 || al2(sh(son(e))) == 1) 
3017
	if (al2(sh(e))!= 1 || al2(sh(son(e))) == 1)
2988
	{
3018
	{
2989
	  /*
3019
	  /*
2990
	   * Is already aligned correctly, 
3020
	   * Is already aligned correctly,
2991
	   * whether as bit or byte-offset
3021
	   * whether as bit or byte-offset
2992
	   */
3022
	   */
2993
	  e = son(e); goto tailrecurse;
3023
	  e = son(e); goto tailrecurse;
2994
	}
3024
	}
2995
	r = regfrmdest(&dest, sp);
3025
	r = regfrmdest(&dest, sp);
2996
	v = reg_operand(son(e), sp);
3026
	v = reg_operand(son(e), sp);
2997
	rir_ins(i_sl,  v, 3 ,r);  
3027
	rir_ins(i_sl,  v, 3 ,r);
2998
      }
3028
      }
2999
      else {
3029
      else {
3000
	int al = (al2(sh(son(e)))==1)?al2(sh(e)):(al2(sh(e))/8);
3030
	int al = (al2(sh(son(e))) ==1)?al2(sh(e)):(al2(sh(e)) /8);
3001
	r = regfrmdest(&dest, sp);
3031
	r = regfrmdest(&dest, sp);
3002
	v = reg_operand(son(e), sp); 
3032
	v = reg_operand(son(e), sp);
3003
	rir_ins(i_a, v, al-1, r);
3033
	rir_ins(i_a, v, al-1, r);
3004
	rir_ins(i_and, r, -al ,r);
3034
	rir_ins(i_and, r, -al ,r);
3005
	if (al2(sh(son(e)))==1) 
3035
	if (al2(sh(son(e))) ==1)
3006
	{ /* 
3036
	{ /*
3007
	   * operand is bit-offset,
3037
	   * operand is bit-offset,
3008
	   * byte-offset required 
3038
	   * byte-offset required
3009
	   */
3039
	   */
3010
	  rir_ins(i_sra, r, 3 ,r);
3040
	  rir_ins(i_sra, r, 3 ,r);
3011
	}
3041
	}
3012
      }
3042
      }
3013
      setregalt(aa,r);
3043
      setregalt(aa,r);
3014
      mka.regmove = move(aa, dest, guardreg(r,sp).fixed, 0);
3044
      mka.regmove = move(aa, dest, guardreg(r,sp).fixed, 0);
3015
      return mka;
3045
      return mka;
3016
    }
3046
    }
3017
/*****************************************************************************/
3047
/*****************************************************************************/
3018
    
3048
 
3019
   case min_tag:
3049
   case min_tag:
3020
   case max_tag:
3050
   case max_tag:
3021
   case offset_max_tag:
3051
   case offset_max_tag:
3022
    {
3052
    {
3023
      ans aa;
3053
      ans aa;
3024
      int left;
3054
      int left;
3025
      int right;
3055
      int right;
3026
      int r=regfrmdest(&dest, sp);
3056
      int r=regfrmdest(&dest, sp);
3027
      int creg;
3057
      int creg;
3028
      int lab;
3058
      int lab;
3029
      
3059
 
3030
      space nsp;
3060
      space nsp;
3031
      if (IsRev(e))
3061
      if (IsRev(e))
3032
      {
3062
      {
3033
	right=reg_operand(bro(son(e)),sp);
3063
	right=reg_operand(bro(son(e)),sp);
3034
	nsp=guardreg(right,sp);
3064
	nsp=guardreg(right,sp);
Line 3042... Line 3072...
3042
      }
3072
      }
3043
      creg = next_creg();
3073
      creg = next_creg();
3044
      lab = new_label();
3074
      lab = new_label();
3045
      cmp_rr_ins(i_cmp,left,right,creg);
3075
      cmp_rr_ins(i_cmp,left,right,creg);
3046
      mov_rr_ins(left,r);comment(NIL);
3076
      mov_rr_ins(left,r);comment(NIL);
3047
      if(name(e)==min_tag)
3077
      if (name(e) ==min_tag)
3048
      {
3078
      {
3049
	bc_ins(i_blt,creg,lab,LIKELY_TO_JUMP);
3079
	bc_ins(i_blt,creg,lab,LIKELY_TO_JUMP);
3050
      }
3080
      }
3051
      else
3081
      else
3052
      {
3082
      {
3053
	bc_ins(i_bgt,creg,lab,LIKELY_TO_JUMP);  
3083
	bc_ins(i_bgt,creg,lab,LIKELY_TO_JUMP);
3054
      }
3084
      }
3055
      mov_rr_ins(right,r);comment(NIL);
3085
      mov_rr_ins(right,r);comment(NIL);
3056
      set_label(lab);
3086
      set_label(lab);
3057
      setregalt(aa,r);
3087
      setregalt(aa,r);
3058
      move(aa, dest,guardreg(r,sp).fixed , 0);
3088
      move(aa, dest,guardreg(r,sp).fixed , 0);
Line 3061... Line 3091...
3061
    }
3091
    }
3062
/*****************************************************************************/
3092
/*****************************************************************************/
3063
   case offset_add_tag:
3093
   case offset_add_tag:
3064
    {
3094
    {
3065
      /*
3095
      /*
3066
       * byte offset + bit offset 
3096
       * byte offset + bit offset
3067
       * all others converted to plus_tag by needscan
3097
       * all others converted to plus_tag by needscan
3068
       * The byte offset must be converted into bits for
3098
       * The byte offset must be converted into bits for
3069
       * the addition
3099
       * the addition
3070
       */
3100
       */
3071
      exp byte_offset = son(e);
3101
      exp byte_offset = son(e);
Line 3075... Line 3105...
3075
      int bit_offset_reg;
3105
      int bit_offset_reg;
3076
      space nsp;
3106
      space nsp;
3077
      ans aa;
3107
      ans aa;
3078
      nsp = guardreg(destr, sp);
3108
      nsp = guardreg(destr, sp);
3079
 
3109
 
3080
      rir_ins( i_sl , byte_offset_reg , 3 , destr);
3110
      rir_ins(i_sl , byte_offset_reg , 3 , destr);
3081
      if ( name(bit_offset)==val_tag )
3111
      if (name(bit_offset) ==val_tag)
3082
      {
3112
      {
3083
	if( no(bit_offset)!=0 )
3113
	if (no(bit_offset)!=0)
3084
	{
3114
	{
3085
	  rir_ins(i_a, destr , no(bit_offset) , destr);
3115
	  rir_ins(i_a, destr , no(bit_offset), destr);
3086
	}
3116
	}
3087
      }
3117
      }
3088
      else 
3118
      else
3089
      {
3119
      {
3090
	bit_offset_reg = reg_operand(bit_offset, nsp);
3120
	bit_offset_reg = reg_operand(bit_offset, nsp);
3091
	rrr_ins(i_a, destr , bit_offset_reg , destr);
3121
	rrr_ins(i_a, destr , bit_offset_reg , destr);
3092
      }
3122
      }
3093
      setregalt(aa, destr);
3123
      setregalt(aa, destr);
3094
      mka.regmove = move(aa, dest, nsp.fixed, 0);
3124
      mka.regmove = move(aa, dest, nsp.fixed, 0);
3095
      return mka;
3125
      return mka;
3096
    }
3126
    }
3097
/*****************************************************************************/
3127
/*****************************************************************************/
3098
   case offset_subtract_tag: 
3128
   case offset_subtract_tag:
3099
    { 
3129
    {
3100
     /*
3130
     /*
3101
      * bit offset - byte offset
3131
      * bit offset - byte offset
3102
      * all others converted to minus_tag by needscan
3132
      * all others converted to minus_tag by needscan
3103
      */
3133
      */
3104
     exp bit_offset = son(e);
3134
     exp bit_offset = son(e);
3105
     exp byte_offset = bro(bit_offset);
3135
     exp byte_offset = bro(bit_offset);
3106
     int destr = regfrmdest(&dest, sp) ;
3136
     int destr = regfrmdest(&dest, sp);
3107
     int byte_offset_reg = reg_operand(byte_offset, sp);
3137
     int byte_offset_reg = reg_operand(byte_offset, sp);
3108
     int bit_offset_reg;
3138
     int bit_offset_reg;
3109
     space nsp;
3139
     space nsp;
3110
     ans aa;
3140
     ans aa;
3111
     nsp = guardreg( destr,sp);
3141
     nsp = guardreg(destr,sp);
3112
     
3142
 
3113
     rir_ins(i_sl, byte_offset_reg , 3 , destr);
3143
     rir_ins(i_sl, byte_offset_reg , 3 , destr);
3114
     if(name(bit_offset)==val_tag)
3144
     if (name(bit_offset) ==val_tag)
3115
     {
3145
     {
3116
       if(no(bit_offset)!=0)
3146
       if (no(bit_offset)!=0)
3117
       {
3147
       {
3118
	 rir_ins(i_s,destr,no(bit_offset),destr);
3148
	 rir_ins(i_s,destr,no(bit_offset),destr);
3119
       }
3149
       }
3120
     }
3150
     }
3121
     else
3151
     else
Line 3130... Line 3160...
3130
/*****************************************************************************/
3160
/*****************************************************************************/
3131
   case current_env_tag:
3161
   case current_env_tag:
3132
    {
3162
    {
3133
      int r=regfrmdest(&dest, sp);
3163
      int r=regfrmdest(&dest, sp);
3134
      ans aa;
3164
      ans aa;
3135
      if(p_has_fp)
3165
      if (p_has_fp)
3136
      {
3166
      {
3137
       	mov_rr_ins(R_FP,r);comment("move FP to register");
3167
       	mov_rr_ins(R_FP,r);comment("move FP to register");
3138
      }
3168
      }
3139
      else
3169
      else
3140
      {
3170
      {
3141
	/* If we don't have a frame pointer we give the location
3171
	/* If we don't have a frame pointer we give the location
3142
	   of where the frame pointer would be anyway */
3172
	   of where the frame pointer would be anyway */
3143
	rir_ins(i_a , R_SP, p_frame_size , r );
3173
	rir_ins(i_a , R_SP, p_frame_size , r);
3144
      }
3174
      }
3145
      setregalt(aa, r);
3175
      setregalt(aa, r);
3146
      mka.regmove = move(aa, dest, sp.fixed, 0);
3176
      mka.regmove = move(aa, dest, sp.fixed, 0);
3147
      return mka;
3177
      return mka;
3148
    }
3178
    }
3149
/*****************************************************************************/
3179
/*****************************************************************************/
Line 3151... Line 3181...
3151
    {
3181
    {
3152
      /* NOTE: env_offset works in conjunction with current_env.
3182
      /* NOTE: env_offset works in conjunction with current_env.
3153
	 So it must be consistent with current env */
3183
	 So it must be consistent with current env */
3154
      constval = frame_offset(son(e));
3184
      constval = frame_offset(son(e));
3155
      goto moveconst;
3185
      goto moveconst;
3156
    }
3186
    }
3157
/*****************************************************************************/
3187
/*****************************************************************************/
3158
   case goto_lv_tag:
3188
   case goto_lv_tag:
3159
    {
3189
    {
3160
      int r = reg_operand(son(e),sp);
3190
      int r = reg_operand(son(e),sp);
3161
 
3191
 
Line 3187... Line 3217...
3187
/*****************************************************************************/
3217
/*****************************************************************************/
3188
   case long_jump_tag:
3218
   case long_jump_tag:
3189
    {
3219
    {
3190
     int fp = reg_operand(son(e), sp);
3220
     int fp = reg_operand(son(e), sp);
3191
     int labval = reg_operand(bro(son(e)), sp);
3221
     int labval = reg_operand(bro(son(e)), sp);
3192
     /* 
3222
     /*
3193
      * Long jumps are always done through the frame pointer 
3223
      * Long jumps are always done through the frame pointer
3194
      * since you cannot tell whether or not you are going in
3224
      * since you cannot tell whether or not you are going in
3195
      * to a proc which needs a frame pointer or not
3225
      * to a proc which needs a frame pointer or not
3196
      * so it is made sure that any procedure that has
3226
      * so it is made sure that any procedure that has
3197
      * make_local_lv and current_env is forced to have a
3227
      * make_local_lv and current_env is forced to have a
3198
      * frame pointer.
3228
      * frame pointer.
Line 3207... Line 3237...
3207
/*****************************************************************************/
3237
/*****************************************************************************/
3208
   case alloca_tag:
3238
   case alloca_tag:
3209
    {
3239
    {
3210
      int dreg = regfrmdest(&dest,sp);
3240
      int dreg = regfrmdest(&dest,sp);
3211
      ans aa;
3241
      ans aa;
3212
      int xdreg = (IS_R_TMP(dreg) && checkalloc(e)) ? getreg (sp.fixed) : dreg;
3242
      int xdreg = (IS_R_TMP(dreg) && checkalloc(e))? getreg(sp.fixed): dreg;
3213
      
3243
 
3214
      ASSERT(p_has_alloca);
3244
      ASSERT(p_has_alloca);
3215
      ASSERT(p_has_fp);
3245
      ASSERT(p_has_fp);
3216
 
3246
 
3217
 
3247
 
3218
      
3248
 
3219
      if(name(son(e))==val_tag)
3249
      if (name(son(e)) ==val_tag)
3220
      {
3250
      {
3221
	/* allocate constant number of bytes on stack*/
3251
	/* allocate constant number of bytes on stack*/
3222
	int no_of_bytes = ALLOCA_ALIGNMENT(no(son(e)));
3252
	int no_of_bytes = ALLOCA_ALIGNMENT(no(son(e)));
3223
	if(checkalloc(e))
3253
	if (checkalloc(e))
3224
	{
3254
	{
3225
	  rir_ins(i_a,R_SP,-(long)no_of_bytes,xdreg);
3255
	  rir_ins(i_a,R_SP,- (long)no_of_bytes,xdreg);
3226
	}
3256
	}
3227
	else
3257
	else
3228
	{
3258
	{
3229
	  rir_ins(i_a,R_SP,-(long)no_of_bytes,R_SP);
3259
	  rir_ins(i_a,R_SP,- (long)no_of_bytes,R_SP);
3230
	}
3260
	}
3231
      }
3261
      }
3232
      else
3262
      else
3233
      {
3263
      {
3234
	int nreg = reg_operand(son(e),sp);
3264
	int nreg = reg_operand(son(e),sp);
Line 3241... Line 3271...
3241
	}
3271
	}
3242
	else
3272
	else
3243
	{
3273
	{
3244
	  rrr_ins(i_sf,R_TMP0,R_SP,R_SP);
3274
	  rrr_ins(i_sf,R_TMP0,R_SP,R_SP);
3245
	}
3275
	}
3246
	
3276
 
3247
      }
3277
      }
3248
      if (checkalloc(e))
3278
      if (checkalloc(e))
3249
      {
3279
      {
3250
	baseoff b;
3280
	baseoff b;
3251
	int cr;
3281
	int cr;
3252
	int slab;
3282
	int slab;
3253
	b = find_tg("__TDFstacklim");
3283
	b = find_tg("__TDFstacklim");
3254
	cr = next_creg();
3284
	cr = next_creg();
3255
	
3285
 
3256
	slab = get_stack_overflow_lab();
3286
	slab = get_stack_overflow_lab();
3257
	ld_ins(i_l,b,R_TMP0);
3287
	ld_ins(i_l,b,R_TMP0);
3258
	cmp_rr_ins(i_cmp,xdreg,R_TMP0,cr);
3288
	cmp_rr_ins(i_cmp,xdreg,R_TMP0,cr);
3259
	bc_ins(i_blt,cr,slab,UNLIKELY_TO_JUMP);
3289
	bc_ins(i_blt,cr,slab,UNLIKELY_TO_JUMP);
3260
	mov_rr_ins(xdreg,R_SP);comment(NIL);
3290
	mov_rr_ins(xdreg,R_SP);comment(NIL);
3261
      }
3291
      }
3262
      
3292
 
3263
      
3293
 
3264
 
3294
 
3265
      if (p_args_and_link_size==0)
3295
      if (p_args_and_link_size==0)
3266
      {
3296
      {
3267
	mov_rr_ins(R_SP,dreg);comment(NIL);
3297
	mov_rr_ins(R_SP,dreg);comment(NIL);
3268
      }
3298
      }
3269
      else
3299
      else
3270
      {
3300
      {
3271
	rir_ins(i_a, R_SP, p_args_and_link_size,dreg);
3301
	rir_ins(i_a, R_SP, p_args_and_link_size,dreg);
3272
      }
3302
      }
3273
      if(p_has_back_chain)
3303
      if (p_has_back_chain)
3274
      {
3304
      {
3275
	save_back_chain_using_frame_pointer();
3305
	save_back_chain_using_frame_pointer();
3276
      }
3306
      }
3277
      if(p_has_saved_sp)
3307
      if (p_has_saved_sp)
3278
      {
3308
      {
3279
	save_sp_on_stack();
3309
	save_sp_on_stack();
3280
      }
3310
      }
3281
      setregalt(aa,dreg);
3311
      setregalt(aa,dreg);
3282
      move(aa,dest,guardreg(dreg,sp).fixed,0);
3312
      move(aa,dest,guardreg(dreg,sp).fixed,0);
3283
      return mka;
3313
      return mka;
3284
    }
3314
    }
3285
/*****************************************************************************/
3315
/*****************************************************************************/
3286
   case last_local_tag:
3316
   case last_local_tag:
3287
    {
3317
    {
3288
      int r = regfrmdest(&dest, sp);
3318
      int r = regfrmdest(&dest, sp);
3289
      ans aa;
3319
      ans aa;
3290
      /* The last pointer returned by alloca is placed into r */
3320
      /* The last pointer returned by alloca is placed into r */
3291
 
3321
 
3292
      if(p_args_and_link_size !=0)
3322
      if (p_args_and_link_size !=0)
3293
      {
3323
      {
3294
	rir_ins(i_a, R_SP, p_args_and_link_size, r);
3324
	rir_ins(i_a, R_SP, p_args_and_link_size, r);
3295
      }
3325
      }
3296
      else
3326
      else
3297
      {
3327
      {
3298
	mov_rr_ins( R_SP , r );comment(NIL);
3328
	mov_rr_ins(R_SP , r);comment(NIL);
3299
      }
3329
      }
3300
      setregalt(aa, r);
3330
      setregalt(aa, r);
3301
      mka.regmove = move(aa, dest, sp.fixed, 1);
3331
      mka.regmove = move(aa, dest, sp.fixed, 1);
3302
      return mka;
3332
      return mka;
3303
    }
3333
    }
3304
/*****************************************************************************/
3334
/*****************************************************************************/
3305
   case local_free_all_tag:
3335
   case local_free_all_tag:
3306
    {
3336
    {
3307
      if(p_has_alloca)
3337
      if (p_has_alloca)
3308
      {
3338
      {
3309
	/* The stack pointer is returned to how it was before
3339
	/* The stack pointer is returned to how it was before
3310
	   any calls to alloca were made */
3340
	   any calls to alloca were made */
3311
	rir_ins(i_a , R_FP,- p_frame_size ,R_SP);
3341
	rir_ins(i_a , R_FP,- p_frame_size ,R_SP);
3312
	if (p_has_back_chain)
3342
	if (p_has_back_chain)
3313
	{
3343
	{
3314
	  save_back_chain_using_frame_pointer();
3344
	  save_back_chain_using_frame_pointer();
3315
	}
3345
	}
3316
	if(p_has_saved_sp)
3346
	if (p_has_saved_sp)
3317
	{
3347
	{
3318
	  save_sp_on_stack();
3348
	  save_sp_on_stack();
3319
	}
3349
	}
3320
      }
3350
      }
3321
      return mka;
3351
      return mka;
3322
    }
3352
    }
3323
/*****************************************************************************/
3353
/*****************************************************************************/
3324
   case local_free_tag:
3354
   case local_free_tag:
3325
    {
3355
    {
3326
      int r;
3356
      int r;
3327
      int off;
3357
      int off;
3328
      space nsp;
3358
      space nsp;
3329
      
3359
 
3330
      ASSERT(p_has_alloca);
3360
      ASSERT(p_has_alloca);
3331
      r = reg_operand(son(e), sp); 
3361
      r = reg_operand(son(e), sp);
3332
      /* r is a pointer returned by alloca
3362
      /* r is a pointer returned by alloca
3333
	 off is the number of bytes to free up */
3363
	 off is the number of bytes to free up */
3334
      if (name(bro(son(e)))==val_tag)
3364
      if (name(bro(son(e))) ==val_tag)
3335
      {
3365
      {
3336
	int displacement=ALLOCA_ALIGNMENT(no(bro(son(e))));
3366
	int displacement=ALLOCA_ALIGNMENT(no(bro(son(e))));
3337
	displacement -= p_args_and_link_size;
3367
	displacement -= p_args_and_link_size;
3338
	if(displacement!=0)
3368
	if (displacement!=0)
3339
	{
3369
	{
3340
	  rir_ins(i_a,r,displacement,R_SP);
3370
	  rir_ins(i_a,r,displacement,R_SP);
3341
	}
3371
	}
3342
	else
3372
	else
3343
	{
3373
	{
3344
	  mov_rr_ins(r,R_SP);comment(NIL);
3374
	  mov_rr_ins(r,R_SP);comment(NIL);
3345
	}
3375
	}
3346
      }
3376
      }
3347
      else
3377
      else
3348
      {    
3378
      {
3349
	nsp=guardreg(r,sp);
3379
	nsp=guardreg(r,sp);
3350
	off = reg_operand(bro(son(e)),nsp);
3380
	off = reg_operand(bro(son(e)),nsp);
3351
	
3381
 
3352
	rir_ins(i_a,off,7,off);
3382
	rir_ins(i_a,off,7,off);
3353
	rir_ins(i_and,off,~7,off);
3383
	rir_ins(i_and,off,~7,off);
3354
	rrr_ins(i_a,r,off,R_SP);
3384
	rrr_ins(i_a,r,off,R_SP);
3355
	if (p_args_and_link_size !=0)
3385
	if (p_args_and_link_size !=0)
3356
	{
3386
	{
3357
	  rir_ins(i_a , R_SP , - p_args_and_link_size , R_SP);
3387
	  rir_ins(i_a , R_SP , - p_args_and_link_size , R_SP);
3358
	}
3388
	}
3359
      }
3389
      }
3360
      if(p_has_back_chain)
3390
      if (p_has_back_chain)
3361
      {
3391
      {
3362
	save_back_chain_using_frame_pointer();
3392
	save_back_chain_using_frame_pointer();
3363
      }
3393
      }
3364
      if(p_has_saved_sp)
3394
      if (p_has_saved_sp)
3365
      {
3395
      {
3366
	save_sp_on_stack();
3396
	save_sp_on_stack();
3367
      }
3397
      }
3368
      return mka;
3398
      return mka;
3369
    }
3399
    }
3370
/*****************************************************************************/
3400
/*****************************************************************************/
3371
/* SPEC 3.1 constructions */
3401
/* SPEC 3.1 constructions */
3372
/**************************/
3402
/**************************/
3373
   case locptr_tag:
3403
   case locptr_tag:
3374
    {
3404
    {
3375
      /* this is the only way of accessing callers in a general proc 
3405
      /* this is the only way of accessing callers in a general proc
3376
       when calculating general_env_offset using current_env */
3406
       when calculating general_env_offset using current_env */
3377
      int destr = regfrmdest(&dest,sp);
3407
      int destr = regfrmdest(&dest,sp);
3378
      int pr = reg_operand(son(e),sp);
3408
      int pr = reg_operand(son(e),sp);
3379
      space nsp;
3409
      space nsp;
3380
      baseoff b;
3410
      baseoff b;
Line 3401... Line 3431...
3401
/*****************************************************************************/
3431
/*****************************************************************************/
3402
   case make_callee_list_tag:
3432
   case make_callee_list_tag:
3403
    {
3433
    {
3404
      make_callee_list_tag_code(e,sp);
3434
      make_callee_list_tag_code(e,sp);
3405
      return mka;
3435
      return mka;
3406
    }    
3436
    }
3407
/*****************************************************************************/
3437
/*****************************************************************************/
3408
   case same_callees_tag:
3438
   case same_callees_tag:
3409
    {
3439
    {
3410
      make_same_callees_tag_code(e,sp);
3440
      make_same_callees_tag_code(e,sp);
3411
      return mka;
3441
      return mka;
3412
    }
3442
    }
3413
/*****************************************************************************/
3443
/*****************************************************************************/
3414
   case make_dynamic_callee_tag:
3444
   case make_dynamic_callee_tag:
3415
    {
3445
    {
3416
      make_dynamic_callee_tag_code(e,sp);
3446
      make_dynamic_callee_tag_code(e,sp);
3417
      return mka;
3447
      return mka;
3418
    }
3448
    }
3419
/*****************************************************************************/
3449
/*****************************************************************************/
3420
   case caller_name_tag:
3450
   case caller_name_tag:
3421
    {
3451
    {
3422
      return mka;
3452
      return mka;
3423
    }
3453
    }
3424
/*****************************************************************************/
3454
/*****************************************************************************/
3425
   case return_to_label_tag:
3455
   case return_to_label_tag:
3426
    {
3456
    {
3427
      make_return_to_label_tag_code(e,sp);
3457
      make_return_to_label_tag_code(e,sp);
3428
      return mka;
3458
      return mka;
3429
    }
3459
    }
3430
/*****************************************************************************/
3460
/*****************************************************************************/
3431
   case set_stack_limit_tag:
3461
   case set_stack_limit_tag:
3432
    {
3462
    {
3433
      baseoff b;
3463
      baseoff b;
Line 3436... Line 3466...
3436
      st_ins(i_st,r,b);
3466
      st_ins(i_st,r,b);
3437
      return mka;
3467
      return mka;
3438
    }
3468
    }
3439
/*****************************************************************************/
3469
/*****************************************************************************/
3440
   case env_size_tag:
3470
   case env_size_tag:
3441
    {
3471
    {
3442
      exp tg = son(son(e));
3472
      exp tg = son(son(e));
3443
      procrec * pr = &procrecs[no(son(tg))];
3473
      procrec * pr = &procrecs[no(son(tg))];
3444
      constval = ((pr->frame_size)>>3) + pr->max_callee_bytes;
3474
      constval = ((pr->frame_size) >>3) + pr->max_callee_bytes;
3445
      goto moveconst;
3475
      goto moveconst;
3446
    }
3476
    }
3447
/*****************************************************************************/
3477
/*****************************************************************************/
3448
   case trap_tag:
3478
   case trap_tag:
3449
    {
3479
    {
Line 3474... Line 3504...
3474
    mka.regmove = r;
3504
    mka.regmove = r;
3475
    return mka;
3505
    return mka;
3476
  }
3506
  }
3477
}				/* end make_code */
3507
}				/* end make_code */
3478
 
3508
 
3479
void move_dlts PROTO_N ((dr,sr,szr,bytemove)) PROTO_T (int dr X int sr X int szr X int bytemove ) 
3509
void move_dlts(int dr, int sr, int szr, int bytemove)
3480
  /* move szr bytes to dr from sr (using R_TMP0)- either nooverlap or dr<=sr */
3510
  /* move szr bytes to dr from sr (using R_TMP0)- either nooverlap or dr<=sr */
3481
{
3511
{
3482
  baseoff sr_baseoff;
3512
  baseoff sr_baseoff;
3483
  baseoff dr_baseoff;
3513
  baseoff dr_baseoff;
3484
  int lin = new_label();
3514
  int lin = new_label();
3485
 
3515
 
3486
  sr_baseoff.base = sr;
3516
  sr_baseoff.base = sr;
3487
  sr_baseoff.offset = 1;
3517
  sr_baseoff.offset = 1;
3488
  dr_baseoff.base = dr;
3518
  dr_baseoff.base = dr;
3489
  dr_baseoff.offset = 1;
3519
  dr_baseoff.offset = 1;
3490
  /* +++ could do this word at a time? */
3520
  /* +++ could do this word at a time? */
3491
  rir_ins(i_a,sr,-1,sr);               /* ai     sr,sr,-1 */
3521
  rir_ins(i_a,sr,-1,sr);               /* ai     sr,sr,-1 */
3492
  rir_ins(i_a,dr,-1,dr);               /* ai     dr,dr,-1 */
3522
  rir_ins(i_a,dr,-1,dr);               /* ai     dr,dr,-1 */
3493
  mt_ins(i_mtctr,szr);                 /* mtctr  szr      */
3523
  mt_ins(i_mtctr,szr);                 /* mtctr  szr      */
Line 3500... Line 3530...
3500
  rrr_ins( i_sf, szr , dr ,dr );       /* sf     dr,szr,dr*/
3530
  rrr_ins( i_sf, szr , dr ,dr );       /* sf     dr,szr,dr*/
3501
  rir_ins( i_a ,dr , 1, dr );          /* ai     dr,dr,1  */
3531
  rir_ins( i_a ,dr , 1, dr );          /* ai     dr,dr,1  */
3502
  return;
3532
  return;
3503
}
3533
}
3504
 
3534
 
3505
void move_dgts PROTO_N ((dr, sr, szr, bytemove)) PROTO_T (int dr X int sr X int szr X int bytemove)
3535
void move_dgts(int dr, int sr, int szr, int bytemove)
3506
	/* move szr bytes to dr from sr (using R_TMP0) with overlap and dr>sr */
3536
	/* move szr bytes to dr from sr (using R_TMP0) with overlap and dr>sr */
3507
{ 
3537
{
3508
  baseoff sr_baseoff;
3538
  baseoff sr_baseoff;
3509
  baseoff dr_baseoff;
3539
  baseoff dr_baseoff;
3510
  int lin = new_label();
3540
  int lin = new_label();
3511
  
3541
 
3512
  sr_baseoff.base = sr;
3542
  sr_baseoff.base = sr;
3513
  sr_baseoff.offset = -1;
3543
  sr_baseoff.offset = -1;
3514
  dr_baseoff.base = dr;
3544
  dr_baseoff.base = dr;
3515
  dr_baseoff.offset = -1;
3545
  dr_baseoff.offset = -1;
3516
  /* +++ could do this word at a time? */
3546
  /* +++ could do this word at a time? */
Line 3522... Line 3552...
3522
  st_ro_ins(i_stbu,R_TMP0,dr_baseoff); /* stbu   0,-1(dr)  */comment(NIL);
3552
  st_ro_ins(i_stbu,R_TMP0,dr_baseoff); /* stbu   0,-1(dr)  */comment(NIL);
3523
  uncond_ins(i_bdn, lin);              /* bdn    L.???     */
3553
  uncond_ins(i_bdn, lin);              /* bdn    L.???     */
3524
  return;
3554
  return;
3525
}
3555
}
3526
 
3556
 
3527
int regfrmdest PROTO_N ((dest, sp)) PROTO_T(where * dest X space sp ) 
3557
int regfrmdest(where * dest, space sp)
3528
{
3558
{
3529
  switch (dest->answhere.discrim) {
3559
  switch (dest->answhere.discrim) {
3530
   case inreg: 
3560
   case inreg:
3531
    {
3561
    {
3532
      return regalt (dest->answhere);
3562
      return regalt(dest->answhere);
3533
      
3563
 
3534
    }
3564
    }
3535
   default: 
3565
   default:
3536
    {
3566
    {
3537
      return getreg (sp.fixed);
3567
      return getreg(sp.fixed);
3538
    }
3568
    }
3539
  }
3569
  }
3540
}	
3570
}
3541
freg fregfrmdest PROTO_N ((dble,dest,sp)) PROTO_T (bool dble X where * dest X space sp )
3571
freg fregfrmdest(bool dble, where * dest, space sp)
3542
{
3572
{
3543
  freg fr;
3573
  freg fr;
3544
  
3574
 
3545
  switch (dest->answhere.discrim)
3575
  switch (dest->answhere.discrim)
3546
  {
3576
  {
3547
   case infreg:
3577
   case infreg:
3548
    {
3578
    {
3549
      fr = fregalt(dest->answhere);
3579
      fr = fregalt(dest->answhere);
3550
      fr.dble = dble;
3580
      fr.dble = dble;
3551
      return fr;
3581
      return fr;
3552
    }
3582
    }
3553
   default:
3583
   default:
3554
    {
3584
    {
3555
      fr.dble = dble;
3585
      fr.dble = dble;
3556
      fr.fr = getfreg(sp.flt);
3586
      fr.fr = getfreg(sp.flt);
Line 3558... Line 3588...
3558
    }
3588
    }
3559
 
3589
 
3560
  }
3590
  }
3561
}
3591
}
3562
 
3592
 
3563
static int get_next_mlv_number PROTO_Z ()
3593
static int get_next_mlv_number(void)
3564
{
3594
{
3565
  static next_lv_number=0;
3595
  static next_lv_number=0;
3566
  next_lv_number++;
3596
  next_lv_number++;
3567
  return next_lv_number;
3597
  return next_lv_number;
3568
}
3598
}
3569
 
3599
 
3570
 
3600
 
3571
 
3601
 
3572
void adjust_to_size PROTO_N ((src_shpe,sreg,dest_shpe,dreg,trap)) PROTO_T ( int src_shpe X int sreg X int dest_shpe X int dreg X int trap) 
3602
void adjust_to_size(int src_shpe, int sreg, int dest_shpe, int dreg, int trap)
3573
{
3603
{
3574
  
3604
 
3575
/*                 
3605
/*
3576
   0 means nothing to be done
3606
   0 means nothing to be done
3577
   
3607
 
3578
                      d   e   s   t
3608
                      d   e   s   t
3579
 
3609
 
3580
                  s   u   s   u   s   u
3610
                  s   u   s   u   s   u
3581
                  c   c   w   w   l   l
3611
                  c   c   w   w   l   l
3582
                  h   h   o   o   o   o
3612
                  h   h   o   o   o   o
Line 3589... Line 3619...
3589
 r    uword       X   X   X   0   0   0
3619
 r    uword       X   X   X   0   0   0
3590
 c    slong       X   X   X   X   0   0
3620
 c    slong       X   X   X   X   0   0
3591
      ulong       X   X   X   X   0   0
3621
      ulong       X   X   X   X   0   0
3592
   */
3622
   */
3593
  /* Perform the options on the above table */
3623
  /* Perform the options on the above table */
3594
  if( src_shpe == dest_shpe || 
3624
  if (src_shpe == dest_shpe ||
3595
      dest_shpe == slonghd  || 
3625
      dest_shpe == slonghd  ||
3596
      dest_shpe == ulonghd  || 
3626
      dest_shpe == ulonghd  ||
3597
      (src_shpe == scharhd && dest_shpe == swordhd) || 
3627
     (src_shpe == scharhd && dest_shpe == swordhd) ||
3598
      (src_shpe == ucharhd && dest_shpe != scharhd) )
3628
     (src_shpe == ucharhd && dest_shpe != scharhd))
3599
  {
3629
  {
3600
    /* Do no adjustment */
3630
    /* Do no adjustment */
3601
    if(sreg!=dreg)
3631
    if (sreg!=dreg)
3602
    {
3632
    {
3603
      mov_rr_ins(sreg,dreg);comment(NIL);
3633
      mov_rr_ins(sreg,dreg);comment(NIL);
3604
    }
3634
    }
3605
    return;
3635
    return;
3606
  }
3636
  }
3607
  
3637
 
3608
  
3638
 
3609
  if(trap==NO_ERROR_JUMP)
3639
  if (trap==NO_ERROR_JUMP)
3610
  {
3640
  {
3611
    switch(dest_shpe)
3641
    switch (dest_shpe)
3612
    {
3642
    {
3613
     case scharhd:
3643
     case scharhd:
3614
      if(architecture==POWERPC_CODE)
3644
      if (architecture==POWERPC_CODE)
3615
      {
3645
      {
3616
	rr_ins(i_extsb,sreg,dreg);
3646
	rr_ins(i_extsb,sreg,dreg);
3617
      }
3647
      }
3618
      else
3648
      else
3619
      {
3649
      {
Line 3639... Line 3669...
3639
      break;
3669
      break;
3640
    }
3670
    }
3641
  }
3671
  }
3642
  else
3672
  else
3643
  {
3673
  {
3644
    switch(dest_shpe)
3674
    switch (dest_shpe)
3645
    {
3675
    {
3646
     case scharhd:
3676
     case scharhd:
3647
      testsigned(sreg, -128, 127, trap);
3677
      testsigned(sreg, -128, 127, trap);
3648
      if(sreg !=dreg){ mov_rr_ins(sreg,dreg);comment(NIL); }
3678
      if (sreg !=dreg) { mov_rr_ins(sreg,dreg);comment(NIL); }
3649
      break;
3679
      break;
3650
     case ucharhd:
3680
     case ucharhd:
3651
      testusigned(sreg,255,trap);
3681
      testusigned(sreg,255,trap);
3652
      if(sreg !=dreg){ mov_rr_ins(sreg,dreg);comment(NIL); }
3682
      if (sreg !=dreg) { mov_rr_ins(sreg,dreg);comment(NIL); }
3653
      break;
3683
      break;
3654
     case swordhd:
3684
     case swordhd:
3655
      testsigned(sreg,-0x8000,0x7fff,trap);
3685
      testsigned(sreg,-0x8000,0x7fff,trap);
3656
      if(sreg !=dreg){ mov_rr_ins(sreg,dreg);comment(NIL); }
3686
      if (sreg !=dreg) { mov_rr_ins(sreg,dreg);comment(NIL); }
3657
      break;
3687
      break;
3658
     case uwordhd:
3688
     case uwordhd:
3659
      testusigned(sreg,0xffff,trap);
3689
      testusigned(sreg,0xffff,trap);
3660
      if(sreg !=dreg){ mov_rr_ins(sreg,dreg);comment(NIL); }
3690
      if (sreg !=dreg) { mov_rr_ins(sreg,dreg);comment(NIL); }
3661
      break;
3691
      break;
3662
     case slonghd:
3692
     case slonghd:
3663
     case ulonghd:
3693
     case ulonghd:
3664
      mov_rr_ins(sreg,dreg);comment(NIL);
3694
      mov_rr_ins(sreg,dreg);comment(NIL);
3665
      break;
3695
      break;