2 |
7u83 |
1 |
/*
|
|
|
2 |
Copyright (c) 1993 Open Software Foundation, Inc.
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
All Rights Reserved
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
Permission to use, copy, modify, and distribute this software
|
|
|
9 |
and its documentation for any purpose and without fee is hereby
|
|
|
10 |
granted, provided that the above copyright notice appears in all
|
|
|
11 |
copies and that both the copyright notice and this permission
|
|
|
12 |
notice appear in supporting documentation.
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING
|
|
|
16 |
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
|
|
17 |
PARTICULAR PURPOSE.
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
|
|
|
21 |
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
|
22 |
LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
|
|
|
23 |
NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
|
|
24 |
WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
25 |
*/
|
|
|
26 |
|
|
|
27 |
/*
|
|
|
28 |
Crown Copyright (c) 1997
|
|
|
29 |
|
|
|
30 |
This TenDRA(r) Computer Program is subject to Copyright
|
|
|
31 |
owned by the United Kingdom Secretary of State for Defence
|
|
|
32 |
acting through the Defence Evaluation and Research Agency
|
|
|
33 |
(DERA). It is made available to Recipients with a
|
|
|
34 |
royalty-free licence for its use, reproduction, transfer
|
|
|
35 |
to other parties and amendment for any purpose not excluding
|
|
|
36 |
product development provided that any such use et cetera
|
|
|
37 |
shall be deemed to be acceptance of the following conditions:-
|
|
|
38 |
|
|
|
39 |
(1) Its Recipients shall ensure that this Notice is
|
|
|
40 |
reproduced upon any copies or amended versions of it;
|
|
|
41 |
|
|
|
42 |
(2) Any amended version of it shall be clearly marked to
|
|
|
43 |
show both the nature of and the organisation responsible
|
|
|
44 |
for the relevant amendment or amendments;
|
|
|
45 |
|
|
|
46 |
(3) Its onward transfer from a recipient to another
|
|
|
47 |
party shall be deemed to be that party's acceptance of
|
|
|
48 |
these conditions;
|
|
|
49 |
|
|
|
50 |
(4) DERA gives no warranty or assurance as to its
|
|
|
51 |
quality or suitability for any purpose and DERA accepts
|
|
|
52 |
no liability whatsoever in relation to any use to which
|
|
|
53 |
it may be put.
|
|
|
54 |
*/
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
/**********************************************************************
|
|
|
59 |
$Author: release $
|
|
|
60 |
$Date: 1998/03/27 09:47:57 $
|
|
|
61 |
$Revision: 1.3 $
|
|
|
62 |
$Log: powertrans.c,v $
|
|
|
63 |
* Revision 1.3 1998/03/27 09:47:57 release
|
|
|
64 |
* Changes for 4.1.2 release.
|
|
|
65 |
*
|
|
|
66 |
* Revision 1.2 1998/02/04 15:48:35 release
|
|
|
67 |
* Added OSF copyright message.
|
|
|
68 |
*
|
|
|
69 |
* Revision 1.1.1.1 1998/01/17 15:55:58 release
|
|
|
70 |
* First version to be checked into rolling release.
|
|
|
71 |
*
|
|
|
72 |
* Revision 1.2 1996/10/04 16:03:26 pwe
|
|
|
73 |
* add banners and mod for PWE ownership
|
|
|
74 |
*
|
|
|
75 |
**********************************************************************/
|
|
|
76 |
|
|
|
77 |
|
|
|
78 |
#include "config.h"
|
|
|
79 |
#include "release.h"
|
|
|
80 |
#include "flags.h" /* for option flags */
|
|
|
81 |
#include "tempdecs.h" /* for tempdecopt */
|
|
|
82 |
#include "comment.h" /* for do_comment */
|
|
|
83 |
#include "translat.h" /* for optim_level, translate() */
|
|
|
84 |
#include "installglob.h"
|
|
|
85 |
#include "reader_v.h" /* for reader_revison */
|
|
|
86 |
#include "construct_v.h" /* for construct_revision */
|
|
|
87 |
#include "target_v.h" /* for comiple_date */
|
|
|
88 |
#include "macro.h"
|
|
|
89 |
|
|
|
90 |
int architecture=COMMON_CODE;
|
|
|
91 |
bool do_tlrecursion; /* expected by needscan.c */
|
|
|
92 |
|
|
|
93 |
int main PROTO_N ((argc,argv)) PROTO_T (int argc X char **argv)
|
|
|
94 |
{
|
|
|
95 |
bool errflg = 0;
|
|
|
96 |
int a=1;
|
|
|
97 |
char *infname=(char*)0;
|
|
|
98 |
char *outfname=(char*)0;
|
|
|
99 |
char *arg;
|
|
|
100 |
char *powertrans;
|
|
|
101 |
|
|
|
102 |
/*
|
|
|
103 |
* Initialise executable name
|
|
|
104 |
*/
|
|
|
105 |
powertrans = argv [0] ;
|
|
|
106 |
for ( arg = powertrans ; *arg ; arg++ )
|
|
|
107 |
{
|
|
|
108 |
if ( *arg == '/' )
|
|
|
109 |
{
|
|
|
110 |
powertrans = arg + 1 ;
|
|
|
111 |
}
|
|
|
112 |
}
|
|
|
113 |
|
|
|
114 |
/* errors messages are output on stdout, ensure they get out */
|
|
|
115 |
setbuf(stdout, NULL);
|
|
|
116 |
|
|
|
117 |
/*
|
|
|
118 |
* Set defaults for options (see construct/flags.c)
|
|
|
119 |
*/
|
|
|
120 |
do_macros = 0; /* If you have compiled
|
|
|
121 |
with -DDO_ASSEMBLER_MACROS this makes the
|
|
|
122 |
output easier to read*/
|
|
|
123 |
|
|
|
124 |
do_alloca = 1; /* Use builtin alloca */
|
|
|
125 |
do_inlining = 1; /* Do inlining of functions */
|
|
|
126 |
do_special_fns = 1; /* Builtin procs used */
|
|
|
127 |
do_loopconsts = 1; /* Take constant expression out of loops */
|
|
|
128 |
do_foralls = 1; /* Replace indexing on loop variable by
|
|
|
129 |
* incremented pointer access.
|
|
|
130 |
*/
|
|
|
131 |
redo_structfns = 1; /* procs delivering structs
|
|
|
132 |
* recast to extra param
|
|
|
133 |
* for call struct/union return convention
|
|
|
134 |
*/
|
|
|
135 |
diagnose = 0; /* Produce diagnosics */
|
|
|
136 |
do_profile = 0; /* Produce profiling info */
|
|
|
137 |
extra_checks = 1; /* Do extra portability checks */
|
|
|
138 |
separate_units = 0; /* Translate units separately */
|
|
|
139 |
all_variables_visible = 0; /* Set vis flag for all declarations */
|
|
|
140 |
do_unroll=1; /* Do unrolling of loops */
|
|
|
141 |
flpt_const_overflow_fail = 1; /* Constant floating point arithmetic
|
|
|
142 |
* fails installation, if overflow
|
|
|
143 |
*/
|
|
|
144 |
strict_fl_div = 1; /* Don't mult by 1/constant */
|
|
|
145 |
round_after_flop = 1; /* Round every time */
|
|
|
146 |
|
|
|
147 |
do_tlrecursion = 0; /* Do proc tail recursion optimisation
|
|
|
148 |
* (see needscan.c)
|
|
|
149 |
*/
|
|
|
150 |
tempdecopt = 1; /* (see tempdecs.c) */
|
|
|
151 |
do_comment = 0; /* (see comment.c) */
|
|
|
152 |
optim_level = 2; /* Optimize level */
|
|
|
153 |
|
|
|
154 |
/*
|
|
|
155 |
* Process program args
|
|
|
156 |
*
|
|
|
157 |
* Only advertise options in manual page, other debugging
|
|
|
158 |
* options available as well
|
|
|
159 |
*/
|
|
|
160 |
#define GET_0_1 ((arg[2] == '1') ? 1 : 0)
|
|
|
161 |
while (a<argc&&(arg=argv[a], arg[0]=='-'))
|
|
|
162 |
{
|
|
|
163 |
switch ( arg [1] )
|
|
|
164 |
{
|
|
|
165 |
case 'A' : do_alloca = GET_0_1 ; break ;
|
|
|
166 |
case 'B' : flpt_const_overflow_fail = GET_0_1; break;
|
|
|
167 |
case 'C' : do_loopconsts = GET_0_1; break ;
|
|
|
168 |
case 'E' : extra_checks = 0 ; break ;
|
|
|
169 |
case 'F' : do_foralls = GET_0_1 ; break ;
|
|
|
170 |
case 'H' : diagnose = 1 ; break ;
|
|
|
171 |
case 'I' : do_inlining = GET_0_1 ; break ;
|
|
|
172 |
case 'K' :
|
|
|
173 |
if (arg[2]=='R')
|
|
|
174 |
{
|
|
|
175 |
architecture = RS6000_CODE;
|
|
|
176 |
}
|
|
|
177 |
else if (arg[2]=='P')
|
|
|
178 |
{
|
|
|
179 |
architecture = POWERPC_CODE;
|
|
|
180 |
}
|
|
|
181 |
else
|
|
|
182 |
{
|
|
|
183 |
fprintf(stderr,"Unknown architecture: -K should be followed by R for rs6000 or P for powerpc\n");
|
|
|
184 |
}
|
|
|
185 |
break;
|
|
|
186 |
case 'M' : strict_fl_div = GET_0_1 ; break ;
|
|
|
187 |
case 'O' : {
|
|
|
188 |
/* optimisation level */
|
|
|
189 |
optim_level = atoi ( arg + 2 ) ;
|
|
|
190 |
if ( optim_level < 0 ) optim_level = 0 ;
|
|
|
191 |
if ( optim_level > 4 ) optim_level = 4 ;
|
|
|
192 |
break ;
|
|
|
193 |
}
|
|
|
194 |
|
|
|
195 |
case 'P' : do_profile = 1 ; break ;
|
|
|
196 |
case 'Q' : exit(EXIT_SUCCESS); break;
|
|
|
197 |
case 'R' : round_after_flop = GET_0_1; break;
|
|
|
198 |
case 'U' : do_unroll = GET_0_1; break;
|
|
|
199 |
|
|
|
200 |
case 'V':
|
|
|
201 |
fprintf(stderr, "DERA TDF translator (TDF version %d.%d)\n",
|
|
|
202 |
MAJOR_VERSION, MINOR_VERSION);
|
|
|
203 |
fprintf(stderr, "reader %d.%d: \n", reader_version,
|
|
|
204 |
reader_revision);
|
|
|
205 |
fprintf(stderr, "construct %d.%d: \n", construct_version,
|
|
|
206 |
construct_revision);
|
|
|
207 |
fprintf(stderr, "translator %d.%d: \n", target_version, target_revision);
|
|
|
208 |
fprintf(stderr, "system %s: \n", target_system);
|
|
|
209 |
#ifdef __DATE__
|
|
|
210 |
IGNORE fprintf(stderr, "installer compilation : %s\n", __DATE__);
|
|
|
211 |
#endif
|
|
|
212 |
#ifdef RELEASE
|
|
|
213 |
IGNORE fprintf(stderr, "release: %s\n",RELEASE);
|
|
|
214 |
#endif
|
|
|
215 |
break;
|
|
|
216 |
|
|
|
217 |
case 'W' : break;
|
|
|
218 |
case 'X' : {
|
|
|
219 |
/* disable all optimisations */
|
|
|
220 |
optim_level = 0 ;
|
|
|
221 |
tempdecopt = 0 ;
|
|
|
222 |
do_inlining = 0 ;
|
|
|
223 |
do_loopconsts = 0 ;
|
|
|
224 |
do_foralls = 0 ;
|
|
|
225 |
do_tlrecursion = 0 ;
|
|
|
226 |
do_unroll = 0;
|
|
|
227 |
break ;
|
|
|
228 |
}
|
|
|
229 |
case 'Z' : report_versions = 1 ; break ;
|
|
|
230 |
|
|
|
231 |
/* undocumented power specific flags below here */
|
|
|
232 |
case 'c' : do_comment = 1 ; break ;
|
|
|
233 |
|
|
|
234 |
default : {
|
|
|
235 |
fprintf ( stderr, "%s : unknown option, %s\n",
|
|
|
236 |
powertrans, arg ) ;
|
|
|
237 |
break ;
|
|
|
238 |
}
|
|
|
239 |
}
|
|
|
240 |
a++ ;
|
|
|
241 |
}
|
|
|
242 |
|
|
|
243 |
/* we expect two further filename arguments */
|
|
|
244 |
if ( argc == a + 2 ) {
|
|
|
245 |
infname = argv [a] ;
|
|
|
246 |
outfname = argv [ a + 1 ] ;
|
|
|
247 |
} else if ( argc == a + 1 ) {
|
|
|
248 |
infname = argv [a] ;
|
|
|
249 |
outfname = "-" ;
|
|
|
250 |
} else {
|
|
|
251 |
errflg = 1 ;
|
|
|
252 |
}
|
|
|
253 |
|
|
|
254 |
/* quit if arguments were wrong */
|
|
|
255 |
if ( errflg ) {
|
|
|
256 |
exit ( EXIT_FAILURE ) ;
|
|
|
257 |
}
|
|
|
258 |
|
|
|
259 |
/* switch off certain optimisations in diagnostics mode */
|
|
|
260 |
if ( diagnose ) {
|
|
|
261 |
optim_level = 0 ;
|
|
|
262 |
tempdecopt = 0 ;
|
|
|
263 |
do_inlining = 0 ;
|
|
|
264 |
do_loopconsts = 0 ;
|
|
|
265 |
do_foralls = 0 ;
|
|
|
266 |
do_unroll=0;
|
|
|
267 |
do_tlrecursion = 0;
|
|
|
268 |
do_special_fns = 0; /* no builtins */
|
|
|
269 |
all_variables_visible = 1; /* set vis flag for all declarations */
|
|
|
270 |
}
|
|
|
271 |
return translate(infname, outfname);
|
|
|
272 |
}
|