OSDN Git Service

* Make-lang.in (F77_SRCS): Remove all .j files.
[pf3gnuchains/gcc-fork.git] / gcc / f / com.h
1 /* com.h -- Public #include File (module.h template V1.0)
2    Copyright (C) 1995, 1996, 1997, 2000 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 /* The C front-end provides __g77_integer and __g77_uinteger types so that
131    the appropriately-sized signed and unsigned integer types are available
132    for libf2c.  If you change this, also the definitions of those types
133    in ../c-decl.c. */
134 #define FFECOM_f2cINTEGER                       \
135   (LONG_TYPE_SIZE == FLOAT_TYPE_SIZE            \
136    ? FFECOM_f2ccodeLONG                         \
137    : (INT_TYPE_SIZE == FLOAT_TYPE_SIZE          \
138       ? FFECOM_f2ccodeINT                       \
139       : (abort (), -1)))
140
141 #define FFECOM_f2cLOGICAL FFECOM_f2cINTEGER
142
143 /* The C front-end provides __g77_longint and __g77_ulongint types so that
144    the appropriately-sized signed and unsigned integer types are available
145    for libf2c.  If you change this, also the definitions of those types
146    in ../c-decl.c. */
147 #define FFECOM_f2cLONGINT                               \
148  (LONG_TYPE_SIZE == (FLOAT_TYPE_SIZE * 2)               \
149   ? FFECOM_f2ccodeLONG                                  \
150   : (LONG_LONG_TYPE_SIZE == (FLOAT_TYPE_SIZE * 2)       \
151      ? FFECOM_f2ccodeLONGLONG                           \
152      : (abort (), -1)))
153
154 #define FFECOM_f2cADDRESS FFECOM_f2ccodeCHARPTR
155 #define FFECOM_f2cSHORTINT FFECOM_f2ccodeSHORT
156 #define FFECOM_f2cREAL FFECOM_f2ccodeFLOAT
157 #define FFECOM_f2cDOUBLEREAL FFECOM_f2ccodeDOUBLE
158 #define FFECOM_f2cCOMPLEX FFECOM_f2ccodeTWOREALS
159 #define FFECOM_f2cDOUBLECOMPLEX FFECOM_f2ccodeTWODOUBLEREALS
160 #define FFECOM_f2cSHORTLOGICAL FFECOM_f2ccodeSHORT
161 #define FFECOM_f2cLOGICAL1 FFECOM_f2ccodeCHAR
162 #define FFECOM_f2cINTEGER1 FFECOM_f2ccodeCHAR
163
164 /* These must be f2c's INTEGER type, to match runtime/f2c.h.in.  */
165
166 #define FFECOM_f2cFLAG FFECOM_f2cINTEGER
167 #define FFECOM_f2cFTNINT FFECOM_f2cINTEGER
168 #define FFECOM_f2cFTNLEN FFECOM_f2cINTEGER
169
170 #endif  /* #if FFECOM_DETERMINE_TYPES */
171
172 /* Everything else in f2c.h, specifically the structures used in
173    interfacing compiled code with the library, must remain exactly
174    as delivered, or g77 internals (mostly com.c and ste.c) must
175    be modified accordingly to compensate.  Or there will be...trouble.  */
176
177 typedef enum
178   {
179 #define DEFGFRT(CODE,NAME,TYPE,ARGS,VOLATILE,COMPLEX) CODE,
180 #include "com-rt.def"
181 #undef DEFGFRT
182     FFECOM_gfrt
183   } ffecomGfrt;
184
185 #endif  /* FFECOM_targetCURRENT == FFECOM_targetGCC */
186
187 /* Typedefs. */
188
189 #if FFECOM_targetCURRENT == FFECOM_targetGCC
190 #ifndef TREE_CODE
191 #include "tree.h"
192 #endif
193
194 #ifndef BUILT_FOR_270
195 #ifdef DECL_STATIC_CONSTRUCTOR  /* In gcc/tree.h. */
196 #define BUILT_FOR_270 1
197 #else
198 #define BUILT_FOR_270 0
199 #endif
200 #endif  /* !defined (BUILT_FOR_270) */
201
202 #ifndef BUILT_FOR_280
203 #ifdef DECL_ONE_ONLY    /* In gcc/tree.h. */
204 #define BUILT_FOR_280 1
205 #else
206 #define BUILT_FOR_280 0
207 #endif
208 #endif  /* !defined (BUILT_FOR_280) */
209
210 typedef tree ffecomConstant;
211 #define FFECOM_constantHOOK
212 typedef tree ffecomNonter;
213 #define FFECOM_nonterHOOK
214 typedef tree ffecomLabel;
215 #define FFECOM_globalHOOK
216 typedef tree ffecomGlobal;
217 #define FFECOM_labelHOOK
218 typedef tree ffecomStorage;
219 #define FFECOM_storageHOOK
220 typedef struct _ffecom_symbol_ ffecomSymbol;
221 #define FFECOM_symbolHOOK
222
223 struct _ffecom_symbol_
224   {
225     tree decl_tree;
226     tree length_tree;           /* For CHARACTER dummies. */
227     tree vardesc_tree;          /* For NAMELIST. */
228     tree assign_tree;           /* For ASSIGN'ed vars. */
229     bool addr;                  /* Is address of item instead of item. */
230   };
231 #endif  /* FFECOM_targetCURRENT == FFECOM_targetGCC */
232
233 /* Include files needed by this one. */
234
235 #include "bld.h"
236 #include "info.h"
237 #include "lab.h"
238 #include "storag.h"
239 #include "symbol.h"
240
241 /* Structure definitions. */
242
243
244 /* Global objects accessed by users of this module. */
245
246 #if FFECOM_targetCURRENT == FFECOM_targetGCC
247 extern tree string_type_node;
248 extern tree ffecom_integer_type_node;
249 extern tree ffecom_integer_zero_node;
250 extern tree ffecom_integer_one_node;
251 extern tree ffecom_tree_type[FFEINFO_basictype][FFEINFO_kindtype];
252 extern ffecomSymbol ffecom_symbol_null_;
253 extern ffeinfoKindtype ffecom_pointer_kind_;
254 extern ffeinfoKindtype ffecom_label_kind_;
255
256 extern int ffecom_f2c_typecode_[FFEINFO_basictype][FFEINFO_kindtype];
257 extern tree ffecom_f2c_integer_type_node;
258 extern tree ffecom_f2c_address_type_node;
259 extern tree ffecom_f2c_real_type_node;
260 extern tree ffecom_f2c_doublereal_type_node;
261 extern tree ffecom_f2c_complex_type_node;
262 extern tree ffecom_f2c_doublecomplex_type_node;
263 extern tree ffecom_f2c_longint_type_node;
264 extern tree ffecom_f2c_logical_type_node;
265 extern tree ffecom_f2c_flag_type_node;
266 extern tree ffecom_f2c_ftnlen_type_node;
267 extern tree ffecom_f2c_ftnlen_zero_node;
268 extern tree ffecom_f2c_ftnlen_one_node;
269 extern tree ffecom_f2c_ftnlen_two_node;
270 extern tree ffecom_f2c_ptr_to_ftnlen_type_node;
271 extern tree ffecom_f2c_ftnint_type_node;
272 extern tree ffecom_f2c_ptr_to_ftnint_type_node;
273 #endif  /* FFECOM_targetCURRENT == FFECOM_targetGCC */
274
275 /* Declare functions with prototypes. */
276
277 #if FFECOM_targetCURRENT == FFECOM_targetGCC
278 tree ffecom_1 (enum tree_code code, tree type, tree node);
279 tree ffecom_1_fn (tree node);
280 tree ffecom_2 (enum tree_code code, tree type, tree node1, tree node2);
281 bool ffecom_2pass_advise_entrypoint (ffesymbol entry);
282 void ffecom_2pass_do_entrypoint (ffesymbol entry);
283 tree ffecom_2s (enum tree_code code, tree type, tree node1, tree node2);
284 tree ffecom_3 (enum tree_code code, tree type, tree node1, tree node2,
285                tree node3);
286 tree ffecom_3s (enum tree_code code, tree type, tree node1, tree node2,
287                 tree node3);
288 tree ffecom_arg_expr (ffebld expr, tree *length);
289 tree ffecom_arg_ptr_to_const_expr (ffebld expr, tree *length);
290 tree ffecom_arg_ptr_to_expr (ffebld expr, tree *length);
291 tree ffecom_call_gfrt (ffecomGfrt ix, tree args, tree hook);
292 tree ffecom_constantunion (ffebldConstantUnion *cu, ffeinfoBasictype bt,
293                            ffeinfoKindtype kt, tree tree_type);
294 tree ffecom_const_expr (ffebld expr);
295 tree ffecom_decl_field (tree context, tree prevfield, const char *name,
296                         tree type);
297 #endif  /* FFECOM_targetCURRENT == FFECOM_targetGCC */
298 void ffecom_close_include (FILE *f);
299 int ffecom_decode_include_option (char *spec);
300 #if FFECOM_targetCURRENT == FFECOM_targetGCC
301 tree ffecom_end_compstmt (void);
302 #endif  /* FFECOM_targetCURRENT == FFECOM_targetGCC */
303 void ffecom_end_transition (void);
304 void ffecom_exec_transition (void);
305 void ffecom_expand_let_stmt (ffebld dest, ffebld source);
306 #if FFECOM_targetCURRENT == FFECOM_targetGCC
307 tree ffecom_expr (ffebld expr);
308 tree ffecom_expr_assign (ffebld expr);
309 tree ffecom_expr_assign_w (ffebld expr);
310 tree ffecom_expr_rw (tree type, ffebld expr);
311 tree ffecom_expr_w (tree type, ffebld expr);
312 void ffecom_finish_compile (void);
313 void ffecom_finish_decl (tree decl, tree init, bool is_top_level);
314 void ffecom_finish_progunit (void);
315 tree ffecom_get_invented_identifier (const char *pattern, ...)
316   ATTRIBUTE_PRINTF_1;
317 ffeinfoKindtype ffecom_gfrt_basictype (ffecomGfrt ix);
318 ffeinfoKindtype ffecom_gfrt_kindtype (ffecomGfrt ix);
319 void ffecom_init_0 (void);
320 void ffecom_init_2 (void);
321 tree ffecom_list_expr (ffebld list);
322 tree ffecom_list_ptr_to_expr (ffebld list);
323 tree ffecom_lookup_label (ffelab label);
324 tree ffecom_make_tempvar (const char *commentary, tree type,
325                           ffetargetCharacterSize size, int elements);
326 tree ffecom_modify (tree newtype, tree lhs, tree rhs);
327 void ffecom_save_tree_forever (tree t);
328 #endif  /* FFECOM_targetCURRENT == FFECOM_targetGCC */
329 void ffecom_file (const char *name);
330 void ffecom_notify_init_storage (ffestorag st);
331 void ffecom_notify_init_symbol (ffesymbol s);
332 void ffecom_notify_primary_entry (ffesymbol fn);
333 FILE *ffecom_open_include (char *name, ffewhereLine l, ffewhereColumn c);
334 #if FFECOM_targetCURRENT == FFECOM_targetGCC
335 void ffecom_prepare_arg_ptr_to_expr (ffebld expr);
336 bool ffecom_prepare_end (void);
337 void ffecom_prepare_expr_ (ffebld expr, ffebld dest);
338 void ffecom_prepare_expr_rw (tree type, ffebld expr);
339 void ffecom_prepare_expr_w (tree type, ffebld expr);
340 void ffecom_prepare_ptr_to_expr (ffebld expr);
341 void ffecom_prepare_return_expr (ffebld expr);
342 tree ffecom_ptr_to_const_expr (ffebld expr);
343 tree ffecom_ptr_to_expr (ffebld expr);
344 tree ffecom_return_expr (ffebld expr);
345 tree ffecom_save_tree (tree t);
346 void ffecom_start_compstmt (void);
347 tree ffecom_start_decl (tree decl, bool is_init);
348 void ffecom_sym_commit (ffesymbol s);
349 #endif  /* FFECOM_targetCURRENT == FFECOM_targetGCC */
350 ffesymbol ffecom_sym_end_transition (ffesymbol s);
351 ffesymbol ffecom_sym_exec_transition (ffesymbol s);
352 ffesymbol ffecom_sym_learned (ffesymbol s);
353 #if FFECOM_targetCURRENT == FFECOM_targetGCC
354 void ffecom_sym_retract (ffesymbol s);
355 tree ffecom_temp_label (void);
356 tree ffecom_truth_value (tree expr);
357 tree ffecom_truth_value_invert (tree expr);
358 tree ffecom_type_expr (ffebld expr);
359 tree ffecom_which_entrypoint_decl (void);
360
361 /* These need to be in the front end with exactly these interfaces,
362    as they're called by the back end.  */
363
364 int mark_addressable (tree expr);
365 #endif  /* FFECOM_targetCURRENT == FFECOM_targetGCC */
366
367 /* Define macros. */
368
369 #if FFECOM_targetCURRENT == FFECOM_targetFFE
370 #define ffecom_expr(e) (e)
371 #define ffecom_init_0()
372 #define ffecom_init_2()
373 #define ffecom_label_kind() FFEINFO_kindtypeINTEGERDEFAULT
374 #define ffecom_pointer_kind() FFEINFO_kindtypeINTEGERDEFAULT
375 #define ffecom_ptr_to_expr(e) (e)
376 #define ffecom_sym_commit(s)
377 #define ffecom_sym_retract(s)
378 #endif  /* FFECOM_targetCURRENT == FFECOM_targetFFE */
379
380 #if FFECOM_targetCURRENT == FFECOM_targetGCC
381 #define ffecom_f2c_typecode(bt,kt) ffecom_f2c_typecode_[(bt)][(kt)]
382 #define ffecom_label_kind() ffecom_label_kind_
383 #define ffecom_pointer_kind() ffecom_pointer_kind_
384 #define ffecom_prepare_expr(e) ffecom_prepare_expr_ ((e), NULL)
385 #endif  /* FFECOM_targetCURRENT == FFECOM_targetGCC */
386
387 #define ffecom_init_1()
388 #define ffecom_init_3()
389 #define ffecom_init_4()
390 #define ffecom_terminate_0()
391 #define ffecom_terminate_1()
392 #define ffecom_terminate_2()
393 #define ffecom_terminate_3()
394 #define ffecom_terminate_4()
395
396 /* End of #include file. */
397
398 #endif