Subversion Repositories tendra.SVN

Rev

Rev 6 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
6 7u83 2
 * Copyright (c) 2002-2005 The TenDRA Project <http://www.tendra.org/>.
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions are met:
7
 *
8
 * 1. Redistributions of source code must retain the above copyright notice,
9
 *    this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
11
 *    this list of conditions and the following disclaimer in the documentation
12
 *    and/or other materials provided with the distribution.
13
 * 3. Neither the name of The TenDRA Project nor the names of its contributors
14
 *    may be used to endorse or promote products derived from this software
15
 *    without specific, prior written permission.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
18
 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
19
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
 *
29
 * $Id$
30
 */
31
/*
2 7u83 32
    		 Crown Copyright (c) 1997
33
 
34
    This TenDRA(r) Computer Program is subject to Copyright
35
    owned by the United Kingdom Secretary of State for Defence
36
    acting through the Defence Evaluation and Research Agency
37
    (DERA).  It is made available to Recipients with a
38
    royalty-free licence for its use, reproduction, transfer
39
    to other parties and amendment for any purpose not excluding
40
    product development provided that any such use et cetera
41
    shall be deemed to be acceptance of the following conditions:-
42
 
43
        (1) Its Recipients shall ensure that this Notice is
44
        reproduced upon any copies or amended versions of it;
45
 
46
        (2) Any amended version of it shall be clearly marked to
47
        show both the nature of and the organisation responsible
48
        for the relevant amendment or amendments;
49
 
50
        (3) Its onward transfer from a recipient to another
51
        party shall be deemed to be that party's acceptance of
52
        these conditions;
53
 
54
        (4) DERA gives no warranty or assurance as to its
55
        quality or suitability for any purpose and DERA accepts
56
        no liability whatsoever in relation to any use to which
57
        it may be put.
58
*/
59
 
60
 
61
/**********************************************************************
62
$Author: release $
63
$Date: 1998/02/04 10:43:45 $
64
$Revision: 1.2 $
65
$Log: translate.c,v $
66
 * Revision 1.2  1998/02/04  10:43:45  release
67
 * Changes during testing.
68
 *
69
 * Revision 1.1.1.1  1998/01/17  15:56:07  release
70
 * First version to be checked into rolling release.
71
 *
72
 * Revision 1.11  1996/04/24  08:55:54  currie
73
 * Case may require 3 regs
74
 *
75
 * Revision 1.10  1996/01/17  11:27:11  currie
76
 * proc with no diagnostics
77
 *
78
 * Revision 1.9  1996/01/12  10:06:14  currie
79
 * AVS - env_offset + main declared but not d3efined
80
 *
81
 * Revision 1.8  1995/10/25  13:48:29  currie
82
 * change to position of .glob
83
 *
84
 * Revision 1.7  1995/10/02  10:30:35  currie
85
 * env_offset + -g (PIC)
86
 *
87
 * Revision 1.6  1995/09/20  14:23:10  currie
88
 * callee-list blunder + fix for silliness in ultrix assembler
89
 *
90
 * Revision 1.4  1995/09/12  10:59:45  currie
91
 * gcc pedanttry
92
 *
93
 * Revision 1.3  1995/08/16  16:07:14  currie
94
 * Shortened some .h names
95
 *
96
 * Revision 1.2  1995/06/28  12:15:26  currie
97
 * New make_stack_limit etc
98
 *
99
 * Revision 1.1  1995/04/13  09:08:06  currie
100
 * Initial revision
101
 *
102
***********************************************************************/
103
#include "config.h"
104
#include "cross_config.h"
105
 
106
#ifndef CROSS_INCLUDE
107
#include <symconst.h>
108
#else
109
#include CROSS_INCLUDE/symconst.h>
110
#endif
111
 
112
#include "common_types.h"
113
#include "symtab.h"
114
#include "installglob.h"
115
#include "tags.h"
116
#include "exp.h"
117
#include "expmacs.h"
118
#include "optimise.h"
119
#include "flags.h"
120
#include "shapemacs.h"
121
#include "tempdecs.h"
122
#include "weights.h"
123
#include "procrectypes.h"
124
#include "regalloc.h"
125
#include "new_code.h"
126
#include "code_here.h"
127
#include "eval.h"
128
#include "bitsmacs.h"
129
#include "needs_scan.h"
130
#include "ibinasm.h"
131
#include "syms.h"
132
#include "out_ba.h"
133
#include "xalloc.h"
134
#include "new_symbol.h"
135
#include "mipsdiags.h"
136
#include "extern_adds.h"
137
#include "mips_ins.h"
138
#include "machine.h"
139
#include "main.h"
140
#include "frames.h"
141
#include "basicread.h"
142
#include "getregs.h"
143
#include "locate.h"
144
#include "me_fns.h"
145
 
