OSDN Git Service

delete/change my email address
[pf3gnuchains/gcc-fork.git] / 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_globalNULL NULL_TREE
60 #define FFECOM_labelNULL NULL_TREE
61 #define FFECOM_storageNULL NULL_TREE
62 #define FFECOM_symbolNULL ffecom_symbol_null_
63
64 /* Shorthand for types used in f2c.h and that g77 perhaps allows some
65    flexibility regarding in the section below.  I.e. the actual numbers
66    below aren't important, as long as they're unique.  */
67
68 #define FFECOM_f2ccodeCHAR 1
69 #define FFECOM_f2ccodeSHORT 2
70 #define FFECOM_f2ccodeINT 3
71 #define FFECOM_f2ccodeLONG 4
72 #define FFECOM_f2ccodeLONGLONG 5
73 #define FFECOM_f2ccodeCHARPTR 6         /* char * */
74 #define FFECOM_f2ccodeFLOAT 7
75 #define FFECOM_f2ccodeDOUBLE 8
76 #define FFECOM_f2ccodeLONGDOUBLE 9
77 #define FFECOM_f2ccodeTWOREALS 10
78 #define FFECOM_f2ccodeTWODOUBLEREALS 11
79
80 #if FFECOM_DETERMINE_TYPES      /* only for com.c and configure */
81
82 /* Begin f2c.h information.  This must match the info in the f2c.h used
83    to build the libf2c with which g77-generated code is linked, or there
84    will probably be bugs, some of them difficult to detect or even trigger.  */
85
86 /* Do we need int (for 32-bit or 64-bit systems) or long (16-bit or
87    normally 32-bit) for f2c-type integers? */
88
89 #ifndef BITS_PER_WORD
90 #define BITS_PER_WORD 32
91 #endif
92
93 #ifndef CHAR_TYPE_SIZE
94 #define CHAR_TYPE_SIZE BITS_PER_UNIT
95 #endif
96
97 #ifndef SHORT_TYPE_SIZE
98 #define SHORT_TYPE_SIZE (BITS_PER_UNIT * MIN ((UNITS_PER_WORD + 1) / 2, 2))
99 #endif
100
101 #ifndef INT_TYPE_SIZE
102 #define INT_TYPE_SIZE BITS_PER_WORD
103 #endif
104
105 #ifndef LONG_TYPE_SIZE
106 #define LONG_TYPE_SIZE BITS_PER_WORD
107 #endif
108
109 #ifndef LONG_LONG_TYPE_SIZE
110 #define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2)
111 #endif
112
113 #ifndef WCHAR_UNSIGNED
114 #define WCHAR_UNSIGNED 0
115 #endif
116
117 #ifndef FLOAT_TYPE_SIZE
118 #define FLOAT_TYPE_SIZE BITS_PER_WORD
119 #endif
120
121 #ifndef DOUBLE_TYPE_SIZE
122 #define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
123 #endif
124
125 #ifndef LONG_DOUBLE_TYPE_SIZE
126 #define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
127 #endif
128
129 #if LONG_TYPE_SIZE == FLOAT_TYPE_SIZE
130 #  define FFECOM_f2cINTEGER FFECOM_f2ccodeLONG
131 #  define FFECOM_f2cLOGICAL FFECOM_f2ccodeLONG
132 #elif INT_TYPE_SIZE == FLOAT_TYPE_SIZE
133 #  define FFECOM_f2cINTEGER FFECOM_f2ccodeINT
134 #  define FFECOM_f2cLOGICAL FFECOM_f2ccodeINT
135 #else
136 #  error Cannot find a suitable type for FFECOM_f2cINTEGER
137 #endif
138
139 #if LONG_TYPE_SIZE == (FLOAT_TYPE_SIZE * 2)
140 #  define FFECOM_f2cLONGINT FFECOM_f2ccodeLONG
141 #elif LONG_LONG_TYPE_SIZE == (FLOAT_TYPE_SIZE * 2)
142 #  define FFECOM_f2cLONGINT FFECOM_f2ccodeLONGLONG
143 #else
144 #  error Cannot find a suitable type for FFECOM_f2cLONGINT
145 #endif
146
147 #define FFECOM_f2cADDRESS FFECOM_f2ccodeCHARPTR
148 #define FFECOM_f2cSHORTINT FFECOM_f2ccodeSHORT
149 #define FFECOM_f2cREAL FFECOM_f2ccodeFLOAT
150 #define FFECOM_f2cDOUBLEREAL FFECOM_f2ccodeDOUBLE
151 #define FFECOM_f2cCOMPLEX FFECOM_f2ccodeTWOREALS
152 #define FFECOM_f2cDOUBLECOMPLEX FFECOM_f2ccodeTWODOUBLEREALS
153 #define FFECOM_f2cSHORTLOGICAL FFECOM_f2ccodeSHORT
154 #define FFECOM_f2cLOGICAL1 FFECOM_f2ccodeCHAR
155 #define FFECOM_f2cINTEGER1 FFECOM_f2ccodeCHAR
156
157 /* These must be f2c's INTEGER type, to match runtime/f2c.h.in.  */
158
159 #define FFECOM_f2cFLAG FFECOM_f2cINTEGER
160 #define FFECOM_f2cFTNINT FFECOM_f2cINTEGER
161 #define FFECOM_f2cFTNLEN FFECOM_f2cINTEGER
162
163 #endif  /* #if FFECOM_DETERMINE_TYPES */
164
165 /* Everything else in f2c.h, specifically the structures used in
166    interfacing compiled code with the library, must remain exactly
167    as delivered, or g77 internals (mostly com.c and ste.c) must
168    be modified accordingly to compensate.  Or there will be...trouble.  */
169
170 typedef enum
171   {
172 #define DEFGFRT(CODE,NAME,TYPE,ARGS,VOLATILE,COMPLEX) CODE,
173 #include "com-rt.def"
174 #undef DEFGFRT
175     FFECOM_gfrt
176   } ffecomGfrt;
177
178 #endif  /* FFECOM_targetCURRENT == FFECOM_targetGCC */
179
180 /* Typedefs. */
181
182 #if FFECOM_targetCURRENT == FFECOM_targetGCC
183 #ifndef TREE_CODE
184 #include "tree.j"
185 #endif
186
187 #ifndef BUILT_FOR_270
188 #ifdef DECL_STATIC_CONSTRUCTOR  /* In gcc/tree.h. */
189 #define BUILT_FOR_270 1
190 #else
191 #define BUILT_FOR_270 0
192 #endif
193 #endif  /* !defined (BUILT_FOR_270) */
194
195 #ifndef BUILT_FOR_280
196 #ifdef DECL_ONE_ONLY    /* In gcc/tree.h. */
197 #define BUILT_FOR_280 1
198 #else
199 #define BUILT_FOR_280 0
200 #endif
201 #endif  /* !defined (BUILT_FOR_280) */
202
203 typedef tree ffecomConstant;
204 #define FFECOM_constantHOOK
205 typedef tree ffecomLabel;
206 #define FFECOM_globalHOOK
207 typedef tree ffecomGlobal;
208 #define FFECOM_labelHOOK
209 typedef tree ffecomStorage;
210 #define FFECOM_storageHOOK
211 typedef struct _ffecom_symbol_ ffecomSymbol;
212 #define FFECOM_symbolHOOK
213
214 struct _ffecom_symbol_
215   {
216     tree decl_tree;
217     tree length_tree;           /* For CHARACTER dummies. */
218     tree vardesc_tree;          /* For NAMELIST. */
219     tree assign_tree;           /* For ASSIGN'ed vars. */
220     bool addr;                  /* Is address of item instead of item. */
221   };
222 #endif  /* FFECOM_targetCURRENT == FFECOM_targetGCC */
223
224 /* Include files needed by this one. */
225
226 #include "bld.h"
227 #include "info.h"
228 #include "lab.h"
229 #include "storag.h"
230 #include "symbol.h"
231
232 /* Structure definitions. */
233
234
235 /* Global objects accessed by users of this module. */
236
237 #if FFECOM_targetCURRENT == FFECOM_targetGCC
238 extern tree long_integer_type_node;
239 extern tree complex_double_type_node;
240 extern tree string_type_node;
241 extern tree ffecom_integer_type_node;
242 extern tree ffecom_integer_zero_node;
243 extern tree ffecom_integer_one_node;
244 extern tree ffecom_tree_type[FFEINFO_basictype][FFEINFO_kindtype];
245 extern ffecomSymbol ffecom_symbol_null_;
246 extern ffeinfoKindtype ffecom_pointer_kind_;
247 extern ffeinfoKindtype ffecom_label_kind_;
248
249 extern int ffecom_f2c_typecode_[FFEINFO_basictype][FFEINFO_kindtype];
250 extern tree ffecom_f2c_integer_type_node;
251 extern tree ffecom_f2c_address_type_node;
252 extern tree ffecom_f2c_real_type_node;
253 extern tree ffecom_f2c_doublereal_type_node;
254 extern tree ffecom_f2c_complex_type_node;
255 extern tree ffecom_f2c_doublecomplex_type_node;
256 extern tree ffecom_f2c_longint_type_node;
257 extern tree ffecom_f2c_logical_type_node;
258 extern tree ffecom_f2c_flag_type_node;
259 extern tree ffecom_f2c_ftnlen_type_node;
260 extern tree ffecom_f2c_ftnlen_zero_node;
261 extern tree ffecom_f2c_ftnlen_one_node;
262 extern tree ffecom_f2c_ftnlen_two_node;
263 extern tree ffecom_f2c_ptr_to_ftnlen_type_node;
264 extern tree ffecom_f2c_ftnint_type_node;
265 extern tree ffecom_f2c_ptr_to_ftnint_type_node;
266 #endif  /* FFECOM_targetCURRENT == FFECOM_targetGCC */
267
268 /* Declare functions with prototypes. */
269
270 #if FFECOM_targetCURRENT == FFECOM_targetGCC
271 tree ffecom_1 (enum tree_code code, tree type, tree node);
272 tree ffecom_1_fn (tree node);
273 tree ffecom_2 (enum tree_code code, tree type, tree node1, tree node2);
274 bool ffecom_2pass_advise_entrypoint (ffesymbol entry);
275 void ffecom_2pass_do_entrypoint (ffesymbol entry);
276 tree ffecom_2s (enum tree_code code, tree type, tree node1, tree node2);
277 tree ffecom_3 (enum tree_code code, tree type, tree node1, tree node2,
278                tree node3);
279 tree ffecom_3s (enum tree_code code, tree type, tree node1, tree node2,
280                 tree node3);
281 tree ffecom_arg_expr (ffebld expr, tree *length);
282 tree ffecom_arg_ptr_to_expr (ffebld expr, tree *length);
283 tree ffecom_call_gfrt (ffecomGfrt ix, tree args);
284 tree ffecom_constantunion (ffebldConstantUnion *cu, ffeinfoBasictype bt,
285                            ffeinfoKindtype kt, tree tree_type);
286 tree ffecom_decl_field (tree context, tree prevfield, char *name,
287                         tree type);
288 #endif  /* FFECOM_targetCURRENT == FFECOM_targetGCC */
289 void ffecom_close_include (FILE *f);
290 int ffecom_decode_include_option (char *spec);
291 void ffecom_end_transition (void);
292 void ffecom_exec_transition (void);
293 void ffecom_expand_let_stmt (ffebld dest, ffebld source);
294 #if FFECOM_targetCURRENT == FFECOM_targetGCC
295 tree ffecom_expr (ffebld expr);
296 tree ffecom_expr_assign (ffebld expr);
297 tree ffecom_expr_assign_w (ffebld expr);
298 tree ffecom_expr_rw (ffebld expr);
299 void ffecom_finish_compile (void);
300 void ffecom_finish_decl (tree decl, tree init, bool is_top_level);
301 void ffecom_finish_progunit (void);
302 tree ffecom_get_invented_identifier (char *pattern, char *text,
303                                      int number);
304 ffeinfoKindtype ffecom_gfrt_basictype (ffecomGfrt ix);
305 ffeinfoKindtype ffecom_gfrt_kindtype (ffecomGfrt ix);
306 void ffecom_init_0 (void);
307 void ffecom_init_2 (void);
308 tree ffecom_list_expr (ffebld list);
309 tree ffecom_list_ptr_to_expr (ffebld list);
310 tree ffecom_lookup_label (ffelab label);
311 tree ffecom_modify (tree newtype, tree lhs, tree rhs);
312 #endif  /* FFECOM_targetCURRENT == FFECOM_targetGCC */
313 void ffecom_file (char *name);
314 void ffecom_notify_init_storage (ffestorag st);
315 void ffecom_notify_init_symbol (ffesymbol s);
316 void ffecom_notify_primary_entry (ffesymbol fn);
317 FILE *ffecom_open_include (char *name, ffewhereLine l, ffewhereColumn c);
318 #if FFECOM_targetCURRENT == FFECOM_targetGCC
319 void ffecom_pop_calltemps (void);
320 void ffecom_pop_tempvar (tree var);
321 tree ffecom_ptr_to_expr (ffebld expr);
322 void ffecom_push_calltemps (void);
323 tree ffecom_push_tempvar (tree type, ffetargetCharacterSize size,
324                           int elements, bool auto_pop);
325 tree ffecom_return_expr (ffebld expr);
326 tree ffecom_save_tree (tree t);
327 tree ffecom_start_decl (tree decl, bool is_init);
328 void ffecom_sym_commit (ffesymbol s);
329 #endif  /* FFECOM_targetCURRENT == FFECOM_targetGCC */
330 ffesymbol ffecom_sym_end_transition (ffesymbol s);
331 ffesymbol ffecom_sym_exec_transition (ffesymbol s);
332 ffesymbol ffecom_sym_learned (ffesymbol s);
333 #if FFECOM_targetCURRENT == FFECOM_targetGCC
334 void ffecom_sym_retract (ffesymbol s);
335 tree ffecom_temp_label (void);
336 tree ffecom_truth_value (tree expr);
337 tree ffecom_truth_value_invert (tree expr);
338 tree ffecom_which_entrypoint_decl (void);
339
340 /* These need to be in the front end with exactly these interfaces,
341    as they're called by the back end.  */
342
343 int mark_addressable (tree expr);
344 #endif  /* FFECOM_targetCURRENT == FFECOM_targetGCC */
345
346 /* Define macros. */
347
348 #if FFECOM_targetCURRENT == FFECOM_targetFFE
349 #define ffecom_expr(e) (e)
350 #define ffecom_init_0()
351 #define ffecom_init_2()
352 #define ffecom_label_kind() FFEINFO_kindtypeINTEGERDEFAULT
353 #define ffecom_pointer_kind() FFEINFO_kindtypeINTEGERDEFAULT
354 #define ffecom_ptr_to_expr(e) (e)
355 #define ffecom_sym_commit(s)
356 #define ffecom_sym_retract(s)
357 #endif  /* FFECOM_targetCURRENT == FFECOM_targetFFE */
358
359 #if FFECOM_targetCURRENT == FFECOM_targetGCC
360 #define ffecom_f2c_typecode(bt,kt) ffecom_f2c_typecode_[(bt)][(kt)]
361 #define ffecom_label_kind() ffecom_label_kind_
362 #define ffecom_pointer_kind() ffecom_pointer_kind_
363 #endif  /* FFECOM_targetCURRENT == FFECOM_targetGCC */
364
365 #define ffecom_init_1()
366 #define ffecom_init_3()
367 #define ffecom_init_4()
368 #define ffecom_terminate_0()
369 #define ffecom_terminate_1()
370 #define ffecom_terminate_2()
371 #define ffecom_terminate_3()
372 #define ffecom_terminate_4()
373
374 /* End of #include file. */
375
376 #endif