Subversion Repositories tendra.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
2
    		 Crown Copyright (c) 1997
3
 
4
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
12
 
13
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
15
 
16
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
19
 
20
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
22
        these conditions;
23
 
24
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
27
        it may be put.
28
*/
29
 
30
 
31
/**********************************************************************
32
$Author: pwe $
33
$Date: 1998/03/17 16:34:54 $
34
$Revision: 1.6 $
35
$Log: dw2_extra.c,v $
36
 * Revision 1.6  1998/03/17  16:34:54  pwe
37
 * correction for non-NEWDIAGS
38
 *
39
 * Revision 1.5  1998/03/15  16:00:15  pwe
40
 * regtrack dwarf dagnostics added
41
 *
42
 * Revision 1.4  1998/03/11  11:03:04  pwe
43
 * DWARF optimisation info
44
 *
45
 * Revision 1.3  1998/02/18  11:22:01  pwe
46
 * test corrections
47
 *
48
 * Revision 1.2  1998/01/21  10:29:59  pwe
49
 * labdiff change
50
 *
51
 * Revision 1.1.1.1  1998/01/17  15:55:51  release
52
 * First version to be checked into rolling release.
53
 *
54
 * Revision 1.1  1998/01/09  14:47:37  pwe
55
 * prep restructure
56
 *
57
 * Revision 1.10  1997/12/04  20:01:36  pwe
58
 * ANDF-DE V1.9
59
 *
60
 * Revision 1.9  1997/10/28  10:26:55  pwe
61
 * correct extra diags / locations
62
 *
63
 * Revision 1.8  1997/10/23  09:37:36  pwe
64
 * extra_diags
65
 *
66
 * Revision 1.7  1997/10/10  18:26:09  pwe
67
 * prep ANDF-DE revision
68
 *
69
 * Revision 1.6  1997/08/23  13:46:10  pwe
70
 * initial ANDF-DE
71
 *
72
 * Revision 1.5  1997/05/02  11:05:04  pwe
73
 * minor dwarf2 corrections
74
 *
75
 * Revision 1.4  1997/04/17  11:56:12  pwe
76
 * dwarf2 improvements
77
 *
78
 * Revision 1.3  1997/04/02  10:33:49  pwe
79
 * diagnose pl_tests
80
 *
81
 * Revision 1.2  1997/03/24  11:15:53  pwe
82
 * dwarf2 option/default
83
 *
84
 * Revision 1.1  1997/03/20  16:24:44  pwe
85
 * dwarf2
86
 *
87
**********************************************************************/
88
 
89
#include "config.h"
90
#include "common_types.h"
91
 
92
#ifdef NEWDWARF
93
 
94
#include "localtypes.h"
95
#include "dg_aux.h"
96
#include "dg_types.h"
97
#include "dw2_config.h"
98
#include "dw2_codes.h"
99
#include "dw2_entries.h"
100
#include "dw2_basic.h"
101
#include "dw2_info.h"
102
#include "codermacs.h"
103
#include "flags.h"
104
#include "operand.h"
105
#include "machine.h"
106
#include "instr386.h"
107
#include "expmacs.h"
108
#include "shapemacs.h"
109
#include "instr.h"
110
#include "basicread.h"
111
#include "szs_als.h"
112
#include "coder.h"
113
#include "tags.h"
114
#include "const.h"
115
#include "label_ops.h"
116
#include "flpttypes.h"
117
#include "f64.h"
118
#include "dw2_extra.h"
119
#include "operand.h"
120
#include "reg_record.h"
121
#include "dw2_locdata.h"
122
 
123
 
124
extern int locals_offset; /* declared in cproc.c */
125
 
126
 
127
static long dwarfreg [8] = {0, 2, 1, 3, 7, 6, 5, 4};
128
#define dw_sp 4
129
#define dw_fp 5
130
#define retaddr 8
131
 
132
static long cie_pointer;
133
static long fde_end;
134
static long proc_end;
135
 
136
static char * sp50 = "                                                  ";
137
 
138
enum loctype { L_INREG = 1, L_REGOFF, L_GLOB, L_INDIRECT };
139
 
140
typedef struct {
141
  enum loctype key;
142
  int reg;
143
  char* s;
144
  long off;
145
} loc_s;
146
 
147
static int extra_deref;
148
static int locate_param;
149
static int has_fp;
150
static int no_location;
151
 
152
 
153
 
154
 
155
static void outsep
156
    PROTO_Z ()
157
{
158
  outs (", ");
159
}
160
 
161
 
162
int dw_is_const
163
    PROTO_N ( (e) )
164
    PROTO_T ( exp e )
165
{
166
  switch (name(e)) {
167
    case val_tag:
168
    case null_tag:
169
    case real_tag:
170
      return 1;
171
    case name_tag:
172
      return (!isdiscarded(e) && isvar(son(e)));
173
#if 0
174
    case cont_tag:
175
      return (name(son(e)) == name_tag && !isdiscarded(son(e)) &&
176
		!isvar(son(son(e))) && !isparam(son(son(e))) );
177
#endif
178
    case reff_tag:
179
      return 1;
180
    default:
181
      return 0;
182
  }
183
}
184
 
185
exp dw_has_location
186
    PROTO_N ( (e) )
187
    PROTO_T ( exp e )
188
{
189
  switch (name(e)) {
190
    case name_tag: {
191
      if (isdiscarded(e) || isvar(son(e)))
192
	return nilexp;
193
      return (son(e));
194
    }
195
    case cont_tag: {
196
      do {
197
	e = son(e);
198
	if (name(e) == name_tag && isdiscarded(e))
199
	  return nilexp;
200
      }
201
      while (name(e) != ident_tag);
202
      return e;
203
    }
204
    default:
205
      return nilexp;
206
  }
207
}
208
 
209
 
210
static loc_s name_to_loc PROTO_S ((exp e));
211
 
212
static loc_s find_param
213
    PROTO_N ( (e) )
214
    PROTO_T ( exp e )
215
{
216
  switch (name(e)) {
217
    case name_tag:
218
      if (isvar(son(e)))
219
	extra_deref--;
220
      if (isparam(son(e)))
221
        return name_to_loc (e);
222
      return find_param (son(son(e)));
223
    case cont_tag:
224
      extra_deref++;	/* drop through */
225
    case chvar_tag:
226
    case chfl_tag:
227
      return find_param (son(e));
228
    default:
229
      break;
230
  }
231
  failer ("parameter inconsistency");
232
  return find_param (e);
233
}
234
 
