Subversion Repositories tendra.SVN

Rev

Rev 2 | Go to most recent revision | 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
/**********************************************************************
32
$Author: release $
33
$Date: 1998/01/17 15:56:04 $
34
$Revision: 1.1.1.1 $
35
$Log: main.c,v $
36
 * Revision 1.1.1.1  1998/01/17  15:56:04  release
37
 * First version to be checked into rolling release.
38
 *
39
 * Revision 1.2  1995/09/12  11:00:34  currie
40
 * gcc pedanttry
41
 *
42
 * Revision 1.1  1995/04/13  09:33:41  currie
43
 * Initial revision
44
 *
45
***********************************************************************/
46
 
47
/*********************************************************************
48
                     main.c
49
 
50
   This is the main routine.
51
    It constructs .G (binasm) and .T (symbol table) files from the input .t
52
    files. If -S is given it will also construct a .s (assembler) file in as_file.
53
 
54
 *********************************************************************/
55
 
56
 
57
 
58
 
59
#include "config.h"
60
#include "version.h"
61
#include "common_types.h"
62
#include "basicread.h"
63
#include "flags.h"
64
#include "main_reads.h"
65
#include "flpt.h"
66
#include "externs.h"
67
#include "installglob.h"
68
#include "machine.h"
69
#include "exp.h"
70
#include "dump_distr.h"
71
#include "construct_v.h"
72
#include "reader_v.h"
73
extern void output_symtab PROTO_S (( char* ));
74
 
75
 
76
/* extern int bytes_allocated; */
77
 
78
void out_rename
79
    PROTO_N ( (oldid, newid) )
80
    PROTO_T ( char * oldid X char * newid )
81
{
82
	/* ??? this may be wrong with diagnostics */
83
	return;
84
}
85
 
86
extern int good_trans;
87
bool do_extern_adds;
88
FILE * as_file;
89
 
90
FILE * ba_file;
91
 
92
int   majorno = 3;
93
int   minorno = 0;
94
 
95
long  currentfile = -1;		/* our source fileno 0.. */
96
long  mainfile = 0;		/* would be best if it  actually contained
97
				   main ! */
98
bool BIGEND = (little_end == 0);
99
 
100
bool do_tlrecursion = 1;
101
 
102
bool opt
103
    PROTO_N ( (c) )
104
    PROTO_T ( char c )
105
{ if (c == '0' || c == 0) return 0;
106
  else return 1;
107
}
108
 
109
int   main
110
    PROTO_N ( (argc, argv) )
111
    PROTO_T ( int argc X char **argv )
