Subversion Repositories tendra.SVN

Rev

Rev 2 | Details | Compare with Previous | 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
/* 	$Id: translate.c,v 1.2 1998/02/04 10:43:34 release Exp $	 */
32
 
33
#ifndef lint
34
static char vcid[] = "$Id: translate.c,v 1.2 1998/02/04 10:43:34 release Exp $";
35
#endif /* lint */
36
 
37
/*
38
$Log: translate.c,v $
39
 * Revision 1.2  1998/02/04  10:43:34  release
40
 * Changes during testing.
41
 *
42
 * Revision 1.1.1.1  1998/01/17  15:56:01  release
43
 * First version to be checked into rolling release.
44
 *
45
 * Revision 1.24  1996/03/25  14:35:45  john
46
 * introduced do_extern_adds
47
 *
48
 * Revision 1.23  1996/02/15  09:58:29  john
49
 * Fixed handling of initialisation procedures
50
 *
51
 * Revision 1.22  1996/01/23  16:59:10  john
52
 * Fix to diagnostics
53
 *
54
 * Revision 1.21  1996/01/18  09:33:31  john
55
 * Fix diagnostics
56
 *
57
 * Revision 1.20  1996/01/17  10:05:07  john
58
 * Fix to diagnostics
59
 *
60
 * Revision 1.19  1996/01/17  09:31:53  john
61
 * Fix to diagnostics
62
 *
63
 * Revision 1.18  1995/12/04  09:14:16  john
64
 * Fix to diagnostics
65
 *
66
 * Revision 1.17  1995/11/14  15:40:12  john
67
 * Implemented dynamic initialisations
68
 *
69
 * Revision 1.16  1995/11/13  12:44:45  john
70
 * Minor change
71
 *
72
 * Revision 1.15  1995/09/22  16:02:27  john
73
 * Changed special id's
74
 *
75
 * Revision 1.14  1995/09/04  16:27:08  john
76
 * Fix to general procs
77
 *
78
 * Revision 1.13  1995/08/21  08:46:45  john
79
 * Changed include files
80
 *
81
 * Revision 1.12  1995/08/04  15:51:29  john
82
 * Minor change
83
 *
84
 * Revision 1.11  1995/06/28  10:27:52  john
85
 * Hack to fix source file names for diagnostics.
86
 *
87
 * Revision 1.10  1995/06/21  14:25:47  john
88
 * Reformatting
89
 *
90
 * Revision 1.9  1995/06/15  08:33:56  john
91
 * Fixed syntax error
92
 *
93
 * Revision 1.8  1995/06/13  14:02:22  john
94
 * Fixed s-register allocation with frame pointer & added support for
95
 * trap error treatment
96
 *
97
 * Revision 1.7  1995/05/25  15:33:39  john
98
 * Cosmetic change
99
 *
100
 * Revision 1.6  1995/05/23  15:38:28  john
101
 * Changed Version information
102
 *
103
 * Revision 1.5  1995/05/16  10:56:33  john
104
 * Changes for spec 3.1
105
 *
106
 * Revision 1.4  1995/04/10  14:14:16  john
107
 * Minor change
108
 *
109
 * Revision 1.3  1995/04/07  11:07:13  john
110
 * Changed assembler output (mainly scheduling changes).
111
 *
112
 * Revision 1.2  1995/03/29  14:06:31  john
113
 * Changes to keep tcheck happy
114
 *
115
 * Revision 1.1.1.1  1995/03/23  10:39:25  john
116
 * Entered into CVS
117
 *
118
 * Revision 1.13  1995/03/23  10:16:41  john
119
 * Added support for scheduler
120
 *
121
 * Revision 1.12  1995/01/26  13:52:12  john
122
 * Removed unused variable and added include files
123
 *
124
 * Revision 1.11  1995/01/10  09:43:56  john
125
 * Added code for out-of-line optimisation
126
 *
127
*/
128
 