235
static loc_s name_to_loc
236
    PROTO_N ( (e) )
237
    PROTO_T ( exp e )
238
{
239
  loc_s l;
240
  exp id = son(e);
241
  long n_off = no(e)/8;
242
  if (locate_param && !isparam(id)) {
243
    return find_param (son(id));
244
#if 0
245
    if (name(son(id)) == name_tag && isloadparam(son(id)) && isparam(son(son(id))))
246
      return name_to_loc (son(id));
247
    if (name(son(id)) == cont_tag && name(son(son(id))) == name_tag &&
248
		isparam(son(son(son(id)))))
249
      return name_to_loc (son(son(id)));
250
    failer ("parameter inconsistency");
251
#endif
252
  }
253
  if (isglob (id)) {
254
    l.key = L_GLOB;
255
    l.s = brog(id) -> dec_u.dec_val.dec_id;
256
    l.off = n_off;
257
  }
258
  else {
259
    switch (ptno (id)) {
260
      case local_pl: {
261
	l.key = L_REGOFF;
262
	l.reg = -1;
263
	l.off = (no(id)/8) + n_off;
264
	if (name(id))
265
	  l.off -= locals_offset;
266
	else {			/* env_off modification */
267
	  if (locate_param) {
268
	    l.reg = dw_sp;
269
	  }
270
	}
271
	if (has_fp && l.reg < 0)
272
	  l.off += 4;
273
	break;
274
      };
275
      case callstack_pl: {
276
	failer ("callstack arg - location list needed");
277
	break;
278
      };
279
      case par_pl: {
280
	l.key = L_REGOFF;
281
	l.reg = (locate_param ? dw_sp : -1);
282
	l.off = (no(id)/8) +4 + n_off;
283
	break;
284
      };
285
      case reg_pl: {
286
	int z = get_reg_no (no(id));
287
	l.key = L_INREG;
288
	l.reg = (z >= first_fl_reg ? 100 + z - first_fl_reg : 
289
					(int)dwarfreg[z]);
290
	break;
291
      };
292
      default:
293
	failer ("no location for id");
294
	SET (l);
295
    }
296
    if (has_fp && l.reg < 0)
297
      l.off += 4;
298
  }
299
  return l;
300
}
301
 
302
static loc_s find_loc
303
    PROTO_N ( (e) )
304
    PROTO_T ( exp e )
305
{
306
  loc_s l;
307
  switch ( name ( e ) ) {
308
 
309
    case name_tag : {
310
      if (isdiscarded(e) || (isglob(son(e)) && no(son(e)) == 0 &&
311
				!(brog(son(e))->dec_u.dec_val.extnamed) )) {
312
	l.key = L_INREG;
313
	l.reg = 0;
314
	no_location = 1;
315
	return l;
316
      }
317
      if ( isvar(son(e)) )
318
	extra_deref--;
319
      return name_to_loc (e);
320
    }
321
 
322
    case cont_tag :
323
    case contvol_tag : {
324
      if (name(son(e)) == name_tag) {
325
	if (isdiscarded(son(e)) ||
326
			(isglob(son(son(e))) && no(son(son(e))) == 0 &&
327
			 !(brog(son(son(e)))->dec_u.dec_val.extnamed) )) {
328
	  l.key = L_INREG;
329
	  l.reg = 0;
330
	  no_location = 1;
331
	  return l;
332
	}
333
	if ( isvar(son(son(e))) )
334
	  return name_to_loc (son(e));
335
      }
336
      l = find_loc (son(e));
337
      if (l.key == L_INREG) {
338
	l.key = L_REGOFF;
339
	l.off = 0;
340
      }
341
      else
342
	l.key = L_INDIRECT;
343
      break;
344
    }
345
 
346
    case reff_tag : {
347
      l = find_loc (son(e));
348
      if (l.key == L_GLOB || l.key == L_REGOFF)
349
	l.off += (no(e)/8);
350
      else
351
      if (l.key == L_INREG) {
352
	l.key = L_REGOFF;
353
	l.off = (no(e)/8);
354
	extra_deref--;
355
      }
356
      else
357
	l.key = L_INDIRECT;
358
      break;
359
    }
360
 
361
    case chvar_tag : {
362
      l = find_loc (son(e));
363
      break;
364
    }
365
 
366
    default:
367
      failer ("unimplemented location condition");
368
      SET (l);
369
  }
370
  return l;
371
}
372
 
373
static int inreg_length
374
    PROTO_N ( (r, more) )
375
    PROTO_T ( int r X int more )
376
{
377
  int ans = 1 + more;
378
  if (r >= 32)
379
    ans += uleb128_length((unsigned long)r);
380
  return ans;
381
}
382
 
383
static void out_inreg
384
    PROTO_N ( (r, more) )
385
    PROTO_T ( int r X int more )
386
{
387
  if (!more) {
388
    if (r < 32)
389
      outn ((long)(DW_OP_reg0 + r));
390
    else {
391
      outn ((long)DW_OP_regx); outsep(); uleb128((unsigned long)r);
392
    }
393
  }
394
  else {
395
    if (r < 32)
396
      outn ((long)(DW_OP_breg0 + r));
397
    else {
398
      outn ((long)DW_OP_bregx); outsep(); uleb128((unsigned long)r);
399
    }
400
    outsep(); outn ((long)0);
401
  }
402
  return;
403
}
404
 
405
static int regoff_length
406
    PROTO_N ( (l) )
407
    PROTO_T ( loc_s l )
408
{
409
  return (1 + sleb128_length (l.off));
410
}
411
 
412
static void out_regoff
413
    PROTO_N ( (l) )
414
    PROTO_T ( loc_s l )
415
{
416
  outn ((long)(l.reg < 0 ? DW_OP_fbreg : DW_OP_breg0 + l.reg)); outsep();
417
  sleb128 (l.off);
418
  return;
419
}
420
 
421
static int glob_length
422
    PROTO_N ( (l) )
423
    PROTO_T ( loc_s l )
424
{
425
  UNUSED (l);
426
  return 5;
427
}
428
 
429
static void out_glob
430
    PROTO_N ( (l) )
431
    PROTO_T ( loc_s l )
432
{
433
  outn ((long)DW_OP_addr); d_outnl ();
434
  out32 (); outs (l.s);
435
  if (l.off) {
436
    outs (" + ");
437
    outn ((long)l.off);
438
  }
439
  return;
440
}
441
 
