1 /* com.c -- Implementation File (module.c template V1.0)
2 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 Free Software Foundation, Inc.
4 Contributed by James Craig Burley.
6 This file is part of GNU Fortran.
8 GNU Fortran is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GNU Fortran is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU Fortran; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
27 Contains compiler-specific functions.
32 /* Understanding this module means understanding the interface between
33 the g77 front end and the gcc back end (or, perhaps, some other
34 back end). In here are the functions called by the front end proper
35 to notify whatever back end is in place about certain things, and
36 also the back-end-specific functions. It's a bear to deal with, so
37 lately I've been trying to simplify things, especially with regard
38 to the gcc-back-end-specific stuff.
40 Building expressions generally seems quite easy, but building decls
41 has been challenging and is undergoing revision. gcc has several
44 TYPE_DECL -- a type (int, float, struct, function, etc.)
45 CONST_DECL -- a constant of some type other than function
46 LABEL_DECL -- a variable or a constant?
47 PARM_DECL -- an argument to a function (a variable that is a dummy)
48 RESULT_DECL -- the return value of a function (a variable)
49 VAR_DECL -- other variable (can hold a ptr-to-function, struct, int, etc.)
50 FUNCTION_DECL -- a function (either the actual function or an extern ref)
51 FIELD_DECL -- a field in a struct or union (goes into types)
53 g77 has a set of functions that somewhat parallels the gcc front end
54 when it comes to building decls:
56 Internal Function (one we define, not just declare as extern):
57 if (is_nested) push_f_function_context ();
58 start_function (get_identifier ("function_name"), function_type,
59 is_nested, is_public);
60 // for each arg, build PARM_DECL and call push_parm_decl (decl) with it;
61 store_parm_decls (is_main_program);
62 ffecom_start_compstmt ();
63 // for stmts and decls inside function, do appropriate things;
64 ffecom_end_compstmt ();
65 finish_function (is_nested);
66 if (is_nested) pop_f_function_context ();
71 // fill in external, public, static, &c for decl, and
72 // set DECL_INITIAL to error_mark_node if going to initialize
73 // set is_top_level TRUE only if not at top level and decl
74 // must go in top level (i.e. not within current function decl context)
75 d = start_decl (decl, is_top_level);
76 init = ...; // if have initializer
77 finish_decl (d, init, is_top_level);
89 #include "output.h" /* Must follow tree.h so TREE_CODE is defined! */
92 #include "diagnostic.h"
94 #include "langhooks.h"
95 #include "langhooks-def.h"
98 /* VMS-specific definitions */
101 #define O_RDONLY 0 /* Open arg for Read/Only */
102 #define O_WRONLY 1 /* Open arg for Write/Only */
103 #define read(fd,buf,size) VMS_read (fd,buf,size)
104 #define write(fd,buf,size) VMS_write (fd,buf,size)
105 #define open(fname,mode,prot) VMS_open (fname,mode,prot)
106 #define fopen(fname,mode) VMS_fopen (fname,mode)
107 #define freopen(fname,mode,ofile) VMS_freopen (fname,mode,ofile)
108 #define strncat(dst,src,cnt) VMS_strncat (dst,src,cnt)
109 #define fstat(fd,stbuf) VMS_fstat (fd,stbuf)
110 static int VMS_fstat (), VMS_stat ();
111 static char * VMS_strncat ();
112 static int VMS_read ();
113 static int VMS_write ();
114 static int VMS_open ();
115 static FILE * VMS_fopen ();
116 static FILE * VMS_freopen ();
117 static void hack_vms_include_specification ();
118 typedef struct { unsigned :16, :16, :16; } vms_ino_t;
119 #define ino_t vms_ino_t
120 #define INCLUDE_LEN_FUDGE 10 /* leave room for VMS syntax conversion */
123 #define FFECOM_DETERMINE_TYPES 1 /* for com.h */
140 /* Externals defined here. */
142 /* Stream for reading from the input file. */
145 /* These definitions parallel those in c-decl.c so that code from that
146 module can be used pretty much as is. Much of these defs aren't
147 otherwise used, i.e. by g77 code per se, except some of them are used
148 to build some of them that are. The ones that are global (i.e. not
149 "static") are those that ste.c and such might use (directly
150 or by using com macros that reference them in their definitions). */
152 tree string_type_node;
154 /* The rest of these are inventions for g77, though there might be
155 similar things in the C front end. As they are found, these
156 inventions should be renamed to be canonical. Note that only
157 the ones currently required to be global are so. */
159 static GTY(()) tree ffecom_tree_fun_type_void;
161 tree ffecom_integer_type_node; /* Abbrev for _tree_type[blah][blah]. */
162 tree ffecom_integer_zero_node; /* Like *_*_* with g77's integer type. */
163 tree ffecom_integer_one_node; /* " */
164 tree ffecom_tree_type[FFEINFO_basictype][FFEINFO_kindtype];
166 /* _fun_type things are the f2c-specific versions. For -fno-f2c,
167 just use build_function_type and build_pointer_type on the
168 appropriate _tree_type array element. */
170 static GTY(()) tree ffecom_tree_fun_type[FFEINFO_basictype][FFEINFO_kindtype];
172 ffecom_tree_ptr_to_fun_type[FFEINFO_basictype][FFEINFO_kindtype];
173 static GTY(()) tree ffecom_tree_subr_type;
174 static GTY(()) tree ffecom_tree_ptr_to_subr_type;
175 static GTY(()) tree ffecom_tree_blockdata_type;
177 static GTY(()) tree ffecom_tree_xargc_;
179 ffecomSymbol ffecom_symbol_null_
188 ffeinfoKindtype ffecom_pointer_kind_ = FFEINFO_basictypeNONE;
189 ffeinfoKindtype ffecom_label_kind_ = FFEINFO_basictypeNONE;
191 int ffecom_f2c_typecode_[FFEINFO_basictype][FFEINFO_kindtype];
192 tree ffecom_f2c_integer_type_node;
193 static GTY(()) tree ffecom_f2c_ptr_to_integer_type_node;
194 tree ffecom_f2c_address_type_node;
195 tree ffecom_f2c_real_type_node;
196 static GTY(()) tree ffecom_f2c_ptr_to_real_type_node;
197 tree ffecom_f2c_doublereal_type_node;
198 tree ffecom_f2c_complex_type_node;
199 tree ffecom_f2c_doublecomplex_type_node;
200 tree ffecom_f2c_longint_type_node;
201 tree ffecom_f2c_logical_type_node;
202 tree ffecom_f2c_flag_type_node;
203 tree ffecom_f2c_ftnlen_type_node;
204 tree ffecom_f2c_ftnlen_zero_node;
205 tree ffecom_f2c_ftnlen_one_node;
206 tree ffecom_f2c_ftnlen_two_node;
207 tree ffecom_f2c_ptr_to_ftnlen_type_node;
208 tree ffecom_f2c_ftnint_type_node;
209 tree ffecom_f2c_ptr_to_ftnint_type_node;
211 /* Simple definitions and enumerations. */
213 #ifndef FFECOM_sizeMAXSTACKITEM
214 #define FFECOM_sizeMAXSTACKITEM 32*1024 /* Keep user-declared things
215 larger than this # bytes
216 off stack if possible. */
219 /* For systems that have large enough stacks, they should define
220 this to 0, and here, for ease of use later on, we just undefine
223 #if FFECOM_sizeMAXSTACKITEM == 0
224 #undef FFECOM_sizeMAXSTACKITEM
230 FFECOM_rttypeVOIDSTAR_, /* C's `void *' type. */
231 FFECOM_rttypeFTNINT_, /* f2c's `ftnint' type. */
232 FFECOM_rttypeINTEGER_, /* f2c's `integer' type. */
233 FFECOM_rttypeLONGINT_, /* f2c's `longint' type. */
234 FFECOM_rttypeLOGICAL_, /* f2c's `logical' type. */
235 FFECOM_rttypeREAL_F2C_, /* f2c's `real' returned as `double'. */
236 FFECOM_rttypeREAL_GNU_, /* `real' returned as such. */
237 FFECOM_rttypeCOMPLEX_F2C_, /* f2c's `complex' returned via 1st arg. */
238 FFECOM_rttypeCOMPLEX_GNU_, /* f2c's `complex' returned directly. */
239 FFECOM_rttypeDOUBLE_, /* C's `double' type. */
240 FFECOM_rttypeDOUBLEREAL_, /* f2c's `doublereal' type. */
241 FFECOM_rttypeDBLCMPLX_F2C_, /* f2c's `doublecomplex' returned via 1st arg. */
242 FFECOM_rttypeDBLCMPLX_GNU_, /* f2c's `doublecomplex' returned directly. */
243 FFECOM_rttypeCHARACTER_, /* f2c `char *'/`ftnlen' pair. */
247 /* Internal typedefs. */
249 typedef struct _ffecom_concat_list_ ffecomConcatList_;
251 /* Private include files. */
254 /* Internal structure definitions. */
256 struct _ffecom_concat_list_
261 ffetargetCharacterSize minlen;
262 ffetargetCharacterSize maxlen;
265 /* Static functions (internal). */
267 static tree ffe_type_for_mode (enum machine_mode, int);
268 static tree ffe_type_for_size (unsigned int, int);
269 static tree ffe_unsigned_type (tree);
270 static tree ffe_signed_type (tree);
271 static tree ffe_signed_or_unsigned_type (int, tree);
272 static bool ffe_mark_addressable (tree);
273 static tree ffe_truthvalue_conversion (tree);
274 static void ffecom_init_decl_processing (void);
275 static tree ffecom_arglist_expr_ (const char *argstring, ffebld args);
276 static tree ffecom_widest_expr_type_ (ffebld list);
277 static bool ffecom_overlap_ (tree dest_decl, tree dest_offset,
278 tree dest_size, tree source_tree,
279 ffebld source, bool scalar_arg);
280 static bool ffecom_args_overlapping_ (tree dest_tree, ffebld dest,
281 tree args, tree callee_commons,
283 static tree ffecom_build_f2c_string_ (int i, const char *s);
284 static tree ffecom_call_ (tree fn, ffeinfoKindtype kt,
285 bool is_f2c_complex, tree type,
286 tree args, tree dest_tree,
287 ffebld dest, bool *dest_used,
288 tree callee_commons, bool scalar_args, tree hook);
289 static tree ffecom_call_binop_ (tree fn, ffeinfoKindtype kt,
290 bool is_f2c_complex, tree type,
291 ffebld left, ffebld right,
292 tree dest_tree, ffebld dest,
293 bool *dest_used, tree callee_commons,
294 bool scalar_args, bool ref, tree hook);
295 static void ffecom_char_args_x_ (tree *xitem, tree *length,
296 ffebld expr, bool with_null);
297 static tree ffecom_check_size_overflow_ (ffesymbol s, tree type, bool dummy);
298 static tree ffecom_char_enhance_arg_ (tree *xtype, ffesymbol s);
299 static ffecomConcatList_
300 ffecom_concat_list_gather_ (ffecomConcatList_ catlist,
302 ffetargetCharacterSize max);
303 static void ffecom_concat_list_kill_ (ffecomConcatList_ catlist);
304 static ffecomConcatList_ ffecom_concat_list_new_ (ffebld expr,
305 ffetargetCharacterSize max);
306 static void ffecom_debug_kludge_ (tree aggr, const char *aggr_type,
307 ffesymbol member, tree member_type,
308 ffetargetOffset offset);
309 static void ffecom_do_entry_ (ffesymbol fn, int entrynum);
310 static tree ffecom_expr_ (ffebld expr, tree dest_tree, ffebld dest,
311 bool *dest_used, bool assignp, bool widenp);
312 static tree ffecom_expr_intrinsic_ (ffebld expr, tree dest_tree,
313 ffebld dest, bool *dest_used);
314 static tree ffecom_expr_power_integer_ (ffebld expr);
315 static void ffecom_expr_transform_ (ffebld expr);
316 static void ffecom_f2c_make_type_ (tree *type, int tcode, const char *name);
317 static void ffecom_f2c_set_lio_code_ (ffeinfoBasictype bt, int size,
319 static ffeglobal ffecom_finish_global_ (ffeglobal global);
320 static ffesymbol ffecom_finish_symbol_transform_ (ffesymbol s);
321 static tree ffecom_get_appended_identifier_ (char us, const char *text);
322 static tree ffecom_get_external_identifier_ (ffesymbol s);
323 static tree ffecom_get_identifier_ (const char *text);
324 static tree ffecom_gen_sfuncdef_ (ffesymbol s,
327 static const char *ffecom_gfrt_args_ (ffecomGfrt ix);
328 static tree ffecom_gfrt_tree_ (ffecomGfrt ix);
329 static tree ffecom_init_zero_ (tree decl);
330 static tree ffecom_intrinsic_ichar_ (tree tree_type, ffebld arg,
332 static tree ffecom_intrinsic_len_ (ffebld expr);
333 static void ffecom_let_char_ (tree dest_tree,
335 ffetargetCharacterSize dest_size,
337 static void ffecom_make_gfrt_ (ffecomGfrt ix);
338 static void ffecom_member_phase1_ (ffestorag mst, ffestorag st);
339 static void ffecom_member_phase2_ (ffestorag mst, ffestorag st);
340 static void ffecom_prepare_let_char_ (ffetargetCharacterSize dest_size,
342 static void ffecom_push_dummy_decls_ (ffebld dumlist,
344 static void ffecom_start_progunit_ (void);
345 static ffesymbol ffecom_sym_transform_ (ffesymbol s);
346 static ffesymbol ffecom_sym_transform_assign_ (ffesymbol s);
347 static void ffecom_transform_common_ (ffesymbol s);
348 static void ffecom_transform_equiv_ (ffestorag st);
349 static tree ffecom_transform_namelist_ (ffesymbol s);
350 static void ffecom_tree_canonize_ptr_ (tree *decl, tree *offset,
352 static void ffecom_tree_canonize_ref_ (tree *decl, tree *offset,
353 tree *size, tree tree);
354 static tree ffecom_tree_divide_ (tree tree_type, tree left, tree right,
355 tree dest_tree, ffebld dest,
356 bool *dest_used, tree hook);
357 static tree ffecom_type_localvar_ (ffesymbol s,
360 static tree ffecom_type_namelist_ (void);
361 static tree ffecom_type_vardesc_ (void);
362 static tree ffecom_vardesc_ (ffebld expr);
363 static tree ffecom_vardesc_array_ (ffesymbol s);
364 static tree ffecom_vardesc_dims_ (ffesymbol s);
365 static tree ffecom_convert_narrow_ (tree type, tree expr);
366 static tree ffecom_convert_widen_ (tree type, tree expr);
368 /* These are static functions that parallel those found in the C front
369 end and thus have the same names. */
371 static tree bison_rule_compstmt_ (void);
372 static void bison_rule_pushlevel_ (void);
373 static void delete_block (tree block);
374 static int duplicate_decls (tree newdecl, tree olddecl);
375 static void finish_decl (tree decl, tree init, bool is_top_level);
376 static void finish_function (int nested);
377 static const char *ffe_printable_name (tree decl, int v);
378 static void ffe_print_error_function (diagnostic_context *, const char *);
379 static tree lookup_name_current_level (tree name);
380 static struct f_binding_level *make_binding_level (void);
381 static void pop_f_function_context (void);
382 static void push_f_function_context (void);
383 static void push_parm_decl (tree parm);
384 static tree pushdecl_top_level (tree decl);
385 static int kept_level_p (void);
386 static tree storedecls (tree decls);
387 static void store_parm_decls (int is_main_program);
388 static tree start_decl (tree decl, bool is_top_level);
389 static void start_function (tree name, tree type, int nested, int public);
390 static void ffecom_file_ (const char *name);
391 static void ffecom_close_include_ (FILE *f);
392 static FILE *ffecom_open_include_ (char *name, ffewhereLine l,
395 /* Static objects accessed by functions in this module. */
397 static ffesymbol ffecom_primary_entry_ = NULL;
398 static ffesymbol ffecom_nested_entry_ = NULL;
399 static ffeinfoKind ffecom_primary_entry_kind_;
400 static bool ffecom_primary_entry_is_proc_;
401 static GTY(()) tree ffecom_outer_function_decl_;
402 static GTY(()) tree ffecom_previous_function_decl_;
403 static GTY(()) tree ffecom_which_entrypoint_decl_;
404 static GTY(()) tree ffecom_float_zero_;
405 static GTY(()) tree ffecom_float_half_;
406 static GTY(()) tree ffecom_double_zero_;
407 static GTY(()) tree ffecom_double_half_;
408 static GTY(()) tree ffecom_func_result_;/* For functions. */
409 static GTY(()) tree ffecom_func_length_;/* For CHARACTER fns. */
410 static ffebld ffecom_list_blockdata_;
411 static ffebld ffecom_list_common_;
412 static ffebld ffecom_master_arglist_;
413 static ffeinfoBasictype ffecom_master_bt_;
414 static ffeinfoKindtype ffecom_master_kt_;
415 static ffetargetCharacterSize ffecom_master_size_;
416 static int ffecom_num_fns_ = 0;
417 static int ffecom_num_entrypoints_ = 0;
418 static bool ffecom_is_altreturning_ = FALSE;
419 static GTY(()) tree ffecom_multi_type_node_;
420 static GTY(()) tree ffecom_multi_retval_;
422 ffecom_multi_fields_[FFEINFO_basictype][FFEINFO_kindtype];
423 static bool ffecom_member_namelisted_; /* _member_phase1_ namelisted? */
424 static bool ffecom_doing_entry_ = FALSE;
425 static bool ffecom_transform_only_dummies_ = FALSE;
426 static int ffecom_typesize_pointer_;
427 static int ffecom_typesize_integer1_;
429 /* Holds pointer-to-function expressions. */
431 static GTY(()) tree ffecom_gfrt_[FFECOM_gfrt];
433 /* Holds the external names of the functions. */
435 static const char *const ffecom_gfrt_name_[FFECOM_gfrt]
438 #define DEFGFRT(CODE,NAME,TYPE,ARGS,VOLATILE,COMPLEX,CONST) NAME,
439 #include "com-rt.def"
443 /* Whether the function returns. */
445 static const bool ffecom_gfrt_volatile_[FFECOM_gfrt]
448 #define DEFGFRT(CODE,NAME,TYPE,ARGS,VOLATILE,COMPLEX,CONST) VOLATILE,
449 #include "com-rt.def"
453 /* Whether the function returns type complex. */
455 static const bool ffecom_gfrt_complex_[FFECOM_gfrt]
458 #define DEFGFRT(CODE,NAME,TYPE,ARGS,VOLATILE,COMPLEX,CONST) COMPLEX,
459 #include "com-rt.def"
463 /* Whether the function is const
464 (i.e., has no side effects and only depends on its arguments). */
466 static const bool ffecom_gfrt_const_[FFECOM_gfrt]
469 #define DEFGFRT(CODE,NAME,TYPE,ARGS,VOLATILE,COMPLEX,CONST) CONST,
470 #include "com-rt.def"
474 /* Type code for the function return value. */
476 static const ffecomRttype_ ffecom_gfrt_type_[FFECOM_gfrt]
479 #define DEFGFRT(CODE,NAME,TYPE,ARGS,VOLATILE,COMPLEX,CONST) TYPE,
480 #include "com-rt.def"
484 /* String of codes for the function's arguments. */
486 static const char *const ffecom_gfrt_argstring_[FFECOM_gfrt]
489 #define DEFGFRT(CODE,NAME,TYPE,ARGS,VOLATILE,COMPLEX,CONST) ARGS,
490 #include "com-rt.def"
494 /* Internal macros. */
496 /* We let tm.h override the types used here, to handle trivial differences
497 such as the choice of unsigned int or long unsigned int for size_t.
498 When machines start needing nontrivial differences in the size type,
499 it would be best to do something here to figure out automatically
500 from other information what type to use. */
503 #define SIZE_TYPE "long unsigned int"
506 #define ffecom_concat_list_count_(catlist) ((catlist).count)
507 #define ffecom_concat_list_expr_(catlist,i) ((catlist).exprs[(i)])
508 #define ffecom_concat_list_maxlen_(catlist) ((catlist).maxlen)
509 #define ffecom_concat_list_minlen_(catlist) ((catlist).minlen)
511 #define ffecom_char_args_(i,l,e) ffecom_char_args_x_((i),(l),(e),FALSE)
512 #define ffecom_char_args_with_null_(i,l,e) ffecom_char_args_x_((i),(l),(e),TRUE)
514 /* For each binding contour we allocate a binding_level structure
515 * which records the names defined in that contour.
518 * 1) one for each function definition,
519 * where internal declarations of the parameters appear.
521 * The current meaning of a name can be found by searching the levels from
522 * the current one out to the global one.
525 /* Note that the information in the `names' component of the global contour
526 is duplicated in the IDENTIFIER_GLOBAL_VALUEs of all identifiers. */
528 struct f_binding_level GTY(())
530 /* A chain of _DECL nodes for all variables, constants, functions,
531 and typedef types. These are in the reverse of the order supplied.
535 /* For each level (except not the global one),
536 a chain of BLOCK nodes for all the levels
537 that were entered and exited one level down. */
540 /* The BLOCK node for this level, if one has been preallocated.
541 If 0, the BLOCK is allocated (if needed) when the level is popped. */
544 /* The binding level which this one is contained in (inherits from). */
545 struct f_binding_level *level_chain;
547 /* 0: no ffecom_prepare_* functions called at this level yet;
548 1: ffecom_prepare* functions called, except not ffecom_prepare_end;
549 2: ffecom_prepare_end called. */
553 #define NULL_BINDING_LEVEL (struct f_binding_level *) NULL
555 /* The binding level currently in effect. */
557 static GTY(()) struct f_binding_level *current_binding_level;
559 /* A chain of binding_level structures awaiting reuse. */
561 static GTY((deletable (""))) struct f_binding_level *free_binding_level;
563 /* The outermost binding level, for names of file scope.
564 This is created when the compiler is started and exists
565 through the entire run. */
567 static struct f_binding_level *global_binding_level;
569 /* Binding level structures are initialized by copying this one. */
571 static const struct f_binding_level clear_binding_level
573 {NULL, NULL, NULL, NULL_BINDING_LEVEL, 0};
575 /* Language-dependent contents of an identifier. */
577 struct lang_identifier GTY(())
579 struct tree_identifier common;
586 /* Macros for access to language-specific slots in an identifier. */
587 /* Each of these slots contains a DECL node or null. */
589 /* This represents the value which the identifier has in the
590 file-scope namespace. */
591 #define IDENTIFIER_GLOBAL_VALUE(NODE) \
592 (((struct lang_identifier *)(NODE))->global_value)
593 /* This represents the value which the identifier has in the current
595 #define IDENTIFIER_LOCAL_VALUE(NODE) \
596 (((struct lang_identifier *)(NODE))->local_value)
597 /* This represents the value which the identifier has as a label in
598 the current label scope. */
599 #define IDENTIFIER_LABEL_VALUE(NODE) \
600 (((struct lang_identifier *)(NODE))->label_value)
601 /* This is nonzero if the identifier was "made up" by g77 code. */
602 #define IDENTIFIER_INVENTED(NODE) \
603 (((struct lang_identifier *)(NODE))->invented)
605 /* The resulting tree type. */
607 GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"),
608 chain_next ("(union lang_tree_node *)TREE_CHAIN (&%h.generic)")))
610 union tree_node GTY ((tag ("0"),
611 desc ("tree_node_structure (&%h)")))
613 struct lang_identifier GTY ((tag ("1"))) identifier;
616 /* Fortran doesn't use either of these. */
617 struct lang_decl GTY(())
620 struct lang_type GTY(())
624 /* In identifiers, C uses the following fields in a special way:
625 TREE_PUBLIC to record that there was a previous local extern decl.
626 TREE_USED to record that such a decl was used.
627 TREE_ADDRESSABLE to record that the address of such a decl was used. */
629 /* A list (chain of TREE_LIST nodes) of all LABEL_DECLs in the function
630 that have names. Here so we can clear out their names' definitions
631 at the end of the function. */
633 static GTY(()) tree named_labels;
635 /* A list of LABEL_DECLs from outer contexts that are currently shadowed. */
637 static GTY(()) tree shadowed_labels;
639 /* Return the subscript expression, modified to do range-checking.
641 `array' is the array type to be checked against.
642 `element' is the subscript expression to check.
643 `dim' is the dimension number (starting at 0).
644 `total_dims' is the total number of dimensions (0 for CHARACTER substring).
645 `item' is the array decl or NULL_TREE.
649 ffecom_subscript_check_ (tree array, tree element, int dim, int total_dims,
650 const char *array_name, tree item)
652 tree low = TYPE_MIN_VALUE (TYPE_DOMAIN (array));
653 tree high = TYPE_MAX_VALUE (TYPE_DOMAIN (array));
658 if (element == error_mark_node)
661 if (TREE_TYPE (low) != TREE_TYPE (element))
663 if (TYPE_PRECISION (TREE_TYPE (low))
664 > TYPE_PRECISION (TREE_TYPE (element)))
665 element = convert (TREE_TYPE (low), element);
668 low = convert (TREE_TYPE (element), low);
670 high = convert (TREE_TYPE (element), high);
674 element = ffecom_save_tree (element);
677 /* Special handling for substring range checks. Fortran allows the
678 end subscript < begin subscript, which means that expressions like
679 string(1:0) are valid (and yield a null string). In view of this,
680 enforce two simpler conditions:
681 1) element<=high for end-substring;
682 2) element>=low for start-substring.
683 Run-time character movement will enforce remaining conditions.
685 More complicated checks would be better, but present structure only
686 provides one index element at a time, so it is not possible to
687 enforce a check of both i and j in string(i:j). If it were, the
688 complete set of rules would read,
689 if ( ((j<i) && ((low<=i<=high) || (low<=j<=high))) ||
690 ((low<=i<=high) && (low<=j<=high)) )
696 cond = ffecom_2 (LE_EXPR, integer_type_node, element, high);
698 cond = ffecom_2 (LE_EXPR, integer_type_node, low, element);
702 /* Array reference substring range checking. */
704 cond = ffecom_2 (LE_EXPR, integer_type_node,
709 cond = ffecom_2 (TRUTH_ANDIF_EXPR, integer_type_node,
711 ffecom_2 (LE_EXPR, integer_type_node,
717 /* If the array index is safe at compile-time, return element. */
718 if (integer_nonzerop (cond))
733 var = concat (array_name, "[", (dim ? "end" : "start"),
734 "-substring]", NULL);
735 len = strlen (var) + 1;
736 arg1 = build_string (len, var);
741 len = strlen (array_name) + 1;
742 arg1 = build_string (len, array_name);
746 var = xmalloc (strlen (array_name) + 40);
747 sprintf (var, "%s[subscript-%d-of-%d]",
749 dim + 1, total_dims);
750 len = strlen (var) + 1;
751 arg1 = build_string (len, var);
757 = build_type_variant (build_array_type (char_type_node,
761 build_int_2 (len, 0))),
763 TREE_CONSTANT (arg1) = 1;
764 TREE_STATIC (arg1) = 1;
765 arg1 = ffecom_1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (arg1)),
768 /* s_rnge adds one to the element to print it, so bias against
769 that -- want to print a faithful *subscript* value. */
770 arg2 = convert (ffecom_f2c_ftnint_type_node,
771 ffecom_2 (MINUS_EXPR,
774 convert (TREE_TYPE (element),
777 proc = concat (input_filename, "/",
778 IDENTIFIER_POINTER (DECL_NAME (current_function_decl)),
780 len = strlen (proc) + 1;
781 arg3 = build_string (len, proc);
786 = build_type_variant (build_array_type (char_type_node,
790 build_int_2 (len, 0))),
792 TREE_CONSTANT (arg3) = 1;
793 TREE_STATIC (arg3) = 1;
794 arg3 = ffecom_1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (arg3)),
797 arg4 = convert (ffecom_f2c_ftnint_type_node,
798 build_int_2 (input_line, 0));
800 arg1 = build_tree_list (NULL_TREE, arg1);
801 arg2 = build_tree_list (NULL_TREE, arg2);
802 arg3 = build_tree_list (NULL_TREE, arg3);
803 arg4 = build_tree_list (NULL_TREE, arg4);
804 TREE_CHAIN (arg3) = arg4;
805 TREE_CHAIN (arg2) = arg3;
806 TREE_CHAIN (arg1) = arg2;
810 die = ffecom_call_gfrt (FFECOM_gfrtRANGE,
812 TREE_SIDE_EFFECTS (die) = 1;
813 die = convert (void_type_node, die);
815 if (integer_zerop (cond) && item)
816 ffe_mark_addressable (item);
818 return ffecom_3 (COND_EXPR, TREE_TYPE (element), cond, element, die);
821 /* Return the computed element of an array reference.
823 `item' is NULL_TREE, or the transformed pointer to the array.
824 `expr' is the original opARRAYREF expression, which is transformed
825 if `item' is NULL_TREE.
826 `want_ptr' is nonzero if a pointer to the element, instead of
827 the element itself, is to be returned. */
830 ffecom_arrayref_ (tree item, ffebld expr, int want_ptr)
832 ffebld dims[FFECOM_dimensionsMAX];
835 int flatten = ffe_is_flatten_arrays ();
841 const char *array_name;
845 if (ffebld_op (ffebld_left (expr)) == FFEBLD_opSYMTER)
846 array_name = ffesymbol_text (ffebld_symter (ffebld_left (expr)));
848 array_name = "[expr?]";
850 /* Build up ARRAY_REFs in reverse order (since we're column major
851 here in Fortran land). */
853 for (i = 0, list = ffebld_right (expr);
855 ++i, list = ffebld_trail (list))
857 dims[i] = ffebld_head (list);
858 type = ffeinfo_type (ffebld_basictype (dims[i]),
859 ffebld_kindtype (dims[i]));
861 && ffecom_typesize_pointer_ > ffecom_typesize_integer1_
862 && ffetype_size (type) > ffecom_typesize_integer1_)
863 /* E.g. ARRAY(INDEX), given INTEGER*8 INDEX, on a system with 64-bit
864 pointers and 32-bit integers. Do the full 64-bit pointer
865 arithmetic, for codes using arrays for nonstandard heap-like
872 need_ptr = want_ptr || flatten;
877 item = ffecom_ptr_to_expr (ffebld_left (expr));
879 item = ffecom_expr (ffebld_left (expr));
881 if (item == error_mark_node)
884 if (ffeinfo_where (ffebld_info (expr)) == FFEINFO_whereFLEETING
885 && ! ffe_mark_addressable (item))
886 return error_mark_node;
889 if (item == error_mark_node)
896 for (--i, array = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (item)));
898 --i, array = TYPE_MAIN_VARIANT (TREE_TYPE (array)))
900 min = TYPE_MIN_VALUE (TYPE_DOMAIN (array));
901 element = ffecom_expr_ (dims[i], NULL, NULL, NULL, FALSE, TRUE);
902 if (flag_bounds_check)
903 element = ffecom_subscript_check_ (array, element, i, total_dims,
905 if (element == error_mark_node)
908 /* Widen integral arithmetic as desired while preserving
910 tree_type = TREE_TYPE (element);
911 tree_type_x = tree_type;
913 && GET_MODE_CLASS (TYPE_MODE (tree_type)) == MODE_INT
914 && TYPE_PRECISION (tree_type) < TYPE_PRECISION (sizetype))
915 tree_type_x = (TREE_UNSIGNED (tree_type) ? usizetype : ssizetype);
917 if (TREE_TYPE (min) != tree_type_x)
918 min = convert (tree_type_x, min);
919 if (TREE_TYPE (element) != tree_type_x)
920 element = convert (tree_type_x, element);
922 item = ffecom_2 (PLUS_EXPR,
923 build_pointer_type (TREE_TYPE (array)),
925 size_binop (MULT_EXPR,
926 size_in_bytes (TREE_TYPE (array)),
928 fold (build (MINUS_EXPR,
934 item = ffecom_1 (INDIRECT_REF,
935 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (item))),
945 array = TYPE_MAIN_VARIANT (TREE_TYPE (item));
947 element = ffecom_expr_ (dims[i], NULL, NULL, NULL, FALSE, TRUE);
948 if (flag_bounds_check)
949 element = ffecom_subscript_check_ (array, element, i, total_dims,
951 if (element == error_mark_node)
954 /* Widen integral arithmetic as desired while preserving
956 tree_type = TREE_TYPE (element);
957 tree_type_x = tree_type;
959 && GET_MODE_CLASS (TYPE_MODE (tree_type)) == MODE_INT
960 && TYPE_PRECISION (tree_type) < TYPE_PRECISION (sizetype))
961 tree_type_x = (TREE_UNSIGNED (tree_type) ? usizetype : ssizetype);
963 element = convert (tree_type_x, element);
965 item = ffecom_2 (ARRAY_REF,
966 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (item))),
975 /* This is like gcc's stabilize_reference -- in fact, most of the code
976 comes from that -- but it handles the situation where the reference
977 is going to have its subparts picked at, and it shouldn't change
978 (or trigger extra invocations of functions in the subtrees) due to
979 this. save_expr is a bit overzealous, because we don't need the
980 entire thing calculated and saved like a temp. So, for DECLs, no
981 change is needed, because these are stable aggregates, and ARRAY_REF
982 and such might well be stable too, but for things like calculations,
983 we do need to calculate a snapshot of a value before picking at it. */
986 ffecom_stabilize_aggregate_ (tree ref)
989 enum tree_code code = TREE_CODE (ref);
996 /* No action is needed in this case. */
1002 case FIX_TRUNC_EXPR:
1003 case FIX_FLOOR_EXPR:
1004 case FIX_ROUND_EXPR:
1006 result = build_nt (code, stabilize_reference (TREE_OPERAND (ref, 0)));
1010 result = build_nt (INDIRECT_REF,
1011 stabilize_reference_1 (TREE_OPERAND (ref, 0)));
1015 result = build_nt (COMPONENT_REF,
1016 stabilize_reference (TREE_OPERAND (ref, 0)),
1017 TREE_OPERAND (ref, 1));
1021 result = build_nt (BIT_FIELD_REF,
1022 stabilize_reference (TREE_OPERAND (ref, 0)),
1023 stabilize_reference_1 (TREE_OPERAND (ref, 1)),
1024 stabilize_reference_1 (TREE_OPERAND (ref, 2)));
1028 result = build_nt (ARRAY_REF,
1029 stabilize_reference (TREE_OPERAND (ref, 0)),
1030 stabilize_reference_1 (TREE_OPERAND (ref, 1)));
1034 result = build_nt (COMPOUND_EXPR,
1035 stabilize_reference_1 (TREE_OPERAND (ref, 0)),
1036 stabilize_reference (TREE_OPERAND (ref, 1)));
1044 return save_expr (ref);
1047 return error_mark_node;
1050 TREE_TYPE (result) = TREE_TYPE (ref);
1051 TREE_READONLY (result) = TREE_READONLY (ref);
1052 TREE_SIDE_EFFECTS (result) = TREE_SIDE_EFFECTS (ref);
1053 TREE_THIS_VOLATILE (result) = TREE_THIS_VOLATILE (ref);
1058 /* A rip-off of gcc's convert.c convert_to_complex function,
1059 reworked to handle complex implemented as C structures
1060 (RECORD_TYPE with two fields, real and imaginary `r' and `i'). */
1063 ffecom_convert_to_complex_ (tree type, tree expr)
1065 register enum tree_code form = TREE_CODE (TREE_TYPE (expr));
1068 assert (TREE_CODE (type) == RECORD_TYPE);
1070 subtype = TREE_TYPE (TYPE_FIELDS (type));
1072 if (form == REAL_TYPE || form == INTEGER_TYPE || form == ENUMERAL_TYPE)
1074 expr = convert (subtype, expr);
1075 return ffecom_2 (COMPLEX_EXPR, type, expr,
1076 convert (subtype, integer_zero_node));
1079 if (form == RECORD_TYPE)
1081 tree elt_type = TREE_TYPE (TYPE_FIELDS (TREE_TYPE (expr)));
1082 if (TYPE_MAIN_VARIANT (elt_type) == TYPE_MAIN_VARIANT (subtype))
1086 expr = save_expr (expr);
1087 return ffecom_2 (COMPLEX_EXPR,
1090 ffecom_1 (REALPART_EXPR,
1091 TREE_TYPE (TYPE_FIELDS (TREE_TYPE (expr))),
1094 ffecom_1 (IMAGPART_EXPR,
1095 TREE_TYPE (TYPE_FIELDS (TREE_TYPE (expr))),
1100 if (form == POINTER_TYPE || form == REFERENCE_TYPE)
1101 error ("pointer value used where a complex was expected");
1103 error ("aggregate value used where a complex was expected");
1105 return ffecom_2 (COMPLEX_EXPR, type,
1106 convert (subtype, integer_zero_node),
1107 convert (subtype, integer_zero_node));
1110 /* Like gcc's convert(), but crashes if widening might happen. */
1113 ffecom_convert_narrow_ (tree type, tree expr)
1115 register tree e = expr;
1116 register enum tree_code code = TREE_CODE (type);
1118 if (type == TREE_TYPE (e)
1119 || TREE_CODE (e) == ERROR_MARK)
1121 if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (e)))
1122 return fold (build1 (NOP_EXPR, type, e));
1123 if (TREE_CODE (TREE_TYPE (e)) == ERROR_MARK
1124 || code == ERROR_MARK)
1125 return error_mark_node;
1126 if (TREE_CODE (TREE_TYPE (e)) == VOID_TYPE)
1128 assert ("void value not ignored as it ought to be" == NULL);
1129 return error_mark_node;
1131 assert (code != VOID_TYPE);
1132 if ((code != RECORD_TYPE)
1133 && (TREE_CODE (TREE_TYPE (e)) == RECORD_TYPE))
1134 assert ("converting COMPLEX to REAL" == NULL);
1135 assert (code != ENUMERAL_TYPE);
1136 if (code == INTEGER_TYPE)
1138 assert ((TREE_CODE (TREE_TYPE (e)) == INTEGER_TYPE
1139 && TYPE_PRECISION (type) <= TYPE_PRECISION (TREE_TYPE (e)))
1140 || (TREE_CODE (TREE_TYPE (e)) == POINTER_TYPE
1141 && (TYPE_PRECISION (type)
1142 == TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (e))))));
1143 return fold (convert_to_integer (type, e));
1145 if (code == POINTER_TYPE)
1147 assert (TREE_CODE (TREE_TYPE (e)) == POINTER_TYPE);
1148 return fold (convert_to_pointer (type, e));
1150 if (code == REAL_TYPE)
1152 assert (TREE_CODE (TREE_TYPE (e)) == REAL_TYPE);
1153 assert (TYPE_PRECISION (type) <= TYPE_PRECISION (TREE_TYPE (e)));
1154 return fold (convert_to_real (type, e));
1156 if (code == COMPLEX_TYPE)
1158 assert (TREE_CODE (TREE_TYPE (e)) == COMPLEX_TYPE);
1159 assert (TYPE_PRECISION (TREE_TYPE (type)) <= TYPE_PRECISION (TREE_TYPE (TREE_TYPE (e))));
1160 return fold (convert_to_complex (type, e));
1162 if (code == RECORD_TYPE)
1164 assert (TREE_CODE (TREE_TYPE (e)) == RECORD_TYPE);
1165 /* Check that at least the first field name agrees. */
1166 assert (DECL_NAME (TYPE_FIELDS (type))
1167 == DECL_NAME (TYPE_FIELDS (TREE_TYPE (e))));
1168 assert (TYPE_PRECISION (TREE_TYPE (TYPE_FIELDS (type)))
1169 <= TYPE_PRECISION (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (e)))));
1170 if (TYPE_PRECISION (TREE_TYPE (TYPE_FIELDS (type)))
1171 == TYPE_PRECISION (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (e)))))
1173 return fold (ffecom_convert_to_complex_ (type, e));
1176 assert ("conversion to non-scalar type requested" == NULL);
1177 return error_mark_node;
1180 /* Like gcc's convert(), but crashes if narrowing might happen. */
1183 ffecom_convert_widen_ (tree type, tree expr)
1185 register tree e = expr;
1186 register enum tree_code code = TREE_CODE (type);
1188 if (type == TREE_TYPE (e)
1189 || TREE_CODE (e) == ERROR_MARK)
1191 if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (e)))
1192 return fold (build1 (NOP_EXPR, type, e));
1193 if (TREE_CODE (TREE_TYPE (e)) == ERROR_MARK
1194 || code == ERROR_MARK)
1195 return error_mark_node;
1196 if (TREE_CODE (TREE_TYPE (e)) == VOID_TYPE)
1198 assert ("void value not ignored as it ought to be" == NULL);
1199 return error_mark_node;
1201 assert (code != VOID_TYPE);
1202 if ((code != RECORD_TYPE)
1203 && (TREE_CODE (TREE_TYPE (e)) == RECORD_TYPE))
1204 assert ("narrowing COMPLEX to REAL" == NULL);
1205 assert (code != ENUMERAL_TYPE);
1206 if (code == INTEGER_TYPE)
1208 assert ((TREE_CODE (TREE_TYPE (e)) == INTEGER_TYPE
1209 && TYPE_PRECISION (type) >= TYPE_PRECISION (TREE_TYPE (e)))
1210 || (TREE_CODE (TREE_TYPE (e)) == POINTER_TYPE
1211 && (TYPE_PRECISION (type)
1212 == TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (e))))));
1213 return fold (convert_to_integer (type, e));
1215 if (code == POINTER_TYPE)
1217 assert (TREE_CODE (TREE_TYPE (e)) == POINTER_TYPE);
1218 return fold (convert_to_pointer (type, e));
1220 if (code == REAL_TYPE)
1222 assert (TREE_CODE (TREE_TYPE (e)) == REAL_TYPE);
1223 assert (TYPE_PRECISION (type) >= TYPE_PRECISION (TREE_TYPE (e)));
1224 return fold (convert_to_real (type, e));
1226 if (code == COMPLEX_TYPE)
1228 assert (TREE_CODE (TREE_TYPE (e)) == COMPLEX_TYPE);
1229 assert (TYPE_PRECISION (TREE_TYPE (type)) >= TYPE_PRECISION (TREE_TYPE (TREE_TYPE (e))));
1230 return fold (convert_to_complex (type, e));
1232 if (code == RECORD_TYPE)
1234 assert (TREE_CODE (TREE_TYPE (e)) == RECORD_TYPE);
1235 /* Check that at least the first field name agrees. */
1236 assert (DECL_NAME (TYPE_FIELDS (type))
1237 == DECL_NAME (TYPE_FIELDS (TREE_TYPE (e))));
1238 assert (TYPE_PRECISION (TREE_TYPE (TYPE_FIELDS (type)))
1239 >= TYPE_PRECISION (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (e)))));
1240 if (TYPE_PRECISION (TREE_TYPE (TYPE_FIELDS (type)))
1241 == TYPE_PRECISION (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (e)))))
1243 return fold (ffecom_convert_to_complex_ (type, e));
1246 assert ("conversion to non-scalar type requested" == NULL);
1247 return error_mark_node;
1250 /* Handles making a COMPLEX type, either the standard
1251 (but buggy?) gbe way, or the safer (but less elegant?)
1255 ffecom_make_complex_type_ (tree subtype)
1261 if (ffe_is_emulate_complex ())
1263 type = make_node (RECORD_TYPE);
1264 realfield = ffecom_decl_field (type, NULL_TREE, "r", subtype);
1265 imagfield = ffecom_decl_field (type, realfield, "i", subtype);
1266 TYPE_FIELDS (type) = realfield;
1271 type = make_node (COMPLEX_TYPE);
1272 TREE_TYPE (type) = subtype;
1279 /* Chooses either the gbe or the f2c way to build a
1280 complex constant. */
1283 ffecom_build_complex_constant_ (tree type, tree realpart, tree imagpart)
1287 if (ffe_is_emulate_complex ())
1289 bothparts = build_tree_list (TYPE_FIELDS (type), realpart);
1290 TREE_CHAIN (bothparts) = build_tree_list (TREE_CHAIN (TYPE_FIELDS (type)), imagpart);
1291 bothparts = build_constructor (type, bothparts);
1295 bothparts = build_complex (type, realpart, imagpart);
1302 ffecom_arglist_expr_ (const char *c, ffebld expr)
1305 tree *plist = &list;
1306 tree trail = NULL_TREE; /* Append char length args here. */
1307 tree *ptrail = &trail;
1312 tree wanted = NULL_TREE;
1313 static const char zed[] = "0";
1318 while (expr != NULL)
1341 wanted = ffecom_f2c_complex_type_node;
1345 wanted = ffecom_f2c_doublereal_type_node;
1349 wanted = ffecom_f2c_doublecomplex_type_node;
1353 wanted = ffecom_f2c_real_type_node;
1357 wanted = ffecom_f2c_integer_type_node;
1361 wanted = ffecom_f2c_longint_type_node;
1365 assert ("bad argstring code" == NULL);
1371 exprh = ffebld_head (expr);
1375 if ((wanted == NULL_TREE)
1378 (ffecom_tree_type[ffeinfo_basictype (ffebld_info (exprh))]
1379 [ffeinfo_kindtype (ffebld_info (exprh))])
1380 == TYPE_MODE (wanted))))
1382 = build_tree_list (NULL_TREE,
1383 ffecom_arg_ptr_to_expr (exprh,
1387 item = ffecom_arg_expr (exprh, &length);
1388 item = ffecom_convert_widen_ (wanted, item);
1391 item = ffecom_1 (ADDR_EXPR,
1392 build_pointer_type (TREE_TYPE (item)),
1396 = build_tree_list (NULL_TREE,
1400 plist = &TREE_CHAIN (*plist);
1401 expr = ffebld_trail (expr);
1402 if (length != NULL_TREE)
1404 *ptrail = build_tree_list (NULL_TREE, length);
1405 ptrail = &TREE_CHAIN (*ptrail);
1409 /* We've run out of args in the call; if the implementation expects
1410 more, supply null pointers for them, which the implementation can
1411 check to see if an arg was omitted. */
1413 while (*c != '\0' && *c != '0')
1418 assert ("missing arg to run-time routine!" == NULL);
1433 assert ("bad arg string code" == NULL);
1437 = build_tree_list (NULL_TREE,
1439 plist = &TREE_CHAIN (*plist);
1448 ffecom_widest_expr_type_ (ffebld list)
1451 ffebld widest = NULL;
1453 ffetype widest_type = NULL;
1456 for (; list != NULL; list = ffebld_trail (list))
1458 item = ffebld_head (list);
1461 if ((widest != NULL)
1462 && (ffeinfo_basictype (ffebld_info (item))
1463 != ffeinfo_basictype (ffebld_info (widest))))
1465 type = ffeinfo_type (ffeinfo_basictype (ffebld_info (item)),
1466 ffeinfo_kindtype (ffebld_info (item)));
1467 if ((widest == FFEINFO_kindtypeNONE)
1468 || (ffetype_size (type)
1469 > ffetype_size (widest_type)))
1476 assert (widest != NULL);
1477 t = ffecom_tree_type[ffeinfo_basictype (ffebld_info (widest))]
1478 [ffeinfo_kindtype (ffebld_info (widest))];
1479 assert (t != NULL_TREE);
1483 /* Check whether a partial overlap between two expressions is possible.
1485 Can *starting* to write a portion of expr1 change the value
1486 computed (perhaps already, *partially*) by expr2?
1488 Currently, this is a concern only for a COMPLEX expr1. But if it
1489 isn't in COMMON or local EQUIVALENCE, since we don't support
1490 aliasing of arguments, it isn't a concern. */
1493 ffecom_possible_partial_overlap_ (ffebld expr1, ffebld expr2 ATTRIBUTE_UNUSED)
1498 switch (ffebld_op (expr1))
1500 case FFEBLD_opSYMTER:
1501 sym = ffebld_symter (expr1);
1504 case FFEBLD_opARRAYREF:
1505 if (ffebld_op (ffebld_left (expr1)) != FFEBLD_opSYMTER)
1507 sym = ffebld_symter (ffebld_left (expr1));
1514 if (ffesymbol_where (sym) != FFEINFO_whereCOMMON
1515 && (ffesymbol_where (sym) != FFEINFO_whereLOCAL
1516 || ! (st = ffesymbol_storage (sym))
1517 || ! ffestorag_parent (st)))
1520 /* It's in COMMON or local EQUIVALENCE. */
1525 /* Check whether dest and source might overlap. ffebld versions of these
1526 might or might not be passed, will be NULL if not.
1528 The test is really whether source_tree is modifiable and, if modified,
1529 might overlap destination such that the value(s) in the destination might
1530 change before it is finally modified. dest_* are the canonized
1531 destination itself. */
1534 ffecom_overlap_ (tree dest_decl, tree dest_offset, tree dest_size,
1535 tree source_tree, ffebld source UNUSED, bool scalar_arg)
1542 if (source_tree == NULL_TREE)
1545 switch (TREE_CODE (source_tree))
1548 case IDENTIFIER_NODE:
1559 case TRUNC_DIV_EXPR:
1561 case FLOOR_DIV_EXPR:
1562 case ROUND_DIV_EXPR:
1563 case TRUNC_MOD_EXPR:
1565 case FLOOR_MOD_EXPR:
1566 case ROUND_MOD_EXPR:
1568 case EXACT_DIV_EXPR:
1569 case FIX_TRUNC_EXPR:
1571 case FIX_FLOOR_EXPR:
1572 case FIX_ROUND_EXPR:
1586 case TRUTH_ANDIF_EXPR:
1587 case TRUTH_ORIF_EXPR:
1588 case TRUTH_AND_EXPR:
1590 case TRUTH_XOR_EXPR:
1591 case TRUTH_NOT_EXPR:
1607 return ffecom_overlap_ (dest_decl, dest_offset, dest_size,
1608 TREE_OPERAND (source_tree, 1), NULL,
1612 return ffecom_overlap_ (dest_decl, dest_offset, dest_size,
1613 TREE_OPERAND (source_tree, 0), NULL,
1618 case NON_LVALUE_EXPR:
1620 if (TREE_CODE (TREE_TYPE (source_tree)) != POINTER_TYPE)
1623 ffecom_tree_canonize_ptr_ (&source_decl, &source_offset,
1625 source_size = TYPE_SIZE (TREE_TYPE (TREE_TYPE (source_tree)));
1630 ffecom_overlap_ (dest_decl, dest_offset, dest_size,
1631 TREE_OPERAND (source_tree, 1), NULL,
1633 || ffecom_overlap_ (dest_decl, dest_offset, dest_size,
1634 TREE_OPERAND (source_tree, 2), NULL,
1639 ffecom_tree_canonize_ref_ (&source_decl, &source_offset,
1641 TREE_OPERAND (source_tree, 0));
1645 if (TREE_CODE (TREE_TYPE (source_tree)) != POINTER_TYPE)
1648 source_decl = source_tree;
1649 source_offset = bitsize_zero_node;
1650 source_size = TYPE_SIZE (TREE_TYPE (TREE_TYPE (source_tree)));
1654 case REFERENCE_EXPR:
1655 case PREDECREMENT_EXPR:
1656 case PREINCREMENT_EXPR:
1657 case POSTDECREMENT_EXPR:
1658 case POSTINCREMENT_EXPR:
1666 /* Come here when source_decl, source_offset, and source_size filled
1667 in appropriately. */
1669 if (source_decl == NULL_TREE)
1670 return FALSE; /* No decl involved, so no overlap. */
1672 if (source_decl != dest_decl)
1673 return FALSE; /* Different decl, no overlap. */
1675 if (TREE_CODE (dest_size) == ERROR_MARK)
1676 return TRUE; /* Assignment into entire assumed-size
1677 array? Shouldn't happen.... */
1679 t = ffecom_2 (LE_EXPR, integer_type_node,
1680 ffecom_2 (PLUS_EXPR, TREE_TYPE (dest_offset),
1682 convert (TREE_TYPE (dest_offset),
1684 convert (TREE_TYPE (dest_offset),
1687 if (integer_onep (t))
1688 return FALSE; /* Destination precedes source. */
1691 || (source_size == NULL_TREE)
1692 || (TREE_CODE (source_size) == ERROR_MARK)
1693 || integer_zerop (source_size))
1694 return TRUE; /* No way to tell if dest follows source. */
1696 t = ffecom_2 (LE_EXPR, integer_type_node,
1697 ffecom_2 (PLUS_EXPR, TREE_TYPE (source_offset),
1699 convert (TREE_TYPE (source_offset),
1701 convert (TREE_TYPE (source_offset),
1704 if (integer_onep (t))
1705 return FALSE; /* Destination follows source. */
1707 return TRUE; /* Destination and source overlap. */
1710 /* Check whether dest might overlap any of a list of arguments or is
1711 in a COMMON area the callee might know about (and thus modify). */
1714 ffecom_args_overlapping_ (tree dest_tree, ffebld dest UNUSED, tree args,
1715 tree callee_commons, bool scalar_args)
1722 ffecom_tree_canonize_ref_ (&dest_decl, &dest_offset, &dest_size,
1725 if (dest_decl == NULL_TREE)
1726 return FALSE; /* Seems unlikely! */
1728 /* If the decl cannot be determined reliably, or if its in COMMON
1729 and the callee isn't known to not futz with COMMON via other
1730 means, overlap might happen. */
1732 if ((TREE_CODE (dest_decl) == ERROR_MARK)
1733 || ((callee_commons != NULL_TREE)
1734 && TREE_PUBLIC (dest_decl)))
1737 for (; args != NULL_TREE; args = TREE_CHAIN (args))
1739 if (((arg = TREE_VALUE (args)) != NULL_TREE)
1740 && ffecom_overlap_ (dest_decl, dest_offset, dest_size,
1741 arg, NULL, scalar_args))
1748 /* Build a string for a variable name as used by NAMELIST. This means that
1749 if we're using the f2c library, we build an uppercase string, since
1753 ffecom_build_f2c_string_ (int i, const char *s)
1755 if (!ffe_is_f2c_library ())
1756 return build_string (i, s);
1765 if (((size_t) i) > ARRAY_SIZE (space))
1766 tmp = malloc_new_ks (malloc_pool_image (), "f2c_string", i);
1770 for (p = s, q = tmp; *p != '\0'; ++p, ++q)
1774 t = build_string (i, tmp);
1776 if (((size_t) i) > ARRAY_SIZE (space))
1777 malloc_kill_ks (malloc_pool_image (), tmp, i);
1783 /* Returns CALL_EXPR or equivalent with given type (pass NULL_TREE for
1784 type to just get whatever the function returns), handling the
1785 f2c value-returning convention, if required, by prepending
1786 to the arglist a pointer to a temporary to receive the return value. */
1789 ffecom_call_ (tree fn, ffeinfoKindtype kt, bool is_f2c_complex, tree type,
1790 tree args, tree dest_tree, ffebld dest, bool *dest_used,
1791 tree callee_commons, bool scalar_args, tree hook)
1796 if (dest_used != NULL)
1801 if ((dest_used == NULL)
1803 || (ffeinfo_basictype (ffebld_info (dest))
1804 != FFEINFO_basictypeCOMPLEX)
1805 || (ffeinfo_kindtype (ffebld_info (dest)) != kt)
1806 || ((type != NULL_TREE) && (TREE_TYPE (dest_tree) != type))
1807 || ffecom_args_overlapping_ (dest_tree, dest, args,
1817 tempvar = dest_tree;
1822 = build_tree_list (NULL_TREE,
1823 ffecom_1 (ADDR_EXPR,
1824 build_pointer_type (TREE_TYPE (tempvar)),
1826 TREE_CHAIN (item) = args;
1828 item = ffecom_3s (CALL_EXPR, TREE_TYPE (TREE_TYPE (TREE_TYPE (fn))), fn,
1831 if (tempvar != dest_tree)
1832 item = ffecom_2 (COMPOUND_EXPR, TREE_TYPE (tempvar), item, tempvar);
1835 item = ffecom_3s (CALL_EXPR, TREE_TYPE (TREE_TYPE (TREE_TYPE (fn))), fn,
1838 if ((type != NULL_TREE) && (TREE_TYPE (item) != type))
1839 item = ffecom_convert_narrow_ (type, item);
1844 /* Given two arguments, transform them and make a call to the given
1845 function via ffecom_call_. */
1848 ffecom_call_binop_ (tree fn, ffeinfoKindtype kt, bool is_f2c_complex,
1849 tree type, ffebld left, ffebld right, tree dest_tree,
1850 ffebld dest, bool *dest_used, tree callee_commons,
1851 bool scalar_args, bool ref, tree hook)
1860 /* Pass arguments by reference. */
1861 left_tree = ffecom_arg_ptr_to_expr (left, &left_length);
1862 right_tree = ffecom_arg_ptr_to_expr (right, &right_length);
1866 /* Pass arguments by value. */
1867 left_tree = ffecom_arg_expr (left, &left_length);
1868 right_tree = ffecom_arg_expr (right, &right_length);
1872 left_tree = build_tree_list (NULL_TREE, left_tree);
1873 right_tree = build_tree_list (NULL_TREE, right_tree);
1874 TREE_CHAIN (left_tree) = right_tree;
1876 if (left_length != NULL_TREE)
1878 left_length = build_tree_list (NULL_TREE, left_length);
1879 TREE_CHAIN (right_tree) = left_length;
1882 if (right_length != NULL_TREE)
1884 right_length = build_tree_list (NULL_TREE, right_length);
1885 if (left_length != NULL_TREE)
1886 TREE_CHAIN (left_length) = right_length;
1888 TREE_CHAIN (right_tree) = right_length;
1891 return ffecom_call_ (fn, kt, is_f2c_complex, type, left_tree,
1892 dest_tree, dest, dest_used, callee_commons,
1896 /* Return ptr/length args for char subexpression
1898 Handles CHARACTER-type CONTER, SYMTER, SUBSTR, ARRAYREF, and FUNCREF
1899 subexpressions by constructing the appropriate trees for the ptr-to-
1900 character-text and length-of-character-text arguments in a calling
1903 Note that if with_null is TRUE, and the expression is an opCONTER,
1904 a null byte is appended to the string. */
1907 ffecom_char_args_x_ (tree *xitem, tree *length, ffebld expr, bool with_null)
1911 ffetargetCharacter1 val;
1912 ffetargetCharacterSize newlen;
1914 switch (ffebld_op (expr))
1916 case FFEBLD_opCONTER:
1917 val = ffebld_constant_character1 (ffebld_conter (expr));
1918 newlen = ffetarget_length_character1 (val);
1921 /* Begin FFETARGET-NULL-KLUDGE. */
1925 *length = build_int_2 (newlen, 0);
1926 TREE_TYPE (*length) = ffecom_f2c_ftnlen_type_node;
1927 high = build_int_2 (newlen, 0);
1928 TREE_TYPE (high) = ffecom_f2c_ftnlen_type_node;
1929 item = build_string (newlen,
1930 ffetarget_text_character1 (val));
1931 /* End FFETARGET-NULL-KLUDGE. */
1933 = build_type_variant
1937 (ffecom_f2c_ftnlen_type_node,
1938 ffecom_f2c_ftnlen_one_node,
1941 TREE_CONSTANT (item) = 1;
1942 TREE_STATIC (item) = 1;
1943 item = ffecom_1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (item)),
1947 case FFEBLD_opSYMTER:
1949 ffesymbol s = ffebld_symter (expr);
1951 item = ffesymbol_hook (s).decl_tree;
1952 if (item == NULL_TREE)
1954 s = ffecom_sym_transform_ (s);
1955 item = ffesymbol_hook (s).decl_tree;
1957 if (ffesymbol_kind (s) == FFEINFO_kindENTITY)
1959 if (ffesymbol_size (s) == FFETARGET_charactersizeNONE)
1960 *length = ffesymbol_hook (s).length_tree;
1963 *length = build_int_2 (ffesymbol_size (s), 0);
1964 TREE_TYPE (*length) = ffecom_f2c_ftnlen_type_node;
1967 else if (item == error_mark_node)
1968 *length = error_mark_node;
1970 /* FFEINFO_kindFUNCTION. */
1971 *length = NULL_TREE;
1972 if (!ffesymbol_hook (s).addr
1973 && (item != error_mark_node))
1974 item = ffecom_1 (ADDR_EXPR,
1975 build_pointer_type (TREE_TYPE (item)),
1980 case FFEBLD_opARRAYREF:
1982 ffecom_char_args_ (&item, length, ffebld_left (expr));
1984 if (item == error_mark_node || *length == error_mark_node)
1986 item = *length = error_mark_node;
1990 item = ffecom_arrayref_ (item, expr, 1);
1994 case FFEBLD_opSUBSTR:
1998 ffebld thing = ffebld_right (expr);
2001 const char *char_name;
2005 assert (ffebld_op (thing) == FFEBLD_opITEM);
2006 start = ffebld_head (thing);
2007 thing = ffebld_trail (thing);
2008 assert (ffebld_trail (thing) == NULL);
2009 end = ffebld_head (thing);
2011 /* Determine name for pretty-printing range-check errors. */
2012 for (left_symter = ffebld_left (expr);
2013 left_symter && ffebld_op (left_symter) == FFEBLD_opARRAYREF;
2014 left_symter = ffebld_left (left_symter))
2016 if (ffebld_op (left_symter) == FFEBLD_opSYMTER)
2017 char_name = ffesymbol_text (ffebld_symter (left_symter));
2019 char_name = "[expr?]";
2021 ffecom_char_args_ (&item, length, ffebld_left (expr));
2023 if (item == error_mark_node || *length == error_mark_node)
2025 item = *length = error_mark_node;
2029 array = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (item)));
2031 /* ~~~~Handle INTEGER*8 start/end, a la FFEBLD_opARRAYREF. */
2039 end_tree = ffecom_expr (end);
2040 if (flag_bounds_check)
2041 end_tree = ffecom_subscript_check_ (array, end_tree, 1, 0,
2042 char_name, NULL_TREE);
2043 end_tree = convert (ffecom_f2c_ftnlen_type_node,
2046 if (end_tree == error_mark_node)
2048 item = *length = error_mark_node;
2057 start_tree = ffecom_expr (start);
2058 if (flag_bounds_check)
2059 start_tree = ffecom_subscript_check_ (array, start_tree, 0, 0,
2060 char_name, NULL_TREE);
2061 start_tree = convert (ffecom_f2c_ftnlen_type_node,
2064 if (start_tree == error_mark_node)
2066 item = *length = error_mark_node;
2070 start_tree = ffecom_save_tree (start_tree);
2072 item = ffecom_2 (PLUS_EXPR, TREE_TYPE (item),
2074 ffecom_2 (MINUS_EXPR,
2075 TREE_TYPE (start_tree),
2077 ffecom_f2c_ftnlen_one_node));
2081 *length = ffecom_2 (PLUS_EXPR, ffecom_f2c_ftnlen_type_node,
2082 ffecom_f2c_ftnlen_one_node,
2083 ffecom_2 (MINUS_EXPR,
2084 ffecom_f2c_ftnlen_type_node,
2090 end_tree = ffecom_expr (end);
2091 if (flag_bounds_check)
2092 end_tree = ffecom_subscript_check_ (array, end_tree, 1, 0,
2093 char_name, NULL_TREE);
2094 end_tree = convert (ffecom_f2c_ftnlen_type_node,
2097 if (end_tree == error_mark_node)
2099 item = *length = error_mark_node;
2103 *length = ffecom_2 (PLUS_EXPR, ffecom_f2c_ftnlen_type_node,
2104 ffecom_f2c_ftnlen_one_node,
2105 ffecom_2 (MINUS_EXPR,
2106 ffecom_f2c_ftnlen_type_node,
2107 end_tree, start_tree));
2113 case FFEBLD_opFUNCREF:
2115 ffesymbol s = ffebld_symter (ffebld_left (expr));
2118 ffetargetCharacterSize size = ffeinfo_size (ffebld_info (expr));
2121 if (size == FFETARGET_charactersizeNONE)
2122 /* ~~Kludge alert! This should someday be fixed. */
2125 *length = build_int_2 (size, 0);
2126 TREE_TYPE (*length) = ffecom_f2c_ftnlen_type_node;
2128 if (ffeinfo_where (ffebld_info (ffebld_left (expr)))
2129 == FFEINFO_whereINTRINSIC)
2133 /* Invocation of an intrinsic returning CHARACTER*1. */
2134 item = ffecom_expr_intrinsic_ (expr, NULL_TREE,
2138 ix = ffeintrin_gfrt_direct (ffebld_symter_implementation (ffebld_left (expr)));
2139 assert (ix != FFECOM_gfrt);
2140 item = ffecom_gfrt_tree_ (ix);
2145 item = ffesymbol_hook (s).decl_tree;
2146 if (item == NULL_TREE)
2148 s = ffecom_sym_transform_ (s);
2149 item = ffesymbol_hook (s).decl_tree;
2151 if (item == error_mark_node)
2153 item = *length = error_mark_node;
2157 if (!ffesymbol_hook (s).addr)
2158 item = ffecom_1_fn (item);
2160 tempvar = ffebld_nonter_hook (expr);
2162 tempvar = ffecom_1 (ADDR_EXPR,
2163 build_pointer_type (TREE_TYPE (tempvar)),
2166 args = build_tree_list (NULL_TREE, tempvar);
2168 if (ffesymbol_where (s) == FFEINFO_whereCONSTANT) /* Sfunc args by value. */
2169 TREE_CHAIN (args) = ffecom_list_expr (ffebld_right (expr));
2172 TREE_CHAIN (args) = build_tree_list (NULL_TREE, *length);
2173 if (ffesymbol_where (s) == FFEINFO_whereINTRINSIC)
2175 TREE_CHAIN (TREE_CHAIN (args))
2176 = ffecom_arglist_expr_ (ffecom_gfrt_args_ (ix),
2177 ffebld_right (expr));
2181 TREE_CHAIN (TREE_CHAIN (args))
2182 = ffecom_list_ptr_to_expr (ffebld_right (expr));
2186 item = ffecom_3s (CALL_EXPR,
2187 TREE_TYPE (TREE_TYPE (TREE_TYPE (item))),
2188 item, args, NULL_TREE);
2189 item = ffecom_2 (COMPOUND_EXPR, TREE_TYPE (tempvar), item,
2194 case FFEBLD_opCONVERT:
2196 ffecom_char_args_ (&item, length, ffebld_left (expr));
2198 if (item == error_mark_node || *length == error_mark_node)
2200 item = *length = error_mark_node;
2204 if ((ffebld_size_known (ffebld_left (expr))
2205 == FFETARGET_charactersizeNONE)
2206 || (ffebld_size_known (ffebld_left (expr)) < (ffebld_size (expr))))
2207 { /* Possible blank-padding needed, copy into
2213 tempvar = ffebld_nonter_hook (expr);
2215 tempvar = ffecom_1 (ADDR_EXPR,
2216 build_pointer_type (TREE_TYPE (tempvar)),
2219 newlen = build_int_2 (ffebld_size (expr), 0);
2220 TREE_TYPE (newlen) = ffecom_f2c_ftnlen_type_node;
2222 args = build_tree_list (NULL_TREE, tempvar);
2223 TREE_CHAIN (args) = build_tree_list (NULL_TREE, item);
2224 TREE_CHAIN (TREE_CHAIN (args)) = build_tree_list (NULL_TREE, newlen);
2225 TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (args)))
2226 = build_tree_list (NULL_TREE, *length);
2228 item = ffecom_call_gfrt (FFECOM_gfrtCOPY, args, NULL_TREE);
2229 TREE_SIDE_EFFECTS (item) = 1;
2230 item = ffecom_2 (COMPOUND_EXPR, TREE_TYPE (tempvar), fold (item),
2235 { /* Just truncate the length. */
2236 *length = build_int_2 (ffebld_size (expr), 0);
2237 TREE_TYPE (*length) = ffecom_f2c_ftnlen_type_node;
2242 assert ("bad op for single char arg expr" == NULL);
2250 /* Check the size of the type to be sure it doesn't overflow the
2251 "portable" capacities of the compiler back end. `dummy' types
2252 can generally overflow the normal sizes as long as the computations
2253 themselves don't overflow. A particular target of the back end
2254 must still enforce its size requirements, though, and the back
2255 end takes care of this in stor-layout.c. */
2258 ffecom_check_size_overflow_ (ffesymbol s, tree type, bool dummy)
2260 if (TREE_CODE (type) == ERROR_MARK)
2263 if (TYPE_SIZE (type) == NULL_TREE)
2266 if (TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
2269 /* An array is too large if size is negative or the type_size overflows
2270 or its "upper half" is larger than 3 (which would make the signed
2271 byte size and offset computations overflow). */
2273 if ((tree_int_cst_sgn (TYPE_SIZE (type)) < 0)
2274 || (!dummy && (TREE_INT_CST_HIGH (TYPE_SIZE (type)) > 3
2275 || TREE_OVERFLOW (TYPE_SIZE (type)))))
2277 ffebad_start (FFEBAD_ARRAY_LARGE);
2278 ffebad_string (ffesymbol_text (s));
2279 ffebad_here (0, ffesymbol_where_line (s), ffesymbol_where_column (s));
2282 return error_mark_node;
2288 /* Builds a length argument (PARM_DECL). Also wraps type in an array type
2289 where the dimension info is (1:size) where <size> is ffesymbol_size(s) if
2290 known, length_arg if not known (FFETARGET_charactersizeNONE). */
2293 ffecom_char_enhance_arg_ (tree *xtype, ffesymbol s)
2295 ffetargetCharacterSize sz = ffesymbol_size (s);
2300 if (ffesymbol_where (s) == FFEINFO_whereCONSTANT)
2301 tlen = NULL_TREE; /* A statement function, no length passed. */
2304 if (ffesymbol_where (s) == FFEINFO_whereDUMMY)
2305 tlen = ffecom_get_invented_identifier ("__g77_length_%s",
2306 ffesymbol_text (s));
2308 tlen = ffecom_get_invented_identifier ("__g77_%s", "length");
2309 tlen = build_decl (PARM_DECL, tlen, ffecom_f2c_ftnlen_type_node);
2310 DECL_ARTIFICIAL (tlen) = 1;
2313 if (sz == FFETARGET_charactersizeNONE)
2315 assert (tlen != NULL_TREE);
2316 highval = variable_size (tlen);
2320 highval = build_int_2 (sz, 0);
2321 TREE_TYPE (highval) = ffecom_f2c_ftnlen_type_node;
2324 type = build_array_type (type,
2325 build_range_type (ffecom_f2c_ftnlen_type_node,
2326 ffecom_f2c_ftnlen_one_node,
2333 /* ffecom_concat_list_gather_ -- Gather list of concatenated string exprs
2335 ffecomConcatList_ catlist;
2336 ffebld expr; // expr of CHARACTER basictype.
2337 ffetargetCharacterSize max; // max chars to gather or _...NONE if no max
2338 catlist = ffecom_concat_list_gather_(catlist,expr,max);
2340 Scans expr for character subexpressions, updates and returns catlist
2343 static ffecomConcatList_
2344 ffecom_concat_list_gather_ (ffecomConcatList_ catlist, ffebld expr,
2345 ffetargetCharacterSize max)
2347 ffetargetCharacterSize sz;
2354 if ((max != FFETARGET_charactersizeNONE) && (catlist.minlen >= max))
2355 return catlist; /* Don't append any more items. */
2357 switch (ffebld_op (expr))
2359 case FFEBLD_opCONTER:
2360 case FFEBLD_opSYMTER:
2361 case FFEBLD_opARRAYREF:
2362 case FFEBLD_opFUNCREF:
2363 case FFEBLD_opSUBSTR:
2364 case FFEBLD_opCONVERT: /* Callers should strip this off beforehand
2365 if they don't need to preserve it. */
2366 if (catlist.count == catlist.max)
2367 { /* Make a (larger) list. */
2371 newmax = (catlist.max == 0) ? 8 : catlist.max * 2;
2372 newx = malloc_new_ks (malloc_pool_image (), "catlist",
2373 newmax * sizeof (newx[0]));
2374 if (catlist.max != 0)
2376 memcpy (newx, catlist.exprs, catlist.max * sizeof (newx[0]));
2377 malloc_kill_ks (malloc_pool_image (), catlist.exprs,
2378 catlist.max * sizeof (newx[0]));
2380 catlist.max = newmax;
2381 catlist.exprs = newx;
2383 if ((sz = ffebld_size_known (expr)) != FFETARGET_charactersizeNONE)
2384 catlist.minlen += sz;
2386 ++catlist.minlen; /* Not true for F90; can be 0 length. */
2387 if ((sz = ffebld_size_max (expr)) == FFETARGET_charactersizeNONE)
2388 catlist.maxlen = sz;
2390 catlist.maxlen += sz;
2391 if ((max != FFETARGET_charactersizeNONE) && (catlist.minlen > max))
2392 { /* This item overlaps (or is beyond) the end
2393 of the destination. */
2394 switch (ffebld_op (expr))
2396 case FFEBLD_opCONTER:
2397 case FFEBLD_opSYMTER:
2398 case FFEBLD_opARRAYREF:
2399 case FFEBLD_opFUNCREF:
2400 case FFEBLD_opSUBSTR:
2401 /* ~~Do useful truncations here. */
2405 assert ("op changed or inconsistent switches!" == NULL);
2409 catlist.exprs[catlist.count++] = expr;
2412 case FFEBLD_opPAREN:
2413 expr = ffebld_left (expr);
2414 goto recurse; /* :::::::::::::::::::: */
2416 case FFEBLD_opCONCATENATE:
2417 catlist = ffecom_concat_list_gather_ (catlist, ffebld_left (expr), max);
2418 expr = ffebld_right (expr);
2419 goto recurse; /* :::::::::::::::::::: */
2421 #if 0 /* Breaks passing small actual arg to larger
2422 dummy arg of sfunc */
2423 case FFEBLD_opCONVERT:
2424 expr = ffebld_left (expr);
2426 ffetargetCharacterSize cmax;
2428 cmax = catlist.len + ffebld_size_known (expr);
2430 if ((max == FFETARGET_charactersizeNONE) || (max > cmax))
2433 goto recurse; /* :::::::::::::::::::: */
2440 assert ("bad op in _gather_" == NULL);
2445 /* ffecom_concat_list_kill_ -- Kill list of concatenated string exprs
2447 ffecomConcatList_ catlist;
2448 ffecom_concat_list_kill_(catlist);
2450 Anything allocated within the list info is deallocated. */
2453 ffecom_concat_list_kill_ (ffecomConcatList_ catlist)
2455 if (catlist.max != 0)
2456 malloc_kill_ks (malloc_pool_image (), catlist.exprs,
2457 catlist.max * sizeof (catlist.exprs[0]));
2460 /* Make list of concatenated string exprs.
2462 Returns a flattened list of concatenated subexpressions given a
2463 tree of such expressions. */
2465 static ffecomConcatList_
2466 ffecom_concat_list_new_ (ffebld expr, ffetargetCharacterSize max)
2468 ffecomConcatList_ catlist;
2470 catlist.maxlen = catlist.minlen = catlist.max = catlist.count = 0;
2471 return ffecom_concat_list_gather_ (catlist, expr, max);
2474 /* Provide some kind of useful info on member of aggregate area,
2475 since current g77/gcc technology does not provide debug info
2476 on these members. */
2479 ffecom_debug_kludge_ (tree aggr, const char *aggr_type, ffesymbol member,
2480 tree member_type UNUSED, ffetargetOffset offset)
2490 for (type_id = member_type;
2491 TREE_CODE (type_id) != IDENTIFIER_NODE;
2494 switch (TREE_CODE (type_id))
2498 type_id = TYPE_NAME (type_id);
2503 type_id = TREE_TYPE (type_id);
2507 assert ("no IDENTIFIER_NODE for type!" == NULL);
2508 type_id = error_mark_node;
2514 if (ffecom_transform_only_dummies_
2515 || !ffe_is_debug_kludge ())
2516 return; /* Can't do this yet, maybe later. */
2519 + strlen (aggr_type)
2520 + IDENTIFIER_LENGTH (DECL_NAME (aggr));
2522 + IDENTIFIER_LENGTH (type_id);
2525 if (((size_t) len) >= ARRAY_SIZE (space))
2526 buff = malloc_new_ks (malloc_pool_image (), "debug_kludge", len + 1);
2530 sprintf (&buff[0], "At (%s) `%s' plus %ld bytes",
2532 IDENTIFIER_POINTER (DECL_NAME (aggr)),
2535 value = build_string (len, buff);
2537 = build_type_variant (build_array_type (char_type_node,
2541 build_int_2 (strlen (buff), 0))),
2543 decl = build_decl (VAR_DECL,
2544 ffecom_get_identifier_ (ffesymbol_text (member)),
2546 TREE_CONSTANT (decl) = 1;
2547 TREE_STATIC (decl) = 1;
2548 DECL_INITIAL (decl) = error_mark_node;
2549 DECL_IN_SYSTEM_HEADER (decl) = 1; /* Don't let -Wunused complain. */
2550 decl = start_decl (decl, FALSE);
2551 finish_decl (decl, value, FALSE);
2553 if (buff != &space[0])
2554 malloc_kill_ks (malloc_pool_image (), buff, len + 1);
2557 /* ffecom_do_entry_ -- Do compilation of a particular entrypoint
2559 ffesymbol fn; // the SUBROUTINE, FUNCTION, or ENTRY symbol itself
2560 int i; // entry# for this entrypoint (used by master fn)
2561 ffecom_do_entrypoint_(s,i);
2563 Makes a public entry point that calls our private master fn (already
2567 ffecom_do_entry_ (ffesymbol fn, int entrynum)
2570 tree type; /* Type of function. */
2571 tree multi_retval; /* Var holding return value (union). */
2572 tree result; /* Var holding result. */
2573 ffeinfoBasictype bt;
2577 bool charfunc; /* All entry points return same type
2579 bool cmplxfunc; /* Use f2c way of returning COMPLEX. */
2580 bool multi; /* Master fn has multiple return types. */
2581 bool altreturning = FALSE; /* This entry point has alternate
2583 location_t old_loc = input_location;
2585 input_filename = ffesymbol_where_filename (fn);
2586 input_line = ffesymbol_where_filelinenum (fn);
2588 ffecom_doing_entry_ = TRUE; /* Don't bother with array dimensions. */
2590 switch (ffecom_primary_entry_kind_)
2592 case FFEINFO_kindFUNCTION:
2594 /* Determine actual return type for function. */
2596 gt = FFEGLOBAL_typeFUNC;
2597 bt = ffesymbol_basictype (fn);
2598 kt = ffesymbol_kindtype (fn);
2599 if (bt == FFEINFO_basictypeNONE)
2601 ffeimplic_establish_symbol (fn);
2602 if (ffesymbol_funcresult (fn) != NULL)
2603 ffeimplic_establish_symbol (ffesymbol_funcresult (fn));
2604 bt = ffesymbol_basictype (fn);
2605 kt = ffesymbol_kindtype (fn);
2608 if (bt == FFEINFO_basictypeCHARACTER)
2609 charfunc = TRUE, cmplxfunc = FALSE;
2610 else if ((bt == FFEINFO_basictypeCOMPLEX)
2611 && ffesymbol_is_f2c (fn))
2612 charfunc = FALSE, cmplxfunc = TRUE;
2614 charfunc = cmplxfunc = FALSE;
2617 type = ffecom_tree_fun_type_void;
2618 else if (ffesymbol_is_f2c (fn))
2619 type = ffecom_tree_fun_type[bt][kt];
2621 type = build_function_type (ffecom_tree_type[bt][kt], NULL_TREE);
2623 if ((type == NULL_TREE)
2624 || (TREE_TYPE (type) == NULL_TREE))
2625 type = ffecom_tree_fun_type_void; /* _sym_exec_transition. */
2627 multi = (ffecom_master_bt_ == FFEINFO_basictypeNONE);
2630 case FFEINFO_kindSUBROUTINE:
2631 gt = FFEGLOBAL_typeSUBR;
2632 bt = FFEINFO_basictypeNONE;
2633 kt = FFEINFO_kindtypeNONE;
2634 if (ffecom_is_altreturning_)
2635 { /* Am _I_ altreturning? */
2636 for (item = ffesymbol_dummyargs (fn);
2638 item = ffebld_trail (item))
2640 if (ffebld_op (ffebld_head (item)) == FFEBLD_opSTAR)
2642 altreturning = TRUE;
2647 type = ffecom_tree_subr_type;
2649 type = ffecom_tree_fun_type_void;
2652 type = ffecom_tree_fun_type_void;
2659 assert ("say what??" == NULL);
2661 case FFEINFO_kindANY:
2662 gt = FFEGLOBAL_typeANY;
2663 bt = FFEINFO_basictypeNONE;
2664 kt = FFEINFO_kindtypeNONE;
2665 type = error_mark_node;
2672 /* build_decl uses the current lineno and input_filename to set the decl
2673 source info. So, I've putzed with ffestd and ffeste code to update that
2674 source info to point to the appropriate statement just before calling
2675 ffecom_do_entrypoint (which calls this fn). */
2677 start_function (ffecom_get_external_identifier_ (fn),
2679 0, /* nested/inline */
2680 1); /* TREE_PUBLIC */
2682 if (((g = ffesymbol_global (fn)) != NULL)
2683 && ((ffeglobal_type (g) == gt)
2684 || (ffeglobal_type (g) == FFEGLOBAL_typeEXT)))
2686 ffeglobal_set_hook (g, current_function_decl);
2689 /* Reset args in master arg list so they get retransitioned. */
2691 for (item = ffecom_master_arglist_;
2693 item = ffebld_trail (item))
2698 arg = ffebld_head (item);
2699 if (ffebld_op (arg) != FFEBLD_opSYMTER)
2700 continue; /* Alternate return or some such thing. */
2701 s = ffebld_symter (arg);
2702 ffesymbol_hook (s).decl_tree = NULL_TREE;
2703 ffesymbol_hook (s).length_tree = NULL_TREE;
2706 /* Build dummy arg list for this entry point. */
2708 if (charfunc || cmplxfunc)
2709 { /* Prepend arg for where result goes. */
2714 type = ffecom_tree_type[FFEINFO_basictypeCHARACTER][kt];
2716 type = ffecom_tree_type[FFEINFO_basictypeCOMPLEX][kt];
2718 result = ffecom_get_invented_identifier ("__g77_%s", "result");
2720 /* Make length arg _and_ enhance type info for CHAR arg itself. */
2723 length = ffecom_char_enhance_arg_ (&type, fn);
2725 length = NULL_TREE; /* Not ref'd if !charfunc. */
2727 type = build_pointer_type (type);
2728 result = build_decl (PARM_DECL, result, type);
2730 push_parm_decl (result);
2731 ffecom_func_result_ = result;
2735 push_parm_decl (length);
2736 ffecom_func_length_ = length;
2740 result = DECL_RESULT (current_function_decl);
2742 ffecom_push_dummy_decls_ (ffesymbol_dummyargs (fn), FALSE);
2744 store_parm_decls (0);
2746 ffecom_start_compstmt ();
2747 /* Disallow temp vars at this level. */
2748 current_binding_level->prep_state = 2;
2750 /* Make local var to hold return type for multi-type master fn. */
2754 multi_retval = ffecom_get_invented_identifier ("__g77_%s",
2756 multi_retval = build_decl (VAR_DECL, multi_retval,
2757 ffecom_multi_type_node_);
2758 multi_retval = start_decl (multi_retval, FALSE);
2759 finish_decl (multi_retval, NULL_TREE, FALSE);
2762 multi_retval = NULL_TREE; /* Not actually ref'd if !multi. */
2764 /* Here we emit the actual code for the entry point. */
2770 tree arglist = NULL_TREE;
2771 tree *plist = &arglist;
2777 /* Prepare actual arg list based on master arg list. */
2779 for (list = ffecom_master_arglist_;
2781 list = ffebld_trail (list))
2783 arg = ffebld_head (list);
2784 if (ffebld_op (arg) != FFEBLD_opSYMTER)
2786 s = ffebld_symter (arg);
2787 if (ffesymbol_hook (s).decl_tree == NULL_TREE
2788 || ffesymbol_hook (s).decl_tree == error_mark_node)
2789 actarg = null_pointer_node; /* We don't have this arg. */
2791 actarg = ffesymbol_hook (s).decl_tree;
2792 *plist = build_tree_list (NULL_TREE, actarg);
2793 plist = &TREE_CHAIN (*plist);
2796 /* This code appends the length arguments for character
2797 variables/arrays. */
2799 for (list = ffecom_master_arglist_;
2801 list = ffebld_trail (list))
2803 arg = ffebld_head (list);
2804 if (ffebld_op (arg) != FFEBLD_opSYMTER)
2806 s = ffebld_symter (arg);
2807 if (ffesymbol_basictype (s) != FFEINFO_basictypeCHARACTER)
2808 continue; /* Only looking for CHARACTER arguments. */
2809 if (ffesymbol_kind (s) != FFEINFO_kindENTITY)
2810 continue; /* Only looking for variables and arrays. */
2811 if (ffesymbol_hook (s).length_tree == NULL_TREE
2812 || ffesymbol_hook (s).length_tree == error_mark_node)
2813 actarg = ffecom_f2c_ftnlen_zero_node; /* We don't have this arg. */
2815 actarg = ffesymbol_hook (s).length_tree;
2816 *plist = build_tree_list (NULL_TREE, actarg);
2817 plist = &TREE_CHAIN (*plist);
2820 /* Prepend character-value return info to actual arg list. */
2824 prepend = build_tree_list (NULL_TREE, ffecom_func_result_);
2825 TREE_CHAIN (prepend)
2826 = build_tree_list (NULL_TREE, ffecom_func_length_);
2827 TREE_CHAIN (TREE_CHAIN (prepend)) = arglist;
2831 /* Prepend multi-type return value to actual arg list. */
2836 = build_tree_list (NULL_TREE,
2837 ffecom_1 (ADDR_EXPR,
2838 build_pointer_type (TREE_TYPE (multi_retval)),
2840 TREE_CHAIN (prepend) = arglist;
2844 /* Prepend my entry-point number to the actual arg list. */
2846 prepend = build_tree_list (NULL_TREE, build_int_2 (entrynum, 0));
2847 TREE_CHAIN (prepend) = arglist;
2850 /* Build the call to the master function. */
2852 master_fn = ffecom_1_fn (ffecom_previous_function_decl_);
2853 call = ffecom_3s (CALL_EXPR,
2854 TREE_TYPE (TREE_TYPE (TREE_TYPE (master_fn))),
2855 master_fn, arglist, NULL_TREE);
2857 /* Decide whether the master function is a function or subroutine, and
2858 handle the return value for my entry point. */
2860 if (charfunc || ((ffecom_primary_entry_kind_ == FFEINFO_kindSUBROUTINE)
2863 expand_expr_stmt (call);
2864 expand_null_return ();
2866 else if (multi && cmplxfunc)
2868 expand_expr_stmt (call);
2870 = ffecom_1 (INDIRECT_REF,
2871 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (result))),
2873 result = ffecom_modify (NULL_TREE, result,
2874 ffecom_2 (COMPONENT_REF, TREE_TYPE (result),
2876 ffecom_multi_fields_[bt][kt]));
2877 expand_expr_stmt (result);
2878 expand_null_return ();
2882 expand_expr_stmt (call);
2884 = ffecom_modify (NULL_TREE, result,
2885 convert (TREE_TYPE (result),
2886 ffecom_2 (COMPONENT_REF,
2887 ffecom_tree_type[bt][kt],
2889 ffecom_multi_fields_[bt][kt])));
2890 expand_return (result);
2895 = ffecom_1 (INDIRECT_REF,
2896 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (result))),
2898 result = ffecom_modify (NULL_TREE, result, call);
2899 expand_expr_stmt (result);
2900 expand_null_return ();
2904 result = ffecom_modify (NULL_TREE,
2906 convert (TREE_TYPE (result),
2908 expand_return (result);
2912 ffecom_end_compstmt ();
2914 finish_function (0);
2916 input_location = old_loc;
2918 ffecom_doing_entry_ = FALSE;
2921 /* Transform expr into gcc tree with possible destination
2923 Recursive descent on expr while making corresponding tree nodes and
2924 attaching type info and such. If destination supplied and compatible
2925 with temporary that would be made in certain cases, temporary isn't
2926 made, destination used instead, and dest_used flag set TRUE. */
2929 ffecom_expr_ (ffebld expr, tree dest_tree, ffebld dest, bool *dest_used,
2930 bool assignp, bool widenp)
2935 ffeinfoBasictype bt;
2938 tree dt; /* decl_tree for an ffesymbol. */
2939 tree tree_type, tree_type_x;
2942 enum tree_code code;
2944 assert (expr != NULL);
2946 if (dest_used != NULL)
2949 bt = ffeinfo_basictype (ffebld_info (expr));
2950 kt = ffeinfo_kindtype (ffebld_info (expr));
2951 tree_type = ffecom_tree_type[bt][kt];
2953 /* Widen integral arithmetic as desired while preserving signedness. */
2954 tree_type_x = NULL_TREE;
2955 if (widenp && tree_type
2956 && GET_MODE_CLASS (TYPE_MODE (tree_type)) == MODE_INT
2957 && TYPE_PRECISION (tree_type) < TYPE_PRECISION (sizetype))
2958 tree_type_x = (TREE_UNSIGNED (tree_type) ? usizetype : ssizetype);
2960 switch (ffebld_op (expr))
2962 case FFEBLD_opACCTER:
2965 ffebit bits = ffebld_accter_bits (expr);
2966 ffetargetOffset source_offset = 0;
2967 ffetargetOffset dest_offset = ffebld_accter_pad (expr);
2970 assert (dest_offset == 0
2971 || (bt == FFEINFO_basictypeCHARACTER
2972 && kt == FFEINFO_kindtypeCHARACTER1));
2977 ffebldConstantUnion cu;
2980 ffebldConstantArray ca = ffebld_accter (expr);
2982 ffebit_test (bits, source_offset, &value, &length);
2988 for (i = 0; i < length; ++i)
2990 cu = ffebld_constantarray_get (ca, bt, kt,
2993 t = ffecom_constantunion (&cu, bt, kt, tree_type);
2996 && dest_offset != 0)
2997 purpose = build_int_2 (dest_offset, 0);
2999 purpose = NULL_TREE;
3001 if (list == NULL_TREE)
3002 list = item = build_tree_list (purpose, t);
3005 TREE_CHAIN (item) = build_tree_list (purpose, t);
3006 item = TREE_CHAIN (item);
3010 source_offset += length;
3011 dest_offset += length;
3015 item = build_int_2 ((ffebld_accter_size (expr)
3016 + ffebld_accter_pad (expr)) - 1, 0);
3017 ffebit_kill (ffebld_accter_bits (expr));
3018 TREE_TYPE (item) = ffecom_integer_type_node;
3022 build_range_type (ffecom_integer_type_node,
3023 ffecom_integer_zero_node,
3025 list = build_constructor (item, list);
3026 TREE_CONSTANT (list) = 1;
3027 TREE_STATIC (list) = 1;
3030 case FFEBLD_opARRTER:
3035 if (ffebld_arrter_pad (expr) == 0)
3039 assert (bt == FFEINFO_basictypeCHARACTER
3040 && kt == FFEINFO_kindtypeCHARACTER1);
3042 /* Becomes PURPOSE first time through loop. */
3043 item = build_int_2 (ffebld_arrter_pad (expr), 0);
3046 for (i = 0; i < ffebld_arrter_size (expr); ++i)
3048 ffebldConstantUnion cu
3049 = ffebld_constantarray_get (ffebld_arrter (expr), bt, kt, i);
3051 t = ffecom_constantunion (&cu, bt, kt, tree_type);
3053 if (list == NULL_TREE)
3054 /* Assume item is PURPOSE first time through loop. */
3055 list = item = build_tree_list (item, t);
3058 TREE_CHAIN (item) = build_tree_list (NULL_TREE, t);
3059 item = TREE_CHAIN (item);
3064 item = build_int_2 ((ffebld_arrter_size (expr)
3065 + ffebld_arrter_pad (expr)) - 1, 0);
3066 TREE_TYPE (item) = ffecom_integer_type_node;
3070 build_range_type (ffecom_integer_type_node,
3071 ffecom_integer_zero_node,
3073 list = build_constructor (item, list);
3074 TREE_CONSTANT (list) = 1;
3075 TREE_STATIC (list) = 1;
3078 case FFEBLD_opCONTER:
3079 assert (ffebld_conter_pad (expr) == 0);
3081 = ffecom_constantunion (&ffebld_constant_union (ffebld_conter (expr)),
3085 case FFEBLD_opSYMTER:
3086 if ((ffebld_symter_generic (expr) != FFEINTRIN_genNONE)
3087 || (ffebld_symter_specific (expr) != FFEINTRIN_specNONE))
3088 return ffecom_ptr_to_expr (expr); /* Same as %REF(intrinsic). */
3089 s = ffebld_symter (expr);
3090 t = ffesymbol_hook (s).decl_tree;
3093 { /* ASSIGN'ed-label expr. */
3094 if (ffe_is_ugly_assign ())
3096 /* User explicitly wants ASSIGN'ed variables to be at the same
3097 memory address as the variables when used in non-ASSIGN
3098 contexts. That can make old, arcane, non-standard code
3099 work, but don't try to do it when a pointer wouldn't fit
3100 in the normal variable (take other approach, and warn,
3105 s = ffecom_sym_transform_ (s);
3106 t = ffesymbol_hook (s).decl_tree;
3107 assert (t != NULL_TREE);
3110 if (t == error_mark_node)
3113 if (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (t)))
3114 >= GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (null_pointer_node))))
3116 if (ffesymbol_hook (s).addr)
3117 t = ffecom_1 (INDIRECT_REF,
3118 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (t))), t);
3122 if (ffesymbol_hook (s).assign_tree == NULL_TREE)
3124 /* xgettext:no-c-format */
3125 ffebad_start_msg ("ASSIGN'ed label cannot fit into `%A' at %0 -- using wider sibling",
3126 FFEBAD_severityWARNING);
3127 ffebad_string (ffesymbol_text (s));
3128 ffebad_here (0, ffesymbol_where_line (s),
3129 ffesymbol_where_column (s));
3134 /* Don't use the normal variable's tree for ASSIGN, though mark
3135 it as in the system header (housekeeping). Use an explicit,
3136 specially created sibling that is known to be wide enough
3137 to hold pointers to labels. */
3140 && TREE_CODE (t) == VAR_DECL)
3141 DECL_IN_SYSTEM_HEADER (t) = 1; /* Don't let -Wunused complain. */
3143 t = ffesymbol_hook (s).assign_tree;
3146 s = ffecom_sym_transform_assign_ (s);
3147 t = ffesymbol_hook (s).assign_tree;
3148 assert (t != NULL_TREE);
3155 s = ffecom_sym_transform_ (s);
3156 t = ffesymbol_hook (s).decl_tree;
3157 assert (t != NULL_TREE);
3159 if (ffesymbol_hook (s).addr)
3160 t = ffecom_1 (INDIRECT_REF,
3161 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (t))), t);
3165 case FFEBLD_opARRAYREF:
3166 return ffecom_arrayref_ (NULL_TREE, expr, 0);
3168 case FFEBLD_opUPLUS:
3169 left = ffecom_expr_ (ffebld_left (expr), NULL, NULL, NULL, FALSE, widenp);
3170 return ffecom_1 (NOP_EXPR, tree_type, left);
3172 case FFEBLD_opPAREN:
3173 /* ~~~Make sure Fortran rules respected here */
3174 left = ffecom_expr_ (ffebld_left (expr), NULL, NULL, NULL, FALSE, widenp);
3175 return ffecom_1 (NOP_EXPR, tree_type, left);
3177 case FFEBLD_opUMINUS:
3178 left = ffecom_expr_ (ffebld_left (expr), NULL, NULL, NULL, FALSE, widenp);
3181 tree_type = tree_type_x;
3182 left = convert (tree_type, left);
3184 return ffecom_1 (NEGATE_EXPR, tree_type, left);
3187 left = ffecom_expr_ (ffebld_left (expr), NULL, NULL, NULL, FALSE, widenp);
3188 right = ffecom_expr_ (ffebld_right (expr), NULL, NULL, NULL, FALSE, widenp);
3191 tree_type = tree_type_x;
3192 left = convert (tree_type, left);
3193 right = convert (tree_type, right);
3195 return ffecom_2 (PLUS_EXPR, tree_type, left, right);
3197 case FFEBLD_opSUBTRACT:
3198 left = ffecom_expr_ (ffebld_left (expr), NULL, NULL, NULL, FALSE, widenp);
3199 right = ffecom_expr_ (ffebld_right (expr), NULL, NULL, NULL, FALSE, widenp);
3202 tree_type = tree_type_x;
3203 left = convert (tree_type, left);
3204 right = convert (tree_type, right);
3206 return ffecom_2 (MINUS_EXPR, tree_type, left, right);
3208 case FFEBLD_opMULTIPLY:
3209 left = ffecom_expr_ (ffebld_left (expr), NULL, NULL, NULL, FALSE, widenp);
3210 right = ffecom_expr_ (ffebld_right (expr), NULL, NULL, NULL, FALSE, widenp);
3213 tree_type = tree_type_x;
3214 left = convert (tree_type, left);
3215 right = convert (tree_type, right);
3217 return ffecom_2 (MULT_EXPR, tree_type, left, right);
3219 case FFEBLD_opDIVIDE:
3220 left = ffecom_expr_ (ffebld_left (expr), NULL, NULL, NULL, FALSE, widenp);
3221 right = ffecom_expr_ (ffebld_right (expr), NULL, NULL, NULL, FALSE, widenp);
3224 tree_type = tree_type_x;
3225 left = convert (tree_type, left);
3226 right = convert (tree_type, right);
3228 return ffecom_tree_divide_ (tree_type, left, right,
3229 dest_tree, dest, dest_used,
3230 ffebld_nonter_hook (expr));
3232 case FFEBLD_opPOWER:
3234 ffebld left = ffebld_left (expr);
3235 ffebld right = ffebld_right (expr);
3237 ffeinfoKindtype rtkt;
3238 ffeinfoKindtype ltkt;
3241 switch (ffeinfo_basictype (ffebld_info (right)))
3244 case FFEINFO_basictypeINTEGER:
3247 item = ffecom_expr_power_integer_ (expr);
3248 if (item != NULL_TREE)
3252 rtkt = FFEINFO_kindtypeINTEGER1;
3253 switch (ffeinfo_basictype (ffebld_info (left)))
3255 case FFEINFO_basictypeINTEGER:
3256 if ((ffeinfo_kindtype (ffebld_info (left))
3257 == FFEINFO_kindtypeINTEGER4)
3258 || (ffeinfo_kindtype (ffebld_info (right))
3259 == FFEINFO_kindtypeINTEGER4))
3261 code = FFECOM_gfrtPOW_QQ;
3262 ltkt = FFEINFO_kindtypeINTEGER4;
3263 rtkt = FFEINFO_kindtypeINTEGER4;
3267 code = FFECOM_gfrtPOW_II;
3268 ltkt = FFEINFO_kindtypeINTEGER1;
3272 case FFEINFO_basictypeREAL:
3273 if (ffeinfo_kindtype (ffebld_info (left))
3274 == FFEINFO_kindtypeREAL1)
3276 code = FFECOM_gfrtPOW_RI;
3277 ltkt = FFEINFO_kindtypeREAL1;
3281 code = FFECOM_gfrtPOW_DI;
3282 ltkt = FFEINFO_kindtypeREAL2;
3286 case FFEINFO_basictypeCOMPLEX:
3287 if (ffeinfo_kindtype (ffebld_info (left))
3288 == FFEINFO_kindtypeREAL1)
3290 code = FFECOM_gfrtPOW_CI; /* Overlapping result okay. */
3291 ltkt = FFEINFO_kindtypeREAL1;
3295 code = FFECOM_gfrtPOW_ZI; /* Overlapping result okay. */
3296 ltkt = FFEINFO_kindtypeREAL2;
3301 assert ("bad pow_*i" == NULL);
3302 code = FFECOM_gfrtPOW_CI; /* Overlapping result okay. */
3303 ltkt = FFEINFO_kindtypeREAL1;
3306 if (ffeinfo_kindtype (ffebld_info (left)) != ltkt)
3307 left = ffeexpr_convert (left, NULL, NULL,
3308 ffeinfo_basictype (ffebld_info (left)),
3310 FFETARGET_charactersizeNONE,
3311 FFEEXPR_contextLET);
3312 if (ffeinfo_kindtype (ffebld_info (right)) != rtkt)
3313 right = ffeexpr_convert (right, NULL, NULL,
3314 FFEINFO_basictypeINTEGER,
3316 FFETARGET_charactersizeNONE,
3317 FFEEXPR_contextLET);
3320 case FFEINFO_basictypeREAL:
3321 if (ffeinfo_kindtype (ffebld_info (left)) == FFEINFO_kindtypeREAL1)
3322 left = ffeexpr_convert (left, NULL, NULL, FFEINFO_basictypeREAL,
3323 FFEINFO_kindtypeREALDOUBLE, 0,
3324 FFETARGET_charactersizeNONE,
3325 FFEEXPR_contextLET);
3326 if (ffeinfo_kindtype (ffebld_info (right))
3327 == FFEINFO_kindtypeREAL1)
3328 right = ffeexpr_convert (right, NULL, NULL,
3329 FFEINFO_basictypeREAL,
3330 FFEINFO_kindtypeREALDOUBLE, 0,
3331 FFETARGET_charactersizeNONE,
3332 FFEEXPR_contextLET);
3333 /* We used to call FFECOM_gfrtPOW_DD here,
3334 which passes arguments by reference. */
3335 code = FFECOM_gfrtL_POW;
3336 /* Pass arguments by value. */
3340 case FFEINFO_basictypeCOMPLEX:
3341 if (ffeinfo_kindtype (ffebld_info (left)) == FFEINFO_kindtypeREAL1)
3342 left = ffeexpr_convert (left, NULL, NULL,
3343 FFEINFO_basictypeCOMPLEX,
3344 FFEINFO_kindtypeREALDOUBLE, 0,
3345 FFETARGET_charactersizeNONE,
3346 FFEEXPR_contextLET);
3347 if (ffeinfo_kindtype (ffebld_info (right))
3348 == FFEINFO_kindtypeREAL1)
3349 right = ffeexpr_convert (right, NULL, NULL,
3350 FFEINFO_basictypeCOMPLEX,
3351 FFEINFO_kindtypeREALDOUBLE, 0,
3352 FFETARGET_charactersizeNONE,
3353 FFEEXPR_contextLET);
3354 code = FFECOM_gfrtPOW_ZZ; /* Overlapping result okay. */
3355 ref = TRUE; /* Pass arguments by reference. */
3359 assert ("bad pow_x*" == NULL);
3360 code = FFECOM_gfrtPOW_II;
3363 return ffecom_call_binop_ (ffecom_gfrt_tree_ (code),
3364 ffecom_gfrt_kindtype (code),
3365 (ffe_is_f2c_library ()
3366 && ffecom_gfrt_complex_[code]),
3367 tree_type, left, right,
3368 dest_tree, dest, dest_used,
3369 NULL_TREE, FALSE, ref,
3370 ffebld_nonter_hook (expr));
3376 case FFEINFO_basictypeLOGICAL:
3377 item = ffecom_truth_value_invert (ffecom_expr (ffebld_left (expr)));
3378 return convert (tree_type, item);
3380 case FFEINFO_basictypeINTEGER:
3381 return ffecom_1 (BIT_NOT_EXPR, tree_type,
3382 ffecom_expr (ffebld_left (expr)));
3385 assert ("NOT bad basictype" == NULL);
3387 case FFEINFO_basictypeANY:
3388 return error_mark_node;
3392 case FFEBLD_opFUNCREF:
3393 assert (ffeinfo_basictype (ffebld_info (expr))
3394 != FFEINFO_basictypeCHARACTER);
3396 case FFEBLD_opSUBRREF:
3397 if (ffeinfo_where (ffebld_info (ffebld_left (expr)))
3398 == FFEINFO_whereINTRINSIC)
3399 { /* Invocation of an intrinsic. */
3400 item = ffecom_expr_intrinsic_ (expr, dest_tree, dest,
3404 s = ffebld_symter (ffebld_left (expr));
3405 dt = ffesymbol_hook (s).decl_tree;
3406 if (dt == NULL_TREE)
3408 s = ffecom_sym_transform_ (s);
3409 dt = ffesymbol_hook (s).decl_tree;
3411 if (dt == error_mark_node)
3414 if (ffesymbol_hook (s).addr)
3417 item = ffecom_1_fn (dt);
3419 if (ffesymbol_where (s) == FFEINFO_whereCONSTANT)
3420 args = ffecom_list_expr (ffebld_right (expr));
3422 args = ffecom_list_ptr_to_expr (ffebld_right (expr));
3424 if (args == error_mark_node)
3425 return error_mark_node;
3427 item = ffecom_call_ (item, kt,
3428 ffesymbol_is_f2c (s)
3429 && (bt == FFEINFO_basictypeCOMPLEX)
3430 && (ffesymbol_where (s)
3431 != FFEINFO_whereCONSTANT),
3434 dest_tree, dest, dest_used,
3435 error_mark_node, FALSE,
3436 ffebld_nonter_hook (expr));
3437 TREE_SIDE_EFFECTS (item) = 1;
3443 case FFEINFO_basictypeLOGICAL:
3445 = ffecom_2 (TRUTH_ANDIF_EXPR, integer_type_node,
3446 ffecom_truth_value (ffecom_expr (ffebld_left (expr))),
3447 ffecom_truth_value (ffecom_expr (ffebld_right (expr))));
3448 return convert (tree_type, item);
3450 case FFEINFO_basictypeINTEGER:
3451 return ffecom_2 (BIT_AND_EXPR, tree_type,
3452 ffecom_expr (ffebld_left (expr)),
3453 ffecom_expr (ffebld_right (expr)));
3456 assert ("AND bad basictype" == NULL);
3458 case FFEINFO_basictypeANY:
3459 return error_mark_node;
3466 case FFEINFO_basictypeLOGICAL:
3468 = ffecom_2 (TRUTH_ORIF_EXPR, integer_type_node,
3469 ffecom_truth_value (ffecom_expr (ffebld_left (expr))),
3470 ffecom_truth_value (ffecom_expr (ffebld_right (expr))));
3471 return convert (tree_type, item);
3473 case FFEINFO_basictypeINTEGER:
3474 return ffecom_2 (BIT_IOR_EXPR, tree_type,
3475 ffecom_expr (ffebld_left (expr)),
3476 ffecom_expr (ffebld_right (expr)));
3479 assert ("OR bad basictype" == NULL);
3481 case FFEINFO_basictypeANY:
3482 return error_mark_node;
3490 case FFEINFO_basictypeLOGICAL:
3492 = ffecom_2 (NE_EXPR, integer_type_node,
3493 ffecom_expr (ffebld_left (expr)),
3494 ffecom_expr (ffebld_right (expr)));
3495 return convert (tree_type, ffecom_truth_value (item));
3497 case FFEINFO_basictypeINTEGER:
3498 return ffecom_2 (BIT_XOR_EXPR, tree_type,
3499 ffecom_expr (ffebld_left (expr)),
3500 ffecom_expr (ffebld_right (expr)));
3503 assert ("XOR/NEQV bad basictype" == NULL);
3505 case FFEINFO_basictypeANY:
3506 return error_mark_node;
3513 case FFEINFO_basictypeLOGICAL:
3515 = ffecom_2 (EQ_EXPR, integer_type_node,
3516 ffecom_expr (ffebld_left (expr)),
3517 ffecom_expr (ffebld_right (expr)));
3518 return convert (tree_type, ffecom_truth_value (item));
3520 case FFEINFO_basictypeINTEGER:
3522 ffecom_1 (BIT_NOT_EXPR, tree_type,
3523 ffecom_2 (BIT_XOR_EXPR, tree_type,
3524 ffecom_expr (ffebld_left (expr)),
3525 ffecom_expr (ffebld_right (expr))));
3528 assert ("EQV bad basictype" == NULL);
3530 case FFEINFO_basictypeANY:
3531 return error_mark_node;
3535 case FFEBLD_opCONVERT:
3536 if (ffebld_op (ffebld_left (expr)) == FFEBLD_opANY)
3537 return error_mark_node;
3541 case FFEINFO_basictypeLOGICAL:
3542 case FFEINFO_basictypeINTEGER:
3543 case FFEINFO_basictypeREAL:
3544 return convert (tree_type, ffecom_expr (ffebld_left (expr)));
3546 case FFEINFO_basictypeCOMPLEX:
3547 switch (ffeinfo_basictype (ffebld_info (ffebld_left (expr))))
3549 case FFEINFO_basictypeINTEGER:
3550 case FFEINFO_basictypeLOGICAL:
3551 case FFEINFO_basictypeREAL:
3552 item = ffecom_expr (ffebld_left (expr));
3553 if (item == error_mark_node)
3554 return error_mark_node;
3555 /* convert() takes care of converting to the subtype first,
3556 at least in gcc-2.7.2. */
3557 item = convert (tree_type, item);
3560 case FFEINFO_basictypeCOMPLEX:
3561 return convert (tree_type, ffecom_expr (ffebld_left (expr)));
3564 assert ("CONVERT COMPLEX bad basictype" == NULL);
3566 case FFEINFO_basictypeANY:
3567 return error_mark_node;
3572 assert ("CONVERT bad basictype" == NULL);
3574 case FFEINFO_basictypeANY:
3575 return error_mark_node;
3581 goto relational; /* :::::::::::::::::::: */
3585 goto relational; /* :::::::::::::::::::: */
3589 goto relational; /* :::::::::::::::::::: */
3593 goto relational; /* :::::::::::::::::::: */
3597 goto relational; /* :::::::::::::::::::: */
3602 relational: /* :::::::::::::::::::: */
3603 switch (ffeinfo_basictype (ffebld_info (ffebld_left (expr))))
3605 case FFEINFO_basictypeLOGICAL:
3606 case FFEINFO_basictypeINTEGER:
3607 case FFEINFO_basictypeREAL:
3608 item = ffecom_2 (code, integer_type_node,
3609 ffecom_expr (ffebld_left (expr)),
3610 ffecom_expr (ffebld_right (expr)));
3611 return convert (tree_type, item);
3613 case FFEINFO_basictypeCOMPLEX:
3614 assert (code == EQ_EXPR || code == NE_EXPR);
3617 tree arg1 = ffecom_expr (ffebld_left (expr));
3618 tree arg2 = ffecom_expr (ffebld_right (expr));
3620 if (arg1 == error_mark_node || arg2 == error_mark_node)
3621 return error_mark_node;
3623 arg1 = ffecom_save_tree (arg1);
3624 arg2 = ffecom_save_tree (arg2);
3626 if (TREE_CODE (TREE_TYPE (arg1)) == COMPLEX_TYPE)
3628 real_type = TREE_TYPE (TREE_TYPE (arg1));
3629 assert (real_type == TREE_TYPE (TREE_TYPE (arg2)));
3633 real_type = TREE_TYPE (TYPE_FIELDS (TREE_TYPE (arg1)));
3634 assert (real_type == TREE_TYPE (TYPE_FIELDS (TREE_TYPE (arg2))));
3638 = ffecom_2 (TRUTH_ANDIF_EXPR, integer_type_node,
3639 ffecom_2 (EQ_EXPR, integer_type_node,
3640 ffecom_1 (REALPART_EXPR, real_type, arg1),
3641 ffecom_1 (REALPART_EXPR, real_type, arg2)),
3642 ffecom_2 (EQ_EXPR, integer_type_node,
3643 ffecom_1 (IMAGPART_EXPR, real_type, arg1),
3644 ffecom_1 (IMAGPART_EXPR, real_type,
3646 if (code == EQ_EXPR)
3647 item = ffecom_truth_value (item);
3649 item = ffecom_truth_value_invert (item);
3650 return convert (tree_type, item);
3653 case FFEINFO_basictypeCHARACTER:
3655 ffebld left = ffebld_left (expr);
3656 ffebld right = ffebld_right (expr);
3662 /* f2c run-time functions do the implicit blank-padding for us,
3663 so we don't usually have to implement blank-padding ourselves.
3664 (The exception is when we pass an argument to a separately
3665 compiled statement function -- if we know the arg is not the
3666 same length as the dummy, we must truncate or extend it. If
3667 we "inline" statement functions, that necessity goes away as
3670 Strip off the CONVERT operators that blank-pad. (Truncation by
3671 CONVERT shouldn't happen here, but it can happen in
3674 while (ffebld_op (left) == FFEBLD_opCONVERT)
3675 left = ffebld_left (left);
3676 while (ffebld_op (right) == FFEBLD_opCONVERT)
3677 right = ffebld_left (right);
3679 left_tree = ffecom_arg_ptr_to_expr (left, &left_length);
3680 right_tree = ffecom_arg_ptr_to_expr (right, &right_length);
3682 if (left_tree == error_mark_node || left_length == error_mark_node
3683 || right_tree == error_mark_node
3684 || right_length == error_mark_node)
3685 return error_mark_node;
3687 if ((ffebld_size_known (left) == 1)
3688 && (ffebld_size_known (right) == 1))
3691 = ffecom_1 (INDIRECT_REF,
3692 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (left_tree))),
3695 = ffecom_1 (INDIRECT_REF,
3696 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (right_tree))),
3700 = ffecom_2 (code, integer_type_node,
3701 ffecom_2 (ARRAY_REF,
3702 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (left_tree))),
3705 ffecom_2 (ARRAY_REF,
3706 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (right_tree))),
3712 item = build_tree_list (NULL_TREE, left_tree);
3713 TREE_CHAIN (item) = build_tree_list (NULL_TREE, right_tree);
3714 TREE_CHAIN (TREE_CHAIN (item)) = build_tree_list (NULL_TREE,
3716 TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (item)))
3717 = build_tree_list (NULL_TREE, right_length);
3718 item = ffecom_call_gfrt (FFECOM_gfrtCMP, item, NULL_TREE);
3719 item = ffecom_2 (code, integer_type_node,
3721 convert (TREE_TYPE (item),
3722 integer_zero_node));
3724 item = convert (tree_type, item);
3730 assert ("relational bad basictype" == NULL);
3732 case FFEINFO_basictypeANY:
3733 return error_mark_node;
3737 case FFEBLD_opPERCENT_LOC:
3738 item = ffecom_arg_ptr_to_expr (ffebld_left (expr), &list);
3739 return convert (tree_type, item);
3741 case FFEBLD_opPERCENT_VAL:
3742 item = ffecom_arg_expr (ffebld_left (expr), &list);
3743 return convert (tree_type, item);
3747 case FFEBLD_opBOUNDS:
3748 case FFEBLD_opREPEAT:
3749 case FFEBLD_opLABTER:
3750 case FFEBLD_opLABTOK:
3751 case FFEBLD_opIMPDO:
3752 case FFEBLD_opCONCATENATE:
3753 case FFEBLD_opSUBSTR:
3755 assert ("bad op" == NULL);
3758 return error_mark_node;
3762 assert ("didn't think anything got here anymore!!" == NULL);
3764 switch (ffebld_arity (expr))
3767 TREE_OPERAND (item, 0) = ffecom_expr (ffebld_left (expr));
3768 TREE_OPERAND (item, 1) = ffecom_expr (ffebld_right (expr));
3769 if (TREE_OPERAND (item, 0) == error_mark_node
3770 || TREE_OPERAND (item, 1) == error_mark_node)
3771 return error_mark_node;
3775 TREE_OPERAND (item, 0) = ffecom_expr (ffebld_left (expr));
3776 if (TREE_OPERAND (item, 0) == error_mark_node)
3777 return error_mark_node;
3788 /* Returns the tree that does the intrinsic invocation.
3790 Note: this function applies only to intrinsics returning
3791 CHARACTER*1 or non-CHARACTER results, and to intrinsic
3795 ffecom_expr_intrinsic_ (ffebld expr, tree dest_tree, ffebld dest,
3799 tree saved_expr1; /* For those who need it. */
3800 tree saved_expr2; /* For those who need it. */
3801 ffeinfoBasictype bt;
3805 tree real_type; /* REAL type corresponding to COMPLEX. */
3807 ffebld list = ffebld_right (expr); /* List of (some) args. */
3808 ffebld arg1; /* For handy reference. */
3811 ffeintrinImp codegen_imp;
3814 assert (ffebld_op (ffebld_left (expr)) == FFEBLD_opSYMTER);
3816 if (dest_used != NULL)
3819 bt = ffeinfo_basictype (ffebld_info (expr));
3820 kt = ffeinfo_kindtype (ffebld_info (expr));
3821 tree_type = ffecom_tree_type[bt][kt];
3825 arg1 = ffebld_head (list);
3826 if (arg1 != NULL && ffebld_op (arg1) == FFEBLD_opANY)
3827 return error_mark_node;
3828 if ((list = ffebld_trail (list)) != NULL)
3830 arg2 = ffebld_head (list);
3831 if (arg2 != NULL && ffebld_op (arg2) == FFEBLD_opANY)
3832 return error_mark_node;
3833 if ((list = ffebld_trail (list)) != NULL)
3835 arg3 = ffebld_head (list);
3836 if (arg3 != NULL && ffebld_op (arg3) == FFEBLD_opANY)
3837 return error_mark_node;
3846 arg1 = arg2 = arg3 = NULL;
3848 /* <list> ends up at the opITEM of the 3rd arg, or NULL if there are < 3
3849 args. This is used by the MAX/MIN expansions. */
3852 arg1_type = ffecom_tree_type
3853 [ffeinfo_basictype (ffebld_info (arg1))]
3854 [ffeinfo_kindtype (ffebld_info (arg1))];
3856 arg1_type = NULL_TREE; /* Really not needed, but might catch bugs
3859 /* There are several ways for each of the cases in the following switch
3860 statements to exit (from simplest to use to most complicated):
3862 break; (when expr_tree == NULL)
3864 A standard call is made to the specific intrinsic just as if it had been
3865 passed in as a dummy procedure and called as any old procedure. This
3866 method can produce slower code but in some cases it's the easiest way for
3867 now. However, if a (presumably faster) direct call is available,
3868 that is used, so this is the easiest way in many more cases now.
3870 gfrt = FFECOM_gfrtWHATEVER;
3873 gfrt contains the gfrt index of a library function to call, passing the
3874 argument(s) by value rather than by reference. Used when a more
3875 careful choice of library function is needed than that provided
3876 by the vanilla `break;'.
3880 The expr_tree has been completely set up and is ready to be returned
3881 as is. No further actions are taken. Use this when the tree is not
3882 in the simple form for one of the arity_n labels. */
3884 /* For info on how the switch statement cases were written, see the files
3885 enclosed in comments below the switch statement. */
3887 codegen_imp = ffebld_symter_implementation (ffebld_left (expr));
3888 gfrt = ffeintrin_gfrt_direct (codegen_imp);
3889 if (gfrt == FFECOM_gfrt)
3890 gfrt = ffeintrin_gfrt_indirect (codegen_imp);
3892 switch (codegen_imp)
3894 case FFEINTRIN_impABS:
3895 case FFEINTRIN_impCABS:
3896 case FFEINTRIN_impCDABS:
3897 case FFEINTRIN_impDABS:
3898 case FFEINTRIN_impIABS:
3899 if (ffeinfo_basictype (ffebld_info (arg1))
3900 == FFEINFO_basictypeCOMPLEX)
3902 if (kt == FFEINFO_kindtypeREAL1)
3903 gfrt = FFECOM_gfrtCABS;
3904 else if (kt == FFEINFO_kindtypeREAL2)
3905 gfrt = FFECOM_gfrtCDABS;
3908 return ffecom_1 (ABS_EXPR, tree_type,
3909 convert (tree_type, ffecom_expr (arg1)));
3911 case FFEINTRIN_impACOS:
3912 case FFEINTRIN_impDACOS:
3915 case FFEINTRIN_impAIMAG:
3916 case FFEINTRIN_impDIMAG:
3917 case FFEINTRIN_impIMAGPART:
3918 if (TREE_CODE (arg1_type) == COMPLEX_TYPE)
3919 arg1_type = TREE_TYPE (arg1_type);
3921 arg1_type = TREE_TYPE (TYPE_FIELDS (arg1_type));
3925 ffecom_1 (IMAGPART_EXPR, arg1_type,
3926 ffecom_expr (arg1)));
3928 case FFEINTRIN_impAINT:
3929 case FFEINTRIN_impDINT:
3931 /* ~~Someday implement FIX_TRUNC_EXPR yielding same type as arg. */
3932 return ffecom_1 (FIX_TRUNC_EXPR, tree_type, ffecom_expr (arg1));
3933 #else /* in the meantime, must use floor to avoid range problems with ints */
3934 /* r__1 = r1 >= 0 ? floor(r1) : -floor(-r1); */
3935 saved_expr1 = ffecom_save_tree (ffecom_expr (arg1));
3938 ffecom_3 (COND_EXPR, double_type_node,
3940 (ffecom_2 (GE_EXPR, integer_type_node,
3943 ffecom_float_zero_))),
3944 ffecom_call_gfrt (FFECOM_gfrtL_FLOOR,
3945 build_tree_list (NULL_TREE,
3946 convert (double_type_node,
3949 ffecom_1 (NEGATE_EXPR, double_type_node,
3950 ffecom_call_gfrt (FFECOM_gfrtL_FLOOR,
3951 build_tree_list (NULL_TREE,
3952 convert (double_type_node,
3953 ffecom_1 (NEGATE_EXPR,
3961 case FFEINTRIN_impANINT:
3962 case FFEINTRIN_impDNINT:
3963 #if 0 /* This way of doing it won't handle real
3964 numbers of large magnitudes. */
3965 saved_expr1 = ffecom_save_tree (ffecom_expr (arg1));
3966 expr_tree = convert (tree_type,
3967 convert (integer_type_node,
3968 ffecom_3 (COND_EXPR, tree_type,
3973 ffecom_float_zero_)),
3974 ffecom_2 (PLUS_EXPR,
3977 ffecom_float_half_),
3978 ffecom_2 (MINUS_EXPR,
3981 ffecom_float_half_))));
3983 #else /* So we instead call floor. */
3984 /* r__1 = r1 >= 0 ? floor(r1 + .5) : -floor(.5 - r1) */
3985 saved_expr1 = ffecom_save_tree (ffecom_expr (arg1));
3988 ffecom_3 (COND_EXPR, double_type_node,
3990 (ffecom_2 (GE_EXPR, integer_type_node,
3993 ffecom_float_zero_))),
3994 ffecom_call_gfrt (FFECOM_gfrtL_FLOOR,
3995 build_tree_list (NULL_TREE,
3996 convert (double_type_node,
3997 ffecom_2 (PLUS_EXPR,
4001 ffecom_float_half_)))),
4003 ffecom_1 (NEGATE_EXPR, double_type_node,
4004 ffecom_call_gfrt (FFECOM_gfrtL_FLOOR,
4005 build_tree_list (NULL_TREE,
4006 convert (double_type_node,
4007 ffecom_2 (MINUS_EXPR,
4010 ffecom_float_half_),
4017 case FFEINTRIN_impASIN:
4018 case FFEINTRIN_impDASIN:
4019 case FFEINTRIN_impATAN:
4020 case FFEINTRIN_impDATAN:
4021 case FFEINTRIN_impATAN2:
4022 case FFEINTRIN_impDATAN2:
4025 case FFEINTRIN_impCHAR:
4026 case FFEINTRIN_impACHAR:
4027 tempvar = ffebld_nonter_hook (expr);
4030 tree tmv = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (tempvar)));
4032 expr_tree = ffecom_modify (tmv,
4033 ffecom_2 (ARRAY_REF, tmv, tempvar,
4035 convert (tmv, ffecom_expr (arg1)));
4037 expr_tree = ffecom_2 (COMPOUND_EXPR, TREE_TYPE (tempvar),
4040 expr_tree = ffecom_1 (ADDR_EXPR,
4041 build_pointer_type (TREE_TYPE (expr_tree)),
4045 case FFEINTRIN_impCMPLX:
4046 case FFEINTRIN_impDCMPLX:
4049 convert (tree_type, ffecom_expr (arg1));
4051 real_type = ffecom_tree_type[FFEINFO_basictypeREAL][kt];
4053 ffecom_2 (COMPLEX_EXPR, tree_type,
4054 convert (real_type, ffecom_expr (arg1)),
4056 ffecom_expr (arg2)));
4058 case FFEINTRIN_impCOMPLEX:
4060 ffecom_2 (COMPLEX_EXPR, tree_type,
4062 ffecom_expr (arg2));
4064 case FFEINTRIN_impCONJG:
4065 case FFEINTRIN_impDCONJG:
4069 real_type = ffecom_tree_type[FFEINFO_basictypeREAL][kt];
4070 arg1_tree = ffecom_save_tree (ffecom_expr (arg1));
4072 ffecom_2 (COMPLEX_EXPR, tree_type,
4073 ffecom_1 (REALPART_EXPR, real_type, arg1_tree),
4074 ffecom_1 (NEGATE_EXPR, real_type,
4075 ffecom_1 (IMAGPART_EXPR, real_type, arg1_tree)));
4078 case FFEINTRIN_impCOS:
4079 case FFEINTRIN_impCCOS:
4080 case FFEINTRIN_impCDCOS:
4081 case FFEINTRIN_impDCOS:
4082 if (bt == FFEINFO_basictypeCOMPLEX)
4084 if (kt == FFEINFO_kindtypeREAL1)
4085 gfrt = FFECOM_gfrtCCOS; /* Overlapping result okay. */
4086 else if (kt == FFEINFO_kindtypeREAL2)
4087 gfrt = FFECOM_gfrtCDCOS; /* Overlapping result okay. */
4091 case FFEINTRIN_impCOSH:
4092 case FFEINTRIN_impDCOSH:
4095 case FFEINTRIN_impDBLE:
4096 case FFEINTRIN_impDFLOAT:
4097 case FFEINTRIN_impDREAL:
4098 case FFEINTRIN_impFLOAT:
4099 case FFEINTRIN_impIDINT:
4100 case FFEINTRIN_impIFIX:
4101 case FFEINTRIN_impINT2:
4102 case FFEINTRIN_impINT8:
4103 case FFEINTRIN_impINT:
4104 case FFEINTRIN_impLONG:
4105 case FFEINTRIN_impREAL:
4106 case FFEINTRIN_impSHORT:
4107 case FFEINTRIN_impSNGL:
4108 return convert (tree_type, ffecom_expr (arg1));
4110 case FFEINTRIN_impDIM:
4111 case FFEINTRIN_impDDIM:
4112 case FFEINTRIN_impIDIM:
4113 saved_expr1 = ffecom_save_tree (convert (tree_type,
4114 ffecom_expr (arg1)));
4115 saved_expr2 = ffecom_save_tree (convert (tree_type,
4116 ffecom_expr (arg2)));
4118 ffecom_3 (COND_EXPR, tree_type,
4120 (ffecom_2 (GT_EXPR, integer_type_node,
4123 ffecom_2 (MINUS_EXPR, tree_type,
4126 convert (tree_type, ffecom_float_zero_));
4128 case FFEINTRIN_impDPROD:
4130 ffecom_2 (MULT_EXPR, tree_type,
4131 convert (tree_type, ffecom_expr (arg1)),
4132 convert (tree_type, ffecom_expr (arg2)));
4134 case FFEINTRIN_impEXP:
4135 case FFEINTRIN_impCDEXP:
4136 case FFEINTRIN_impCEXP:
4137 case FFEINTRIN_impDEXP:
4138 if (bt == FFEINFO_basictypeCOMPLEX)
4140 if (kt == FFEINFO_kindtypeREAL1)
4141 gfrt = FFECOM_gfrtCEXP; /* Overlapping result okay. */
4142 else if (kt == FFEINFO_kindtypeREAL2)
4143 gfrt = FFECOM_gfrtCDEXP; /* Overlapping result okay. */
4147 case FFEINTRIN_impICHAR:
4148 case FFEINTRIN_impIACHAR:
4149 #if 0 /* The simple approach. */
4150 ffecom_char_args_ (&expr_tree, &saved_expr1 /* Ignored */ , arg1);
4152 = ffecom_1 (INDIRECT_REF,
4153 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (expr_tree))),
4156 = ffecom_2 (ARRAY_REF,
4157 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (expr_tree))),
4160 return convert (tree_type, expr_tree);
4161 #else /* The more interesting (and more optimal) approach. */
4162 expr_tree = ffecom_intrinsic_ichar_ (tree_type, arg1, &saved_expr1);
4163 expr_tree = ffecom_3 (COND_EXPR, tree_type,
4166 convert (tree_type, integer_zero_node));
4170 case FFEINTRIN_impINDEX:
4173 case FFEINTRIN_impLEN:
4175 break; /* The simple approach. */
4177 return ffecom_intrinsic_len_ (arg1); /* The more optimal approach. */
4180 case FFEINTRIN_impLGE:
4181 case FFEINTRIN_impLGT:
4182 case FFEINTRIN_impLLE:
4183 case FFEINTRIN_impLLT:
4186 case FFEINTRIN_impLOG:
4187 case FFEINTRIN_impALOG:
4188 case FFEINTRIN_impCDLOG:
4189 case FFEINTRIN_impCLOG:
4190 case FFEINTRIN_impDLOG:
4191 if (bt == FFEINFO_basictypeCOMPLEX)
4193 if (kt == FFEINFO_kindtypeREAL1)
4194 gfrt = FFECOM_gfrtCLOG; /* Overlapping result okay. */
4195 else if (kt == FFEINFO_kindtypeREAL2)
4196 gfrt = FFECOM_gfrtCDLOG; /* Overlapping result okay. */
4200 case FFEINTRIN_impLOG10:
4201 case FFEINTRIN_impALOG10:
4202 case FFEINTRIN_impDLOG10:
4203 if (gfrt != FFECOM_gfrt)
4204 break; /* Already picked one, stick with it. */
4206 if (kt == FFEINFO_kindtypeREAL1)
4207 /* We used to call FFECOM_gfrtALOG10 here. */
4208 gfrt = FFECOM_gfrtL_LOG10;
4209 else if (kt == FFEINFO_kindtypeREAL2)
4210 /* We used to call FFECOM_gfrtDLOG10 here. */
4211 gfrt = FFECOM_gfrtL_LOG10;
4214 case FFEINTRIN_impMAX:
4215 case FFEINTRIN_impAMAX0:
4216 case FFEINTRIN_impAMAX1:
4217 case FFEINTRIN_impDMAX1:
4218 case FFEINTRIN_impMAX0:
4219 case FFEINTRIN_impMAX1:
4220 if (bt != ffeinfo_basictype (ffebld_info (arg1)))
4221 arg1_type = ffecom_widest_expr_type_ (ffebld_right (expr));
4223 arg1_type = tree_type;
4224 expr_tree = ffecom_2 (MAX_EXPR, arg1_type,
4225 convert (arg1_type, ffecom_expr (arg1)),
4226 convert (arg1_type, ffecom_expr (arg2)));
4227 for (; list != NULL; list = ffebld_trail (list))
4229 if ((ffebld_head (list) == NULL)
4230 || (ffebld_op (ffebld_head (list)) == FFEBLD_opANY))
4232 expr_tree = ffecom_2 (MAX_EXPR, arg1_type,
4235 ffecom_expr (ffebld_head (list))));
4237 return convert (tree_type, expr_tree);
4239 case FFEINTRIN_impMIN:
4240 case FFEINTRIN_impAMIN0:
4241 case FFEINTRIN_impAMIN1:
4242 case FFEINTRIN_impDMIN1:
4243 case FFEINTRIN_impMIN0:
4244 case FFEINTRIN_impMIN1:
4245 if (bt != ffeinfo_basictype (ffebld_info (arg1)))
4246 arg1_type = ffecom_widest_expr_type_ (ffebld_right (expr));
4248 arg1_type = tree_type;
4249 expr_tree = ffecom_2 (MIN_EXPR, arg1_type,
4250 convert (arg1_type, ffecom_expr (arg1)),
4251 convert (arg1_type, ffecom_expr (arg2)));
4252 for (; list != NULL; list = ffebld_trail (list))
4254 if ((ffebld_head (list) == NULL)
4255 || (ffebld_op (ffebld_head (list)) == FFEBLD_opANY))
4257 expr_tree = ffecom_2 (MIN_EXPR, arg1_type,
4260 ffecom_expr (ffebld_head (list))));
4262 return convert (tree_type, expr_tree);
4264 case FFEINTRIN_impMOD:
4265 case FFEINTRIN_impAMOD:
4266 case FFEINTRIN_impDMOD:
4267 if (bt != FFEINFO_basictypeREAL)
4268 return ffecom_2 (TRUNC_MOD_EXPR, tree_type,
4269 convert (tree_type, ffecom_expr (arg1)),
4270 convert (tree_type, ffecom_expr (arg2)));
4272 if (kt == FFEINFO_kindtypeREAL1)
4273 /* We used to call FFECOM_gfrtAMOD here. */
4274 gfrt = FFECOM_gfrtL_FMOD;
4275 else if (kt == FFEINFO_kindtypeREAL2)
4276 /* We used to call FFECOM_gfrtDMOD here. */
4277 gfrt = FFECOM_gfrtL_FMOD;
4280 case FFEINTRIN_impNINT:
4281 case FFEINTRIN_impIDNINT:
4283 /* ~~Ideally FIX_ROUND_EXPR would be implemented, but it ain't yet. */
4284 return ffecom_1 (FIX_ROUND_EXPR, tree_type, ffecom_expr (arg1));
4286 /* i__1 = r1 >= 0 ? floor(r1 + .5) : -floor(.5 - r1); */
4287 saved_expr1 = ffecom_save_tree (ffecom_expr (arg1));
4289 convert (ffecom_integer_type_node,
4290 ffecom_3 (COND_EXPR, arg1_type,
4292 (ffecom_2 (GE_EXPR, integer_type_node,
4295 ffecom_float_zero_))),
4296 ffecom_2 (PLUS_EXPR, arg1_type,
4299 ffecom_float_half_)),
4300 ffecom_2 (MINUS_EXPR, arg1_type,
4303 ffecom_float_half_))));
4306 case FFEINTRIN_impSIGN:
4307 case FFEINTRIN_impDSIGN:
4308 case FFEINTRIN_impISIGN:
4310 tree arg2_tree = ffecom_expr (arg2);
4314 (ffecom_1 (ABS_EXPR, tree_type,
4316 ffecom_expr (arg1))));
4318 = ffecom_3 (COND_EXPR, tree_type,
4320 (ffecom_2 (GE_EXPR, integer_type_node,
4322 convert (TREE_TYPE (arg2_tree),
4323 integer_zero_node))),
4325 ffecom_1 (NEGATE_EXPR, tree_type, saved_expr1));
4326 /* Make sure SAVE_EXPRs get referenced early enough. */
4328 = ffecom_2 (COMPOUND_EXPR, tree_type,
4329 convert (void_type_node, saved_expr1),
4334 case FFEINTRIN_impSIN:
4335 case FFEINTRIN_impCDSIN:
4336 case FFEINTRIN_impCSIN:
4337 case FFEINTRIN_impDSIN:
4338 if (bt == FFEINFO_basictypeCOMPLEX)
4340 if (kt == FFEINFO_kindtypeREAL1)
4341 gfrt = FFECOM_gfrtCSIN; /* Overlapping result okay. */
4342 else if (kt == FFEINFO_kindtypeREAL2)
4343 gfrt = FFECOM_gfrtCDSIN; /* Overlapping result okay. */
4347 case FFEINTRIN_impSINH:
4348 case FFEINTRIN_impDSINH:
4351 case FFEINTRIN_impSQRT:
4352 case FFEINTRIN_impCDSQRT:
4353 case FFEINTRIN_impCSQRT:
4354 case FFEINTRIN_impDSQRT:
4355 if (bt == FFEINFO_basictypeCOMPLEX)
4357 if (kt == FFEINFO_kindtypeREAL1)
4358 gfrt = FFECOM_gfrtCSQRT; /* Overlapping result okay. */
4359 else if (kt == FFEINFO_kindtypeREAL2)
4360 gfrt = FFECOM_gfrtCDSQRT; /* Overlapping result okay. */
4364 case FFEINTRIN_impTAN:
4365 case FFEINTRIN_impDTAN:
4366 case FFEINTRIN_impTANH:
4367 case FFEINTRIN_impDTANH:
4370 case FFEINTRIN_impREALPART:
4371 if (TREE_CODE (arg1_type) == COMPLEX_TYPE)
4372 arg1_type = TREE_TYPE (arg1_type);
4374 arg1_type = TREE_TYPE (TYPE_FIELDS (arg1_type));
4378 ffecom_1 (REALPART_EXPR, arg1_type,
4379 ffecom_expr (arg1)));
4381 case FFEINTRIN_impIAND:
4382 case FFEINTRIN_impAND:
4383 return ffecom_2 (BIT_AND_EXPR, tree_type,
4385 ffecom_expr (arg1)),
4387 ffecom_expr (arg2)));
4389 case FFEINTRIN_impIOR:
4390 case FFEINTRIN_impOR:
4391 return ffecom_2 (BIT_IOR_EXPR, tree_type,
4393 ffecom_expr (arg1)),
4395 ffecom_expr (arg2)));
4397 case FFEINTRIN_impIEOR:
4398 case FFEINTRIN_impXOR:
4399 return ffecom_2 (BIT_XOR_EXPR, tree_type,
4401 ffecom_expr (arg1)),
4403 ffecom_expr (arg2)));
4405 case FFEINTRIN_impLSHIFT:
4406 return ffecom_2 (LSHIFT_EXPR, tree_type,
4408 convert (integer_type_node,
4409 ffecom_expr (arg2)));
4411 case FFEINTRIN_impRSHIFT:
4412 return ffecom_2 (RSHIFT_EXPR, tree_type,
4414 convert (integer_type_node,
4415 ffecom_expr (arg2)));
4417 case FFEINTRIN_impNOT:
4418 return ffecom_1 (BIT_NOT_EXPR, tree_type, ffecom_expr (arg1));
4420 case FFEINTRIN_impBIT_SIZE:
4421 return convert (tree_type, TYPE_SIZE (arg1_type));
4423 case FFEINTRIN_impBTEST:
4425 ffetargetLogical1 target_true;
4426 ffetargetLogical1 target_false;
4430 ffetarget_logical1 (&target_true, TRUE);
4431 ffetarget_logical1 (&target_false, FALSE);
4432 if (target_true == 1)
4433 true_tree = convert (tree_type, integer_one_node);
4435 true_tree = convert (tree_type, build_int_2 (target_true, 0));
4436 if (target_false == 0)
4437 false_tree = convert (tree_type, integer_zero_node);
4439 false_tree = convert (tree_type, build_int_2 (target_false, 0));
4442 ffecom_3 (COND_EXPR, tree_type,
4444 (ffecom_2 (EQ_EXPR, integer_type_node,
4445 ffecom_2 (BIT_AND_EXPR, arg1_type,
4447 ffecom_2 (LSHIFT_EXPR, arg1_type,
4450 convert (integer_type_node,
4451 ffecom_expr (arg2)))),
4453 integer_zero_node))),
4458 case FFEINTRIN_impIBCLR:
4460 ffecom_2 (BIT_AND_EXPR, tree_type,
4462 ffecom_1 (BIT_NOT_EXPR, tree_type,
4463 ffecom_2 (LSHIFT_EXPR, tree_type,
4466 convert (integer_type_node,
4467 ffecom_expr (arg2)))));
4469 case FFEINTRIN_impIBITS:
4471 tree arg3_tree = ffecom_save_tree (convert (integer_type_node,
4472 ffecom_expr (arg3)));
4474 = ffecom_tree_type[FFEINFO_basictypeHOLLERITH][kt];
4477 = ffecom_2 (BIT_AND_EXPR, tree_type,
4478 ffecom_2 (RSHIFT_EXPR, tree_type,
4480 convert (integer_type_node,
4481 ffecom_expr (arg2))),
4483 ffecom_2 (RSHIFT_EXPR, uns_type,
4484 ffecom_1 (BIT_NOT_EXPR,
4487 integer_zero_node)),
4488 ffecom_2 (MINUS_EXPR,
4490 TYPE_SIZE (uns_type),
4492 /* Fix up, because the RSHIFT_EXPR above can't shift over TYPE_SIZE. */
4494 = ffecom_3 (COND_EXPR, tree_type,
4496 (ffecom_2 (NE_EXPR, integer_type_node,
4498 integer_zero_node)),
4500 convert (tree_type, integer_zero_node));
4504 case FFEINTRIN_impIBSET:
4506 ffecom_2 (BIT_IOR_EXPR, tree_type,
4508 ffecom_2 (LSHIFT_EXPR, tree_type,
4509 convert (tree_type, integer_one_node),
4510 convert (integer_type_node,
4511 ffecom_expr (arg2))));
4513 case FFEINTRIN_impISHFT:
4515 tree arg1_tree = ffecom_save_tree (ffecom_expr (arg1));
4516 tree arg2_tree = ffecom_save_tree (convert (integer_type_node,
4517 ffecom_expr (arg2)));
4519 = ffecom_tree_type[FFEINFO_basictypeHOLLERITH][kt];
4522 = ffecom_3 (COND_EXPR, tree_type,
4524 (ffecom_2 (GE_EXPR, integer_type_node,
4526 integer_zero_node)),
4527 ffecom_2 (LSHIFT_EXPR, tree_type,
4531 ffecom_2 (RSHIFT_EXPR, uns_type,
4532 convert (uns_type, arg1_tree),
4533 ffecom_1 (NEGATE_EXPR,
4536 /* Fix up, because {L|R}SHIFT_EXPR don't go over TYPE_SIZE bounds. */
4538 = ffecom_3 (COND_EXPR, tree_type,
4540 (ffecom_2 (NE_EXPR, integer_type_node,
4544 TYPE_SIZE (uns_type))),
4546 convert (tree_type, integer_zero_node));
4547 /* Make sure SAVE_EXPRs get referenced early enough. */
4549 = ffecom_2 (COMPOUND_EXPR, tree_type,
4550 convert (void_type_node, arg1_tree),
4551 ffecom_2 (COMPOUND_EXPR, tree_type,
4552 convert (void_type_node, arg2_tree),
4557 case FFEINTRIN_impISHFTC:
4559 tree arg1_tree = ffecom_save_tree (ffecom_expr (arg1));
4560 tree arg2_tree = ffecom_save_tree (convert (integer_type_node,
4561 ffecom_expr (arg2)));
4562 tree arg3_tree = (arg3 == NULL) ? TYPE_SIZE (tree_type)
4563 : ffecom_save_tree (convert (integer_type_node, ffecom_expr (arg3)));
4569 = ffecom_tree_type[FFEINFO_basictypeHOLLERITH][kt];
4572 = ffecom_2 (LSHIFT_EXPR, tree_type,
4573 ffecom_1 (BIT_NOT_EXPR, tree_type,
4574 convert (tree_type, integer_zero_node)),
4576 /* Fix up, because LSHIFT_EXPR above can't shift over TYPE_SIZE. */
4578 = ffecom_3 (COND_EXPR, tree_type,
4580 (ffecom_2 (NE_EXPR, integer_type_node,
4582 TYPE_SIZE (uns_type))),
4584 convert (tree_type, integer_zero_node));
4585 mask_arg1 = ffecom_save_tree (mask_arg1);
4587 = ffecom_2 (BIT_AND_EXPR, tree_type,
4589 ffecom_1 (BIT_NOT_EXPR, tree_type,
4591 masked_arg1 = ffecom_save_tree (masked_arg1);
4593 = ffecom_2 (BIT_IOR_EXPR, tree_type,
4595 ffecom_2 (RSHIFT_EXPR, uns_type,
4596 convert (uns_type, masked_arg1),
4597 ffecom_1 (NEGATE_EXPR,
4600 ffecom_2 (LSHIFT_EXPR, tree_type,
4602 ffecom_2 (PLUS_EXPR, integer_type_node,
4606 = ffecom_2 (BIT_IOR_EXPR, tree_type,
4607 ffecom_2 (LSHIFT_EXPR, tree_type,
4611 ffecom_2 (RSHIFT_EXPR, uns_type,
4612 convert (uns_type, masked_arg1),
4613 ffecom_2 (MINUS_EXPR,
4618 = ffecom_3 (COND_EXPR, tree_type,
4620 (ffecom_2 (LT_EXPR, integer_type_node,
4622 integer_zero_node)),
4626 = ffecom_2 (BIT_IOR_EXPR, tree_type,
4627 ffecom_2 (BIT_AND_EXPR, tree_type,
4630 ffecom_2 (BIT_AND_EXPR, tree_type,
4631 ffecom_1 (BIT_NOT_EXPR, tree_type,
4635 = ffecom_3 (COND_EXPR, tree_type,
4637 (ffecom_2 (TRUTH_ORIF_EXPR, integer_type_node,
4638 ffecom_2 (EQ_EXPR, integer_type_node,
4643 ffecom_2 (EQ_EXPR, integer_type_node,
4645 integer_zero_node))),
4648 /* Make sure SAVE_EXPRs get referenced early enough. */
4650 = ffecom_2 (COMPOUND_EXPR, tree_type,
4651 convert (void_type_node, arg1_tree),
4652 ffecom_2 (COMPOUND_EXPR, tree_type,
4653 convert (void_type_node, arg2_tree),
4654 ffecom_2 (COMPOUND_EXPR, tree_type,
4655 convert (void_type_node,
4657 ffecom_2 (COMPOUND_EXPR, tree_type,
4658 convert (void_type_node,
4662 = ffecom_2 (COMPOUND_EXPR, tree_type,
4663 convert (void_type_node,
4669 case FFEINTRIN_impLOC:
4671 tree arg1_tree = ffecom_expr (arg1);
4674 = convert (tree_type,
4675 ffecom_1 (ADDR_EXPR,
4676 build_pointer_type (TREE_TYPE (arg1_tree)),
4681 case FFEINTRIN_impMVBITS:
4686 ffebld arg4 = ffebld_head (ffebld_trail (list));
4689 ffebld arg5 = ffebld_head (ffebld_trail (ffebld_trail (list)));
4693 tree arg5_plus_arg3;
4695 arg2_tree = convert (integer_type_node,
4696 ffecom_expr (arg2));
4697 arg3_tree = ffecom_save_tree (convert (integer_type_node,
4698 ffecom_expr (arg3)));
4699 arg4_tree = ffecom_expr_rw (NULL_TREE, arg4);
4700 arg4_type = TREE_TYPE (arg4_tree);
4702 arg1_tree = ffecom_save_tree (convert (arg4_type,
4703 ffecom_expr (arg1)));
4705 arg5_tree = ffecom_save_tree (convert (integer_type_node,
4706 ffecom_expr (arg5)));
4709 = ffecom_2 (LSHIFT_EXPR, arg4_type,
4710 ffecom_2 (BIT_AND_EXPR, arg4_type,
4711 ffecom_2 (RSHIFT_EXPR, arg4_type,
4714 ffecom_1 (BIT_NOT_EXPR, arg4_type,
4715 ffecom_2 (LSHIFT_EXPR, arg4_type,
4716 ffecom_1 (BIT_NOT_EXPR,
4720 integer_zero_node)),
4724 = ffecom_save_tree (ffecom_2 (PLUS_EXPR, arg4_type,
4728 = ffecom_2 (LSHIFT_EXPR, arg4_type,
4729 ffecom_1 (BIT_NOT_EXPR, arg4_type,
4731 integer_zero_node)),
4733 /* Fix up, because LSHIFT_EXPR above can't shift over TYPE_SIZE. */
4735 = ffecom_3 (COND_EXPR, arg4_type,
4737 (ffecom_2 (NE_EXPR, integer_type_node,
4739 convert (TREE_TYPE (arg5_plus_arg3),
4740 TYPE_SIZE (arg4_type)))),
4742 convert (arg4_type, integer_zero_node));
4744 = ffecom_2 (BIT_AND_EXPR, arg4_type,
4746 ffecom_2 (BIT_IOR_EXPR, arg4_type,
4748 ffecom_1 (BIT_NOT_EXPR, arg4_type,
4749 ffecom_2 (LSHIFT_EXPR, arg4_type,
4750 ffecom_1 (BIT_NOT_EXPR,
4754 integer_zero_node)),
4757 = ffecom_2 (BIT_IOR_EXPR, arg4_type,
4760 /* Fix up (twice), because LSHIFT_EXPR above
4761 can't shift over TYPE_SIZE. */
4763 = ffecom_3 (COND_EXPR, arg4_type,
4765 (ffecom_2 (NE_EXPR, integer_type_node,
4767 convert (TREE_TYPE (arg3_tree),
4768 integer_zero_node))),
4772 = ffecom_3 (COND_EXPR, arg4_type,
4774 (ffecom_2 (NE_EXPR, integer_type_node,
4776 convert (TREE_TYPE (arg3_tree),
4777 TYPE_SIZE (arg4_type)))),
4781 = ffecom_2s (MODIFY_EXPR, void_type_node,
4784 /* Make sure SAVE_EXPRs get referenced early enough. */
4786 = ffecom_2 (COMPOUND_EXPR, void_type_node,
4788 ffecom_2 (COMPOUND_EXPR, void_type_node,
4790 ffecom_2 (COMPOUND_EXPR, void_type_node,
4792 ffecom_2 (COMPOUND_EXPR, void_type_node,
4796 = ffecom_2 (COMPOUND_EXPR, void_type_node,
4803 case FFEINTRIN_impDERF:
4804 case FFEINTRIN_impERF:
4805 case FFEINTRIN_impDERFC:
4806 case FFEINTRIN_impERFC:
4809 case FFEINTRIN_impIARGC:
4810 /* extern int xargc; i__1 = xargc - 1; */
4811 expr_tree = ffecom_2 (MINUS_EXPR, TREE_TYPE (ffecom_tree_xargc_),
4813 convert (TREE_TYPE (ffecom_tree_xargc_),
4817 case FFEINTRIN_impSIGNAL_func:
4818 case FFEINTRIN_impSIGNAL_subr:
4824 arg1_tree = convert (ffecom_f2c_integer_type_node,
4825 ffecom_expr (arg1));
4826 arg1_tree = ffecom_1 (ADDR_EXPR,
4827 build_pointer_type (TREE_TYPE (arg1_tree)),
4830 /* Pass procedure as a pointer to it, anything else by value. */
4831 if (ffeinfo_kind (ffebld_info (arg2)) == FFEINFO_kindENTITY)
4832 arg2_tree = convert (integer_type_node, ffecom_expr (arg2));
4834 arg2_tree = ffecom_ptr_to_expr (arg2);
4835 arg2_tree = convert (TREE_TYPE (null_pointer_node),
4839 arg3_tree = ffecom_expr_w (NULL_TREE, arg3);
4841 arg3_tree = NULL_TREE;
4843 arg1_tree = build_tree_list (NULL_TREE, arg1_tree);
4844 arg2_tree = build_tree_list (NULL_TREE, arg2_tree);
4845 TREE_CHAIN (arg1_tree) = arg2_tree;
4848 = ffecom_call_ (ffecom_gfrt_tree_ (gfrt),
4849 ffecom_gfrt_kindtype (gfrt),
4851 ((codegen_imp == FFEINTRIN_impSIGNAL_subr) ?
4855 NULL_TREE, NULL, NULL, NULL_TREE, TRUE,
4856 ffebld_nonter_hook (expr));
4858 if (arg3_tree != NULL_TREE)
4860 = ffecom_modify (NULL_TREE, arg3_tree,
4861 convert (TREE_TYPE (arg3_tree),
4866 case FFEINTRIN_impALARM:
4872 arg1_tree = convert (ffecom_f2c_integer_type_node,
4873 ffecom_expr (arg1));
4874 arg1_tree = ffecom_1 (ADDR_EXPR,
4875 build_pointer_type (TREE_TYPE (arg1_tree)),
4878 /* Pass procedure as a pointer to it, anything else by value. */
4879 if (ffeinfo_kind (ffebld_info (arg2)) == FFEINFO_kindENTITY)
4880 arg2_tree = convert (integer_type_node, ffecom_expr (arg2));
4882 arg2_tree = ffecom_ptr_to_expr (arg2);
4883 arg2_tree = convert (TREE_TYPE (null_pointer_node),
4887 arg3_tree = ffecom_expr_w (NULL_TREE, arg3);
4889 arg3_tree = NULL_TREE;
4891 arg1_tree = build_tree_list (NULL_TREE, arg1_tree);
4892 arg2_tree = build_tree_list (NULL_TREE, arg2_tree);
4893 TREE_CHAIN (arg1_tree) = arg2_tree;
4896 = ffecom_call_ (ffecom_gfrt_tree_ (gfrt),
4897 ffecom_gfrt_kindtype (gfrt),
4901 NULL_TREE, NULL, NULL, NULL_TREE, TRUE,
4902 ffebld_nonter_hook (expr));
4904 if (arg3_tree != NULL_TREE)
4906 = ffecom_modify (NULL_TREE, arg3_tree,
4907 convert (TREE_TYPE (arg3_tree),
4912 case FFEINTRIN_impCHDIR_subr:
4913 case FFEINTRIN_impFDATE_subr:
4914 case FFEINTRIN_impFGET_subr:
4915 case FFEINTRIN_impFPUT_subr:
4916 case FFEINTRIN_impGETCWD_subr:
4917 case FFEINTRIN_impHOSTNM_subr:
4918 case FFEINTRIN_impSYSTEM_subr:
4919 case FFEINTRIN_impUNLINK_subr:
4921 tree arg1_len = integer_zero_node;
4925 arg1_tree = ffecom_arg_ptr_to_expr (arg1, &arg1_len);
4928 arg2_tree = ffecom_expr_w (NULL_TREE, arg2);
4930 arg2_tree = NULL_TREE;
4932 arg1_tree = build_tree_list (NULL_TREE, arg1_tree);
4933 arg1_len = build_tree_list (NULL_TREE, arg1_len);
4934 TREE_CHAIN (arg1_tree) = arg1_len;
4937 = ffecom_call_ (ffecom_gfrt_tree_ (gfrt),
4938 ffecom_gfrt_kindtype (gfrt),
4942 NULL_TREE, NULL, NULL, NULL_TREE, TRUE,
4943 ffebld_nonter_hook (expr));
4945 if (arg2_tree != NULL_TREE)
4947 = ffecom_modify (NULL_TREE, arg2_tree,
4948 convert (TREE_TYPE (arg2_tree),
4953 case FFEINTRIN_impEXIT:
4957 expr_tree = build_tree_list (NULL_TREE,
4958 ffecom_1 (ADDR_EXPR,
4960 (ffecom_integer_type_node),
4961 integer_zero_node));
4964 ffecom_call_ (ffecom_gfrt_tree_ (gfrt),
4965 ffecom_gfrt_kindtype (gfrt),
4969 NULL_TREE, NULL, NULL, NULL_TREE, TRUE,
4970 ffebld_nonter_hook (expr));
4972 case FFEINTRIN_impFLUSH:
4974 gfrt = FFECOM_gfrtFLUSH;
4976 gfrt = FFECOM_gfrtFLUSH1;
4979 case FFEINTRIN_impCHMOD_subr:
4980 case FFEINTRIN_impLINK_subr:
4981 case FFEINTRIN_impRENAME_subr:
4982 case FFEINTRIN_impSYMLNK_subr:
4984 tree arg1_len = integer_zero_node;
4986 tree arg2_len = integer_zero_node;
4990 arg1_tree = ffecom_arg_ptr_to_expr (arg1, &arg1_len);
4991 arg2_tree = ffecom_arg_ptr_to_expr (arg2, &arg2_len);
4993 arg3_tree = ffecom_expr_w (NULL_TREE, arg3);
4995 arg3_tree = NULL_TREE;
4997 arg1_tree = build_tree_list (NULL_TREE, arg1_tree);
4998 arg1_len = build_tree_list (NULL_TREE, arg1_len);
4999 arg2_tree = build_tree_list (NULL_TREE, arg2_tree);
5000 arg2_len = build_tree_list (NULL_TREE, arg2_len);
5001 TREE_CHAIN (arg1_tree) = arg2_tree;
5002 TREE_CHAIN (arg2_tree) = arg1_len;
5003 TREE_CHAIN (arg1_len) = arg2_len;
5004 expr_tree = ffecom_call_ (ffecom_gfrt_tree_ (gfrt),
5005 ffecom_gfrt_kindtype (gfrt),
5009 NULL_TREE, NULL, NULL, NULL_TREE, TRUE,
5010 ffebld_nonter_hook (expr));
5011 if (arg3_tree != NULL_TREE)
5012 expr_tree = ffecom_modify (NULL_TREE, arg3_tree,
5013 convert (TREE_TYPE (arg3_tree),
5018 case FFEINTRIN_impLSTAT_subr:
5019 case FFEINTRIN_impSTAT_subr:
5021 tree arg1_len = integer_zero_node;
5026 arg1_tree = ffecom_arg_ptr_to_expr (arg1, &arg1_len);
5028 arg2_tree = ffecom_ptr_to_expr (arg2);
5031 arg3_tree = ffecom_expr_w (NULL_TREE, arg3);
5033 arg3_tree = NULL_TREE;
5035 arg1_tree = build_tree_list (NULL_TREE, arg1_tree);
5036 arg1_len = build_tree_list (NULL_TREE, arg1_len);
5037 arg2_tree = build_tree_list (NULL_TREE, arg2_tree);
5038 TREE_CHAIN (arg1_tree) = arg2_tree;
5039 TREE_CHAIN (arg2_tree) = arg1_len;
5040 expr_tree = ffecom_call_ (ffecom_gfrt_tree_ (gfrt),
5041 ffecom_gfrt_kindtype (gfrt),
5045 NULL_TREE, NULL, NULL, NULL_TREE, TRUE,
5046 ffebld_nonter_hook (expr));
5047 if (arg3_tree != NULL_TREE)
5048 expr_tree = ffecom_modify (NULL_TREE, arg3_tree,
5049 convert (TREE_TYPE (arg3_tree),
5054 case FFEINTRIN_impFGETC_subr:
5055 case FFEINTRIN_impFPUTC_subr:
5059 tree arg2_len = integer_zero_node;
5062 arg1_tree = convert (ffecom_f2c_integer_type_node,
5063 ffecom_expr (arg1));
5064 arg1_tree = ffecom_1 (ADDR_EXPR,
5065 build_pointer_type (TREE_TYPE (arg1_tree)),
5068 arg2_tree = ffecom_arg_ptr_to_expr (arg2, &arg2_len);
5070 arg3_tree = ffecom_expr_w (NULL_TREE, arg3);
5072 arg3_tree = NULL_TREE;
5074 arg1_tree = build_tree_list (NULL_TREE, arg1_tree);
5075 arg2_tree = build_tree_list (NULL_TREE, arg2_tree);
5076 arg2_len = build_tree_list (NULL_TREE, arg2_len);
5077 TREE_CHAIN (arg1_tree) = arg2_tree;
5078 TREE_CHAIN (arg2_tree) = arg2_len;
5080 expr_tree = ffecom_call_ (ffecom_gfrt_tree_ (gfrt),
5081 ffecom_gfrt_kindtype (gfrt),
5085 NULL_TREE, NULL, NULL, NULL_TREE, TRUE,
5086 ffebld_nonter_hook (expr));
5087 if (arg3_tree != NULL_TREE)
5088 expr_tree = ffecom_modify (NULL_TREE, arg3_tree,
5089 convert (TREE_TYPE (arg3_tree),
5094 case FFEINTRIN_impFSTAT_subr:
5100 arg1_tree = convert (ffecom_f2c_integer_type_node,
5101 ffecom_expr (arg1));
5102 arg1_tree = ffecom_1 (ADDR_EXPR,
5103 build_pointer_type (TREE_TYPE (arg1_tree)),
5106 arg2_tree = convert (ffecom_f2c_ptr_to_integer_type_node,
5107 ffecom_ptr_to_expr (arg2));
5110 arg3_tree = NULL_TREE;
5112 arg3_tree = ffecom_expr_w (NULL_TREE, arg3);
5114 arg1_tree = build_tree_list (NULL_TREE, arg1_tree);
5115 arg2_tree = build_tree_list (NULL_TREE, arg2_tree);
5116 TREE_CHAIN (arg1_tree) = arg2_tree;
5117 expr_tree = ffecom_call_ (ffecom_gfrt_tree_ (gfrt),
5118 ffecom_gfrt_kindtype (gfrt),
5122 NULL_TREE, NULL, NULL, NULL_TREE, TRUE,
5123 ffebld_nonter_hook (expr));
5124 if (arg3_tree != NULL_TREE) {
5125 expr_tree = ffecom_modify (NULL_TREE, arg3_tree,
5126 convert (TREE_TYPE (arg3_tree),
5132 case FFEINTRIN_impKILL_subr:
5138 arg1_tree = convert (ffecom_f2c_integer_type_node,
5139 ffecom_expr (arg1));
5140 arg1_tree = ffecom_1 (ADDR_EXPR,
5141 build_pointer_type (TREE_TYPE (arg1_tree)),
5144 arg2_tree = convert (ffecom_f2c_integer_type_node,
5145 ffecom_expr (arg2));
5146 arg2_tree = ffecom_1 (ADDR_EXPR,
5147 build_pointer_type (TREE_TYPE (arg2_tree)),
5151 arg3_tree = NULL_TREE;
5153 arg3_tree = ffecom_expr_w (NULL_TREE, arg3);
5155 arg1_tree = build_tree_list (NULL_TREE, arg1_tree);
5156 arg2_tree = build_tree_list (NULL_TREE, arg2_tree);
5157 TREE_CHAIN (arg1_tree) = arg2_tree;
5158 expr_tree = ffecom_call_ (ffecom_gfrt_tree_ (gfrt),
5159 ffecom_gfrt_kindtype (gfrt),
5163 NULL_TREE, NULL, NULL, NULL_TREE, TRUE,
5164 ffebld_nonter_hook (expr));
5165 if (arg3_tree != NULL_TREE) {
5166 expr_tree = ffecom_modify (NULL_TREE, arg3_tree,
5167 convert (TREE_TYPE (arg3_tree),
5173 case FFEINTRIN_impCTIME_subr:
5174 case FFEINTRIN_impTTYNAM_subr:
5176 tree arg1_len = integer_zero_node;
5180 arg1_tree = ffecom_arg_ptr_to_expr (arg2, &arg1_len);
5182 arg2_tree = convert (((codegen_imp == FFEINTRIN_impCTIME_subr) ?
5183 ffecom_f2c_longint_type_node :
5184 ffecom_f2c_integer_type_node),
5185 ffecom_expr (arg1));
5186 arg2_tree = ffecom_1 (ADDR_EXPR,
5187 build_pointer_type (TREE_TYPE (arg2_tree)),
5190 arg1_tree = build_tree_list (NULL_TREE, arg1_tree);
5191 arg1_len = build_tree_list (NULL_TREE, arg1_len);
5192 arg2_tree = build_tree_list (NULL_TREE, arg2_tree);
5193 TREE_CHAIN (arg1_len) = arg2_tree;
5194 TREE_CHAIN (arg1_tree) = arg1_len;
5197 = ffecom_call_ (ffecom_gfrt_tree_ (gfrt),
5198 ffecom_gfrt_kindtype (gfrt),
5202 NULL_TREE, NULL, NULL, NULL_TREE, TRUE,
5203 ffebld_nonter_hook (expr));
5204 TREE_SIDE_EFFECTS (expr_tree) = 1;
5208 case FFEINTRIN_impIRAND:
5209 case FFEINTRIN_impRAND:
5210 /* Arg defaults to 0 (normal random case) */
5215 arg1_tree = ffecom_integer_zero_node;
5217 arg1_tree = ffecom_expr (arg1);
5218 arg1_tree = convert (ffecom_f2c_integer_type_node,
5220 arg1_tree = ffecom_1 (ADDR_EXPR,
5221 build_pointer_type (TREE_TYPE (arg1_tree)),
5223 arg1_tree = build_tree_list (NULL_TREE, arg1_tree);
5225 expr_tree = ffecom_call_ (ffecom_gfrt_tree_ (gfrt),
5226 ffecom_gfrt_kindtype (gfrt),
5228 ((codegen_imp == FFEINTRIN_impIRAND) ?
5229 ffecom_f2c_integer_type_node :
5230 ffecom_f2c_real_type_node),
5232 dest_tree, dest, dest_used,
5234 ffebld_nonter_hook (expr));
5238 case FFEINTRIN_impFTELL_subr:
5239 case FFEINTRIN_impUMASK_subr:
5244 arg1_tree = convert (ffecom_f2c_integer_type_node,
5245 ffecom_expr (arg1));
5246 arg1_tree = ffecom_1 (ADDR_EXPR,
5247 build_pointer_type (TREE_TYPE (arg1_tree)),
5251 arg2_tree = NULL_TREE;
5253 arg2_tree = ffecom_expr_w (NULL_TREE, arg2);
5255 expr_tree = ffecom_call_ (ffecom_gfrt_tree_ (gfrt),
5256 ffecom_gfrt_kindtype (gfrt),
5259 build_tree_list (NULL_TREE, arg1_tree),
5260 NULL_TREE, NULL, NULL, NULL_TREE,
5262 ffebld_nonter_hook (expr));
5263 if (arg2_tree != NULL_TREE) {
5264 expr_tree = ffecom_modify (NULL_TREE, arg2_tree,
5265 convert (TREE_TYPE (arg2_tree),
5271 case FFEINTRIN_impCPU_TIME:
5272 case FFEINTRIN_impSECOND_subr:
5276 arg1_tree = ffecom_expr_w (NULL_TREE, arg1);
5279 = ffecom_call_ (ffecom_gfrt_tree_ (gfrt),
5280 ffecom_gfrt_kindtype (gfrt),
5284 NULL_TREE, NULL, NULL, NULL_TREE, TRUE,
5285 ffebld_nonter_hook (expr));
5288 = ffecom_modify (NULL_TREE, arg1_tree,
5289 convert (TREE_TYPE (arg1_tree),
5294 case FFEINTRIN_impDTIME_subr:
5295 case FFEINTRIN_impETIME_subr:
5300 result_tree = ffecom_expr_w (NULL_TREE, arg2);
5302 arg1_tree = ffecom_ptr_to_expr (arg1);
5304 expr_tree = ffecom_call_ (ffecom_gfrt_tree_ (gfrt),
5305 ffecom_gfrt_kindtype (gfrt),
5308 build_tree_list (NULL_TREE, arg1_tree),
5309 NULL_TREE, NULL, NULL, NULL_TREE,
5311 ffebld_nonter_hook (expr));
5312 expr_tree = ffecom_modify (NULL_TREE, result_tree,
5313 convert (TREE_TYPE (result_tree),
5318 /* Straightforward calls of libf2c routines: */
5319 case FFEINTRIN_impABORT:
5320 case FFEINTRIN_impACCESS:
5321 case FFEINTRIN_impBESJ0:
5322 case FFEINTRIN_impBESJ1:
5323 case FFEINTRIN_impBESJN:
5324 case FFEINTRIN_impBESY0:
5325 case FFEINTRIN_impBESY1:
5326 case FFEINTRIN_impBESYN:
5327 case FFEINTRIN_impCHDIR_func:
5328 case FFEINTRIN_impCHMOD_func:
5329 case FFEINTRIN_impDATE:
5330 case FFEINTRIN_impDATE_AND_TIME:
5331 case FFEINTRIN_impDBESJ0:
5332 case FFEINTRIN_impDBESJ1:
5333 case FFEINTRIN_impDBESJN:
5334 case FFEINTRIN_impDBESY0:
5335 case FFEINTRIN_impDBESY1:
5336 case FFEINTRIN_impDBESYN:
5337 case FFEINTRIN_impDTIME_func:
5338 case FFEINTRIN_impETIME_func:
5339 case FFEINTRIN_impFGETC_func:
5340 case FFEINTRIN_impFGET_func:
5341 case FFEINTRIN_impFNUM:
5342 case FFEINTRIN_impFPUTC_func:
5343 case FFEINTRIN_impFPUT_func:
5344 case FFEINTRIN_impFSEEK:
5345 case FFEINTRIN_impFSTAT_func:
5346 case FFEINTRIN_impFTELL_func:
5347 case FFEINTRIN_impGERROR:
5348 case FFEINTRIN_impGETARG:
5349 case FFEINTRIN_impGETCWD_func:
5350 case FFEINTRIN_impGETENV:
5351 case FFEINTRIN_impGETGID:
5352 case FFEINTRIN_impGETLOG:
5353 case FFEINTRIN_impGETPID:
5354 case FFEINTRIN_impGETUID:
5355 case FFEINTRIN_impGMTIME:
5356 case FFEINTRIN_impHOSTNM_func:
5357 case FFEINTRIN_impIDATE_unix:
5358 case FFEINTRIN_impIDATE_vxt:
5359 case FFEINTRIN_impIERRNO:
5360 case FFEINTRIN_impISATTY:
5361 case FFEINTRIN_impITIME:
5362 case FFEINTRIN_impKILL_func:
5363 case FFEINTRIN_impLINK_func:
5364 case FFEINTRIN_impLNBLNK:
5365 case FFEINTRIN_impLSTAT_func:
5366 case FFEINTRIN_impLTIME:
5367 case FFEINTRIN_impMCLOCK8:
5368 case FFEINTRIN_impMCLOCK:
5369 case FFEINTRIN_impPERROR:
5370 case FFEINTRIN_impRENAME_func:
5371 case FFEINTRIN_impSECNDS:
5372 case FFEINTRIN_impSECOND_func:
5373 case FFEINTRIN_impSLEEP:
5374 case FFEINTRIN_impSRAND:
5375 case FFEINTRIN_impSTAT_func:
5376 case FFEINTRIN_impSYMLNK_func:
5377 case FFEINTRIN_impSYSTEM_CLOCK:
5378 case FFEINTRIN_impSYSTEM_func:
5379 case FFEINTRIN_impTIME8:
5380 case FFEINTRIN_impTIME_unix:
5381 case FFEINTRIN_impTIME_vxt:
5382 case FFEINTRIN_impUMASK_func:
5383 case FFEINTRIN_impUNLINK_func:
5386 case FFEINTRIN_impCTIME_func: /* CHARACTER functions not handled here. */
5387 case FFEINTRIN_impFDATE_func: /* CHARACTER functions not handled here. */
5388 case FFEINTRIN_impTTYNAM_func: /* CHARACTER functions not handled here. */
5389 case FFEINTRIN_impNONE:
5390 case FFEINTRIN_imp: /* Hush up gcc warning. */
5391 fprintf (stderr, "No %s implementation.\n",
5392 ffeintrin_name_implementation (ffebld_symter_implementation (ffebld_left (expr))));
5393 assert ("unimplemented intrinsic" == NULL);
5394 return error_mark_node;
5397 assert (gfrt != FFECOM_gfrt); /* Must have an implementation! */
5399 expr_tree = ffecom_arglist_expr_ (ffecom_gfrt_args_ (gfrt),
5400 ffebld_right (expr));
5402 return ffecom_call_ (ffecom_gfrt_tree_ (gfrt), ffecom_gfrt_kindtype (gfrt),
5403 (ffe_is_f2c_library () && ffecom_gfrt_complex_[gfrt]),
5405 expr_tree, dest_tree, dest, dest_used,
5407 ffebld_nonter_hook (expr));
5409 /* See bottom of this file for f2c transforms used to determine
5410 many of the above implementations. The info seems to confuse
5411 Emacs's C mode indentation, which is why it's been moved to
5412 the bottom of this source file. */
5415 /* For power (exponentiation) where right-hand operand is type INTEGER,
5416 generate in-line code to do it the fast way (which, if the operand
5417 is a constant, might just mean a series of multiplies). */
5420 ffecom_expr_power_integer_ (ffebld expr)
5422 tree l = ffecom_expr (ffebld_left (expr));
5423 tree r = ffecom_expr (ffebld_right (expr));
5424 tree ltype = TREE_TYPE (l);
5425 tree rtype = TREE_TYPE (r);
5426 tree result = NULL_TREE;
5428 if (l == error_mark_node
5429 || r == error_mark_node)
5430 return error_mark_node;
5432 if (TREE_CODE (r) == INTEGER_CST)
5434 int sgn = tree_int_cst_sgn (r);
5437 return convert (ltype, integer_one_node);
5439 if ((TREE_CODE (ltype) == INTEGER_TYPE)
5442 /* Reciprocal of integer is either 0, -1, or 1, so after
5443 calculating that (which we leave to the back end to do
5444 or not do optimally), don't bother with any multiplying. */
5446 result = ffecom_tree_divide_ (ltype,
5447 convert (ltype, integer_one_node),
5449 NULL_TREE, NULL, NULL, NULL_TREE);
5450 r = ffecom_1 (NEGATE_EXPR,
5453 if ((TREE_INT_CST_LOW (r) & 1) == 0)
5454 result = ffecom_1 (ABS_EXPR, rtype,
5458 /* Generate appropriate series of multiplies, preceded
5459 by divide if the exponent is negative. */
5465 l = ffecom_tree_divide_ (ltype,
5466 convert (ltype, integer_one_node),
5468 NULL_TREE, NULL, NULL,
5469 ffebld_nonter_hook (expr));
5470 r = ffecom_1 (NEGATE_EXPR, rtype, r);
5471 assert (TREE_CODE (r) == INTEGER_CST);
5473 if (tree_int_cst_sgn (r) < 0)
5474 { /* The "most negative" number. */
5475 r = ffecom_1 (NEGATE_EXPR, rtype,
5476 ffecom_2 (RSHIFT_EXPR, rtype,
5480 l = ffecom_2 (MULT_EXPR, ltype,
5488 if (TREE_INT_CST_LOW (r) & 1)
5490 if (result == NULL_TREE)
5493 result = ffecom_2 (MULT_EXPR, ltype,
5498 r = ffecom_2 (RSHIFT_EXPR, rtype,
5501 if (integer_zerop (r))
5503 assert (TREE_CODE (r) == INTEGER_CST);
5506 l = ffecom_2 (MULT_EXPR, ltype,
5513 /* Though rhs isn't a constant, in-line code cannot be expanded
5514 while transforming dummies
5515 because the back end cannot be easily convinced to generate
5516 stores (MODIFY_EXPR), handle temporaries, and so on before
5517 all the appropriate rtx's have been generated for things like
5518 dummy args referenced in rhs -- which doesn't happen until
5519 store_parm_decls() is called (expand_function_start, I believe,
5520 does the actual rtx-stuffing of PARM_DECLs).
5522 So, in this case, let the caller generate the call to the
5523 run-time-library function to evaluate the power for us. */
5525 if (ffecom_transform_only_dummies_)
5528 /* Right-hand operand not a constant, expand in-line code to figure
5529 out how to do the multiplies, &c.
5531 The returned expression is expressed this way in GNU C, where l and
5534 ({ typeof (r) rtmp = r;
5535 typeof (l) ltmp = l;
5542 if ((basetypeof (l) == basetypeof (int))
5545 result = ((typeof (l)) 1) / ltmp;
5546 if ((ltmp < 0) && (((-rtmp) & 1) == 0))
5552 if ((basetypeof (l) != basetypeof (int))
5555 ltmp = ((typeof (l)) 1) / ltmp;
5559 rtmp = -(rtmp >> 1);
5567 if ((rtmp >>= 1) == 0)
5576 Note that some of the above is compile-time collapsable, such as
5577 the first part of the if statements that checks the base type of
5578 l against int. The if statements are phrased that way to suggest
5579 an easy way to generate the if/else constructs here, knowing that
5580 the back end should (and probably does) eliminate the resulting
5581 dead code (either the int case or the non-int case), something
5582 it couldn't do without the redundant phrasing, requiring explicit
5583 dead-code elimination here, which would be kind of difficult to
5590 tree basetypeof_l_is_int;
5595 = build_int_2 ((TREE_CODE (ltype) == INTEGER_TYPE), 0);
5597 se = expand_start_stmt_expr (/*has_scope=*/1);
5599 ffecom_start_compstmt ();
5601 rtmp = ffecom_make_tempvar ("power_r", rtype,
5602 FFETARGET_charactersizeNONE, -1);
5603 ltmp = ffecom_make_tempvar ("power_l", ltype,
5604 FFETARGET_charactersizeNONE, -1);
5605 result = ffecom_make_tempvar ("power_res", ltype,
5606 FFETARGET_charactersizeNONE, -1);
5607 if (TREE_CODE (ltype) == COMPLEX_TYPE
5608 || TREE_CODE (ltype) == RECORD_TYPE)
5609 divide = ffecom_make_tempvar ("power_div", ltype,
5610 FFETARGET_charactersizeNONE, -1);
5614 expand_expr_stmt (ffecom_modify (void_type_node,
5617 expand_expr_stmt (ffecom_modify (void_type_node,
5620 expand_start_cond (ffecom_truth_value
5621 (ffecom_2 (EQ_EXPR, integer_type_node,
5623 convert (rtype, integer_zero_node))),
5625 expand_expr_stmt (ffecom_modify (void_type_node,
5627 convert (ltype, integer_one_node)));
5628 expand_start_else ();
5629 if (! integer_zerop (basetypeof_l_is_int))
5631 expand_start_cond (ffecom_2 (LT_EXPR, integer_type_node,
5634 integer_zero_node)),
5636 expand_expr_stmt (ffecom_modify (void_type_node,
5640 convert (ltype, integer_one_node),
5642 NULL_TREE, NULL, NULL,
5644 expand_start_cond (ffecom_truth_value
5645 (ffecom_2 (TRUTH_ANDIF_EXPR, integer_type_node,
5646 ffecom_2 (LT_EXPR, integer_type_node,
5649 integer_zero_node)),
5650 ffecom_2 (EQ_EXPR, integer_type_node,
5651 ffecom_2 (BIT_AND_EXPR,
5653 ffecom_1 (NEGATE_EXPR,
5659 integer_zero_node)))),
5661 expand_expr_stmt (ffecom_modify (void_type_node,
5663 ffecom_1 (NEGATE_EXPR,
5667 expand_start_else ();
5669 expand_expr_stmt (ffecom_modify (void_type_node,
5671 convert (ltype, integer_one_node)));
5672 expand_start_cond (ffecom_truth_value
5673 (ffecom_2 (TRUTH_ANDIF_EXPR, integer_type_node,
5674 ffecom_truth_value_invert
5675 (basetypeof_l_is_int),
5676 ffecom_2 (LT_EXPR, integer_type_node,
5679 integer_zero_node)))),
5681 expand_expr_stmt (ffecom_modify (void_type_node,
5685 convert (ltype, integer_one_node),
5687 NULL_TREE, NULL, NULL,
5689 expand_expr_stmt (ffecom_modify (void_type_node,
5691 ffecom_1 (NEGATE_EXPR, rtype,
5693 expand_start_cond (ffecom_truth_value
5694 (ffecom_2 (LT_EXPR, integer_type_node,
5696 convert (rtype, integer_zero_node))),
5698 expand_expr_stmt (ffecom_modify (void_type_node,
5700 ffecom_1 (NEGATE_EXPR, rtype,
5701 ffecom_2 (RSHIFT_EXPR,
5704 integer_one_node))));
5705 expand_expr_stmt (ffecom_modify (void_type_node,
5707 ffecom_2 (MULT_EXPR, ltype,
5712 expand_start_loop (1);
5713 expand_start_cond (ffecom_truth_value
5714 (ffecom_2 (BIT_AND_EXPR, rtype,
5716 convert (rtype, integer_one_node))),
5718 expand_expr_stmt (ffecom_modify (void_type_node,
5720 ffecom_2 (MULT_EXPR, ltype,
5724 expand_exit_loop_if_false (NULL,
5726 (ffecom_modify (rtype,
5728 ffecom_2 (RSHIFT_EXPR,
5731 integer_one_node))));
5732 expand_expr_stmt (ffecom_modify (void_type_node,
5734 ffecom_2 (MULT_EXPR, ltype,
5739 if (!integer_zerop (basetypeof_l_is_int))
5741 expand_expr_stmt (result);
5743 t = ffecom_end_compstmt ();
5745 result = expand_end_stmt_expr (se);
5747 /* This code comes from c-parse.in, after its expand_end_stmt_expr. */
5749 if (TREE_CODE (t) == BLOCK)
5751 /* Make a BIND_EXPR for the BLOCK already made. */
5752 result = build (BIND_EXPR, TREE_TYPE (result),
5753 NULL_TREE, result, t);
5754 /* Remove the block from the tree at this point.
5755 It gets put back at the proper place
5756 when the BIND_EXPR is expanded. */
5766 /* ffecom_expr_transform_ -- Transform symbols in expr
5768 ffebld expr; // FFE expression.
5769 ffecom_expr_transform_ (expr);
5771 Recursive descent on expr while transforming any untransformed SYMTERs. */
5774 ffecom_expr_transform_ (ffebld expr)
5784 switch (ffebld_op (expr))
5786 case FFEBLD_opSYMTER:
5787 s = ffebld_symter (expr);
5788 t = ffesymbol_hook (s).decl_tree;
5789 if ((t == NULL_TREE)
5790 && ((ffesymbol_kind (s) != FFEINFO_kindNONE)
5791 || ((ffesymbol_where (s) != FFEINFO_whereNONE)
5792 && (ffesymbol_where (s) != FFEINFO_whereINTRINSIC))))
5794 s = ffecom_sym_transform_ (s);
5795 t = ffesymbol_hook (s).decl_tree; /* Sfunc expr non-dummy,
5798 break; /* Ok if (t == NULL) here. */
5801 ffecom_expr_transform_ (ffebld_head (expr));
5802 expr = ffebld_trail (expr);
5803 goto tail_recurse; /* :::::::::::::::::::: */
5809 switch (ffebld_arity (expr))
5812 ffecom_expr_transform_ (ffebld_left (expr));
5813 expr = ffebld_right (expr);
5814 goto tail_recurse; /* :::::::::::::::::::: */
5817 expr = ffebld_left (expr);
5818 goto tail_recurse; /* :::::::::::::::::::: */
5827 /* Make a type based on info in live f2c.h file. */
5830 ffecom_f2c_make_type_ (tree *type, int tcode, const char *name)
5834 case FFECOM_f2ccodeCHAR:
5835 *type = make_signed_type (CHAR_TYPE_SIZE);
5838 case FFECOM_f2ccodeSHORT:
5839 *type = make_signed_type (SHORT_TYPE_SIZE);
5842 case FFECOM_f2ccodeINT:
5843 *type = make_signed_type (INT_TYPE_SIZE);
5846 case FFECOM_f2ccodeLONG:
5847 *type = make_signed_type (LONG_TYPE_SIZE);
5850 case FFECOM_f2ccodeLONGLONG:
5851 *type = make_signed_type (LONG_LONG_TYPE_SIZE);
5854 case FFECOM_f2ccodeCHARPTR:
5855 *type = build_pointer_type (DEFAULT_SIGNED_CHAR
5856 ? signed_char_type_node
5857 : unsigned_char_type_node);
5860 case FFECOM_f2ccodeFLOAT:
5861 *type = make_node (REAL_TYPE);
5862 TYPE_PRECISION (*type) = FLOAT_TYPE_SIZE;
5863 layout_type (*type);
5866 case FFECOM_f2ccodeDOUBLE:
5867 *type = make_node (REAL_TYPE);
5868 TYPE_PRECISION (*type) = DOUBLE_TYPE_SIZE;
5869 layout_type (*type);
5872 case FFECOM_f2ccodeLONGDOUBLE:
5873 *type = make_node (REAL_TYPE);
5874 TYPE_PRECISION (*type) = LONG_DOUBLE_TYPE_SIZE;
5875 layout_type (*type);
5878 case FFECOM_f2ccodeTWOREALS:
5879 *type = ffecom_make_complex_type_ (ffecom_f2c_real_type_node);
5882 case FFECOM_f2ccodeTWODOUBLEREALS:
5883 *type = ffecom_make_complex_type_ (ffecom_f2c_doublereal_type_node);
5887 assert ("unexpected FFECOM_f2ccodeXYZZY!" == NULL);
5888 *type = error_mark_node;
5892 pushdecl (build_decl (TYPE_DECL,
5893 ffecom_get_invented_identifier ("__g77_f2c_%s", name),
5897 /* Set the f2c list-directed-I/O code for whatever (integral) type has the
5901 ffecom_f2c_set_lio_code_ (ffeinfoBasictype bt, int size, int code)
5906 for (j = 0; ((size_t) j) < ARRAY_SIZE (ffecom_tree_type[0]); ++j)
5907 if ((t = ffecom_tree_type[bt][j]) != NULL_TREE
5908 && compare_tree_int (TYPE_SIZE (t), size) == 0)
5910 assert (code != -1);
5911 ffecom_f2c_typecode_[bt][j] = code;
5916 /* Finish up globals after doing all program units in file
5918 Need to handle only uninitialized COMMON areas. */
5921 ffecom_finish_global_ (ffeglobal global)
5927 if (ffeglobal_type (global) != FFEGLOBAL_typeCOMMON)
5930 if (ffeglobal_common_init (global))
5933 cbt = ffeglobal_hook (global);
5934 if ((cbt == NULL_TREE)
5935 || !ffeglobal_common_have_size (global))
5936 return global; /* No need to make common, never ref'd. */
5938 DECL_EXTERNAL (cbt) = 0;
5940 /* Give the array a size now. */
5942 size = build_int_2 ((ffeglobal_common_size (global)
5943 + ffeglobal_common_pad (global)) - 1,
5946 cbtype = TREE_TYPE (cbt);
5947 TYPE_DOMAIN (cbtype) = build_range_type (integer_type_node,
5950 if (!TREE_TYPE (size))
5951 TREE_TYPE (size) = TYPE_DOMAIN (cbtype);
5952 layout_type (cbtype);
5954 cbt = start_decl (cbt, FALSE);
5955 assert (cbt == ffeglobal_hook (global));
5957 finish_decl (cbt, NULL_TREE, FALSE);
5962 /* Finish up any untransformed symbols. */
5965 ffecom_finish_symbol_transform_ (ffesymbol s)
5967 if ((s == NULL) || (TREE_CODE (current_function_decl) == ERROR_MARK))
5970 /* It's easy to know to transform an untransformed symbol, to make sure
5971 we put out debugging info for it. But COMMON variables, unlike
5972 EQUIVALENCE ones, aren't given declarations in addition to the
5973 tree expressions that specify offsets, because COMMON variables
5974 can be referenced in the outer scope where only dummy arguments
5975 (PARM_DECLs) should really be seen. To be safe, just don't do any
5976 VAR_DECLs for COMMON variables when we transform them for real
5977 use, and therefore we do all the VAR_DECL creating here. */
5979 if (ffesymbol_hook (s).decl_tree == NULL_TREE)
5981 if (ffesymbol_kind (s) != FFEINFO_kindNONE
5982 || (ffesymbol_where (s) != FFEINFO_whereNONE
5983 && ffesymbol_where (s) != FFEINFO_whereINTRINSIC
5984 && ffesymbol_where (s) != FFEINFO_whereDUMMY))
5985 /* Not transformed, and not CHARACTER*(*), and not a dummy
5986 argument, which can happen only if the entry point names
5987 it "rides in on" are all invalidated for other reasons. */
5988 s = ffecom_sym_transform_ (s);
5991 if ((ffesymbol_where (s) == FFEINFO_whereCOMMON)
5992 && (ffesymbol_hook (s).decl_tree != error_mark_node))
5994 /* This isn't working, at least for dbxout. The .s file looks
5995 okay to me (burley), but in gdb 4.9 at least, the variables
5996 appear to reside somewhere outside of the common area, so
5997 it doesn't make sense to mislead anyone by generating the info
5998 on those variables until this is fixed. NOTE: Same problem
5999 with EQUIVALENCE, sadly...see similar #if later. */
6000 ffecom_member_phase2_ (ffesymbol_storage (ffesymbol_common (s)),
6001 ffesymbol_storage (s));
6007 /* Append underscore(s) to name before calling get_identifier. "us"
6008 is nonzero if the name already contains an underscore and thus
6009 needs two underscores appended. */
6012 ffecom_get_appended_identifier_ (char us, const char *name)
6018 newname = xmalloc ((i = strlen (name)) + 1
6019 + ffe_is_underscoring ()
6021 memcpy (newname, name, i);
6023 newname[i + us] = '_';
6024 newname[i + 1 + us] = '\0';
6025 id = get_identifier (newname);
6032 /* Decide whether to append underscore to name before calling
6036 ffecom_get_external_identifier_ (ffesymbol s)
6039 const char *name = ffesymbol_text (s);
6041 /* If name is a built-in name, just return it as is. */
6043 if (!ffe_is_underscoring ()
6044 || (strcmp (name, FFETARGET_nameBLANK_COMMON) == 0)
6045 || (strcmp (name, FFETARGET_nameUNNAMED_MAIN) == 0)
6046 || (strcmp (name, FFETARGET_nameUNNAMED_BLOCK_DATA) == 0))
6047 return get_identifier (name);
6049 us = ffe_is_second_underscore ()
6050 ? (strchr (name, '_') != NULL)
6053 return ffecom_get_appended_identifier_ (us, name);
6056 /* Decide whether to append underscore to internal name before calling
6059 This is for non-external, top-function-context names only. Transform
6060 identifier so it doesn't conflict with the transformed result
6061 of using a _different_ external name. E.g. if "CALL FOO" is
6062 transformed into "FOO_();", then the variable in "FOO_ = 3"
6063 must be transformed into something that does not conflict, since
6064 these two things should be independent.
6066 The transformation is as follows. If the name does not contain
6067 an underscore, there is no possible conflict, so just return.
6068 If the name does contain an underscore, then transform it just
6069 like we transform an external identifier. */
6072 ffecom_get_identifier_ (const char *name)
6074 /* If name does not contain an underscore, just return it as is. */
6076 if (!ffe_is_underscoring ()
6077 || (strchr (name, '_') == NULL))
6078 return get_identifier (name);
6080 return ffecom_get_appended_identifier_ (ffe_is_second_underscore (),
6084 /* ffecom_gen_sfuncdef_ -- Generate definition of statement function
6087 ffesymbol s; // kindFUNCTION, whereIMMEDIATE.
6088 t = ffecom_gen_sfuncdef_(s,ffesymbol_basictype(s),
6089 ffesymbol_kindtype(s));
6091 Call after setting up containing function and getting trees for all
6095 ffecom_gen_sfuncdef_ (ffesymbol s, ffeinfoBasictype bt, ffeinfoKindtype kt)
6097 ffebld expr = ffesymbol_sfexpr (s);
6101 bool charfunc = (bt == FFEINFO_basictypeCHARACTER);
6102 static bool recurse = FALSE;
6103 location_t old_loc = input_location;
6105 ffecom_nested_entry_ = s;
6107 /* For now, we don't have a handy pointer to where the sfunc is actually
6108 defined, though that should be easy to add to an ffesymbol. (The
6109 token/where info available might well point to the place where the type
6110 of the sfunc is declared, especially if that precedes the place where
6111 the sfunc itself is defined, which is typically the case.) We should
6112 put out a null pointer rather than point somewhere wrong, but I want to
6113 see how it works at this point. */
6115 input_filename = ffesymbol_where_filename (s);
6116 input_line = ffesymbol_where_filelinenum (s);
6118 /* Pretransform the expression so any newly discovered things belong to the
6119 outer program unit, not to the statement function. */
6121 ffecom_expr_transform_ (expr);
6123 /* Make sure no recursive invocation of this fn (a specific case of failing
6124 to pretransform an sfunc's expression, i.e. where its expression
6125 references another untransformed sfunc) happens. */
6130 push_f_function_context ();
6133 type = void_type_node;
6136 type = ffecom_tree_type[bt][kt];
6137 if (type == NULL_TREE)
6138 type = integer_type_node; /* _sym_exec_transition reports
6142 start_function (ffecom_get_identifier_ (ffesymbol_text (s)),
6143 build_function_type (type, NULL_TREE),
6144 1, /* nested/inline */
6145 0); /* TREE_PUBLIC */
6147 /* We don't worry about COMPLEX return values here, because this is
6148 entirely internal to our code, and gcc has the ability to return COMPLEX
6149 directly as a value. */
6152 { /* Prepend arg for where result goes. */
6155 type = ffecom_tree_type[FFEINFO_basictypeCHARACTER][kt];
6157 result = ffecom_get_invented_identifier ("__g77_%s", "result");
6159 ffecom_char_enhance_arg_ (&type, s); /* Ignore returned length. */
6161 type = build_pointer_type (type);
6162 result = build_decl (PARM_DECL, result, type);
6164 push_parm_decl (result);
6167 result = NULL_TREE; /* Not ref'd if !charfunc. */
6169 ffecom_push_dummy_decls_ (ffesymbol_dummyargs (s), TRUE);
6171 store_parm_decls (0);
6173 ffecom_start_compstmt ();
6179 ffetargetCharacterSize sz = ffesymbol_size (s);
6182 result_length = build_int_2 (sz, 0);
6183 TREE_TYPE (result_length) = ffecom_f2c_ftnlen_type_node;
6185 ffecom_prepare_let_char_ (sz, expr);
6187 ffecom_prepare_end ();
6189 ffecom_let_char_ (result, result_length, sz, expr);
6190 expand_null_return ();
6194 ffecom_prepare_expr (expr);
6196 ffecom_prepare_end ();
6198 expand_return (ffecom_modify (NULL_TREE,
6199 DECL_RESULT (current_function_decl),
6200 ffecom_expr (expr)));
6204 ffecom_end_compstmt ();
6206 func = current_function_decl;
6207 finish_function (1);
6209 pop_f_function_context ();
6213 input_location = old_loc;
6215 ffecom_nested_entry_ = NULL;
6221 ffecom_gfrt_args_ (ffecomGfrt ix)
6223 return ffecom_gfrt_argstring_[ix];
6227 ffecom_gfrt_tree_ (ffecomGfrt ix)
6229 if (ffecom_gfrt_[ix] == NULL_TREE)
6230 ffecom_make_gfrt_ (ix);
6232 return ffecom_1 (ADDR_EXPR,
6233 build_pointer_type (TREE_TYPE (ffecom_gfrt_[ix])),
6237 /* Return initialize-to-zero expression for this VAR_DECL. */
6239 /* A somewhat evil way to prevent the garbage collector
6240 from collecting 'tree' structures. */
6241 #define NUM_TRACKED_CHUNK 63
6242 struct tree_ggc_tracker GTY(())
6244 struct tree_ggc_tracker *next;
6245 tree trees[NUM_TRACKED_CHUNK];
6247 static GTY(()) struct tree_ggc_tracker *tracker_head;
6250 ffecom_save_tree_forever (tree t)
6253 if (tracker_head != NULL)
6254 for (i = 0; i < NUM_TRACKED_CHUNK; i++)
6255 if (tracker_head->trees[i] == NULL)
6257 tracker_head->trees[i] = t;
6262 /* Need to allocate a new block. */
6263 struct tree_ggc_tracker *old_head = tracker_head;
6265 tracker_head = ggc_alloc (sizeof (*tracker_head));
6266 tracker_head->next = old_head;
6267 tracker_head->trees[0] = t;
6268 for (i = 1; i < NUM_TRACKED_CHUNK; i++)
6269 tracker_head->trees[i] = NULL;
6274 ffecom_init_zero_ (tree decl)
6277 int incremental = TREE_STATIC (decl);
6278 tree type = TREE_TYPE (decl);
6282 make_decl_rtl (decl, NULL);
6283 assemble_variable (decl, TREE_PUBLIC (decl) ? 1 : 0, 0, 1);
6286 if ((TREE_CODE (type) != ARRAY_TYPE)
6287 && (TREE_CODE (type) != RECORD_TYPE)
6288 && (TREE_CODE (type) != UNION_TYPE)
6290 init = convert (type, integer_zero_node);
6291 else if (!incremental)
6293 init = build_constructor (type, NULL_TREE);
6294 TREE_CONSTANT (init) = 1;
6295 TREE_STATIC (init) = 1;
6299 assemble_zeros (int_size_in_bytes (type));
6300 init = error_mark_node;
6307 ffecom_intrinsic_ichar_ (tree tree_type, ffebld arg, tree *maybe_tree)
6312 switch (ffebld_op (arg))
6314 case FFEBLD_opCONTER: /* For F90, check 0-length. */
6315 if (ffetarget_length_character1
6316 (ffebld_constant_character1
6317 (ffebld_conter (arg))) == 0)
6319 *maybe_tree = integer_zero_node;
6320 return convert (tree_type, integer_zero_node);
6323 *maybe_tree = integer_one_node;
6324 expr_tree = build_int_2 (*ffetarget_text_character1
6325 (ffebld_constant_character1
6326 (ffebld_conter (arg))),
6328 TREE_TYPE (expr_tree) = tree_type;
6331 case FFEBLD_opSYMTER:
6332 case FFEBLD_opARRAYREF:
6333 case FFEBLD_opFUNCREF:
6334 case FFEBLD_opSUBSTR:
6335 ffecom_char_args_ (&expr_tree, &length_tree, arg);
6337 if ((expr_tree == error_mark_node)
6338 || (length_tree == error_mark_node))
6340 *maybe_tree = error_mark_node;
6341 return error_mark_node;
6344 if (integer_zerop (length_tree))
6346 *maybe_tree = integer_zero_node;
6347 return convert (tree_type, integer_zero_node);
6351 = ffecom_1 (INDIRECT_REF,
6352 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (expr_tree))),
6355 = ffecom_2 (ARRAY_REF,
6356 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (expr_tree))),
6359 expr_tree = convert (tree_type, expr_tree);
6361 if (TREE_CODE (length_tree) == INTEGER_CST)
6362 *maybe_tree = integer_one_node;
6363 else /* Must check length at run time. */
6365 = ffecom_truth_value
6366 (ffecom_2 (GT_EXPR, integer_type_node,
6368 ffecom_f2c_ftnlen_zero_node));
6371 case FFEBLD_opPAREN:
6372 case FFEBLD_opCONVERT:
6373 if (ffeinfo_size (ffebld_info (arg)) == 0)
6375 *maybe_tree = integer_zero_node;
6376 return convert (tree_type, integer_zero_node);
6378 return ffecom_intrinsic_ichar_ (tree_type, ffebld_left (arg),
6381 case FFEBLD_opCONCATENATE:
6388 expr_left = ffecom_intrinsic_ichar_ (tree_type, ffebld_left (arg),
6390 expr_right = ffecom_intrinsic_ichar_ (tree_type, ffebld_right (arg),
6392 *maybe_tree = ffecom_2 (TRUTH_ORIF_EXPR, integer_type_node,
6395 expr_tree = ffecom_3 (COND_EXPR, tree_type,
6403 assert ("bad op in ICHAR" == NULL);
6404 return error_mark_node;
6408 /* ffecom_intrinsic_len_ -- Return length info for char arg (LEN())
6412 length_arg = ffecom_intrinsic_len_ (expr);
6414 Handles CHARACTER-type CONTER, SYMTER, SUBSTR, ARRAYREF, and FUNCREF
6415 subexpressions by constructing the appropriate tree for the
6416 length-of-character-text argument in a calling sequence. */
6419 ffecom_intrinsic_len_ (ffebld expr)
6421 ffetargetCharacter1 val;
6424 switch (ffebld_op (expr))
6426 case FFEBLD_opCONTER:
6427 val = ffebld_constant_character1 (ffebld_conter (expr));
6428 length = build_int_2 (ffetarget_length_character1 (val), 0);
6429 TREE_TYPE (length) = ffecom_f2c_ftnlen_type_node;
6432 case FFEBLD_opSYMTER:
6434 ffesymbol s = ffebld_symter (expr);
6437 item = ffesymbol_hook (s).decl_tree;
6438 if (item == NULL_TREE)
6440 s = ffecom_sym_transform_ (s);
6441 item = ffesymbol_hook (s).decl_tree;
6443 if (ffesymbol_kind (s) == FFEINFO_kindENTITY)
6445 if (ffesymbol_size (s) == FFETARGET_charactersizeNONE)
6446 length = ffesymbol_hook (s).length_tree;
6449 length = build_int_2 (ffesymbol_size (s), 0);
6450 TREE_TYPE (length) = ffecom_f2c_ftnlen_type_node;
6453 else if (item == error_mark_node)
6454 length = error_mark_node;
6455 else /* FFEINFO_kindFUNCTION: */
6460 case FFEBLD_opARRAYREF:
6461 length = ffecom_intrinsic_len_ (ffebld_left (expr));
6464 case FFEBLD_opSUBSTR:
6468 ffebld thing = ffebld_right (expr);
6472 assert (ffebld_op (thing) == FFEBLD_opITEM);
6473 start = ffebld_head (thing);
6474 thing = ffebld_trail (thing);
6475 assert (ffebld_trail (thing) == NULL);
6476 end = ffebld_head (thing);
6478 length = ffecom_intrinsic_len_ (ffebld_left (expr));
6480 if (length == error_mark_node)
6489 length = convert (ffecom_f2c_ftnlen_type_node,
6495 start_tree = convert (ffecom_f2c_ftnlen_type_node,
6496 ffecom_expr (start));
6498 if (start_tree == error_mark_node)
6500 length = error_mark_node;
6506 length = ffecom_2 (PLUS_EXPR, ffecom_f2c_ftnlen_type_node,
6507 ffecom_f2c_ftnlen_one_node,
6508 ffecom_2 (MINUS_EXPR,
6509 ffecom_f2c_ftnlen_type_node,
6515 end_tree = convert (ffecom_f2c_ftnlen_type_node,
6518 if (end_tree == error_mark_node)
6520 length = error_mark_node;
6524 length = ffecom_2 (PLUS_EXPR, ffecom_f2c_ftnlen_type_node,
6525 ffecom_f2c_ftnlen_one_node,
6526 ffecom_2 (MINUS_EXPR,
6527 ffecom_f2c_ftnlen_type_node,
6528 end_tree, start_tree));
6534 case FFEBLD_opCONCATENATE:
6536 = ffecom_2 (PLUS_EXPR, ffecom_f2c_ftnlen_type_node,
6537 ffecom_intrinsic_len_ (ffebld_left (expr)),
6538 ffecom_intrinsic_len_ (ffebld_right (expr)));
6541 case FFEBLD_opFUNCREF:
6542 case FFEBLD_opCONVERT:
6543 length = build_int_2 (ffebld_size (expr), 0);
6544 TREE_TYPE (length) = ffecom_f2c_ftnlen_type_node;
6548 assert ("bad op for single char arg expr" == NULL);
6549 length = ffecom_f2c_ftnlen_zero_node;
6553 assert (length != NULL_TREE);
6558 /* Handle CHARACTER assignments.
6560 Generates code to do the assignment. Used by ordinary assignment
6561 statement handler ffecom_let_stmt and by statement-function
6562 handler to generate code for a statement function. */
6565 ffecom_let_char_ (tree dest_tree, tree dest_length,
6566 ffetargetCharacterSize dest_size, ffebld source)
6568 ffecomConcatList_ catlist;
6573 if ((dest_tree == error_mark_node)
6574 || (dest_length == error_mark_node))
6577 assert (dest_tree != NULL_TREE);
6578 assert (dest_length != NULL_TREE);
6580 /* Source might be an opCONVERT, which just means it is a different size
6581 than the destination. Since the underlying implementation here handles
6582 that (directly or via the s_copy or s_cat run-time-library functions),
6583 we don't need the "convenience" of an opCONVERT that tells us to
6584 truncate or blank-pad, particularly since the resulting implementation
6585 would probably be slower than otherwise. */
6587 while (ffebld_op (source) == FFEBLD_opCONVERT)
6588 source = ffebld_left (source);
6590 catlist = ffecom_concat_list_new_ (source, dest_size);
6591 switch (ffecom_concat_list_count_ (catlist))
6593 case 0: /* Shouldn't happen, but in case it does... */
6594 ffecom_concat_list_kill_ (catlist);
6595 source_tree = null_pointer_node;
6596 source_length = ffecom_f2c_ftnlen_zero_node;
6597 expr_tree = build_tree_list (NULL_TREE, dest_tree);
6598 TREE_CHAIN (expr_tree) = build_tree_list (NULL_TREE, source_tree);
6599 TREE_CHAIN (TREE_CHAIN (expr_tree))
6600 = build_tree_list (NULL_TREE, dest_length);
6601 TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (expr_tree)))
6602 = build_tree_list (NULL_TREE, source_length);
6604 expr_tree = ffecom_call_gfrt (FFECOM_gfrtCOPY, expr_tree, NULL_TREE);
6605 TREE_SIDE_EFFECTS (expr_tree) = 1;
6607 expand_expr_stmt (expr_tree);
6611 case 1: /* The (fairly) easy case. */
6612 ffecom_char_args_ (&source_tree, &source_length,
6613 ffecom_concat_list_expr_ (catlist, 0));
6614 ffecom_concat_list_kill_ (catlist);
6615 assert (source_tree != NULL_TREE);
6616 assert (source_length != NULL_TREE);
6618 if ((source_tree == error_mark_node)
6619 || (source_length == error_mark_node))
6625 = ffecom_1 (INDIRECT_REF,
6626 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE
6630 = ffecom_2 (ARRAY_REF,
6631 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE
6636 = ffecom_1 (INDIRECT_REF,
6637 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE
6641 = ffecom_2 (ARRAY_REF,
6642 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE
6647 expr_tree = ffecom_modify (void_type_node, dest_tree, source_tree);
6649 expand_expr_stmt (expr_tree);
6654 expr_tree = build_tree_list (NULL_TREE, dest_tree);
6655 TREE_CHAIN (expr_tree) = build_tree_list (NULL_TREE, source_tree);
6656 TREE_CHAIN (TREE_CHAIN (expr_tree))
6657 = build_tree_list (NULL_TREE, dest_length);
6658 TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (expr_tree)))
6659 = build_tree_list (NULL_TREE, source_length);
6661 expr_tree = ffecom_call_gfrt (FFECOM_gfrtCOPY, expr_tree, NULL_TREE);
6662 TREE_SIDE_EFFECTS (expr_tree) = 1;
6664 expand_expr_stmt (expr_tree);
6668 default: /* Must actually concatenate things. */
6672 /* Heavy-duty concatenation. */
6675 int count = ffecom_concat_list_count_ (catlist);
6687 hook = ffebld_nonter_hook (source);
6689 assert (TREE_CODE (hook) == TREE_VEC);
6690 assert (TREE_VEC_LENGTH (hook) == 2);
6691 length_array = lengths = TREE_VEC_ELT (hook, 0);
6692 item_array = items = TREE_VEC_ELT (hook, 1);
6695 for (i = 0; i < count; ++i)
6697 ffecom_char_args_ (&citem, &clength,
6698 ffecom_concat_list_expr_ (catlist, i));
6699 if ((citem == error_mark_node)
6700 || (clength == error_mark_node))
6702 ffecom_concat_list_kill_ (catlist);
6707 = ffecom_2 (COMPOUND_EXPR, TREE_TYPE (items),
6708 ffecom_modify (void_type_node,
6709 ffecom_2 (ARRAY_REF,
6710 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (item_array))),
6712 build_int_2 (i, 0)),
6716 = ffecom_2 (COMPOUND_EXPR, TREE_TYPE (lengths),
6717 ffecom_modify (void_type_node,
6718 ffecom_2 (ARRAY_REF,
6719 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (length_array))),
6721 build_int_2 (i, 0)),
6726 expr_tree = build_tree_list (NULL_TREE, dest_tree);
6727 TREE_CHAIN (expr_tree)
6728 = build_tree_list (NULL_TREE,
6729 ffecom_1 (ADDR_EXPR,
6730 build_pointer_type (TREE_TYPE (items)),
6732 TREE_CHAIN (TREE_CHAIN (expr_tree))
6733 = build_tree_list (NULL_TREE,
6734 ffecom_1 (ADDR_EXPR,
6735 build_pointer_type (TREE_TYPE (lengths)),
6737 TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (expr_tree)))
6740 ffecom_1 (ADDR_EXPR, ffecom_f2c_ptr_to_ftnlen_type_node,
6741 convert (ffecom_f2c_ftnlen_type_node,
6742 build_int_2 (count, 0))));
6743 TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (expr_tree))))
6744 = build_tree_list (NULL_TREE, dest_length);
6746 expr_tree = ffecom_call_gfrt (FFECOM_gfrtCAT, expr_tree, NULL_TREE);
6747 TREE_SIDE_EFFECTS (expr_tree) = 1;
6749 expand_expr_stmt (expr_tree);
6752 ffecom_concat_list_kill_ (catlist);
6755 /* ffecom_make_gfrt_ -- Make initial info for run-time routine
6758 ffecom_make_gfrt_(ix);
6760 Assumes gfrt_[ix] is NULL_TREE, and replaces it with the FUNCTION_DECL
6761 for the indicated run-time routine (ix). */
6764 ffecom_make_gfrt_ (ffecomGfrt ix)
6769 switch (ffecom_gfrt_type_[ix])
6771 case FFECOM_rttypeVOID_:
6772 ttype = void_type_node;
6775 case FFECOM_rttypeVOIDSTAR_:
6776 ttype = TREE_TYPE (null_pointer_node); /* `void *'. */
6779 case FFECOM_rttypeFTNINT_:
6780 ttype = ffecom_f2c_ftnint_type_node;
6783 case FFECOM_rttypeINTEGER_:
6784 ttype = ffecom_f2c_integer_type_node;
6787 case FFECOM_rttypeLONGINT_:
6788 ttype = ffecom_f2c_longint_type_node;
6791 case FFECOM_rttypeLOGICAL_:
6792 ttype = ffecom_f2c_logical_type_node;
6795 case FFECOM_rttypeREAL_F2C_:
6796 ttype = double_type_node;
6799 case FFECOM_rttypeREAL_GNU_:
6800 ttype = float_type_node;
6803 case FFECOM_rttypeCOMPLEX_F2C_:
6804 ttype = void_type_node;
6807 case FFECOM_rttypeCOMPLEX_GNU_:
6808 ttype = ffecom_f2c_complex_type_node;
6811 case FFECOM_rttypeDOUBLE_:
6812 ttype = double_type_node;
6815 case FFECOM_rttypeDOUBLEREAL_:
6816 ttype = ffecom_f2c_doublereal_type_node;
6819 case FFECOM_rttypeDBLCMPLX_F2C_:
6820 ttype = void_type_node;
6823 case FFECOM_rttypeDBLCMPLX_GNU_:
6824 ttype = ffecom_f2c_doublecomplex_type_node;
6827 case FFECOM_rttypeCHARACTER_:
6828 ttype = void_type_node;
6833 assert ("bad rttype" == NULL);
6837 ttype = build_function_type (ttype, NULL_TREE);
6838 t = build_decl (FUNCTION_DECL,
6839 get_identifier (ffecom_gfrt_name_[ix]),
6841 DECL_EXTERNAL (t) = 1;
6842 TREE_READONLY (t) = ffecom_gfrt_const_[ix] ? 1 : 0;
6843 TREE_PUBLIC (t) = 1;
6844 TREE_THIS_VOLATILE (t) = ffecom_gfrt_volatile_[ix] ? 1 : 0;
6846 /* Sanity check: A function that's const cannot be volatile. */
6848 assert (ffecom_gfrt_const_[ix] ? !ffecom_gfrt_volatile_[ix] : 1);
6850 /* Sanity check: A function that's const cannot return complex. */
6852 assert (ffecom_gfrt_const_[ix] ? !ffecom_gfrt_complex_[ix] : 1);
6854 t = start_decl (t, TRUE);
6856 finish_decl (t, NULL_TREE, TRUE);
6858 ffecom_gfrt_[ix] = t;
6861 /* Phase 1 pass over each member of a COMMON/EQUIVALENCE group. */
6864 ffecom_member_phase1_ (ffestorag mst UNUSED, ffestorag st)
6866 ffesymbol s = ffestorag_symbol (st);
6868 if (ffesymbol_namelisted (s))
6869 ffecom_member_namelisted_ = TRUE;
6872 /* Phase 2 pass over each member of a COMMON/EQUIVALENCE group. Declare
6873 the member so debugger will see it. Otherwise nobody should be
6874 referencing the member. */
6877 ffecom_member_phase2_ (ffestorag mst, ffestorag st)
6885 || ((mt = ffestorag_hook (mst)) == NULL)
6886 || (mt == error_mark_node))
6890 || ((s = ffestorag_symbol (st)) == NULL))
6893 type = ffecom_type_localvar_ (s,
6894 ffesymbol_basictype (s),
6895 ffesymbol_kindtype (s));
6896 if (type == error_mark_node)
6899 t = build_decl (VAR_DECL,
6900 ffecom_get_identifier_ (ffesymbol_text (s)),
6903 TREE_STATIC (t) = TREE_STATIC (mt);
6904 DECL_INITIAL (t) = NULL_TREE;
6905 TREE_ASM_WRITTEN (t) = 1;
6909 gen_rtx (MEM, TYPE_MODE (type),
6910 plus_constant (XEXP (DECL_RTL (mt), 0),
6911 ffestorag_modulo (mst)
6912 + ffestorag_offset (st)
6913 - ffestorag_offset (mst))));
6915 t = start_decl (t, FALSE);
6917 finish_decl (t, NULL_TREE, FALSE);
6920 /* Prepare source expression for assignment into a destination perhaps known
6921 to be of a specific size. */
6924 ffecom_prepare_let_char_ (ffetargetCharacterSize dest_size, ffebld source)
6926 ffecomConcatList_ catlist;
6931 tree tempvar = NULL_TREE;
6933 while (ffebld_op (source) == FFEBLD_opCONVERT)
6934 source = ffebld_left (source);
6936 catlist = ffecom_concat_list_new_ (source, dest_size);
6937 count = ffecom_concat_list_count_ (catlist);
6942 = ffecom_make_tempvar ("let_char_len", ffecom_f2c_ftnlen_type_node,
6943 FFETARGET_charactersizeNONE, count);
6945 = ffecom_make_tempvar ("let_char_item", ffecom_f2c_address_type_node,
6946 FFETARGET_charactersizeNONE, count);
6948 tempvar = make_tree_vec (2);
6949 TREE_VEC_ELT (tempvar, 0) = ltmp;
6950 TREE_VEC_ELT (tempvar, 1) = itmp;
6953 for (i = 0; i < count; ++i)
6954 ffecom_prepare_arg_ptr_to_expr (ffecom_concat_list_expr_ (catlist, i));
6956 ffecom_concat_list_kill_ (catlist);
6960 ffebld_nonter_set_hook (source, tempvar);
6961 current_binding_level->prep_state = 1;
6965 /* ffecom_push_dummy_decls_ -- Transform dummy args, push parm decls in order
6967 Ignores STAR (alternate-return) dummies. All other get exec-transitioned
6968 (which generates their trees) and then their trees get push_parm_decl'd.
6970 The second arg is TRUE if the dummies are for a statement function, in
6971 which case lengths are not pushed for character arguments (since they are
6972 always known by both the caller and the callee, though the code allows
6973 for someday permitting CHAR*(*) stmtfunc dummies). */
6976 ffecom_push_dummy_decls_ (ffebld dummy_list, bool stmtfunc)
6983 ffecom_transform_only_dummies_ = TRUE;
6985 /* First push the parms corresponding to actual dummy "contents". */
6987 for (dumlist = dummy_list; dumlist != NULL; dumlist = ffebld_trail (dumlist))
6989 dummy = ffebld_head (dumlist);
6990 switch (ffebld_op (dummy))
6994 continue; /* Forget alternate returns. */
6999 assert (ffebld_op (dummy) == FFEBLD_opSYMTER);
7000 s = ffebld_symter (dummy);
7001 parm = ffesymbol_hook (s).decl_tree;
7002 if (parm == NULL_TREE)
7004 s = ffecom_sym_transform_ (s);
7005 parm = ffesymbol_hook (s).decl_tree;
7006 assert (parm != NULL_TREE);
7008 if (parm != error_mark_node)
7009 push_parm_decl (parm);
7012 /* Then, for CHARACTER dummies, push the parms giving their lengths. */
7014 for (dumlist = dummy_list; dumlist != NULL; dumlist = ffebld_trail (dumlist))
7016 dummy = ffebld_head (dumlist);
7017 switch (ffebld_op (dummy))
7021 continue; /* Forget alternate returns, they mean
7027 s = ffebld_symter (dummy);
7028 if (ffesymbol_basictype (s) != FFEINFO_basictypeCHARACTER)
7029 continue; /* Only looking for CHARACTER arguments. */
7030 if (stmtfunc && (ffesymbol_size (s) != FFETARGET_charactersizeNONE))
7031 continue; /* Stmtfunc arg with known size needs no
7033 if (ffesymbol_kind (s) != FFEINFO_kindENTITY)
7034 continue; /* Only looking for variables and arrays. */
7035 parm = ffesymbol_hook (s).length_tree;
7036 assert (parm != NULL_TREE);
7037 if (parm != error_mark_node)
7038 push_parm_decl (parm);
7041 ffecom_transform_only_dummies_ = FALSE;
7044 /* ffecom_start_progunit_ -- Beginning of program unit
7046 Does GNU back end stuff necessary to teach it about the start of its
7047 equivalent of a Fortran program unit. */
7050 ffecom_start_progunit_ (void)
7052 ffesymbol fn = ffecom_primary_entry_;
7054 tree id; /* Identifier (name) of function. */
7055 tree type; /* Type of function. */
7056 tree result; /* Result of function. */
7057 ffeinfoBasictype bt;
7061 ffeglobalType egt = FFEGLOBAL_type;
7064 bool altentries = (ffecom_num_entrypoints_ != 0);
7067 && (ffecom_primary_entry_kind_ == FFEINFO_kindFUNCTION)
7068 && (ffecom_master_bt_ == FFEINFO_basictypeNONE);
7069 bool main_program = FALSE;
7070 location_t old_loc = input_location;
7072 assert (fn != NULL);
7073 assert (ffesymbol_hook (fn).decl_tree == NULL_TREE);
7075 input_filename = ffesymbol_where_filename (fn);
7076 input_line = ffesymbol_where_filelinenum (fn);
7078 switch (ffecom_primary_entry_kind_)
7080 case FFEINFO_kindPROGRAM:
7081 main_program = TRUE;
7082 gt = FFEGLOBAL_typeMAIN;
7083 bt = FFEINFO_basictypeNONE;
7084 kt = FFEINFO_kindtypeNONE;
7085 type = ffecom_tree_fun_type_void;
7090 case FFEINFO_kindBLOCKDATA:
7091 gt = FFEGLOBAL_typeBDATA;
7092 bt = FFEINFO_basictypeNONE;
7093 kt = FFEINFO_kindtypeNONE;
7094 type = ffecom_tree_fun_type_void;
7099 case FFEINFO_kindFUNCTION:
7100 gt = FFEGLOBAL_typeFUNC;
7101 egt = FFEGLOBAL_typeEXT;
7102 bt = ffesymbol_basictype (fn);
7103 kt = ffesymbol_kindtype (fn);
7104 if (bt == FFEINFO_basictypeNONE)
7106 ffeimplic_establish_symbol (fn);
7107 if (ffesymbol_funcresult (fn) != NULL)
7108 ffeimplic_establish_symbol (ffesymbol_funcresult (fn));
7109 bt = ffesymbol_basictype (fn);
7110 kt = ffesymbol_kindtype (fn);
7114 charfunc = cmplxfunc = FALSE;
7115 else if (bt == FFEINFO_basictypeCHARACTER)
7116 charfunc = TRUE, cmplxfunc = FALSE;
7117 else if ((bt == FFEINFO_basictypeCOMPLEX)
7118 && ffesymbol_is_f2c (fn)
7120 charfunc = FALSE, cmplxfunc = TRUE;
7122 charfunc = cmplxfunc = FALSE;
7124 if (multi || charfunc)
7125 type = ffecom_tree_fun_type_void;
7126 else if (ffesymbol_is_f2c (fn) && !altentries)
7127 type = ffecom_tree_fun_type[bt][kt];
7129 type = build_function_type (ffecom_tree_type[bt][kt], NULL_TREE);
7131 if ((type == NULL_TREE)
7132 || (TREE_TYPE (type) == NULL_TREE))
7133 type = ffecom_tree_fun_type_void; /* _sym_exec_transition. */
7136 case FFEINFO_kindSUBROUTINE:
7137 gt = FFEGLOBAL_typeSUBR;
7138 egt = FFEGLOBAL_typeEXT;
7139 bt = FFEINFO_basictypeNONE;
7140 kt = FFEINFO_kindtypeNONE;
7141 if (ffecom_is_altreturning_)
7142 type = ffecom_tree_subr_type;
7144 type = ffecom_tree_fun_type_void;
7150 assert ("say what??" == NULL);
7152 case FFEINFO_kindANY:
7153 gt = FFEGLOBAL_typeANY;
7154 bt = FFEINFO_basictypeNONE;
7155 kt = FFEINFO_kindtypeNONE;
7156 type = error_mark_node;
7164 id = ffecom_get_invented_identifier ("__g77_masterfun_%s",
7165 ffesymbol_text (fn));
7167 #if FFETARGET_isENFORCED_MAIN
7168 else if (main_program)
7169 id = get_identifier (FFETARGET_nameENFORCED_MAIN_NAME);
7172 id = ffecom_get_external_identifier_ (fn);
7176 0, /* nested/inline */
7177 !altentries); /* TREE_PUBLIC */
7179 TREE_USED (current_function_decl) = 1; /* Avoid spurious warning if altentries. */
7182 && ((g = ffesymbol_global (fn)) != NULL)
7183 && ((ffeglobal_type (g) == gt)
7184 || (ffeglobal_type (g) == egt)))
7186 ffeglobal_set_hook (g, current_function_decl);
7189 /* Arg handling needs exec-transitioned ffesymbols to work with. But
7190 exec-transitioning needs current_function_decl to be filled in. So we
7191 do these things in two phases. */
7194 { /* 1st arg identifies which entrypoint. */
7195 ffecom_which_entrypoint_decl_
7196 = build_decl (PARM_DECL,
7197 ffecom_get_invented_identifier ("__g77_%s",
7198 "which_entrypoint"),
7200 push_parm_decl (ffecom_which_entrypoint_decl_);
7206 { /* Arg for result (return value). */
7211 type = ffecom_tree_type[FFEINFO_basictypeCHARACTER][kt];
7213 type = ffecom_tree_type[FFEINFO_basictypeCOMPLEX][kt];
7215 type = ffecom_multi_type_node_;
7217 result = ffecom_get_invented_identifier ("__g77_%s", "result");
7219 /* Make length arg _and_ enhance type info for CHAR arg itself. */
7222 length = ffecom_char_enhance_arg_ (&type, fn);
7224 length = NULL_TREE; /* Not ref'd if !charfunc. */
7226 type = build_pointer_type (type);
7227 result = build_decl (PARM_DECL, result, type);
7229 push_parm_decl (result);
7231 ffecom_multi_retval_ = result;
7233 ffecom_func_result_ = result;
7237 push_parm_decl (length);
7238 ffecom_func_length_ = length;
7242 if (ffecom_primary_entry_is_proc_)
7245 arglist = ffecom_master_arglist_;
7247 arglist = ffesymbol_dummyargs (fn);
7248 ffecom_push_dummy_decls_ (arglist, FALSE);
7251 if (TREE_CODE (current_function_decl) != ERROR_MARK)
7252 store_parm_decls (main_program ? 1 : 0);
7254 ffecom_start_compstmt ();
7255 /* Disallow temp vars at this level. */
7256 current_binding_level->prep_state = 2;
7258 input_location = old_loc;
7260 /* This handles any symbols still untransformed, in case -g specified.
7261 This used to be done in ffecom_finish_progunit, but it turns out to
7262 be necessary to do it here so that statement functions are
7263 expanded before code. But don't bother for BLOCK DATA. */
7265 if (ffecom_primary_entry_kind_ != FFEINFO_kindBLOCKDATA)
7266 ffesymbol_drive (ffecom_finish_symbol_transform_);
7269 /* ffecom_sym_transform_ -- Transform FFE sym into backend sym
7272 ffecom_sym_transform_(s);
7274 The ffesymbol_hook info for s is updated with appropriate backend info
7278 ffecom_sym_transform_ (ffesymbol s)
7280 tree t; /* Transformed thingy. */
7281 tree tlen; /* Length if CHAR*(*). */
7282 bool addr; /* Is t the address of the thingy? */
7283 ffeinfoBasictype bt;
7286 location_t old_loc = input_location;
7288 /* Must ensure special ASSIGN variables are declared at top of outermost
7289 block, else they'll end up in the innermost block when their first
7290 ASSIGN is seen, which leaves them out of scope when they're the
7291 subject of a GOTO or I/O statement.
7293 We make this variable even if -fugly-assign. Just let it go unused,
7294 in case it turns out there are cases where we really want to use this
7295 variable anyway (e.g. ASSIGN to INTEGER*2 variable). */
7297 if (! ffecom_transform_only_dummies_
7298 && ffesymbol_assigned (s)
7299 && ! ffesymbol_hook (s).assign_tree)
7300 s = ffecom_sym_transform_assign_ (s);
7302 if (ffesymbol_sfdummyparent (s) == NULL)
7304 input_filename = ffesymbol_where_filename (s);
7305 input_line = ffesymbol_where_filelinenum (s);
7309 ffesymbol sf = ffesymbol_sfdummyparent (s);
7311 input_filename = ffesymbol_where_filename (sf);
7312 input_line = ffesymbol_where_filelinenum (sf);
7315 bt = ffeinfo_basictype (ffebld_info (s));
7316 kt = ffeinfo_kindtype (ffebld_info (s));
7322 switch (ffesymbol_kind (s))
7324 case FFEINFO_kindNONE:
7325 switch (ffesymbol_where (s))
7327 case FFEINFO_whereDUMMY: /* Subroutine or function. */
7328 assert (ffecom_transform_only_dummies_);
7330 /* Before 0.4, this could be ENTITY/DUMMY, but see
7331 ffestu_sym_end_transition -- no longer true (in particular, if
7332 it could be an ENTITY, it _will_ be made one, so that
7333 possibility won't come through here). So we never make length
7334 arg for CHARACTER type. */
7336 t = build_decl (PARM_DECL,
7337 ffecom_get_identifier_ (ffesymbol_text (s)),
7338 ffecom_tree_ptr_to_subr_type);
7339 DECL_ARTIFICIAL (t) = 1;
7343 case FFEINFO_whereGLOBAL: /* Subroutine or function. */
7344 assert (!ffecom_transform_only_dummies_);
7346 if (((g = ffesymbol_global (s)) != NULL)
7347 && ((ffeglobal_type (g) == FFEGLOBAL_typeSUBR)
7348 || (ffeglobal_type (g) == FFEGLOBAL_typeFUNC)
7349 || (ffeglobal_type (g) == FFEGLOBAL_typeEXT))
7350 && (ffeglobal_hook (g) != NULL_TREE)
7351 && ffe_is_globals ())
7353 t = ffeglobal_hook (g);
7357 t = build_decl (FUNCTION_DECL,
7358 ffecom_get_external_identifier_ (s),
7359 ffecom_tree_subr_type); /* Assume subr. */
7360 DECL_EXTERNAL (t) = 1;
7361 TREE_PUBLIC (t) = 1;
7363 t = start_decl (t, FALSE);
7364 finish_decl (t, NULL_TREE, FALSE);
7367 && ((ffeglobal_type (g) == FFEGLOBAL_typeSUBR)
7368 || (ffeglobal_type (g) == FFEGLOBAL_typeFUNC)
7369 || (ffeglobal_type (g) == FFEGLOBAL_typeEXT)))
7370 ffeglobal_set_hook (g, t);
7372 ffecom_save_tree_forever (t);
7377 assert ("NONE where unexpected" == NULL);
7379 case FFEINFO_whereANY:
7384 case FFEINFO_kindENTITY:
7385 switch (ffeinfo_where (ffesymbol_info (s)))
7388 case FFEINFO_whereCONSTANT:
7389 /* ~~Debugging info needed? */
7390 assert (!ffecom_transform_only_dummies_);
7391 t = error_mark_node; /* Shouldn't ever see this in expr. */
7394 case FFEINFO_whereLOCAL:
7395 assert (!ffecom_transform_only_dummies_);
7398 ffestorag st = ffesymbol_storage (s);
7401 type = ffecom_type_localvar_ (s, bt, kt);
7403 if (type == error_mark_node)
7405 t = error_mark_node;
7410 && (ffestorag_size (st) == 0))
7412 t = error_mark_node;
7417 && (ffestorag_parent (st) != NULL))
7418 { /* Child of EQUIVALENCE parent. */
7421 ffetargetOffset offset;
7423 est = ffestorag_parent (st);
7424 ffecom_transform_equiv_ (est);
7426 et = ffestorag_hook (est);
7427 assert (et != NULL_TREE);
7429 if (! TREE_STATIC (et))
7430 put_var_into_stack (et, /*rescan=*/true);
7432 offset = ffestorag_modulo (est)
7433 + ffestorag_offset (ffesymbol_storage (s))
7434 - ffestorag_offset (est);
7436 ffecom_debug_kludge_ (et, "EQUIVALENCE", s, type, offset);
7438 /* (t_type *) (((char *) &et) + offset) */
7440 t = convert (string_type_node, /* (char *) */
7441 ffecom_1 (ADDR_EXPR,
7442 build_pointer_type (TREE_TYPE (et)),
7444 t = ffecom_2 (PLUS_EXPR, TREE_TYPE (t),
7446 build_int_2 (offset, 0));
7447 t = convert (build_pointer_type (type),
7449 TREE_CONSTANT (t) = staticp (et);
7456 bool init = ffesymbol_is_init (s);
7458 t = build_decl (VAR_DECL,
7459 ffecom_get_identifier_ (ffesymbol_text (s)),
7463 || ffesymbol_namelisted (s)
7464 #ifdef FFECOM_sizeMAXSTACKITEM
7466 && (ffestorag_size (st) > FFECOM_sizeMAXSTACKITEM))
7468 || ((ffecom_primary_entry_kind_ != FFEINFO_kindPROGRAM)
7469 && (ffecom_primary_entry_kind_
7470 != FFEINFO_kindBLOCKDATA)
7471 && (ffesymbol_is_save (s) || ffe_is_saveall ())))
7472 TREE_STATIC (t) = !ffesymbol_attr (s, FFESYMBOL_attrADJUSTABLE);
7474 TREE_STATIC (t) = 0; /* No need to make static. */
7476 if (init || ffe_is_init_local_zero ())
7477 DECL_INITIAL (t) = error_mark_node;
7479 /* Keep -Wunused from complaining about var if it
7480 is used as sfunc arg or DATA implied-DO. */
7481 if (ffesymbol_attrs (s) & FFESYMBOL_attrsSFARG)
7482 DECL_IN_SYSTEM_HEADER (t) = 1;
7484 t = start_decl (t, FALSE);
7488 if (ffesymbol_init (s) != NULL)
7489 initexpr = ffecom_expr (ffesymbol_init (s));
7491 initexpr = ffecom_init_zero_ (t);
7493 else if (ffe_is_init_local_zero ())
7494 initexpr = ffecom_init_zero_ (t);
7496 initexpr = NULL_TREE; /* Not ref'd if !init. */
7498 finish_decl (t, initexpr, FALSE);
7500 if (st != NULL && DECL_SIZE (t) != error_mark_node)
7502 assert (TREE_CODE (DECL_SIZE_UNIT (t)) == INTEGER_CST);
7503 assert (0 == compare_tree_int (DECL_SIZE_UNIT (t),
7504 ffestorag_size (st)));
7510 case FFEINFO_whereRESULT:
7511 assert (!ffecom_transform_only_dummies_);
7513 if (bt == FFEINFO_basictypeCHARACTER)
7514 { /* Result is already in list of dummies, use
7516 t = ffecom_func_result_;
7517 tlen = ffecom_func_length_;
7521 if ((ffecom_num_entrypoints_ == 0)
7522 && (bt == FFEINFO_basictypeCOMPLEX)
7523 && (ffesymbol_is_f2c (ffecom_primary_entry_)))
7524 { /* Result is already in list of dummies, use
7526 t = ffecom_func_result_;
7530 if (ffecom_func_result_ != NULL_TREE)
7532 t = ffecom_func_result_;
7535 if ((ffecom_num_entrypoints_ != 0)
7536 && (ffecom_master_bt_ == FFEINFO_basictypeNONE))
7538 assert (ffecom_multi_retval_ != NULL_TREE);
7539 t = ffecom_1 (INDIRECT_REF, ffecom_multi_type_node_,
7540 ffecom_multi_retval_);
7541 t = ffecom_2 (COMPONENT_REF, ffecom_tree_type[bt][kt],
7542 t, ffecom_multi_fields_[bt][kt]);
7547 t = build_decl (VAR_DECL,
7548 ffecom_get_identifier_ (ffesymbol_text (s)),
7549 ffecom_tree_type[bt][kt]);
7550 TREE_STATIC (t) = 0; /* Put result on stack. */
7551 t = start_decl (t, FALSE);
7552 finish_decl (t, NULL_TREE, FALSE);
7554 ffecom_func_result_ = t;
7558 case FFEINFO_whereDUMMY:
7566 bool adjustable = FALSE; /* Conditionally adjustable? */
7568 type = ffecom_tree_type[bt][kt];
7569 if (ffesymbol_sfdummyparent (s) != NULL)
7571 if (current_function_decl == ffecom_outer_function_decl_)
7572 { /* Exec transition before sfunc
7573 context; get it later. */
7576 t = ffecom_get_identifier_ (ffesymbol_text
7577 (ffesymbol_sfdummyparent (s)));
7580 t = ffecom_get_identifier_ (ffesymbol_text (s));
7582 assert (ffecom_transform_only_dummies_);
7584 old_sizes = get_pending_sizes ();
7585 put_pending_sizes (old_sizes);
7587 if (bt == FFEINFO_basictypeCHARACTER)
7588 tlen = ffecom_char_enhance_arg_ (&type, s);
7589 type = ffecom_check_size_overflow_ (s, type, TRUE);
7591 for (dl = ffesymbol_dims (s); dl != NULL; dl = ffebld_trail (dl))
7593 if (type == error_mark_node)
7596 dim = ffebld_head (dl);
7597 assert (ffebld_op (dim) == FFEBLD_opBOUNDS);
7598 if ((ffebld_left (dim) == NULL) || ffecom_doing_entry_)
7599 low = ffecom_integer_one_node;
7601 low = ffecom_expr (ffebld_left (dim));
7602 assert (ffebld_right (dim) != NULL);
7603 if ((ffebld_op (ffebld_right (dim)) == FFEBLD_opSTAR)
7604 || ffecom_doing_entry_)
7606 /* Used to just do high=low. But for ffecom_tree_
7607 canonize_ref_, it probably is important to correctly
7608 assess the size. E.g. given COMPLEX C(*),CFUNC and
7609 C(2)=CFUNC(C), overlap can happen, while it can't
7610 for, say, C(1)=CFUNC(C(2)). */
7611 /* Even more recently used to set to INT_MAX, but that
7612 broke when some overflow checking went into the back
7613 end. Now we just leave the upper bound unspecified. */
7617 high = ffecom_expr (ffebld_right (dim));
7619 /* Determine whether array is conditionally adjustable,
7620 to decide whether back-end magic is needed.
7622 Normally the front end uses the back-end function
7623 variable_size to wrap SAVE_EXPR's around expressions
7624 affecting the size/shape of an array so that the
7625 size/shape info doesn't change during execution
7626 of the compiled code even though variables and
7627 functions referenced in those expressions might.
7629 variable_size also makes sure those saved expressions
7630 get evaluated immediately upon entry to the
7631 compiled procedure -- the front end normally doesn't
7632 have to worry about that.
7634 However, there is a problem with this that affects
7635 g77's implementation of entry points, and that is
7636 that it is _not_ true that each invocation of the
7637 compiled procedure is permitted to evaluate
7638 array size/shape info -- because it is possible
7639 that, for some invocations, that info is invalid (in
7640 which case it is "promised" -- i.e. a violation of
7641 the Fortran standard -- that the compiled code
7642 won't reference the array or its size/shape
7643 during that particular invocation).
7645 To phrase this in C terms, consider this gcc function:
7647 void foo (int *n, float (*a)[*n])
7649 // a is "pointer to array ...", fyi.
7652 Suppose that, for some invocations, it is permitted
7653 for a caller of foo to do this:
7657 Now the _written_ code for foo can take such a call
7658 into account by either testing explicitly for whether
7659 (a == NULL) || (n == NULL) -- presumably it is
7660 not permitted to reference *a in various fashions
7661 if (n == NULL) I suppose -- or it can avoid it by
7662 looking at other info (other arguments, static/global
7665 However, this won't work in gcc 2.5.8 because it'll
7666 automatically emit the code to save the "*n"
7667 expression, which'll yield a NULL dereference for
7668 the "foo (NULL, NULL)" call, something the code
7669 for foo cannot prevent.
7671 g77 definitely needs to avoid executing such
7672 code anytime the pointer to the adjustable array
7673 is NULL, because even if its bounds expressions
7674 don't have any references to possible "absent"
7675 variables like "*n" -- say all variable references
7676 are to COMMON variables, i.e. global (though in C,
7677 local static could actually make sense) -- the
7678 expressions could yield other run-time problems
7679 for allowably "dead" values in those variables.
7681 For example, let's consider a more complicated
7687 void foo (float (*a)[i/j])
7692 The above is (essentially) quite valid for Fortran
7693 but, again, for a call like "foo (NULL);", it is
7694 permitted for i and j to be undefined when the
7695 call is made. If j happened to be zero, for
7696 example, emitting the code to evaluate "i/j"
7697 could result in a run-time error.
7699 Offhand, though I don't have my F77 or F90
7700 standards handy, it might even be valid for a
7701 bounds expression to contain a function reference,
7702 in which case I doubt it is permitted for an
7703 implementation to invoke that function in the
7704 Fortran case involved here (invocation of an
7705 alternate ENTRY point that doesn't have the adjustable
7706 array as one of its arguments).
7708 So, the code that the compiler would normally emit
7709 to preevaluate the size/shape info for an
7710 adjustable array _must not_ be executed at run time
7711 in certain cases. Specifically, for Fortran,
7712 the case is when the pointer to the adjustable
7713 array == NULL. (For gnu-ish C, it might be nice
7714 for the source code itself to specify an expression
7715 that, if TRUE, inhibits execution of the code. Or
7716 reverse the sense for elegance.)
7718 (Note that g77 could use a different test than NULL,
7719 actually, since it happens to always pass an
7720 integer to the called function that specifies which
7721 entry point is being invoked. Hmm, this might
7722 solve the next problem.)
7724 One way a user could, I suppose, write "foo" so
7725 it works is to insert COND_EXPR's for the
7726 size/shape info so the dangerous stuff isn't
7727 actually done, as in:
7729 void foo (int *n, float (*a)[(a == NULL) ? 0 : *n])
7734 The next problem is that the front end needs to
7735 be able to tell the back end about the array's
7736 decl _before_ it tells it about the conditional
7737 expression to inhibit evaluation of size/shape info,
7740 To solve this, the front end needs to be able
7741 to give the back end the expression to inhibit
7742 generation of the preevaluation code _after_
7743 it makes the decl for the adjustable array.
7745 Until then, the above example using the COND_EXPR
7746 doesn't pass muster with gcc because the "(a == NULL)"
7747 part has a reference to "a", which is still
7748 undefined at that point.
7750 g77 will therefore use a different mechanism in the
7754 && ((TREE_CODE (low) != INTEGER_CST)
7755 || (high && TREE_CODE (high) != INTEGER_CST)))
7758 #if 0 /* Old approach -- see below. */
7759 if (TREE_CODE (low) != INTEGER_CST)
7760 low = ffecom_3 (COND_EXPR, integer_type_node,
7761 ffecom_adjarray_passed_ (s),
7763 ffecom_integer_zero_node);
7765 if (high && TREE_CODE (high) != INTEGER_CST)
7766 high = ffecom_3 (COND_EXPR, integer_type_node,
7767 ffecom_adjarray_passed_ (s),
7769 ffecom_integer_zero_node);
7772 /* ~~~gcc/stor-layout.c (layout_type) should do this,
7773 probably. Fixes 950302-1.f. */
7775 if (TREE_CODE (low) != INTEGER_CST)
7776 low = variable_size (low);
7778 /* ~~~Similarly, this fixes dumb0.f. The C front end
7779 does this, which is why dumb0.c would work. */
7781 if (high && TREE_CODE (high) != INTEGER_CST)
7782 high = variable_size (high);
7787 build_range_type (ffecom_integer_type_node,
7789 type = ffecom_check_size_overflow_ (s, type, TRUE);
7792 if (type == error_mark_node)
7794 t = error_mark_node;
7798 if ((ffesymbol_sfdummyparent (s) == NULL)
7799 || (ffesymbol_basictype (s) == FFEINFO_basictypeCHARACTER))
7801 type = build_pointer_type (type);
7805 t = build_decl (PARM_DECL, t, type);
7806 DECL_ARTIFICIAL (t) = 1;
7808 /* If this arg is present in every entry point's list of
7809 dummy args, then we're done. */
7811 if (ffesymbol_numentries (s)
7812 == (ffecom_num_entrypoints_ + 1))
7817 /* If variable_size in stor-layout has been called during
7818 the above, then get_pending_sizes should have the
7819 yet-to-be-evaluated saved expressions pending.
7820 Make the whole lot of them get emitted, conditionally
7821 on whether the array decl ("t" above) is not NULL. */
7824 tree sizes = get_pending_sizes ();
7829 tem = TREE_CHAIN (tem))
7831 tree temv = TREE_VALUE (tem);
7837 = ffecom_2 (COMPOUND_EXPR,
7846 = ffecom_3 (COND_EXPR,
7853 convert (TREE_TYPE (sizes),
7854 integer_zero_node));
7855 sizes = ffecom_save_tree (sizes);
7858 = tree_cons (NULL_TREE, sizes, tem);
7862 put_pending_sizes (sizes);
7868 && (ffesymbol_numentries (s)
7869 != ffecom_num_entrypoints_ + 1))
7871 = ffecom_2 (NE_EXPR, integer_type_node,
7877 && (ffesymbol_numentries (s)
7878 != ffecom_num_entrypoints_ + 1))
7880 ffebad_start (FFEBAD_MISSING_ADJARRAY_UNSUPPORTED);
7881 ffebad_here (0, ffesymbol_where_line (s),
7882 ffesymbol_where_column (s));
7883 ffebad_string (ffesymbol_text (s));
7892 case FFEINFO_whereCOMMON:
7897 ffestorag st = ffesymbol_storage (s);
7900 cs = ffesymbol_common (s); /* The COMMON area itself. */
7901 if (st != NULL) /* Else not laid out. */
7903 ffecom_transform_common_ (cs);
7904 st = ffesymbol_storage (s);
7907 type = ffecom_type_localvar_ (s, bt, kt);
7909 cg = ffesymbol_global (cs); /* The global COMMON info. */
7911 || (ffeglobal_type (cg) != FFEGLOBAL_typeCOMMON))
7914 ct = ffeglobal_hook (cg); /* The common area's tree. */
7916 if ((ct == NULL_TREE)
7918 || (type == error_mark_node))
7919 t = error_mark_node;
7922 ffetargetOffset offset;
7926 cst = ffestorag_parent (st);
7927 assert (cst == ffesymbol_storage (cs));
7929 offset = ffestorag_modulo (cst)
7930 + ffestorag_offset (st)
7931 - ffestorag_offset (cst);
7933 ffecom_debug_kludge_ (ct, "COMMON", s, type, offset);
7935 /* (t_type *) (((char *) &ct) + offset) */
7937 t = convert (string_type_node, /* (char *) */
7938 ffecom_1 (ADDR_EXPR,
7939 build_pointer_type (TREE_TYPE (ct)),
7941 toffset = build_int_2 (offset, 0);
7942 TREE_TYPE (toffset) = ssizetype;
7943 t = ffecom_2 (PLUS_EXPR, TREE_TYPE (t),
7945 t = convert (build_pointer_type (type),
7947 TREE_CONSTANT (t) = 1;
7954 case FFEINFO_whereIMMEDIATE:
7955 case FFEINFO_whereGLOBAL:
7956 case FFEINFO_whereFLEETING:
7957 case FFEINFO_whereFLEETING_CADDR:
7958 case FFEINFO_whereFLEETING_IADDR:
7959 case FFEINFO_whereINTRINSIC:
7960 case FFEINFO_whereCONSTANT_SUBOBJECT:
7962 assert ("ENTITY where unheard of" == NULL);
7964 case FFEINFO_whereANY:
7965 t = error_mark_node;
7970 case FFEINFO_kindFUNCTION:
7971 switch (ffeinfo_where (ffesymbol_info (s)))
7973 case FFEINFO_whereLOCAL: /* Me. */
7974 assert (!ffecom_transform_only_dummies_);
7975 t = current_function_decl;
7978 case FFEINFO_whereGLOBAL:
7979 assert (!ffecom_transform_only_dummies_);
7981 if (((g = ffesymbol_global (s)) != NULL)
7982 && ((ffeglobal_type (g) == FFEGLOBAL_typeFUNC)
7983 || (ffeglobal_type (g) == FFEGLOBAL_typeEXT))
7984 && (ffeglobal_hook (g) != NULL_TREE)
7985 && ffe_is_globals ())
7987 t = ffeglobal_hook (g);
7991 if (ffesymbol_is_f2c (s)
7992 && (ffesymbol_where (s) != FFEINFO_whereCONSTANT))
7993 t = ffecom_tree_fun_type[bt][kt];
7995 t = build_function_type (ffecom_tree_type[bt][kt], NULL_TREE);
7997 t = build_decl (FUNCTION_DECL,
7998 ffecom_get_external_identifier_ (s),
8000 DECL_EXTERNAL (t) = 1;
8001 TREE_PUBLIC (t) = 1;
8003 t = start_decl (t, FALSE);
8004 finish_decl (t, NULL_TREE, FALSE);
8007 && ((ffeglobal_type (g) == FFEGLOBAL_typeFUNC)
8008 || (ffeglobal_type (g) == FFEGLOBAL_typeEXT)))
8009 ffeglobal_set_hook (g, t);
8011 ffecom_save_tree_forever (t);
8015 case FFEINFO_whereDUMMY:
8016 assert (ffecom_transform_only_dummies_);
8018 if (ffesymbol_is_f2c (s)
8019 && (ffesymbol_where (s) != FFEINFO_whereCONSTANT))
8020 t = ffecom_tree_ptr_to_fun_type[bt][kt];
8022 t = build_pointer_type
8023 (build_function_type (ffecom_tree_type[bt][kt], NULL_TREE));
8025 t = build_decl (PARM_DECL,
8026 ffecom_get_identifier_ (ffesymbol_text (s)),
8028 DECL_ARTIFICIAL (t) = 1;
8032 case FFEINFO_whereCONSTANT: /* Statement function. */
8033 assert (!ffecom_transform_only_dummies_);
8034 t = ffecom_gen_sfuncdef_ (s, bt, kt);
8037 case FFEINFO_whereINTRINSIC:
8038 assert (!ffecom_transform_only_dummies_);
8039 break; /* Let actual references generate their
8043 assert ("FUNCTION where unheard of" == NULL);
8045 case FFEINFO_whereANY:
8046 t = error_mark_node;
8051 case FFEINFO_kindSUBROUTINE:
8052 switch (ffeinfo_where (ffesymbol_info (s)))
8054 case FFEINFO_whereLOCAL: /* Me. */
8055 assert (!ffecom_transform_only_dummies_);
8056 t = current_function_decl;
8059 case FFEINFO_whereGLOBAL:
8060 assert (!ffecom_transform_only_dummies_);
8062 if (((g = ffesymbol_global (s)) != NULL)
8063 && ((ffeglobal_type (g) == FFEGLOBAL_typeSUBR)
8064 || (ffeglobal_type (g) == FFEGLOBAL_typeEXT))
8065 && (ffeglobal_hook (g) != NULL_TREE)
8066 && ffe_is_globals ())
8068 t = ffeglobal_hook (g);
8072 t = build_decl (FUNCTION_DECL,
8073 ffecom_get_external_identifier_ (s),
8074 ffecom_tree_subr_type);
8075 DECL_EXTERNAL (t) = 1;
8076 TREE_PUBLIC (t) = 1;
8078 t = start_decl (t, ffe_is_globals ());
8079 finish_decl (t, NULL_TREE, ffe_is_globals ());
8082 && ((ffeglobal_type (g) == FFEGLOBAL_typeSUBR)
8083 || (ffeglobal_type (g) == FFEGLOBAL_typeEXT)))
8084 ffeglobal_set_hook (g, t);
8086 ffecom_save_tree_forever (t);
8090 case FFEINFO_whereDUMMY:
8091 assert (ffecom_transform_only_dummies_);
8093 t = build_decl (PARM_DECL,
8094 ffecom_get_identifier_ (ffesymbol_text (s)),
8095 ffecom_tree_ptr_to_subr_type);
8096 DECL_ARTIFICIAL (t) = 1;
8100 case FFEINFO_whereINTRINSIC:
8101 assert (!ffecom_transform_only_dummies_);
8102 break; /* Let actual references generate their
8106 assert ("SUBROUTINE where unheard of" == NULL);
8108 case FFEINFO_whereANY:
8109 t = error_mark_node;
8114 case FFEINFO_kindPROGRAM:
8115 switch (ffeinfo_where (ffesymbol_info (s)))
8117 case FFEINFO_whereLOCAL: /* Me. */
8118 assert (!ffecom_transform_only_dummies_);
8119 t = current_function_decl;
8122 case FFEINFO_whereCOMMON:
8123 case FFEINFO_whereDUMMY:
8124 case FFEINFO_whereGLOBAL:
8125 case FFEINFO_whereRESULT:
8126 case FFEINFO_whereFLEETING:
8127 case FFEINFO_whereFLEETING_CADDR:
8128 case FFEINFO_whereFLEETING_IADDR:
8129 case FFEINFO_whereIMMEDIATE:
8130 case FFEINFO_whereINTRINSIC:
8131 case FFEINFO_whereCONSTANT:
8132 case FFEINFO_whereCONSTANT_SUBOBJECT:
8134 assert ("PROGRAM where unheard of" == NULL);
8136 case FFEINFO_whereANY:
8137 t = error_mark_node;
8142 case FFEINFO_kindBLOCKDATA:
8143 switch (ffeinfo_where (ffesymbol_info (s)))
8145 case FFEINFO_whereLOCAL: /* Me. */
8146 assert (!ffecom_transform_only_dummies_);
8147 t = current_function_decl;
8150 case FFEINFO_whereGLOBAL:
8151 assert (!ffecom_transform_only_dummies_);
8153 t = build_decl (FUNCTION_DECL,
8154 ffecom_get_external_identifier_ (s),
8155 ffecom_tree_blockdata_type);
8156 DECL_EXTERNAL (t) = 1;
8157 TREE_PUBLIC (t) = 1;
8159 t = start_decl (t, FALSE);
8160 finish_decl (t, NULL_TREE, FALSE);
8162 ffecom_save_tree_forever (t);
8166 case FFEINFO_whereCOMMON:
8167 case FFEINFO_whereDUMMY:
8168 case FFEINFO_whereRESULT:
8169 case FFEINFO_whereFLEETING:
8170 case FFEINFO_whereFLEETING_CADDR:
8171 case FFEINFO_whereFLEETING_IADDR:
8172 case FFEINFO_whereIMMEDIATE:
8173 case FFEINFO_whereINTRINSIC:
8174 case FFEINFO_whereCONSTANT:
8175 case FFEINFO_whereCONSTANT_SUBOBJECT:
8177 assert ("BLOCKDATA where unheard of" == NULL);
8179 case FFEINFO_whereANY:
8180 t = error_mark_node;
8185 case FFEINFO_kindCOMMON:
8186 switch (ffeinfo_where (ffesymbol_info (s)))
8188 case FFEINFO_whereLOCAL:
8189 assert (!ffecom_transform_only_dummies_);
8190 ffecom_transform_common_ (s);
8193 case FFEINFO_whereNONE:
8194 case FFEINFO_whereCOMMON:
8195 case FFEINFO_whereDUMMY:
8196 case FFEINFO_whereGLOBAL:
8197 case FFEINFO_whereRESULT:
8198 case FFEINFO_whereFLEETING:
8199 case FFEINFO_whereFLEETING_CADDR:
8200 case FFEINFO_whereFLEETING_IADDR:
8201 case FFEINFO_whereIMMEDIATE:
8202 case FFEINFO_whereINTRINSIC:
8203 case FFEINFO_whereCONSTANT:
8204 case FFEINFO_whereCONSTANT_SUBOBJECT:
8206 assert ("COMMON where unheard of" == NULL);
8208 case FFEINFO_whereANY:
8209 t = error_mark_node;
8214 case FFEINFO_kindCONSTRUCT:
8215 switch (ffeinfo_where (ffesymbol_info (s)))
8217 case FFEINFO_whereLOCAL:
8218 assert (!ffecom_transform_only_dummies_);
8221 case FFEINFO_whereNONE:
8222 case FFEINFO_whereCOMMON:
8223 case FFEINFO_whereDUMMY:
8224 case FFEINFO_whereGLOBAL:
8225 case FFEINFO_whereRESULT:
8226 case FFEINFO_whereFLEETING:
8227 case FFEINFO_whereFLEETING_CADDR:
8228 case FFEINFO_whereFLEETING_IADDR:
8229 case FFEINFO_whereIMMEDIATE:
8230 case FFEINFO_whereINTRINSIC:
8231 case FFEINFO_whereCONSTANT:
8232 case FFEINFO_whereCONSTANT_SUBOBJECT:
8234 assert ("CONSTRUCT where unheard of" == NULL);
8236 case FFEINFO_whereANY:
8237 t = error_mark_node;
8242 case FFEINFO_kindNAMELIST:
8243 switch (ffeinfo_where (ffesymbol_info (s)))
8245 case FFEINFO_whereLOCAL:
8246 assert (!ffecom_transform_only_dummies_);
8247 t = ffecom_transform_namelist_ (s);
8250 case FFEINFO_whereNONE:
8251 case FFEINFO_whereCOMMON:
8252 case FFEINFO_whereDUMMY:
8253 case FFEINFO_whereGLOBAL:
8254 case FFEINFO_whereRESULT:
8255 case FFEINFO_whereFLEETING:
8256 case FFEINFO_whereFLEETING_CADDR:
8257 case FFEINFO_whereFLEETING_IADDR:
8258 case FFEINFO_whereIMMEDIATE:
8259 case FFEINFO_whereINTRINSIC:
8260 case FFEINFO_whereCONSTANT:
8261 case FFEINFO_whereCONSTANT_SUBOBJECT:
8263 assert ("NAMELIST where unheard of" == NULL);
8265 case FFEINFO_whereANY:
8266 t = error_mark_node;
8272 assert ("kind unheard of" == NULL);
8274 case FFEINFO_kindANY:
8275 t = error_mark_node;
8279 ffesymbol_hook (s).decl_tree = t;
8280 ffesymbol_hook (s).length_tree = tlen;
8281 ffesymbol_hook (s).addr = addr;
8283 input_location = old_loc;
8288 /* Transform into ASSIGNable symbol.
8290 Symbol has already been transformed, but for whatever reason, the
8291 resulting decl_tree has been deemed not usable for an ASSIGN target.
8292 (E.g. it isn't wide enough to hold a pointer.) So, here we invent
8293 another local symbol of type void * and stuff that in the assign_tree
8294 argument. The F77/F90 standards allow this implementation. */
8297 ffecom_sym_transform_assign_ (ffesymbol s)
8299 tree t; /* Transformed thingy. */
8300 location_t old_loc = input_location;
8302 if (ffesymbol_sfdummyparent (s) == NULL)
8304 input_filename = ffesymbol_where_filename (s);
8305 input_line = ffesymbol_where_filelinenum (s);
8309 ffesymbol sf = ffesymbol_sfdummyparent (s);
8311 input_filename = ffesymbol_where_filename (sf);
8312 input_line = ffesymbol_where_filelinenum (sf);
8315 assert (!ffecom_transform_only_dummies_);
8317 t = build_decl (VAR_DECL,
8318 ffecom_get_invented_identifier ("__g77_ASSIGN_%s",
8319 ffesymbol_text (s)),
8320 TREE_TYPE (null_pointer_node));
8322 switch (ffesymbol_where (s))
8324 case FFEINFO_whereLOCAL:
8325 /* Unlike for regular vars, SAVE status is easy to determine for
8326 ASSIGNed vars, since there's no initialization, there's no
8327 effective storage association (so "SAVE J" does not apply to
8328 K even given "EQUIVALENCE (J,K)"), there's no size issue
8329 to worry about, etc. */
8330 if ((ffesymbol_is_save (s) || ffe_is_saveall ())
8331 && (ffecom_primary_entry_kind_ != FFEINFO_kindPROGRAM)
8332 && (ffecom_primary_entry_kind_ != FFEINFO_kindBLOCKDATA))
8333 TREE_STATIC (t) = 1; /* SAVEd in proc, make static. */
8335 TREE_STATIC (t) = 0; /* No need to make static. */
8338 case FFEINFO_whereCOMMON:
8339 TREE_STATIC (t) = 1; /* Assume COMMONs always SAVEd. */
8342 case FFEINFO_whereDUMMY:
8343 /* Note that twinning a DUMMY means the caller won't see
8344 the ASSIGNed value. But both F77 and F90 allow implementations
8345 to do this, i.e. disallow Fortran code that would try and
8346 take advantage of actually putting a label into a variable
8347 via a dummy argument (or any other storage association, for
8349 TREE_STATIC (t) = 0;
8353 TREE_STATIC (t) = 0;
8357 t = start_decl (t, FALSE);
8358 finish_decl (t, NULL_TREE, FALSE);
8360 ffesymbol_hook (s).assign_tree = t;
8362 input_location = old_loc;
8367 /* Implement COMMON area in back end.
8369 Because COMMON-based variables can be referenced in the dimension
8370 expressions of dummy (adjustable) arrays, and because dummies
8371 (in the gcc back end) need to be put in the outer binding level
8372 of a function (which has two binding levels, the outer holding
8373 the dummies and the inner holding the other vars), special care
8374 must be taken to handle COMMON areas.
8376 The current strategy is basically to always tell the back end about
8377 the COMMON area as a top-level external reference to just a block
8378 of storage of the master type of that area (e.g. integer, real,
8379 character, whatever -- not a structure). As a distinct action,
8380 if initial values are provided, tell the back end about the area
8381 as a top-level non-external (initialized) area and remember not to
8382 allow further initialization or expansion of the area. Meanwhile,
8383 if no initialization happens at all, tell the back end about
8384 the largest size we've seen declared so the space does get reserved.
8385 (This function doesn't handle all that stuff, but it does some
8386 of the important things.)
8388 Meanwhile, for COMMON variables themselves, just keep creating
8389 references like *((float *) (&common_area + offset)) each time
8390 we reference the variable. In other words, don't make a VAR_DECL
8391 or any kind of component reference (like we used to do before 0.4),
8392 though we might do that as well just for debugging purposes (and
8393 stuff the rtl with the appropriate offset expression). */
8396 ffecom_transform_common_ (ffesymbol s)
8398 ffestorag st = ffesymbol_storage (s);
8399 ffeglobal g = ffesymbol_global (s);
8404 bool is_init = ffestorag_is_init (st);
8406 assert (st != NULL);
8409 || (ffeglobal_type (g) != FFEGLOBAL_typeCOMMON))
8412 /* First update the size of the area in global terms. */
8414 ffeglobal_size_common (s, ffestorag_size (st));
8416 if (!ffeglobal_common_init (g))
8417 is_init = FALSE; /* No explicit init, don't let erroneous joins init. */
8419 cbt = ffeglobal_hook (g);
8421 /* If we already have declared this common block for a previous program
8422 unit, and either we already initialized it or we don't have new
8423 initialization for it, just return what we have without changing it. */
8425 if ((cbt != NULL_TREE)
8427 || !DECL_EXTERNAL (cbt)))
8429 if (st->hook == NULL) ffestorag_set_hook (st, cbt);
8433 /* Process inits. */
8437 if (ffestorag_init (st) != NULL)
8441 /* Set the padding for the expression, so ffecom_expr
8442 knows to insert that many zeros. */
8443 switch (ffebld_op (sexp = ffestorag_init (st)))
8445 case FFEBLD_opCONTER:
8446 ffebld_conter_set_pad (sexp, ffestorag_modulo (st));
8449 case FFEBLD_opARRTER:
8450 ffebld_arrter_set_pad (sexp, ffestorag_modulo (st));
8453 case FFEBLD_opACCTER:
8454 ffebld_accter_set_pad (sexp, ffestorag_modulo (st));
8458 assert ("bad op for cmn init (pad)" == NULL);
8462 init = ffecom_expr (sexp);
8463 if (init == error_mark_node)
8464 { /* Hopefully the back end complained! */
8466 if (cbt != NULL_TREE)
8471 init = error_mark_node;
8476 /* cbtype must be permanently allocated! */
8478 /* Allocate the MAX of the areas so far, seen filewide. */
8479 high = build_int_2 ((ffeglobal_common_size (g)
8480 + ffeglobal_common_pad (g)) - 1, 0);
8481 TREE_TYPE (high) = ffecom_integer_type_node;
8484 cbtype = build_array_type (char_type_node,
8485 build_range_type (integer_type_node,
8489 cbtype = build_array_type (char_type_node, NULL_TREE);
8491 if (cbt == NULL_TREE)
8494 = build_decl (VAR_DECL,
8495 ffecom_get_external_identifier_ (s),
8497 TREE_STATIC (cbt) = 1;
8498 TREE_PUBLIC (cbt) = 1;
8503 TREE_TYPE (cbt) = cbtype;
8505 DECL_EXTERNAL (cbt) = init ? 0 : 1;
8506 DECL_INITIAL (cbt) = init ? error_mark_node : NULL_TREE;
8508 cbt = start_decl (cbt, TRUE);
8509 if (ffeglobal_hook (g) != NULL)
8510 assert (cbt == ffeglobal_hook (g));
8512 assert (!init || !DECL_EXTERNAL (cbt));
8514 /* Make sure that any type can live in COMMON and be referenced
8515 without getting a bus error. We could pick the most restrictive
8516 alignment of all entities actually placed in the COMMON, but
8517 this seems easy enough. */
8519 DECL_ALIGN (cbt) = BIGGEST_ALIGNMENT;
8520 DECL_USER_ALIGN (cbt) = 0;
8522 if (is_init && (ffestorag_init (st) == NULL))
8523 init = ffecom_init_zero_ (cbt);
8525 finish_decl (cbt, init, TRUE);
8528 ffestorag_set_init (st, ffebld_new_any ());
8532 assert (DECL_SIZE_UNIT (cbt) != NULL_TREE);
8533 assert (TREE_CODE (DECL_SIZE_UNIT (cbt)) == INTEGER_CST);
8534 assert (0 == compare_tree_int (DECL_SIZE_UNIT (cbt),
8535 (ffeglobal_common_size (g)
8536 + ffeglobal_common_pad (g))));
8539 ffeglobal_set_hook (g, cbt);
8541 ffestorag_set_hook (st, cbt);
8543 ffecom_save_tree_forever (cbt);
8546 /* Make master area for local EQUIVALENCE. */
8549 ffecom_transform_equiv_ (ffestorag eqst)
8555 bool is_init = ffestorag_is_init (eqst);
8557 assert (eqst != NULL);
8559 eqt = ffestorag_hook (eqst);
8561 if (eqt != NULL_TREE)
8564 /* Process inits. */
8568 if (ffestorag_init (eqst) != NULL)
8572 /* Set the padding for the expression, so ffecom_expr
8573 knows to insert that many zeros. */
8574 switch (ffebld_op (sexp = ffestorag_init (eqst)))
8576 case FFEBLD_opCONTER:
8577 ffebld_conter_set_pad (sexp, ffestorag_modulo (eqst));
8580 case FFEBLD_opARRTER:
8581 ffebld_arrter_set_pad (sexp, ffestorag_modulo (eqst));
8584 case FFEBLD_opACCTER:
8585 ffebld_accter_set_pad (sexp, ffestorag_modulo (eqst));
8589 assert ("bad op for eqv init (pad)" == NULL);
8593 init = ffecom_expr (sexp);
8594 if (init == error_mark_node)
8595 init = NULL_TREE; /* Hopefully the back end complained! */
8598 init = error_mark_node;
8600 else if (ffe_is_init_local_zero ())
8601 init = error_mark_node;
8605 ffecom_member_namelisted_ = FALSE;
8606 ffestorag_drive (ffestorag_list_equivs (eqst),
8607 &ffecom_member_phase1_,
8610 high = build_int_2 ((ffestorag_size (eqst)
8611 + ffestorag_modulo (eqst)) - 1, 0);
8612 TREE_TYPE (high) = ffecom_integer_type_node;
8614 eqtype = build_array_type (char_type_node,
8615 build_range_type (ffecom_integer_type_node,
8616 ffecom_integer_zero_node,
8619 eqt = build_decl (VAR_DECL,
8620 ffecom_get_invented_identifier ("__g77_equiv_%s",
8622 (ffestorag_symbol (eqst))),
8624 DECL_EXTERNAL (eqt) = 0;
8626 || ffecom_member_namelisted_
8627 #ifdef FFECOM_sizeMAXSTACKITEM
8628 || (ffestorag_size (eqst) > FFECOM_sizeMAXSTACKITEM)
8630 || ((ffecom_primary_entry_kind_ != FFEINFO_kindPROGRAM)
8631 && (ffecom_primary_entry_kind_ != FFEINFO_kindBLOCKDATA)
8632 && (ffestorag_is_save (eqst) || ffe_is_saveall ())))
8633 TREE_STATIC (eqt) = 1;
8635 TREE_STATIC (eqt) = 0;
8636 TREE_PUBLIC (eqt) = 0;
8637 TREE_ADDRESSABLE (eqt) = 1; /* Ensure non-register allocation */
8638 DECL_CONTEXT (eqt) = current_function_decl;
8640 DECL_INITIAL (eqt) = error_mark_node;
8642 DECL_INITIAL (eqt) = NULL_TREE;
8644 eqt = start_decl (eqt, FALSE);
8646 /* Make sure that any type can live in EQUIVALENCE and be referenced
8647 without getting a bus error. We could pick the most restrictive
8648 alignment of all entities actually placed in the EQUIVALENCE, but
8649 this seems easy enough. */
8651 DECL_ALIGN (eqt) = BIGGEST_ALIGNMENT;
8652 DECL_USER_ALIGN (eqt) = 0;
8654 if ((!is_init && ffe_is_init_local_zero ())
8655 || (is_init && (ffestorag_init (eqst) == NULL)))
8656 init = ffecom_init_zero_ (eqt);
8658 finish_decl (eqt, init, FALSE);
8661 ffestorag_set_init (eqst, ffebld_new_any ());
8664 assert (TREE_CODE (DECL_SIZE_UNIT (eqt)) == INTEGER_CST);
8665 assert (0 == compare_tree_int (DECL_SIZE_UNIT (eqt),
8666 (ffestorag_size (eqst)
8667 + ffestorag_modulo (eqst))));
8670 ffestorag_set_hook (eqst, eqt);
8672 ffestorag_drive (ffestorag_list_equivs (eqst),
8673 &ffecom_member_phase2_,
8677 /* Implement NAMELIST in back end. See f2c/format.c for more info. */
8680 ffecom_transform_namelist_ (ffesymbol s)
8683 tree nmltype = ffecom_type_namelist_ ();
8691 static int mynumber = 0;
8693 nmlt = build_decl (VAR_DECL,
8694 ffecom_get_invented_identifier ("__g77_namelist_%d",
8697 TREE_STATIC (nmlt) = 1;
8698 DECL_INITIAL (nmlt) = error_mark_node;
8700 nmlt = start_decl (nmlt, FALSE);
8702 /* Process inits. */
8704 i = strlen (ffesymbol_text (s));
8706 high = build_int_2 (i, 0);
8707 TREE_TYPE (high) = ffecom_f2c_ftnlen_type_node;
8709 nameinit = ffecom_build_f2c_string_ (i + 1,
8710 ffesymbol_text (s));
8711 TREE_TYPE (nameinit)
8712 = build_type_variant
8715 build_range_type (ffecom_f2c_ftnlen_type_node,
8716 ffecom_f2c_ftnlen_one_node,
8719 TREE_CONSTANT (nameinit) = 1;
8720 TREE_STATIC (nameinit) = 1;
8721 nameinit = ffecom_1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (nameinit)),
8724 varsinit = ffecom_vardesc_array_ (s);
8725 varsinit = ffecom_1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (varsinit)),
8727 TREE_CONSTANT (varsinit) = 1;
8728 TREE_STATIC (varsinit) = 1;
8733 for (i = 0, b = ffesymbol_namelist (s); b != NULL; b = ffebld_trail (b))
8736 nvarsinit = build_int_2 (i, 0);
8737 TREE_TYPE (nvarsinit) = integer_type_node;
8738 TREE_CONSTANT (nvarsinit) = 1;
8739 TREE_STATIC (nvarsinit) = 1;
8741 nmlinits = build_tree_list ((field = TYPE_FIELDS (nmltype)), nameinit);
8742 TREE_CHAIN (nmlinits) = build_tree_list ((field = TREE_CHAIN (field)),
8744 TREE_CHAIN (TREE_CHAIN (nmlinits))
8745 = build_tree_list ((field = TREE_CHAIN (field)), nvarsinit);
8747 nmlinits = build_constructor (nmltype, nmlinits);
8748 TREE_CONSTANT (nmlinits) = 1;
8749 TREE_STATIC (nmlinits) = 1;
8751 finish_decl (nmlt, nmlinits, FALSE);
8753 nmlt = ffecom_1 (ADDR_EXPR, build_pointer_type (nmltype), nmlt);
8758 /* A subroutine of ffecom_tree_canonize_ref_. The incoming tree is
8759 analyzed on the assumption it is calculating a pointer to be
8760 indirected through. It must return the proper decl and offset,
8761 taking into account different units of measurements for offsets. */
8764 ffecom_tree_canonize_ptr_ (tree *decl, tree *offset, tree t)
8766 switch (TREE_CODE (t))
8770 case NON_LVALUE_EXPR:
8771 ffecom_tree_canonize_ptr_ (decl, offset, TREE_OPERAND (t, 0));
8775 ffecom_tree_canonize_ptr_ (decl, offset, TREE_OPERAND (t, 0));
8776 if ((*decl == NULL_TREE)
8777 || (*decl == error_mark_node))
8780 if (TREE_CODE (TREE_OPERAND (t, 1)) == INTEGER_CST)
8782 /* An offset into COMMON. */
8783 *offset = fold (build (PLUS_EXPR, TREE_TYPE (*offset),
8784 *offset, TREE_OPERAND (t, 1)));
8785 /* Convert offset (presumably in bytes) into canonical units
8786 (presumably bits). */
8787 *offset = size_binop (MULT_EXPR,
8788 convert (bitsizetype, *offset),
8789 TYPE_SIZE (TREE_TYPE (TREE_TYPE (t))));
8792 /* Not a COMMON reference, so an unrecognized pattern. */
8793 *decl = error_mark_node;
8798 *offset = bitsize_zero_node;
8802 if (TREE_CODE (TREE_OPERAND (t, 0)) == VAR_DECL)
8804 /* A reference to COMMON. */
8805 *decl = TREE_OPERAND (t, 0);
8806 *offset = bitsize_zero_node;
8811 /* Not a COMMON reference, so an unrecognized pattern. */
8812 *decl = error_mark_node;
8817 /* Given a tree that is possibly intended for use as an lvalue, return
8818 information representing a canonical view of that tree as a decl, an
8819 offset into that decl, and a size for the lvalue.
8821 If there's no applicable decl, NULL_TREE is returned for the decl,
8822 and the other fields are left undefined.
8824 If the tree doesn't fit the recognizable forms, an ERROR_MARK node
8825 is returned for the decl, and the other fields are left undefined.
8827 Otherwise, the decl returned currently is either a VAR_DECL or a
8830 The offset returned is always valid, but of course not necessarily
8831 a constant, and not necessarily converted into the appropriate
8832 type, leaving that up to the caller (so as to avoid that overhead
8833 if the decls being looked at are different anyway).
8835 If the size cannot be determined (e.g. an adjustable array),
8836 an ERROR_MARK node is returned for the size. Otherwise, the
8837 size returned is valid, not necessarily a constant, and not
8838 necessarily converted into the appropriate type as with the
8841 Note that the offset and size expressions are expressed in the
8842 base storage units (usually bits) rather than in the units of
8843 the type of the decl, because two decls with different types
8844 might overlap but with apparently non-overlapping array offsets,
8845 whereas converting the array offsets to consistant offsets will
8846 reveal the overlap. */
8849 ffecom_tree_canonize_ref_ (tree *decl, tree *offset, tree *size, tree t)
8851 /* The default path is to report a nonexistant decl. */
8857 switch (TREE_CODE (t))
8860 case IDENTIFIER_NODE:
8869 case TRUNC_DIV_EXPR:
8871 case FLOOR_DIV_EXPR:
8872 case ROUND_DIV_EXPR:
8873 case TRUNC_MOD_EXPR:
8875 case FLOOR_MOD_EXPR:
8876 case ROUND_MOD_EXPR:
8878 case EXACT_DIV_EXPR:
8879 case FIX_TRUNC_EXPR:
8881 case FIX_FLOOR_EXPR:
8882 case FIX_ROUND_EXPR:
8896 case TRUTH_ANDIF_EXPR:
8897 case TRUTH_ORIF_EXPR:
8898 case TRUTH_AND_EXPR:
8900 case TRUTH_XOR_EXPR:
8901 case TRUTH_NOT_EXPR:
8921 *offset = bitsize_zero_node;
8922 *size = TYPE_SIZE (TREE_TYPE (t));
8927 tree array = TREE_OPERAND (t, 0);
8928 tree element = TREE_OPERAND (t, 1);
8931 if ((array == NULL_TREE)
8932 || (element == NULL_TREE))
8934 *decl = error_mark_node;
8938 ffecom_tree_canonize_ref_ (decl, &init_offset, size,
8940 if ((*decl == NULL_TREE)
8941 || (*decl == error_mark_node))
8944 /* Calculate ((element - base) * NBBY) + init_offset. */
8945 *offset = fold (build (MINUS_EXPR, TREE_TYPE (element),
8947 TYPE_MIN_VALUE (TYPE_DOMAIN
8948 (TREE_TYPE (array)))));
8950 *offset = size_binop (MULT_EXPR,
8951 convert (bitsizetype, *offset),
8952 TYPE_SIZE (TREE_TYPE (TREE_TYPE (array))));
8954 *offset = size_binop (PLUS_EXPR, init_offset, *offset);
8956 *size = TYPE_SIZE (TREE_TYPE (t));
8962 /* Most of this code is to handle references to COMMON. And so
8963 far that is useful only for calling library functions, since
8964 external (user) functions might reference common areas. But
8965 even calling an external function, it's worthwhile to decode
8966 COMMON references because if not storing into COMMON, we don't
8967 want COMMON-based arguments to gratuitously force use of a
8970 *size = TYPE_SIZE (TREE_TYPE (t));
8972 ffecom_tree_canonize_ptr_ (decl, offset,
8973 TREE_OPERAND (t, 0));
8980 case NON_LVALUE_EXPR:
8983 case COND_EXPR: /* More cases than we can handle. */
8985 case REFERENCE_EXPR:
8986 case PREDECREMENT_EXPR:
8987 case PREINCREMENT_EXPR:
8988 case POSTDECREMENT_EXPR:
8989 case POSTINCREMENT_EXPR:
8992 *decl = error_mark_node;
8997 /* Do divide operation appropriate to type of operands. */
9000 ffecom_tree_divide_ (tree tree_type, tree left, tree right, tree dest_tree,
9001 ffebld dest, bool *dest_used, tree hook)
9003 if ((left == error_mark_node)
9004 || (right == error_mark_node))
9005 return error_mark_node;
9007 switch (TREE_CODE (tree_type))
9010 return ffecom_2 (TRUNC_DIV_EXPR, tree_type,
9015 if (! optimize_size)
9016 return ffecom_2 (RDIV_EXPR, tree_type,
9022 if (TREE_TYPE (tree_type)
9023 == ffecom_tree_type [FFEINFO_basictypeREAL][FFEINFO_kindtypeREAL1])
9024 ix = FFECOM_gfrtDIV_CC; /* Overlapping result okay. */
9026 ix = FFECOM_gfrtDIV_ZZ; /* Overlapping result okay. */
9028 left = ffecom_1 (ADDR_EXPR,
9029 build_pointer_type (TREE_TYPE (left)),
9031 left = build_tree_list (NULL_TREE, left);
9032 right = ffecom_1 (ADDR_EXPR,
9033 build_pointer_type (TREE_TYPE (right)),
9035 right = build_tree_list (NULL_TREE, right);
9036 TREE_CHAIN (left) = right;
9038 return ffecom_call_ (ffecom_gfrt_tree_ (ix),
9039 ffecom_gfrt_kindtype (ix),
9040 ffe_is_f2c_library (),
9043 dest_tree, dest, dest_used,
9044 NULL_TREE, TRUE, hook);
9052 if (TREE_TYPE (TYPE_FIELDS (tree_type))
9053 == ffecom_tree_type [FFEINFO_basictypeREAL][FFEINFO_kindtypeREAL1])
9054 ix = FFECOM_gfrtDIV_CC; /* Overlapping result okay. */
9056 ix = FFECOM_gfrtDIV_ZZ; /* Overlapping result okay. */
9058 left = ffecom_1 (ADDR_EXPR,
9059 build_pointer_type (TREE_TYPE (left)),
9061 left = build_tree_list (NULL_TREE, left);
9062 right = ffecom_1 (ADDR_EXPR,
9063 build_pointer_type (TREE_TYPE (right)),
9065 right = build_tree_list (NULL_TREE, right);
9066 TREE_CHAIN (left) = right;
9068 return ffecom_call_ (ffecom_gfrt_tree_ (ix),
9069 ffecom_gfrt_kindtype (ix),
9070 ffe_is_f2c_library (),
9073 dest_tree, dest, dest_used,
9074 NULL_TREE, TRUE, hook);
9079 return ffecom_2 (RDIV_EXPR, tree_type,
9085 /* Build type info for non-dummy variable. */
9088 ffecom_type_localvar_ (ffesymbol s, ffeinfoBasictype bt, ffeinfoKindtype kt)
9096 type = ffecom_tree_type[bt][kt];
9097 if (bt == FFEINFO_basictypeCHARACTER)
9099 hight = build_int_2 (ffesymbol_size (s), 0);
9100 TREE_TYPE (hight) = ffecom_f2c_ftnlen_type_node;
9105 build_range_type (ffecom_f2c_ftnlen_type_node,
9106 ffecom_f2c_ftnlen_one_node,
9108 type = ffecom_check_size_overflow_ (s, type, FALSE);
9111 for (dl = ffesymbol_dims (s); dl != NULL; dl = ffebld_trail (dl))
9113 if (type == error_mark_node)
9116 dim = ffebld_head (dl);
9117 assert (ffebld_op (dim) == FFEBLD_opBOUNDS);
9119 if (ffebld_left (dim) == NULL)
9120 lowt = integer_one_node;
9122 lowt = ffecom_expr (ffebld_left (dim));
9124 if (TREE_CODE (lowt) != INTEGER_CST)
9125 lowt = variable_size (lowt);
9127 assert (ffebld_right (dim) != NULL);
9128 hight = ffecom_expr (ffebld_right (dim));
9130 if (TREE_CODE (hight) != INTEGER_CST)
9131 hight = variable_size (hight);
9133 type = build_array_type (type,
9134 build_range_type (ffecom_integer_type_node,
9136 type = ffecom_check_size_overflow_ (s, type, FALSE);
9142 /* Build Namelist type. */
9144 static GTY(()) tree ffecom_type_namelist_var;
9146 ffecom_type_namelist_ (void)
9148 if (ffecom_type_namelist_var == NULL_TREE)
9150 tree namefield, varsfield, nvarsfield, vardesctype, type;
9152 vardesctype = ffecom_type_vardesc_ ();
9154 type = make_node (RECORD_TYPE);
9156 vardesctype = build_pointer_type (build_pointer_type (vardesctype));
9158 namefield = ffecom_decl_field (type, NULL_TREE, "name",
9160 varsfield = ffecom_decl_field (type, namefield, "vars", vardesctype);
9161 nvarsfield = ffecom_decl_field (type, varsfield, "nvars",
9164 TYPE_FIELDS (type) = namefield;
9167 ffecom_type_namelist_var = type;
9170 return ffecom_type_namelist_var;
9173 /* Build Vardesc type. */
9175 static GTY(()) tree ffecom_type_vardesc_var;
9177 ffecom_type_vardesc_ (void)
9179 if (ffecom_type_vardesc_var == NULL_TREE)
9181 tree namefield, addrfield, dimsfield, typefield, type;
9182 type = make_node (RECORD_TYPE);
9184 namefield = ffecom_decl_field (type, NULL_TREE, "name",
9186 addrfield = ffecom_decl_field (type, namefield, "addr",
9188 dimsfield = ffecom_decl_field (type, addrfield, "dims",
9189 ffecom_f2c_ptr_to_ftnlen_type_node);
9190 typefield = ffecom_decl_field (type, dimsfield, "type",
9193 TYPE_FIELDS (type) = namefield;
9196 ffecom_type_vardesc_var = type;
9199 return ffecom_type_vardesc_var;
9203 ffecom_vardesc_ (ffebld expr)
9207 assert (ffebld_op (expr) == FFEBLD_opSYMTER);
9208 s = ffebld_symter (expr);
9210 if (ffesymbol_hook (s).vardesc_tree == NULL_TREE)
9213 tree vardesctype = ffecom_type_vardesc_ ();
9221 static int mynumber = 0;
9223 var = build_decl (VAR_DECL,
9224 ffecom_get_invented_identifier ("__g77_vardesc_%d",
9227 TREE_STATIC (var) = 1;
9228 DECL_INITIAL (var) = error_mark_node;
9230 var = start_decl (var, FALSE);
9232 /* Process inits. */
9234 nameinit = ffecom_build_f2c_string_ ((i = strlen (ffesymbol_text (s)))
9236 ffesymbol_text (s));
9237 TREE_TYPE (nameinit)
9238 = build_type_variant
9241 build_range_type (integer_type_node,
9243 build_int_2 (i, 0))),
9245 TREE_CONSTANT (nameinit) = 1;
9246 TREE_STATIC (nameinit) = 1;
9247 nameinit = ffecom_1 (ADDR_EXPR,
9248 build_pointer_type (TREE_TYPE (nameinit)),
9251 addrinit = ffecom_arg_ptr_to_expr (expr, &typeinit);
9253 dimsinit = ffecom_vardesc_dims_ (s);
9255 if (typeinit == NULL_TREE)
9257 ffeinfoBasictype bt = ffesymbol_basictype (s);
9258 ffeinfoKindtype kt = ffesymbol_kindtype (s);
9259 int tc = ffecom_f2c_typecode (bt, kt);
9262 typeinit = build_int_2 (tc, (tc < 0) ? -1 : 0);
9265 typeinit = ffecom_1 (NEGATE_EXPR, TREE_TYPE (typeinit), typeinit);
9267 varinits = build_tree_list ((field = TYPE_FIELDS (vardesctype)),
9269 TREE_CHAIN (varinits) = build_tree_list ((field = TREE_CHAIN (field)),
9271 TREE_CHAIN (TREE_CHAIN (varinits))
9272 = build_tree_list ((field = TREE_CHAIN (field)), dimsinit);
9273 TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (varinits)))
9274 = build_tree_list ((field = TREE_CHAIN (field)), typeinit);
9276 varinits = build_constructor (vardesctype, varinits);
9277 TREE_CONSTANT (varinits) = 1;
9278 TREE_STATIC (varinits) = 1;
9280 finish_decl (var, varinits, FALSE);
9282 var = ffecom_1 (ADDR_EXPR, build_pointer_type (vardesctype), var);
9284 ffesymbol_hook (s).vardesc_tree = var;
9287 return ffesymbol_hook (s).vardesc_tree;
9291 ffecom_vardesc_array_ (ffesymbol s)
9295 tree item = NULL_TREE;
9298 static int mynumber = 0;
9300 for (i = 0, list = NULL_TREE, b = ffesymbol_namelist (s);
9302 b = ffebld_trail (b), ++i)
9306 t = ffecom_vardesc_ (ffebld_head (b));
9308 if (list == NULL_TREE)
9309 list = item = build_tree_list (NULL_TREE, t);
9312 TREE_CHAIN (item) = build_tree_list (NULL_TREE, t);
9313 item = TREE_CHAIN (item);
9317 item = build_array_type (build_pointer_type (ffecom_type_vardesc_ ()),
9318 build_range_type (integer_type_node,
9320 build_int_2 (i, 0)));
9321 list = build_constructor (item, list);
9322 TREE_CONSTANT (list) = 1;
9323 TREE_STATIC (list) = 1;
9325 var = ffecom_get_invented_identifier ("__g77_vardesc_array_%d", mynumber++);
9326 var = build_decl (VAR_DECL, var, item);
9327 TREE_STATIC (var) = 1;
9328 DECL_INITIAL (var) = error_mark_node;
9329 var = start_decl (var, FALSE);
9330 finish_decl (var, list, FALSE);
9336 ffecom_vardesc_dims_ (ffesymbol s)
9338 if (ffesymbol_dims (s) == NULL)
9339 return convert (ffecom_f2c_ptr_to_ftnlen_type_node,
9347 tree item = NULL_TREE;
9351 tree baseoff = NULL_TREE;
9352 static int mynumber = 0;
9354 numdim = build_int_2 ((int) ffesymbol_rank (s), 0);
9355 TREE_TYPE (numdim) = ffecom_f2c_ftnlen_type_node;
9357 numelem = ffecom_expr (ffesymbol_arraysize (s));
9358 TREE_TYPE (numelem) = ffecom_f2c_ftnlen_type_node;
9361 backlist = NULL_TREE;
9362 for (b = ffesymbol_dims (s), e = ffesymbol_extents (s);
9364 b = ffebld_trail (b), e = ffebld_trail (e))
9370 if (ffebld_trail (b) == NULL)
9374 t = convert (ffecom_f2c_ftnlen_type_node,
9375 ffecom_expr (ffebld_head (e)));
9377 if (list == NULL_TREE)
9378 list = item = build_tree_list (NULL_TREE, t);
9381 TREE_CHAIN (item) = build_tree_list (NULL_TREE, t);
9382 item = TREE_CHAIN (item);
9386 if (ffebld_left (ffebld_head (b)) == NULL)
9387 low = ffecom_integer_one_node;
9389 low = ffecom_expr (ffebld_left (ffebld_head (b)));
9390 low = convert (ffecom_f2c_ftnlen_type_node, low);
9392 back = build_tree_list (low, t);
9393 TREE_CHAIN (back) = backlist;
9397 for (item = backlist; item != NULL_TREE; item = TREE_CHAIN (item))
9399 if (TREE_VALUE (item) == NULL_TREE)
9400 baseoff = TREE_PURPOSE (item);
9402 baseoff = ffecom_2 (PLUS_EXPR, ffecom_f2c_ftnlen_type_node,
9403 TREE_PURPOSE (item),
9404 ffecom_2 (MULT_EXPR,
9405 ffecom_f2c_ftnlen_type_node,
9410 /* backlist now dead, along with all TREE_PURPOSEs on it. */
9412 baseoff = build_tree_list (NULL_TREE, baseoff);
9413 TREE_CHAIN (baseoff) = list;
9415 numelem = build_tree_list (NULL_TREE, numelem);
9416 TREE_CHAIN (numelem) = baseoff;
9418 numdim = build_tree_list (NULL_TREE, numdim);
9419 TREE_CHAIN (numdim) = numelem;
9421 item = build_array_type (ffecom_f2c_ftnlen_type_node,
9422 build_range_type (integer_type_node,
9425 ((int) ffesymbol_rank (s)
9427 list = build_constructor (item, numdim);
9428 TREE_CONSTANT (list) = 1;
9429 TREE_STATIC (list) = 1;
9431 var = ffecom_get_invented_identifier ("__g77_dims_%d", mynumber++);
9432 var = build_decl (VAR_DECL, var, item);
9433 TREE_STATIC (var) = 1;
9434 DECL_INITIAL (var) = error_mark_node;
9435 var = start_decl (var, FALSE);
9436 finish_decl (var, list, FALSE);
9438 var = ffecom_1 (ADDR_EXPR, build_pointer_type (item), var);
9444 /* Essentially does a "fold (build1 (code, type, node))" while checking
9445 for certain housekeeping things.
9447 NOTE: for building an ADDR_EXPR around a FUNCTION_DECL, use
9448 ffecom_1_fn instead. */
9451 ffecom_1 (enum tree_code code, tree type, tree node)
9455 if ((node == error_mark_node)
9456 || (type == error_mark_node))
9457 return error_mark_node;
9459 if (code == ADDR_EXPR)
9461 if (!ffe_mark_addressable (node))
9462 assert ("can't mark_addressable this node!" == NULL);
9465 switch (ffe_is_emulate_complex () ? code : NOP_EXPR)
9470 item = build (COMPONENT_REF, type, node, TYPE_FIELDS (TREE_TYPE (node)));
9474 item = build (COMPONENT_REF, type, node, TREE_CHAIN (TYPE_FIELDS (TREE_TYPE (node))));
9479 if (TREE_CODE (type) != RECORD_TYPE)
9481 item = build1 (code, type, node);
9484 node = ffecom_stabilize_aggregate_ (node);
9485 realtype = TREE_TYPE (TYPE_FIELDS (type));
9487 ffecom_2 (COMPLEX_EXPR, type,
9488 ffecom_1 (NEGATE_EXPR, realtype,
9489 ffecom_1 (REALPART_EXPR, realtype,
9491 ffecom_1 (NEGATE_EXPR, realtype,
9492 ffecom_1 (IMAGPART_EXPR, realtype,
9497 item = build1 (code, type, node);
9501 if (TREE_SIDE_EFFECTS (node))
9502 TREE_SIDE_EFFECTS (item) = 1;
9503 if (code == ADDR_EXPR && staticp (node))
9504 TREE_CONSTANT (item) = 1;
9505 else if (code == INDIRECT_REF)
9506 TREE_READONLY (item) = TYPE_READONLY (type);
9510 /* Like ffecom_1 (ADDR_EXPR, TREE_TYPE (node), node), except
9511 handles TREE_CODE (node) == FUNCTION_DECL. In particular,
9512 does not set TREE_ADDRESSABLE (because calling an inline
9513 function does not mean the function needs to be separately
9517 ffecom_1_fn (tree node)
9522 if (node == error_mark_node)
9523 return error_mark_node;
9525 type = build_type_variant (TREE_TYPE (node),
9526 TREE_READONLY (node),
9527 TREE_THIS_VOLATILE (node));
9528 item = build1 (ADDR_EXPR,
9529 build_pointer_type (type), node);
9530 if (TREE_SIDE_EFFECTS (node))
9531 TREE_SIDE_EFFECTS (item) = 1;
9533 TREE_CONSTANT (item) = 1;
9537 /* Essentially does a "fold (build (code, type, node1, node2))" while
9538 checking for certain housekeeping things. */
9541 ffecom_2 (enum tree_code code, tree type, tree node1, tree node2)
9545 if ((node1 == error_mark_node)
9546 || (node2 == error_mark_node)
9547 || (type == error_mark_node))
9548 return error_mark_node;
9550 switch (ffe_is_emulate_complex () ? code : NOP_EXPR)
9552 tree a, b, c, d, realtype;
9555 assert ("no CONJ_EXPR support yet" == NULL);
9556 return error_mark_node;
9559 item = build_tree_list (TYPE_FIELDS (type), node1);
9560 TREE_CHAIN (item) = build_tree_list (TREE_CHAIN (TYPE_FIELDS (type)), node2);
9561 item = build_constructor (type, item);
9565 if (TREE_CODE (type) != RECORD_TYPE)
9567 item = build (code, type, node1, node2);
9570 node1 = ffecom_stabilize_aggregate_ (node1);
9571 node2 = ffecom_stabilize_aggregate_ (node2);
9572 realtype = TREE_TYPE (TYPE_FIELDS (type));
9574 ffecom_2 (COMPLEX_EXPR, type,
9575 ffecom_2 (PLUS_EXPR, realtype,
9576 ffecom_1 (REALPART_EXPR, realtype,
9578 ffecom_1 (REALPART_EXPR, realtype,
9580 ffecom_2 (PLUS_EXPR, realtype,
9581 ffecom_1 (IMAGPART_EXPR, realtype,
9583 ffecom_1 (IMAGPART_EXPR, realtype,
9588 if (TREE_CODE (type) != RECORD_TYPE)
9590 item = build (code, type, node1, node2);
9593 node1 = ffecom_stabilize_aggregate_ (node1);
9594 node2 = ffecom_stabilize_aggregate_ (node2);
9595 realtype = TREE_TYPE (TYPE_FIELDS (type));
9597 ffecom_2 (COMPLEX_EXPR, type,
9598 ffecom_2 (MINUS_EXPR, realtype,
9599 ffecom_1 (REALPART_EXPR, realtype,
9601 ffecom_1 (REALPART_EXPR, realtype,
9603 ffecom_2 (MINUS_EXPR, realtype,
9604 ffecom_1 (IMAGPART_EXPR, realtype,
9606 ffecom_1 (IMAGPART_EXPR, realtype,
9611 if (TREE_CODE (type) != RECORD_TYPE)
9613 item = build (code, type, node1, node2);
9616 node1 = ffecom_stabilize_aggregate_ (node1);
9617 node2 = ffecom_stabilize_aggregate_ (node2);
9618 realtype = TREE_TYPE (TYPE_FIELDS (type));
9619 a = save_expr (ffecom_1 (REALPART_EXPR, realtype,
9621 b = save_expr (ffecom_1 (IMAGPART_EXPR, realtype,
9623 c = save_expr (ffecom_1 (REALPART_EXPR, realtype,
9625 d = save_expr (ffecom_1 (IMAGPART_EXPR, realtype,
9628 ffecom_2 (COMPLEX_EXPR, type,
9629 ffecom_2 (MINUS_EXPR, realtype,
9630 ffecom_2 (MULT_EXPR, realtype,
9633 ffecom_2 (MULT_EXPR, realtype,
9636 ffecom_2 (PLUS_EXPR, realtype,
9637 ffecom_2 (MULT_EXPR, realtype,
9640 ffecom_2 (MULT_EXPR, realtype,
9646 if ((TREE_CODE (node1) != RECORD_TYPE)
9647 && (TREE_CODE (node2) != RECORD_TYPE))
9649 item = build (code, type, node1, node2);
9652 assert (TREE_CODE (node1) == RECORD_TYPE);
9653 assert (TREE_CODE (node2) == RECORD_TYPE);
9654 node1 = ffecom_stabilize_aggregate_ (node1);
9655 node2 = ffecom_stabilize_aggregate_ (node2);
9656 realtype = TREE_TYPE (TYPE_FIELDS (type));
9658 ffecom_2 (TRUTH_ANDIF_EXPR, type,
9659 ffecom_2 (code, type,
9660 ffecom_1 (REALPART_EXPR, realtype,
9662 ffecom_1 (REALPART_EXPR, realtype,
9664 ffecom_2 (code, type,
9665 ffecom_1 (IMAGPART_EXPR, realtype,
9667 ffecom_1 (IMAGPART_EXPR, realtype,
9672 if ((TREE_CODE (node1) != RECORD_TYPE)
9673 && (TREE_CODE (node2) != RECORD_TYPE))
9675 item = build (code, type, node1, node2);
9678 assert (TREE_CODE (node1) == RECORD_TYPE);
9679 assert (TREE_CODE (node2) == RECORD_TYPE);
9680 node1 = ffecom_stabilize_aggregate_ (node1);
9681 node2 = ffecom_stabilize_aggregate_ (node2);
9682 realtype = TREE_TYPE (TYPE_FIELDS (type));
9684 ffecom_2 (TRUTH_ORIF_EXPR, type,
9685 ffecom_2 (code, type,
9686 ffecom_1 (REALPART_EXPR, realtype,
9688 ffecom_1 (REALPART_EXPR, realtype,
9690 ffecom_2 (code, type,
9691 ffecom_1 (IMAGPART_EXPR, realtype,
9693 ffecom_1 (IMAGPART_EXPR, realtype,
9698 item = build (code, type, node1, node2);
9702 if (TREE_SIDE_EFFECTS (node1) || TREE_SIDE_EFFECTS (node2))
9703 TREE_SIDE_EFFECTS (item) = 1;
9707 /* ffecom_2pass_advise_entrypoint -- Advise that there's this entrypoint
9709 ffesymbol s; // the ENTRY point itself
9710 if (ffecom_2pass_advise_entrypoint(s))
9711 // the ENTRY point has been accepted
9713 Does whatever compiler needs to do when it learns about the entrypoint,
9714 like determine the return type of the master function, count the
9715 number of entrypoints, etc. Returns FALSE if the return type is
9716 not compatible with the return type(s) of other entrypoint(s).
9718 NOTE: for every call to this fn that returns TRUE, _do_entrypoint must
9719 later (after _finish_progunit) be called with the same entrypoint(s)
9720 as passed to this fn for which TRUE was returned.
9723 Return FALSE if the return type conflicts with previous entrypoints. */
9726 ffecom_2pass_advise_entrypoint (ffesymbol entry)
9728 ffebld list; /* opITEM. */
9729 ffebld mlist; /* opITEM. */
9730 ffebld plist; /* opITEM. */
9731 ffebld arg; /* ffebld_head(opITEM). */
9732 ffebld item; /* opITEM. */
9733 ffesymbol s; /* ffebld_symter(arg). */
9734 ffeinfoBasictype bt = ffesymbol_basictype (entry);
9735 ffeinfoKindtype kt = ffesymbol_kindtype (entry);
9736 ffetargetCharacterSize size = ffesymbol_size (entry);
9739 if (ffecom_num_entrypoints_ == 0)
9740 { /* First entrypoint, make list of main
9741 arglist's dummies. */
9742 assert (ffecom_primary_entry_ != NULL);
9744 ffecom_master_bt_ = ffesymbol_basictype (ffecom_primary_entry_);
9745 ffecom_master_kt_ = ffesymbol_kindtype (ffecom_primary_entry_);
9746 ffecom_master_size_ = ffesymbol_size (ffecom_primary_entry_);
9748 for (plist = NULL, list = ffesymbol_dummyargs (ffecom_primary_entry_);
9750 list = ffebld_trail (list))
9752 arg = ffebld_head (list);
9753 if (ffebld_op (arg) != FFEBLD_opSYMTER)
9754 continue; /* Alternate return or some such thing. */
9755 item = ffebld_new_item (arg, NULL);
9757 ffecom_master_arglist_ = item;
9759 ffebld_set_trail (plist, item);
9764 /* If necessary, scan entry arglist for alternate returns. Do this scan
9765 apparently redundantly (it's done below to UNIONize the arglists) so
9766 that we don't complain about RETURN 1 if an offending ENTRY is the only
9767 one with an alternate return. */
9769 if (!ffecom_is_altreturning_)
9771 for (list = ffesymbol_dummyargs (entry);
9773 list = ffebld_trail (list))
9775 arg = ffebld_head (list);
9776 if (ffebld_op (arg) == FFEBLD_opSTAR)
9778 ffecom_is_altreturning_ = TRUE;
9784 /* Now check type compatibility. */
9786 switch (ffecom_master_bt_)
9788 case FFEINFO_basictypeNONE:
9789 ok = (bt != FFEINFO_basictypeCHARACTER);
9792 case FFEINFO_basictypeCHARACTER:
9794 = (bt == FFEINFO_basictypeCHARACTER)
9795 && (kt == ffecom_master_kt_)
9796 && (size == ffecom_master_size_);
9799 case FFEINFO_basictypeANY:
9800 return FALSE; /* Just don't bother. */
9803 if (bt == FFEINFO_basictypeCHARACTER)
9809 if ((bt != ffecom_master_bt_) || (kt != ffecom_master_kt_))
9811 ffecom_master_bt_ = FFEINFO_basictypeNONE;
9812 ffecom_master_kt_ = FFEINFO_kindtypeNONE;
9819 ffebad_start (FFEBAD_ENTRY_CONFLICTS);
9820 ffest_ffebad_here_current_stmt (0);
9822 return FALSE; /* Can't handle entrypoint. */
9825 /* Entrypoint type compatible with previous types. */
9827 ++ffecom_num_entrypoints_;
9829 /* Master-arg-list = UNION(Master-arg-list,entry-arg-list). */
9831 for (list = ffesymbol_dummyargs (entry);
9833 list = ffebld_trail (list))
9835 arg = ffebld_head (list);
9836 if (ffebld_op (arg) != FFEBLD_opSYMTER)
9837 continue; /* Alternate return or some such thing. */
9838 s = ffebld_symter (arg);
9839 for (plist = NULL, mlist = ffecom_master_arglist_;
9841 plist = mlist, mlist = ffebld_trail (mlist))
9842 { /* plist points to previous item for easy
9843 appending of arg. */
9844 if (ffebld_symter (ffebld_head (mlist)) == s)
9845 break; /* Already have this arg in the master list. */
9848 continue; /* Already have this arg in the master list. */
9850 /* Append this arg to the master list. */
9852 item = ffebld_new_item (arg, NULL);
9854 ffecom_master_arglist_ = item;
9856 ffebld_set_trail (plist, item);
9862 /* ffecom_2pass_do_entrypoint -- Do compilation of entrypoint
9864 ffesymbol s; // the ENTRY point itself
9865 ffecom_2pass_do_entrypoint(s);
9867 Does whatever compiler needs to do to make the entrypoint actually
9868 happen. Must be called for each entrypoint after
9869 ffecom_finish_progunit is called. */
9872 ffecom_2pass_do_entrypoint (ffesymbol entry)
9874 static int mfn_num = 0;
9877 if (mfn_num != ffecom_num_fns_)
9878 { /* First entrypoint for this program unit. */
9880 mfn_num = ffecom_num_fns_;
9881 ffecom_do_entry_ (ffecom_primary_entry_, 0);
9886 --ffecom_num_entrypoints_;
9888 ffecom_do_entry_ (entry, ent_num);
9891 /* Essentially does a "fold (build (code, type, node1, node2))" while
9892 checking for certain housekeeping things. Always sets
9893 TREE_SIDE_EFFECTS. */
9896 ffecom_2s (enum tree_code code, tree type, tree node1, tree node2)
9900 if ((node1 == error_mark_node)
9901 || (node2 == error_mark_node)
9902 || (type == error_mark_node))
9903 return error_mark_node;
9905 item = build (code, type, node1, node2);
9906 TREE_SIDE_EFFECTS (item) = 1;
9910 /* Essentially does a "fold (build (code, type, node1, node2, node3))" while
9911 checking for certain housekeeping things. */
9914 ffecom_3 (enum tree_code code, tree type, tree node1, tree node2, tree node3)
9918 if ((node1 == error_mark_node)
9919 || (node2 == error_mark_node)
9920 || (node3 == error_mark_node)
9921 || (type == error_mark_node))
9922 return error_mark_node;
9924 item = build (code, type, node1, node2, node3);
9925 if (TREE_SIDE_EFFECTS (node1) || TREE_SIDE_EFFECTS (node2)
9926 || (node3 != NULL_TREE && TREE_SIDE_EFFECTS (node3)))
9927 TREE_SIDE_EFFECTS (item) = 1;
9931 /* Essentially does a "fold (build (code, type, node1, node2, node3))" while
9932 checking for certain housekeeping things. Always sets
9933 TREE_SIDE_EFFECTS. */
9936 ffecom_3s (enum tree_code code, tree type, tree node1, tree node2, tree node3)
9940 if ((node1 == error_mark_node)
9941 || (node2 == error_mark_node)
9942 || (node3 == error_mark_node)
9943 || (type == error_mark_node))
9944 return error_mark_node;
9946 item = build (code, type, node1, node2, node3);
9947 TREE_SIDE_EFFECTS (item) = 1;
9951 /* ffecom_arg_expr -- Transform argument expr into gcc tree
9953 See use by ffecom_list_expr.
9955 If expression is NULL, returns an integer zero tree. If it is not
9956 a CHARACTER expression, returns whatever ffecom_expr
9957 returns and sets the length return value to NULL_TREE. Otherwise
9958 generates code to evaluate the character expression, returns the proper
9959 pointer to the result, but does NOT set the length return value to a tree
9960 that specifies the length of the result. (In other words, the length
9961 variable is always set to NULL_TREE, because a length is never passed.)
9964 Don't set returned length, since nobody needs it (yet; someday if
9965 we allow CHARACTER*(*) dummies to statement functions, we'll need
9969 ffecom_arg_expr (ffebld expr, tree *length)
9973 *length = NULL_TREE;
9976 return integer_zero_node;
9978 if (ffeinfo_basictype (ffebld_info (expr)) != FFEINFO_basictypeCHARACTER)
9979 return ffecom_expr (expr);
9981 return ffecom_arg_ptr_to_expr (expr, &ign);
9984 /* Transform expression into constant argument-pointer-to-expression tree.
9986 If the expression can be transformed into a argument-pointer-to-expression
9987 tree that is constant, that is done, and the tree returned. Else
9988 NULL_TREE is returned.
9990 That way, a caller can attempt to provide compile-time initialization
9991 of a variable and, if that fails, *then* choose to start a new block
9992 and resort to using temporaries, as appropriate. */
9995 ffecom_arg_ptr_to_const_expr (ffebld expr, tree *length)
9998 return integer_zero_node;
10000 if (ffebld_op (expr) == FFEBLD_opANY)
10003 *length = error_mark_node;
10004 return error_mark_node;
10007 if (ffebld_arity (expr) == 0
10008 && (ffebld_op (expr) != FFEBLD_opSYMTER
10009 || ffebld_where (expr) == FFEINFO_whereCOMMON
10010 || ffebld_where (expr) == FFEINFO_whereGLOBAL
10011 || ffebld_where (expr) == FFEINFO_whereINTRINSIC))
10015 t = ffecom_arg_ptr_to_expr (expr, length);
10016 assert (TREE_CONSTANT (t));
10017 assert (! length || TREE_CONSTANT (*length));
10022 && ffebld_size (expr) != FFETARGET_charactersizeNONE)
10023 *length = build_int_2 (ffebld_size (expr), 0);
10025 *length = NULL_TREE;
10029 /* ffecom_arg_ptr_to_expr -- Transform argument expr into gcc tree
10031 See use by ffecom_list_ptr_to_expr.
10033 If expression is NULL, returns an integer zero tree. If it is not
10034 a CHARACTER expression, returns whatever ffecom_ptr_to_expr
10035 returns and sets the length return value to NULL_TREE. Otherwise
10036 generates code to evaluate the character expression, returns the proper
10037 pointer to the result, AND sets the length return value to a tree that
10038 specifies the length of the result.
10040 If the length argument is NULL, this is a slightly special
10041 case of building a FORMAT expression, that is, an expression that
10042 will be used at run time without regard to length. For the current
10043 implementation, which uses the libf2c library, this means it is nice
10044 to append a null byte to the end of the expression, where feasible,
10045 to make sure any diagnostic about the FORMAT string terminates at
10048 For now, treat %REF(char-expr) as the same as char-expr with a NULL
10049 length argument. This might even be seen as a feature, if a null
10050 byte can always be appended. */
10053 ffecom_arg_ptr_to_expr (ffebld expr, tree *length)
10057 ffecomConcatList_ catlist;
10059 if (length != NULL)
10060 *length = NULL_TREE;
10063 return integer_zero_node;
10065 switch (ffebld_op (expr))
10067 case FFEBLD_opPERCENT_VAL:
10068 if (ffeinfo_basictype (ffebld_info (expr)) != FFEINFO_basictypeCHARACTER)
10069 return ffecom_expr (ffebld_left (expr));
10074 temp_exp = ffecom_arg_ptr_to_expr (ffebld_left (expr), &temp_length);
10075 if (temp_exp == error_mark_node)
10076 return error_mark_node;
10078 return ffecom_1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (temp_exp)),
10082 case FFEBLD_opPERCENT_REF:
10083 if (ffeinfo_basictype (ffebld_info (expr)) != FFEINFO_basictypeCHARACTER)
10084 return ffecom_ptr_to_expr (ffebld_left (expr));
10085 if (length != NULL)
10087 ign_length = NULL_TREE;
10088 length = &ign_length;
10090 expr = ffebld_left (expr);
10093 case FFEBLD_opPERCENT_DESCR:
10094 switch (ffeinfo_basictype (ffebld_info (expr)))
10096 case FFEINFO_basictypeCHARACTER:
10097 break; /* Passed by descriptor anyway. */
10100 item = ffecom_ptr_to_expr (expr);
10101 if (item != error_mark_node)
10102 *length = TYPE_SIZE (TREE_TYPE (TREE_TYPE (item)));
10111 if (ffeinfo_basictype (ffebld_info (expr)) != FFEINFO_basictypeCHARACTER)
10112 return ffecom_ptr_to_expr (expr);
10114 assert (ffeinfo_kindtype (ffebld_info (expr))
10115 == FFEINFO_kindtypeCHARACTER1);
10117 while (ffebld_op (expr) == FFEBLD_opPAREN)
10118 expr = ffebld_left (expr);
10120 catlist = ffecom_concat_list_new_ (expr, FFETARGET_charactersizeNONE);
10121 switch (ffecom_concat_list_count_ (catlist))
10123 case 0: /* Shouldn't happen, but in case it does... */
10124 if (length != NULL)
10126 *length = ffecom_f2c_ftnlen_zero_node;
10127 TREE_TYPE (*length) = ffecom_f2c_ftnlen_type_node;
10129 ffecom_concat_list_kill_ (catlist);
10130 return null_pointer_node;
10132 case 1: /* The (fairly) easy case. */
10133 if (length == NULL)
10134 ffecom_char_args_with_null_ (&item, &ign_length,
10135 ffecom_concat_list_expr_ (catlist, 0));
10137 ffecom_char_args_ (&item, length,
10138 ffecom_concat_list_expr_ (catlist, 0));
10139 ffecom_concat_list_kill_ (catlist);
10140 assert (item != NULL_TREE);
10143 default: /* Must actually concatenate things. */
10148 int count = ffecom_concat_list_count_ (catlist);
10159 ffetargetCharacterSize sz;
10161 sz = ffecom_concat_list_maxlen_ (catlist);
10163 assert (sz != FFETARGET_charactersizeNONE);
10168 hook = ffebld_nonter_hook (expr);
10170 assert (TREE_CODE (hook) == TREE_VEC);
10171 assert (TREE_VEC_LENGTH (hook) == 3);
10172 length_array = lengths = TREE_VEC_ELT (hook, 0);
10173 item_array = items = TREE_VEC_ELT (hook, 1);
10174 temporary = TREE_VEC_ELT (hook, 2);
10177 known_length = ffecom_f2c_ftnlen_zero_node;
10179 for (i = 0; i < count; ++i)
10182 && (length == NULL))
10183 ffecom_char_args_with_null_ (&citem, &clength,
10184 ffecom_concat_list_expr_ (catlist, i));
10186 ffecom_char_args_ (&citem, &clength,
10187 ffecom_concat_list_expr_ (catlist, i));
10188 if ((citem == error_mark_node)
10189 || (clength == error_mark_node))
10191 ffecom_concat_list_kill_ (catlist);
10192 *length = error_mark_node;
10193 return error_mark_node;
10197 = ffecom_2 (COMPOUND_EXPR, TREE_TYPE (items),
10198 ffecom_modify (void_type_node,
10199 ffecom_2 (ARRAY_REF,
10200 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (item_array))),
10202 build_int_2 (i, 0)),
10205 clength = ffecom_save_tree (clength);
10206 if (length != NULL)
10208 = ffecom_2 (PLUS_EXPR, ffecom_f2c_ftnlen_type_node,
10212 = ffecom_2 (COMPOUND_EXPR, TREE_TYPE (lengths),
10213 ffecom_modify (void_type_node,
10214 ffecom_2 (ARRAY_REF,
10215 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (length_array))),
10217 build_int_2 (i, 0)),
10222 temporary = ffecom_1 (ADDR_EXPR,
10223 build_pointer_type (TREE_TYPE (temporary)),
10226 item = build_tree_list (NULL_TREE, temporary);
10228 = build_tree_list (NULL_TREE,
10229 ffecom_1 (ADDR_EXPR,
10230 build_pointer_type (TREE_TYPE (items)),
10232 TREE_CHAIN (TREE_CHAIN (item))
10233 = build_tree_list (NULL_TREE,
10234 ffecom_1 (ADDR_EXPR,
10235 build_pointer_type (TREE_TYPE (lengths)),
10237 TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (item)))
10240 ffecom_1 (ADDR_EXPR, ffecom_f2c_ptr_to_ftnlen_type_node,
10241 convert (ffecom_f2c_ftnlen_type_node,
10242 build_int_2 (count, 0))));
10243 num = build_int_2 (sz, 0);
10244 TREE_TYPE (num) = ffecom_f2c_ftnlen_type_node;
10245 TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (item))))
10246 = build_tree_list (NULL_TREE, num);
10248 item = ffecom_call_gfrt (FFECOM_gfrtCAT, item, NULL_TREE);
10249 TREE_SIDE_EFFECTS (item) = 1;
10250 item = ffecom_2 (COMPOUND_EXPR, TREE_TYPE (temporary),
10254 if (length != NULL)
10255 *length = known_length;
10258 ffecom_concat_list_kill_ (catlist);
10259 assert (item != NULL_TREE);
10263 /* Generate call to run-time function.
10265 The first arg is the GNU Fortran Run-Time function index, the second
10266 arg is the list of arguments to pass to it. Returned is the expression
10267 (WITHOUT TREE_SIDE_EFFECTS set!) that makes the call and returns the
10268 result (which may be void). */
10271 ffecom_call_gfrt (ffecomGfrt ix, tree args, tree hook)
10273 return ffecom_call_ (ffecom_gfrt_tree_ (ix),
10274 ffecom_gfrt_kindtype (ix),
10275 ffe_is_f2c_library () && ffecom_gfrt_complex_[ix],
10276 NULL_TREE, args, NULL_TREE, NULL,
10277 NULL, NULL_TREE, TRUE, hook);
10280 /* Transform constant-union to tree. */
10283 ffecom_constantunion (ffebldConstantUnion *cu, ffeinfoBasictype bt,
10284 ffeinfoKindtype kt, tree tree_type)
10290 case FFEINFO_basictypeINTEGER:
10292 HOST_WIDE_INT hi, lo;
10296 #if FFETARGET_okINTEGER1
10297 case FFEINFO_kindtypeINTEGER1:
10298 lo = ffebld_cu_val_integer1 (*cu);
10299 hi = (lo < 0) ? -1 : 0;
10303 #if FFETARGET_okINTEGER2
10304 case FFEINFO_kindtypeINTEGER2:
10305 lo = ffebld_cu_val_integer2 (*cu);
10306 hi = (lo < 0) ? -1 : 0;
10310 #if FFETARGET_okINTEGER3
10311 case FFEINFO_kindtypeINTEGER3:
10312 lo = ffebld_cu_val_integer3 (*cu);
10313 hi = (lo < 0) ? -1 : 0;
10317 #if FFETARGET_okINTEGER4
10318 case FFEINFO_kindtypeINTEGER4:
10319 #if HOST_BITS_PER_LONGLONG > HOST_BITS_PER_WIDE_INT
10321 long long int big = ffebld_cu_val_integer4 (*cu);
10322 hi = (HOST_WIDE_INT) (big >> HOST_BITS_PER_WIDE_INT);
10323 lo = (HOST_WIDE_INT) big;
10326 lo = ffebld_cu_val_integer4 (*cu);
10327 hi = (lo < 0) ? -1 : 0;
10333 assert ("bad INTEGER constant kind type" == NULL);
10334 /* Fall through. */
10335 case FFEINFO_kindtypeANY:
10336 return error_mark_node;
10338 item = build_int_2 (lo, hi);
10339 TREE_TYPE (item) = tree_type;
10343 case FFEINFO_basictypeLOGICAL:
10349 #if FFETARGET_okLOGICAL1
10350 case FFEINFO_kindtypeLOGICAL1:
10351 val = ffebld_cu_val_logical1 (*cu);
10355 #if FFETARGET_okLOGICAL2
10356 case FFEINFO_kindtypeLOGICAL2:
10357 val = ffebld_cu_val_logical2 (*cu);
10361 #if FFETARGET_okLOGICAL3
10362 case FFEINFO_kindtypeLOGICAL3:
10363 val = ffebld_cu_val_logical3 (*cu);
10367 #if FFETARGET_okLOGICAL4
10368 case FFEINFO_kindtypeLOGICAL4:
10369 val = ffebld_cu_val_logical4 (*cu);
10374 assert ("bad LOGICAL constant kind type" == NULL);
10375 /* Fall through. */
10376 case FFEINFO_kindtypeANY:
10377 return error_mark_node;
10379 item = build_int_2 (val, (val < 0) ? -1 : 0);
10380 TREE_TYPE (item) = tree_type;
10384 case FFEINFO_basictypeREAL:
10386 REAL_VALUE_TYPE val;
10390 #if FFETARGET_okREAL1
10391 case FFEINFO_kindtypeREAL1:
10392 val = ffetarget_value_real1 (ffebld_cu_val_real1 (*cu));
10396 #if FFETARGET_okREAL2
10397 case FFEINFO_kindtypeREAL2:
10398 val = ffetarget_value_real2 (ffebld_cu_val_real2 (*cu));
10402 #if FFETARGET_okREAL3
10403 case FFEINFO_kindtypeREAL3:
10404 val = ffetarget_value_real3 (ffebld_cu_val_real3 (*cu));
10409 assert ("bad REAL constant kind type" == NULL);
10410 /* Fall through. */
10411 case FFEINFO_kindtypeANY:
10412 return error_mark_node;
10414 item = build_real (tree_type, val);
10418 case FFEINFO_basictypeCOMPLEX:
10420 REAL_VALUE_TYPE real;
10421 REAL_VALUE_TYPE imag;
10422 tree el_type = ffecom_tree_type[FFEINFO_basictypeREAL][kt];
10426 #if FFETARGET_okCOMPLEX1
10427 case FFEINFO_kindtypeREAL1:
10428 real = ffetarget_value_real1 (ffebld_cu_val_complex1 (*cu).real);
10429 imag = ffetarget_value_real1 (ffebld_cu_val_complex1 (*cu).imaginary);
10433 #if FFETARGET_okCOMPLEX2
10434 case FFEINFO_kindtypeREAL2:
10435 real = ffetarget_value_real2 (ffebld_cu_val_complex2 (*cu).real);
10436 imag = ffetarget_value_real2 (ffebld_cu_val_complex2 (*cu).imaginary);
10440 #if FFETARGET_okCOMPLEX3
10441 case FFEINFO_kindtypeREAL3:
10442 real = ffetarget_value_real3 (ffebld_cu_val_complex3 (*cu).real);
10443 imag = ffetarget_value_real3 (ffebld_cu_val_complex3 (*cu).imaginary);
10448 assert ("bad REAL constant kind type" == NULL);
10449 /* Fall through. */
10450 case FFEINFO_kindtypeANY:
10451 return error_mark_node;
10453 item = ffecom_build_complex_constant_ (tree_type,
10454 build_real (el_type, real),
10455 build_real (el_type, imag));
10459 case FFEINFO_basictypeCHARACTER:
10460 { /* Happens only in DATA and similar contexts. */
10461 ffetargetCharacter1 val;
10465 #if FFETARGET_okCHARACTER1
10466 case FFEINFO_kindtypeLOGICAL1:
10467 val = ffebld_cu_val_character1 (*cu);
10472 assert ("bad CHARACTER constant kind type" == NULL);
10473 /* Fall through. */
10474 case FFEINFO_kindtypeANY:
10475 return error_mark_node;
10477 item = build_string (ffetarget_length_character1 (val),
10478 ffetarget_text_character1 (val));
10480 = build_type_variant (build_array_type (char_type_node,
10482 (integer_type_node,
10485 (ffetarget_length_character1
10491 case FFEINFO_basictypeHOLLERITH:
10493 ffetargetHollerith h;
10495 h = ffebld_cu_val_hollerith (*cu);
10497 /* If not at least as wide as default INTEGER, widen it. */
10498 if (h.length >= FLOAT_TYPE_SIZE / CHAR_TYPE_SIZE)
10499 item = build_string (h.length, h.text);
10502 char str[FLOAT_TYPE_SIZE / CHAR_TYPE_SIZE];
10504 memcpy (str, h.text, h.length);
10505 memset (&str[h.length], ' ',
10506 FLOAT_TYPE_SIZE / CHAR_TYPE_SIZE
10508 item = build_string (FLOAT_TYPE_SIZE / CHAR_TYPE_SIZE,
10512 = build_type_variant (build_array_type (char_type_node,
10514 (integer_type_node,
10522 case FFEINFO_basictypeTYPELESS:
10524 ffetargetInteger1 ival;
10525 ffetargetTypeless tless;
10528 tless = ffebld_cu_val_typeless (*cu);
10529 error = ffetarget_convert_integer1_typeless (&ival, tless);
10530 assert (error == FFEBAD);
10532 item = build_int_2 ((int) ival, 0);
10537 assert ("not yet on constant type" == NULL);
10538 /* Fall through. */
10539 case FFEINFO_basictypeANY:
10540 return error_mark_node;
10543 TREE_CONSTANT (item) = 1;
10548 /* Transform constant-union to tree, with the type known. */
10551 ffecom_constantunion_with_type (ffebldConstantUnion *cu, tree tree_type,
10560 #if FFETARGET_okINTEGER1
10561 case FFEBLD_constINTEGER1:
10562 val = ffebld_cu_val_integer1 (*cu);
10563 item = build_int_2 (val, (val < 0) ? -1 : 0);
10566 #if FFETARGET_okINTEGER2
10567 case FFEBLD_constINTEGER2:
10568 val = ffebld_cu_val_integer2 (*cu);
10569 item = build_int_2 (val, (val < 0) ? -1 : 0);
10572 #if FFETARGET_okINTEGER3
10573 case FFEBLD_constINTEGER3:
10574 val = ffebld_cu_val_integer3 (*cu);
10575 item = build_int_2 (val, (val < 0) ? -1 : 0);
10578 #if FFETARGET_okINTEGER4
10579 case FFEBLD_constINTEGER4:
10580 #if HOST_BITS_PER_LONGLONG > HOST_BITS_PER_WIDE_INT
10582 long long int big = ffebld_cu_val_integer4 (*cu);
10583 item = build_int_2 ((HOST_WIDE_INT) big,
10585 (big >> HOST_BITS_PER_WIDE_INT));
10588 val = ffebld_cu_val_integer4 (*cu);
10589 item = build_int_2 (val, (val < 0) ? -1 : 0);
10593 #if FFETARGET_okLOGICAL1
10594 case FFEBLD_constLOGICAL1:
10595 val = ffebld_cu_val_logical1 (*cu);
10596 item = build_int_2 (val, (val < 0) ? -1 : 0);
10599 #if FFETARGET_okLOGICAL2
10600 case FFEBLD_constLOGICAL2:
10601 val = ffebld_cu_val_logical2 (*cu);
10602 item = build_int_2 (val, (val < 0) ? -1 : 0);
10605 #if FFETARGET_okLOGICAL3
10606 case FFEBLD_constLOGICAL3:
10607 val = ffebld_cu_val_logical3 (*cu);
10608 item = build_int_2 (val, (val < 0) ? -1 : 0);
10611 #if FFETARGET_okLOGICAL4
10612 case FFEBLD_constLOGICAL4:
10613 val = ffebld_cu_val_logical4 (*cu);
10614 item = build_int_2 (val, (val < 0) ? -1 : 0);
10618 assert ("constant type not supported"==NULL);
10619 return error_mark_node;
10623 TREE_TYPE (item) = tree_type;
10625 TREE_CONSTANT (item) = 1;
10629 /* Transform expression into constant tree.
10631 If the expression can be transformed into a tree that is constant,
10632 that is done, and the tree returned. Else NULL_TREE is returned.
10634 That way, a caller can attempt to provide compile-time initialization
10635 of a variable and, if that fails, *then* choose to start a new block
10636 and resort to using temporaries, as appropriate. */
10639 ffecom_const_expr (ffebld expr)
10642 return integer_zero_node;
10644 if (ffebld_op (expr) == FFEBLD_opANY)
10645 return error_mark_node;
10647 if (ffebld_arity (expr) == 0
10648 && (ffebld_op (expr) != FFEBLD_opSYMTER
10649 || ffebld_where (expr) == FFEINFO_whereGLOBAL
10650 || ffebld_where (expr) == FFEINFO_whereINTRINSIC))
10654 t = ffecom_expr (expr);
10655 assert (TREE_CONSTANT (t));
10662 /* Handy way to make a field in a struct/union. */
10665 ffecom_decl_field (tree context, tree prevfield, const char *name, tree type)
10669 field = build_decl (FIELD_DECL, get_identifier (name), type);
10670 DECL_CONTEXT (field) = context;
10671 DECL_ALIGN (field) = 0;
10672 DECL_USER_ALIGN (field) = 0;
10673 if (prevfield != NULL_TREE)
10674 TREE_CHAIN (prevfield) = field;
10680 ffecom_close_include (FILE *f)
10682 ffecom_close_include_ (f);
10685 /* End a compound statement (block). */
10688 ffecom_end_compstmt (void)
10690 return bison_rule_compstmt_ ();
10693 /* ffecom_end_transition -- Perform end transition on all symbols
10695 ffecom_end_transition();
10697 Calls ffecom_sym_end_transition for each global and local symbol. */
10700 ffecom_end_transition (void)
10704 if (ffe_is_ffedebug ())
10705 fprintf (dmpout, "; end_stmt_transition\n");
10707 ffecom_list_blockdata_ = NULL;
10708 ffecom_list_common_ = NULL;
10710 ffesymbol_drive (ffecom_sym_end_transition);
10711 if (ffe_is_ffedebug ())
10713 ffestorag_report ();
10716 ffecom_start_progunit_ ();
10718 for (item = ffecom_list_blockdata_;
10720 item = ffebld_trail (item))
10727 static int number = 0;
10729 callee = ffebld_head (item);
10730 s = ffebld_symter (callee);
10731 t = ffesymbol_hook (s).decl_tree;
10732 if (t == NULL_TREE)
10734 s = ffecom_sym_transform_ (s);
10735 t = ffesymbol_hook (s).decl_tree;
10738 dt = build_pointer_type (TREE_TYPE (t));
10740 var = build_decl (VAR_DECL,
10741 ffecom_get_invented_identifier ("__g77_forceload_%d",
10744 DECL_EXTERNAL (var) = 0;
10745 TREE_STATIC (var) = 1;
10746 TREE_PUBLIC (var) = 0;
10747 DECL_INITIAL (var) = error_mark_node;
10748 TREE_USED (var) = 1;
10750 var = start_decl (var, FALSE);
10752 t = ffecom_1 (ADDR_EXPR, dt, t);
10754 finish_decl (var, t, FALSE);
10757 /* This handles any COMMON areas that weren't referenced but have, for
10758 example, important initial data. */
10760 for (item = ffecom_list_common_;
10762 item = ffebld_trail (item))
10763 ffecom_transform_common_ (ffebld_symter (ffebld_head (item)));
10765 ffecom_list_common_ = NULL;
10768 /* ffecom_exec_transition -- Perform exec transition on all symbols
10770 ffecom_exec_transition();
10772 Calls ffecom_sym_exec_transition for each global and local symbol.
10773 Make sure error updating not inhibited. */
10776 ffecom_exec_transition (void)
10780 if (ffe_is_ffedebug ())
10781 fprintf (dmpout, "; exec_stmt_transition\n");
10783 inhibited = ffebad_inhibit ();
10784 ffebad_set_inhibit (FALSE);
10786 ffesymbol_drive (ffecom_sym_exec_transition); /* Don't retract! */
10787 ffeequiv_exec_transition (); /* Handle all pending EQUIVALENCEs. */
10788 if (ffe_is_ffedebug ())
10790 ffestorag_report ();
10794 ffebad_set_inhibit (TRUE);
10797 /* Handle assignment statement.
10799 Convert dest and source using ffecom_expr, then join them
10800 with an ASSIGN op and pass the whole thing to expand_expr_stmt. */
10803 ffecom_expand_let_stmt (ffebld dest, ffebld source)
10810 if (ffeinfo_basictype (ffebld_info (dest)) != FFEINFO_basictypeCHARACTER)
10815 /* This attempts to replicate the test below, but must not be
10816 true when the test below is false. (Always err on the side
10817 of creating unused temporaries, to avoid ICEs.) */
10818 if (ffebld_op (dest) != FFEBLD_opSYMTER
10819 || ((dest_tree = ffesymbol_hook (ffebld_symter (dest)).decl_tree)
10820 && (TREE_CODE (dest_tree) != VAR_DECL
10821 || TREE_ADDRESSABLE (dest_tree))))
10823 ffecom_prepare_expr_ (source, dest);
10828 ffecom_prepare_expr_ (source, NULL);
10832 ffecom_prepare_expr_w (NULL_TREE, dest);
10834 /* For COMPLEX assignment like C1=C2, if partial overlap is possible,
10835 create a temporary through which the assignment is to take place,
10836 since MODIFY_EXPR doesn't handle partial overlap properly. */
10837 if (ffebld_basictype (dest) == FFEINFO_basictypeCOMPLEX
10838 && ffecom_possible_partial_overlap_ (dest, source))
10840 assign_temp = ffecom_make_tempvar ("complex_let",
10842 [ffebld_basictype (dest)]
10843 [ffebld_kindtype (dest)],
10844 FFETARGET_charactersizeNONE,
10848 assign_temp = NULL_TREE;
10850 ffecom_prepare_end ();
10852 dest_tree = ffecom_expr_w (NULL_TREE, dest);
10853 if (dest_tree == error_mark_node)
10856 if ((TREE_CODE (dest_tree) != VAR_DECL)
10857 || TREE_ADDRESSABLE (dest_tree))
10858 source_tree = ffecom_expr_ (source, dest_tree, dest, &dest_used,
10862 assert (! dest_used);
10864 source_tree = ffecom_expr (source);
10866 if (source_tree == error_mark_node)
10870 expr_tree = source_tree;
10871 else if (assign_temp)
10873 expr_tree = ffecom_2s (MODIFY_EXPR, void_type_node,
10876 expand_expr_stmt (expr_tree);
10877 expr_tree = ffecom_2s (MODIFY_EXPR, void_type_node,
10882 expr_tree = ffecom_2s (MODIFY_EXPR, void_type_node,
10886 expand_expr_stmt (expr_tree);
10890 ffecom_prepare_let_char_ (ffebld_size_known (dest), source);
10891 ffecom_prepare_expr_w (NULL_TREE, dest);
10893 ffecom_prepare_end ();
10895 ffecom_char_args_ (&dest_tree, &dest_length, dest);
10896 ffecom_let_char_ (dest_tree, dest_length, ffebld_size_known (dest),
10900 /* ffecom_expr -- Transform expr into gcc tree
10903 ffebld expr; // FFE expression.
10904 tree = ffecom_expr(expr);
10906 Recursive descent on expr while making corresponding tree nodes and
10907 attaching type info and such. */
10910 ffecom_expr (ffebld expr)
10912 return ffecom_expr_ (expr, NULL_TREE, NULL, NULL, FALSE, FALSE);
10915 /* Like ffecom_expr, but return tree usable for assigned GOTO or FORMAT. */
10918 ffecom_expr_assign (ffebld expr)
10920 return ffecom_expr_ (expr, NULL_TREE, NULL, NULL, TRUE, FALSE);
10923 /* Like ffecom_expr_rw, but return tree usable for ASSIGN. */
10926 ffecom_expr_assign_w (ffebld expr)
10928 return ffecom_expr_ (expr, NULL_TREE, NULL, NULL, TRUE, FALSE);
10931 /* Transform expr for use as into read/write tree and stabilize the
10932 reference. Not for use on CHARACTER expressions.
10934 Recursive descent on expr while making corresponding tree nodes and
10935 attaching type info and such. */
10938 ffecom_expr_rw (tree type, ffebld expr)
10940 assert (expr != NULL);
10941 /* Different target types not yet supported. */
10942 assert (type == NULL_TREE || type == ffecom_type_expr (expr));
10944 return stabilize_reference (ffecom_expr (expr));
10947 /* Transform expr for use as into write tree and stabilize the
10948 reference. Not for use on CHARACTER expressions.
10950 Recursive descent on expr while making corresponding tree nodes and
10951 attaching type info and such. */
10954 ffecom_expr_w (tree type, ffebld expr)
10956 assert (expr != NULL);
10957 /* Different target types not yet supported. */
10958 assert (type == NULL_TREE || type == ffecom_type_expr (expr));
10960 return stabilize_reference (ffecom_expr (expr));
10963 /* Do global stuff. */
10966 ffecom_finish_compile (void)
10968 assert (ffecom_outer_function_decl_ == NULL_TREE);
10969 assert (current_function_decl == NULL_TREE);
10971 ffeglobal_drive (ffecom_finish_global_);
10974 /* Public entry point for front end to access finish_decl. */
10977 ffecom_finish_decl (tree decl, tree init, bool is_top_level)
10979 assert (!is_top_level);
10980 finish_decl (decl, init, FALSE);
10983 /* Finish a program unit. */
10986 ffecom_finish_progunit (void)
10988 ffecom_end_compstmt ();
10990 ffecom_previous_function_decl_ = current_function_decl;
10991 ffecom_which_entrypoint_decl_ = NULL_TREE;
10993 finish_function (0);
10996 /* Wrapper for get_identifier. pattern is sprintf-like. */
10999 ffecom_get_invented_identifier (const char *pattern, ...)
11005 va_start (ap, pattern);
11006 if (vasprintf (&nam, pattern, ap) == 0)
11009 decl = get_identifier (nam);
11011 IDENTIFIER_INVENTED (decl) = 1;
11016 ffecom_gfrt_basictype (ffecomGfrt gfrt)
11018 assert (gfrt < FFECOM_gfrt);
11020 switch (ffecom_gfrt_type_[gfrt])
11022 case FFECOM_rttypeVOID_:
11023 case FFECOM_rttypeVOIDSTAR_:
11024 return FFEINFO_basictypeNONE;
11026 case FFECOM_rttypeFTNINT_:
11027 return FFEINFO_basictypeINTEGER;
11029 case FFECOM_rttypeINTEGER_:
11030 return FFEINFO_basictypeINTEGER;
11032 case FFECOM_rttypeLONGINT_:
11033 return FFEINFO_basictypeINTEGER;
11035 case FFECOM_rttypeLOGICAL_:
11036 return FFEINFO_basictypeLOGICAL;
11038 case FFECOM_rttypeREAL_F2C_:
11039 case FFECOM_rttypeREAL_GNU_:
11040 return FFEINFO_basictypeREAL;
11042 case FFECOM_rttypeCOMPLEX_F2C_:
11043 case FFECOM_rttypeCOMPLEX_GNU_:
11044 return FFEINFO_basictypeCOMPLEX;
11046 case FFECOM_rttypeDOUBLE_:
11047 case FFECOM_rttypeDOUBLEREAL_:
11048 return FFEINFO_basictypeREAL;
11050 case FFECOM_rttypeDBLCMPLX_F2C_:
11051 case FFECOM_rttypeDBLCMPLX_GNU_:
11052 return FFEINFO_basictypeCOMPLEX;
11054 case FFECOM_rttypeCHARACTER_:
11055 return FFEINFO_basictypeCHARACTER;
11058 return FFEINFO_basictypeANY;
11063 ffecom_gfrt_kindtype (ffecomGfrt gfrt)
11065 assert (gfrt < FFECOM_gfrt);
11067 switch (ffecom_gfrt_type_[gfrt])
11069 case FFECOM_rttypeVOID_:
11070 case FFECOM_rttypeVOIDSTAR_:
11071 return FFEINFO_kindtypeNONE;
11073 case FFECOM_rttypeFTNINT_:
11074 return FFEINFO_kindtypeINTEGER1;
11076 case FFECOM_rttypeINTEGER_:
11077 return FFEINFO_kindtypeINTEGER1;
11079 case FFECOM_rttypeLONGINT_:
11080 return FFEINFO_kindtypeINTEGER4;
11082 case FFECOM_rttypeLOGICAL_:
11083 return FFEINFO_kindtypeLOGICAL1;
11085 case FFECOM_rttypeREAL_F2C_:
11086 case FFECOM_rttypeREAL_GNU_:
11087 return FFEINFO_kindtypeREAL1;
11089 case FFECOM_rttypeCOMPLEX_F2C_:
11090 case FFECOM_rttypeCOMPLEX_GNU_:
11091 return FFEINFO_kindtypeREAL1;
11093 case FFECOM_rttypeDOUBLE_:
11094 case FFECOM_rttypeDOUBLEREAL_:
11095 return FFEINFO_kindtypeREAL2;
11097 case FFECOM_rttypeDBLCMPLX_F2C_:
11098 case FFECOM_rttypeDBLCMPLX_GNU_:
11099 return FFEINFO_kindtypeREAL2;
11101 case FFECOM_rttypeCHARACTER_:
11102 return FFEINFO_kindtypeCHARACTER1;
11105 return FFEINFO_kindtypeANY;
11110 ffecom_init_0 (void)
11119 tree double_ftype_double, double_ftype_double_double;
11120 tree float_ftype_float, float_ftype_float_float;
11121 tree ldouble_ftype_ldouble, ldouble_ftype_ldouble_ldouble;
11122 tree ffecom_tree_ptr_to_fun_type_void;
11124 /* This block of code comes from the now-obsolete cktyps.c. It checks
11125 whether the compiler environment is buggy in known ways, some of which
11126 would, if not explicitly checked here, result in subtle bugs in g77. */
11128 if (ffe_is_do_internal_checks ())
11130 static const char names[][12]
11132 {"bar", "bletch", "foo", "foobar"};
11137 name = bsearch ("foo", &names[0], ARRAY_SIZE (names), sizeof (names[0]),
11138 (int (*)(const void *, const void *)) strcmp);
11139 if (name != &names[2][0])
11141 assert ("bsearch doesn't work, #define FFEPROJ_BSEARCH 0 in proj.h"
11146 ul = strtoul ("123456789", NULL, 10);
11147 if (ul != 123456789L)
11149 assert ("strtoul doesn't have enough range, #define FFEPROJ_STRTOUL 0\
11150 in proj.h" == NULL);
11154 fl = atof ("56.789");
11155 if ((fl < 56.788) || (fl > 56.79))
11157 assert ("atof not type double, fix your #include <stdio.h>"
11163 ffecom_outer_function_decl_ = NULL_TREE;
11164 current_function_decl = NULL_TREE;
11165 named_labels = NULL_TREE;
11166 current_binding_level = NULL_BINDING_LEVEL;
11167 free_binding_level = NULL_BINDING_LEVEL;
11168 /* Make the binding_level structure for global names. */
11170 global_binding_level = current_binding_level;
11171 current_binding_level->prep_state = 2;
11173 build_common_tree_nodes (1);
11175 /* Define `int' and `char' first so that dbx will output them first. */
11176 pushdecl (build_decl (TYPE_DECL, get_identifier ("int"),
11177 integer_type_node));
11178 /* CHARACTER*1 is unsigned in ICHAR contexts. */
11179 char_type_node = make_unsigned_type (CHAR_TYPE_SIZE);
11180 pushdecl (build_decl (TYPE_DECL, get_identifier ("char"),
11182 pushdecl (build_decl (TYPE_DECL, get_identifier ("long int"),
11183 long_integer_type_node));
11184 pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned int"),
11185 unsigned_type_node));
11186 pushdecl (build_decl (TYPE_DECL, get_identifier ("long unsigned int"),
11187 long_unsigned_type_node));
11188 pushdecl (build_decl (TYPE_DECL, get_identifier ("long long int"),
11189 long_long_integer_type_node));
11190 pushdecl (build_decl (TYPE_DECL, get_identifier ("long long unsigned int"),
11191 long_long_unsigned_type_node));
11192 pushdecl (build_decl (TYPE_DECL, get_identifier ("short int"),
11193 short_integer_type_node));
11194 pushdecl (build_decl (TYPE_DECL, get_identifier ("short unsigned int"),
11195 short_unsigned_type_node));
11197 /* Set the sizetype before we make other types. This *should* be the
11198 first type we create. */
11201 (TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (get_identifier (SIZE_TYPE))));
11202 ffecom_typesize_pointer_
11203 = TREE_INT_CST_LOW (TYPE_SIZE (sizetype)) / BITS_PER_UNIT;
11205 build_common_tree_nodes_2 (0);
11207 /* Define both `signed char' and `unsigned char'. */
11208 pushdecl (build_decl (TYPE_DECL, get_identifier ("signed char"),
11209 signed_char_type_node));
11211 pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned char"),
11212 unsigned_char_type_node));
11214 pushdecl (build_decl (TYPE_DECL, get_identifier ("float"),
11216 pushdecl (build_decl (TYPE_DECL, get_identifier ("double"),
11217 double_type_node));
11218 pushdecl (build_decl (TYPE_DECL, get_identifier ("long double"),
11219 long_double_type_node));
11221 /* For now, override what build_common_tree_nodes has done. */
11222 complex_integer_type_node = ffecom_make_complex_type_ (integer_type_node);
11223 complex_float_type_node = ffecom_make_complex_type_ (float_type_node);
11224 complex_double_type_node = ffecom_make_complex_type_ (double_type_node);
11225 complex_long_double_type_node
11226 = ffecom_make_complex_type_ (long_double_type_node);
11228 pushdecl (build_decl (TYPE_DECL, get_identifier ("complex int"),
11229 complex_integer_type_node));
11230 pushdecl (build_decl (TYPE_DECL, get_identifier ("complex float"),
11231 complex_float_type_node));
11232 pushdecl (build_decl (TYPE_DECL, get_identifier ("complex double"),
11233 complex_double_type_node));
11234 pushdecl (build_decl (TYPE_DECL, get_identifier ("complex long double"),
11235 complex_long_double_type_node));
11237 pushdecl (build_decl (TYPE_DECL, get_identifier ("void"),
11239 /* We are not going to have real types in C with less than byte alignment,
11240 so we might as well not have any types that claim to have it. */
11241 TYPE_ALIGN (void_type_node) = BITS_PER_UNIT;
11242 TYPE_USER_ALIGN (void_type_node) = 0;
11244 string_type_node = build_pointer_type (char_type_node);
11246 ffecom_tree_fun_type_void
11247 = build_function_type (void_type_node, NULL_TREE);
11249 ffecom_tree_ptr_to_fun_type_void
11250 = build_pointer_type (ffecom_tree_fun_type_void);
11252 endlink = tree_cons (NULL_TREE, void_type_node, NULL_TREE);
11254 t = tree_cons (NULL_TREE, float_type_node, endlink);
11255 float_ftype_float = build_function_type (float_type_node, t);
11256 t = tree_cons (NULL_TREE, float_type_node, t);
11257 float_ftype_float_float = build_function_type (float_type_node, t);
11259 t = tree_cons (NULL_TREE, double_type_node, endlink);
11260 double_ftype_double = build_function_type (double_type_node, t);
11261 t = tree_cons (NULL_TREE, double_type_node, t);
11262 double_ftype_double_double = build_function_type (double_type_node, t);
11264 t = tree_cons (NULL_TREE, long_double_type_node, endlink);
11265 ldouble_ftype_ldouble = build_function_type (long_double_type_node, t);
11266 t = tree_cons (NULL_TREE, long_double_type_node, t);
11267 ldouble_ftype_ldouble_ldouble = build_function_type (long_double_type_node,
11270 for (i = 0; ((size_t) i) < ARRAY_SIZE (ffecom_tree_type); ++i)
11271 for (j = 0; ((size_t) j) < ARRAY_SIZE (ffecom_tree_type[0]); ++j)
11273 ffecom_tree_type[i][j] = NULL_TREE;
11274 ffecom_tree_fun_type[i][j] = NULL_TREE;
11275 ffecom_tree_ptr_to_fun_type[i][j] = NULL_TREE;
11276 ffecom_f2c_typecode_[i][j] = -1;
11279 /* Set up standard g77 types. Note that INTEGER and LOGICAL are set
11280 to size FLOAT_TYPE_SIZE because they have to be the same size as
11281 REAL, which also is FLOAT_TYPE_SIZE, according to the standard.
11282 Compiler options and other such stuff that change the ways these
11283 types are set should not affect this particular setup. */
11285 ffecom_tree_type[FFEINFO_basictypeINTEGER][FFEINFO_kindtypeINTEGER1]
11286 = t = make_signed_type (FLOAT_TYPE_SIZE);
11287 pushdecl (build_decl (TYPE_DECL, get_identifier ("integer"),
11289 type = ffetype_new ();
11291 ffeinfo_set_type (FFEINFO_basictypeINTEGER, FFEINFO_kindtypeINTEGER1,
11293 ffetype_set_ams (type,
11294 TYPE_ALIGN (t) / BITS_PER_UNIT, 0,
11295 TREE_INT_CST_LOW (TYPE_SIZE (t)) / BITS_PER_UNIT);
11296 ffetype_set_star (base_type,
11297 TREE_INT_CST_LOW (TYPE_SIZE (t)) / CHAR_TYPE_SIZE,
11299 ffetype_set_kind (base_type, 1, type);
11300 ffecom_typesize_integer1_ = ffetype_size (type);
11301 assert (ffetype_size (type) == sizeof (ffetargetInteger1));
11303 ffecom_tree_type[FFEINFO_basictypeHOLLERITH][FFEINFO_kindtypeINTEGER1]
11304 = t = make_unsigned_type (FLOAT_TYPE_SIZE); /* HOLLERITH means unsigned. */
11305 pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned"),
11308 ffecom_tree_type[FFEINFO_basictypeINTEGER][FFEINFO_kindtypeINTEGER2]
11309 = t = make_signed_type (CHAR_TYPE_SIZE);
11310 pushdecl (build_decl (TYPE_DECL, get_identifier ("byte"),
11312 type = ffetype_new ();
11313 ffeinfo_set_type (FFEINFO_basictypeINTEGER, FFEINFO_kindtypeINTEGER2,
11315 ffetype_set_ams (type,
11316 TYPE_ALIGN (t) / BITS_PER_UNIT, 0,
11317 TREE_INT_CST_LOW (TYPE_SIZE (t)) / BITS_PER_UNIT);
11318 ffetype_set_star (base_type,
11319 TREE_INT_CST_LOW (TYPE_SIZE (t)) / CHAR_TYPE_SIZE,
11321 ffetype_set_kind (base_type, 3, type);
11322 assert (ffetype_size (type) == sizeof (ffetargetInteger2));
11324 ffecom_tree_type[FFEINFO_basictypeHOLLERITH][FFEINFO_kindtypeINTEGER2]
11325 = t = make_unsigned_type (CHAR_TYPE_SIZE);
11326 pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned byte"),
11329 ffecom_tree_type[FFEINFO_basictypeINTEGER][FFEINFO_kindtypeINTEGER3]
11330 = t = make_signed_type (CHAR_TYPE_SIZE * 2);
11331 pushdecl (build_decl (TYPE_DECL, get_identifier ("word"),
11333 type = ffetype_new ();
11334 ffeinfo_set_type (FFEINFO_basictypeINTEGER, FFEINFO_kindtypeINTEGER3,
11336 ffetype_set_ams (type,
11337 TYPE_ALIGN (t) / BITS_PER_UNIT, 0,
11338 TREE_INT_CST_LOW (TYPE_SIZE (t)) / BITS_PER_UNIT);
11339 ffetype_set_star (base_type,
11340 TREE_INT_CST_LOW (TYPE_SIZE (t)) / CHAR_TYPE_SIZE,
11342 ffetype_set_kind (base_type, 6, type);
11343 assert (ffetype_size (type) == sizeof (ffetargetInteger3));
11345 ffecom_tree_type[FFEINFO_basictypeHOLLERITH][FFEINFO_kindtypeINTEGER3]
11346 = t = make_unsigned_type (CHAR_TYPE_SIZE * 2);
11347 pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned word"),
11350 ffecom_tree_type[FFEINFO_basictypeINTEGER][FFEINFO_kindtypeINTEGER4]
11351 = t = make_signed_type (FLOAT_TYPE_SIZE * 2);
11352 pushdecl (build_decl (TYPE_DECL, get_identifier ("integer4"),
11354 type = ffetype_new ();
11355 ffeinfo_set_type (FFEINFO_basictypeINTEGER, FFEINFO_kindtypeINTEGER4,
11357 ffetype_set_ams (type,
11358 TYPE_ALIGN (t) / BITS_PER_UNIT, 0,
11359 TREE_INT_CST_LOW (TYPE_SIZE (t)) / BITS_PER_UNIT);
11360 ffetype_set_star (base_type,
11361 TREE_INT_CST_LOW (TYPE_SIZE (t)) / CHAR_TYPE_SIZE,
11363 ffetype_set_kind (base_type, 2, type);
11364 assert (ffetype_size (type) == sizeof (ffetargetInteger4));
11366 ffecom_tree_type[FFEINFO_basictypeHOLLERITH][FFEINFO_kindtypeINTEGER4]
11367 = t = make_unsigned_type (FLOAT_TYPE_SIZE * 2);
11368 pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned4"),
11372 if (ffe_is_do_internal_checks ()
11373 && LONG_TYPE_SIZE != FLOAT_TYPE_SIZE
11374 && LONG_TYPE_SIZE != CHAR_TYPE_SIZE
11375 && LONG_TYPE_SIZE != SHORT_TYPE_SIZE
11376 && LONG_TYPE_SIZE != LONG_LONG_TYPE_SIZE)
11378 fprintf (stderr, "Sorry, no g77 support for LONG_TYPE_SIZE (%d bits) yet.\n",
11383 ffecom_tree_type[FFEINFO_basictypeLOGICAL][FFEINFO_kindtypeLOGICAL1]
11384 = t = make_signed_type (FLOAT_TYPE_SIZE);
11385 pushdecl (build_decl (TYPE_DECL, get_identifier ("logical"),
11387 type = ffetype_new ();
11389 ffeinfo_set_type (FFEINFO_basictypeLOGICAL, FFEINFO_kindtypeLOGICAL1,
11391 ffetype_set_ams (type,
11392 TYPE_ALIGN (t) / BITS_PER_UNIT, 0,
11393 TREE_INT_CST_LOW (TYPE_SIZE (t)) / BITS_PER_UNIT);
11394 ffetype_set_star (base_type,
11395 TREE_INT_CST_LOW (TYPE_SIZE (t)) / CHAR_TYPE_SIZE,
11397 ffetype_set_kind (base_type, 1, type);
11398 assert (ffetype_size (type) == sizeof (ffetargetLogical1));
11400 ffecom_tree_type[FFEINFO_basictypeLOGICAL][FFEINFO_kindtypeLOGICAL2]
11401 = t = make_signed_type (CHAR_TYPE_SIZE);
11402 pushdecl (build_decl (TYPE_DECL, get_identifier ("logical2"),
11404 type = ffetype_new ();
11405 ffeinfo_set_type (FFEINFO_basictypeLOGICAL, FFEINFO_kindtypeLOGICAL2,
11407 ffetype_set_ams (type,
11408 TYPE_ALIGN (t) / BITS_PER_UNIT, 0,
11409 TREE_INT_CST_LOW (TYPE_SIZE (t)) / BITS_PER_UNIT);
11410 ffetype_set_star (base_type,
11411 TREE_INT_CST_LOW (TYPE_SIZE (t)) / CHAR_TYPE_SIZE,
11413 ffetype_set_kind (base_type, 3, type);
11414 assert (ffetype_size (type) == sizeof (ffetargetLogical2));
11416 ffecom_tree_type[FFEINFO_basictypeLOGICAL][FFEINFO_kindtypeLOGICAL3]
11417 = t = make_signed_type (CHAR_TYPE_SIZE * 2);
11418 pushdecl (build_decl (TYPE_DECL, get_identifier ("logical3"),
11420 type = ffetype_new ();
11421 ffeinfo_set_type (FFEINFO_basictypeLOGICAL, FFEINFO_kindtypeLOGICAL3,
11423 ffetype_set_ams (type,
11424 TYPE_ALIGN (t) / BITS_PER_UNIT, 0,
11425 TREE_INT_CST_LOW (TYPE_SIZE (t)) / BITS_PER_UNIT);
11426 ffetype_set_star (base_type,
11427 TREE_INT_CST_LOW (TYPE_SIZE (t)) / CHAR_TYPE_SIZE,
11429 ffetype_set_kind (base_type, 6, type);
11430 assert (ffetype_size (type) == sizeof (ffetargetLogical3));
11432 ffecom_tree_type[FFEINFO_basictypeLOGICAL][FFEINFO_kindtypeLOGICAL4]
11433 = t = make_signed_type (FLOAT_TYPE_SIZE * 2);
11434 pushdecl (build_decl (TYPE_DECL, get_identifier ("logical4"),
11436 type = ffetype_new ();
11437 ffeinfo_set_type (FFEINFO_basictypeLOGICAL, FFEINFO_kindtypeLOGICAL4,
11439 ffetype_set_ams (type,
11440 TYPE_ALIGN (t) / BITS_PER_UNIT, 0,
11441 TREE_INT_CST_LOW (TYPE_SIZE (t)) / BITS_PER_UNIT);
11442 ffetype_set_star (base_type,
11443 TREE_INT_CST_LOW (TYPE_SIZE (t)) / CHAR_TYPE_SIZE,
11445 ffetype_set_kind (base_type, 2, type);
11446 assert (ffetype_size (type) == sizeof (ffetargetLogical4));
11448 ffecom_tree_type[FFEINFO_basictypeREAL][FFEINFO_kindtypeREAL1]
11449 = t = make_node (REAL_TYPE);
11450 TYPE_PRECISION (t) = FLOAT_TYPE_SIZE;
11451 pushdecl (build_decl (TYPE_DECL, get_identifier ("real"),
11454 type = ffetype_new ();
11456 ffeinfo_set_type (FFEINFO_basictypeREAL, FFEINFO_kindtypeREAL1,
11458 ffetype_set_ams (type,
11459 TYPE_ALIGN (t) / BITS_PER_UNIT, 0,
11460 TREE_INT_CST_LOW (TYPE_SIZE (t)) / BITS_PER_UNIT);
11461 ffetype_set_star (base_type,
11462 TREE_INT_CST_LOW (TYPE_SIZE (t)) / CHAR_TYPE_SIZE,
11464 ffetype_set_kind (base_type, 1, type);
11465 ffecom_f2c_typecode_[FFEINFO_basictypeREAL][FFEINFO_kindtypeREAL1]
11466 = FFETARGET_f2cTYREAL;
11467 assert (ffetype_size (type) == sizeof (ffetargetReal1));
11469 ffecom_tree_type[FFEINFO_basictypeREAL][FFEINFO_kindtypeREALDOUBLE]
11470 = t = make_node (REAL_TYPE);
11471 TYPE_PRECISION (t) = FLOAT_TYPE_SIZE * 2; /* Always twice REAL. */
11472 pushdecl (build_decl (TYPE_DECL, get_identifier ("double precision"),
11475 type = ffetype_new ();
11476 ffeinfo_set_type (FFEINFO_basictypeREAL, FFEINFO_kindtypeREALDOUBLE,
11478 ffetype_set_ams (type,
11479 TYPE_ALIGN (t) / BITS_PER_UNIT, 0,
11480 TREE_INT_CST_LOW (TYPE_SIZE (t)) / BITS_PER_UNIT);
11481 ffetype_set_star (base_type,
11482 TREE_INT_CST_LOW (TYPE_SIZE (t)) / CHAR_TYPE_SIZE,
11484 ffetype_set_kind (base_type, 2, type);
11485 ffecom_f2c_typecode_[FFEINFO_basictypeREAL][FFEINFO_kindtypeREAL2]
11486 = FFETARGET_f2cTYDREAL;
11487 assert (ffetype_size (type) == sizeof (ffetargetReal2));
11489 ffecom_tree_type[FFEINFO_basictypeCOMPLEX][FFEINFO_kindtypeREAL1]
11490 = t = ffecom_make_complex_type_ (ffecom_tree_type[FFEINFO_basictypeREAL][FFEINFO_kindtypeREAL1]);
11491 pushdecl (build_decl (TYPE_DECL, get_identifier ("complex"),
11493 type = ffetype_new ();
11495 ffeinfo_set_type (FFEINFO_basictypeCOMPLEX, FFEINFO_kindtypeREAL1,
11497 ffetype_set_ams (type,
11498 TYPE_ALIGN (t) / BITS_PER_UNIT, 0,
11499 TREE_INT_CST_LOW (TYPE_SIZE (t)) / BITS_PER_UNIT);
11500 ffetype_set_star (base_type,
11501 TREE_INT_CST_LOW (TYPE_SIZE (t)) / CHAR_TYPE_SIZE,
11503 ffetype_set_kind (base_type, 1, type);
11504 ffecom_f2c_typecode_[FFEINFO_basictypeCOMPLEX][FFEINFO_kindtypeREAL1]
11505 = FFETARGET_f2cTYCOMPLEX;
11506 assert (ffetype_size (type) == sizeof (ffetargetComplex1));
11508 ffecom_tree_type[FFEINFO_basictypeCOMPLEX][FFEINFO_kindtypeREALDOUBLE]
11509 = t = ffecom_make_complex_type_ (ffecom_tree_type[FFEINFO_basictypeREAL][FFEINFO_kindtypeREAL2]);
11510 pushdecl (build_decl (TYPE_DECL, get_identifier ("double complex"),
11512 type = ffetype_new ();
11513 ffeinfo_set_type (FFEINFO_basictypeCOMPLEX, FFEINFO_kindtypeREALDOUBLE,
11515 ffetype_set_ams (type,
11516 TYPE_ALIGN (t) / BITS_PER_UNIT, 0,
11517 TREE_INT_CST_LOW (TYPE_SIZE (t)) / BITS_PER_UNIT);
11518 ffetype_set_star (base_type,
11519 TREE_INT_CST_LOW (TYPE_SIZE (t)) / CHAR_TYPE_SIZE,
11521 ffetype_set_kind (base_type, 2,
11523 ffecom_f2c_typecode_[FFEINFO_basictypeCOMPLEX][FFEINFO_kindtypeREAL2]
11524 = FFETARGET_f2cTYDCOMPLEX;
11525 assert (ffetype_size (type) == sizeof (ffetargetComplex2));
11527 /* Make function and ptr-to-function types for non-CHARACTER types. */
11529 for (i = 0; ((size_t) i) < ARRAY_SIZE (ffecom_tree_type); ++i)
11530 for (j = 0; ((size_t) j) < ARRAY_SIZE (ffecom_tree_type[0]); ++j)
11532 if ((t = ffecom_tree_type[i][j]) != NULL_TREE)
11534 if (i == FFEINFO_basictypeINTEGER)
11536 /* Figure out the smallest INTEGER type that can hold
11537 a pointer on this machine. */
11538 if (GET_MODE_SIZE (TYPE_MODE (t))
11539 >= GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (null_pointer_node))))
11541 if ((ffecom_pointer_kind_ == FFEINFO_kindtypeNONE)
11542 || (GET_MODE_SIZE (TYPE_MODE (ffecom_tree_type[i][ffecom_pointer_kind_]))
11543 > GET_MODE_SIZE (TYPE_MODE (t))))
11544 ffecom_pointer_kind_ = j;
11547 else if (i == FFEINFO_basictypeCOMPLEX)
11548 t = void_type_node;
11549 /* For f2c compatibility, REAL functions are really
11550 implemented as DOUBLE PRECISION. */
11551 else if ((i == FFEINFO_basictypeREAL)
11552 && (j == FFEINFO_kindtypeREAL1))
11553 t = ffecom_tree_type
11554 [FFEINFO_basictypeREAL][FFEINFO_kindtypeREAL2];
11556 t = ffecom_tree_fun_type[i][j] = build_function_type (t,
11558 ffecom_tree_ptr_to_fun_type[i][j] = build_pointer_type (t);
11562 /* Set up pointer types. */
11564 if (ffecom_pointer_kind_ == FFEINFO_basictypeNONE)
11565 fatal_error ("no INTEGER type can hold a pointer on this configuration");
11566 else if (0 && ffe_is_do_internal_checks ())
11567 fprintf (stderr, "Pointer type kt=%d\n", ffecom_pointer_kind_);
11568 ffetype_set_kind (ffeinfo_type (FFEINFO_basictypeINTEGER,
11569 FFEINFO_kindtypeINTEGERDEFAULT),
11571 ffeinfo_type (FFEINFO_basictypeINTEGER,
11572 ffecom_pointer_kind_));
11574 if (ffe_is_ugly_assign ())
11575 ffecom_label_kind_ = ffecom_pointer_kind_; /* Require ASSIGN etc to this. */
11577 ffecom_label_kind_ = FFEINFO_kindtypeINTEGERDEFAULT;
11578 if (0 && ffe_is_do_internal_checks ())
11579 fprintf (stderr, "Label type kt=%d\n", ffecom_label_kind_);
11581 ffecom_integer_type_node
11582 = ffecom_tree_type[FFEINFO_basictypeINTEGER][FFEINFO_kindtypeINTEGER1];
11583 ffecom_integer_zero_node = convert (ffecom_integer_type_node,
11584 integer_zero_node);
11585 ffecom_integer_one_node = convert (ffecom_integer_type_node,
11588 /* Yes, the "FLOAT_TYPE_SIZE" references below are intentional.
11589 Turns out that by TYLONG, runtime/libI77/lio.h really means
11590 "whatever size an ftnint is". For consistency and sanity,
11591 com.h and runtime/f2c.h.in agree that flag, ftnint, and ftlen
11592 all are INTEGER, which we also make out of whatever back-end
11593 integer type is FLOAT_TYPE_SIZE bits wide. This change, from
11594 LONG_TYPE_SIZE, for TYLONG and TYLOGICAL, was necessary to
11595 accommodate machines like the Alpha. Note that this suggests
11596 f2c and libf2c are missing a distinction perhaps needed on
11597 some machines between "int" and "long int". -- burley 0.5.5 950215 */
11599 ffecom_f2c_set_lio_code_ (FFEINFO_basictypeINTEGER, FLOAT_TYPE_SIZE,
11600 FFETARGET_f2cTYLONG);
11601 ffecom_f2c_set_lio_code_ (FFEINFO_basictypeINTEGER, SHORT_TYPE_SIZE,
11602 FFETARGET_f2cTYSHORT);
11603 ffecom_f2c_set_lio_code_ (FFEINFO_basictypeINTEGER, CHAR_TYPE_SIZE,
11604 FFETARGET_f2cTYINT1);
11605 ffecom_f2c_set_lio_code_ (FFEINFO_basictypeINTEGER, LONG_LONG_TYPE_SIZE,
11606 FFETARGET_f2cTYQUAD);
11607 ffecom_f2c_set_lio_code_ (FFEINFO_basictypeLOGICAL, FLOAT_TYPE_SIZE,
11608 FFETARGET_f2cTYLOGICAL);
11609 ffecom_f2c_set_lio_code_ (FFEINFO_basictypeLOGICAL, SHORT_TYPE_SIZE,
11610 FFETARGET_f2cTYLOGICAL2);
11611 ffecom_f2c_set_lio_code_ (FFEINFO_basictypeLOGICAL, CHAR_TYPE_SIZE,
11612 FFETARGET_f2cTYLOGICAL1);
11613 /* ~~~Not really such a type in libf2c, e.g. I/O support? */
11614 ffecom_f2c_set_lio_code_ (FFEINFO_basictypeLOGICAL, LONG_LONG_TYPE_SIZE,
11615 FFETARGET_f2cTYQUAD);
11617 /* CHARACTER stuff is all special-cased, so it is not handled in the above
11618 loop. CHARACTER items are built as arrays of unsigned char. */
11620 ffecom_tree_type[FFEINFO_basictypeCHARACTER]
11621 [FFEINFO_kindtypeCHARACTER1] = t = char_type_node;
11622 type = ffetype_new ();
11624 ffeinfo_set_type (FFEINFO_basictypeCHARACTER,
11625 FFEINFO_kindtypeCHARACTER1,
11627 ffetype_set_ams (type,
11628 TYPE_ALIGN (t) / BITS_PER_UNIT, 0,
11629 TREE_INT_CST_LOW (TYPE_SIZE (t)) / BITS_PER_UNIT);
11630 ffetype_set_kind (base_type, 1, type);
11631 assert (ffetype_size (type)
11632 == sizeof (((ffetargetCharacter1) { 0, NULL }).text[0]));
11634 ffecom_tree_fun_type[FFEINFO_basictypeCHARACTER]
11635 [FFEINFO_kindtypeCHARACTER1] = ffecom_tree_fun_type_void;
11636 ffecom_tree_ptr_to_fun_type[FFEINFO_basictypeCHARACTER]
11637 [FFEINFO_kindtypeCHARACTER1]
11638 = ffecom_tree_ptr_to_fun_type_void;
11639 ffecom_f2c_typecode_[FFEINFO_basictypeCHARACTER][FFEINFO_kindtypeCHARACTER1]
11640 = FFETARGET_f2cTYCHAR;
11642 ffecom_f2c_typecode_[FFEINFO_basictypeANY][FFEINFO_kindtypeANY]
11645 /* Make multi-return-value type and fields. */
11647 ffecom_multi_type_node_ = make_node (UNION_TYPE);
11651 for (i = 0; ((size_t) i) < ARRAY_SIZE (ffecom_tree_type); ++i)
11652 for (j = 0; ((size_t) j) < ARRAY_SIZE (ffecom_tree_type[0]); ++j)
11656 if (ffecom_tree_type[i][j] == NULL_TREE)
11657 continue; /* Not supported. */
11658 sprintf (&name[0], "bt_%s_kt_%s",
11659 ffeinfo_basictype_string ((ffeinfoBasictype) i),
11660 ffeinfo_kindtype_string ((ffeinfoKindtype) j));
11661 ffecom_multi_fields_[i][j] = build_decl (FIELD_DECL,
11662 get_identifier (name),
11663 ffecom_tree_type[i][j]);
11664 DECL_CONTEXT (ffecom_multi_fields_[i][j])
11665 = ffecom_multi_type_node_;
11666 DECL_ALIGN (ffecom_multi_fields_[i][j]) = 0;
11667 DECL_USER_ALIGN (ffecom_multi_fields_[i][j]) = 0;
11668 TREE_CHAIN (ffecom_multi_fields_[i][j]) = field;
11669 field = ffecom_multi_fields_[i][j];
11672 TYPE_FIELDS (ffecom_multi_type_node_) = field;
11673 layout_type (ffecom_multi_type_node_);
11675 /* Subroutines usually return integer because they might have alternate
11678 ffecom_tree_subr_type
11679 = build_function_type (integer_type_node, NULL_TREE);
11680 ffecom_tree_ptr_to_subr_type
11681 = build_pointer_type (ffecom_tree_subr_type);
11682 ffecom_tree_blockdata_type
11683 = build_function_type (void_type_node, NULL_TREE);
11685 builtin_function ("__builtin_atanf", float_ftype_float,
11686 BUILT_IN_ATANF, BUILT_IN_NORMAL, "atanf", NULL_TREE);
11687 builtin_function ("__builtin_atan", double_ftype_double,
11688 BUILT_IN_ATAN, BUILT_IN_NORMAL, "atan", NULL_TREE);
11689 builtin_function ("__builtin_atanl", ldouble_ftype_ldouble,
11690 BUILT_IN_ATANL, BUILT_IN_NORMAL, "atanl", NULL_TREE);
11692 builtin_function ("__builtin_atan2f", float_ftype_float_float,
11693 BUILT_IN_ATAN2F, BUILT_IN_NORMAL, "atan2f", NULL_TREE);
11694 builtin_function ("__builtin_atan2", double_ftype_double_double,
11695 BUILT_IN_ATAN2, BUILT_IN_NORMAL, "atan2", NULL_TREE);
11696 builtin_function ("__builtin_atan2l", ldouble_ftype_ldouble_ldouble,
11697 BUILT_IN_ATAN2L, BUILT_IN_NORMAL, "atan2l", NULL_TREE);
11699 builtin_function ("__builtin_cosf", float_ftype_float,
11700 BUILT_IN_COSF, BUILT_IN_NORMAL, "cosf", NULL_TREE);
11701 builtin_function ("__builtin_cos", double_ftype_double,
11702 BUILT_IN_COS, BUILT_IN_NORMAL, "cos", NULL_TREE);
11703 builtin_function ("__builtin_cosl", ldouble_ftype_ldouble,
11704 BUILT_IN_COSL, BUILT_IN_NORMAL, "cosl", NULL_TREE);
11706 builtin_function ("__builtin_expf", float_ftype_float,
11707 BUILT_IN_EXPF, BUILT_IN_NORMAL, "expf", NULL_TREE);
11708 builtin_function ("__builtin_exp", double_ftype_double,
11709 BUILT_IN_EXP, BUILT_IN_NORMAL, "exp", NULL_TREE);
11710 builtin_function ("__builtin_expl", ldouble_ftype_ldouble,
11711 BUILT_IN_EXPL, BUILT_IN_NORMAL, "expl", NULL_TREE);
11713 builtin_function ("__builtin_floorf", float_ftype_float,
11714 BUILT_IN_FLOORF, BUILT_IN_NORMAL, "floorf", NULL_TREE);
11715 builtin_function ("__builtin_floor", double_ftype_double,
11716 BUILT_IN_FLOOR, BUILT_IN_NORMAL, "floor", NULL_TREE);
11717 builtin_function ("__builtin_floorl", ldouble_ftype_ldouble,
11718 BUILT_IN_FLOORL, BUILT_IN_NORMAL, "floorl", NULL_TREE);
11720 builtin_function ("__builtin_fmodf", float_ftype_float_float,
11721 BUILT_IN_FMODF, BUILT_IN_NORMAL, "fmodf", NULL_TREE);
11722 builtin_function ("__builtin_fmod", double_ftype_double_double,
11723 BUILT_IN_FMOD, BUILT_IN_NORMAL, "fmod", NULL_TREE);
11724 builtin_function ("__builtin_fmodl", ldouble_ftype_ldouble_ldouble,
11725 BUILT_IN_FMODL, BUILT_IN_NORMAL, "fmodl", NULL_TREE);
11727 builtin_function ("__builtin_logf", float_ftype_float,
11728 BUILT_IN_LOGF, BUILT_IN_NORMAL, "logf", NULL_TREE);
11729 builtin_function ("__builtin_log", double_ftype_double,
11730 BUILT_IN_LOG, BUILT_IN_NORMAL, "log", NULL_TREE);
11731 builtin_function ("__builtin_logl", ldouble_ftype_ldouble,
11732 BUILT_IN_LOGL, BUILT_IN_NORMAL, "logl", NULL_TREE);
11734 builtin_function ("__builtin_powf", float_ftype_float_float,
11735 BUILT_IN_POWF, BUILT_IN_NORMAL, "powf", NULL_TREE);
11736 builtin_function ("__builtin_pow", double_ftype_double_double,
11737 BUILT_IN_POW, BUILT_IN_NORMAL, "pow", NULL_TREE);
11738 builtin_function ("__builtin_powl", ldouble_ftype_ldouble_ldouble,
11739 BUILT_IN_POWL, BUILT_IN_NORMAL, "powl", NULL_TREE);
11741 builtin_function ("__builtin_sinf", float_ftype_float,
11742 BUILT_IN_SINF, BUILT_IN_NORMAL, "sinf", NULL_TREE);
11743 builtin_function ("__builtin_sin", double_ftype_double,
11744 BUILT_IN_SIN, BUILT_IN_NORMAL, "sin", NULL_TREE);
11745 builtin_function ("__builtin_sinl", ldouble_ftype_ldouble,
11746 BUILT_IN_SINL, BUILT_IN_NORMAL, "sinl", NULL_TREE);
11748 builtin_function ("__builtin_sqrtf", float_ftype_float,
11749 BUILT_IN_SQRTF, BUILT_IN_NORMAL, "sqrtf", NULL_TREE);
11750 builtin_function ("__builtin_sqrt", double_ftype_double,
11751 BUILT_IN_SQRT, BUILT_IN_NORMAL, "sqrt", NULL_TREE);
11752 builtin_function ("__builtin_sqrtl", ldouble_ftype_ldouble,
11753 BUILT_IN_SQRTL, BUILT_IN_NORMAL, "sqrtl", NULL_TREE);
11755 builtin_function ("__builtin_tanf", float_ftype_float,
11756 BUILT_IN_TANF, BUILT_IN_NORMAL, "tanf", NULL_TREE);
11757 builtin_function ("__builtin_tan", double_ftype_double,
11758 BUILT_IN_TAN, BUILT_IN_NORMAL, "tan", NULL_TREE);
11759 builtin_function ("__builtin_tanl", ldouble_ftype_ldouble,
11760 BUILT_IN_TANL, BUILT_IN_NORMAL, "tanl", NULL_TREE);
11762 pedantic_lvalues = FALSE;
11764 ffecom_f2c_make_type_ (&ffecom_f2c_integer_type_node,
11767 ffecom_f2c_make_type_ (&ffecom_f2c_address_type_node,
11770 ffecom_f2c_make_type_ (&ffecom_f2c_real_type_node,
11773 ffecom_f2c_make_type_ (&ffecom_f2c_doublereal_type_node,
11774 FFECOM_f2cDOUBLEREAL,
11776 ffecom_f2c_make_type_ (&ffecom_f2c_complex_type_node,
11779 ffecom_f2c_make_type_ (&ffecom_f2c_doublecomplex_type_node,
11780 FFECOM_f2cDOUBLECOMPLEX,
11782 ffecom_f2c_make_type_ (&ffecom_f2c_longint_type_node,
11785 ffecom_f2c_make_type_ (&ffecom_f2c_logical_type_node,
11788 ffecom_f2c_make_type_ (&ffecom_f2c_flag_type_node,
11791 ffecom_f2c_make_type_ (&ffecom_f2c_ftnlen_type_node,
11794 ffecom_f2c_make_type_ (&ffecom_f2c_ftnint_type_node,
11798 ffecom_f2c_ftnlen_zero_node
11799 = convert (ffecom_f2c_ftnlen_type_node, integer_zero_node);
11801 ffecom_f2c_ftnlen_one_node
11802 = convert (ffecom_f2c_ftnlen_type_node, integer_one_node);
11804 ffecom_f2c_ftnlen_two_node = build_int_2 (2, 0);
11805 TREE_TYPE (ffecom_f2c_ftnlen_two_node) = ffecom_integer_type_node;
11807 ffecom_f2c_ptr_to_ftnlen_type_node
11808 = build_pointer_type (ffecom_f2c_ftnlen_type_node);
11810 ffecom_f2c_ptr_to_ftnint_type_node
11811 = build_pointer_type (ffecom_f2c_ftnint_type_node);
11813 ffecom_f2c_ptr_to_integer_type_node
11814 = build_pointer_type (ffecom_f2c_integer_type_node);
11816 ffecom_f2c_ptr_to_real_type_node
11817 = build_pointer_type (ffecom_f2c_real_type_node);
11819 ffecom_float_zero_ = build_real (float_type_node, dconst0);
11820 ffecom_double_zero_ = build_real (double_type_node, dconst0);
11821 ffecom_float_half_ = build_real (float_type_node, dconsthalf);
11822 ffecom_double_half_ = build_real (double_type_node, dconsthalf);
11824 /* Do "extern int xargc;". */
11826 ffecom_tree_xargc_ = build_decl (VAR_DECL,
11827 get_identifier ("f__xargc"),
11828 integer_type_node);
11829 DECL_EXTERNAL (ffecom_tree_xargc_) = 1;
11830 TREE_STATIC (ffecom_tree_xargc_) = 1;
11831 TREE_PUBLIC (ffecom_tree_xargc_) = 1;
11832 ffecom_tree_xargc_ = start_decl (ffecom_tree_xargc_, FALSE);
11833 finish_decl (ffecom_tree_xargc_, NULL_TREE, FALSE);
11835 #if 0 /* This is being fixed, and seems to be working now. */
11836 if ((FLOAT_TYPE_SIZE != 32)
11837 || (TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (null_pointer_node))) != 32))
11839 warning ("configuration: REAL, INTEGER, and LOGICAL are %d bits wide,",
11840 (int) FLOAT_TYPE_SIZE);
11841 warning ("and pointers are %d bits wide, but g77 doesn't yet work",
11842 (int) TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (null_pointer_node))));
11843 warning ("properly unless they all are 32 bits wide");
11844 warning ("Please keep this in mind before you report bugs.");
11848 #if 0 /* Code in ste.c that would crash has been commented out. */
11849 if (TYPE_PRECISION (ffecom_f2c_ftnlen_type_node)
11850 < TYPE_PRECISION (string_type_node))
11851 /* I/O will probably crash. */
11852 warning ("configuration: char * holds %d bits, but ftnlen only %d",
11853 TYPE_PRECISION (string_type_node),
11854 TYPE_PRECISION (ffecom_f2c_ftnlen_type_node));
11857 #if 0 /* ASSIGN-related stuff has been changed to accommodate this. */
11858 if (TYPE_PRECISION (ffecom_integer_type_node)
11859 < TYPE_PRECISION (string_type_node))
11860 /* ASSIGN 10 TO I will crash. */
11861 warning ("configuration: char * holds %d bits, but INTEGER only %d --\n\
11862 ASSIGN statement might fail",
11863 TYPE_PRECISION (string_type_node),
11864 TYPE_PRECISION (ffecom_integer_type_node));
11868 /* ffecom_init_2 -- Initialize
11870 ffecom_init_2(); */
11873 ffecom_init_2 (void)
11875 assert (ffecom_outer_function_decl_ == NULL_TREE);
11876 assert (current_function_decl == NULL_TREE);
11877 assert (ffecom_which_entrypoint_decl_ == NULL_TREE);
11879 ffecom_master_arglist_ = NULL;
11881 ffecom_primary_entry_ = NULL;
11882 ffecom_is_altreturning_ = FALSE;
11883 ffecom_func_result_ = NULL_TREE;
11884 ffecom_multi_retval_ = NULL_TREE;
11887 /* ffecom_list_expr -- Transform list of exprs into gcc tree
11890 ffebld expr; // FFE opITEM list.
11891 tree = ffecom_list_expr(expr);
11893 List of actual args is transformed into corresponding gcc backend list. */
11896 ffecom_list_expr (ffebld expr)
11899 tree *plist = &list;
11900 tree trail = NULL_TREE; /* Append char length args here. */
11901 tree *ptrail = &trail;
11904 while (expr != NULL)
11906 tree texpr = ffecom_arg_expr (ffebld_head (expr), &length);
11908 if (texpr == error_mark_node)
11909 return error_mark_node;
11911 *plist = build_tree_list (NULL_TREE, texpr);
11912 plist = &TREE_CHAIN (*plist);
11913 expr = ffebld_trail (expr);
11914 if (length != NULL_TREE)
11916 *ptrail = build_tree_list (NULL_TREE, length);
11917 ptrail = &TREE_CHAIN (*ptrail);
11926 /* ffecom_list_ptr_to_expr -- Transform list of exprs into gcc tree
11929 ffebld expr; // FFE opITEM list.
11930 tree = ffecom_list_ptr_to_expr(expr);
11932 List of actual args is transformed into corresponding gcc backend list for
11933 use in calling an external procedure (vs. a statement function). */
11936 ffecom_list_ptr_to_expr (ffebld expr)
11939 tree *plist = &list;
11940 tree trail = NULL_TREE; /* Append char length args here. */
11941 tree *ptrail = &trail;
11944 while (expr != NULL)
11946 tree texpr = ffecom_arg_ptr_to_expr (ffebld_head (expr), &length);
11948 if (texpr == error_mark_node)
11949 return error_mark_node;
11951 *plist = build_tree_list (NULL_TREE, texpr);
11952 plist = &TREE_CHAIN (*plist);
11953 expr = ffebld_trail (expr);
11954 if (length != NULL_TREE)
11956 *ptrail = build_tree_list (NULL_TREE, length);
11957 ptrail = &TREE_CHAIN (*ptrail);
11966 /* Obtain gcc's LABEL_DECL tree for label. */
11969 ffecom_lookup_label (ffelab label)
11973 if (ffelab_hook (label) == NULL_TREE)
11975 char labelname[16];
11977 switch (ffelab_type (label))
11979 case FFELAB_typeLOOPEND:
11980 case FFELAB_typeNOTLOOP:
11981 case FFELAB_typeENDIF:
11982 sprintf (labelname, "%" ffelabValue_f "u", ffelab_value (label));
11983 glabel = build_decl (LABEL_DECL, get_identifier (labelname),
11985 DECL_CONTEXT (glabel) = current_function_decl;
11986 DECL_MODE (glabel) = VOIDmode;
11989 case FFELAB_typeFORMAT:
11990 glabel = build_decl (VAR_DECL,
11991 ffecom_get_invented_identifier
11992 ("__g77_format_%d", (int) ffelab_value (label)),
11993 build_type_variant (build_array_type
11997 TREE_CONSTANT (glabel) = 1;
11998 TREE_STATIC (glabel) = 1;
11999 DECL_CONTEXT (glabel) = current_function_decl;
12000 DECL_INITIAL (glabel) = NULL;
12001 make_decl_rtl (glabel, NULL);
12002 expand_decl (glabel);
12004 ffecom_save_tree_forever (glabel);
12008 case FFELAB_typeANY:
12009 glabel = error_mark_node;
12013 assert ("bad label type" == NULL);
12017 ffelab_set_hook (label, glabel);
12021 glabel = ffelab_hook (label);
12027 /* Stabilizes the arguments. Don't use this if the lhs and rhs come from
12028 a single source specification (as in the fourth argument of MVBITS).
12029 If the type is NULL_TREE, the type of lhs is used to make the type of
12030 the MODIFY_EXPR. */
12033 ffecom_modify (tree newtype, tree lhs, tree rhs)
12035 if (lhs == error_mark_node || rhs == error_mark_node)
12036 return error_mark_node;
12038 if (newtype == NULL_TREE)
12039 newtype = TREE_TYPE (lhs);
12041 if (TREE_SIDE_EFFECTS (lhs))
12042 lhs = stabilize_reference (lhs);
12044 return ffecom_2s (MODIFY_EXPR, newtype, lhs, rhs);
12047 /* Register source file name. */
12050 ffecom_file (const char *name)
12052 ffecom_file_ (name);
12055 /* ffecom_notify_init_storage -- An aggregate storage is now fully init'ed
12058 ffecom_notify_init_storage(st);
12060 Gets called when all possible units in an aggregate storage area (a LOCAL
12061 with equivalences or a COMMON) have been initialized. The initialization
12062 info either is in ffestorag_init or, if that is NULL,
12063 ffestorag_accretion:
12065 ffestorag_init may contain an opCONTER or opARRTER. opCONTER may occur
12066 even for an array if the array is one element in length!
12068 ffestorag_accretion will contain an opACCTER. It is much like an
12069 opARRTER except it has an ffebit object in it instead of just a size.
12070 The back end can use the info in the ffebit object, if it wants, to
12071 reduce the amount of actual initialization, but in any case it should
12072 kill the ffebit object when done. Also, set accretion to NULL but
12073 init to a non-NULL value.
12075 After performing initialization, DO NOT set init to NULL, because that'll
12076 tell the front end it is ok for more initialization to happen. Instead,
12077 set init to an opANY expression or some such thing that you can use to
12078 tell that you've already initialized the object.
12081 Support two-pass FFE. */
12084 ffecom_notify_init_storage (ffestorag st)
12086 ffebld init; /* The initialization expression. */
12088 if (ffestorag_init (st) == NULL)
12090 init = ffestorag_accretion (st);
12091 assert (init != NULL);
12092 ffestorag_set_accretion (st, NULL);
12093 ffestorag_set_accretes (st, 0);
12094 ffestorag_set_init (st, init);
12098 /* ffecom_notify_init_symbol -- A symbol is now fully init'ed
12101 ffecom_notify_init_symbol(s);
12103 Gets called when all possible units in a symbol (not placed in COMMON
12104 or involved in EQUIVALENCE, unless it as yet has no ffestorag object)
12105 have been initialized. The initialization info either is in
12106 ffesymbol_init or, if that is NULL, ffesymbol_accretion:
12108 ffesymbol_init may contain an opCONTER or opARRTER. opCONTER may occur
12109 even for an array if the array is one element in length!
12111 ffesymbol_accretion will contain an opACCTER. It is much like an
12112 opARRTER except it has an ffebit object in it instead of just a size.
12113 The back end can use the info in the ffebit object, if it wants, to
12114 reduce the amount of actual initialization, but in any case it should
12115 kill the ffebit object when done. Also, set accretion to NULL but
12116 init to a non-NULL value.
12118 After performing initialization, DO NOT set init to NULL, because that'll
12119 tell the front end it is ok for more initialization to happen. Instead,
12120 set init to an opANY expression or some such thing that you can use to
12121 tell that you've already initialized the object.
12124 Support two-pass FFE. */
12127 ffecom_notify_init_symbol (ffesymbol s)
12129 ffebld init; /* The initialization expression. */
12131 if (ffesymbol_storage (s) == NULL)
12132 return; /* Do nothing until COMMON/EQUIVALENCE
12133 possibilities checked. */
12135 if ((ffesymbol_init (s) == NULL)
12136 && ((init = ffesymbol_accretion (s)) != NULL))
12138 ffesymbol_set_accretion (s, NULL);
12139 ffesymbol_set_accretes (s, 0);
12140 ffesymbol_set_init (s, init);
12144 /* ffecom_notify_primary_entry -- Learn which is the primary entry point
12147 ffecom_notify_primary_entry(s);
12149 Gets called when implicit or explicit PROGRAM statement seen or when
12150 FUNCTION, SUBROUTINE, or BLOCK DATA statement seen, with the primary
12151 global symbol that serves as the entry point. */
12154 ffecom_notify_primary_entry (ffesymbol s)
12156 ffecom_primary_entry_ = s;
12157 ffecom_primary_entry_kind_ = ffesymbol_kind (s);
12159 if ((ffecom_primary_entry_kind_ == FFEINFO_kindFUNCTION)
12160 || (ffecom_primary_entry_kind_ == FFEINFO_kindSUBROUTINE))
12161 ffecom_primary_entry_is_proc_ = TRUE;
12163 ffecom_primary_entry_is_proc_ = FALSE;
12165 if (!ffe_is_silent ())
12167 if (ffecom_primary_entry_kind_ == FFEINFO_kindPROGRAM)
12168 fprintf (stderr, "%s:\n", ffesymbol_text (s));
12170 fprintf (stderr, " %s:\n", ffesymbol_text (s));
12173 if (ffecom_primary_entry_kind_ == FFEINFO_kindSUBROUTINE)
12178 for (list = ffesymbol_dummyargs (s);
12180 list = ffebld_trail (list))
12182 arg = ffebld_head (list);
12183 if (ffebld_op (arg) == FFEBLD_opSTAR)
12185 ffecom_is_altreturning_ = TRUE;
12193 ffecom_open_include (char *name, ffewhereLine l, ffewhereColumn c)
12195 return ffecom_open_include_ (name, l, c);
12198 /* ffecom_ptr_to_expr -- Transform expr into gcc tree with & in front
12201 ffebld expr; // FFE expression.
12202 tree = ffecom_ptr_to_expr(expr);
12204 Like ffecom_expr, but sticks address-of in front of most things. */
12207 ffecom_ptr_to_expr (ffebld expr)
12210 ffeinfoBasictype bt;
12211 ffeinfoKindtype kt;
12214 assert (expr != NULL);
12216 switch (ffebld_op (expr))
12218 case FFEBLD_opSYMTER:
12219 s = ffebld_symter (expr);
12220 if (ffesymbol_where (s) == FFEINFO_whereINTRINSIC)
12224 ix = ffeintrin_gfrt_indirect (ffebld_symter_implementation (expr));
12225 assert (ix != FFECOM_gfrt);
12226 if ((item = ffecom_gfrt_[ix]) == NULL_TREE)
12228 ffecom_make_gfrt_ (ix);
12229 item = ffecom_gfrt_[ix];
12234 item = ffesymbol_hook (s).decl_tree;
12235 if (item == NULL_TREE)
12237 s = ffecom_sym_transform_ (s);
12238 item = ffesymbol_hook (s).decl_tree;
12241 assert (item != NULL);
12242 if (item == error_mark_node)
12244 if (!ffesymbol_hook (s).addr)
12245 item = ffecom_1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (item)),
12249 case FFEBLD_opARRAYREF:
12250 return ffecom_arrayref_ (NULL_TREE, expr, 1);
12252 case FFEBLD_opCONTER:
12254 bt = ffeinfo_basictype (ffebld_info (expr));
12255 kt = ffeinfo_kindtype (ffebld_info (expr));
12257 item = ffecom_constantunion (&ffebld_constant_union
12258 (ffebld_conter (expr)), bt, kt,
12259 ffecom_tree_type[bt][kt]);
12260 if (item == error_mark_node)
12261 return error_mark_node;
12262 item = ffecom_1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (item)),
12267 return error_mark_node;
12270 bt = ffeinfo_basictype (ffebld_info (expr));
12271 kt = ffeinfo_kindtype (ffebld_info (expr));
12273 item = ffecom_expr (expr);
12274 if (item == error_mark_node)
12275 return error_mark_node;
12277 /* The back end currently optimizes a bit too zealously for us, in that
12278 we fail JCB001 if the following block of code is omitted. It checks
12279 to see if the transformed expression is a symbol or array reference,
12280 and encloses it in a SAVE_EXPR if that is the case. */
12283 if ((TREE_CODE (item) == VAR_DECL)
12284 || (TREE_CODE (item) == PARM_DECL)
12285 || (TREE_CODE (item) == RESULT_DECL)
12286 || (TREE_CODE (item) == INDIRECT_REF)
12287 || (TREE_CODE (item) == ARRAY_REF)
12288 || (TREE_CODE (item) == COMPONENT_REF)
12290 || (TREE_CODE (item) == OFFSET_REF)
12292 || (TREE_CODE (item) == BUFFER_REF)
12293 || (TREE_CODE (item) == REALPART_EXPR)
12294 || (TREE_CODE (item) == IMAGPART_EXPR))
12296 item = ffecom_save_tree (item);
12299 item = ffecom_1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (item)),
12304 assert ("fall-through error" == NULL);
12305 return error_mark_node;
12308 /* Obtain a temp var with given data type.
12310 size is FFETARGET_charactersizeNONE for a non-CHARACTER type
12311 or >= 0 for a CHARACTER type.
12313 elements is -1 for a scalar or > 0 for an array of type. */
12316 ffecom_make_tempvar (const char *commentary, tree type,
12317 ffetargetCharacterSize size, int elements)
12320 static int mynumber;
12322 assert (current_binding_level->prep_state < 2);
12324 if (type == error_mark_node)
12325 return error_mark_node;
12327 if (size != FFETARGET_charactersizeNONE)
12328 type = build_array_type (type,
12329 build_range_type (ffecom_f2c_ftnlen_type_node,
12330 ffecom_f2c_ftnlen_one_node,
12331 build_int_2 (size, 0)));
12332 if (elements != -1)
12333 type = build_array_type (type,
12334 build_range_type (integer_type_node,
12336 build_int_2 (elements - 1,
12338 t = build_decl (VAR_DECL,
12339 ffecom_get_invented_identifier ("__g77_%s_%d",
12344 t = start_decl (t, FALSE);
12345 finish_decl (t, NULL_TREE, FALSE);
12350 /* Prepare argument pointer to expression.
12352 Like ffecom_prepare_expr, except for expressions to be evaluated
12353 via ffecom_arg_ptr_to_expr. */
12356 ffecom_prepare_arg_ptr_to_expr (ffebld expr)
12358 /* ~~For now, it seems to be the same thing. */
12359 ffecom_prepare_expr (expr);
12363 /* End of preparations. */
12366 ffecom_prepare_end (void)
12368 int prep_state = current_binding_level->prep_state;
12370 assert (prep_state < 2);
12371 current_binding_level->prep_state = 2;
12373 return (prep_state == 1) ? TRUE : FALSE;
12376 /* Prepare expression.
12378 This is called before any code is generated for the current block.
12379 It scans the expression, declares any temporaries that might be needed
12380 during evaluation of the expression, and stores those temporaries in
12381 the appropriate "hook" fields of the expression. `dest', if not NULL,
12382 specifies the destination that ffecom_expr_ will see, in case that
12383 helps avoid generating unused temporaries.
12385 ~~Improve to avoid allocating unused temporaries by taking `dest'
12386 into account vis-a-vis aliasing requirements of complex/character
12390 ffecom_prepare_expr_ (ffebld expr, ffebld dest UNUSED)
12392 ffeinfoBasictype bt;
12393 ffeinfoKindtype kt;
12394 ffetargetCharacterSize sz;
12395 tree tempvar = NULL_TREE;
12397 assert (current_binding_level->prep_state < 2);
12402 bt = ffeinfo_basictype (ffebld_info (expr));
12403 kt = ffeinfo_kindtype (ffebld_info (expr));
12404 sz = ffeinfo_size (ffebld_info (expr));
12406 /* Generate whatever temporaries are needed to represent the result
12407 of the expression. */
12409 if (bt == FFEINFO_basictypeCHARACTER)
12411 while (ffebld_op (expr) == FFEBLD_opPAREN)
12412 expr = ffebld_left (expr);
12415 switch (ffebld_op (expr))
12418 /* Don't make temps for SYMTER, CONTER, etc. */
12419 if (ffebld_arity (expr) == 0)
12424 case FFEINFO_basictypeCOMPLEX:
12425 if (ffebld_op (expr) == FFEBLD_opFUNCREF)
12429 if (ffebld_op (ffebld_left (expr)) != FFEBLD_opSYMTER)
12432 s = ffebld_symter (ffebld_left (expr));
12433 if (ffesymbol_where (s) == FFEINFO_whereCONSTANT
12434 || (ffesymbol_where (s) != FFEINFO_whereINTRINSIC
12435 && ! ffesymbol_is_f2c (s))
12436 || (ffesymbol_where (s) == FFEINFO_whereINTRINSIC
12437 && ! ffe_is_f2c_library ()))
12440 else if (ffebld_op (expr) == FFEBLD_opPOWER)
12442 /* Requires special treatment. There's no POW_CC function
12443 in libg2c, so POW_ZZ is used, which means we always
12444 need a double-complex temp, not a single-complex. */
12445 kt = FFEINFO_kindtypeREAL2;
12447 else if (ffebld_op (expr) != FFEBLD_opDIVIDE)
12448 /* The other ops don't need temps for complex operands. */
12451 /* ~~~Avoid making temps for some intrinsics, such as AIMAG(C),
12452 REAL(C). See 19990325-0.f, routine `check', for cases. */
12453 tempvar = ffecom_make_tempvar ("complex",
12455 [FFEINFO_basictypeCOMPLEX][kt],
12456 FFETARGET_charactersizeNONE,
12460 case FFEINFO_basictypeCHARACTER:
12461 if (ffebld_op (expr) != FFEBLD_opFUNCREF)
12464 if (sz == FFETARGET_charactersizeNONE)
12465 /* ~~Kludge alert! This should someday be fixed. */
12468 tempvar = ffecom_make_tempvar ("char", char_type_node, sz, -1);
12476 case FFEBLD_opCONCATENATE:
12478 /* This gets special handling, because only one set of temps
12479 is needed for a tree of these -- the tree is treated as
12480 a flattened list of concatenations when generating code. */
12482 ffecomConcatList_ catlist;
12483 tree ltmp, itmp, result;
12487 catlist = ffecom_concat_list_new_ (expr, FFETARGET_charactersizeNONE);
12488 count = ffecom_concat_list_count_ (catlist);
12493 = ffecom_make_tempvar ("concat_len",
12494 ffecom_f2c_ftnlen_type_node,
12495 FFETARGET_charactersizeNONE, count);
12497 = ffecom_make_tempvar ("concat_item",
12498 ffecom_f2c_address_type_node,
12499 FFETARGET_charactersizeNONE, count);
12501 = ffecom_make_tempvar ("concat_res",
12503 ffecom_concat_list_maxlen_ (catlist),
12506 tempvar = make_tree_vec (3);
12507 TREE_VEC_ELT (tempvar, 0) = ltmp;
12508 TREE_VEC_ELT (tempvar, 1) = itmp;
12509 TREE_VEC_ELT (tempvar, 2) = result;
12512 for (i = 0; i < count; ++i)
12513 ffecom_prepare_arg_ptr_to_expr (ffecom_concat_list_expr_ (catlist,
12516 ffecom_concat_list_kill_ (catlist);
12520 ffebld_nonter_set_hook (expr, tempvar);
12521 current_binding_level->prep_state = 1;
12526 case FFEBLD_opCONVERT:
12527 if (bt == FFEINFO_basictypeCHARACTER
12528 && ((ffebld_size_known (ffebld_left (expr))
12529 == FFETARGET_charactersizeNONE)
12530 || (ffebld_size_known (ffebld_left (expr)) >= sz)))
12531 tempvar = ffecom_make_tempvar ("convert", char_type_node, sz, -1);
12537 ffebld_nonter_set_hook (expr, tempvar);
12538 current_binding_level->prep_state = 1;
12541 /* Prepare subexpressions for this expr. */
12543 switch (ffebld_op (expr))
12545 case FFEBLD_opPERCENT_LOC:
12546 ffecom_prepare_ptr_to_expr (ffebld_left (expr));
12549 case FFEBLD_opPERCENT_VAL:
12550 case FFEBLD_opPERCENT_REF:
12551 ffecom_prepare_expr (ffebld_left (expr));
12554 case FFEBLD_opPERCENT_DESCR:
12555 ffecom_prepare_arg_ptr_to_expr (ffebld_left (expr));
12558 case FFEBLD_opITEM:
12564 item = ffebld_trail (item))
12565 if (ffebld_head (item) != NULL)
12566 ffecom_prepare_expr (ffebld_head (item));
12571 /* Need to handle character conversion specially. */
12572 switch (ffebld_arity (expr))
12575 ffecom_prepare_expr (ffebld_left (expr));
12576 ffecom_prepare_expr (ffebld_right (expr));
12580 ffecom_prepare_expr (ffebld_left (expr));
12591 /* Prepare expression for reading and writing.
12593 Like ffecom_prepare_expr, except for expressions to be evaluated
12594 via ffecom_expr_rw. */
12597 ffecom_prepare_expr_rw (tree type, ffebld expr)
12599 /* This is all we support for now. */
12600 assert (type == NULL_TREE || type == ffecom_type_expr (expr));
12602 /* ~~For now, it seems to be the same thing. */
12603 ffecom_prepare_expr (expr);
12607 /* Prepare expression for writing.
12609 Like ffecom_prepare_expr, except for expressions to be evaluated
12610 via ffecom_expr_w. */
12613 ffecom_prepare_expr_w (tree type, ffebld expr)
12615 /* This is all we support for now. */
12616 assert (type == NULL_TREE || type == ffecom_type_expr (expr));
12618 /* ~~For now, it seems to be the same thing. */
12619 ffecom_prepare_expr (expr);
12623 /* Prepare expression for returning.
12625 Like ffecom_prepare_expr, except for expressions to be evaluated
12626 via ffecom_return_expr. */
12629 ffecom_prepare_return_expr (ffebld expr)
12631 assert (current_binding_level->prep_state < 2);
12633 if (ffecom_primary_entry_kind_ == FFEINFO_kindSUBROUTINE
12634 && ffecom_is_altreturning_
12636 ffecom_prepare_expr (expr);
12639 /* Prepare pointer to expression.
12641 Like ffecom_prepare_expr, except for expressions to be evaluated
12642 via ffecom_ptr_to_expr. */
12645 ffecom_prepare_ptr_to_expr (ffebld expr)
12647 /* ~~For now, it seems to be the same thing. */
12648 ffecom_prepare_expr (expr);
12652 /* Transform expression into constant pointer-to-expression tree.
12654 If the expression can be transformed into a pointer-to-expression tree
12655 that is constant, that is done, and the tree returned. Else NULL_TREE
12658 That way, a caller can attempt to provide compile-time initialization
12659 of a variable and, if that fails, *then* choose to start a new block
12660 and resort to using temporaries, as appropriate. */
12663 ffecom_ptr_to_const_expr (ffebld expr)
12666 return integer_zero_node;
12668 if (ffebld_op (expr) == FFEBLD_opANY)
12669 return error_mark_node;
12671 if (ffebld_arity (expr) == 0
12672 && (ffebld_op (expr) != FFEBLD_opSYMTER
12673 || ffebld_where (expr) == FFEINFO_whereCOMMON
12674 || ffebld_where (expr) == FFEINFO_whereGLOBAL
12675 || ffebld_where (expr) == FFEINFO_whereINTRINSIC))
12679 t = ffecom_ptr_to_expr (expr);
12680 assert (TREE_CONSTANT (t));
12687 /* ffecom_return_expr -- Returns return-value expr given alt return expr
12689 tree rtn; // NULL_TREE means use expand_null_return()
12690 ffebld expr; // NULL if no alt return expr to RETURN stmt
12691 rtn = ffecom_return_expr(expr);
12693 Based on the program unit type and other info (like return function
12694 type, return master function type when alternate ENTRY points,
12695 whether subroutine has any alternate RETURN points, etc), returns the
12696 appropriate expression to be returned to the caller, or NULL_TREE
12697 meaning no return value or the caller expects it to be returned somewhere
12698 else (which is handled by other parts of this module). */
12701 ffecom_return_expr (ffebld expr)
12705 switch (ffecom_primary_entry_kind_)
12707 case FFEINFO_kindPROGRAM:
12708 case FFEINFO_kindBLOCKDATA:
12712 case FFEINFO_kindSUBROUTINE:
12713 if (!ffecom_is_altreturning_)
12714 rtn = NULL_TREE; /* No alt returns, never an expr. */
12715 else if (expr == NULL)
12716 rtn = integer_zero_node;
12718 rtn = ffecom_expr (expr);
12721 case FFEINFO_kindFUNCTION:
12722 if ((ffecom_multi_retval_ != NULL_TREE)
12723 || (ffesymbol_basictype (ffecom_primary_entry_)
12724 == FFEINFO_basictypeCHARACTER)
12725 || ((ffesymbol_basictype (ffecom_primary_entry_)
12726 == FFEINFO_basictypeCOMPLEX)
12727 && (ffecom_num_entrypoints_ == 0)
12728 && ffesymbol_is_f2c (ffecom_primary_entry_)))
12729 { /* Value is returned by direct assignment
12730 into (implicit) dummy. */
12734 rtn = ffecom_func_result_;
12736 /* Spurious error if RETURN happens before first reference! So elide
12737 this code. In particular, for debugging registry, rtn should always
12738 be non-null after all, but TREE_USED won't be set until we encounter
12739 a reference in the code. Perfectly okay (but weird) code that,
12740 e.g., has "GOTO 20;10 RETURN;20 RTN=0;GOTO 10", would result in
12741 this diagnostic for no reason. Have people use -O -Wuninitialized
12742 and leave it to the back end to find obviously weird cases. */
12744 /* Used to "assert(rtn != NULL_TREE);" here, but it's kind of a valid
12745 situation; if the return value has never been referenced, it won't
12746 have a tree under 2pass mode. */
12747 if ((rtn == NULL_TREE)
12748 || !TREE_USED (rtn))
12750 ffebad_start (FFEBAD_RETURN_VALUE_UNSET);
12751 ffebad_here (0, ffesymbol_where_line (ffecom_primary_entry_),
12752 ffesymbol_where_column (ffecom_primary_entry_));
12753 ffebad_string (ffesymbol_text (ffesymbol_funcresult
12754 (ffecom_primary_entry_)));
12761 assert ("bad unit kind" == NULL);
12762 case FFEINFO_kindANY:
12763 rtn = error_mark_node;
12770 /* Do save_expr only if tree is not error_mark_node. */
12773 ffecom_save_tree (tree t)
12775 return save_expr (t);
12778 /* Start a compound statement (block). */
12781 ffecom_start_compstmt (void)
12783 bison_rule_pushlevel_ ();
12786 /* Public entry point for front end to access start_decl. */
12789 ffecom_start_decl (tree decl, bool is_initialized)
12791 DECL_INITIAL (decl) = is_initialized ? error_mark_node : NULL_TREE;
12792 return start_decl (decl, FALSE);
12795 /* ffecom_sym_commit -- Symbol's state being committed to reality
12798 ffecom_sym_commit(s);
12800 Does whatever the backend needs when a symbol is committed after having
12801 been backtrackable for a period of time. */
12804 ffecom_sym_commit (ffesymbol s UNUSED)
12806 assert (!ffesymbol_retractable ());
12809 /* ffecom_sym_end_transition -- Perform end transition on all symbols
12811 ffecom_sym_end_transition();
12813 Does backend-specific stuff and also calls ffest_sym_end_transition
12814 to do the necessary FFE stuff.
12816 Backtracking is never enabled when this fn is called, so don't worry
12820 ffecom_sym_end_transition (ffesymbol s)
12824 assert (!ffesymbol_retractable ());
12826 s = ffest_sym_end_transition (s);
12828 if ((ffesymbol_kind (s) == FFEINFO_kindBLOCKDATA)
12829 && (ffesymbol_where (s) == FFEINFO_whereGLOBAL))
12831 ffecom_list_blockdata_
12832 = ffebld_new_item (ffebld_new_symter (s, FFEINTRIN_genNONE,
12833 FFEINTRIN_specNONE,
12834 FFEINTRIN_impNONE),
12835 ffecom_list_blockdata_);
12838 /* This is where we finally notice that a symbol has partial initialization
12839 and finalize it. */
12841 if (ffesymbol_accretion (s) != NULL)
12843 assert (ffesymbol_init (s) == NULL);
12844 ffecom_notify_init_symbol (s);
12846 else if (((st = ffesymbol_storage (s)) != NULL)
12847 && ((st = ffestorag_parent (st)) != NULL)
12848 && (ffestorag_accretion (st) != NULL))
12850 assert (ffestorag_init (st) == NULL);
12851 ffecom_notify_init_storage (st);
12854 if ((ffesymbol_kind (s) == FFEINFO_kindCOMMON)
12855 && (ffesymbol_where (s) == FFEINFO_whereLOCAL)
12856 && (ffesymbol_storage (s) != NULL))
12858 ffecom_list_common_
12859 = ffebld_new_item (ffebld_new_symter (s, FFEINTRIN_genNONE,
12860 FFEINTRIN_specNONE,
12861 FFEINTRIN_impNONE),
12862 ffecom_list_common_);
12868 /* ffecom_sym_exec_transition -- Perform exec transition on all symbols
12870 ffecom_sym_exec_transition();
12872 Does backend-specific stuff and also calls ffest_sym_exec_transition
12873 to do the necessary FFE stuff.
12875 See the long-winded description in ffecom_sym_learned for info
12876 on handling the situation where backtracking is inhibited. */
12879 ffecom_sym_exec_transition (ffesymbol s)
12881 s = ffest_sym_exec_transition (s);
12886 /* ffecom_sym_learned -- Initial or more info gained on symbol after exec
12889 s = ffecom_sym_learned(s);
12891 Called when a new symbol is seen after the exec transition or when more
12892 info (perhaps) is gained for an UNCERTAIN symbol. The symbol state when
12893 it arrives here is that all its latest info is updated already, so its
12894 state may be UNCERTAIN or UNDERSTOOD, it might already have the hook
12895 field filled in if its gone through here or exec_transition first, and
12898 The backend probably wants to check ffesymbol_retractable() to see if
12899 backtracking is in effect. If so, the FFE's changes to the symbol may
12900 be retracted (undone) or committed (ratified), at which time the
12901 appropriate ffecom_sym_retract or _commit function will be called
12904 If the backend has its own backtracking mechanism, great, use it so that
12905 committal is a simple operation. Though it doesn't make much difference,
12906 I suppose: the reason for tentative symbol evolution in the FFE is to
12907 enable error detection in weird incorrect statements early and to disable
12908 incorrect error detection on a correct statement. The backend is not
12909 likely to introduce any information that'll get involved in these
12910 considerations, so it is probably just fine that the implementation
12911 model for this fn and for _exec_transition is to not do anything
12912 (besides the required FFE stuff) if ffesymbol_retractable() returns TRUE
12913 and instead wait until ffecom_sym_commit is called (which it never
12914 will be as long as we're using ambiguity-detecting statement analysis in
12915 the FFE, which we are initially to shake out the code, but don't depend
12916 on this), otherwise go ahead and do whatever is needed.
12918 In essence, then, when this fn and _exec_transition get called while
12919 backtracking is enabled, a general mechanism would be to flag which (or
12920 both) of these were called (and in what order? neat question as to what
12921 might happen that I'm too lame to think through right now) and then when
12922 _commit is called reproduce the original calling sequence, if any, for
12923 the two fns (at which point backtracking will, of course, be disabled). */
12926 ffecom_sym_learned (ffesymbol s)
12928 ffestorag_exec_layout (s);
12933 /* ffecom_sym_retract -- Symbol's state being retracted from reality
12936 ffecom_sym_retract(s);
12938 Does whatever the backend needs when a symbol is retracted after having
12939 been backtrackable for a period of time. */
12942 ffecom_sym_retract (ffesymbol s UNUSED)
12944 assert (!ffesymbol_retractable ());
12946 #if 0 /* GCC doesn't commit any backtrackable sins,
12947 so nothing needed here. */
12948 switch (ffesymbol_hook (s).state)
12950 case 0: /* nothing happened yet. */
12953 case 1: /* exec transition happened. */
12956 case 2: /* learned happened. */
12959 case 3: /* learned then exec. */
12962 case 4: /* exec then learned. */
12966 assert ("bad hook state" == NULL);
12972 /* Create temporary gcc label. */
12975 ffecom_temp_label (void)
12978 static int mynumber = 0;
12980 glabel = build_decl (LABEL_DECL,
12981 ffecom_get_invented_identifier ("__g77_label_%d",
12984 DECL_CONTEXT (glabel) = current_function_decl;
12985 DECL_MODE (glabel) = VOIDmode;
12990 /* Return an expression that is usable as an arg in a conditional context
12991 (IF, DO WHILE, .NOT., and so on).
12993 Use the one provided for the back end as of >2.6.0. */
12996 ffecom_truth_value (tree expr)
12998 return ffe_truthvalue_conversion (expr);
13001 /* Return the inversion of a truth value (the inversion of what
13002 ffecom_truth_value builds).
13004 Apparently invert_truthvalue, which is properly in the back end, is
13005 enough for now, so just use it. */
13008 ffecom_truth_value_invert (tree expr)
13010 return invert_truthvalue (ffecom_truth_value (expr));
13013 /* Return the tree that is the type of the expression, as would be
13014 returned in TREE_TYPE(ffecom_expr(expr)), without otherwise
13015 transforming the expression, generating temporaries, etc. */
13018 ffecom_type_expr (ffebld expr)
13020 ffeinfoBasictype bt;
13021 ffeinfoKindtype kt;
13024 assert (expr != NULL);
13026 bt = ffeinfo_basictype (ffebld_info (expr));
13027 kt = ffeinfo_kindtype (ffebld_info (expr));
13028 tree_type = ffecom_tree_type[bt][kt];
13030 switch (ffebld_op (expr))
13032 case FFEBLD_opCONTER:
13033 case FFEBLD_opSYMTER:
13034 case FFEBLD_opARRAYREF:
13035 case FFEBLD_opUPLUS:
13036 case FFEBLD_opPAREN:
13037 case FFEBLD_opUMINUS:
13039 case FFEBLD_opSUBTRACT:
13040 case FFEBLD_opMULTIPLY:
13041 case FFEBLD_opDIVIDE:
13042 case FFEBLD_opPOWER:
13044 case FFEBLD_opFUNCREF:
13045 case FFEBLD_opSUBRREF:
13049 case FFEBLD_opNEQV:
13051 case FFEBLD_opCONVERT:
13058 case FFEBLD_opPERCENT_LOC:
13061 case FFEBLD_opACCTER:
13062 case FFEBLD_opARRTER:
13063 case FFEBLD_opITEM:
13064 case FFEBLD_opSTAR:
13065 case FFEBLD_opBOUNDS:
13066 case FFEBLD_opREPEAT:
13067 case FFEBLD_opLABTER:
13068 case FFEBLD_opLABTOK:
13069 case FFEBLD_opIMPDO:
13070 case FFEBLD_opCONCATENATE:
13071 case FFEBLD_opSUBSTR:
13073 assert ("bad op for ffecom_type_expr" == NULL);
13074 /* Fall through. */
13076 return error_mark_node;
13080 /* Return PARM_DECL for arg#1 of master fn containing alternate ENTRY points
13082 If the PARM_DECL already exists, return it, else create it. It's an
13083 integer_type_node argument for the master function that implements a
13084 subroutine or function with more than one entrypoint and is bound at
13085 run time with the entrypoint number (0 for SUBROUTINE/FUNCTION, 1 for
13086 first ENTRY statement, and so on). */
13089 ffecom_which_entrypoint_decl (void)
13091 assert (ffecom_which_entrypoint_decl_ != NULL_TREE);
13093 return ffecom_which_entrypoint_decl_;
13096 /* The following sections consists of private and public functions
13097 that have the same names and perform roughly the same functions
13098 as counterparts in the C front end. Changes in the C front end
13099 might affect how things should be done here. Only functions
13100 needed by the back end should be public here; the rest should
13101 be private (static in the C sense). Functions needed by other
13102 g77 front-end modules should be accessed by them via public
13103 ffecom_* names, which should themselves call private versions
13104 in this section so the private versions are easy to recognize
13105 when upgrading to a new gcc and finding interesting changes
13108 Functions named after rule "foo:" in c-parse.y are named
13109 "bison_rule_foo_" so they are easy to find. */
13112 bison_rule_pushlevel_ (void)
13114 emit_line_note (input_location);
13116 clear_last_expr ();
13117 expand_start_bindings (0);
13121 bison_rule_compstmt_ (void)
13124 int keep = kept_level_p ();
13126 /* Make the temps go away. */
13128 current_binding_level->names = NULL_TREE;
13130 emit_line_note (input_location);
13131 expand_end_bindings (getdecls (), keep, 0);
13132 t = poplevel (keep, 1, 0);
13137 /* Return a definition for a builtin function named NAME and whose data type
13138 is TYPE. TYPE should be a function type with argument types.
13139 FUNCTION_CODE tells later passes how to compile calls to this function.
13140 See tree.h for its possible values.
13142 If LIBRARY_NAME is nonzero, use that for DECL_ASSEMBLER_NAME,
13143 the name to be called if we can't opencode the function. If
13144 ATTRS is nonzero, use that for the function's attribute list. */
13147 builtin_function (const char *name, tree type, int function_code,
13148 enum built_in_class class, const char *library_name,
13149 tree attrs ATTRIBUTE_UNUSED)
13151 tree decl = build_decl (FUNCTION_DECL, get_identifier (name), type);
13152 DECL_EXTERNAL (decl) = 1;
13153 TREE_PUBLIC (decl) = 1;
13155 SET_DECL_ASSEMBLER_NAME (decl, get_identifier (library_name));
13156 make_decl_rtl (decl, NULL);
13158 DECL_BUILT_IN_CLASS (decl) = class;
13159 DECL_FUNCTION_CODE (decl) = function_code;
13164 /* Handle when a new declaration NEWDECL
13165 has the same name as an old one OLDDECL
13166 in the same binding contour.
13167 Prints an error message if appropriate.
13169 If safely possible, alter OLDDECL to look like NEWDECL, and return 1.
13170 Otherwise, return 0. */
13173 duplicate_decls (tree newdecl, tree olddecl)
13175 int types_match = 1;
13176 int new_is_definition = (TREE_CODE (newdecl) == FUNCTION_DECL
13177 && DECL_INITIAL (newdecl) != 0);
13178 tree oldtype = TREE_TYPE (olddecl);
13179 tree newtype = TREE_TYPE (newdecl);
13181 if (olddecl == newdecl)
13184 if (TREE_CODE (newtype) == ERROR_MARK
13185 || TREE_CODE (oldtype) == ERROR_MARK)
13188 /* New decl is completely inconsistent with the old one =>
13189 tell caller to replace the old one.
13190 This is always an error except in the case of shadowing a builtin. */
13191 if (TREE_CODE (olddecl) != TREE_CODE (newdecl))
13194 /* For real parm decl following a forward decl,
13195 return 1 so old decl will be reused. */
13196 if (types_match && TREE_CODE (newdecl) == PARM_DECL
13197 && TREE_ASM_WRITTEN (olddecl) && ! TREE_ASM_WRITTEN (newdecl))
13200 /* The new declaration is the same kind of object as the old one.
13201 The declarations may partially match. Print warnings if they don't
13202 match enough. Ultimately, copy most of the information from the new
13203 decl to the old one, and keep using the old one. */
13205 if (TREE_CODE (olddecl) == FUNCTION_DECL
13206 && DECL_BUILT_IN (olddecl))
13208 /* A function declaration for a built-in function. */
13209 if (!TREE_PUBLIC (newdecl))
13211 else if (!types_match)
13213 /* Accept the return type of the new declaration if same modes. */
13214 tree oldreturntype = TREE_TYPE (TREE_TYPE (olddecl));
13215 tree newreturntype = TREE_TYPE (TREE_TYPE (newdecl));
13217 if (TYPE_MODE (oldreturntype) == TYPE_MODE (newreturntype))
13219 /* Function types may be shared, so we can't just modify
13220 the return type of olddecl's function type. */
13222 = build_function_type (newreturntype,
13223 TYPE_ARG_TYPES (TREE_TYPE (olddecl)));
13227 TREE_TYPE (olddecl) = newtype;
13233 else if (TREE_CODE (olddecl) == FUNCTION_DECL
13234 && DECL_SOURCE_LINE (olddecl) == 0)
13236 /* A function declaration for a predeclared function
13237 that isn't actually built in. */
13238 if (!TREE_PUBLIC (newdecl))
13240 else if (!types_match)
13242 /* If the types don't match, preserve volatility indication.
13243 Later on, we will discard everything else about the
13244 default declaration. */
13245 TREE_THIS_VOLATILE (newdecl) |= TREE_THIS_VOLATILE (olddecl);
13249 /* Copy all the DECL_... slots specified in the new decl
13250 except for any that we copy here from the old type.
13252 Past this point, we don't change OLDTYPE and NEWTYPE
13253 even if we change the types of NEWDECL and OLDDECL. */
13257 /* Merge the data types specified in the two decls. */
13258 if (TREE_CODE (newdecl) != FUNCTION_DECL || !DECL_BUILT_IN (olddecl))
13259 TREE_TYPE (newdecl)
13260 = TREE_TYPE (olddecl)
13261 = TREE_TYPE (newdecl);
13263 /* Lay the type out, unless already done. */
13264 if (oldtype != TREE_TYPE (newdecl))
13266 if (TREE_TYPE (newdecl) != error_mark_node)
13267 layout_type (TREE_TYPE (newdecl));
13268 if (TREE_CODE (newdecl) != FUNCTION_DECL
13269 && TREE_CODE (newdecl) != TYPE_DECL
13270 && TREE_CODE (newdecl) != CONST_DECL)
13271 layout_decl (newdecl, 0);
13275 /* Since the type is OLDDECL's, make OLDDECL's size go with. */
13276 DECL_SIZE (newdecl) = DECL_SIZE (olddecl);
13277 DECL_SIZE_UNIT (newdecl) = DECL_SIZE_UNIT (olddecl);
13278 if (TREE_CODE (olddecl) != FUNCTION_DECL)
13279 if (DECL_ALIGN (olddecl) > DECL_ALIGN (newdecl))
13281 DECL_ALIGN (newdecl) = DECL_ALIGN (olddecl);
13282 DECL_USER_ALIGN (newdecl) |= DECL_USER_ALIGN (olddecl);
13286 /* Keep the old rtl since we can safely use it. */
13287 COPY_DECL_RTL (olddecl, newdecl);
13289 /* Merge the type qualifiers. */
13290 if (TREE_READONLY (newdecl))
13291 TREE_READONLY (olddecl) = 1;
13292 if (TREE_THIS_VOLATILE (newdecl))
13294 TREE_THIS_VOLATILE (olddecl) = 1;
13295 if (TREE_CODE (newdecl) == VAR_DECL)
13296 make_var_volatile (newdecl);
13299 /* Keep source location of definition rather than declaration.
13300 Likewise, keep decl at outer scope. */
13301 if ((DECL_INITIAL (newdecl) == 0 && DECL_INITIAL (olddecl) != 0)
13302 || (DECL_CONTEXT (newdecl) != 0 && DECL_CONTEXT (olddecl) == 0))
13304 DECL_SOURCE_LOCATION (newdecl) = DECL_SOURCE_LOCATION (olddecl);
13306 if (DECL_CONTEXT (olddecl) == 0
13307 && TREE_CODE (newdecl) != FUNCTION_DECL)
13308 DECL_CONTEXT (newdecl) = 0;
13311 /* Merge the unused-warning information. */
13312 if (DECL_IN_SYSTEM_HEADER (olddecl))
13313 DECL_IN_SYSTEM_HEADER (newdecl) = 1;
13314 else if (DECL_IN_SYSTEM_HEADER (newdecl))
13315 DECL_IN_SYSTEM_HEADER (olddecl) = 1;
13317 /* Merge the initialization information. */
13318 if (DECL_INITIAL (newdecl) == 0)
13319 DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
13321 /* Merge the section attribute.
13322 We want to issue an error if the sections conflict but that must be
13323 done later in decl_attributes since we are called before attributes
13325 if (DECL_SECTION_NAME (newdecl) == NULL_TREE)
13326 DECL_SECTION_NAME (newdecl) = DECL_SECTION_NAME (olddecl);
13328 /* Copy the assembler name. */
13329 COPY_DECL_ASSEMBLER_NAME (olddecl, newdecl);
13331 if (TREE_CODE (newdecl) == FUNCTION_DECL)
13333 DECL_STATIC_CONSTRUCTOR(newdecl) |= DECL_STATIC_CONSTRUCTOR(olddecl);
13334 DECL_STATIC_DESTRUCTOR (newdecl) |= DECL_STATIC_DESTRUCTOR (olddecl);
13335 TREE_THIS_VOLATILE (newdecl) |= TREE_THIS_VOLATILE (olddecl);
13336 TREE_READONLY (newdecl) |= TREE_READONLY (olddecl);
13337 DECL_IS_MALLOC (newdecl) |= DECL_IS_MALLOC (olddecl);
13338 DECL_IS_PURE (newdecl) |= DECL_IS_PURE (olddecl);
13341 /* If cannot merge, then use the new type and qualifiers,
13342 and don't preserve the old rtl. */
13345 TREE_TYPE (olddecl) = TREE_TYPE (newdecl);
13346 TREE_READONLY (olddecl) = TREE_READONLY (newdecl);
13347 TREE_THIS_VOLATILE (olddecl) = TREE_THIS_VOLATILE (newdecl);
13348 TREE_SIDE_EFFECTS (olddecl) = TREE_SIDE_EFFECTS (newdecl);
13351 /* Merge the storage class information. */
13352 /* For functions, static overrides non-static. */
13353 if (TREE_CODE (newdecl) == FUNCTION_DECL)
13355 TREE_PUBLIC (newdecl) &= TREE_PUBLIC (olddecl);
13356 /* This is since we don't automatically
13357 copy the attributes of NEWDECL into OLDDECL. */
13358 TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl);
13359 /* If this clears `static', clear it in the identifier too. */
13360 if (! TREE_PUBLIC (olddecl))
13361 TREE_PUBLIC (DECL_NAME (olddecl)) = 0;
13363 if (DECL_EXTERNAL (newdecl))
13365 TREE_STATIC (newdecl) = TREE_STATIC (olddecl);
13366 DECL_EXTERNAL (newdecl) = DECL_EXTERNAL (olddecl);
13367 /* An extern decl does not override previous storage class. */
13368 TREE_PUBLIC (newdecl) = TREE_PUBLIC (olddecl);
13372 TREE_STATIC (olddecl) = TREE_STATIC (newdecl);
13373 TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl);
13376 /* If either decl says `inline', this fn is inline,
13377 unless its definition was passed already. */
13378 if (DECL_INLINE (newdecl) && DECL_INITIAL (olddecl) == 0)
13379 DECL_INLINE (olddecl) = 1;
13380 DECL_INLINE (newdecl) = DECL_INLINE (olddecl);
13382 /* Get rid of any built-in function if new arg types don't match it
13383 or if we have a function definition. */
13384 if (TREE_CODE (newdecl) == FUNCTION_DECL
13385 && DECL_BUILT_IN (olddecl)
13386 && (!types_match || new_is_definition))
13388 TREE_TYPE (olddecl) = TREE_TYPE (newdecl);
13389 DECL_BUILT_IN_CLASS (olddecl) = NOT_BUILT_IN;
13392 /* If redeclaring a builtin function, and not a definition,
13394 Also preserve various other info from the definition. */
13395 if (TREE_CODE (newdecl) == FUNCTION_DECL && !new_is_definition)
13397 if (DECL_BUILT_IN (olddecl))
13399 DECL_BUILT_IN_CLASS (newdecl) = DECL_BUILT_IN_CLASS (olddecl);
13400 DECL_FUNCTION_CODE (newdecl) = DECL_FUNCTION_CODE (olddecl);
13403 DECL_RESULT (newdecl) = DECL_RESULT (olddecl);
13404 DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
13405 DECL_SAVED_INSNS (newdecl) = DECL_SAVED_INSNS (olddecl);
13406 DECL_ARGUMENTS (newdecl) = DECL_ARGUMENTS (olddecl);
13409 /* Copy most of the decl-specific fields of NEWDECL into OLDDECL.
13410 But preserve olddecl's DECL_UID. */
13412 register unsigned olddecl_uid = DECL_UID (olddecl);
13414 memcpy ((char *) olddecl + sizeof (struct tree_common),
13415 (char *) newdecl + sizeof (struct tree_common),
13416 sizeof (struct tree_decl) - sizeof (struct tree_common));
13417 DECL_UID (olddecl) = olddecl_uid;
13423 /* Finish processing of a declaration;
13424 install its initial value.
13425 If the length of an array type is not known before,
13426 it must be determined now, from the initial value, or it is an error. */
13429 finish_decl (tree decl, tree init, bool is_top_level)
13431 register tree type = TREE_TYPE (decl);
13432 int was_incomplete = (DECL_SIZE (decl) == 0);
13433 bool at_top_level = (current_binding_level == global_binding_level);
13434 bool top_level = is_top_level || at_top_level;
13436 /* Caller should pass TRUE for is_top_level only if we wouldn't be at top
13438 assert (!is_top_level || !at_top_level);
13440 if (TREE_CODE (decl) == PARM_DECL)
13441 assert (init == NULL_TREE);
13442 /* Remember that PARM_DECL doesn't have a DECL_INITIAL field per se -- it
13443 overlaps DECL_ARG_TYPE. */
13444 else if (init == NULL_TREE)
13445 assert (DECL_INITIAL (decl) == NULL_TREE);
13447 assert (DECL_INITIAL (decl) == error_mark_node);
13449 if (init != NULL_TREE)
13451 if (TREE_CODE (decl) != TYPE_DECL)
13452 DECL_INITIAL (decl) = init;
13455 /* typedef foo = bar; store the type of bar as the type of foo. */
13456 TREE_TYPE (decl) = TREE_TYPE (init);
13457 DECL_INITIAL (decl) = init = 0;
13461 /* Deduce size of array from initialization, if not already known */
13463 if (TREE_CODE (type) == ARRAY_TYPE
13464 && TYPE_DOMAIN (type) == 0
13465 && TREE_CODE (decl) != TYPE_DECL)
13467 assert (top_level);
13468 assert (was_incomplete);
13470 layout_decl (decl, 0);
13473 if (TREE_CODE (decl) == VAR_DECL)
13475 if (DECL_SIZE (decl) == NULL_TREE
13476 && TYPE_SIZE (TREE_TYPE (decl)) != NULL_TREE)
13477 layout_decl (decl, 0);
13479 if (DECL_SIZE (decl) == NULL_TREE
13480 && (TREE_STATIC (decl)
13482 /* A static variable with an incomplete type is an error if it is
13483 initialized. Also if it is not file scope. Otherwise, let it
13484 through, but if it is not `extern' then it may cause an error
13486 (DECL_INITIAL (decl) != 0 || DECL_CONTEXT (decl) != 0)
13488 /* An automatic variable with an incomplete type is an error. */
13489 !DECL_EXTERNAL (decl)))
13491 assert ("storage size not known" == NULL);
13495 if ((DECL_EXTERNAL (decl) || TREE_STATIC (decl))
13496 && (DECL_SIZE (decl) != 0)
13497 && (TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST))
13499 assert ("storage size not constant" == NULL);
13504 /* Output the assembler code and/or RTL code for variables and functions,
13505 unless the type is an undefined structure or union. If not, it will get
13506 done when the type is completed. */
13508 if (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == FUNCTION_DECL)
13510 rest_of_decl_compilation (decl, NULL,
13511 DECL_CONTEXT (decl) == 0,
13514 if (DECL_CONTEXT (decl) != 0)
13516 /* Recompute the RTL of a local array now if it used to be an
13517 incomplete type. */
13519 && !TREE_STATIC (decl) && !DECL_EXTERNAL (decl))
13521 /* If we used it already as memory, it must stay in memory. */
13522 TREE_ADDRESSABLE (decl) = TREE_USED (decl);
13523 /* If it's still incomplete now, no init will save it. */
13524 if (DECL_SIZE (decl) == 0)
13525 DECL_INITIAL (decl) = 0;
13526 expand_decl (decl);
13528 /* Compute and store the initial value. */
13529 if (TREE_CODE (decl) != FUNCTION_DECL)
13530 expand_decl_init (decl);
13533 else if (TREE_CODE (decl) == TYPE_DECL)
13535 rest_of_decl_compilation (decl, NULL,
13536 DECL_CONTEXT (decl) == 0,
13540 /* At the end of a declaration, throw away any variable type sizes of types
13541 defined inside that declaration. There is no use computing them in the
13542 following function definition. */
13543 if (current_binding_level == global_binding_level)
13544 get_pending_sizes ();
13547 /* Finish up a function declaration and compile that function
13548 all the way to assembler language output. The free the storage
13549 for the function definition.
13551 This is called after parsing the body of the function definition.
13553 NESTED is nonzero if the function being finished is nested in another. */
13556 finish_function (int nested)
13558 register tree fndecl = current_function_decl;
13560 assert (fndecl != NULL_TREE);
13561 if (TREE_CODE (fndecl) != ERROR_MARK)
13564 assert (DECL_CONTEXT (fndecl) != NULL_TREE);
13566 assert (DECL_CONTEXT (fndecl) == NULL_TREE);
13569 /* TREE_READONLY (fndecl) = 1;
13570 This caused &foo to be of type ptr-to-const-function
13571 which then got a warning when stored in a ptr-to-function variable. */
13573 poplevel (1, 0, 1);
13575 if (TREE_CODE (fndecl) != ERROR_MARK)
13577 BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
13579 /* Must mark the RESULT_DECL as being in this function. */
13581 DECL_CONTEXT (DECL_RESULT (fndecl)) = fndecl;
13583 /* Obey `register' declarations if `setjmp' is called in this fn. */
13584 /* Generate rtl for function exit. */
13585 expand_function_end ();
13587 /* If this is a nested function, protect the local variables in the stack
13588 above us from being collected while we're compiling this function. */
13590 ggc_push_context ();
13592 /* Run the optimizers and output the assembler code for this function. */
13593 rest_of_compilation (fndecl);
13595 /* Undo the GC context switch. */
13597 ggc_pop_context ();
13600 if (TREE_CODE (fndecl) != ERROR_MARK
13602 && DECL_SAVED_INSNS (fndecl) == 0)
13604 /* Stop pointing to the local nodes about to be freed. */
13605 /* But DECL_INITIAL must remain nonzero so we know this was an actual
13606 function definition. */
13607 /* For a nested function, this is done in pop_f_function_context. */
13608 /* If rest_of_compilation set this to 0, leave it 0. */
13609 if (DECL_INITIAL (fndecl) != 0)
13610 DECL_INITIAL (fndecl) = error_mark_node;
13611 DECL_ARGUMENTS (fndecl) = 0;
13616 /* Let the error reporting routines know that we're outside a function.
13617 For a nested function, this value is used in pop_c_function_context
13618 and then reset via pop_function_context. */
13619 ffecom_outer_function_decl_ = current_function_decl = NULL;
13623 /* Plug-in replacement for identifying the name of a decl and, for a
13624 function, what we call it in diagnostics. For now, "program unit"
13625 should suffice, since it's a bit of a hassle to figure out which
13626 of several kinds of things it is. Note that it could conceivably
13627 be a statement function, which probably isn't really a program unit
13628 per se, but if that comes up, it should be easy to check (being a
13629 nested function and all). */
13631 static const char *
13632 ffe_printable_name (tree decl, int v)
13634 /* Just to keep GCC quiet about the unused variable.
13635 In theory, differing values of V should produce different
13640 if (TREE_CODE (decl) == ERROR_MARK)
13641 return "erroneous code";
13642 return IDENTIFIER_POINTER (DECL_NAME (decl));
13646 /* g77's function to print out name of current function that caused
13650 ffe_print_error_function (diagnostic_context *context __attribute__((unused)),
13653 static ffeglobal last_g = NULL;
13654 static ffesymbol last_s = NULL;
13659 if ((ffecom_primary_entry_ == NULL)
13660 || (ffesymbol_global (ffecom_primary_entry_) == NULL))
13668 g = ffesymbol_global (ffecom_primary_entry_);
13669 if (ffecom_nested_entry_ == NULL)
13671 s = ffecom_primary_entry_;
13672 kind = _(ffeinfo_kind_message (ffesymbol_kind (s)));
13676 s = ffecom_nested_entry_;
13677 kind = _("In statement function");
13681 if ((last_g != g) || (last_s != s))
13684 fprintf (stderr, "%s: ", file);
13687 fprintf (stderr, _("Outside of any program unit:\n"));
13690 const char *name = ffesymbol_text (s);
13692 fprintf (stderr, "%s `%s':\n", kind, name);
13700 /* Similar to `lookup_name' but look only at current binding level. */
13703 lookup_name_current_level (tree name)
13707 if (current_binding_level == global_binding_level)
13708 return IDENTIFIER_GLOBAL_VALUE (name);
13710 if (IDENTIFIER_LOCAL_VALUE (name) == 0)
13713 for (t = current_binding_level->names; t; t = TREE_CHAIN (t))
13714 if (DECL_NAME (t) == name)
13720 /* Create a new `struct f_binding_level'. */
13722 static struct f_binding_level *
13723 make_binding_level (void)
13726 return ggc_alloc (sizeof (struct f_binding_level));
13729 /* Save and restore the variables in this file and elsewhere
13730 that keep track of the progress of compilation of the current function.
13731 Used for nested functions. */
13735 struct f_function *next;
13737 tree shadowed_labels;
13738 struct f_binding_level *binding_level;
13741 struct f_function *f_function_chain;
13743 /* Restore the variables used during compilation of a C function. */
13746 pop_f_function_context (void)
13748 struct f_function *p = f_function_chain;
13751 /* Bring back all the labels that were shadowed. */
13752 for (link = shadowed_labels; link; link = TREE_CHAIN (link))
13753 if (DECL_NAME (TREE_VALUE (link)) != 0)
13754 IDENTIFIER_LABEL_VALUE (DECL_NAME (TREE_VALUE (link)))
13755 = TREE_VALUE (link);
13757 if (current_function_decl != error_mark_node
13758 && DECL_SAVED_INSNS (current_function_decl) == 0)
13760 /* Stop pointing to the local nodes about to be freed. */
13761 /* But DECL_INITIAL must remain nonzero so we know this was an actual
13762 function definition. */
13763 DECL_INITIAL (current_function_decl) = error_mark_node;
13764 DECL_ARGUMENTS (current_function_decl) = 0;
13767 pop_function_context ();
13769 f_function_chain = p->next;
13771 named_labels = p->named_labels;
13772 shadowed_labels = p->shadowed_labels;
13773 current_binding_level = p->binding_level;
13778 /* Save and reinitialize the variables
13779 used during compilation of a C function. */
13782 push_f_function_context (void)
13784 struct f_function *p = xmalloc (sizeof (struct f_function));
13786 push_function_context ();
13788 p->next = f_function_chain;
13789 f_function_chain = p;
13791 p->named_labels = named_labels;
13792 p->shadowed_labels = shadowed_labels;
13793 p->binding_level = current_binding_level;
13797 push_parm_decl (tree parm)
13799 int old_immediate_size_expand = immediate_size_expand;
13801 /* Don't try computing parm sizes now -- wait till fn is called. */
13803 immediate_size_expand = 0;
13805 /* Fill in arg stuff. */
13807 DECL_ARG_TYPE (parm) = TREE_TYPE (parm);
13808 DECL_ARG_TYPE_AS_WRITTEN (parm) = TREE_TYPE (parm);
13809 TREE_READONLY (parm) = 1; /* All implementation args are read-only. */
13811 parm = pushdecl (parm);
13813 immediate_size_expand = old_immediate_size_expand;
13815 finish_decl (parm, NULL_TREE, FALSE);
13818 /* Like pushdecl, only it places X in GLOBAL_BINDING_LEVEL, if appropriate. */
13821 pushdecl_top_level (tree x)
13824 register struct f_binding_level *b = current_binding_level;
13825 register tree f = current_function_decl;
13827 current_binding_level = global_binding_level;
13828 current_function_decl = NULL_TREE;
13830 current_binding_level = b;
13831 current_function_decl = f;
13835 /* Store the list of declarations of the current level.
13836 This is done for the parameter declarations of a function being defined,
13837 after they are modified in the light of any missing parameters. */
13840 storedecls (tree decls)
13842 return current_binding_level->names = decls;
13845 /* Store the parameter declarations into the current function declaration.
13846 This is called after parsing the parameter declarations, before
13847 digesting the body of the function.
13849 For an old-style definition, modify the function's type
13850 to specify at least the number of arguments. */
13853 store_parm_decls (int is_main_program UNUSED)
13855 register tree fndecl = current_function_decl;
13857 if (fndecl == error_mark_node)
13860 /* This is a chain of PARM_DECLs from old-style parm declarations. */
13861 DECL_ARGUMENTS (fndecl) = storedecls (nreverse (getdecls ()));
13863 /* Initialize the RTL code for the function. */
13864 init_function_start (fndecl);
13866 /* Set up parameters and prepare for return, for the function. */
13867 expand_function_start (fndecl, 0);
13871 start_decl (tree decl, bool is_top_level)
13874 bool at_top_level = (current_binding_level == global_binding_level);
13875 bool top_level = is_top_level || at_top_level;
13877 /* Caller should pass TRUE for is_top_level only if we wouldn't be at top
13879 assert (!is_top_level || !at_top_level);
13881 if (DECL_INITIAL (decl) != NULL_TREE)
13883 assert (DECL_INITIAL (decl) == error_mark_node);
13884 assert (!DECL_EXTERNAL (decl));
13886 else if (top_level)
13887 assert ((TREE_STATIC (decl) == 1) || DECL_EXTERNAL (decl) == 1);
13889 /* For Fortran, we by default put things in .common when possible. */
13890 DECL_COMMON (decl) = 1;
13892 /* Add this decl to the current binding level. TEM may equal DECL or it may
13893 be a previous decl of the same name. */
13895 tem = pushdecl_top_level (decl);
13897 tem = pushdecl (decl);
13899 /* For a local variable, define the RTL now. */
13901 /* But not if this is a duplicate decl and we preserved the rtl from the
13902 previous one (which may or may not happen). */
13903 && !DECL_RTL_SET_P (tem))
13905 if (TYPE_SIZE (TREE_TYPE (tem)) != 0)
13907 else if (TREE_CODE (TREE_TYPE (tem)) == ARRAY_TYPE
13908 && DECL_INITIAL (tem) != 0)
13915 /* Create the FUNCTION_DECL for a function definition.
13916 DECLSPECS and DECLARATOR are the parts of the declaration;
13917 they describe the function's name and the type it returns,
13918 but twisted together in a fashion that parallels the syntax of C.
13920 This function creates a binding context for the function body
13921 as well as setting up the FUNCTION_DECL in current_function_decl.
13923 Returns 1 on success. If the DECLARATOR is not suitable for a function
13924 (it defines a datum instead), we return 0, which tells
13925 ffe_parse_file to report a parse error.
13927 NESTED is nonzero for a function nested within another function. */
13930 start_function (tree name, tree type, int nested, int public)
13934 int old_immediate_size_expand = immediate_size_expand;
13937 shadowed_labels = 0;
13939 /* Don't expand any sizes in the return type of the function. */
13940 immediate_size_expand = 0;
13945 assert (current_function_decl != NULL_TREE);
13946 assert (DECL_CONTEXT (current_function_decl) == NULL_TREE);
13950 assert (current_function_decl == NULL_TREE);
13953 if (TREE_CODE (type) == ERROR_MARK)
13954 decl1 = current_function_decl = error_mark_node;
13957 decl1 = build_decl (FUNCTION_DECL,
13960 TREE_PUBLIC (decl1) = public ? 1 : 0;
13962 DECL_INLINE (decl1) = 1;
13963 TREE_STATIC (decl1) = 1;
13964 DECL_EXTERNAL (decl1) = 0;
13966 announce_function (decl1);
13968 /* Make the init_value nonzero so pushdecl knows this is not tentative.
13969 error_mark_node is replaced below (in poplevel) with the BLOCK. */
13970 DECL_INITIAL (decl1) = error_mark_node;
13972 /* Record the decl so that the function name is defined. If we already have
13973 a decl for this name, and it is a FUNCTION_DECL, use the old decl. */
13975 current_function_decl = pushdecl (decl1);
13979 ffecom_outer_function_decl_ = current_function_decl;
13982 current_binding_level->prep_state = 2;
13984 if (TREE_CODE (current_function_decl) != ERROR_MARK)
13986 make_decl_rtl (current_function_decl, NULL);
13988 restype = TREE_TYPE (TREE_TYPE (current_function_decl));
13989 DECL_RESULT (current_function_decl)
13990 = build_decl (RESULT_DECL, NULL_TREE, restype);
13993 if (!nested && (TREE_CODE (current_function_decl) != ERROR_MARK))
13994 TREE_ADDRESSABLE (current_function_decl) = 1;
13996 immediate_size_expand = old_immediate_size_expand;
13999 /* Here are the public functions the GNU back end needs. */
14002 convert (tree type, tree expr)
14004 register tree e = expr;
14005 register enum tree_code code = TREE_CODE (type);
14007 if (type == TREE_TYPE (e)
14008 || TREE_CODE (e) == ERROR_MARK)
14010 if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (e)))
14011 return fold (build1 (NOP_EXPR, type, e));
14012 if (TREE_CODE (TREE_TYPE (e)) == ERROR_MARK
14013 || code == ERROR_MARK)
14014 return error_mark_node;
14015 if (TREE_CODE (TREE_TYPE (e)) == VOID_TYPE)
14017 assert ("void value not ignored as it ought to be" == NULL);
14018 return error_mark_node;
14020 if (code == VOID_TYPE)
14021 return build1 (CONVERT_EXPR, type, e);
14022 if ((code != RECORD_TYPE)
14023 && (TREE_CODE (TREE_TYPE (e)) == RECORD_TYPE))
14024 e = ffecom_1 (REALPART_EXPR, TREE_TYPE (TYPE_FIELDS (TREE_TYPE (e))),
14026 if (code == INTEGER_TYPE || code == ENUMERAL_TYPE)
14027 return fold (convert_to_integer (type, e));
14028 if (code == POINTER_TYPE)
14029 return fold (convert_to_pointer (type, e));
14030 if (code == REAL_TYPE)
14031 return fold (convert_to_real (type, e));
14032 if (code == COMPLEX_TYPE)
14033 return fold (convert_to_complex (type, e));
14034 if (code == RECORD_TYPE)
14035 return fold (ffecom_convert_to_complex_ (type, e));
14037 assert ("conversion to non-scalar type requested" == NULL);
14038 return error_mark_node;
14041 /* Return the list of declarations of the current level.
14042 Note that this list is in reverse order unless/until
14043 you nreverse it; and when you do nreverse it, you must
14044 store the result back using `storedecls' or you will lose. */
14049 return current_binding_level->names;
14052 /* Nonzero if we are currently in the global binding level. */
14055 global_bindings_p (void)
14057 return current_binding_level == global_binding_level;
14061 ffecom_init_decl_processing (void)
14068 /* Delete the node BLOCK from the current binding level.
14069 This is used for the block inside a stmt expr ({...})
14070 so that the block can be reinserted where appropriate. */
14073 delete_block (tree block)
14076 if (current_binding_level->blocks == block)
14077 current_binding_level->blocks = TREE_CHAIN (block);
14078 for (t = current_binding_level->blocks; t;)
14080 if (TREE_CHAIN (t) == block)
14081 TREE_CHAIN (t) = TREE_CHAIN (block);
14083 t = TREE_CHAIN (t);
14085 TREE_CHAIN (block) = NULL;
14086 /* Clear TREE_USED which is always set by poplevel.
14087 The flag is set again if insert_block is called. */
14088 TREE_USED (block) = 0;
14092 insert_block (tree block)
14094 TREE_USED (block) = 1;
14095 current_binding_level->blocks
14096 = chainon (current_binding_level->blocks, block);
14099 /* Each front end provides its own. */
14100 static bool ffe_init (void);
14101 static void ffe_finish (void);
14102 static bool ffe_post_options (const char **);
14103 static void ffe_print_identifier (FILE *, tree, int);
14105 struct language_function GTY(())
14110 #undef LANG_HOOKS_NAME
14111 #define LANG_HOOKS_NAME "GNU F77"
14112 #undef LANG_HOOKS_INIT
14113 #define LANG_HOOKS_INIT ffe_init
14114 #undef LANG_HOOKS_FINISH
14115 #define LANG_HOOKS_FINISH ffe_finish
14116 #undef LANG_HOOKS_INIT_OPTIONS
14117 #define LANG_HOOKS_INIT_OPTIONS ffe_init_options
14118 #undef LANG_HOOKS_HANDLE_OPTION
14119 #define LANG_HOOKS_HANDLE_OPTION ffe_handle_option
14120 #undef LANG_HOOKS_POST_OPTIONS
14121 #define LANG_HOOKS_POST_OPTIONS ffe_post_options
14122 #undef LANG_HOOKS_PARSE_FILE
14123 #define LANG_HOOKS_PARSE_FILE ffe_parse_file
14124 #undef LANG_HOOKS_MARK_ADDRESSABLE
14125 #define LANG_HOOKS_MARK_ADDRESSABLE ffe_mark_addressable
14126 #undef LANG_HOOKS_PRINT_IDENTIFIER
14127 #define LANG_HOOKS_PRINT_IDENTIFIER ffe_print_identifier
14128 #undef LANG_HOOKS_DECL_PRINTABLE_NAME
14129 #define LANG_HOOKS_DECL_PRINTABLE_NAME ffe_printable_name
14130 #undef LANG_HOOKS_PRINT_ERROR_FUNCTION
14131 #define LANG_HOOKS_PRINT_ERROR_FUNCTION ffe_print_error_function
14132 #undef LANG_HOOKS_TRUTHVALUE_CONVERSION
14133 #define LANG_HOOKS_TRUTHVALUE_CONVERSION ffe_truthvalue_conversion
14135 #undef LANG_HOOKS_TYPE_FOR_MODE
14136 #define LANG_HOOKS_TYPE_FOR_MODE ffe_type_for_mode
14137 #undef LANG_HOOKS_TYPE_FOR_SIZE
14138 #define LANG_HOOKS_TYPE_FOR_SIZE ffe_type_for_size
14139 #undef LANG_HOOKS_SIGNED_TYPE
14140 #define LANG_HOOKS_SIGNED_TYPE ffe_signed_type
14141 #undef LANG_HOOKS_UNSIGNED_TYPE
14142 #define LANG_HOOKS_UNSIGNED_TYPE ffe_unsigned_type
14143 #undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE
14144 #define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE ffe_signed_or_unsigned_type
14146 /* We do not wish to use alias-set based aliasing at all. Used in the
14147 extreme (every object with its own set, with equivalences recorded) it
14148 might be helpful, but there are problems when it comes to inlining. We
14149 get on ok with flag_argument_noalias, and alias-set aliasing does
14150 currently limit how stack slots can be reused, which is a lose. */
14151 #undef LANG_HOOKS_GET_ALIAS_SET
14152 #define LANG_HOOKS_GET_ALIAS_SET hook_get_alias_set_0
14154 const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
14156 /* Table indexed by tree code giving a string containing a character
14157 classifying the tree code. Possibilities are
14158 t, d, s, c, r, <, 1, 2 and e. See tree.def for details. */
14160 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
14162 const char tree_code_type[] = {
14163 #include "tree.def"
14167 /* Table indexed by tree code giving number of expression
14168 operands beyond the fixed part of the node structure.
14169 Not used for types or decls. */
14171 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
14173 const unsigned char tree_code_length[] = {
14174 #include "tree.def"
14178 /* Names of tree components.
14179 Used for printing out the tree and error messages. */
14180 #define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
14182 const char *const tree_code_name[] = {
14183 #include "tree.def"
14188 ffe_post_options (const char **pfilename)
14190 const char *filename = *pfilename;
14192 /* Open input file. */
14193 if (filename == 0 || !strcmp (filename, "-"))
14196 filename = "stdin";
14199 finput = fopen (filename, "r");
14202 fatal_error ("can't open %s: %m", filename);
14211 #ifdef IO_BUFFER_SIZE
14212 setvbuf (finput, xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
14215 ffecom_init_decl_processing ();
14217 /* If the file is output from cpp, it should contain a first line
14218 `# 1 "real-filename"', and the current design of gcc (toplev.c
14219 in particular and the way it sets up information relied on by
14220 INCLUDE) requires that we read this now, and store the
14221 "real-filename" info in master_input_filename. Ask the lexer
14222 to try doing this. */
14223 ffelex_hash_kludge (finput);
14225 push_srcloc (input_filename, 0);
14227 /* FIXME: The ffelex_hash_kludge code needs to be cleaned up to
14228 set the new file name. Maybe in ffe_post_options. */
14235 ffe_terminate_0 ();
14237 if (ffe_is_ffedebug ())
14238 malloc_pool_display (malloc_pool_image ());
14244 ffe_mark_addressable (tree exp)
14246 register tree x = exp;
14248 switch (TREE_CODE (x))
14251 case COMPONENT_REF:
14253 x = TREE_OPERAND (x, 0);
14257 TREE_ADDRESSABLE (x) = 1;
14264 if (DECL_REGISTER (x) && !TREE_ADDRESSABLE (x)
14265 && DECL_NONLOCAL (x))
14267 if (TREE_PUBLIC (x))
14269 assert ("address of global register var requested" == NULL);
14272 assert ("address of register variable requested" == NULL);
14274 else if (DECL_REGISTER (x) && !TREE_ADDRESSABLE (x))
14276 if (TREE_PUBLIC (x))
14278 assert ("address of global register var requested" == NULL);
14281 assert ("address of register var requested" == NULL);
14283 put_var_into_stack (x, /*rescan=*/true);
14286 case FUNCTION_DECL:
14287 TREE_ADDRESSABLE (x) = 1;
14288 #if 0 /* poplevel deals with this now. */
14289 if (DECL_CONTEXT (x) == 0)
14290 TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (x)) = 1;
14298 /* Exit a binding level.
14299 Pop the level off, and restore the state of the identifier-decl mappings
14300 that were in effect when this level was entered.
14302 If KEEP is nonzero, this level had explicit declarations, so
14303 and create a "block" (a BLOCK node) for the level
14304 to record its declarations and subblocks for symbol table output.
14306 If FUNCTIONBODY is nonzero, this level is the body of a function,
14307 so create a block as if KEEP were set and also clear out all
14310 If REVERSE is nonzero, reverse the order of decls before putting
14311 them into the BLOCK. */
14314 poplevel (int keep, int reverse, int functionbody)
14316 register tree link;
14317 /* The chain of decls was accumulated in reverse order.
14318 Put it into forward order, just for cleanliness. */
14320 tree subblocks = current_binding_level->blocks;
14323 int block_previously_created;
14325 /* Get the decls in the order they were written.
14326 Usually current_binding_level->names is in reverse order.
14327 But parameter decls were previously put in forward order. */
14330 current_binding_level->names
14331 = decls = nreverse (current_binding_level->names);
14333 decls = current_binding_level->names;
14335 /* Output any nested inline functions within this block
14336 if they weren't already output. */
14338 for (decl = decls; decl; decl = TREE_CHAIN (decl))
14339 if (TREE_CODE (decl) == FUNCTION_DECL
14340 && ! TREE_ASM_WRITTEN (decl)
14341 && DECL_INITIAL (decl) != 0
14342 && TREE_ADDRESSABLE (decl))
14344 /* If this decl was copied from a file-scope decl
14345 on account of a block-scope extern decl,
14346 propagate TREE_ADDRESSABLE to the file-scope decl.
14348 DECL_ABSTRACT_ORIGIN can be set to itself if warn_return_type is
14349 true, since then the decl goes through save_for_inline_copying. */
14350 if (DECL_ABSTRACT_ORIGIN (decl) != 0
14351 && DECL_ABSTRACT_ORIGIN (decl) != decl)
14352 TREE_ADDRESSABLE (DECL_ABSTRACT_ORIGIN (decl)) = 1;
14353 else if (DECL_SAVED_INSNS (decl) != 0)
14355 push_function_context ();
14356 output_inline_function (decl);
14357 pop_function_context ();
14361 /* If there were any declarations or structure tags in that level,
14362 or if this level is a function body,
14363 create a BLOCK to record them for the life of this function. */
14366 block_previously_created = (current_binding_level->this_block != 0);
14367 if (block_previously_created)
14368 block = current_binding_level->this_block;
14369 else if (keep || functionbody)
14370 block = make_node (BLOCK);
14373 BLOCK_VARS (block) = decls;
14374 BLOCK_SUBBLOCKS (block) = subblocks;
14377 /* In each subblock, record that this is its superior. */
14379 for (link = subblocks; link; link = TREE_CHAIN (link))
14380 BLOCK_SUPERCONTEXT (link) = block;
14382 /* Clear out the meanings of the local variables of this level. */
14384 for (link = decls; link; link = TREE_CHAIN (link))
14386 if (DECL_NAME (link) != 0)
14388 /* If the ident. was used or addressed via a local extern decl,
14389 don't forget that fact. */
14390 if (DECL_EXTERNAL (link))
14392 if (TREE_USED (link))
14393 TREE_USED (DECL_NAME (link)) = 1;
14394 if (TREE_ADDRESSABLE (link))
14395 TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (link)) = 1;
14397 IDENTIFIER_LOCAL_VALUE (DECL_NAME (link)) = 0;
14401 /* If the level being exited is the top level of a function,
14402 check over all the labels, and clear out the current
14403 (function local) meanings of their names. */
14407 /* If this is the top level block of a function,
14408 the vars are the function's parameters.
14409 Don't leave them in the BLOCK because they are
14410 found in the FUNCTION_DECL instead. */
14412 BLOCK_VARS (block) = 0;
14415 /* Pop the current level, and free the structure for reuse. */
14418 register struct f_binding_level *level = current_binding_level;
14419 current_binding_level = current_binding_level->level_chain;
14421 level->level_chain = free_binding_level;
14422 free_binding_level = level;
14425 /* Dispose of the block that we just made inside some higher level. */
14427 && current_function_decl != error_mark_node)
14428 DECL_INITIAL (current_function_decl) = block;
14431 if (!block_previously_created)
14432 current_binding_level->blocks
14433 = chainon (current_binding_level->blocks, block);
14435 /* If we did not make a block for the level just exited,
14436 any blocks made for inner levels
14437 (since they cannot be recorded as subblocks in that level)
14438 must be carried forward so they will later become subblocks
14439 of something else. */
14440 else if (subblocks)
14441 current_binding_level->blocks
14442 = chainon (current_binding_level->blocks, subblocks);
14445 TREE_USED (block) = 1;
14450 ffe_print_identifier (FILE *file, tree node, int indent)
14452 print_node (file, "global", IDENTIFIER_GLOBAL_VALUE (node), indent + 4);
14453 print_node (file, "local", IDENTIFIER_LOCAL_VALUE (node), indent + 4);
14456 /* Record a decl-node X as belonging to the current lexical scope.
14457 Check for errors (such as an incompatible declaration for the same
14458 name already seen in the same scope).
14460 Returns either X or an old decl for the same name.
14461 If an old decl is returned, it may have been smashed
14462 to agree with what X says. */
14468 register tree name = DECL_NAME (x);
14469 register struct f_binding_level *b = current_binding_level;
14471 if ((TREE_CODE (x) == FUNCTION_DECL)
14472 && (DECL_INITIAL (x) == 0)
14473 && DECL_EXTERNAL (x))
14474 DECL_CONTEXT (x) = NULL_TREE;
14476 DECL_CONTEXT (x) = current_function_decl;
14480 if (IDENTIFIER_INVENTED (name))
14482 DECL_ARTIFICIAL (x) = 1;
14483 DECL_IN_SYSTEM_HEADER (x) = 1;
14486 t = lookup_name_current_level (name);
14488 assert ((t == NULL_TREE) || (DECL_CONTEXT (x) == NULL_TREE));
14490 /* Don't push non-parms onto list for parms until we understand
14491 why we're doing this and whether it works. */
14493 assert ((b == global_binding_level)
14494 || !ffecom_transform_only_dummies_
14495 || TREE_CODE (x) == PARM_DECL);
14497 if ((t != NULL_TREE) && duplicate_decls (x, t))
14500 /* If we are processing a typedef statement, generate a whole new
14501 ..._TYPE node (which will be just an variant of the existing
14502 ..._TYPE node with identical properties) and then install the
14503 TYPE_DECL node generated to represent the typedef name as the
14504 TYPE_NAME of this brand new (duplicate) ..._TYPE node.
14506 The whole point here is to end up with a situation where each and every
14507 ..._TYPE node the compiler creates will be uniquely associated with
14508 AT MOST one node representing a typedef name. This way, even though
14509 the compiler substitutes corresponding ..._TYPE nodes for TYPE_DECL
14510 (i.e. "typedef name") nodes very early on, later parts of the
14511 compiler can always do the reverse translation and get back the
14512 corresponding typedef name. For example, given:
14514 typedef struct S MY_TYPE; MY_TYPE object;
14516 Later parts of the compiler might only know that `object' was of type
14517 `struct S' if it were not for code just below. With this code
14518 however, later parts of the compiler see something like:
14520 struct S' == struct S typedef struct S' MY_TYPE; struct S' object;
14522 And they can then deduce (from the node for type struct S') that the
14523 original object declaration was:
14527 Being able to do this is important for proper support of protoize, and
14528 also for generating precise symbolic debugging information which
14529 takes full account of the programmer's (typedef) vocabulary.
14531 Obviously, we don't want to generate a duplicate ..._TYPE node if the
14532 TYPE_DECL node that we are now processing really represents a
14533 standard built-in type.
14535 Since all standard types are effectively declared at line zero in the
14536 source file, we can easily check to see if we are working on a
14537 standard type by checking the current value of lineno. */
14539 if (TREE_CODE (x) == TYPE_DECL)
14541 if (DECL_SOURCE_LINE (x) == 0)
14543 if (TYPE_NAME (TREE_TYPE (x)) == 0)
14544 TYPE_NAME (TREE_TYPE (x)) = x;
14546 else if (TREE_TYPE (x) != error_mark_node)
14548 tree tt = TREE_TYPE (x);
14550 tt = build_type_copy (tt);
14551 TYPE_NAME (tt) = x;
14552 TREE_TYPE (x) = tt;
14556 /* This name is new in its binding level. Install the new declaration
14558 if (b == global_binding_level)
14559 IDENTIFIER_GLOBAL_VALUE (name) = x;
14561 IDENTIFIER_LOCAL_VALUE (name) = x;
14564 /* Put decls on list in reverse order. We will reverse them later if
14566 TREE_CHAIN (x) = b->names;
14572 /* Nonzero if the current level needs to have a BLOCK made. */
14575 kept_level_p (void)
14579 for (decl = current_binding_level->names;
14581 decl = TREE_CHAIN (decl))
14583 if (TREE_USED (decl) || TREE_CODE (decl) != VAR_DECL
14584 || (DECL_NAME (decl) && ! DECL_ARTIFICIAL (decl)))
14585 /* Currently, there aren't supposed to be non-artificial names
14586 at other than the top block for a function -- they're
14587 believed to always be temps. But it's wise to check anyway. */
14593 /* Enter a new binding level.
14594 If TAG_TRANSPARENT is nonzero, do so only for the name space of variables,
14595 not for that of tags. */
14598 pushlevel (int tag_transparent)
14600 register struct f_binding_level *newlevel = NULL_BINDING_LEVEL;
14602 assert (! tag_transparent);
14604 if (current_binding_level == global_binding_level)
14609 /* Reuse or create a struct for this binding level. */
14611 if (free_binding_level)
14613 newlevel = free_binding_level;
14614 free_binding_level = free_binding_level->level_chain;
14618 newlevel = make_binding_level ();
14621 /* Add this level to the front of the chain (stack) of levels that
14624 *newlevel = clear_binding_level;
14625 newlevel->level_chain = current_binding_level;
14626 current_binding_level = newlevel;
14629 /* Set the BLOCK node for the innermost scope
14630 (the one we are currently in). */
14633 set_block (tree block)
14635 current_binding_level->this_block = block;
14636 current_binding_level->names = chainon (current_binding_level->names,
14637 BLOCK_VARS (block));
14638 current_binding_level->blocks = chainon (current_binding_level->blocks,
14639 BLOCK_SUBBLOCKS (block));
14643 ffe_signed_or_unsigned_type (int unsignedp, tree type)
14647 if (! INTEGRAL_TYPE_P (type))
14649 if (TYPE_PRECISION (type) == TYPE_PRECISION (signed_char_type_node))
14650 return unsignedp ? unsigned_char_type_node : signed_char_type_node;
14651 if (TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node))
14652 return unsignedp ? unsigned_type_node : integer_type_node;
14653 if (TYPE_PRECISION (type) == TYPE_PRECISION (short_integer_type_node))
14654 return unsignedp ? short_unsigned_type_node : short_integer_type_node;
14655 if (TYPE_PRECISION (type) == TYPE_PRECISION (long_integer_type_node))
14656 return unsignedp ? long_unsigned_type_node : long_integer_type_node;
14657 if (TYPE_PRECISION (type) == TYPE_PRECISION (long_long_integer_type_node))
14658 return (unsignedp ? long_long_unsigned_type_node
14659 : long_long_integer_type_node);
14661 type2 = ffe_type_for_size (TYPE_PRECISION (type), unsignedp);
14662 if (type2 == NULL_TREE)
14669 ffe_signed_type (tree type)
14671 tree type1 = TYPE_MAIN_VARIANT (type);
14672 ffeinfoKindtype kt;
14675 if (type1 == unsigned_char_type_node || type1 == char_type_node)
14676 return signed_char_type_node;
14677 if (type1 == unsigned_type_node)
14678 return integer_type_node;
14679 if (type1 == short_unsigned_type_node)
14680 return short_integer_type_node;
14681 if (type1 == long_unsigned_type_node)
14682 return long_integer_type_node;
14683 if (type1 == long_long_unsigned_type_node)
14684 return long_long_integer_type_node;
14685 #if 0 /* gcc/c-* files only */
14686 if (type1 == unsigned_intDI_type_node)
14687 return intDI_type_node;
14688 if (type1 == unsigned_intSI_type_node)
14689 return intSI_type_node;
14690 if (type1 == unsigned_intHI_type_node)
14691 return intHI_type_node;
14692 if (type1 == unsigned_intQI_type_node)
14693 return intQI_type_node;
14696 type2 = ffe_type_for_size (TYPE_PRECISION (type1), 0);
14697 if (type2 != NULL_TREE)
14700 for (kt = 0; kt < ARRAY_SIZE (ffecom_tree_type[0]); ++kt)
14702 type2 = ffecom_tree_type[FFEINFO_basictypeHOLLERITH][kt];
14704 if (type1 == type2)
14705 return ffecom_tree_type[FFEINFO_basictypeINTEGER][kt];
14711 /* Prepare expr to be an argument of a TRUTH_NOT_EXPR,
14712 or validate its data type for an `if' or `while' statement or ?..: exp.
14714 This preparation consists of taking the ordinary
14715 representation of an expression expr and producing a valid tree
14716 boolean expression describing whether expr is nonzero. We could
14717 simply always do build_binary_op (NE_EXPR, expr, integer_zero_node, 1),
14718 but we optimize comparisons, &&, ||, and !.
14720 The resulting type should always be `integer_type_node'. */
14723 ffe_truthvalue_conversion (tree expr)
14725 if (TREE_CODE (expr) == ERROR_MARK)
14728 #if 0 /* This appears to be wrong for C++. */
14729 /* These really should return error_mark_node after 2.4 is stable.
14730 But not all callers handle ERROR_MARK properly. */
14731 switch (TREE_CODE (TREE_TYPE (expr)))
14734 error ("struct type value used where scalar is required");
14735 return integer_zero_node;
14738 error ("union type value used where scalar is required");
14739 return integer_zero_node;
14742 error ("array type value used where scalar is required");
14743 return integer_zero_node;
14750 switch (TREE_CODE (expr))
14752 /* It is simpler and generates better code to have only TRUTH_*_EXPR
14753 or comparison expressions as truth values at this level. */
14755 case COMPONENT_REF:
14756 /* A one-bit unsigned bit-field is already acceptable. */
14757 if (1 == TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (expr, 1)))
14758 && TREE_UNSIGNED (TREE_OPERAND (expr, 1)))
14764 /* It is simpler and generates better code to have only TRUTH_*_EXPR
14765 or comparison expressions as truth values at this level. */
14767 if (integer_zerop (TREE_OPERAND (expr, 1)))
14768 return build_unary_op (TRUTH_NOT_EXPR, TREE_OPERAND (expr, 0), 0);
14770 case NE_EXPR: case LE_EXPR: case GE_EXPR: case LT_EXPR: case GT_EXPR:
14771 case TRUTH_ANDIF_EXPR:
14772 case TRUTH_ORIF_EXPR:
14773 case TRUTH_AND_EXPR:
14774 case TRUTH_OR_EXPR:
14775 case TRUTH_XOR_EXPR:
14776 TREE_TYPE (expr) = integer_type_node;
14783 return integer_zerop (expr) ? integer_zero_node : integer_one_node;
14786 return real_zerop (expr) ? integer_zero_node : integer_one_node;
14789 if (TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 0)))
14790 return build (COMPOUND_EXPR, integer_type_node,
14791 TREE_OPERAND (expr, 0), integer_one_node);
14793 return integer_one_node;
14796 return ffecom_2 ((TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 1))
14797 ? TRUTH_OR_EXPR : TRUTH_ORIF_EXPR),
14799 ffe_truthvalue_conversion (TREE_OPERAND (expr, 0)),
14800 ffe_truthvalue_conversion (TREE_OPERAND (expr, 1)));
14805 /* These don't change whether an object is nonzero or zero. */
14806 return ffe_truthvalue_conversion (TREE_OPERAND (expr, 0));
14810 /* These don't change whether an object is zero or nonzero, but
14811 we can't ignore them if their second arg has side-effects. */
14812 if (TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 1)))
14813 return build (COMPOUND_EXPR, integer_type_node, TREE_OPERAND (expr, 1),
14814 ffe_truthvalue_conversion (TREE_OPERAND (expr, 0)));
14816 return ffe_truthvalue_conversion (TREE_OPERAND (expr, 0));
14820 /* Distribute the conversion into the arms of a COND_EXPR. */
14821 tree arg1 = TREE_OPERAND (expr, 1);
14822 tree arg2 = TREE_OPERAND (expr, 2);
14823 if (! VOID_TYPE_P (TREE_TYPE (arg1)))
14824 arg1 = ffe_truthvalue_conversion (arg1);
14825 if (! VOID_TYPE_P (TREE_TYPE (arg2)))
14826 arg2 = ffe_truthvalue_conversion (arg2);
14827 return fold (build (COND_EXPR, integer_type_node,
14828 TREE_OPERAND (expr, 0), arg1, arg2));
14832 /* Don't cancel the effect of a CONVERT_EXPR from a REFERENCE_TYPE,
14833 since that affects how `default_conversion' will behave. */
14834 if (TREE_CODE (TREE_TYPE (expr)) == REFERENCE_TYPE
14835 || TREE_CODE (TREE_TYPE (TREE_OPERAND (expr, 0))) == REFERENCE_TYPE)
14837 /* fall through... */
14839 /* If this is widening the argument, we can ignore it. */
14840 if (TYPE_PRECISION (TREE_TYPE (expr))
14841 >= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (expr, 0))))
14842 return ffe_truthvalue_conversion (TREE_OPERAND (expr, 0));
14846 /* With IEEE arithmetic, x - x may not equal 0, so we can't optimize
14848 if (TARGET_FLOAT_FORMAT == IEEE_FLOAT_FORMAT
14849 && TREE_CODE (TREE_TYPE (expr)) == REAL_TYPE)
14851 /* fall through... */
14853 /* This and MINUS_EXPR can be changed into a comparison of the
14855 if (TREE_TYPE (TREE_OPERAND (expr, 0))
14856 == TREE_TYPE (TREE_OPERAND (expr, 1)))
14857 return ffecom_2 (NE_EXPR, integer_type_node,
14858 TREE_OPERAND (expr, 0),
14859 TREE_OPERAND (expr, 1));
14860 return ffecom_2 (NE_EXPR, integer_type_node,
14861 TREE_OPERAND (expr, 0),
14862 fold (build1 (NOP_EXPR,
14863 TREE_TYPE (TREE_OPERAND (expr, 0)),
14864 TREE_OPERAND (expr, 1))));
14867 if (integer_onep (TREE_OPERAND (expr, 1)))
14872 #if 0 /* No such thing in Fortran. */
14873 if (warn_parentheses && C_EXP_ORIGINAL_CODE (expr) == MODIFY_EXPR)
14874 warning ("suggest parentheses around assignment used as truth value");
14882 if (TREE_CODE (TREE_TYPE (expr)) == COMPLEX_TYPE)
14884 ((TREE_SIDE_EFFECTS (expr)
14885 ? TRUTH_OR_EXPR : TRUTH_ORIF_EXPR),
14887 ffe_truthvalue_conversion (ffecom_1 (REALPART_EXPR,
14888 TREE_TYPE (TREE_TYPE (expr)),
14890 ffe_truthvalue_conversion (ffecom_1 (IMAGPART_EXPR,
14891 TREE_TYPE (TREE_TYPE (expr)),
14894 return ffecom_2 (NE_EXPR, integer_type_node,
14896 convert (TREE_TYPE (expr), integer_zero_node));
14900 ffe_type_for_mode (enum machine_mode mode, int unsignedp)
14906 if (mode == TYPE_MODE (integer_type_node))
14907 return unsignedp ? unsigned_type_node : integer_type_node;
14909 if (mode == TYPE_MODE (signed_char_type_node))
14910 return unsignedp ? unsigned_char_type_node : signed_char_type_node;
14912 if (mode == TYPE_MODE (short_integer_type_node))
14913 return unsignedp ? short_unsigned_type_node : short_integer_type_node;
14915 if (mode == TYPE_MODE (long_integer_type_node))
14916 return unsignedp ? long_unsigned_type_node : long_integer_type_node;
14918 if (mode == TYPE_MODE (long_long_integer_type_node))
14919 return unsignedp ? long_long_unsigned_type_node : long_long_integer_type_node;
14921 #if HOST_BITS_PER_WIDE_INT >= 64
14922 if (mode == TYPE_MODE (intTI_type_node))
14923 return unsignedp ? unsigned_intTI_type_node : intTI_type_node;
14926 if (mode == TYPE_MODE (float_type_node))
14927 return float_type_node;
14929 if (mode == TYPE_MODE (double_type_node))
14930 return double_type_node;
14932 if (mode == TYPE_MODE (long_double_type_node))
14933 return long_double_type_node;
14935 if (mode == TYPE_MODE (build_pointer_type (char_type_node)))
14936 return build_pointer_type (char_type_node);
14938 if (mode == TYPE_MODE (build_pointer_type (integer_type_node)))
14939 return build_pointer_type (integer_type_node);
14941 for (i = 0; ((size_t) i) < ARRAY_SIZE (ffecom_tree_type); ++i)
14942 for (j = 0; ((size_t) j) < ARRAY_SIZE (ffecom_tree_type[0]); ++j)
14944 if (((t = ffecom_tree_type[i][j]) != NULL_TREE)
14945 && (mode == TYPE_MODE (t)))
14947 if ((i == FFEINFO_basictypeINTEGER) && unsignedp)
14948 return ffecom_tree_type[FFEINFO_basictypeHOLLERITH][j];
14958 ffe_type_for_size (unsigned bits, int unsignedp)
14960 ffeinfoKindtype kt;
14963 if (bits == TYPE_PRECISION (integer_type_node))
14964 return unsignedp ? unsigned_type_node : integer_type_node;
14966 if (bits == TYPE_PRECISION (signed_char_type_node))
14967 return unsignedp ? unsigned_char_type_node : signed_char_type_node;
14969 if (bits == TYPE_PRECISION (short_integer_type_node))
14970 return unsignedp ? short_unsigned_type_node : short_integer_type_node;
14972 if (bits == TYPE_PRECISION (long_integer_type_node))
14973 return unsignedp ? long_unsigned_type_node : long_integer_type_node;
14975 if (bits == TYPE_PRECISION (long_long_integer_type_node))
14976 return (unsignedp ? long_long_unsigned_type_node
14977 : long_long_integer_type_node);
14979 for (kt = 0; kt < ARRAY_SIZE (ffecom_tree_type[0]); ++kt)
14981 type_node = ffecom_tree_type[FFEINFO_basictypeINTEGER][kt];
14983 if ((type_node != NULL_TREE) && (bits == TYPE_PRECISION (type_node)))
14984 return unsignedp ? ffecom_tree_type[FFEINFO_basictypeHOLLERITH][kt]
14992 ffe_unsigned_type (tree type)
14994 tree type1 = TYPE_MAIN_VARIANT (type);
14995 ffeinfoKindtype kt;
14998 if (type1 == signed_char_type_node || type1 == char_type_node)
14999 return unsigned_char_type_node;
15000 if (type1 == integer_type_node)
15001 return unsigned_type_node;
15002 if (type1 == short_integer_type_node)
15003 return short_unsigned_type_node;
15004 if (type1 == long_integer_type_node)
15005 return long_unsigned_type_node;
15006 if (type1 == long_long_integer_type_node)
15007 return long_long_unsigned_type_node;
15008 #if 0 /* gcc/c-* files only */
15009 if (type1 == intDI_type_node)
15010 return unsigned_intDI_type_node;
15011 if (type1 == intSI_type_node)
15012 return unsigned_intSI_type_node;
15013 if (type1 == intHI_type_node)
15014 return unsigned_intHI_type_node;
15015 if (type1 == intQI_type_node)
15016 return unsigned_intQI_type_node;
15019 type2 = ffe_type_for_size (TYPE_PRECISION (type1), 1);
15020 if (type2 != NULL_TREE)
15023 for (kt = 0; kt < ARRAY_SIZE (ffecom_tree_type[0]); ++kt)
15025 type2 = ffecom_tree_type[FFEINFO_basictypeINTEGER][kt];
15027 if (type1 == type2)
15028 return ffecom_tree_type[FFEINFO_basictypeHOLLERITH][kt];
15034 /* From gcc/cccp.c, the code to handle -I. */
15036 /* Skip leading "./" from a directory name.
15037 This may yield the empty string, which represents the current directory. */
15039 static const char *
15040 skip_redundant_dir_prefix (const char *dir)
15042 while (dir[0] == '.' && dir[1] == '/')
15043 for (dir += 2; *dir == '/'; dir++)
15045 if (dir[0] == '.' && !dir[1])
15050 /* The file_name_map structure holds a mapping of file names for a
15051 particular directory. This mapping is read from the file named
15052 FILE_NAME_MAP_FILE in that directory. Such a file can be used to
15053 map filenames on a file system with severe filename restrictions,
15054 such as DOS. The format of the file name map file is just a series
15055 of lines with two tokens on each line. The first token is the name
15056 to map, and the second token is the actual name to use. */
15058 struct file_name_map
15060 struct file_name_map *map_next;
15065 #define FILE_NAME_MAP_FILE "header.gcc"
15067 /* Current maximum length of directory names in the search path
15068 for include files. (Altered as we get more of them.) */
15070 static int max_include_len = 0;
15072 struct file_name_list
15074 struct file_name_list *next;
15076 /* Mapping of file names for this directory. */
15077 struct file_name_map *name_map;
15078 /* Nonzero if name_map is valid. */
15082 static struct file_name_list *include = NULL; /* First dir to search */
15083 static struct file_name_list *last_include = NULL; /* Last in chain */
15085 /* I/O buffer structure.
15086 The `fname' field is nonzero for source files and #include files
15087 and for the dummy text used for -D and -U.
15088 It is zero for rescanning results of macro expansion
15089 and for expanding macro arguments. */
15090 #define INPUT_STACK_MAX 400
15091 static struct file_buf {
15093 /* Filename specified with #line command. */
15094 const char *nominal_fname;
15095 /* Record where in the search path this file was found.
15096 For #include_next. */
15097 struct file_name_list *dir;
15099 ffewhereColumn column;
15100 } instack[INPUT_STACK_MAX];
15102 static int last_error_tick = 0; /* Incremented each time we print it. */
15104 /* Current nesting level of input sources.
15105 `instack[indepth]' is the level currently being read. */
15106 static int indepth = -1;
15108 typedef struct file_buf FILE_BUF;
15110 /* Nonzero means -I- has been seen,
15111 so don't look for #include "foo" the source-file directory. */
15112 static int ignore_srcdir;
15114 #ifndef INCLUDE_LEN_FUDGE
15115 #define INCLUDE_LEN_FUDGE 0
15118 static void append_include_chain (struct file_name_list *first,
15119 struct file_name_list *last);
15120 static FILE *open_include_file (char *filename,
15121 struct file_name_list *searchptr);
15122 static void print_containing_files (ffebadSeverity sev);
15123 static char *read_filename_string (int ch, FILE *f);
15124 static struct file_name_map *read_name_map (const char *dirname);
15126 /* Append a chain of `struct file_name_list's
15127 to the end of the main include chain.
15128 FIRST is the beginning of the chain to append, and LAST is the end. */
15131 append_include_chain (struct file_name_list *first,
15132 struct file_name_list *last)
15134 struct file_name_list *dir;
15136 if (!first || !last)
15142 last_include->next = first;
15144 for (dir = first; ; dir = dir->next) {
15145 int len = strlen (dir->fname) + INCLUDE_LEN_FUDGE;
15146 if (len > max_include_len)
15147 max_include_len = len;
15153 last_include = last;
15156 /* Try to open include file FILENAME. SEARCHPTR is the directory
15157 being tried from the include file search path. This function maps
15158 filenames on file systems based on information read by
15162 open_include_file (char *filename, struct file_name_list *searchptr)
15164 register struct file_name_map *map;
15165 register char *from;
15168 if (searchptr && ! searchptr->got_name_map)
15170 searchptr->name_map = read_name_map (searchptr->fname
15171 ? searchptr->fname : ".");
15172 searchptr->got_name_map = 1;
15175 /* First check the mapping for the directory we are using. */
15176 if (searchptr && searchptr->name_map)
15179 if (searchptr->fname)
15180 from += strlen (searchptr->fname) + 1;
15181 for (map = searchptr->name_map; map; map = map->map_next)
15183 if (! strcmp (map->map_from, from))
15185 /* Found a match. */
15186 return fopen (map->map_to, "r");
15191 /* Try to find a mapping file for the particular directory we are
15192 looking in. Thus #include <sys/types.h> will look up sys/types.h
15193 in /usr/include/header.gcc and look up types.h in
15194 /usr/include/sys/header.gcc. */
15195 p = strrchr (filename, '/');
15196 #ifdef DIR_SEPARATOR
15197 if (! p) p = strrchr (filename, DIR_SEPARATOR);
15199 char *tmp = strrchr (filename, DIR_SEPARATOR);
15200 if (tmp != NULL && tmp > p) p = tmp;
15206 && searchptr->fname
15207 && strlen (searchptr->fname) == (size_t) (p - filename)
15208 && ! strncmp (searchptr->fname, filename, (int) (p - filename)))
15210 /* FILENAME is in SEARCHPTR, which we've already checked. */
15211 return fopen (filename, "r");
15217 map = read_name_map (".");
15221 dir = xmalloc (p - filename + 1);
15222 memcpy (dir, filename, p - filename);
15223 dir[p - filename] = '\0';
15225 map = read_name_map (dir);
15228 for (; map; map = map->map_next)
15229 if (! strcmp (map->map_from, from))
15230 return fopen (map->map_to, "r");
15232 return fopen (filename, "r");
15235 /* Print the file names and line numbers of the #include
15236 commands which led to the current file. */
15239 print_containing_files (ffebadSeverity sev)
15241 FILE_BUF *ip = NULL;
15247 /* If stack of files hasn't changed since we last printed
15248 this info, don't repeat it. */
15249 if (last_error_tick == input_file_stack_tick)
15252 for (i = indepth; i >= 0; i--)
15253 if (instack[i].fname != NULL) {
15258 /* Give up if we don't find a source file. */
15262 /* Find the other, outer source files. */
15263 for (i--; i >= 0; i--)
15264 if (instack[i].fname != NULL)
15270 str1 = "In file included";
15282 /* xgettext:no-c-format */
15283 ffebad_start_msg ("%A from %B at %0%C", sev);
15284 ffebad_here (0, ip->line, ip->column);
15285 ffebad_string (str1);
15286 ffebad_string (ip->nominal_fname);
15287 ffebad_string (str2);
15291 /* Record we have printed the status as of this time. */
15292 last_error_tick = input_file_stack_tick;
15295 /* Read a space delimited string of unlimited length from a stdio
15299 read_filename_string (int ch, FILE *f)
15305 set = alloc = xmalloc (len + 1);
15306 if (! ISSPACE (ch))
15309 while ((ch = getc (f)) != EOF && ! ISSPACE (ch))
15311 if (set - alloc == len)
15314 alloc = xrealloc (alloc, len + 1);
15315 set = alloc + len / 2;
15325 /* Read the file name map file for DIRNAME. */
15327 static struct file_name_map *
15328 read_name_map (const char *dirname)
15330 /* This structure holds a linked list of file name maps, one per
15332 struct file_name_map_list
15334 struct file_name_map_list *map_list_next;
15335 char *map_list_name;
15336 struct file_name_map *map_list_map;
15338 static struct file_name_map_list *map_list;
15339 register struct file_name_map_list *map_list_ptr;
15343 int separator_needed;
15345 dirname = skip_redundant_dir_prefix (dirname);
15347 for (map_list_ptr = map_list; map_list_ptr;
15348 map_list_ptr = map_list_ptr->map_list_next)
15349 if (! strcmp (map_list_ptr->map_list_name, dirname))
15350 return map_list_ptr->map_list_map;
15352 map_list_ptr = xmalloc (sizeof (struct file_name_map_list));
15353 map_list_ptr->map_list_name = xstrdup (dirname);
15354 map_list_ptr->map_list_map = NULL;
15356 dirlen = strlen (dirname);
15357 separator_needed = dirlen != 0 && dirname[dirlen - 1] != '/';
15358 if (separator_needed)
15359 name = concat (dirname, "/", FILE_NAME_MAP_FILE, NULL);
15361 name = concat (dirname, FILE_NAME_MAP_FILE, NULL);
15362 f = fopen (name, "r");
15365 map_list_ptr->map_list_map = NULL;
15370 while ((ch = getc (f)) != EOF)
15373 struct file_name_map *ptr;
15377 from = read_filename_string (ch, f);
15378 while ((ch = getc (f)) != EOF && ISSPACE (ch) && ch != '\n')
15380 to = read_filename_string (ch, f);
15382 ptr = xmalloc (sizeof (struct file_name_map));
15383 ptr->map_from = from;
15385 /* Make the real filename absolute. */
15390 if (separator_needed)
15391 ptr->map_to = concat (dirname, "/", to, NULL);
15393 ptr->map_to = concat (dirname, to, NULL);
15397 ptr->map_next = map_list_ptr->map_list_map;
15398 map_list_ptr->map_list_map = ptr;
15400 while ((ch = getc (f)) != '\n')
15407 map_list_ptr->map_list_next = map_list;
15408 map_list = map_list_ptr;
15410 return map_list_ptr->map_list_map;
15414 ffecom_file_ (const char *name)
15418 /* Do partial setup of input buffer for the sake of generating
15419 early #line directives (when -g is in effect). */
15421 fp = &instack[++indepth];
15422 memset (fp, 0, sizeof (FILE_BUF));
15425 fp->nominal_fname = fp->fname = name;
15429 ffecom_close_include_ (FILE *f)
15434 input_file_stack_tick++;
15436 ffewhere_line_kill (instack[indepth].line);
15437 ffewhere_column_kill (instack[indepth].column);
15441 ffecom_decode_include_option (const char *dir)
15443 if (! ignore_srcdir && !strcmp (dir, "-"))
15447 struct file_name_list *dirtmp
15448 = xmalloc (sizeof (struct file_name_list));
15449 dirtmp->next = 0; /* New one goes on the end */
15450 dirtmp->fname = dir;
15451 dirtmp->got_name_map = 0;
15452 append_include_chain (dirtmp, dirtmp);
15456 /* Open INCLUDEd file. */
15459 ffecom_open_include_ (char *name, ffewhereLine l, ffewhereColumn c)
15462 size_t flen = strlen (fbeg);
15463 struct file_name_list *search_start = include; /* Chain of dirs to search */
15464 struct file_name_list dsp[1]; /* First in chain, if #include "..." */
15465 struct file_name_list *searchptr = 0;
15466 char *fname; /* Dynamically allocated fname buffer */
15473 dsp[0].fname = NULL;
15475 /* If -I- was specified, don't search current dir, only spec'd ones. */
15476 if (!ignore_srcdir)
15478 for (fp = &instack[indepth]; fp >= instack; fp--)
15484 if ((nam = fp->nominal_fname) != NULL)
15486 /* Found a named file. Figure out dir of the file,
15487 and put it in front of the search list. */
15488 dsp[0].next = search_start;
15489 search_start = dsp;
15491 ep = strrchr (nam, '/');
15492 #ifdef DIR_SEPARATOR
15493 if (ep == NULL) ep = strrchr (nam, DIR_SEPARATOR);
15495 char *tmp = strrchr (nam, DIR_SEPARATOR);
15496 if (tmp != NULL && tmp > ep) ep = tmp;
15500 ep = strrchr (nam, ']');
15501 if (ep == NULL) ep = strrchr (nam, '>');
15502 if (ep == NULL) ep = strrchr (nam, ':');
15503 if (ep != NULL) ep++;
15508 fname = xmalloc (n + 1);
15509 strncpy (fname, nam, n);
15511 dsp[0].fname = fname;
15512 if (n + INCLUDE_LEN_FUDGE > max_include_len)
15513 max_include_len = n + INCLUDE_LEN_FUDGE;
15516 dsp[0].fname = NULL; /* Current directory */
15517 dsp[0].got_name_map = 0;
15523 /* Allocate this permanently, because it gets stored in the definitions
15525 fname = xmalloc (max_include_len + flen + 4);
15526 /* + 2 above for slash and terminating null. */
15527 /* + 2 added for '.h' on VMS (to support '#include filename') (NOT USED
15530 /* If specified file name is absolute, just open it. */
15533 #ifdef DIR_SEPARATOR
15534 || *fbeg == DIR_SEPARATOR
15538 strncpy (fname, (char *) fbeg, flen);
15540 f = open_include_file (fname, NULL);
15546 /* Search directory path, trying to open the file.
15547 Copy each filename tried into FNAME. */
15549 for (searchptr = search_start; searchptr; searchptr = searchptr->next)
15551 if (searchptr->fname)
15553 /* The empty string in a search path is ignored.
15554 This makes it possible to turn off entirely
15555 a standard piece of the list. */
15556 if (searchptr->fname[0] == 0)
15558 strcpy (fname, skip_redundant_dir_prefix (searchptr->fname));
15559 if (fname[0] && fname[strlen (fname) - 1] != '/')
15560 strcat (fname, "/");
15561 fname[strlen (fname) + flen] = 0;
15566 strncat (fname, fbeg, flen);
15568 /* Change this 1/2 Unix 1/2 VMS file specification into a
15569 full VMS file specification */
15570 if (searchptr->fname && (searchptr->fname[0] != 0))
15572 /* Fix up the filename */
15573 hack_vms_include_specification (fname);
15577 /* This is a normal VMS filespec, so use it unchanged. */
15578 strncpy (fname, (char *) fbeg, flen);
15580 #if 0 /* Not for g77. */
15581 /* if it's '#include filename', add the missing .h */
15582 if (strchr (fname, '.') == NULL)
15583 strcat (fname, ".h");
15587 f = open_include_file (fname, searchptr);
15589 if (f == NULL && errno == EACCES)
15591 print_containing_files (FFEBAD_severityWARNING);
15592 /* xgettext:no-c-format */
15593 ffebad_start_msg ("At %0, INCLUDE file %A exists, but is not readable",
15594 FFEBAD_severityWARNING);
15595 ffebad_string (fname);
15596 ffebad_here (0, l, c);
15607 /* A file that was not found. */
15609 strncpy (fname, (char *) fbeg, flen);
15611 print_containing_files (ffebad_severity (FFEBAD_OPEN_INCLUDE));
15612 ffebad_start (FFEBAD_OPEN_INCLUDE);
15613 ffebad_here (0, l, c);
15614 ffebad_string (fname);
15618 if (dsp[0].fname != NULL)
15619 free ((char *) dsp[0].fname);
15624 if (indepth >= (INPUT_STACK_MAX - 1))
15626 print_containing_files (FFEBAD_severityFATAL);
15627 /* xgettext:no-c-format */
15628 ffebad_start_msg ("At %0, INCLUDE nesting too deep",
15629 FFEBAD_severityFATAL);
15630 ffebad_string (fname);
15631 ffebad_here (0, l, c);
15636 instack[indepth].line = ffewhere_line_use (l);
15637 instack[indepth].column = ffewhere_column_use (c);
15639 fp = &instack[indepth + 1];
15640 memset (fp, 0, sizeof (FILE_BUF));
15641 fp->nominal_fname = fp->fname = fname;
15642 fp->dir = searchptr;
15645 input_file_stack_tick++;
15650 /**INDENT* (Do not reformat this comment even with -fca option.)
15651 Data-gathering files: Given the source file listed below, compiled with
15652 f2c I obtained the output file listed after that, and from the output
15653 file I derived the above code.
15655 -------- (begin input file to f2c)
15661 double precision D1,D2
15663 call getem(A1,A2,C1,C2,I1,I2,R1,R2,D1,D2)
15690 c FFEINTRIN_impACOS
15691 call fooR(ACOS(R1))
15692 c FFEINTRIN_impAIMAG
15693 call fooR(AIMAG(C1))
15694 c FFEINTRIN_impAINT
15695 call fooR(AINT(R1))
15696 c FFEINTRIN_impALOG
15697 call fooR(ALOG(R1))
15698 c FFEINTRIN_impALOG10
15699 call fooR(ALOG10(R1))
15700 c FFEINTRIN_impAMAX0
15701 call fooR(AMAX0(I1,I2))
15702 c FFEINTRIN_impAMAX1
15703 call fooR(AMAX1(R1,R2))
15704 c FFEINTRIN_impAMIN0
15705 call fooR(AMIN0(I1,I2))
15706 c FFEINTRIN_impAMIN1
15707 call fooR(AMIN1(R1,R2))
15708 c FFEINTRIN_impAMOD
15709 call fooR(AMOD(R1,R2))
15710 c FFEINTRIN_impANINT
15711 call fooR(ANINT(R1))
15712 c FFEINTRIN_impASIN
15713 call fooR(ASIN(R1))
15714 c FFEINTRIN_impATAN
15715 call fooR(ATAN(R1))
15716 c FFEINTRIN_impATAN2
15717 call fooR(ATAN2(R1,R2))
15718 c FFEINTRIN_impCABS
15719 call fooR(CABS(C1))
15720 c FFEINTRIN_impCCOS
15721 call fooC(CCOS(C1))
15722 c FFEINTRIN_impCEXP
15723 call fooC(CEXP(C1))
15724 c FFEINTRIN_impCHAR
15725 call fooA(CHAR(I1))
15726 c FFEINTRIN_impCLOG
15727 call fooC(CLOG(C1))
15728 c FFEINTRIN_impCONJG
15729 call fooC(CONJG(C1))
15732 c FFEINTRIN_impCOSH
15733 call fooR(COSH(R1))
15734 c FFEINTRIN_impCSIN
15735 call fooC(CSIN(C1))
15736 c FFEINTRIN_impCSQRT
15737 call fooC(CSQRT(C1))
15738 c FFEINTRIN_impDABS
15739 call fooD(DABS(D1))
15740 c FFEINTRIN_impDACOS
15741 call fooD(DACOS(D1))
15742 c FFEINTRIN_impDASIN
15743 call fooD(DASIN(D1))
15744 c FFEINTRIN_impDATAN
15745 call fooD(DATAN(D1))
15746 c FFEINTRIN_impDATAN2
15747 call fooD(DATAN2(D1,D2))
15748 c FFEINTRIN_impDCOS
15749 call fooD(DCOS(D1))
15750 c FFEINTRIN_impDCOSH
15751 call fooD(DCOSH(D1))
15752 c FFEINTRIN_impDDIM
15753 call fooD(DDIM(D1,D2))
15754 c FFEINTRIN_impDEXP
15755 call fooD(DEXP(D1))
15757 call fooR(DIM(R1,R2))
15758 c FFEINTRIN_impDINT
15759 call fooD(DINT(D1))
15760 c FFEINTRIN_impDLOG
15761 call fooD(DLOG(D1))
15762 c FFEINTRIN_impDLOG10
15763 call fooD(DLOG10(D1))
15764 c FFEINTRIN_impDMAX1
15765 call fooD(DMAX1(D1,D2))
15766 c FFEINTRIN_impDMIN1
15767 call fooD(DMIN1(D1,D2))
15768 c FFEINTRIN_impDMOD
15769 call fooD(DMOD(D1,D2))
15770 c FFEINTRIN_impDNINT
15771 call fooD(DNINT(D1))
15772 c FFEINTRIN_impDPROD
15773 call fooD(DPROD(R1,R2))
15774 c FFEINTRIN_impDSIGN
15775 call fooD(DSIGN(D1,D2))
15776 c FFEINTRIN_impDSIN
15777 call fooD(DSIN(D1))
15778 c FFEINTRIN_impDSINH
15779 call fooD(DSINH(D1))
15780 c FFEINTRIN_impDSQRT
15781 call fooD(DSQRT(D1))
15782 c FFEINTRIN_impDTAN
15783 call fooD(DTAN(D1))
15784 c FFEINTRIN_impDTANH
15785 call fooD(DTANH(D1))
15788 c FFEINTRIN_impIABS
15789 call fooI(IABS(I1))
15790 c FFEINTRIN_impICHAR
15791 call fooI(ICHAR(A1))
15792 c FFEINTRIN_impIDIM
15793 call fooI(IDIM(I1,I2))
15794 c FFEINTRIN_impIDNINT
15795 call fooI(IDNINT(D1))
15796 c FFEINTRIN_impINDEX
15797 call fooI(INDEX(A1,A2))
15798 c FFEINTRIN_impISIGN
15799 call fooI(ISIGN(I1,I2))
15803 call fooL(LGE(A1,A2))
15805 call fooL(LGT(A1,A2))
15807 call fooL(LLE(A1,A2))
15809 call fooL(LLT(A1,A2))
15810 c FFEINTRIN_impMAX0
15811 call fooI(MAX0(I1,I2))
15812 c FFEINTRIN_impMAX1
15813 call fooI(MAX1(R1,R2))
15814 c FFEINTRIN_impMIN0
15815 call fooI(MIN0(I1,I2))
15816 c FFEINTRIN_impMIN1
15817 call fooI(MIN1(R1,R2))
15819 call fooI(MOD(I1,I2))
15820 c FFEINTRIN_impNINT
15821 call fooI(NINT(R1))
15822 c FFEINTRIN_impSIGN
15823 call fooR(SIGN(R1,R2))
15826 c FFEINTRIN_impSINH
15827 call fooR(SINH(R1))
15828 c FFEINTRIN_impSQRT
15829 call fooR(SQRT(R1))
15832 c FFEINTRIN_impTANH
15833 call fooR(TANH(R1))
15834 c FFEINTRIN_imp_CMPLX_C
15835 call fooC(cmplx(C1,C2))
15836 c FFEINTRIN_imp_CMPLX_D
15837 call fooZ(cmplx(D1,D2))
15838 c FFEINTRIN_imp_CMPLX_I
15839 call fooC(cmplx(I1,I2))
15840 c FFEINTRIN_imp_CMPLX_R
15841 call fooC(cmplx(R1,R2))
15842 c FFEINTRIN_imp_DBLE_C
15843 call fooD(dble(C1))
15844 c FFEINTRIN_imp_DBLE_D
15845 call fooD(dble(D1))
15846 c FFEINTRIN_imp_DBLE_I
15847 call fooD(dble(I1))
15848 c FFEINTRIN_imp_DBLE_R
15849 call fooD(dble(R1))
15850 c FFEINTRIN_imp_INT_C
15852 c FFEINTRIN_imp_INT_D
15854 c FFEINTRIN_imp_INT_I
15856 c FFEINTRIN_imp_INT_R
15858 c FFEINTRIN_imp_REAL_C
15859 call fooR(real(C1))
15860 c FFEINTRIN_imp_REAL_D
15861 call fooR(real(D1))
15862 c FFEINTRIN_imp_REAL_I
15863 call fooR(real(I1))
15864 c FFEINTRIN_imp_REAL_R
15865 call fooR(real(R1))
15867 c FFEINTRIN_imp_INT_D:
15869 c FFEINTRIN_specIDINT
15870 call fooI(IDINT(D1))
15872 c FFEINTRIN_imp_INT_R:
15874 c FFEINTRIN_specIFIX
15875 call fooI(IFIX(R1))
15876 c FFEINTRIN_specINT
15879 c FFEINTRIN_imp_REAL_D:
15881 c FFEINTRIN_specSNGL
15882 call fooR(SNGL(D1))
15884 c FFEINTRIN_imp_REAL_I:
15886 c FFEINTRIN_specFLOAT
15887 call fooR(FLOAT(I1))
15888 c FFEINTRIN_specREAL
15889 call fooR(REAL(I1))
15892 -------- (end input file to f2c)
15894 -------- (begin output from providing above input file as input to:
15895 -------- `f2c | gcc -E -C - | sed -e "s:/[*]*://:g" -e "s:[*]*[/]://:g" \
15896 -------- -e "s:^#.*$::g"')
15898 // -- translated by f2c (version 19950223).
15899 You must link the resulting object file with the libraries:
15900 -lf2c -lm (in that order)
15904 // f2c.h -- Standard Fortran to C header file //
15906 /// barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed."
15908 - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) //
15913 // F2C_INTEGER will normally be `int' but would be `long' on 16-bit systems //
15914 // we assume short, float are OK //
15915 typedef long int // long int // integer;
15916 typedef char *address;
15917 typedef short int shortint;
15918 typedef float real;
15919 typedef double doublereal;
15920 typedef struct { real r, i; } complex;
15921 typedef struct { doublereal r, i; } doublecomplex;
15922 typedef long int // long int // logical;
15923 typedef short int shortlogical;
15924 typedef char logical1;
15925 typedef char integer1;
15926 // typedef long long longint; // // system-dependent //
15931 // Extern is for use with -E //
15945 typedef long int // int or long int // flag;
15946 typedef long int // int or long int // ftnlen;
15947 typedef long int // int or long int // ftnint;
15950 //external read, write//
15959 //internal read, write//
15989 //rewind, backspace, endfile//
16001 ftnint *inex; //parameters in standard's order//
16027 union Multitype { // for multiple entry points //
16038 typedef union Multitype Multitype;
16040 typedef long Long; // No longer used; formerly in Namelist //
16042 struct Vardesc { // for Namelist //
16048 typedef struct Vardesc Vardesc;
16055 typedef struct Namelist Namelist;
16064 // procedure parameter types for -A and -C++ //
16069 typedef int // Unknown procedure type // (*U_fp)();
16070 typedef shortint (*J_fp)();
16071 typedef integer (*I_fp)();
16072 typedef real (*R_fp)();
16073 typedef doublereal (*D_fp)(), (*E_fp)();
16074 typedef // Complex // void (*C_fp)();
16075 typedef // Double Complex // void (*Z_fp)();
16076 typedef logical (*L_fp)();
16077 typedef shortlogical (*K_fp)();
16078 typedef // Character // void (*H_fp)();
16079 typedef // Subroutine // int (*S_fp)();
16081 // E_fp is for real functions when -R is not specified //
16082 typedef void C_f; // complex function //
16083 typedef void H_f; // character function //
16084 typedef void Z_f; // double complex function //
16085 typedef doublereal E_f; // real function with -R not specified //
16087 // undef any lower-case symbols that your C compiler predefines, e.g.: //
16090 // (No such symbols should be defined in a strict ANSI C compiler.
16091 We can avoid trouble with f2c-translated code by using
16116 // Main program // MAIN__()
16118 // System generated locals //
16121 doublereal d__1, d__2;
16123 doublecomplex z__1, z__2, z__3;
16127 // Builtin functions //
16130 double pow_ri(), pow_di();
16134 double acos(), r_imag(), r_int(), log(), r_lg10(), r_mod(), r_nint(),
16135 asin(), atan(), atan2(), c_abs();
16136 void c_cos(), c_exp(), c_log(), r_cnjg();
16137 double cos(), cosh();
16138 void c_sin(), c_sqrt();
16139 double d_dim(), exp(), r_dim(), d_int(), d_lg10(), d_mod(), d_nint(),
16140 d_sign(), sin(), sinh(), sqrt(), tan(), tanh();
16141 integer i_dim(), i_dnnt(), i_indx(), i_sign(), i_len();
16142 logical l_ge(), l_gt(), l_le(), l_lt();
16146 // Local variables //
16147 extern // Subroutine // int fooa_(), fooc_(), food_(), fooi_(), foor_(),
16148 fool_(), fooz_(), getem_();
16149 static char a1[10], a2[10];
16150 static complex c1, c2;
16151 static doublereal d1, d2;
16152 static integer i1, i2;
16153 static real r1, r2;
16156 getem_(a1, a2, &c1, &c2, &i1, &i2, &r1, &r2, &d1, &d2, 10L, 10L);
16164 d__1 = (doublereal) i1;
16165 q__1.r = c1.r / d__1, q__1.i = c1.i / d__1;
16175 c_div(&q__1, &c1, &c2);
16177 q__1.r = c1.r / r1, q__1.i = c1.i / r1;
16179 z__1.r = c1.r / d1, z__1.i = c1.i / d1;
16182 i__1 = pow_ii(&i1, &i2);
16184 r__1 = pow_ri(&r1, &i1);
16186 d__1 = pow_di(&d1, &i1);
16188 pow_ci(&q__1, &c1, &i1);
16190 d__1 = (doublereal) r1;
16191 d__2 = (doublereal) r2;
16192 r__1 = pow_dd(&d__1, &d__2);
16194 d__2 = (doublereal) r1;
16195 d__1 = pow_dd(&d__2, &d1);
16197 d__1 = pow_dd(&d1, &d2);
16199 d__2 = (doublereal) r1;
16200 d__1 = pow_dd(&d1, &d__2);
16202 z__2.r = c1.r, z__2.i = c1.i;
16203 z__3.r = c2.r, z__3.i = c2.i;
16204 pow_zz(&z__1, &z__2, &z__3);
16205 q__1.r = z__1.r, q__1.i = z__1.i;
16207 z__2.r = c1.r, z__2.i = c1.i;
16208 z__3.r = r1, z__3.i = 0.;
16209 pow_zz(&z__1, &z__2, &z__3);
16210 q__1.r = z__1.r, q__1.i = z__1.i;
16212 z__2.r = c1.r, z__2.i = c1.i;
16213 z__3.r = d1, z__3.i = 0.;
16214 pow_zz(&z__1, &z__2, &z__3);
16216 // FFEINTRIN_impABS //
16217 r__1 = (doublereal)(( r1 ) >= 0 ? ( r1 ) : -( r1 )) ;
16219 // FFEINTRIN_impACOS //
16222 // FFEINTRIN_impAIMAG //
16223 r__1 = r_imag(&c1);
16225 // FFEINTRIN_impAINT //
16228 // FFEINTRIN_impALOG //
16231 // FFEINTRIN_impALOG10 //
16232 r__1 = r_lg10(&r1);
16234 // FFEINTRIN_impAMAX0 //
16235 r__1 = (real) (( i1 ) >= ( i2 ) ? ( i1 ) : ( i2 )) ;
16237 // FFEINTRIN_impAMAX1 //
16238 r__1 = (doublereal)(( r1 ) >= ( r2 ) ? ( r1 ) : ( r2 )) ;
16240 // FFEINTRIN_impAMIN0 //
16241 r__1 = (real) (( i1 ) <= ( i2 ) ? ( i1 ) : ( i2 )) ;
16243 // FFEINTRIN_impAMIN1 //
16244 r__1 = (doublereal)(( r1 ) <= ( r2 ) ? ( r1 ) : ( r2 )) ;
16246 // FFEINTRIN_impAMOD //
16247 r__1 = r_mod(&r1, &r2);
16249 // FFEINTRIN_impANINT //
16250 r__1 = r_nint(&r1);
16252 // FFEINTRIN_impASIN //
16255 // FFEINTRIN_impATAN //
16258 // FFEINTRIN_impATAN2 //
16259 r__1 = atan2(r1, r2);
16261 // FFEINTRIN_impCABS //
16264 // FFEINTRIN_impCCOS //
16267 // FFEINTRIN_impCEXP //
16270 // FFEINTRIN_impCHAR //
16271 *(unsigned char *)&ch__1[0] = i1;
16273 // FFEINTRIN_impCLOG //
16276 // FFEINTRIN_impCONJG //
16277 r_cnjg(&q__1, &c1);
16279 // FFEINTRIN_impCOS //
16282 // FFEINTRIN_impCOSH //
16285 // FFEINTRIN_impCSIN //
16288 // FFEINTRIN_impCSQRT //
16289 c_sqrt(&q__1, &c1);
16291 // FFEINTRIN_impDABS //
16292 d__1 = (( d1 ) >= 0 ? ( d1 ) : -( d1 )) ;
16294 // FFEINTRIN_impDACOS //
16297 // FFEINTRIN_impDASIN //
16300 // FFEINTRIN_impDATAN //
16303 // FFEINTRIN_impDATAN2 //
16304 d__1 = atan2(d1, d2);
16306 // FFEINTRIN_impDCOS //
16309 // FFEINTRIN_impDCOSH //
16312 // FFEINTRIN_impDDIM //
16313 d__1 = d_dim(&d1, &d2);
16315 // FFEINTRIN_impDEXP //
16318 // FFEINTRIN_impDIM //
16319 r__1 = r_dim(&r1, &r2);
16321 // FFEINTRIN_impDINT //
16324 // FFEINTRIN_impDLOG //
16327 // FFEINTRIN_impDLOG10 //
16328 d__1 = d_lg10(&d1);
16330 // FFEINTRIN_impDMAX1 //
16331 d__1 = (( d1 ) >= ( d2 ) ? ( d1 ) : ( d2 )) ;
16333 // FFEINTRIN_impDMIN1 //
16334 d__1 = (( d1 ) <= ( d2 ) ? ( d1 ) : ( d2 )) ;
16336 // FFEINTRIN_impDMOD //
16337 d__1 = d_mod(&d1, &d2);
16339 // FFEINTRIN_impDNINT //
16340 d__1 = d_nint(&d1);
16342 // FFEINTRIN_impDPROD //
16343 d__1 = (doublereal) r1 * r2;
16345 // FFEINTRIN_impDSIGN //
16346 d__1 = d_sign(&d1, &d2);
16348 // FFEINTRIN_impDSIN //
16351 // FFEINTRIN_impDSINH //
16354 // FFEINTRIN_impDSQRT //
16357 // FFEINTRIN_impDTAN //
16360 // FFEINTRIN_impDTANH //
16363 // FFEINTRIN_impEXP //
16366 // FFEINTRIN_impIABS //
16367 i__1 = (( i1 ) >= 0 ? ( i1 ) : -( i1 )) ;
16369 // FFEINTRIN_impICHAR //
16370 i__1 = *(unsigned char *)a1;
16372 // FFEINTRIN_impIDIM //
16373 i__1 = i_dim(&i1, &i2);
16375 // FFEINTRIN_impIDNINT //
16376 i__1 = i_dnnt(&d1);
16378 // FFEINTRIN_impINDEX //
16379 i__1 = i_indx(a1, a2, 10L, 10L);
16381 // FFEINTRIN_impISIGN //
16382 i__1 = i_sign(&i1, &i2);
16384 // FFEINTRIN_impLEN //
16385 i__1 = i_len(a1, 10L);
16387 // FFEINTRIN_impLGE //
16388 L__1 = l_ge(a1, a2, 10L, 10L);
16390 // FFEINTRIN_impLGT //
16391 L__1 = l_gt(a1, a2, 10L, 10L);
16393 // FFEINTRIN_impLLE //
16394 L__1 = l_le(a1, a2, 10L, 10L);
16396 // FFEINTRIN_impLLT //
16397 L__1 = l_lt(a1, a2, 10L, 10L);
16399 // FFEINTRIN_impMAX0 //
16400 i__1 = (( i1 ) >= ( i2 ) ? ( i1 ) : ( i2 )) ;
16402 // FFEINTRIN_impMAX1 //
16403 i__1 = (integer) (doublereal)(( r1 ) >= ( r2 ) ? ( r1 ) : ( r2 )) ;
16405 // FFEINTRIN_impMIN0 //
16406 i__1 = (( i1 ) <= ( i2 ) ? ( i1 ) : ( i2 )) ;
16408 // FFEINTRIN_impMIN1 //
16409 i__1 = (integer) (doublereal)(( r1 ) <= ( r2 ) ? ( r1 ) : ( r2 )) ;
16411 // FFEINTRIN_impMOD //
16414 // FFEINTRIN_impNINT //
16415 i__1 = i_nint(&r1);
16417 // FFEINTRIN_impSIGN //
16418 r__1 = r_sign(&r1, &r2);
16420 // FFEINTRIN_impSIN //
16423 // FFEINTRIN_impSINH //
16426 // FFEINTRIN_impSQRT //
16429 // FFEINTRIN_impTAN //
16432 // FFEINTRIN_impTANH //
16435 // FFEINTRIN_imp_CMPLX_C //
16438 q__1.r = r__1, q__1.i = r__2;
16440 // FFEINTRIN_imp_CMPLX_D //
16441 z__1.r = d1, z__1.i = d2;
16443 // FFEINTRIN_imp_CMPLX_I //
16446 q__1.r = r__1, q__1.i = r__2;
16448 // FFEINTRIN_imp_CMPLX_R //
16449 q__1.r = r1, q__1.i = r2;
16451 // FFEINTRIN_imp_DBLE_C //
16452 d__1 = (doublereal) c1.r;
16454 // FFEINTRIN_imp_DBLE_D //
16457 // FFEINTRIN_imp_DBLE_I //
16458 d__1 = (doublereal) i1;
16460 // FFEINTRIN_imp_DBLE_R //
16461 d__1 = (doublereal) r1;
16463 // FFEINTRIN_imp_INT_C //
16464 i__1 = (integer) c1.r;
16466 // FFEINTRIN_imp_INT_D //
16467 i__1 = (integer) d1;
16469 // FFEINTRIN_imp_INT_I //
16472 // FFEINTRIN_imp_INT_R //
16473 i__1 = (integer) r1;
16475 // FFEINTRIN_imp_REAL_C //
16478 // FFEINTRIN_imp_REAL_D //
16481 // FFEINTRIN_imp_REAL_I //
16484 // FFEINTRIN_imp_REAL_R //
16488 // FFEINTRIN_imp_INT_D: //
16490 // FFEINTRIN_specIDINT //
16491 i__1 = (integer) d1;
16494 // FFEINTRIN_imp_INT_R: //
16496 // FFEINTRIN_specIFIX //
16497 i__1 = (integer) r1;
16499 // FFEINTRIN_specINT //
16500 i__1 = (integer) r1;
16503 // FFEINTRIN_imp_REAL_D: //
16505 // FFEINTRIN_specSNGL //
16509 // FFEINTRIN_imp_REAL_I: //
16511 // FFEINTRIN_specFLOAT //
16514 // FFEINTRIN_specREAL //
16520 -------- (end output file from f2c)
16524 #include "gt-f-com.h"
16525 #include "gtype-f.h"