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) 1996
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
			    VERSION INFORMATION
31
			    ===================
32
 
33
--------------------------------------------------------------------------
34
$Header: /u/g/release/CVSROOT/Source/src/installers/680x0/sunos/main.c,v 1.2 1998/02/06 17:04:20 release Exp $
35
--------------------------------------------------------------------------
36
$Log: main.c,v $
37
 * Revision 1.2  1998/02/06  17:04:20  release
38
 * Last minute pre-release polishing.
39
 *
40
 * Revision 1.1.1.1  1998/01/17  15:55:51  release
41
 * First version to be checked into rolling release.
42
 *
43
Revision 1.1.1.1  1997/10/13 12:42:56  ma
44
First version.
45
 
46
Revision 1.5  1997/10/13 08:49:39  ma
47
Made all pl_tests for general proc & exception handling pass.
48
 
49
Revision 1.4  1997/09/25 06:45:19  ma
50
All general_proc tests passed
51
 
52
Revision 1.3  1997/06/18 10:09:40  ma
53
Checking in before merging with Input Baseline changes.
54
 
55
Revision 1.2  1997/04/20 11:30:33  ma
56
Introduced gcproc.c & general_proc.[ch].
57
Added cases for apply_general_proc next to apply_proc in all files.
58
 
59
Revision 1.1.1.1  1997/03/14 07:50:15  ma
60
Imported from DRA
61
 
62
 * Revision 1.1.1.1  1996/09/20  10:56:55  john
63
 *
64
 * Revision 1.3  1996/09/13  13:47:17  john
65
 * Removed my_check_routines
66
 *
67
 * Revision 1.2  1996/07/05  14:23:07  john
68
 * Changed version reporting
69
 *
70
 * Revision 1.1.1.1  1996/03/26  15:45:15  john
71
 *
72
 * Revision 1.9  94/06/30  11:52:52  11:52:52  ra (Robert Andrews)
73
 * Print version numbers from common section as well as machine dependent
74
 * version number.
75
 *
76
 * Revision 1.8  94/06/29  14:22:32  14:22:32  ra (Robert Andrews)
77
 * Changed version number.  Added support for common installer command-line
78
 * options.
79
 *
80
 * Revision 1.7  94/02/21  16:01:03  16:01:03  ra (Robert Andrews)
81
 * A number of flags which used to be bool are now int.
82
 *
83
 * Revision 1.6  93/11/19  16:22:12  16:22:12  ra (Robert Andrews)
84
 * Changed version number to 0.5.
85
 *
86
 * Revision 1.5  93/05/24  15:57:30  15:57:30  ra (Robert Andrews)
87
 * version has been renamed version_str.  New flags for reporting version
88
 * numbers of input capsules and hptrans version (on stderr).
89
 *
90
 * Revision 1.4  93/04/19  13:42:20  13:42:20  ra (Robert Andrews)
91
 * New version number for March93 spec.
92
 *
93
 * Revision 1.3  93/04/19  13:35:03  13:35:03  ra (Robert Andrews)
94
 * Representation of alignments has changed.
95
 *
96
 * Revision 1.2  93/02/26  17:01:08  17:01:08  ra (Robert Andrews)
97
 * Added version.h, an automatically generated file which contains
98
 * an overall RCS revision number and the date of this revision.
99
 *
100
 * Revision 1.1  93/02/26  16:21:57  16:21:57  ra (Robert Andrews)
101
 * Initial revision
102
 *
103
--------------------------------------------------------------------------
104
*/
105
 
106
#include "config.h"
107
#include "release.h"
108
#include "common_types.h"
109
#include "assembler.h"
110
#include "basicread.h"
111
#include "flpt.h"
112
#include "main_reads.h"
113
#include "weights.h"
114
#include "instrs.h"
115
#include "installglob.h"
116
#include "expmacs.h"
117
#include "exp.h"
118
#include "externs.h"
119
#include "flags.h"
120
#include "mach.h"
121
#include "mach_ins.h"
122
#include "mach_op.h"
123
#include "codex.h"
124
#include "output.h"
125
#include "peephole.h"
126
#include "szs_als.h"
127
#include "tests.h"
128
#include "utility.h"
129
#include "version.h"
130
#include "reader_v.h"
131
#include "construct_v.h"
132
#include "where.h"
133
#if have_diagnostics
134
#include "xdb_basics.h"
135
#include "xdb_output.h"
136
#endif
137
extern int errors ;
138
extern int max_errors ;
139
 
140
 
141
/*
142
    PROGRAM NAME AND VERSION NUMBER
143
*/
144
 