442
static int indirect_length
443
    PROTO_N ( (e) )
444
    PROTO_T ( exp e )
445
{
446
  int length;
447
  loc_s l;
448
  switch (name(e)) {
449
    case cont_tag: {
450
      length = 1;
451
      break;
452
    }
453
    case reff_tag: {
454
      if (no(e) >= 0)
455
	length = 1 + uleb128_length ((unsigned long)(no(e)/8));
456
      else
457
	length = 2 + uleb128_length ((unsigned long)(-no(e)/8));
458
      break;
459
    }
460
    default: {
461
      failer ("unimplemented dwarf locate");
462
      return 0;
463
    }
464
  }
465
  l = find_loc (son(e));
466
  switch (l.key) {
467
    case L_INREG: {
468
      length += inreg_length (l.reg, 1);
469
      break;
470
    }
471
    case L_REGOFF: {
472
      length += regoff_length(l);
473
      break;
474
    }
475
    case L_GLOB: {
476
      length += glob_length(l);
477
      break;
478
    }
479
    case L_INDIRECT: {
480
      length += indirect_length(son(e));
481
      break;
482
    }
483
  }
484
  return length;
485
}
486
 
487
static void out_indirect
488
    PROTO_N ( (e) )
489
    PROTO_T ( exp e )
490
{
491
  loc_s l;
492
  l = find_loc (e);
493
  switch (l.key) {
494
    case L_INREG: {
495
      out_inreg (l.reg, 1);
496
      outsep();
497
      break;
498
    }
499
    case L_REGOFF: {
500
      out_regoff (l);
501
      outsep();
502
      break;
503
    }
504
    case L_GLOB: {
505
      out_glob (l);
506
      d_outnl(); out8();
507
      break;
508
    }
509
    case L_INDIRECT: {
510
      out_indirect(son(e));
511
      outsep();
512
      break;
513
    }
514
  }
515
  switch (name(e)) {
516
    case cont_tag: {
517
      outn ((long)DW_OP_deref);
518
      break;
519
    }
520
    case reff_tag: {
521
      if (no(e) >= 0) {
522
	outn ((long)DW_OP_plus_uconst); outsep();
523
	uleb128 ((unsigned long)(no(e)/8));
524
      }
525
      else {
526
	outn ((long)DW_OP_constu); outsep();
527
	uleb128 ((unsigned long)(-no(e)/8)); outsep();
528
	outn ((long)DW_OP_minus);
529
      }
530
      break;
531
    }
532
  }
533
  return;
534
}
535
 
536
 
537
void dw2_locate_exp
538
    PROTO_N ( (e, locate_const, cx) )
539
    PROTO_T ( exp e X int locate_const X int cx )
540
{
541
  loc_s l;
542
  int length;
543
  int within_loclist = (cx & 1);
544
  locate_param = (cx & 2);
545
  extra_deref = locate_const;
546
  no_location = 0;
547
  l = find_loc (e);	/* may reduce extra_deref */
548
  length = extra_deref;
549
  switch (l.key) {
550
    case L_INREG: {
551
      length += inreg_length (l.reg, extra_deref);
552
      break;
553
    }
554
    case L_REGOFF: {
555
      length += regoff_length(l);
556
      break;
557
    }
558
    case L_GLOB: {
559
      length += glob_length(l);
560
      break;
561
    }
562
    case L_INDIRECT: {
563
      length += indirect_length(e);
564
      break;
565
    }
566
  }
567
  if (no_location)
568
    length = 0;
569
 
570
  if (within_loclist) {
571
    out16 ();
572
    outn ((long)length); outnl();
573
    if (no_location)
574
      return;
575
    out8 ();
576
  }
577
  else {
578
    out8 ();
579
    outn ((long)length);
580
    if (no_location) {
581
      outnl();
582
      return;
583
    }
584
    outsep();
585
  }
586
  switch (l.key) {
587
    case L_INREG: {
588
      out_inreg (l.reg, extra_deref);
589
      break;
590
    }
591
    case L_REGOFF: {
592
      out_regoff (l);
593
      break;
594
    }
595
    case L_GLOB: {
596
      out_glob (l);
597
      break;
598
    }
599
    case L_INDIRECT: {
600
      out_indirect (e);
601
      break;
602
    }
603
  }
604
  while (extra_deref) {
605
    if (extra_deref < 0) {
606
      failer ("miscalculated location");
607
      break;
608
    }
609
#if 0
610
    if (locate_const)
611
      failer ("constant location???");
612
#endif
613
    outsep();
614
    outn ((long)DW_OP_deref);
615
    extra_deref--;
616
  }
617
  d_outnl ();
618
  return;
619
}
620
 
621
 
622
void dw2_prepare_locate
623
    PROTO_N ( (id) )
624
    PROTO_T ( exp id )
625
{
626
			/* set local proc conditions for local locations */
627
  exp p = son(id);	/* proc or general proc */
628
  locals_offset = no(p);
629
  has_fp = proc_has_fp(p);
630
  return;
631
}
632
 
633
void dw_at_procdetails
634
    PROTO_Z ()
635
{
636
			/* return address and frame base */
637
  out8(); outn((long)2); outsep(); outn((long)DW_OP_fbreg); outsep();
638
  if (has_fp) {
639
    outn((long)4); d_outnl();
640
    out8(); outn((long)1); outsep();
641
    outn((long)DW_OP_reg0+dw_fp); d_outnl();
642
  }
643
  else {
644
    outn((long)0); d_outnl();
645
    out8(); outn((long)0); d_outnl();
646
  }
647
  return;
648
}
649
 
650
 
651
void dw2_locate_result
652
    PROTO_N ( (sha) )
653
    PROTO_T ( shape sha )
654
{
655
  long length = 1;
656
  int reg = 0;
657
  int indirect = 0;
658
  int multi = 0;
659
  if (is_floating(name(sha))) {
660
    reg = 100;
661
    length = inreg_length (reg, 0);
662
  }
663
  else
664
  if (!reg_result(sha)) {
665
    indirect = 1;
666
    length = 2;
667
  }
668
  else
669
  if (shape_size (sha) > 32) {
670
    multi = 1;
671
    length = 6;
672
  }
673
  out8 (); outn (length); outsep();
674
  if (multi) {
675
    outn ((long)DW_OP_reg0); outsep();
676
    outn ((long)DW_OP_piece); outsep(); outn ((long)4);
677
    outsep();
678
    outn ((long)DW_OP_reg0+2); outsep();
679
    outn ((long)DW_OP_piece); outsep(); outn ((long)4);
680
  }
681
  else
682
  if (indirect) {
683
    outn ((long)DW_OP_breg0); outsep(); outn ((long)0);
684
  }
685
  else {
686
    out_inreg (reg, 0);
687
  }
688
  d_outnl ();
689
  return;
690
}
691
 
