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
    Copyright (c) 1993 Open Software Foundation, Inc.
3
 
4
 
5
    All Rights Reserved
6
 
7
 
8
    Permission to use, copy, modify, and distribute this software
9
    and its documentation for any purpose and without fee is hereby
10
    granted, provided that the above copyright notice appears in all
11
    copies and that both the copyright notice and this permission
12
    notice appear in supporting documentation.
13
 
14
 
15
    OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING
16
    ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
17
    PARTICULAR PURPOSE.
18
 
19
 
20
    IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
21
    CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
22
    LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
23
    NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
24
    WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25
*/
26
 
27
/*
28
    		 Crown Copyright (c) 1997
29
 
30
    This TenDRA(r) Computer Program is subject to Copyright
31
    owned by the United Kingdom Secretary of State for Defence
32
    acting through the Defence Evaluation and Research Agency
33
    (DERA).  It is made available to Recipients with a
34
    royalty-free licence for its use, reproduction, transfer
35
    to other parties and amendment for any purpose not excluding
36
    product development provided that any such use et cetera
37
    shall be deemed to be acceptance of the following conditions:-
38
 
39
        (1) Its Recipients shall ensure that this Notice is
40
        reproduced upon any copies or amended versions of it;
41
 
42
        (2) Any amended version of it shall be clearly marked to
43
        show both the nature of and the organisation responsible
44
        for the relevant amendment or amendments;
45
 
46
        (3) Its onward transfer from a recipient to another
47
        party shall be deemed to be that party's acceptance of
48
        these conditions;
49
 
50
        (4) DERA gives no warranty or assurance as to its
51
        quality or suitability for any purpose and DERA accepts
52
        no liability whatsoever in relation to any use to which
53
        it may be put.
54
*/
55
 
56
 
57
#include "config.h"
58
#ifdef DEBUG_POWERTRANS
59
#include "common_types.h"
60
#include "exptypes.h"
61
#include "expmacs.h"
62
#include "exp.h"
63
#include "tags.h"
64
#include "shapemacs.h"
65
#include "ash.h"
66
#include "addresstypes.h"
67
#include "locate.h"
68
#include "translat.h"
69
 
70
#include "pp.h"
71
/*
72
 * This file contains debugging tools used in debugging a translator
73
 */
74
 
75
void properties PROTO_S ((int));
76
exp show_bro PROTO_S ((int));
77
exp show_son PROTO_S ((int));
78
exp show_current PROTO_S ((int));
79
exp show_father PROTO_S ((int));
80
exp show_pt PROTO_S ((int));
81
exp recurse PROTO_S ((int));
82
exp infotag PROTO_S ((exp,int));
83
void showme PROTO_S ((exp,int,int));
84
static exp last_exp_seen=NULL;
85
static exp last_exp_seen1=NULL;
86
static exp last_exp_seen2=NULL;
87
static exp last_exp_seen3=NULL;
88
static exp last_exp_seen4=NULL;
89
static exp last_exp_seen5=NULL;
90
 
91
static void exp_show PROTO_S ((exp,int,int,int));
92
char *find_test_name PROTO_S ((exp));
93
static void myprint PROTO_S ((char *));
94
char *shape_name PROTO_S ((int ));
95
char *getname PROTO_S ((int));
96
void ident_props PROTO_S ((exp));
97
void proc_tag_props PROTO_S ((exp));
98
void general_proc_tag_props PROTO_S ((exp));
99
void solve_props PROTO_S ((exp));
100
void movecont_props PROTO_S ((exp));
101
void cont_props PROTO_S ((exp));
102
void labst_props PROTO_S ((exp));
103
void name_props PROTO_S ((exp));
104
void string_props PROTO_S ((exp));
105
void val_props PROTO_S ((exp));
106
void rep_props PROTO_S ((exp));
107
void apply_props PROTO_S ((exp));
108
 
109
static exp stored_idents[1000];
110
static exp stored_labsts[1000];
111
static int store_ident PROTO_S ((exp));
112
static int store_labst PROTO_S ((exp));
113
static int no_of_idents_stored=0;
114
static int no_of_labsts_stored=0;
115
static int ident_no PROTO_S ((exp));
116
static int labst_no PROTO_S ((exp));
117
 
118
static int store_ident PROTO_N ((e)) PROTO_T (exp e)
119
{
120
  no_of_idents_stored++;
121
  stored_idents[no_of_idents_stored]=e;
122
  return no_of_idents_stored;
123
}
124
static int store_labst PROTO_N ((e)) PROTO_T (exp e)
125
{
126
  no_of_labsts_stored++;
127
  stored_labsts[no_of_labsts_stored]=e;
128
  return no_of_labsts_stored;
129
}
130
static int ident_no PROTO_N ((e)) PROTO_T (exp e)
131
{
132
  int i;
133
  for (i=no_of_idents_stored;i>0;i--)
134
    if(stored_idents[i]==e) return i;
135
  return 0;
136
}
137
static int labst_no PROTO_N ((e)) PROTO_T (exp e)
138
{
139
  int i;
140
  for (i=no_of_labsts_stored;i>0;i--)
141
    if(stored_labsts[i]==e) return i;
142
  return 0;
143
}
144
void scan_for_labsts PROTO_N ((e)) PROTO_T (exp e)
145
{
146
  if (e==nilexp)
147
    return;
148
  switch(name(e))
149
  {
150
   case labst_tag:
151
    store_labst(e);
152
    break;
153
   case ident_tag:
154
    store_ident(e);
155
    break;
156
    /* don't scan sons of these tags */
157
   case name_tag:
158
   case env_offset_tag:
159
    if(!last(e)) scan_for_labsts(bro(e));
160
    return;
161
    /* don't scan bros of these tags */
162
   case case_tag:
163
    scan_for_labsts(son(e));
164
    return;
165
  }
166
  scan_for_labsts(son(e));
167
  if(!last(e)) scan_for_labsts(bro(e));
168
  return;
169
}
170
 
171
 
172
 
