OSDN Git Service

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