145
char *progname = "hptrans" ;
146
static char *version_str = "Version: 0.6" ;
147
static char *revision = REVISION_STRING ;
148
static char *revdate = DATE_STRING ;
149
int normal_version = 1 ;
150
 
151
 
152
/*
153
    EXTRA COMPILATION FLAGS
154
*/
155
 
156
int do_peephole = 1 ;
157
int do_pic = 0 ;
158
static int do_quit = 0 ;
159
static int do_sep_units = 0 ;
160
static int ignore_errors = 0 ;
161
#ifdef EBUG
162
int optimize = 0 ;
163
#else
164
static int optimize = 1 ;
165
#endif
166
static int report_version = 0 ;
167
static int report_tdf_versions = 0 ;
168
static int show_options = 0 ;
169
static int dummy_option = 0 ;
170
 
171
#ifdef EBUG
172
 
173
int do_test = 0 ;
174
int seek_label = 0 ;
175
int seek_extern = 0 ;
176
int seek_label_no ;
177
char *seek_extern_id ;
178
 
179
int seek_line = 0 ;
180
int seek_line_no ;
181
static char *seek_line_id ;
182
 
183
#endif
184
 
185
int diag_override ;
186
static int diag_stab_override = 0 ;
187
static int diag_xdb_new_override = 0 ;
188
static int diag_xdb_old_override = 0 ;
189
 
190
 
191
 
192
/*
193
    VARIABLE SIZES AND ALIGNMENTS
194
*/
195
 
196
alignment MAX_BF_SIZE ;
197
 
198
 
199
/*
200
    MAXIMUM EXPONENT FOR FLOATING-POINT NUMBERS
201
*/
202
 
203
int target_dbl_maxexp = 1024 ;
204
 
205
 
206
/*
207
    OPTIONS
208
 
209
    There are two types of options.  Firstly, for certain key words,
210
    key, the option "-key" enables, and the option "-no_key" disables,
211
    the corresponding action.  Some of these options take an additional
212
    argument in their positive form, i.e. "-key arg".  Secondly, single
213
    letter options are used as shorthand for some of the options of the
214
    first type.
215
 
216
    Each entry in this table gives a key word, key, followed by the
217
    single letter option for "-key" (or 0 is there isn't one) and
218
    the single letter option for "-no_key".  There is also a pointer
219
    to the boolean changed by this option and, if the option takes a
220
    qualifying string, a pointer to the string thus set.
221
*/
222
 
223
struct {
224
    char *opt ;
225
    char on ;
226
    char off ;
227
    char sw ;
228
    int *flag ;
229
    char **value ;
230
} options [] = {
231
    { "alloca", 0, 0, 'A', &do_alloca, null },
232
    { "cc", 'c', 'g', 0, &cc_conventions, null },
233
    { "diag", 'H', 0, 0, &diagnose, null },
234
    { "extra_checks", 0, 'E', 0, &extra_checks, null },
235
    { "float_div", 0, 0, 'M', &strict_fl_div, null },
236
    { "float_inf", 0, 0, 'B', &flpt_const_overflow_fail, null },
237
    { "foralls", 0, 0, 'F', &do_foralls, null },
238
    { "ignore", 0, 0, 0, &ignore_errors, null },
239
    { "immediate", 'i', 0, 0, &output_immediately, null },
240
    { "inlining", 0, 0, 'I', &do_inlining, null },
241
    { "loopconsts", 0, 0, 'C', &do_loopconsts, null },
242
#if have_diagnostics
243
    { "stab", 0, 0, 0, &diag_stab_override, null },
244
    { "new_diag", 0, 0, 0, &diag_xdb_new_override, null },
245
    { "old_diag", 0, 0, 0, &diag_xdb_old_override, null },
246
#endif
247
    { "opt", 'O', 'X', 0, &optimize, null },
248
    { "options", 'o', 0, 0, &show_options, null },
249
    { "peephole", 0, 0, 0, &do_peephole, null },
250
    { "pic", 0, 0, 'D', &do_pic, null },
251
    { "profile", 'P', 0, 0, &do_profile, null },
252
    { "quit", 'Q', 0, 0, &do_quit, null },
253
    { "report_version", 'Z', 0, 0, &report_tdf_versions, null },
254
    { "round", 'r', 0, 'R', &round_after_flop, null },
255
    { "separate_units", 'U', 0, 0, &do_sep_units, null },
256
    { "special_fns", 0, 0, 0, &do_special_fns, null },
257
    { "sub_params", 0, 0, 0, &do_sub_params, null },
258
#ifdef EBUG
259
    { "label", 'L', 0, 0, &seek_extern, &seek_extern_id },
260
    { "line", 'l', 0, 0, &seek_line, &seek_line_id },
261
    { "test", 'l', 0, 0, &do_test, null },
262
#endif
263
    { "unroll", 0, 0, 'U', &do_unroll, null },
264
    { "version", 'V', 0, 0, &report_version, null },
265
    { "write_strings", 0, 0, 'W', &dummy_option, null }
266
} ;
267
 