173
void showme PROTO_N ((e,depth_of_recursion,flag)) PROTO_T (exp e X int depth_of_recursion X int flag)
174
{
175
  no_of_labsts_stored=0;
176
  no_of_idents_stored=0;
177
  if (name(e)==labst_tag)
178
    store_labst(e);
179
  if (name(e)==ident_tag)
180
    store_ident(e);
181
  scan_for_labsts(son(e));
182
  exp_show(e,0,depth_of_recursion,flag);
183
  return;
184
}
185
 
186
exp show_current PROTO_N ((i)) PROTO_T (int i)
187
{
188
  exp l;
189
  switch(i)
190
  {
191
   case 0:l=last_exp_seen;break;
192
   case 1:l=last_exp_seen1;break;
193
   case 2:l=last_exp_seen2;break;
194
   case 3:l=last_exp_seen3;break;
195
   case 4:l=last_exp_seen4;break;
196
   case 5:l=last_exp_seen5;break;
197
  }
198
 
199
  if (l==NULL)
200
  {
201
    printf("No current exp for stored exp no %d\n",i);
202
  }
203
  else
204
  {
205
    infotag(l,i);
206
  }
207
  return l;
208
}
209
 
210
exp show_bro PROTO_N ((i)) PROTO_T (int i)
211
{
212
  exp l;
213
  switch(i)
214
  {
215
   case 0:l=last_exp_seen;break;
216
   case 1:l=last_exp_seen1;break;
217
   case 2:l=last_exp_seen2;break;
218
   case 3:l=last_exp_seen3;break;
219
   case 4:l=last_exp_seen4;break;
220
   case 5:l=last_exp_seen5;break;
221
  }
222
 
223
  if (l==NULL)
224
  {
225
    printf("No current exp\n");
226
    return NULL;
227
  }
228
 
229
  if(bro(l)!=NULL)
230
  {
231
    infotag(bro(l),i);
232
  }
233
  else
234
  {
235
    printf("No brother field to stored exp no %d\n",i);
236
  }
237
  return l;
238
 
239
 
240
}
241
exp show_son PROTO_N ((i)) PROTO_T (int i)
242
{
243
  exp l;
244
  switch(i)
245
  {
246
   case 0:l=last_exp_seen;break;
247
   case 1:l=last_exp_seen1;break;
248
   case 2:l=last_exp_seen2;break;
249
   case 3:l=last_exp_seen3;break;
250
   case 4:l=last_exp_seen4;break;
251
   case 5:l=last_exp_seen5;break;
252
  }
253
 
254
  if(l==NULL)
255
  {
256
    printf("No current exp\n");
257
    return 0;
258
 
259
  }
260
 
261
  if(son(l)!=NULL)
262
  {
263
    infotag(son(l),i);
264
  }
265
  else
266
  {
267
    printf("No son field to stored exp no %d\n",i);
268
  }
269
  return l;
270
 
271
}
272
exp show_father PROTO_N ((i)) PROTO_T (int i)
273
{
274
  exp l;
275
  switch(i)
276
  {
277
   case 0:l=last_exp_seen;break;
278
   case 1:l=last_exp_seen1;break;
279
   case 2:l=last_exp_seen2;break;
280
   case 3:l=last_exp_seen3;break;
281
   case 4:l=last_exp_seen4;break;
282
   case 5:l=last_exp_seen5;break;
283
  }
284
 
285
  if(l==NULL)
286
  {
287
    printf("No current stored exp no %d\n",i);
288
    return NULL;
289
  }
290
  if (father(l)!=NULL)
291
  {
292
    infotag(father(l),i);
293
  }
294
  else
295
  {
296
    printf("Cannot find father of stored exp no %d\n",i);
297
  }
298
  return l;
299
}
300
exp show_pt PROTO_N ((i)) PROTO_T (int i)
301
{
302
  exp l;
303
  switch(i)
304
  {
305
   case 0:l=last_exp_seen;break;
306
   case 1:l=last_exp_seen1;break;
307
   case 2:l=last_exp_seen2;break;
308
   case 3:l=last_exp_seen3;break;
309
   case 4:l=last_exp_seen4;break;
310
   case 5:l=last_exp_seen5;break;
311
  }
312
 
313
  if(l==NULL)
314
  {
315
    printf("No current exp\n");
316
    return 0;
317
 
318
  }
319
 
320
  if(pt(l)!=NULL)
321
  {
322
    infotag(pt(l),i);
323
  }
324
  else
325
  {
326
    printf("No pt field to stored exp no %d\n",i);
327
  }
328
  return l;
329
 
330
}
331
 
332
exp recurse PROTO_N ((i)) PROTO_T (int i)
333
{
334
  exp l;
335
  switch(i)
336
  {
337
   case 0:l=last_exp_seen;break;
338
   case 1:l=last_exp_seen1;break;
339
   case 2:l=last_exp_seen2;break;
340
   case 3:l=last_exp_seen3;break;
341
   case 4:l=last_exp_seen4;break;
342
   case 5:l=last_exp_seen5;break;
343
  }
344
 
345
  if(l==NULL)
346
  {
347
    printf("No current exp for no %d (Use infotag)\n",i);
348
  }
349
  else
350
  {
351
    showme(l,-1,1);
352
  }
353
  return l;
354
}
355
 
356
 
