Subversion Repositories tendra.SVN

Rev

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

Rev 5 Rev 6
Line -... Line 1...
-
 
1
/*
-
 
2
 * Copyright (c) 2002-2005 The TenDRA Project <http://www.tendra.org/>.
-
 
3
 * All rights reserved.
-
 
4
 *
-
 
5
 * Redistribution and use in source and binary forms, with or without
-
 
6
 * modification, are permitted provided that the following conditions are met:
-
 
7
 *
-
 
8
 * 1. Redistributions of source code must retain the above copyright notice,
-
 
9
 *    this list of conditions and the following disclaimer.
-
 
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
-
 
11
 *    this list of conditions and the following disclaimer in the documentation
-
 
12
 *    and/or other materials provided with the distribution.
-
 
13
 * 3. Neither the name of The TenDRA Project nor the names of its contributors
-
 
14
 *    may be used to endorse or promote products derived from this software
-
 
15
 *    without specific, prior written permission.
-
 
16
 *
-
 
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
-
 
18
 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-
 
19
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-
 
20
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
-
 
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-
 
22
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-
 
23
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-
 
24
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-
 
25
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-
 
26
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-
 
27
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
28
 *
-
 
29
 * $Id$
-
 
30
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
 
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
Line 230... Line 260...
230
};
260
};
231
 
261
 
232
/* PROCEDURES */
262
/* PROCEDURES */
233
 
263
 
234
void temp_push_fl
264
void temp_push_fl
235
    PROTO_Z ()
265
(void)
236
{
266
{
237
  ++fstack_pos;
267
  ++fstack_pos;
238
  return;
268
  return;
239
}
269
}
240
void temp_pop_fl
270
void temp_pop_fl
241
    PROTO_Z ()
271
(void)
242
{
272
{
243
  --fstack_pos;
273
  --fstack_pos;
244
  return;
274
  return;
245
}
275
}
246
 
276
 
Line 250... Line 280...
250
outreal outputs a floating point number
280
outreal outputs a floating point number
251
 
281
 
252
****************************************************************/
282
****************************************************************/
253
 
283
 
254
void outreal
284
void outreal
255
    PROTO_N ( (e) )
-
 
256
    PROTO_T ( exp e )
