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
/* 80x86/trans.c */
32
 
33
/**********************************************************************
34
$Author: pwe $
35
$Date: 1998/03/11 11:03:06 $
36
$Revision: 1.4 $
37
$Log: trans.c,v $
38
 * Revision 1.4  1998/03/11  11:03:06  pwe
39
 * DWARF optimisation info
40
 *
41
 * Revision 1.3  1998/02/06  17:04:21  release
42
 * Last minute pre-release polishing.
43
 *
44
 * Revision 1.2  1998/01/21  10:30:01  pwe
45
 * labdiff change
46
 *
47
 * Revision 1.1.1.1  1998/01/17  15:55:52  release
48
 * First version to be checked into rolling release.
49
 *
50
 * Revision 1.14  1997/12/05  10:32:38  pwe
51
 * system identification
52
 *
53
 * Revision 1.13  1997/10/23  09:37:15  pwe
54
 * extra_diags
55
 *
56
 * Revision 1.12  1997/10/10  18:25:33  pwe
57
 * prep ANDF-DE revision
58
 *
59
 * Revision 1.11  1997/08/23  13:45:46  pwe
60
 * initial ANDF-DE
61
 *
62
 * Revision 1.10  1997/06/02  08:36:00  pwe
63
 * diags visibility
64
 *
65
 * Revision 1.9  1997/03/24  11:15:36  pwe
66
 * dwarf2 option/default
67
 *
68
 * Revision 1.8  1997/03/20  16:24:10  pwe
69
 * dwarf2
70
 *
71
 * Revision 1.7  1996/12/13  14:39:36  pwe
72
 * prep NEWDIAGS
73
 *
74
 * Revision 1.6  1996/02/16  10:10:44  pwe
75
 * Linux/ELF struct result and PIC jump table
76
 *
77
 * Revision 1.5  1996/02/08  13:45:15  pwe
78
 * Linux elf v aout option
79
 *
80
 * Revision 1.4  1995/03/16  09:13:35  pwe
81
 * sco_gas now install time option
82
 *
83
 * Revision 1.3  1995/02/17  13:21:17  pwe
84
 * rationalise compilation info
85
 *
86
 * Revision 1.2  1995/01/30  12:56:56  pwe
87
 * Ownership -> PWE, tidy banners
88
 *
89
 * Revision 1.1  1994/10/27  14:15:22  jmf
90
 * Initial revision
91
 *
92
 * Revision 1.2  1994/07/13  07:39:57  jmf
93
 * Remove prefix initialising, do it in machine.c
94
 *
95
 * Revision 1.1  1994/07/12  14:42:47  jmf
96
 * Initial revision
97
 *
98
**********************************************************************/
99
 
100
 
101
#include "config.h"
102
#include "release.h"
103
#include "common_types.h"
104
#include "basicread.h"
105
#include "flags.h"
106
#include "out.h"
107
#include "main_reads.h"
108
#include "flpt.h"
109
#include "externs.h"
110
#include "weights.h"
111
#include "installglob.h"
112
#include "instr.h"
113
#include "machine.h"
114
#include "exp.h"
115
#include "expmacs.h"
116
#include "instr386.h"
117
#include "localflags.h"
118
#include "messages_8.h"
119
#include "diag_fns.h"
120
#include "readglob.h"
121
#include "assembler.h"
122
#include "target_v.h"
123
#include "system_v.h"
124
#include "reader_v.h"
125
#include "construct_v.h"
126
#include "operand.h"
127
#ifdef NEWDIAGS
128
#include "diag_v.h"
129
#include "dg_version.h"
130
#endif
131
#ifdef NEWDWARF
132
#include "dw2_iface.h"
133
#include "dw2_vsn.h"
134
#include "dw2_abbrev.h"
135
#include "dw2_common.h"
136
static bool dump_abbrev = 0 ;
137
#endif
138
 
139
#if DWARF
140
#include "dwarf_mc.h"
141
#endif
142
 
143
extern int print_inlines;
144
 
145
/* PROCEDURES */
146
 
147
static void init_all
148
    PROTO_Z ()
149
{
150
  init_flpt();
151
#include "inits.h"
152
  good_trans = 0;
153
  capsule_freelist = (capsule_frees*)0;
154
  old_proc_props = (proc_props *)0;
155
 
156
/* 80x86 specific */
157
  extra_stack = 0;
158
  top_def = (dec*)0;
159
  init_weights();
160
  initzeros ();
161
  const_list = nilexp;
162
  return;
163
}
164
 
165
int   main
166
    PROTO_N ( (argc, argv) )
167
    PROTO_T ( int argc X char **argv )
