Subversion Repositories tendra.SVN

Rev

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

Rev 2 Rev 7
Line -... Line 1...
-
 
1
/*
-
 
2
 * Copyright (c) 2002-2005 The TenDRA Project <http://www.tendra.org/>.
-
 
3
 * All rights reserved.
-
 
4
 *
-
 
5
 * Redistribution and use in source and binary forms, with or without
-
 
6
 * modification, are permitted provided that the following conditions are met:
-
 
7
 *
-
 
8
 * 1. Redistributions of source code must retain the above copyright notice,
-
 
9
 *    this list of conditions and the following disclaimer.
-
 
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
-
 
11
 *    this list of conditions and the following disclaimer in the documentation
-
 
12
 *    and/or other materials provided with the distribution.
-
 
13
 * 3. Neither the name of The TenDRA Project nor the names of its contributors
-
 
14
 *    may be used to endorse or promote products derived from this software
-
 
15
 *    without specific, prior written permission.
-
 
16
 *
-
 
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
-
 
18
 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-
 
19
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-
 
20
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
-
 
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-
 
22
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-
 
23
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-
 
24
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-
 
25
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-
 
26
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-
 
27
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
28
 *
-
 
29
 * $Id$
-
 
30
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
 
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
Line 335... Line 365...
335
 
365
 
336
 
366
 
337
/* PROCEDURES */
367
/* PROCEDURES */
338
 
368
 
339
void clean_stack
369
void clean_stack
340
    PROTO_Z ()
370
(void)
341
{
371
{
342
  if (no_frame && not_in_params && not_in_postlude && stack_dec != 0)
372
  if (no_frame && not_in_params && not_in_postlude && stack_dec != 0)
343
    stack_return(-stack_dec);
373
    stack_return(-stack_dec);
344
}
374
}
345
 
375
 
346
 
376
 
347
/* is this a pushable proc argument ? */
377
/* is this a pushable proc argument ? */
348
static int push_arg
378
static int push_arg
349
    PROTO_N ( (e) )
-
 
350
    PROTO_T ( exp e )
379
(exp e)
351
{
380
{
352
  shape sha = sh(e);
381
  shape sha = sh(e);
353
  unsigned char  n = name (sha);
382
  unsigned char  n = name(sha);
354
 
383
 
355
  if (name(e) == real_tag)
384
  if (name(e) == real_tag)
356
    return 1;
385
    return 1;
357
 
386
 
358
  if (is_floating (n) || n == cpdhd || n == nofhd)
387
  if (is_floating(n) || n == cpdhd || n == nofhd)
359
    return 0;
388
    return 0;
360
 
389
 
361
  return (1);
390
  return(1);
362
}
391
}
363
 
392
 
364
static void code_push
393
static void code_push
365
    PROTO_N ( (stack, t) )
-
 
366
    PROTO_T ( ash stack X exp t )
394
(ash stack, exp t)
367
{
395
{
368
  int n = (int)name(t);
396
  int n = (int)name(t);
369
  if (is_o(n))
397
  if (is_o(n))
370
    coder (pushdest, stack, t);
398
    coder(pushdest, stack, t);
371
  else {
399
  else {
372
    coder(reg0, stack, t);
400
    coder(reg0, stack, t);
373
    move(sh(t), reg0, pushdest);
401
    move(sh(t), reg0, pushdest);
374
  };
402
  };
375
  return;
403
  return;
376
}
404
}
377
 
405
 
378
/* produce the code for proc params in
406
/* produce the code for proc params in
379
   order from last to first */
407
   order from last to first */
380
static void code_pars
408
static void code_pars
381
    PROTO_N ( (stack, t) )
-
 
382
    PROTO_T ( ash stack X exp t )
409
(ash stack, exp t)
383
{
410
{
384
  int tsize = shape_size(sh(t));
411
  int tsize = shape_size(sh(t));
385
  if (last (t)) {		/* last parameter is pushed first */
412
  if (last (t)) {		/* last parameter is pushed first */
386
    code_push (stack, (name(t)==caller_tag) ? son(t) : t);
413
    code_push(stack,(name(t) ==caller_tag)? son(t): t);
387
    stack_dec -= rounder (tsize, param_align);
414
    stack_dec -= rounder(tsize, param_align);
388
  }
415
  }
389
  else {
416
  else {
390
    code_pars (stack, bro (t));/* encode the rest of the parameters */
417
    code_pars (stack, bro (t));/* encode the rest of the parameters */
391
    code_push (stack, (name(t)==caller_tag) ? son(t) : t);	/* code this parameter */
418
    code_push (stack, (name(t)==caller_tag) ? son(t) : t);	/* code this parameter */
392
    stack_dec -= rounder (tsize, param_align);
419
    stack_dec -= rounder(tsize, param_align);
393
    /* allow for the size */
420
    /* allow for the size */
394
  };
421
  };
395
}
422
}
396
 
423
 
397
/* stack parameters ready for apply_proc */
424
/* stack parameters ready for apply_proc */
398
static int procargs
425
static int procargs
399
    PROTO_N ( (stack, arg, has_checkstack) )
-
 
400
    PROTO_T ( ash stack X exp arg X int has_checkstack )
426
(ash stack, exp arg, int has_checkstack)
401
{
427
{
402
  int use_push = 1;
428
  int use_push = 1;
403
  int longs = 0, extra;
429
  int longs = 0, extra;
404
  exp t = arg;
430
  exp t = arg;
405
  while (t != nilexp) {
431
  while (t != nilexp) {
406
    if (name(t)==caller_tag) {
432
    if (name(t) ==caller_tag) {
407
      if (use_push && !push_arg (son(t)))
433
      if (use_push && !push_arg(son(t)))
408
        use_push = 0;
434
        use_push = 0;
409
      no(t) = longs;	/* needed for postlude */
435
      no(t) = longs;	/* needed for postlude */
410
    }
436
    }
411
    else {
437
    else {
412
      if (use_push && !push_arg (t))
438
      if (use_push && !push_arg(t))
413
        use_push = 0;
439
        use_push = 0;
414
    }
440
    }
415
    longs = rounder(longs + shape_size(sh(t)), param_align);
441
    longs = rounder(longs + shape_size(sh(t)), param_align);
416
    if (last(t))
442
    if (last(t))
417
      break;
443
      break;
418
    t = bro(t);
444
    t = bro(t);
419
  };
445
  };
420
  extra = (longs - stack_dec) % stack_align;
446
  extra = (longs - stack_dec)% stack_align;
421
  longs += extra;
447
  longs += extra;
422
 
448
 
423
  if (use_push) {
449
  if (use_push) {
424
	  /* push instructions can be used. Note that stack_dec is moved
450
	  /* push instructions can be used. Note that stack_dec is moved
425
	     so that instructions which address positively with respect to
451
	     so that instructions which address positively with respect to
Line 433... Line 459...
433
#endif
459
#endif
434
    };
460
    };
435
    if (arg != nilexp) {
461
    if (arg != nilexp) {
436
      if (has_checkstack && longs > 160) {
462
      if (has_checkstack && longs > 160) {
437
	/* check stack before pushing args if more than 5 words */
463
	/* check stack before pushing args if more than 5 words */
438
	checkalloc_stack (mw (zeroe, longs/8), 0);
464
	checkalloc_stack(mw(zeroe, longs/8), 0);
439
      }
465
      }
440
      code_pars (stack, arg);
466
      code_pars(stack, arg);
441
    }
467
    }
442
  }
468
  }
443
  else {
469
  else {
444
	  /* if push cannot be used, move the stack down first, and then
470
	  /* if push cannot be used, move the stack down first, and then
445
	     assemble the parameters in place. Again, adjust stack_dec. */
471
	     assemble the parameters in place. Again, adjust stack_dec. */
446
    int off = extra;
472
    int off = extra;
447
    if (has_checkstack)
473
    if (has_checkstack)
448
      checkalloc_stack (mw (zeroe, longs/8), 1);
474
      checkalloc_stack(mw(zeroe, longs/8), 1);
449
    else
475
    else
450
      decstack (longs);
476
      decstack(longs);
451
    cond1_set = 0;
477
    cond1_set = 0;
452
    cond2_set = 0;
478
    cond2_set = 0;
453
    stack_dec -= longs;
479
    stack_dec -= longs;
454
#ifdef NEWDWARF
480
#ifdef NEWDWARF
455
    if (diagnose && dwarf2 && no_frame)
481
    if (diagnose && dwarf2 && no_frame)
Line 457... Line 483...
457
#endif
483
#endif
458
 
484
 
459
    t = arg;
485
    t = arg;
460
    while (1)
486
    while (1)
461
     {
487
     {
462
	coder(mw(ind_sp.where_exp, off), stack, (name(t)==caller_tag ? son(t) : t));
488
	coder(mw(ind_sp.where_exp, off), stack,(name(t) ==caller_tag ? son(t): t));
463
	off = rounder(off + shape_size(sh(t)), param_align);
489
	off = rounder(off + shape_size(sh(t)), param_align);
464
	if (last(t))
490
	if (last(t))
465
	  break;
491
	  break;
466
	t = bro(t);
492
	t = bro(t);
467
     };
493
     };
Line 470... Line 496...
470
}
496
}
471
 
497
 
472
/* stack dynamic or same callees */
498
/* stack dynamic or same callees */
473
/* %edx and %ecx don't need to be preserved */
499
/* %edx and %ecx don't need to be preserved */
474
static int push_cees
500
static int push_cees
475
    PROTO_N ( (src, siz, vc, stack) )
-
 
476
    PROTO_T ( exp src X exp siz X int vc X ash stack )
501
(exp src, exp siz, int vc, ash stack)
477
{
502
{
478
  int old_regsinuse = regsinuse;
503
  int old_regsinuse = regsinuse;
479
  int longs = -1;
504
  int longs = -1;
480
  if (siz == nilexp && callee_size >= 0)
505
  if (siz == nilexp && callee_size >= 0)
481
    longs = callee_size;
506
    longs = callee_size;
482
  if (siz != nilexp && name(siz) == val_tag)
507
  if (siz != nilexp && name(siz) == val_tag)
483
    longs = rounder (no(siz), param_align);
508
    longs = rounder(no(siz), param_align);
484
  if (longs == 0) {
509
  if (longs == 0) {
485
    if (vc) {
510
    if (vc) {
486
      ins2 (leal, 32, 32, mw(ind_sp.where_exp, longs), reg0);
511
      ins2(leal, 32, 32, mw(ind_sp.where_exp, longs), reg0);
487
      ins0 (pusheax);
512
      ins0(pusheax);
488
      stack_dec -= 32;
513
      stack_dec -= 32;
489
      return (32);
514
      return(32);
490
    }
515
    }
491
    return (0);
516
    return(0);
492
  }
517
  }
493
  if (longs < 0) {
518
  if (longs < 0) {
494
    must_use_bp = 1;	/* scan2 must ensure !no_frame */
519
    must_use_bp = 1;	/* scan2 must ensure !no_frame */
495
    if (siz == nilexp) {
520
    if (siz == nilexp) {
496
	/* calculate size from calling proc callees */
521
	/* calculate size from calling proc callees */
497
      outs (" movl 8(%ebp),%eax\n");
522
      outs(" movl 8(%ebp),%eax\n");
498
      outs (" subl %ebp,%eax\n");
523
      outs(" subl %ebp,%eax\n");
499
      outs (" subl $12,%eax\n");
524
      outs(" subl $12,%eax\n");
500
    }
525
    }
501
    else {
526
    else {
502
      coder (reg0, stack, siz);
527
      coder(reg0, stack, siz);
503
      if (al2(sh(siz)) < param_align) {
528
      if (al2(sh(siz)) < param_align) {
504
	if (al2(sh(siz)) == 1) {
529
	if (al2(sh(siz)) == 1) {
505
	  outs (" addl $31,%eax\n");
530
	  outs(" addl $31,%eax\n");
506
	  outs (" shrl $3,%eax\n");
531
	  outs(" shrl $3,%eax\n");
507
	}
532
	}
508
	else
533
	else
509
	  outs (" addl $3,%eax\n");
534
	  outs(" addl $3,%eax\n");
510
	outs (" andl $-4,%eax\n");
535
	outs(" andl $-4,%eax\n");
511
      }
536
      }
512
    }
537
    }
513
    ins0 (pusheax);
538
    ins0(pusheax);
514
    stack_dec -= 32;
539
    stack_dec -= 32;
515
  }
540
  }
516
  if (src == nilexp) {
541
  if (src == nilexp) {
517
    if (callee_size >= 0)
542
    if (callee_size >= 0)
518
      outs (" leal 8(%ebp),%eax\n");
543
      outs(" leal 8(%ebp),%eax\n");
519
    else
544
    else
520
      outs (" leal 12(%ebp),%eax\n");
545
      outs(" leal 12(%ebp),%eax\n");
521
    }
546
    }
522
  else
547
  else
523
    coder (reg0, stack, src);
548
    coder(reg0, stack, src);
524
  move (slongsh, reg5, reg1);
549
  move(slongsh, reg5, reg1);
525
  move (slongsh, reg0, reg5);
550
  move(slongsh, reg0, reg5);
526
  if (longs < 0) {
551
  if (longs < 0) {
527
    ins0 (popecx);
552
    ins0(popecx);
528
    stack_dec += 32;
553
    stack_dec += 32;
529
    if (vc)
554
    if (vc)
530
      outs (" movl %esp,%eax\n");
555
      outs(" movl %esp,%eax\n");
531
    outs (" subl %ecx,%esp\n");
556
    outs(" subl %ecx,%esp\n");
532
    outs (" shrl $2,%ecx\n");
557
    outs(" shrl $2,%ecx\n");
533
    if (vc)
558
    if (vc)
534
      outs (" pushl %eax\n");
559
      outs(" pushl %eax\n");
535
  }
560
  }
536
  else {
561
  else {
537
    sub(slongsh, mw(zeroe, longs/8), sp, sp);
562
    sub(slongsh, mw(zeroe, longs/8), sp, sp);
538
    stack_dec -= longs;
563
    stack_dec -= longs;
539
    if (vc) {
564
    if (vc) {
540
      ins2 (leal, 32, 32, mw(ind_sp.where_exp, longs), reg0);
565
      ins2(leal, 32, 32, mw(ind_sp.where_exp, longs), reg0);
541
      ins0 (pusheax);
566
      ins0(pusheax);
542
      stack_dec -= 32;
567
      stack_dec -= 32;
543
    }
568
    }
544
    move (slongsh, mw(zeroe, longs/32), reg2);
569
    move(slongsh, mw(zeroe, longs/32), reg2);
545
    if (vc)
570
    if (vc)
546
      longs += 32;
571
      longs += 32;
547
  }
572
  }
548
  move (slongsh, reg4, reg0);
573
  move(slongsh, reg4, reg0);
549
  if (vc)
574
  if (vc)
550
    outs (" leal 4(%esp),%edi\n");
575
    outs(" leal 4(%esp),%edi\n");
551
  else
576
  else
552
    outs (" movl %esp,%edi\n");
577
    outs(" movl %esp,%edi\n");
553
  outs (" rep\n movsl\n");
578
  outs(" rep\n movsl\n");
554
  move (slongsh, reg0, reg4);
579
  move(slongsh, reg0, reg4);
555
  move (slongsh, reg1, reg5);
580
  move(slongsh, reg1, reg5);
556
  regsinuse = old_regsinuse;
581
  regsinuse = old_regsinuse;
557
  invalidate_dest (reg1);
582
  invalidate_dest(reg1);
558
  invalidate_dest (reg2);
583
  invalidate_dest(reg2);
559
  invalidate_dest (reg4);
584
  invalidate_dest(reg4);
560
  invalidate_dest (reg5);
585
  invalidate_dest(reg5);
561
  return longs;
586
  return longs;
562
}
587
}
563
 
588
 
564
 
589
 
565
 
590
 
Line 577... Line 602...
577
};
602
};
578
 
603
 
579
/* allocate registers ebx esi edi,
604
/* allocate registers ebx esi edi,
580
   providing br registers are left */
605
   providing br registers are left */
581
static regu alloc_reg_big
606
static regu alloc_reg_big
582
    PROTO_N ( (rs, sha, br, byteuse) )
-
 
583
    PROTO_T ( int rs X shape sha X int br X int byteuse )
607
(int rs, shape sha, int br, int byteuse)
584
{
608
{
585
  int  sz,
609
  int  sz,
586
        nr,
610
        nr,
587
        mask,
611
        mask,
588
        i,
612
        i,
Line 597... Line 621...
597
		 - bits_in[((unsigned int)rs >> 4) & 0x7];
621
		 - bits_in[((unsigned int)rs >> 4) & 0x7];
598
 
622
 
599
 
623
 
600
  if ((reg_left) < (br)) {	/* can't allocate */
624
  if ((reg_left) < (br)) {	/* can't allocate */
601
    ru.can_do = 0;
625
    ru.can_do = 0;
602
    return (ru);
626
    return(ru);
603
  };
627
  };
604
 
628
 
605
  switch (nr) {			/* number of registers needed
629
  switch (nr) {			/* number of registers needed
606
				   (consecutive) */
630
				   (consecutive) */
607
    case 1:
631
    case 1:
608
      mask = (noshort == 0) ? bigmask1 : bigmask1ns;
632
      mask = (noshort == 0)? bigmask1 : bigmask1ns;
609
      i = nobigreg - noshort;
633
      i = nobigreg - noshort;
610
      break;
634
      break;
611
    case 2:
635
    case 2:
612
      mask = bigmask2;
636
      mask = bigmask2;
613
      i = nobigreg - 1;
637
      i = nobigreg - 1;
614
      break;
638
      break;
615
    default: {
639
    default: {
616
      SET(mask);
640
      SET(mask);
617
      SET(i);
641
      SET(i);
618
      failer (WRONG_REGSIZE);
642
      failer(WRONG_REGSIZE);
619
    };
643
    };
620
  };
644
  };
621
 
645
 
622
  while ((rs & mask) != 0 && i > 0) {
646
  while ((rs & mask)!= 0 && i > 0) {
623
    mask = (int)((unsigned int)mask >> 1);
647
    mask = (int)((unsigned int)mask >> 1);
624
    --i;
648
    --i;
625
  };
649
  };
626
 
650
 
627
  if (i > 0) {			/* allocate registers */
651
  if (i > 0) {			/* allocate registers */
Line 631... Line 655...
631
    ru.ru_reg_free = rs | mask;
655
    ru.ru_reg_free = rs | mask;
632
  }
656
  }
633
  else
657
  else
634
    ru.can_do = 0;
658
    ru.can_do = 0;
635
 
659
 
636
  return (ru);
660
  return(ru);
637
}
661
}
638
 
662
 
639
/* allocate registers ecx edx ebx esi edi
663
/* allocate registers ecx edx ebx esi edi
640
   if at least br registers are available */
664
   if at least br registers are available */
641
static regu alloc_reg_small
665
static regu alloc_reg_small
642
    PROTO_N ( (rs, sha, br, byteuse) )
-
 
643
    PROTO_T ( int rs X shape sha X int br X int byteuse )