692
 
693
void dw2_locate_val
694
    PROTO_N ( (v) )
695
    PROTO_T ( dg_where v )
696
{
697
  out8 ();
698
  switch (v.k) {
699
    case NO_WH: {
700
      outn ((long)0);
701
      break;
702
    }
703
    case WH_STR: {
704
      loc_s l;
705
      l.key = L_GLOB;
706
      l.s = v.u.s;
707
      l.off = v.o;
708
      outn ((long)glob_length (l)); outsep();
709
      out_glob (l);
710
      break;
711
    }
712
    case WH_REG: {
713
      int r = (int)dwarfreg[v.u.l];
714
      outn ((long)inreg_length (r, 0)); outsep();
715
      out_inreg (r, 0);
716
      break;
717
    }
718
    case WH_REGOFF: {
719
      loc_s l;
720
      l.key = L_REGOFF;
721
      l.reg = (int)v.u.l;
722
      l.off = v.o;
723
      if (l.reg == -2) {
724
	l.reg = -1;
725
	l.off -= locals_offset;
726
      }
727
      outn ((long)regoff_length (l)); outsep();
728
      out_regoff (l);
729
      break;
730
    }
731
    default:
732
      failer ("unexpected locate val");
733
  }
734
  d_outnl ();
735
  return;
736
}
737
 
738
 
739
static int dw_eval_exp
740
    PROTO_N ( (e, line_started) )
741
    PROTO_T ( exp e X int line_started )
742
{
743
  if (line_started)
744
    outsep();
745
  else {
746
    out8 ();
747
    line_started = 1;
748
  }
749
  switch (name(e)) {
750
    case name_tag:
751
    case cont_tag:
752
    case contvol_tag:
753
    case reff_tag: {
754
      loc_s l;
755
      locate_param = extra_deref = no_location = 0;
756
      l = find_loc (e);
757
      if (no_location || extra_deref)
758
	failer ("value unobtainable by DWARF expression");
759
      switch (l.key) {
760
	case L_INREG: {
761
	  out_inreg (l.reg, extra_deref);
762
	  break;
763
	}
764
	case L_REGOFF: {
765
	  out_regoff (l);
766
	  break;
767
	}
768
	case L_GLOB: {
769
	  out_glob (l);
770
	  d_outnl ();
771
	  line_started = 0;
772
	  break;
773
	}
774
	case L_INDIRECT: {
775
	  out_indirect (e);
776
	  break;
777
	}
778
      }
779
      break;
780
    }
781
    case val_tag:
782
    case null_tag : {
783
      if (isbigval(e)) {
784
	flt64 x;
785
	int ov;
786
	x = flt_to_f64(no(e), is_signed(sh(e)), &ov);
787
	outn((long)(is_signed(sh(e)) ? DW_OP_const8s : DW_OP_const8u)); d_outnl();
788
	out32(); outn((long)(x.small)); outsep(); outn((long)(x.big)); d_outnl();
789
	line_started = 0;
790
      }
791
      else
792
      if (no(e) >= 0 && no(e) < 32)
793
	outn((long)(DW_OP_lit0 + no(e)));
794
      else
795
      if (is_signed(sh(e))) {
796
	outn((long)DW_OP_consts); outsep();
797
	sleb128 ((long)no(e));
798
      }
799
      else {
800
	outn((long)DW_OP_constu); outsep();
801
	uleb128 ((unsigned long)no(e));
802
      }
803
      break;
804
    }
805
    case plus_tag:
806
    case offset_add_tag : {
807
      line_started = dw_eval_exp (son(e), line_started);
808
      if (name(bro(son(e))) == val_tag && !is_signed(sh(e)) && !isbigval(bro(son(e)))) {
809
	if (line_started)
810
	  outsep();
811
	else {
812
	  out8 ();
813
	  line_started = 1;
814
	}
815
	outn((long)DW_OP_plus_uconst); outsep();
816
	uleb128 ((unsigned long)no(e));
817
      }
818
      else {
819
	line_started = dw_eval_exp (bro(son(e)), line_started);
820
	if (line_started)
821
	  outsep();
822
	else {
823
	  out8 ();
824
	  line_started = 1;
825
	}
826
	outn((long)DW_OP_plus);
827
      }
828
      break;
829
    }
830
    case minus_tag:
831
    case offset_subtract_tag : {
832
      line_started = dw_eval_exp (son(e), line_started);
833
      line_started = dw_eval_exp (bro(son(e)), line_started);
834
      if (line_started)
835
	outsep();
836
      else {
837
	out8 ();
838
	line_started = 1;
839
      }
840
      outn((long)DW_OP_minus);
841
      break;
842
    }
843
    case neg_tag:
844
    case offset_negate_tag : {
845
      line_started = dw_eval_exp (son(e), line_started);
846
      if (line_started)
847
	outsep();
848
      else {
849
	out8 ();
850
	line_started = 1;
851
      }
852
      outn((long)DW_OP_neg);
853
      break;
854
    }
855
    case mult_tag:
856
    case offset_mult_tag : {
857
      line_started = dw_eval_exp (son(e), line_started);
858
      line_started = dw_eval_exp (bro(son(e)), line_started);
859
      if (line_started)
860
	outsep();
861
      else {
862
	out8 ();
863
	line_started = 1;
864
      }
865
      outn((long)DW_OP_mul);
866
      break;
867
    }
868
    case div0_tag :
869
    case div1_tag :
870
    case div2_tag :
871
    case offset_div_by_int_tag :
872
    case offset_div_tag : {
873
      line_started = dw_eval_exp (son(e), line_started);
874
      line_started = dw_eval_exp (bro(son(e)), line_started);
875
      if (line_started)
876
	outsep();
877
      else {
878
	out8 ();
879
	line_started = 1;
880
      }
881
      outn((long)DW_OP_div);
882
      break;
883
    }
884
    default:
885
      failer ("unsupported operation for DWARF expression");
886
  }
887
  return line_started;
888
}
889
 
890
 
