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.
5 This file is part of GNU Fortran.
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)
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.
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
28 /* Allow multiple inclusion to work. */
33 /* Simple definitions and enumerations. */
35 #define FFECOM_dimensionsMAX 7 /* Max # dimensions (quick hack). */
37 #define FFECOM_targetFFE 1
38 #define FFECOM_targetGCC 2
40 #ifndef FFE_STANDALONE
41 #define FFECOM_targetCURRENT FFECOM_targetGCC /* Backend! */
42 #define FFECOM_ONEPASS 0
44 #define FFECOM_targetCURRENT FFECOM_targetFFE
45 #define FFECOM_ONEPASS 0
49 #define FFECOM_TWOPASS 0
51 #define FFECOM_TWOPASS 1
54 #define FFECOM_SIZE_UNIT "byte" /* Singular form. */
55 #define FFECOM_SIZE_UNITS "bytes" /* Plural form. */
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_
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. */
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
81 #if FFECOM_DETERMINE_TYPES /* only for com.c and configure */
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. */
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? */
91 #define BITS_PER_WORD 32
94 #ifndef CHAR_TYPE_SIZE
95 #define CHAR_TYPE_SIZE BITS_PER_UNIT
98 #ifndef SHORT_TYPE_SIZE
99 #define SHORT_TYPE_SIZE (BITS_PER_UNIT * MIN ((UNITS_PER_WORD + 1) / 2, 2))
102 #ifndef INT_TYPE_SIZE
103 #define INT_TYPE_SIZE BITS_PER_WORD
106 #ifndef LONG_TYPE_SIZE
107 #define LONG_TYPE_SIZE BITS_PER_WORD
110 #ifndef LONG_LONG_TYPE_SIZE
111 #define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2)
114 #ifndef WCHAR_UNSIGNED
115 #define WCHAR_UNSIGNED 0
118 #ifndef FLOAT_TYPE_SIZE
119 #define FLOAT_TYPE_SIZE BITS_PER_WORD
122 #ifndef DOUBLE_TYPE_SIZE
123 #define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
126 #ifndef LONG_DOUBLE_TYPE_SIZE
127 #define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
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
137 # error Cannot find a suitable type for FFECOM_f2cINTEGER
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
145 # error Cannot find a suitable type for FFECOM_f2cLONGINT
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
158 /* These must be f2c's INTEGER type, to match runtime/f2c.h.in. */
160 #define FFECOM_f2cFLAG FFECOM_f2cINTEGER
161 #define FFECOM_f2cFTNINT FFECOM_f2cINTEGER
162 #define FFECOM_f2cFTNLEN FFECOM_f2cINTEGER
164 #endif /* #if FFECOM_DETERMINE_TYPES */
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. */
173 #define DEFGFRT(CODE,NAME,TYPE,ARGS,VOLATILE,COMPLEX) CODE,
174 #include "com-rt.def"
179 #endif /* FFECOM_targetCURRENT == FFECOM_targetGCC */
183 #if FFECOM_targetCURRENT == FFECOM_targetGCC
188 #ifndef BUILT_FOR_270
189 #ifdef DECL_STATIC_CONSTRUCTOR /* In gcc/tree.h. */
190 #define BUILT_FOR_270 1
192 #define BUILT_FOR_270 0
194 #endif /* !defined (BUILT_FOR_270) */
196 #ifndef BUILT_FOR_280
197 #ifdef DECL_ONE_ONLY /* In gcc/tree.h. */
198 #define BUILT_FOR_280 1
200 #define BUILT_FOR_280 0
202 #endif /* !defined (BUILT_FOR_280) */
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
217 struct _ffecom_symbol_
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. */
225 #endif /* FFECOM_targetCURRENT == FFECOM_targetGCC */
227 /* Include files needed by this one. */
235 /* Structure definitions. */
238 /* Global objects accessed by users of this module. */
240 #if FFECOM_targetCURRENT == FFECOM_targetGCC
241 extern tree string_type_node
;
242 extern tree ffecom_integer_type_node
;
243 extern tree ffecom_integer_zero_node
;
244 extern tree ffecom_integer_one_node
;
245 extern tree ffecom_tree_type
[FFEINFO_basictype
][FFEINFO_kindtype
];
246 extern ffecomSymbol ffecom_symbol_null_
;
247 extern ffeinfoKindtype ffecom_pointer_kind_
;
248 extern ffeinfoKindtype ffecom_label_kind_
;
250 extern int ffecom_f2c_typecode_
[FFEINFO_basictype
][FFEINFO_kindtype
];
251 extern tree ffecom_f2c_integer_type_node
;
252 extern tree ffecom_f2c_address_type_node
;
253 extern tree ffecom_f2c_real_type_node
;
254 extern tree ffecom_f2c_doublereal_type_node
;
255 extern tree ffecom_f2c_complex_type_node
;
256 extern tree ffecom_f2c_doublecomplex_type_node
;
257 extern tree ffecom_f2c_longint_type_node
;
258 extern tree ffecom_f2c_logical_type_node
;
259 extern tree ffecom_f2c_flag_type_node
;
260 extern tree ffecom_f2c_ftnlen_type_node
;
261 extern tree ffecom_f2c_ftnlen_zero_node
;
262 extern tree ffecom_f2c_ftnlen_one_node
;
263 extern tree ffecom_f2c_ftnlen_two_node
;
264 extern tree ffecom_f2c_ptr_to_ftnlen_type_node
;
265 extern tree ffecom_f2c_ftnint_type_node
;
266 extern tree ffecom_f2c_ptr_to_ftnint_type_node
;
267 #endif /* FFECOM_targetCURRENT == FFECOM_targetGCC */
269 /* Declare functions with prototypes. */
271 #if FFECOM_targetCURRENT == FFECOM_targetGCC
272 tree
ffecom_1 (enum tree_code code
, tree type
, tree node
);
273 tree
ffecom_1_fn (tree node
);
274 tree
ffecom_2 (enum tree_code code
, tree type
, tree node1
, tree node2
);
275 bool ffecom_2pass_advise_entrypoint (ffesymbol entry
);
276 void ffecom_2pass_do_entrypoint (ffesymbol entry
);
277 tree
ffecom_2s (enum tree_code code
, tree type
, tree node1
, tree node2
);
278 tree
ffecom_3 (enum tree_code code
, tree type
, tree node1
, tree node2
,
280 tree
ffecom_3s (enum tree_code code
, tree type
, tree node1
, tree node2
,
282 tree
ffecom_arg_expr (ffebld expr
, tree
*length
);
283 tree
ffecom_arg_ptr_to_const_expr (ffebld expr
, tree
*length
);
284 tree
ffecom_arg_ptr_to_expr (ffebld expr
, tree
*length
);
285 tree
ffecom_call_gfrt (ffecomGfrt ix
, tree args
, tree hook
);
286 tree
ffecom_constantunion (ffebldConstantUnion
*cu
, ffeinfoBasictype bt
,
287 ffeinfoKindtype kt
, tree tree_type
);
288 tree
ffecom_const_expr (ffebld expr
);
289 tree
ffecom_decl_field (tree context
, tree prevfield
, const char *name
,
291 #endif /* FFECOM_targetCURRENT == FFECOM_targetGCC */
292 void ffecom_close_include (FILE *f
);
293 int ffecom_decode_include_option (char *spec
);
294 #if FFECOM_targetCURRENT == FFECOM_targetGCC
295 tree
ffecom_end_compstmt (void);
296 #endif /* FFECOM_targetCURRENT == FFECOM_targetGCC */
297 void ffecom_end_transition (void);
298 void ffecom_exec_transition (void);
299 void ffecom_expand_let_stmt (ffebld dest
, ffebld source
);
300 #if FFECOM_targetCURRENT == FFECOM_targetGCC
301 tree
ffecom_expr (ffebld expr
);
302 tree
ffecom_expr_assign (ffebld expr
);
303 tree
ffecom_expr_assign_w (ffebld expr
);
304 tree
ffecom_expr_rw (tree type
, ffebld expr
);
305 tree
ffecom_expr_w (tree type
, ffebld expr
);
306 void ffecom_finish_compile (void);
307 void ffecom_finish_decl (tree decl
, tree init
, bool is_top_level
);
308 void ffecom_finish_progunit (void);
309 tree
ffecom_get_invented_identifier (const char *pattern
, ...)
311 ffeinfoKindtype
ffecom_gfrt_basictype (ffecomGfrt ix
);
312 ffeinfoKindtype
ffecom_gfrt_kindtype (ffecomGfrt ix
);
313 void ffecom_init_0 (void);
314 void ffecom_init_2 (void);
315 tree
ffecom_list_expr (ffebld list
);
316 tree
ffecom_list_ptr_to_expr (ffebld list
);
317 tree
ffecom_lookup_label (ffelab label
);
318 tree
ffecom_make_tempvar (const char *commentary
, tree type
,
319 ffetargetCharacterSize size
, int elements
);
320 tree
ffecom_modify (tree newtype
, tree lhs
, tree rhs
);
321 void ffecom_save_tree_forever (tree t
);
322 #endif /* FFECOM_targetCURRENT == FFECOM_targetGCC */
323 void ffecom_file (const char *name
);
324 void ffecom_notify_init_storage (ffestorag st
);
325 void ffecom_notify_init_symbol (ffesymbol s
);
326 void ffecom_notify_primary_entry (ffesymbol fn
);
327 FILE *ffecom_open_include (char *name
, ffewhereLine l
, ffewhereColumn c
);
328 #if FFECOM_targetCURRENT == FFECOM_targetGCC
329 void ffecom_prepare_arg_ptr_to_expr (ffebld expr
);
330 bool ffecom_prepare_end (void);
331 void ffecom_prepare_expr_ (ffebld expr
, ffebld dest
);
332 void ffecom_prepare_expr_rw (tree type
, ffebld expr
);
333 void ffecom_prepare_expr_w (tree type
, ffebld expr
);
334 void ffecom_prepare_ptr_to_expr (ffebld expr
);
335 void ffecom_prepare_return_expr (ffebld expr
);
336 tree
ffecom_ptr_to_const_expr (ffebld expr
);
337 tree
ffecom_ptr_to_expr (ffebld expr
);
338 tree
ffecom_return_expr (ffebld expr
);
339 tree
ffecom_save_tree (tree t
);
340 void ffecom_start_compstmt (void);
341 tree
ffecom_start_decl (tree decl
, bool is_init
);
342 void ffecom_sym_commit (ffesymbol s
);
343 #endif /* FFECOM_targetCURRENT == FFECOM_targetGCC */
344 ffesymbol
ffecom_sym_end_transition (ffesymbol s
);
345 ffesymbol
ffecom_sym_exec_transition (ffesymbol s
);
346 ffesymbol
ffecom_sym_learned (ffesymbol s
);
347 #if FFECOM_targetCURRENT == FFECOM_targetGCC
348 void ffecom_sym_retract (ffesymbol s
);
349 tree
ffecom_temp_label (void);
350 tree
ffecom_truth_value (tree expr
);
351 tree
ffecom_truth_value_invert (tree expr
);
352 tree
ffecom_type_expr (ffebld expr
);
353 tree
ffecom_which_entrypoint_decl (void);
355 /* These need to be in the front end with exactly these interfaces,
356 as they're called by the back end. */
358 int mark_addressable (tree expr
);
359 #endif /* FFECOM_targetCURRENT == FFECOM_targetGCC */
363 #if FFECOM_targetCURRENT == FFECOM_targetFFE
364 #define ffecom_expr(e) (e)
365 #define ffecom_init_0()
366 #define ffecom_init_2()
367 #define ffecom_label_kind() FFEINFO_kindtypeINTEGERDEFAULT
368 #define ffecom_pointer_kind() FFEINFO_kindtypeINTEGERDEFAULT
369 #define ffecom_ptr_to_expr(e) (e)
370 #define ffecom_sym_commit(s)
371 #define ffecom_sym_retract(s)
372 #endif /* FFECOM_targetCURRENT == FFECOM_targetFFE */
374 #if FFECOM_targetCURRENT == FFECOM_targetGCC
375 #define ffecom_f2c_typecode(bt,kt) ffecom_f2c_typecode_[(bt)][(kt)]
376 #define ffecom_label_kind() ffecom_label_kind_
377 #define ffecom_pointer_kind() ffecom_pointer_kind_
378 #define ffecom_prepare_expr(e) ffecom_prepare_expr_ ((e), NULL)
379 #endif /* FFECOM_targetCURRENT == FFECOM_targetGCC */
381 #define ffecom_init_1()
382 #define ffecom_init_3()
383 #define ffecom_init_4()
384 #define ffecom_terminate_0()
385 #define ffecom_terminate_1()
386 #define ffecom_terminate_2()
387 #define ffecom_terminate_3()
388 #define ffecom_terminate_4()
390 /* End of #include file. */