Subversion Repositories tendra.SVN

Rev

Rev 5 | 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: driver.c,v 1.2 1998/02/06 17:04:28 release Exp $	 */
32
 
33
#ifndef lint
34
static char vcid[] = "$Id: driver.c,v 1.2 1998/02/06 17:04:28 release Exp $";
35
#endif /* lint */
36
 
37
/*
38
  driver.c
39
  Provides the driver function for the TDF->DEC Alpha translator.
40
  JM  17/9/93
41
*/
42
 
43
/*
44
$Log: driver.c,v $
45
 * Revision 1.2  1998/02/06  17:04:28  release
46
 * Last minute pre-release polishing.
47
 *
48
 * Revision 1.1.1.1  1998/01/17  15:56:01  release
49
 * First version to be checked into rolling release.
50
 *
51
 * Revision 1.10  1996/03/25  14:56:18  john
52
 * introduced do_extern_adds
53
 *
54
 * Revision 1.9  1995/09/06  09:00:42  john
55
 * removed old command line argument parsing
56
 *
57
 * Revision 1.8  1995/06/28  10:23:36  john
58
 * Added RELEASE info to version information
59
 *
60
 * Revision 1.7  1995/06/13  14:00:22  john
61
 * Changed denormal constant handling
62
 *
63
 * Revision 1.6  1995/05/23  10:55:35  john
64
 * Removed unneeded header file.
65
 *
66
 * Revision 1.5  1995/05/16  10:46:51  john
67
 * Fixed error message
68
 *
69
 * Revision 1.4  1995/04/07  11:01:18  john
70
 * Added new command line arg processing.  Changed handling of IEEE denormals
71
 *
72
 * Revision 1.3  1995/03/29  14:06:52  john
73
 * Added inclusion of bool.h
74
 *
75
 * Revision 1.2  1995/03/29  10:30:10  john
76
 * Added option to control handling of denormalised numbers.
77
 *
78
 * Revision 1.1.1.1  1995/03/23  10:39:30  john
79
 * Entered into CVS
80
 *
81
 * Revision 1.21  1995/03/03  15:22:35  john
82
 * Added scheduling code
83
 *
84
 * Revision 1.20  1995/02/13  08:58:39  john
85
 * Turned foralls optimisation off, by default.
86
 *
87
 * Revision 1.19  1995/01/26  13:38:35  john
88
 * Added symboldecs.h to list of included files
89
 *
90
 * Revision 1.18  1995/01/18  11:44:33  john
91
 * Added : to version numbers
92
 *
93
 * Revision 1.17  1995/01/12  15:07:12  john
94
 * Minor change
95
 *
96
*/
97
 
98
 
99
#include "config.h"
100
#include "release.h"
101
#include "common_types.h"
102
#include "basicread.h"
103
#include "flags.h"
104
#include "main_reads.h"
105
#include "flpt.h"
106
#include "externs.h"
107
#include "installglob.h"
108
#include "machine.h"
109
#include "exp.h"
110
#include "dump_distr.h"
111
#include "file.h"
112
#include "fail.h"
113
#include "version.h"
114
#include "reader_v.h"
115
#include "construct_v.h"
116
#include "symbol.h"
117
#include "bool.h"
118
FILE *as_file;		/* assembly file */
119
FILE *ba_file;
120
 
121
#define SUCCESS 0
122
#define FAILURE 1
123
#ifndef compile_date
124
#ifdef __DATE__
125
#define compile_date __DATE__
126
#else
127
#error "compile_date is not set"
128
#define compile_date	"04/07/71"
129
#endif
130
#endif
131
int use_umulh_for_div;
132
bool do_scheduling = TRUE;
133
bool fail_with_denormal_constant = TRUE;
134
bool treat_denorm_specially = FALSE;
135
bool trap_all_fops = FALSE;
136
bool do_extern_adds = FALSE;
137
 
138
static int infoopt = FALSE;	/* set if the -V option has been invoked */
139
static bool produce_symbolic_assembler = FALSE;
140
 
141
void printinfo
142
    PROTO_Z ()
143
{
144
  (void)fprintf(stderr,"DRA TDF DEC Alpha/OSF1 translator %d.%d.%d:(TDF version %d.%d)\n",
145
		target_version,target_revision,target_patchlevel,
146
		MAJOR_VERSION,MINOR_VERSION);
147
  (void)fprintf(stderr,"reader %d.%d: ",reader_version,reader_revision);
148
  (void)fprintf(stderr,"construct %d.%d: \n",construct_version,
149
		construct_revision);
150
  (void)fprintf(stderr,"installer compilation %s\n",compile_date);
151
  (void)fprintf(stderr,"release: %s\n",RELEASE);
152
  return;
153
}
154
 
155
void out_rename
156
    PROTO_N ( ( oldid,newid ) )
157
    PROTO_T ( char *oldid X char *newid )
158
{
159
  UNUSED(oldid);
160
  UNUSED(newid);
161
  return;
162
}
163
 
164
int get_switch
165
    PROTO_N ( ( option,range_max ) )
166
    PROTO_T ( char option X int range_max )
167
{
168
  int val = option - '0';
169
  if (val>=0 && val <= range_max){
170
    return val;
171
  }	
172
  else {
173
    (void)fprintf(stderr,"alphatrans: error : illegal option value : 0 .. %d expected\n",range_max);
174
    exit(EXIT_FAILURE);
175
  }
176
  return 0;
177
}
178
 
179
 
180
 
181
/*
182
  Reads and processes a command line option.
183
*/
184
void process_flag
185
    PROTO_N ( ( option ) )
186
    PROTO_T ( char *option )