666
(int rs, shape sha, int br, int byteuse)
644
{
667
{
645
  int  sz,
668
  int  sz,
646
        nr,
669
        nr,
647
        mask,
670
        mask,
648
        i,
671
        i,
Line 657... Line 680...
657
		 - bits_in[((unsigned int)rs >> 4) & 0x7];
680
		 - bits_in[((unsigned int)rs >> 4) & 0x7];
658
 
681
 
659
 
682
 
660
  if ((reg_left) < (br)) {	/* can't allocate */
683
  if ((reg_left) < (br)) {	/* can't allocate */
661
    ru.can_do = 0;
684
    ru.can_do = 0;
662
    return (ru);
685
    return(ru);
663
  };
686
  };
664
 
687
 
665
  switch (nr) {			/* number of registers needed
688
  switch (nr) {			/* number of registers needed
666
				   (consecutive) */
689
				   (consecutive) */
667
    case 1:
690
    case 1:
Line 673... Line 696...
673
      i = nosmallreg - 1;
696
      i = nosmallreg - 1;
674
      break;
697
      break;
675
    default: {
698
    default: {
676
      SET(mask);
699
      SET(mask);
677
      SET(i);
700
      SET(i);
678
      failer (WRONG_REGSIZE);
701
      failer(WRONG_REGSIZE);
679
     };
702
     };
680
  };
703
  };
681
 
704
 
682
  while ((rs & mask) != 0 && i > 0) {
705
  while ((rs & mask)!= 0 && i > 0) {
683
    mask = (int)((unsigned int)mask << 1);
706
    mask = (int)((unsigned int)mask << 1);
684
    --i;
707
    --i;
685
  };
708
  };
686
 
709
 
687
  if (i > 0) {			/* allocate */
710
  if (i > 0) {			/* allocate */
688
    min_rfree |= mask;
711
    min_rfree |= mask;
689
    ru.can_do = 1;
712
    ru.can_do = 1;
690
    ru.ru_regs = mask;
713
    ru.ru_regs = mask;
691
    ru.ru_reg_free = rs | mask;
714
    ru.ru_reg_free = rs | mask;
692
    return (ru);
715
    return(ru);
693
  }
716
  }
694
  else
717
  else
695
    return alloc_reg_big(rs, sha, br, byteuse);
718
    return alloc_reg_big(rs, sha, br, byteuse);
696
 
719
 
697
}
720
}
698
 
721
 
699
 
722
 
700
/* allocate floating point registers, if
723
/* allocate floating point registers, if
701
   at least br are available */
724
   at least br are available */
702
static regu alloc_fl_small
725
static regu alloc_fl_small
703
    PROTO_N ( (rs, br) )
-
 
704
    PROTO_T ( int rs X int br )
726
(int rs, int br)
705
{
727
{
706
  int  mask,
728
  int  mask,
707
        i,
729
        i,
708
        reg_left;
730
        reg_left;
709
  regu ru;
731
  regu ru;
710
  reg_left = nofl - bits_in[((unsigned int)rs >> 8) & 0xf] 
732
  reg_left = nofl - bits_in[((unsigned int)rs >> 8) & 0xf]
711
		- bits_in[((unsigned int)rs >> 12) & 0xf];
733
		- bits_in[((unsigned int)rs >> 12) & 0xf];
712
 
734
 
713
 
735
 
714
  if ((reg_left) < (br)) {	/* can't allocate */
736
  if ((reg_left) < (br)) {	/* can't allocate */
715
    ru.can_do = 0;
737
    ru.can_do = 0;
716
    return (ru);
738
    return(ru);
717
  };
739
  };
718
 
740
 
719
  mask = smallflmask;
741
  mask = smallflmask;
720
  i = nofl;
742
  i = nofl;
721
 
743
 
722
  while ((rs & mask) != 0 && i > 0) {
744
  while ((rs & mask)!= 0 && i > 0) {
723
    mask = (int)((unsigned int)mask << 1);
745
    mask = (int)((unsigned int)mask << 1);
724
    --i;
746
    --i;
725
  };
747
  };
726
 
748
 
727
  if (i > 0) {			/* allocate */
749
  if (i > 0) {			/* allocate */
Line 730... Line 752...
730
    ru.ru_reg_free = rs | mask;
752
    ru.ru_reg_free = rs | mask;
731
  }
753
  }
732
  else
754
  else
733
    ru.can_do = 0;		/* can't allocate */
755
    ru.can_do = 0;		/* can't allocate */
734
 
756
 
735
  return (ru);
757
  return(ru);
736
}
758
}
737
 
759
 
738
/* allocate all registers */
760
/* allocate all registers */
739
static regu alloc_reg
761
static regu alloc_reg
740
    PROTO_N ( (rs, sha, br, big_reg, e) )
-
 
741
    PROTO_T ( int rs X shape sha X int br X int big_reg X exp e )