891
void dw2_offset_exp
892
    PROTO_N ( (e) )
893
    PROTO_T ( exp e )
894
{
895
  long block_end = next_dwarf_label ();
896
  if (name(sh(e)) != offsethd)
897
    failer ("wrong shape for offset expression");
898
  dw_at_form (DW_FORM_block2); d_outnl();
899
  out16 (); out_dwf_dist_to_label (block_end); d_outnl();
900
  if (dw_eval_exp (e, 0))
901
    d_outnl();
902
  if (name(sh(e)) == offsethd && al2(sh(e)) < 8 ) {
903
    out8 (); outn((long)(DW_OP_lit0 + 8)); outsep();
904
    outn((long)DW_OP_mul); d_outnl();
905
  }
906
  out_dwf_label (block_end, 1);
907
  return;
908
}
909
 
910
 
911
void dw2_cie
912
    PROTO_Z ()
913
{
914
  long cie_end;
915
  cie_pointer = next_dwarf_label();
916
  cie_end = next_dwarf_label();
917
  enter_section ("debug_frame");
918
  outnl_comment ("Common Information Entry");
919
  out_dwf_label (cie_pointer, 1);
920
  out32 (); out_dwf_dist_to_label (cie_end); d_outnl();
921
  out32 (); outn ((long)DW_CIE_id); d_outnl ();
922
  out8 (); outn ((long)DW_CIE_MOD_VERSION); d_outnl ();
923
  out_string ("DERA/DDC-I");
924
  out8 (); uleb128 ((unsigned long)framecode_factor); d_outnl ();
925
  out8 (); sleb128 ((long)framedata_factor); d_outnl ();
926
  out8 (); outn ((long)retaddr); d_outnl ();	/* return address column */
927
  out8 (); outn ((long)DW_CFA_def_cfa);
928
	outsep (); uleb128 ((unsigned long)dw_sp);
929
	outsep (); uleb128 ((unsigned long)0);	/* CFA is sp at entry point */
930
	d_outnl ();
931
  out8 (); outn ((long)DW_CFA_undefined);
932
	outsep (); uleb128 ((unsigned long)dwarfreg [0]);	/* eax */
933
	d_outnl ();
934
  out8 (); outn ((long)DW_CFA_undefined);
935
	outsep (); uleb128 ((unsigned long)dwarfreg [1]);	/* edx */
936
	d_outnl ();
937
  out8 (); outn ((long)DW_CFA_undefined);
938
	outsep (); uleb128 ((unsigned long)dwarfreg [2]);	/* ecx */
939
	d_outnl ();
940
  out8 (); outn ((long)DW_CFA_same_value);
941
	outsep (); uleb128 ((unsigned long)dwarfreg [3]);	/* ebx */
942
	d_outnl ();
943
  out8 (); outn ((long)DW_CFA_same_value);
944
	outsep (); uleb128 ((unsigned long)dwarfreg [4]);	/* edi */
945
	d_outnl ();
946
  out8 (); outn ((long)DW_CFA_same_value);
947
	outsep (); uleb128 ((unsigned long)dwarfreg [5]);	/* esi */
948
	d_outnl ();
949
  out8 (); outn ((long)DW_CFA_same_value);
950
	outsep (); uleb128 ((unsigned long)dwarfreg [6]);	/* ebp */
951
	d_outnl ();
952
  out8 (); outn ((long)DW_CFA_DD_location);
953
	outsep (); uleb128 ((unsigned long)dw_sp);		/* esp */
954
	outsep (); outn ((long)2);	/* location block */
955
	outsep (); outn ((long)DW_OP_plus_uconst);
956
	outsep (); uleb128 ((unsigned long)4);	/* virtual pop return address */
957
	d_outnl ();
958
  out8 (); outn ((long)DW_CFA_offset + retaddr);
959
	outsep (); uleb128 ((unsigned long)0);	/* return address */
960
	d_outnl ();
961
  dot_align (PTR_SZ/8);
962
  out_dwf_label (cie_end, 1);
963
  exit_section ();
964
  return;
965
}
966
 
967
static void short_advance
968
    PROTO_N ( (lo, hi) )
969
    PROTO_T ( long lo X long hi )
970
{
971
  if (lo) {
972
    out8 (); out_dwf_label (hi, 0);  outs (" - "); out_dwf_label (lo, 0);
973
    outs (" + "); outn ((long)DW_CFA_advance_loc); d_outnl ();
974
  }
975
  else {
976
    out8 (); outn ((long)DW_CFA_set_loc); d_outnl ();
977
    out32 (); out_dwf_label (hi, 0); d_outnl ();
978
  }
979
  return;
980
}
981
 
982
long dw2_start_fde
983
    PROTO_N ( (proc_start, fblab) )
984
    PROTO_T ( long proc_start X long fblab )
985
{
986
  long hold_pos;
987
  fde_end = next_dwarf_label();
988
  proc_end = next_dwarf_label();
989
  enter_section ("debug_frame");
990
  outnl_comment ("Frame Descriptor Entry");
991
  out32 (); out_dwf_dist_to_label (fde_end); d_outnl ();
992
  out32 (); out_dwf_label (cie_pointer, 0); d_outnl ();
993
  out32 (); out_dwf_label (proc_start, 0); d_outnl ();
994
  out32 (); out_dwf_labdiff (proc_start, proc_end); d_outnl ();
995
 
996
  if (callee_size >= 0) {
997
    unsigned long pop_bytes = 4;
998
    int n = (remove_struct_ref && has_struct_res(crt_proc_exp)) ? 32 : 0;
999
    if ((n += callee_size) != 0) {
1000
      pop_bytes += (unsigned long)(n/8);
1001
      out8 (); outn ((long)DW_CFA_DD_location);
1002
	outsep (); uleb128 ((unsigned long)dw_sp);
1003
	outsep (); outn ((long)1 + (long)uleb128_length(pop_bytes));
1004
	outsep (); outn ((long)DW_OP_plus_uconst);
1005
	outsep (); uleb128 (pop_bytes);	/* adjust virtual pops */
1006
	d_outnl ();
1007
    }
1008
  }
1009
  else {	/* var_callees */
1010
    int extra = (remove_struct_ref && has_struct_res(crt_proc_exp)) ? 2 : 0;
1011
    out8 (); outn ((long)DW_CFA_DD_location);
1012
	outsep (); uleb128 ((unsigned long)dw_sp);
1013
	outsep (); outn ((long)(3 + extra));	/* location block length */
1014
	outsep (); outn ((long)DW_OP_plus_uconst);
1015
	outsep (); uleb128 ((unsigned long)4);	/* virtual pop return address */
1016
	outsep (); outn ((long)DW_OP_deref);	/* over callees */
1017
	if (extra) {
1018
	  outsep (); outn ((long)DW_OP_plus_uconst);
1019
	  outsep (); uleb128 ((unsigned long)4);	/* pop struct_res */
1020
	}
1021
	d_outnl ();
1022
  }
1023
 
1024
  if (!no_frame) {
1025
    short_advance (proc_start, fblab);
1026
    out8 (); outn ((long)DW_CFA_def_cfa);
1027
	outsep (); uleb128 ((unsigned long)dwarfreg[6]);
1028
	outsep (); uleb128 ((unsigned long)4);	/* CFA now relative to %ebp */
1029
	d_outnl ();
1030
    out8 (); outn ((long)DW_CFA_offset + dwarfreg[6]); /* %ebp */
1031
	outsep (); uleb128 ((unsigned long)1); d_outnl ();
1032
  }
1033
 
1034
  if (flush_before_tell)
1035
    IGNORE fflush(fpout);
1036
  hold_pos = ftell (fpout);
1037
  outs (sp50); outs (sp50); outs (sp50); outs (sp50); outs (sp50); outs (sp50); outs (sp50);
1038
  d_outnl ();
1039
 
1040
  exit_section ();
1041
  return hold_pos;
1042
}
1043
 