146
extern long aritherr_lab;
147
extern long stackerr_lab;
148
 
149
 
6 7u83 150
extern exp find_named_tg(char*, shape);
2 7u83 151
extern shape f_top;
152
extern shape f_proc;
153
 
154
procrec * procrecs;
155
dec ** main_globals;
156
int main_globals_index;
157
 
158
extern long fscopefile;
159
extern bool do_extern_adds;
160
 
161
ash ashof
6 7u83 162
(shape s)
2 7u83 163
{
164
	ash a;
165
	a.ashsize = shape_size(s);
166
	a.ashalign = shape_align(s);
167
	return a;
168
}
169
 
170
 
171
bool not_reserved
6 7u83 172
(char *id)
2 7u83 173
{
174
  /* various identifier reserved by MIPS */
6 7u83 175
  if (!strcmp(id, "edata"))
176
    return(0);
177
  if (!strcmp(id, "etext"))
178
    return(0);
179
  if (!strcmp(id, "end"))
180
    return(0);
181
  if (!strcmp(id, "_ftext"))
182
    return(0);
183
  if (!strcmp(id, "_fdata"))
184
    return(0);
185
  if (!strcmp(id, "_fbss"))
186
    return(0);
187
  if (!strcmp(id, "_gp"))
188
    return(0);
189
  if (!strcmp(id, "_procedure_table"))
190
    return(0);
191
  if (!strcmp(id, "_procedure_string_table"))
192
    return(0);
193
  return(1);
2 7u83 194
}
195
 
196
 
197
 
198
 
199
 
200
char varsize
6 7u83 201
(shape sha)
2 7u83 202
{
6 7u83 203
  return(name(sha) ==nofhd);
2 7u83 204
}
205
 
206
int current_symno;
207
 
208
void globalise_name
6 7u83 209
(dec * my_def)
2 7u83 210
{
211
	char *id = my_def -> dec_u.dec_val.dec_id;
212
        if (!my_def -> dec_u.dec_val.extnamed) return;
213
	if (as_file)
6 7u83 214
	  fprintf(as_file, "\t.globl\t%s\n", id);
215
	out_common(symnos[my_def->dec_u.dec_val.sym_number], iglobal);
2 7u83 216
 
217
}
218
 