762
(int rs, shape sha, int br, int big_reg, exp e)
742
{
763
{
743
  if (name (sha) >= shrealhd && name (sha) <= doublehd) {
764
  if (name(sha) >= shrealhd && name(sha) <= doublehd) {
744
#ifdef NEWDIAGS
765
#ifdef NEWDIAGS
745
    if (big_reg || diag_visible || round_after_flop ||
766
    if (big_reg || diag_visible || round_after_flop ||
746
#else
767
#else
747
    if (big_reg || diagnose || round_after_flop ||
768
    if (big_reg || diagnose || round_after_flop ||
748
#endif
769
#endif
749
	(is80586 && isvar(e))) {
770
	(is80586 && isvar(e))) {
750
      regu ru;
771
      regu ru;
751
      ru.can_do = 0;
772
      ru.can_do = 0;
752
      return (ru);
773
      return(ru);
753
    }
774
    }
754
    else
775
    else
755
      return (alloc_fl_small (rs, br));
776
      return(alloc_fl_small(rs, br));
756
  };
777
  };
757
  if (big_reg)
778
  if (big_reg)
758
    return (alloc_reg_big (rs, sha, br, isbyteuse(e)));
779
    return(alloc_reg_big(rs, sha, br, isbyteuse(e)));
759
  else
780
  else
760
    return (alloc_reg_small (rs, sha, br, isbyteuse(e)));
781
    return(alloc_reg_small(rs, sha, br, isbyteuse(e)));
761
}
782
}
762
 
783
 
763
 
784
 
764
/************************************************************************
785
/************************************************************************
765
   def_where choose where to put a declaration. e is the declaration.
786
   def_where choose where to put a declaration. e is the declaration.
Line 780... Line 801...
780
 
801
 
781
 ************************************************************************/
802
 ************************************************************************/
782
 
803
 
783
 
804
 
784
static dcl alloc_regable
805
static dcl alloc_regable
785
    PROTO_N ( (dc, def, e, big_reg) )
-
 
786
    PROTO_T ( dcl dc X exp def X exp e X int big_reg )
806
(dcl dc, exp def, exp e, int big_reg)
787
{
807
{
788
  where alt;
808
  where alt;
789
  int defsize = shape_size(sh(def));
809
  int defsize = shape_size(sh(def));
790
  regu ru;
810
  regu ru;
791
  alt = equiv_reg (mw (def, 0), defsize);
811
  alt = equiv_reg(mw(def, 0), defsize);
792
 
812
 
793
  if (alt.where_exp != nilexp) {
813
  if (alt.where_exp != nilexp) {
794
    int  mask = no (son (alt.where_exp));
814
    int  mask = no(son(alt.where_exp));
795
    if (mask != 1 && (!big_reg || mask >= 0x8)) {
815
    if (mask != 1 && (!big_reg || mask >= 0x8)) {
796
      if ((mask & regsinuse) != 0 && !isvar (e) &&
816
      if ((mask & regsinuse)!= 0 && !isvar(e) &&
797
	  (defsize > 8 || mask < 0x10)) {
817
	 (defsize > 8 || mask < 0x10)) {
798
	if (no_side (bro (son (e)))) {
818
	if (no_side(bro(son(e)))) {
799
	  dc.dcl_pl = reg_pl;
819
	  dc.dcl_pl = reg_pl;
800
	  dc.dcl_n = mask;
820
	  dc.dcl_n = mask;
801
	  dc.dcl_new = 0;
821
	  dc.dcl_new = 0;
802
	  return (dc);
822
	  return(dc);
803
	};
823
	};
804
      };
824
      };
805
    };
825
    };
806
  };
826
  };
807
 
827
 
808
 
828
 
809
  if (ru = alloc_reg (regsinuse, sh (def), no (e), big_reg, e),
829
  if (ru = alloc_reg(regsinuse, sh(def), no(e), big_reg, e),
810
      ru.can_do) {
830
      ru.can_do) {
811
    if (alt.where_exp != nilexp) {
831
    if (alt.where_exp != nilexp) {
812
      int  mask = no (son (alt.where_exp));
832
      int  mask = no(son(alt.where_exp));
813
      if (mask != 1 && (!big_reg || mask >= 0x8)) {
833
      if (mask != 1 && (!big_reg || mask >= 0x8)) {
814
	if ((mask & regsinuse) == 0 &&
834
	if ((mask & regsinuse) == 0 &&
815
	    (defsize > 8 || mask < 0x10)) {
835
	   (defsize > 8 || mask < 0x10)) {
816
	  dc.dcl_pl = reg_pl;
836
	  dc.dcl_pl = reg_pl;
817
	  dc.dcl_n = mask;
837
	  dc.dcl_n = mask;
818
	  return (dc);
838
	  return(dc);
819
	};
839
	};
820
      };
840
      };
821
    };
841
    };
822
 
842
 
823
    dc.dcl_pl = reg_pl;
843
    dc.dcl_pl = reg_pl;
824
    dc.dcl_n = ru.ru_regs;
844
    dc.dcl_n = ru.ru_regs;
825
    return (dc);
845
    return(dc);
826
  };
846
  };
827
  dc.dcl_pl = 0;
847
  dc.dcl_pl = 0;
828
  return (dc);
848
  return(dc);
829
}
849
}
830
 
850
 
831
static dcl def_where
851
static dcl def_where
832
    PROTO_N ( (e, def, stack) )
-
 
833
    PROTO_T ( exp e X exp def X ash stack )
852
(exp e, exp def, ash stack)
834
{
853
{
835
  int big_reg = has_intnl_call(e);
854
  int big_reg = has_intnl_call(e);
836
  dcl dc;
855
  dcl dc;
837
  ash locash;
856
  ash locash;
838
  exp body = bro (def);
857
  exp body = bro(def);
839
  dc.dcl_place = stack;
858
  dc.dcl_place = stack;
840
  dc.dcl_new = 1;
859
  dc.dcl_new = 1;
841
 
860
 
842
 
861
 
843
  if (name (sh (def)) == tophd && !isvis(e)) {
862
  if (name(sh(def)) == tophd && !isvis(e)) {
844
    dc.dcl_pl = nowhere_pl;
863
    dc.dcl_pl = nowhere_pl;
845
    dc.dcl_n = 0;
864
    dc.dcl_n = 0;
846
    return (dc);
865
    return(dc);
847
  };
866
  };
848
 
867
 
849
  if (name(def) == name_tag && !isvar(son(def)) &&
868
  if (name(def) == name_tag && !isvar(son(def)) &&
850
        no(def) == 0 && isloadparam(def)) {
869
        no(def) == 0 && isloadparam(def)) {
851
    if (regable (e) && (name(son(son(def)))==formal_callee_tag ?
870
    if (regable(e) && (name(son(son(def))) ==formal_callee_tag ?
852
			 !has_same_callees : !has_tail_call)) {
871
			 !has_same_callees : !has_tail_call)) {
853
	dcl ndc;
872
	dcl ndc;
854
	ndc = alloc_regable (dc, def, e, big_reg);
873
	ndc = alloc_regable(dc, def, e, big_reg);
855
	if (ndc.dcl_pl != 0)		/* local copy of arg in register */
874
	if (ndc.dcl_pl != 0)		/* local copy of arg in register */
856
	  return (ndc);
875
	  return(ndc);
857
    };
876
    };
858
    dc.dcl_pl = ptno (son (def));
877
    dc.dcl_pl = ptno(son(def));
859
    dc.dcl_n = no (son (def));
878
    dc.dcl_n = no(son(def));
860
    dc.dcl_new = 0;
879
    dc.dcl_new = 0;
861
    return dc;
880
    return dc;
862
  };
881
  };
863
 
882
 
864
 
883
 
865
  if (!isvar (e) &&
884
  if (!isvar(e) &&
866
      ((name (def) == name_tag && !isvar (son (def)) &&
885
     ((name(def) == name_tag && !isvar(son(def)) &&
867
	  (!isglob (son (def)))
886
	 (!isglob(son(def)))
868
	) ||
887
	) ||
869
	(name (def) == cont_tag && name (son (def)) == name_tag &&
888
	(name(def) == cont_tag && name(son(def)) == name_tag &&
870
	  isvar (son (son (def))) &&
889
	  isvar(son(son(def))) &&
871
	  (!isglob (son (son (def)))) &&
890
	 (!isglob(son(son(def)))) &&
872
 
891
 
873
	  no_side(body)))) {
892
	  no_side(body)))) {
874
    /* either we are identifying something already identified or the
893
    /* either we are identifying something already identified or the
875
       contents of a variable which is not altered by the body of the
894
       contents of a variable which is not altered by the body of the
876
       definition */
895
       definition */
877
    if (name (def) == name_tag) {
896
    if (name(def) == name_tag) {
878
      dc.dcl_pl = ptno (son (def));
897
      dc.dcl_pl = ptno(son(def));
879
      dc.dcl_n = no (son (def)) + no (def);
898
      dc.dcl_n = no(son(def)) + no(def);
880
    }
899
    }
881
    else {
900
    else {
882
      dc.dcl_pl = ptno (son (son (def)));
901
      dc.dcl_pl = ptno(son(son(def)));
883
      dc.dcl_n = no (son (son (def))) + no (son (def));
902
      dc.dcl_n = no(son(son(def))) + no(son(def));
884
    };
903
    };
885
    /* we have the declaration */
904
    /* we have the declaration */
886
 
905
 
887
    if (dc.dcl_pl == reg_pl) {	/* if the old one was in registers, reuse
906
    if (dc.dcl_pl == reg_pl) {	/* if the old one was in registers, reuse
888
				   it. */
907
				   it. */
889
      dc.dcl_new = 0;
908
      dc.dcl_new = 0;
890
      return (dc);
909
      return(dc);
891
    };
910
    };
892
 
911
 
893
    if (regable (e)) {
912
    if (regable(e)) {
894
	dcl ndc;
913
	dcl ndc;
895
	ndc = alloc_regable (dc, def, e, big_reg);
914
	ndc = alloc_regable(dc, def, e, big_reg);
896
	if (ndc.dcl_pl != 0)
915
	if (ndc.dcl_pl != 0)
897
	  return (ndc);
916
	  return(ndc);
898
    };
917
    };
899
 
918
 
900
    dc.dcl_new = 0;		/* if there was not room, reuse the old
919
    dc.dcl_new = 0;		/* if there was not room, reuse the old
901
				   dec */
920
				   dec */
902
    return (dc);
921
    return(dc);
903
 
922
 
904
  };
923
  };
905
 
924
 
906
  /* try to allocate in registers, except when narrowing fp variety */
925
  /* try to allocate in registers, except when narrowing fp variety */
907
  if (regable (e) &&
926
  if (regable(e) &&
908
	(name(def) != chfl_tag || name(sh(def)) >= name(sh(son(def))))) {
927
	(name(def)!= chfl_tag || name(sh(def)) >= name(sh(son(def))))) {
909
    dcl ndc;
928
    dcl ndc;
910
    ndc = alloc_regable (dc, def, e, big_reg);
929
    ndc = alloc_regable(dc, def, e, big_reg);
911
    if (ndc.dcl_pl != 0)
930
    if (ndc.dcl_pl != 0)
912
      return (ndc);
931
      return(ndc);
913
  };
932
  };
914
 
933
 
915
 
934
 
916
  /* otherwise allocate on the stack */
935
  /* otherwise allocate on the stack */
917
 
936
 
918
  {
937
  {
919
    int a = 32;
938
    int a = 32;
920
    shape s = sh(def);
939
    shape s = sh(def);
921
    if (stack_aligned_8byte && (name(s) == realhd ||
940
    if (stack_aligned_8byte && (name(s) == realhd ||
922
			(name(s) == nofhd && ptno(s) == realhd)))
941
			(name(s) == nofhd && ptno(s) == realhd)))
923
      a = 64;
942
      a = 64;
924
 
943
 
925
    locash.ashalign = 32;
944
    locash.ashalign = 32;
926
    dc.dcl_n = rounder(stack.ashsize, a);
945
    dc.dcl_n = rounder(stack.ashsize, a);
927
 
946
 
928
    locash.ashsize = dc.dcl_n + shape_size(sh(def));
947
    locash.ashsize = dc.dcl_n + shape_size(sh(def));
929
 
948
 
930
    dc.dcl_place = locash;
949
    dc.dcl_place = locash;
931
    dc.dcl_pl = local_pl;
950
    dc.dcl_pl = local_pl;
932
    return (dc);
951
    return(dc);
933
  };
952
  };
934
 
953
 
935
}
954
}
936
 
955
 
937
/***********************************************************************
956
/***********************************************************************
938
   solve produces the code for the solve construction.
957
   solve produces the code for the solve construction.
939
    s is the whole list of braches
958
    s is the whole list of braches
940
    l is the branches of which the label record have not been created.
959
    l is the branches of which the label record have not been created.
941
    dest is the destination for the value produced by each branch
960
    dest is the destination for the value produced by each branch
942
    jr is the jump record for the end of the construction.
961
    jr is the jump record for the end of the construction.
943
    stack is the initial stack ash
962
    stack is the initial stack ash
944
 ***********************************************************************/
963
 ***********************************************************************/
945
 
964
 
946
 
965
 
947
static void solve
966
static void solve
948
    PROTO_N ( (s, l, dest, jr, stack) )
-
 
949
    PROTO_T ( exp s X exp l X where dest X exp jr X ash stack )
967
(exp s, exp l, where dest, exp jr, ash stack)
950
{
968
{
951
  while (!last (l)) {		/* not the last branch */
969
  while (!last (l)) {		/* not the last branch */
952
    exp record = getexp (f_bottom, nilexp,
970
    exp record = getexp(f_bottom, nilexp,
953
        (bool)(props (son (bro (l))) & 2),
971
       (bool)(props(son(bro(l))) & 2),
954
        nilexp,
972
        nilexp,
955
	nilexp, 0, 0, 0);
973
	nilexp, 0, 0, 0);
956
    sonno(record) = stack_dec;
974
    sonno(record) = stack_dec;
957
    ptno(record) = next_lab();
975
    ptno(record) = next_lab();
958
    fstack_pos_of(record) = (prop)fstack_pos;	/* CAST:jmf: */
976
    fstack_pos_of(record) = (prop)fstack_pos;	/* CAST:jmf: */
959
    /* record the floating point stack position, fstack_pos */
977
    /* record the floating point stack position, fstack_pos */
960
    /* record is jump record for the label */
978
    /* record is jump record for the label */
961
    pt (son (bro (l))) = record;/* put it away */
979
    pt (son (bro (l))) = record;/* put it away */
962
    l = bro (l);
980
    l = bro(l);
963
  };
981
  };
964
 
982
 
965
  {
983
  {
966
    int  r1 = regsinuse;	/* record regsinuse for the start of each
984
    int  r1 = regsinuse;	/* record regsinuse for the start of each
967
				   branch and for the end. */
985
				   branch and for the end. */
968
    exp t;
986
    exp t;
969
    if (name (s) != goto_tag || pt (s) != bro (s))
987
    if (name(s)!= goto_tag || pt(s)!= bro(s))
970
      coder (dest, stack, s);	/* code the starting exp */
988
      coder (dest, stack, s);	/* code the starting exp */
971
#ifdef NEWDIAGS
989
#ifdef NEWDIAGS
972
    else
990
    else
973
      diag_arg (dest, stack, s);
991
      diag_arg(dest, stack, s);
974
#endif
992
#endif
975
    reset_fpucon();
993
    reset_fpucon();
976
    t = s;
994
    t = s;
977
    do {
995
    do {
978
      regsinuse = r1;
996
      regsinuse = r1;
979
      if (name (sh (t)) != bothd) {
997
      if (name(sh(t))!= bothd) {
980
	jump (jr, in_fstack (dest.where_exp));
998
	jump(jr, in_fstack(dest.where_exp));
981
      };
999
      };
982
      /* only put in jump if needed */
1000
      /* only put in jump if needed */
983
      t = bro (t);
1001
      t = bro(t);
984
      align_label(2, pt (son (t)));
1002
      align_label(2, pt(son(t)));
985
      set_label (pt (son (t)));
1003
      set_label(pt(son(t)));
986
      coder (dest, stack, t);
1004
      coder(dest, stack, t);
987
      reset_fpucon();
1005
      reset_fpucon();
988
    }
1006
    }
989
    while (!last (t));
1007
    while (!last(t));
990
    regsinuse = r1;
1008
    regsinuse = r1;
991
    return;
1009
    return;
992
  }
1010
  }
993
}
1011
}
994
 
1012
 
Line 996... Line 1014...
996
   caser produces the code for the case construction e, putting the
1014
   caser produces the code for the case construction e, putting the
997
   result into dest.
1015
   result into dest.
998
 *************************************************************************/
1016
 *************************************************************************/
999
 
1017
 
1000
static void caser
1018
static void caser
1001
    PROTO_N ( (arg, exhaustive, case_exp) )
-
 
1002
    PROTO_T ( exp arg X int exhaustive X exp case_exp )
1019
(exp arg, int exhaustive, exp case_exp)
1003
{
1020
{
1004
  exp t = arg;
1021
  exp t = arg;
1005
  int  n;
1022
  int  n;
1006
  int i;
1023
  int i;
1007
  int *v;
1024
  int *v;
Line 1013... Line 1030...
1013
  do
1030
  do
1014
  {
1031
  {
1015
    t=bro(t);
1032
    t=bro(t);
1016
  }
1033
  }
1017
  while (bro(t)!=nilexp);
1034
  while (bro(t)!=nilexp);
1018
  max=((son(t)==nilexp) ? no(t) : no(son(t)));
1035
  max= ((son(t) ==nilexp)? no(t): no(son(t)));
1019
 
1036
 
1020
 
1037
 
1021
  /* prepare to use jump table */
1038
  /* prepare to use jump table */
1022
  v = (int *) xcalloc (max - min + 1, sizeof (int));
1039
  v = (int *)xcalloc(max - min + 1, sizeof(int));
1023
  for (i = 0; i < (max - min + 1); ++i)
1040
  for (i = 0; i < (max - min + 1); ++i)
1024
    v[i] = -1;
1041
    v[i] = -1;
1025
  t = arg;
1042
  t = arg;
1026
  do {
1043
  do {
1027
    exp lab;
1044
    exp lab;
1028
    t = bro (t);
1045
    t = bro(t);
1029
    lab = final_dest(pt(t));
1046
    lab = final_dest(pt(t));
1030
    n = ptno (pt (son (lab)));
1047
    n = ptno(pt(son(lab)));
1031
    for (i = no (t);
1048
    for (i = no(t);
1032
	i <= ((son (t) == nilexp) ? no (t) : no (son (t)));
1049
	i <= ((son(t) == nilexp)? no(t): no(son(t)));
1033
	++i)
1050
	++i)
1034
      v[i - min] = n;
1051
      v[i - min] = n;
1035
  }
1052
  }
1036
  while (bro (t) != nilexp);
1053
  while (bro(t)!= nilexp);
1037
 
1054
 
1038
  switch (name (sh (arg))) EXHAUSTIVE {
1055
  switch (name(sh(arg)))EXHAUSTIVE {
1039
    case scharhd:
1056
    case scharhd:
1040
    case ucharhd:
1057
    case ucharhd:
1041
      sz = 8;
1058
      sz = 8;
1042
      break;
1059
      break;
1043
    case swordhd:
1060
    case swordhd:
1044
    case uwordhd:
1061
    case uwordhd:
1045
      sz = 16;
1062
      sz = 16;
1046
      break;
1063
      break;
1047
    case slonghd:
1064
    case slonghd:
1048
    case ulonghd:
1065
    case ulonghd:
1049
      sz = 32;
1066
      sz = 32;
1050
      break;
1067
      break;
1051
  };
1068
  };
1052
 
1069
 
1053
  caseins (sz, arg, min, max,v, exhaustive, 0 , case_exp);
1070
  caseins(sz, arg, min, max,v, exhaustive, 0 , case_exp);
1054
		/* put in jump table */
1071
		/* put in jump table */
1055
  return;
1072
  return;
1056
}
1073
}
1057
 
1074
 
1058
 
1075
 
1059
/********************************************************************
1076
/********************************************************************
1060
   coder produces code for all constructions. It uses codec to
1077
   coder produces code for all constructions. It uses codec to
1061
   produce the code for the non side-effecting constructions. e is
1078
   produce the code for the non side-effecting constructions. e is
1062
   the construction to be processed, dest is where the result is to go,
1079
   the construction to be processed, dest is where the result is to go,
1063
   stack is the ash for the current stack.
1080
   stack is the ash for the current stack.
1064
 ********************************************************************/
1081
 ********************************************************************/
1065
 
1082
 
1066
static ash stack_room
1083
static ash stack_room
1067
    PROTO_N ( (stack, dest, off) )
-
 
1068
    PROTO_T ( ash stack X where dest X int off )
1084
(ash stack, where dest, int off)
1069
{
1085
{
1070
  if (name(dest.where_exp) == ident_tag)
1086
  if (name(dest.where_exp) == ident_tag)
1071
   {
1087
   {
1072
     if (ptno(dest.where_exp) != local_pl)
1088
     if (ptno(dest.where_exp)!= local_pl)
1073
       return stack;
1089
       return stack;
1074
     if ((no(dest.where_exp) + off) > stack.ashsize)
1090
     if ((no(dest.where_exp) + off) > stack.ashsize)
1075
       stack.ashsize = no(dest.where_exp) + off;
1091
       stack.ashsize = no(dest.where_exp) + off;
1076
   };
1092
   };
1077
 
1093
 
Line 1083... Line 1099...
1083
#ifdef NEWDIAGS
1099
#ifdef NEWDIAGS
1084
static void coder1
1100
static void coder1
1085
#else
1101
#else
1086
void coder
1102
void coder
1087
#endif
1103
#endif
1088
    PROTO_N ( (dest, stack, e) )
-
 
1089
    PROTO_T ( where dest X ash stack X exp e )
1104
(where dest, ash stack, exp e)
1090
{
1105
{
1091
  float old_scale;
1106
  float old_scale;
1092
  switch (name (e)) {
1107
  switch (name(e)) {
1093
    case ident_tag:
1108
    case ident_tag:
1094
      {
1109
      {
1095
	exp def = son (e);
1110
	exp def = son(e);
1096
	exp body = bro (def);
1111
	exp body = bro(def);
1097
	int  sz;
1112
	int  sz;
1098
	dcl dc;
1113
	dcl dc;
1099
	int  old_fstack_pos;
1114
	int  old_fstack_pos;
1100
	if (isinlined(e) && dest.where_off == 0 &&
1115
	if (isinlined(e) && dest.where_off == 0 &&
1101
		name(dest.where_exp) == ident_tag &&
1116
		name(dest.where_exp) == ident_tag &&
1102
		(!has_intnl_call(e) || ptno(dest.where_exp) != reg_pl ||
1117
		(!has_intnl_call(e) || ptno(dest.where_exp)!= reg_pl ||
1103
		   (no(dest.where_exp) > 4 && no(dest.where_exp) < smallflmask))) {
1118
		  (no(dest.where_exp) > 4 && no(dest.where_exp) < smallflmask))) {
1104
	  dc.dcl_pl = ptno(dest.where_exp);
1119
	  dc.dcl_pl = ptno(dest.where_exp);
1105
	  dc.dcl_n = no(dest.where_exp);
1120
	  dc.dcl_n = no(dest.where_exp);
1106
	  dc.dcl_place.ashsize = stack.ashsize + shape_size(sh(def));
1121
	  dc.dcl_place.ashsize = stack.ashsize + shape_size(sh(def));
1107
	  dc.dcl_place.ashalign = 32;
1122
	  dc.dcl_place.ashalign = 32;
1108
	  dc.dcl_new = 1;
1123
	  dc.dcl_new = 1;
Line 1113... Line 1128...
1113
	sz = (dc.dcl_place).ashsize;
1128
	sz = (dc.dcl_place).ashsize;
1114
 
1129
 
1115
 
1130
 
1116
	ptno (e) = dc.dcl_pl;	/* record the allocation in pt and no for
1131
	ptno (e) = dc.dcl_pl;	/* record the allocation in pt and no for
1117
				   when the value is used. */
1132
				   when the value is used. */
1118
	no (e) = dc.dcl_n;
1133
	no(e) = dc.dcl_n;
1119
 
1134
 
1120
	if (ptno (e) == reg_pl && name (sh (def)) >= shrealhd &&
1135
	if (ptno(e) == reg_pl && name(sh(def)) >= shrealhd &&
1121
	    name (sh (def)) <= doublehd) {
1136
	    name(sh(def)) <= doublehd) {
1122
	  /* if the value being defined is going in the floating point
1137
	  /* if the value being defined is going in the floating point
1123
	     registers, record the floating point stack level, so that we
1138
	     registers, record the floating point stack level, so that we
1124
	     can ensure that it is the same at the end of the construction
1139
	     can ensure that it is the same at the end of the construction
1125
	     */
1140
	     */
1126
	  old_fstack_pos = fstack_pos;
1141
	  old_fstack_pos = fstack_pos;
Line 1130... Line 1145...
1130
          set_env_off(-dc.dcl_n, e);
1145
          set_env_off(-dc.dcl_n, e);
1131
        };
1146
        };
1132
 
1147
 
1133
	if (dc.dcl_new) {	/* if it is new we must evaluate the def
1148
	if (dc.dcl_new) {	/* if it is new we must evaluate the def
1134
				*/
1149
				*/
1135
	  if (ptno (e) == nowhere_pl)
1150
	  if (ptno(e) == nowhere_pl)
1136
	    coder (zero, stack, def);/* discard the value */
1151
	    coder (zero, stack, def);/* discard the value */
1137
	  else
1152
	  else
1138
           {
1153
           {
1139
	    coder (mw (e, 0), stack, def);
1154
	    coder(mw(e, 0), stack, def);
1140
           };
1155
           };
1141
 
1156
 
1142
	  if (ptno (e) == reg_pl) {
1157
	  if (ptno(e) == reg_pl) {
1143
	    /* modify regsinuse if a register is being used */
1158
	    /* modify regsinuse if a register is being used */
1144
	    regsinuse |= dc.dcl_n;
1159
	    regsinuse |= dc.dcl_n;
1145
	  };
1160
	  };
1146
	  if (ptno (e) == local_pl) {
1161
	  if (ptno(e) == local_pl) {
1147
	    /* modify max_stack if the stack is being used */
1162
	    /* modify max_stack if the stack is being used */
1148
	    if (sz > max_stack)
1163
	    if (sz > max_stack)
1149
	      max_stack = sz;
1164
	      max_stack = sz;
1150
	  };
1165
	  };
1151
	};
1166
	};
1152
 
1167
 
1153
	coder (dest, dc.dcl_place, body);/* code the body */
1168
	coder (dest, dc.dcl_place, body);/* code the body */
1154
 
1169
 
1155
	if (dc.dcl_new && ptno (e) == reg_pl) {
1170
	if (dc.dcl_new && ptno(e) == reg_pl) {
1156
	  regsinuse &= ~dc.dcl_n;/* restore regsinuse. It is done by
1171
	  regsinuse &= ~dc.dcl_n;/* restore regsinuse. It is done by
1157
				   removing the bits of this allocation,
1172
				   removing the bits of this allocation,
1158
				   rather than restoring the old value, so
1173
				   rather than restoring the old value, so
1159
				   that allocation and restoration need
1174
				   that allocation and restoration need
1160
				   not nest */
1175
				   not nest */
1161
	  if (name (sh (def)) >= shrealhd && name (sh (def)) <= doublehd &&
1176
	  if (name(sh(def)) >= shrealhd && name(sh(def)) <= doublehd &&
1162
	      fstack_pos != (SET(old_fstack_pos) old_fstack_pos) &&
1177
	      fstack_pos != (SET(old_fstack_pos)old_fstack_pos) &&
1163
	      ptno (e) == reg_pl &&
1178
	      ptno(e) == reg_pl &&
1164
	      name (sh (e)) != bothd) {
1179
	      name(sh(e))!= bothd) {
1165
	    /* restore the floating point registers if necessary */
1180
	    /* restore the floating point registers if necessary */
1166
 
1181
 
1167
	    if (ptno (e) == reg_pl &&
1182
	    if (ptno(e) == reg_pl &&
1168
		!in_fstack (dest.where_exp)) {
1183
		!in_fstack(dest.where_exp)) {
1169
	      int   rn = get_reg_no (no (e));
1184
	      int   rn = get_reg_no(no(e));
1170
	      if (rn == fstack_pos)
1185
	      if (rn == fstack_pos)
1171
		discard_fstack ();
1186
		discard_fstack();
1172
	      else {
1187
	      else {
1173
		if (rn < fstack_pos)
1188
		if (rn < fstack_pos)
1174
		  discard_st1 ();
1189
		  discard_st1();
1175
	      };
1190
	      };
1176
	    };
1191
	    };
1177
	  };
1192
	  };
1178
	};
1193
	};
1179
 
1194
 
1180
	if (dc.dcl_new && ptno (e) == local_pl) {
1195
	if (dc.dcl_new && ptno(e) == local_pl) {
1181
	  exp temp = getexp (f_top, nilexp, 1, e, nilexp, 0, 0, name_tag);
1196
	  exp temp = getexp(f_top, nilexp, 1, e, nilexp, 0, 0, name_tag);
1182
	  if (isvar(e))
1197
	  if (isvar(e))
1183
	    temp = getexp (f_top, nilexp, 1, temp, nilexp, 0, 0, cont_tag);
1198
	    temp = getexp(f_top, nilexp, 1, temp, nilexp, 0, 0, cont_tag);
1184
	  invalidate_dest ( mw ( temp, 0 ) );
1199
	  invalidate_dest(mw(temp, 0));
1185
	  if (isvar(e))
1200
	  if (isvar(e))
1186
	    retcell (son(temp));
1201
	    retcell(son(temp));
1187
	  retcell (temp);
1202
	  retcell(temp);
1188
	}
1203
	}
1189
 
1204
 
1190
	if (isenvoff(e)) {	/* prepare for possible later constant evaluation */
1205
	if (isenvoff(e)) {	/* prepare for possible later constant evaluation */
1191
	  hasenvoff_list = getexp (f_bottom, hasenvoff_list, 0, e, nilexp, 0, 0, 0);
1206
	  hasenvoff_list = getexp(f_bottom, hasenvoff_list, 0, e, nilexp, 0, 0, 0);
1192
	}
1207
	}
1193
 
1208
 
1194
	return;
1209
	return;
1195
      };
1210
      };
1196
    case seq_tag:
1211
    case seq_tag:
1197
      {
1212
      {
1198
	exp t = son (son (e));
1213
	exp t = son(son(e));
1199
	int no_bottom;
1214
	int no_bottom;
1200
	while (coder (zero, stack, t),
1215
	while (coder(zero, stack, t),
1201
	/* code and discard the statements */
1216
	/* code and discard the statements */
1202
	    no_bottom = (name (sh (t)) != bothd),
1217
	    no_bottom = (name(sh(t))!= bothd),
1203
	    !last (t))
1218
	    !last(t))
1204
	  t = bro (t);
1219
	  t = bro(t);
1205
	if (no_bottom)
1220
	if (no_bottom)
1206
	  coder (dest, stack, bro (son (e)));
1221
	  coder(dest, stack, bro(son(e)));
1207
#ifdef NEWDIAGS
1222
#ifdef NEWDIAGS
1208
	else
1223
	else
1209
	if (diagnose) {			/* Beware lost information !!! */
1224
	if (diagnose) {			/* Beware lost information !!! */
1210
	  name(bro(son(e))) = top_tag;
1225
	  name(bro(son(e))) = top_tag;
1211
	  son(bro(son(e))) = nilexp;
1226
	  son(bro(son(e))) = nilexp;
Line 1215... Line 1230...
1215
	return;
1230
	return;
1216
      };
1231
      };
1217
    case cond_tag:
1232
    case cond_tag:
1218
      {
1233
      {
1219
	int  old_fstack_pos = fstack_pos;
1234
	int  old_fstack_pos = fstack_pos;
1220
	exp first = son (e);
1235
	exp first = son(e);
1221
	exp alt = bro (first);
1236
	exp alt = bro(first);
1222
	exp record;	/* jump record for alt */
1237
	exp record;	/* jump record for alt */
1223
	int  r1;
1238
	int  r1;
1224
	exp jr = nilexp;/* jump record for end of construction */
1239
	exp jr = nilexp;/* jump record for end of construction */
1225
 
1240
 
1226
	if ( no(son(alt)) == 0) {
1241
	if (no(son(alt)) == 0) {
1227
	  coder(dest, stack, first);
1242
	  coder(dest, stack, first);
1228
#ifdef NEWDIAGS
1243
#ifdef NEWDIAGS
1229
	  if (diagnose) {		/* Beware lost information !!! */
1244
	  if (diagnose) {		/* Beware lost information !!! */
1230
	    name(bro(son(alt))) = top_tag;
1245
	    name(bro(son(alt))) = top_tag;
1231
	    son(bro(son(alt))) = nilexp;
1246
	    son(bro(son(alt))) = nilexp;
Line 1236... Line 1251...
1236
	};
1251
	};
1237
 
1252
 
1238
	clean_stack();
1253
	clean_stack();
1239
 
1254
 
1240
 
1255
 
1241
	record = getexp (f_bottom, nilexp, 0,
1256
	record = getexp(f_bottom, nilexp, 0,
1242
	      nilexp, nilexp,
1257
	      nilexp, nilexp,
1243
	      0, 0, 0);
1258
	      0, 0, 0);
1244
        sonno(record) = stack_dec;
1259
        sonno(record) = stack_dec;
1245
        fstack_pos_of(record) = (prop)fstack_pos;
1260
        fstack_pos_of(record) = (prop)fstack_pos;
1246
	if (pt(son(alt)) != nilexp)
1261
	if (pt(son(alt))!= nilexp)
1247
	    ptno(record) = ptno(pt(son(alt)));
1262
	    ptno(record) = ptno(pt(son(alt)));
1248
	else
1263
	else
1249
            ptno(record) = next_lab();
1264
            ptno(record) = next_lab();
1250
 
1265
 
1251
 
1266
 
1252
	if (name(bro(son(alt))) == top_tag && stack_dec == 0 && !is_loaded_lv(alt))  {
1267
	if (name(bro(son(alt))) == top_tag && stack_dec == 0 && !is_loaded_lv(alt)) {
1253
	  int extract = take_out_of_line(first, alt, repeat_level > 0, scale);
1268
	  int extract = take_out_of_line(first, alt, repeat_level > 0, scale);
1254
 
1269
 
1255
	  if (extract) {
1270
	  if (extract) {
1256
	    exp t = son(son(first));
1271
	    exp t = son(son(first));
1257
	    exp p, s, z;
1272
	    exp p, s, z;
1258
	    int test_n;
1273
	    int test_n;
1259
	    shape sha;
1274
	    shape sha;
1260
	    outofline * rec;
1275
	    outofline * rec;
1261
	    exp tst = (is_tester(t, 0)) ? t : bro(son(t));
1276
	    exp tst = (is_tester(t, 0))? t : bro(son(t));
1262
	      jr = getexp (f_bottom, nilexp, 0, nilexp, nilexp, 0,
1277
	      jr = getexp(f_bottom, nilexp, 0, nilexp, nilexp, 0,
1263
	        0, 0);
1278
	        0, 0);
1264
              sonno(jr) = stack_dec;
1279
              sonno(jr) = stack_dec;
1265
              ptno(jr) = next_lab();
1280
              ptno(jr) = next_lab();
1266
              fstack_pos_of(jr) = (prop)fstack_pos;
1281
              fstack_pos_of(jr) = (prop)fstack_pos;
1267
	    sha = sh(son(tst));
1282
	    sha = sh(son(tst));
Line 1281... Line 1296...
1281
	      first = bro(son(first));
1296
	      first = bro(son(first));
1282
	    else
1297
	    else
1283
	      son(son(first)) = bro(son(son(first)));
1298
	      son(son(first)) = bro(son(son(first)));
1284
 
1299
 
1285
	    rec->body = first;
1300
	    rec->body = first;
1286
	    pt (son (alt)) = record;
1301
	    pt(son(alt)) = record;
1287
 
1302
 
1288
	    test_n = (int)test_number(tst);
1303
	    test_n = (int)test_number(tst);
1289
	    if (name(sha) < shrealhd || name(sha) > doublehd)
1304
	    if (name(sha) < shrealhd || name(sha) > doublehd)
1290
	      test_n = (int)int_inverse_ntest[test_n];
1305
	      test_n = (int)int_inverse_ntest[test_n];
1291
	    else
1306
	    else
1292
	      test_n = (int)real_inverse_ntest[test_n];
1307
	      test_n = (int)real_inverse_ntest[test_n];
1293
 
1308
 
1294
	    settest_number(tst, test_n);
1309
	    settest_number(tst, test_n);
1295
	    z = getexp (f_bottom, nilexp, 0, nilexp, nilexp, 0, 0, 0);
1310
	    z = getexp(f_bottom, nilexp, 0, nilexp, nilexp, 0, 0, 0);
1296
	    sonno(z) = stack_dec;
1311
	    sonno(z) = stack_dec;
1297
	    fstack_pos_of(z) = (prop)fstack_pos;
1312
	    fstack_pos_of(z) = (prop)fstack_pos;
1298
	    ptno(z) = rec->labno;
1313
	    ptno(z) = rec->labno;
1299
	    s = getexp(sha, nilexp, 0, nilexp, z, 0, 0, 0);
1314
	    s = getexp(sha, nilexp, 0, nilexp, z, 0, 0, 0);
1300
	    p = getexp(sha, tst, 0, s, nilexp, 0, 0, 0);
1315
	    p = getexp(sha, tst, 0, s, nilexp, 0, 0, 0);
1301
	    pt(tst) = p;
1316
	    pt(tst) = p;
1302
	    coder(zero, stack, t);
1317
	    coder(zero, stack, t);
1303
	    if (name(sh(first)) != bothd) {
1318
	    if (name(sh(first))!= bothd) {
1304
	      reset_fpucon();
1319
	      reset_fpucon();
1305
	      set_label(jr);
1320
	      set_label(jr);
1306
#ifdef NEWDWARF
1321
#ifdef NEWDWARF
1307
	      START_BB ();
1322
	      START_BB();
1308
#endif
1323
#endif
1309
	      clear_reg_record(crt_reg_record);
1324
	      clear_reg_record(crt_reg_record);
1310
	    };
1325
	    };
1311
 
1326
 
1312
	    rec->cond1_set = cond1_set;
1327
	    rec->cond1_set = cond1_set;
Line 1317... Line 1332...
1317
#if 0
1332
#if 0
1318
#ifdef NEWDWARF
1333
#ifdef NEWDWARF
1319
	    if (dwarf2) {
1334
	    if (dwarf2) {
1320
	      rec->dw2_hi = next_dwarf_label();
1335
	      rec->dw2_hi = next_dwarf_label();
1321
	      rec->dw2_slave = next_dwarf_label();
1336
	      rec->dw2_slave = next_dwarf_label();
1322
	      dw2_extend_scope (rec->labno, rec->dw2_hi, rec->dw2_slave);
1337
	      dw2_extend_scope(rec->labno, rec->dw2_hi, rec->dw2_slave);
1323
	    }
1338
	    }
1324
#endif
1339
#endif
1325
#endif
1340
#endif
1326
	    return;
1341
	    return;
1327
	  };
1342
	  };
Line 1331... Line 1346...
1331
        scale = (float)0.5*scale;
1346
        scale = (float)0.5*scale;
1332
 
1347
 
1333
	/* record floating point stack position so that we can align the
1348
	/* record floating point stack position so that we can align the
1334
	   positions */
1349
	   positions */
1335
	/* jump record set up for alt */
1350
	/* jump record set up for alt */
1336
	pt (son (alt)) = record;
1351
	pt(son(alt)) = record;
1337
	/* set the record in for use by jumps in first. */
1352
	/* set the record in for use by jumps in first. */
1338
 
1353
 
1339
	r1 = regsinuse;		/* regsinuse is the same at the start of
1354
	r1 = regsinuse;		/* regsinuse is the same at the start of
1340
				   first and alt, and at the end of the
1355
				   first and alt, and at the end of the
1341
				   construction. */
1356
				   construction. */
1342
	coder (dest, stack, first);
1357
	coder(dest, stack, first);
1343
	reset_fpucon();
1358
	reset_fpucon();
1344
	clean_stack();
1359
	clean_stack();
1345
 
1360
 
1346
	regsinuse = r1;		/* restore regsinuse for alt */
1361
	regsinuse = r1;		/* restore regsinuse for alt */
1347
 
1362
 
1348
	if (name (bro (son (alt))) == top_tag && !is_loaded_lv(alt)) {
1363
	if (name(bro(son(alt))) == top_tag && !is_loaded_lv(alt)) {
1349
	  /* if alt is only load top, do nothing but set the label */
1364
	  /* if alt is only load top, do nothing but set the label */
1350
	  if (name(sh(first)) == bothd && no(son(alt)) != 0)
1365
	  if (name(sh(first)) == bothd && no(son(alt))!= 0)
1351
	    align_label(2, record);
1366
	    align_label(2, record);
1352
 
1367
 
1353
	  if (name(first) == seq_tag &&
1368
	  if (name(first) == seq_tag &&
1354
		  name(bro(son(first))) == seq_tag &&
1369
		  name(bro(son(first))) == seq_tag &&
1355
		  name(bro(son(bro(son(first))))) == apply_tag)
1370
		  name(bro(son(bro(son(first))))) == apply_tag)
1356
	    align_label(0, record);
1371
	    align_label(0, record);
1357
	  set_label (record);
1372
	  set_label(record);
1358
#ifdef NEWDWARF
1373
#ifdef NEWDWARF
1359
	  START_BB ();
1374
	  START_BB();
1360
#endif
1375
#endif
1361
	  fstack_pos = old_fstack_pos;
1376
	  fstack_pos = old_fstack_pos;
1362
	  clear_reg_record (crt_reg_record);
1377
	  clear_reg_record(crt_reg_record);
1363
          scale = old_scale;
1378
          scale = old_scale;
1364
	  return;
1379
	  return;
1365
	};
1380
	};
1366
 
1381
 
1367
	if (name (sh (first)) != bothd &&
1382
	if (name(sh(first))!= bothd &&
1368
		(no(son(alt)) != 0 || name(bro(son(alt))) != goto_tag)) {
1383
		(no(son(alt))!= 0 || name(bro(son(alt)))!= goto_tag)) {
1369
	  /* if the first did not end with jump or ret, put in a jump to
1384
	  /* if the first did not end with jump or ret, put in a jump to
1370
	     the end of the construction, and make a jump record for it */
1385
	     the end of the construction, and make a jump record for it */
1371
	    jr = getexp (f_bottom, nilexp, 0, nilexp, nilexp, 0,
1386
	    jr = getexp(f_bottom, nilexp, 0, nilexp, nilexp, 0,
1372
	        0, 0);
1387
	        0, 0);
1373
            sonno(jr) = stack_dec;
1388
            sonno(jr) = stack_dec;
1374
            ptno(jr) = next_lab();
1389
            ptno(jr) = next_lab();
1375
            fstack_pos_of(jr) = (prop)fstack_pos;
1390
            fstack_pos_of(jr) = (prop)fstack_pos;
1376
	  jump (jr, in_fstack (dest.where_exp));
1391
	  jump(jr, in_fstack(dest.where_exp));
1377
	};
1392
	};
1378
 
1393
 
1379
	if (no(son(alt)) != 0 || name(bro(son(alt))) != goto_tag) {
1394
	if (no(son(alt))!= 0 || name(bro(son(alt)))!= goto_tag) {
1380
	if (no(son(alt)) != 0)
1395
	if (no(son(alt))!= 0)
1381
          align_label(2, record);
1396
          align_label(2, record);
1382
	set_label (record);	/* the label for the start of alt */
1397
	set_label (record);	/* the label for the start of alt */
1383
	fstack_pos = old_fstack_pos;
1398
	fstack_pos = old_fstack_pos;
1384
	coder (dest, stack, alt);
1399
	coder(dest, stack, alt);
1385
	reset_fpucon();
1400
	reset_fpucon();
1386
	regsinuse = r1;		/* restore regsinuse for end of
1401
	regsinuse = r1;		/* restore regsinuse for end of
1387
				   construction */
1402
				   construction */
1388
	if (name (sh (first)) != bothd) {
1403
	if (name(sh(first))!= bothd) {
1389
	  /* set the label for the end of the construction if first needed
1404
	  /* set the label for the end of the construction if first needed
1390
	     it. */
1405
	     it. */
1391
	  SET(jr);
1406
	  SET(jr);
1392
	  if (name(sh(alt)) == bothd)
1407
	  if (name(sh(alt)) == bothd)
1393
	    align_label(2, jr);
1408
	    align_label(2, jr);
1394
	  set_label (jr);
1409
	  set_label(jr);
1395
#ifdef NEWDWARF
1410
#ifdef NEWDWARF
1396
	  START_BB ();
1411
	  START_BB();
1397
#endif
1412
#endif
1398
	};
1413
	};
1399
      };
1414
      };
1400
	cond1_set = 0;
1415
	cond1_set = 0;
1401
	cond2_set = 0;		/* we don't know what condition flags are
1416
	cond2_set = 0;		/* we don't know what condition flags are
Line 1403... Line 1418...
1403
        scale = old_scale;
1418
        scale = old_scale;
1404
	return;
1419
	return;
1405
      };
1420
      };
1406
    case labst_tag: 		/* code a labelled statement */
1421
    case labst_tag: 		/* code a labelled statement */
1407
      {
1422
      {
1408
	clear_reg_record (crt_reg_record);
1423
	clear_reg_record(crt_reg_record);
1409
	cond1_set = 0;
1424
	cond1_set = 0;
1410
	cond2_set = 0;
1425
	cond2_set = 0;
1411
	fpucon = normal_fpucon;
1426
	fpucon = normal_fpucon;
1412
 
1427
 
1413
        if (is_loaded_lv(e)) {
1428
        if (is_loaded_lv(e)) {
1414
	  set_lv_label(e);
1429
	  set_lv_label(e);
1415
	  if (need_preserve_stack)
1430
	  if (need_preserve_stack)
1416
	    restore_stack ();
1431
	    restore_stack();
1417
	  else if (!has_alloca)
1432
	  else if (!has_alloca)
1418
            set_stack_from_bp();
1433
            set_stack_from_bp();
1419
	};
1434
	};
1420
        fstack_pos = (int)fstack_pos_of(pt(son(e)));
1435
        fstack_pos = (int)fstack_pos_of(pt(son(e)));
1421
        stack_dec = sonno(pt(son(e)));
1436
        stack_dec = sonno(pt(son(e)));
1422
 
1437
 
1423
        old_scale = scale;
1438
        old_scale = scale;
1424
#ifdef NEWDWARF
1439
#ifdef NEWDWARF
1425
	START_BB ();
1440
	START_BB();
1426
#endif
1441
#endif
1427
	coder (dest, stack, bro (son (e)));
1442
	coder(dest, stack, bro(son(e)));
1428
        scale = old_scale;
1443
        scale = old_scale;
1429
 
1444
 
1430
	clear_reg_record (crt_reg_record);
1445
	clear_reg_record(crt_reg_record);
1431
	clean_stack();
1446
	clean_stack();
1432
	return;
1447
	return;
1433
      };
1448
      };
1434
    case rep_tag:
1449
    case rep_tag:
1435
      {
1450
      {
1436
	exp start = son (e);
1451
	exp start = son(e);
1437
	exp body = bro (start);
1452
	exp body = bro(start);
1438
	exp record;		/* jump record for loop label */
1453
	exp record;		/* jump record for loop label */
1439
        ++repeat_level;
1454
        ++repeat_level;
1440
	coder (mw (body, 0), stack, start);
1455
	coder(mw(body, 0), stack, start);
1441
	/* code the starter of the loop */
1456
	/* code the starter of the loop */
1442
	reset_fpucon();
1457
	reset_fpucon();
1443
	clean_stack();
1458
	clean_stack();
1444
	record = getexp (f_bottom, nilexp, 1, nilexp,
1459
	record = getexp(f_bottom, nilexp, 1, nilexp,
1445
	    nilexp, 0, 0, 0);
1460
	    nilexp, 0, 0, 0);
1446
        sonno(record) = stack_dec;
1461
        sonno(record) = stack_dec;
1447
        ptno(record) = next_lab();
1462
        ptno(record) = next_lab();
1448
        fstack_pos_of(record) = (prop)fstack_pos;
1463
        fstack_pos_of(record) = (prop)fstack_pos;
1449
	cond1_set = 0;
1464
	cond1_set = 0;
1450
	cond2_set = 0;
1465
	cond2_set = 0;
1451
        align_label(1, record);
1466
        align_label(1, record);
1452
	set_label (record);	/* set the label at the start of body */
1467
	set_label (record);	/* set the label at the start of body */
1453
	pt (son (body)) = record;
1468
	pt(son(body)) = record;
1454
        old_scale = scale;
1469
        old_scale = scale;
1455
        if (scale < 1e30)
1470
        if (scale < 1e30)
1456
		scale = (float)20.0 * scale;
1471
		scale = (float)20.0 * scale;
1457
	coder (dest, stack, body);
1472
	coder(dest, stack, body);
1458
        scale = old_scale;
1473
        scale = old_scale;
1459
        --repeat_level;
1474
        --repeat_level;
1460
	return;
1475
	return;
1461
      };
1476
      };
1462
    case prof_tag:
1477
    case prof_tag:
Line 1467... Line 1482...
1467
	exp lab;
1482
	exp lab;
1468
        clean_stack();
1483
        clean_stack();
1469
	lab = final_dest(pt(e));
1484
	lab = final_dest(pt(e));
1470
#ifdef NEWDWARF
1485
#ifdef NEWDWARF
1471
	if (current_dg_info) {
1486
	if (current_dg_info) {
1472
	  current_dg_info->data.i_tst.brk = set_dw_text_label ();
1487
	  current_dg_info->data.i_tst.brk = set_dw_text_label();
1473
	  current_dg_info->data.i_tst.jlab.u.l = ptno(pt (son (lab)));
1488
	  current_dg_info->data.i_tst.jlab.u.l = ptno(pt(son(lab)));
1474
	  current_dg_info->data.i_tst.jlab.k = LAB_CODE;
1489
	  current_dg_info->data.i_tst.jlab.k = LAB_CODE;
1475
	}
1490
	}
1476
#endif
1491
#endif
1477
	if (label_is_next(lab, e)) {
1492
	if (label_is_next(lab, e)) {
1478
	  int  fs_dest = (int)fstack_pos_of (pt (son (lab)));
1493
	  int  fs_dest = (int)fstack_pos_of(pt(son(lab)));
1479
	  int  good_fs = fstack_pos;
1494
	  int  good_fs = fstack_pos;
1480
	  while (fstack_pos > fs_dest)
1495
	  while (fstack_pos > fs_dest)
1481
	    discard_fstack ();
1496
	    discard_fstack();
1482
	  reset_fpucon();
1497
	  reset_fpucon();
1483
	  fstack_pos = good_fs;
1498
	  fstack_pos = good_fs;
1484
	  return;
1499
	  return;
1485
	};
1500
	};
1486
	jump (pt (son (lab)), 0);
1501
	jump(pt(son(lab)), 0);
1487
	return;
1502
	return;
1488
      };
1503
      };
1489
    case goto_lv_tag:
1504
    case goto_lv_tag:
1490
      {
1505
      {
1491
	clean_stack();
1506
	clean_stack();
Line 1493... Line 1508...
1493
        jumpins(son(e));
1508
        jumpins(son(e));
1494
        return;
1509
        return;
1495
      };
1510
      };
1496
    case long_jump_tag:
1511
    case long_jump_tag:
1497
      {
1512
      {
1498
	coder (pushdest, stack, bro(son(e)));
1513
	coder(pushdest, stack, bro(son(e)));
1499
	extra_stack += 32;
1514
	extra_stack += 32;
1500
	coder (pushdest, stack, son(e));
1515
	coder(pushdest, stack, son(e));
1501
	extra_stack += 32;
1516
	extra_stack += 32;
1502
	check_stack_max;
1517
	check_stack_max;
1503
	reset_fpucon();
1518
	reset_fpucon();
1504
	long_jump(e);
1519
	long_jump(e);
1505
	extra_stack -= 64;
1520
	extra_stack -= 64;
Line 1515... Line 1530...
1515
 
1530
 
1516
	if (name(lab) == labst_tag) {
1531
	if (name(lab) == labst_tag) {
1517
	  exp q = short_next_jump(e);
1532
	  exp q = short_next_jump(e);
1518
	  if (q != nilexp &&
1533
	  if (q != nilexp &&
1519
		(name(q) == goto_tag ||
1534
		(name(q) == goto_tag ||
1520
		   (name(q) == res_tag && name(son(q)) == top_tag)) &&
1535
		  (name(q) == res_tag && name(son(q)) == top_tag)) &&
1521
		label_is_next(lab, q)) {
1536
		label_is_next(lab, q)) {
1522
	    shape sha = sh(son(e));
1537
	    shape sha = sh(son(e));
1523
	    if (name(q) == goto_tag) {
1538
	    if (name(q) == goto_tag) {
1524
	      temp = pt(q);
1539
	      temp = pt(q);
1525
	      pt(q) = lab;
1540
	      pt(q) = lab;
1526
	    }
1541
	    }
1527
	    else {
1542
	    else {
1528
              temp = getexp (f_bottom, nilexp, 0, nilexp,
1543
              temp = getexp(f_bottom, nilexp, 0, nilexp,
1529
                                nilexp, 0, 0, 0);
1544
                                nilexp, 0, 0, 0);
1530
	      ptno(temp) = crt_ret_lab;
1545
	      ptno(temp) = crt_ret_lab;
1531
	      fstack_pos_of(temp) = (prop)first_fl_reg;
1546
	      fstack_pos_of(temp) = (prop)first_fl_reg;
1532
	      temp = getexp(f_top, nilexp, 0, nilexp, temp,
1547
	      temp = getexp(f_top, nilexp, 0, nilexp, temp,
1533
				 0, 0, 0);
1548
				 0, 0, 0);
Line 1539... Line 1554...
1539
	      isret = 1;
1554
	      isret = 1;
1540
	    };
1555
	    };
1541
	    lab = temp;
1556
	    lab = temp;
1542
	    pt(e) = lab;
1557
	    pt(e) = lab;
1543
	    if (name(sha) < shrealhd || name(sha) > doublehd)
1558
	    if (name(sha) < shrealhd || name(sha) > doublehd)
1544
	      settest_number(e, (int)int_inverse_ntest[testno]);
1559
	      settest_number(e,(int)int_inverse_ntest[testno]);
1545
	    else
1560
	    else
1546
	      settest_number(e, (int)real_inverse_ntest[testno]);
1561
	      settest_number(e,(int)real_inverse_ntest[testno]);
1547
#ifdef NEWDIAGS
1562
#ifdef NEWDIAGS
1548
	    if (current_dg_info)
1563
	    if (current_dg_info)
1549
	      current_dg_info->data.i_tst.inv = 1 - current_dg_info->data.i_tst.inv;
1564
	      current_dg_info->data.i_tst.inv = 1 - current_dg_info->data.i_tst.inv;
1550
#endif
1565
#endif
1551
	  };
1566
	  };
Line 1564... Line 1579...
1564
	  ++no(son(temp));
1579
	  ++no(son(temp));
1565
	};
1580
	};
1566
	pt(e) = temp;
1581
	pt(e) = temp;
1567
       {
1582
       {
1568
	where qw;
1583
	where qw;
1569
	exp lab_exp = pt (e);
1584
	exp lab_exp = pt(e);
1570
	exp jr = pt (son (lab_exp));
1585
	exp jr = pt(son(lab_exp));
1571
	exp arg1 = son (e);
1586
	exp arg1 = son(e);
1572
	exp arg2 = bro (arg1);
1587
	exp arg2 = bro(arg1);
1573
	if (!is_o (name (arg1)) || is_crc(arg1)) {
1588
	if (!is_o(name(arg1)) || is_crc(arg1)) {
1574
	  /* arg1 is not a possible 80386 operand, precompute it in reg0
1589
	  /* arg1 is not a possible 80386 operand, precompute it in reg0
1575
	  */
1590
	  */
1576
	  qw.where_exp = copyexp (reg0.where_exp);
1591
	  qw.where_exp = copyexp(reg0.where_exp);
1577
	  sh (qw.where_exp) = sh (arg1);
1592
	  sh(qw.where_exp) = sh(arg1);
1578
	  qw.where_off = 0;
1593
	  qw.where_off = 0;
1579
	  coder (qw, stack, arg1);
1594
	  coder(qw, stack, arg1);
1580
	  arg1 = qw.where_exp;
1595
	  arg1 = qw.where_exp;
1581
	};
1596
	};
1582
	if (!is_o (name (arg2)) || is_crc(arg2)) {
1597
	if (!is_o(name(arg2)) || is_crc(arg2)) {
1583
	  /* arg2 is not a possible 80386 operand, precompute it in reg0
1598
	  /* arg2 is not a possible 80386 operand, precompute it in reg0
1584
	  */
1599
	  */
1585
	  qw.where_exp = copyexp (reg0.where_exp);
1600
	  qw.where_exp = copyexp(reg0.where_exp);
1586
	  sh (qw.where_exp) = sh (arg2);
1601
	  sh(qw.where_exp) = sh(arg2);
1587
	  qw.where_off = 0;
1602
	  qw.where_off = 0;
1588
	  coder (qw, stack, arg2);
1603
	  coder(qw, stack, arg2);
1589
	  arg2 = qw.where_exp;
1604
	  arg2 = qw.where_exp;
1590
	};
1605
	};
1591
 
1606
 
1592
	clean_stack();
1607
	clean_stack();
1593
#ifdef NEWDWARF
1608
#ifdef NEWDWARF
1594
	if (current_dg_info) {
1609
	if (current_dg_info) {
1595
	  current_dg_info->data.i_tst.brk = set_dw_text_label ();
1610
	  current_dg_info->data.i_tst.brk = set_dw_text_label();
1596
	  current_dg_info->data.i_tst.jlab.u.l = ptno(jr);
1611
	  current_dg_info->data.i_tst.jlab.u.l = ptno(jr);
1597
	  current_dg_info->data.i_tst.jlab.k = LAB_CODE;
1612
	  current_dg_info->data.i_tst.jlab.k = LAB_CODE;
1598
	}
1613
	}
1599
#endif
1614
#endif
1600
	test (sh (arg1), mw (arg1, 0), mw (arg2, 0));
1615
	test(sh(arg1), mw(arg1, 0), mw(arg2, 0));
1601
	branch ((int)test_number(e), jr, 1, (int)name(sh(arg1)));
1616
	branch((int)test_number(e), jr, 1,(int)name(sh(arg1)));
1602
#ifdef NEWDWARF
1617
#ifdef NEWDWARF
1603
	START_BB ();
1618
	START_BB();
1604
	if (current_dg_info)
1619
	if (current_dg_info)
1605
	  current_dg_info->data.i_tst.cont = set_dw_text_label ();
1620
	  current_dg_info->data.i_tst.cont = set_dw_text_label();
1606
#endif
1621
#endif
1607
	return;
1622
	return;
1608
       };
1623
       };
1609
      };
1624
      };
1610
    case absbool_tag:
1625
    case absbool_tag:
Line 1619... Line 1634...
1619
 
1634
 
1620
	if (name(e) == test_tag) {
1635
	if (name(e) == test_tag) {
1621
	  if (name(lab) == labst_tag) {
1636
	  if (name(lab) == labst_tag) {
1622
	    exp q = short_next_jump(e);
1637
	    exp q = short_next_jump(e);
1623
	    if (q != nilexp &&
1638
	    if (q != nilexp &&
1624
		  (name(q) == goto_tag ||
1639
		 (name(q) == goto_tag ||
1625
		     (name(q) == res_tag && name(son(q)) == top_tag)) &&
1640
		    (name(q) == res_tag && name(son(q)) == top_tag)) &&
1626
		  label_is_next(lab, q)) {
1641
		  label_is_next(lab, q)) {
1627
	      shape sha = sh(son(e));
1642
	      shape sha = sh(son(e));
1628
	      if (name(q) == goto_tag) {
1643
	      if (name(q) == goto_tag) {
1629
	        temp = pt(q);
1644
	        temp = pt(q);
1630
	        pt(q) = lab;
1645
	        pt(q) = lab;
1631
	      }
1646
	      }
1632
	      else {
1647
	      else {
1633
                temp = getexp (f_bottom, nilexp, 0, nilexp,
1648
                temp = getexp(f_bottom, nilexp, 0, nilexp,
1634
                                nilexp, 0, 0, 0);
1649
                                nilexp, 0, 0, 0);
1635
		ptno(temp) = crt_ret_lab;
1650
		ptno(temp) = crt_ret_lab;
1636
		fstack_pos_of(temp) = (prop)first_fl_reg;
1651
		fstack_pos_of(temp) = (prop)first_fl_reg;
1637
	        temp = getexp(f_top, nilexp, 0, nilexp, temp,
1652
	        temp = getexp(f_top, nilexp, 0, nilexp, temp,
1638
				 0, 0, 0);
1653
				 0, 0, 0);
Line 1644... Line 1659...
1644
	        isret = 1;
1659
	        isret = 1;
1645
	      };
1660
	      };
1646
	      lab = temp;
1661
	      lab = temp;
1647
	      pt(e) = lab;
1662
	      pt(e) = lab;
1648
	      if (name(sha) < shrealhd || name(sha) > doublehd)
1663
	      if (name(sha) < shrealhd || name(sha) > doublehd)
1649
	        settest_number(e, (int)int_inverse_ntest[testno]);
1664
	        settest_number(e,(int)int_inverse_ntest[testno]);
1650
	      else
1665
	      else
1651
	        settest_number(e, (int)real_inverse_ntest[testno]);
1666
	        settest_number(e,(int)real_inverse_ntest[testno]);
1652
#ifdef NEWDIAGS
1667
#ifdef NEWDIAGS
1653
	      if (current_dg_info)
1668
	      if (current_dg_info)
1654
		current_dg_info->data.i_tst.inv = 1 - current_dg_info->data.i_tst.inv;
1669
		current_dg_info->data.i_tst.inv = 1 - current_dg_info->data.i_tst.inv;
1655
#endif
1670
#endif
1656
	    };
1671
	    };
Line 1670... Line 1685...
1670
	  };
1685
	  };
1671
	  pt(e) = temp;
1686
	  pt(e) = temp;
1672
	};
1687
	};
1673
	{
1688
	{
1674
	  where qw;
1689
	  where qw;
1675
	  exp arg1 = son (e);
1690
	  exp arg1 = son(e);
1676
	  exp arg2 = bro (arg1);
1691
	  exp arg2 = bro(arg1);
1677
	  unsigned char  test_n = test_number (e);
1692
	  unsigned char  test_n = test_number(e);
1678
	  exp lab_exp = pt (e);
1693
	  exp lab_exp = pt(e);
1679
	  exp jr;
1694
	  exp jr;
1680
	  int sg;
1695
	  int sg;
1681
	  if (name(e)==test_tag)
1696
	  if (name(e) ==test_tag)
1682
	    jr = pt (son (lab_exp));
1697
	    jr = pt(son(lab_exp));
1683
	  if (!is_o (name (arg1)) || is_crc(arg1)) {
1698
	  if (!is_o(name(arg1)) || is_crc(arg1)) {
1684
	    /* arg1 is not a possible 80386 operand, precompute it in reg0
1699
	    /* arg1 is not a possible 80386 operand, precompute it in reg0
1685
	       */
1700
	       */
1686
	    qw.where_exp = copyexp (reg0.where_exp);
1701
	    qw.where_exp = copyexp(reg0.where_exp);
1687
	    sh (qw.where_exp) = sh (arg1);
1702
	    sh(qw.where_exp) = sh(arg1);
1688
	    qw.where_off = 0;
1703
	    qw.where_off = 0;
1689
	    coder (qw, stack, arg1);
1704
	    coder(qw, stack, arg1);
1690
	    arg1 = qw.where_exp;
1705
	    arg1 = qw.where_exp;
1691
	  }
1706
	  }
1692
#ifdef NEWDIAGS
1707
#ifdef NEWDIAGS
1693
	  else
1708
	  else
1694
	    diag_arg (dest, stack, arg1);
1709
	    diag_arg(dest, stack, arg1);
1695
#endif
1710
#endif
1696
	  if (!is_o (name (arg2)) || is_crc(arg2)) {
1711
	  if (!is_o(name(arg2)) || is_crc(arg2)) {
1697
	    /* arg2 is not a possible 80386 operand, precompute it in reg0
1712
	    /* arg2 is not a possible 80386 operand, precompute it in reg0
1698
	       */
1713
	       */
1699
	    qw.where_exp = copyexp (reg0.where_exp);
1714
	    qw.where_exp = copyexp(reg0.where_exp);
1700
	    sh (qw.where_exp) = sh (arg2);
1715
	    sh(qw.where_exp) = sh(arg2);
1701
	    qw.where_off = 0;
1716
	    qw.where_off = 0;
1702
	    coder (qw, stack, arg2);
1717
	    coder(qw, stack, arg2);
1703
	    arg2 = qw.where_exp;
1718
	    arg2 = qw.where_exp;
1704
	  }
1719
	  }
1705
#ifdef NEWDIAGS
1720
#ifdef NEWDIAGS
1706
	  else
1721
	  else
1707
	    diag_arg (dest, stack, arg2);
1722
	    diag_arg(dest, stack, arg2);
1708
#endif
1723
#endif
1709
 
1724
 
1710
	  switch (name (sh (arg1))) {
1725
	  switch (name(sh(arg1))) {
1711
	    case scharhd:
1726
	    case scharhd:
1712
	    case swordhd:
1727
	    case swordhd:
1713
	    case slonghd:
1728
	    case slonghd:
1714
	    case offsethd:
1729
	    case offsethd:
1715
	      sg = 1;
1730
	      sg = 1;
Line 1726... Line 1741...
1726
	    default:
1741
	    default:
1727
	      sg = is_signed(sh(arg1));
1742
	      sg = is_signed(sh(arg1));
1728
	      break;
1743
	      break;
1729
	  };
1744
	  };
1730
 
1745
 
1731
	  if (name (arg1) == val_tag || name (arg1) == env_offset_tag ||
1746
	  if (name(arg1) == val_tag || name(arg1) == env_offset_tag ||
1732
		(name (arg1) == name_tag && isvar(son(arg1)) && isglob(son(arg1)) )) {
1747
		(name(arg1) == name_tag && isvar(son(arg1)) && isglob(son(arg1)))) {
1733
		/* if only one constant, cmp expects it to be arg2 */
1748
		/* if only one constant, cmp expects it to be arg2 */
1734
	    exp holde = arg1;
1749
	    exp holde = arg1;
1735
	    arg1 = arg2;
1750
	    arg1 = arg2;
1736
	    arg2 = holde;
1751
	    arg2 = holde;
1737
	    test_n = exchange_ntest[test_n];
1752
	    test_n = exchange_ntest[test_n];
Line 1739... Line 1754...
1739
	    if (current_dg_info)
1754
	    if (current_dg_info)
1740
	      current_dg_info->data.i_tst.inv = 1 - current_dg_info->data.i_tst.inv;
1755
	      current_dg_info->data.i_tst.inv = 1 - current_dg_info->data.i_tst.inv;
1741
#endif
1756
#endif
1742
	  };
1757
	  };
1743
 
1758
 
1744
	  if (name (arg1) == null_tag) {
1759
	  if (name(arg1) == null_tag) {
1745
	    failer("test_tag of wrong form");
1760
	    failer("test_tag of wrong form");
1746
	  }
1761
	  }
1747
	  else {
1762
	  else {
1748
	    clean_stack();
1763
	    clean_stack();
1749
	    if (name(e) == absbool_tag && sg &&
1764
	    if (name(e) == absbool_tag && sg &&
1750
		(test_n == f_greater_than || test_n == f_less_than_or_equal)) {
1765
		(test_n == f_greater_than || test_n == f_less_than_or_equal)) {
1751
	      cond1_set = 0;	/* avoid cmp(0) optimisation to clear overflow */
1766
	      cond1_set = 0;	/* avoid cmp(0) optimisation to clear overflow */
1752
	    }
1767
	    }
1753
	    if (cmp (sh (arg1), mw (arg1, 0), mw (arg2, 0), (int)test_n, e)) {
1768
	    if (cmp(sh(arg1), mw(arg1, 0), mw(arg2, 0), (int)test_n, e)) {
1754
	      if (sg) {
1769
	      if (sg) {
1755
		sg = -1;   /* ignore overflow when testing sign bit */
1770
		sg = -1;   /* ignore overflow when testing sign bit */
1756
	      }
1771
	      }
1757
	    }
1772
	    }
1758
	    if (name(e) == test_tag) {
1773
	    if (name(e) == test_tag) {
1759
	      SET(jr);
1774
	      SET(jr);
1760
#ifdef NEWDWARF
1775
#ifdef NEWDWARF
1761
	      if (current_dg_info) {
1776
	      if (current_dg_info) {
1762
		current_dg_info->data.i_tst.brk = set_dw_text_label ();
1777
		current_dg_info->data.i_tst.brk = set_dw_text_label();
1763
		current_dg_info->data.i_tst.jlab.u.l = ptno(jr);
1778
		current_dg_info->data.i_tst.jlab.u.l = ptno(jr);
1764
		current_dg_info->data.i_tst.jlab.k = LAB_CODE;
1779
		current_dg_info->data.i_tst.jlab.k = LAB_CODE;
1765
	      }
1780
	      }
1766
#endif
1781
#endif
1767
	      branch ((int)test_n, jr, sg, (int)name(sh(arg1)));
1782
	      branch((int)test_n, jr, sg,(int)name(sh(arg1)));
1768
#ifdef NEWDWARF
1783
#ifdef NEWDWARF
1769
	      START_BB ();
1784
	      START_BB();
1770
	      if (current_dg_info)
1785
	      if (current_dg_info)
1771
	        current_dg_info->data.i_tst.cont = set_dw_text_label ();
1786
	        current_dg_info->data.i_tst.cont = set_dw_text_label();
1772
#endif
1787
#endif
1773
	    }
1788
	    }
1774
	    else
1789
	    else
1775
	    if (!eq_where (dest, zero)) {
1790
	    if (!eq_where(dest, zero)) {
1776
	      setcc((int)int_inverse_ntest[test_n], sg,
1791
	      setcc((int)int_inverse_ntest[test_n], sg,
1777
			 (int)name(sh(arg1)));
1792
			(int)name(sh(arg1)));
1778
	      if (shape_size(sh(e)) > 8)
1793
	      if (shape_size(sh(e)) > 8)
1779
	        and(slongsh, reg0, mw(zeroe, 0xff), reg0);
1794
	        and(slongsh, reg0, mw(zeroe, 0xff), reg0);
1780
	      move(sh(e), reg0, dest);
1795
	      move(sh(e), reg0, dest);
1781
	    };
1796
	    };
1782
	  };
1797
	  };
Line 1785... Line 1800...
1785
	};
1800
	};
1786
      };
1801
      };
1787
    case ass_tag:
1802
    case ass_tag:
1788
    case assvol_tag:
1803
    case assvol_tag:
1789
      {
1804
      {
1790
	exp assdest = son (e);
1805
	exp assdest = son(e);
1791
	exp assval = bro (assdest);
1806
	exp assval = bro(assdest);
1792
 
1807
 
1793
        if (!newcode && name(sh(assval)) == bitfhd)
1808
        if (!newcode && name(sh(assval)) == bitfhd)
1794
         {
1809
         {
1795
           bits_to_mem(assval, e, stack);
1810
           bits_to_mem(assval, e, stack);
1796
           return;
1811
           return;
1797
         };
1812
         };
1798
 
1813
 
1799
	coder (mw(e, 0), stack, assval);
1814
	coder(mw(e, 0), stack, assval);
1800
	/* set the destination and code the rest */
1815
	/* set the destination and code the rest */
1801
	return;
1816
	return;
1802
      };
1817
      };
1803
    case concatnof_tag:
1818
    case concatnof_tag:
1804
     {
1819
     {
Line 1814... Line 1829...
1814
       int sz;
1829
       int sz;
1815
       int off;
1830
       int off;
1816
       if (no(e) == 0)
1831
       if (no(e) == 0)
1817
         return;
1832
         return;
1818
 
1833
 
1819
       sz = shape_size(sh(e))/no(e);
1834
       sz = shape_size(sh(e)) /no(e);
1820
       for (i = 0; i < no(e); ++i)
1835
       for (i = 0; i < no(e); ++i)
1821
        {
1836
        {
1822
          off = dest.where_off + i*sz;
1837
          off = dest.where_off + i*sz;
1823
          coder(mw(dest.where_exp, off),
1838
          coder(mw(dest.where_exp, off),
1824
                stack_room(stack, dest, off), copyexp(son(e)));
1839
                stack_room(stack, dest, off), copyexp(son(e)));
Line 1864... Line 1879...
1864
         };
1879
         };
1865
      };
1880
      };
1866
    case apply_tag:
1881
    case apply_tag:
1867
    case apply_general_tag:
1882
    case apply_general_tag:
1868
      {
1883
      {
1869
	exp proc = son (e);
1884
	exp proc = son(e);
1870
	exp arg = (!last(proc)) ? bro (proc) : nilexp;
1885
	exp arg = (!last(proc))? bro(proc): nilexp;
1871
	exp cees = nilexp;
1886
	exp cees = nilexp;
1872
	exp postlude = nilexp;
1887
	exp postlude = nilexp;
1873
	int untidy_call = 0;
1888
	int untidy_call = 0;
1874
	int has_checkstack = 0;
1889
	int has_checkstack = 0;
1875
	int  longs, more_longs, old_regsinuse, prev_use_bp;
1890
	int  longs, more_longs, old_regsinuse, prev_use_bp;
Line 1879... Line 1894...
1879
	int push_result = 0;
1894
	int push_result = 0;
1880
	int post_offset = 0;
1895
	int post_offset = 0;
1881
	int ret_stack_dec;
1896
	int ret_stack_dec;
1882
 
1897
 
1883
	if (builtinproc(e)) {
1898
	if (builtinproc(e)) {
1884
	  dec* dp = brog (son(proc));
1899
	  dec* dp = brog(son(proc));
1885
	  char *id = dp -> dec_u.dec_val.dec_id;
1900
	  char *id = dp -> dec_u.dec_val.dec_id;
1886
	  special_ins (id + prefix_length, arg, dest);
1901
	  special_ins(id + prefix_length, arg, dest);
1887
	  return;
1902
	  return;
1888
	}
1903
	}
1889
 
1904
 
1890
	if (name(e)==apply_general_tag) {
1905
	if (name(e) ==apply_general_tag) {
1891
	  arg = son(arg);
1906
	  arg = son(arg);
1892
	  cees = bro(bro(proc));
1907
	  cees = bro(bro(proc));
1893
	  if (name(bro(cees)) != top_tag)
1908
	  if (name(bro(cees))!= top_tag)
1894
	    postlude = bro(cees);
1909
	    postlude = bro(cees);
1895
	  untidy_call = call_is_untidy(e);
1910
	  untidy_call = call_is_untidy(e);
1896
	  has_checkstack = call_has_checkstack(e);
1911
	  has_checkstack = call_has_checkstack(e);
1897
	}
1912
	}
1898
 
1913
 
1899
	not_in_params = 0;
1914
	not_in_params = 0;
1900
	longs = procargs (stack, arg, has_checkstack);
1915
	longs = procargs(stack, arg, has_checkstack);
1901
	ret_stack_dec = stack_dec;
1916
	ret_stack_dec = stack_dec;
1902
 
1917
 
1903
	prev_use_bp = must_use_bp;	/* may be altered by push_cees */
1918
	prev_use_bp = must_use_bp;	/* may be altered by push_cees */
1904
	if (cees == nilexp)
1919
	if (cees == nilexp)
1905
	  more_longs = 0;
1920
	  more_longs = 0;
1906
	else {
1921
	else {
1907
	  switch (name(cees)) {
1922
	  switch (name(cees)) {
1908
	    case make_callee_list_tag:
1923
	    case make_callee_list_tag:
1909
	      {
1924
	      {
1910
		more_longs = procargs (stack, son(cees), has_checkstack);
1925
		more_longs = procargs(stack, son(cees), has_checkstack);
1911
		if (call_has_vcallees(cees)) {
1926
		if (call_has_vcallees(cees)) {
1912
		  ins2 (leal, 32, 32, mw(ind_sp.where_exp, more_longs), reg0);
1927
		  ins2(leal, 32, 32, mw(ind_sp.where_exp, more_longs), reg0);
1913
		  ins0 (pusheax);
1928
		  ins0(pusheax);
1914
		  stack_dec -= 32;
1929
		  stack_dec -= 32;
1915
		  more_longs += 32;
1930
		  more_longs += 32;
1916
		}
1931
		}
1917
		break;
1932
		break;
1918
	      }
1933
	      }
1919
	    case make_dynamic_callee_tag:
1934
	    case make_dynamic_callee_tag:
1920
	      {
1935
	      {
1921
		exp ptr = son(cees);
1936
		exp ptr = son(cees);
1922
		exp siz = bro(ptr);
1937
		exp siz = bro(ptr);
1923
		more_longs = push_cees (ptr, siz, call_has_vcallees(cees), stack);
1938
		more_longs = push_cees(ptr, siz, call_has_vcallees(cees), stack);
1924
		break;
1939
		break;
1925
	      }
1940
	      }
1926
	    case same_callees_tag:
1941
	    case same_callees_tag:
1927
	      {
1942
	      {
1928
		more_longs = push_cees (nilexp, nilexp, call_has_vcallees(cees), stack);
1943
		more_longs = push_cees(nilexp, nilexp, call_has_vcallees(cees), stack);
1929
		break;
1944
		break;
1930
	      }
1945
	      }
1931
	  }
1946
	  }
1932
	}
1947
	}
1933
 
1948
 
Line 1941... Line 1956...
1941
	}
1956
	}
1942
	if (postlude == nilexp && !untidy_call) {
1957
	if (postlude == nilexp && !untidy_call) {
1943
	  old_regsinuse = regsinuse;
1958
	  old_regsinuse = regsinuse;
1944
	  if (multi_reg)
1959
	  if (multi_reg)
1945
	    regsinuse |= 0x2;	/* prevent callins using pop edx */
1960
	    regsinuse |= 0x2;	/* prevent callins using pop edx */
1946
	  callins (longs, son (e), ret_stack_dec);
1961
	  callins(longs, son(e), ret_stack_dec);
1947
	  regsinuse = old_regsinuse;
1962
	  regsinuse = old_regsinuse;
1948
	}
1963
	}
1949
	else {
1964
	else {
1950
	  callins (0, son (e), ret_stack_dec);	/* delay arg stack return */
1965
	  callins (0, son (e), ret_stack_dec);	/* delay arg stack return */
1951
	  if (untidy_call) {
1966
	  if (untidy_call) {
1952
	    stack_dec = 0;	/* as alloca, must_use_bp */
1967
	    stack_dec = 0;	/* as alloca, must_use_bp */
1953
	    if (need_preserve_stack)
1968
	    if (need_preserve_stack)
1954
	      save_stack ();
1969
	      save_stack();
1955
	  };
1970
	  };
1956
	}
1971
	}
1957
	must_use_bp = prev_use_bp;
1972
	must_use_bp = prev_use_bp;
1958
 
1973
 
1959
	invalidate_dest (mw (nilexp, 0));
1974
	invalidate_dest(mw(nilexp, 0));
1960
 
1975
 
1961
	clear_low_reg_record (crt_reg_record);
1976
	clear_low_reg_record(crt_reg_record);
1962
	cond1_set = 0;
1977
	cond1_set = 0;
1963
	cond2_set = 0;		/* we don't know the state of the
1978
	cond2_set = 0;		/* we don't know the state of the
1964
				   conditions */
1979
				   conditions */
1965
	if (eq_where (dest, zero))
1980
	if (eq_where(dest, zero))
1966
	{
1981
	{
1967
	  if (reg_result (sh (e))) {/* answer in register */
1982
	  if (reg_result (sh (e))) {/* answer in register */
1968
	    if (name (sh (e)) >= shrealhd && name (sh (e)) <= doublehd) {
1983
	    if (name(sh(e)) >= shrealhd && name(sh(e)) <= doublehd) {
1969
	      push_fl;
1984
	      push_fl;
1970
	      discard_fstack();
1985
	      discard_fstack();
1971
	    }
1986
	    }
1972
	  }
1987
	  }
1973
	}
1988
	}
Line 1978... Line 1993...
1978
	  else {
1993
	  else {
1979
	    push_result = 1;
1994
	    push_result = 1;
1980
	    temp_dest = pushdest;
1995
	    temp_dest = pushdest;
1981
	  }
1996
	  }
1982
	  if (reg_result (sh (e))) {/* answer in register */
1997
	  if (reg_result (sh (e))) {/* answer in register */
1983
	    if (name (sh (e)) >= shrealhd && name (sh (e)) <= doublehd) {
1998
	    if (name(sh(e)) >= shrealhd && name(sh(e)) <= doublehd) {
1984
	      push_fl;
1999
	      push_fl;
1985
	      move (sh (e), flstack, temp_dest);
2000
	      move(sh(e), flstack, temp_dest);
1986
	    }
2001
	    }
1987
	    else
2002
	    else
1988
	      move (sh (e), reg0, temp_dest);
2003
	      move(sh(e), reg0, temp_dest);
1989
	  }
2004
	  }
1990
	  else
2005
	  else
1991
	    failer(STRUCT_RES);  /* compound result */
2006
	    failer(STRUCT_RES);  /* compound result */
1992
	}
2007
	}
1993
 
2008
 
1994
	if (postlude != nilexp) {
2009
	if (postlude != nilexp) {
1995
	  int sz = rounder (shape_size(sh(e)), param_align);
2010
	  int sz = rounder(shape_size(sh(e)), param_align);
1996
	  old_nip = not_in_postlude;
2011
	  old_nip = not_in_postlude;
1997
	  not_in_postlude = 0;
2012
	  not_in_postlude = 0;
1998
	  while (name(postlude) == ident_tag && name(son(postlude)) == caller_name_tag) {
2013
	  while (name(postlude) == ident_tag && name(son(postlude)) == caller_name_tag) {
1999
	    int n = no(son(postlude));
2014
	    int n = no(son(postlude));
2000
	    exp a = arg;
2015
	    exp a = arg;
2001
	    while (n != 0) {
2016
	    while (n != 0) {
2002
	      a = bro(a);
2017
	      a = bro(a);
2003
	      n--;
2018
	      n--;
2004
	    }
2019
	    }
2005
	    if (name(a) != caller_tag)
2020
	    if (name(a)!= caller_tag)
2006
	      failer(BAD_POSTLUDE);
2021
	      failer(BAD_POSTLUDE);
2007
	    no(postlude) = no(a) + stack_dec - post_offset;
2022
	    no(postlude) = no(a) + stack_dec - post_offset;
2008
	    ptno(postlude) = callstack_pl;
2023
	    ptno(postlude) = callstack_pl;
2009
	    postlude = bro(son(postlude));
2024
	    postlude = bro(son(postlude));
2010
	  }
2025
	  }
2011
	  if (push_result) {
2026
	  if (push_result) {
2012
	    stack_dec -= sz;
2027
	    stack_dec -= sz;
2013
	    check_stack_max;
2028
	    check_stack_max;
2014
	  }
2029
	  }
2015
	  coder (zero, stack, postlude);
2030
	  coder(zero, stack, postlude);
2016
	  if (push_result) {
2031
	  if (push_result) {
2017
	    if (name (dest.where_exp) == apply_tag) {
2032
	    if (name(dest.where_exp) == apply_tag) {
2018
	      move(sh(e), ind_sp, dest);
2033
	      move(sh(e), ind_sp, dest);
2019
	      stack_dec += sz;
2034
	      stack_dec += sz;
2020
	    }
2035
	    }
2021
	    else {
2036
	    else {
2022
	      longs += shape_size(sh(e));
2037
	      longs += shape_size(sh(e));
2023
	      if (dest.where_exp == ind_sp.where_exp)
2038
	      if (dest.where_exp == ind_sp.where_exp)
2024
		dest.where_off += longs;
2039
		dest.where_off += longs;
2025
	      move(sh(e), ind_sp, dest);
2040
	      move(sh(e), ind_sp, dest);
2026
	    }
2041
	    }
2027
	  }
2042
	  }
2028
	  stack_return (longs);
2043
	  stack_return(longs);
2029
	  not_in_postlude = old_nip;
2044
	  not_in_postlude = old_nip;
2030
	}
2045
	}
2031
 
2046
 
2032
	return;
2047
	return;
2033
      };
2048
      };
2034
    case tail_call_tag:
2049
    case tail_call_tag:
2035
      {
2050
      {
2036
	exp proc = son (e);
2051
	exp proc = son(e);
2037
	exp cees = bro(proc);
2052
	exp cees = bro(proc);
2038
	int longs;
2053
	int longs;
2039
	int prev_use_bp = must_use_bp;	/* may be altered by push_cees */
2054
	int prev_use_bp = must_use_bp;	/* may be altered by push_cees */
2040
	int old_nip = not_in_params;
2055
	int old_nip = not_in_params;
2041
	int old_stack_dec = stack_dec;
2056
	int old_stack_dec = stack_dec;
2042
	not_in_params = 0;
2057
	not_in_params = 0;
2043
	switch (name(cees)) {
2058
	switch (name(cees)) {
2044
	  case make_callee_list_tag:
2059
	  case make_callee_list_tag:
2045
	    {
2060
	    {
2046
	      not_in_params = 0;
2061
	      not_in_params = 0;
2047
	      longs = procargs (stack, son(cees), call_has_checkstack(e));
2062
	      longs = procargs(stack, son(cees), call_has_checkstack(e));
2048
	      not_in_params = old_nip;
2063
	      not_in_params = old_nip;
2049
	      break;
2064
	      break;
2050
	    }
2065
	    }
2051
	  case make_dynamic_callee_tag:
2066
	  case make_dynamic_callee_tag:
2052
	    {
2067
	    {
2053
	      longs = push_cees (son(cees), bro(son(cees)), 0, stack);
2068
	      longs = push_cees(son(cees), bro(son(cees)), 0, stack);
2054
	      break;
2069
	      break;
2055
	    }
2070
	    }
2056
	  case same_callees_tag:
2071
	  case same_callees_tag:
2057
	    {
2072
	    {
2058
	      longs = 0;
2073
	      longs = 0;
Line 2063... Line 2078...
2063
 
2078
 
2064
	/* clear off any unwanted fstack registers */
2079
	/* clear off any unwanted fstack registers */
2065
	{
2080
	{
2066
	  int good_fs = fstack_pos;
2081
	  int good_fs = fstack_pos;
2067
	  while (fstack_pos > first_fl_reg)
2082
	  while (fstack_pos > first_fl_reg)
2068
	    discard_fstack ();
2083
	    discard_fstack();
2069
	  fstack_pos = good_fs;
2084
	  fstack_pos = good_fs;
2070
	  reset_fpucon();
2085
	  reset_fpucon();
2071
	}
2086
	}
2072
 
2087
 
2073
	if (longs == 0) {
2088
	if (longs == 0) {
2074
	  coder (reg0, stack, proc);	/* proc value to %eax */
2089
	  coder (reg0, stack, proc);	/* proc value to %eax */
2075
	  restore_callregs (0);
2090
	  restore_callregs(0);
2076
		/* stack reduced to old callees and return address */
2091
		/* stack reduced to old callees and return address */
2077
 
2092
 
2078
	  if (name(cees) == same_callees_tag) {
2093
	  if (name(cees) == same_callees_tag) {
2079
	    if (callee_size < 0 && !call_has_vcallees(cees)) {
2094
	    if (callee_size < 0 && !call_has_vcallees(cees)) {
2080
	      outs (" popl %ecx\n");
2095
	      outs(" popl %ecx\n");
2081
	      outs (" movl %ecx, (%esp)\n");
2096
	      outs(" movl %ecx, (%esp)\n");
2082
	    }
2097
	    }
2083
	    if (callee_size >= 0 && call_has_vcallees(cees)) {
2098
	    if (callee_size >= 0 && call_has_vcallees(cees)) {
2084
	      outs (" popl %ecx\n");
2099
	      outs(" popl %ecx\n");
2085
	      outs (" leal "); outn((long)callee_size/8); outs("(%esp),%edx\n");
2100
	      outs(" leal "); outn((long)callee_size/8); outs("(%esp),%edx\n");
2086
	      outs (" pushl %edx\n");
2101
	      outs(" pushl %edx\n");
2087
	      outs (" pushl %ecx\n");
2102
	      outs(" pushl %ecx\n");
2088
	    }
2103
	    }
2089
	  }
2104
	  }
2090
	  else {
2105
	  else {
2091
	    if (callee_size != 0 || call_has_vcallees(cees)) {
2106
	    if (callee_size != 0 || call_has_vcallees(cees)) {
2092
	      outs (" popl %ecx\n");
2107
	      outs(" popl %ecx\n");
2093
	      if (callee_size < 0) {
2108
	      if (callee_size < 0) {
2094
		outs (" popl %edx\n");
2109
		outs(" popl %edx\n");
2095
		outs (" movl %edx,%esp\n");
2110
		outs(" movl %edx,%esp\n");
2096
	      }
2111
	      }
2097
	      else
2112
	      else
2098
	      if (callee_size == 0)
2113
	      if (callee_size == 0)
2099
		outs (" movl %esp %edx\n");
2114
		outs(" movl %esp %edx\n");
2100
	      else {
2115
	      else {
2101
		outs (" leal "); outn((long)callee_size/8); outs("(%esp),%edx\n");
2116
		outs(" leal "); outn((long)callee_size/8); outs("(%esp),%edx\n");
2102
		outs (" movl %edx,%esp\n");
2117
		outs(" movl %edx,%esp\n");
2103
	      }
2118
	      }
2104
	      if (call_has_vcallees(cees))
2119
	      if (call_has_vcallees(cees))
2105
		outs (" pushl %edx\n");
2120
		outs(" pushl %edx\n");
2106
	      outs (" pushl %ecx\n");
2121
	      outs(" pushl %ecx\n");
2107
	    }
2122
	    }
2108
	  }
2123
	  }
2109
	  outs (" jmp *%eax\n\n");
2124
	  outs(" jmp *%eax\n\n");
2110
	}
2125
	}
2111
	else {
2126
	else {
2112
			/* callees have been pushed */
2127
			/* callees have been pushed */
2113
	  if (call_has_vcallees(cees)) {
2128
	  if (call_has_vcallees(cees)) {
2114
	    if (callee_size >= 0) {
2129
	    if (callee_size >= 0) {
2115
	      outs (" leal ");
2130
	      outs(" leal ");
2116
	      rel_ap (4 + callee_size/8, 1);
2131
	      rel_ap(4 + callee_size/8, 1);
2117
	      outs (",%eax\n");
2132
	      outs(",%eax\n");
2118
	      ins0 (pusheax);
2133
	      ins0(pusheax);
2119
	    }
2134
	    }
2120
	    else {
2135
	    else {
2121
	      outs (" pushl ");
2136
	      outs(" pushl ");
2122
	      rel_ap (4, 1);
2137
	      rel_ap(4, 1);
2123
	    }
2138
	    }
2124
	    outnl();
2139
	    outnl();
2125
	    stack_dec -= 32;
2140
	    stack_dec -= 32;
2126
	  }
2141
	  }
2127
	  outs (" pushl ");
2142
	  outs(" pushl ");
2128
	  rel_ap (0, 1);	/* push return address after callees */
2143
	  rel_ap (0, 1);	/* push return address after callees */
2129
	  outnl();
2144
	  outnl();
2130
	  stack_dec -= 32;
2145
	  stack_dec -= 32;
2131
	  coder (pushdest, stack, proc);	/* push proc for call by return */
2146
	  coder (pushdest, stack, proc);	/* push proc for call by return */
2132
	  stack_dec -= 32;
2147
	  stack_dec -= 32;
2133
	  check_stack_max;
2148
	  check_stack_max;
2134
	  if (longs < 0) {	/* must be dynamic_callees */
2149
	  if (longs < 0) {	/* must be dynamic_callees */
2135
	    exp sz = bro(son(cees));
2150
	    exp sz = bro(son(cees));
2136
	    move (slongsh, mw(sz,0), reg2);
2151
	    move(slongsh, mw(sz,0), reg2);
2137
	    if (al2(sh(sz)) < param_align) {
2152
	    if (al2(sh(sz)) < param_align) {
2138
	      if (al2(sh(sz)) == 1) {
2153
	      if (al2(sh(sz)) == 1) {
2139
		outs (" addl $31,%ecx\n");
2154
		outs(" addl $31,%ecx\n");
2140
		outs (" shrl $3,%ecx\n");
2155
		outs(" shrl $3,%ecx\n");
2141
	      }
2156
	      }
2142
	      else
2157
	      else
2143
		outs (" addl $3,%ecx\n");
2158
		outs(" addl $3,%ecx\n");
2144
	      outs (" andl $-4,%ecx\n");
2159
	      outs(" andl $-4,%ecx\n");
2145
	    }
2160
	    }
2146
	  }
2161
	  }
2147
	  if (!call_has_vcallees(cees)) {
2162
	  if (!call_has_vcallees(cees)) {
2148
	    if (callee_size >= 0) {
2163
	    if (callee_size >= 0) {
2149
	      outs (" leal ");
2164
	      outs(" leal ");
2150
	      rel_ap (4 + callee_size/8, 1);
2165
	      rel_ap(4 + callee_size/8, 1);
2151
	      outs (",%eax\n");
2166
	      outs(",%eax\n");
2152
	    }
2167
	    }
2153
	    else {
2168
	    else {
2154
	      outs (" movl ");
2169
	      outs(" movl ");
2155
	      rel_ap (4, 1);
2170
	      rel_ap(4, 1);
2156
	      outs (",%eax\n");
2171
	      outs(",%eax\n");
2157
	    }
2172
	    }
2158
	  }
2173
	  }
2159
 
2174
 
2160
	  restore_callregs (1);
2175
	  restore_callregs(1);
2161
 
2176
 
2162
		/* callees, return and proc to call are stacked */
2177
		/* callees, return and proc to call are stacked */
2163
		/* size in %ecx if longs<0; callers at %eax unless stacked for vcallees */
2178
		/* size in %ecx if longs<0; callers at %eax unless stacked for vcallees */
2164
	  outs (" pushl %esi\n");
2179
	  outs(" pushl %esi\n");
2165
	  outs (" pushl %edi\n");
2180
	  outs(" pushl %edi\n");
2166
	  if (call_has_vcallees(cees))
2181
	  if (call_has_vcallees(cees))
2167
	    outs (" movl 16(%esp),%edi\n");
2182
	    outs(" movl 16(%esp),%edi\n");
2168
	  else
2183
	  else
2169
	    outs (" movl %eax,%edi\n");
2184
	    outs(" movl %eax,%edi\n");
2170
	  if (longs < 0) {
2185
	  if (longs < 0) {
2171
	    outs (" addl $");
2186
	    outs(" addl $");
2172
	    outn ((long)(call_has_vcallees(cees) ? 20 : 16));
2187
	    outn((long)(call_has_vcallees(cees)? 20 : 16));
2173
	    outs (", %ecx\n");
2188
	    outs(", %ecx\n");
2174
	    outs (" leal -4(%esp),%esi\n");
2189
	    outs(" leal -4(%esp),%esi\n");
2175
	    outs (" addl %ecx,%esi\n");
2190
	    outs(" addl %ecx,%esi\n");
2176
	    outs (" shrl $2,%ecx\n");
2191
	    outs(" shrl $2,%ecx\n");
2177
	  }
2192
	  }
2178
	  else {
2193
	  else {
2179
	    outs (" movl $");
2194
	    outs(" movl $");
2180
	    outn ((long)(longs/32 + (call_has_vcallees(cees) ? 5 : 4)));
2195
	    outn((long)(longs/32 + (call_has_vcallees(cees)? 5 : 4)));
2181
	    outs (",%ecx\n");
2196
	    outs(",%ecx\n");
2182
	    outs (" leal ");
2197
	    outs(" leal ");
2183
	    outn ((long)(longs/8 + (call_has_vcallees(cees) ? 16 : 12)));
2198
	    outn((long)(longs/8 + (call_has_vcallees(cees)? 16 : 12)));
2184
	    outs ("(%esp),%esi\n");
2199
	    outs("(%esp),%esi\n");
2185
	  }
2200
	  }
2186
	  outs (" subl $4,%edi\n");
2201
	  outs(" subl $4,%edi\n");
2187
	  outs (" std\n rep\n movsl\n cld\n");
2202
	  outs(" std\n rep\n movsl\n cld\n");
2188
	  outs (" leal 4(%edi),%esp\n");
2203
	  outs(" leal 4(%edi),%esp\n");
2189
	  outs (" popl %edi\n");
2204
	  outs(" popl %edi\n");
2190
	  outs (" popl %esi\n");
2205
	  outs(" popl %esi\n");
2191
	  outs (" ret\n");
2206
	  outs(" ret\n");
2192
	}
2207
	}
2193
 
2208
 
2194
	cond1_set = 0;
2209
	cond1_set = 0;
2195
	cond2_set = 0;
2210
	cond2_set = 0;
2196
	stack_dec = old_stack_dec;
2211
	stack_dec = old_stack_dec;
Line 2201... Line 2216...
2201
      {
2216
      {
2202
	where sz_where;
2217
	where sz_where;
2203
        if (name(son(e)) == val_tag)
2218
        if (name(son(e)) == val_tag)
2204
          {
2219
          {
2205
	    int n = no(son(e));
2220
	    int n = no(son(e));
2206
	    if (name(sh(son(e))) != offsethd)
2221
	    if (name(sh(son(e)))!= offsethd)
2207
	      n = 8 * n;
2222
	      n = 8 * n;
2208
	    sz_where = mw(zeroe, rounder(n, stack_align)/8);
2223
	    sz_where = mw(zeroe, rounder(n, stack_align) /8);
2209
          }
2224
          }
2210
        else {
2225
        else {
2211
	  exp temp = getexp(slongsh, nilexp, 0, nilexp, nilexp, 0, 0, val_tag);
2226
	  exp temp = getexp(slongsh, nilexp, 0, nilexp, nilexp, 0, 0, val_tag);
2212
          if (name(sh(son(e))) == offsethd && al2(sh(son(e))) == 1) {
2227
          if (name(sh(son(e))) == offsethd && al2(sh(son(e))) == 1) {
2213
	    no(temp) = 31;
2228
	    no(temp) = 31;
2214
	    bop (add, ulongsh, temp, son(e), reg0, stack);
2229
	    bop(add, ulongsh, temp, son(e), reg0, stack);
2215
            shiftr (ulongsh, mw(zeroe,3), reg0, reg0);
2230
            shiftr(ulongsh, mw(zeroe,3), reg0, reg0);
2216
	    and (ulongsh, mw (zeroe, -4), reg0, reg0);
2231
	    and(ulongsh, mw(zeroe, -4), reg0, reg0);
2217
	    sz_where = reg0;
2232
	    sz_where = reg0;
2218
          }
2233
          }
2219
          else if (al2(sh(son(e))) < 32) {
2234
          else if (al2(sh(son(e))) < 32) {
2220
	    no(temp) = 3;
2235
	    no(temp) = 3;
2221
	    bop (add, ulongsh, temp, son(e), reg0, stack);
2236
	    bop(add, ulongsh, temp, son(e), reg0, stack);
2222
	    and (ulongsh, mw (zeroe, -4), reg0, reg0);
2237
	    and(ulongsh, mw(zeroe, -4), reg0, reg0);
2223
	    sz_where = reg0;
2238
	    sz_where = reg0;
2224
          }
2239
          }
2225
	  else {
2240
	  else {
2226
	    sz_where = reg0;
2241
	    sz_where = reg0;
2227
	    coder (sz_where, stack, son(e));
2242
	    coder(sz_where, stack, son(e));
2228
	  }
2243
	  }
2229
	  retcell (temp);
2244
	  retcell(temp);
2230
        };
2245
        };
2231
	if (checkalloc(e))
2246
	if (checkalloc(e))
2232
	  checkalloc_stack(sz_where, 1);	/* uses reg1 */
2247
	  checkalloc_stack(sz_where, 1);	/* uses reg1 */
2233
	else
2248
	else
2234
	  sub (ulongsh, sz_where, sp, sp);
2249
	  sub(ulongsh, sz_where, sp, sp);
2235
	if (!eq_where (dest, zero))
2250
	if (!eq_where(dest, zero))
2236
	  move (sh (e), sp, dest);
2251
	  move(sh(e), sp, dest);
2237
	if (need_preserve_stack)
2252
	if (need_preserve_stack)
2238
	  save_stack ();
2253
	  save_stack();
2239
	return;
2254
	return;
2240
      };
2255
      };
2241
    case last_local_tag:
2256
    case last_local_tag:
2242
      {
2257
      {
2243
	move (sh (e), sp, dest);
2258
	move(sh(e), sp, dest);
2244
	return;
2259
	return;
2245
      };
2260
      };
2246
    case local_free_tag:
2261
    case local_free_tag:
2247
        move(slongsh, mw(son(e),0), sp);
2262
        move(slongsh, mw(son(e),0), sp);
2248
        if (name(bro(son(e))) == val_tag)
2263
        if (name(bro(son(e))) == val_tag)
2249
          {
2264
          {
2250
            int sz;
2265
            int sz;
2251
	    int n = no(bro(son(e)));
2266
	    int n = no(bro(son(e)));
2252
	    if (name(sh(bro(son(e)))) != offsethd)
2267
	    if (name(sh(bro(son(e))))!= offsethd)
2253
	      n = 8 * n;
2268
	      n = 8 * n;
2254
	    sz = rounder(n, stack_align);
2269
	    sz = rounder(n, stack_align);
2255
            add(slongsh, mw(zeroe, sz/8), sp, sp);
2270
            add(slongsh, mw(zeroe, sz/8), sp, sp);
2256
          }
2271
          }
2257
	else
2272
	else
2258
	    add(slongsh, mw(bro(son(e)), 0), sp, sp);
2273
	    add(slongsh, mw(bro(son(e)), 0), sp, sp);
2259
	add(slongsh, mw(zeroe, 3), sp, sp);
2274
	add(slongsh, mw(zeroe, 3), sp, sp);
2260
	and (slongsh, mw (zeroe, -stack_align/8), sp, sp);
2275
	and(slongsh, mw(zeroe, -stack_align/8), sp, sp);
2261
	if (need_preserve_stack)
2276
	if (need_preserve_stack)
2262
	  save_stack ();
2277
	  save_stack();
2263
        return;
2278
        return;
2264
    case local_free_all_tag:
2279
    case local_free_all_tag:
2265
        set_stack_from_bp();
2280
        set_stack_from_bp();
2266
	if (need_preserve_stack)
2281
	if (need_preserve_stack)
2267
	  save_stack ();
2282
	  save_stack();
2268
        return;
2283
        return;
2269
    case ignorable_tag:
2284
    case ignorable_tag:
2270
	coder(dest, stack, son(e));
2285
	coder(dest, stack, son(e));
2271
	return;
2286
	return;
2272
    case res_tag:
2287
    case res_tag:
Line 2285... Line 2300...
2285
	    /* int simple_res = (name(son(e)) == val_tag); */
2300
	    /* int simple_res = (name(son(e)) == val_tag); */
2286
	    int  good_fs;
2301
	    int  good_fs;
2287
 
2302
 
2288
	    /* if (!simple_res) */
2303
	    /* if (!simple_res) */
2289
	    {
2304
	    {
2290
	      if (name (sh (son (e))) >= shrealhd &&
2305
	      if (name(sh(son(e))) >= shrealhd &&
2291
		  name (sh (son (e))) <= doublehd) {
2306
		  name(sh(son(e))) <= doublehd) {
2292
	        coder (flstack, stack, son (e));
2307
	        coder(flstack, stack, son(e));
2293
	        with_fl_reg = 1;
2308
	        with_fl_reg = 1;
2294
	      }
2309
	      }
2295
	      else {
2310
	      else {
2296
	        coder (reg0, stack, son (e));
2311
	        coder(reg0, stack, son(e));
2297
	      };
2312
	      };
2298
	    };
2313
	    };
2299
 
2314
 
2300
	    if (name (sh (son (e))) != bothd) {
2315
	    if (name(sh(son(e)))!= bothd) {
2301
	      good_fs = fstack_pos;
2316
	      good_fs = fstack_pos;
2302
	      if (with_fl_reg) {/* jumping with a floating value */
2317
	      if (with_fl_reg) {/* jumping with a floating value */
2303
	        /* clear off any unwanted stack registers */
2318
	        /* clear off any unwanted stack registers */
2304
	        while (fstack_pos > (first_fl_reg + 1))
2319
	        while (fstack_pos > (first_fl_reg + 1))
2305
	          discard_st1 ();
2320
	          discard_st1();
2306
	        fstack_pos = good_fs - 1;
2321
	        fstack_pos = good_fs - 1;
2307
	      }
2322
	      }
2308
	      else {
2323
	      else {
2309
	        /* clear off any unwanted stack registers */
2324
	        /* clear off any unwanted stack registers */
2310
	         while (fstack_pos > first_fl_reg)
2325
	         while (fstack_pos > first_fl_reg)
2311
	          discard_fstack ();
2326
	          discard_fstack();
2312
	        fstack_pos = good_fs;
2327
	        fstack_pos = good_fs;
2313
	      };
2328
	      };
2314
	      reset_fpucon();
2329
	      reset_fpucon();
2315
	      if (name(e)==untidy_return_tag) {
2330
	      if (name(e) ==untidy_return_tag) {
2316
		int old_regsinuse = regsinuse;
2331
		int old_regsinuse = regsinuse;
2317
		regsinuse &= ~0x6;	/* %ecx, %edx not preserved */
2332
		regsinuse &= ~0x6;	/* %ecx, %edx not preserved */
2318
		if (shape_size(sh(son(e))) > 32 && !with_fl_reg)
2333
		if (shape_size(sh(son(e))) > 32 && !with_fl_reg)
2319
		  regsinuse |= 0x2;	/* %edx used for return value */
2334
		  regsinuse |= 0x2;	/* %edx used for return value */
2320
		if (stack_dec != 0)
2335
		if (stack_dec != 0)
2321
		  stack_return (- stack_dec);
2336
		  stack_return(- stack_dec);
2322
		regsinuse = old_regsinuse;
2337
		regsinuse = old_regsinuse;
2323
		outs (" pushl ");
2338
		outs(" pushl ");
2324
		rel_ap (0, 1);	/* push return address for return after pops */
2339
		rel_ap (0, 1);	/* push return address for return after pops */
2325
		outnl();
2340
		outnl();
2326
#ifdef NEWDWARF
2341
#ifdef NEWDWARF
2327
		if (diagnose && dwarf2)
2342
		if (diagnose && dwarf2)
2328
		  dw2_untidy_return ();
2343
		  dw2_untidy_return();
2329
#endif
2344
#endif
2330
	      }
2345
	      }
2331
#ifdef NEWDWARF
2346
#ifdef NEWDWARF
2332
	      if (diagnose && dwarf2) {
2347
	      if (diagnose && dwarf2) {
2333
		over_lab = next_dwarf_label ();
2348
		over_lab = next_dwarf_label();
2334
		dw2_return_pos (over_lab);
2349
		dw2_return_pos(over_lab);
2335
	      }
2350
	      }
2336
#endif
2351
#endif
2337
	      restore_callregs (name(e)==untidy_return_tag);
2352
	      restore_callregs(name(e) ==untidy_return_tag);
2338
#if 0
2353
#if 0
2339
	      if (simple_res) {	/* now done earlier for dw2_returns consistency */
2354
	      if (simple_res) {	/* now done earlier for dw2_returns consistency */
2340
	        coder (reg0, stack, son (e));
2355
	        coder(reg0, stack, son(e));
2341
	      };
2356
	      };
2342
#endif
2357
#endif
2343
 
2358
 
2344
	      if (name(e)==untidy_return_tag)
2359
	      if (name(e) ==untidy_return_tag)
2345
		ins0(ret);
2360
		ins0(ret);
2346
	      else
2361
	      else
2347
		retins();
2362
		retins();
2348
	      outnl();
2363
	      outnl();
2349
#ifdef NEWDWARF
2364
#ifdef NEWDWARF
2350
	      if (diagnose && dwarf2)
2365
	      if (diagnose && dwarf2)
2351
		dw2_after_fde_exit (over_lab);
2366
		dw2_after_fde_exit(over_lab);
2352
#endif
2367
#endif
2353
	    };
2368
	    };
2354
	    stack_dec = old_stack_dec;
2369
	    stack_dec = old_stack_dec;
2355
	    return;
2370
	    return;
2356
	  };
2371
	  };
Line 2361... Line 2376...
2361
    case return_to_label_tag:
2376
    case return_to_label_tag:
2362
      {
2377
      {
2363
	int good_fs = fstack_pos;
2378
	int good_fs = fstack_pos;
2364
		/* clear off any unwanted stack registers */
2379
		/* clear off any unwanted stack registers */
2365
	while (fstack_pos > first_fl_reg)
2380
	while (fstack_pos > first_fl_reg)
2366
	  discard_fstack ();
2381
	  discard_fstack();
2367
	fstack_pos = good_fs;
2382
	fstack_pos = good_fs;
2368
	reset_fpucon();
2383
	reset_fpucon();
2369
	move(slongsh, mw(son(e), 0), reg0);
2384
	move(slongsh, mw(son(e), 0), reg0);
2370
	restore_callregs(0);
2385
	restore_callregs(0);
2371
	ins0 ("jmp *%eax");
2386
	ins0("jmp *%eax");
2372
	return;
2387
	return;
2373
      };
2388
      };
2374
    case movecont_tag:
2389
    case movecont_tag:
2375
      {
2390
      {
2376
	exp frome = son (e);
2391
	exp frome = son(e);
2377
	exp toe = bro (frome);
2392
	exp toe = bro(frome);
2378
	exp lengthe = bro (toe);
2393
	exp lengthe = bro(toe);
2379
	movecont (mw (frome, 0), mw (toe, 0), mw (lengthe, 0),
2394
	movecont(mw(frome, 0), mw(toe, 0), mw(lengthe, 0),
2380
		  isnooverlap(e));
2395
		  isnooverlap(e));
2381
	return;
2396
	return;
2382
      };
2397
      };
2383
    case solve_tag:
2398
    case solve_tag:
2384
      {
2399
      {
2385
	exp jr = getexp (f_bottom, nilexp, 0, nilexp, nilexp, 0,
2400
	exp jr = getexp(f_bottom, nilexp, 0, nilexp, nilexp, 0,
2386
	    0, 0);
2401
	    0, 0);
2387
	clean_stack();
2402
	clean_stack();
2388
        sonno(jr) = stack_dec;
2403
        sonno(jr) = stack_dec;
2389
        ptno(jr) = next_lab();
2404
        ptno(jr) = next_lab();
2390
        fstack_pos_of(jr) = (prop)fstack_pos;
2405
        fstack_pos_of(jr) = (prop)fstack_pos;
2391
	/* jump record for end */
2406
	/* jump record for end */
2392
	solve (son (e), son (e), dest, jr, stack);
2407
	solve(son(e), son(e), dest, jr, stack);
2393
	if (name (sh (e)) != bothd) {
2408
	if (name(sh(e))!= bothd) {
2394
	  align_label(0, jr);
2409
	  align_label(0, jr);
2395
	  set_label (jr);
2410
	  set_label(jr);
2396
#ifdef NEWDWARF
2411
#ifdef NEWDWARF
2397
	  START_BB ();
2412
	  START_BB();
2398
#endif
2413
#endif
2399
	};
2414
	};
2400
	fpucon = normal_fpucon;
2415
	fpucon = normal_fpucon;
2401
	cond1_set = 0;
2416
	cond1_set = 0;
2402
	cond2_set = 0;
2417
	cond2_set = 0;
2403
	return;
2418
	return;
2404
      };
2419
      };
2405
    case case_tag:
2420
    case case_tag:
2406
      {
2421
      {
2407
	where qw;
2422
	where qw;
2408
	exp arg1 = son (e);
2423
	exp arg1 = son(e);
2409
	exp b = bro (arg1);
2424
	exp b = bro(arg1);
2410
	exp t = arg1;
2425
	exp t = arg1;
2411
	while (!last (t))
2426
	while (!last(t))
2412
	  t = bro (t);
2427
	  t = bro(t);
2413
	bro (t) = nilexp;
2428
	bro(t) = nilexp;
2414
 
2429
 
2415
	if (!is_o (name (arg1)) || is_crc(arg1)) {
2430
	if (!is_o(name(arg1)) || is_crc(arg1)) {
2416
				/* argument is not a possible 80386
2431
				/* argument is not a possible 80386
2417
				   operand, precompute it in reg0 */
2432
				   operand, precompute it in reg0 */
2418
	  qw.where_exp = copyexp (reg0.where_exp);
2433
	  qw.where_exp = copyexp(reg0.where_exp);
2419
	  sh (qw.where_exp) = sh (arg1);
2434
	  sh(qw.where_exp) = sh(arg1);
2420
	  qw.where_off = 0;
2435
	  qw.where_off = 0;
2421
	  coder (qw, stack, arg1);
2436
	  coder(qw, stack, arg1);
2422
	  arg1 = qw.where_exp;
2437
	  arg1 = qw.where_exp;
2423
	  bro (arg1) = b;
2438
	  bro(arg1) = b;
2424
	};
2439
	};
2425
 
2440
 
2426
	clean_stack();
2441
	clean_stack();
2427
 
2442
 
2428
	IGNORE caser (arg1, name(sh(e)) == bothd, e);
2443
	IGNORE caser(arg1, name(sh(e)) == bothd, e);
2429
 
2444
 
2430
	return;
2445
	return;
2431
      };
2446
      };
2432
#ifndef NEWDIAGS
2447
#ifndef NEWDIAGS
2433
    case diagnose_tag:  {
2448
    case diagnose_tag:  {
2434
	diag_info * d = dno(e);
2449
	diag_info * d = dno(e);
2435
	if (d->key == DIAG_INFO_SOURCE)  {
2450
	if (d->key == DIAG_INFO_SOURCE) {
2436
	  crt_lno = natint(d -> data.source.beg.line_no);
2451
	  crt_lno = natint(d -> data.source.beg.line_no);
2437
	  crt_charno = natint(d -> data.source.beg.char_off);
2452
	  crt_charno = natint(d -> data.source.beg.char_off);
2438
	  crt_flnm = d -> data.source.beg.file->file.ints.chars;
2453
	  crt_flnm = d -> data.source.beg.file->file.ints.chars;
2439
	};
2454
	};
2440
        output_diag(d, crt_proc_id, e);
2455
        output_diag(d, crt_proc_id, e);
Line 2442... Line 2457...
2442
        output_end_scope(d, e);
2457
        output_end_scope(d, e);
2443
        return;
2458
        return;
2444
      };
2459
      };
2445
#endif
2460
#endif
2446
    case trap_tag: {
2461
    case trap_tag: {
2447
	trap_ins (no(e));
2462
	trap_ins(no(e));
2448
	return;
2463
	return;
2449
      }
2464
      }
2450
    case asm_tag: {
2465
    case asm_tag: {
2451
	if (props(e))
2466
	if (props(e))
2452
	  asm_ins (e);
2467
	  asm_ins(e);
2453
	else {
2468
	else {
2454
	  start_asm ();
2469
	  start_asm();
2455
          coder(dest, stack, son(e));
2470
          coder(dest, stack, son(e));
2456
	  end_asm ();
2471
	  end_asm();
2457
	}
2472
	}
2458
	clear_low_reg_record (crt_reg_record);
2473
	clear_low_reg_record(crt_reg_record);
2459
	return;
2474
	return;
2460
      }
2475
      }
2461
    default:
2476
    default:
2462
      if (!is_a (name (e))) {
2477
      if (!is_a(name(e))) {
2463
	failer (BADOP);
2478
	failer(BADOP);
2464
	return;
2479
	return;
2465
      };
2480
      };
2466
 
2481
 
2467
      if (name(dest.where_exp) != val_tag)
2482
      if (name(dest.where_exp)!= val_tag)
2468
	codec (dest, stack, e);
2483
	codec(dest, stack, e);
2469
      else
2484
      else
2470
      if (!optop(e)) {
2485
      if (!optop(e)) {
2471
	if (name(sh(e)) >= shrealhd && name(sh(e)) <= doublehd) {
2486
	if (name(sh(e)) >= shrealhd && name(sh(e)) <= doublehd) {
2472
	  codec (flstack, stack, e);
2487
	  codec(flstack, stack, e);
2473
	  discard_fstack ();
2488
	  discard_fstack();
2474
	}
2489
	}
2475
	else
2490
	else
2476
	  codec (reg0, stack, e);
2491
	  codec(reg0, stack, e);
2477
      }
2492
      }
2478
      else
2493
      else
2479
      if (name(e)!=name_tag && name(e)!=env_offset_tag && son(e)!=nilexp) {
2494
      if (name(e)!=name_tag && name(e)!=env_offset_tag && son(e)!=nilexp) {
2480
	exp l = son(e);		/* catch all discards with side-effects */
2495
	exp l = son(e);		/* catch all discards with side-effects */
2481
	for (;;) {
2496
	for (;;) {
2482
	  coder (dest, stack, l);
2497
	  coder(dest, stack, l);
2483
	  if (last(l)) break;
2498
	  if (last(l))break;
2484
	  l = bro(l);
2499
	  l = bro(l);
2485
	}
2500
	}
2486
      }
2501
      }
2487
      return;
2502
      return;
2488
  };
2503
  };
Line 2494... Line 2509...
2494
	ash stack;
2509
	ash stack;
2495
	exp e;
2510
	exp e;
2496
};
2511
};
2497
 
2512
 
2498
static void coder2
2513
static void coder2
2499
    PROTO_N ( (args) )
-
 
2500
    PROTO_T ( void * args )
2514
(void * args)
2501
{
2515
{
2502
  struct coder_args * x = (struct coder_args *) args;
2516
  struct coder_args * x = (struct coder_args *)args;
2503
  coder1 (x->dest, x->stack, x->e);
2517
  coder1(x->dest, x->stack, x->e);
2504
  return;
2518
  return;
2505
}
2519
}
2506
 
2520
 
2507
static dg_where dg_where_dest
2521
static dg_where dg_where_dest
2508
    PROTO_N ( (e) )
-
 
2509
    PROTO_T ( exp e )
2522
(exp e)
2510
{
2523
{
2511
  dg_where w;
2524
  dg_where w;
2512
  if (name(e) == name_tag || name(e) == reff_tag) {
2525
  if (name(e) == name_tag || name(e) == reff_tag) {
2513
    w = dg_where_dest (son(e));
2526
    w = dg_where_dest(son(e));
2514
    w.o += no(e)/8;
2527
    w.o += no(e) /8;
2515
    return w;
2528
    return w;
2516
  }
2529
  }
2517
  if (name(e) != ident_tag)
2530
  if (name(e)!= ident_tag)
2518
    failer ("bad dg_where");
2531
    failer("bad dg_where");
2519
  if (isglob (e)) {
2532
  if (isglob(e)) {
2520
    w.k = WH_STR;
2533
    w.k = WH_STR;
2521
    w.u.s = (brog(e))->dec_u.dec_val.dec_id;
2534
    w.u.s = (brog(e)) ->dec_u.dec_val.dec_id;
2522
    w.o = 0;
2535
    w.o = 0;
2523
    return w;
2536
    return w;
2524
  }
2537
  }
2525
  if (ptno(e) < 0 || ptno(e) > 10)	/* contop case */
2538
  if (ptno(e) < 0 || ptno(e) > 10)	/* contop case */
2526
    return (dg_where_dest (son(e)));
2539
    return(dg_where_dest(son(e)));
2527
  switch (ptno (e)) {
2540
  switch (ptno(e)) {
2528
    case local_pl: {
2541
    case local_pl: {
2529
      w.k = WH_REGOFF;
2542
      w.k = WH_REGOFF;
2530
      w.u.l = -2;
2543
      w.u.l = -2;
2531
      w.o = no(e)/8;
2544
      w.o = no(e) /8;
2532
      break;
2545
      break;
2533
    }
2546
    }
2534
    case par_pl: {
2547
    case par_pl: {
2535
      w.k = WH_REGOFF;
2548
      w.k = WH_REGOFF;
2536
      w.u.l = -1;
2549
      w.u.l = -1;
2537
      w.o = (no(e)/8) + 4;
2550
      w.o = (no(e) /8) + 4;
2538
      break;
2551
      break;
2539
    }
2552
    }
2540
    case reg_pl: {
2553
    case reg_pl: {
2541
      w.k = WH_REG;
2554
      w.k = WH_REG;
2542
      w.u.l = get_reg_no (no(e));
2555
      w.u.l = get_reg_no(no(e));
2543
      break;
2556
      break;
2544
    }
2557
    }
2545
    default:
2558
    default:
2546
      failer ("bad dg_where");
2559
      failer("bad dg_where");
2547
      SET(w);
2560
      SET(w);
2548
  }
2561
  }
2549
  return w;
2562
  return w;
2550
}
2563
}
2551
 
2564
 
2552
static dg_where contop_where
2565
static dg_where contop_where
2553
    PROTO_N ( (id) )
-
 
2554
    PROTO_T ( exp id )
2566
(exp id)
2555
{
2567
{
2556
  return (dg_where_dest (bro(son(id))));
2568
  return(dg_where_dest(bro(son(id))));
2557
}
2569
}
2558
 
2570
 
2559
 
2571
 
2560
dg_where find_diag_res
2572
dg_where find_diag_res
2561
    PROTO_N ( (args) )
-
 
2562
    PROTO_T ( void * args )
2573
(void * args)
2563
{
2574
{
2564
  struct coder_args * x = (struct coder_args *) args;
2575
  struct coder_args * x = (struct coder_args *)args;
2565
  exp e = x->dest.where_exp;
2576
  exp e = x->dest.where_exp;
2566
  dg_where w;
2577
  dg_where w;
2567
  switch (name(e)) {
2578
  switch (name(e)) {
2568
    case val_tag: {
2579
    case val_tag: {
2569
      w.k = NO_WH;
2580
      w.k = NO_WH;
2570
      break;
2581
      break;
2571
    }
2582
    }
2572
    case ident_tag:
2583
    case ident_tag:
2573
    case name_tag: {
2584
    case name_tag: {
2574
      w = dg_where_dest (e);
2585
      w = dg_where_dest(e);
2575
      break;
2586
      break;
2576
    }
2587
    }
2577
    case ass_tag: {
2588
    case ass_tag: {
2578
      if (name(son(e)) == ident_tag)
2589
      if (name(son(e)) == ident_tag)
2579
	w = contop_where (son(e));
2590
	w = contop_where(son(e));
2580
      else
2591
      else
2581
	w = dg_where_dest (son(e));
2592
	w = dg_where_dest(son(e));
2582
      break;
2593
      break;
2583
    }
2594
    }
2584
    case apply_tag: {
2595
    case apply_tag: {
2585
      w.k = WH_REGOFF;
2596
      w.k = WH_REGOFF;
2586
      w.u.l = get_reg_no (no(son(sp.where_exp)));
2597
      w.u.l = get_reg_no(no(son(sp.where_exp)));
2587
      w.o = 0;
2598
      w.o = 0;
2588
      break;
2599
      break;
2589
    }
2600
    }
2590
    default:
2601
    default:
2591
      failer ("unexpected diag_res dest");
2602
      failer("unexpected diag_res dest");
2592
      SET(w);
2603
      SET(w);
2593
  }
2604
  }
2594
  return w;
2605
  return w;
2595
}
2606
}
2596
 
2607
 
2597
void coder
2608
void coder
2598
    PROTO_N ( (dest, stack, e) )
-
 
2599
    PROTO_T ( where dest X ash stack X exp e )
2609
(where dest, ash stack, exp e)
2600
{
2610
{
2601
  dg_info d;
2611
  dg_info d;
2602
  dg_info was_current = current_dg_info;
2612
  dg_info was_current = current_dg_info;
2603
  current_dg_info = nildiag;
2613
  current_dg_info = nildiag;
2604
  if (extra_diags) {
2614
  if (extra_diags) {
2605
    switch (name (e)) {
2615
    switch (name(e)) {
2606
      case apply_tag:
2616
      case apply_tag:
2607
      case apply_general_tag: {
2617
      case apply_general_tag: {
2608
	d = dgf(e);
2618
	d = dgf(e);
2609
	while (d && d->key != DGA_CALL)
2619
	while (d && d->key != DGA_CALL)
2610
	  d = d->more;
2620
	  d = d->more;
2611
	if (!d) {
2621
	if (!d) {
2612
	  d = new_dg_info (DGA_CALL);
2622
	  d = new_dg_info(DGA_CALL);
2613
	  d->data.i_call.clnam = (char*)0;
2623
	  d->data.i_call.clnam = (char*)0;
2614
	  d->data.i_call.pos = no_short_sourcepos;
2624
	  d->data.i_call.pos = no_short_sourcepos;
2615
	  d->data.i_call.ck = 0;
2625
	  d->data.i_call.ck = 0;
2616
	  dgf(e) = combine_diaginfo (dgf(e), d);
2626
	  dgf(e) = combine_diaginfo(dgf(e), d);
2617
	}
2627
	}
2618
	break;
2628
	break;
2619
      }
2629
      }
2620
      case test_tag: {
2630
      case test_tag: {
2621
	d = dgf(e);
2631
	d = dgf(e);
2622
	if (dw_doing_branch_tests)
2632
	if (dw_doing_branch_tests)
2623
	  break;
2633
	  break;
2624
	while (d && d->key != DGA_TEST)
2634
	while (d && d->key != DGA_TEST)
2625
	  d = d->more;
2635
	  d = d->more;
2626
	if (!d) {
2636
	if (!d) {
2627
	  d = new_dg_info (DGA_TEST);
2637
	  d = new_dg_info(DGA_TEST);
2628
	  d->data.i_tst.pos = no_short_sourcepos;
2638
	  d->data.i_tst.pos = no_short_sourcepos;
2629
	  d->data.i_tst.inv = 0;
2639
	  d->data.i_tst.inv = 0;
2630
	  dgf(e) = combine_diaginfo (dgf(e), d);
2640
	  dgf(e) = combine_diaginfo(dgf(e), d);
2631
	}
2641
	}
2632
	break;
2642
	break;
2633
      }
2643
      }
2634
      case goto_tag: {
2644
      case goto_tag: {
2635
	short_sourcepos p;
2645
	short_sourcepos p;
Line 2641... Line 2651...
2641
	  if (d->key == DGA_SRC)
2651
	  if (d->key == DGA_SRC)
2642
	    p = d->data.i_src.startpos;
2652
	    p = d->data.i_src.startpos;
2643
	  d = d->more;
2653
	  d = d->more;
2644
	}
2654
	}
2645
	if (!d) {
2655
	if (!d) {
2646
	  d = new_dg_info (DGA_JUMP);
2656
	  d = new_dg_info(DGA_JUMP);
2647
	  d->data.i_tst.pos = p;
2657
	  d->data.i_tst.pos = p;
2648
	  dgf(e) = combine_diaginfo (dgf(e), d);
2658
	  dgf(e) = combine_diaginfo(dgf(e), d);
2649
	}
2659
	}
2650
	break;
2660
	break;
2651
      }
2661
      }
2652
      case goto_lv_tag:
2662
      case goto_lv_tag:
2653
      case return_to_label_tag:
2663
      case return_to_label_tag:
Line 2657... Line 2667...
2657
	if (dw_doing_branch_tests)
2667
	if (dw_doing_branch_tests)
2658
	  break;
2668
	  break;
2659
	while (d && d->key != DGA_LJ)
2669
	while (d && d->key != DGA_LJ)
2660
	  d = d->more;
2670
	  d = d->more;
2661
	if (!d) {
2671
	if (!d) {
2662
	  d = new_dg_info (DGA_LJ);
2672
	  d = new_dg_info(DGA_LJ);
2663
	  d->data.i_tst.pos = no_short_sourcepos;
2673
	  d->data.i_tst.pos = no_short_sourcepos;
2664
	  dgf(e) = combine_diaginfo (dgf(e), d);
2674
	  dgf(e) = combine_diaginfo(dgf(e), d);
2665
	}
2675
	}
2666
	break;
2676
	break;
2667
      }
2677
      }
2668
    }
2678
    }
2669
  }
2679
  }
Line 2673... Line 2683...
2673
    struct coder_args args;
2683
    struct coder_args args;
2674
    args.dest = dest;
2684
    args.dest = dest;
2675
    args.stack = stack;
2685
    args.stack = stack;
2676
    current_dg_exp = args.e = e;
2686
    current_dg_exp = args.e = e;
2677
    while (d != nildiag) {
2687
    while (d != nildiag) {
2678
      if (d->key == DGA_SRC && d->data.i_src.startpos.file)  {
2688
      if (d->key == DGA_SRC && d->data.i_src.startpos.file) {
2679
	crt_lno = d->data.i_src.startpos.line;
2689
	crt_lno = d->data.i_src.startpos.line;
2680
	crt_charno = d->data.i_src.startpos.column;
2690
	crt_charno = d->data.i_src.startpos.column;
2681
	crt_flnm = d->data.i_src.startpos.file->file_name;
2691
	crt_flnm = d->data.i_src.startpos.file->file_name;
2682
        if (d->data.i_src.endpos.file)  {
2692
        if (d->data.i_src.endpos.file) {
2683
	  dpos = d;
2693
	  dpos = d;
2684
	  break;
2694
	  break;
2685
	}
2695
	}
2686
      };
2696
      };
2687
      d = d->more;
2697
      d = d->more;
2688
    };
2698
    };
2689
#ifdef NEWDWARF
2699
#ifdef NEWDWARF
2690
    CODE_DIAG_INFO (dgf(e), crt_proc_id, coder2, (void*)&args);
2700
    CODE_DIAG_INFO(dgf(e), crt_proc_id, coder2,(void*) &args);
2691
#else
2701
#else
2692
    code_diag_info (dgf(e), crt_proc_id, coder2, (void*)&args);
2702
    code_diag_info(dgf(e), crt_proc_id, coder2,(void*) &args);
2693
#endif
2703
#endif
2694
    if (dpos) {
2704
    if (dpos) {
2695
      crt_lno = dpos->data.i_src.endpos.line;
2705
      crt_lno = dpos->data.i_src.endpos.line;
2696
      crt_charno = dpos->data.i_src.endpos.column;
2706
      crt_charno = dpos->data.i_src.endpos.column;
2697
      crt_flnm = dpos->data.i_src.endpos.file->file_name;
2707
      crt_flnm = dpos->data.i_src.endpos.file->file_name;
2698
    };
2708
    };
2699
  }
2709
  }
2700
  else
2710
  else
2701
    coder1 (dest, stack, e);
2711
    coder1(dest, stack, e);
2702
  current_dg_info = was_current;
2712
  current_dg_info = was_current;
2703
  return;
2713
  return;
2704
}
2714
}
2705
 
2715
 
2706
 
2716
 
2707
 
2717
 
2708
static void done_arg
2718
static void done_arg
2709
    PROTO_N ( (args) )
-
 
2710
    PROTO_T ( void * args )
2719
(void * args)
2711
{
2720
{
2712
  UNUSED (args);
2721
  UNUSED(args);
2713
  return;
2722
  return;
2714
}
2723
}
2715
 
2724
 
2716
void diag_arg
2725
void diag_arg
2717
    PROTO_N ( (dest, stack, e) )
-
 
2718
    PROTO_T ( where dest X ash stack X exp e )
2726
(where dest, ash stack, exp e)
2719
{
2727
{
2720
  if (dgf(e)) {
2728
  if (dgf(e)) {
2721
    struct coder_args args;
2729
    struct coder_args args;
2722
    args.dest = dest;
2730
    args.dest = dest;
2723
    args.stack = stack;
2731
    args.stack = stack;
2724
    current_dg_exp = args.e = e;
2732
    current_dg_exp = args.e = e;
2725
#ifdef NEWDWARF
2733
#ifdef NEWDWARF
2726
    CODE_DIAG_INFO (dgf(e), crt_proc_id, done_arg, (void*)&args);
2734
    CODE_DIAG_INFO(dgf(e), crt_proc_id, done_arg,(void*) &args);
2727
#else
2735
#else
2728
    code_diag_info (dgf(e), crt_proc_id, done_arg, (void*)&args);
2736
    code_diag_info(dgf(e), crt_proc_id, done_arg,(void*) &args);
2729
#endif
2737
#endif
2730
  }
2738
  }
2731
  return;
2739
  return;
2732
}
2740
}
2733
 
2741