Initial import from FreeBSD RELENG_4:
[games.git] / contrib / gcc / f / com.h
1 /* com.h -- Public #include File (module.h template V1.0)
2    Copyright (C) 1995-1997 Free Software Foundation, Inc.
3    Contributed by James Craig Burley.
4
5 This file is part of GNU Fortran.
6
7 GNU Fortran is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GNU Fortran is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU Fortran; see the file COPYING.  If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA.
21
22    Owning Modules:
23       com.c
24
25    Modifications:
26 */
27
28 /* Allow multiple inclusion to work. */
29
30 #ifndef _H_f_com
31 #define _H_f_com
32
33 /* Simple definitions and enumerations. */
34
35 #define FFECOM_dimensionsMAX 7  /* Max # dimensions (quick hack). */
36
37 #define FFECOM_targetFFE 1
38 #define FFECOM_targetGCC 2
39
40 #ifndef FFE_STANDALONE
41 #define FFECOM_targetCURRENT FFECOM_targetGCC   /* Backend! */
42 #define FFECOM_ONEPASS 0
43 #else
44 #define FFECOM_targetCURRENT FFECOM_targetFFE
45 #define FFECOM_ONEPASS 0
46 #endif
47
48 #if FFECOM_ONEPASS
49 #define FFECOM_TWOPASS 0
50 #else
51 #define FFECOM_TWOPASS 1
52 #endif
53
54 #define FFECOM_SIZE_UNIT "byte" /* Singular form. */
55 #define FFECOM_SIZE_UNITS "bytes"       /* Plural form. */
56
57 #if FFECOM_targetCURRENT == FFECOM_targetGCC
58 #define FFECOM_constantNULL NULL_TREE
59 #define FFECOM_nonterNULL NULL_TREE
60 #define FFECOM_globalNULL NULL_TREE
61 #define FFECOM_labelNULL NULL_TREE
62 #define FFECOM_storageNULL NULL_TREE
63 #define FFECOM_symbolNULL ffecom_symbol_null_
64
65 /* Shorthand for types used in f2c.h and that g77 perhaps allows some
66    flexibility regarding in the section below.  I.e. the actual numbers
67    below aren't important, as long as they're unique.  */
68
69 #define FFECOM_f2ccodeCHAR 1
70 #define FFECOM_f2ccodeSHORT 2
71 #define FFECOM_f2ccodeINT 3
72 #define FFECOM_f2ccodeLONG 4
73 #define FFECOM_f2ccodeLONGLONG 5
74 #define FFECOM_f2ccodeCHARPTR 6         /* char * */
75 #define FFECOM_f2ccodeFLOAT 7
76 #define FFECOM_f2ccodeDOUBLE 8
77 #define FFECOM_f2ccodeLONGDOUBLE 9
78 #define FFECOM_f2ccodeTWOREALS 10
79 #define FFECOM_f2ccodeTWODOUBLEREALS 11
80
81 #if FFECOM_DETERMINE_TYPES      /* only for com.c and configure */
82
83 /* Begin f2c.h information.  This must match the info in the f2c.h used
84    to build the libf2c with which g77-generated code is linked, or there
85    will probably be bugs, some of them difficult to detect or even trigger.  */
86
87 /* Do we need int (for 32-bit or 64-bit systems) or long (16-bit or
88    normally 32-bit) for f2c-type integers? */
89
90 #ifndef BITS_PER_WORD
91 #define BITS_PER_WORD 32
92 #endif
93
94 #ifndef CHAR_TYPE_SIZE
95 #define CHAR_TYPE_SIZE BITS_PER_UNIT
96 #endif
97
98 #ifndef SHORT_TYPE_SIZE
99 #define SHORT_TYPE_SIZE (BITS_PER_UNIT * MIN ((UNITS_PER_WORD + 1) / 2, 2))
100 #endif
101
102 #ifndef INT_TYPE_SIZE
103 #define INT_TYPE_SIZE BITS_PER_WORD
104 #endif
105
106 #ifndef LONG_TYPE_SIZE
107 #define LONG_TYPE_SIZE BITS_PER_WORD
108 #endif
109
110 #ifndef LONG_LONG_TYPE_SIZE
111 #define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2)
112 #endif
113
114 #ifndef WCHAR_UNSIGNED
115 #define WCHAR_UNSIGNED 0
116 #endif
117
118 #ifndef FLOAT_TYPE_SIZE
119 #define FLOAT_TYPE_SIZE BITS_PER_WORD
120 #endif
121
122 #ifndef DOUBLE_TYPE_SIZE
123 #define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
124 #endif
125
126 #ifndef LONG_DOUBLE_TYPE_SIZE
127 #define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
128 #endif
129
130 #if LONG_TYPE_SIZE == FLOAT_TYPE_SIZE
131 #  define FFECOM_f2cINTEGER FFECOM_f2ccodeLONG
132 #  define FFECOM_f2cLOGICAL FFECOM_f2ccodeLONG
133 #elif INT_TYPE_SIZE == FLOAT_TYPE_SIZE
134 #  define FFECOM_f2cINTEGER FFECOM_f2ccodeINT
135 #  define FFECOM_f2cLOGICAL FFECOM_f2ccodeINT
136 #else
137 #  error Cannot find a suitable type for FFECOM_f2cINTEGER
138 #endif
139
140 #if LONG_TYPE_SIZE == (FLOAT_TYPE_SIZE * 2)
141 #  define FFECOM_f2cLONGINT FFECOM_f2ccodeLONG
142 #elif LONG_LONG_TYPE_SIZE == (FLOAT_TYPE_SIZE * 2)
143 #  define FFECOM_f2cLONGINT FFECOM_f2ccodeLONGLONG
144 #else
145 #  error Cannot find a suitable type for FFECOM_f2cLONGINT
146 #endif
147
148 #define FFECOM_f2cADDRESS FFECOM_f2ccodeCHARPTR
149 #define FFECOM_f2cSHORTINT FFECOM_f2ccodeSHORT
150 #define FFECOM_f2cREAL FFECOM_f2ccodeFLOAT
151 #define FFECOM_f2cDOUBLEREAL FFECOM_f2ccodeDOUBLE
152 #define FFECOM_f2cCOMPLEX FFECOM_f2ccodeTWOREALS
153 #define FFECOM_f2cDOUBLECOMPLEX FFECOM_f2ccodeTWODOUBLEREALS
154 #define FFECOM_f2cSHORTLOGICAL FFECOM_f2ccodeSHORT
155 #define FFECOM_f2cLOGICAL1 FFECOM_f2ccodeCHAR
156 #define FFECOM_f2cINTEGER1 FFECOM_f2ccodeCHAR
157
158 /* These must be f2c's INTEGER type, to match runtime/f2c.h.in.  */
159
160 #define FFECOM_f2cFLAG FFECOM_f2cINTEGER
161 #define FFECOM_f2cFTNINT FFECOM_f2cINTEGER
162 #define FFECOM_f2cFTNLEN FFECOM_f2cINTEGER
163
164 #endif  /* #if FFECOM_DETERMINE_TYPES */
165
166 /* Everything else in f2c.h, specifically the structures used in
167    interfacing compiled code with the library, must remain exactly
168    as delivered, or g77 internals (mostly com.c and ste.c) must
169    be modified accordingly to compensate.  Or there will be...trouble.  */
170
171 typedef enum
172   {
173 #define DEFGFRT(CODE,NAME,TYPE,ARGS,VOLATILE,COMPLEX) CODE,
174 #include "com-rt.def"
175 #undef DEFGFRT
176     FFECOM_gfrt
177   } ffecomGfrt;
178
179 #endif  /* FFECOM_targetCURRENT == FFECOM_targetGCC */
180
181 /* Typedefs. */
182
183 #if FFECOM_targetCURRENT == FFECOM_targetGCC
184 #ifndef TREE_CODE
185 #include "tree.j"
186 #endif
187
188 #ifndef BUILT_FOR_270
189 #ifdef DECL_STATIC_CONSTRUCTOR  /* In gcc/tree.h. */
190 #define BUILT_FOR_270 1
191 #else
192 #define BUILT_FOR_270 0
193 #endif
194 #endif  /* !defined (BUILT_FOR_270) */
195
196 #ifndef BUILT_FOR_280
197 #ifdef DECL_ONE_ONLY    /* In gcc/tree.h. */
198 #define BUILT_FOR_280 1
199 #else
200 #define BUILT_FOR_280 0
201 #endif
202 #endif  /* !defined (BUILT_FOR_280) */
203
204 typedef tree ffecomConstant;
205 #define FFECOM_constantHOOK
206 typedef tree ffecomNonter;
207 #define FFECOM_nonterHOOK
208 typedef tree ffecomLabel;
209 #define FFECOM_globalHOOK
210 typedef tree ffecomGlobal;
211 #define FFECOM_labelHOOK
212 typedef tree ffecomStorage;
213 #define FFECOM_storageHOOK
214 typedef struct _ffecom_symbol_ ffecomSymbol;
215 #define FFECOM_symbolHOOK
216
217 struct _ffecom_symbol_
218   {
219     tree decl_tree;
220     tree length_tree;           /* For CHARACTER dummies. */
221     tree vardesc_tree;          /* For NAMELIST. */
222     tree assign_tree;           /* For ASSIGN'ed vars. */
223     bool addr;                  /* Is address of item instead of item. */
224   };
225 #endif  /* FFECOM_targetCURRENT == FFECOM_targetGCC */
226
227 /* Include files needed by this one. */
228
229 #include "bld.h"
230 #include "info.h"
231 #include "lab.h"
232 #include "storag.h"
233 #include "symbol.h"
234
235 /* Structure definitions. */
236
237
238 /* Global objects accessed by users of this module. */
239
240 #if FFECOM_targetCURRENT == FFECOM_targetGCC
241 extern tree long_integer_type_node;
242 extern tree complex_double_type_node;
243 extern tree string_type_node;
244 extern tree ffecom_integer_type_node;
245 extern tree ffecom_integer_zero_node;
246 extern tree ffecom_integer_one_node;
247 extern tree ffecom_tree_type[FFEINFO_basictype][FFEINFO_kindtype];
248 extern ffecomSymbol ffecom_symbol_null_;
249 extern ffeinfoKindtype ffecom_pointer_kind_;
250 extern ffeinfoKindtype ffecom_label_kind_;
251
252 extern int ffecom_f2c_typecode_[FFEINFO_basictype][FFEINFO_kindtype];
253 extern tree ffecom_f2c_integer_type_node;
254 extern tree ffecom_f2c_address_type_node;
255 extern tree ffecom_f2c_real_type_node;
256 extern tree ffecom_f2c_doublereal_type_node;
257 extern tree ffecom_f2c_complex_type_node;
258 extern tree ffecom_f2c_doublecomplex_type_node;
259 extern tree ffecom_f2c_longint_type_node;
260 extern tree ffecom_f2c_logical_type_node;
261 extern tree ffecom_f2c_flag_type_node;
262 extern tree ffecom_f2c_ftnlen_type_node;
263 extern tree ffecom_f2c_ftnlen_zero_node;
264 extern tree ffecom_f2c_ftnlen_one_node;
265 extern tree ffecom_f2c_ftnlen_two_node;
266 extern tree ffecom_f2c_ptr_to_ftnlen_type_node;
267 extern tree ffecom_f2c_ftnint_type_node;
268 extern tree ffecom_f2c_ptr_to_ftnint_type_node;
269 #endif  /* FFECOM_targetCURRENT == FFECOM_targetGCC */
270
271 /* Declare functions with prototypes. */
272
273 #if FFECOM_targetCURRENT == FFECOM_targetGCC
274 tree ffecom_1 (enum tree_code code, tree type, tree node);
275 tree ffecom_1_fn (tree node);
276 tree ffecom_2 (enum tree_code code, tree type, tree node1, tree node2);
277 bool ffecom_2pass_advise_entrypoint (ffesymbol entry);
278 void ffecom_2pass_do_entrypoint (ffesymbol entry);
279 tree ffecom_2s (enum tree_code code, tree type, tree node1, tree node2);
280 tree ffecom_3 (enum tree_code code, tree type, tree node1, tree node2,
281                tree node3);
282 tree ffecom_3s (enum tree_code code, tree type, tree node1, tree node2,
283                 tree node3);
284 tree ffecom_arg_expr (ffebld expr, tree *length);
285 tree ffecom_arg_ptr_to_const_expr (ffebld expr, tree *length);
286 tree ffecom_arg_ptr_to_expr (ffebld expr, tree *length);
287 tree ffecom_call_gfrt (ffecomGfrt ix, tree args, tree hook);
288 tree ffecom_constantunion (ffebldConstantUnion *cu, ffeinfoBasictype bt,
289                            ffeinfoKindtype kt, tree tree_type);
290 tree ffecom_const_expr (ffebld expr);
291 tree ffecom_decl_field (tree context, tree prevfield, const char *name,
292                         tree type);
293 #endif  /* FFECOM_targetCURRENT == FFECOM_targetGCC */
294 void ffecom_close_include (FILE *f);
295 int ffecom_decode_include_option (char *spec);
296 #if FFECOM_targetCURRENT == FFECOM_targetGCC
297 tree ffecom_end_compstmt (void);
298 #endif  /* FFECOM_targetCURRENT == FFECOM_targetGCC */
299 void ffecom_end_transition (void);
300 void ffecom_exec_transition (void);
301 void ffecom_expand_let_stmt (ffebld dest, ffebld source);
302 #if FFECOM_targetCURRENT == FFECOM_targetGCC
303 tree ffecom_expr (ffebld expr);
304 tree ffecom_expr_assign (ffebld expr);
305 tree ffecom_expr_assign_w (ffebld expr);
306 tree ffecom_expr_rw (tree type, ffebld expr);
307 tree ffecom_expr_w (tree type, ffebld expr);
308 void ffecom_finish_compile (void);
309 void ffecom_finish_decl (tree decl, tree init, bool is_top_level);
310 void ffecom_finish_progunit (void);
311 tree ffecom_get_invented_identifier (const char *pattern, const char *text,
312                                      int number);
313 ffeinfoKindtype ffecom_gfrt_basictype (ffecomGfrt ix);
314 ffeinfoKindtype ffecom_gfrt_kindtype (ffecomGfrt ix);
315 void ffecom_init_0 (void);
316 void ffecom_init_2 (void);
317 tree ffecom_list_expr (ffebld list);
318 tree ffecom_list_ptr_to_expr (ffebld list);
319 tree ffecom_lookup_label (ffelab label);
320 tree ffecom_make_tempvar (const char *commentary, tree type,
321                           ffetargetCharacterSize size, int elements);
322 tree ffecom_modify (tree newtype, tree lhs, tree rhs);
323 #endif  /* FFECOM_targetCURRENT == FFECOM_targetGCC */
324 void ffecom_file (char *name);
325 void ffecom_notify_init_storage (ffestorag st);
326 void ffecom_notify_init_symbol (ffesymbol s);
327 void ffecom_notify_primary_entry (ffesymbol fn);
328 FILE *ffecom_open_include (char *name, ffewhereLine l, ffewhereColumn c);
329 #if FFECOM_targetCURRENT == FFECOM_targetGCC
330 void ffecom_prepare_arg_ptr_to_expr (ffebld expr);
331 bool ffecom_prepare_end (void);
332 void ffecom_prepare_expr_ (ffebld expr, ffebld dest);
333 void ffecom_prepare_expr_rw (tree type, ffebld expr);
334 void ffecom_prepare_expr_w (tree type, ffebld expr);
335 void ffecom_prepare_ptr_to_expr (ffebld expr);
336 void ffecom_prepare_return_expr (ffebld expr);
337 tree ffecom_ptr_to_const_expr (ffebld expr);
338 tree ffecom_ptr_to_expr (ffebld expr);
339 tree ffecom_return_expr (ffebld expr);
340 tree ffecom_save_tree (tree t);
341 void ffecom_start_compstmt (void);
342 tree ffecom_start_decl (tree decl, bool is_init);
343 void ffecom_sym_commit (ffesymbol s);
344 #endif  /* FFECOM_targetCURRENT == FFECOM_targetGCC */
345 ffesymbol ffecom_sym_end_transition (ffesymbol s);
346 ffesymbol ffecom_sym_exec_transition (ffesymbol s);
347 ffesymbol ffecom_sym_learned (ffesymbol s);
348 #if FFECOM_targetCURRENT == FFECOM_targetGCC
349 void ffecom_sym_retract (ffesymbol s);
350 tree ffecom_temp_label (void);
351 tree ffecom_truth_value (tree expr);
352 tree ffecom_truth_value_invert (tree expr);
353 tree ffecom_type_expr (ffebld expr);
354 tree ffecom_which_entrypoint_decl (void);
355
356 /* These need to be in the front end with exactly these interfaces,
357    as they're called by the back end.  */
358
359 int mark_addressable (tree expr);
360 #endif  /* FFECOM_targetCURRENT == FFECOM_targetGCC */
361
362 /* Define macros. */
363
364 #if FFECOM_targetCURRENT == FFECOM_targetFFE
365 #define ffecom_expr(e) (e)
366 #define ffecom_init_0()
367 #define ffecom_init_2()
368 #define ffecom_label_kind() FFEINFO_kindtypeINTEGERDEFAULT
369 #define ffecom_pointer_kind() FFEINFO_kindtypeINTEGERDEFAULT
370 #define ffecom_ptr_to_expr(e) (e)
371 #define ffecom_sym_commit(s)
372 #define ffecom_sym_retract(s)
373 #endif  /* FFECOM_targetCURRENT == FFECOM_targetFFE */
374
375 #if FFECOM_targetCURRENT == FFECOM_targetGCC
376 #define ffecom_f2c_typecode(bt,kt) ffecom_f2c_typecode_[(bt)][(kt)]
377 #define ffecom_label_kind() ffecom_label_kind_
378 #define ffecom_pointer_kind() ffecom_pointer_kind_
379 #define ffecom_prepare_expr(e) ffecom_prepare_expr_ ((e), NULL)
380 #endif  /* FFECOM_targetCURRENT == FFECOM_targetGCC */
381
382 #define ffecom_init_1()
383 #define ffecom_init_3()
384 #define ffecom_init_4()
385 #define ffecom_terminate_0()
386 #define ffecom_terminate_1()
387 #define ffecom_terminate_2()
388 #define ffecom_terminate_3()
389 #define ffecom_terminate_4()
390
391 /* End of #include file. */
392
393 #endif