xref: /openbsd/gnu/usr.bin/gcc/gcc/f/com.h (revision 107477e9)
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 GCC_F_COM_H
31 #define GCC_F_COM_H
32 
33 /* Simple definitions and enumerations. */
34 
35 #define FFECOM_dimensionsMAX 7	/* Max # dimensions (quick hack). */
36 
37 #define FFECOM_SIZE_UNIT "byte"	/* Singular form. */
38 #define FFECOM_SIZE_UNITS "bytes"	/* Plural form. */
39 
40 #define FFECOM_constantNULL NULL_TREE
41 #define FFECOM_nonterNULL NULL_TREE
42 #define FFECOM_globalNULL NULL_TREE
43 #define FFECOM_labelNULL NULL_TREE
44 #define FFECOM_storageNULL NULL_TREE
45 #define FFECOM_symbolNULL ffecom_symbol_null_
46 
47 /* Shorthand for types used in f2c.h and that g77 perhaps allows some
48    flexibility regarding in the section below.  I.e. the actual numbers
49    below aren't important, as long as they're unique.  */
50 
51 #define FFECOM_f2ccodeCHAR 1
52 #define FFECOM_f2ccodeSHORT 2
53 #define FFECOM_f2ccodeINT 3
54 #define FFECOM_f2ccodeLONG 4
55 #define FFECOM_f2ccodeLONGLONG 5
56 #define FFECOM_f2ccodeCHARPTR 6		/* char * */
57 #define FFECOM_f2ccodeFLOAT 7
58 #define FFECOM_f2ccodeDOUBLE 8
59 #define FFECOM_f2ccodeLONGDOUBLE 9
60 #define FFECOM_f2ccodeTWOREALS 10
61 #define FFECOM_f2ccodeTWODOUBLEREALS 11
62 
63 #if FFECOM_DETERMINE_TYPES	/* only for com.c and configure */
64 
65 /* Begin f2c.h information.  This must match the info in the f2c.h used
66    to build the libf2c with which g77-generated code is linked, or there
67    will probably be bugs, some of them difficult to detect or even trigger.  */
68 
69 /* The C front-end provides __g77_integer and __g77_uinteger types so that
70    the appropriately-sized signed and unsigned integer types are available
71    for libf2c.  If you change this, also the definitions of those types
72    in ../c-decl.c. */
73 #define FFECOM_f2cINTEGER			\
74   (LONG_TYPE_SIZE == FLOAT_TYPE_SIZE		\
75    ? FFECOM_f2ccodeLONG				\
76    : (INT_TYPE_SIZE == FLOAT_TYPE_SIZE		\
77       ? FFECOM_f2ccodeINT			\
78       : (abort (), -1)))
79 
80 #define FFECOM_f2cLOGICAL FFECOM_f2cINTEGER
81 
82 /* The C front-end provides __g77_longint and __g77_ulongint types so that
83    the appropriately-sized signed and unsigned integer types are available
84    for libf2c.  If you change this, also the definitions of those types
85    in ../c-decl.c. */
86 #define FFECOM_f2cLONGINT				\
87  (LONG_TYPE_SIZE == (FLOAT_TYPE_SIZE * 2)		\
88   ? FFECOM_f2ccodeLONG					\
89   : (LONG_LONG_TYPE_SIZE == (FLOAT_TYPE_SIZE * 2)	\
90      ? FFECOM_f2ccodeLONGLONG				\
91      : (abort (), -1)))
92 
93 #define FFECOM_f2cADDRESS FFECOM_f2ccodeCHARPTR
94 #define FFECOM_f2cSHORTINT FFECOM_f2ccodeSHORT
95 #define FFECOM_f2cREAL FFECOM_f2ccodeFLOAT
96 #define FFECOM_f2cDOUBLEREAL FFECOM_f2ccodeDOUBLE
97 #define FFECOM_f2cCOMPLEX FFECOM_f2ccodeTWOREALS
98 #define FFECOM_f2cDOUBLECOMPLEX FFECOM_f2ccodeTWODOUBLEREALS
99 #define FFECOM_f2cSHORTLOGICAL FFECOM_f2ccodeSHORT
100 #define FFECOM_f2cLOGICAL1 FFECOM_f2ccodeCHAR
101 #define FFECOM_f2cINTEGER1 FFECOM_f2ccodeCHAR
102 
103 /* These must be f2c's INTEGER type, to match runtime/f2c.h.in.  */
104 
105 #define FFECOM_f2cFLAG FFECOM_f2cINTEGER
106 #define FFECOM_f2cFTNINT FFECOM_f2cINTEGER
107 #define FFECOM_f2cFTNLEN FFECOM_f2cINTEGER
108 
109 #endif	/* #if FFECOM_DETERMINE_TYPES */
110 
111 /* Everything else in f2c.h, specifically the structures used in
112    interfacing compiled code with the library, must remain exactly
113    as delivered, or g77 internals (mostly com.c and ste.c) must
114    be modified accordingly to compensate.  Or there will be...trouble.  */
115 
116 typedef enum
117   {
118 #define DEFGFRT(CODE,NAME,TYPE,ARGS,VOLATILE,COMPLEX,CONST) CODE,
119 #include "com-rt.def"
120 #undef DEFGFRT
121     FFECOM_gfrt
122   } ffecomGfrt;
123 
124 /* Typedefs. */
125 
126 #ifndef TREE_CODE
127 #include "tree.h"
128 #endif
129 
130 typedef tree ffecomConstant;
131 #define FFECOM_constantHOOK
132 typedef tree ffecomNonter;
133 #define FFECOM_nonterHOOK
134 typedef tree ffecomLabel;
135 #define FFECOM_globalHOOK
136 typedef tree ffecomGlobal;
137 #define FFECOM_labelHOOK
138 typedef tree ffecomStorage;
139 #define FFECOM_storageHOOK
140 typedef struct _ffecom_symbol_ ffecomSymbol;
141 #define FFECOM_symbolHOOK
142 
143 struct _ffecom_symbol_
144   {
145     tree decl_tree;
146     tree length_tree;		/* For CHARACTER dummies. */
147     tree vardesc_tree;		/* For NAMELIST. */
148     tree assign_tree;		/* For ASSIGN'ed vars. */
149     bool addr;			/* Is address of item instead of item. */
150   };
151 
152 /* Include files needed by this one. */
153 
154 #include "bld.h"
155 #include "info.h"
156 #include "lab.h"
157 #include "storag.h"
158 #include "symbol.h"
159 
160 extern int global_bindings_p			PARAMS ((void));
161 extern tree getdecls				PARAMS ((void));
162 extern void pushlevel				PARAMS ((int));
163 extern tree poplevel				PARAMS ((int,int, int));
164 extern void insert_block			PARAMS ((tree));
165 extern void set_block				PARAMS ((tree));
166 extern tree pushdecl				PARAMS ((tree));
167 
168 /* Global objects accessed by users of this module. */
169 
170 extern GTY(()) tree string_type_node;
171 extern GTY(()) tree ffecom_integer_type_node;
172 extern GTY(()) tree ffecom_integer_zero_node;
173 extern GTY(()) tree ffecom_integer_one_node;
174 extern GTY(()) tree ffecom_tree_type[FFEINFO_basictype][FFEINFO_kindtype];
175 extern ffecomSymbol ffecom_symbol_null_;
176 extern ffeinfoKindtype ffecom_pointer_kind_;
177 extern ffeinfoKindtype ffecom_label_kind_;
178 
179 extern int ffecom_f2c_typecode_[FFEINFO_basictype][FFEINFO_kindtype];
180 extern GTY(()) tree ffecom_f2c_integer_type_node;
181 extern GTY(()) tree ffecom_f2c_address_type_node;
182 extern GTY(()) tree ffecom_f2c_real_type_node;
183 extern GTY(()) tree ffecom_f2c_doublereal_type_node;
184 extern GTY(()) tree ffecom_f2c_complex_type_node;
185 extern GTY(()) tree ffecom_f2c_doublecomplex_type_node;
186 extern GTY(()) tree ffecom_f2c_longint_type_node;
187 extern GTY(()) tree ffecom_f2c_logical_type_node;
188 extern GTY(()) tree ffecom_f2c_flag_type_node;
189 extern GTY(()) tree ffecom_f2c_ftnlen_type_node;
190 extern GTY(()) tree ffecom_f2c_ftnlen_zero_node;
191 extern GTY(()) tree ffecom_f2c_ftnlen_one_node;
192 extern GTY(()) tree ffecom_f2c_ftnlen_two_node;
193 extern GTY(()) tree ffecom_f2c_ptr_to_ftnlen_type_node;
194 extern GTY(()) tree ffecom_f2c_ftnint_type_node;
195 extern GTY(()) tree ffecom_f2c_ptr_to_ftnint_type_node;
196 
197 /* Declare functions with prototypes. */
198 
199 tree ffecom_1 (enum tree_code code, tree type, tree node);
200 tree ffecom_1_fn (tree node);
201 tree ffecom_2 (enum tree_code code, tree type, tree node1, tree node2);
202 bool ffecom_2pass_advise_entrypoint (ffesymbol entry);
203 void ffecom_2pass_do_entrypoint (ffesymbol entry);
204 tree ffecom_2s (enum tree_code code, tree type, tree node1, tree node2);
205 tree ffecom_3 (enum tree_code code, tree type, tree node1, tree node2,
206 	       tree node3);
207 tree ffecom_3s (enum tree_code code, tree type, tree node1, tree node2,
208 		tree node3);
209 tree ffecom_arg_expr (ffebld expr, tree *length);
210 tree ffecom_arg_ptr_to_const_expr (ffebld expr, tree *length);
211 tree ffecom_arg_ptr_to_expr (ffebld expr, tree *length);
212 tree ffecom_call_gfrt (ffecomGfrt ix, tree args, tree hook);
213 tree ffecom_constantunion_with_type (ffebldConstantUnion *cu,
214 		            tree tree_type,ffebldConst ct);
215 tree ffecom_constantunion (ffebldConstantUnion *cu, ffeinfoBasictype bt,
216 			   ffeinfoKindtype kt, tree tree_type);
217 tree ffecom_const_expr (ffebld expr);
218 tree ffecom_decl_field (tree context, tree prevfield, const char *name,
219 			tree type);
220 void ffecom_close_include (FILE *f);
221 int ffecom_decode_include_option (char *spec);
222 tree ffecom_end_compstmt (void);
223 void ffecom_end_transition (void);
224 void ffecom_exec_transition (void);
225 void ffecom_expand_let_stmt (ffebld dest, ffebld source);
226 tree ffecom_expr (ffebld expr);
227 tree ffecom_expr_assign (ffebld expr);
228 tree ffecom_expr_assign_w (ffebld expr);
229 tree ffecom_expr_rw (tree type, ffebld expr);
230 tree ffecom_expr_w (tree type, ffebld expr);
231 void ffecom_finish_compile (void);
232 void ffecom_finish_decl (tree decl, tree init, bool is_top_level);
233 void ffecom_finish_progunit (void);
234 tree ffecom_get_invented_identifier (const char *pattern, ...)
235   ATTRIBUTE_PRINTF_1;
236 ffeinfoBasictype ffecom_gfrt_basictype (ffecomGfrt ix);
237 ffeinfoKindtype ffecom_gfrt_kindtype (ffecomGfrt ix);
238 void ffecom_init_0 (void);
239 void ffecom_init_2 (void);
240 tree ffecom_list_expr (ffebld list);
241 tree ffecom_list_ptr_to_expr (ffebld list);
242 tree ffecom_lookup_label (ffelab label);
243 tree ffecom_make_tempvar (const char *commentary, tree type,
244 			  ffetargetCharacterSize size, int elements);
245 tree ffecom_modify (tree newtype, tree lhs, tree rhs);
246 void ffecom_save_tree_forever (tree t);
247 void ffecom_file (const char *name);
248 void ffecom_notify_init_storage (ffestorag st);
249 void ffecom_notify_init_symbol (ffesymbol s);
250 void ffecom_notify_primary_entry (ffesymbol fn);
251 FILE *ffecom_open_include (char *name, ffewhereLine l, ffewhereColumn c);
252 void ffecom_prepare_arg_ptr_to_expr (ffebld expr);
253 bool ffecom_prepare_end (void);
254 void ffecom_prepare_expr_ (ffebld expr, ffebld dest);
255 void ffecom_prepare_expr_rw (tree type, ffebld expr);
256 void ffecom_prepare_expr_w (tree type, ffebld expr);
257 void ffecom_prepare_ptr_to_expr (ffebld expr);
258 void ffecom_prepare_return_expr (ffebld expr);
259 tree ffecom_ptr_to_const_expr (ffebld expr);
260 tree ffecom_ptr_to_expr (ffebld expr);
261 tree ffecom_return_expr (ffebld expr);
262 tree ffecom_save_tree (tree t);
263 void ffecom_start_compstmt (void);
264 tree ffecom_start_decl (tree decl, bool is_init);
265 void ffecom_sym_commit (ffesymbol s);
266 ffesymbol ffecom_sym_end_transition (ffesymbol s);
267 ffesymbol ffecom_sym_exec_transition (ffesymbol s);
268 ffesymbol ffecom_sym_learned (ffesymbol s);
269 void ffecom_sym_retract (ffesymbol s);
270 tree ffecom_temp_label (void);
271 tree ffecom_truth_value (tree expr);
272 tree ffecom_truth_value_invert (tree expr);
273 tree ffecom_type_expr (ffebld expr);
274 tree ffecom_which_entrypoint_decl (void);
275 void ffe_parse_file (int);
276 
277 /* Define macros. */
278 
279 #define ffecom_f2c_typecode(bt,kt) ffecom_f2c_typecode_[(bt)][(kt)]
280 #define ffecom_label_kind() ffecom_label_kind_
281 #define ffecom_pointer_kind() ffecom_pointer_kind_
282 #define ffecom_prepare_expr(e) ffecom_prepare_expr_ ((e), NULL)
283 
284 #define ffecom_init_1()
285 #define ffecom_init_3()
286 #define ffecom_init_4()
287 #define ffecom_terminate_0()
288 #define ffecom_terminate_1()
289 #define ffecom_terminate_2()
290 #define ffecom_terminate_3()
291 #define ffecom_terminate_4()
292 
293 /* End of #include file. */
294 
295 #endif /* ! GCC_F_COM_H */
296