129
#include "config.h"
130
#include "common_types.h"
131
#include "installglob.h"
132
#include "tags.h"
133
#include "exp.h"
134
#include "expmacs.h"
135
#include "optimise.h"
136
#include "flags.h"
137
#include "shapemacs.h"
138
#include "tempdecs.h"
139
#include "weights.h"
140
#include "procrectypes.h"
141
#include "regalloc.h"
142
#include "procrecs.h"
143
#include "coder.h"
144
#include "code_here.h"
145
#include "eval.h"
146
#include "bitsmacs.h"
147
#include "scan.h"
148
#include "xalloc.h"
149
#include "main.h"
150
#include "frames.h"
151
#include "reg_defs.h"
152
#include "symbol.h"
153
#include "alphadiags.h"
154
#include "out_ba.h"
155
#include "syms.h"
156
#include "ibinasm.h"
157
#include "machine.h"
158
#include "fail.h"
159
#include "directives.h"
160
#include "pseudo.h"
161
#include "outofline.h"
162
#include "alpha_ins.h"
163
#include "labels.h"
164
#include "inst_fmt.h"
165
#include "regexps.h"
166
#include "getregs.h"
167
#include "extern_adds.h"
168
#include "version.h"
169
#include "locate.h"
170
#include "translate.h"
171
#include "cross_config.h"
172
 
173
#if DO_SCHEDULE
174
#include "scheduler.h"
175
#endif
176
 
177
#ifndef CROSS_INCLUDE
178
#include <symconst.h>
179
#else
180
#include CROSS_INCLUDE/symconst.h>
181
#endif
182
 
183
procrec * procrecs;
184
dec ** main_globals;
185
int main_globals_index;
186
 
187
extern filename * fds;
188
 
189
/*
190
  return the appropriate storage class based on the size parameter.
191
  The size is given in bytes.
192
*/
193
char *storage_class
194
    PROTO_N ( ( size ) )
195
    PROTO_T ( int size )
196
{
197
  switch(size){
198
    case 1:{
199
      return s_byte;
200
    }
201
    case 2:{
202
      return s_word;
203
    }
204
    case 4:{
205
      return s_long;
206
    }
207
    case 8:{
208
      return s_quad;
209
    }
210
    default:
211
    failer("illegal size for global");
212
  }
213
  return s_byte;
214
}
215
 
216
 
217
ash ashof
218
    PROTO_N ( ( s ) )
219
    PROTO_T ( shape s )
220
{
221
  ash a;
222
  a.ashsize = shape_size(s);
223
  a.ashalign = shape_align(s);
224
  return a;
225
}
226
 
227
/*
228
  used to prevent illegal use of the 
229
  various identifiers reserved by the alpha
230
  assembler
231
*/
232
static bool not_reserved
233
    PROTO_N ( ( id ) )
234
    PROTO_T ( char *id )
235
{
236
 
237
  if (!strcmp (id, "edata"))
238
    return (0);
239
  if (!strcmp (id, "etext"))
240
    return (0);
241
  if (!strcmp (id, "end"))
242
    return (0);
243
  if (!strcmp (id, "_ftext"))
244
    return (0);
245
  if (!strcmp (id, "_fdata"))
246
    return (0);
247
  if (!strcmp (id, "_fbss"))
248
    return (0);
249
  if (!strcmp (id, "_gp"))
250
    return (0);
251
  if (!strcmp (id, "_procedure_table"))
252
    return (0);
253
  if (!strcmp (id, "_procedure_string_table"))
254
    return (0);
255
  return (1);
256
}
257
 
258
 
259
/* return true if sha has an exposed nof component, false otherwise */
260
bool varsize
261
    PROTO_N ( ( sha ) )
262
    PROTO_T ( shape sha )
263
{
264
  return (name(sha)==nofhd);
265
}
266
 
267
static int current_symno;
268
 
269
static void add_odd_bits
270
    PROTO_N ( ( r ) )
271
    PROTO_T ( outofline *r )
272
{
273
  space sp;
274
  if (r != (outofline*)nilexp) {
275
    if (r -> next == (outofline*)nilexp){
276
    }
277
    add_odd_bits(r -> next);
278
  }
279
  else {
280
    return;
281
  }	
282
  set_label(r->labno);
283
  sp = r->sp;
284
  clear_all();
285
  make_code(r->body,sp,r->dest,ptno(r->jr));
286
  if (name(sh(r->body)) != bothd)  {
287
    integer_branch(i_br,31,ptno(r->jr));
288
  }
289
  return;
290
}
291
 
292
void code_it
293
    PROTO_N ( ( my_def ) )
294
    PROTO_T ( dec *my_def )