168
{
169
  int i;
170
  char *outfname;
171
 
172
		/* defaults */
173
  do_inlining = 1;		/* inline */
174
  redo_structfns = 1;		/* replace fns delivering structs */
175
  redo_structparams = 0;	/* no change to struct params */
176
  is80486 = 1;			/* (at least) 80486 */
177
  is80586 = 1;			/* Pentium */
178
  separate_units = 0;		/* combine units */
179
  do_foralls = 1;		/* do forall optimisations */
180
  extra_checks = 1;		/* perform the extra checks */
181
  always_use_frame = 0;		/* avoid using frame pointer */
182
  do_loopconsts = 1;		/* extract constants from loops */
183
  diagnose = 0;			/* diagnostics off */
184
#ifdef NEWDIAGS
185
  diag_visible = 0;
186
  extra_diags = 0;
187
#endif
188
#ifdef NEWDWARF
189
  dwarf2 = 0;
190
#endif
191
  do_profile = 0;		/* no profiling code */
192
  writable_strings = 0;		/* strings are read only */
193
  PIC_code = 0;			/* do not produce PIC code */
194
  all_variables_visible = 0;	/* use registers */
195
  do_alloca = 1;		/* inline calls of alloca */
196
  round_after_flop = 0;		/* do not round after each floating point
197
				   operation */
198
  strict_fl_div = 1;		/* do not replace divisions by
199
				   multiplication by the inverse */
200
  flpt_const_overflow_fail = 1;	/* constant floating point arithmetic
201
				   fails installation, if overflow */
202
  flpt_always_comparable = 0;	/* this is the default for SVR4.2 */
203
  report_versions = 0;		/* do not print version numbers */
204
  permit_8byte_align = 1;	/* allow 8byte alignment for local doubles
205
				*/
206
  do_unroll = 1;		/* perform loop unrolling */
207
  replace_arith_type = 1;	/* use the C definitions of promote etc.
208
				*/
209
  indirect_jumps = 1;		/* follow gotos and tests to final dest */
210
  no_bss = 0;			/* use .comm */
211
 
212
 
213
  ptr_null = 0;			/* null value for pointer */
214
  proc_null = 0;		/* null value for proc */
215
  lv_null = 0;			/* null value for label_value*/
216
 
217
 
218
  for (i = 1; i != argc && argv[i][0] == '-'; ++i) {/* read flags */
219
    char *s = argv[i];
220
 
221
    switch (s[1]) {
222
      case 'A':
223
        do_alloca = (s[2] == '1');
224
        break;
225
      case 'B':
226
	flpt_const_overflow_fail = (s[2] == '1');
227
	break;
228
      case 'C':
229
	do_loopconsts = (s[2] == '1');
230
	break;
231
      case 'D':
232
        PIC_code = (s[2] == '1');
233
        break;
234
      case 'E':
235
        extra_checks = 0;
236
        break;
237
      case 'F':
238
	do_foralls = (s[2] == '1');
239
	break;
240
      case 'G':
241
	gcc_compatible = (s[2] == '1');
242
	break;
243
      case 'H':
244
	diagnose = 1;
245
#ifdef NEWDIAGS
246
	if (s[2] != 'O')
247
#endif
248
	{
249
#ifdef NEWDIAGS
250
	  diag_visible = 1;
251
#endif
252
	  always_use_frame = 1;
253
          do_inlining = 0;
254
          do_loopconsts = 0;
255
          do_foralls = 0;
256
          all_variables_visible = 1;
257
	}
258
	break;
259
      case 'I':
260
	do_inlining = (s[2] == '1');
261
	break;
262
#ifdef NEWDWARF
263
      case 'J':
264
	diagnose = 1;
265
	extra_diags = 1;
266
	dwarf2 = 1;
267
	break;
268
#endif
269
      case 'K':
270
        if (s[2] == '3')
271
         {
272
           is80486 = 0;
273
           is80586 = 0;
274
         };
275
        if (s[2] == '4')
276
         {
277
           is80486 = 1;
278
           is80586 = 0;
279
         };
280
        if (s[2] == '5')
281
         {
282
           is80486 = 1;
283
           is80586 = 1;
284
         };
285
        break;
286
      case 'M':
287
	strict_fl_div = (s[2] == '1');
288
	break;
289
      case 'N':
290
	do_prom = 1;
291
	break;
292
      case 'P':
293
	do_profile = 1;
294
	break;
295
      case 'Q':
296
	return 0;
297
      case 'R':
298
        round_after_flop = (s[2] == '1');
299
        break;
300
#ifdef NEWDWARF
301
      case 'T':
302
	dump_abbrev = 1;
303
	diagnose = 1;
304
	extra_diags = 1;
305
	dwarf2 = 1;
306
	break;
307
#endif
308
      case 'U':
309
	do_unroll = (s[2] == '1');
310
	break;
311
      case 'V':
312
	IGNORE fprintf(stderr, "DERA ANDF 80x86/Pentium translator (TDF version %d.%d)\n",
313
		 MAJOR_VERSION, MINOR_VERSION);
314
	IGNORE fprintf(stderr, "reader %d.%d: ", reader_version,
315
		 reader_revision);
316
	IGNORE fprintf(stderr, "construct %d.%d: ", construct_version,
317
		 construct_revision);
318
	IGNORE fprintf(stderr, "target %d.%d: ", target_version,
319
		 target_revision);
320
#if DWARF
321
	IGNORE fprintf(stderr, "dwarf1 %d.%d: ", DWARF_MAJOR,
322
		 DWARF_MINOR);
323
#endif
324
#ifdef NEWDIAGS
325
	IGNORE fprintf(stderr, "diag_info %d.%d:\n%s   ", diag_version,
326
		 diag_revision, DG_VERSION);
327
#endif
328
#ifdef NEWDWARF
329
	IGNORE fprintf(stderr, "dwarf2 %d.%d: ", DWARF2_MAJOR,
330
		 DWARF2_MINOR);
331
#endif
332
	IGNORE fprintf(stderr, "\n");
333
	IGNORE fprintf(stderr, "system %s: ", target_system);
334
#ifdef __DATE__
335
	IGNORE fprintf(stderr, "installer compilation %s", __DATE__);
336
#endif
337
	IGNORE fprintf(stderr, "\n");
338
#ifdef RELEASE
339
	IGNORE fprintf(stderr, "release: %s\n",RELEASE);
340
#endif
341
        break;
342
      case 'W':
343
        writable_strings = (s[2] == '1');
344
        break;
345
      case 'X':
346
	do_unroll = 0;
347
	do_inlining = 0;
348
	do_loopconsts = 0;
349
	do_special_fns = 0;
350
	do_foralls = 0;
351
	indirect_jumps = 0;
352
        all_variables_visible = 1;
353
        break;
354
      case 'Z':
355
	report_versions = 1;
356
	break;
357
 
358
      case 'a':
359
        always_use_frame = 1;
360
        break;
361
      case 'b':
362
        all_variables_visible = 1;
363
        break;
364
      case 'c':
365
	replace_arith_type = 0;
366
	break;
367
      case 'd':
368
        redo_structfns = 0;
369
        break;
370
      case 'e':
371
	indirect_jumps = 0;
372
	break;
373
      case 'f':
374
	ptr_null = 0x55555555;		/* null value for pointer */
375
	break;
376
      case 'g':
377
        flpt_always_comparable = 1;
378
        break;
379
      case 'h':
380
	no_bss = 1;
381
	break;
382
      case 'i':
383
	print_inlines = 1;
384
	break;
385
#if islinux
386
      case 'k':
387
	set_linux_format (s[2] == '1');
388
	break;
389
#endif
390
#if issco
391
      case 's':
392
	sco_gas = 1;
393
	break;
394
#endif
395
 
396
      default:
397
	failer (BAD_FLAG);
398
	break;
399
    };
400
  };
401
 
402
#if islinux
403
  if (gcc_compatible < 0)
404
    gcc_compatible = ! linux_elf;
405
#endif
406
 
407
  if (i == argc)
408
    i--;	/* BAD_COMMAND1 */
409
 
410
  for (; i < argc ; i += 2) {
411
    if (i == (argc-1))
412
      {
413
        failer (BAD_COMMAND1);
414
        return (1);
415
      };
416
 
417
 
418
    outfname = argv[i+1];
419
 
420
    /* initiate the output file */
421
    if (!outinit (outfname)) {
422
      failer (CANT_OPEN);
423
      return (1);
424
    };
425
 
426
    if (!initreader (argv[i])) {
427
      failer (CANT_READ);
428
      return (1);
429
    };
430
 
431
    init_all();
432
 
433
#ifdef NEWDWARF
434
    if (dwarf2) {
435
      init_dwarf2 ();
436
    } else
437
#endif
438
    if (diagnose) out_diagnose_prelude();
439
 
440
#ifdef NEWDWARF
441
    if (dump_abbrev) {
442
      outs (".text\n");
443
      do_abbreviations ();
444
      dwarf2_prelude ();
445
      make_dwarf_common ();
446
      dwarf2_postlude ();
447
    } else
448
#endif
449
 
450
    IGNORE d_capsule();
451
 
452
    while (weak_list)
453
     {
454
       outs(".set ");
455
       outs(weak_list -> weak_id);
456
       outs(",");
457
       outs(weak_list -> val_id);
458
       outnl();
459
       weak_list = weak_list -> next;
460
     };
461
 
462
#ifdef NEWDWARF
463
    if (dwarf2) {
464
      end_dwarf2 ();
465
    } else
466
#endif
467
    if (diagnose) out_diagnose_postlude();
468
 
469
    outend ();			/* close the .s file */
470
    endreader();
471
 
472
    if (good_trans)
473
      exit(EXIT_FAILURE);
474
  }
475
  return 0;
476
}