357
char * getname PROTO_N ((n)) PROTO_T (int n)
358
{
359
  char * tagname;
360
  switch (n){
361
   case 0                     :tagname= "zero";break;
362
   case ident_tag             :tagname= "ident";break;
363
   case seq_tag               :tagname= "seq";break;
364
   case cond_tag              :tagname= "cond";break;
365
   case labst_tag             :tagname= "labst";break;
366
   case rep_tag               :tagname= "rep";break;
367
   case goto_tag              :tagname= "goto";break;
368
   case test_tag              :tagname= "test";break;
369
   case ass_tag               :tagname= "ass";break;
370
   case apply_tag             :tagname= "apply";break;
371
   case res_tag               :tagname= "res";break;
372
   case goto_lv_tag           :tagname= "goto_lv";break;
373
   case solve_tag             :tagname= "solve";break;
374
   case assvol_tag            :tagname= "assvol";break;
375
   case compound_tag          :tagname= "compound";break;
376
   case nof_tag               :tagname= "nof";break;
377
   case local_free_all_tag    :tagname= "local_free_all";break;
378
   case local_free_tag        :tagname= "local_free";break;
379
   case last_local_tag        :tagname= "last_local";break;
380
   case long_jump_tag         :tagname= "long_jump";break;
381
   case concatnof_tag         :tagname= "concatnof";break;
382
   case ncopies_tag           :tagname= "ncopies";break;
383
   case case_tag              :tagname= "case";break;
384
   case movecont_tag          :tagname= "movecont";break;
385
   case testbit_tag           :tagname= "testbit";break;
386
   case alloca_tag            :tagname= "alloca";break;
387
   case diagnose_tag          :tagname= "diagnose";break;
388
   case prof_tag              :tagname= "prof";break;
389
   case ignorable_tag         :tagname= "ignorable";break;
390
   case bfass_tag             :tagname= "bfass";break;
391
   case bfassvol_tag          :tagname= "bfassvol";break;
392
   case condassign_tag        :tagname= "condassign";break;
393
   case apply_general_tag     :tagname= "apply_general";break;
394
   case tail_call_tag         :tagname= "tail_call";break;
395
   case untidy_return_tag     :tagname= "untidy_return";break;
396
   case same_callees_tag      :tagname= "same_callees";break;
397
   case plus_tag              :tagname= "plus";break;
398
   case neg_tag               :tagname= "neg";break;
399
   case shl_tag               :tagname= "shl";break;
400
   case mod_tag               :tagname= "mod";break;
401
   case rem2_tag              :tagname= "rem2";break;
402
   case abs_tag               :tagname= "abs";break;
403
   case round_tag             :tagname= "round";break;
404
   case offset_pad_tag        :tagname= "offset_pad";break;
405
   case offset_div_tag        :tagname= "offset_div";break;
406
   case offset_max_tag        :tagname= "offset_max";break;
407
   case minptr_tag            :tagname= "minptr";break;
408
   case fpower_tag            :tagname= "fpower";break;
409
   case fplus_tag             :tagname= "fplus";break;
410
   case fminus_tag            :tagname= "fminus";break;
411
   case fmult_tag             :tagname= "fmult";break;
412
   case fdiv_tag              :tagname= "fdiv";break;
413
   case fabs_tag              :tagname= "fabs";break;
414
   case fneg_tag              :tagname= "fneg";break;
415
   case float_tag             :tagname= "float";break;
416
   case chfl_tag              :tagname= "chfl";break;
417
   case and_tag               :tagname= "and";break;
418
   case or_tag                :tagname= "or";break;
419
   case xor_tag               :tagname= "xor";break;
420
   case not_tag               :tagname= "not";break;
421
   case component_tag         :tagname= "component";break;
422
   case max_tag               :tagname= "max";break;
423
   case min_tag               :tagname= "min";break;
424
   case bitf_to_int_tag       :tagname= "bitf_to_int";break;
425
   case bfcont_tag            :tagname= "bfcont";break;
426
   case fmax_tag              :tagname= "fmax";break;
427
   case shr_tag               :tagname= "shr";break;
428
   case fmin_tag              :tagname= "fmin";break;
429
   case div0_tag              :tagname= "div0";break;
430
   case bfcontvol_tag         :tagname= "bfcontvol";break;
431
   case absbool_tag           :tagname= "absbool";break;
432
   case addptr_tag            :tagname= "addptr";break;
433
   case chvar_tag             :tagname= "chvar";break;
434
   case minus_tag             :tagname= "minus";break;
435
   case mult_tag              :tagname= "mult";break;
436
   case subptr_tag            :tagname= "subptr";break;
437
   case realpart_tag          :tagname= "realpart";break;
438
   case div1_tag              :tagname= "div1";break;
439
   case div2_tag              :tagname= "div2";break;
440
   case offset_add_tag        :tagname= "offset_add";break;
441
   case offset_div_by_int_tag :tagname= "offset_div_by_int";break;
442
   case offset_mult_tag       :tagname= "offset_mult";break;
443
   case offset_negate_tag     :tagname= "offset_negate";break;
444
   case offset_subtract_tag   :tagname= "offset_subtract";break;
445
   case rem0_tag              :tagname= "rem0";break;
446
   case rotl_tag              :tagname= "rotl";break;
447
   case rotr_tag              :tagname= "rotr";break;
448
   case power_tag             :tagname= "power";break;
449
   case imag_tag              :tagname= "imag";break;
450
   case make_complex_tag      :tagname= "make_complex";break;
451
   case int_to_bitf_tag       :tagname= "int_to_bitf";break;
452
   case hold_tag              :tagname= "hold";break;
453
   case hold2_tag             :tagname= "hold2";break;
454
   case cont_tag              :tagname= "cont";break;
455
   case field_tag             :tagname= "field";break;
456
   case val_tag               :tagname= "val";break;
457
   case reff_tag              :tagname= "reff";break;
458
   case name_tag              :tagname= "name";break;
459
   case proc_tag              :tagname= "proc";break;
460
   case top_tag               :tagname= "top";break;
461
   case contvol_tag           :tagname= "contvol";break;
462
   case current_env_tag       :tagname= "current_env";break;
463
   case env_offset_tag        :tagname= "env_offset";break;
464
   case make_lv_tag           :tagname= "make_lv";break;
465
   case clear_tag             :tagname= "clear";break;
466
   case null_tag              :tagname= "null";break;
467
   case real_tag              :tagname= "real";break;
468
   case string_tag            :tagname= "string";break;
469
   case general_proc_tag      :tagname= "general_proc";break;     
470
   case env_size_tag          :tagname= "env_size";break;
471
   case give_stack_limit_tag  :tagname= "give_stack_limit";break;
472
   case general_env_offset_tag:tagname= "general_env_offset";break;
473
   case caller_tag            :tagname= "caller";break;
474
   case caller_name_tag       :tagname= "caller_name";break;
475
   case make_dynamic_callee_tag:tagname="make_dynamic_callee";break;
476
   case make_callee_list_tag  :tagname= "make_callee_list";break;
477
   case set_stack_limit_tag   :tagname= "set_stack_limit";break;
478
   case formal_callee_tag     :tagname= "formal_callee";break;
479
   case trap_tag              :tagname= "trap_tag";break;
480
 
481
    /* Powertrans specific */
482
   case locptr_tag           :tagname= "locptr_tag";break;
483
 
484
   default                    :tagname= "undefined";
485
 
486
  }
487
  return tagname;
488
}
489
 