285
(exp e)
257
{
286
{
258
  flt * f = &flptnos[no(e)];
287
  flt * f = &flptnos[no(e)];
259
  int sw = name(sh(e)) - shrealhd;
288
  int sw = name(sh(e)) - shrealhd;
260
  r2l longs;
289
  r2l longs;
261
 
290
 
Line 287... Line 316...
287
 
316
 
288
/* output operand i (in bytes) relative to
317
/* output operand i (in bytes) relative to
289
   stack pointer  uses address relative to
318
   stack pointer  uses address relative to
290
   frame pointer if it might be shorter */
319
   frame pointer if it might be shorter */
291
void rel_sp
320
void rel_sp
292
    PROTO_N ( (i, b) )
-
 
293
    PROTO_T ( int i X int b )
321
(int i, int b)
294
{
322
{
295
  int  n = i + (extra_stack / 8);
323
  int  n = i + (extra_stack / 8);
296
  if (!must_use_bp) {
324
  if (!must_use_bp) {
297
				/* if we might use alloca all
325
				/* if we might use alloca all
298
				   displacements must be relative to frame
326
				   displacements must be relative to frame
299
				   pointer */
327
				   pointer */
300
    if (n == 0) {
328
    if (n == 0) {
301
      outs ("(%esp");
329
      outs("(%esp");
302
      if (b)
330
      if (b)
303
	outs (")");
331
	outs(")");
304
      return;
332
      return;
305
    };
333
    };
306
    if (n <= 127 || no_frame || stack_aligned_8byte) {
334
    if (n <= 127 || no_frame || stack_aligned_8byte) {
307
				/* use stack pointer if displacement from
335
				/* use stack pointer if displacement from
308
				   it is small */
336
				   it is small */
309
      outn ((long)n);
337
      outn((long)n);
310
      outs ("(%esp");
338
      outs("(%esp");
311
      if (b)
339
      if (b)
312
	outs (")");
340
	outs(")");
313
      return;
341
      return;
314
    };
342
    };
315
  };
343
  };
316
  /* otherwise use displacement from frame pointer */
344
  /* otherwise use displacement from frame pointer */
317
  outn ((long)(i + (stack_dec / 8)));
345
  outn((long)(i + (stack_dec / 8)));
318
  outs("-");
346
  outs("-");
319
  outs(local_prefix);
347
  outs(local_prefix);
320
  outs ("disp");
348
  outs("disp");
321
  outn ((long)crt_proc_id);
349
  outn((long)crt_proc_id);
322
  outs ("(%ebp");
350
  outs("(%ebp");
323
  if (b)
351
  if (b)
324
    outs (")");
352
    outs(")");
325
  return;
353
  return;
326
}
354
}
327
 
355
 
328
/* output operand i (in bytes) relative to
356
/* output operand i (in bytes) relative to
329
   stack pointer */
357
   stack pointer */
330
void rel_cp
358
void rel_cp
331
    PROTO_N ( (i, b) )
-
 
332
    PROTO_T ( int i X int b )
359
(int i, int b)
333
{
360
{
334
  int  n = i + (extra_stack / 8);
361
  int  n = i + (extra_stack / 8);
335
  if (n == 0) {
362
  if (n == 0) {
336
    outs ("(%esp");
363
    outs("(%esp");
337
    if (b)
364
    if (b)
338
      outs (")");
365
      outs(")");
339
    return;
366
    return;
340
  };
367
  };
341
  outn ((long)n);
368
  outn((long)n);
342
  outs ("(%esp");
369
  outs("(%esp");
343
  if (b)
370
  if (b)
344
    outs (")");
371
    outs(")");
345
  return;
372
  return;
346
}
373
}
347
 
374
 
348
/* output operand relative to frame
375
/* output operand relative to frame
349
   pointer */
376
   pointer */
350
void rel_ap
377
void rel_ap
351
    PROTO_N ( (i, b) )
-
 
352
    PROTO_T ( int i X int b )
378
(int i, int b)
353
{
379
{
354
  if (no_frame) {
380
  if (no_frame) {
355
    outn ((long)(i + ((extra_stack - stack_dec) / 8)));
381
    outn((long)(i + ((extra_stack - stack_dec) / 8)));
356
    outs("+");
382
    outs("+");
357
    outs(local_prefix);
383
    outs(local_prefix);
358
    outs ("disp");
384
    outs("disp");
359
    outn ((long)crt_proc_id);
385
    outn((long)crt_proc_id);
360
    outs ("(%esp");
386
    outs("(%esp");
361
    if (b)
387
    if (b)
362
      outs (")");
388
      outs(")");
363
    return;
389
    return;
364
  }
390
  }
365
  else {
391
  else {
366
    outn ((long)i + 4);
392
    outn((long)i + 4);
367
    outs ("(%ebp");
393
    outs("(%ebp");
368
    if (b)
394
    if (b)
369
      outs (")");
395
      outs(")");
370
    return;
396
    return;
371
  };
397
  };
372
}
398
}
373
 
399
 
374
/* output operand relative to frame
400
/* output operand relative to frame
375
   pointer and push space*/
401
   pointer and push space*/
376
void rel_ap1
402
void rel_ap1
377
    PROTO_N ( (i, b) )
-
 
378
    PROTO_T ( int i X int b )
403
(int i, int b)
379
{
404
{
380
  if (no_frame) {
405
  if (no_frame) {
381
    outn ((long)(i + ((extra_stack - stack_dec) / 8)));
406
    outn((long)(i + ((extra_stack - stack_dec) / 8)));
382
    outs("+");
407
    outs("+");
383
    outs(local_prefix);
408
    outs(local_prefix);
384
    outs ("fcwdisp");
409
    outs("fcwdisp");
385
    outn ((long)crt_proc_id);
410
    outn((long)crt_proc_id);
386
    outs ("(%esp");
411
    outs("(%esp");
387
    if (b)
412
    if (b)
388
      outs (")");
413
      outs(")");
389
    return;
414
    return;
390
  }
415
  }
391
  else {
416
  else {
392
    outn ((long)i);
417
    outn((long)i);
393
    outs("-");
418
    outs("-");
394
    outs(local_prefix);
419
    outs(local_prefix);
395
    outs ("fcwdisp");
420
    outs("fcwdisp");
396
    outn ((long)crt_proc_id);
421
    outn((long)crt_proc_id);
397
    outs ("(%ebp");
422
    outs("(%ebp");
398
    if (b)
423
    if (b)
399
      outs (")");
424
      outs(")");
400
    return;
425
    return;
401
  };
426
  };
402
}
427
}
403
 
428
 
404
int  get_reg_no
429
int  get_reg_no
405
    PROTO_N ( (regs) )
-
 
406
    PROTO_T ( int regs )
430
(int regs)
407
{
431
{
408
  frr fr;
432
  frr fr;
409
  /* find the registers associated with the bit pattern regs */
433
  /* find the registers associated with the bit pattern regs */
410
 
434
 
411
  fr = first_reg (regs);
435
  fr = first_reg(regs);
412
  if (regs == 0x10000 || fr.fr_no == (fstack_pos))
436
  if (regs == 0x10000 || fr.fr_no == (fstack_pos))
413
    return (fstack_pos);
437
    return(fstack_pos);
414
  return (fr.fr_no);		/* this is the register number */
438
  return (fr.fr_no);		/* this is the register number */
415
}
439
}
416
 
440
 
417
/* output a register address, regs is a
441
/* output a register address, regs is a
418
   bit pattern, rdisp is an offset in bit
442
   bit pattern, rdisp is an offset in bit
419
   units. le tells us how to refer to the
443
   units. le tells us how to refer to the
420
   register (eg al or ax or eax) */
444
   register (eg al or ax or eax) */
421
void regn
445
void regn
422
    PROTO_N ( (regs, rdisp, ldname, le) )
-
 
423
    PROTO_T ( int regs X int rdisp X exp ldname X int le )
446
(int regs, int rdisp, exp ldname, int le)
424
{
447
{
425
  int  z;
448
  int  z;
426
  char **rn;
449
  char **rn;
427
  UNUSED(rdisp);
450
  UNUSED(rdisp);
428
  z = get_reg_no (regs);
451
  z = get_reg_no(regs);
429
 
452
 
430
  if (name (ldname) == name_tag && islastuse(ldname))
453
  if (name(ldname) == name_tag && islastuse(ldname))
431
    regsinuse = regsinuse & ~regs;
454
    regsinuse = regsinuse & ~regs;
432
 
455
 
433
  if (z >= first_fl_reg) {
456
  if (z >= first_fl_reg) {
434
    if (z == first_fl_reg) {
457
    if (z == first_fl_reg) {
435
      outs (fl_reg_name[0]);
458
      outs(fl_reg_name[0]);
436
      return;
459
      return;
437
    };
460
    };
438
    if (fstack_pos > 16) {
461
    if (fstack_pos > 16) {
439
      failer (BAD_FSTACK);
462
      failer(BAD_FSTACK);
440
      exit(EXIT_FAILURE);
463
      exit(EXIT_FAILURE);
441
    };
464
    };
442
    outs (fl_reg_name[fstack_pos - z]);
465
    outs(fl_reg_name[fstack_pos - z]);
443
    /* variables held in the floating point registers have to be addressed
466
    /* variables held in the floating point registers have to be addressed
444
       relative to the current stack position, because the registers are a
467
       relative to the current stack position, because the registers are a
445
       stack as well as a register bank */
468
       stack as well as a register bank */
446
    return;
469
    return;
447
  };
470
  };
448
 
471
 
449
  switch (le) {
472
  switch (le) {
450
    case 8:
473
    case 8:
451
      rn = reg_name_byte;
474
      rn = reg_name_byte;
Line 462... Line 485...
462
}
485
}
463
 
486
 
464
 
487
 
465
/* output a displacement from register operand */
488
/* output a displacement from register operand */
466
void ind_reg
489
void ind_reg
467
    PROTO_N ( (regs, rdisp, offset, ldname, b) )
-
 
468
    PROTO_T ( int regs X int rdisp X int offset X exp ldname X int b )
490
(int regs, int rdisp, int offset, exp ldname, int b)
469
{
491
{
470
  if (regs == 128)
492
  if (regs == 128)
471
    offset += extra_stack;
493
    offset += extra_stack;
472
 
494
 
473
  if (offset == 0) {
495
  if (offset == 0) {
474
    outs ("(");
496
    outs("(");
475
    regn (regs, rdisp, ldname, 32);
497
    regn(regs, rdisp, ldname, 32);
476
    if (b)
498
    if (b)
477
      outs (")");
499
      outs(")");
478
  }
500
  }
479
  else {
501
  else {
480
    outn ((long)offset / 8);
502
    outn((long)offset / 8);
481
    outs ("(");
503
    outs("(");
482
    regn (regs, rdisp, ldname, 32);
504
    regn(regs, rdisp, ldname, 32);
483
    if (b)
505
    if (b)
484
      outs (")");
506
      outs(")");
485
  };
507
  };
486
  return;
508
  return;
487
}
509
}
488
 
510
 
489
/* use indexed addressing */
511
/* use indexed addressing */
490
void index_opnd
512
void index_opnd
491
    PROTO_N ( (whmain, wh, sc) )
-
 
492
    PROTO_T ( where whmain X where wh X int sc )
513
(where whmain, where wh, int sc)
493
{
514
{
494
  exp m = whmain.where_exp;
515
  exp m = whmain.where_exp;
495
  if ((name (m) == name_tag && ptno (son (m)) == reg_pl) ||
516
  if ((name(m) == name_tag && ptno(son(m)) == reg_pl) ||
496
      (name (m) == cont_tag && name (son (m)) == name_tag &&
517
     (name(m) == cont_tag && name(son(m)) == name_tag &&
497
	isvar (son (son (m))) && ptno (son (son (m))) == reg_pl))
518
	isvar(son(son(m))) && ptno(son(son(m))) == reg_pl))
498
    outs ("(");
519
    outs("(");
499
  operand (32, whmain, 0, 0);
520
  operand(32, whmain, 0, 0);
500
  outs (",");
521
  outs(",");
501
  operand (32, wh, 1, 0);
522
  operand(32, wh, 1, 0);
502
  if (sc != 1) {
523
  if (sc != 1) {
503
    outs (",");
524
    outs(",");
504
    outn ((long)sc);
525
    outn((long)sc);
505
  };
526
  };
506
  outs (")");
527
  outs(")");
507
  return;
528
  return;
508
}
529
}
509
 
530
 
510
 
531
 
511
/* output an external operand */
532
/* output an external operand */
512
void extn
533
void extn
513
    PROTO_N ( (id, off, b) )
-
 
514
    PROTO_T ( exp id X int off X int b )
534
(exp id, int off, int b)
515
{
535
{
516
  dec * et;
536
  dec * et;
517
 
537
 
518
  et = brog (id);
538
  et = brog(id);
519
 
539
 
520
  if (PIC_code)
540
  if (PIC_code)
521
   {
541
   {
522
     char * got;
542
     char * got;
523
     if (et -> dec_u.dec_val.extnamed)
543
     if (et -> dec_u.dec_val.extnamed)
524
        got = "GOT";
544
        got = "GOT";
525
     else
545
     else
526
        got = "GOTOFF";
546
        got = "GOTOFF";
527
     outs (et -> dec_u.dec_val.dec_id);
547
     outs(et -> dec_u.dec_val.dec_id);
528
     outs("@");
548
     outs("@");
529
     outs(got);
549
     outs(got);
530
     if (off != 0)
550
     if (off != 0)
531
      {
551
      {
532
        outs ("+");
552
        outs("+");
533
        outn ((long)off / 8);
553
        outn((long)off / 8);
534
      };
554
      };
535
     outs("(%ebx");
555
     outs("(%ebx");
536
     if (b)
556
     if (b)
537
       outs(")");
557
       outs(")");
538
     return;
558
     return;
539
   };
559
   };
540
 
560
 
541
  if (off == 0)
561
  if (off == 0)
542
    outs (et -> dec_u.dec_val.dec_id);
562
    outs(et -> dec_u.dec_val.dec_id);
543
  else {
563
  else {
544
    outs (et -> dec_u.dec_val.dec_id);
564
    outs(et -> dec_u.dec_val.dec_id);
545
    outs ("+");
565
    outs("+");
546
    outn ((long)off / 8);
566
    outn((long)off / 8);
547
  };
567
  };
548
  if (!b)
568
  if (!b)
549
    outs ("(");
569
    outs("(");
550
  return;
570
  return;
551
}
571
}
552
 
572
 
553
/* an integer constant */
573
/* an integer constant */
554
void int_operand
574
void int_operand
555
    PROTO_N ( (k, l) )
-
 
556
    PROTO_T ( int k X int l )
575
(int k, int l)
557
{
576
{
558
  int  mask;
577
  int  mask;
559
  switch (l) {
578
  switch (l) {
560
    case 8:
579
    case 8:
561
      mask = 0xff;
580
      mask = 0xff;
Line 564... Line 583...
564
      mask = 0xffff;
583
      mask = 0xffff;
565
      break;
584
      break;
566
    default:
585
    default:
567
      mask = 0xffffffff;
586
      mask = 0xffffffff;
568
  };
587
  };
569
  outs ("$");
588
  outs("$");
570
  outn ((long)k & mask);
589
  outn((long)k & mask);
571
  return;
590
  return;
572
}
591
}
573
 
592
 
574
 
593
 
575
/* an external literal */
594
/* an external literal */
576
void const_extn
595
void const_extn
577
    PROTO_N ( (ident, noff) )
-
 
578
    PROTO_T ( exp ident X int noff )
596
(exp ident, int noff)
579
{
597
{
580
  if (!PIC_code)
598
  if (!PIC_code)
581
    outs ("$");
599
    outs("$");
582
  extn (ident, noff, 1);
600
  extn(ident, noff, 1);
583
  return;
601
  return;
584
}
602
}
585
 
603
 
586
/* an external literal */
604
/* an external literal */
587
void proc_extn
605
void proc_extn
588
    PROTO_N ( (id, off) )
-
 
589
    PROTO_T ( exp id X int off )
606
(exp id, int off)
590
{
607
{
591
  if (PIC_code)
608
  if (PIC_code)
592
   {
609
   {
593
     dec * et;
610
     dec * et;
594
     et = brog (id);
611
     et = brog(id);
595
     if (off == 0)
612
     if (off == 0)
596
       outs (et -> dec_u.dec_val.dec_id);
613
       outs(et -> dec_u.dec_val.dec_id);
597
     else {
614
     else {
598
        outn ((long)off / 8);
615
        outn((long)off / 8);
599
        outs ("+");
616
        outs("+");
600
        outs (et -> dec_u.dec_val.dec_id);
617
        outs(et -> dec_u.dec_val.dec_id);
601
     };
618
     };
602
     if (et -> dec_u.dec_val.extnamed)
619
     if (et -> dec_u.dec_val.extnamed)
603
        outs("@PLT");
620
        outs("@PLT");
604
   }
621
   }
605
  else
622
  else
606
   {
623
   {
607
     outs ("$");
624
     outs("$");
608
     extn (id, off, 1);
625
     extn(id, off, 1);
609
   };
626
   };
610
 
627
 
611
  return;
628
  return;
612
}
629
}
613
 
630
 
614
void ldisp
631
void ldisp
615
    PROTO_Z ()
632
(void)
616
{
633
{
617
   outs(local_prefix);
634
   outs(local_prefix);
618
   outs("disp");
635
   outs("disp");
619
   outn((long)crt_proc_id);
636
   outn((long)crt_proc_id);
620
}
637
}
621
 
638
 
622
void label_operand
639
void label_operand
623
    PROTO_N ( (e) )
-
 
624
    PROTO_T ( exp e )
640
(exp e)
625
{
641
{
626
  punner l;
642
  punner l;
627
  l.e = pt(e);
643
  l.e = pt(e);
628
  outs("$");
644
  outs("$");
629
  outs(local_prefix);
645
  outs(local_prefix);
Line 631... Line 647...
631
  outn((long)l.i);
647
  outn((long)l.i);
632
  return;
648
  return;
633
}
649
}
634
 
650
 
635
void set_lv_label
651
void set_lv_label
636
    PROTO_N ( (e) )
-
 
637
    PROTO_T ( exp e )
652
(exp e)
638
{
653
{
639
  punner l;
654
  punner l;
640
  l.e = e;
655
  l.e = e;
641
  min_rfree |= 0x78;  /* save all callee registers */
656
  min_rfree |= 0x78;  /* save all callee registers */
642
 
657
 
Line 647... Line 662...
647
  outnl();
662
  outnl();
648
  return;
663
  return;
649
}
664
}
650
 
665
 
651
void set_env_off
666
void set_env_off
652
    PROTO_N ( (s, n) )
-
 
653
    PROTO_T ( int s X exp n )
667
(int s, exp n)
654
{
668
{
655
  punner l;
669
  punner l;
656
  l.e = n;
670
  l.e = n;
657
  outs(".set ");
671
  outs(".set ");
658
  outs(local_prefix);
672
  outs(local_prefix);
659
  outs("O");
673
  outs("O");
660
  outn((long)l.i);		/* produce an identifying number */
674
  outn((long)l.i);		/* produce an identifying number */
661
  outs(",");
675
  outs(",");
662
  if (s<4)
676
  if (s<4)
663
   {
677
   {
664
    outn((long)-s/8);
678
    outn((long) -s/8);
665
    outs("-");
679
    outs("-");
666
    outs(local_prefix);
680
    outs(local_prefix);
667
    outs ("disp");
681
    outs("disp");
668
    outn ((long)crt_proc_id);
682
    outn((long)crt_proc_id);
669
   }
683
   }
670
  else
684
  else
671
   outn((long)s/8);
685
   outn((long)s/8);
672
  outnl();
686
  outnl();
673
}
687
}
674
 
688
 
675
void envoff_operand
689
void envoff_operand
676
    PROTO_N ( (e, off) )
-
 
677
    PROTO_T ( exp e X int off )
690
(exp e, int off)
678
{
691
{
679
  punner l;
692
  punner l;
680
  l.e = e;
693
  l.e = e;
681
  if (off != 0)
694
  if (off != 0)
682
   {
695
   {
Line 688... Line 701...
688
  outn((long)l.i);		/* produce an identifying number */
701
  outn((long)l.i);		/* produce an identifying number */
689
  return;
702
  return;
690
}
703
}
691
 
704
 
692
void envsize_operand
705
void envsize_operand
693
    PROTO_N ( (e) )
-
 
694
    PROTO_T ( exp e )
706
(exp e)
695
{
707
{
696
  dec * et = brog(e);
708
  dec * et = brog(e);
697
  outs (local_prefix);
709
  outs(local_prefix);
698
  outs ("ESZ");
710
  outs("ESZ");
699
  outs (et -> dec_u.dec_val.dec_id);
711
  outs(et -> dec_u.dec_val.dec_id);
700
  return;
712
  return;
701
}
713
}
702
 
714
 
703
/* 80386 instruction with no operands */
715
/* 80386 instruction with no operands */
704
void ins0
716
void ins0
705
    PROTO_N ( (i) )
-
 
706
    PROTO_T ( char *i )
717
(char *i)
707
{
718
{
708
  outs (margin);
719
  outs(margin);
709
  outs (i);
720
  outs(i);
710
  outnl ();
721
  outnl();
711
  return;
722
  return;
712
}
723
}
713
 
724
 
714
/* one operand */
725
/* one operand */
715
void ins1
726
void ins1
716
    PROTO_N ( (i, le1, a1) )
-
 
717
    PROTO_T ( char *i X int le1 X where a1 )
727
(char *i, int le1, where a1)
718
{
728
{
719
  outs (margin);
729
  outs(margin);
720
  outs (i);
730
  outs(i);
721
  outs (spx);
731
  outs(spx);
722
  operand (le1, a1, 1, 0);
732
  operand(le1, a1, 1, 0);
723
  outnl ();
733
  outnl();
724
  return;
734
  return;
725
}
735
}
726
 
736
 
727
/* one operand, which is indirect */
737
/* one operand, which is indirect */
728
void ins1ind
738
void ins1ind
729
    PROTO_N ( (i, le1, a1) )
-
 
730
    PROTO_T ( char *i X int le1 X where a1 )
739
(char *i, int le1, where a1)
731
{
740
{
732
  outs (margin);
741
  outs(margin);
733
  outs (i);
742
  outs(i);
734
  outs (spx);
743
  outs(spx);
735
  outs ("*");
744
  outs("*");
736
  operand (le1, a1, 1, 0);
745
  operand(le1, a1, 1, 0);
737
  outnl ();
746
  outnl();
738
  return;
747
  return;
739
}
748
}
740
 
749
 
741
/* one operand, which is immediate */
750
/* one operand, which is immediate */
742
void ins1lit
751
void ins1lit
743
    PROTO_N ( (i, le1, a1) )
-
 
744
    PROTO_T ( char *i X int le1 X where a1 )
752
(char *i, int le1, where a1)
745
{
753
{
746
  outs (margin);
754
  outs(margin);
747
  outs (i);
755
  outs(i);
748
  outs (spx);
756
  outs(spx);
749
  operand (le1, a1, 1, 1);
757
  operand(le1, a1, 1, 1);
750
  outnl ();
758
  outnl();
751
  return;
759
  return;
752
}
760
}
753
 
761
 
754
/* two operands */
762
/* two operands */
755
void ins2
763
void ins2
756
    PROTO_N ( (i, le1, le2, a1, a2) )
-
 
757
    PROTO_T ( char *i X int le1 X int le2 X where a1 X where a2 )
764
(char *i, int le1, int le2, where a1, where a2)
758
{
765
{
759
  outs (margin);
766
  outs(margin);
760
  outs (i);
767
  outs(i);
761
  outs (spx);
768
  outs(spx);
762
  operand (le1, a1, 1, 0);
769
  operand(le1, a1, 1, 0);
763
  outs (sep);
770
  outs(sep);
764
  operand (le2, a2, 1, 0);
771
  operand(le2, a2, 1, 0);
765
  outnl ();
772
  outnl();
766
  return;
773
  return;
767
}
774
}
768
 
775
 
769
/* three operands */
776
/* three operands */
770
void ins3
777
void ins3
771
    PROTO_N ( (i, le1, le2, le3, a1, a2, a3) )
-
 
772
    PROTO_T ( char *i X int le1 X int le2 X int le3 X where a1 X where a2 X where a3 )
778
(char *i, int le1, int le2, int le3, where a1, where a2, where a3)
773
{
779
{
774
  outs (margin);
780
  outs(margin);
775
  outs (i);
781
  outs(i);
776
  outs (spx);
782
  outs(spx);
777
  operand (le1, a1, 1, 0);
783
  operand(le1, a1, 1, 0);
778
  outs (sep);
784
  outs(sep);
779
  operand (le2, a2, 1, 0);
785
  operand(le2, a2, 1, 0);
780
  outs (sep);
786
  outs(sep);
781
  operand (le3, a3, 1, 0);
787
  operand(le3, a3, 1, 0);
782
  outnl ();
788
  outnl();
783
  return;
789
  return;
784
}
790
}
785
 
791
 
786
 
792
 
787
void simplest_set_lab
793
void simplest_set_lab
788
    PROTO_N ( (labno) )
-
 
789
    PROTO_T ( int labno )
794
(int labno)
790
{
795
{
791
  outs(local_prefix);
796
  outs(local_prefix);
792
  outn ((long)labno);
797
  outn((long)labno);
793
  outs (":");
798
  outs(":");
794
  outnl ();
799
  outnl();
795
}
800
}
796
 
801
 
797
 
802
 
798
void simple_set_label
803
void simple_set_label
799
    PROTO_N ( (labno) )
-
 
800
    PROTO_T ( int labno )
804
(int labno)
801
{
805
{
802
#ifdef CHECKIMPROVE
806
#ifdef CHECKIMPROVE
803
  if (labno == last_jump_label)
807
  if (labno == last_jump_label)
804
    failer("redundant jump");
808
    failer("redundant jump");
805
#endif
809
#endif
806
#ifndef NEWDIAGS
810
#ifndef NEWDIAGS
807
  int   st = 0;
811
  int   st = 0;
808
  if (!diagnose && labno == last_jump_label) {
812
  if (!diagnose && labno == last_jump_label) {
809
    st = fseek (fpout, last_jump_pos, 0);
813
    st = fseek(fpout, last_jump_pos, 0);
810
  };
814
  };
811
  /* eliminate immediately previous jump to this label */
815
  /* eliminate immediately previous jump to this label */
812
  if (st == -1) {
816
  if (st == -1) {
813
    failer (SEEK_FAILURE);
817
    failer(SEEK_FAILURE);
814
    exit(EXIT_FAILURE);
818
    exit(EXIT_FAILURE);
815
  };
819
  };
816
#endif
820
#endif
817
 
821
 
818
  cond1_set = 0;
822
  cond1_set = 0;
819
  cond2_set = 0;
823
  cond2_set = 0;
820
  outs(local_prefix);
824
  outs(local_prefix);
821
  outn ((long)labno);		/* the label no is held in the ptr field
825
  outn ((long)labno);		/* the label no is held in the ptr field
822
				*/
826
				*/
823
  outs (":");
827
  outs(":");
824
  outnl ();
828
  outnl();
825
/* Removed for experiments: improves compress?
829
/* Removed for experiments: improves compress?
826
  keep_short = 1;
830
  keep_short = 1;
827
*/
831
*/
828
  return;
832
  return;
829
}
833
}
830
 
834
 
831
/* set label described by the jump record jr */
835
/* set label described by the jump record jr */
832
void set_label
836
void set_label
833
    PROTO_N ( (jr) )
-
 
834
    PROTO_T ( exp jr )
837
(exp jr)
835
{
838
{
836
  simple_set_label (ptno (jr));
839
  simple_set_label(ptno(jr));
837
}
840
}
838
 
841
 
839
/*  jump record: exp
842
/*  jump record: exp
840
    pt - label;
843
    pt - label;
841
    last - forward;
844
    last - forward;
842
    son - stack_dec;
845
    son - stack_dec;
843
    prop - floating stack position
846
    prop - floating stack position
844
*/
847
*/
845
 
848
 
846
void discard_fstack
849
void discard_fstack
847
    PROTO_Z ()
850
(void)
848
{
851
{
849
  outs (" fstp %st(0)");
852
  outs(" fstp %st(0)");
850
  outnl ();
853
  outnl();
851
  pop_fl;
854
  pop_fl;
852
  return;
855
  return;
853
}
856
}
854
 
857
 
855
void discard_st1
858
void discard_st1
856
    PROTO_Z ()
859
(void)
857
{
860
{
858
  outs (" fstp %st(1)");
861
  outs(" fstp %st(1)");
859
  outnl ();
862
  outnl();
860
  pop_fl;
863
  pop_fl;
861
}
864
}
862
 
865
 
863
 
866
 
864
/* output a jump to the label described by
867
/* output a jump to the label described by
865
   jump record jr */
868
   jump record jr */
866
void jump
869
void jump
867
    PROTO_N ( (jr, with_fl_reg) )
-
 
868
    PROTO_T ( exp jr X int with_fl_reg )
870
(exp jr, int with_fl_reg)
869
{
871
{
870
  int  fs_dest = (int)fstack_pos_of (jr);
872
  int  fs_dest = (int)fstack_pos_of(jr);
871
  int  good_fs = fstack_pos;
873
  int  good_fs = fstack_pos;
872
  int  good_sd = stack_dec;
874
  int  good_sd = stack_dec;
873
  if (fs_dest < first_fl_reg)
875
  if (fs_dest < first_fl_reg)
874
    failer (FSTACK_UNSET);
876
    failer(FSTACK_UNSET);
875
  if (with_fl_reg) {		/* jumping with a floating value */
877
  if (with_fl_reg) {		/* jumping with a floating value */
876
    /* clear off any unwanted stack registers */
878
    /* clear off any unwanted stack registers */
877
    while (fstack_pos > (fs_dest + 1))
879
    while (fstack_pos > (fs_dest + 1))
878
      discard_st1 ();
880
      discard_st1();
879
    fstack_pos = good_fs - 1;
881
    fstack_pos = good_fs - 1;
880
  }
882
  }
881
  else {
883
  else {
882
    /* clear off any unwanted stack registers */
884
    /* clear off any unwanted stack registers */
883
    while (fstack_pos > fs_dest)
885
    while (fstack_pos > fs_dest)
884
      discard_fstack ();
886
      discard_fstack();
885
    fstack_pos = good_fs;
887
    fstack_pos = good_fs;
886
  };
888
  };
887
 
889
 
888
  if (sonno(jr) > stack_dec) {
890
  if (sonno(jr) > stack_dec) {
889
    add(slongsh, mw (zeroe, (sonno(jr)-stack_dec) / 8), sp, sp);
891
    add(slongsh, mw(zeroe,(sonno(jr) -stack_dec) / 8), sp, sp);
890
    stack_dec = sonno(jr);
892
    stack_dec = sonno(jr);
891
  }
893
  }
892
 
894
 
893
  reset_fpucon();
895
  reset_fpucon();
894
  stack_dec = good_sd;
896
  stack_dec = good_sd;
895
 
897
 
896
#ifndef NEWDIAGS
898
#ifndef NEWDIAGS
897
  if (flush_before_tell)
899
  if (flush_before_tell)
898
    IGNORE fflush(fpout);
900
    IGNORE fflush(fpout);
899
  last_jump_pos = ftell (fpout);
901
  last_jump_pos = ftell(fpout);
900
#endif
902
#endif
901
  outs (margin);
903
  outs(margin);
902
  outs (jmp);
904
  outs(jmp);
903
  outs (spx);
905
  outs(spx);
904
  outs(local_prefix);
906
  outs(local_prefix);
905
  outn ((long)ptno (jr));
907
  outn((long)ptno(jr));
906
  outnl ();
908
  outnl();
907
  last_jump_label = ptno (jr);
909
  last_jump_label = ptno(jr);
908
  return;
910
  return;
909
}
911
}
910
 
912
 
911
static char* xse = "<=0";	/* no corresponding jump instruction */
913
static char* xse = "<=0";	/* no corresponding jump instruction */
912
static char* xnse = ">0";
914
static char* xnse = ">0";
Line 914... Line 916...
914
 
916
 
915
/* output code for a branch instruction
917
/* output code for a branch instruction
916
   determined by test_no. The test is
918
   determined by test_no. The test is
917
   signed if sg is true */
919
   signed if sg is true */
918
static char *out_branch
920
static char *out_branch
919
    PROTO_N ( (sg, test_no, shnm) )
-
 
920
    PROTO_T ( int sg X int test_no X int shnm )
921
(int sg, int test_no, int shnm)
921
{
922
{
922
  if (shnm >= shrealhd && shnm <= doublehd) {
923
  if (shnm >= shrealhd && shnm <= doublehd) {
923
    switch (test_no) {
924
    switch (test_no) {
924
      case 1:
925
      case 1:
925
	return (jne);
926
	return(jne);
926
 
927
 
927
      case 2:
928
      case 2:
928
	return (jne);
929
	return(jne);
929
 
930
 
930
      case 3:
931
      case 3:
931
	return (jpe);
932
	return(jpe);
932
 
933
 
933
      case 4:
934
      case 4:
934
	return (jpe);
935
	return(jpe);
935
 
936
 
936
      case 5:
937
      case 5:
937
	return (jpe);
938
	return(jpe);
938
 
939
 
939
      case 6:
940
      case 6:
940
	return (jpo);
-
 
941
 
-
 
942
      case 7:
-
 
943
	return (jpo);
941
	return(jpo);
944
 
942
 
945
      case 8:
943
      case 7:
946
	return (jpo);
944
	return(jpo);
947
 
945
 
948
      case 9:
946
      case 8:
949
	return (je);
947
	return(jpo);
950
 
948
 
951
      case 10:
949
      case 9:
952
	return (je);
950
	return(je);
953
 
951
 
-
 
952
      case 10:
-
 
953
	return(je);
-
 
954
 
954
      case 11:
955
      case 11:
955
	return (jne);
956
	return(jne);
956
 
957
 
957
      case 12:
958
      case 12:
958
	return (je);
959
	return(je);
959
 
960
 
960
      case 13:
961
      case 13:
961
	return (jne);
962
	return(jne);
962
 
963
 
963
      case 14:
964
      case 14:
964
	return (je);
965
	return(je);
965
 
966
 
966
      default:
967
      default:
967
	failer (BAD_TESTNO);
968
	failer(BAD_TESTNO);
968
    };
969
    };
969
  };
970
  };
970
 
971
 
971
  if (sg) {
972
  if (sg) {
972
    switch (test_no) {
973
    switch (test_no) {
973
      case 1:
974
      case 1:
974
	return (sg<0 ? xse : jle);
975
	return(sg<0 ? xse : jle);
975
      case 2:
976
      case 2:
976
	return (sg<0 ? js : jl);
977
	return(sg<0 ? js : jl);
977
 
978
 
978
      case 3:
979
      case 3:
979
	return (sg<0 ? jns : jge);
980
	return(sg<0 ? jns : jge);
980
 
981
 
981
      case 4:
982
      case 4:
982
	return (sg<0 ? xnse : jg);
983
	return(sg<0 ? xnse : jg);
983
 
984
 
984
      case 5:
985
      case 5:
985
	return (jne);
986
	return(jne);
986
 
987
 
987
      case 6:
988
      case 6:
988
	return (je);
989
	return(je);
989
 
990
 
990
      default:
991
      default:
991
	failer (BAD_TESTNO);
992
	failer(BAD_TESTNO);
992
    };
993
    };
993
  }
994
  }
994
  else {
995
  else {
995
    switch (test_no) {
996
    switch (test_no) {
996
      case 1:
997
      case 1:
997
	return (jbe);
998
	return(jbe);
998
 
-
 
999
      case 2:
-
 
1000
	return (jb);
-
 
1001
 
999
 
-
 
1000
      case 2:
-
 
1001
	return(jb);
-
 
1002
 
1002
      case 3:
1003
      case 3:
1003
	return (jae);
1004
	return(jae);
1004
 
1005
 
1005
      case 4:
1006
      case 4:
1006
	return (ja);
1007
	return(ja);
1007
 
1008
 
1008
      case 5:
1009
      case 5:
1009
	return (jne);
1010
	return(jne);
1010
 
1011
 
1011
      case 6:
1012
      case 6:
1012
	return (je);
1013
	return(je);
1013
 
1014
 
1014
      default:
1015
      default:
1015
	failer (BAD_TESTNO);
1016
	failer(BAD_TESTNO);
1016
    };
1017
    };
1017
  };
1018
  };
1018
  return ((char *) 0);
1019
  return((char *)0);
1019
}
1020
}
1020
 
1021
 
1021
void simple_branch
1022
void simple_branch
1022
    PROTO_N ( (j, labno) )
-
 
1023
    PROTO_T ( char *j X int labno )
1023
(char *j, int labno)
1024
{
1024
{
1025
  outs (margin);
1025
  outs(margin);
1026
  outs (j);
1026
  outs(j);
1027
  outs (spx);
1027
  outs(spx);
1028
  outs(local_prefix);
1028
  outs(local_prefix);
1029
  outn ((long)labno);
1029
  outn((long)labno);
1030
  outnl ();
1030
  outnl();
1031
 
1031
 
1032
}
1032
}
1033
 
1033
 
1034
 
1034
 
1035
/* output conditional jump to jr. testno
1035
/* output conditional jump to jr. testno
1036
   specifies kind of test. sg is 1 if
1036
   specifies kind of test. sg is 1 if
1037
   signed arithmetic, 0 unsigned, -1 if
1037
   signed arithmetic, 0 unsigned, -1 if
1038
   signed vs zero (ignoring overflow).
1038
   signed vs zero (ignoring overflow).
1039
   shnm name of shape */
1039
   shnm name of shape */
1040
void branch
1040
void branch
1041
    PROTO_N ( (test_no, jr, sg, shnm) )
-
 
1042
    PROTO_T ( int test_no X exp jr X int sg X int shnm )
1041
(int test_no, exp jr, int sg, int shnm)
1043
{
1042
{
1044
  int  fs_dest = (int)fstack_pos_of (jr);
1043
  int  fs_dest = (int)fstack_pos_of(jr);
1045
  int  good_fs = fstack_pos;
1044
  int  good_fs = fstack_pos;
1046
  int  good_fpucon = fpucon;
1045
  int  good_fpucon = fpucon;
1047
  if (fs_dest < first_fl_reg)
1046
  if (fs_dest < first_fl_reg)
1048
    failer (FSTACK_UNSET);
1047
    failer(FSTACK_UNSET);
1049
  if (fstack_pos > fs_dest || sonno(jr) != stack_dec || fpucon != normal_fpucon
1048
  if (fstack_pos > fs_dest || sonno(jr)!= stack_dec || fpucon != normal_fpucon
1050
	|| cmp_64hilab >= 0) {
1049
	|| cmp_64hilab >= 0) {
1051
	/* floating point stack or call stack need attention */
1050
	/* floating point stack or call stack need attention */
1052
    int  nl = next_lab ();
1051
    int  nl = next_lab();
1053
    int inv_test_no = (flpt_always_comparable ||
1052
    int inv_test_no = (flpt_always_comparable ||
1054
			 (shnm < shrealhd || shnm > doublehd))
1053
			(shnm < shrealhd || shnm > doublehd))
1055
				? (int)int_inverse_ntest[test_no]
1054
				?(int)int_inverse_ntest[test_no]
1056
				: (int)real_inverse_ntest[test_no];
1055
				:(int)real_inverse_ntest[test_no];
1057
 
1056
 
1058
    char* cj = out_branch ((cmp_64hilab >= 0 ? 0 : sg), inv_test_no, shnm);
1057
    char* cj = out_branch((cmp_64hilab >= 0 ? 0 : sg), inv_test_no, shnm);
1059
    if (*cj == 'j') {
1058
    if (*cj == 'j') {
1060
      simple_branch (cj, nl);
1059
      simple_branch(cj, nl);
1061
    }
1060
    }
1062
    else	/* compare with zero, ignoring overflow */
1061
    else	/* compare with zero, ignoring overflow */
1063
    if (*cj == '>') {
1062
    if (*cj == '>') {
1064
      int nl1 = next_lab ();
1063
      int nl1 = next_lab();
1065
      simple_branch (js, nl1);
1064
      simple_branch(js, nl1);
1066
      simple_branch (jne, nl);
1065
      simple_branch(jne, nl);
1067
      simplest_set_lab (nl1);
1066
      simplest_set_lab(nl1);
1068
    }
1067
    }
1069
    else {
1068
    else {
1070
      simple_branch (js, nl);
1069
      simple_branch(js, nl);
1071
      simple_branch (je, nl);
1070
      simple_branch(je, nl);
1072
    }
1071
    }
1073
 
1072
 
1074
    if (cmp_64hilab >= 0) {
1073
    if (cmp_64hilab >= 0) {
1075
      int nl2 = ptno (jr);
1074
      int nl2 = ptno(jr);
1076
      if (shnm != s64hd)
1075
      if (shnm != s64hd)
1077
	failer ("uncompleted 64-bit comparison");
1076
	failer("uncompleted 64-bit comparison");
1078
      if (fstack_pos > fs_dest || sonno(jr) != stack_dec || fpucon != normal_fpucon) {
1077
      if (fstack_pos > fs_dest || sonno(jr)!= stack_dec || fpucon != normal_fpucon) {
1079
	nl2 = next_lab ();
1078
	nl2 = next_lab();
1080
	simplest_set_lab (nl2);
1079
	simplest_set_lab(nl2);
1081
      }
1080
      }
1082
      jump (jr, 0);
1081
      jump(jr, 0);
1083
      simplest_set_lab (cmp_64hilab);
1082
      simplest_set_lab(cmp_64hilab);
1084
      simple_branch (out_branch (1, test_no, shnm), nl2);
1083
      simple_branch(out_branch(1, test_no, shnm), nl2);
1085
      cmp_64hilab = -1;
1084
      cmp_64hilab = -1;
1086
    }
1085
    }
1087
    else
1086
    else
1088
      jump (jr, 0);
1087
      jump(jr, 0);
1089
 
1088
 
1090
    fstack_pos = good_fs;
1089
    fstack_pos = good_fs;
1091
    fpucon = good_fpucon;
1090
    fpucon = good_fpucon;
1092
    simplest_set_lab (nl);
1091
    simplest_set_lab(nl);
1093
    return;
1092
    return;
1094
  };
1093
  };
1095
 
1094
 
1096
  {
1095
  {
1097
    char* cj = out_branch (sg, test_no, shnm);
1096
    char* cj = out_branch(sg, test_no, shnm);
1098
    if (*cj == 'j') {
1097
    if (*cj == 'j') {
1099
      simple_branch (cj, ptno (jr));
1098
      simple_branch(cj, ptno(jr));
1100
    }
1099
    }
1101
    else	/* compare with zero, ignoring overflow */
1100
    else	/* compare with zero, ignoring overflow */
1102
    if (*cj == '>') {
1101
    if (*cj == '>') {
1103
      int nl1 = next_lab ();
1102
      int nl1 = next_lab();
1104
      simple_branch (js, nl1);
1103
      simple_branch(js, nl1);
1105
      simple_branch (jne, ptno (jr));
1104
      simple_branch(jne, ptno(jr));
1106
      simplest_set_lab (nl1);
1105
      simplest_set_lab(nl1);
1107
    }
1106
    }
1108
    else {
1107
    else {
1109
      simple_branch (js, ptno (jr));
1108
      simple_branch(js, ptno(jr));
1110
      simple_branch (je, ptno (jr));
1109
      simple_branch(je, ptno(jr));
1111
    }
1110
    }
1112
  }
1111
  }
1113
  return;
1112
  return;
1114
}
1113
}
1115
 
1114
 
1116
void setcc
1115
void setcc
1117
    PROTO_N ( (test_no, sg, shnm) )
-
 
1118
    PROTO_T ( int test_no X int sg X int shnm )
1116
(int test_no, int sg, int shnm)
1119
{
1117
{
1120
  char * b;
1118
  char * b;
1121
  if (cmp_64hilab >= 0) {
1119
  if (cmp_64hilab >= 0) {
1122
    int chl = cmp_64hilab;
1120
    int chl = cmp_64hilab;
1123
    int nl = next_lab ();
1121
    int nl = next_lab();
1124
    if (shnm != s64hd)
1122
    if (shnm != s64hd)
1125
      failer ("uncompleted 64-bit comparison");
1123
      failer("uncompleted 64-bit comparison");
1126
    cmp_64hilab = -1;
1124
    cmp_64hilab = -1;
1127
    setcc (test_no, 0, ulonghd);
1125
    setcc(test_no, 0, ulonghd);
1128
    simple_branch (jmp, nl);
1126
    simple_branch(jmp, nl);
1129
    simplest_set_lab (chl);
1127
    simplest_set_lab(chl);
1130
    setcc (test_no, sg, slonghd);
1128
    setcc(test_no, sg, slonghd);
1131
    simplest_set_lab (nl);
1129
    simplest_set_lab(nl);
1132
  }
1130
  }
1133
 
1131
 
1134
  b = out_branch (sg, test_no, shnm);
1132
  b = out_branch(sg, test_no, shnm);
1135
  if (*b != 'j')
1133
  if (*b != 'j')
1136
    failer(NO_SETCC);
1134
    failer(NO_SETCC);
1137
  outs(margin);
1135
  outs(margin);
1138
  outs("set");
1136
  outs("set");
1139
  outs(&b[1]);
1137
  outs(&b[1]);
Line 1144... Line 1142...
1144
}
1142
}
1145
 
1143
 
1146
/* output conditional jump to jr if overflow
1144
/* output conditional jump to jr if overflow
1147
   sg is 1 if signed arithmetic, 0 unsigned */
1145
   sg is 1 if signed arithmetic, 0 unsigned */
1148
void jmp_overflow
1146
void jmp_overflow
1149
    PROTO_N ( (jr, sg, inv) )
-
 
1150
    PROTO_T ( exp jr X int sg X int inv )
1147
(exp jr, int sg, int inv)
1151
{
1148
{
1152
  int  fs_dest = (int)fstack_pos_of (jr);
1149
  int  fs_dest = (int)fstack_pos_of(jr);
1153
  int  good_fs = fstack_pos;
1150
  int  good_fs = fstack_pos;
1154
  int  good_fpucon = fpucon;
1151
  int  good_fpucon = fpucon;
1155
  if (fs_dest < first_fl_reg)
1152
  if (fs_dest < first_fl_reg)
1156
    failer (FSTACK_UNSET);
1153
    failer(FSTACK_UNSET);
1157
  if (fstack_pos > fs_dest || sonno(jr) != stack_dec || fpucon != normal_fpucon) {
1154
  if (fstack_pos > fs_dest || sonno(jr)!= stack_dec || fpucon != normal_fpucon) {
1158
	/* floating point stack or call stack need attention */
1155
	/* floating point stack or call stack need attention */
1159
    int  nl = next_lab ();
1156
    int  nl = next_lab();
1160
    if (sg)
1157
    if (sg)
1161
      simple_branch(jno, nl);
1158
      simple_branch(jno, nl);
1162
    else
1159
    else
1163
      simple_branch((inv ? jb : jae), nl);
1160
      simple_branch((inv ? jb : jae), nl);
1164
    jump (jr, 0);
1161
    jump(jr, 0);
1165
    fstack_pos = good_fs;
1162
    fstack_pos = good_fs;
1166
    fpucon = good_fpucon;
1163
    fpucon = good_fpucon;
1167
    simplest_set_lab (nl);
1164
    simplest_set_lab(nl);
1168
    return;
1165
    return;
1169
  };
1166
  };
1170
  if (sg)
1167
  if (sg)
1171
    simple_branch(jo, ptno(jr));
1168
    simple_branch(jo, ptno(jr));
1172
  else
1169
  else
Line 1175... Line 1172...
1175
}
1172
}
1176
 
1173
 
1177
 
1174
 
1178
/* software interrupt */
1175
/* software interrupt */
1179
void trap_ins
1176
void trap_ins
1180
    PROTO_N ( (s) )
-
 
1181
    PROTO_T ( int s )
1177
(int s)
1182
{
1178
{
1183
#ifndef AVOID_INTOV
1179
#ifndef AVOID_INTOV
1184
  if (s == f_overflow) {
1180
  if (s == f_overflow) {
1185
    ins0 ("int $4");	/* numeric interrupt */
1181
    ins0 ("int $4");	/* numeric interrupt */
1186
    return;
1182
    return;
Line 1192... Line 1188...
1192
    return;
1188
    return;
1193
  }
1189
  }
1194
#endif
1190
#endif
1195
#endif
1191
#endif
1196
  if (cont_err_handler == nilexp) {
1192
  if (cont_err_handler == nilexp) {
1197
    cont_err_handler = make_extn ("__trans386_errhandler", f_proc, 1);
1193
    cont_err_handler = make_extn("__trans386_errhandler", f_proc, 1);
1198
    if (!PIC_code)
1194
    if (!PIC_code)
1199
      cont_err_handler = getexp (f_proc, nilexp, 1, cont_err_handler, nilexp, 0, 0, cont_tag);
1195
      cont_err_handler = getexp(f_proc, nilexp, 1, cont_err_handler, nilexp, 0, 0, cont_tag);
1200
  }
1196
  }
1201
  ins1 (pushl, 32, mw (zeroe, s));
1197
  ins1(pushl, 32, mw(zeroe, s));
1202
#ifdef NEWDWARF
1198
#ifdef NEWDWARF
1203
  if (diagnose && dwarf2 && no_frame)
1199
  if (diagnose && dwarf2 && no_frame)
1204
    dw2_track_push();
1200
    dw2_track_push();
1205
#endif
1201
#endif
1206
  ins2 (movl, 32, 32, mw(cont_err_handler, 0), reg0);
1202
  ins2(movl, 32, 32, mw(cont_err_handler, 0), reg0);
1207
  if (PIC_code)
1203
  if (PIC_code)
1208
    ins1ind (call, 32, ind_reg0);
1204
    ins1ind(call, 32, ind_reg0);
1209
  else
1205
  else
1210
    ins1ind (call, 32, reg0);
1206
    ins1ind(call, 32, reg0);
1211
  return;
1207
  return;
1212
}
1208
}
1213
 
1209
 
1214
 
1210
 
1215
/* output software interrupt if overflow
1211
/* output software interrupt if overflow
1216
   sg is 1 if signed arithmetic, 0 unsigned */
1212
   sg is 1 if signed arithmetic, 0 unsigned */
1217
void trap_overflow
1213
void trap_overflow
1218
    PROTO_N ( (sg, inv) )
-
 
1219
    PROTO_T ( int sg X int inv )
1214
(int sg, int inv)
1220
{
1215
{
1221
#ifdef AVOID_INTOV
1216
#ifdef AVOID_INTOV
1222
    int nl = next_lab ();
1217
    int nl = next_lab();
1223
    if (sg)
1218
    if (sg)
1224
      simple_branch(jno, nl);
1219
      simple_branch(jno, nl);
1225
    else
1220
    else
1226
      simple_branch((inv ? jb : jae), nl);
1221
      simple_branch((inv ? jb : jae), nl);
1227
    trap_ins(f_overflow);
1222
    trap_ins(f_overflow);
1228
    simplest_set_lab (nl);
1223
    simplest_set_lab(nl);
1229
#else
1224
#else
1230
  if (sg)
1225
  if (sg)
1231
    ins0(into);
1226
    ins0(into);
1232
  else {
1227
  else {
1233
    int nl = next_lab ();
1228
    int nl = next_lab();
1234
    simple_branch((inv ? jb : jae), nl);
1229
    simple_branch((inv ? jb : jae), nl);
1235
    trap_ins(f_overflow);
1230
    trap_ins(f_overflow);
1236
    simplest_set_lab (nl);
1231
    simplest_set_lab(nl);
1237
  }
1232
  }
1238
#endif
1233
#endif
1239
  return;
1234
  return;
1240
}
1235
}
1241
 
1236
 
1242
 
1237
 
1243
/* conditional software interrupt
1238
/* conditional software interrupt
1244
   sg is 1 if signed arithmetic
1239
   sg is 1 if signed arithmetic
1245
   shnm name of shape */
1240
   shnm name of shape */
1246
void test_trap
1241
void test_trap
1247
    PROTO_N ( (test_no, sg, shnm) )
-
 
1248
    PROTO_T ( int test_no X int sg X int shnm )
1242
(int test_no, int sg, int shnm)
1249
{
1243
{
1250
  int nl = next_lab ();
1244
  int nl = next_lab();
1251
  int inv_test_no = (flpt_always_comparable ||
1245
  int inv_test_no = (flpt_always_comparable ||
1252
			 (shnm < shrealhd || shnm > doublehd))
1246
			(shnm < shrealhd || shnm > doublehd))
1253
				? (int)int_inverse_ntest[test_no]
1247
				?(int)int_inverse_ntest[test_no]
1254
				: (int)real_inverse_ntest[test_no];
1248
				:(int)real_inverse_ntest[test_no];
1255
  simple_branch (out_branch (sg, inv_test_no, shnm), nl);
1249
  simple_branch(out_branch(sg, inv_test_no, shnm), nl);
1256
  trap_ins(f_overflow);
1250
  trap_ins(f_overflow);
1257
  simplest_set_lab (nl);
1251
  simplest_set_lab(nl);
1258
  return;
1252
  return;
1259
}
1253
}
1260
 
1254
 
1261
 
1255
 
1262
 
1256
 
1263
/* special output for doing multiply by
1257
/* special output for doing multiply by
1264
   using index instructions */
1258
   using index instructions */
1265
void mult_op
1259
void mult_op
1266
    PROTO_N ( (inc, rmain, rind, sc, dest) )
-
 
1267
    PROTO_T ( int inc X where rmain X where rind X int sc X where dest )
1260
(int inc, where rmain, where rind, int sc, where dest)
1268
{
1261
{
1269
  outs (margin);
1262
  outs(margin);
1270
  outs ("leal");
1263
  outs("leal");
1271
  outs (spx);
1264
  outs(spx);
1272
  if (inc != 0)
1265
  if (inc != 0)
1273
    outn ((long)inc);
1266
    outn((long)inc);
1274
  outs ("(");
1267
  outs("(");
1275
  if (name (rmain.where_exp) != val_tag ||
1268
  if (name(rmain.where_exp)!= val_tag ||
1276
      (no (rmain.where_exp) + rmain.where_off) != 0)
1269
     (no(rmain.where_exp) + rmain.where_off)!= 0)
1277
    operand (32, rmain, 1, 0);
1270
    operand(32, rmain, 1, 0);
1278
  outs (",");
1271
  outs(",");
1279
  operand (32, rind, 1, 0);
1272
  operand(32, rind, 1, 0);
1280
  if (sc != 1) {
1273
  if (sc != 1) {
1281
    outs (",");
1274
    outs(",");
1282
    outn ((long)sc);
1275
    outn((long)sc);
1283
  };
1276
  };
1284
  outs ("),");
1277
  outs("),");
1285
 
1278
 
1286
  if (inmem (dest)) {
1279
  if (inmem(dest)) {
1287
    operand (32, reg0, 1, 0);
1280
    operand(32, reg0, 1, 0);
1288
    outnl ();
1281
    outnl();
1289
    invalidate_dest (reg0);
1282
    invalidate_dest(reg0);
1290
    end_contop ();
1283
    end_contop();
1291
    move (slongsh, reg0, dest);
1284
    move(slongsh, reg0, dest);
1292
  }
1285
  }
1293
  else {
1286
  else {
1294
    operand (32, dest, 1, 0);
1287
    operand(32, dest, 1, 0);
1295
    outnl ();
1288
    outnl();
1296
    end_contop ();
1289
    end_contop();
1297
  };
1290
  };
1298
  return;
1291
  return;
1299
}
1292
}
1300
 
1293
 
1301
/* output the case switch jump and the jump table */
1294
/* output the case switch jump and the jump table */
1302
void caseins
1295
void caseins
1303
    PROTO_N ( (sz, arg, min, max, v, exhaustive, in_eax, case_exp) )
-
 
1304
    PROTO_T ( int sz X exp arg X int min X int max X int *v X int exhaustive X int in_eax X exp case_exp )
1296
(int sz, exp arg, int min, int max, int *v, int exhaustive, int in_eax, exp case_exp)
1305
{
1297
{
1306
  int tab;
1298
  int tab;
1307
  int absent;
1299
  int absent;
1308
  where a;
1300
  where a;
1309
  int need_label_flag=0;
1301
  int need_label_flag=0;
1310
  exp next= short_next_jump(case_exp);
1302
  exp next= short_next_jump(case_exp);
1311
  if (next != nilexp && name(next)==goto_tag)
1303
  if (next != nilexp && name(next) ==goto_tag)
1312
  {
1304
  {
1313
    exp lab=final_dest(pt(next));
1305
    exp lab=final_dest(pt(next));
1314
    absent=ptno(pt(son(lab)));
1306
    absent=ptno(pt(son(lab)));
1315
  }
1307
  }
1316
  else
1308
  else
1317
  {
1309
  {
1318
    absent = (exhaustive) ? -1 : next_lab ();
1310
    absent = (exhaustive)? -1 : next_lab();
1319
    need_label_flag=1;
1311
    need_label_flag=1;
1320
  }
1312
  }
1321
 
1313
 
1322
  tab = next_lab ();
1314
  tab = next_lab();
1323
  a = mw (arg, 0);
1315
  a = mw(arg, 0);
1324
 
1316
 
1325
  if (inmem (mw (arg, 0)) || sz != 32) {
1317
  if (inmem(mw(arg, 0)) || sz != 32) {
1326
    if (!in_eax)
1318
    if (!in_eax)
1327
      change_var (slongsh, a, reg0);
1319
      change_var(slongsh, a, reg0);
1328
    a = reg0;
1320
    a = reg0;
1329
  }
1321
  }
1330
 
1322
 
1331
  /* the switch jump */
1323
  /* the switch jump */
1332
  out_switch_jump(tab, a, min);
1324
  out_switch_jump(tab, a, min);
Line 1335... Line 1327...
1335
  out_switch_table(tab, min, max, v, absent);
1327
  out_switch_table(tab, min, max, v, absent);
1336
 
1328
 
1337
  if (!exhaustive && need_label_flag==1) {
1329
  if (!exhaustive && need_label_flag==1) {
1338
    /*  label for default of switch; continue here */
1330
    /*  label for default of switch; continue here */
1339
    outs(local_prefix);
1331
    outs(local_prefix);
1340
    outn ((long)absent);
1332
    outn((long)absent);
1341
    outs (":");
1333
    outs(":");
1342
    outnl ();
1334
    outnl();
1343
#ifdef NEWDWARF
1335
#ifdef NEWDWARF
1344
    START_BB ();
1336
    START_BB();
1345
#endif
1337
#endif
1346
  };
1338
  };
1347
  return;
1339
  return;
1348
}
1340
}
1349
 
1341
 
1350
 
1342
 
1351
void const_intnl
1343
void const_intnl
1352
    PROTO_N ( (addr, lab, off) )
-
 
1353
    PROTO_T ( int addr X int lab X int off )
1344
(int addr, int lab, int off)
1354
{
1345
{
1355
  if (PIC_code)
1346
  if (PIC_code)
1356
   {
1347
   {
1357
    outs(local_prefix);
1348
    outs(local_prefix);
1358
    outn ((long)lab);
1349
    outn((long)lab);
1359
    outs("@GOTOFF");
1350
    outs("@GOTOFF");
1360
    if (off != 0) {
1351
    if (off != 0) {
1361
      outs ("+");
1352
      outs("+");
1362
      outn ((long)off / 8);
1353
      outn((long)off / 8);
1363
    };
1354
    };
1364
    outs("(%ebx)");
1355
    outs("(%ebx)");
1365
    return;
1356
    return;
1366
   }
1357
   }
1367
  else
1358
  else
1368
   {
1359
   {
1369
    if (addr)
1360
    if (addr)
1370
      outs ("$");
1361
      outs("$");
1371
    outs(local_prefix);
1362
    outs(local_prefix);
1372
    outn ((long)lab);
1363
    outn((long)lab);
1373
    if (off != 0) {
1364
    if (off != 0) {
1374
      outs ("+");
1365
      outs("+");
1375
      outn ((long)off / 8);
1366
      outn((long)off / 8);
1376
    };
1367
    };
1377
    return;
1368
    return;
1378
  };
1369
  };
1379
}
1370
}
1380
 
1371
 
1381
void load_stack0
1372
void load_stack0
1382
    PROTO_Z ()
1373
(void)
1383
{
1374
{
1384
  outs (" fld %st(0)");
1375
  outs(" fld %st(0)");
1385
  outnl ();
1376
  outnl();
1386
  return;
1377
  return;
1387
}
1378
}
1388
 
1379
 
1389
void outbp
1380
void outbp
1390
    PROTO_Z ()
1381
(void)
1391
{
1382
{
1392
  outs("%ebp");
1383
  outs("%ebp");
1393
}
1384
}
1394
 
1385
 
1395
void set_stack_from_bp
1386
void set_stack_from_bp
1396
    PROTO_Z ()
1387
(void)
1397
{
1388
{
1398
  outs (margin);
1389
  outs(margin);
1399
  outs (leal);
1390
  outs(leal);
1400
  outs (spx);
1391
  outs(spx);
1401
  outn((long)stack_dec/8);
1392
  outn((long)stack_dec/8);
1402
  outs("-");
1393
  outs("-");
1403
  outs(local_prefix);
1394
  outs(local_prefix);
1404
  outs("disp");
1395
  outs("disp");
1405
  outn((long)crt_proc_id);
1396
  outn((long)crt_proc_id);
1406
  outs ("(%ebp)");
1397
  outs("(%ebp)");
1407
  outs (sep);
1398
  outs(sep);
1408
  outs("%esp");
1399
  outs("%esp");
1409
  outnl ();
1400
  outnl();
1410
  return;
1401
  return;
1411
}
1402
}
1412
 
1403
 
1413
void testah
1404
void testah
1414
    PROTO_N ( (mask) )
-
 
1415
    PROTO_T ( int mask )
1405
(int mask)
1416
{
1406
{
1417
  outs(" testb $");
1407
  outs(" testb $");
1418
  outn((long)mask);
1408
  outn((long)mask);
1419
  outs(",%ah");
1409
  outs(",%ah");
1420
  outnl();
1410
  outnl();
1421
  return;
1411
  return;
1422
}
1412
}
1423
 
1413
 
1424
exp make_extn
1414
exp make_extn
1425
    PROTO_N ( (n, s, v) )
-
 
1426
    PROTO_T ( char * n X shape s X int v )
1415
(char * n, shape s, int v)
1427
{
1416
{
1428
  dec * g = (dec *) (xmalloc (sizeof(dec)));
1417
  dec * g = (dec *)(xmalloc(sizeof(dec)));
1429
  exp id = getexp (s, nilexp, 1, nilexp, nilexp, 0, 0, ident_tag);
1418
  exp id = getexp(s, nilexp, 1, nilexp, nilexp, 0, 0, ident_tag);
1430
  exp nme = getexp (s, nilexp, 1, id, nilexp, 0, 0, name_tag);
1419
  exp nme = getexp(s, nilexp, 1, id, nilexp, 0, 0, name_tag);
1431
  setglob (id);
1420
  setglob(id);
1432
  if (v) {
1421
  if (v) {
1433
#if keep_PIC_vars
1422
#if keep_PIC_vars
1434
        setvar(id);
1423
        setvar(id);
1435
#else
1424
#else
1436
        if (PIC_code)
1425
        if (PIC_code)
Line 1439... Line 1428...
1439
          setvar(id);
1428
          setvar(id);
1440
#endif
1429
#endif
1441
  }
1430
  }
1442
  brog(id) = g;
1431
  brog(id) = g;
1443
  if (prefix_length != 0) {
1432
  if (prefix_length != 0) {
1444
    int nl = (int) strlen (n);
1433
    int nl = (int)strlen(n);
1445
    int j;
1434
    int j;
1446
    char * newn = (char *) xcalloc ((nl + prefix_length + 1), sizeof (char));
1435
    char * newn = (char *)xcalloc((nl + prefix_length + 1), sizeof(char));
1447
    for (j = 0; j < prefix_length; ++j)
1436
    for (j = 0; j < prefix_length; ++j)
1448
      newn[j] = name_prefix[j];
1437
      newn[j] = name_prefix[j];
1449
    for (j = 0; j < nl; ++j)
1438
    for (j = 0; j < nl; ++j)
1450
      newn[j+prefix_length] = n[j];
1439
      newn[j+prefix_length] = n[j];
1451
    newn[nl+prefix_length] = 0;
1440
    newn[nl+prefix_length] = 0;
1452
    n = newn;
1441
    n = newn;
1453
  }
1442
  }
1454
  g -> dec_u.dec_val.dec_exp = id;
1443
  g -> dec_u.dec_val.dec_exp = id;
1455
  g -> dec_u.dec_val.dec_id = n;
1444
  g -> dec_u.dec_val.dec_id = n;
1456
  g -> dec_u.dec_val.extnamed = 1;
1445
  g -> dec_u.dec_val.extnamed = 1;
1457
  return (nme);
1446
  return(nme);
1458
}
1447
}
1459
 
1448
 
1460
 
1449
 
1461
 
1450
 
1462
/* shift or rotate 64 bits in reg0/reg1 */
1451
/* shift or rotate 64 bits in reg0/reg1 */
1463
void rotshift64
1452
void rotshift64
1464
    PROTO_N ( (shft, sig, wshift) )
-
 
1465
    PROTO_T ( int shft X int sig X where wshift )
1453
(int shft, int sig, where wshift)
1466
{
1454
{
1467
  if (name(wshift.where_exp) == val_tag) {	/* no of places is constant */
1455
  if (name(wshift.where_exp) == val_tag) {	/* no of places is constant */
1468
    int places = no (wshift.where_exp) + wshift.where_off;
1456
    int places = no(wshift.where_exp) + wshift.where_off;
1469
    if (places >= 32) {
1457
    if (places >= 32) {
1470
      places -= 32;
1458
      places -= 32;
1471
      switch (shft) {
1459
      switch (shft) {
1472
	case 0:
1460
	case 0:
1473
	  if (places)
1461
	  if (places)
1474
	    ins2 (shll, 8, 32, mw(zeroe,places), reg0);
1462
	    ins2(shll, 8, 32, mw(zeroe,places), reg0);
1475
	  move (ulongsh, reg0, reg1);
1463
	  move(ulongsh, reg0, reg1);
1476
	  move (ulongsh, zero, reg0);
1464
	  move(ulongsh, zero, reg0);
1477
	  return;
1465
	  return;
1478
	case 1:
1466
	case 1:
1479
	  move (ulongsh, reg1, reg0);
1467
	  move(ulongsh, reg1, reg0);
1480
	  if (places)
1468
	  if (places)
1481
	    ins2 ((sig ? sarl : shrl), 8, 32, mw(zeroe,places), reg0);
1469
	    ins2((sig ? sarl : shrl), 8, 32, mw(zeroe,places), reg0);
1482
	  if (sig)
1470
	  if (sig)
1483
	    ins2 (sarl, 8, 32, mw(zeroe,31), reg1);
1471
	    ins2(sarl, 8, 32, mw(zeroe,31), reg1);
1484
	  else
1472
	  else
1485
	    move (ulongsh, zero, reg1);
1473
	    move(ulongsh, zero, reg1);
1486
	  return;
1474
	  return;
1487
	default: {
1475
	default: {
1488
	  if (!places) {
1476
	  if (!places) {
1489
	    ins2 (xchg, 32, 32, reg0, reg1);
1477
	    ins2(xchg, 32, 32, reg0, reg1);
1490
	    return;
1478
	    return;
1491
	  }
1479
	  }
1492
	  places = 32 - places;
1480
	  places = 32 - places;
1493
	  shft = 5 - shft;	/* reverse rotate */
1481
	  shft = 5 - shft;	/* reverse rotate */
1494
	}
1482
	}
Line 1496... Line 1484...
1496
    };
1484
    };
1497
    if (places == 0)
1485
    if (places == 0)
1498
      return;
1486
      return;
1499
    switch (shft) {	/* between 1 and 31 places */
1487
    switch (shft) {	/* between 1 and 31 places */
1500
      case 0:
1488
      case 0:
1501
	ins3 (shldl, 8, 32, 32, mw(zeroe,places), reg0, reg1);
1489
	ins3(shldl, 8, 32, 32, mw(zeroe,places), reg0, reg1);
1502
	ins2 (shll, 8, 32, mw(zeroe,places), reg0);
1490
	ins2(shll, 8, 32, mw(zeroe,places), reg0);
1503
	return;
1491
	return;
1504
      case 1:
1492
      case 1:
1505
	ins3 (shrdl, 8, 32, 32, mw(zeroe,places), reg1, reg0);
1493
	ins3(shrdl, 8, 32, 32, mw(zeroe,places), reg1, reg0);
1506
	ins2 ((sig ? sarl : shrl), 8, 32, mw(zeroe,places), reg1);
1494
	ins2((sig ? sarl : shrl), 8, 32, mw(zeroe,places), reg1);
1507
	return;
1495
	return;
1508
      default: {
1496
      default: {
1509
	char * dsh = (shft == 2 ? shrdl : shldl);
1497
	char * dsh = (shft == 2 ? shrdl : shldl);
1510
        extra_stack += 64;
1498
        extra_stack += 64;
1511
	check_stack_max;
1499
	check_stack_max;
1512
	ins0 (pushedx);
1500
	ins0(pushedx);
1513
#ifdef NEWDWARF
1501
#ifdef NEWDWARF
1514
	if (diagnose && dwarf2 && no_frame)
1502
	if (diagnose && dwarf2 && no_frame)
1515
	  dw2_track_push();
1503
	  dw2_track_push();
1516
#endif
1504
#endif
1517
	ins0 (pusheax);
1505
	ins0(pusheax);
1518
#ifdef NEWDWARF
1506
#ifdef NEWDWARF
1519
	if (diagnose && dwarf2 && no_frame)
1507
	if (diagnose && dwarf2 && no_frame)
1520
	  dw2_track_push();
1508
	  dw2_track_push();
1521
#endif
1509
#endif
1522
	ins3 (dsh, 8, 32, 32, mw(zeroe,places),
1510
	ins3(dsh, 8, 32, 32, mw(zeroe,places),
1523
		reg1, mw(ind_sp.where_exp,-32));
1511
		reg1, mw(ind_sp.where_exp,-32));
1524
	ins3 (dsh, 8, 32, 32, mw(zeroe,places),
1512
	ins3(dsh, 8, 32, 32, mw(zeroe,places),
1525
		reg0, mw(ind_sp.where_exp,-64));
1513
		reg0, mw(ind_sp.where_exp,-64));
1526
	ins0 (popeax);
1514
	ins0(popeax);
1527
#ifdef NEWDWARF
1515
#ifdef NEWDWARF
1528
	if (diagnose && dwarf2 && no_frame)
1516
	if (diagnose && dwarf2 && no_frame)
1529
	  dw2_track_pop();
1517
	  dw2_track_pop();
1530
#endif
1518
#endif
1531
	ins0 (popedx);
1519
	ins0(popedx);
1532
#ifdef NEWDWARF
1520
#ifdef NEWDWARF
1533
	if (diagnose && dwarf2 && no_frame)
1521
	if (diagnose && dwarf2 && no_frame)
1534
	  dw2_track_pop();
1522
	  dw2_track_pop();
1535
#endif
1523
#endif
1536
	invalidate_dest (ind_sp);
1524
	invalidate_dest(ind_sp);
1537
        extra_stack -= 64;
1525
        extra_stack -= 64;
1538
	return;
1526
	return;
1539
      }
1527
      }
1540
    }
1528
    }
1541
  };
1529
  };
1542
  {				/* number of places in reg2 */
1530
  {				/* number of places in reg2 */
1543
    int lablow = next_lab ();
1531
    int lablow = next_lab();
1544
    int labend = next_lab ();
1532
    int labend = next_lab();
1545
    ins2 (cmpl, 32, 32, mw(zeroe,32), reg2);
1533
    ins2(cmpl, 32, 32, mw(zeroe,32), reg2);
1546
    simple_branch (jl, lablow);
1534
    simple_branch(jl, lablow);
1547
    switch (shft) {
1535
    switch (shft) {
1548
      case 0:
1536
      case 0:
1549
	ins2 (subl, 32, 32, mw(zeroe,32), reg2);
1537
	ins2(subl, 32, 32, mw(zeroe,32), reg2);
1550
	ins2 (shll, 8, 32, reg2, reg0);
1538
	ins2(shll, 8, 32, reg2, reg0);
1551
	move (ulongsh, reg0, reg1);
1539
	move(ulongsh, reg0, reg1);
1552
	move (ulongsh, zero, reg0);
1540
	move(ulongsh, zero, reg0);
1553
	break;
1541
	break;
1554
      case 1:
1542
      case 1:
1555
	ins2 (subl, 32, 32, mw(zeroe,32), reg2);
1543
	ins2(subl, 32, 32, mw(zeroe,32), reg2);
1556
	move (ulongsh, reg1, reg0);
1544
	move(ulongsh, reg1, reg0);
1557
	ins2 ((sig ? sarl : shrl), 8, 32, reg2, reg0);
1545
	ins2((sig ? sarl : shrl), 8, 32, reg2, reg0);
1558
	if (sig)
1546
	if (sig)
1559
	  ins2 (sarl, 8, 32, mw(zeroe,31), reg1);
1547
	  ins2(sarl, 8, 32, mw(zeroe,31), reg1);
1560
	else
1548
	else
1561
	  move (ulongsh, zero, reg1);
1549
	  move(ulongsh, zero, reg1);
1562
	break;
1550
	break;
1563
      default: {
1551
      default: {
1564
	int labx = next_lab ();
1552
	int labx = next_lab();
1565
	char * dsh = (shft == 2 ? shldl : shrdl);	/* reversed rotate */
1553
	char * dsh = (shft == 2 ? shldl : shrdl);	/* reversed rotate */
1566
	simple_branch (je, labx);
1554
	simple_branch(je, labx);
1567
	ins2 (subl, 32, 32, mw(zeroe,64), reg2);
1555
	ins2(subl, 32, 32, mw(zeroe,64), reg2);
1568
	ins1 (negl, 32, reg2);
1556
	ins1(negl, 32, reg2);
1569
        extra_stack += 64;
1557
        extra_stack += 64;
1570
	check_stack_max;
1558
	check_stack_max;
1571
	ins0 (pushedx);
1559
	ins0(pushedx);
1572
#ifdef NEWDWARF
1560
#ifdef NEWDWARF
1573
	if (diagnose && dwarf2 && no_frame)
1561
	if (diagnose && dwarf2 && no_frame)
1574
	  dw2_track_push();
1562
	  dw2_track_push();
1575
#endif
1563
#endif
1576
	ins0 (pusheax);
1564
	ins0(pusheax);
1577
#ifdef NEWDWARF
1565
#ifdef NEWDWARF
1578
	if (diagnose && dwarf2 && no_frame)
1566
	if (diagnose && dwarf2 && no_frame)
1579
	  dw2_track_push();
1567
	  dw2_track_push();
1580
#endif
1568
#endif
1581
	ins3 (dsh, 8, 32, 32, reg2, reg1, mw(ind_sp.where_exp,-32));
1569
	ins3(dsh, 8, 32, 32, reg2, reg1, mw(ind_sp.where_exp,-32));
1582
	ins3 (dsh, 8, 32, 32, reg2, reg0, mw(ind_sp.where_exp,-64));
1570
	ins3(dsh, 8, 32, 32, reg2, reg0, mw(ind_sp.where_exp,-64));
1583
	ins0 (popeax);
1571
	ins0(popeax);
1584
#ifdef NEWDWARF
1572
#ifdef NEWDWARF
1585
	if (diagnose && dwarf2 && no_frame)
1573
	if (diagnose && dwarf2 && no_frame)
1586
	  dw2_track_pop();
1574
	  dw2_track_pop();
1587
#endif
1575
#endif
1588
	ins0 (popedx);
1576
	ins0(popedx);
1589
#ifdef NEWDWARF
1577
#ifdef NEWDWARF
1590
	if (diagnose && dwarf2 && no_frame)
1578
	if (diagnose && dwarf2 && no_frame)
1591
	  dw2_track_pop();
1579
	  dw2_track_pop();
1592
#endif
1580
#endif
1593
	invalidate_dest (ind_sp);
1581
	invalidate_dest(ind_sp);
1594
        extra_stack -= 64;
1582
        extra_stack -= 64;
1595
	simple_branch (jmp, labend);
1583
	simple_branch(jmp, labend);
1596
	simplest_set_lab (labx);
1584
	simplest_set_lab(labx);
1597
	ins2 (xchg, 32, 32, reg0, reg1);
1585
	ins2(xchg, 32, 32, reg0, reg1);
1598
      }
1586
      }
1599
    }
1587
    }
1600
    simple_branch (jmp, labend);
1588
    simple_branch(jmp, labend);
1601
    simplest_set_lab (lablow);
1589
    simplest_set_lab(lablow);
1602
    switch (shft) {	/* between 0 and 31 places */
1590
    switch (shft) {	/* between 0 and 31 places */
1603
      case 0:
1591
      case 0:
1604
	ins3 (shldl, 8, 32, 32, reg2, reg0, reg1);
1592
	ins3(shldl, 8, 32, 32, reg2, reg0, reg1);
1605
	ins2 (shll, 8, 32, reg2, reg0);
1593
	ins2(shll, 8, 32, reg2, reg0);
1606
	break;
1594
	break;
1607
      case 1:
1595
      case 1:
1608
	ins3 (shrdl, 8, 32, 32, reg2, reg1, reg0);
1596
	ins3(shrdl, 8, 32, 32, reg2, reg1, reg0);
1609
	ins2 ((sig ? sarl : shrl), 8, 32, reg2, reg1);
1597
	ins2((sig ? sarl : shrl), 8, 32, reg2, reg1);
1610
	break;
1598
	break;
1611
      default: {
1599
      default: {
1612
	char * dsh = (shft == 2 ? shrdl : shldl);
1600
	char * dsh = (shft == 2 ? shrdl : shldl);
1613
        extra_stack += 64;
1601
        extra_stack += 64;
1614
	check_stack_max;
1602
	check_stack_max;
1615
	ins0 (pushedx);
1603
	ins0(pushedx);
1616
#ifdef NEWDWARF
1604
#ifdef NEWDWARF
1617
	if (diagnose && dwarf2 && no_frame)
1605
	if (diagnose && dwarf2 && no_frame)
1618
	  dw2_track_push();
1606
	  dw2_track_push();
1619
#endif
1607
#endif
1620
	ins0 (pusheax);
1608
	ins0(pusheax);
1621
#ifdef NEWDWARF
1609
#ifdef NEWDWARF
1622
	if (diagnose && dwarf2 && no_frame)
1610
	if (diagnose && dwarf2 && no_frame)
1623
	  dw2_track_push();
1611
	  dw2_track_push();
1624
#endif
1612
#endif
1625
	ins3 (dsh, 8, 32, 32, reg2, reg1, mw(ind_sp.where_exp,-32));
1613
	ins3(dsh, 8, 32, 32, reg2, reg1, mw(ind_sp.where_exp,-32));
1626
	ins3 (dsh, 8, 32, 32, reg2, reg0, mw(ind_sp.where_exp,-64));
1614
	ins3(dsh, 8, 32, 32, reg2, reg0, mw(ind_sp.where_exp,-64));
1627
	ins0 (popeax);
1615
	ins0(popeax);
1628
#ifdef NEWDWARF
1616
#ifdef NEWDWARF
1629
	if (diagnose && dwarf2 && no_frame)
1617
	if (diagnose && dwarf2 && no_frame)
1630
	  dw2_track_pop();
1618
	  dw2_track_pop();
1631
#endif
1619
#endif
1632
	ins0 (popedx);
1620
	ins0(popedx);
1633
#ifdef NEWDWARF
1621
#ifdef NEWDWARF
1634
	if (diagnose && dwarf2 && no_frame)
1622
	if (diagnose && dwarf2 && no_frame)
1635
	  dw2_track_pop();
1623
	  dw2_track_pop();
1636
#endif
1624
#endif
1637
	invalidate_dest (ind_sp);
1625
	invalidate_dest(ind_sp);
1638
        extra_stack -= 64;
1626
        extra_stack -= 64;
1639
      }
1627
      }
1640
    }
1628
    }
1641
    simplest_set_lab (labend);
1629
    simplest_set_lab(labend);
1642
  };
1630
  };
1643
  return;
1631
  return;
1644
}
1632
}