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