490
exp infotag PROTO_N ((e,i)) PROTO_T (exp e X int i)
491
{
492
  switch(i)
493
  {
494
   case 0:last_exp_seen=e;break;
495
   case 1:last_exp_seen1=e;break;
496
   case 2:last_exp_seen2=e;break;
497
   case 3:last_exp_seen3=e;break;
498
   case 4:last_exp_seen4=e;break;
499
   case 5:last_exp_seen5=e;break;
500
  }
501
 
502
  if (e==nilexp){
503
    printf("Error 'nilexp'\n");
504
    return e;
505
  }
506
  printf("-------------------------------------------------------------------------------\n");
507
  printf("| %-17s 0x%-8x         | SHAPE information                    |\n",getname(name(e)),(unsigned int)e);
508
  printf("-------------------------------------------------------------------------------\n");
509
  printf("| no(e)        = %-15d       ",no(e));
510
  if(sh(e)!=NULL)
511
  {
512
    printf("| name(sh(e))        = %-15s |\n",shape_name(name(sh(e))));
513
  }
514
  else
515
  {
516
    printf("| No shape                             |\n");
517
  }
518
  printf("| props(e)     = ");
519
  {
520
    int i;
521
    unsigned short mask;
522
    for (i=15;i>=0;i--)
523
    {
524
      mask=1<<i;
525
      if (mask & props(e))
526
      {
527
	printf("1");
528
      }
529
      else 
530
      {
531
	printf("0");
532
      }
533
 
534
      if (i%4 == 0)
535
      {
536
	printf(" ");
537
      }
538
    }
539
  }
540
 
541
  if(sh(e)!=NULL)
542
  {
543
    printf("  | shape_size(sh(e))  = %-8d        |\n",shape_size(sh(e)));
544
  }
545
  else
546
  {
547
    printf("  |                                      |\n");
548
  }
549
 
550
  printf("| bro(e)       = 0x%-8x            ",(unsigned int)bro(e));  
551
 
552
  if(sh(e)!=NULL)
553
  {
554
 
555
    printf("| shape_align(sh(e)) = %-8d        |",(int)shape_align(sh(e)));
556
 
557
  }
558
  else
559
  {
560
    printf("|                                      |");
561
  }
562
  if(bro(e)!=NULL)
563
  {
564
    if(last(e))
565
    {
566
      printf("-->father:%s\n",getname(name(bro(e))));
567
    }
568
    else
569
    {
570
      printf("-->brother:%s\n",getname(name(bro(e))));
571
    }
572
  }
573
  else
574
  {
575
    printf("-->NULL\n");
576
  }
577
 
578
 
579
  printf("| sh(e)        = 0x%-8x            ",(unsigned int)sh(e));
580
 
581
  if(sh(e)!=NULL)
582
  {
583
    printf("| is_signed(sh(e))   = %-2d              |\n",is_signed(sh(e)));
584
  }
585
  else
586
  {
587
    printf("|                                      |\n");
588
  }
589
  printf("| pt(e)        = 0x%-8x            ",(unsigned int)pt(e));  
590
 
591
  if(sh(e)!=NULL)
592
  {
593
    printf("| al1(sh(e))         = %-2d              |\n",(int)al1(sh(e)));
594
  }
595
  else
596
  {
597
    printf("|                                      |\n");
598
  }
599
 
600
  printf("| last(e)      = %d                     ",last(e));
601
 
602
  if(sh(e)!=NULL)
603
  {
604
    printf("| al2(sh(e))         = %-2d              |\n",(int)al2(sh(e)));
605
  }
606
  else
607
  {
608
    printf("|                                      |\n");
609
  }
610
 
611
  printf("-------------------------------------------------------------------------------\n");
612
  if(son(e)!=nilexp)
613
  {
614
    int finished=0;
615
    exp point=son(e);    
616
    if (name(e)==name_tag)
617
    {
618
      printf("son is ident 0x%-8x\n",(unsigned int)son(e));
619
      return e;
620
    }
621
 
622
    printf("                |\n");
623
 
624
    /* first line */
625
    while(!finished)
626
    {
627
      finished=last(point);
628
      printf("------------------------------   ");
629
      point=bro(point);
630
    }
631
    printf("\n");
632
    /* second line */
633
    point=son(e);
634
    finished=0;
635
    while(!finished)
636
    {
637
      finished=last(point);
638
      printf("| %-17s0x%-8x|   ",getname(name(point)),(unsigned int)point);
639
      point=bro(point);
640
    }
641
    printf("\n");
642
    /**/
643
    point=son(e);
644
    finished=0;
645
    while(!finished)
646
    {
647
      finished=last(point);
648
      printf("------------------------------   ");
649
      point=bro(point);
650
    }
651
    printf("\n");
652
    /* new line */
653
    point=son(e);
654
    finished=0;
655
    while(!finished)
656
    {
657
      finished=last(point);
658
      printf("| no          = %-10d   |   ",no(point));      
659
      point=bro(point);
660
    }
661
    printf("\n");
662
    /* new line */
663
    point=son(e);
664
    finished=0;
665
    while(!finished)
666
    {
667
      finished=last(point);
668
      printf("| pt          = 0x%-8x   |   ",(unsigned int)pt(point));      
669
      point=bro(point);
670
    }
671
    printf("\n");
672
    /* third line */
673
    point=son(e);
674
    finished=0;
675
    while(!finished)
676
    {
677
      finished=last(point);
678
      if(sh(point)!=NULL)
679
      {
680
	printf("| name(sh) = %-15s |",shape_name(name(sh(point))));      
681
      }
682
      else
683
      {
684
	printf("|                            |");
685
      }
686
      if(finished==0)
687
      {
688
	printf("-->");
689
      }
690
      point=bro(point);
691
    }
692
    printf("\n");
693
 
694
    /* fourth line */
695
    point=son(e);
696
    finished=0;
697
    while(!finished)
698
    {
699
      finished=last(point);
700
      if(sh(point)!=NULL)
701
      {
702
	printf("| shape_size  = %-4d         |   ",shape_size(sh(point)));
703
      }
704
      else
705
      {
706
	printf("|                            |   ");
707
      }
708
      point=bro(point);
709
    }
710
    printf("\n");
711
    /**/
712
    point=son(e);
713
    finished=0;
714
    while(!finished)
715
    {
716
      finished=last(point);
717
      if(sh(point)!=NULL)
718
      {
719
	printf("| shape_align = %-4d         |   ",(int)shape_align(sh(point)));
720
      }
721
      else
722
      {
723
	printf("|                            |   ");
724
      }
725
      point=bro(point);
726
    }
727
    printf("\n");
728
    /* fifth_line */
729
    point=son(e);
730
    finished=0;
731
    while(!finished)
732
    {
733
      finished=last(point);
734
      if(sh(point)!=NULL)
735
      {
736
	printf("| is_signed   = %-4d         |   ",is_signed(sh(e)));
737
      }
738
      else
739
      {
740
	printf("|                            |   ");
741
      }
742
 
743
      point=bro(point);
744
    }
745
    printf("\n");
746
    /**/
747
    point=son(e);
748
    finished=0;
749
    while(!finished)
750
    {
751
      finished=last(point);
752
      printf("------------------------------   ");
753
      point=bro(point);
754
    }
755
    printf("\n");
756
    /* last line */
757
    point=son(e);
758
    finished=0;
759
    while(!finished)
760
    {
761
      finished=last(point);
762
      if(son(point)==NULL)
763
      {
764
 
765
	printf("                                 ");
766
      }
767
      else 
768
      {
769
	printf("                |                ");
770
      }
771
 
772
 
773
      point=bro(point);
774
    }
775
    printf("\n");
776
  }
777
 
778
 
779
 
780
 
781
 
782
  return e;
783
}
784
static void print_spaces PROTO_N ((n)) PROTO_T (int n)
785
{
786
  int i;
787
  int j=0;
788
  for (i=0;i<n;i++)
789
  {
790
    switch(j)
791
    {
792
     case 0:printf(" ");break;
793
     case 1:printf(" ");break;
794
     case 2:printf("|");break;
795
     } 
796
     j++;
797
    if (j==3)
798
      j=0;
799
  }
800
 
801
}
802
 