112
{
113
  long  i;
114
  char *nm;
115
  char *aname;
116
  char *dname;
117
  bool withs = 0;
118
  bool no_opts = 0;
119
  bool override_diags = 0;
120
/*  bool show_size = 0; */
121
 
122
  as_file = (FILE *) 0;
123
  do_inlining = 1;
124
  redo_structfns = 1;
125
  do_unroll = 1;
126
  do_extern_adds = 0;
127
 
128
 
129
  flpt_const_overflow_fail = 1; /* HUGEVAL requires 0 for Ysystem */
130
 
131
  do_foralls = 1;
132
  do_alloca = 1;
133
  for (i = 1; argv[i][0] == '-'; ++i) {/* read flags */
134
    char *s = argv[i];
135
    switch (s[1]) {
136
/*      case '?':
137
	show_size = 1;
138
	break;
139
*/
140
      case 'A':
141
	do_alloca = opt(s[2]);
142
	break;
143
      case 'B':
144
	flpt_const_overflow_fail = opt(s[2]);
145
	break;
146
      case 'C':
147
	do_loopconsts = opt(s[2]);
148
	break;
149
      case 'D':
150
	failer("No PIC code available");
151
	exit(EXIT_FAILURE);
152
      case 'E':
153
        extra_checks = 0;
154
        break;
155
      case 'e':
156
	do_extern_adds = opt(s[2]);
157
	break;
158
      case 'F':
159
        do_foralls = opt(s[2]);
160
        break;
161
      case '-':
162
      	override_diags = 1;
163
      	break;
164
      case 'H':
165
	diagnose = 1;
166
	do_alloca = 0; /* dbx does not understand variable frame sizes */
167
	break;
168
      case 'I':
169
	do_inlining = opt(s[2]);
170
        break;
171
      case 'K':
172
	/* only MIPS ultrix */
173
	break;
174
      case 'M':
175
	strict_fl_div = (opt(s[2]) == 0);
176
	break;
177
      case 'P':
178
	do_profile = 1;
179
	break;
180
      case 'Q':
181
	exit(EXIT_FAILURE);
182
      case 'R':
183
	round_after_flop = opt(s[2]);
184
	break;
185
      case 'S':
186
	withs =1;
187
	break;
188
      case 'U':
189
        do_unroll = opt(s[2]);
190
        break;
191
      case 'V': {
192
		int   ind = 2;
193
		int maj = 0;
194
		minorno = 0;
195
		for (;; ind++) {
196
		  char  si = s[ind];
197
		  if (si != ' ') {
198
		    if (si >= '0' && si <= '9') {
199
		      maj = maj * 10 + si - '0';
200
		    }
201
		    else
202
		      break;
203
		  }
204
		}
205
 
206
		if (s[ind] != '.') {
207
		  fprintf(stderr,
208
                "DRA TDF Mips Ultrix (as:3.x) translator %d.%d: (TDF version %d.%d)\n",
209
                 mipstrans_version,mipstrans_revision, MAJOR_VERSION, MINOR_VERSION);
210
                 fprintf(stderr, "reader %d.%d: \n", reader_version,
211
		 reader_revision);
212
	         fprintf(stderr, "construct %d.%d: \n", construct_version,
213
		 construct_revision);
214
        	 break;
215
		}
216
		majorno = maj;
217
		minorno = 0;
218
 
219
		for (ind++;; ind++) {
220
		  char  si = s[ind];
221
		  if (si >= '0' && si <= '9') {
222
		    minorno = minorno * 10 + si - '0';
223
		  }
224
		  else
225
		    break;
226
		}
227
 
228
	      }
229
      case 'W':
230
        writable_strings = opt(s[2]);
231
        break;
232
      case 'X':
233
        no_opts = 1;
234
        break;
235
      case 'd':
236
        do_dump_opt = 0;
237
        break;
238
      case 'l':
239
        do_tlrecursion = opt(s[2]);
240
        break;
241
      case 'Z': /* prints on stderr the versions of all the capsules
242
                   from which this capsule was made */
243
        report_versions = 1;
244
        break;
245
      default:
246
	failer ("Illegal flag");
247
	break;
248
    };
249
  };
250
 
251
#ifdef V210
252
	if (majorno != 2) {
253
		printf("This translator is only for ULTRIX versions 2.x\n");
254
		exit(EXIT_FAILURE);
255
	}
256
#else
257
	if (majorno == 2) {
258
		printf("This translator is not for ULTRIX versions 2.x\n");
259
		exit(EXIT_FAILURE);
260
	}
261
#endif
262
 
263
  if (override_diags) diagnose = 0;
264
  if (diagnose || no_opts) {		/* line numbering goes to hell with
265
				   optimisations */
266
 
267
        do_inlining = 0;
268
        do_loopconsts = 0;
269
        do_foralls = 0;
270
        do_dump_opt = 0;
271
        do_unroll = 0;
272
	do_tlrecursion = 0;
273
  };
274
 
275
 
276
  if (withs) {			/* requires assembler text */
277
    aname = argv[argc - 1];
278
    as_file = fopen (aname, "w");
279
    if (as_file == (FILE *) 0) {
280
      failer ("can't find .s file");
281
      return 1;
282
    }
283
    argc--;
284
  }
285
 
286
 
287
  dname = argv[argc - 1];	/* the .T file */
288
  nm = argv[argc - 2];		/* the .G file */
289
  ba_file = fopen (nm, "w");
290
  if (ba_file == (FILE *) 0) {
291
    printf ("install: can't open output file %s\n", nm);
292
    return (1);
293
  }
294
 
295
 
296
  if (!initreader (argv[argc - 3])) {
297
    failer ("cant read .t file");
298
    return (1);
299
  };
300
 
301
  init_flpt();
302
#include "inits.h"
303
  top_def = (dec*)0;
304
 
305
 
306
 
307
 
308
 
309
  local_prefix = "$$";
310
  name_prefix = "";
311
 
312
 
313
  d_capsule();
314
/*
315
  if (show_size) {
316
	printf("bytes allocated = %d\n", bytes_allocated);
317
  }
318
*/
319
 
320
 
321
 
322
  if (as_file)
323
    fclose (as_file);		/* close the .s file */
324
  fclose (ba_file);		/* close the .G file */
325
  output_symtab (dname);	/* construct the .T file */
326
  return (good_trans);		/* return 1 for error, 0 for good */
327
}
328