295
{
296
  exp tg = my_def -> dec_u.dec_val.dec_exp;
297
  char *id = my_def -> dec_u.dec_val.dec_id;
298
  char * outline;
299
  int symdef = my_def ->dec_u.dec_val.sym_number;
300
  bool extnamed =  my_def -> dec_u.dec_val.extnamed;
301
  static  space tempspace = {
302
    0, 0
303
    };
304
  if (symnos[symdef] >=0){
305
    if (son (tg) != nilexp && (!extnamed || !is_comm(son(tg)))) {
306
      if (name (son (tg)) == proc_tag || name(son(tg)) == general_proc_tag) {
307
	diag_descriptor * dd =  my_def -> dec_u.dec_val.diag_info;
308
	/* compile code for proc */
309
	set_text_section();
310
	if(!strncmp("__I.TDF",id,7)) {
311
	  /* we have an initialisation procedure, just change its name 
312
	     and the linker will do the rest */
313
	  char *new_id = (char*)xcalloc(strlen(id)+strlen("__init_")+1,
314
					sizeof(char));
315
	  strcpy(new_id,"__init_");
316
	  strcat(new_id,id);
317
	  xfree(id);
318
	  id = new_id;
319
	  my_def -> dec_u.dec_val.dec_id = id;
320
	}
321
	if (diagnose && dd != (diag_descriptor*)NULL) {
322
	  sourcemark *sm = &dd -> data.id.whence;
323
	  set_file(sm->file->file.ints.chars,2);
324
	  stabd(fscopefile = find_file(sm->file),
325
		sm->line_no.nat_val.small_nat);
326
	}
327
	else if (diagnose){
328
	  out_value(0,ifile,make_INT64(0,1),0);
329
	  out_data("NOFILE.c",strlen("NOFILE.c"));
330
	  out_loc(0,0);
331
 
332
#if 0
333
	  init_table_space(1,0);
334
	  if (nofds == 0) {
335
	    nofds = 1;
336
	    symnosforfiles();
337
	    nofds = 0;
338
	  }
339
	  stabd(0,1);
340
#endif
341
	}
342
 
343
	if (as_file){
344
#if DO_SCHEDULE
345
	  outline = (char*)xcalloc(80,sizeof(char));
346
	  sprintf(outline,"\t.ent\t%s\n%s:\n", id, id);
347
#else	
348
	  fprintf(as_file, "\t.ent\t%s\n%s:\n", id, id);
349
#endif
350
	}	
351
	output_instruction(class_null,outline,
352
			   out_ent(current_symno = symnos[symdef],ient,2));
353
	output_instruction(class_null,(char*)NULL,
354
			   out_common(symnos[symdef],ilabel));
355
	output_instruction(class_null,(char*)NULL,
356
			   out_option(1,(diagnose)?1:2));
357
	symnoforstart (symdef, currentfile);
358
	settempregs (son(tg));
359
#if DO_SCHEDULE
360
	start_new_capsule(true);
361
#endif
362
	code_here (son (tg), tempspace, nowhere);
363
#if DO_SCHEDULE
364
	close_capsule();
365
#endif
366
	if(diagnose && dd != (diag_descriptor*)NULL){
367
	  stabd(fscopefile,currentlno+1);
368
	}
369
	if (as_file){
370
#if DO_SCHEDULE
371
	  outline = (char*)xcalloc(strlen(id)+10,sizeof(char));
372
	  sprintf(outline,"\t.end\t%s\n",id);
373
#else
374
	  fprintf (as_file, "\t.end\t%s\n", id);
375
#endif
376
	}
377
	output_data(outline,out_common(symnoforend(my_def,currentfile),iend));
378
      }
379
      else {			/* global values */
380
	exp c = son (tg);
381
#if DO_SCHEDULE
382
	start_new_capsule(false);
383
#endif
384
	(void)evaluated (c,(isvar (tg))?(-symdef - 1):symdef+1);
385
#if DO_SCHEDULE
386
	close_capsule();
387
#endif
388
      }
389
    }
390
    else {	/* global declarations but no definitions or is_comm */
391
      long  size;
392
      shape s = my_def -> dec_u.dec_val.dec_shape;
393
      bool vs = son(tg)!=nilexp /* ie is_comm */;
394
      size = (shape_size(s) + 7) >> 3;
395
      if ((isvar(tg) || name(s) != prokhd) && not_reserved (id)) {
396
	if (vs /*&& size != 0*/) {
397
	  if (as_file){
398
#if DO_SCHEDULE
399
	    outline = (char*)xcalloc(80,sizeof(char));
400
	    sprintf(outline,"\t.comm\t%s %ld\n",id,(size==0)?4:size);
401
#else	
402
	    fprintf (as_file, "\t.comm\t%s %ld\n", id, size==0?4:size);
403
#endif
404
	  }
405
	  output_instruction(class_null,outline,
406
			     out_value(symnos[symdef],icomm,(size==0)?4:size,
407
				       0));
408
	}	
409
	else {
410
	  if (as_file){
411
#if !DO_SCHEDULE
412
	    fprintf (as_file, "\t.extern\t%s %ld\n", id,
413
		     size);
414
#else	
415
	    outline = (char*)xcalloc(80,sizeof(char));
416
	    sprintf(outline,"\t.extern\t%s %ld\n",id,size);
417
#endif
418
	  }
419
	  output_instruction(class_null,outline,
420
			     out_value(symnos[symdef],iextern,size,1));
421
	}
422
      }
423
      else if (son (tg) == nilexp && !extnamed) {
424
	if (as_file){
425
#if !DO_SCHEDULE
426
	  fprintf (as_file, "\n\t.lcomm\t%s %ld\n", id, size);
427
#else
428
	  outline = (char*)xcalloc(80,sizeof(char));
429
	  sprintf(outline,"\n\t.lcomm\t%s %ld\n", id, size);
430
#endif
431
	}
432
	output_instruction(class_null,outline,
433
			   out_value(symnos[symdef],ilcomm,size,1));
434
      }			
435
    }
436
 
437
  /*  NO! the pt fields are wrong!
438
      kill_exp(son(tg), son(tg));
439
      */
440
  }
441
/*end:*/
442
  /*son(tg) = nilexp;*/
443
  my_def -> dec_u.dec_val.processed = 1;
444
  return;
445
}
446
 