219
void code_it
6 7u83 220
(dec * my_def)
2 7u83 221
{
222
  exp tg = my_def -> dec_u.dec_val.dec_exp;
223
  char *id = my_def -> dec_u.dec_val.dec_id;
224
  long symdef = my_def ->dec_u.dec_val.sym_number;
225
  bool extnamed =  my_def -> dec_u.dec_val.extnamed;
226
 
227
  static  space tempspace = {
228
      0, 0
229
    };
230
  if (symnos[symdef] <0) goto end; /* ? unused symbols */
231
 
6 7u83 232
  if (son(tg)!= nilexp && (!extnamed || !is_comm(son(tg)))) {
233
    if (name(son(tg)) == proc_tag
2 7u83 234
		|| name(son(tg)) == general_proc_tag) {
235
        diag_descriptor * dd =  my_def -> dec_u.dec_val.diag_info;
236
	/* compile code for proc */
237
	if (as_file) {
6 7u83 238
	  fprintf(as_file,"\t.text\n\t.align 3\n");
2 7u83 239
	}
240
 
241
 
6 7u83 242
	out_common(0, itext);
243
	out_value(0, ialign, 3, 0);
2 7u83 244
	if (diagnose) {
6 7u83 245
	 if (dd != (diag_descriptor*)0) {
2 7u83 246
	    sourcemark *sm = &dd -> data.id.whence;
247
	    stabd(fscopefile = find_file(sm->file->file.ints.chars),
248
	               sm->line_no.nat_val.small_nat);
249
	 }
250
	 else { stabd(0,1); /*no diagnostics for this proc */ }
251
	}
252
 
253
	globalise_name(my_def);
254
 
6 7u83 255
	if (as_file)fprintf(as_file, "\t.ent\t%s\n%s:\n", id, id);
2 7u83 256
 
257
	out_ent (current_symno = symnos[symdef], ient, 2);/* why 2? */
6 7u83 258
	out_common(symnos[symdef], ilabel);
2 7u83 259
	if (as_file) {
6 7u83 260
		fprintf(as_file,
261
			(diagnose)? "\t.option O1\n" : "\t.option O2\n");
2 7u83 262
	}
263
 
6 7u83 264
	out_option(1,(diagnose)? 1 : 2);
2 7u83 265
 
6 7u83 266
	symnoforstart(symdef, currentfile);
267
	settempregs(son(tg));
268
	code_here(son(tg), tempspace, nowhere);
2 7u83 269
	if (diagnose && dd != (diag_descriptor*)0) {
270
		stabd(fscopefile, currentlno+1);
271
	}
272
	if (as_file)
6 7u83 273
	  fprintf(as_file, "\t.end\t%s\n", id);
274
	out_common(symnoforend(my_def, currentfile), iend);
2 7u83 275
    }
276
    else {			/* global values */
277
 
6 7u83 278
	exp c = son(tg);
279
	IGNORE evaluated(c,(isvar(tg))?(-symdef - 1): symdef + 1, my_def);
2 7u83 280
 
281
 
282
    };
283
  }
284
  else {	/* global declarations but no definitions or is_comm */
285
      long  size;
6 7u83 286
      shape s = (son(tg) ==nilexp)?my_def -> dec_u.dec_val.dec_shape :
2 7u83 287
				sh(son(tg));
288
      size = (shape_size(s) + 7) >> 3;
289
 
6 7u83 290
      if ((isvar(tg) || name(s)!= prokhd) && not_reserved(id)) {
291
	if ((son(tg)!= nilexp && is_comm(son(tg)))
292
		|| (son(tg) ==nilexp && varsize(sh(tg)))) {
2 7u83 293
	  if (size !=0) { /* ? ? ! ? */
294
	     globalise_name(my_def);
295
	     if (as_file)
6 7u83 296
	        fprintf(as_file, "\t.comm\t%s %ld\n", id, size);
297
	      out_value(symnos[symdef], icomm, size, 1);
2 7u83 298
	  }
299
	}
300
	else {
301
	  if (as_file)
6 7u83 302
	    fprintf(as_file, "\t.extern\t%s %ld\n", id,
2 7u83 303
		size);
6 7u83 304
	  out_value(symnos[symdef], iextern, size, 1);
2 7u83 305
	}
306
      }
307
      else
6 7u83 308
	if (son(tg) == nilexp && !extnamed) {
2 7u83 309
	  if (size !=0) { /* ? ? ! ? */
310
	      if (as_file)
6 7u83 311
	        fprintf(as_file, "\t.lcomm\t%s %ld\n", id, size);
312
	      out_value(symnos[symdef], ilcomm, size, 1);
2 7u83 313
	  }
314
	}
315
 
316
  }
317
 
318
 
319
end:
320
  my_def -> dec_u.dec_val.processed = 1;
321
  return;
322
}
323
 
324
void mark_unaliased
6 7u83 325
(exp e)
2 7u83 326
{
6 7u83 327
  exp p = pt(e);
2 7u83 328
  bool ca = 1;
329
  while (p != nilexp && ca) {
6 7u83 330
    if (bro(p) ==nilexp ||
331
      (!(last(p) && name(bro(p)) == cont_tag) &&
332
	!(!last(p) && last(bro(p)) && name(bro(bro(p))) == ass_tag)))
2 7u83 333
      ca = 0;
6 7u83 334
    p = pt(p);
2 7u83 335
  };
336
  if (ca)
6 7u83 337
    setcaonly(e);
2 7u83 338
  return;
339
}
340
 
341
void remove_unused
6 7u83 342
(void)
2 7u83 343
{ dec ** sdef = &top_def;
6 7u83 344
  while (*sdef != (dec *)0) {
2 7u83 345
    exp crt_exp = (*sdef) -> dec_u.dec_val.dec_exp;
346
    bool extnamed = (*sdef) -> dec_u.dec_val.extnamed;
347
    if (no(crt_exp) == 0 && !extnamed) {
6 7u83 348
	*sdef = (*sdef) ->def_next;
2 7u83 349
    }
6 7u83 350
    else sdef = & ((*sdef) ->def_next);
2 7u83 351
  }
352
}
353
 