803
 
804
static void exp_show PROTO_N ((e,depth,depth_of_recursion,flag)) PROTO_T (exp e X int depth X int depth_of_recursion X int flag)
805
{
806
  char *tagname;
807
 
808
  if( e == nilexp || depth == depth_of_recursion )
809
    return;
810
  printf("(0x%x)",(int)e);
811
  tagname = getname(name(e));
812
 
813
  print_spaces(depth);
814
 
815
  switch(name(e))
816
  {
817
    /* Don't want to look down son's of name_tag's or env_offset_tag because this will take you to
818
ident_tag's and thus into an infinite loop */
819
 
820
   case proc_tag:
821
   case general_proc_tag:
822
    {
823
      if (done_scan==1)
824
      {
825
	baseoff b = boff(father(e));
826
	char *ext;
827
	ext = main_globals[(-b.base) - 1]->dec_u.dec_val.dec_id;
828
	printf("%s:\"%s\"\n",tagname,ext);
829
      }
830
      else
831
      {
832
	printf("%s:\n",tagname);
833
      }
834
 
835
      exp_show(son(e),depth+1,depth_of_recursion,0);
836
      break;
837
    }
838
 
839
   case name_tag:
840
    {
841
      int l = ident_no(son(e));
842
      if(l)
843
	printf("%s:<%s> no=%d obtain {tag~%04d}\n",tagname,shape_name(name(sh(e))),no(e),l);
844
#if 1
845
      else if(name(sh(e))==prokhd &&(name(son(son(e)))==proc_tag||son(son(e))==nilexp||name(son(son(e)))==general_proc_tag) && done_scan==1)
846
      {
847
	baseoff b = boff(son(e));
848
	char *ext;
849
	ext = main_globals[(-b.base) - 1]->dec_u.dec_val.dec_id;
850
	printf("%s:<%s> function \"%s\"(0x%x)\n",tagname,shape_name(name(sh(e))),ext,(int)(son(e)));
851
      }
852
#endif
853
      else
854
	printf("%s:<%s> no=%d obtain (0x%x)\n",tagname,shape_name(name(sh(e))),no(e),(int)son(e));
855
      break;
856
    }
857
   case trap_tag:
858
    {
859
      printf("%s:no=%d\n",tagname,no(e));
860
      exp_show(son(e),depth+1,depth_of_recursion,0);
861
      break;
862
    }
863
 
864
   case general_env_offset_tag:
865
   case env_offset_tag:
866
    {
867
      int l = ident_no(son(e));
868
      if(l)
869
	printf("%s:<%s> for ident {tag~%04d}\n",tagname,shape_name(name(sh(e))),l);
870
      else
871
	printf("%s:<%s> for ident (0x%x)\n",tagname,shape_name(name(sh(e))),(int)son(e));
872
      break;
873
    }
874
   case caller_name_tag:
875
    {
876
      printf("%s:<%s> for caller NO_%d\n",tagname,shape_name(name(sh(e))),no(e));
877
      break;
878
    } 
879
   case case_tag:
880
    printf("%s:<%s>\n",tagname,shape_name(name(sh(e))));
881
    exp_show(son(e),depth+1,depth_of_recursion,1);
882
    {
883
      exp s=son(e);
884
      do
885
      {
886
	int label;
887
	s=bro(s);
888
	printf("(0x%x)",(int)s);
889
	print_spaces(depth+1);
890
	printf("(%d",no(s));
891
	if(son(s)!=nilexp)
892
	  printf("-%d)",no(son(s)));
893
	else 
894
	  printf(")");
895
	label = labst_no(pt(s));
896
	if (label)
897
	  printf(" ----> {label~%04d}\n",label);
898
	else
899
	  printf(" ----> (0x%x)\n",(int)pt(s));
900
      }
901
      while ( !last(s));
902
    }
903
    break;
904
   case goto_tag:
905
    {
906
      int label= labst_no(pt(e));
907
      if (label)
908
	printf("%s:<%s> ---->{label~%04d}\n",tagname,shape_name(name(sh(e))),label);
909
      else
910
	printf("%s:<%s> ---->(0x%x)\n",tagname,shape_name(name(sh(e))),(int)pt(e));
911
      exp_show(son(e),depth+1,depth_of_recursion,0);
912
      break;
913
    }
914
   case fdiv_tag:
915
   case fplus_tag:
916
   case fminus_tag:
917
   case fneg_tag:
918
   case fpower_tag:
919
   case mult_tag:
920
   case neg_tag:
921
   case plus_tag:
922
   case power_tag:
923
   case rem0_tag:
924
   case rem2_tag:
925
   case mod_tag:
926
   case round_tag:
927
   case shl_tag:
928
   case shr_tag:
929
 
930
    if (optop(e))
931
    {
932
      printf("%s:<%s>\n",tagname,shape_name(name(sh(e))));
933
    }
934
    else
935
    {
936
      int label = labst_no(pt(e));
937
      if (label)
938
	printf("%s:<%s> error_jump=>{label~%04d}\n",tagname,shape_name(name(sh(e))),label);
939
      else
940
	printf("%s:<%s> error_jump=>0x%x\n",tagname,shape_name(name(sh(e))),(unsigned int)pt(e));
941
    }
942
    exp_show(son(e),depth+1,depth_of_recursion,0);
943
    break;
944
 
945
 
946
 
947
   case last_local_tag:
948
    printf("%s: pt=0x%x\n",tagname,(unsigned int)pt(e));
949
    exp_show(son(e),depth+1,depth_of_recursion,0);
950
    break;
951
   case make_lv_tag:
952
    {
953
      int label = labst_no(pt(e));
954
      if(label)
955
	printf("%s: {label~%04d}\n",tagname,label);
956
      else
957
	printf("%s: Label=0x%x\n",tagname,(unsigned int)pt(e));
958
      exp_show(son(e),depth+1,depth_of_recursion,0);
959
      break;
960
    }
961
 
962
   case seq_tag:
963
   case rotl_tag:
964
   case rotr_tag:
965
   case realpart_tag:
966
   case nof_tag:
967
   case not_tag:
968
   case null_tag:
969
   case offset_add_tag:
970
   case offset_div_tag:
971
   case offset_max_tag:
972
   case offset_mult_tag:
973
   case offset_negate_tag:
974
   case offset_pad_tag:
975
   case offset_subtract_tag:
976
   case or_tag:
977
   case minptr_tag:
978
   case ignorable_tag:
979
   case imag_tag:
980
   case float_tag:
981
   case fmax_tag:
982
   case fmin_tag:
983
   case fabs_tag:
984
   case div2_tag:
985
   case div1_tag:   
986
   case div0_tag:
987
   case current_env_tag:
988
   case concatnof_tag:
989
   case abs_tag:
990
   case addptr_tag:
991
   case alloca_tag:
992
   case and_tag:
993
   case apply_tag:
994
   case int_to_bitf_tag:
995
   case bitf_to_int_tag:
996
   case cont_tag:
997
   case cond_tag:
998
   case chfl_tag:
999
   case caller_tag:
1000
    printf("%s:<%s>\n",tagname,shape_name(name(sh(e))));
1001
    exp_show(son(e),depth+1,depth_of_recursion,0);
1002
    break;
1003
   case bfass_tag:
1004
   case bfcont_tag:
1005
    if (name(sh(e))==bitfhd)
1006
    {
1007
      printf("%s:<%s> %s %d bit bitfield , bit_offset=%d\n",tagname,shape_name(name(sh(e))),is_signed(sh(e))?"Signed":"Unsigned",shape_size(sh(e)),no(e));
1008
    }
1009
    else
1010
    {
1011
      printf("%s:<%s> bit_offset=%d\n",tagname,shape_name(name(sh(e))),no(e));
1012
    }
1013
 
1014
    exp_show(son(e),depth+1,depth_of_recursion,0);
1015
    break;
1016
   case chvar_tag:
1017
    if (name(sh(e))==bitfhd)
1018
    {
1019
      printf("%s:<%s> %s %d bit bitfield\n",tagname,shape_name(name(sh(e))),is_signed(sh(e))==0?"Unsigned":"Signed",shape_size(sh(e)));
1020
    }
1021
    else
1022
    {
1023
      printf("%s:<%s>\n",tagname,shape_name(name(sh(e))));
1024
    }
1025
    exp_show(son(e),depth+1,depth_of_recursion,0);
1026
    break;
1027
   case make_callee_list_tag:
1028
    if(call_has_vcallees(e))
1029
    {
1030
      printf("%s:has_vcallees no=%d\n",tagname,no(e));
1031
    }
1032
    else
1033
    {
1034
      printf("%s: no=%d\n",tagname,no(e));
1035
    }
1036
    exp_show(son(e),depth+1,depth_of_recursion,0);
1037
    break;
1038
   case clear_tag:
1039
    printf("%s:<%s> no=%d\n",tagname,shape_name(name(sh(e))),no(e));
1040
    exp_show(son(e),depth+1,depth_of_recursion,0);
1041
    break;
1042
   case labst_tag:
1043
    printf("%s:<%s> {label~%04d}\n",tagname,shape_name(name(sh(e))),labst_no(e));
1044
    exp_show(son(e),depth+1,depth_of_recursion,0);
1045
    break;
1046
   case diagnose_tag:
1047
    printf("%s:<%s> dno=0x%x\n",tagname,shape_name(name(sh(e))),(unsigned int)dno(e));
1048
    exp_show(son(e),depth+1,depth_of_recursion,0);
1049
    break;
1050
   case val_tag:
1051
    if (is_signed(sh(e)))
1052
    {
1053
      printf("%s:<%s> no=%d (0x%08x)\n",tagname,shape_name(name(sh(e))),no(e),no(e));
1054
    }
1055
    else
1056
    {
1057
      printf("%s:<%s> no=%u (0x%08x)\n",tagname,shape_name(name(sh(e))),no(e),no(e));
1058
    }
1059
 
1060
    exp_show(son(e),depth+1,depth_of_recursion,0);
1061
    break;
1062
   case reff_tag:
1063
   case field_tag:
1064
   case real_tag:
1065
   case ncopies_tag:
1066
    printf("%s:<%s> no=%d\n",tagname,shape_name(name(sh(e))),no(e));
1067
    exp_show(son(e),depth+1,depth_of_recursion,0);
1068
    break;
1069
 
1070
  case test_tag:
1071
    {
1072
      int label= labst_no(pt(e));
1073
      if (label)
1074
	printf("%s: (f_%s) fails---->{label~%04d}\n",tagname,find_test_name(e),label);
1075
      else
1076
	printf("%s: (f_%s) fails---->(0x%x)\n",tagname,find_test_name(e),(int)pt(e));
1077
      exp_show(son(e),depth+1,depth_of_recursion,0);
1078
      break;
1079
    }
1080
 
1081
   case ident_tag:
1082
    printf("%s:<%s> {tag~%04d}",tagname,shape_name(name(sh(e))),ident_no(e));
1083
    if (isvar(e))
1084
    {
1085
      printf(" VAR");
1086
    }
1087
    if(isvis(e))
1088
    {
1089
      printf(" VIS");
1090
    }
1091
    if(isenvoff(e))
1092
    {
1093
      printf(" ENVOFF");
1094
    }
1095
    if(iscaonly(e))
1096
    {
1097
      printf(" CAONLY");
1098
    }
1099
    if (isparam(e))
1100
    {
1101
      printf(" PARAM");
1102
    }
1103
    if (isglob(e))
1104
    {
1105
      printf(" GLOB");
1106
    }
1107
    printf("\n");
1108
 
1109
    exp_show(son(e),depth+1,depth_of_recursion,0);
1110
    break;
1111
 
1112
 
1113
  case string_tag:
1114
    printf("%s: \"",tagname);
1115
    myprint(nostr(e));
1116
    printf("\"\n");
1117
    exp_show(son(e),depth+1,depth_of_recursion,0);
1118
    break;
1119
 
1120
 
1121
  default:
1122
/* default action will be */
1123
    printf("%s:\n",tagname);
1124
    exp_show(son(e),depth+1,depth_of_recursion,0);
1125
  }
1126
 
1127
 
1128
 
1129
 
1130
  /* always look at brother unless told not to or it is last */
1131
  if (last(e) || flag)
1132
    return;
1133
  else 
1134
  {
1135
    exp_show(bro(e),depth,depth_of_recursion,0);
1136
    return;
1137
  }
1138
}
1139
char *find_test_name PROTO_N ((e)) PROTO_T (exp e)
1140
{
1141
  char *word;
1142
  switch (test_number(e))
1143
  {
1144
   case 1:
1145
    word="greater_than";
1146
    break;
1147
   case 2:
1148
    word="greater_than_or_equal";
1149
    break;
1150
   case 3:
1151
    word="less_than";
1152
    break;
1153
   case 4:
1154
    word="less_than_or_equal";
1155
    break;
1156
   case 5:
1157
    word="equal";
1158
    break;
1159
   case 6:
1160
    word="not_equal";
1161
    break;
1162
   case 7:
1163
    word="not_less_than_or_equal";
1164
    break;
1165
   case 8:
1166
    word="not_less_than";
1167
    break;
1168
   case 9:
1169
    word="not_greater_than_or_equal";
1170
    break;
1171
   case 10:
1172
    word="not_greater_than";
1173
    break;
1174
   case 11:
1175
    word="less_than_or_greater_than";
1176
    break;
1177
   case 12:
1178
    word="not_less_than_and_not_greater_than";
1179
    break;
1180
   case 13:
1181
    word="comparable";
1182
    break;
1183
   case 14:
1184
    word="not_comparable";
1185
    break;
1186
  }
1187
  return word;
1188
}
1189
static void myprint PROTO_N ((word)) PROTO_T (char *word)
1190
{
1191
  char *k;
1192
  k=word;
1193
  while(*k!=0){
1194
    switch(*k){
1195
    case '\n':
1196
      printf("\\n");
1197
      break;
1198
    case '\t':
1199
      printf("\\t");
1200
      break;
1201
    default:
1202
      printf("%c",*k);
1203
    }
1204
    k++;
1205
  }
1206
  return;
1207
}
1208
char *shape_name PROTO_N ((n)) PROTO_T (int n)
1209
{
1210
  char *k;
1211
  switch(n)
1212
  {
1213
   case 1:
1214
    k="bothd";
1215
    break;
1216
   case 2:
1217
    k="tophd";
1218
    break;
1219
   case 3:
1220
    k="scharhd";
1221
    break;
1222
   case 4:
1223
    k="ucharhd";
1224
    break;
1225
   case 5:
1226
    k="swordhd";
1227
    break;
1228
   case 6:
1229
    k="uwordhd";
1230
    break;
1231
   case 7:
1232
    k="slonghd";
1233
    break;
1234
   case 8:
1235
    k="ulonghd";
1236
    break;
1237
   case 9:
1238
    k="s64hd";
1239
    break;
1240
   case 10:
1241
    k="u64hd";
1242
    break;
1243
   case 17:
1244
    k="shcomplexhd";
1245
    break;
1246
   case 18:
1247
    k="complexhd";
1248
    break;
1249
   case 19:
1250
    k="complexdoublehd";
1251
    break;
1252
   case 20:
1253
    k="shrealhd";
1254
    break;
1255
   case 21:
1256
    k="realhd";
1257
    break;
1258
   case 22:
1259
    k="doublehd";
1260
    break;
1261
   case 23:
1262
    k="bitfhd";
1263
    break;
1264
   case 24:
1265
    k="prokhd";
1266
    break;
1267
   case 25:
1268
    k="ptrhd";
1269
    break;
1270
   case 26:
1271
    k="offsethd";
1272
    break;
1273
   case 27:
1274
    k="sizehd";
1275
    break;
1276
   case 28:
1277
    k="cpdhd";
1278
    break;
1279
   case 29:
1280
    k="nofhd";
1281
    break;
1282
   case 30:
1283
    k="tokhd";
1284
    break;
1285
 
1286
   default:
1287
    k="unknown";
1288
    break;
1289
  }
1290
  return k;
1291
}
1292
void properties PROTO_N ((i)) PROTO_T (int i)
1293
{
1294
  exp l;
1295
 
1296
  switch(i)
1297
  {
1298
   case 0:l=last_exp_seen;break;
1299
   case 1:l=last_exp_seen1;break;
1300
   case 2:l=last_exp_seen2;break;
1301
   case 3:l=last_exp_seen3;break;
1302
   case 4:l=last_exp_seen4;break;
1303
   case 5:l=last_exp_seen5;break;
1304
  }
1305
  if(l==NULL)
1306
  {
1307
    printf("No current exp\n");
1308
    return;
1309
  }
1310
  switch(name(l))
1311
  {
1312
    case ident_tag:ident_props(l);break;
1313
    case proc_tag:proc_tag_props(l);break;
1314
    case general_proc_tag:general_proc_tag_props(l);break;
1315
    case solve_tag:solve_props(l);break;
1316
   case movecont_tag:movecont_props(l);break;
1317
   case cont_tag:cont_props(l);break;
1318
   case labst_tag:labst_props(l);break;
1319
   case name_tag:name_props(l);break;
1320
   case string_tag:string_props(l);break;
1321
   case val_tag:val_props(l);break;
1322
   case rep_tag:rep_props(l);break;
1323
   case apply_tag:apply_props(l);break;
1324
   default:printf("Don't know about the properties of a %s\n",getname(name(l)));break;
1325
  }
1326
  return;
1327
}
1328
void ident_props PROTO_N ((e)) PROTO_T (exp e)
1329
{
1330
  printf("isvar       = %d\n",isvar(e));
1331
  printf("isvis       = %d\n",isvis(e));
1332
  printf("isenvoff    = %d\n",isenvoff(e));
1333
  printf("iscaonly    = %d\n",iscaonly(e));
1334
  printf("isusereg    = %d\n",isusereg(e));
1335
  printf("isparam     = %d\n",isparam(e));
1336
  printf("isglob      = %d\n",isglob(e));
1337
  printf("copying     = %d\n",copying(e));
1338
  printf("isinlined   = %d\n",isinlined(e));
1339
#ifdef POWER
1340
#define subvar 0x0100
1341
  printf("subvar      = %d\n",!(!(props(e) & subvar)));
1342
  printf("inreg_bits  = %d\n",!(!(props(e) & inreg_bits)));
1343
  printf("infreg_bits = %d\n",!(!(props(e) & infreg_bits)));
1344
  printf("inanyreg    = %d\n",!(!(props(e) & inanyreg)));
1345
  printf("defer_bit   = %d\n",!(!(props(e) & defer_bit)));
1346
  printf("notparreg   = %d\n",!(!(props(e) & notparreg)));
1347
  printf("notresreg   = %d\n",!(!(props(e) & notresreg)));
1348
#endif
1349
}
1350
void proc_tag_props PROTO_N ((e)) PROTO_T (exp e)
1351
{
1352
  printf("has_struct_res     = %d\n",has_struct_res(e));
1353
  printf("loc_address        = %d\n",loc_address(e));
1354
  printf("proc_has_setjmp    = %d\n",proc_has_setjmp(e));
1355
  printf("proc_has_lv        = %d\n",proc_has_lv(e));
1356
  printf("isrecursive        = %d\n",isrecursive(e));
1357
  printf("proc_uses_crt_env  = %d\n",proc_uses_crt_env(e));
1358
  printf("proc_uses_external = %d\n",proc_uses_external(e));
1359
}
1360
void general_proc_tag_props PROTO_N ((e)) PROTO_T (exp e)
1361
{
1362
  printf("has_struct_res     = %d\n",has_struct_res(e));
1363
  printf("loc_address        = %d\n",loc_address(e));
1364
  printf("proc_has_setjmp    = %d\n",proc_has_setjmp(e));
1365
  printf("proc_has_lv        = %d\n",proc_has_lv(e));
1366
  printf("isrecursive        = %d\n",isrecursive(e));
1367
  printf("proc_uses_crt_env  = %d\n",proc_uses_crt_env(e));
1368
  printf("proc_uses_external = %d\n",proc_uses_external(e));
1369
  printf("PROCPROPS\n");
1370
  printf("proc_has_vcallees  = %d\n",proc_has_vcallees(e));
1371
  printf("proc_has_vcallers  = %d\n",proc_has_vcallers(e));
1372
  printf("proc_has_checkstack= %d\n",proc_has_checkstack(e));
1373
  printf("proc_has_nolongj   = %d\n",proc_has_nolongj(e));
1374
}
1375
 