447
static void mark_unaliased
448
    PROTO_N ( ( e ) )
449
    PROTO_T ( exp e )
450
{
451
  exp p = pt (e);
452
  bool ca = 1;
453
  while (p != nilexp && ca) {
454
    if (bro(p)==nilexp || (!(last (p) && name (bro (p)) == cont_tag) &&
455
	 !(!last (p) && last (bro (p)) && name (bro (bro (p))) == ass_tag)))
456
      ca = 0;
457
    p = pt (p);
458
  }
459
  if (ca)
460
    setcaonly (e);
461
  return;
462
}
463
 
464
/*
465
  Return the tag with name 'name'
466
*/
467
baseoff find_tag
468
    PROTO_N ( ( name ) )
469
    PROTO_T ( char *name )
470
{
471
  int i;
472
  for(i=0; i<main_globals_index; i++){
473
    exp tag = main_globals[i]->dec_u.dec_val.dec_exp;
474
    char * id = main_globals[i]->dec_u.dec_val.dec_id;
475
    if(!strcmp(id,name)) return boff(tag);
476
  }
477
  printf("%s\n: ",name);
478
  failer("tag not declared");
479
  exit(EXIT_FAILURE);
480
}
481
 
482
 
483
void translate_capsule
484
    PROTO_Z ()