1044
void dw2_fde_entry
1045
    PROTO_N ( (dwl0, dwl1, dwl2, dwl3, dwl4, dwl8, space) )
1046
    PROTO_T ( long dwl0 X long dwl1 X long dwl2 X long dwl3 X long dwl4 X long dwl8 X int space )
1047
{
1048
  long here = dwl0;
1049
  unsigned long up = 0;
1050
  if (!no_frame) {
1051
    here = dwl1;
1052
    ++up;
1053
  }
1054
  if (min_rfree & 0x8) {
1055
    short_advance (here, dwl2);
1056
    here = dwl2;
1057
    out8 ();
1058
    if (no_frame) {
1059
	outn ((long)DW_CFA_DD_def_cfa_inc_offset); outsep ();
1060
    }
1061
	outn ((long)DW_CFA_offset + dwarfreg[3]); /* %ebx */
1062
	outsep (); uleb128 (++up); d_outnl ();
1063
  }
1064
  if (min_rfree & 0x10) {
1065
    short_advance (here, dwl3);
1066
    here = dwl3;
1067
    out8 ();
1068
    if (no_frame) {
1069
	outn ((long)DW_CFA_DD_def_cfa_inc_offset); outsep ();
1070
    }
1071
	outn ((long)DW_CFA_offset + dwarfreg[4]); /* %edi */
1072
	outsep (); uleb128 (++up); d_outnl ();
1073
  }
1074
  if (min_rfree & 0x20) {
1075
    short_advance (here, dwl4);
1076
    here = dwl4;
1077
    out8 ();
1078
    if (no_frame) {
1079
	outn ((long)DW_CFA_DD_def_cfa_inc_offset); outsep ();
1080
    }
1081
	outn ((long)DW_CFA_offset + dwarfreg[5]); /* %esi */
1082
	outsep (); uleb128 (++up); d_outnl ();
1083
  }
1084
  if (no_frame && (min_rfree & 0x40)) {
1085
    short_advance (here, dwl1);
1086
    here = dwl1;
1087
    out8 (); outn ((long)DW_CFA_DD_def_cfa_inc_offset); outsep ();
1088
	outn ((long)DW_CFA_offset + dwarfreg[6]); /* %ebp */
1089
	outsep (); uleb128 (++up); d_outnl ();
1090
  }
1091
  if (space && no_frame) {
1092
    short_advance (here, dwl8);
1093
    out8 (); outn ((long)DW_CFA_def_cfa_offset); outsep ();
1094
	uleb128 ((unsigned long)space); d_outnl ();
1095
  }
1096
  return;
1097
}
1098
 
1099
void dw2_untidy_return
1100
    PROTO_Z ()
1101
{
1102
	/* we have pushed the return address */
1103
  long here = set_dw_text_label ();
1104
  enter_section ("debug_frame");
1105
  out8 (); outn ((long)DW_CFA_set_loc); d_outnl ();
1106
  out32 (); out_dwf_label (here, 0); d_outnl ();
1107
  out8 (); outn ((long)DW_CFA_remember_state); outsep ();
1108
  if (no_frame) {
1109
    outn ((long)DW_CFA_DD_def_cfa_inc_offset); d_outnl ();
1110
  }
1111
  exit_section ();
1112
  return;
1113
}
1114
 
1115
long dw2_prep_fde_restore_args
1116
    PROTO_N ( (untidy) )
1117
    PROTO_T ( int untidy )
1118
{
1119
  long here;
1120
  if (!untidy) {
1121
    long pos;
1122
    enter_section ("debug_frame");
1123
    out8 (); outn ((long)DW_CFA_remember_state); d_outnl ();
1124
    pos = ftell(fpout);
1125
    outs (sp50); outs (sp50); outs (sp50); outs (sp50); outs (sp50); outs (sp50);
1126
    d_outnl ();
1127
    d_outnl();
1128
    exit_section ();
1129
    return pos;
1130
  }
1131
	/* otherwise */
1132
  here = set_dw_text_label ();
1133
  enter_section ("debug_frame");
1134
  short_advance ((long)0, here);
1135
  out8 (); outn ((long)DW_CFA_restore + dwarfreg[3]); d_outnl ();
1136
  out8 (); outn ((long)DW_CFA_restore + dwarfreg[4]); d_outnl ();
1137
  out8 (); outn ((long)DW_CFA_restore + dwarfreg[5]); d_outnl ();
1138
  out8 (); outn ((long)DW_CFA_restore + dwarfreg[6]); d_outnl ();
1139
 
1140
  if (!no_frame) {	/* %ebp restored, return address pushed */
1141
    out8 (); outn ((long)DW_CFA_def_cfa);
1142
	outsep (); uleb128 ((unsigned long)dw_sp);
1143
	outsep (); uleb128 ((unsigned long)0);	/* temp CFA */
1144
	d_outnl ();
1145
    out8 (); outn ((long)DW_CFA_undefined);
1146
	outsep (); uleb128 ((unsigned long)dw_sp);
1147
	d_outnl ();
1148
  }
1149
  exit_section ();
1150
  return 0;
1151
}
1152
 