1376
void solve_props PROTO_N ((e)) PROTO_T (exp e)
1377
{
1378
#ifdef POWER
1379
  printf("is_copying_solve = %d\n",is_copying_solve(e));
1380
#endif
1381
}
1382
void movecont_props PROTO_N ((e)) PROTO_T (exp e)
1383
{
1384
  printf("isnooverlap = %d\n",isnooverlap(e));
1385
}
1386
void cont_props PROTO_N ((e)) PROTO_T (exp e)
1387
{
1388
  printf("to_propagate = %d\n",to_propagate(e));
1389
}
1390
void labst_props PROTO_N ((e)) PROTO_T (exp e)
1391
{
1392
  printf("is_loaded_lv = %d\n",is_loaded_lv(e));
1393
  printf("isunroll     = %d\n",isunroll(e));
1394
}
1395
void name_props PROTO_N ((e)) PROTO_T (exp e)
1396
{
1397
  printf("islastuse   = %d\n",islastuse(e));
1398
  printf("isloadparam = %d\n",isloadparam(e));
1399
  printf("isreallyass = %d\n",isreallyass(e));
1400
}
1401
void string_props PROTO_N ((e)) PROTO_T (exp e)
1402
{
1403
  printf("string_char_size = %d\n",string_char_size(e));
1404
}
1405
void val_props PROTO_N ((e)) PROTO_T (exp e)
1406
{
1407
  printf("isbigval = %d\n",isbigval(e));
1408
}
1409
void rep_props PROTO_N ((e)) PROTO_T (exp e)
1410
{
1411
  printf("isunrolled = %d\n",isunrolled(e));
1412
}
1413
void apply_props PROTO_N ((e)) PROTO_T (exp e)
1414
{
1415
  printf("istoinline = %d\n",istoinline(e));
1416
}
1417
#endif