187
{
188
  switch(option[1]){
189
   case 'A':
190
    /* alloca switching */
191
    do_alloca = get_switch(option[2],1);
192
    break;
193
   case 'B':
194
    /* big floating point constants -> infinity */
195
    break;
196
   case 'C':
197
    do_loopconsts = get_switch(option[2],1);
198
    break;
199
   case 'D':
200
    failer("no PIC code available");
201
    exit(EXIT_FAILURE);
202
   case 'E':
203
    extra_checks = 0;
204
    break;
205
   case 'F':
206
    do_foralls = get_switch(option[2],1);
207
    break;
208
   case 'H':
209
    diagnose = 1;
210
    do_inlining = 0;
211
    do_loopconsts = 0;
212
    do_foralls = 0;
213
    do_dump_opt = 0;
214
    do_alloca = 0;
215
    break;
216
   case 'I':
217
    do_inlining=get_switch(option[2],1);
218
    break;
219
   case 'K':
220
    fprintf(stderr,"alphatrans: [-K..] -> only one kind of processor is supported\n");
221
    break;
222
   case 'M':
223
    strict_fl_div = get_switch(option[2],1);
224
    break;
225
   case 'P':
226
    do_profile = 1;
227
    break;
228
   case 'Q':
229
    exit(EXIT_SUCCESS);
230
    break;
231
   case 'R':
232
    round_after_flop = get_switch(option[2],1);
233
    break;
234
   case 'S':
235
    produce_symbolic_assembler = TRUE;
236
    break;
237
   case 'U':
238
    do_unroll = get_switch(option[2],1);
239
    break;
240
   case 'X':
241
    do_inlining=0;
242
    do_loopconsts=0;
243
#ifdef USE_OLD_UNROLLER
244
    dostrengths=0;
245
#endif
246
    do_special_fns=0;
247
    do_foralls=0;
248
    do_dump_opt=0;
249
    break;
250
   case 'V':
251
   case 'v':
252
   case 'i':
253
    printinfo();
254
    infoopt = TRUE;
255
    break;
256
   case 'W':
257
    writable_strings = get_switch(option[2],1);
258
    break;
259
   case 'Z':
260
    report_versions = 1;
261
    break;
262
   case 'u':
263
    use_umulh_for_div = get_switch(option[2],1);
264
    break;
265
   case 's':
266
    do_scheduling = get_switch(option[2],1);
267
    break;
268
   case 'd':	
269
    /* handle IEEE denormals */
270
     treat_denorm_specially = TRUE;
271
     switch(get_switch(option[2],2)){
272
     case 0: /* replace denormal const with 0.0 (don't do this) */
273
       alphawarn("Unsupported denormal switch");
274
       fail_with_denormal_constant = FALSE;
275
       break;
276
     case 1: /* error if denormal const is encountered */
277
       fail_with_denormal_constant = TRUE;
278
       break;
279
     case 2: 
280
     /* handle denormals properly (and slowly), by 
281
       stopping the interleaving of floating point 
282
       operations and using the OS exception handler */
283
       treat_denorm_specially = FALSE;
284
       trap_all_fops = TRUE;
285
       break;
286
     }
287
     break;
288
  default:
289
    alphafail(ILLEGAL_FLAG,option);
290
    break;
291
  }
292
}
293
 
294
bool BIGEND = (little_end == 0);
295
bool do_tlrecursion = 1;
296
int currentfile = -1;
297
int mainfile=0;
298
int majorno = 3;
299
int minorno = 11;
300
 
301
#define MIN_COMMAND_LINE_ARGS 4
302
 
303
int main
304
    PROTO_N ( ( argc,argv ) )
305
    PROTO_T ( int argc X char *argv[] )
306
{
307
  int i;
308
  int num_flags=0;
309
  char *aname;	/* name of file for assembly output */
310
  char *dname;	/* name of file to hold symbol table */
311
  char *baname;
312
  char *tname;
313
  do_inlining=0;
314
  redo_structfns=1;
315
  do_foralls=0;
316
  do_alloca=1;
317
#if DO_NEW_DIVISION 
318
  use_umulh_for_div = 1;
319
#else
320
  use_umulh_for_div = 0;
321
#endif
322
  /* read command line options */
323
  for(i=1;i<argc;++i){
324
    if(argv[i][0] == '-'){
325
      num_flags++;
326
      process_flag(argv[i]);
327
    }
328
  }
329
  if((argc-num_flags)<MIN_COMMAND_LINE_ARGS){
330
    if(infoopt){
331
      exit(EXIT_SUCCESS);
332
    }
333
    else{
334
      alphafail(TOO_FEW_PARAMETERS);
335
    }
336
  }
337
 
338
  /* the files are passed in the order .t .G .T .s */
339
 
340
  if(produce_symbolic_assembler){
341
      aname = argv[argc-1];
342
      as_file = open_file(aname,WRITE);
343
      argc--;
344
  }
345
  baname = argv[argc-2];
346
  dname = argv[argc-1];
347
  tname = argv[argc-3];
348
 
349
  ba_file = open_file(baname,WRITE);
350
  if(!initreader (tname)) alphafail(OPENING_T_FILE,tname);
351
  init_flpt();
352
#include "inits.h"
353
  top_def = (dec*)0;
354
  local_prefix="$$";
355
  name_prefix="";
356
#if DO_SCHEDULE
357
  if(do_scheduling){
358
    initialise_scheduler();
359
  }
360
#endif
361
 
362
  (void)d_capsule();
363
  output_symtab(dname);
364
#if DO_SCHEDULE
365
  if(do_scheduling){
366
/*    schduler_finished();*/
367
  }
368
#endif
369
  close_file(as_file);
370
  close_file(ba_file);
371
  return (SUCCESS);
372
}
373
 
374
 
375
 
376
 
377
 
378
 
379