268
 
269
/*
270
    MAIN ROUTINE
271
 
272
    This routine processes the command-line arguments, calls the
273
    initialization routines, and then calls the main processing
274
    routines.
275
*/
276
 
277
int main
278
    PROTO_N ( ( argc, argv ) )
279
    PROTO_T ( int argc X char **argv )
280
{
281
    int a ;
282
    char **p = null ;
283
    char *input = null ;
284
    char *output = null ;
285
 
286
    /* Set up program name */
287
    progname = basename ( argv [0] ) ;
288
 
289
    /* Set default options */
290
    diagnose = 0 ;
291
    do_alloca = 1 ;
292
    do_foralls = 1 ;
293
    do_inlining = 1 ;
294
    do_loopconsts = 1 ;
295
    do_profile = 0 ;
296
    do_special_fns = 1 ;
297
    do_unroll = 1 ;
298
    extra_checks = 1 ;
299
    redo_structfns = 0 ;
300
 
301
    /* Process arguments */
302
    for ( a = 1 ; a < argc ; a++ ) {
303
	if ( p ) {
304
	    /* Set extra part of two part options */
305
	    *p = argv [a] ;
306
	    p = null ;
307
	} else if ( argv [a][0] == '-' && argv [a][1] ) {
308
	    /* Search option table */
309
	    bool found = 0 ;
310
	    char *s = argv [a] + 1 ;
311
	    int i, n = array_size ( options ) ;
312
	    if ( ( s [1] == '0' || s [1] == '1' ) && s [2] == 0 ) {
313
		for ( i = 0 ; !found && i < n ; i++ ) {
314
		    if ( *s == options [i].sw ) {
315
			*( options [i].flag ) = ( s [1] - '0' ) ;
316
			p = options [i].value ;
317
			found = 1 ;
318
		    }
319
		}
320
	    } else if ( s [1] ) {
321
		bool b = 1 ;
322
		if ( strncmp ( s, "no_", 3 ) == 0 ) {
323
		    s += 3 ;
324
		    b = 0 ;
325
		}
326
		for ( i = 0 ; !found && i < n ; i++ ) {
327
		    if ( eq ( s, options [i].opt ) ) {
328
			*( options [i].flag ) = b ;
329
			if ( b ) p = options [i].value ;
330
			found = 1 ;
331
		    }
332
		}
333
	    } else {
334
		for ( i = 0 ; !found && i < n ; i++ ) {
335
		    if ( *s == options [i].on ) {
336
			*( options [i].flag ) = 1 ;
337
			p = options [i].value ;
338
			found = 1 ;
339
		    } else if ( *s == options [i].off ) {
340
			*( options [i].flag ) = 0 ;
341
			found = 1 ;
342
		    }
343
		}
344
	    }
345
	    if ( !found ) warning ( "Unknown option, %s", argv [a] ) ;
346
	} else {
347
	    /* Set up input and output files */
348
	    if ( input == null ) {
349
		input = argv [a] ;
350
	    } else if ( output == null ) {
351
		output = argv [a] ;
352
	    } else {
353
		error ( "Too many arguments" ) ;
354
		exit ( EXIT_FAILURE ) ;
355
	    }
356
	}
357
    }
358
 
359
#ifdef EBUG
360
    /* Deal with debugging options */
361
    if ( seek_extern ) {
362
	if ( is_local ( seek_extern_id ) ) {
363
	    seek_label = 1 ;
364
	    seek_label_no = atoi ( seek_extern_id + 1 ) ;
365
	}
366
    }
367
    if ( seek_line ) seek_line_no = atoi ( seek_line_id ) ;
368
#endif
369
 
370
    /* Report version if required */
371
    if ( report_version ) {
372
#ifdef NEXT
373
	char *machine = "NeXT" ;
374
#else
375
#ifdef SUN
376
	char *machine = "Sun/3" ;
377
#else
378
	char *machine = "HP" ;
379
#endif
380
#endif
381
	fprintf(stderr, "DRA TDF translator (TDF version %d.%d)\n",
382
		MAJOR_VERSION, MINOR_VERSION);
383
	fprintf(stderr, "reader %d.%d: ", reader_version,
384
		reader_revision);
385
	fprintf(stderr, "construct %d.%d: ", construct_version,
386
		construct_revision);
387
	fprintf(stderr, "target %d.%d.%d: \n", target_version,
388
		target_revision,target_patchlevel);
389
	fprintf(stderr, "system %s",machine);
390
#ifdef __DATE__
391
	fprintf(stderr," : installer compilation %s\n", __DATE__);
392
#endif
393
	fprintf(stderr,"release: %s\n",RELEASE);
394
	fprintf ( stderr, ".\n" ) ;
395
#ifdef EBUG
396
	fprintf ( stderr, "Last revised %s.\n", revdate ) ;
397
#endif
398
    }
399
    if ( report_tdf_versions ) report_versions = 1 ;
400
 
401
    /* Check on diagnostics */
402
    if ( !have_diagnostics && diagnose ) {
403
	error ( "Diagnostics not supported" ) ;
404
	diagnose = 0 ;
405
    }
406
 
407
#if have_diagnostics
408
    diag_override = DIAG_UNKNOWN ;
409
    if ( diag_stab_override ) diag_override = DIAG_STAB ;
410
    if ( diag_xdb_new_override ) diag_override = DIAG_XDB_NEW ;
411
    if ( diag_xdb_old_override ) diag_override = DIAG_XDB_OLD ;
412
#endif
413
 
414
    /* Switch off optimizations if required */
415
    if ( diagnose || !optimize ) {
416
	do_inlining = 0 ;
417
	do_loopconsts = 0 ;
418
	do_foralls = 0 ;
419
	do_peephole = 0 ;
420
	do_unroll = 0 ;
421
    }
422
 
423
    /* Show options if necessary */
424
    if ( show_options ) {
425
	int i, n = array_size ( options ) ;
426
	for ( i = 0 ; i < n ; i++ ) {
427
	    bool b = *( options [i].flag ) ;
428
	    char **pv = options [i].value ;
429
	    printf ( "%s = %s", options [i].opt, ( b ? "True" : "False" ) ) ;
430
	    if ( pv && b ) printf ( " (%s)", *pv ) ;
431
	    printf ( "\n" ) ;
432
	}
433
    }
434
 
435
    /* Check on separate units */
436
    if ( do_sep_units ) {
437
	separate_units = 1 ;
438
#if 0
439
	current_alloc_size = first_alloc_size ;
440
#endif
441
    }
442
 
443
    do_pic = 0 ; /* TODO */
444
 
445
    /* Other options */
446
    if ( do_pic ) PIC_code = 1 ;
447
    if ( !extra_checks ) target_dbl_maxexp = 16384 ;
448
    if ( do_quit ) exit ( EXIT_SUCCESS ) ;
449
 
450
    /* Open input file */
451
    if ( input == null ) {
452
	error ( "Not enough arguments" ) ;
453
	exit ( EXIT_FAILURE ) ;
454
    }
455
    if ( !initreader ( input ) ) {
456
	exit ( EXIT_FAILURE ) ;
457
    }
458
    /*open_input ( input ) ;*/
459
 
460
    /* Set up alignment rules */
461
    double_align = DBL_ALIGN ;
462
    param_align = PARAM_ALIGN ;
463
    stack_align = STACK_ALIGN ;
464
 
465
    MAX_BF_SIZE = ( cc_conventions ? MAX_BF_SIZE_CC : MAX_BF_SIZE_GCC ) ;
466
 
467
    /* Call initialization routines */
468
    top_def = null ;
469
    init_flpt () ;
470
    init_instructions () ;
471
#include "inits.h"
472
    init_weights () ;
473
    init_wheres () ;
474
 
475
    /* Decode, optimize and process the input TDF */
476
    open_output ( output ) ;
477
    asm_comment ;
478
    outs ( " TDF to 680x0, " ) ;
479
    outs ( version_str ) ;
480
    outs ( ", " ) ;
481
    outs ( revision ) ;
482
    outnl () ;
483
    init_output () ;
484
    area ( ptext ) ;
485
#if have_diagnostics
486
    if ( diagnose ) diag_prologue () ;
487
#endif
488
    d_capsule () ;
489
#if have_diagnostics
490
    if ( diagnose ) diag_epilogue () ;
491
#endif
492
#ifdef asm_version
493
    if ( normal_version ) {
494
	asm_version ;
495
    } else {
496
	asm_version_aux ;
497
    }
498
    outnl () ;
499
#endif
500
    if ( errors && !ignore_errors ) exit ( EXIT_FAILURE ) ;
501
    return ( 0 ) ;
502
}