485
{
486
  dec * my_def;
487
  int noprocs;
488
  int i;
489
  char * outline = (char*)xcalloc(80,sizeof(char));
490
  extern exp* usages;
491
  setregalt (nowhere.answhere, NO_REG);
492
  nowhere.ashwhere.ashsize = 0;
493
  nowhere.ashwhere.ashsize = 0;
494
  opt_all_exps ();
495
    /* mark static unaliased */
496
  my_def = top_def;
497
  while (my_def != (dec *) 0) {
498
    exp crt_exp = my_def -> dec_u.dec_val.dec_exp;
499
    if (son (crt_exp) != nilexp && !my_def -> dec_u.dec_val.extnamed &&
500
	isvar (crt_exp)) {
501
      mark_unaliased (crt_exp);
502
    }
503
    my_def = my_def -> def_next;
504
  }
505
 
506
  if(diagnose){
507
    /* remove static functions with no uses if compiling with diagnostics */
508
    dec **ptr_def = &top_def;
509
    while(*ptr_def) {
510
      exp crt_exp = (*ptr_def)->dec_u.dec_val.dec_exp;
511
      if(son(crt_exp) != nilexp) {
512
	if(((name(son(crt_exp)) == general_proc_tag) || 
513
	   (name(son(crt_exp)) == proc_tag)) &&
514
	   ((no(crt_exp) == 0) && (diagnose) && !(*ptr_def)->dec_u.dec_val.extnamed)) {
515
	  dec *old_ptr = *ptr_def;
516
	  *ptr_def = (*ptr_def)->def_next;
517
	  free(old_ptr);
518
	}
519
	else {
520
	  ptr_def = &((*ptr_def)->def_next);
521
	}
522
      }
523
      else {
524
	ptr_def = &((*ptr_def)->def_next);
525
      }
526
    }
527
  }
528
 
529
  noprocs = 0;
530
  my_def = top_def;
531
  while (my_def != (dec *) 0) {
532
    exp crt_exp = my_def -> dec_u.dec_val.dec_exp;
533
    if (son (crt_exp) != nilexp && (name (son (crt_exp)) == proc_tag ||
534
	name(son(crt_exp))==general_proc_tag)) {
535
      noprocs++;
536
    }
537
    my_def = my_def -> def_next;
538
  }
539
  /* count procs */
540
 
541
  procrecs = (procrec *) xcalloc (noprocs, sizeof (procrec));
542
  noprocs = 0;
543
 
544
  my_def = top_def;
545
  while (my_def != (dec *) 0) {
546
    exp crt_exp = my_def -> dec_u.dec_val.dec_exp;
547
    if (son (crt_exp) != nilexp && (name (son (crt_exp)) == proc_tag
548
				    || name(son(crt_exp))==general_proc_tag)) {
549
      no (son (crt_exp)) = noprocs++;
550
      /* put index into procrecs in no(proc) */
551
    }
552
    my_def = my_def -> def_next;
553
  }
554
  if(do_extern_adds) {
555
    usages = (exp*)xcalloc(noprocs, sizeof(exp));
556
    my_def = top_def;
557
    while (my_def != (dec *) 0) {
558
      exp crt_exp = my_def -> dec_u.dec_val.dec_exp;
559
      if (son(crt_exp) == nilexp && isvar(crt_exp) ) {
560
	global_usages(crt_exp, noprocs);
561
	/* try to identify globals ptrs in procs */
562
      }
563
      my_def = my_def -> def_next;
564
    }
565
  }
566
 
567
 
568
  if(diagnose){
569
    int l,i;
570
    char * ftmp;
571
    init_table_space(nofds,noprocs);
572
    add_dense_no(0,0);
573
    add_dense_no(0,0);
574
#if 1
575
    for(i=0; i<nofds; ++i) {
576
      l = (int)strlen (fds[i]->file.ints.chars);
577
      ftmp = xcalloc(l+1,sizeof(char));
578
      ftmp[0] = 'X';
579
      strcpy(ftmp+1,fds[i]->file.ints.chars);
580
      fds[i]->file.ints.chars = (char*)xrealloc((void*)fds[i]->file.ints.chars,
581
						(l+1)*sizeof(char));
582
      strcpy(fds[i]->file.ints.chars,ftmp);	
583
      xfree(ftmp);
584
    }
585
#endif
586
    symnosforfiles();
587
    stab_types();
588
  }
589
  else{
590
    init_table_space(1,noprocs);
591
    add_dense_no(0,0);
592
    add_dense_no(0,0);
593
    (void)new_lsym_d ("NOFILE.c",0,stFile,scText,0,0);
594
  }
595
  my_def = top_def;
596
  while (my_def != (dec *) 0) {
597
    exp crt_exp = my_def -> dec_u.dec_val.dec_exp;
598
    if (son (crt_exp) != nilexp && (name (son (crt_exp)) == proc_tag
599
				    || name(son(crt_exp))==general_proc_tag)) {
600
      procrec * pr = &procrecs[no (son (crt_exp))];
601
      exp * st = &son(crt_exp);
602
      bool has_varargs = vascan(st);
603
      (*st)->dfile = "";
604
      if(has_varargs){
605
	set_has_c_vararg(*st);
606
      }
607
      else {
608
	clear_has_c_vararg(*st);
609
      }
610
 
611
      pr -> needsproc = scan (st, &st);
612
      pr->callee_size = (callee_size + 63)&~63;
613
    }
614
    my_def = my_def -> def_next;
615
  }
616
 
617
 
618
  /* calculate the break points for register allocation and do it */
619
  my_def = top_def;
620
  while (my_def != (dec *) 0) {
621
    exp crt_exp = my_def -> dec_u.dec_val.dec_exp;
622
    if (son (crt_exp) != nilexp && (name (son (crt_exp)) == proc_tag
623
				    || name(son(crt_exp))==general_proc_tag)){
624
      procrec * pr = &procrecs[no (son (crt_exp))];
625
      needs * ndpr = & pr->needsproc;
626
      long pprops = (ndpr->propsneeds);
627
      bool leaf = (pprops & anyproccall) == 0;
628
      spacereq forrest;
629
      int   freefixed = 6;
630
      int   freefloat = 8;	
631
      setframe_flags(son(crt_exp), leaf);
632
      /*      if(Has_vcallees || proc_has_gen_call(son(crt_exp))) freefixed--;*/
633
      if(Has_vcallees) freefixed--;
634
      freefixed += (Has_fp==0);
635
      if (!No_S) (void)weightsv (1.0, bro (son (son (crt_exp))));
636
      /* estimate usage of tags in body of proc */
637
      forrest = regalloc (bro (son (son (crt_exp))), freefixed, freefloat, 0);
638
      /* reg and stack allocation for tags */
639
      pr -> spacereqproc = forrest;
640
      setframe_info(son(crt_exp));
641
    }
642
    my_def = my_def -> def_next;
643
  }
644
  /* put defs in main globals and set up symnos*/
645
  my_def = top_def;
646
  main_globals_index = 0;
647
  while (my_def != (dec*) 0) {
648
    main_globals_index++;
649
    my_def = my_def -> def_next;
650
  }
651
 
652
  data_lab = (main_globals_index > 33)?main_globals_index:33;
653
  main_globals = (dec**)xcalloc(main_globals_index, sizeof(dec*));
654
  symnos = (int *) xcalloc (main_globals_index, sizeof (int));
655
 
656
  my_def = top_def;
657
  for (i=0; i < main_globals_index; i++) {
658
    main_globals[i] = my_def;
659
    my_def = my_def -> def_next;
660
  }
661
 
662
  /* ... and set in the position and "addresses" of the externals */
663
  for (i = 0; i < main_globals_index; i++) {
664
    exp tg = main_globals[i] -> dec_u.dec_val.dec_exp;
665
    char *id = main_globals[i] -> dec_u.dec_val.dec_id;
666
    bool extnamed = main_globals[i] -> dec_u.dec_val.extnamed;
667
    main_globals[i] ->dec_u.dec_val.sym_number = i;	    
668
    /* if not nilexp */
669
    if ( no (tg) != 0 || (extnamed && son(tg) != nilexp) 
670
	 || !strcmp(id,"__alpha_errhandler") || !strcmp(id,"__alpha_stack_limit")) {
671
      if(no(tg)==1 && son(tg)==nilexp && 
672
	 (bro(pt(tg)) == nilexp || 
673
	  name(bro(pt(tg)))==101 || name(bro(pt(tg)))==102 ) 
674
          /* diagnostics only! */ ) {
675
	symnos[i]= -1;
676
      }
677
      else {	 
678
	no (tg) = (i + 1) * 64 + 32;
679
	symnos[i] = symnoforext (main_globals[i], mainfile);
680
      }
681
    }
682
    else{
683
      /* only applies to alphatrans */
684
      symnos[i] = -1;
685
/*      symnos[i] = symnoforext (main_globals[i],mainfile);*/
686
    }
687
  }
688
 
689
  if(as_file){
690
    fprintf(as_file," # produced by TDF->Alpha/OSF1 installer\n");
691
    fprintf(as_file," # installer version %d.%d.%d\n",target_version,
692
	    target_revision,target_patchlevel);
693
    /*comment(" # produced by TDF->Alpha/OSF1 installer\n");*/
694
#if !DO_SCHEDULE
695
    fprintf(as_file,"\t.ugen\n");
696
#else
697
    sprintf(outline,"\t.ugen\n");
698
#endif
699
  }
700
#if DO_SCHEDULE
701
  output_data(outline,out_common(0,iugen));
702
#else
703
  out_common(0,iugen);
704
#endif
705
 
706
  if(as_file){
707
#if !DO_SCHEDULE
708
    fprintf(as_file,"\t.verstamp %d %d\n",majorno,minorno);
709
#else
710
    outline = (char*)xcalloc(30,sizeof(char));
711
    sprintf(outline,"\t.verstamp %d %d\n",majorno,minorno);
712
#endif
713
  }
714
 
715
#if DO_SCHEDULE
716
  output_data(outline,out_verstamp(majorno,minorno));
717
#else
718
  out_verstamp(majorno,minorno);
719
#endif  
720
 
721
#if DO_SCHEDULE
722
  output_data((char*)NULL,out_option(1,diagnose?1:2));
723
#else
724
  out_option(1,diagnose?1:2);
725
#endif  
726
 
727
  if (diagnose && nofds!=0) {
728
    stab_file (0);
729
  }
730
  else{
731
    currentfile = 0;
732
  }
733
 
734
  /* 
735
     compile procedures, evaluate constants, put in the 
736
     .comm entries for undefined objects 
737
  */
738
  my_def = top_def;
739
 
740
#if DO_SCHEDULE
741
    start_new_capsule(false);
742
#endif
743
  while (my_def != (dec *) 0) {
744
    exp tg = my_def -> dec_u.dec_val.dec_exp;
745
    char *id = my_def -> dec_u.dec_val.dec_id;
746
    bool extnamed = my_def -> dec_u.dec_val.extnamed;
747
    if (son (tg) != nilexp && (extnamed || no (tg) != 0 || 
748
			       !strcmp (id, "main"))) {
749
      if (extnamed) {
750
	/* globalise all global names  */
751
	if(!strncmp("__I.TDF",id,7)) {
752
	  char *new_id = (char*)xcalloc(strlen(id)+strlen("__init_")+1,
753
					sizeof(char));
754
	  strcpy(new_id,"__init_");
755
	  strcat(new_id,id);
756
	  xfree(id);
757
	  id = new_id;
758
	  my_def->dec_u.dec_val.dec_id = new_id;
759
	}
760
 
761
	if (as_file){
762
#if DO_SCHEDULE
763
	  outline = (char*)xcalloc(strlen(id)+10,sizeof(char));
764
	  sprintf (outline,"\t.globl\t%s\n ",id);
765
#else
766
	  fprintf (as_file, "\t.globl\t%s\n", id);
767
#endif	
768
	}
769
	output_data(outline,out_common(symnos[my_def->dec_u.dec_val.sym_number]
770
				       ,iglobal));
771
      }
772
    }
773
    my_def = my_def -> def_next;
774
  }
775
#if DO_SCHEDULE
776
    close_capsule();
777
#endif
778
 
779
  my_def = top_def;
780
#if DO_SCHEDULE
781
  setnoreorder();
782
#endif
783
  while (my_def != (dec *) 0) {
784
    if (!my_def -> dec_u.dec_val.processed){
785
      code_it (my_def);
786
      my_def = my_def -> def_next;
787
    }
788
  }
789
#if DO_SCHEDULE
790
  schedule_block();
791
#endif
792
  return;
793
}
794
 
795
void translate_unit
796
    PROTO_Z ()
797
{
798
  if (separate_units){
799
    dec * my_def;
800
    translate_capsule();
801
    my_def = top_def;
802
    while (my_def != (dec *) 0) {
803
      exp crt_exp = my_def -> dec_u.dec_val.dec_exp;
804
      no(crt_exp) = 0;
805
      pt(crt_exp) = nilexp;
806
      my_def = my_def -> def_next;
807
    }
808
    crt_repeat = nilexp;
809
    repeat_list = nilexp;
810
  }
811
  return;
812
}
813
 
814
void translate_tagdef
815
    PROTO_Z ()
816
{
817
  return;
818
}
819
 
820
 
821
 
822
 
823
 
824
 
825
 
826
 
827
 
828
 
829
 
830
 
831
 
832
 
833