354
 
355
 
356
void translate_capsule
6 7u83 357
(void)
2 7u83 358
{
359
  dec * my_def;
360
  int noprocs;
361
  int i;
362
 
6 7u83 363
  opt_all_exps();
2 7u83 364
  remove_unused();
365
 
366
#ifdef INCLUDE_INITS
367
  my_def = top_def;
6 7u83 368
  while (my_def != (dec *)0) {
2 7u83 369
        exp crt_exp = my_def -> dec_u.dec_val.dec_exp;
370
	char * id = my_def -> dec_u.dec_val.dec_id;
6 7u83 371
	if (strcmp(id, "main") ==0 && son(crt_exp)!= nilexp &&
2 7u83 372
		name(son(crt_exp)) == proc_tag) {
373
	   exp fn = me_obtain(find_named_tg("__DO_I_TDF", f_proc));
374
	   exp cll = getexp(f_top, nilexp, 0, fn, nilexp, 0, 0, apply_tag);
375
	   exp * dm = &son(son(crt_exp));
376
	   exp hld, seq;
377
	   bro(fn) = cll; setlast(fn);
6 7u83 378
	   while (name(*dm) ==ident_tag && isparam(*dm))dm = &bro(son(*dm));
2 7u83 379
	   /* dm is body of main after params */
380
	   hld = getexp(f_top, *dm, 0, cll, nilexp, 0, 1, 0);
381
	   seq = getexp(sh(*dm), bro(*dm), last(*dm), hld, nilexp, 0, 0, seq_tag);
382
	   bro(*dm) = seq; setlast(*dm);
383
	   bro(cll) = hld; setlast(cll);
384
	   *dm = seq;
385
	   break;
386
	}
387
        my_def = my_def -> def_next;
388
   }
389
#endif
390
 
391
    /* mark static unaliased */
392
  my_def = top_def;
6 7u83 393
  while (my_def != (dec *)0) {
2 7u83 394
    exp crt_exp = my_def -> dec_u.dec_val.dec_exp;
6 7u83 395
    if (son(crt_exp)!= nilexp &&
2 7u83 396
	!my_def -> dec_u.dec_val.extnamed &&
6 7u83 397
	isvar(crt_exp))
398
      mark_unaliased(crt_exp);
2 7u83 399
    my_def = my_def -> def_next;
400
  };
401
 
402
  noprocs = 0;
403
  my_def = top_def;
6 7u83 404
  while (my_def != (dec *)0) {
2 7u83 405
    exp crt_exp = my_def -> dec_u.dec_val.dec_exp;
6 7u83 406
    if (son(crt_exp)!= nilexp
407
        && (name(son(crt_exp)) == proc_tag ||
2 7u83 408
		name(son(crt_exp)) == general_proc_tag)) {
409
      noprocs++;
410
    }
411
    my_def = my_def -> def_next;
412
  }
413
  /* count procs */
414
 
6 7u83 415
  procrecs = (procrec *)xcalloc(noprocs, sizeof(procrec));
2 7u83 416
  noprocs = 0;
417
 
418
  my_def = top_def;
6 7u83 419
  while (my_def != (dec *)0) {
2 7u83 420
    exp crt_exp = my_def -> dec_u.dec_val.dec_exp;
6 7u83 421
    if (son(crt_exp)!= nilexp &&
422
	(name(son(crt_exp)) == proc_tag || name(son(crt_exp)) == general_proc_tag)) {
423
      no(son(crt_exp)) = noprocs++;
2 7u83 424
      /* put index into procrecs in no(proc) */
425
    }
426
    my_def = my_def -> def_next;
427
  }
428
 
429
  if (do_extern_adds) {
430
	usages = (exp*)xcalloc(noprocs, sizeof(exp));
431
	my_def = top_def;
6 7u83 432
  	while (my_def != (dec *)0) {
2 7u83 433
		exp crt_exp = my_def -> dec_u.dec_val.dec_exp;
6 7u83 434
		if (son(crt_exp) == nilexp && isvar(crt_exp)) {
2 7u83 435
			global_usages(crt_exp, noprocs);
436
			/* try to identify globals ptrs in procs */
437
		}
438
		my_def = my_def -> def_next;
439
	}
440
  }
441
 
442
  if (diagnose && nofds !=0) {
6 7u83 443
      init_table_space(nofds, noprocs);
444
      add_dense_no(0, 0);
2 7u83 445
      add_dense_no (0, 0);	/* dont know why!! */
6 7u83 446
      symnosforfiles();
2 7u83 447
      stab_types();
448
  }
449
  else {
6 7u83 450
    init_table_space(1,noprocs);
451
    add_dense_no(0, 0);
2 7u83 452
    add_dense_no (0, 0);	/* dont know why!! */
6 7u83 453
    IGNORE new_lsym_d("NOFILE.c", 0, stFile, scText, 0, 0);
2 7u83 454
  };
455
 
456
  /* scan to put everything in MIPS form */
457
 
458
  my_def = top_def;
6 7u83 459
  while (my_def != (dec *)0) {
2 7u83 460
    exp crt_exp = my_def -> dec_u.dec_val.dec_exp;
6 7u83 461
    if (son(crt_exp)!= nilexp
462
	&& (name(son(crt_exp)) == proc_tag ||
463
		name(son(crt_exp)) == general_proc_tag)) {
464
      procrec * pr = &procrecs[no(son(crt_exp))];
2 7u83 465
      exp * st = &son(crt_exp);
6 7u83 466
      pr -> needsproc = scan(st, &st);
467
      pr->callee_size = (callee_size+63) &~63;
2 7u83 468
    }
469
    my_def = my_def -> def_next;
470
  }
471
 
472
 
473
  /* calculate the break points for register allocation and do it */
474
  my_def = top_def;
6 7u83 475
  while (my_def != (dec *)0) {
2 7u83 476
    exp crt_exp = my_def -> dec_u.dec_val.dec_exp;
6 7u83 477
    if (son(crt_exp)!= nilexp
478
        && (name(son(crt_exp)) == proc_tag ||
479
		name(son(crt_exp)) == general_proc_tag)) {
480
      procrec * pr = &procrecs[no(son(crt_exp))];
2 7u83 481
      needs * ndpr = & pr->needsproc;
482
      long pprops = (ndpr->propsneeds);
483
      bool leaf = (pprops & anyproccall) == 0;
484
      spacereq forrest;
485
      int   freefixed = 8;	/* NO OF S_REGISTERS */
486
      int   freefloat = 6;	/* NO OF S $f REGISTERS */
487
 
488
      setframe_flags(son(crt_exp), leaf);
489
      if (!Has_fp) freefixed++; /* can use $30 as normal caller save */
490
 
491
      if (Has_vcallees) { freefixed--; }
492
 
6 7u83 493
      if (!No_S)IGNORE weightsv(1.0, bro(son(son(crt_exp))));
2 7u83 494
      /* estimate usage of tags in body of proc */
495
 
6 7u83 496
      forrest = regalloc(bro(son(son(crt_exp))), freefixed, freefloat,
2 7u83 497
				(PIC_code && !leaf)?32:0);
498
      /* reg and stack allocation for tags */
499
 
500
      pr -> spacereqproc = forrest;
501
 
502
      setframe_info(son(crt_exp));
503
    }
504
    my_def = my_def -> def_next;
505
  }
506
 
507
  /* put defs in main globals and set up symnos*/
508
  my_def = top_def;
509
  main_globals_index = 0;
6 7u83 510
  while (my_def != (dec*)0) {
2 7u83 511
  	main_globals_index++;
512
  	my_def = my_def -> def_next;
513
  }
514
 
515
  data_lab = (main_globals_index > 33)?main_globals_index:33;
516
  main_globals = (dec**)xcalloc(main_globals_index, sizeof(dec*));
6 7u83 517
  symnos = (int *)xcalloc(main_globals_index, sizeof(int));
2 7u83 518
 
519
  my_def = top_def;
520
  for (i=0; i < main_globals_index; i++) {
521
  	main_globals[i] = my_def;
522
  	my_def = my_def -> def_next;
523
  }
524
 
525
 
526
    /* ... and set in the position and "addresses" of the externals */
527
  for (i = 0; i < main_globals_index; i++) {
528
    exp tg = main_globals[i] -> dec_u.dec_val.dec_exp;
529
    char *id = main_globals[i] -> dec_u.dec_val.dec_id;
530
    bool extnamed = main_globals[i] -> dec_u.dec_val.extnamed;
531
    diag_descriptor * dinf = main_globals[i] -> dec_u.dec_val.diag_info;
532
    main_globals[i] ->dec_u.dec_val.sym_number = i;
6 7u83 533
    if (no(tg)!= 0 || (extnamed && son(tg)!= nilexp)
2 7u83 534
		|| strcmp(id,"__TDFhandler") == 0
6 7u83 535
		|| strcmp(id,"__TDFstacklim") ==0
2 7u83 536
	) {
6 7u83 537
     	if (no(tg) ==1 && son(tg) ==nilexp && dinf != (diag_descriptor *)0
2 7u83 538
 		 /* diagnostics only! */ ) {
6 7u83 539
    		symnos[i] = -1;
2 7u83 540
    	}
541
    	else {
6 7u83 542
          no(tg) = (i + 1)* 64 + 32;
543
          symnos[i] = symnoforext(main_globals[i], mainfile);
2 7u83 544
        }
545
    }
546
    else
547
      symnos[i] = -1;
548
  };
549
 
550
 
551
 
6 7u83 552
  setregalt(nowhere.answhere, 0);
2 7u83 553
  nowhere.ashwhere.ashsize = 0;
554
  nowhere.ashwhere.ashsize = 0;
555
 
556
  if (as_file) {
6 7u83 557
    fprintf(as_file, "\t.verstamp %d %d\n", majorno, minorno);
2 7u83 558
 
559
    if (PIC_code) {
6 7u83 560
	fprintf(as_file, "\t.option pic2\n");
2 7u83 561
    }
562
    else {
6 7u83 563
        fprintf(as_file,(diagnose)? "\t.option O1\n" : "\t.option O2\n");
2 7u83 564
    }
565
  }
566
 
6 7u83 567
  out_verstamp(majorno, minorno);
2 7u83 568
				/* this is the only? use of these nos, to
569
				   satisfy as1 */
570
  if (PIC_code) {
571
	out_option(2, 2);
572
  }
573
  else
6 7u83 574
  { out_option(1,(diagnose)? 1 : 2); }
2 7u83 575
 
576
  if (diagnose && nofds!=0) {
6 7u83 577
    stab_file(0);
2 7u83 578
  }
579
  else
580
  {
581
    currentfile = 0;
582
  }
583
 
584
 
585
  /* compile procedures, evaluate constants, put in the .comm entries for
586
     undefined objects */
587
 
588
  my_def = top_def;
589
 
590
/*
591
  while (my_def != (dec *) 0) {
592
    exp tg = my_def -> dec_u.dec_val.dec_exp;
593
    char *id = my_def -> dec_u.dec_val.dec_id;
594
    bool extnamed = my_def -> dec_u.dec_val.extnamed;
595
    if (son (tg) != nilexp && (extnamed || no (tg) != 0 || !strcmp (id, "main"))) {
596
      if (extnamed) {
597
	if (as_file)
598
	  fprintf (as_file, "\t.globl\t%s\n", id);
599
	out_common (symnos[my_def->dec_u.dec_val.sym_number], iglobal);
600
      }
601
    }
602
    my_def = my_def -> def_next;
603
  }
604
*/
605
  my_def = top_def;
606
 
6 7u83 607
  while (my_def != (dec *)0) {
2 7u83 608
    if (!my_def -> dec_u.dec_val.processed)
6 7u83 609
       code_it(my_def);
2 7u83 610
    my_def = my_def -> def_next;
611
  };
612
 
613
 
614
  return;		/* return 1 for error, 0 for good */
615
 
616
 
617
}
618
void translate_unit
6 7u83 619
(void)
2 7u83 620
{
621
  if (separate_units)
622
   {
623
     dec * my_def;
624
     translate_capsule();
625
     my_def = top_def;
6 7u83 626
     while (my_def != (dec *)0) {
2 7u83 627
       exp crt_exp = my_def -> dec_u.dec_val.dec_exp;
628
       no(crt_exp) = 0;
629
       pt(crt_exp) = nilexp;
630
       my_def = my_def -> def_next;
631
     };
632
     crt_repeat = nilexp;
633
     repeat_list = nilexp;
634
   };
635
  return;
636
}
637
 
638
 
639
void translate_tagdef
6 7u83 640
(void)
2 7u83 641
{
642
  return;
643
}