1153
void dw2_fde_restore_args
1154
    PROTO_N ( (dwl0, dwl1, dwl2, dwl3, dwl4, space) )
1155
    PROTO_T ( long dwl0 X long dwl1 X long dwl2 X long dwl3 X long dwl4 X int space )
1156
{
1157
  long here = 0;
1158
  if (no_frame && dwl0) {
1159
    short_advance (here, dwl0);
1160
    here = dwl0;
1161
    out8 (); outn ((long)DW_CFA_def_cfa_offset); outsep ();
1162
	uleb128 ((unsigned long)space); d_outnl ();
1163
  }
1164
  if (no_frame && (min_rfree & 0x40)) {
1165
    short_advance (here, dwl1);
1166
    here = dwl1;
1167
    out8 (); outn ((long)DW_CFA_DD_def_cfa_dec_offset); outsep ();
1168
	outn ((long)DW_CFA_restore + dwarfreg[6]); /* %ebp */
1169
	d_outnl ();
1170
  }
1171
  if (min_rfree & 0x20) {
1172
    short_advance (here, dwl2);
1173
    here = dwl2;
1174
    out8 ();
1175
    if (no_frame) {
1176
	outn ((long)DW_CFA_DD_def_cfa_dec_offset); outsep ();
1177
    }
1178
	outn ((long)DW_CFA_restore + dwarfreg[5]); /* %esi */
1179
	d_outnl ();
1180
  }
1181
  if (min_rfree & 0x10) {
1182
    short_advance (here, dwl3);
1183
    here = dwl3;
1184
    out8 ();
1185
    if (no_frame) {
1186
	outn ((long)DW_CFA_DD_def_cfa_dec_offset); outsep ();
1187
    }
1188
	outn ((long)DW_CFA_restore + dwarfreg[4]); /* %edi */
1189
	d_outnl ();
1190
  }
1191
  if (min_rfree & 0x8) {
1192
    short_advance (here, dwl4);
1193
    here = dwl4;
1194
    out8 ();
1195
    if (no_frame) {
1196
	outn ((long)DW_CFA_DD_def_cfa_dec_offset); outsep ();
1197
    }
1198
	outn ((long)DW_CFA_restore + dwarfreg[3]); /* %ebx */
1199
	d_outnl ();
1200
  }
1201
  if (!no_frame)  {
1202
    short_advance (here, dwl1);
1203
    here = dwl1;
1204
    out8 (); outn ((long)DW_CFA_restore + dwarfreg[6]); /* %ebp */
1205
	outsep (); outn ((long)DW_CFA_def_cfa);
1206
	outsep (); uleb128 ((unsigned long)dw_sp);
1207
	outsep (); uleb128 ((unsigned long)0);	/* CFA is sp at entry point */
1208
	d_outnl ();
1209
  }
1210
  UNUSED (here);
1211
}
1212
 
1213
void dw2_after_fde_exit
1214
    PROTO_N ( (here) )
1215
    PROTO_T ( long here )
1216
{
1217
  out_dwf_label (here, 1);
1218
  enter_section ("debug_frame");
1219
  short_advance ((long)0, here);
1220
  out8 (); outn ((long)DW_CFA_restore_state); d_outnl ();
1221
  exit_section ();
1222
  return;
1223
}
1224
 
1225
void dw2_track_push
1226
    PROTO_Z ()
1227
{
1228
  long here = set_dw_text_label ();
1229
  enter_section ("debug_frame");
1230
  short_advance ((long)0, here);
1231
  out8 (); outn ((long)DW_CFA_DD_def_cfa_inc_offset); d_outnl ();
1232
  exit_section ();
1233
  return;
1234
}
1235
 
1236
void dw2_track_pop
1237
    PROTO_Z ()
1238
{
1239
  long here = set_dw_text_label ();
1240
  enter_section ("debug_frame");
1241
  short_advance ((long)0, here);
1242
  out8 (); outn ((long)DW_CFA_DD_def_cfa_dec_offset); d_outnl ();
1243
  exit_section ();
1244
  return;
1245
}
1246
 
1247
void dw2_track_sp
1248
    PROTO_Z ()
1249
{
1250
  long here = set_dw_text_label ();
1251
  enter_section ("debug_frame");
1252
  short_advance ((long)0, here);
1253
  out8 (); outn ((long)DW_CFA_DD_def_cfa_fixed_offset); d_outnl ();
1254
  out32 (); outn ((long)((extra_stack - stack_dec) / 8));
1255
    outs("+");
1256
    outs(local_prefix);
1257
    outs ("disp");
1258
    outn ((long)crt_proc_id);
1259
  d_outnl ();
1260
  exit_section ();
1261
  return;
1262
}
1263
 
1264
 
1265
void dw2_complete_fde
1266
    PROTO_Z ()
1267
{
1268
  out_dwf_label (proc_end, 1);
1269
  enter_section ("debug_frame");
1270
  dot_align (PTR_SZ/8);
1271
  out_dwf_label (fde_end, 1);
1272
  exit_section ();
1273
  return;
1274
}
1275
 
1276
 
1277
void dw2_start_extra_bit
1278
    PROTO_N ( (body) )
1279
    PROTO_T ( exp body )
1280
{
1281
  dg_info di = new_dg_info (DGA_EXTRA);
1282
  di->data.i_scope.start = next_dwarf_label();
1283
  di->data.i_scope.end = next_dwarf_label();
1284
  di->more = dgf(body);
1285
  dgf(body) = di;
1286
  return;
1287
}
1288
 
1289
void dw2_end_extra_bit
1290
    PROTO_N ( (body) )
1291
    PROTO_T ( exp body )
1292
{
1293
  UNUSED (body);
1294
  return;
1295
}
1296
 
1297
 
1298
static exp lab_mark_list;
1299
 
1300
static void mark_lab
1301
    PROTO_N ( (labst) )
1302
    PROTO_T ( exp labst )
1303
{
1304
  if (!dg_labmark (labst)) {
1305
    set_dg_labmark (labst);
1306
    if (son(son(labst)) != nilexp)
1307
      failer ("strange labst");
1308
    son(son(labst)) = lab_mark_list;
1309
    lab_mark_list = labst;
1310
  }
1311
  return;
1312
}
1313
 
1314
static void trace_branch_aux
1315
    PROTO_N ( (whole, e) )
1316
    PROTO_T ( exp whole X exp e )
1317
{
1318
  exp t;
1319
  switch (name(e)) {
1320
    case test_tag:
1321
    case goto_tag: {
1322
      if (!intnl_to (whole, pt(e)))
1323
	mark_lab (pt(e));
1324
      break;
1325
    }
1326
    case case_tag: {
1327
      t = bro(son(e));
1328
      for (;;) {
1329
	if (!intnl_to (whole, pt(t)))
1330
	  mark_lab (pt(t));
1331
	if (last(t)) break;
1332
	t = bro(t);
1333
      }
1334
      break;
1335
    }
1336
    case labst_tag: {
1337
      t = final_dest(e);
1338
      if (!intnl_to (whole, t))
1339
	mark_lab (t);
1340
      break;
1341
    }
1342
    case name_tag:
1343
    case env_offset_tag:
1344
    case general_env_offset_tag:
1345
      return;
1346
  }
1347
  t = son(e);
1348
  if (t) {
1349
    for (;;) {
1350
      trace_branch_aux (whole, t);
1351
      if (last(t) || name(e) == case_tag) break;
1352
      t = bro(t);
1353
    }
1354
  }
1355
  return;
1356
}
1357
 
1358
void trace_dw_branch_exits
1359
    PROTO_N ( (e) )
1360
    PROTO_T ( exp e )
1361
{
1362
  lab_mark_list = nilexp;
1363
  trace_branch_aux (e, e);
1364
  while (lab_mark_list) {
1365
    exp labst = lab_mark_list;
1366
    exp dest = final_dest(labst);
1367
    clear_dg_labmark (labst);
1368
    lab_mark_list = son(son(labst));
1369
    son(son(labst)) = nilexp;
1370
    IGNORE dw_entry (dwe_break, (long)0);
1371
    out32 (); out_code_label ((long)ptno(pt(son(dest)))); d_outnl ();
1372
  }
1373
  return;
1374
}
1375
 
1376
 
1377
 
1378
int dw_loc_equivalence
1379
    PROTO_N ( (a, b) )
1380
    PROTO_T ( exp a X exp b )
1381
{
1382
  return eq_where_exp (a, b, 1, 0);
1383
}
1384
 
1385
typedef struct
1386
{
1387
  dg_name	nm;
1388
  long		start;
1389
  long		end;
1390
} dw_regassn;
1391
 
1392
typedef struct
1393
{
1394
  dg_name	alloc;
1395
  void *	share_set;
1396
  dw_regassn	assn [2];
1397
} dw_regdata;
1398
 
1399
#define TRACKREGS no_fixed_regs
1400
 
1401
static dw_regdata regassns [TRACKREGS];
1402
 
1403
 
1404
void dw_allocated
1405
    PROTO_N ( (nm, id) )
1406
    PROTO_T ( dg_name nm X exp id )
1407
{
1408
  int reg = no(id);
1409
  if (!isglob(id) && ptno(id) == reg_pl && reg < TRACKREGS) {
1410
    dw_close_regassn (reg, 0);
1411
    dw_close_regassn (reg, 1);
1412
    regassns[reg].alloc = nm;
1413
    regassns[reg].share_set = (void *)0;
1414
  }
1415
  return;
1416
}
1417
 
1418
void dw_deallocated
1419
    PROTO_N ( (nm) )
1420
    PROTO_T ( dg_name nm )
1421
{
1422
  int i;
1423
  for (i=0; i<TRACKREGS; i++) {
1424
    if (regassns[i].alloc == nm) {
1425
      dw_close_regassn (i, 0);
1426
      dw_close_regassn (i, 1);
1427
      regassns[i].alloc = (dg_name)0;
1428
      regassns[i].share_set = (void *)0;
1429
    }
1430
  }
1431
  return;
1432
}
1433
 
1434
void dw_all_deallocated		/* initialisation */
1435
    PROTO_Z ()
1436
{
1437
  int i;
1438
  for (i=0; i<TRACKREGS; i++) {
1439
    dw_regassn * a = &(regassns[i].assn[0]);
1440
    dw_regassn * b = &(regassns[i].assn[1]);
1441
    regassns[i].alloc = (dg_name)0;
1442
    regassns[i].share_set = (void *)0;
1443
    a->start = a->end = b->start = b->end = (long)0;
1444
  }
1445
  return;
1446
}
1447
 
1448
 
1449
int dw_ignore_used_regassn = 0;
1450
 
1451
void dw_init_regassn
1452
    PROTO_N ( (reg, x) )
1453
    PROTO_T ( int reg X int x )
1454
{
1455
  if (reg < TRACKREGS) {
1456
    dg_name nm = find_equiv_object ((!x ? crt_reg_record[reg].first_dest
1457
				: crt_reg_record[reg].second_dest), 0);
1458
    if (nm) {
1459
      dw_regassn * a = &(regassns[reg].assn[x]);
1460
      a->nm = nm;
1461
      a->start = set_dw_text_label ();
1462
      a->end = (long)0;
1463
    }
1464
  }
1465
  return;
1466
}
1467
 
1468
void dw_used_regassn
1469
    PROTO_N ( (reg, x) )
1470
    PROTO_T ( int reg X int x )
1471
{
1472
  if (reg < TRACKREGS && regassns[reg].assn[x].start)
1473
    regassns[reg].assn[x].end = set_dw_text_label ();
1474
  return;
1475
}
1476
 
1477
void dw_close_regassn
1478
    PROTO_N ( (reg, x) )
1479
    PROTO_T ( int reg X int x )
1480
{
1481
  dw_regassn * a;
1482
  if (dw_ignore_used_regassn || reg >= TRACKREGS)
1483
    return;
1484
  a = &(regassns[reg].assn[x]);
1485
  if (a->end) {
1486
    if (!regassns[reg].share_set) {
1487
      regassns[reg].share_set = (void *)
1488
		dw_new_regshare (regassns[reg].alloc, dwarfreg[reg]);
1489
    }
1490
    dw_add_regshare (regassns[reg].share_set, a->nm,
1491
		a->start, a->end);
1492
    a->end = (long)0;
1493
    if (!regassns[reg].alloc && !regassns[reg].assn[1-x].start)
1494
      regassns[reg].share_set = (void *)0;
1495
  }
1496
  a->start = (long)0;
1497
  return;
1498
}
1499
 
1500
#endif