1 /* com.c -- Implementation File (module.c template V1.0)
2 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000
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):
58 yes = suspend_momentary ();
59 if (is_nested) push_f_function_context ();
60 start_function (get_identifier ("function_name"), function_type,
61 is_nested, is_public);
62 // for each arg, build PARM_DECL and call push_parm_decl (decl) with it;
63 store_parm_decls (is_main_program);
64 ffecom_start_compstmt ();
65 // for stmts and decls inside function, do appropriate things;
66 ffecom_end_compstmt ();
67 finish_function (is_nested);
68 if (is_nested) pop_f_function_context ();
69 if (is_nested) resume_momentary (yes);
75 yes = suspend_momentary ();
76 // fill in external, public, static, &c for decl, and
77 // set DECL_INITIAL to error_mark_node if going to initialize
78 // set is_top_level TRUE only if not at top level and decl
79 // must go in top level (i.e. not within current function decl context)
80 d = start_decl (decl, is_top_level);
81 init = ...; // if have initializer
82 finish_decl (d, init, is_top_level);
83 resume_momentary (yes);
90 #if FFECOM_targetCURRENT == FFECOM_targetGCC
95 #include "output.j" /* Must follow tree.j so TREE_CODE is defined! */
98 #endif /* FFECOM_targetCURRENT == FFECOM_targetGCC */
100 #define FFECOM_GCC_INCLUDE 1 /* Enable -I. */
102 /* BEGIN stuff from gcc/cccp.c. */
104 /* The following symbols should be autoconfigured:
111 In the mean time, we'll get by with approximations based
112 on existing GCC configuration symbols. */
115 # ifndef HAVE_STDLIB_H
116 # define HAVE_STDLIB_H 1
118 # ifndef HAVE_UNISTD_H
119 # define HAVE_UNISTD_H 1
121 # ifndef STDC_HEADERS
122 # define STDC_HEADERS 1
124 #endif /* defined (POSIX) */
126 #if defined (POSIX) || (defined (USG) && !defined (VMS))
127 # ifndef HAVE_FCNTL_H
128 # define HAVE_FCNTL_H 1
135 # if TIME_WITH_SYS_TIME
136 # include <sys/time.h>
140 # include <sys/time.h>
145 # include <sys/resource.h>
152 /* This defines "errno" properly for VMS, and gives us EACCES. */
165 /* VMS-specific definitions */
168 #define O_RDONLY 0 /* Open arg for Read/Only */
169 #define O_WRONLY 1 /* Open arg for Write/Only */
170 #define read(fd,buf,size) VMS_read (fd,buf,size)
171 #define write(fd,buf,size) VMS_write (fd,buf,size)
172 #define open(fname,mode,prot) VMS_open (fname,mode,prot)
173 #define fopen(fname,mode) VMS_fopen (fname,mode)
174 #define freopen(fname,mode,ofile) VMS_freopen (fname,mode,ofile)
175 #define strncat(dst,src,cnt) VMS_strncat (dst,src,cnt)
176 #define fstat(fd,stbuf) VMS_fstat (fd,stbuf)
177 static int VMS_fstat (), VMS_stat ();
178 static char * VMS_strncat ();
179 static int VMS_read ();
180 static int VMS_write ();
181 static int VMS_open ();
182 static FILE * VMS_fopen ();
183 static FILE * VMS_freopen ();
184 static void hack_vms_include_specification ();
185 typedef struct { unsigned :16, :16, :16; } vms_ino_t;
186 #define ino_t vms_ino_t
187 #define INCLUDE_LEN_FUDGE 10 /* leave room for VMS syntax conversion */
189 #define BSTRING /* VMS/GCC supplies the bstring routines */
190 #endif /* __GNUC__ */
197 /* END stuff from gcc/cccp.c. */
199 #define FFECOM_DETERMINE_TYPES 1 /* for com.h */
216 /* Externals defined here. */
218 #if FFECOM_targetCURRENT == FFECOM_targetGCC
220 /* ~~gcc/tree.h *should* declare this, because toplev.c and dwarfout.c
223 const char * const language_string = "GNU F77";
225 /* Stream for reading from the input file. */
228 /* These definitions parallel those in c-decl.c so that code from that
229 module can be used pretty much as is. Much of these defs aren't
230 otherwise used, i.e. by g77 code per se, except some of them are used
231 to build some of them that are. The ones that are global (i.e. not
232 "static") are those that ste.c and such might use (directly
233 or by using com macros that reference them in their definitions). */
235 tree string_type_node;
237 /* The rest of these are inventions for g77, though there might be
238 similar things in the C front end. As they are found, these
239 inventions should be renamed to be canonical. Note that only
240 the ones currently required to be global are so. */
242 static tree ffecom_tree_fun_type_void;
244 tree ffecom_integer_type_node; /* Abbrev for _tree_type[blah][blah]. */
245 tree ffecom_integer_zero_node; /* Like *_*_* with g77's integer type. */
246 tree ffecom_integer_one_node; /* " */
247 tree ffecom_tree_type[FFEINFO_basictype][FFEINFO_kindtype];
249 /* _fun_type things are the f2c-specific versions. For -fno-f2c,
250 just use build_function_type and build_pointer_type on the
251 appropriate _tree_type array element. */
253 static tree ffecom_tree_fun_type[FFEINFO_basictype][FFEINFO_kindtype];
254 static tree ffecom_tree_ptr_to_fun_type[FFEINFO_basictype][FFEINFO_kindtype];
255 static tree ffecom_tree_subr_type;
256 static tree ffecom_tree_ptr_to_subr_type;
257 static tree ffecom_tree_blockdata_type;
259 static tree ffecom_tree_xargc_;
261 ffecomSymbol ffecom_symbol_null_
270 ffeinfoKindtype ffecom_pointer_kind_ = FFEINFO_basictypeNONE;
271 ffeinfoKindtype ffecom_label_kind_ = FFEINFO_basictypeNONE;
273 int ffecom_f2c_typecode_[FFEINFO_basictype][FFEINFO_kindtype];
274 tree ffecom_f2c_integer_type_node;
275 tree ffecom_f2c_ptr_to_integer_type_node;
276 tree ffecom_f2c_address_type_node;
277 tree ffecom_f2c_real_type_node;
278 tree ffecom_f2c_ptr_to_real_type_node;
279 tree ffecom_f2c_doublereal_type_node;
280 tree ffecom_f2c_complex_type_node;
281 tree ffecom_f2c_doublecomplex_type_node;
282 tree ffecom_f2c_longint_type_node;
283 tree ffecom_f2c_logical_type_node;
284 tree ffecom_f2c_flag_type_node;
285 tree ffecom_f2c_ftnlen_type_node;
286 tree ffecom_f2c_ftnlen_zero_node;
287 tree ffecom_f2c_ftnlen_one_node;
288 tree ffecom_f2c_ftnlen_two_node;
289 tree ffecom_f2c_ptr_to_ftnlen_type_node;
290 tree ffecom_f2c_ftnint_type_node;
291 tree ffecom_f2c_ptr_to_ftnint_type_node;
292 #endif /* FFECOM_targetCURRENT == FFECOM_targetGCC */
294 /* Simple definitions and enumerations. */
296 #ifndef FFECOM_sizeMAXSTACKITEM
297 #define FFECOM_sizeMAXSTACKITEM 32*1024 /* Keep user-declared things
298 larger than this # bytes
299 off stack if possible. */
302 /* For systems that have large enough stacks, they should define
303 this to 0, and here, for ease of use later on, we just undefine
306 #if FFECOM_sizeMAXSTACKITEM == 0
307 #undef FFECOM_sizeMAXSTACKITEM
313 FFECOM_rttypeVOIDSTAR_, /* C's `void *' type. */
314 FFECOM_rttypeFTNINT_, /* f2c's `ftnint' type. */
315 FFECOM_rttypeINTEGER_, /* f2c's `integer' type. */
316 FFECOM_rttypeLONGINT_, /* f2c's `longint' type. */
317 FFECOM_rttypeLOGICAL_, /* f2c's `logical' type. */
318 FFECOM_rttypeREAL_F2C_, /* f2c's `real' returned as `double'. */
319 FFECOM_rttypeREAL_GNU_, /* `real' returned as such. */
320 FFECOM_rttypeCOMPLEX_F2C_, /* f2c's `complex' returned via 1st arg. */
321 FFECOM_rttypeCOMPLEX_GNU_, /* f2c's `complex' returned directly. */
322 FFECOM_rttypeDOUBLE_, /* C's `double' type. */
323 FFECOM_rttypeDOUBLEREAL_, /* f2c's `doublereal' type. */
324 FFECOM_rttypeDBLCMPLX_F2C_, /* f2c's `doublecomplex' returned via 1st arg. */
325 FFECOM_rttypeDBLCMPLX_GNU_, /* f2c's `doublecomplex' returned directly. */
326 FFECOM_rttypeCHARACTER_, /* f2c `char *'/`ftnlen' pair. */
330 /* Internal typedefs. */
332 #if FFECOM_targetCURRENT == FFECOM_targetGCC
333 typedef struct _ffecom_concat_list_ ffecomConcatList_;
334 #endif /* FFECOM_targetCURRENT == FFECOM_targetGCC */
336 /* Private include files. */
339 /* Internal structure definitions. */
341 #if FFECOM_targetCURRENT == FFECOM_targetGCC
342 struct _ffecom_concat_list_
347 ffetargetCharacterSize minlen;
348 ffetargetCharacterSize maxlen;
350 #endif /* FFECOM_targetCURRENT == FFECOM_targetGCC */
352 /* Static functions (internal). */
354 #if FFECOM_targetCURRENT == FFECOM_targetGCC
355 static tree ffecom_arglist_expr_ (const char *argstring, ffebld args);
356 static tree ffecom_widest_expr_type_ (ffebld list);
357 static bool ffecom_overlap_ (tree dest_decl, tree dest_offset,
358 tree dest_size, tree source_tree,
359 ffebld source, bool scalar_arg);
360 static bool ffecom_args_overlapping_ (tree dest_tree, ffebld dest,
361 tree args, tree callee_commons,
363 static tree ffecom_build_f2c_string_ (int i, const char *s);
364 static tree ffecom_call_ (tree fn, ffeinfoKindtype kt,
365 bool is_f2c_complex, tree type,
366 tree args, tree dest_tree,
367 ffebld dest, bool *dest_used,
368 tree callee_commons, bool scalar_args, tree hook);
369 static tree ffecom_call_binop_ (tree fn, ffeinfoKindtype kt,
370 bool is_f2c_complex, tree type,
371 ffebld left, ffebld right,
372 tree dest_tree, ffebld dest,
373 bool *dest_used, tree callee_commons,
374 bool scalar_args, tree hook);
375 static void ffecom_char_args_x_ (tree *xitem, tree *length,
376 ffebld expr, bool with_null);
377 static tree ffecom_check_size_overflow_ (ffesymbol s, tree type, bool dummy);
378 static tree ffecom_char_enhance_arg_ (tree *xtype, ffesymbol s);
379 static ffecomConcatList_
380 ffecom_concat_list_gather_ (ffecomConcatList_ catlist,
382 ffetargetCharacterSize max);
383 static void ffecom_concat_list_kill_ (ffecomConcatList_ catlist);
384 static ffecomConcatList_ ffecom_concat_list_new_ (ffebld expr,
385 ffetargetCharacterSize max);
386 static void ffecom_debug_kludge_ (tree aggr, const char *aggr_type,
387 ffesymbol member, tree member_type,
388 ffetargetOffset offset);
389 static void ffecom_do_entry_ (ffesymbol fn, int entrynum);
390 static tree ffecom_expr_ (ffebld expr, tree dest_tree, ffebld dest,
391 bool *dest_used, bool assignp, bool widenp);
392 static tree ffecom_expr_intrinsic_ (ffebld expr, tree dest_tree,
393 ffebld dest, bool *dest_used);
394 static tree ffecom_expr_power_integer_ (ffebld expr);
395 static void ffecom_expr_transform_ (ffebld expr);
396 static void ffecom_f2c_make_type_ (tree *type, int tcode, const char *name);
397 static void ffecom_f2c_set_lio_code_ (ffeinfoBasictype bt, int size,
399 static ffeglobal ffecom_finish_global_ (ffeglobal global);
400 static ffesymbol ffecom_finish_symbol_transform_ (ffesymbol s);
401 static tree ffecom_get_appended_identifier_ (char us, const char *text);
402 static tree ffecom_get_external_identifier_ (ffesymbol s);
403 static tree ffecom_get_identifier_ (const char *text);
404 static tree ffecom_gen_sfuncdef_ (ffesymbol s,
407 static const char *ffecom_gfrt_args_ (ffecomGfrt ix);
408 static tree ffecom_gfrt_tree_ (ffecomGfrt ix);
409 static tree ffecom_init_zero_ (tree decl);
410 static tree ffecom_intrinsic_ichar_ (tree tree_type, ffebld arg,
412 static tree ffecom_intrinsic_len_ (ffebld expr);
413 static void ffecom_let_char_ (tree dest_tree,
415 ffetargetCharacterSize dest_size,
417 static void ffecom_make_gfrt_ (ffecomGfrt ix);
418 static void ffecom_member_phase1_ (ffestorag mst, ffestorag st);
419 static void ffecom_member_phase2_ (ffestorag mst, ffestorag st);
420 static void ffecom_prepare_let_char_ (ffetargetCharacterSize dest_size,
422 static void ffecom_push_dummy_decls_ (ffebld dumlist,
424 static void ffecom_start_progunit_ (void);
425 static ffesymbol ffecom_sym_transform_ (ffesymbol s);
426 static ffesymbol ffecom_sym_transform_assign_ (ffesymbol s);
427 static void ffecom_transform_common_ (ffesymbol s);
428 static void ffecom_transform_equiv_ (ffestorag st);
429 static tree ffecom_transform_namelist_ (ffesymbol s);
430 static void ffecom_tree_canonize_ptr_ (tree *decl, tree *offset,
432 static void ffecom_tree_canonize_ref_ (tree *decl, tree *offset,
433 tree *size, tree tree);
434 static tree ffecom_tree_divide_ (tree tree_type, tree left, tree right,
435 tree dest_tree, ffebld dest,
436 bool *dest_used, tree hook);
437 static tree ffecom_type_localvar_ (ffesymbol s,
440 static tree ffecom_type_namelist_ (void);
441 static tree ffecom_type_vardesc_ (void);
442 static tree ffecom_vardesc_ (ffebld expr);
443 static tree ffecom_vardesc_array_ (ffesymbol s);
444 static tree ffecom_vardesc_dims_ (ffesymbol s);
445 static tree ffecom_convert_narrow_ (tree type, tree expr);
446 static tree ffecom_convert_widen_ (tree type, tree expr);
447 #endif /* FFECOM_targetCURRENT == FFECOM_targetGCC */
449 /* These are static functions that parallel those found in the C front
450 end and thus have the same names. */
452 #if FFECOM_targetCURRENT == FFECOM_targetGCC
453 static tree bison_rule_compstmt_ (void);
454 static void bison_rule_pushlevel_ (void);
455 static void delete_block (tree block);
456 static int duplicate_decls (tree newdecl, tree olddecl);
457 static void finish_decl (tree decl, tree init, bool is_top_level);
458 static void finish_function (int nested);
459 static const char *lang_printable_name (tree decl, int v);
460 static tree lookup_name_current_level (tree name);
461 static struct binding_level *make_binding_level (void);
462 static void pop_f_function_context (void);
463 static void push_f_function_context (void);
464 static void push_parm_decl (tree parm);
465 static tree pushdecl_top_level (tree decl);
466 static int kept_level_p (void);
467 static tree storedecls (tree decls);
468 static void store_parm_decls (int is_main_program);
469 static tree start_decl (tree decl, bool is_top_level);
470 static void start_function (tree name, tree type, int nested, int public);
471 #endif /* FFECOM_targetCURRENT == FFECOM_targetGCC */
472 #if FFECOM_GCC_INCLUDE
473 static void ffecom_file_ (const char *name);
474 static void ffecom_initialize_char_syntax_ (void);
475 static void ffecom_close_include_ (FILE *f);
476 static int ffecom_decode_include_option_ (char *spec);
477 static FILE *ffecom_open_include_ (char *name, ffewhereLine l,
479 #endif /* FFECOM_GCC_INCLUDE */
481 /* Static objects accessed by functions in this module. */
483 static ffesymbol ffecom_primary_entry_ = NULL;
484 static ffesymbol ffecom_nested_entry_ = NULL;
485 static ffeinfoKind ffecom_primary_entry_kind_;
486 static bool ffecom_primary_entry_is_proc_;
487 #if FFECOM_targetCURRENT == FFECOM_targetGCC
488 static tree ffecom_outer_function_decl_;
489 static tree ffecom_previous_function_decl_;
490 static tree ffecom_which_entrypoint_decl_;
491 static tree ffecom_float_zero_ = NULL_TREE;
492 static tree ffecom_float_half_ = NULL_TREE;
493 static tree ffecom_double_zero_ = NULL_TREE;
494 static tree ffecom_double_half_ = NULL_TREE;
495 static tree ffecom_func_result_;/* For functions. */
496 static tree ffecom_func_length_;/* For CHARACTER fns. */
497 static ffebld ffecom_list_blockdata_;
498 static ffebld ffecom_list_common_;
499 static ffebld ffecom_master_arglist_;
500 static ffeinfoBasictype ffecom_master_bt_;
501 static ffeinfoKindtype ffecom_master_kt_;
502 static ffetargetCharacterSize ffecom_master_size_;
503 static int ffecom_num_fns_ = 0;
504 static int ffecom_num_entrypoints_ = 0;
505 static bool ffecom_is_altreturning_ = FALSE;
506 static tree ffecom_multi_type_node_;
507 static tree ffecom_multi_retval_;
509 ffecom_multi_fields_[FFEINFO_basictype][FFEINFO_kindtype];
510 static bool ffecom_member_namelisted_; /* _member_phase1_ namelisted? */
511 static bool ffecom_doing_entry_ = FALSE;
512 static bool ffecom_transform_only_dummies_ = FALSE;
513 static int ffecom_typesize_pointer_;
514 static int ffecom_typesize_integer1_;
516 /* Holds pointer-to-function expressions. */
518 static tree ffecom_gfrt_[FFECOM_gfrt]
521 #define DEFGFRT(CODE,NAME,TYPE,ARGS,VOLATILE,COMPLEX) NULL_TREE,
522 #include "com-rt.def"
526 /* Holds the external names of the functions. */
528 static const char *ffecom_gfrt_name_[FFECOM_gfrt]
531 #define DEFGFRT(CODE,NAME,TYPE,ARGS,VOLATILE,COMPLEX) NAME,
532 #include "com-rt.def"
536 /* Whether the function returns. */
538 static bool ffecom_gfrt_volatile_[FFECOM_gfrt]
541 #define DEFGFRT(CODE,NAME,TYPE,ARGS,VOLATILE,COMPLEX) VOLATILE,
542 #include "com-rt.def"
546 /* Whether the function returns type complex. */
548 static bool ffecom_gfrt_complex_[FFECOM_gfrt]
551 #define DEFGFRT(CODE,NAME,TYPE,ARGS,VOLATILE,COMPLEX) COMPLEX,
552 #include "com-rt.def"
556 /* Type code for the function return value. */
558 static ffecomRttype_ ffecom_gfrt_type_[FFECOM_gfrt]
561 #define DEFGFRT(CODE,NAME,TYPE,ARGS,VOLATILE,COMPLEX) TYPE,
562 #include "com-rt.def"
566 /* String of codes for the function's arguments. */
568 static const char *ffecom_gfrt_argstring_[FFECOM_gfrt]
571 #define DEFGFRT(CODE,NAME,TYPE,ARGS,VOLATILE,COMPLEX) ARGS,
572 #include "com-rt.def"
575 #endif /* FFECOM_targetCURRENT == FFECOM_targetGCC */
577 /* Internal macros. */
579 #if FFECOM_targetCURRENT == FFECOM_targetGCC
581 /* We let tm.h override the types used here, to handle trivial differences
582 such as the choice of unsigned int or long unsigned int for size_t.
583 When machines start needing nontrivial differences in the size type,
584 it would be best to do something here to figure out automatically
585 from other information what type to use. */
588 #define SIZE_TYPE "long unsigned int"
591 #define ffecom_concat_list_count_(catlist) ((catlist).count)
592 #define ffecom_concat_list_expr_(catlist,i) ((catlist).exprs[(i)])
593 #define ffecom_concat_list_maxlen_(catlist) ((catlist).maxlen)
594 #define ffecom_concat_list_minlen_(catlist) ((catlist).minlen)
596 #define ffecom_char_args_(i,l,e) ffecom_char_args_x_((i),(l),(e),FALSE)
597 #define ffecom_char_args_with_null_(i,l,e) ffecom_char_args_x_((i),(l),(e),TRUE)
599 /* For each binding contour we allocate a binding_level structure
600 * which records the names defined in that contour.
603 * 1) one for each function definition,
604 * where internal declarations of the parameters appear.
606 * The current meaning of a name can be found by searching the levels from
607 * the current one out to the global one.
610 /* Note that the information in the `names' component of the global contour
611 is duplicated in the IDENTIFIER_GLOBAL_VALUEs of all identifiers. */
615 /* A chain of _DECL nodes for all variables, constants, functions,
616 and typedef types. These are in the reverse of the order supplied.
620 /* For each level (except not the global one),
621 a chain of BLOCK nodes for all the levels
622 that were entered and exited one level down. */
625 /* The BLOCK node for this level, if one has been preallocated.
626 If 0, the BLOCK is allocated (if needed) when the level is popped. */
629 /* The binding level which this one is contained in (inherits from). */
630 struct binding_level *level_chain;
632 /* 0: no ffecom_prepare_* functions called at this level yet;
633 1: ffecom_prepare* functions called, except not ffecom_prepare_end;
634 2: ffecom_prepare_end called. */
638 #define NULL_BINDING_LEVEL (struct binding_level *) NULL
640 /* The binding level currently in effect. */
642 static struct binding_level *current_binding_level;
644 /* A chain of binding_level structures awaiting reuse. */
646 static struct binding_level *free_binding_level;
648 /* The outermost binding level, for names of file scope.
649 This is created when the compiler is started and exists
650 through the entire run. */
652 static struct binding_level *global_binding_level;
654 /* Binding level structures are initialized by copying this one. */
656 static struct binding_level clear_binding_level
658 {NULL, NULL, NULL, NULL_BINDING_LEVEL, 0};
660 /* Language-dependent contents of an identifier. */
662 struct lang_identifier
664 struct tree_identifier ignore;
665 tree global_value, local_value, label_value;
669 /* Macros for access to language-specific slots in an identifier. */
670 /* Each of these slots contains a DECL node or null. */
672 /* This represents the value which the identifier has in the
673 file-scope namespace. */
674 #define IDENTIFIER_GLOBAL_VALUE(NODE) \
675 (((struct lang_identifier *)(NODE))->global_value)
676 /* This represents the value which the identifier has in the current
678 #define IDENTIFIER_LOCAL_VALUE(NODE) \
679 (((struct lang_identifier *)(NODE))->local_value)
680 /* This represents the value which the identifier has as a label in
681 the current label scope. */
682 #define IDENTIFIER_LABEL_VALUE(NODE) \
683 (((struct lang_identifier *)(NODE))->label_value)
684 /* This is nonzero if the identifier was "made up" by g77 code. */
685 #define IDENTIFIER_INVENTED(NODE) \
686 (((struct lang_identifier *)(NODE))->invented)
688 /* In identifiers, C uses the following fields in a special way:
689 TREE_PUBLIC to record that there was a previous local extern decl.
690 TREE_USED to record that such a decl was used.
691 TREE_ADDRESSABLE to record that the address of such a decl was used. */
693 /* A list (chain of TREE_LIST nodes) of all LABEL_DECLs in the function
694 that have names. Here so we can clear out their names' definitions
695 at the end of the function. */
697 static tree named_labels;
699 /* A list of LABEL_DECLs from outer contexts that are currently shadowed. */
701 static tree shadowed_labels;
703 #endif /* FFECOM_targetCURRENT == FFECOM_targetGCC */
705 /* Return the subscript expression, modified to do range-checking.
707 `array' is the array to be checked against.
708 `element' is the subscript expression to check.
709 `dim' is the dimension number (starting at 0).
710 `total_dims' is the total number of dimensions (0 for CHARACTER substring).
714 ffecom_subscript_check_ (tree array, tree element, int dim, int total_dims,
717 tree low = TYPE_MIN_VALUE (TYPE_DOMAIN (array));
718 tree high = TYPE_MAX_VALUE (TYPE_DOMAIN (array));
723 if (element == error_mark_node)
726 if (TREE_TYPE (low) != TREE_TYPE (element))
728 if (TYPE_PRECISION (TREE_TYPE (low))
729 > TYPE_PRECISION (TREE_TYPE (element)))
730 element = convert (TREE_TYPE (low), element);
733 low = convert (TREE_TYPE (element), low);
735 high = convert (TREE_TYPE (element), high);
739 element = ffecom_save_tree (element);
740 cond = ffecom_2 (LE_EXPR, integer_type_node,
745 cond = ffecom_2 (TRUTH_ANDIF_EXPR, integer_type_node,
747 ffecom_2 (LE_EXPR, integer_type_node,
764 var = xmalloc (strlen (array_name) + 20);
765 sprintf (&var[0], "%s[%s-substring]",
767 dim ? "end" : "start");
768 len = strlen (var) + 1;
772 len = strlen (array_name) + 1;
777 var = xmalloc (strlen (array_name) + 40);
778 sprintf (&var[0], "%s[subscript-%d-of-%d]",
780 dim + 1, total_dims);
781 len = strlen (var) + 1;
785 arg1 = build_string (len, var);
791 = build_type_variant (build_array_type (char_type_node,
795 build_int_2 (len, 0))),
797 TREE_CONSTANT (arg1) = 1;
798 TREE_STATIC (arg1) = 1;
799 arg1 = ffecom_1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (arg1)),
802 /* s_rnge adds one to the element to print it, so bias against
803 that -- want to print a faithful *subscript* value. */
804 arg2 = convert (ffecom_f2c_ftnint_type_node,
805 ffecom_2 (MINUS_EXPR,
808 convert (TREE_TYPE (element),
811 proc = xmalloc ((len = strlen (input_filename)
812 + IDENTIFIER_LENGTH (DECL_NAME (current_function_decl))
815 sprintf (&proc[0], "%s/%s",
817 IDENTIFIER_POINTER (DECL_NAME (current_function_decl)));
818 arg3 = build_string (len, proc);
823 = build_type_variant (build_array_type (char_type_node,
827 build_int_2 (len, 0))),
829 TREE_CONSTANT (arg3) = 1;
830 TREE_STATIC (arg3) = 1;
831 arg3 = ffecom_1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (arg3)),
834 arg4 = convert (ffecom_f2c_ftnint_type_node,
835 build_int_2 (lineno, 0));
837 arg1 = build_tree_list (NULL_TREE, arg1);
838 arg2 = build_tree_list (NULL_TREE, arg2);
839 arg3 = build_tree_list (NULL_TREE, arg3);
840 arg4 = build_tree_list (NULL_TREE, arg4);
841 TREE_CHAIN (arg3) = arg4;
842 TREE_CHAIN (arg2) = arg3;
843 TREE_CHAIN (arg1) = arg2;
847 die = ffecom_call_gfrt (FFECOM_gfrtRANGE,
849 TREE_SIDE_EFFECTS (die) = 1;
851 element = ffecom_3 (COND_EXPR,
860 /* Return the computed element of an array reference.
862 `item' is NULL_TREE, or the transformed pointer to the array.
863 `expr' is the original opARRAYREF expression, which is transformed
864 if `item' is NULL_TREE.
865 `want_ptr' is non-zero if a pointer to the element, instead of
866 the element itself, is to be returned. */
869 ffecom_arrayref_ (tree item, ffebld expr, int want_ptr)
871 ffebld dims[FFECOM_dimensionsMAX];
874 int flatten = ffe_is_flatten_arrays ();
884 if (ffebld_op (ffebld_left (expr)) == FFEBLD_opSYMTER)
885 array_name = ffesymbol_text (ffebld_symter (ffebld_left (expr)));
887 array_name = "[expr?]";
889 /* Build up ARRAY_REFs in reverse order (since we're column major
890 here in Fortran land). */
892 for (i = 0, list = ffebld_right (expr);
894 ++i, list = ffebld_trail (list))
896 dims[i] = ffebld_head (list);
897 type = ffeinfo_type (ffebld_basictype (dims[i]),
898 ffebld_kindtype (dims[i]));
900 && ffecom_typesize_pointer_ > ffecom_typesize_integer1_
901 && ffetype_size (type) > ffecom_typesize_integer1_)
902 /* E.g. ARRAY(INDEX), given INTEGER*8 INDEX, on a system with 64-bit
903 pointers and 32-bit integers. Do the full 64-bit pointer
904 arithmetic, for codes using arrays for nonstandard heap-like
911 need_ptr = want_ptr || flatten;
916 item = ffecom_ptr_to_expr (ffebld_left (expr));
918 item = ffecom_expr (ffebld_left (expr));
920 if (item == error_mark_node)
923 if (ffeinfo_where (ffebld_info (expr)) == FFEINFO_whereFLEETING
924 && ! mark_addressable (item))
925 return error_mark_node;
928 if (item == error_mark_node)
935 for (--i, array = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (item)));
937 --i, array = TYPE_MAIN_VARIANT (TREE_TYPE (array)))
939 min = TYPE_MIN_VALUE (TYPE_DOMAIN (array));
940 element = ffecom_expr_ (dims[i], NULL, NULL, NULL, FALSE, TRUE);
941 if (flag_bounds_check)
942 element = ffecom_subscript_check_ (array, element, i, total_dims,
944 if (element == error_mark_node)
947 /* Widen integral arithmetic as desired while preserving
949 tree_type = TREE_TYPE (element);
950 tree_type_x = tree_type;
952 && GET_MODE_CLASS (TYPE_MODE (tree_type)) == MODE_INT
953 && TYPE_PRECISION (tree_type) < TYPE_PRECISION (sizetype))
954 tree_type_x = (TREE_UNSIGNED (tree_type) ? usizetype : ssizetype);
956 if (TREE_TYPE (min) != tree_type_x)
957 min = convert (tree_type_x, min);
958 if (TREE_TYPE (element) != tree_type_x)
959 element = convert (tree_type_x, element);
961 item = ffecom_2 (PLUS_EXPR,
962 build_pointer_type (TREE_TYPE (array)),
964 size_binop (MULT_EXPR,
965 size_in_bytes (TREE_TYPE (array)),
967 fold (build (MINUS_EXPR,
973 item = ffecom_1 (INDIRECT_REF,
974 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (item))),
984 array = TYPE_MAIN_VARIANT (TREE_TYPE (item));
986 element = ffecom_expr_ (dims[i], NULL, NULL, NULL, FALSE, TRUE);
987 if (flag_bounds_check)
988 element = ffecom_subscript_check_ (array, element, i, total_dims,
990 if (element == error_mark_node)
993 /* Widen integral arithmetic as desired while preserving
995 tree_type = TREE_TYPE (element);
996 tree_type_x = tree_type;
998 && GET_MODE_CLASS (TYPE_MODE (tree_type)) == MODE_INT
999 && TYPE_PRECISION (tree_type) < TYPE_PRECISION (sizetype))
1000 tree_type_x = (TREE_UNSIGNED (tree_type) ? usizetype : ssizetype);
1002 element = convert (tree_type_x, element);
1004 item = ffecom_2 (ARRAY_REF,
1005 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (item))),
1014 /* This is like gcc's stabilize_reference -- in fact, most of the code
1015 comes from that -- but it handles the situation where the reference
1016 is going to have its subparts picked at, and it shouldn't change
1017 (or trigger extra invocations of functions in the subtrees) due to
1018 this. save_expr is a bit overzealous, because we don't need the
1019 entire thing calculated and saved like a temp. So, for DECLs, no
1020 change is needed, because these are stable aggregates, and ARRAY_REF
1021 and such might well be stable too, but for things like calculations,
1022 we do need to calculate a snapshot of a value before picking at it. */
1024 #if FFECOM_targetCURRENT == FFECOM_targetGCC
1026 ffecom_stabilize_aggregate_ (tree ref)
1029 enum tree_code code = TREE_CODE (ref);
1036 /* No action is needed in this case. */
1042 case FIX_TRUNC_EXPR:
1043 case FIX_FLOOR_EXPR:
1044 case FIX_ROUND_EXPR:
1046 result = build_nt (code, stabilize_reference (TREE_OPERAND (ref, 0)));
1050 result = build_nt (INDIRECT_REF,
1051 stabilize_reference_1 (TREE_OPERAND (ref, 0)));
1055 result = build_nt (COMPONENT_REF,
1056 stabilize_reference (TREE_OPERAND (ref, 0)),
1057 TREE_OPERAND (ref, 1));
1061 result = build_nt (BIT_FIELD_REF,
1062 stabilize_reference (TREE_OPERAND (ref, 0)),
1063 stabilize_reference_1 (TREE_OPERAND (ref, 1)),
1064 stabilize_reference_1 (TREE_OPERAND (ref, 2)));
1068 result = build_nt (ARRAY_REF,
1069 stabilize_reference (TREE_OPERAND (ref, 0)),
1070 stabilize_reference_1 (TREE_OPERAND (ref, 1)));
1074 result = build_nt (COMPOUND_EXPR,
1075 stabilize_reference_1 (TREE_OPERAND (ref, 0)),
1076 stabilize_reference (TREE_OPERAND (ref, 1)));
1080 result = build1 (INDIRECT_REF, TREE_TYPE (ref),
1081 save_expr (build1 (ADDR_EXPR,
1082 build_pointer_type (TREE_TYPE (ref)),
1088 return save_expr (ref);
1091 return error_mark_node;
1094 TREE_TYPE (result) = TREE_TYPE (ref);
1095 TREE_READONLY (result) = TREE_READONLY (ref);
1096 TREE_SIDE_EFFECTS (result) = TREE_SIDE_EFFECTS (ref);
1097 TREE_THIS_VOLATILE (result) = TREE_THIS_VOLATILE (ref);
1103 /* A rip-off of gcc's convert.c convert_to_complex function,
1104 reworked to handle complex implemented as C structures
1105 (RECORD_TYPE with two fields, real and imaginary `r' and `i'). */
1107 #if FFECOM_targetCURRENT == FFECOM_targetGCC
1109 ffecom_convert_to_complex_ (tree type, tree expr)
1111 register enum tree_code form = TREE_CODE (TREE_TYPE (expr));
1114 assert (TREE_CODE (type) == RECORD_TYPE);
1116 subtype = TREE_TYPE (TYPE_FIELDS (type));
1118 if (form == REAL_TYPE || form == INTEGER_TYPE || form == ENUMERAL_TYPE)
1120 expr = convert (subtype, expr);
1121 return ffecom_2 (COMPLEX_EXPR, type, expr,
1122 convert (subtype, integer_zero_node));
1125 if (form == RECORD_TYPE)
1127 tree elt_type = TREE_TYPE (TYPE_FIELDS (TREE_TYPE (expr)));
1128 if (TYPE_MAIN_VARIANT (elt_type) == TYPE_MAIN_VARIANT (subtype))
1132 expr = save_expr (expr);
1133 return ffecom_2 (COMPLEX_EXPR,
1136 ffecom_1 (REALPART_EXPR,
1137 TREE_TYPE (TYPE_FIELDS (TREE_TYPE (expr))),
1140 ffecom_1 (IMAGPART_EXPR,
1141 TREE_TYPE (TYPE_FIELDS (TREE_TYPE (expr))),
1146 if (form == POINTER_TYPE || form == REFERENCE_TYPE)
1147 error ("pointer value used where a complex was expected");
1149 error ("aggregate value used where a complex was expected");
1151 return ffecom_2 (COMPLEX_EXPR, type,
1152 convert (subtype, integer_zero_node),
1153 convert (subtype, integer_zero_node));
1157 /* Like gcc's convert(), but crashes if widening might happen. */
1159 #if FFECOM_targetCURRENT == FFECOM_targetGCC
1161 ffecom_convert_narrow_ (type, expr)
1164 register tree e = expr;
1165 register enum tree_code code = TREE_CODE (type);
1167 if (type == TREE_TYPE (e)
1168 || TREE_CODE (e) == ERROR_MARK)
1170 if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (e)))
1171 return fold (build1 (NOP_EXPR, type, e));
1172 if (TREE_CODE (TREE_TYPE (e)) == ERROR_MARK
1173 || code == ERROR_MARK)
1174 return error_mark_node;
1175 if (TREE_CODE (TREE_TYPE (e)) == VOID_TYPE)
1177 assert ("void value not ignored as it ought to be" == NULL);
1178 return error_mark_node;
1180 assert (code != VOID_TYPE);
1181 if ((code != RECORD_TYPE)
1182 && (TREE_CODE (TREE_TYPE (e)) == RECORD_TYPE))
1183 assert ("converting COMPLEX to REAL" == NULL);
1184 assert (code != ENUMERAL_TYPE);
1185 if (code == INTEGER_TYPE)
1187 assert ((TREE_CODE (TREE_TYPE (e)) == INTEGER_TYPE
1188 && TYPE_PRECISION (type) <= TYPE_PRECISION (TREE_TYPE (e)))
1189 || (TREE_CODE (TREE_TYPE (e)) == POINTER_TYPE
1190 && (TYPE_PRECISION (type)
1191 == TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (e))))));
1192 return fold (convert_to_integer (type, e));
1194 if (code == POINTER_TYPE)
1196 assert (TREE_CODE (TREE_TYPE (e)) == POINTER_TYPE);
1197 return fold (convert_to_pointer (type, e));
1199 if (code == REAL_TYPE)
1201 assert (TREE_CODE (TREE_TYPE (e)) == REAL_TYPE);
1202 assert (TYPE_PRECISION (type) <= TYPE_PRECISION (TREE_TYPE (e)));
1203 return fold (convert_to_real (type, e));
1205 if (code == COMPLEX_TYPE)
1207 assert (TREE_CODE (TREE_TYPE (e)) == COMPLEX_TYPE);
1208 assert (TYPE_PRECISION (TREE_TYPE (type)) <= TYPE_PRECISION (TREE_TYPE (TREE_TYPE (e))));
1209 return fold (convert_to_complex (type, e));
1211 if (code == RECORD_TYPE)
1213 assert (TREE_CODE (TREE_TYPE (e)) == RECORD_TYPE);
1214 /* Check that at least the first field name agrees. */
1215 assert (DECL_NAME (TYPE_FIELDS (type))
1216 == DECL_NAME (TYPE_FIELDS (TREE_TYPE (e))));
1217 assert (TYPE_PRECISION (TREE_TYPE (TYPE_FIELDS (type)))
1218 <= TYPE_PRECISION (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (e)))));
1219 if (TYPE_PRECISION (TREE_TYPE (TYPE_FIELDS (type)))
1220 == TYPE_PRECISION (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (e)))))
1222 return fold (ffecom_convert_to_complex_ (type, e));
1225 assert ("conversion to non-scalar type requested" == NULL);
1226 return error_mark_node;
1230 /* Like gcc's convert(), but crashes if narrowing might happen. */
1232 #if FFECOM_targetCURRENT == FFECOM_targetGCC
1234 ffecom_convert_widen_ (type, expr)
1237 register tree e = expr;
1238 register enum tree_code code = TREE_CODE (type);
1240 if (type == TREE_TYPE (e)
1241 || TREE_CODE (e) == ERROR_MARK)
1243 if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (e)))
1244 return fold (build1 (NOP_EXPR, type, e));
1245 if (TREE_CODE (TREE_TYPE (e)) == ERROR_MARK
1246 || code == ERROR_MARK)
1247 return error_mark_node;
1248 if (TREE_CODE (TREE_TYPE (e)) == VOID_TYPE)
1250 assert ("void value not ignored as it ought to be" == NULL);
1251 return error_mark_node;
1253 assert (code != VOID_TYPE);
1254 if ((code != RECORD_TYPE)
1255 && (TREE_CODE (TREE_TYPE (e)) == RECORD_TYPE))
1256 assert ("narrowing COMPLEX to REAL" == NULL);
1257 assert (code != ENUMERAL_TYPE);
1258 if (code == INTEGER_TYPE)
1260 assert ((TREE_CODE (TREE_TYPE (e)) == INTEGER_TYPE
1261 && TYPE_PRECISION (type) >= TYPE_PRECISION (TREE_TYPE (e)))
1262 || (TREE_CODE (TREE_TYPE (e)) == POINTER_TYPE
1263 && (TYPE_PRECISION (type)
1264 == TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (e))))));
1265 return fold (convert_to_integer (type, e));
1267 if (code == POINTER_TYPE)
1269 assert (TREE_CODE (TREE_TYPE (e)) == POINTER_TYPE);
1270 return fold (convert_to_pointer (type, e));
1272 if (code == REAL_TYPE)
1274 assert (TREE_CODE (TREE_TYPE (e)) == REAL_TYPE);
1275 assert (TYPE_PRECISION (type) >= TYPE_PRECISION (TREE_TYPE (e)));
1276 return fold (convert_to_real (type, e));
1278 if (code == COMPLEX_TYPE)
1280 assert (TREE_CODE (TREE_TYPE (e)) == COMPLEX_TYPE);
1281 assert (TYPE_PRECISION (TREE_TYPE (type)) >= TYPE_PRECISION (TREE_TYPE (TREE_TYPE (e))));
1282 return fold (convert_to_complex (type, e));
1284 if (code == RECORD_TYPE)
1286 assert (TREE_CODE (TREE_TYPE (e)) == RECORD_TYPE);
1287 /* Check that at least the first field name agrees. */
1288 assert (DECL_NAME (TYPE_FIELDS (type))
1289 == DECL_NAME (TYPE_FIELDS (TREE_TYPE (e))));
1290 assert (TYPE_PRECISION (TREE_TYPE (TYPE_FIELDS (type)))
1291 >= TYPE_PRECISION (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (e)))));
1292 if (TYPE_PRECISION (TREE_TYPE (TYPE_FIELDS (type)))
1293 == TYPE_PRECISION (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (e)))))
1295 return fold (ffecom_convert_to_complex_ (type, e));
1298 assert ("conversion to non-scalar type requested" == NULL);
1299 return error_mark_node;
1303 /* Handles making a COMPLEX type, either the standard
1304 (but buggy?) gbe way, or the safer (but less elegant?)
1307 #if FFECOM_targetCURRENT == FFECOM_targetGCC
1309 ffecom_make_complex_type_ (tree subtype)
1315 if (ffe_is_emulate_complex ())
1317 type = make_node (RECORD_TYPE);
1318 realfield = ffecom_decl_field (type, NULL_TREE, "r", subtype);
1319 imagfield = ffecom_decl_field (type, realfield, "i", subtype);
1320 TYPE_FIELDS (type) = realfield;
1325 type = make_node (COMPLEX_TYPE);
1326 TREE_TYPE (type) = subtype;
1334 /* Chooses either the gbe or the f2c way to build a
1335 complex constant. */
1337 #if FFECOM_targetCURRENT == FFECOM_targetGCC
1339 ffecom_build_complex_constant_ (tree type, tree realpart, tree imagpart)
1343 if (ffe_is_emulate_complex ())
1345 bothparts = build_tree_list (TYPE_FIELDS (type), realpart);
1346 TREE_CHAIN (bothparts) = build_tree_list (TREE_CHAIN (TYPE_FIELDS (type)), imagpart);
1347 bothparts = build (CONSTRUCTOR, type, NULL_TREE, bothparts);
1351 bothparts = build_complex (type, realpart, imagpart);
1358 #if FFECOM_targetCURRENT == FFECOM_targetGCC
1360 ffecom_arglist_expr_ (const char *c, ffebld expr)
1363 tree *plist = &list;
1364 tree trail = NULL_TREE; /* Append char length args here. */
1365 tree *ptrail = &trail;
1370 tree wanted = NULL_TREE;
1371 static char zed[] = "0";
1376 while (expr != NULL)
1399 wanted = ffecom_f2c_complex_type_node;
1403 wanted = ffecom_f2c_doublereal_type_node;
1407 wanted = ffecom_f2c_doublecomplex_type_node;
1411 wanted = ffecom_f2c_real_type_node;
1415 wanted = ffecom_f2c_integer_type_node;
1419 wanted = ffecom_f2c_longint_type_node;
1423 assert ("bad argstring code" == NULL);
1429 exprh = ffebld_head (expr);
1433 if ((wanted == NULL_TREE)
1436 (ffecom_tree_type[ffeinfo_basictype (ffebld_info (exprh))]
1437 [ffeinfo_kindtype (ffebld_info (exprh))])
1438 == TYPE_MODE (wanted))))
1440 = build_tree_list (NULL_TREE,
1441 ffecom_arg_ptr_to_expr (exprh,
1445 item = ffecom_arg_expr (exprh, &length);
1446 item = ffecom_convert_widen_ (wanted, item);
1449 item = ffecom_1 (ADDR_EXPR,
1450 build_pointer_type (TREE_TYPE (item)),
1454 = build_tree_list (NULL_TREE,
1458 plist = &TREE_CHAIN (*plist);
1459 expr = ffebld_trail (expr);
1460 if (length != NULL_TREE)
1462 *ptrail = build_tree_list (NULL_TREE, length);
1463 ptrail = &TREE_CHAIN (*ptrail);
1467 /* We've run out of args in the call; if the implementation expects
1468 more, supply null pointers for them, which the implementation can
1469 check to see if an arg was omitted. */
1471 while (*c != '\0' && *c != '0')
1476 assert ("missing arg to run-time routine!" == NULL);
1491 assert ("bad arg string code" == NULL);
1495 = build_tree_list (NULL_TREE,
1497 plist = &TREE_CHAIN (*plist);
1506 #if FFECOM_targetCURRENT == FFECOM_targetGCC
1508 ffecom_widest_expr_type_ (ffebld list)
1511 ffebld widest = NULL;
1513 ffetype widest_type = NULL;
1516 for (; list != NULL; list = ffebld_trail (list))
1518 item = ffebld_head (list);
1521 if ((widest != NULL)
1522 && (ffeinfo_basictype (ffebld_info (item))
1523 != ffeinfo_basictype (ffebld_info (widest))))
1525 type = ffeinfo_type (ffeinfo_basictype (ffebld_info (item)),
1526 ffeinfo_kindtype (ffebld_info (item)));
1527 if ((widest == FFEINFO_kindtypeNONE)
1528 || (ffetype_size (type)
1529 > ffetype_size (widest_type)))
1536 assert (widest != NULL);
1537 t = ffecom_tree_type[ffeinfo_basictype (ffebld_info (widest))]
1538 [ffeinfo_kindtype (ffebld_info (widest))];
1539 assert (t != NULL_TREE);
1544 /* Check whether a partial overlap between two expressions is possible.
1546 Can *starting* to write a portion of expr1 change the value
1547 computed (perhaps already, *partially*) by expr2?
1549 Currently, this is a concern only for a COMPLEX expr1. But if it
1550 isn't in COMMON or local EQUIVALENCE, since we don't support
1551 aliasing of arguments, it isn't a concern. */
1554 ffecom_possible_partial_overlap_ (ffebld expr1, ffebld expr2 ATTRIBUTE_UNUSED)
1559 switch (ffebld_op (expr1))
1561 case FFEBLD_opSYMTER:
1562 sym = ffebld_symter (expr1);
1565 case FFEBLD_opARRAYREF:
1566 if (ffebld_op (ffebld_left (expr1)) != FFEBLD_opSYMTER)
1568 sym = ffebld_symter (ffebld_left (expr1));
1575 if (ffesymbol_where (sym) != FFEINFO_whereCOMMON
1576 && (ffesymbol_where (sym) != FFEINFO_whereLOCAL
1577 || ! (st = ffesymbol_storage (sym))
1578 || ! ffestorag_parent (st)))
1581 /* It's in COMMON or local EQUIVALENCE. */
1586 /* Check whether dest and source might overlap. ffebld versions of these
1587 might or might not be passed, will be NULL if not.
1589 The test is really whether source_tree is modifiable and, if modified,
1590 might overlap destination such that the value(s) in the destination might
1591 change before it is finally modified. dest_* are the canonized
1592 destination itself. */
1594 #if FFECOM_targetCURRENT == FFECOM_targetGCC
1596 ffecom_overlap_ (tree dest_decl, tree dest_offset, tree dest_size,
1597 tree source_tree, ffebld source UNUSED,
1605 if (source_tree == NULL_TREE)
1608 switch (TREE_CODE (source_tree))
1611 case IDENTIFIER_NODE:
1622 case TRUNC_DIV_EXPR:
1624 case FLOOR_DIV_EXPR:
1625 case ROUND_DIV_EXPR:
1626 case TRUNC_MOD_EXPR:
1628 case FLOOR_MOD_EXPR:
1629 case ROUND_MOD_EXPR:
1631 case EXACT_DIV_EXPR:
1632 case FIX_TRUNC_EXPR:
1634 case FIX_FLOOR_EXPR:
1635 case FIX_ROUND_EXPR:
1650 case BIT_ANDTC_EXPR:
1652 case TRUTH_ANDIF_EXPR:
1653 case TRUTH_ORIF_EXPR:
1654 case TRUTH_AND_EXPR:
1656 case TRUTH_XOR_EXPR:
1657 case TRUTH_NOT_EXPR:
1673 return ffecom_overlap_ (dest_decl, dest_offset, dest_size,
1674 TREE_OPERAND (source_tree, 1), NULL,
1678 return ffecom_overlap_ (dest_decl, dest_offset, dest_size,
1679 TREE_OPERAND (source_tree, 0), NULL,
1684 case NON_LVALUE_EXPR:
1686 if (TREE_CODE (TREE_TYPE (source_tree)) != POINTER_TYPE)
1689 ffecom_tree_canonize_ptr_ (&source_decl, &source_offset,
1691 source_size = TYPE_SIZE (TREE_TYPE (TREE_TYPE (source_tree)));
1696 ffecom_overlap_ (dest_decl, dest_offset, dest_size,
1697 TREE_OPERAND (source_tree, 1), NULL,
1699 || ffecom_overlap_ (dest_decl, dest_offset, dest_size,
1700 TREE_OPERAND (source_tree, 2), NULL,
1705 ffecom_tree_canonize_ref_ (&source_decl, &source_offset,
1707 TREE_OPERAND (source_tree, 0));
1711 if (TREE_CODE (TREE_TYPE (source_tree)) != POINTER_TYPE)
1714 source_decl = source_tree;
1715 source_offset = size_zero_node;
1716 source_size = TYPE_SIZE (TREE_TYPE (TREE_TYPE (source_tree)));
1720 case REFERENCE_EXPR:
1721 case PREDECREMENT_EXPR:
1722 case PREINCREMENT_EXPR:
1723 case POSTDECREMENT_EXPR:
1724 case POSTINCREMENT_EXPR:
1732 /* Come here when source_decl, source_offset, and source_size filled
1733 in appropriately. */
1735 if (source_decl == NULL_TREE)
1736 return FALSE; /* No decl involved, so no overlap. */
1738 if (source_decl != dest_decl)
1739 return FALSE; /* Different decl, no overlap. */
1741 if (TREE_CODE (dest_size) == ERROR_MARK)
1742 return TRUE; /* Assignment into entire assumed-size
1743 array? Shouldn't happen.... */
1745 t = ffecom_2 (LE_EXPR, integer_type_node,
1746 ffecom_2 (PLUS_EXPR, TREE_TYPE (dest_offset),
1748 convert (TREE_TYPE (dest_offset),
1750 convert (TREE_TYPE (dest_offset),
1753 if (integer_onep (t))
1754 return FALSE; /* Destination precedes source. */
1757 || (source_size == NULL_TREE)
1758 || (TREE_CODE (source_size) == ERROR_MARK)
1759 || integer_zerop (source_size))
1760 return TRUE; /* No way to tell if dest follows source. */
1762 t = ffecom_2 (LE_EXPR, integer_type_node,
1763 ffecom_2 (PLUS_EXPR, TREE_TYPE (source_offset),
1765 convert (TREE_TYPE (source_offset),
1767 convert (TREE_TYPE (source_offset),
1770 if (integer_onep (t))
1771 return FALSE; /* Destination follows source. */
1773 return TRUE; /* Destination and source overlap. */
1777 /* Check whether dest might overlap any of a list of arguments or is
1778 in a COMMON area the callee might know about (and thus modify). */
1780 #if FFECOM_targetCURRENT == FFECOM_targetGCC
1782 ffecom_args_overlapping_ (tree dest_tree, ffebld dest UNUSED,
1783 tree args, tree callee_commons,
1791 ffecom_tree_canonize_ref_ (&dest_decl, &dest_offset, &dest_size,
1794 if (dest_decl == NULL_TREE)
1795 return FALSE; /* Seems unlikely! */
1797 /* If the decl cannot be determined reliably, or if its in COMMON
1798 and the callee isn't known to not futz with COMMON via other
1799 means, overlap might happen. */
1801 if ((TREE_CODE (dest_decl) == ERROR_MARK)
1802 || ((callee_commons != NULL_TREE)
1803 && TREE_PUBLIC (dest_decl)))
1806 for (; args != NULL_TREE; args = TREE_CHAIN (args))
1808 if (((arg = TREE_VALUE (args)) != NULL_TREE)
1809 && ffecom_overlap_ (dest_decl, dest_offset, dest_size,
1810 arg, NULL, scalar_args))
1818 /* Build a string for a variable name as used by NAMELIST. This means that
1819 if we're using the f2c library, we build an uppercase string, since
1822 #if FFECOM_targetCURRENT == FFECOM_targetGCC
1824 ffecom_build_f2c_string_ (int i, const char *s)
1826 if (!ffe_is_f2c_library ())
1827 return build_string (i, s);
1836 if (((size_t) i) > ARRAY_SIZE (space))
1837 tmp = malloc_new_ks (malloc_pool_image (), "f2c_string", i);
1841 for (p = s, q = tmp; *p != '\0'; ++p, ++q)
1842 *q = ffesrc_toupper (*p);
1845 t = build_string (i, tmp);
1847 if (((size_t) i) > ARRAY_SIZE (space))
1848 malloc_kill_ks (malloc_pool_image (), tmp, i);
1855 /* Returns CALL_EXPR or equivalent with given type (pass NULL_TREE for
1856 type to just get whatever the function returns), handling the
1857 f2c value-returning convention, if required, by prepending
1858 to the arglist a pointer to a temporary to receive the return value. */
1860 #if FFECOM_targetCURRENT == FFECOM_targetGCC
1862 ffecom_call_ (tree fn, ffeinfoKindtype kt, bool is_f2c_complex,
1863 tree type, tree args, tree dest_tree,
1864 ffebld dest, bool *dest_used, tree callee_commons,
1865 bool scalar_args, tree hook)
1870 if (dest_used != NULL)
1875 if ((dest_used == NULL)
1877 || (ffeinfo_basictype (ffebld_info (dest))
1878 != FFEINFO_basictypeCOMPLEX)
1879 || (ffeinfo_kindtype (ffebld_info (dest)) != kt)
1880 || ((type != NULL_TREE) && (TREE_TYPE (dest_tree) != type))
1881 || ffecom_args_overlapping_ (dest_tree, dest, args,
1886 tempvar = ffecom_make_tempvar (ffecom_tree_type
1887 [FFEINFO_basictypeCOMPLEX][kt],
1888 FFETARGET_charactersizeNONE,
1898 tempvar = dest_tree;
1903 = build_tree_list (NULL_TREE,
1904 ffecom_1 (ADDR_EXPR,
1905 build_pointer_type (TREE_TYPE (tempvar)),
1907 TREE_CHAIN (item) = args;
1909 item = ffecom_3s (CALL_EXPR, TREE_TYPE (TREE_TYPE (TREE_TYPE (fn))), fn,
1912 if (tempvar != dest_tree)
1913 item = ffecom_2 (COMPOUND_EXPR, TREE_TYPE (tempvar), item, tempvar);
1916 item = ffecom_3s (CALL_EXPR, TREE_TYPE (TREE_TYPE (TREE_TYPE (fn))), fn,
1919 if ((type != NULL_TREE) && (TREE_TYPE (item) != type))
1920 item = ffecom_convert_narrow_ (type, item);
1926 /* Given two arguments, transform them and make a call to the given
1927 function via ffecom_call_. */
1929 #if FFECOM_targetCURRENT == FFECOM_targetGCC
1931 ffecom_call_binop_ (tree fn, ffeinfoKindtype kt, bool is_f2c_complex,
1932 tree type, ffebld left, ffebld right,
1933 tree dest_tree, ffebld dest, bool *dest_used,
1934 tree callee_commons, bool scalar_args, tree hook)
1941 left_tree = ffecom_arg_ptr_to_expr (left, &left_length);
1942 right_tree = ffecom_arg_ptr_to_expr (right, &right_length);
1944 left_tree = build_tree_list (NULL_TREE, left_tree);
1945 right_tree = build_tree_list (NULL_TREE, right_tree);
1946 TREE_CHAIN (left_tree) = right_tree;
1948 if (left_length != NULL_TREE)
1950 left_length = build_tree_list (NULL_TREE, left_length);
1951 TREE_CHAIN (right_tree) = left_length;
1954 if (right_length != NULL_TREE)
1956 right_length = build_tree_list (NULL_TREE, right_length);
1957 if (left_length != NULL_TREE)
1958 TREE_CHAIN (left_length) = right_length;
1960 TREE_CHAIN (right_tree) = right_length;
1963 return ffecom_call_ (fn, kt, is_f2c_complex, type, left_tree,
1964 dest_tree, dest, dest_used, callee_commons,
1969 /* Return ptr/length args for char subexpression
1971 Handles CHARACTER-type CONTER, SYMTER, SUBSTR, ARRAYREF, and FUNCREF
1972 subexpressions by constructing the appropriate trees for the ptr-to-
1973 character-text and length-of-character-text arguments in a calling
1976 Note that if with_null is TRUE, and the expression is an opCONTER,
1977 a null byte is appended to the string. */
1979 #if FFECOM_targetCURRENT == FFECOM_targetGCC
1981 ffecom_char_args_x_ (tree *xitem, tree *length, ffebld expr, bool with_null)
1985 ffetargetCharacter1 val;
1986 ffetargetCharacterSize newlen;
1988 switch (ffebld_op (expr))
1990 case FFEBLD_opCONTER:
1991 val = ffebld_constant_character1 (ffebld_conter (expr));
1992 newlen = ffetarget_length_character1 (val);
1995 /* Begin FFETARGET-NULL-KLUDGE. */
1999 *length = build_int_2 (newlen, 0);
2000 TREE_TYPE (*length) = ffecom_f2c_ftnlen_type_node;
2001 high = build_int_2 (newlen, 0);
2002 TREE_TYPE (high) = ffecom_f2c_ftnlen_type_node;
2003 item = build_string (newlen,
2004 ffetarget_text_character1 (val));
2005 /* End FFETARGET-NULL-KLUDGE. */
2007 = build_type_variant
2011 (ffecom_f2c_ftnlen_type_node,
2012 ffecom_f2c_ftnlen_one_node,
2015 TREE_CONSTANT (item) = 1;
2016 TREE_STATIC (item) = 1;
2017 item = ffecom_1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (item)),
2021 case FFEBLD_opSYMTER:
2023 ffesymbol s = ffebld_symter (expr);
2025 item = ffesymbol_hook (s).decl_tree;
2026 if (item == NULL_TREE)
2028 s = ffecom_sym_transform_ (s);
2029 item = ffesymbol_hook (s).decl_tree;
2031 if (ffesymbol_kind (s) == FFEINFO_kindENTITY)
2033 if (ffesymbol_size (s) == FFETARGET_charactersizeNONE)
2034 *length = ffesymbol_hook (s).length_tree;
2037 *length = build_int_2 (ffesymbol_size (s), 0);
2038 TREE_TYPE (*length) = ffecom_f2c_ftnlen_type_node;
2041 else if (item == error_mark_node)
2042 *length = error_mark_node;
2044 /* FFEINFO_kindFUNCTION. */
2045 *length = NULL_TREE;
2046 if (!ffesymbol_hook (s).addr
2047 && (item != error_mark_node))
2048 item = ffecom_1 (ADDR_EXPR,
2049 build_pointer_type (TREE_TYPE (item)),
2054 case FFEBLD_opARRAYREF:
2056 ffecom_char_args_ (&item, length, ffebld_left (expr));
2058 if (item == error_mark_node || *length == error_mark_node)
2060 item = *length = error_mark_node;
2064 item = ffecom_arrayref_ (item, expr, 1);
2068 case FFEBLD_opSUBSTR:
2072 ffebld thing = ffebld_right (expr);
2079 assert (ffebld_op (thing) == FFEBLD_opITEM);
2080 start = ffebld_head (thing);
2081 thing = ffebld_trail (thing);
2082 assert (ffebld_trail (thing) == NULL);
2083 end = ffebld_head (thing);
2085 /* Determine name for pretty-printing range-check errors. */
2086 for (left_symter = ffebld_left (expr);
2087 left_symter && ffebld_op (left_symter) == FFEBLD_opARRAYREF;
2088 left_symter = ffebld_left (left_symter))
2090 if (ffebld_op (left_symter) == FFEBLD_opSYMTER)
2091 char_name = ffesymbol_text (ffebld_symter (left_symter));
2093 char_name = "[expr?]";
2095 ffecom_char_args_ (&item, length, ffebld_left (expr));
2097 if (item == error_mark_node || *length == error_mark_node)
2099 item = *length = error_mark_node;
2103 array = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (item)));
2105 /* ~~~~Handle INTEGER*8 start/end, a la FFEBLD_opARRAYREF. */
2113 end_tree = ffecom_expr (end);
2114 if (flag_bounds_check)
2115 end_tree = ffecom_subscript_check_ (array, end_tree, 1, 0,
2117 end_tree = convert (ffecom_f2c_ftnlen_type_node,
2120 if (end_tree == error_mark_node)
2122 item = *length = error_mark_node;
2131 start_tree = ffecom_expr (start);
2132 if (flag_bounds_check)
2133 start_tree = ffecom_subscript_check_ (array, start_tree, 0, 0,
2135 start_tree = convert (ffecom_f2c_ftnlen_type_node,
2138 if (start_tree == error_mark_node)
2140 item = *length = error_mark_node;
2144 start_tree = ffecom_save_tree (start_tree);
2146 item = ffecom_2 (PLUS_EXPR, TREE_TYPE (item),
2148 ffecom_2 (MINUS_EXPR,
2149 TREE_TYPE (start_tree),
2151 ffecom_f2c_ftnlen_one_node));
2155 *length = ffecom_2 (PLUS_EXPR, ffecom_f2c_ftnlen_type_node,
2156 ffecom_f2c_ftnlen_one_node,
2157 ffecom_2 (MINUS_EXPR,
2158 ffecom_f2c_ftnlen_type_node,
2164 end_tree = ffecom_expr (end);
2165 if (flag_bounds_check)
2166 end_tree = ffecom_subscript_check_ (array, end_tree, 1, 0,
2168 end_tree = convert (ffecom_f2c_ftnlen_type_node,
2171 if (end_tree == error_mark_node)
2173 item = *length = error_mark_node;
2177 *length = ffecom_2 (PLUS_EXPR, ffecom_f2c_ftnlen_type_node,
2178 ffecom_f2c_ftnlen_one_node,
2179 ffecom_2 (MINUS_EXPR,
2180 ffecom_f2c_ftnlen_type_node,
2181 end_tree, start_tree));
2187 case FFEBLD_opFUNCREF:
2189 ffesymbol s = ffebld_symter (ffebld_left (expr));
2192 ffetargetCharacterSize size = ffeinfo_size (ffebld_info (expr));
2195 if (size == FFETARGET_charactersizeNONE)
2196 /* ~~Kludge alert! This should someday be fixed. */
2199 *length = build_int_2 (size, 0);
2200 TREE_TYPE (*length) = ffecom_f2c_ftnlen_type_node;
2202 if (ffeinfo_where (ffebld_info (ffebld_left (expr)))
2203 == FFEINFO_whereINTRINSIC)
2207 /* Invocation of an intrinsic returning CHARACTER*1. */
2208 item = ffecom_expr_intrinsic_ (expr, NULL_TREE,
2212 ix = ffeintrin_gfrt_direct (ffebld_symter_implementation (ffebld_left (expr)));
2213 assert (ix != FFECOM_gfrt);
2214 item = ffecom_gfrt_tree_ (ix);
2219 item = ffesymbol_hook (s).decl_tree;
2220 if (item == NULL_TREE)
2222 s = ffecom_sym_transform_ (s);
2223 item = ffesymbol_hook (s).decl_tree;
2225 if (item == error_mark_node)
2227 item = *length = error_mark_node;
2231 if (!ffesymbol_hook (s).addr)
2232 item = ffecom_1_fn (item);
2236 tempvar = ffecom_push_tempvar (char_type_node, size, -1, TRUE);
2238 tempvar = ffebld_nonter_hook (expr);
2241 tempvar = ffecom_1 (ADDR_EXPR,
2242 build_pointer_type (TREE_TYPE (tempvar)),
2245 args = build_tree_list (NULL_TREE, tempvar);
2247 if (ffesymbol_where (s) == FFEINFO_whereCONSTANT) /* Sfunc args by value. */
2248 TREE_CHAIN (args) = ffecom_list_expr (ffebld_right (expr));
2251 TREE_CHAIN (args) = build_tree_list (NULL_TREE, *length);
2252 if (ffesymbol_where (s) == FFEINFO_whereINTRINSIC)
2254 TREE_CHAIN (TREE_CHAIN (args))
2255 = ffecom_arglist_expr_ (ffecom_gfrt_args_ (ix),
2256 ffebld_right (expr));
2260 TREE_CHAIN (TREE_CHAIN (args))
2261 = ffecom_list_ptr_to_expr (ffebld_right (expr));
2265 item = ffecom_3s (CALL_EXPR,
2266 TREE_TYPE (TREE_TYPE (TREE_TYPE (item))),
2267 item, args, NULL_TREE);
2268 item = ffecom_2 (COMPOUND_EXPR, TREE_TYPE (tempvar), item,
2273 case FFEBLD_opCONVERT:
2275 ffecom_char_args_ (&item, length, ffebld_left (expr));
2277 if (item == error_mark_node || *length == error_mark_node)
2279 item = *length = error_mark_node;
2283 if ((ffebld_size_known (ffebld_left (expr))
2284 == FFETARGET_charactersizeNONE)
2285 || (ffebld_size_known (ffebld_left (expr)) < (ffebld_size (expr))))
2286 { /* Possible blank-padding needed, copy into
2293 tempvar = ffecom_make_tempvar (char_type_node,
2294 ffebld_size (expr), -1);
2296 tempvar = ffebld_nonter_hook (expr);
2299 tempvar = ffecom_1 (ADDR_EXPR,
2300 build_pointer_type (TREE_TYPE (tempvar)),
2303 newlen = build_int_2 (ffebld_size (expr), 0);
2304 TREE_TYPE (newlen) = ffecom_f2c_ftnlen_type_node;
2306 args = build_tree_list (NULL_TREE, tempvar);
2307 TREE_CHAIN (args) = build_tree_list (NULL_TREE, item);
2308 TREE_CHAIN (TREE_CHAIN (args)) = build_tree_list (NULL_TREE, newlen);
2309 TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (args)))
2310 = build_tree_list (NULL_TREE, *length);
2312 item = ffecom_call_gfrt (FFECOM_gfrtCOPY, args, NULL_TREE);
2313 TREE_SIDE_EFFECTS (item) = 1;
2314 item = ffecom_2 (COMPOUND_EXPR, TREE_TYPE (tempvar), fold (item),
2319 { /* Just truncate the length. */
2320 *length = build_int_2 (ffebld_size (expr), 0);
2321 TREE_TYPE (*length) = ffecom_f2c_ftnlen_type_node;
2326 assert ("bad op for single char arg expr" == NULL);
2335 /* Check the size of the type to be sure it doesn't overflow the
2336 "portable" capacities of the compiler back end. `dummy' types
2337 can generally overflow the normal sizes as long as the computations
2338 themselves don't overflow. A particular target of the back end
2339 must still enforce its size requirements, though, and the back
2340 end takes care of this in stor-layout.c. */
2342 #if FFECOM_targetCURRENT == FFECOM_targetGCC
2344 ffecom_check_size_overflow_ (ffesymbol s, tree type, bool dummy)
2346 if (TREE_CODE (type) == ERROR_MARK)
2349 if (TYPE_SIZE (type) == NULL_TREE)
2352 if (TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
2355 if ((tree_int_cst_sgn (TYPE_SIZE (type)) < 0)
2356 || (!dummy && (((TREE_INT_CST_HIGH (TYPE_SIZE (type)) != 0))
2357 || TREE_OVERFLOW (TYPE_SIZE (type)))))
2359 ffebad_start (FFEBAD_ARRAY_LARGE);
2360 ffebad_string (ffesymbol_text (s));
2361 ffebad_here (0, ffesymbol_where_line (s), ffesymbol_where_column (s));
2364 return error_mark_node;
2371 /* Builds a length argument (PARM_DECL). Also wraps type in an array type
2372 where the dimension info is (1:size) where <size> is ffesymbol_size(s) if
2373 known, length_arg if not known (FFETARGET_charactersizeNONE). */
2375 #if FFECOM_targetCURRENT == FFECOM_targetGCC
2377 ffecom_char_enhance_arg_ (tree *xtype, ffesymbol s)
2379 ffetargetCharacterSize sz = ffesymbol_size (s);
2384 if (ffesymbol_where (s) == FFEINFO_whereCONSTANT)
2385 tlen = NULL_TREE; /* A statement function, no length passed. */
2388 if (ffesymbol_where (s) == FFEINFO_whereDUMMY)
2389 tlen = ffecom_get_invented_identifier ("__g77_length_%s",
2390 ffesymbol_text (s));
2392 tlen = ffecom_get_invented_identifier ("__g77_%s", "length");
2393 tlen = build_decl (PARM_DECL, tlen, ffecom_f2c_ftnlen_type_node);
2395 DECL_ARTIFICIAL (tlen) = 1;
2399 if (sz == FFETARGET_charactersizeNONE)
2401 assert (tlen != NULL_TREE);
2402 highval = variable_size (tlen);
2406 highval = build_int_2 (sz, 0);
2407 TREE_TYPE (highval) = ffecom_f2c_ftnlen_type_node;
2410 type = build_array_type (type,
2411 build_range_type (ffecom_f2c_ftnlen_type_node,
2412 ffecom_f2c_ftnlen_one_node,
2420 /* ffecom_concat_list_gather_ -- Gather list of concatenated string exprs
2422 ffecomConcatList_ catlist;
2423 ffebld expr; // expr of CHARACTER basictype.
2424 ffetargetCharacterSize max; // max chars to gather or _...NONE if no max
2425 catlist = ffecom_concat_list_gather_(catlist,expr,max);
2427 Scans expr for character subexpressions, updates and returns catlist
2430 #if FFECOM_targetCURRENT == FFECOM_targetGCC
2431 static ffecomConcatList_
2432 ffecom_concat_list_gather_ (ffecomConcatList_ catlist, ffebld expr,
2433 ffetargetCharacterSize max)
2435 ffetargetCharacterSize sz;
2437 recurse: /* :::::::::::::::::::: */
2442 if ((max != FFETARGET_charactersizeNONE) && (catlist.minlen >= max))
2443 return catlist; /* Don't append any more items. */
2445 switch (ffebld_op (expr))
2447 case FFEBLD_opCONTER:
2448 case FFEBLD_opSYMTER:
2449 case FFEBLD_opARRAYREF:
2450 case FFEBLD_opFUNCREF:
2451 case FFEBLD_opSUBSTR:
2452 case FFEBLD_opCONVERT: /* Callers should strip this off beforehand
2453 if they don't need to preserve it. */
2454 if (catlist.count == catlist.max)
2455 { /* Make a (larger) list. */
2459 newmax = (catlist.max == 0) ? 8 : catlist.max * 2;
2460 newx = malloc_new_ks (malloc_pool_image (), "catlist",
2461 newmax * sizeof (newx[0]));
2462 if (catlist.max != 0)
2464 memcpy (newx, catlist.exprs, catlist.max * sizeof (newx[0]));
2465 malloc_kill_ks (malloc_pool_image (), catlist.exprs,
2466 catlist.max * sizeof (newx[0]));
2468 catlist.max = newmax;
2469 catlist.exprs = newx;
2471 if ((sz = ffebld_size_known (expr)) != FFETARGET_charactersizeNONE)
2472 catlist.minlen += sz;
2474 ++catlist.minlen; /* Not true for F90; can be 0 length. */
2475 if ((sz = ffebld_size_max (expr)) == FFETARGET_charactersizeNONE)
2476 catlist.maxlen = sz;
2478 catlist.maxlen += sz;
2479 if ((max != FFETARGET_charactersizeNONE) && (catlist.minlen > max))
2480 { /* This item overlaps (or is beyond) the end
2481 of the destination. */
2482 switch (ffebld_op (expr))
2484 case FFEBLD_opCONTER:
2485 case FFEBLD_opSYMTER:
2486 case FFEBLD_opARRAYREF:
2487 case FFEBLD_opFUNCREF:
2488 case FFEBLD_opSUBSTR:
2489 /* ~~Do useful truncations here. */
2493 assert ("op changed or inconsistent switches!" == NULL);
2497 catlist.exprs[catlist.count++] = expr;
2500 case FFEBLD_opPAREN:
2501 expr = ffebld_left (expr);
2502 goto recurse; /* :::::::::::::::::::: */
2504 case FFEBLD_opCONCATENATE:
2505 catlist = ffecom_concat_list_gather_ (catlist, ffebld_left (expr), max);
2506 expr = ffebld_right (expr);
2507 goto recurse; /* :::::::::::::::::::: */
2509 #if 0 /* Breaks passing small actual arg to larger
2510 dummy arg of sfunc */
2511 case FFEBLD_opCONVERT:
2512 expr = ffebld_left (expr);
2514 ffetargetCharacterSize cmax;
2516 cmax = catlist.len + ffebld_size_known (expr);
2518 if ((max == FFETARGET_charactersizeNONE) || (max > cmax))
2521 goto recurse; /* :::::::::::::::::::: */
2528 assert ("bad op in _gather_" == NULL);
2534 /* ffecom_concat_list_kill_ -- Kill list of concatenated string exprs
2536 ffecomConcatList_ catlist;
2537 ffecom_concat_list_kill_(catlist);
2539 Anything allocated within the list info is deallocated. */
2541 #if FFECOM_targetCURRENT == FFECOM_targetGCC
2543 ffecom_concat_list_kill_ (ffecomConcatList_ catlist)
2545 if (catlist.max != 0)
2546 malloc_kill_ks (malloc_pool_image (), catlist.exprs,
2547 catlist.max * sizeof (catlist.exprs[0]));
2551 /* Make list of concatenated string exprs.
2553 Returns a flattened list of concatenated subexpressions given a
2554 tree of such expressions. */
2556 #if FFECOM_targetCURRENT == FFECOM_targetGCC
2557 static ffecomConcatList_
2558 ffecom_concat_list_new_ (ffebld expr, ffetargetCharacterSize max)
2560 ffecomConcatList_ catlist;
2562 catlist.maxlen = catlist.minlen = catlist.max = catlist.count = 0;
2563 return ffecom_concat_list_gather_ (catlist, expr, max);
2568 /* Provide some kind of useful info on member of aggregate area,
2569 since current g77/gcc technology does not provide debug info
2570 on these members. */
2572 #if FFECOM_targetCURRENT == FFECOM_targetGCC
2574 ffecom_debug_kludge_ (tree aggr, const char *aggr_type, ffesymbol member,
2575 tree member_type UNUSED, ffetargetOffset offset)
2585 for (type_id = member_type;
2586 TREE_CODE (type_id) != IDENTIFIER_NODE;
2589 switch (TREE_CODE (type_id))
2593 type_id = TYPE_NAME (type_id);
2598 type_id = TREE_TYPE (type_id);
2602 assert ("no IDENTIFIER_NODE for type!" == NULL);
2603 type_id = error_mark_node;
2609 if (ffecom_transform_only_dummies_
2610 || !ffe_is_debug_kludge ())
2611 return; /* Can't do this yet, maybe later. */
2614 + strlen (aggr_type)
2615 + IDENTIFIER_LENGTH (DECL_NAME (aggr));
2617 + IDENTIFIER_LENGTH (type_id);
2620 if (((size_t) len) >= ARRAY_SIZE (space))
2621 buff = malloc_new_ks (malloc_pool_image (), "debug_kludge", len + 1);
2625 sprintf (&buff[0], "At (%s) `%s' plus %ld bytes",
2627 IDENTIFIER_POINTER (DECL_NAME (aggr)),
2630 value = build_string (len, buff);
2632 = build_type_variant (build_array_type (char_type_node,
2636 build_int_2 (strlen (buff), 0))),
2638 decl = build_decl (VAR_DECL,
2639 ffecom_get_identifier_ (ffesymbol_text (member)),
2641 TREE_CONSTANT (decl) = 1;
2642 TREE_STATIC (decl) = 1;
2643 DECL_INITIAL (decl) = error_mark_node;
2644 DECL_IN_SYSTEM_HEADER (decl) = 1; /* Don't let -Wunused complain. */
2645 decl = start_decl (decl, FALSE);
2646 finish_decl (decl, value, FALSE);
2648 if (buff != &space[0])
2649 malloc_kill_ks (malloc_pool_image (), buff, len + 1);
2653 /* ffecom_do_entry_ -- Do compilation of a particular entrypoint
2655 ffesymbol fn; // the SUBROUTINE, FUNCTION, or ENTRY symbol itself
2656 int i; // entry# for this entrypoint (used by master fn)
2657 ffecom_do_entrypoint_(s,i);
2659 Makes a public entry point that calls our private master fn (already
2662 #if FFECOM_targetCURRENT == FFECOM_targetGCC
2664 ffecom_do_entry_ (ffesymbol fn, int entrynum)
2667 tree type; /* Type of function. */
2668 tree multi_retval; /* Var holding return value (union). */
2669 tree result; /* Var holding result. */
2670 ffeinfoBasictype bt;
2674 bool charfunc; /* All entry points return same type
2676 bool cmplxfunc; /* Use f2c way of returning COMPLEX. */
2677 bool multi; /* Master fn has multiple return types. */
2678 bool altreturning = FALSE; /* This entry point has alternate returns. */
2680 int old_lineno = lineno;
2681 char *old_input_filename = input_filename;
2683 input_filename = ffesymbol_where_filename (fn);
2684 lineno = ffesymbol_where_filelinenum (fn);
2686 /* c-parse.y indeed does call suspend_momentary and not only ignores the
2687 return value, but also never calls resume_momentary, when starting an
2688 outer function (see "fndef:", "setspecs:", and so on). So g77 does the
2689 same thing. It shouldn't be a problem since start_function calls
2690 temporary_allocation, but it might be necessary. If it causes a problem
2691 here, then maybe there's a bug lurking in gcc. NOTE: This identical
2692 comment appears twice in thist file. */
2694 suspend_momentary ();
2696 ffecom_doing_entry_ = TRUE; /* Don't bother with array dimensions. */
2698 switch (ffecom_primary_entry_kind_)
2700 case FFEINFO_kindFUNCTION:
2702 /* Determine actual return type for function. */
2704 gt = FFEGLOBAL_typeFUNC;
2705 bt = ffesymbol_basictype (fn);
2706 kt = ffesymbol_kindtype (fn);
2707 if (bt == FFEINFO_basictypeNONE)
2709 ffeimplic_establish_symbol (fn);
2710 if (ffesymbol_funcresult (fn) != NULL)
2711 ffeimplic_establish_symbol (ffesymbol_funcresult (fn));
2712 bt = ffesymbol_basictype (fn);
2713 kt = ffesymbol_kindtype (fn);
2716 if (bt == FFEINFO_basictypeCHARACTER)
2717 charfunc = TRUE, cmplxfunc = FALSE;
2718 else if ((bt == FFEINFO_basictypeCOMPLEX)
2719 && ffesymbol_is_f2c (fn))
2720 charfunc = FALSE, cmplxfunc = TRUE;
2722 charfunc = cmplxfunc = FALSE;
2725 type = ffecom_tree_fun_type_void;
2726 else if (ffesymbol_is_f2c (fn))
2727 type = ffecom_tree_fun_type[bt][kt];
2729 type = build_function_type (ffecom_tree_type[bt][kt], NULL_TREE);
2731 if ((type == NULL_TREE)
2732 || (TREE_TYPE (type) == NULL_TREE))
2733 type = ffecom_tree_fun_type_void; /* _sym_exec_transition. */
2735 multi = (ffecom_master_bt_ == FFEINFO_basictypeNONE);
2738 case FFEINFO_kindSUBROUTINE:
2739 gt = FFEGLOBAL_typeSUBR;
2740 bt = FFEINFO_basictypeNONE;
2741 kt = FFEINFO_kindtypeNONE;
2742 if (ffecom_is_altreturning_)
2743 { /* Am _I_ altreturning? */
2744 for (item = ffesymbol_dummyargs (fn);
2746 item = ffebld_trail (item))
2748 if (ffebld_op (ffebld_head (item)) == FFEBLD_opSTAR)
2750 altreturning = TRUE;
2755 type = ffecom_tree_subr_type;
2757 type = ffecom_tree_fun_type_void;
2760 type = ffecom_tree_fun_type_void;
2767 assert ("say what??" == NULL);
2769 case FFEINFO_kindANY:
2770 gt = FFEGLOBAL_typeANY;
2771 bt = FFEINFO_basictypeNONE;
2772 kt = FFEINFO_kindtypeNONE;
2773 type = error_mark_node;
2780 /* build_decl uses the current lineno and input_filename to set the decl
2781 source info. So, I've putzed with ffestd and ffeste code to update that
2782 source info to point to the appropriate statement just before calling
2783 ffecom_do_entrypoint (which calls this fn). */
2785 start_function (ffecom_get_external_identifier_ (fn),
2787 0, /* nested/inline */
2788 1); /* TREE_PUBLIC */
2790 if (((g = ffesymbol_global (fn)) != NULL)
2791 && ((ffeglobal_type (g) == gt)
2792 || (ffeglobal_type (g) == FFEGLOBAL_typeEXT)))
2794 ffeglobal_set_hook (g, current_function_decl);
2797 /* Reset args in master arg list so they get retransitioned. */
2799 for (item = ffecom_master_arglist_;
2801 item = ffebld_trail (item))
2806 arg = ffebld_head (item);
2807 if (ffebld_op (arg) != FFEBLD_opSYMTER)
2808 continue; /* Alternate return or some such thing. */
2809 s = ffebld_symter (arg);
2810 ffesymbol_hook (s).decl_tree = NULL_TREE;
2811 ffesymbol_hook (s).length_tree = NULL_TREE;
2814 /* Build dummy arg list for this entry point. */
2816 yes = suspend_momentary ();
2818 if (charfunc || cmplxfunc)
2819 { /* Prepend arg for where result goes. */
2824 type = ffecom_tree_type[FFEINFO_basictypeCHARACTER][kt];
2826 type = ffecom_tree_type[FFEINFO_basictypeCOMPLEX][kt];
2828 result = ffecom_get_invented_identifier ("__g77_%s", "result");
2830 /* Make length arg _and_ enhance type info for CHAR arg itself. */
2833 length = ffecom_char_enhance_arg_ (&type, fn);
2835 length = NULL_TREE; /* Not ref'd if !charfunc. */
2837 type = build_pointer_type (type);
2838 result = build_decl (PARM_DECL, result, type);
2840 push_parm_decl (result);
2841 ffecom_func_result_ = result;
2845 push_parm_decl (length);
2846 ffecom_func_length_ = length;
2850 result = DECL_RESULT (current_function_decl);
2852 ffecom_push_dummy_decls_ (ffesymbol_dummyargs (fn), FALSE);
2854 resume_momentary (yes);
2856 store_parm_decls (0);
2858 ffecom_start_compstmt ();
2859 /* Disallow temp vars at this level. */
2860 current_binding_level->prep_state = 2;
2862 /* Make local var to hold return type for multi-type master fn. */
2866 yes = suspend_momentary ();
2868 multi_retval = ffecom_get_invented_identifier ("__g77_%s",
2870 multi_retval = build_decl (VAR_DECL, multi_retval,
2871 ffecom_multi_type_node_);
2872 multi_retval = start_decl (multi_retval, FALSE);
2873 finish_decl (multi_retval, NULL_TREE, FALSE);
2875 resume_momentary (yes);
2878 multi_retval = NULL_TREE; /* Not actually ref'd if !multi. */
2880 /* Here we emit the actual code for the entry point. */
2886 tree arglist = NULL_TREE;
2887 tree *plist = &arglist;
2893 /* Prepare actual arg list based on master arg list. */
2895 for (list = ffecom_master_arglist_;
2897 list = ffebld_trail (list))
2899 arg = ffebld_head (list);
2900 if (ffebld_op (arg) != FFEBLD_opSYMTER)
2902 s = ffebld_symter (arg);
2903 if (ffesymbol_hook (s).decl_tree == NULL_TREE
2904 || ffesymbol_hook (s).decl_tree == error_mark_node)
2905 actarg = null_pointer_node; /* We don't have this arg. */
2907 actarg = ffesymbol_hook (s).decl_tree;
2908 *plist = build_tree_list (NULL_TREE, actarg);
2909 plist = &TREE_CHAIN (*plist);
2912 /* This code appends the length arguments for character
2913 variables/arrays. */
2915 for (list = ffecom_master_arglist_;
2917 list = ffebld_trail (list))
2919 arg = ffebld_head (list);
2920 if (ffebld_op (arg) != FFEBLD_opSYMTER)
2922 s = ffebld_symter (arg);
2923 if (ffesymbol_basictype (s) != FFEINFO_basictypeCHARACTER)
2924 continue; /* Only looking for CHARACTER arguments. */
2925 if (ffesymbol_kind (s) != FFEINFO_kindENTITY)
2926 continue; /* Only looking for variables and arrays. */
2927 if (ffesymbol_hook (s).length_tree == NULL_TREE
2928 || ffesymbol_hook (s).length_tree == error_mark_node)
2929 actarg = ffecom_f2c_ftnlen_zero_node; /* We don't have this arg. */
2931 actarg = ffesymbol_hook (s).length_tree;
2932 *plist = build_tree_list (NULL_TREE, actarg);
2933 plist = &TREE_CHAIN (*plist);
2936 /* Prepend character-value return info to actual arg list. */
2940 prepend = build_tree_list (NULL_TREE, ffecom_func_result_);
2941 TREE_CHAIN (prepend)
2942 = build_tree_list (NULL_TREE, ffecom_func_length_);
2943 TREE_CHAIN (TREE_CHAIN (prepend)) = arglist;
2947 /* Prepend multi-type return value to actual arg list. */
2952 = build_tree_list (NULL_TREE,
2953 ffecom_1 (ADDR_EXPR,
2954 build_pointer_type (TREE_TYPE (multi_retval)),
2956 TREE_CHAIN (prepend) = arglist;
2960 /* Prepend my entry-point number to the actual arg list. */
2962 prepend = build_tree_list (NULL_TREE, build_int_2 (entrynum, 0));
2963 TREE_CHAIN (prepend) = arglist;
2966 /* Build the call to the master function. */
2968 master_fn = ffecom_1_fn (ffecom_previous_function_decl_);
2969 call = ffecom_3s (CALL_EXPR,
2970 TREE_TYPE (TREE_TYPE (TREE_TYPE (master_fn))),
2971 master_fn, arglist, NULL_TREE);
2973 /* Decide whether the master function is a function or subroutine, and
2974 handle the return value for my entry point. */
2976 if (charfunc || ((ffecom_primary_entry_kind_ == FFEINFO_kindSUBROUTINE)
2979 expand_expr_stmt (call);
2980 expand_null_return ();
2982 else if (multi && cmplxfunc)
2984 expand_expr_stmt (call);
2986 = ffecom_1 (INDIRECT_REF,
2987 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (result))),
2989 result = ffecom_modify (NULL_TREE, result,
2990 ffecom_2 (COMPONENT_REF, TREE_TYPE (result),
2992 ffecom_multi_fields_[bt][kt]));
2993 expand_expr_stmt (result);
2994 expand_null_return ();
2998 expand_expr_stmt (call);
3000 = ffecom_modify (NULL_TREE, result,
3001 convert (TREE_TYPE (result),
3002 ffecom_2 (COMPONENT_REF,
3003 ffecom_tree_type[bt][kt],
3005 ffecom_multi_fields_[bt][kt])));
3006 expand_return (result);
3011 = ffecom_1 (INDIRECT_REF,
3012 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (result))),
3014 result = ffecom_modify (NULL_TREE, result, call);
3015 expand_expr_stmt (result);
3016 expand_null_return ();
3020 result = ffecom_modify (NULL_TREE,
3022 convert (TREE_TYPE (result),
3024 expand_return (result);
3030 ffecom_end_compstmt ();
3032 finish_function (0);
3034 lineno = old_lineno;
3035 input_filename = old_input_filename;
3037 ffecom_doing_entry_ = FALSE;
3041 /* Transform expr into gcc tree with possible destination
3043 Recursive descent on expr while making corresponding tree nodes and
3044 attaching type info and such. If destination supplied and compatible
3045 with temporary that would be made in certain cases, temporary isn't
3046 made, destination used instead, and dest_used flag set TRUE. */
3048 #if FFECOM_targetCURRENT == FFECOM_targetGCC
3050 ffecom_expr_ (ffebld expr, tree dest_tree, ffebld dest,
3051 bool *dest_used, bool assignp, bool widenp)
3056 ffeinfoBasictype bt;
3059 tree dt; /* decl_tree for an ffesymbol. */
3060 tree tree_type, tree_type_x;
3063 enum tree_code code;
3065 assert (expr != NULL);
3067 if (dest_used != NULL)
3070 bt = ffeinfo_basictype (ffebld_info (expr));
3071 kt = ffeinfo_kindtype (ffebld_info (expr));
3072 tree_type = ffecom_tree_type[bt][kt];
3074 /* Widen integral arithmetic as desired while preserving signedness. */
3075 tree_type_x = NULL_TREE;
3076 if (widenp && tree_type
3077 && GET_MODE_CLASS (TYPE_MODE (tree_type)) == MODE_INT
3078 && TYPE_PRECISION (tree_type) < TYPE_PRECISION (sizetype))
3079 tree_type_x = (TREE_UNSIGNED (tree_type) ? usizetype : ssizetype);
3081 switch (ffebld_op (expr))
3083 case FFEBLD_opACCTER:
3086 ffebit bits = ffebld_accter_bits (expr);
3087 ffetargetOffset source_offset = 0;
3088 ffetargetOffset dest_offset = ffebld_accter_pad (expr);
3091 assert (dest_offset == 0
3092 || (bt == FFEINFO_basictypeCHARACTER
3093 && kt == FFEINFO_kindtypeCHARACTER1));
3098 ffebldConstantUnion cu;
3101 ffebldConstantArray ca = ffebld_accter (expr);
3103 ffebit_test (bits, source_offset, &value, &length);
3109 for (i = 0; i < length; ++i)
3111 cu = ffebld_constantarray_get (ca, bt, kt,
3114 t = ffecom_constantunion (&cu, bt, kt, tree_type);
3117 && dest_offset != 0)
3118 purpose = build_int_2 (dest_offset, 0);
3120 purpose = NULL_TREE;
3122 if (list == NULL_TREE)
3123 list = item = build_tree_list (purpose, t);
3126 TREE_CHAIN (item) = build_tree_list (purpose, t);
3127 item = TREE_CHAIN (item);
3131 source_offset += length;
3132 dest_offset += length;
3136 item = build_int_2 ((ffebld_accter_size (expr)
3137 + ffebld_accter_pad (expr)) - 1, 0);
3138 ffebit_kill (ffebld_accter_bits (expr));
3139 TREE_TYPE (item) = ffecom_integer_type_node;
3143 build_range_type (ffecom_integer_type_node,
3144 ffecom_integer_zero_node,
3146 list = build (CONSTRUCTOR, item, NULL_TREE, list);
3147 TREE_CONSTANT (list) = 1;
3148 TREE_STATIC (list) = 1;
3151 case FFEBLD_opARRTER:
3156 if (ffebld_arrter_pad (expr) == 0)
3160 assert (bt == FFEINFO_basictypeCHARACTER
3161 && kt == FFEINFO_kindtypeCHARACTER1);
3163 /* Becomes PURPOSE first time through loop. */
3164 item = build_int_2 (ffebld_arrter_pad (expr), 0);
3167 for (i = 0; i < ffebld_arrter_size (expr); ++i)
3169 ffebldConstantUnion cu
3170 = ffebld_constantarray_get (ffebld_arrter (expr), bt, kt, i);
3172 t = ffecom_constantunion (&cu, bt, kt, tree_type);
3174 if (list == NULL_TREE)
3175 /* Assume item is PURPOSE first time through loop. */
3176 list = item = build_tree_list (item, t);
3179 TREE_CHAIN (item) = build_tree_list (NULL_TREE, t);
3180 item = TREE_CHAIN (item);
3185 item = build_int_2 ((ffebld_arrter_size (expr)
3186 + ffebld_arrter_pad (expr)) - 1, 0);
3187 TREE_TYPE (item) = ffecom_integer_type_node;
3191 build_range_type (ffecom_integer_type_node,
3192 ffecom_integer_zero_node,
3194 list = build (CONSTRUCTOR, item, NULL_TREE, list);
3195 TREE_CONSTANT (list) = 1;
3196 TREE_STATIC (list) = 1;
3199 case FFEBLD_opCONTER:
3200 assert (ffebld_conter_pad (expr) == 0);
3202 = ffecom_constantunion (&ffebld_constant_union (ffebld_conter (expr)),
3206 case FFEBLD_opSYMTER:
3207 if ((ffebld_symter_generic (expr) != FFEINTRIN_genNONE)
3208 || (ffebld_symter_specific (expr) != FFEINTRIN_specNONE))
3209 return ffecom_ptr_to_expr (expr); /* Same as %REF(intrinsic). */
3210 s = ffebld_symter (expr);
3211 t = ffesymbol_hook (s).decl_tree;
3214 { /* ASSIGN'ed-label expr. */
3215 if (ffe_is_ugly_assign ())
3217 /* User explicitly wants ASSIGN'ed variables to be at the same
3218 memory address as the variables when used in non-ASSIGN
3219 contexts. That can make old, arcane, non-standard code
3220 work, but don't try to do it when a pointer wouldn't fit
3221 in the normal variable (take other approach, and warn,
3226 s = ffecom_sym_transform_ (s);
3227 t = ffesymbol_hook (s).decl_tree;
3228 assert (t != NULL_TREE);
3231 if (t == error_mark_node)
3234 if (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (t)))
3235 >= GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (null_pointer_node))))
3237 if (ffesymbol_hook (s).addr)
3238 t = ffecom_1 (INDIRECT_REF,
3239 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (t))), t);
3243 if (ffesymbol_hook (s).assign_tree == NULL_TREE)
3245 ffebad_start_msg ("ASSIGN'ed label cannot fit into `%A' at %0 -- using wider sibling",
3246 FFEBAD_severityWARNING);
3247 ffebad_string (ffesymbol_text (s));
3248 ffebad_here (0, ffesymbol_where_line (s),
3249 ffesymbol_where_column (s));
3254 /* Don't use the normal variable's tree for ASSIGN, though mark
3255 it as in the system header (housekeeping). Use an explicit,
3256 specially created sibling that is known to be wide enough
3257 to hold pointers to labels. */
3260 && TREE_CODE (t) == VAR_DECL)
3261 DECL_IN_SYSTEM_HEADER (t) = 1; /* Don't let -Wunused complain. */
3263 t = ffesymbol_hook (s).assign_tree;
3266 s = ffecom_sym_transform_assign_ (s);
3267 t = ffesymbol_hook (s).assign_tree;
3268 assert (t != NULL_TREE);
3275 s = ffecom_sym_transform_ (s);
3276 t = ffesymbol_hook (s).decl_tree;
3277 assert (t != NULL_TREE);
3279 if (ffesymbol_hook (s).addr)
3280 t = ffecom_1 (INDIRECT_REF,
3281 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (t))), t);
3285 case FFEBLD_opARRAYREF:
3286 return ffecom_arrayref_ (NULL_TREE, expr, 0);
3288 case FFEBLD_opUPLUS:
3289 left = ffecom_expr_ (ffebld_left (expr), NULL, NULL, NULL, FALSE, widenp);
3290 return ffecom_1 (NOP_EXPR, tree_type, left);
3292 case FFEBLD_opPAREN:
3293 /* ~~~Make sure Fortran rules respected here */
3294 left = ffecom_expr_ (ffebld_left (expr), NULL, NULL, NULL, FALSE, widenp);
3295 return ffecom_1 (NOP_EXPR, tree_type, left);
3297 case FFEBLD_opUMINUS:
3298 left = ffecom_expr_ (ffebld_left (expr), NULL, NULL, NULL, FALSE, widenp);
3301 tree_type = tree_type_x;
3302 left = convert (tree_type, left);
3304 return ffecom_1 (NEGATE_EXPR, tree_type, left);
3307 left = ffecom_expr_ (ffebld_left (expr), NULL, NULL, NULL, FALSE, widenp);
3308 right = ffecom_expr_ (ffebld_right (expr), NULL, NULL, NULL, FALSE, widenp);
3311 tree_type = tree_type_x;
3312 left = convert (tree_type, left);
3313 right = convert (tree_type, right);
3315 return ffecom_2 (PLUS_EXPR, tree_type, left, right);
3317 case FFEBLD_opSUBTRACT:
3318 left = ffecom_expr_ (ffebld_left (expr), NULL, NULL, NULL, FALSE, widenp);
3319 right = ffecom_expr_ (ffebld_right (expr), NULL, NULL, NULL, FALSE, widenp);
3322 tree_type = tree_type_x;
3323 left = convert (tree_type, left);
3324 right = convert (tree_type, right);
3326 return ffecom_2 (MINUS_EXPR, tree_type, left, right);
3328 case FFEBLD_opMULTIPLY:
3329 left = ffecom_expr_ (ffebld_left (expr), NULL, NULL, NULL, FALSE, widenp);
3330 right = ffecom_expr_ (ffebld_right (expr), NULL, NULL, NULL, FALSE, widenp);
3333 tree_type = tree_type_x;
3334 left = convert (tree_type, left);
3335 right = convert (tree_type, right);
3337 return ffecom_2 (MULT_EXPR, tree_type, left, right);
3339 case FFEBLD_opDIVIDE:
3340 left = ffecom_expr_ (ffebld_left (expr), NULL, NULL, NULL, FALSE, widenp);
3341 right = ffecom_expr_ (ffebld_right (expr), NULL, NULL, NULL, FALSE, widenp);
3344 tree_type = tree_type_x;
3345 left = convert (tree_type, left);
3346 right = convert (tree_type, right);
3348 return ffecom_tree_divide_ (tree_type, left, right,
3349 dest_tree, dest, dest_used,
3350 ffebld_nonter_hook (expr));
3352 case FFEBLD_opPOWER:
3354 ffebld left = ffebld_left (expr);
3355 ffebld right = ffebld_right (expr);
3357 ffeinfoKindtype rtkt;
3358 ffeinfoKindtype ltkt;
3360 switch (ffeinfo_basictype (ffebld_info (right)))
3362 case FFEINFO_basictypeINTEGER:
3365 item = ffecom_expr_power_integer_ (expr);
3366 if (item != NULL_TREE)
3370 rtkt = FFEINFO_kindtypeINTEGER1;
3371 switch (ffeinfo_basictype (ffebld_info (left)))
3373 case FFEINFO_basictypeINTEGER:
3374 if ((ffeinfo_kindtype (ffebld_info (left))
3375 == FFEINFO_kindtypeINTEGER4)
3376 || (ffeinfo_kindtype (ffebld_info (right))
3377 == FFEINFO_kindtypeINTEGER4))
3379 code = FFECOM_gfrtPOW_QQ;
3380 ltkt = FFEINFO_kindtypeINTEGER4;
3381 rtkt = FFEINFO_kindtypeINTEGER4;
3385 code = FFECOM_gfrtPOW_II;
3386 ltkt = FFEINFO_kindtypeINTEGER1;
3390 case FFEINFO_basictypeREAL:
3391 if (ffeinfo_kindtype (ffebld_info (left))
3392 == FFEINFO_kindtypeREAL1)
3394 code = FFECOM_gfrtPOW_RI;
3395 ltkt = FFEINFO_kindtypeREAL1;
3399 code = FFECOM_gfrtPOW_DI;
3400 ltkt = FFEINFO_kindtypeREAL2;
3404 case FFEINFO_basictypeCOMPLEX:
3405 if (ffeinfo_kindtype (ffebld_info (left))
3406 == FFEINFO_kindtypeREAL1)
3408 code = FFECOM_gfrtPOW_CI; /* Overlapping result okay. */
3409 ltkt = FFEINFO_kindtypeREAL1;
3413 code = FFECOM_gfrtPOW_ZI; /* Overlapping result okay. */
3414 ltkt = FFEINFO_kindtypeREAL2;
3419 assert ("bad pow_*i" == NULL);
3420 code = FFECOM_gfrtPOW_CI; /* Overlapping result okay. */
3421 ltkt = FFEINFO_kindtypeREAL1;
3424 if (ffeinfo_kindtype (ffebld_info (left)) != ltkt)
3425 left = ffeexpr_convert (left, NULL, NULL,
3426 ffeinfo_basictype (ffebld_info (left)),
3428 FFETARGET_charactersizeNONE,
3429 FFEEXPR_contextLET);
3430 if (ffeinfo_kindtype (ffebld_info (right)) != rtkt)
3431 right = ffeexpr_convert (right, NULL, NULL,
3432 FFEINFO_basictypeINTEGER,
3434 FFETARGET_charactersizeNONE,
3435 FFEEXPR_contextLET);
3438 case FFEINFO_basictypeREAL:
3439 if (ffeinfo_kindtype (ffebld_info (left)) == FFEINFO_kindtypeREAL1)
3440 left = ffeexpr_convert (left, NULL, NULL, FFEINFO_basictypeREAL,
3441 FFEINFO_kindtypeREALDOUBLE, 0,
3442 FFETARGET_charactersizeNONE,
3443 FFEEXPR_contextLET);
3444 if (ffeinfo_kindtype (ffebld_info (right))
3445 == FFEINFO_kindtypeREAL1)
3446 right = ffeexpr_convert (right, NULL, NULL,
3447 FFEINFO_basictypeREAL,
3448 FFEINFO_kindtypeREALDOUBLE, 0,
3449 FFETARGET_charactersizeNONE,
3450 FFEEXPR_contextLET);
3451 code = FFECOM_gfrtPOW_DD;
3454 case FFEINFO_basictypeCOMPLEX:
3455 if (ffeinfo_kindtype (ffebld_info (left)) == FFEINFO_kindtypeREAL1)
3456 left = ffeexpr_convert (left, NULL, NULL,
3457 FFEINFO_basictypeCOMPLEX,
3458 FFEINFO_kindtypeREALDOUBLE, 0,
3459 FFETARGET_charactersizeNONE,
3460 FFEEXPR_contextLET);
3461 if (ffeinfo_kindtype (ffebld_info (right))
3462 == FFEINFO_kindtypeREAL1)
3463 right = ffeexpr_convert (right, NULL, NULL,
3464 FFEINFO_basictypeCOMPLEX,
3465 FFEINFO_kindtypeREALDOUBLE, 0,
3466 FFETARGET_charactersizeNONE,
3467 FFEEXPR_contextLET);
3468 code = FFECOM_gfrtPOW_ZZ; /* Overlapping result okay. */
3472 assert ("bad pow_x*" == NULL);
3473 code = FFECOM_gfrtPOW_II;
3476 return ffecom_call_binop_ (ffecom_gfrt_tree_ (code),
3477 ffecom_gfrt_kindtype (code),
3478 (ffe_is_f2c_library ()
3479 && ffecom_gfrt_complex_[code]),
3480 tree_type, left, right,
3481 dest_tree, dest, dest_used,
3483 ffebld_nonter_hook (expr));
3489 case FFEINFO_basictypeLOGICAL:
3490 item = ffecom_truth_value_invert (ffecom_expr (ffebld_left (expr)));
3491 return convert (tree_type, item);
3493 case FFEINFO_basictypeINTEGER:
3494 return ffecom_1 (BIT_NOT_EXPR, tree_type,
3495 ffecom_expr (ffebld_left (expr)));
3498 assert ("NOT bad basictype" == NULL);
3500 case FFEINFO_basictypeANY:
3501 return error_mark_node;
3505 case FFEBLD_opFUNCREF:
3506 assert (ffeinfo_basictype (ffebld_info (expr))
3507 != FFEINFO_basictypeCHARACTER);
3509 case FFEBLD_opSUBRREF:
3510 if (ffeinfo_where (ffebld_info (ffebld_left (expr)))
3511 == FFEINFO_whereINTRINSIC)
3512 { /* Invocation of an intrinsic. */
3513 item = ffecom_expr_intrinsic_ (expr, dest_tree, dest,
3517 s = ffebld_symter (ffebld_left (expr));
3518 dt = ffesymbol_hook (s).decl_tree;
3519 if (dt == NULL_TREE)
3521 s = ffecom_sym_transform_ (s);
3522 dt = ffesymbol_hook (s).decl_tree;
3524 if (dt == error_mark_node)
3527 if (ffesymbol_hook (s).addr)
3530 item = ffecom_1_fn (dt);
3532 if (ffesymbol_where (s) == FFEINFO_whereCONSTANT)
3533 args = ffecom_list_expr (ffebld_right (expr));
3535 args = ffecom_list_ptr_to_expr (ffebld_right (expr));
3537 if (args == error_mark_node)
3538 return error_mark_node;
3540 item = ffecom_call_ (item, kt,
3541 ffesymbol_is_f2c (s)
3542 && (bt == FFEINFO_basictypeCOMPLEX)
3543 && (ffesymbol_where (s)
3544 != FFEINFO_whereCONSTANT),
3547 dest_tree, dest, dest_used,
3548 error_mark_node, FALSE,
3549 ffebld_nonter_hook (expr));
3550 TREE_SIDE_EFFECTS (item) = 1;
3556 case FFEINFO_basictypeLOGICAL:
3558 = ffecom_2 (TRUTH_ANDIF_EXPR, integer_type_node,
3559 ffecom_truth_value (ffecom_expr (ffebld_left (expr))),
3560 ffecom_truth_value (ffecom_expr (ffebld_right (expr))));
3561 return convert (tree_type, item);
3563 case FFEINFO_basictypeINTEGER:
3564 return ffecom_2 (BIT_AND_EXPR, tree_type,
3565 ffecom_expr (ffebld_left (expr)),
3566 ffecom_expr (ffebld_right (expr)));
3569 assert ("AND bad basictype" == NULL);
3571 case FFEINFO_basictypeANY:
3572 return error_mark_node;
3579 case FFEINFO_basictypeLOGICAL:
3581 = ffecom_2 (TRUTH_ORIF_EXPR, integer_type_node,
3582 ffecom_truth_value (ffecom_expr (ffebld_left (expr))),
3583 ffecom_truth_value (ffecom_expr (ffebld_right (expr))));
3584 return convert (tree_type, item);
3586 case FFEINFO_basictypeINTEGER:
3587 return ffecom_2 (BIT_IOR_EXPR, tree_type,
3588 ffecom_expr (ffebld_left (expr)),
3589 ffecom_expr (ffebld_right (expr)));
3592 assert ("OR bad basictype" == NULL);
3594 case FFEINFO_basictypeANY:
3595 return error_mark_node;
3603 case FFEINFO_basictypeLOGICAL:
3605 = ffecom_2 (NE_EXPR, integer_type_node,
3606 ffecom_expr (ffebld_left (expr)),
3607 ffecom_expr (ffebld_right (expr)));
3608 return convert (tree_type, ffecom_truth_value (item));
3610 case FFEINFO_basictypeINTEGER:
3611 return ffecom_2 (BIT_XOR_EXPR, tree_type,
3612 ffecom_expr (ffebld_left (expr)),
3613 ffecom_expr (ffebld_right (expr)));
3616 assert ("XOR/NEQV bad basictype" == NULL);
3618 case FFEINFO_basictypeANY:
3619 return error_mark_node;
3626 case FFEINFO_basictypeLOGICAL:
3628 = ffecom_2 (EQ_EXPR, integer_type_node,
3629 ffecom_expr (ffebld_left (expr)),
3630 ffecom_expr (ffebld_right (expr)));
3631 return convert (tree_type, ffecom_truth_value (item));
3633 case FFEINFO_basictypeINTEGER:
3635 ffecom_1 (BIT_NOT_EXPR, tree_type,
3636 ffecom_2 (BIT_XOR_EXPR, tree_type,
3637 ffecom_expr (ffebld_left (expr)),
3638 ffecom_expr (ffebld_right (expr))));
3641 assert ("EQV bad basictype" == NULL);
3643 case FFEINFO_basictypeANY:
3644 return error_mark_node;
3648 case FFEBLD_opCONVERT:
3649 if (ffebld_op (ffebld_left (expr)) == FFEBLD_opANY)
3650 return error_mark_node;
3654 case FFEINFO_basictypeLOGICAL:
3655 case FFEINFO_basictypeINTEGER:
3656 case FFEINFO_basictypeREAL:
3657 return convert (tree_type, ffecom_expr (ffebld_left (expr)));
3659 case FFEINFO_basictypeCOMPLEX:
3660 switch (ffeinfo_basictype (ffebld_info (ffebld_left (expr))))
3662 case FFEINFO_basictypeINTEGER:
3663 case FFEINFO_basictypeLOGICAL:
3664 case FFEINFO_basictypeREAL:
3665 item = ffecom_expr (ffebld_left (expr));
3666 if (item == error_mark_node)
3667 return error_mark_node;
3668 /* convert() takes care of converting to the subtype first,
3669 at least in gcc-2.7.2. */
3670 item = convert (tree_type, item);
3673 case FFEINFO_basictypeCOMPLEX:
3674 return convert (tree_type, ffecom_expr (ffebld_left (expr)));
3677 assert ("CONVERT COMPLEX bad basictype" == NULL);
3679 case FFEINFO_basictypeANY:
3680 return error_mark_node;
3685 assert ("CONVERT bad basictype" == NULL);
3687 case FFEINFO_basictypeANY:
3688 return error_mark_node;
3694 goto relational; /* :::::::::::::::::::: */
3698 goto relational; /* :::::::::::::::::::: */
3702 goto relational; /* :::::::::::::::::::: */
3706 goto relational; /* :::::::::::::::::::: */
3710 goto relational; /* :::::::::::::::::::: */
3715 relational: /* :::::::::::::::::::: */
3716 switch (ffeinfo_basictype (ffebld_info (ffebld_left (expr))))
3718 case FFEINFO_basictypeLOGICAL:
3719 case FFEINFO_basictypeINTEGER:
3720 case FFEINFO_basictypeREAL:
3721 item = ffecom_2 (code, integer_type_node,
3722 ffecom_expr (ffebld_left (expr)),
3723 ffecom_expr (ffebld_right (expr)));
3724 return convert (tree_type, item);
3726 case FFEINFO_basictypeCOMPLEX:
3727 assert (code == EQ_EXPR || code == NE_EXPR);
3730 tree arg1 = ffecom_expr (ffebld_left (expr));
3731 tree arg2 = ffecom_expr (ffebld_right (expr));
3733 if (arg1 == error_mark_node || arg2 == error_mark_node)
3734 return error_mark_node;
3736 arg1 = ffecom_save_tree (arg1);
3737 arg2 = ffecom_save_tree (arg2);
3739 if (TREE_CODE (TREE_TYPE (arg1)) == COMPLEX_TYPE)
3741 real_type = TREE_TYPE (TREE_TYPE (arg1));
3742 assert (real_type == TREE_TYPE (TREE_TYPE (arg2)));
3746 real_type = TREE_TYPE (TYPE_FIELDS (TREE_TYPE (arg1)));
3747 assert (real_type == TREE_TYPE (TYPE_FIELDS (TREE_TYPE (arg2))));
3751 = ffecom_2 (TRUTH_ANDIF_EXPR, integer_type_node,
3752 ffecom_2 (EQ_EXPR, integer_type_node,
3753 ffecom_1 (REALPART_EXPR, real_type, arg1),
3754 ffecom_1 (REALPART_EXPR, real_type, arg2)),
3755 ffecom_2 (EQ_EXPR, integer_type_node,
3756 ffecom_1 (IMAGPART_EXPR, real_type, arg1),
3757 ffecom_1 (IMAGPART_EXPR, real_type,
3759 if (code == EQ_EXPR)
3760 item = ffecom_truth_value (item);
3762 item = ffecom_truth_value_invert (item);
3763 return convert (tree_type, item);
3766 case FFEINFO_basictypeCHARACTER:
3768 ffebld left = ffebld_left (expr);
3769 ffebld right = ffebld_right (expr);
3775 /* f2c run-time functions do the implicit blank-padding for us,
3776 so we don't usually have to implement blank-padding ourselves.
3777 (The exception is when we pass an argument to a separately
3778 compiled statement function -- if we know the arg is not the
3779 same length as the dummy, we must truncate or extend it. If
3780 we "inline" statement functions, that necessity goes away as
3783 Strip off the CONVERT operators that blank-pad. (Truncation by
3784 CONVERT shouldn't happen here, but it can happen in
3787 while (ffebld_op (left) == FFEBLD_opCONVERT)
3788 left = ffebld_left (left);
3789 while (ffebld_op (right) == FFEBLD_opCONVERT)
3790 right = ffebld_left (right);
3792 left_tree = ffecom_arg_ptr_to_expr (left, &left_length);
3793 right_tree = ffecom_arg_ptr_to_expr (right, &right_length);
3795 if (left_tree == error_mark_node || left_length == error_mark_node
3796 || right_tree == error_mark_node
3797 || right_length == error_mark_node)
3798 return error_mark_node;
3800 if ((ffebld_size_known (left) == 1)
3801 && (ffebld_size_known (right) == 1))
3804 = ffecom_1 (INDIRECT_REF,
3805 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (left_tree))),
3808 = ffecom_1 (INDIRECT_REF,
3809 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (right_tree))),
3813 = ffecom_2 (code, integer_type_node,
3814 ffecom_2 (ARRAY_REF,
3815 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (left_tree))),
3818 ffecom_2 (ARRAY_REF,
3819 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (right_tree))),
3825 item = build_tree_list (NULL_TREE, left_tree);
3826 TREE_CHAIN (item) = build_tree_list (NULL_TREE, right_tree);
3827 TREE_CHAIN (TREE_CHAIN (item)) = build_tree_list (NULL_TREE,
3829 TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (item)))
3830 = build_tree_list (NULL_TREE, right_length);
3831 item = ffecom_call_gfrt (FFECOM_gfrtCMP, item, NULL_TREE);
3832 item = ffecom_2 (code, integer_type_node,
3834 convert (TREE_TYPE (item),
3835 integer_zero_node));
3837 item = convert (tree_type, item);
3843 assert ("relational bad basictype" == NULL);
3845 case FFEINFO_basictypeANY:
3846 return error_mark_node;
3850 case FFEBLD_opPERCENT_LOC:
3851 item = ffecom_arg_ptr_to_expr (ffebld_left (expr), &list);
3852 return convert (tree_type, item);
3856 case FFEBLD_opBOUNDS:
3857 case FFEBLD_opREPEAT:
3858 case FFEBLD_opLABTER:
3859 case FFEBLD_opLABTOK:
3860 case FFEBLD_opIMPDO:
3861 case FFEBLD_opCONCATENATE:
3862 case FFEBLD_opSUBSTR:
3864 assert ("bad op" == NULL);
3867 return error_mark_node;
3871 assert ("didn't think anything got here anymore!!" == NULL);
3873 switch (ffebld_arity (expr))
3876 TREE_OPERAND (item, 0) = ffecom_expr (ffebld_left (expr));
3877 TREE_OPERAND (item, 1) = ffecom_expr (ffebld_right (expr));
3878 if (TREE_OPERAND (item, 0) == error_mark_node
3879 || TREE_OPERAND (item, 1) == error_mark_node)
3880 return error_mark_node;
3884 TREE_OPERAND (item, 0) = ffecom_expr (ffebld_left (expr));
3885 if (TREE_OPERAND (item, 0) == error_mark_node)
3886 return error_mark_node;
3898 /* Returns the tree that does the intrinsic invocation.
3900 Note: this function applies only to intrinsics returning
3901 CHARACTER*1 or non-CHARACTER results, and to intrinsic
3904 #if FFECOM_targetCURRENT == FFECOM_targetGCC
3906 ffecom_expr_intrinsic_ (ffebld expr, tree dest_tree,
3907 ffebld dest, bool *dest_used)
3910 tree saved_expr1; /* For those who need it. */
3911 tree saved_expr2; /* For those who need it. */
3912 ffeinfoBasictype bt;
3916 tree real_type; /* REAL type corresponding to COMPLEX. */
3918 ffebld list = ffebld_right (expr); /* List of (some) args. */
3919 ffebld arg1; /* For handy reference. */
3922 ffeintrinImp codegen_imp;
3925 assert (ffebld_op (ffebld_left (expr)) == FFEBLD_opSYMTER);
3927 if (dest_used != NULL)
3930 bt = ffeinfo_basictype (ffebld_info (expr));
3931 kt = ffeinfo_kindtype (ffebld_info (expr));
3932 tree_type = ffecom_tree_type[bt][kt];
3936 arg1 = ffebld_head (list);
3937 if (arg1 != NULL && ffebld_op (arg1) == FFEBLD_opANY)
3938 return error_mark_node;
3939 if ((list = ffebld_trail (list)) != NULL)
3941 arg2 = ffebld_head (list);
3942 if (arg2 != NULL && ffebld_op (arg2) == FFEBLD_opANY)
3943 return error_mark_node;
3944 if ((list = ffebld_trail (list)) != NULL)
3946 arg3 = ffebld_head (list);
3947 if (arg3 != NULL && ffebld_op (arg3) == FFEBLD_opANY)
3948 return error_mark_node;
3957 arg1 = arg2 = arg3 = NULL;
3959 /* <list> ends up at the opITEM of the 3rd arg, or NULL if there are < 3
3960 args. This is used by the MAX/MIN expansions. */
3963 arg1_type = ffecom_tree_type
3964 [ffeinfo_basictype (ffebld_info (arg1))]
3965 [ffeinfo_kindtype (ffebld_info (arg1))];
3967 arg1_type = NULL_TREE; /* Really not needed, but might catch bugs
3970 /* There are several ways for each of the cases in the following switch
3971 statements to exit (from simplest to use to most complicated):
3973 break; (when expr_tree == NULL)
3975 A standard call is made to the specific intrinsic just as if it had been
3976 passed in as a dummy procedure and called as any old procedure. This
3977 method can produce slower code but in some cases it's the easiest way for
3978 now. However, if a (presumably faster) direct call is available,
3979 that is used, so this is the easiest way in many more cases now.
3981 gfrt = FFECOM_gfrtWHATEVER;
3984 gfrt contains the gfrt index of a library function to call, passing the
3985 argument(s) by value rather than by reference. Used when a more
3986 careful choice of library function is needed than that provided
3987 by the vanilla `break;'.
3991 The expr_tree has been completely set up and is ready to be returned
3992 as is. No further actions are taken. Use this when the tree is not
3993 in the simple form for one of the arity_n labels. */
3995 /* For info on how the switch statement cases were written, see the files
3996 enclosed in comments below the switch statement. */
3998 codegen_imp = ffebld_symter_implementation (ffebld_left (expr));
3999 gfrt = ffeintrin_gfrt_direct (codegen_imp);
4000 if (gfrt == FFECOM_gfrt)
4001 gfrt = ffeintrin_gfrt_indirect (codegen_imp);
4003 switch (codegen_imp)
4005 case FFEINTRIN_impABS:
4006 case FFEINTRIN_impCABS:
4007 case FFEINTRIN_impCDABS:
4008 case FFEINTRIN_impDABS:
4009 case FFEINTRIN_impIABS:
4010 if (ffeinfo_basictype (ffebld_info (arg1))
4011 == FFEINFO_basictypeCOMPLEX)
4013 if (kt == FFEINFO_kindtypeREAL1)
4014 gfrt = FFECOM_gfrtCABS;
4015 else if (kt == FFEINFO_kindtypeREAL2)
4016 gfrt = FFECOM_gfrtCDABS;
4019 return ffecom_1 (ABS_EXPR, tree_type,
4020 convert (tree_type, ffecom_expr (arg1)));
4022 case FFEINTRIN_impACOS:
4023 case FFEINTRIN_impDACOS:
4026 case FFEINTRIN_impAIMAG:
4027 case FFEINTRIN_impDIMAG:
4028 case FFEINTRIN_impIMAGPART:
4029 if (TREE_CODE (arg1_type) == COMPLEX_TYPE)
4030 arg1_type = TREE_TYPE (arg1_type);
4032 arg1_type = TREE_TYPE (TYPE_FIELDS (arg1_type));
4036 ffecom_1 (IMAGPART_EXPR, arg1_type,
4037 ffecom_expr (arg1)));
4039 case FFEINTRIN_impAINT:
4040 case FFEINTRIN_impDINT:
4042 /* ~~Someday implement FIX_TRUNC_EXPR yielding same type as arg. */
4043 return ffecom_1 (FIX_TRUNC_EXPR, tree_type, ffecom_expr (arg1));
4044 #else /* in the meantime, must use floor to avoid range problems with ints */
4045 /* r__1 = r1 >= 0 ? floor(r1) : -floor(-r1); */
4046 saved_expr1 = ffecom_save_tree (ffecom_expr (arg1));
4049 ffecom_3 (COND_EXPR, double_type_node,
4051 (ffecom_2 (GE_EXPR, integer_type_node,
4054 ffecom_float_zero_))),
4055 ffecom_call_gfrt (FFECOM_gfrtL_FLOOR,
4056 build_tree_list (NULL_TREE,
4057 convert (double_type_node,
4060 ffecom_1 (NEGATE_EXPR, double_type_node,
4061 ffecom_call_gfrt (FFECOM_gfrtL_FLOOR,
4062 build_tree_list (NULL_TREE,
4063 convert (double_type_node,
4064 ffecom_1 (NEGATE_EXPR,
4072 case FFEINTRIN_impANINT:
4073 case FFEINTRIN_impDNINT:
4074 #if 0 /* This way of doing it won't handle real
4075 numbers of large magnitudes. */
4076 saved_expr1 = ffecom_save_tree (ffecom_expr (arg1));
4077 expr_tree = convert (tree_type,
4078 convert (integer_type_node,
4079 ffecom_3 (COND_EXPR, tree_type,
4084 ffecom_float_zero_)),
4085 ffecom_2 (PLUS_EXPR,
4088 ffecom_float_half_),
4089 ffecom_2 (MINUS_EXPR,
4092 ffecom_float_half_))));
4094 #else /* So we instead call floor. */
4095 /* r__1 = r1 >= 0 ? floor(r1 + .5) : -floor(.5 - r1) */
4096 saved_expr1 = ffecom_save_tree (ffecom_expr (arg1));
4099 ffecom_3 (COND_EXPR, double_type_node,
4101 (ffecom_2 (GE_EXPR, integer_type_node,
4104 ffecom_float_zero_))),
4105 ffecom_call_gfrt (FFECOM_gfrtL_FLOOR,
4106 build_tree_list (NULL_TREE,
4107 convert (double_type_node,
4108 ffecom_2 (PLUS_EXPR,
4112 ffecom_float_half_)))),
4114 ffecom_1 (NEGATE_EXPR, double_type_node,
4115 ffecom_call_gfrt (FFECOM_gfrtL_FLOOR,
4116 build_tree_list (NULL_TREE,
4117 convert (double_type_node,
4118 ffecom_2 (MINUS_EXPR,
4121 ffecom_float_half_),
4128 case FFEINTRIN_impASIN:
4129 case FFEINTRIN_impDASIN:
4130 case FFEINTRIN_impATAN:
4131 case FFEINTRIN_impDATAN:
4132 case FFEINTRIN_impATAN2:
4133 case FFEINTRIN_impDATAN2:
4136 case FFEINTRIN_impCHAR:
4137 case FFEINTRIN_impACHAR:
4139 tempvar = ffecom_make_tempvar (char_type_node, 1, -1);
4141 tempvar = ffebld_nonter_hook (expr);
4145 tree tmv = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (tempvar)));
4147 expr_tree = ffecom_modify (tmv,
4148 ffecom_2 (ARRAY_REF, tmv, tempvar,
4150 convert (tmv, ffecom_expr (arg1)));
4152 expr_tree = ffecom_2 (COMPOUND_EXPR, TREE_TYPE (tempvar),
4155 expr_tree = ffecom_1 (ADDR_EXPR,
4156 build_pointer_type (TREE_TYPE (expr_tree)),
4160 case FFEINTRIN_impCMPLX:
4161 case FFEINTRIN_impDCMPLX:
4164 convert (tree_type, ffecom_expr (arg1));
4166 real_type = ffecom_tree_type[FFEINFO_basictypeREAL][kt];
4168 ffecom_2 (COMPLEX_EXPR, tree_type,
4169 convert (real_type, ffecom_expr (arg1)),
4171 ffecom_expr (arg2)));
4173 case FFEINTRIN_impCOMPLEX:
4175 ffecom_2 (COMPLEX_EXPR, tree_type,
4177 ffecom_expr (arg2));
4179 case FFEINTRIN_impCONJG:
4180 case FFEINTRIN_impDCONJG:
4184 real_type = ffecom_tree_type[FFEINFO_basictypeREAL][kt];
4185 arg1_tree = ffecom_save_tree (ffecom_expr (arg1));
4187 ffecom_2 (COMPLEX_EXPR, tree_type,
4188 ffecom_1 (REALPART_EXPR, real_type, arg1_tree),
4189 ffecom_1 (NEGATE_EXPR, real_type,
4190 ffecom_1 (IMAGPART_EXPR, real_type, arg1_tree)));
4193 case FFEINTRIN_impCOS:
4194 case FFEINTRIN_impCCOS:
4195 case FFEINTRIN_impCDCOS:
4196 case FFEINTRIN_impDCOS:
4197 if (bt == FFEINFO_basictypeCOMPLEX)
4199 if (kt == FFEINFO_kindtypeREAL1)
4200 gfrt = FFECOM_gfrtCCOS; /* Overlapping result okay. */
4201 else if (kt == FFEINFO_kindtypeREAL2)
4202 gfrt = FFECOM_gfrtCDCOS; /* Overlapping result okay. */
4206 case FFEINTRIN_impCOSH:
4207 case FFEINTRIN_impDCOSH:
4210 case FFEINTRIN_impDBLE:
4211 case FFEINTRIN_impDFLOAT:
4212 case FFEINTRIN_impDREAL:
4213 case FFEINTRIN_impFLOAT:
4214 case FFEINTRIN_impIDINT:
4215 case FFEINTRIN_impIFIX:
4216 case FFEINTRIN_impINT2:
4217 case FFEINTRIN_impINT8:
4218 case FFEINTRIN_impINT:
4219 case FFEINTRIN_impLONG:
4220 case FFEINTRIN_impREAL:
4221 case FFEINTRIN_impSHORT:
4222 case FFEINTRIN_impSNGL:
4223 return convert (tree_type, ffecom_expr (arg1));
4225 case FFEINTRIN_impDIM:
4226 case FFEINTRIN_impDDIM:
4227 case FFEINTRIN_impIDIM:
4228 saved_expr1 = ffecom_save_tree (convert (tree_type,
4229 ffecom_expr (arg1)));
4230 saved_expr2 = ffecom_save_tree (convert (tree_type,
4231 ffecom_expr (arg2)));
4233 ffecom_3 (COND_EXPR, tree_type,
4235 (ffecom_2 (GT_EXPR, integer_type_node,
4238 ffecom_2 (MINUS_EXPR, tree_type,
4241 convert (tree_type, ffecom_float_zero_));
4243 case FFEINTRIN_impDPROD:
4245 ffecom_2 (MULT_EXPR, tree_type,
4246 convert (tree_type, ffecom_expr (arg1)),
4247 convert (tree_type, ffecom_expr (arg2)));
4249 case FFEINTRIN_impEXP:
4250 case FFEINTRIN_impCDEXP:
4251 case FFEINTRIN_impCEXP:
4252 case FFEINTRIN_impDEXP:
4253 if (bt == FFEINFO_basictypeCOMPLEX)
4255 if (kt == FFEINFO_kindtypeREAL1)
4256 gfrt = FFECOM_gfrtCEXP; /* Overlapping result okay. */
4257 else if (kt == FFEINFO_kindtypeREAL2)
4258 gfrt = FFECOM_gfrtCDEXP; /* Overlapping result okay. */
4262 case FFEINTRIN_impICHAR:
4263 case FFEINTRIN_impIACHAR:
4264 #if 0 /* The simple approach. */
4265 ffecom_char_args_ (&expr_tree, &saved_expr1 /* Ignored */ , arg1);
4267 = ffecom_1 (INDIRECT_REF,
4268 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (expr_tree))),
4271 = ffecom_2 (ARRAY_REF,
4272 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (expr_tree))),
4275 return convert (tree_type, expr_tree);
4276 #else /* The more interesting (and more optimal) approach. */
4277 expr_tree = ffecom_intrinsic_ichar_ (tree_type, arg1, &saved_expr1);
4278 expr_tree = ffecom_3 (COND_EXPR, tree_type,
4281 convert (tree_type, integer_zero_node));
4285 case FFEINTRIN_impINDEX:
4288 case FFEINTRIN_impLEN:
4290 break; /* The simple approach. */
4292 return ffecom_intrinsic_len_ (arg1); /* The more optimal approach. */
4295 case FFEINTRIN_impLGE:
4296 case FFEINTRIN_impLGT:
4297 case FFEINTRIN_impLLE:
4298 case FFEINTRIN_impLLT:
4301 case FFEINTRIN_impLOG:
4302 case FFEINTRIN_impALOG:
4303 case FFEINTRIN_impCDLOG:
4304 case FFEINTRIN_impCLOG:
4305 case FFEINTRIN_impDLOG:
4306 if (bt == FFEINFO_basictypeCOMPLEX)
4308 if (kt == FFEINFO_kindtypeREAL1)
4309 gfrt = FFECOM_gfrtCLOG; /* Overlapping result okay. */
4310 else if (kt == FFEINFO_kindtypeREAL2)
4311 gfrt = FFECOM_gfrtCDLOG; /* Overlapping result okay. */
4315 case FFEINTRIN_impLOG10:
4316 case FFEINTRIN_impALOG10:
4317 case FFEINTRIN_impDLOG10:
4318 if (gfrt != FFECOM_gfrt)
4319 break; /* Already picked one, stick with it. */
4321 if (kt == FFEINFO_kindtypeREAL1)
4322 gfrt = FFECOM_gfrtALOG10;
4323 else if (kt == FFEINFO_kindtypeREAL2)
4324 gfrt = FFECOM_gfrtDLOG10;
4327 case FFEINTRIN_impMAX:
4328 case FFEINTRIN_impAMAX0:
4329 case FFEINTRIN_impAMAX1:
4330 case FFEINTRIN_impDMAX1:
4331 case FFEINTRIN_impMAX0:
4332 case FFEINTRIN_impMAX1:
4333 if (bt != ffeinfo_basictype (ffebld_info (arg1)))
4334 arg1_type = ffecom_widest_expr_type_ (ffebld_right (expr));
4336 arg1_type = tree_type;
4337 expr_tree = ffecom_2 (MAX_EXPR, arg1_type,
4338 convert (arg1_type, ffecom_expr (arg1)),
4339 convert (arg1_type, ffecom_expr (arg2)));
4340 for (; list != NULL; list = ffebld_trail (list))
4342 if ((ffebld_head (list) == NULL)
4343 || (ffebld_op (ffebld_head (list)) == FFEBLD_opANY))
4345 expr_tree = ffecom_2 (MAX_EXPR, arg1_type,
4348 ffecom_expr (ffebld_head (list))));
4350 return convert (tree_type, expr_tree);
4352 case FFEINTRIN_impMIN:
4353 case FFEINTRIN_impAMIN0:
4354 case FFEINTRIN_impAMIN1:
4355 case FFEINTRIN_impDMIN1:
4356 case FFEINTRIN_impMIN0:
4357 case FFEINTRIN_impMIN1:
4358 if (bt != ffeinfo_basictype (ffebld_info (arg1)))
4359 arg1_type = ffecom_widest_expr_type_ (ffebld_right (expr));
4361 arg1_type = tree_type;
4362 expr_tree = ffecom_2 (MIN_EXPR, arg1_type,
4363 convert (arg1_type, ffecom_expr (arg1)),
4364 convert (arg1_type, ffecom_expr (arg2)));
4365 for (; list != NULL; list = ffebld_trail (list))
4367 if ((ffebld_head (list) == NULL)
4368 || (ffebld_op (ffebld_head (list)) == FFEBLD_opANY))
4370 expr_tree = ffecom_2 (MIN_EXPR, arg1_type,
4373 ffecom_expr (ffebld_head (list))));
4375 return convert (tree_type, expr_tree);
4377 case FFEINTRIN_impMOD:
4378 case FFEINTRIN_impAMOD:
4379 case FFEINTRIN_impDMOD:
4380 if (bt != FFEINFO_basictypeREAL)
4381 return ffecom_2 (TRUNC_MOD_EXPR, tree_type,
4382 convert (tree_type, ffecom_expr (arg1)),
4383 convert (tree_type, ffecom_expr (arg2)));
4385 if (kt == FFEINFO_kindtypeREAL1)
4386 gfrt = FFECOM_gfrtAMOD;
4387 else if (kt == FFEINFO_kindtypeREAL2)
4388 gfrt = FFECOM_gfrtDMOD;
4391 case FFEINTRIN_impNINT:
4392 case FFEINTRIN_impIDNINT:
4394 /* ~~Ideally FIX_ROUND_EXPR would be implemented, but it ain't yet. */
4395 return ffecom_1 (FIX_ROUND_EXPR, tree_type, ffecom_expr (arg1));
4397 /* i__1 = r1 >= 0 ? floor(r1 + .5) : -floor(.5 - r1); */
4398 saved_expr1 = ffecom_save_tree (ffecom_expr (arg1));
4400 convert (ffecom_integer_type_node,
4401 ffecom_3 (COND_EXPR, arg1_type,
4403 (ffecom_2 (GE_EXPR, integer_type_node,
4406 ffecom_float_zero_))),
4407 ffecom_2 (PLUS_EXPR, arg1_type,
4410 ffecom_float_half_)),
4411 ffecom_2 (MINUS_EXPR, arg1_type,
4414 ffecom_float_half_))));
4417 case FFEINTRIN_impSIGN:
4418 case FFEINTRIN_impDSIGN:
4419 case FFEINTRIN_impISIGN:
4421 tree arg2_tree = ffecom_expr (arg2);
4425 (ffecom_1 (ABS_EXPR, tree_type,
4427 ffecom_expr (arg1))));
4429 = ffecom_3 (COND_EXPR, tree_type,
4431 (ffecom_2 (GE_EXPR, integer_type_node,
4433 convert (TREE_TYPE (arg2_tree),
4434 integer_zero_node))),
4436 ffecom_1 (NEGATE_EXPR, tree_type, saved_expr1));
4437 /* Make sure SAVE_EXPRs get referenced early enough. */
4439 = ffecom_2 (COMPOUND_EXPR, tree_type,
4440 convert (void_type_node, saved_expr1),
4445 case FFEINTRIN_impSIN:
4446 case FFEINTRIN_impCDSIN:
4447 case FFEINTRIN_impCSIN:
4448 case FFEINTRIN_impDSIN:
4449 if (bt == FFEINFO_basictypeCOMPLEX)
4451 if (kt == FFEINFO_kindtypeREAL1)
4452 gfrt = FFECOM_gfrtCSIN; /* Overlapping result okay. */
4453 else if (kt == FFEINFO_kindtypeREAL2)
4454 gfrt = FFECOM_gfrtCDSIN; /* Overlapping result okay. */
4458 case FFEINTRIN_impSINH:
4459 case FFEINTRIN_impDSINH:
4462 case FFEINTRIN_impSQRT:
4463 case FFEINTRIN_impCDSQRT:
4464 case FFEINTRIN_impCSQRT:
4465 case FFEINTRIN_impDSQRT:
4466 if (bt == FFEINFO_basictypeCOMPLEX)
4468 if (kt == FFEINFO_kindtypeREAL1)
4469 gfrt = FFECOM_gfrtCSQRT; /* Overlapping result okay. */
4470 else if (kt == FFEINFO_kindtypeREAL2)
4471 gfrt = FFECOM_gfrtCDSQRT; /* Overlapping result okay. */
4475 case FFEINTRIN_impTAN:
4476 case FFEINTRIN_impDTAN:
4477 case FFEINTRIN_impTANH:
4478 case FFEINTRIN_impDTANH:
4481 case FFEINTRIN_impREALPART:
4482 if (TREE_CODE (arg1_type) == COMPLEX_TYPE)
4483 arg1_type = TREE_TYPE (arg1_type);
4485 arg1_type = TREE_TYPE (TYPE_FIELDS (arg1_type));
4489 ffecom_1 (REALPART_EXPR, arg1_type,
4490 ffecom_expr (arg1)));
4492 case FFEINTRIN_impIAND:
4493 case FFEINTRIN_impAND:
4494 return ffecom_2 (BIT_AND_EXPR, tree_type,
4496 ffecom_expr (arg1)),
4498 ffecom_expr (arg2)));
4500 case FFEINTRIN_impIOR:
4501 case FFEINTRIN_impOR:
4502 return ffecom_2 (BIT_IOR_EXPR, tree_type,
4504 ffecom_expr (arg1)),
4506 ffecom_expr (arg2)));
4508 case FFEINTRIN_impIEOR:
4509 case FFEINTRIN_impXOR:
4510 return ffecom_2 (BIT_XOR_EXPR, tree_type,
4512 ffecom_expr (arg1)),
4514 ffecom_expr (arg2)));
4516 case FFEINTRIN_impLSHIFT:
4517 return ffecom_2 (LSHIFT_EXPR, tree_type,
4519 convert (integer_type_node,
4520 ffecom_expr (arg2)));
4522 case FFEINTRIN_impRSHIFT:
4523 return ffecom_2 (RSHIFT_EXPR, tree_type,
4525 convert (integer_type_node,
4526 ffecom_expr (arg2)));
4528 case FFEINTRIN_impNOT:
4529 return ffecom_1 (BIT_NOT_EXPR, tree_type, ffecom_expr (arg1));
4531 case FFEINTRIN_impBIT_SIZE:
4532 return convert (tree_type, TYPE_SIZE (arg1_type));
4534 case FFEINTRIN_impBTEST:
4536 ffetargetLogical1 true;
4537 ffetargetLogical1 false;
4541 ffetarget_logical1 (&true, TRUE);
4542 ffetarget_logical1 (&false, FALSE);
4544 true_tree = convert (tree_type, integer_one_node);
4546 true_tree = convert (tree_type, build_int_2 (true, 0));
4548 false_tree = convert (tree_type, integer_zero_node);
4550 false_tree = convert (tree_type, build_int_2 (false, 0));
4553 ffecom_3 (COND_EXPR, tree_type,
4555 (ffecom_2 (EQ_EXPR, integer_type_node,
4556 ffecom_2 (BIT_AND_EXPR, arg1_type,
4558 ffecom_2 (LSHIFT_EXPR, arg1_type,
4561 convert (integer_type_node,
4562 ffecom_expr (arg2)))),
4564 integer_zero_node))),
4569 case FFEINTRIN_impIBCLR:
4571 ffecom_2 (BIT_AND_EXPR, tree_type,
4573 ffecom_1 (BIT_NOT_EXPR, tree_type,
4574 ffecom_2 (LSHIFT_EXPR, tree_type,
4577 convert (integer_type_node,
4578 ffecom_expr (arg2)))));
4580 case FFEINTRIN_impIBITS:
4582 tree arg3_tree = ffecom_save_tree (convert (integer_type_node,
4583 ffecom_expr (arg3)));
4585 = ffecom_tree_type[FFEINFO_basictypeHOLLERITH][kt];
4588 = ffecom_2 (BIT_AND_EXPR, tree_type,
4589 ffecom_2 (RSHIFT_EXPR, tree_type,
4591 convert (integer_type_node,
4592 ffecom_expr (arg2))),
4594 ffecom_2 (RSHIFT_EXPR, uns_type,
4595 ffecom_1 (BIT_NOT_EXPR,
4598 integer_zero_node)),
4599 ffecom_2 (MINUS_EXPR,
4601 TYPE_SIZE (uns_type),
4603 #if !defined(TREE_SHIFT_FULLWIDTH) || !TREE_SHIFT_FULLWIDTH
4605 = ffecom_3 (COND_EXPR, tree_type,
4607 (ffecom_2 (NE_EXPR, integer_type_node,
4609 integer_zero_node)),
4611 convert (tree_type, integer_zero_node));
4616 case FFEINTRIN_impIBSET:
4618 ffecom_2 (BIT_IOR_EXPR, tree_type,
4620 ffecom_2 (LSHIFT_EXPR, tree_type,
4621 convert (tree_type, integer_one_node),
4622 convert (integer_type_node,
4623 ffecom_expr (arg2))));
4625 case FFEINTRIN_impISHFT:
4627 tree arg1_tree = ffecom_save_tree (ffecom_expr (arg1));
4628 tree arg2_tree = ffecom_save_tree (convert (integer_type_node,
4629 ffecom_expr (arg2)));
4631 = ffecom_tree_type[FFEINFO_basictypeHOLLERITH][kt];
4634 = ffecom_3 (COND_EXPR, tree_type,
4636 (ffecom_2 (GE_EXPR, integer_type_node,
4638 integer_zero_node)),
4639 ffecom_2 (LSHIFT_EXPR, tree_type,
4643 ffecom_2 (RSHIFT_EXPR, uns_type,
4644 convert (uns_type, arg1_tree),
4645 ffecom_1 (NEGATE_EXPR,
4648 #if !defined(TREE_SHIFT_FULLWIDTH) || !TREE_SHIFT_FULLWIDTH
4650 = ffecom_3 (COND_EXPR, tree_type,
4652 (ffecom_2 (NE_EXPR, integer_type_node,
4654 TYPE_SIZE (uns_type))),
4656 convert (tree_type, integer_zero_node));
4658 /* Make sure SAVE_EXPRs get referenced early enough. */
4660 = ffecom_2 (COMPOUND_EXPR, tree_type,
4661 convert (void_type_node, arg1_tree),
4662 ffecom_2 (COMPOUND_EXPR, tree_type,
4663 convert (void_type_node, arg2_tree),
4668 case FFEINTRIN_impISHFTC:
4670 tree arg1_tree = ffecom_save_tree (ffecom_expr (arg1));
4671 tree arg2_tree = ffecom_save_tree (convert (integer_type_node,
4672 ffecom_expr (arg2)));
4673 tree arg3_tree = (arg3 == NULL) ? TYPE_SIZE (tree_type)
4674 : ffecom_save_tree (convert (integer_type_node, ffecom_expr (arg3)));
4680 = ffecom_tree_type[FFEINFO_basictypeHOLLERITH][kt];
4683 = ffecom_2 (LSHIFT_EXPR, tree_type,
4684 ffecom_1 (BIT_NOT_EXPR, tree_type,
4685 convert (tree_type, integer_zero_node)),
4687 #if !defined(TREE_SHIFT_FULLWIDTH) || !TREE_SHIFT_FULLWIDTH
4689 = ffecom_3 (COND_EXPR, tree_type,
4691 (ffecom_2 (NE_EXPR, integer_type_node,
4693 TYPE_SIZE (uns_type))),
4695 convert (tree_type, integer_zero_node));
4697 mask_arg1 = ffecom_save_tree (mask_arg1);
4699 = ffecom_2 (BIT_AND_EXPR, tree_type,
4701 ffecom_1 (BIT_NOT_EXPR, tree_type,
4703 masked_arg1 = ffecom_save_tree (masked_arg1);
4705 = ffecom_2 (BIT_IOR_EXPR, tree_type,
4707 ffecom_2 (RSHIFT_EXPR, uns_type,
4708 convert (uns_type, masked_arg1),
4709 ffecom_1 (NEGATE_EXPR,
4712 ffecom_2 (LSHIFT_EXPR, tree_type,
4714 ffecom_2 (PLUS_EXPR, integer_type_node,
4718 = ffecom_2 (BIT_IOR_EXPR, tree_type,
4719 ffecom_2 (LSHIFT_EXPR, tree_type,
4723 ffecom_2 (RSHIFT_EXPR, uns_type,
4724 convert (uns_type, masked_arg1),
4725 ffecom_2 (MINUS_EXPR,
4730 = ffecom_3 (COND_EXPR, tree_type,
4732 (ffecom_2 (LT_EXPR, integer_type_node,
4734 integer_zero_node)),
4738 = ffecom_2 (BIT_IOR_EXPR, tree_type,
4739 ffecom_2 (BIT_AND_EXPR, tree_type,
4742 ffecom_2 (BIT_AND_EXPR, tree_type,
4743 ffecom_1 (BIT_NOT_EXPR, tree_type,
4747 = ffecom_3 (COND_EXPR, tree_type,
4749 (ffecom_2 (TRUTH_ORIF_EXPR, integer_type_node,
4750 ffecom_2 (EQ_EXPR, integer_type_node,
4755 ffecom_2 (EQ_EXPR, integer_type_node,
4757 integer_zero_node))),
4760 /* Make sure SAVE_EXPRs get referenced early enough. */
4762 = ffecom_2 (COMPOUND_EXPR, tree_type,
4763 convert (void_type_node, arg1_tree),
4764 ffecom_2 (COMPOUND_EXPR, tree_type,
4765 convert (void_type_node, arg2_tree),
4766 ffecom_2 (COMPOUND_EXPR, tree_type,
4767 convert (void_type_node,
4769 ffecom_2 (COMPOUND_EXPR, tree_type,
4770 convert (void_type_node,
4774 = ffecom_2 (COMPOUND_EXPR, tree_type,
4775 convert (void_type_node,
4781 case FFEINTRIN_impLOC:
4783 tree arg1_tree = ffecom_expr (arg1);
4786 = convert (tree_type,
4787 ffecom_1 (ADDR_EXPR,
4788 build_pointer_type (TREE_TYPE (arg1_tree)),
4793 case FFEINTRIN_impMVBITS:
4798 ffebld arg4 = ffebld_head (ffebld_trail (list));
4801 ffebld arg5 = ffebld_head (ffebld_trail (ffebld_trail (list)));
4805 tree arg5_plus_arg3;
4807 arg2_tree = convert (integer_type_node,
4808 ffecom_expr (arg2));
4809 arg3_tree = ffecom_save_tree (convert (integer_type_node,
4810 ffecom_expr (arg3)));
4811 arg4_tree = ffecom_expr_rw (NULL_TREE, arg4);
4812 arg4_type = TREE_TYPE (arg4_tree);
4814 arg1_tree = ffecom_save_tree (convert (arg4_type,
4815 ffecom_expr (arg1)));
4817 arg5_tree = ffecom_save_tree (convert (integer_type_node,
4818 ffecom_expr (arg5)));
4821 = ffecom_2 (LSHIFT_EXPR, arg4_type,
4822 ffecom_2 (BIT_AND_EXPR, arg4_type,
4823 ffecom_2 (RSHIFT_EXPR, arg4_type,
4826 ffecom_1 (BIT_NOT_EXPR, arg4_type,
4827 ffecom_2 (LSHIFT_EXPR, arg4_type,
4828 ffecom_1 (BIT_NOT_EXPR,
4832 integer_zero_node)),
4836 = ffecom_save_tree (ffecom_2 (PLUS_EXPR, arg4_type,
4840 = ffecom_2 (LSHIFT_EXPR, arg4_type,
4841 ffecom_1 (BIT_NOT_EXPR, arg4_type,
4843 integer_zero_node)),
4845 #if !defined(TREE_SHIFT_FULLWIDTH) || !TREE_SHIFT_FULLWIDTH
4847 = ffecom_3 (COND_EXPR, arg4_type,
4849 (ffecom_2 (NE_EXPR, integer_type_node,
4851 convert (TREE_TYPE (arg5_plus_arg3),
4852 TYPE_SIZE (arg4_type)))),
4854 convert (arg4_type, integer_zero_node));
4857 = ffecom_2 (BIT_AND_EXPR, arg4_type,
4859 ffecom_2 (BIT_IOR_EXPR, arg4_type,
4861 ffecom_1 (BIT_NOT_EXPR, arg4_type,
4862 ffecom_2 (LSHIFT_EXPR, arg4_type,
4863 ffecom_1 (BIT_NOT_EXPR,
4867 integer_zero_node)),
4870 = ffecom_2 (BIT_IOR_EXPR, arg4_type,
4873 #if !defined(TREE_SHIFT_FULLWIDTH) || !TREE_SHIFT_FULLWIDTH
4875 = ffecom_3 (COND_EXPR, arg4_type,
4877 (ffecom_2 (NE_EXPR, integer_type_node,
4879 convert (TREE_TYPE (arg3_tree),
4880 integer_zero_node))),
4884 = ffecom_3 (COND_EXPR, arg4_type,
4886 (ffecom_2 (NE_EXPR, integer_type_node,
4888 convert (TREE_TYPE (arg3_tree),
4889 TYPE_SIZE (arg4_type)))),
4894 = ffecom_2s (MODIFY_EXPR, void_type_node,
4897 /* Make sure SAVE_EXPRs get referenced early enough. */
4899 = ffecom_2 (COMPOUND_EXPR, void_type_node,
4901 ffecom_2 (COMPOUND_EXPR, void_type_node,
4903 ffecom_2 (COMPOUND_EXPR, void_type_node,
4905 ffecom_2 (COMPOUND_EXPR, void_type_node,
4909 = ffecom_2 (COMPOUND_EXPR, void_type_node,
4916 case FFEINTRIN_impDERF:
4917 case FFEINTRIN_impERF:
4918 case FFEINTRIN_impDERFC:
4919 case FFEINTRIN_impERFC:
4922 case FFEINTRIN_impIARGC:
4923 /* extern int xargc; i__1 = xargc - 1; */
4924 expr_tree = ffecom_2 (MINUS_EXPR, TREE_TYPE (ffecom_tree_xargc_),
4926 convert (TREE_TYPE (ffecom_tree_xargc_),
4930 case FFEINTRIN_impSIGNAL_func:
4931 case FFEINTRIN_impSIGNAL_subr:
4937 arg1_tree = convert (ffecom_f2c_integer_type_node,
4938 ffecom_expr (arg1));
4939 arg1_tree = ffecom_1 (ADDR_EXPR,
4940 build_pointer_type (TREE_TYPE (arg1_tree)),
4943 /* Pass procedure as a pointer to it, anything else by value. */
4944 if (ffeinfo_kind (ffebld_info (arg2)) == FFEINFO_kindENTITY)
4945 arg2_tree = convert (integer_type_node, ffecom_expr (arg2));
4947 arg2_tree = ffecom_ptr_to_expr (arg2);
4948 arg2_tree = convert (TREE_TYPE (null_pointer_node),
4952 arg3_tree = ffecom_expr_w (NULL_TREE, arg3);
4954 arg3_tree = NULL_TREE;
4956 arg1_tree = build_tree_list (NULL_TREE, arg1_tree);
4957 arg2_tree = build_tree_list (NULL_TREE, arg2_tree);
4958 TREE_CHAIN (arg1_tree) = arg2_tree;
4961 = ffecom_call_ (ffecom_gfrt_tree_ (gfrt),
4962 ffecom_gfrt_kindtype (gfrt),
4964 ((codegen_imp == FFEINTRIN_impSIGNAL_subr) ?
4968 NULL_TREE, NULL, NULL, NULL_TREE, TRUE,
4969 ffebld_nonter_hook (expr));
4971 if (arg3_tree != NULL_TREE)
4973 = ffecom_modify (NULL_TREE, arg3_tree,
4974 convert (TREE_TYPE (arg3_tree),
4979 case FFEINTRIN_impALARM:
4985 arg1_tree = convert (ffecom_f2c_integer_type_node,
4986 ffecom_expr (arg1));
4987 arg1_tree = ffecom_1 (ADDR_EXPR,
4988 build_pointer_type (TREE_TYPE (arg1_tree)),
4991 /* Pass procedure as a pointer to it, anything else by value. */
4992 if (ffeinfo_kind (ffebld_info (arg2)) == FFEINFO_kindENTITY)
4993 arg2_tree = convert (integer_type_node, ffecom_expr (arg2));
4995 arg2_tree = ffecom_ptr_to_expr (arg2);
4996 arg2_tree = convert (TREE_TYPE (null_pointer_node),
5000 arg3_tree = ffecom_expr_w (NULL_TREE, arg3);
5002 arg3_tree = NULL_TREE;
5004 arg1_tree = build_tree_list (NULL_TREE, arg1_tree);
5005 arg2_tree = build_tree_list (NULL_TREE, arg2_tree);
5006 TREE_CHAIN (arg1_tree) = arg2_tree;
5009 = ffecom_call_ (ffecom_gfrt_tree_ (gfrt),
5010 ffecom_gfrt_kindtype (gfrt),
5014 NULL_TREE, NULL, NULL, NULL_TREE, TRUE,
5015 ffebld_nonter_hook (expr));
5017 if (arg3_tree != NULL_TREE)
5019 = ffecom_modify (NULL_TREE, arg3_tree,
5020 convert (TREE_TYPE (arg3_tree),
5025 case FFEINTRIN_impCHDIR_subr:
5026 case FFEINTRIN_impFDATE_subr:
5027 case FFEINTRIN_impFGET_subr:
5028 case FFEINTRIN_impFPUT_subr:
5029 case FFEINTRIN_impGETCWD_subr:
5030 case FFEINTRIN_impHOSTNM_subr:
5031 case FFEINTRIN_impSYSTEM_subr:
5032 case FFEINTRIN_impUNLINK_subr:
5034 tree arg1_len = integer_zero_node;
5038 arg1_tree = ffecom_arg_ptr_to_expr (arg1, &arg1_len);
5041 arg2_tree = ffecom_expr_w (NULL_TREE, arg2);
5043 arg2_tree = NULL_TREE;
5045 arg1_tree = build_tree_list (NULL_TREE, arg1_tree);
5046 arg1_len = build_tree_list (NULL_TREE, arg1_len);
5047 TREE_CHAIN (arg1_tree) = arg1_len;
5050 = ffecom_call_ (ffecom_gfrt_tree_ (gfrt),
5051 ffecom_gfrt_kindtype (gfrt),
5055 NULL_TREE, NULL, NULL, NULL_TREE, TRUE,
5056 ffebld_nonter_hook (expr));
5058 if (arg2_tree != NULL_TREE)
5060 = ffecom_modify (NULL_TREE, arg2_tree,
5061 convert (TREE_TYPE (arg2_tree),
5066 case FFEINTRIN_impEXIT:
5070 expr_tree = build_tree_list (NULL_TREE,
5071 ffecom_1 (ADDR_EXPR,
5073 (ffecom_integer_type_node),
5074 integer_zero_node));
5077 ffecom_call_ (ffecom_gfrt_tree_ (gfrt),
5078 ffecom_gfrt_kindtype (gfrt),
5082 NULL_TREE, NULL, NULL, NULL_TREE, TRUE,
5083 ffebld_nonter_hook (expr));
5085 case FFEINTRIN_impFLUSH:
5087 gfrt = FFECOM_gfrtFLUSH;
5089 gfrt = FFECOM_gfrtFLUSH1;
5092 case FFEINTRIN_impCHMOD_subr:
5093 case FFEINTRIN_impLINK_subr:
5094 case FFEINTRIN_impRENAME_subr:
5095 case FFEINTRIN_impSYMLNK_subr:
5097 tree arg1_len = integer_zero_node;
5099 tree arg2_len = integer_zero_node;
5103 arg1_tree = ffecom_arg_ptr_to_expr (arg1, &arg1_len);
5104 arg2_tree = ffecom_arg_ptr_to_expr (arg2, &arg2_len);
5106 arg3_tree = ffecom_expr_w (NULL_TREE, arg3);
5108 arg3_tree = NULL_TREE;
5110 arg1_tree = build_tree_list (NULL_TREE, arg1_tree);
5111 arg1_len = build_tree_list (NULL_TREE, arg1_len);
5112 arg2_tree = build_tree_list (NULL_TREE, arg2_tree);
5113 arg2_len = build_tree_list (NULL_TREE, arg2_len);
5114 TREE_CHAIN (arg1_tree) = arg2_tree;
5115 TREE_CHAIN (arg2_tree) = arg1_len;
5116 TREE_CHAIN (arg1_len) = arg2_len;
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),
5131 case FFEINTRIN_impLSTAT_subr:
5132 case FFEINTRIN_impSTAT_subr:
5134 tree arg1_len = integer_zero_node;
5139 arg1_tree = ffecom_arg_ptr_to_expr (arg1, &arg1_len);
5141 arg2_tree = ffecom_ptr_to_expr (arg2);
5144 arg3_tree = ffecom_expr_w (NULL_TREE, arg3);
5146 arg3_tree = NULL_TREE;
5148 arg1_tree = build_tree_list (NULL_TREE, arg1_tree);
5149 arg1_len = build_tree_list (NULL_TREE, arg1_len);
5150 arg2_tree = build_tree_list (NULL_TREE, arg2_tree);
5151 TREE_CHAIN (arg1_tree) = arg2_tree;
5152 TREE_CHAIN (arg2_tree) = arg1_len;
5153 expr_tree = ffecom_call_ (ffecom_gfrt_tree_ (gfrt),
5154 ffecom_gfrt_kindtype (gfrt),
5158 NULL_TREE, NULL, NULL, NULL_TREE, TRUE,
5159 ffebld_nonter_hook (expr));
5160 if (arg3_tree != NULL_TREE)
5161 expr_tree = ffecom_modify (NULL_TREE, arg3_tree,
5162 convert (TREE_TYPE (arg3_tree),
5167 case FFEINTRIN_impFGETC_subr:
5168 case FFEINTRIN_impFPUTC_subr:
5172 tree arg2_len = integer_zero_node;
5175 arg1_tree = convert (ffecom_f2c_integer_type_node,
5176 ffecom_expr (arg1));
5177 arg1_tree = ffecom_1 (ADDR_EXPR,
5178 build_pointer_type (TREE_TYPE (arg1_tree)),
5181 arg2_tree = ffecom_arg_ptr_to_expr (arg2, &arg2_len);
5182 arg3_tree = ffecom_expr_w (NULL_TREE, arg3);
5184 arg1_tree = build_tree_list (NULL_TREE, arg1_tree);
5185 arg2_tree = build_tree_list (NULL_TREE, arg2_tree);
5186 arg2_len = build_tree_list (NULL_TREE, arg2_len);
5187 TREE_CHAIN (arg1_tree) = arg2_tree;
5188 TREE_CHAIN (arg2_tree) = arg2_len;
5190 expr_tree = ffecom_call_ (ffecom_gfrt_tree_ (gfrt),
5191 ffecom_gfrt_kindtype (gfrt),
5195 NULL_TREE, NULL, NULL, NULL_TREE, TRUE,
5196 ffebld_nonter_hook (expr));
5197 expr_tree = ffecom_modify (NULL_TREE, arg3_tree,
5198 convert (TREE_TYPE (arg3_tree),
5203 case FFEINTRIN_impFSTAT_subr:
5209 arg1_tree = convert (ffecom_f2c_integer_type_node,
5210 ffecom_expr (arg1));
5211 arg1_tree = ffecom_1 (ADDR_EXPR,
5212 build_pointer_type (TREE_TYPE (arg1_tree)),
5215 arg2_tree = convert (ffecom_f2c_ptr_to_integer_type_node,
5216 ffecom_ptr_to_expr (arg2));
5219 arg3_tree = NULL_TREE;
5221 arg3_tree = ffecom_expr_w (NULL_TREE, arg3);
5223 arg1_tree = build_tree_list (NULL_TREE, arg1_tree);
5224 arg2_tree = build_tree_list (NULL_TREE, arg2_tree);
5225 TREE_CHAIN (arg1_tree) = arg2_tree;
5226 expr_tree = ffecom_call_ (ffecom_gfrt_tree_ (gfrt),
5227 ffecom_gfrt_kindtype (gfrt),
5231 NULL_TREE, NULL, NULL, NULL_TREE, TRUE,
5232 ffebld_nonter_hook (expr));
5233 if (arg3_tree != NULL_TREE) {
5234 expr_tree = ffecom_modify (NULL_TREE, arg3_tree,
5235 convert (TREE_TYPE (arg3_tree),
5241 case FFEINTRIN_impKILL_subr:
5247 arg1_tree = convert (ffecom_f2c_integer_type_node,
5248 ffecom_expr (arg1));
5249 arg1_tree = ffecom_1 (ADDR_EXPR,
5250 build_pointer_type (TREE_TYPE (arg1_tree)),
5253 arg2_tree = convert (ffecom_f2c_integer_type_node,
5254 ffecom_expr (arg2));
5255 arg2_tree = ffecom_1 (ADDR_EXPR,
5256 build_pointer_type (TREE_TYPE (arg2_tree)),
5260 arg3_tree = NULL_TREE;
5262 arg3_tree = ffecom_expr_w (NULL_TREE, arg3);
5264 arg1_tree = build_tree_list (NULL_TREE, arg1_tree);
5265 arg2_tree = build_tree_list (NULL_TREE, arg2_tree);
5266 TREE_CHAIN (arg1_tree) = arg2_tree;
5267 expr_tree = ffecom_call_ (ffecom_gfrt_tree_ (gfrt),
5268 ffecom_gfrt_kindtype (gfrt),
5272 NULL_TREE, NULL, NULL, NULL_TREE, TRUE,
5273 ffebld_nonter_hook (expr));
5274 if (arg3_tree != NULL_TREE) {
5275 expr_tree = ffecom_modify (NULL_TREE, arg3_tree,
5276 convert (TREE_TYPE (arg3_tree),
5282 case FFEINTRIN_impCTIME_subr:
5283 case FFEINTRIN_impTTYNAM_subr:
5285 tree arg1_len = integer_zero_node;
5289 arg1_tree = ffecom_arg_ptr_to_expr (arg2, &arg1_len);
5291 arg2_tree = convert (((codegen_imp == FFEINTRIN_impCTIME_subr) ?
5292 ffecom_f2c_longint_type_node :
5293 ffecom_f2c_integer_type_node),
5294 ffecom_expr (arg1));
5295 arg2_tree = ffecom_1 (ADDR_EXPR,
5296 build_pointer_type (TREE_TYPE (arg2_tree)),
5299 arg1_tree = build_tree_list (NULL_TREE, arg1_tree);
5300 arg1_len = build_tree_list (NULL_TREE, arg1_len);
5301 arg2_tree = build_tree_list (NULL_TREE, arg2_tree);
5302 TREE_CHAIN (arg1_len) = arg2_tree;
5303 TREE_CHAIN (arg1_tree) = arg1_len;
5306 = ffecom_call_ (ffecom_gfrt_tree_ (gfrt),
5307 ffecom_gfrt_kindtype (gfrt),
5311 NULL_TREE, NULL, NULL, NULL_TREE, TRUE,
5312 ffebld_nonter_hook (expr));
5313 TREE_SIDE_EFFECTS (expr_tree) = 1;
5317 case FFEINTRIN_impIRAND:
5318 case FFEINTRIN_impRAND:
5319 /* Arg defaults to 0 (normal random case) */
5324 arg1_tree = ffecom_integer_zero_node;
5326 arg1_tree = ffecom_expr (arg1);
5327 arg1_tree = convert (ffecom_f2c_integer_type_node,
5329 arg1_tree = ffecom_1 (ADDR_EXPR,
5330 build_pointer_type (TREE_TYPE (arg1_tree)),
5332 arg1_tree = build_tree_list (NULL_TREE, arg1_tree);
5334 expr_tree = ffecom_call_ (ffecom_gfrt_tree_ (gfrt),
5335 ffecom_gfrt_kindtype (gfrt),
5337 ((codegen_imp == FFEINTRIN_impIRAND) ?
5338 ffecom_f2c_integer_type_node :
5339 ffecom_f2c_real_type_node),
5341 dest_tree, dest, dest_used,
5343 ffebld_nonter_hook (expr));
5347 case FFEINTRIN_impFTELL_subr:
5348 case FFEINTRIN_impUMASK_subr:
5353 arg1_tree = convert (ffecom_f2c_integer_type_node,
5354 ffecom_expr (arg1));
5355 arg1_tree = ffecom_1 (ADDR_EXPR,
5356 build_pointer_type (TREE_TYPE (arg1_tree)),
5360 arg2_tree = NULL_TREE;
5362 arg2_tree = ffecom_expr_w (NULL_TREE, arg2);
5364 expr_tree = ffecom_call_ (ffecom_gfrt_tree_ (gfrt),
5365 ffecom_gfrt_kindtype (gfrt),
5368 build_tree_list (NULL_TREE, arg1_tree),
5369 NULL_TREE, NULL, NULL, NULL_TREE,
5371 ffebld_nonter_hook (expr));
5372 if (arg2_tree != NULL_TREE) {
5373 expr_tree = ffecom_modify (NULL_TREE, arg2_tree,
5374 convert (TREE_TYPE (arg2_tree),
5380 case FFEINTRIN_impCPU_TIME:
5381 case FFEINTRIN_impSECOND_subr:
5385 arg1_tree = ffecom_expr_w (NULL_TREE, arg1);
5388 = ffecom_call_ (ffecom_gfrt_tree_ (gfrt),
5389 ffecom_gfrt_kindtype (gfrt),
5393 NULL_TREE, NULL, NULL, NULL_TREE, TRUE,
5394 ffebld_nonter_hook (expr));
5397 = ffecom_modify (NULL_TREE, arg1_tree,
5398 convert (TREE_TYPE (arg1_tree),
5403 case FFEINTRIN_impDTIME_subr:
5404 case FFEINTRIN_impETIME_subr:
5409 result_tree = ffecom_expr_w (NULL_TREE, arg2);
5411 arg1_tree = ffecom_ptr_to_expr (arg1);
5413 expr_tree = ffecom_call_ (ffecom_gfrt_tree_ (gfrt),
5414 ffecom_gfrt_kindtype (gfrt),
5417 build_tree_list (NULL_TREE, arg1_tree),
5418 NULL_TREE, NULL, NULL, NULL_TREE,
5420 ffebld_nonter_hook (expr));
5421 expr_tree = ffecom_modify (NULL_TREE, result_tree,
5422 convert (TREE_TYPE (result_tree),
5427 /* Straightforward calls of libf2c routines: */
5428 case FFEINTRIN_impABORT:
5429 case FFEINTRIN_impACCESS:
5430 case FFEINTRIN_impBESJ0:
5431 case FFEINTRIN_impBESJ1:
5432 case FFEINTRIN_impBESJN:
5433 case FFEINTRIN_impBESY0:
5434 case FFEINTRIN_impBESY1:
5435 case FFEINTRIN_impBESYN:
5436 case FFEINTRIN_impCHDIR_func:
5437 case FFEINTRIN_impCHMOD_func:
5438 case FFEINTRIN_impDATE:
5439 case FFEINTRIN_impDATE_AND_TIME:
5440 case FFEINTRIN_impDBESJ0:
5441 case FFEINTRIN_impDBESJ1:
5442 case FFEINTRIN_impDBESJN:
5443 case FFEINTRIN_impDBESY0:
5444 case FFEINTRIN_impDBESY1:
5445 case FFEINTRIN_impDBESYN:
5446 case FFEINTRIN_impDTIME_func:
5447 case FFEINTRIN_impETIME_func:
5448 case FFEINTRIN_impFGETC_func:
5449 case FFEINTRIN_impFGET_func:
5450 case FFEINTRIN_impFNUM:
5451 case FFEINTRIN_impFPUTC_func:
5452 case FFEINTRIN_impFPUT_func:
5453 case FFEINTRIN_impFSEEK:
5454 case FFEINTRIN_impFSTAT_func:
5455 case FFEINTRIN_impFTELL_func:
5456 case FFEINTRIN_impGERROR:
5457 case FFEINTRIN_impGETARG:
5458 case FFEINTRIN_impGETCWD_func:
5459 case FFEINTRIN_impGETENV:
5460 case FFEINTRIN_impGETGID:
5461 case FFEINTRIN_impGETLOG:
5462 case FFEINTRIN_impGETPID:
5463 case FFEINTRIN_impGETUID:
5464 case FFEINTRIN_impGMTIME:
5465 case FFEINTRIN_impHOSTNM_func:
5466 case FFEINTRIN_impIDATE_unix:
5467 case FFEINTRIN_impIDATE_vxt:
5468 case FFEINTRIN_impIERRNO:
5469 case FFEINTRIN_impISATTY:
5470 case FFEINTRIN_impITIME:
5471 case FFEINTRIN_impKILL_func:
5472 case FFEINTRIN_impLINK_func:
5473 case FFEINTRIN_impLNBLNK:
5474 case FFEINTRIN_impLSTAT_func:
5475 case FFEINTRIN_impLTIME:
5476 case FFEINTRIN_impMCLOCK8:
5477 case FFEINTRIN_impMCLOCK:
5478 case FFEINTRIN_impPERROR:
5479 case FFEINTRIN_impRENAME_func:
5480 case FFEINTRIN_impSECNDS:
5481 case FFEINTRIN_impSECOND_func:
5482 case FFEINTRIN_impSLEEP:
5483 case FFEINTRIN_impSRAND:
5484 case FFEINTRIN_impSTAT_func:
5485 case FFEINTRIN_impSYMLNK_func:
5486 case FFEINTRIN_impSYSTEM_CLOCK:
5487 case FFEINTRIN_impSYSTEM_func:
5488 case FFEINTRIN_impTIME8:
5489 case FFEINTRIN_impTIME_unix:
5490 case FFEINTRIN_impTIME_vxt:
5491 case FFEINTRIN_impUMASK_func:
5492 case FFEINTRIN_impUNLINK_func:
5495 case FFEINTRIN_impCTIME_func: /* CHARACTER functions not handled here. */
5496 case FFEINTRIN_impFDATE_func: /* CHARACTER functions not handled here. */
5497 case FFEINTRIN_impTTYNAM_func: /* CHARACTER functions not handled here. */
5498 case FFEINTRIN_impNONE:
5499 case FFEINTRIN_imp: /* Hush up gcc warning. */
5500 fprintf (stderr, "No %s implementation.\n",
5501 ffeintrin_name_implementation (ffebld_symter_implementation (ffebld_left (expr))));
5502 assert ("unimplemented intrinsic" == NULL);
5503 return error_mark_node;
5506 assert (gfrt != FFECOM_gfrt); /* Must have an implementation! */
5508 expr_tree = ffecom_arglist_expr_ (ffecom_gfrt_args_ (gfrt),
5509 ffebld_right (expr));
5511 return ffecom_call_ (ffecom_gfrt_tree_ (gfrt), ffecom_gfrt_kindtype (gfrt),
5512 (ffe_is_f2c_library () && ffecom_gfrt_complex_[gfrt]),
5514 expr_tree, dest_tree, dest, dest_used,
5516 ffebld_nonter_hook (expr));
5518 /* See bottom of this file for f2c transforms used to determine
5519 many of the above implementations. The info seems to confuse
5520 Emacs's C mode indentation, which is why it's been moved to
5521 the bottom of this source file. */
5525 /* For power (exponentiation) where right-hand operand is type INTEGER,
5526 generate in-line code to do it the fast way (which, if the operand
5527 is a constant, might just mean a series of multiplies). */
5529 #if FFECOM_targetCURRENT == FFECOM_targetGCC
5531 ffecom_expr_power_integer_ (ffebld expr)
5533 tree l = ffecom_expr (ffebld_left (expr));
5534 tree r = ffecom_expr (ffebld_right (expr));
5535 tree ltype = TREE_TYPE (l);
5536 tree rtype = TREE_TYPE (r);
5537 tree result = NULL_TREE;
5539 if (l == error_mark_node
5540 || r == error_mark_node)
5541 return error_mark_node;
5543 if (TREE_CODE (r) == INTEGER_CST)
5545 int sgn = tree_int_cst_sgn (r);
5548 return convert (ltype, integer_one_node);
5550 if ((TREE_CODE (ltype) == INTEGER_TYPE)
5553 /* Reciprocal of integer is either 0, -1, or 1, so after
5554 calculating that (which we leave to the back end to do
5555 or not do optimally), don't bother with any multiplying. */
5557 result = ffecom_tree_divide_ (ltype,
5558 convert (ltype, integer_one_node),
5560 NULL_TREE, NULL, NULL, NULL_TREE);
5561 r = ffecom_1 (NEGATE_EXPR,
5564 if ((TREE_INT_CST_LOW (r) & 1) == 0)
5565 result = ffecom_1 (ABS_EXPR, rtype,
5569 /* Generate appropriate series of multiplies, preceded
5570 by divide if the exponent is negative. */
5576 l = ffecom_tree_divide_ (ltype,
5577 convert (ltype, integer_one_node),
5579 NULL_TREE, NULL, NULL,
5580 ffebld_nonter_hook (expr));
5581 r = ffecom_1 (NEGATE_EXPR, rtype, r);
5582 assert (TREE_CODE (r) == INTEGER_CST);
5584 if (tree_int_cst_sgn (r) < 0)
5585 { /* The "most negative" number. */
5586 r = ffecom_1 (NEGATE_EXPR, rtype,
5587 ffecom_2 (RSHIFT_EXPR, rtype,
5591 l = ffecom_2 (MULT_EXPR, ltype,
5599 if (TREE_INT_CST_LOW (r) & 1)
5601 if (result == NULL_TREE)
5604 result = ffecom_2 (MULT_EXPR, ltype,
5609 r = ffecom_2 (RSHIFT_EXPR, rtype,
5612 if (integer_zerop (r))
5614 assert (TREE_CODE (r) == INTEGER_CST);
5617 l = ffecom_2 (MULT_EXPR, ltype,
5624 /* Though rhs isn't a constant, in-line code cannot be expanded
5625 while transforming dummies
5626 because the back end cannot be easily convinced to generate
5627 stores (MODIFY_EXPR), handle temporaries, and so on before
5628 all the appropriate rtx's have been generated for things like
5629 dummy args referenced in rhs -- which doesn't happen until
5630 store_parm_decls() is called (expand_function_start, I believe,
5631 does the actual rtx-stuffing of PARM_DECLs).
5633 So, in this case, let the caller generate the call to the
5634 run-time-library function to evaluate the power for us. */
5636 if (ffecom_transform_only_dummies_)
5639 /* Right-hand operand not a constant, expand in-line code to figure
5640 out how to do the multiplies, &c.
5642 The returned expression is expressed this way in GNU C, where l and
5645 ({ typeof (r) rtmp = r;
5646 typeof (l) ltmp = l;
5653 if ((basetypeof (l) == basetypeof (int))
5656 result = ((typeof (l)) 1) / ltmp;
5657 if ((ltmp < 0) && (((-rtmp) & 1) == 0))
5663 if ((basetypeof (l) != basetypeof (int))
5666 ltmp = ((typeof (l)) 1) / ltmp;
5670 rtmp = -(rtmp >> 1);
5678 if ((rtmp >>= 1) == 0)
5687 Note that some of the above is compile-time collapsable, such as
5688 the first part of the if statements that checks the base type of
5689 l against int. The if statements are phrased that way to suggest
5690 an easy way to generate the if/else constructs here, knowing that
5691 the back end should (and probably does) eliminate the resulting
5692 dead code (either the int case or the non-int case), something
5693 it couldn't do without the redundant phrasing, requiring explicit
5694 dead-code elimination here, which would be kind of difficult to
5701 tree basetypeof_l_is_int;
5706 = build_int_2 ((TREE_CODE (ltype) == INTEGER_TYPE), 0);
5708 se = expand_start_stmt_expr ();
5710 ffecom_start_compstmt ();
5713 rtmp = ffecom_make_tempvar ("power_r", rtype,
5714 FFETARGET_charactersizeNONE, -1);
5715 ltmp = ffecom_make_tempvar ("power_l", ltype,
5716 FFETARGET_charactersizeNONE, -1);
5717 result = ffecom_make_tempvar ("power_res", ltype,
5718 FFETARGET_charactersizeNONE, -1);
5719 if (TREE_CODE (ltype) == COMPLEX_TYPE
5720 || TREE_CODE (ltype) == RECORD_TYPE)
5721 divide = ffecom_make_tempvar ("power_div", ltype,
5722 FFETARGET_charactersizeNONE, -1);
5729 hook = ffebld_nonter_hook (expr);
5731 assert (TREE_CODE (hook) == TREE_VEC);
5732 assert (TREE_VEC_LENGTH (hook) == 4);
5733 rtmp = TREE_VEC_ELT (hook, 0);
5734 ltmp = TREE_VEC_ELT (hook, 1);
5735 result = TREE_VEC_ELT (hook, 2);
5736 divide = TREE_VEC_ELT (hook, 3);
5737 if (TREE_CODE (ltype) == COMPLEX_TYPE
5738 || TREE_CODE (ltype) == RECORD_TYPE)
5745 expand_expr_stmt (ffecom_modify (void_type_node,
5748 expand_expr_stmt (ffecom_modify (void_type_node,
5751 expand_start_cond (ffecom_truth_value
5752 (ffecom_2 (EQ_EXPR, integer_type_node,
5754 convert (rtype, integer_zero_node))),
5756 expand_expr_stmt (ffecom_modify (void_type_node,
5758 convert (ltype, integer_one_node)));
5759 expand_start_else ();
5760 if (! integer_zerop (basetypeof_l_is_int))
5762 expand_start_cond (ffecom_2 (LT_EXPR, integer_type_node,
5765 integer_zero_node)),
5767 expand_expr_stmt (ffecom_modify (void_type_node,
5771 convert (ltype, integer_one_node),
5773 NULL_TREE, NULL, NULL,
5775 expand_start_cond (ffecom_truth_value
5776 (ffecom_2 (TRUTH_ANDIF_EXPR, integer_type_node,
5777 ffecom_2 (LT_EXPR, integer_type_node,
5780 integer_zero_node)),
5781 ffecom_2 (EQ_EXPR, integer_type_node,
5782 ffecom_2 (BIT_AND_EXPR,
5784 ffecom_1 (NEGATE_EXPR,
5790 integer_zero_node)))),
5792 expand_expr_stmt (ffecom_modify (void_type_node,
5794 ffecom_1 (NEGATE_EXPR,
5798 expand_start_else ();
5800 expand_expr_stmt (ffecom_modify (void_type_node,
5802 convert (ltype, integer_one_node)));
5803 expand_start_cond (ffecom_truth_value
5804 (ffecom_2 (TRUTH_ANDIF_EXPR, integer_type_node,
5805 ffecom_truth_value_invert
5806 (basetypeof_l_is_int),
5807 ffecom_2 (LT_EXPR, integer_type_node,
5810 integer_zero_node)))),
5812 expand_expr_stmt (ffecom_modify (void_type_node,
5816 convert (ltype, integer_one_node),
5818 NULL_TREE, NULL, NULL,
5820 expand_expr_stmt (ffecom_modify (void_type_node,
5822 ffecom_1 (NEGATE_EXPR, rtype,
5824 expand_start_cond (ffecom_truth_value
5825 (ffecom_2 (LT_EXPR, integer_type_node,
5827 convert (rtype, integer_zero_node))),
5829 expand_expr_stmt (ffecom_modify (void_type_node,
5831 ffecom_1 (NEGATE_EXPR, rtype,
5832 ffecom_2 (RSHIFT_EXPR,
5835 integer_one_node))));
5836 expand_expr_stmt (ffecom_modify (void_type_node,
5838 ffecom_2 (MULT_EXPR, ltype,
5843 expand_start_loop (1);
5844 expand_start_cond (ffecom_truth_value
5845 (ffecom_2 (BIT_AND_EXPR, rtype,
5847 convert (rtype, integer_one_node))),
5849 expand_expr_stmt (ffecom_modify (void_type_node,
5851 ffecom_2 (MULT_EXPR, ltype,
5855 expand_exit_loop_if_false (NULL,
5857 (ffecom_modify (rtype,
5859 ffecom_2 (RSHIFT_EXPR,
5862 integer_one_node))));
5863 expand_expr_stmt (ffecom_modify (void_type_node,
5865 ffecom_2 (MULT_EXPR, ltype,
5870 if (!integer_zerop (basetypeof_l_is_int))
5872 expand_expr_stmt (result);
5874 t = ffecom_end_compstmt ();
5876 result = expand_end_stmt_expr (se);
5878 /* This code comes from c-parse.in, after its expand_end_stmt_expr. */
5880 if (TREE_CODE (t) == BLOCK)
5882 /* Make a BIND_EXPR for the BLOCK already made. */
5883 result = build (BIND_EXPR, TREE_TYPE (result),
5884 NULL_TREE, result, t);
5885 /* Remove the block from the tree at this point.
5886 It gets put back at the proper place
5887 when the BIND_EXPR is expanded. */
5898 /* ffecom_expr_transform_ -- Transform symbols in expr
5900 ffebld expr; // FFE expression.
5901 ffecom_expr_transform_ (expr);
5903 Recursive descent on expr while transforming any untransformed SYMTERs. */
5905 #if FFECOM_targetCURRENT == FFECOM_targetGCC
5907 ffecom_expr_transform_ (ffebld expr)
5912 tail_recurse: /* :::::::::::::::::::: */
5917 switch (ffebld_op (expr))
5919 case FFEBLD_opSYMTER:
5920 s = ffebld_symter (expr);
5921 t = ffesymbol_hook (s).decl_tree;
5922 if ((t == NULL_TREE)
5923 && ((ffesymbol_kind (s) != FFEINFO_kindNONE)
5924 || ((ffesymbol_where (s) != FFEINFO_whereNONE)
5925 && (ffesymbol_where (s) != FFEINFO_whereINTRINSIC))))
5927 s = ffecom_sym_transform_ (s);
5928 t = ffesymbol_hook (s).decl_tree; /* Sfunc expr non-dummy,
5931 break; /* Ok if (t == NULL) here. */
5934 ffecom_expr_transform_ (ffebld_head (expr));
5935 expr = ffebld_trail (expr);
5936 goto tail_recurse; /* :::::::::::::::::::: */
5942 switch (ffebld_arity (expr))
5945 ffecom_expr_transform_ (ffebld_left (expr));
5946 expr = ffebld_right (expr);
5947 goto tail_recurse; /* :::::::::::::::::::: */
5950 expr = ffebld_left (expr);
5951 goto tail_recurse; /* :::::::::::::::::::: */
5961 /* Make a type based on info in live f2c.h file. */
5963 #if FFECOM_targetCURRENT == FFECOM_targetGCC
5965 ffecom_f2c_make_type_ (tree *type, int tcode, const char *name)
5969 case FFECOM_f2ccodeCHAR:
5970 *type = make_signed_type (CHAR_TYPE_SIZE);
5973 case FFECOM_f2ccodeSHORT:
5974 *type = make_signed_type (SHORT_TYPE_SIZE);
5977 case FFECOM_f2ccodeINT:
5978 *type = make_signed_type (INT_TYPE_SIZE);
5981 case FFECOM_f2ccodeLONG:
5982 *type = make_signed_type (LONG_TYPE_SIZE);
5985 case FFECOM_f2ccodeLONGLONG:
5986 *type = make_signed_type (LONG_LONG_TYPE_SIZE);
5989 case FFECOM_f2ccodeCHARPTR:
5990 *type = build_pointer_type (DEFAULT_SIGNED_CHAR
5991 ? signed_char_type_node
5992 : unsigned_char_type_node);
5995 case FFECOM_f2ccodeFLOAT:
5996 *type = make_node (REAL_TYPE);
5997 TYPE_PRECISION (*type) = FLOAT_TYPE_SIZE;
5998 layout_type (*type);
6001 case FFECOM_f2ccodeDOUBLE:
6002 *type = make_node (REAL_TYPE);
6003 TYPE_PRECISION (*type) = DOUBLE_TYPE_SIZE;
6004 layout_type (*type);
6007 case FFECOM_f2ccodeLONGDOUBLE:
6008 *type = make_node (REAL_TYPE);
6009 TYPE_PRECISION (*type) = LONG_DOUBLE_TYPE_SIZE;
6010 layout_type (*type);
6013 case FFECOM_f2ccodeTWOREALS:
6014 *type = ffecom_make_complex_type_ (ffecom_f2c_real_type_node);
6017 case FFECOM_f2ccodeTWODOUBLEREALS:
6018 *type = ffecom_make_complex_type_ (ffecom_f2c_doublereal_type_node);
6022 assert ("unexpected FFECOM_f2ccodeXYZZY!" == NULL);
6023 *type = error_mark_node;
6027 pushdecl (build_decl (TYPE_DECL,
6028 ffecom_get_invented_identifier ("__g77_f2c_%s", name),
6033 #if FFECOM_targetCURRENT == FFECOM_targetGCC
6034 /* Set the f2c list-directed-I/O code for whatever (integral) type has the
6038 ffecom_f2c_set_lio_code_ (ffeinfoBasictype bt, int size,
6044 for (j = 0; ((size_t) j) < ARRAY_SIZE (ffecom_tree_type[0]); ++j)
6045 if ((t = ffecom_tree_type[bt][j]) != NULL_TREE
6046 && compare_tree_int (TYPE_SIZE (t), size) == 0)
6048 assert (code != -1);
6049 ffecom_f2c_typecode_[bt][j] = code;
6055 /* Finish up globals after doing all program units in file
6057 Need to handle only uninitialized COMMON areas. */
6059 #if FFECOM_targetCURRENT == FFECOM_targetGCC
6061 ffecom_finish_global_ (ffeglobal global)
6067 if (ffeglobal_type (global) != FFEGLOBAL_typeCOMMON)
6070 if (ffeglobal_common_init (global))
6073 cbt = ffeglobal_hook (global);
6074 if ((cbt == NULL_TREE)
6075 || !ffeglobal_common_have_size (global))
6076 return global; /* No need to make common, never ref'd. */
6078 suspend_momentary ();
6080 DECL_EXTERNAL (cbt) = 0;
6082 /* Give the array a size now. */
6084 size = build_int_2 ((ffeglobal_common_size (global)
6085 + ffeglobal_common_pad (global)) - 1,
6088 cbtype = TREE_TYPE (cbt);
6089 TYPE_DOMAIN (cbtype) = build_range_type (integer_type_node,
6092 if (!TREE_TYPE (size))
6093 TREE_TYPE (size) = TYPE_DOMAIN (cbtype);
6094 layout_type (cbtype);
6096 cbt = start_decl (cbt, FALSE);
6097 assert (cbt == ffeglobal_hook (global));
6099 finish_decl (cbt, NULL_TREE, FALSE);
6105 /* Finish up any untransformed symbols. */
6107 #if FFECOM_targetCURRENT == FFECOM_targetGCC
6109 ffecom_finish_symbol_transform_ (ffesymbol s)
6111 if ((s == NULL) || (TREE_CODE (current_function_decl) == ERROR_MARK))
6114 /* It's easy to know to transform an untransformed symbol, to make sure
6115 we put out debugging info for it. But COMMON variables, unlike
6116 EQUIVALENCE ones, aren't given declarations in addition to the
6117 tree expressions that specify offsets, because COMMON variables
6118 can be referenced in the outer scope where only dummy arguments
6119 (PARM_DECLs) should really be seen. To be safe, just don't do any
6120 VAR_DECLs for COMMON variables when we transform them for real
6121 use, and therefore we do all the VAR_DECL creating here. */
6123 if (ffesymbol_hook (s).decl_tree == NULL_TREE)
6125 if (ffesymbol_kind (s) != FFEINFO_kindNONE
6126 || (ffesymbol_where (s) != FFEINFO_whereNONE
6127 && ffesymbol_where (s) != FFEINFO_whereINTRINSIC
6128 && ffesymbol_where (s) != FFEINFO_whereDUMMY))
6129 /* Not transformed, and not CHARACTER*(*), and not a dummy
6130 argument, which can happen only if the entry point names
6131 it "rides in on" are all invalidated for other reasons. */
6132 s = ffecom_sym_transform_ (s);
6135 if ((ffesymbol_where (s) == FFEINFO_whereCOMMON)
6136 && (ffesymbol_hook (s).decl_tree != error_mark_node))
6138 int yes = suspend_momentary ();
6140 /* This isn't working, at least for dbxout. The .s file looks
6141 okay to me (burley), but in gdb 4.9 at least, the variables
6142 appear to reside somewhere outside of the common area, so
6143 it doesn't make sense to mislead anyone by generating the info
6144 on those variables until this is fixed. NOTE: Same problem
6145 with EQUIVALENCE, sadly...see similar #if later. */
6146 ffecom_member_phase2_ (ffesymbol_storage (ffesymbol_common (s)),
6147 ffesymbol_storage (s));
6149 resume_momentary (yes);
6156 /* Append underscore(s) to name before calling get_identifier. "us"
6157 is nonzero if the name already contains an underscore and thus
6158 needs two underscores appended. */
6160 #if FFECOM_targetCURRENT == FFECOM_targetGCC
6162 ffecom_get_appended_identifier_ (char us, const char *name)
6168 newname = xmalloc ((i = strlen (name)) + 1
6169 + ffe_is_underscoring ()
6171 memcpy (newname, name, i);
6173 newname[i + us] = '_';
6174 newname[i + 1 + us] = '\0';
6175 id = get_identifier (newname);
6183 /* Decide whether to append underscore to name before calling
6186 #if FFECOM_targetCURRENT == FFECOM_targetGCC
6188 ffecom_get_external_identifier_ (ffesymbol s)
6191 const char *name = ffesymbol_text (s);
6193 /* If name is a built-in name, just return it as is. */
6195 if (!ffe_is_underscoring ()
6196 || (strcmp (name, FFETARGET_nameBLANK_COMMON) == 0)
6197 #if FFETARGET_isENFORCED_MAIN_NAME
6198 || (strcmp (name, FFETARGET_nameENFORCED_NAME) == 0)
6200 || (strcmp (name, FFETARGET_nameUNNAMED_MAIN) == 0)
6202 || (strcmp (name, FFETARGET_nameUNNAMED_BLOCK_DATA) == 0))
6203 return get_identifier (name);
6205 us = ffe_is_second_underscore ()
6206 ? (strchr (name, '_') != NULL)
6209 return ffecom_get_appended_identifier_ (us, name);
6213 /* Decide whether to append underscore to internal name before calling
6216 This is for non-external, top-function-context names only. Transform
6217 identifier so it doesn't conflict with the transformed result
6218 of using a _different_ external name. E.g. if "CALL FOO" is
6219 transformed into "FOO_();", then the variable in "FOO_ = 3"
6220 must be transformed into something that does not conflict, since
6221 these two things should be independent.
6223 The transformation is as follows. If the name does not contain
6224 an underscore, there is no possible conflict, so just return.
6225 If the name does contain an underscore, then transform it just
6226 like we transform an external identifier. */
6228 #if FFECOM_targetCURRENT == FFECOM_targetGCC
6230 ffecom_get_identifier_ (const char *name)
6232 /* If name does not contain an underscore, just return it as is. */
6234 if (!ffe_is_underscoring ()
6235 || (strchr (name, '_') == NULL))
6236 return get_identifier (name);
6238 return ffecom_get_appended_identifier_ (ffe_is_second_underscore (),
6243 /* ffecom_gen_sfuncdef_ -- Generate definition of statement function
6246 ffesymbol s; // kindFUNCTION, whereIMMEDIATE.
6247 t = ffecom_gen_sfuncdef_(s,ffesymbol_basictype(s),
6248 ffesymbol_kindtype(s));
6250 Call after setting up containing function and getting trees for all
6253 #if FFECOM_targetCURRENT == FFECOM_targetGCC
6255 ffecom_gen_sfuncdef_ (ffesymbol s, ffeinfoBasictype bt, ffeinfoKindtype kt)
6257 ffebld expr = ffesymbol_sfexpr (s);
6261 bool charfunc = (bt == FFEINFO_basictypeCHARACTER);
6262 static bool recurse = FALSE;
6264 int old_lineno = lineno;
6265 char *old_input_filename = input_filename;
6267 ffecom_nested_entry_ = s;
6269 /* For now, we don't have a handy pointer to where the sfunc is actually
6270 defined, though that should be easy to add to an ffesymbol. (The
6271 token/where info available might well point to the place where the type
6272 of the sfunc is declared, especially if that precedes the place where
6273 the sfunc itself is defined, which is typically the case.) We should
6274 put out a null pointer rather than point somewhere wrong, but I want to
6275 see how it works at this point. */
6277 input_filename = ffesymbol_where_filename (s);
6278 lineno = ffesymbol_where_filelinenum (s);
6280 /* Pretransform the expression so any newly discovered things belong to the
6281 outer program unit, not to the statement function. */
6283 ffecom_expr_transform_ (expr);
6285 /* Make sure no recursive invocation of this fn (a specific case of failing
6286 to pretransform an sfunc's expression, i.e. where its expression
6287 references another untransformed sfunc) happens. */
6292 yes = suspend_momentary ();
6294 push_f_function_context ();
6297 type = void_type_node;
6300 type = ffecom_tree_type[bt][kt];
6301 if (type == NULL_TREE)
6302 type = integer_type_node; /* _sym_exec_transition reports
6306 start_function (ffecom_get_identifier_ (ffesymbol_text (s)),
6307 build_function_type (type, NULL_TREE),
6308 1, /* nested/inline */
6309 0); /* TREE_PUBLIC */
6311 /* We don't worry about COMPLEX return values here, because this is
6312 entirely internal to our code, and gcc has the ability to return COMPLEX
6313 directly as a value. */
6315 yes = suspend_momentary ();
6318 { /* Prepend arg for where result goes. */
6321 type = ffecom_tree_type[FFEINFO_basictypeCHARACTER][kt];
6323 result = ffecom_get_invented_identifier ("__g77_%s", "result");
6325 ffecom_char_enhance_arg_ (&type, s); /* Ignore returned length. */
6327 type = build_pointer_type (type);
6328 result = build_decl (PARM_DECL, result, type);
6330 push_parm_decl (result);
6333 result = NULL_TREE; /* Not ref'd if !charfunc. */
6335 ffecom_push_dummy_decls_ (ffesymbol_dummyargs (s), TRUE);
6337 resume_momentary (yes);
6339 store_parm_decls (0);
6341 ffecom_start_compstmt ();
6347 ffetargetCharacterSize sz = ffesymbol_size (s);
6350 result_length = build_int_2 (sz, 0);
6351 TREE_TYPE (result_length) = ffecom_f2c_ftnlen_type_node;
6353 ffecom_prepare_let_char_ (sz, expr);
6355 ffecom_prepare_end ();
6357 ffecom_let_char_ (result, result_length, sz, expr);
6358 expand_null_return ();
6362 ffecom_prepare_expr (expr);
6364 ffecom_prepare_end ();
6366 expand_return (ffecom_modify (NULL_TREE,
6367 DECL_RESULT (current_function_decl),
6368 ffecom_expr (expr)));
6374 ffecom_end_compstmt ();
6376 func = current_function_decl;
6377 finish_function (1);
6379 pop_f_function_context ();
6381 resume_momentary (yes);
6385 lineno = old_lineno;
6386 input_filename = old_input_filename;
6388 ffecom_nested_entry_ = NULL;
6395 #if FFECOM_targetCURRENT == FFECOM_targetGCC
6397 ffecom_gfrt_args_ (ffecomGfrt ix)
6399 return ffecom_gfrt_argstring_[ix];
6403 #if FFECOM_targetCURRENT == FFECOM_targetGCC
6405 ffecom_gfrt_tree_ (ffecomGfrt ix)
6407 if (ffecom_gfrt_[ix] == NULL_TREE)
6408 ffecom_make_gfrt_ (ix);
6410 return ffecom_1 (ADDR_EXPR,
6411 build_pointer_type (TREE_TYPE (ffecom_gfrt_[ix])),
6416 /* Return initialize-to-zero expression for this VAR_DECL. */
6418 #if FFECOM_targetCURRENT == FFECOM_targetGCC
6419 /* A somewhat evil way to prevent the garbage collector
6420 from collecting 'tree' structures. */
6421 #define NUM_TRACKED_CHUNK 63
6422 static struct tree_ggc_tracker
6424 struct tree_ggc_tracker *next;
6425 tree trees[NUM_TRACKED_CHUNK];
6426 } *tracker_head = NULL;
6429 mark_tracker_head (void *arg)
6431 struct tree_ggc_tracker *head;
6434 for (head = * (struct tree_ggc_tracker **) arg;
6439 for (i = 0; i < NUM_TRACKED_CHUNK; i++)
6440 ggc_mark_tree (head->trees[i]);
6445 ffecom_save_tree_forever (tree t)
6448 if (tracker_head != NULL)
6449 for (i = 0; i < NUM_TRACKED_CHUNK; i++)
6450 if (tracker_head->trees[i] == NULL)
6452 tracker_head->trees[i] = t;
6457 /* Need to allocate a new block. */
6458 struct tree_ggc_tracker *old_head = tracker_head;
6460 tracker_head = ggc_alloc (sizeof (*tracker_head));
6461 tracker_head->next = old_head;
6462 tracker_head->trees[0] = t;
6463 for (i = 1; i < NUM_TRACKED_CHUNK; i++)
6464 tracker_head->trees[i] = NULL;
6469 ffecom_init_zero_ (tree decl)
6472 int incremental = TREE_STATIC (decl);
6473 tree type = TREE_TYPE (decl);
6477 make_decl_rtl (decl, NULL, TREE_PUBLIC (decl) ? 1 : 0);
6478 assemble_variable (decl, TREE_PUBLIC (decl) ? 1 : 0, 0, 1);
6483 if ((TREE_CODE (type) != ARRAY_TYPE)
6484 && (TREE_CODE (type) != RECORD_TYPE)
6485 && (TREE_CODE (type) != UNION_TYPE)
6487 init = convert (type, integer_zero_node);
6488 else if (!incremental)
6490 int momentary = suspend_momentary ();
6492 init = build (CONSTRUCTOR, type, NULL_TREE, NULL_TREE);
6493 TREE_CONSTANT (init) = 1;
6494 TREE_STATIC (init) = 1;
6496 resume_momentary (momentary);
6500 int momentary = suspend_momentary ();
6502 assemble_zeros (int_size_in_bytes (type));
6503 init = error_mark_node;
6505 resume_momentary (momentary);
6508 pop_momentary_nofree ();
6514 #if FFECOM_targetCURRENT == FFECOM_targetGCC
6516 ffecom_intrinsic_ichar_ (tree tree_type, ffebld arg,
6522 switch (ffebld_op (arg))
6524 case FFEBLD_opCONTER: /* For F90, check 0-length. */
6525 if (ffetarget_length_character1
6526 (ffebld_constant_character1
6527 (ffebld_conter (arg))) == 0)
6529 *maybe_tree = integer_zero_node;
6530 return convert (tree_type, integer_zero_node);
6533 *maybe_tree = integer_one_node;
6534 expr_tree = build_int_2 (*ffetarget_text_character1
6535 (ffebld_constant_character1
6536 (ffebld_conter (arg))),
6538 TREE_TYPE (expr_tree) = tree_type;
6541 case FFEBLD_opSYMTER:
6542 case FFEBLD_opARRAYREF:
6543 case FFEBLD_opFUNCREF:
6544 case FFEBLD_opSUBSTR:
6545 ffecom_char_args_ (&expr_tree, &length_tree, arg);
6547 if ((expr_tree == error_mark_node)
6548 || (length_tree == error_mark_node))
6550 *maybe_tree = error_mark_node;
6551 return error_mark_node;
6554 if (integer_zerop (length_tree))
6556 *maybe_tree = integer_zero_node;
6557 return convert (tree_type, integer_zero_node);
6561 = ffecom_1 (INDIRECT_REF,
6562 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (expr_tree))),
6565 = ffecom_2 (ARRAY_REF,
6566 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (expr_tree))),
6569 expr_tree = convert (tree_type, expr_tree);
6571 if (TREE_CODE (length_tree) == INTEGER_CST)
6572 *maybe_tree = integer_one_node;
6573 else /* Must check length at run time. */
6575 = ffecom_truth_value
6576 (ffecom_2 (GT_EXPR, integer_type_node,
6578 ffecom_f2c_ftnlen_zero_node));
6581 case FFEBLD_opPAREN:
6582 case FFEBLD_opCONVERT:
6583 if (ffeinfo_size (ffebld_info (arg)) == 0)
6585 *maybe_tree = integer_zero_node;
6586 return convert (tree_type, integer_zero_node);
6588 return ffecom_intrinsic_ichar_ (tree_type, ffebld_left (arg),
6591 case FFEBLD_opCONCATENATE:
6598 expr_left = ffecom_intrinsic_ichar_ (tree_type, ffebld_left (arg),
6600 expr_right = ffecom_intrinsic_ichar_ (tree_type, ffebld_right (arg),
6602 *maybe_tree = ffecom_2 (TRUTH_ORIF_EXPR, integer_type_node,
6605 expr_tree = ffecom_3 (COND_EXPR, tree_type,
6613 assert ("bad op in ICHAR" == NULL);
6614 return error_mark_node;
6619 /* ffecom_intrinsic_len_ -- Return length info for char arg (LEN())
6623 length_arg = ffecom_intrinsic_len_ (expr);
6625 Handles CHARACTER-type CONTER, SYMTER, SUBSTR, ARRAYREF, and FUNCREF
6626 subexpressions by constructing the appropriate tree for the
6627 length-of-character-text argument in a calling sequence. */
6629 #if FFECOM_targetCURRENT == FFECOM_targetGCC
6631 ffecom_intrinsic_len_ (ffebld expr)
6633 ffetargetCharacter1 val;
6636 switch (ffebld_op (expr))
6638 case FFEBLD_opCONTER:
6639 val = ffebld_constant_character1 (ffebld_conter (expr));
6640 length = build_int_2 (ffetarget_length_character1 (val), 0);
6641 TREE_TYPE (length) = ffecom_f2c_ftnlen_type_node;
6644 case FFEBLD_opSYMTER:
6646 ffesymbol s = ffebld_symter (expr);
6649 item = ffesymbol_hook (s).decl_tree;
6650 if (item == NULL_TREE)
6652 s = ffecom_sym_transform_ (s);
6653 item = ffesymbol_hook (s).decl_tree;
6655 if (ffesymbol_kind (s) == FFEINFO_kindENTITY)
6657 if (ffesymbol_size (s) == FFETARGET_charactersizeNONE)
6658 length = ffesymbol_hook (s).length_tree;
6661 length = build_int_2 (ffesymbol_size (s), 0);
6662 TREE_TYPE (length) = ffecom_f2c_ftnlen_type_node;
6665 else if (item == error_mark_node)
6666 length = error_mark_node;
6667 else /* FFEINFO_kindFUNCTION: */
6672 case FFEBLD_opARRAYREF:
6673 length = ffecom_intrinsic_len_ (ffebld_left (expr));
6676 case FFEBLD_opSUBSTR:
6680 ffebld thing = ffebld_right (expr);
6684 assert (ffebld_op (thing) == FFEBLD_opITEM);
6685 start = ffebld_head (thing);
6686 thing = ffebld_trail (thing);
6687 assert (ffebld_trail (thing) == NULL);
6688 end = ffebld_head (thing);
6690 length = ffecom_intrinsic_len_ (ffebld_left (expr));
6692 if (length == error_mark_node)
6701 length = convert (ffecom_f2c_ftnlen_type_node,
6707 start_tree = convert (ffecom_f2c_ftnlen_type_node,
6708 ffecom_expr (start));
6710 if (start_tree == error_mark_node)
6712 length = error_mark_node;
6718 length = ffecom_2 (PLUS_EXPR, ffecom_f2c_ftnlen_type_node,
6719 ffecom_f2c_ftnlen_one_node,
6720 ffecom_2 (MINUS_EXPR,
6721 ffecom_f2c_ftnlen_type_node,
6727 end_tree = convert (ffecom_f2c_ftnlen_type_node,
6730 if (end_tree == error_mark_node)
6732 length = error_mark_node;
6736 length = ffecom_2 (PLUS_EXPR, ffecom_f2c_ftnlen_type_node,
6737 ffecom_f2c_ftnlen_one_node,
6738 ffecom_2 (MINUS_EXPR,
6739 ffecom_f2c_ftnlen_type_node,
6740 end_tree, start_tree));
6746 case FFEBLD_opCONCATENATE:
6748 = ffecom_2 (PLUS_EXPR, ffecom_f2c_ftnlen_type_node,
6749 ffecom_intrinsic_len_ (ffebld_left (expr)),
6750 ffecom_intrinsic_len_ (ffebld_right (expr)));
6753 case FFEBLD_opFUNCREF:
6754 case FFEBLD_opCONVERT:
6755 length = build_int_2 (ffebld_size (expr), 0);
6756 TREE_TYPE (length) = ffecom_f2c_ftnlen_type_node;
6760 assert ("bad op for single char arg expr" == NULL);
6761 length = ffecom_f2c_ftnlen_zero_node;
6765 assert (length != NULL_TREE);
6771 /* Handle CHARACTER assignments.
6773 Generates code to do the assignment. Used by ordinary assignment
6774 statement handler ffecom_let_stmt and by statement-function
6775 handler to generate code for a statement function. */
6777 #if FFECOM_targetCURRENT == FFECOM_targetGCC
6779 ffecom_let_char_ (tree dest_tree, tree dest_length,
6780 ffetargetCharacterSize dest_size, ffebld source)
6782 ffecomConcatList_ catlist;
6787 if ((dest_tree == error_mark_node)
6788 || (dest_length == error_mark_node))
6791 assert (dest_tree != NULL_TREE);
6792 assert (dest_length != NULL_TREE);
6794 /* Source might be an opCONVERT, which just means it is a different size
6795 than the destination. Since the underlying implementation here handles
6796 that (directly or via the s_copy or s_cat run-time-library functions),
6797 we don't need the "convenience" of an opCONVERT that tells us to
6798 truncate or blank-pad, particularly since the resulting implementation
6799 would probably be slower than otherwise. */
6801 while (ffebld_op (source) == FFEBLD_opCONVERT)
6802 source = ffebld_left (source);
6804 catlist = ffecom_concat_list_new_ (source, dest_size);
6805 switch (ffecom_concat_list_count_ (catlist))
6807 case 0: /* Shouldn't happen, but in case it does... */
6808 ffecom_concat_list_kill_ (catlist);
6809 source_tree = null_pointer_node;
6810 source_length = ffecom_f2c_ftnlen_zero_node;
6811 expr_tree = build_tree_list (NULL_TREE, dest_tree);
6812 TREE_CHAIN (expr_tree) = build_tree_list (NULL_TREE, source_tree);
6813 TREE_CHAIN (TREE_CHAIN (expr_tree))
6814 = build_tree_list (NULL_TREE, dest_length);
6815 TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (expr_tree)))
6816 = build_tree_list (NULL_TREE, source_length);
6818 expr_tree = ffecom_call_gfrt (FFECOM_gfrtCOPY, expr_tree, NULL_TREE);
6819 TREE_SIDE_EFFECTS (expr_tree) = 1;
6821 expand_expr_stmt (expr_tree);
6825 case 1: /* The (fairly) easy case. */
6826 ffecom_char_args_ (&source_tree, &source_length,
6827 ffecom_concat_list_expr_ (catlist, 0));
6828 ffecom_concat_list_kill_ (catlist);
6829 assert (source_tree != NULL_TREE);
6830 assert (source_length != NULL_TREE);
6832 if ((source_tree == error_mark_node)
6833 || (source_length == error_mark_node))
6839 = ffecom_1 (INDIRECT_REF,
6840 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE
6844 = ffecom_2 (ARRAY_REF,
6845 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE
6850 = ffecom_1 (INDIRECT_REF,
6851 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE
6855 = ffecom_2 (ARRAY_REF,
6856 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE
6861 expr_tree = ffecom_modify (void_type_node, dest_tree, source_tree);
6863 expand_expr_stmt (expr_tree);
6868 expr_tree = build_tree_list (NULL_TREE, dest_tree);
6869 TREE_CHAIN (expr_tree) = build_tree_list (NULL_TREE, source_tree);
6870 TREE_CHAIN (TREE_CHAIN (expr_tree))
6871 = build_tree_list (NULL_TREE, dest_length);
6872 TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (expr_tree)))
6873 = build_tree_list (NULL_TREE, source_length);
6875 expr_tree = ffecom_call_gfrt (FFECOM_gfrtCOPY, expr_tree, NULL_TREE);
6876 TREE_SIDE_EFFECTS (expr_tree) = 1;
6878 expand_expr_stmt (expr_tree);
6882 default: /* Must actually concatenate things. */
6886 /* Heavy-duty concatenation. */
6889 int count = ffecom_concat_list_count_ (catlist);
6901 = ffecom_push_tempvar (ffecom_f2c_ftnlen_type_node,
6902 FFETARGET_charactersizeNONE, count, TRUE);
6903 item_array = items = ffecom_push_tempvar (ffecom_f2c_address_type_node,
6904 FFETARGET_charactersizeNONE,
6910 hook = ffebld_nonter_hook (source);
6912 assert (TREE_CODE (hook) == TREE_VEC);
6913 assert (TREE_VEC_LENGTH (hook) == 2);
6914 length_array = lengths = TREE_VEC_ELT (hook, 0);
6915 item_array = items = TREE_VEC_ELT (hook, 1);
6919 for (i = 0; i < count; ++i)
6921 ffecom_char_args_ (&citem, &clength,
6922 ffecom_concat_list_expr_ (catlist, i));
6923 if ((citem == error_mark_node)
6924 || (clength == error_mark_node))
6926 ffecom_concat_list_kill_ (catlist);
6931 = ffecom_2 (COMPOUND_EXPR, TREE_TYPE (items),
6932 ffecom_modify (void_type_node,
6933 ffecom_2 (ARRAY_REF,
6934 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (item_array))),
6936 build_int_2 (i, 0)),
6940 = ffecom_2 (COMPOUND_EXPR, TREE_TYPE (lengths),
6941 ffecom_modify (void_type_node,
6942 ffecom_2 (ARRAY_REF,
6943 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (length_array))),
6945 build_int_2 (i, 0)),
6950 expr_tree = build_tree_list (NULL_TREE, dest_tree);
6951 TREE_CHAIN (expr_tree)
6952 = build_tree_list (NULL_TREE,
6953 ffecom_1 (ADDR_EXPR,
6954 build_pointer_type (TREE_TYPE (items)),
6956 TREE_CHAIN (TREE_CHAIN (expr_tree))
6957 = build_tree_list (NULL_TREE,
6958 ffecom_1 (ADDR_EXPR,
6959 build_pointer_type (TREE_TYPE (lengths)),
6961 TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (expr_tree)))
6964 ffecom_1 (ADDR_EXPR, ffecom_f2c_ptr_to_ftnlen_type_node,
6965 convert (ffecom_f2c_ftnlen_type_node,
6966 build_int_2 (count, 0))));
6967 TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (expr_tree))))
6968 = build_tree_list (NULL_TREE, dest_length);
6970 expr_tree = ffecom_call_gfrt (FFECOM_gfrtCAT, expr_tree, NULL_TREE);
6971 TREE_SIDE_EFFECTS (expr_tree) = 1;
6973 expand_expr_stmt (expr_tree);
6976 ffecom_concat_list_kill_ (catlist);
6980 /* ffecom_make_gfrt_ -- Make initial info for run-time routine
6983 ffecom_make_gfrt_(ix);
6985 Assumes gfrt_[ix] is NULL_TREE, and replaces it with the FUNCTION_DECL
6986 for the indicated run-time routine (ix). */
6988 #if FFECOM_targetCURRENT == FFECOM_targetGCC
6990 ffecom_make_gfrt_ (ffecomGfrt ix)
6995 switch (ffecom_gfrt_type_[ix])
6997 case FFECOM_rttypeVOID_:
6998 ttype = void_type_node;
7001 case FFECOM_rttypeVOIDSTAR_:
7002 ttype = TREE_TYPE (null_pointer_node); /* `void *'. */
7005 case FFECOM_rttypeFTNINT_:
7006 ttype = ffecom_f2c_ftnint_type_node;
7009 case FFECOM_rttypeINTEGER_:
7010 ttype = ffecom_f2c_integer_type_node;
7013 case FFECOM_rttypeLONGINT_:
7014 ttype = ffecom_f2c_longint_type_node;
7017 case FFECOM_rttypeLOGICAL_:
7018 ttype = ffecom_f2c_logical_type_node;
7021 case FFECOM_rttypeREAL_F2C_:
7022 ttype = double_type_node;
7025 case FFECOM_rttypeREAL_GNU_:
7026 ttype = float_type_node;
7029 case FFECOM_rttypeCOMPLEX_F2C_:
7030 ttype = void_type_node;
7033 case FFECOM_rttypeCOMPLEX_GNU_:
7034 ttype = ffecom_f2c_complex_type_node;
7037 case FFECOM_rttypeDOUBLE_:
7038 ttype = double_type_node;
7041 case FFECOM_rttypeDOUBLEREAL_:
7042 ttype = ffecom_f2c_doublereal_type_node;
7045 case FFECOM_rttypeDBLCMPLX_F2C_:
7046 ttype = void_type_node;
7049 case FFECOM_rttypeDBLCMPLX_GNU_:
7050 ttype = ffecom_f2c_doublecomplex_type_node;
7053 case FFECOM_rttypeCHARACTER_:
7054 ttype = void_type_node;
7059 assert ("bad rttype" == NULL);
7063 ttype = build_function_type (ttype, NULL_TREE);
7064 t = build_decl (FUNCTION_DECL,
7065 get_identifier (ffecom_gfrt_name_[ix]),
7067 DECL_EXTERNAL (t) = 1;
7068 TREE_PUBLIC (t) = 1;
7069 TREE_THIS_VOLATILE (t) = ffecom_gfrt_volatile_[ix] ? 1 : 0;
7071 t = start_decl (t, TRUE);
7073 finish_decl (t, NULL_TREE, TRUE);
7075 ffecom_gfrt_[ix] = t;
7079 /* Phase 1 pass over each member of a COMMON/EQUIVALENCE group. */
7081 #if FFECOM_targetCURRENT == FFECOM_targetGCC
7083 ffecom_member_phase1_ (ffestorag mst UNUSED, ffestorag st)
7085 ffesymbol s = ffestorag_symbol (st);
7087 if (ffesymbol_namelisted (s))
7088 ffecom_member_namelisted_ = TRUE;
7092 /* Phase 2 pass over each member of a COMMON/EQUIVALENCE group. Declare
7093 the member so debugger will see it. Otherwise nobody should be
7094 referencing the member. */
7096 #if FFECOM_targetCURRENT == FFECOM_targetGCC
7098 ffecom_member_phase2_ (ffestorag mst, ffestorag st)
7106 || ((mt = ffestorag_hook (mst)) == NULL)
7107 || (mt == error_mark_node))
7111 || ((s = ffestorag_symbol (st)) == NULL))
7114 type = ffecom_type_localvar_ (s,
7115 ffesymbol_basictype (s),
7116 ffesymbol_kindtype (s));
7117 if (type == error_mark_node)
7120 t = build_decl (VAR_DECL,
7121 ffecom_get_identifier_ (ffesymbol_text (s)),
7124 TREE_STATIC (t) = TREE_STATIC (mt);
7125 DECL_INITIAL (t) = NULL_TREE;
7126 TREE_ASM_WRITTEN (t) = 1;
7129 = gen_rtx (MEM, TYPE_MODE (type),
7130 plus_constant (XEXP (DECL_RTL (mt), 0),
7131 ffestorag_modulo (mst)
7132 + ffestorag_offset (st)
7133 - ffestorag_offset (mst)));
7135 t = start_decl (t, FALSE);
7137 finish_decl (t, NULL_TREE, FALSE);
7141 /* Prepare source expression for assignment into a destination perhaps known
7142 to be of a specific size. */
7145 ffecom_prepare_let_char_ (ffetargetCharacterSize dest_size, ffebld source)
7147 ffecomConcatList_ catlist;
7152 tree tempvar = NULL_TREE;
7154 while (ffebld_op (source) == FFEBLD_opCONVERT)
7155 source = ffebld_left (source);
7157 catlist = ffecom_concat_list_new_ (source, dest_size);
7158 count = ffecom_concat_list_count_ (catlist);
7163 = ffecom_make_tempvar ("let_char_len", ffecom_f2c_ftnlen_type_node,
7164 FFETARGET_charactersizeNONE, count);
7166 = ffecom_make_tempvar ("let_char_item", ffecom_f2c_address_type_node,
7167 FFETARGET_charactersizeNONE, count);
7169 tempvar = make_tree_vec (2);
7170 TREE_VEC_ELT (tempvar, 0) = ltmp;
7171 TREE_VEC_ELT (tempvar, 1) = itmp;
7174 for (i = 0; i < count; ++i)
7175 ffecom_prepare_arg_ptr_to_expr (ffecom_concat_list_expr_ (catlist, i));
7177 ffecom_concat_list_kill_ (catlist);
7181 ffebld_nonter_set_hook (source, tempvar);
7182 current_binding_level->prep_state = 1;
7186 /* ffecom_push_dummy_decls_ -- Transform dummy args, push parm decls in order
7188 Ignores STAR (alternate-return) dummies. All other get exec-transitioned
7189 (which generates their trees) and then their trees get push_parm_decl'd.
7191 The second arg is TRUE if the dummies are for a statement function, in
7192 which case lengths are not pushed for character arguments (since they are
7193 always known by both the caller and the callee, though the code allows
7194 for someday permitting CHAR*(*) stmtfunc dummies). */
7196 #if FFECOM_targetCURRENT == FFECOM_targetGCC
7198 ffecom_push_dummy_decls_ (ffebld dummy_list, bool stmtfunc)
7205 ffecom_transform_only_dummies_ = TRUE;
7207 /* First push the parms corresponding to actual dummy "contents". */
7209 for (dumlist = dummy_list; dumlist != NULL; dumlist = ffebld_trail (dumlist))
7211 dummy = ffebld_head (dumlist);
7212 switch (ffebld_op (dummy))
7216 continue; /* Forget alternate returns. */
7221 assert (ffebld_op (dummy) == FFEBLD_opSYMTER);
7222 s = ffebld_symter (dummy);
7223 parm = ffesymbol_hook (s).decl_tree;
7224 if (parm == NULL_TREE)
7226 s = ffecom_sym_transform_ (s);
7227 parm = ffesymbol_hook (s).decl_tree;
7228 assert (parm != NULL_TREE);
7230 if (parm != error_mark_node)
7231 push_parm_decl (parm);
7234 /* Then, for CHARACTER dummies, push the parms giving their lengths. */
7236 for (dumlist = dummy_list; dumlist != NULL; dumlist = ffebld_trail (dumlist))
7238 dummy = ffebld_head (dumlist);
7239 switch (ffebld_op (dummy))
7243 continue; /* Forget alternate returns, they mean
7249 s = ffebld_symter (dummy);
7250 if (ffesymbol_basictype (s) != FFEINFO_basictypeCHARACTER)
7251 continue; /* Only looking for CHARACTER arguments. */
7252 if (stmtfunc && (ffesymbol_size (s) != FFETARGET_charactersizeNONE))
7253 continue; /* Stmtfunc arg with known size needs no
7255 if (ffesymbol_kind (s) != FFEINFO_kindENTITY)
7256 continue; /* Only looking for variables and arrays. */
7257 parm = ffesymbol_hook (s).length_tree;
7258 assert (parm != NULL_TREE);
7259 if (parm != error_mark_node)
7260 push_parm_decl (parm);
7263 ffecom_transform_only_dummies_ = FALSE;
7267 /* ffecom_start_progunit_ -- Beginning of program unit
7269 Does GNU back end stuff necessary to teach it about the start of its
7270 equivalent of a Fortran program unit. */
7272 #if FFECOM_targetCURRENT == FFECOM_targetGCC
7274 ffecom_start_progunit_ ()
7276 ffesymbol fn = ffecom_primary_entry_;
7278 tree id; /* Identifier (name) of function. */
7279 tree type; /* Type of function. */
7280 tree result; /* Result of function. */
7281 ffeinfoBasictype bt;
7285 ffeglobalType egt = FFEGLOBAL_type;
7288 bool altentries = (ffecom_num_entrypoints_ != 0);
7291 && (ffecom_primary_entry_kind_ == FFEINFO_kindFUNCTION)
7292 && (ffecom_master_bt_ == FFEINFO_basictypeNONE);
7293 bool main_program = FALSE;
7294 int old_lineno = lineno;
7295 char *old_input_filename = input_filename;
7298 assert (fn != NULL);
7299 assert (ffesymbol_hook (fn).decl_tree == NULL_TREE);
7301 input_filename = ffesymbol_where_filename (fn);
7302 lineno = ffesymbol_where_filelinenum (fn);
7304 /* c-parse.y indeed does call suspend_momentary and not only ignores the
7305 return value, but also never calls resume_momentary, when starting an
7306 outer function (see "fndef:", "setspecs:", and so on). So g77 does the
7307 same thing. It shouldn't be a problem since start_function calls
7308 temporary_allocation, but it might be necessary. If it causes a problem
7309 here, then maybe there's a bug lurking in gcc. NOTE: This identical
7310 comment appears twice in thist file. */
7312 suspend_momentary ();
7314 switch (ffecom_primary_entry_kind_)
7316 case FFEINFO_kindPROGRAM:
7317 main_program = TRUE;
7318 gt = FFEGLOBAL_typeMAIN;
7319 bt = FFEINFO_basictypeNONE;
7320 kt = FFEINFO_kindtypeNONE;
7321 type = ffecom_tree_fun_type_void;
7326 case FFEINFO_kindBLOCKDATA:
7327 gt = FFEGLOBAL_typeBDATA;
7328 bt = FFEINFO_basictypeNONE;
7329 kt = FFEINFO_kindtypeNONE;
7330 type = ffecom_tree_fun_type_void;
7335 case FFEINFO_kindFUNCTION:
7336 gt = FFEGLOBAL_typeFUNC;
7337 egt = FFEGLOBAL_typeEXT;
7338 bt = ffesymbol_basictype (fn);
7339 kt = ffesymbol_kindtype (fn);
7340 if (bt == FFEINFO_basictypeNONE)
7342 ffeimplic_establish_symbol (fn);
7343 if (ffesymbol_funcresult (fn) != NULL)
7344 ffeimplic_establish_symbol (ffesymbol_funcresult (fn));
7345 bt = ffesymbol_basictype (fn);
7346 kt = ffesymbol_kindtype (fn);
7350 charfunc = cmplxfunc = FALSE;
7351 else if (bt == FFEINFO_basictypeCHARACTER)
7352 charfunc = TRUE, cmplxfunc = FALSE;
7353 else if ((bt == FFEINFO_basictypeCOMPLEX)
7354 && ffesymbol_is_f2c (fn)
7356 charfunc = FALSE, cmplxfunc = TRUE;
7358 charfunc = cmplxfunc = FALSE;
7360 if (multi || charfunc)
7361 type = ffecom_tree_fun_type_void;
7362 else if (ffesymbol_is_f2c (fn) && !altentries)
7363 type = ffecom_tree_fun_type[bt][kt];
7365 type = build_function_type (ffecom_tree_type[bt][kt], NULL_TREE);
7367 if ((type == NULL_TREE)
7368 || (TREE_TYPE (type) == NULL_TREE))
7369 type = ffecom_tree_fun_type_void; /* _sym_exec_transition. */
7372 case FFEINFO_kindSUBROUTINE:
7373 gt = FFEGLOBAL_typeSUBR;
7374 egt = FFEGLOBAL_typeEXT;
7375 bt = FFEINFO_basictypeNONE;
7376 kt = FFEINFO_kindtypeNONE;
7377 if (ffecom_is_altreturning_)
7378 type = ffecom_tree_subr_type;
7380 type = ffecom_tree_fun_type_void;
7386 assert ("say what??" == NULL);
7388 case FFEINFO_kindANY:
7389 gt = FFEGLOBAL_typeANY;
7390 bt = FFEINFO_basictypeNONE;
7391 kt = FFEINFO_kindtypeNONE;
7392 type = error_mark_node;
7400 id = ffecom_get_invented_identifier ("__g77_masterfun_%s",
7401 ffesymbol_text (fn));
7403 #if FFETARGET_isENFORCED_MAIN
7404 else if (main_program)
7405 id = get_identifier (FFETARGET_nameENFORCED_MAIN_NAME);
7408 id = ffecom_get_external_identifier_ (fn);
7412 0, /* nested/inline */
7413 !altentries); /* TREE_PUBLIC */
7415 TREE_USED (current_function_decl) = 1; /* Avoid spurious warning if altentries. */
7418 && ((g = ffesymbol_global (fn)) != NULL)
7419 && ((ffeglobal_type (g) == gt)
7420 || (ffeglobal_type (g) == egt)))
7422 ffeglobal_set_hook (g, current_function_decl);
7425 yes = suspend_momentary ();
7427 /* Arg handling needs exec-transitioned ffesymbols to work with. But
7428 exec-transitioning needs current_function_decl to be filled in. So we
7429 do these things in two phases. */
7432 { /* 1st arg identifies which entrypoint. */
7433 ffecom_which_entrypoint_decl_
7434 = build_decl (PARM_DECL,
7435 ffecom_get_invented_identifier ("__g77_%s",
7436 "which_entrypoint"),
7438 push_parm_decl (ffecom_which_entrypoint_decl_);
7444 { /* Arg for result (return value). */
7449 type = ffecom_tree_type[FFEINFO_basictypeCHARACTER][kt];
7451 type = ffecom_tree_type[FFEINFO_basictypeCOMPLEX][kt];
7453 type = ffecom_multi_type_node_;
7455 result = ffecom_get_invented_identifier ("__g77_%s", "result");
7457 /* Make length arg _and_ enhance type info for CHAR arg itself. */
7460 length = ffecom_char_enhance_arg_ (&type, fn);
7462 length = NULL_TREE; /* Not ref'd if !charfunc. */
7464 type = build_pointer_type (type);
7465 result = build_decl (PARM_DECL, result, type);
7467 push_parm_decl (result);
7469 ffecom_multi_retval_ = result;
7471 ffecom_func_result_ = result;
7475 push_parm_decl (length);
7476 ffecom_func_length_ = length;
7480 if (ffecom_primary_entry_is_proc_)
7483 arglist = ffecom_master_arglist_;
7485 arglist = ffesymbol_dummyargs (fn);
7486 ffecom_push_dummy_decls_ (arglist, FALSE);
7489 resume_momentary (yes);
7491 if (TREE_CODE (current_function_decl) != ERROR_MARK)
7492 store_parm_decls (main_program ? 1 : 0);
7494 ffecom_start_compstmt ();
7495 /* Disallow temp vars at this level. */
7496 current_binding_level->prep_state = 2;
7498 lineno = old_lineno;
7499 input_filename = old_input_filename;
7501 /* This handles any symbols still untransformed, in case -g specified.
7502 This used to be done in ffecom_finish_progunit, but it turns out to
7503 be necessary to do it here so that statement functions are
7504 expanded before code. But don't bother for BLOCK DATA. */
7506 if (ffecom_primary_entry_kind_ != FFEINFO_kindBLOCKDATA)
7507 ffesymbol_drive (ffecom_finish_symbol_transform_);
7511 /* ffecom_sym_transform_ -- Transform FFE sym into backend sym
7514 ffecom_sym_transform_(s);
7516 The ffesymbol_hook info for s is updated with appropriate backend info
7519 #if FFECOM_targetCURRENT == FFECOM_targetGCC
7521 ffecom_sym_transform_ (ffesymbol s)
7523 tree t; /* Transformed thingy. */
7524 tree tlen; /* Length if CHAR*(*). */
7525 bool addr; /* Is t the address of the thingy? */
7526 ffeinfoBasictype bt;
7530 int old_lineno = lineno;
7531 char *old_input_filename = input_filename;
7533 /* Must ensure special ASSIGN variables are declared at top of outermost
7534 block, else they'll end up in the innermost block when their first
7535 ASSIGN is seen, which leaves them out of scope when they're the
7536 subject of a GOTO or I/O statement.
7538 We make this variable even if -fugly-assign. Just let it go unused,
7539 in case it turns out there are cases where we really want to use this
7540 variable anyway (e.g. ASSIGN to INTEGER*2 variable). */
7542 if (! ffecom_transform_only_dummies_
7543 && ffesymbol_assigned (s)
7544 && ! ffesymbol_hook (s).assign_tree)
7545 s = ffecom_sym_transform_assign_ (s);
7547 if (ffesymbol_sfdummyparent (s) == NULL)
7549 input_filename = ffesymbol_where_filename (s);
7550 lineno = ffesymbol_where_filelinenum (s);
7554 ffesymbol sf = ffesymbol_sfdummyparent (s);
7556 input_filename = ffesymbol_where_filename (sf);
7557 lineno = ffesymbol_where_filelinenum (sf);
7560 bt = ffeinfo_basictype (ffebld_info (s));
7561 kt = ffeinfo_kindtype (ffebld_info (s));
7567 switch (ffesymbol_kind (s))
7569 case FFEINFO_kindNONE:
7570 switch (ffesymbol_where (s))
7572 case FFEINFO_whereDUMMY: /* Subroutine or function. */
7573 assert (ffecom_transform_only_dummies_);
7575 /* Before 0.4, this could be ENTITY/DUMMY, but see
7576 ffestu_sym_end_transition -- no longer true (in particular, if
7577 it could be an ENTITY, it _will_ be made one, so that
7578 possibility won't come through here). So we never make length
7579 arg for CHARACTER type. */
7581 t = build_decl (PARM_DECL,
7582 ffecom_get_identifier_ (ffesymbol_text (s)),
7583 ffecom_tree_ptr_to_subr_type);
7585 DECL_ARTIFICIAL (t) = 1;
7590 case FFEINFO_whereGLOBAL: /* Subroutine or function. */
7591 assert (!ffecom_transform_only_dummies_);
7593 if (((g = ffesymbol_global (s)) != NULL)
7594 && ((ffeglobal_type (g) == FFEGLOBAL_typeSUBR)
7595 || (ffeglobal_type (g) == FFEGLOBAL_typeFUNC)
7596 || (ffeglobal_type (g) == FFEGLOBAL_typeEXT))
7597 && (ffeglobal_hook (g) != NULL_TREE)
7598 && ffe_is_globals ())
7600 t = ffeglobal_hook (g);
7604 t = build_decl (FUNCTION_DECL,
7605 ffecom_get_external_identifier_ (s),
7606 ffecom_tree_subr_type); /* Assume subr. */
7607 DECL_EXTERNAL (t) = 1;
7608 TREE_PUBLIC (t) = 1;
7610 t = start_decl (t, FALSE);
7611 finish_decl (t, NULL_TREE, FALSE);
7614 && ((ffeglobal_type (g) == FFEGLOBAL_typeSUBR)
7615 || (ffeglobal_type (g) == FFEGLOBAL_typeFUNC)
7616 || (ffeglobal_type (g) == FFEGLOBAL_typeEXT)))
7617 ffeglobal_set_hook (g, t);
7619 ffecom_save_tree_forever (t);
7624 assert ("NONE where unexpected" == NULL);
7626 case FFEINFO_whereANY:
7631 case FFEINFO_kindENTITY:
7632 switch (ffeinfo_where (ffesymbol_info (s)))
7635 case FFEINFO_whereCONSTANT:
7636 /* ~~Debugging info needed? */
7637 assert (!ffecom_transform_only_dummies_);
7638 t = error_mark_node; /* Shouldn't ever see this in expr. */
7641 case FFEINFO_whereLOCAL:
7642 assert (!ffecom_transform_only_dummies_);
7645 ffestorag st = ffesymbol_storage (s);
7649 && (ffestorag_size (st) == 0))
7651 t = error_mark_node;
7655 yes = suspend_momentary ();
7656 type = ffecom_type_localvar_ (s, bt, kt);
7657 resume_momentary (yes);
7659 if (type == error_mark_node)
7661 t = error_mark_node;
7666 && (ffestorag_parent (st) != NULL))
7667 { /* Child of EQUIVALENCE parent. */
7671 ffetargetOffset offset;
7673 est = ffestorag_parent (st);
7674 ffecom_transform_equiv_ (est);
7676 et = ffestorag_hook (est);
7677 assert (et != NULL_TREE);
7679 if (! TREE_STATIC (et))
7680 put_var_into_stack (et);
7682 yes = suspend_momentary ();
7684 offset = ffestorag_modulo (est)
7685 + ffestorag_offset (ffesymbol_storage (s))
7686 - ffestorag_offset (est);
7688 ffecom_debug_kludge_ (et, "EQUIVALENCE", s, type, offset);
7690 /* (t_type *) (((char *) &et) + offset) */
7692 t = convert (string_type_node, /* (char *) */
7693 ffecom_1 (ADDR_EXPR,
7694 build_pointer_type (TREE_TYPE (et)),
7696 t = ffecom_2 (PLUS_EXPR, TREE_TYPE (t),
7698 build_int_2 (offset, 0));
7699 t = convert (build_pointer_type (type),
7701 TREE_CONSTANT (t) = staticp (et);
7705 resume_momentary (yes);
7710 bool init = ffesymbol_is_init (s);
7712 yes = suspend_momentary ();
7714 t = build_decl (VAR_DECL,
7715 ffecom_get_identifier_ (ffesymbol_text (s)),
7719 || ffesymbol_namelisted (s)
7720 #ifdef FFECOM_sizeMAXSTACKITEM
7722 && (ffestorag_size (st) > FFECOM_sizeMAXSTACKITEM))
7724 || ((ffecom_primary_entry_kind_ != FFEINFO_kindPROGRAM)
7725 && (ffecom_primary_entry_kind_
7726 != FFEINFO_kindBLOCKDATA)
7727 && (ffesymbol_is_save (s) || ffe_is_saveall ())))
7728 TREE_STATIC (t) = !ffesymbol_attr (s, FFESYMBOL_attrADJUSTABLE);
7730 TREE_STATIC (t) = 0; /* No need to make static. */
7732 if (init || ffe_is_init_local_zero ())
7733 DECL_INITIAL (t) = error_mark_node;
7735 /* Keep -Wunused from complaining about var if it
7736 is used as sfunc arg or DATA implied-DO. */
7737 if (ffesymbol_attrs (s) & FFESYMBOL_attrsSFARG)
7738 DECL_IN_SYSTEM_HEADER (t) = 1;
7740 t = start_decl (t, FALSE);
7744 if (ffesymbol_init (s) != NULL)
7745 initexpr = ffecom_expr (ffesymbol_init (s));
7747 initexpr = ffecom_init_zero_ (t);
7749 else if (ffe_is_init_local_zero ())
7750 initexpr = ffecom_init_zero_ (t);
7752 initexpr = NULL_TREE; /* Not ref'd if !init. */
7754 finish_decl (t, initexpr, FALSE);
7756 if (st != NULL && DECL_SIZE (t) != error_mark_node)
7758 assert (TREE_CODE (DECL_SIZE_UNIT (t)) == INTEGER_CST);
7759 assert (0 == compare_tree_int (DECL_SIZE_UNIT (t),
7760 ffestorag_size (st)));
7763 resume_momentary (yes);
7768 case FFEINFO_whereRESULT:
7769 assert (!ffecom_transform_only_dummies_);
7771 if (bt == FFEINFO_basictypeCHARACTER)
7772 { /* Result is already in list of dummies, use
7774 t = ffecom_func_result_;
7775 tlen = ffecom_func_length_;
7779 if ((ffecom_num_entrypoints_ == 0)
7780 && (bt == FFEINFO_basictypeCOMPLEX)
7781 && (ffesymbol_is_f2c (ffecom_primary_entry_)))
7782 { /* Result is already in list of dummies, use
7784 t = ffecom_func_result_;
7788 if (ffecom_func_result_ != NULL_TREE)
7790 t = ffecom_func_result_;
7793 if ((ffecom_num_entrypoints_ != 0)
7794 && (ffecom_master_bt_ == FFEINFO_basictypeNONE))
7796 yes = suspend_momentary ();
7798 assert (ffecom_multi_retval_ != NULL_TREE);
7799 t = ffecom_1 (INDIRECT_REF, ffecom_multi_type_node_,
7800 ffecom_multi_retval_);
7801 t = ffecom_2 (COMPONENT_REF, ffecom_tree_type[bt][kt],
7802 t, ffecom_multi_fields_[bt][kt]);
7804 resume_momentary (yes);
7808 yes = suspend_momentary ();
7810 t = build_decl (VAR_DECL,
7811 ffecom_get_identifier_ (ffesymbol_text (s)),
7812 ffecom_tree_type[bt][kt]);
7813 TREE_STATIC (t) = 0; /* Put result on stack. */
7814 t = start_decl (t, FALSE);
7815 finish_decl (t, NULL_TREE, FALSE);
7817 ffecom_func_result_ = t;
7819 resume_momentary (yes);
7822 case FFEINFO_whereDUMMY:
7830 bool adjustable = FALSE; /* Conditionally adjustable? */
7832 type = ffecom_tree_type[bt][kt];
7833 if (ffesymbol_sfdummyparent (s) != NULL)
7835 if (current_function_decl == ffecom_outer_function_decl_)
7836 { /* Exec transition before sfunc
7837 context; get it later. */
7840 t = ffecom_get_identifier_ (ffesymbol_text
7841 (ffesymbol_sfdummyparent (s)));
7844 t = ffecom_get_identifier_ (ffesymbol_text (s));
7846 assert (ffecom_transform_only_dummies_);
7848 old_sizes = get_pending_sizes ();
7849 put_pending_sizes (old_sizes);
7851 if (bt == FFEINFO_basictypeCHARACTER)
7852 tlen = ffecom_char_enhance_arg_ (&type, s);
7853 type = ffecom_check_size_overflow_ (s, type, TRUE);
7855 for (dl = ffesymbol_dims (s); dl != NULL; dl = ffebld_trail (dl))
7857 if (type == error_mark_node)
7860 dim = ffebld_head (dl);
7861 assert (ffebld_op (dim) == FFEBLD_opBOUNDS);
7862 if ((ffebld_left (dim) == NULL) || ffecom_doing_entry_)
7863 low = ffecom_integer_one_node;
7865 low = ffecom_expr (ffebld_left (dim));
7866 assert (ffebld_right (dim) != NULL);
7867 if ((ffebld_op (ffebld_right (dim)) == FFEBLD_opSTAR)
7868 || ffecom_doing_entry_)
7870 /* Used to just do high=low. But for ffecom_tree_
7871 canonize_ref_, it probably is important to correctly
7872 assess the size. E.g. given COMPLEX C(*),CFUNC and
7873 C(2)=CFUNC(C), overlap can happen, while it can't
7874 for, say, C(1)=CFUNC(C(2)). */
7875 /* Even more recently used to set to INT_MAX, but that
7876 broke when some overflow checking went into the back
7877 end. Now we just leave the upper bound unspecified. */
7881 high = ffecom_expr (ffebld_right (dim));
7883 /* Determine whether array is conditionally adjustable,
7884 to decide whether back-end magic is needed.
7886 Normally the front end uses the back-end function
7887 variable_size to wrap SAVE_EXPR's around expressions
7888 affecting the size/shape of an array so that the
7889 size/shape info doesn't change during execution
7890 of the compiled code even though variables and
7891 functions referenced in those expressions might.
7893 variable_size also makes sure those saved expressions
7894 get evaluated immediately upon entry to the
7895 compiled procedure -- the front end normally doesn't
7896 have to worry about that.
7898 However, there is a problem with this that affects
7899 g77's implementation of entry points, and that is
7900 that it is _not_ true that each invocation of the
7901 compiled procedure is permitted to evaluate
7902 array size/shape info -- because it is possible
7903 that, for some invocations, that info is invalid (in
7904 which case it is "promised" -- i.e. a violation of
7905 the Fortran standard -- that the compiled code
7906 won't reference the array or its size/shape
7907 during that particular invocation).
7909 To phrase this in C terms, consider this gcc function:
7911 void foo (int *n, float (*a)[*n])
7913 // a is "pointer to array ...", fyi.
7916 Suppose that, for some invocations, it is permitted
7917 for a caller of foo to do this:
7921 Now the _written_ code for foo can take such a call
7922 into account by either testing explicitly for whether
7923 (a == NULL) || (n == NULL) -- presumably it is
7924 not permitted to reference *a in various fashions
7925 if (n == NULL) I suppose -- or it can avoid it by
7926 looking at other info (other arguments, static/global
7929 However, this won't work in gcc 2.5.8 because it'll
7930 automatically emit the code to save the "*n"
7931 expression, which'll yield a NULL dereference for
7932 the "foo (NULL, NULL)" call, something the code
7933 for foo cannot prevent.
7935 g77 definitely needs to avoid executing such
7936 code anytime the pointer to the adjustable array
7937 is NULL, because even if its bounds expressions
7938 don't have any references to possible "absent"
7939 variables like "*n" -- say all variable references
7940 are to COMMON variables, i.e. global (though in C,
7941 local static could actually make sense) -- the
7942 expressions could yield other run-time problems
7943 for allowably "dead" values in those variables.
7945 For example, let's consider a more complicated
7951 void foo (float (*a)[i/j])
7956 The above is (essentially) quite valid for Fortran
7957 but, again, for a call like "foo (NULL);", it is
7958 permitted for i and j to be undefined when the
7959 call is made. If j happened to be zero, for
7960 example, emitting the code to evaluate "i/j"
7961 could result in a run-time error.
7963 Offhand, though I don't have my F77 or F90
7964 standards handy, it might even be valid for a
7965 bounds expression to contain a function reference,
7966 in which case I doubt it is permitted for an
7967 implementation to invoke that function in the
7968 Fortran case involved here (invocation of an
7969 alternate ENTRY point that doesn't have the adjustable
7970 array as one of its arguments).
7972 So, the code that the compiler would normally emit
7973 to preevaluate the size/shape info for an
7974 adjustable array _must not_ be executed at run time
7975 in certain cases. Specifically, for Fortran,
7976 the case is when the pointer to the adjustable
7977 array == NULL. (For gnu-ish C, it might be nice
7978 for the source code itself to specify an expression
7979 that, if TRUE, inhibits execution of the code. Or
7980 reverse the sense for elegance.)
7982 (Note that g77 could use a different test than NULL,
7983 actually, since it happens to always pass an
7984 integer to the called function that specifies which
7985 entry point is being invoked. Hmm, this might
7986 solve the next problem.)
7988 One way a user could, I suppose, write "foo" so
7989 it works is to insert COND_EXPR's for the
7990 size/shape info so the dangerous stuff isn't
7991 actually done, as in:
7993 void foo (int *n, float (*a)[(a == NULL) ? 0 : *n])
7998 The next problem is that the front end needs to
7999 be able to tell the back end about the array's
8000 decl _before_ it tells it about the conditional
8001 expression to inhibit evaluation of size/shape info,
8004 To solve this, the front end needs to be able
8005 to give the back end the expression to inhibit
8006 generation of the preevaluation code _after_
8007 it makes the decl for the adjustable array.
8009 Until then, the above example using the COND_EXPR
8010 doesn't pass muster with gcc because the "(a == NULL)"
8011 part has a reference to "a", which is still
8012 undefined at that point.
8014 g77 will therefore use a different mechanism in the
8018 && ((TREE_CODE (low) != INTEGER_CST)
8019 || (high && TREE_CODE (high) != INTEGER_CST)))
8022 #if 0 /* Old approach -- see below. */
8023 if (TREE_CODE (low) != INTEGER_CST)
8024 low = ffecom_3 (COND_EXPR, integer_type_node,
8025 ffecom_adjarray_passed_ (s),
8027 ffecom_integer_zero_node);
8029 if (high && TREE_CODE (high) != INTEGER_CST)
8030 high = ffecom_3 (COND_EXPR, integer_type_node,
8031 ffecom_adjarray_passed_ (s),
8033 ffecom_integer_zero_node);
8036 /* ~~~gcc/stor-layout.c (layout_type) should do this,
8037 probably. Fixes 950302-1.f. */
8039 if (TREE_CODE (low) != INTEGER_CST)
8040 low = variable_size (low);
8042 /* ~~~Similarly, this fixes dumb0.f. The C front end
8043 does this, which is why dumb0.c would work. */
8045 if (high && TREE_CODE (high) != INTEGER_CST)
8046 high = variable_size (high);
8051 build_range_type (ffecom_integer_type_node,
8053 type = ffecom_check_size_overflow_ (s, type, TRUE);
8056 if (type == error_mark_node)
8058 t = error_mark_node;
8062 if ((ffesymbol_sfdummyparent (s) == NULL)
8063 || (ffesymbol_basictype (s) == FFEINFO_basictypeCHARACTER))
8065 type = build_pointer_type (type);
8069 t = build_decl (PARM_DECL, t, type);
8071 DECL_ARTIFICIAL (t) = 1;
8074 /* If this arg is present in every entry point's list of
8075 dummy args, then we're done. */
8077 if (ffesymbol_numentries (s)
8078 == (ffecom_num_entrypoints_ + 1))
8083 /* If variable_size in stor-layout has been called during
8084 the above, then get_pending_sizes should have the
8085 yet-to-be-evaluated saved expressions pending.
8086 Make the whole lot of them get emitted, conditionally
8087 on whether the array decl ("t" above) is not NULL. */
8090 tree sizes = get_pending_sizes ();
8095 tem = TREE_CHAIN (tem))
8097 tree temv = TREE_VALUE (tem);
8103 = ffecom_2 (COMPOUND_EXPR,
8112 = ffecom_3 (COND_EXPR,
8119 convert (TREE_TYPE (sizes),
8120 integer_zero_node));
8121 sizes = ffecom_save_tree (sizes);
8124 = tree_cons (NULL_TREE, sizes, tem);
8128 put_pending_sizes (sizes);
8134 && (ffesymbol_numentries (s)
8135 != ffecom_num_entrypoints_ + 1))
8137 = ffecom_2 (NE_EXPR, integer_type_node,
8143 && (ffesymbol_numentries (s)
8144 != ffecom_num_entrypoints_ + 1))
8146 ffebad_start (FFEBAD_MISSING_ADJARRAY_UNSUPPORTED);
8147 ffebad_here (0, ffesymbol_where_line (s),
8148 ffesymbol_where_column (s));
8149 ffebad_string (ffesymbol_text (s));
8158 case FFEINFO_whereCOMMON:
8163 ffestorag st = ffesymbol_storage (s);
8167 cs = ffesymbol_common (s); /* The COMMON area itself. */
8168 if (st != NULL) /* Else not laid out. */
8170 ffecom_transform_common_ (cs);
8171 st = ffesymbol_storage (s);
8174 yes = suspend_momentary ();
8176 type = ffecom_type_localvar_ (s, bt, kt);
8178 cg = ffesymbol_global (cs); /* The global COMMON info. */
8180 || (ffeglobal_type (cg) != FFEGLOBAL_typeCOMMON))
8183 ct = ffeglobal_hook (cg); /* The common area's tree. */
8185 if ((ct == NULL_TREE)
8187 || (type == error_mark_node))
8188 t = error_mark_node;
8191 ffetargetOffset offset;
8194 cst = ffestorag_parent (st);
8195 assert (cst == ffesymbol_storage (cs));
8197 offset = ffestorag_modulo (cst)
8198 + ffestorag_offset (st)
8199 - ffestorag_offset (cst);
8201 ffecom_debug_kludge_ (ct, "COMMON", s, type, offset);
8203 /* (t_type *) (((char *) &ct) + offset) */
8205 t = convert (string_type_node, /* (char *) */
8206 ffecom_1 (ADDR_EXPR,
8207 build_pointer_type (TREE_TYPE (ct)),
8209 t = ffecom_2 (PLUS_EXPR, TREE_TYPE (t),
8211 build_int_2 (offset, 0));
8212 t = convert (build_pointer_type (type),
8214 TREE_CONSTANT (t) = 1;
8219 resume_momentary (yes);
8223 case FFEINFO_whereIMMEDIATE:
8224 case FFEINFO_whereGLOBAL:
8225 case FFEINFO_whereFLEETING:
8226 case FFEINFO_whereFLEETING_CADDR:
8227 case FFEINFO_whereFLEETING_IADDR:
8228 case FFEINFO_whereINTRINSIC:
8229 case FFEINFO_whereCONSTANT_SUBOBJECT:
8231 assert ("ENTITY where unheard of" == NULL);
8233 case FFEINFO_whereANY:
8234 t = error_mark_node;
8239 case FFEINFO_kindFUNCTION:
8240 switch (ffeinfo_where (ffesymbol_info (s)))
8242 case FFEINFO_whereLOCAL: /* Me. */
8243 assert (!ffecom_transform_only_dummies_);
8244 t = current_function_decl;
8247 case FFEINFO_whereGLOBAL:
8248 assert (!ffecom_transform_only_dummies_);
8250 if (((g = ffesymbol_global (s)) != NULL)
8251 && ((ffeglobal_type (g) == FFEGLOBAL_typeFUNC)
8252 || (ffeglobal_type (g) == FFEGLOBAL_typeEXT))
8253 && (ffeglobal_hook (g) != NULL_TREE)
8254 && ffe_is_globals ())
8256 t = ffeglobal_hook (g);
8260 if (ffesymbol_is_f2c (s)
8261 && (ffesymbol_where (s) != FFEINFO_whereCONSTANT))
8262 t = ffecom_tree_fun_type[bt][kt];
8264 t = build_function_type (ffecom_tree_type[bt][kt], NULL_TREE);
8266 t = build_decl (FUNCTION_DECL,
8267 ffecom_get_external_identifier_ (s),
8269 DECL_EXTERNAL (t) = 1;
8270 TREE_PUBLIC (t) = 1;
8272 t = start_decl (t, FALSE);
8273 finish_decl (t, NULL_TREE, FALSE);
8276 && ((ffeglobal_type (g) == FFEGLOBAL_typeFUNC)
8277 || (ffeglobal_type (g) == FFEGLOBAL_typeEXT)))
8278 ffeglobal_set_hook (g, t);
8280 ffecom_save_tree_forever (t);
8284 case FFEINFO_whereDUMMY:
8285 assert (ffecom_transform_only_dummies_);
8287 if (ffesymbol_is_f2c (s)
8288 && (ffesymbol_where (s) != FFEINFO_whereCONSTANT))
8289 t = ffecom_tree_ptr_to_fun_type[bt][kt];
8291 t = build_pointer_type
8292 (build_function_type (ffecom_tree_type[bt][kt], NULL_TREE));
8294 t = build_decl (PARM_DECL,
8295 ffecom_get_identifier_ (ffesymbol_text (s)),
8298 DECL_ARTIFICIAL (t) = 1;
8303 case FFEINFO_whereCONSTANT: /* Statement function. */
8304 assert (!ffecom_transform_only_dummies_);
8305 t = ffecom_gen_sfuncdef_ (s, bt, kt);
8308 case FFEINFO_whereINTRINSIC:
8309 assert (!ffecom_transform_only_dummies_);
8310 break; /* Let actual references generate their
8314 assert ("FUNCTION where unheard of" == NULL);
8316 case FFEINFO_whereANY:
8317 t = error_mark_node;
8322 case FFEINFO_kindSUBROUTINE:
8323 switch (ffeinfo_where (ffesymbol_info (s)))
8325 case FFEINFO_whereLOCAL: /* Me. */
8326 assert (!ffecom_transform_only_dummies_);
8327 t = current_function_decl;
8330 case FFEINFO_whereGLOBAL:
8331 assert (!ffecom_transform_only_dummies_);
8333 if (((g = ffesymbol_global (s)) != NULL)
8334 && ((ffeglobal_type (g) == FFEGLOBAL_typeSUBR)
8335 || (ffeglobal_type (g) == FFEGLOBAL_typeEXT))
8336 && (ffeglobal_hook (g) != NULL_TREE)
8337 && ffe_is_globals ())
8339 t = ffeglobal_hook (g);
8343 t = build_decl (FUNCTION_DECL,
8344 ffecom_get_external_identifier_ (s),
8345 ffecom_tree_subr_type);
8346 DECL_EXTERNAL (t) = 1;
8347 TREE_PUBLIC (t) = 1;
8349 t = start_decl (t, FALSE);
8350 finish_decl (t, NULL_TREE, FALSE);
8353 && ((ffeglobal_type (g) == FFEGLOBAL_typeSUBR)
8354 || (ffeglobal_type (g) == FFEGLOBAL_typeEXT)))
8355 ffeglobal_set_hook (g, t);
8357 ffecom_save_tree_forever (t);
8361 case FFEINFO_whereDUMMY:
8362 assert (ffecom_transform_only_dummies_);
8364 t = build_decl (PARM_DECL,
8365 ffecom_get_identifier_ (ffesymbol_text (s)),
8366 ffecom_tree_ptr_to_subr_type);
8368 DECL_ARTIFICIAL (t) = 1;
8373 case FFEINFO_whereINTRINSIC:
8374 assert (!ffecom_transform_only_dummies_);
8375 break; /* Let actual references generate their
8379 assert ("SUBROUTINE where unheard of" == NULL);
8381 case FFEINFO_whereANY:
8382 t = error_mark_node;
8387 case FFEINFO_kindPROGRAM:
8388 switch (ffeinfo_where (ffesymbol_info (s)))
8390 case FFEINFO_whereLOCAL: /* Me. */
8391 assert (!ffecom_transform_only_dummies_);
8392 t = current_function_decl;
8395 case FFEINFO_whereCOMMON:
8396 case FFEINFO_whereDUMMY:
8397 case FFEINFO_whereGLOBAL:
8398 case FFEINFO_whereRESULT:
8399 case FFEINFO_whereFLEETING:
8400 case FFEINFO_whereFLEETING_CADDR:
8401 case FFEINFO_whereFLEETING_IADDR:
8402 case FFEINFO_whereIMMEDIATE:
8403 case FFEINFO_whereINTRINSIC:
8404 case FFEINFO_whereCONSTANT:
8405 case FFEINFO_whereCONSTANT_SUBOBJECT:
8407 assert ("PROGRAM where unheard of" == NULL);
8409 case FFEINFO_whereANY:
8410 t = error_mark_node;
8415 case FFEINFO_kindBLOCKDATA:
8416 switch (ffeinfo_where (ffesymbol_info (s)))
8418 case FFEINFO_whereLOCAL: /* Me. */
8419 assert (!ffecom_transform_only_dummies_);
8420 t = current_function_decl;
8423 case FFEINFO_whereGLOBAL:
8424 assert (!ffecom_transform_only_dummies_);
8426 t = build_decl (FUNCTION_DECL,
8427 ffecom_get_external_identifier_ (s),
8428 ffecom_tree_blockdata_type);
8429 DECL_EXTERNAL (t) = 1;
8430 TREE_PUBLIC (t) = 1;
8432 t = start_decl (t, FALSE);
8433 finish_decl (t, NULL_TREE, FALSE);
8435 ffecom_save_tree_forever (t);
8439 case FFEINFO_whereCOMMON:
8440 case FFEINFO_whereDUMMY:
8441 case FFEINFO_whereRESULT:
8442 case FFEINFO_whereFLEETING:
8443 case FFEINFO_whereFLEETING_CADDR:
8444 case FFEINFO_whereFLEETING_IADDR:
8445 case FFEINFO_whereIMMEDIATE:
8446 case FFEINFO_whereINTRINSIC:
8447 case FFEINFO_whereCONSTANT:
8448 case FFEINFO_whereCONSTANT_SUBOBJECT:
8450 assert ("BLOCKDATA where unheard of" == NULL);
8452 case FFEINFO_whereANY:
8453 t = error_mark_node;
8458 case FFEINFO_kindCOMMON:
8459 switch (ffeinfo_where (ffesymbol_info (s)))
8461 case FFEINFO_whereLOCAL:
8462 assert (!ffecom_transform_only_dummies_);
8463 ffecom_transform_common_ (s);
8466 case FFEINFO_whereNONE:
8467 case FFEINFO_whereCOMMON:
8468 case FFEINFO_whereDUMMY:
8469 case FFEINFO_whereGLOBAL:
8470 case FFEINFO_whereRESULT:
8471 case FFEINFO_whereFLEETING:
8472 case FFEINFO_whereFLEETING_CADDR:
8473 case FFEINFO_whereFLEETING_IADDR:
8474 case FFEINFO_whereIMMEDIATE:
8475 case FFEINFO_whereINTRINSIC:
8476 case FFEINFO_whereCONSTANT:
8477 case FFEINFO_whereCONSTANT_SUBOBJECT:
8479 assert ("COMMON where unheard of" == NULL);
8481 case FFEINFO_whereANY:
8482 t = error_mark_node;
8487 case FFEINFO_kindCONSTRUCT:
8488 switch (ffeinfo_where (ffesymbol_info (s)))
8490 case FFEINFO_whereLOCAL:
8491 assert (!ffecom_transform_only_dummies_);
8494 case FFEINFO_whereNONE:
8495 case FFEINFO_whereCOMMON:
8496 case FFEINFO_whereDUMMY:
8497 case FFEINFO_whereGLOBAL:
8498 case FFEINFO_whereRESULT:
8499 case FFEINFO_whereFLEETING:
8500 case FFEINFO_whereFLEETING_CADDR:
8501 case FFEINFO_whereFLEETING_IADDR:
8502 case FFEINFO_whereIMMEDIATE:
8503 case FFEINFO_whereINTRINSIC:
8504 case FFEINFO_whereCONSTANT:
8505 case FFEINFO_whereCONSTANT_SUBOBJECT:
8507 assert ("CONSTRUCT where unheard of" == NULL);
8509 case FFEINFO_whereANY:
8510 t = error_mark_node;
8515 case FFEINFO_kindNAMELIST:
8516 switch (ffeinfo_where (ffesymbol_info (s)))
8518 case FFEINFO_whereLOCAL:
8519 assert (!ffecom_transform_only_dummies_);
8520 t = ffecom_transform_namelist_ (s);
8523 case FFEINFO_whereNONE:
8524 case FFEINFO_whereCOMMON:
8525 case FFEINFO_whereDUMMY:
8526 case FFEINFO_whereGLOBAL:
8527 case FFEINFO_whereRESULT:
8528 case FFEINFO_whereFLEETING:
8529 case FFEINFO_whereFLEETING_CADDR:
8530 case FFEINFO_whereFLEETING_IADDR:
8531 case FFEINFO_whereIMMEDIATE:
8532 case FFEINFO_whereINTRINSIC:
8533 case FFEINFO_whereCONSTANT:
8534 case FFEINFO_whereCONSTANT_SUBOBJECT:
8536 assert ("NAMELIST where unheard of" == NULL);
8538 case FFEINFO_whereANY:
8539 t = error_mark_node;
8545 assert ("kind unheard of" == NULL);
8547 case FFEINFO_kindANY:
8548 t = error_mark_node;
8552 ffesymbol_hook (s).decl_tree = t;
8553 ffesymbol_hook (s).length_tree = tlen;
8554 ffesymbol_hook (s).addr = addr;
8556 lineno = old_lineno;
8557 input_filename = old_input_filename;
8563 /* Transform into ASSIGNable symbol.
8565 Symbol has already been transformed, but for whatever reason, the
8566 resulting decl_tree has been deemed not usable for an ASSIGN target.
8567 (E.g. it isn't wide enough to hold a pointer.) So, here we invent
8568 another local symbol of type void * and stuff that in the assign_tree
8569 argument. The F77/F90 standards allow this implementation. */
8571 #if FFECOM_targetCURRENT == FFECOM_targetGCC
8573 ffecom_sym_transform_assign_ (ffesymbol s)
8575 tree t; /* Transformed thingy. */
8577 int old_lineno = lineno;
8578 char *old_input_filename = input_filename;
8580 if (ffesymbol_sfdummyparent (s) == NULL)
8582 input_filename = ffesymbol_where_filename (s);
8583 lineno = ffesymbol_where_filelinenum (s);
8587 ffesymbol sf = ffesymbol_sfdummyparent (s);
8589 input_filename = ffesymbol_where_filename (sf);
8590 lineno = ffesymbol_where_filelinenum (sf);
8593 assert (!ffecom_transform_only_dummies_);
8595 yes = suspend_momentary ();
8597 t = build_decl (VAR_DECL,
8598 ffecom_get_invented_identifier ("__g77_ASSIGN_%s",
8599 ffesymbol_text (s)),
8600 TREE_TYPE (null_pointer_node));
8602 switch (ffesymbol_where (s))
8604 case FFEINFO_whereLOCAL:
8605 /* Unlike for regular vars, SAVE status is easy to determine for
8606 ASSIGNed vars, since there's no initialization, there's no
8607 effective storage association (so "SAVE J" does not apply to
8608 K even given "EQUIVALENCE (J,K)"), there's no size issue
8609 to worry about, etc. */
8610 if ((ffesymbol_is_save (s) || ffe_is_saveall ())
8611 && (ffecom_primary_entry_kind_ != FFEINFO_kindPROGRAM)
8612 && (ffecom_primary_entry_kind_ != FFEINFO_kindBLOCKDATA))
8613 TREE_STATIC (t) = 1; /* SAVEd in proc, make static. */
8615 TREE_STATIC (t) = 0; /* No need to make static. */
8618 case FFEINFO_whereCOMMON:
8619 TREE_STATIC (t) = 1; /* Assume COMMONs always SAVEd. */
8622 case FFEINFO_whereDUMMY:
8623 /* Note that twinning a DUMMY means the caller won't see
8624 the ASSIGNed value. But both F77 and F90 allow implementations
8625 to do this, i.e. disallow Fortran code that would try and
8626 take advantage of actually putting a label into a variable
8627 via a dummy argument (or any other storage association, for
8629 TREE_STATIC (t) = 0;
8633 TREE_STATIC (t) = 0;
8637 t = start_decl (t, FALSE);
8638 finish_decl (t, NULL_TREE, FALSE);
8640 resume_momentary (yes);
8642 ffesymbol_hook (s).assign_tree = t;
8644 lineno = old_lineno;
8645 input_filename = old_input_filename;
8651 /* Implement COMMON area in back end.
8653 Because COMMON-based variables can be referenced in the dimension
8654 expressions of dummy (adjustable) arrays, and because dummies
8655 (in the gcc back end) need to be put in the outer binding level
8656 of a function (which has two binding levels, the outer holding
8657 the dummies and the inner holding the other vars), special care
8658 must be taken to handle COMMON areas.
8660 The current strategy is basically to always tell the back end about
8661 the COMMON area as a top-level external reference to just a block
8662 of storage of the master type of that area (e.g. integer, real,
8663 character, whatever -- not a structure). As a distinct action,
8664 if initial values are provided, tell the back end about the area
8665 as a top-level non-external (initialized) area and remember not to
8666 allow further initialization or expansion of the area. Meanwhile,
8667 if no initialization happens at all, tell the back end about
8668 the largest size we've seen declared so the space does get reserved.
8669 (This function doesn't handle all that stuff, but it does some
8670 of the important things.)
8672 Meanwhile, for COMMON variables themselves, just keep creating
8673 references like *((float *) (&common_area + offset)) each time
8674 we reference the variable. In other words, don't make a VAR_DECL
8675 or any kind of component reference (like we used to do before 0.4),
8676 though we might do that as well just for debugging purposes (and
8677 stuff the rtl with the appropriate offset expression). */
8679 #if FFECOM_targetCURRENT == FFECOM_targetGCC
8681 ffecom_transform_common_ (ffesymbol s)
8683 ffestorag st = ffesymbol_storage (s);
8684 ffeglobal g = ffesymbol_global (s);
8689 bool is_init = ffestorag_is_init (st);
8691 assert (st != NULL);
8694 || (ffeglobal_type (g) != FFEGLOBAL_typeCOMMON))
8697 /* First update the size of the area in global terms. */
8699 ffeglobal_size_common (s, ffestorag_size (st));
8701 if (!ffeglobal_common_init (g))
8702 is_init = FALSE; /* No explicit init, don't let erroneous joins init. */
8704 cbt = ffeglobal_hook (g);
8706 /* If we already have declared this common block for a previous program
8707 unit, and either we already initialized it or we don't have new
8708 initialization for it, just return what we have without changing it. */
8710 if ((cbt != NULL_TREE)
8712 || !DECL_EXTERNAL (cbt)))
8714 if (st->hook == NULL) ffestorag_set_hook (st, cbt);
8718 /* Process inits. */
8722 if (ffestorag_init (st) != NULL)
8726 /* Set the padding for the expression, so ffecom_expr
8727 knows to insert that many zeros. */
8728 switch (ffebld_op (sexp = ffestorag_init (st)))
8730 case FFEBLD_opCONTER:
8731 ffebld_conter_set_pad (sexp, ffestorag_modulo (st));
8734 case FFEBLD_opARRTER:
8735 ffebld_arrter_set_pad (sexp, ffestorag_modulo (st));
8738 case FFEBLD_opACCTER:
8739 ffebld_accter_set_pad (sexp, ffestorag_modulo (st));
8743 assert ("bad op for cmn init (pad)" == NULL);
8747 init = ffecom_expr (sexp);
8748 if (init == error_mark_node)
8749 { /* Hopefully the back end complained! */
8751 if (cbt != NULL_TREE)
8756 init = error_mark_node;
8761 /* cbtype must be permanently allocated! */
8763 /* Allocate the MAX of the areas so far, seen filewide. */
8764 high = build_int_2 ((ffeglobal_common_size (g)
8765 + ffeglobal_common_pad (g)) - 1, 0);
8766 TREE_TYPE (high) = ffecom_integer_type_node;
8769 cbtype = build_array_type (char_type_node,
8770 build_range_type (integer_type_node,
8774 cbtype = build_array_type (char_type_node, NULL_TREE);
8776 if (cbt == NULL_TREE)
8779 = build_decl (VAR_DECL,
8780 ffecom_get_external_identifier_ (s),
8782 TREE_STATIC (cbt) = 1;
8783 TREE_PUBLIC (cbt) = 1;
8788 TREE_TYPE (cbt) = cbtype;
8790 DECL_EXTERNAL (cbt) = init ? 0 : 1;
8791 DECL_INITIAL (cbt) = init ? error_mark_node : NULL_TREE;
8793 cbt = start_decl (cbt, TRUE);
8794 if (ffeglobal_hook (g) != NULL)
8795 assert (cbt == ffeglobal_hook (g));
8797 assert (!init || !DECL_EXTERNAL (cbt));
8799 /* Make sure that any type can live in COMMON and be referenced
8800 without getting a bus error. We could pick the most restrictive
8801 alignment of all entities actually placed in the COMMON, but
8802 this seems easy enough. */
8804 DECL_ALIGN (cbt) = BIGGEST_ALIGNMENT;
8806 if (is_init && (ffestorag_init (st) == NULL))
8807 init = ffecom_init_zero_ (cbt);
8809 finish_decl (cbt, init, TRUE);
8812 ffestorag_set_init (st, ffebld_new_any ());
8816 assert (DECL_SIZE_UNIT (cbt) != NULL_TREE);
8817 assert (TREE_CODE (DECL_SIZE_UNIT (cbt)) == INTEGER_CST);
8818 assert (0 == compare_tree_int (DECL_SIZE_UNIT (cbt),
8819 (ffeglobal_common_size (g)
8820 + ffeglobal_common_pad (g))));
8823 ffeglobal_set_hook (g, cbt);
8825 ffestorag_set_hook (st, cbt);
8827 ffecom_save_tree_forever (cbt);
8831 /* Make master area for local EQUIVALENCE. */
8833 #if FFECOM_targetCURRENT == FFECOM_targetGCC
8835 ffecom_transform_equiv_ (ffestorag eqst)
8841 bool is_init = ffestorag_is_init (eqst);
8844 assert (eqst != NULL);
8846 eqt = ffestorag_hook (eqst);
8848 if (eqt != NULL_TREE)
8851 /* Process inits. */
8855 if (ffestorag_init (eqst) != NULL)
8859 /* Set the padding for the expression, so ffecom_expr
8860 knows to insert that many zeros. */
8861 switch (ffebld_op (sexp = ffestorag_init (eqst)))
8863 case FFEBLD_opCONTER:
8864 ffebld_conter_set_pad (sexp, ffestorag_modulo (eqst));
8867 case FFEBLD_opARRTER:
8868 ffebld_arrter_set_pad (sexp, ffestorag_modulo (eqst));
8871 case FFEBLD_opACCTER:
8872 ffebld_accter_set_pad (sexp, ffestorag_modulo (eqst));
8876 assert ("bad op for eqv init (pad)" == NULL);
8880 init = ffecom_expr (sexp);
8881 if (init == error_mark_node)
8882 init = NULL_TREE; /* Hopefully the back end complained! */
8885 init = error_mark_node;
8887 else if (ffe_is_init_local_zero ())
8888 init = error_mark_node;
8892 ffecom_member_namelisted_ = FALSE;
8893 ffestorag_drive (ffestorag_list_equivs (eqst),
8894 &ffecom_member_phase1_,
8897 yes = suspend_momentary ();
8899 high = build_int_2 ((ffestorag_size (eqst)
8900 + ffestorag_modulo (eqst)) - 1, 0);
8901 TREE_TYPE (high) = ffecom_integer_type_node;
8903 eqtype = build_array_type (char_type_node,
8904 build_range_type (ffecom_integer_type_node,
8905 ffecom_integer_zero_node,
8908 eqt = build_decl (VAR_DECL,
8909 ffecom_get_invented_identifier ("__g77_equiv_%s",
8911 (ffestorag_symbol (eqst))),
8913 DECL_EXTERNAL (eqt) = 0;
8915 || ffecom_member_namelisted_
8916 #ifdef FFECOM_sizeMAXSTACKITEM
8917 || (ffestorag_size (eqst) > FFECOM_sizeMAXSTACKITEM)
8919 || ((ffecom_primary_entry_kind_ != FFEINFO_kindPROGRAM)
8920 && (ffecom_primary_entry_kind_ != FFEINFO_kindBLOCKDATA)
8921 && (ffestorag_is_save (eqst) || ffe_is_saveall ())))
8922 TREE_STATIC (eqt) = 1;
8924 TREE_STATIC (eqt) = 0;
8925 TREE_PUBLIC (eqt) = 0;
8926 DECL_CONTEXT (eqt) = current_function_decl;
8928 DECL_INITIAL (eqt) = error_mark_node;
8930 DECL_INITIAL (eqt) = NULL_TREE;
8932 eqt = start_decl (eqt, FALSE);
8934 /* Make sure that any type can live in EQUIVALENCE and be referenced
8935 without getting a bus error. We could pick the most restrictive
8936 alignment of all entities actually placed in the EQUIVALENCE, but
8937 this seems easy enough. */
8939 DECL_ALIGN (eqt) = BIGGEST_ALIGNMENT;
8941 if ((!is_init && ffe_is_init_local_zero ())
8942 || (is_init && (ffestorag_init (eqst) == NULL)))
8943 init = ffecom_init_zero_ (eqt);
8945 finish_decl (eqt, init, FALSE);
8948 ffestorag_set_init (eqst, ffebld_new_any ());
8951 assert (TREE_CODE (DECL_SIZE_UNIT (eqt)) == INTEGER_CST);
8952 assert (0 == compare_tree_int (DECL_SIZE_UNIT (eqt),
8953 (ffestorag_size (eqst)
8954 + ffestorag_modulo (eqst))));
8957 ffestorag_set_hook (eqst, eqt);
8959 #ifdef SOMEONE_GETS_DEBUG_SUPPORT_WORKING
8960 ffestorag_drive (ffestorag_list_equivs (eqst),
8961 &ffecom_member_phase2_,
8965 resume_momentary (yes);
8969 /* Implement NAMELIST in back end. See f2c/format.c for more info. */
8971 #if FFECOM_targetCURRENT == FFECOM_targetGCC
8973 ffecom_transform_namelist_ (ffesymbol s)
8976 tree nmltype = ffecom_type_namelist_ ();
8985 static int mynumber = 0;
8987 yes = suspend_momentary ();
8989 nmlt = build_decl (VAR_DECL,
8990 ffecom_get_invented_identifier ("__g77_namelist_%d",
8993 TREE_STATIC (nmlt) = 1;
8994 DECL_INITIAL (nmlt) = error_mark_node;
8996 nmlt = start_decl (nmlt, FALSE);
8998 /* Process inits. */
9000 i = strlen (ffesymbol_text (s));
9002 high = build_int_2 (i, 0);
9003 TREE_TYPE (high) = ffecom_f2c_ftnlen_type_node;
9005 nameinit = ffecom_build_f2c_string_ (i + 1,
9006 ffesymbol_text (s));
9007 TREE_TYPE (nameinit)
9008 = build_type_variant
9011 build_range_type (ffecom_f2c_ftnlen_type_node,
9012 ffecom_f2c_ftnlen_one_node,
9015 TREE_CONSTANT (nameinit) = 1;
9016 TREE_STATIC (nameinit) = 1;
9017 nameinit = ffecom_1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (nameinit)),
9020 varsinit = ffecom_vardesc_array_ (s);
9021 varsinit = ffecom_1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (varsinit)),
9023 TREE_CONSTANT (varsinit) = 1;
9024 TREE_STATIC (varsinit) = 1;
9029 for (i = 0, b = ffesymbol_namelist (s); b != NULL; b = ffebld_trail (b))
9032 nvarsinit = build_int_2 (i, 0);
9033 TREE_TYPE (nvarsinit) = integer_type_node;
9034 TREE_CONSTANT (nvarsinit) = 1;
9035 TREE_STATIC (nvarsinit) = 1;
9037 nmlinits = build_tree_list ((field = TYPE_FIELDS (nmltype)), nameinit);
9038 TREE_CHAIN (nmlinits) = build_tree_list ((field = TREE_CHAIN (field)),
9040 TREE_CHAIN (TREE_CHAIN (nmlinits))
9041 = build_tree_list ((field = TREE_CHAIN (field)), nvarsinit);
9043 nmlinits = build (CONSTRUCTOR, nmltype, NULL_TREE, nmlinits);
9044 TREE_CONSTANT (nmlinits) = 1;
9045 TREE_STATIC (nmlinits) = 1;
9047 finish_decl (nmlt, nmlinits, FALSE);
9049 nmlt = ffecom_1 (ADDR_EXPR, build_pointer_type (nmltype), nmlt);
9051 resume_momentary (yes);
9058 /* A subroutine of ffecom_tree_canonize_ref_. The incoming tree is
9059 analyzed on the assumption it is calculating a pointer to be
9060 indirected through. It must return the proper decl and offset,
9061 taking into account different units of measurements for offsets. */
9063 #if FFECOM_targetCURRENT == FFECOM_targetGCC
9065 ffecom_tree_canonize_ptr_ (tree *decl, tree *offset,
9068 switch (TREE_CODE (t))
9072 case NON_LVALUE_EXPR:
9073 ffecom_tree_canonize_ptr_ (decl, offset, TREE_OPERAND (t, 0));
9077 ffecom_tree_canonize_ptr_ (decl, offset, TREE_OPERAND (t, 0));
9078 if ((*decl == NULL_TREE)
9079 || (*decl == error_mark_node))
9082 if (TREE_CODE (TREE_OPERAND (t, 1)) == INTEGER_CST)
9084 /* An offset into COMMON. */
9085 *offset = fold (build (PLUS_EXPR, TREE_TYPE (*offset),
9086 *offset, TREE_OPERAND (t, 1)));
9087 /* Convert offset (presumably in bytes) into canonical units
9088 (presumably bits). */
9089 *offset = fold (build (MULT_EXPR, TREE_TYPE (*offset),
9090 TYPE_SIZE (TREE_TYPE (TREE_TYPE (t))),
9094 /* Not a COMMON reference, so an unrecognized pattern. */
9095 *decl = error_mark_node;
9100 *offset = bitsize_zero_node;
9104 if (TREE_CODE (TREE_OPERAND (t, 0)) == VAR_DECL)
9106 /* A reference to COMMON. */
9107 *decl = TREE_OPERAND (t, 0);
9108 *offset = bitsize_zero_node;
9113 /* Not a COMMON reference, so an unrecognized pattern. */
9114 *decl = error_mark_node;
9120 /* Given a tree that is possibly intended for use as an lvalue, return
9121 information representing a canonical view of that tree as a decl, an
9122 offset into that decl, and a size for the lvalue.
9124 If there's no applicable decl, NULL_TREE is returned for the decl,
9125 and the other fields are left undefined.
9127 If the tree doesn't fit the recognizable forms, an ERROR_MARK node
9128 is returned for the decl, and the other fields are left undefined.
9130 Otherwise, the decl returned currently is either a VAR_DECL or a
9133 The offset returned is always valid, but of course not necessarily
9134 a constant, and not necessarily converted into the appropriate
9135 type, leaving that up to the caller (so as to avoid that overhead
9136 if the decls being looked at are different anyway).
9138 If the size cannot be determined (e.g. an adjustable array),
9139 an ERROR_MARK node is returned for the size. Otherwise, the
9140 size returned is valid, not necessarily a constant, and not
9141 necessarily converted into the appropriate type as with the
9144 Note that the offset and size expressions are expressed in the
9145 base storage units (usually bits) rather than in the units of
9146 the type of the decl, because two decls with different types
9147 might overlap but with apparently non-overlapping array offsets,
9148 whereas converting the array offsets to consistant offsets will
9149 reveal the overlap. */
9151 #if FFECOM_targetCURRENT == FFECOM_targetGCC
9153 ffecom_tree_canonize_ref_ (tree *decl, tree *offset,
9156 /* The default path is to report a nonexistant decl. */
9162 switch (TREE_CODE (t))
9165 case IDENTIFIER_NODE:
9174 case TRUNC_DIV_EXPR:
9176 case FLOOR_DIV_EXPR:
9177 case ROUND_DIV_EXPR:
9178 case TRUNC_MOD_EXPR:
9180 case FLOOR_MOD_EXPR:
9181 case ROUND_MOD_EXPR:
9183 case EXACT_DIV_EXPR:
9184 case FIX_TRUNC_EXPR:
9186 case FIX_FLOOR_EXPR:
9187 case FIX_ROUND_EXPR:
9202 case BIT_ANDTC_EXPR:
9204 case TRUTH_ANDIF_EXPR:
9205 case TRUTH_ORIF_EXPR:
9206 case TRUTH_AND_EXPR:
9208 case TRUTH_XOR_EXPR:
9209 case TRUTH_NOT_EXPR:
9229 *offset = bitsize_zero_node;
9230 *size = TYPE_SIZE (TREE_TYPE (t));
9235 tree array = TREE_OPERAND (t, 0);
9236 tree element = TREE_OPERAND (t, 1);
9239 if ((array == NULL_TREE)
9240 || (element == NULL_TREE))
9242 *decl = error_mark_node;
9246 ffecom_tree_canonize_ref_ (decl, &init_offset, size,
9248 if ((*decl == NULL_TREE)
9249 || (*decl == error_mark_node))
9253 = size_binop (MULT_EXPR,
9254 TYPE_SIZE (TREE_TYPE (TREE_TYPE (array))),
9256 fold (build (MINUS_EXPR, TREE_TYPE (element),
9260 (TREE_TYPE (array)))))));;
9262 *offset = size_binop (PLUS_EXPR, convert (sizetype, init_offset),
9265 *size = TYPE_SIZE (TREE_TYPE (t));
9271 /* Most of this code is to handle references to COMMON. And so
9272 far that is useful only for calling library functions, since
9273 external (user) functions might reference common areas. But
9274 even calling an external function, it's worthwhile to decode
9275 COMMON references because if not storing into COMMON, we don't
9276 want COMMON-based arguments to gratuitously force use of a
9279 *size = TYPE_SIZE (TREE_TYPE (t));
9281 ffecom_tree_canonize_ptr_ (decl, offset,
9282 TREE_OPERAND (t, 0));
9289 case NON_LVALUE_EXPR:
9292 case COND_EXPR: /* More cases than we can handle. */
9294 case REFERENCE_EXPR:
9295 case PREDECREMENT_EXPR:
9296 case PREINCREMENT_EXPR:
9297 case POSTDECREMENT_EXPR:
9298 case POSTINCREMENT_EXPR:
9301 *decl = error_mark_node;
9307 /* Do divide operation appropriate to type of operands. */
9309 #if FFECOM_targetCURRENT == FFECOM_targetGCC
9311 ffecom_tree_divide_ (tree tree_type, tree left, tree right,
9312 tree dest_tree, ffebld dest, bool *dest_used,
9315 if ((left == error_mark_node)
9316 || (right == error_mark_node))
9317 return error_mark_node;
9319 switch (TREE_CODE (tree_type))
9322 return ffecom_2 (TRUNC_DIV_EXPR, tree_type,
9327 if (! optimize_size)
9328 return ffecom_2 (RDIV_EXPR, tree_type,
9334 if (TREE_TYPE (tree_type)
9335 == ffecom_tree_type [FFEINFO_basictypeREAL][FFEINFO_kindtypeREAL1])
9336 ix = FFECOM_gfrtDIV_CC; /* Overlapping result okay. */
9338 ix = FFECOM_gfrtDIV_ZZ; /* Overlapping result okay. */
9340 left = ffecom_1 (ADDR_EXPR,
9341 build_pointer_type (TREE_TYPE (left)),
9343 left = build_tree_list (NULL_TREE, left);
9344 right = ffecom_1 (ADDR_EXPR,
9345 build_pointer_type (TREE_TYPE (right)),
9347 right = build_tree_list (NULL_TREE, right);
9348 TREE_CHAIN (left) = right;
9350 return ffecom_call_ (ffecom_gfrt_tree_ (ix),
9351 ffecom_gfrt_kindtype (ix),
9352 ffe_is_f2c_library (),
9355 dest_tree, dest, dest_used,
9356 NULL_TREE, TRUE, hook);
9364 if (TREE_TYPE (TYPE_FIELDS (tree_type))
9365 == ffecom_tree_type [FFEINFO_basictypeREAL][FFEINFO_kindtypeREAL1])
9366 ix = FFECOM_gfrtDIV_CC; /* Overlapping result okay. */
9368 ix = FFECOM_gfrtDIV_ZZ; /* Overlapping result okay. */
9370 left = ffecom_1 (ADDR_EXPR,
9371 build_pointer_type (TREE_TYPE (left)),
9373 left = build_tree_list (NULL_TREE, left);
9374 right = ffecom_1 (ADDR_EXPR,
9375 build_pointer_type (TREE_TYPE (right)),
9377 right = build_tree_list (NULL_TREE, right);
9378 TREE_CHAIN (left) = right;
9380 return ffecom_call_ (ffecom_gfrt_tree_ (ix),
9381 ffecom_gfrt_kindtype (ix),
9382 ffe_is_f2c_library (),
9385 dest_tree, dest, dest_used,
9386 NULL_TREE, TRUE, hook);
9391 return ffecom_2 (RDIV_EXPR, tree_type,
9398 /* Build type info for non-dummy variable. */
9400 #if FFECOM_targetCURRENT == FFECOM_targetGCC
9402 ffecom_type_localvar_ (ffesymbol s, ffeinfoBasictype bt,
9411 type = ffecom_tree_type[bt][kt];
9412 if (bt == FFEINFO_basictypeCHARACTER)
9414 hight = build_int_2 (ffesymbol_size (s), 0);
9415 TREE_TYPE (hight) = ffecom_f2c_ftnlen_type_node;
9420 build_range_type (ffecom_f2c_ftnlen_type_node,
9421 ffecom_f2c_ftnlen_one_node,
9423 type = ffecom_check_size_overflow_ (s, type, FALSE);
9426 for (dl = ffesymbol_dims (s); dl != NULL; dl = ffebld_trail (dl))
9428 if (type == error_mark_node)
9431 dim = ffebld_head (dl);
9432 assert (ffebld_op (dim) == FFEBLD_opBOUNDS);
9434 if (ffebld_left (dim) == NULL)
9435 lowt = integer_one_node;
9437 lowt = ffecom_expr (ffebld_left (dim));
9439 if (TREE_CODE (lowt) != INTEGER_CST)
9440 lowt = variable_size (lowt);
9442 assert (ffebld_right (dim) != NULL);
9443 hight = ffecom_expr (ffebld_right (dim));
9445 if (TREE_CODE (hight) != INTEGER_CST)
9446 hight = variable_size (hight);
9448 type = build_array_type (type,
9449 build_range_type (ffecom_integer_type_node,
9451 type = ffecom_check_size_overflow_ (s, type, FALSE);
9458 /* Build Namelist type. */
9460 #if FFECOM_targetCURRENT == FFECOM_targetGCC
9462 ffecom_type_namelist_ ()
9464 static tree type = NULL_TREE;
9466 if (type == NULL_TREE)
9468 static tree namefield, varsfield, nvarsfield;
9471 vardesctype = ffecom_type_vardesc_ ();
9473 type = make_node (RECORD_TYPE);
9475 vardesctype = build_pointer_type (build_pointer_type (vardesctype));
9477 namefield = ffecom_decl_field (type, NULL_TREE, "name",
9479 varsfield = ffecom_decl_field (type, namefield, "vars", vardesctype);
9480 nvarsfield = ffecom_decl_field (type, varsfield, "nvars",
9483 TYPE_FIELDS (type) = namefield;
9486 ggc_add_tree_root (&type, 1);
9494 /* Build Vardesc type. */
9496 #if FFECOM_targetCURRENT == FFECOM_targetGCC
9498 ffecom_type_vardesc_ ()
9500 static tree type = NULL_TREE;
9501 static tree namefield, addrfield, dimsfield, typefield;
9503 if (type == NULL_TREE)
9505 type = make_node (RECORD_TYPE);
9507 namefield = ffecom_decl_field (type, NULL_TREE, "name",
9509 addrfield = ffecom_decl_field (type, namefield, "addr",
9511 dimsfield = ffecom_decl_field (type, addrfield, "dims",
9512 ffecom_f2c_ptr_to_ftnlen_type_node);
9513 typefield = ffecom_decl_field (type, dimsfield, "type",
9516 TYPE_FIELDS (type) = namefield;
9519 ggc_add_tree_root (&type, 1);
9527 #if FFECOM_targetCURRENT == FFECOM_targetGCC
9529 ffecom_vardesc_ (ffebld expr)
9533 assert (ffebld_op (expr) == FFEBLD_opSYMTER);
9534 s = ffebld_symter (expr);
9536 if (ffesymbol_hook (s).vardesc_tree == NULL_TREE)
9539 tree vardesctype = ffecom_type_vardesc_ ();
9548 static int mynumber = 0;
9550 yes = suspend_momentary ();
9552 var = build_decl (VAR_DECL,
9553 ffecom_get_invented_identifier ("__g77_vardesc_%d",
9556 TREE_STATIC (var) = 1;
9557 DECL_INITIAL (var) = error_mark_node;
9559 var = start_decl (var, FALSE);
9561 /* Process inits. */
9563 nameinit = ffecom_build_f2c_string_ ((i = strlen (ffesymbol_text (s)))
9565 ffesymbol_text (s));
9566 TREE_TYPE (nameinit)
9567 = build_type_variant
9570 build_range_type (integer_type_node,
9572 build_int_2 (i, 0))),
9574 TREE_CONSTANT (nameinit) = 1;
9575 TREE_STATIC (nameinit) = 1;
9576 nameinit = ffecom_1 (ADDR_EXPR,
9577 build_pointer_type (TREE_TYPE (nameinit)),
9580 addrinit = ffecom_arg_ptr_to_expr (expr, &typeinit);
9582 dimsinit = ffecom_vardesc_dims_ (s);
9584 if (typeinit == NULL_TREE)
9586 ffeinfoBasictype bt = ffesymbol_basictype (s);
9587 ffeinfoKindtype kt = ffesymbol_kindtype (s);
9588 int tc = ffecom_f2c_typecode (bt, kt);
9591 typeinit = build_int_2 (tc, (tc < 0) ? -1 : 0);
9594 typeinit = ffecom_1 (NEGATE_EXPR, TREE_TYPE (typeinit), typeinit);
9596 varinits = build_tree_list ((field = TYPE_FIELDS (vardesctype)),
9598 TREE_CHAIN (varinits) = build_tree_list ((field = TREE_CHAIN (field)),
9600 TREE_CHAIN (TREE_CHAIN (varinits))
9601 = build_tree_list ((field = TREE_CHAIN (field)), dimsinit);
9602 TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (varinits)))
9603 = build_tree_list ((field = TREE_CHAIN (field)), typeinit);
9605 varinits = build (CONSTRUCTOR, vardesctype, NULL_TREE, varinits);
9606 TREE_CONSTANT (varinits) = 1;
9607 TREE_STATIC (varinits) = 1;
9609 finish_decl (var, varinits, FALSE);
9611 var = ffecom_1 (ADDR_EXPR, build_pointer_type (vardesctype), var);
9613 resume_momentary (yes);
9615 ffesymbol_hook (s).vardesc_tree = var;
9618 return ffesymbol_hook (s).vardesc_tree;
9622 #if FFECOM_targetCURRENT == FFECOM_targetGCC
9624 ffecom_vardesc_array_ (ffesymbol s)
9628 tree item = NULL_TREE;
9632 static int mynumber = 0;
9634 for (i = 0, list = NULL_TREE, b = ffesymbol_namelist (s);
9636 b = ffebld_trail (b), ++i)
9640 t = ffecom_vardesc_ (ffebld_head (b));
9642 if (list == NULL_TREE)
9643 list = item = build_tree_list (NULL_TREE, t);
9646 TREE_CHAIN (item) = build_tree_list (NULL_TREE, t);
9647 item = TREE_CHAIN (item);
9651 yes = suspend_momentary ();
9653 item = build_array_type (build_pointer_type (ffecom_type_vardesc_ ()),
9654 build_range_type (integer_type_node,
9656 build_int_2 (i, 0)));
9657 list = build (CONSTRUCTOR, item, NULL_TREE, list);
9658 TREE_CONSTANT (list) = 1;
9659 TREE_STATIC (list) = 1;
9661 var = ffecom_get_invented_identifier ("__g77_vardesc_array_%d", mynumber++);
9662 var = build_decl (VAR_DECL, var, item);
9663 TREE_STATIC (var) = 1;
9664 DECL_INITIAL (var) = error_mark_node;
9665 var = start_decl (var, FALSE);
9666 finish_decl (var, list, FALSE);
9668 resume_momentary (yes);
9674 #if FFECOM_targetCURRENT == FFECOM_targetGCC
9676 ffecom_vardesc_dims_ (ffesymbol s)
9678 if (ffesymbol_dims (s) == NULL)
9679 return convert (ffecom_f2c_ptr_to_ftnlen_type_node,
9687 tree item = NULL_TREE;
9692 tree baseoff = NULL_TREE;
9693 static int mynumber = 0;
9695 numdim = build_int_2 ((int) ffesymbol_rank (s), 0);
9696 TREE_TYPE (numdim) = ffecom_f2c_ftnlen_type_node;
9698 numelem = ffecom_expr (ffesymbol_arraysize (s));
9699 TREE_TYPE (numelem) = ffecom_f2c_ftnlen_type_node;
9702 backlist = NULL_TREE;
9703 for (b = ffesymbol_dims (s), e = ffesymbol_extents (s);
9705 b = ffebld_trail (b), e = ffebld_trail (e))
9711 if (ffebld_trail (b) == NULL)
9715 t = convert (ffecom_f2c_ftnlen_type_node,
9716 ffecom_expr (ffebld_head (e)));
9718 if (list == NULL_TREE)
9719 list = item = build_tree_list (NULL_TREE, t);
9722 TREE_CHAIN (item) = build_tree_list (NULL_TREE, t);
9723 item = TREE_CHAIN (item);
9727 if (ffebld_left (ffebld_head (b)) == NULL)
9728 low = ffecom_integer_one_node;
9730 low = ffecom_expr (ffebld_left (ffebld_head (b)));
9731 low = convert (ffecom_f2c_ftnlen_type_node, low);
9733 back = build_tree_list (low, t);
9734 TREE_CHAIN (back) = backlist;
9738 for (item = backlist; item != NULL_TREE; item = TREE_CHAIN (item))
9740 if (TREE_VALUE (item) == NULL_TREE)
9741 baseoff = TREE_PURPOSE (item);
9743 baseoff = ffecom_2 (PLUS_EXPR, ffecom_f2c_ftnlen_type_node,
9744 TREE_PURPOSE (item),
9745 ffecom_2 (MULT_EXPR,
9746 ffecom_f2c_ftnlen_type_node,
9751 /* backlist now dead, along with all TREE_PURPOSEs on it. */
9753 baseoff = build_tree_list (NULL_TREE, baseoff);
9754 TREE_CHAIN (baseoff) = list;
9756 numelem = build_tree_list (NULL_TREE, numelem);
9757 TREE_CHAIN (numelem) = baseoff;
9759 numdim = build_tree_list (NULL_TREE, numdim);
9760 TREE_CHAIN (numdim) = numelem;
9762 yes = suspend_momentary ();
9764 item = build_array_type (ffecom_f2c_ftnlen_type_node,
9765 build_range_type (integer_type_node,
9768 ((int) ffesymbol_rank (s)
9770 list = build (CONSTRUCTOR, item, NULL_TREE, numdim);
9771 TREE_CONSTANT (list) = 1;
9772 TREE_STATIC (list) = 1;
9774 var = ffecom_get_invented_identifier ("__g77_dims_%d", mynumber++);
9775 var = build_decl (VAR_DECL, var, item);
9776 TREE_STATIC (var) = 1;
9777 DECL_INITIAL (var) = error_mark_node;
9778 var = start_decl (var, FALSE);
9779 finish_decl (var, list, FALSE);
9781 var = ffecom_1 (ADDR_EXPR, build_pointer_type (item), var);
9783 resume_momentary (yes);
9790 /* Essentially does a "fold (build1 (code, type, node))" while checking
9791 for certain housekeeping things.
9793 NOTE: for building an ADDR_EXPR around a FUNCTION_DECL, use
9794 ffecom_1_fn instead. */
9796 #if FFECOM_targetCURRENT == FFECOM_targetGCC
9798 ffecom_1 (enum tree_code code, tree type, tree node)
9802 if ((node == error_mark_node)
9803 || (type == error_mark_node))
9804 return error_mark_node;
9806 if (code == ADDR_EXPR)
9808 if (!mark_addressable (node))
9809 assert ("can't mark_addressable this node!" == NULL);
9812 switch (ffe_is_emulate_complex () ? code : NOP_EXPR)
9817 item = build (COMPONENT_REF, type, node, TYPE_FIELDS (TREE_TYPE (node)));
9821 item = build (COMPONENT_REF, type, node, TREE_CHAIN (TYPE_FIELDS (TREE_TYPE (node))));
9826 if (TREE_CODE (type) != RECORD_TYPE)
9828 item = build1 (code, type, node);
9831 node = ffecom_stabilize_aggregate_ (node);
9832 realtype = TREE_TYPE (TYPE_FIELDS (type));
9834 ffecom_2 (COMPLEX_EXPR, type,
9835 ffecom_1 (NEGATE_EXPR, realtype,
9836 ffecom_1 (REALPART_EXPR, realtype,
9838 ffecom_1 (NEGATE_EXPR, realtype,
9839 ffecom_1 (IMAGPART_EXPR, realtype,
9844 item = build1 (code, type, node);
9848 if (TREE_SIDE_EFFECTS (node))
9849 TREE_SIDE_EFFECTS (item) = 1;
9850 if ((code == ADDR_EXPR) && staticp (node))
9851 TREE_CONSTANT (item) = 1;
9856 /* Like ffecom_1 (ADDR_EXPR, TREE_TYPE (node), node), except
9857 handles TREE_CODE (node) == FUNCTION_DECL. In particular,
9858 does not set TREE_ADDRESSABLE (because calling an inline
9859 function does not mean the function needs to be separately
9862 #if FFECOM_targetCURRENT == FFECOM_targetGCC
9864 ffecom_1_fn (tree node)
9869 if (node == error_mark_node)
9870 return error_mark_node;
9872 type = build_type_variant (TREE_TYPE (node),
9873 TREE_READONLY (node),
9874 TREE_THIS_VOLATILE (node));
9875 item = build1 (ADDR_EXPR,
9876 build_pointer_type (type), node);
9877 if (TREE_SIDE_EFFECTS (node))
9878 TREE_SIDE_EFFECTS (item) = 1;
9880 TREE_CONSTANT (item) = 1;
9885 /* Essentially does a "fold (build (code, type, node1, node2))" while
9886 checking for certain housekeeping things. */
9888 #if FFECOM_targetCURRENT == FFECOM_targetGCC
9890 ffecom_2 (enum tree_code code, tree type, tree node1,
9895 if ((node1 == error_mark_node)
9896 || (node2 == error_mark_node)
9897 || (type == error_mark_node))
9898 return error_mark_node;
9900 switch (ffe_is_emulate_complex () ? code : NOP_EXPR)
9902 tree a, b, c, d, realtype;
9905 assert ("no CONJ_EXPR support yet" == NULL);
9906 return error_mark_node;
9909 item = build_tree_list (TYPE_FIELDS (type), node1);
9910 TREE_CHAIN (item) = build_tree_list (TREE_CHAIN (TYPE_FIELDS (type)), node2);
9911 item = build (CONSTRUCTOR, type, NULL_TREE, item);
9915 if (TREE_CODE (type) != RECORD_TYPE)
9917 item = build (code, type, node1, node2);
9920 node1 = ffecom_stabilize_aggregate_ (node1);
9921 node2 = ffecom_stabilize_aggregate_ (node2);
9922 realtype = TREE_TYPE (TYPE_FIELDS (type));
9924 ffecom_2 (COMPLEX_EXPR, type,
9925 ffecom_2 (PLUS_EXPR, realtype,
9926 ffecom_1 (REALPART_EXPR, realtype,
9928 ffecom_1 (REALPART_EXPR, realtype,
9930 ffecom_2 (PLUS_EXPR, realtype,
9931 ffecom_1 (IMAGPART_EXPR, realtype,
9933 ffecom_1 (IMAGPART_EXPR, realtype,
9938 if (TREE_CODE (type) != RECORD_TYPE)
9940 item = build (code, type, node1, node2);
9943 node1 = ffecom_stabilize_aggregate_ (node1);
9944 node2 = ffecom_stabilize_aggregate_ (node2);
9945 realtype = TREE_TYPE (TYPE_FIELDS (type));
9947 ffecom_2 (COMPLEX_EXPR, type,
9948 ffecom_2 (MINUS_EXPR, realtype,
9949 ffecom_1 (REALPART_EXPR, realtype,
9951 ffecom_1 (REALPART_EXPR, realtype,
9953 ffecom_2 (MINUS_EXPR, realtype,
9954 ffecom_1 (IMAGPART_EXPR, realtype,
9956 ffecom_1 (IMAGPART_EXPR, realtype,
9961 if (TREE_CODE (type) != RECORD_TYPE)
9963 item = build (code, type, node1, node2);
9966 node1 = ffecom_stabilize_aggregate_ (node1);
9967 node2 = ffecom_stabilize_aggregate_ (node2);
9968 realtype = TREE_TYPE (TYPE_FIELDS (type));
9969 a = save_expr (ffecom_1 (REALPART_EXPR, realtype,
9971 b = save_expr (ffecom_1 (IMAGPART_EXPR, realtype,
9973 c = save_expr (ffecom_1 (REALPART_EXPR, realtype,
9975 d = save_expr (ffecom_1 (IMAGPART_EXPR, realtype,
9978 ffecom_2 (COMPLEX_EXPR, type,
9979 ffecom_2 (MINUS_EXPR, realtype,
9980 ffecom_2 (MULT_EXPR, realtype,
9983 ffecom_2 (MULT_EXPR, realtype,
9986 ffecom_2 (PLUS_EXPR, realtype,
9987 ffecom_2 (MULT_EXPR, realtype,
9990 ffecom_2 (MULT_EXPR, realtype,
9996 if ((TREE_CODE (node1) != RECORD_TYPE)
9997 && (TREE_CODE (node2) != RECORD_TYPE))
9999 item = build (code, type, node1, node2);
10002 assert (TREE_CODE (node1) == RECORD_TYPE);
10003 assert (TREE_CODE (node2) == RECORD_TYPE);
10004 node1 = ffecom_stabilize_aggregate_ (node1);
10005 node2 = ffecom_stabilize_aggregate_ (node2);
10006 realtype = TREE_TYPE (TYPE_FIELDS (type));
10008 ffecom_2 (TRUTH_ANDIF_EXPR, type,
10009 ffecom_2 (code, type,
10010 ffecom_1 (REALPART_EXPR, realtype,
10012 ffecom_1 (REALPART_EXPR, realtype,
10014 ffecom_2 (code, type,
10015 ffecom_1 (IMAGPART_EXPR, realtype,
10017 ffecom_1 (IMAGPART_EXPR, realtype,
10022 if ((TREE_CODE (node1) != RECORD_TYPE)
10023 && (TREE_CODE (node2) != RECORD_TYPE))
10025 item = build (code, type, node1, node2);
10028 assert (TREE_CODE (node1) == RECORD_TYPE);
10029 assert (TREE_CODE (node2) == RECORD_TYPE);
10030 node1 = ffecom_stabilize_aggregate_ (node1);
10031 node2 = ffecom_stabilize_aggregate_ (node2);
10032 realtype = TREE_TYPE (TYPE_FIELDS (type));
10034 ffecom_2 (TRUTH_ORIF_EXPR, type,
10035 ffecom_2 (code, type,
10036 ffecom_1 (REALPART_EXPR, realtype,
10038 ffecom_1 (REALPART_EXPR, realtype,
10040 ffecom_2 (code, type,
10041 ffecom_1 (IMAGPART_EXPR, realtype,
10043 ffecom_1 (IMAGPART_EXPR, realtype,
10048 item = build (code, type, node1, node2);
10052 if (TREE_SIDE_EFFECTS (node1) || TREE_SIDE_EFFECTS (node2))
10053 TREE_SIDE_EFFECTS (item) = 1;
10054 return fold (item);
10058 /* ffecom_2pass_advise_entrypoint -- Advise that there's this entrypoint
10060 ffesymbol s; // the ENTRY point itself
10061 if (ffecom_2pass_advise_entrypoint(s))
10062 // the ENTRY point has been accepted
10064 Does whatever compiler needs to do when it learns about the entrypoint,
10065 like determine the return type of the master function, count the
10066 number of entrypoints, etc. Returns FALSE if the return type is
10067 not compatible with the return type(s) of other entrypoint(s).
10069 NOTE: for every call to this fn that returns TRUE, _do_entrypoint must
10070 later (after _finish_progunit) be called with the same entrypoint(s)
10071 as passed to this fn for which TRUE was returned.
10074 Return FALSE if the return type conflicts with previous entrypoints. */
10076 #if FFECOM_targetCURRENT == FFECOM_targetGCC
10078 ffecom_2pass_advise_entrypoint (ffesymbol entry)
10080 ffebld list; /* opITEM. */
10081 ffebld mlist; /* opITEM. */
10082 ffebld plist; /* opITEM. */
10083 ffebld arg; /* ffebld_head(opITEM). */
10084 ffebld item; /* opITEM. */
10085 ffesymbol s; /* ffebld_symter(arg). */
10086 ffeinfoBasictype bt = ffesymbol_basictype (entry);
10087 ffeinfoKindtype kt = ffesymbol_kindtype (entry);
10088 ffetargetCharacterSize size = ffesymbol_size (entry);
10091 if (ffecom_num_entrypoints_ == 0)
10092 { /* First entrypoint, make list of main
10093 arglist's dummies. */
10094 assert (ffecom_primary_entry_ != NULL);
10096 ffecom_master_bt_ = ffesymbol_basictype (ffecom_primary_entry_);
10097 ffecom_master_kt_ = ffesymbol_kindtype (ffecom_primary_entry_);
10098 ffecom_master_size_ = ffesymbol_size (ffecom_primary_entry_);
10100 for (plist = NULL, list = ffesymbol_dummyargs (ffecom_primary_entry_);
10102 list = ffebld_trail (list))
10104 arg = ffebld_head (list);
10105 if (ffebld_op (arg) != FFEBLD_opSYMTER)
10106 continue; /* Alternate return or some such thing. */
10107 item = ffebld_new_item (arg, NULL);
10109 ffecom_master_arglist_ = item;
10111 ffebld_set_trail (plist, item);
10116 /* If necessary, scan entry arglist for alternate returns. Do this scan
10117 apparently redundantly (it's done below to UNIONize the arglists) so
10118 that we don't complain about RETURN 1 if an offending ENTRY is the only
10119 one with an alternate return. */
10121 if (!ffecom_is_altreturning_)
10123 for (list = ffesymbol_dummyargs (entry);
10125 list = ffebld_trail (list))
10127 arg = ffebld_head (list);
10128 if (ffebld_op (arg) == FFEBLD_opSTAR)
10130 ffecom_is_altreturning_ = TRUE;
10136 /* Now check type compatibility. */
10138 switch (ffecom_master_bt_)
10140 case FFEINFO_basictypeNONE:
10141 ok = (bt != FFEINFO_basictypeCHARACTER);
10144 case FFEINFO_basictypeCHARACTER:
10146 = (bt == FFEINFO_basictypeCHARACTER)
10147 && (kt == ffecom_master_kt_)
10148 && (size == ffecom_master_size_);
10151 case FFEINFO_basictypeANY:
10152 return FALSE; /* Just don't bother. */
10155 if (bt == FFEINFO_basictypeCHARACTER)
10161 if ((bt != ffecom_master_bt_) || (kt != ffecom_master_kt_))
10163 ffecom_master_bt_ = FFEINFO_basictypeNONE;
10164 ffecom_master_kt_ = FFEINFO_kindtypeNONE;
10171 ffebad_start (FFEBAD_ENTRY_CONFLICTS);
10172 ffest_ffebad_here_current_stmt (0);
10174 return FALSE; /* Can't handle entrypoint. */
10177 /* Entrypoint type compatible with previous types. */
10179 ++ffecom_num_entrypoints_;
10181 /* Master-arg-list = UNION(Master-arg-list,entry-arg-list). */
10183 for (list = ffesymbol_dummyargs (entry);
10185 list = ffebld_trail (list))
10187 arg = ffebld_head (list);
10188 if (ffebld_op (arg) != FFEBLD_opSYMTER)
10189 continue; /* Alternate return or some such thing. */
10190 s = ffebld_symter (arg);
10191 for (plist = NULL, mlist = ffecom_master_arglist_;
10193 plist = mlist, mlist = ffebld_trail (mlist))
10194 { /* plist points to previous item for easy
10195 appending of arg. */
10196 if (ffebld_symter (ffebld_head (mlist)) == s)
10197 break; /* Already have this arg in the master list. */
10200 continue; /* Already have this arg in the master list. */
10202 /* Append this arg to the master list. */
10204 item = ffebld_new_item (arg, NULL);
10206 ffecom_master_arglist_ = item;
10208 ffebld_set_trail (plist, item);
10215 /* ffecom_2pass_do_entrypoint -- Do compilation of entrypoint
10217 ffesymbol s; // the ENTRY point itself
10218 ffecom_2pass_do_entrypoint(s);
10220 Does whatever compiler needs to do to make the entrypoint actually
10221 happen. Must be called for each entrypoint after
10222 ffecom_finish_progunit is called. */
10224 #if FFECOM_targetCURRENT == FFECOM_targetGCC
10226 ffecom_2pass_do_entrypoint (ffesymbol entry)
10228 static int mfn_num = 0;
10229 static int ent_num;
10231 if (mfn_num != ffecom_num_fns_)
10232 { /* First entrypoint for this program unit. */
10234 mfn_num = ffecom_num_fns_;
10235 ffecom_do_entry_ (ffecom_primary_entry_, 0);
10240 --ffecom_num_entrypoints_;
10242 ffecom_do_entry_ (entry, ent_num);
10247 /* Essentially does a "fold (build (code, type, node1, node2))" while
10248 checking for certain housekeeping things. Always sets
10249 TREE_SIDE_EFFECTS. */
10251 #if FFECOM_targetCURRENT == FFECOM_targetGCC
10253 ffecom_2s (enum tree_code code, tree type, tree node1,
10258 if ((node1 == error_mark_node)
10259 || (node2 == error_mark_node)
10260 || (type == error_mark_node))
10261 return error_mark_node;
10263 item = build (code, type, node1, node2);
10264 TREE_SIDE_EFFECTS (item) = 1;
10265 return fold (item);
10269 /* Essentially does a "fold (build (code, type, node1, node2, node3))" while
10270 checking for certain housekeeping things. */
10272 #if FFECOM_targetCURRENT == FFECOM_targetGCC
10274 ffecom_3 (enum tree_code code, tree type, tree node1,
10275 tree node2, tree node3)
10279 if ((node1 == error_mark_node)
10280 || (node2 == error_mark_node)
10281 || (node3 == error_mark_node)
10282 || (type == error_mark_node))
10283 return error_mark_node;
10285 item = build (code, type, node1, node2, node3);
10286 if (TREE_SIDE_EFFECTS (node1) || TREE_SIDE_EFFECTS (node2)
10287 || (node3 != NULL_TREE && TREE_SIDE_EFFECTS (node3)))
10288 TREE_SIDE_EFFECTS (item) = 1;
10289 return fold (item);
10293 /* Essentially does a "fold (build (code, type, node1, node2, node3))" while
10294 checking for certain housekeeping things. Always sets
10295 TREE_SIDE_EFFECTS. */
10297 #if FFECOM_targetCURRENT == FFECOM_targetGCC
10299 ffecom_3s (enum tree_code code, tree type, tree node1,
10300 tree node2, tree node3)
10304 if ((node1 == error_mark_node)
10305 || (node2 == error_mark_node)
10306 || (node3 == error_mark_node)
10307 || (type == error_mark_node))
10308 return error_mark_node;
10310 item = build (code, type, node1, node2, node3);
10311 TREE_SIDE_EFFECTS (item) = 1;
10312 return fold (item);
10317 /* ffecom_arg_expr -- Transform argument expr into gcc tree
10319 See use by ffecom_list_expr.
10321 If expression is NULL, returns an integer zero tree. If it is not
10322 a CHARACTER expression, returns whatever ffecom_expr
10323 returns and sets the length return value to NULL_TREE. Otherwise
10324 generates code to evaluate the character expression, returns the proper
10325 pointer to the result, but does NOT set the length return value to a tree
10326 that specifies the length of the result. (In other words, the length
10327 variable is always set to NULL_TREE, because a length is never passed.)
10330 Don't set returned length, since nobody needs it (yet; someday if
10331 we allow CHARACTER*(*) dummies to statement functions, we'll need
10334 #if FFECOM_targetCURRENT == FFECOM_targetGCC
10336 ffecom_arg_expr (ffebld expr, tree *length)
10340 *length = NULL_TREE;
10343 return integer_zero_node;
10345 if (ffeinfo_basictype (ffebld_info (expr)) != FFEINFO_basictypeCHARACTER)
10346 return ffecom_expr (expr);
10348 return ffecom_arg_ptr_to_expr (expr, &ign);
10352 /* Transform expression into constant argument-pointer-to-expression tree.
10354 If the expression can be transformed into a argument-pointer-to-expression
10355 tree that is constant, that is done, and the tree returned. Else
10356 NULL_TREE is returned.
10358 That way, a caller can attempt to provide compile-time initialization
10359 of a variable and, if that fails, *then* choose to start a new block
10360 and resort to using temporaries, as appropriate. */
10363 ffecom_arg_ptr_to_const_expr (ffebld expr, tree *length)
10366 return integer_zero_node;
10368 if (ffebld_op (expr) == FFEBLD_opANY)
10371 *length = error_mark_node;
10372 return error_mark_node;
10375 if (ffebld_arity (expr) == 0
10376 && (ffebld_op (expr) != FFEBLD_opSYMTER
10377 || ffebld_where (expr) == FFEINFO_whereCOMMON
10378 || ffebld_where (expr) == FFEINFO_whereGLOBAL
10379 || ffebld_where (expr) == FFEINFO_whereINTRINSIC))
10383 t = ffecom_arg_ptr_to_expr (expr, length);
10384 assert (TREE_CONSTANT (t));
10385 assert (! length || TREE_CONSTANT (*length));
10390 && ffebld_size (expr) != FFETARGET_charactersizeNONE)
10391 *length = build_int_2 (ffebld_size (expr), 0);
10393 *length = NULL_TREE;
10397 /* ffecom_arg_ptr_to_expr -- Transform argument expr into gcc tree
10399 See use by ffecom_list_ptr_to_expr.
10401 If expression is NULL, returns an integer zero tree. If it is not
10402 a CHARACTER expression, returns whatever ffecom_ptr_to_expr
10403 returns and sets the length return value to NULL_TREE. Otherwise
10404 generates code to evaluate the character expression, returns the proper
10405 pointer to the result, AND sets the length return value to a tree that
10406 specifies the length of the result.
10408 If the length argument is NULL, this is a slightly special
10409 case of building a FORMAT expression, that is, an expression that
10410 will be used at run time without regard to length. For the current
10411 implementation, which uses the libf2c library, this means it is nice
10412 to append a null byte to the end of the expression, where feasible,
10413 to make sure any diagnostic about the FORMAT string terminates at
10416 For now, treat %REF(char-expr) as the same as char-expr with a NULL
10417 length argument. This might even be seen as a feature, if a null
10418 byte can always be appended. */
10420 #if FFECOM_targetCURRENT == FFECOM_targetGCC
10422 ffecom_arg_ptr_to_expr (ffebld expr, tree *length)
10426 ffecomConcatList_ catlist;
10428 if (length != NULL)
10429 *length = NULL_TREE;
10432 return integer_zero_node;
10434 switch (ffebld_op (expr))
10436 case FFEBLD_opPERCENT_VAL:
10437 if (ffeinfo_basictype (ffebld_info (expr)) != FFEINFO_basictypeCHARACTER)
10438 return ffecom_expr (ffebld_left (expr));
10443 temp_exp = ffecom_arg_ptr_to_expr (ffebld_left (expr), &temp_length);
10444 if (temp_exp == error_mark_node)
10445 return error_mark_node;
10447 return ffecom_1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (temp_exp)),
10451 case FFEBLD_opPERCENT_REF:
10452 if (ffeinfo_basictype (ffebld_info (expr)) != FFEINFO_basictypeCHARACTER)
10453 return ffecom_ptr_to_expr (ffebld_left (expr));
10454 if (length != NULL)
10456 ign_length = NULL_TREE;
10457 length = &ign_length;
10459 expr = ffebld_left (expr);
10462 case FFEBLD_opPERCENT_DESCR:
10463 switch (ffeinfo_basictype (ffebld_info (expr)))
10465 #ifdef PASS_HOLLERITH_BY_DESCRIPTOR
10466 case FFEINFO_basictypeHOLLERITH:
10468 case FFEINFO_basictypeCHARACTER:
10469 break; /* Passed by descriptor anyway. */
10472 item = ffecom_ptr_to_expr (expr);
10473 if (item != error_mark_node)
10474 *length = TYPE_SIZE (TREE_TYPE (TREE_TYPE (item)));
10483 #ifdef PASS_HOLLERITH_BY_DESCRIPTOR
10484 if ((ffeinfo_basictype (ffebld_info (expr)) == FFEINFO_basictypeHOLLERITH)
10485 && (length != NULL))
10486 { /* Pass Hollerith by descriptor. */
10487 ffetargetHollerith h;
10489 assert (ffebld_op (expr) == FFEBLD_opCONTER);
10490 h = ffebld_cu_val_hollerith (ffebld_constant_union
10491 (ffebld_conter (expr)));
10493 = build_int_2 (h.length, 0);
10494 TREE_TYPE (*length) = ffecom_f2c_ftnlen_type_node;
10498 if (ffeinfo_basictype (ffebld_info (expr)) != FFEINFO_basictypeCHARACTER)
10499 return ffecom_ptr_to_expr (expr);
10501 assert (ffeinfo_kindtype (ffebld_info (expr))
10502 == FFEINFO_kindtypeCHARACTER1);
10504 while (ffebld_op (expr) == FFEBLD_opPAREN)
10505 expr = ffebld_left (expr);
10507 catlist = ffecom_concat_list_new_ (expr, FFETARGET_charactersizeNONE);
10508 switch (ffecom_concat_list_count_ (catlist))
10510 case 0: /* Shouldn't happen, but in case it does... */
10511 if (length != NULL)
10513 *length = ffecom_f2c_ftnlen_zero_node;
10514 TREE_TYPE (*length) = ffecom_f2c_ftnlen_type_node;
10516 ffecom_concat_list_kill_ (catlist);
10517 return null_pointer_node;
10519 case 1: /* The (fairly) easy case. */
10520 if (length == NULL)
10521 ffecom_char_args_with_null_ (&item, &ign_length,
10522 ffecom_concat_list_expr_ (catlist, 0));
10524 ffecom_char_args_ (&item, length,
10525 ffecom_concat_list_expr_ (catlist, 0));
10526 ffecom_concat_list_kill_ (catlist);
10527 assert (item != NULL_TREE);
10530 default: /* Must actually concatenate things. */
10535 int count = ffecom_concat_list_count_ (catlist);
10546 ffetargetCharacterSize sz;
10548 sz = ffecom_concat_list_maxlen_ (catlist);
10550 assert (sz != FFETARGET_charactersizeNONE);
10555 = ffecom_push_tempvar (ffecom_f2c_ftnlen_type_node,
10556 FFETARGET_charactersizeNONE, count, TRUE);
10559 = ffecom_push_tempvar (ffecom_f2c_address_type_node,
10560 FFETARGET_charactersizeNONE, count, TRUE);
10561 temporary = ffecom_push_tempvar (char_type_node,
10567 hook = ffebld_nonter_hook (expr);
10569 assert (TREE_CODE (hook) == TREE_VEC);
10570 assert (TREE_VEC_LENGTH (hook) == 3);
10571 length_array = lengths = TREE_VEC_ELT (hook, 0);
10572 item_array = items = TREE_VEC_ELT (hook, 1);
10573 temporary = TREE_VEC_ELT (hook, 2);
10577 known_length = ffecom_f2c_ftnlen_zero_node;
10579 for (i = 0; i < count; ++i)
10582 && (length == NULL))
10583 ffecom_char_args_with_null_ (&citem, &clength,
10584 ffecom_concat_list_expr_ (catlist, i));
10586 ffecom_char_args_ (&citem, &clength,
10587 ffecom_concat_list_expr_ (catlist, i));
10588 if ((citem == error_mark_node)
10589 || (clength == error_mark_node))
10591 ffecom_concat_list_kill_ (catlist);
10592 *length = error_mark_node;
10593 return error_mark_node;
10597 = ffecom_2 (COMPOUND_EXPR, TREE_TYPE (items),
10598 ffecom_modify (void_type_node,
10599 ffecom_2 (ARRAY_REF,
10600 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (item_array))),
10602 build_int_2 (i, 0)),
10605 clength = ffecom_save_tree (clength);
10606 if (length != NULL)
10608 = ffecom_2 (PLUS_EXPR, ffecom_f2c_ftnlen_type_node,
10612 = ffecom_2 (COMPOUND_EXPR, TREE_TYPE (lengths),
10613 ffecom_modify (void_type_node,
10614 ffecom_2 (ARRAY_REF,
10615 TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (length_array))),
10617 build_int_2 (i, 0)),
10622 temporary = ffecom_1 (ADDR_EXPR,
10623 build_pointer_type (TREE_TYPE (temporary)),
10626 item = build_tree_list (NULL_TREE, temporary);
10628 = build_tree_list (NULL_TREE,
10629 ffecom_1 (ADDR_EXPR,
10630 build_pointer_type (TREE_TYPE (items)),
10632 TREE_CHAIN (TREE_CHAIN (item))
10633 = build_tree_list (NULL_TREE,
10634 ffecom_1 (ADDR_EXPR,
10635 build_pointer_type (TREE_TYPE (lengths)),
10637 TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (item)))
10640 ffecom_1 (ADDR_EXPR, ffecom_f2c_ptr_to_ftnlen_type_node,
10641 convert (ffecom_f2c_ftnlen_type_node,
10642 build_int_2 (count, 0))));
10643 num = build_int_2 (sz, 0);
10644 TREE_TYPE (num) = ffecom_f2c_ftnlen_type_node;
10645 TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (item))))
10646 = build_tree_list (NULL_TREE, num);
10648 item = ffecom_call_gfrt (FFECOM_gfrtCAT, item, NULL_TREE);
10649 TREE_SIDE_EFFECTS (item) = 1;
10650 item = ffecom_2 (COMPOUND_EXPR, TREE_TYPE (temporary),
10654 if (length != NULL)
10655 *length = known_length;
10658 ffecom_concat_list_kill_ (catlist);
10659 assert (item != NULL_TREE);
10664 /* Generate call to run-time function.
10666 The first arg is the GNU Fortran Run-Time function index, the second
10667 arg is the list of arguments to pass to it. Returned is the expression
10668 (WITHOUT TREE_SIDE_EFFECTS set!) that makes the call and returns the
10669 result (which may be void). */
10671 #if FFECOM_targetCURRENT == FFECOM_targetGCC
10673 ffecom_call_gfrt (ffecomGfrt ix, tree args, tree hook)
10675 return ffecom_call_ (ffecom_gfrt_tree_ (ix),
10676 ffecom_gfrt_kindtype (ix),
10677 ffe_is_f2c_library () && ffecom_gfrt_complex_[ix],
10678 NULL_TREE, args, NULL_TREE, NULL,
10679 NULL, NULL_TREE, TRUE, hook);
10683 /* Transform constant-union to tree. */
10685 #if FFECOM_targetCURRENT == FFECOM_targetGCC
10687 ffecom_constantunion (ffebldConstantUnion *cu, ffeinfoBasictype bt,
10688 ffeinfoKindtype kt, tree tree_type)
10694 case FFEINFO_basictypeINTEGER:
10700 #if FFETARGET_okINTEGER1
10701 case FFEINFO_kindtypeINTEGER1:
10702 val = ffebld_cu_val_integer1 (*cu);
10706 #if FFETARGET_okINTEGER2
10707 case FFEINFO_kindtypeINTEGER2:
10708 val = ffebld_cu_val_integer2 (*cu);
10712 #if FFETARGET_okINTEGER3
10713 case FFEINFO_kindtypeINTEGER3:
10714 val = ffebld_cu_val_integer3 (*cu);
10718 #if FFETARGET_okINTEGER4
10719 case FFEINFO_kindtypeINTEGER4:
10720 val = ffebld_cu_val_integer4 (*cu);
10725 assert ("bad INTEGER constant kind type" == NULL);
10726 /* Fall through. */
10727 case FFEINFO_kindtypeANY:
10728 return error_mark_node;
10730 item = build_int_2 (val, (val < 0) ? -1 : 0);
10731 TREE_TYPE (item) = tree_type;
10735 case FFEINFO_basictypeLOGICAL:
10741 #if FFETARGET_okLOGICAL1
10742 case FFEINFO_kindtypeLOGICAL1:
10743 val = ffebld_cu_val_logical1 (*cu);
10747 #if FFETARGET_okLOGICAL2
10748 case FFEINFO_kindtypeLOGICAL2:
10749 val = ffebld_cu_val_logical2 (*cu);
10753 #if FFETARGET_okLOGICAL3
10754 case FFEINFO_kindtypeLOGICAL3:
10755 val = ffebld_cu_val_logical3 (*cu);
10759 #if FFETARGET_okLOGICAL4
10760 case FFEINFO_kindtypeLOGICAL4:
10761 val = ffebld_cu_val_logical4 (*cu);
10766 assert ("bad LOGICAL constant kind type" == NULL);
10767 /* Fall through. */
10768 case FFEINFO_kindtypeANY:
10769 return error_mark_node;
10771 item = build_int_2 (val, (val < 0) ? -1 : 0);
10772 TREE_TYPE (item) = tree_type;
10776 case FFEINFO_basictypeREAL:
10778 REAL_VALUE_TYPE val;
10782 #if FFETARGET_okREAL1
10783 case FFEINFO_kindtypeREAL1:
10784 val = ffetarget_value_real1 (ffebld_cu_val_real1 (*cu));
10788 #if FFETARGET_okREAL2
10789 case FFEINFO_kindtypeREAL2:
10790 val = ffetarget_value_real2 (ffebld_cu_val_real2 (*cu));
10794 #if FFETARGET_okREAL3
10795 case FFEINFO_kindtypeREAL3:
10796 val = ffetarget_value_real3 (ffebld_cu_val_real3 (*cu));
10800 #if FFETARGET_okREAL4
10801 case FFEINFO_kindtypeREAL4:
10802 val = ffetarget_value_real4 (ffebld_cu_val_real4 (*cu));
10807 assert ("bad REAL constant kind type" == NULL);
10808 /* Fall through. */
10809 case FFEINFO_kindtypeANY:
10810 return error_mark_node;
10812 item = build_real (tree_type, val);
10816 case FFEINFO_basictypeCOMPLEX:
10818 REAL_VALUE_TYPE real;
10819 REAL_VALUE_TYPE imag;
10820 tree el_type = ffecom_tree_type[FFEINFO_basictypeREAL][kt];
10824 #if FFETARGET_okCOMPLEX1
10825 case FFEINFO_kindtypeREAL1:
10826 real = ffetarget_value_real1 (ffebld_cu_val_complex1 (*cu).real);
10827 imag = ffetarget_value_real1 (ffebld_cu_val_complex1 (*cu).imaginary);
10831 #if FFETARGET_okCOMPLEX2
10832 case FFEINFO_kindtypeREAL2:
10833 real = ffetarget_value_real2 (ffebld_cu_val_complex2 (*cu).real);
10834 imag = ffetarget_value_real2 (ffebld_cu_val_complex2 (*cu).imaginary);
10838 #if FFETARGET_okCOMPLEX3
10839 case FFEINFO_kindtypeREAL3:
10840 real = ffetarget_value_real3 (ffebld_cu_val_complex3 (*cu).real);
10841 imag = ffetarget_value_real3 (ffebld_cu_val_complex3 (*cu).imaginary);
10845 #if FFETARGET_okCOMPLEX4
10846 case FFEINFO_kindtypeREAL4:
10847 real = ffetarget_value_real4 (ffebld_cu_val_complex4 (*cu).real);
10848 imag = ffetarget_value_real4 (ffebld_cu_val_complex4 (*cu).imaginary);
10853 assert ("bad REAL constant kind type" == NULL);
10854 /* Fall through. */
10855 case FFEINFO_kindtypeANY:
10856 return error_mark_node;
10858 item = ffecom_build_complex_constant_ (tree_type,
10859 build_real (el_type, real),
10860 build_real (el_type, imag));
10864 case FFEINFO_basictypeCHARACTER:
10865 { /* Happens only in DATA and similar contexts. */
10866 ffetargetCharacter1 val;
10870 #if FFETARGET_okCHARACTER1
10871 case FFEINFO_kindtypeLOGICAL1:
10872 val = ffebld_cu_val_character1 (*cu);
10877 assert ("bad CHARACTER constant kind type" == NULL);
10878 /* Fall through. */
10879 case FFEINFO_kindtypeANY:
10880 return error_mark_node;
10882 item = build_string (ffetarget_length_character1 (val),
10883 ffetarget_text_character1 (val));
10885 = build_type_variant (build_array_type (char_type_node,
10887 (integer_type_node,
10890 (ffetarget_length_character1
10896 case FFEINFO_basictypeHOLLERITH:
10898 ffetargetHollerith h;
10900 h = ffebld_cu_val_hollerith (*cu);
10902 /* If not at least as wide as default INTEGER, widen it. */
10903 if (h.length >= FLOAT_TYPE_SIZE / CHAR_TYPE_SIZE)
10904 item = build_string (h.length, h.text);
10907 char str[FLOAT_TYPE_SIZE / CHAR_TYPE_SIZE];
10909 memcpy (str, h.text, h.length);
10910 memset (&str[h.length], ' ',
10911 FLOAT_TYPE_SIZE / CHAR_TYPE_SIZE
10913 item = build_string (FLOAT_TYPE_SIZE / CHAR_TYPE_SIZE,
10917 = build_type_variant (build_array_type (char_type_node,
10919 (integer_type_node,
10927 case FFEINFO_basictypeTYPELESS:
10929 ffetargetInteger1 ival;
10930 ffetargetTypeless tless;
10933 tless = ffebld_cu_val_typeless (*cu);
10934 error = ffetarget_convert_integer1_typeless (&ival, tless);
10935 assert (error == FFEBAD);
10937 item = build_int_2 ((int) ival, 0);
10942 assert ("not yet on constant type" == NULL);
10943 /* Fall through. */
10944 case FFEINFO_basictypeANY:
10945 return error_mark_node;
10948 TREE_CONSTANT (item) = 1;
10955 /* Transform expression into constant tree.
10957 If the expression can be transformed into a tree that is constant,
10958 that is done, and the tree returned. Else NULL_TREE is returned.
10960 That way, a caller can attempt to provide compile-time initialization
10961 of a variable and, if that fails, *then* choose to start a new block
10962 and resort to using temporaries, as appropriate. */
10965 ffecom_const_expr (ffebld expr)
10968 return integer_zero_node;
10970 if (ffebld_op (expr) == FFEBLD_opANY)
10971 return error_mark_node;
10973 if (ffebld_arity (expr) == 0
10974 && (ffebld_op (expr) != FFEBLD_opSYMTER
10976 /* ~~Enable once common/equivalence is handled properly? */
10977 || ffebld_where (expr) == FFEINFO_whereCOMMON
10979 || ffebld_where (expr) == FFEINFO_whereGLOBAL
10980 || ffebld_where (expr) == FFEINFO_whereINTRINSIC))
10984 t = ffecom_expr (expr);
10985 assert (TREE_CONSTANT (t));
10992 /* Handy way to make a field in a struct/union. */
10994 #if FFECOM_targetCURRENT == FFECOM_targetGCC
10996 ffecom_decl_field (tree context, tree prevfield,
10997 const char *name, tree type)
11001 field = build_decl (FIELD_DECL, get_identifier (name), type);
11002 DECL_CONTEXT (field) = context;
11003 DECL_FRAME_SIZE (field) = 0;
11004 if (prevfield != NULL_TREE)
11005 TREE_CHAIN (prevfield) = field;
11013 ffecom_close_include (FILE *f)
11015 #if FFECOM_GCC_INCLUDE
11016 ffecom_close_include_ (f);
11021 ffecom_decode_include_option (char *spec)
11023 #if FFECOM_GCC_INCLUDE
11024 return ffecom_decode_include_option_ (spec);
11030 /* End a compound statement (block). */
11032 #if FFECOM_targetCURRENT == FFECOM_targetGCC
11034 ffecom_end_compstmt (void)
11036 return bison_rule_compstmt_ ();
11038 #endif /* FFECOM_targetCURRENT == FFECOM_targetGCC */
11040 /* ffecom_end_transition -- Perform end transition on all symbols
11042 ffecom_end_transition();
11044 Calls ffecom_sym_end_transition for each global and local symbol. */
11047 ffecom_end_transition ()
11049 #if FFECOM_targetCURRENT == FFECOM_targetGCC
11053 if (ffe_is_ffedebug ())
11054 fprintf (dmpout, "; end_stmt_transition\n");
11056 #if FFECOM_targetCURRENT == FFECOM_targetGCC
11057 ffecom_list_blockdata_ = NULL;
11058 ffecom_list_common_ = NULL;
11061 ffesymbol_drive (ffecom_sym_end_transition);
11062 if (ffe_is_ffedebug ())
11064 ffestorag_report ();
11065 #if FFECOM_targetCURRENT == FFECOM_targetFFE
11066 ffesymbol_report_all ();
11070 #if FFECOM_targetCURRENT == FFECOM_targetGCC
11071 ffecom_start_progunit_ ();
11073 for (item = ffecom_list_blockdata_;
11075 item = ffebld_trail (item))
11083 static int number = 0;
11085 callee = ffebld_head (item);
11086 s = ffebld_symter (callee);
11087 t = ffesymbol_hook (s).decl_tree;
11088 if (t == NULL_TREE)
11090 s = ffecom_sym_transform_ (s);
11091 t = ffesymbol_hook (s).decl_tree;
11094 yes = suspend_momentary ();
11096 dt = build_pointer_type (TREE_TYPE (t));
11098 var = build_decl (VAR_DECL,
11099 ffecom_get_invented_identifier ("__g77_forceload_%d",
11102 DECL_EXTERNAL (var) = 0;
11103 TREE_STATIC (var) = 1;
11104 TREE_PUBLIC (var) = 0;
11105 DECL_INITIAL (var) = error_mark_node;
11106 TREE_USED (var) = 1;
11108 var = start_decl (var, FALSE);
11110 t = ffecom_1 (ADDR_EXPR, dt, t);
11112 finish_decl (var, t, FALSE);
11114 resume_momentary (yes);
11117 /* This handles any COMMON areas that weren't referenced but have, for
11118 example, important initial data. */
11120 for (item = ffecom_list_common_;
11122 item = ffebld_trail (item))
11123 ffecom_transform_common_ (ffebld_symter (ffebld_head (item)));
11125 ffecom_list_common_ = NULL;
11129 /* ffecom_exec_transition -- Perform exec transition on all symbols
11131 ffecom_exec_transition();
11133 Calls ffecom_sym_exec_transition for each global and local symbol.
11134 Make sure error updating not inhibited. */
11137 ffecom_exec_transition ()
11141 if (ffe_is_ffedebug ())
11142 fprintf (dmpout, "; exec_stmt_transition\n");
11144 inhibited = ffebad_inhibit ();
11145 ffebad_set_inhibit (FALSE);
11147 ffesymbol_drive (ffecom_sym_exec_transition); /* Don't retract! */
11148 ffeequiv_exec_transition (); /* Handle all pending EQUIVALENCEs. */
11149 if (ffe_is_ffedebug ())
11151 ffestorag_report ();
11152 #if FFECOM_targetCURRENT == FFECOM_targetFFE
11153 ffesymbol_report_all ();
11158 ffebad_set_inhibit (TRUE);
11161 /* Handle assignment statement.
11163 Convert dest and source using ffecom_expr, then join them
11164 with an ASSIGN op and pass the whole thing to expand_expr_stmt. */
11166 #if FFECOM_targetCURRENT == FFECOM_targetGCC
11168 ffecom_expand_let_stmt (ffebld dest, ffebld source)
11175 if (ffeinfo_basictype (ffebld_info (dest)) != FFEINFO_basictypeCHARACTER)
11180 /* This attempts to replicate the test below, but must not be
11181 true when the test below is false. (Always err on the side
11182 of creating unused temporaries, to avoid ICEs.) */
11183 if (ffebld_op (dest) != FFEBLD_opSYMTER
11184 || ((dest_tree = ffesymbol_hook (ffebld_symter (dest)).decl_tree)
11185 && (TREE_CODE (dest_tree) != VAR_DECL
11186 || TREE_ADDRESSABLE (dest_tree))))
11188 ffecom_prepare_expr_ (source, dest);
11193 ffecom_prepare_expr_ (source, NULL);
11197 ffecom_prepare_expr_w (NULL_TREE, dest);
11199 /* For COMPLEX assignment like C1=C2, if partial overlap is possible,
11200 create a temporary through which the assignment is to take place,
11201 since MODIFY_EXPR doesn't handle partial overlap properly. */
11202 if (ffebld_basictype (dest) == FFEINFO_basictypeCOMPLEX
11203 && ffecom_possible_partial_overlap_ (dest, source))
11205 assign_temp = ffecom_make_tempvar ("complex_let",
11207 [ffebld_basictype (dest)]
11208 [ffebld_kindtype (dest)],
11209 FFETARGET_charactersizeNONE,
11213 assign_temp = NULL_TREE;
11215 ffecom_prepare_end ();
11217 dest_tree = ffecom_expr_w (NULL_TREE, dest);
11218 if (dest_tree == error_mark_node)
11221 if ((TREE_CODE (dest_tree) != VAR_DECL)
11222 || TREE_ADDRESSABLE (dest_tree))
11223 source_tree = ffecom_expr_ (source, dest_tree, dest, &dest_used,
11227 assert (! dest_used);
11229 source_tree = ffecom_expr (source);
11231 if (source_tree == error_mark_node)
11235 expr_tree = source_tree;
11236 else if (assign_temp)
11239 /* The back end understands a conceptual move (evaluate source;
11240 store into dest), so use that, in case it can determine
11241 that it is going to use, say, two registers as temporaries
11242 anyway. So don't use the temp (and someday avoid generating
11243 it, once this code starts triggering regularly). */
11244 expr_tree = ffecom_2s (MOVE_EXPR, void_type_node,
11248 expr_tree = ffecom_2s (MODIFY_EXPR, void_type_node,
11251 expand_expr_stmt (expr_tree);
11252 expr_tree = ffecom_2s (MODIFY_EXPR, void_type_node,
11258 expr_tree = ffecom_2s (MODIFY_EXPR, void_type_node,
11262 expand_expr_stmt (expr_tree);
11266 ffecom_prepare_let_char_ (ffebld_size_known (dest), source);
11267 ffecom_prepare_expr_w (NULL_TREE, dest);
11269 ffecom_prepare_end ();
11271 ffecom_char_args_ (&dest_tree, &dest_length, dest);
11272 ffecom_let_char_ (dest_tree, dest_length, ffebld_size_known (dest),
11277 /* ffecom_expr -- Transform expr into gcc tree
11280 ffebld expr; // FFE expression.
11281 tree = ffecom_expr(expr);
11283 Recursive descent on expr while making corresponding tree nodes and
11284 attaching type info and such. */
11286 #if FFECOM_targetCURRENT == FFECOM_targetGCC
11288 ffecom_expr (ffebld expr)
11290 return ffecom_expr_ (expr, NULL_TREE, NULL, NULL, FALSE, FALSE);
11294 /* Like ffecom_expr, but return tree usable for assigned GOTO or FORMAT. */
11296 #if FFECOM_targetCURRENT == FFECOM_targetGCC
11298 ffecom_expr_assign (ffebld expr)
11300 return ffecom_expr_ (expr, NULL_TREE, NULL, NULL, TRUE, FALSE);
11304 /* Like ffecom_expr_rw, but return tree usable for ASSIGN. */
11306 #if FFECOM_targetCURRENT == FFECOM_targetGCC
11308 ffecom_expr_assign_w (ffebld expr)
11310 return ffecom_expr_ (expr, NULL_TREE, NULL, NULL, TRUE, FALSE);
11314 /* Transform expr for use as into read/write tree and stabilize the
11315 reference. Not for use on CHARACTER expressions.
11317 Recursive descent on expr while making corresponding tree nodes and
11318 attaching type info and such. */
11320 #if FFECOM_targetCURRENT == FFECOM_targetGCC
11322 ffecom_expr_rw (tree type, ffebld expr)
11324 assert (expr != NULL);
11325 /* Different target types not yet supported. */
11326 assert (type == NULL_TREE || type == ffecom_type_expr (expr));
11328 return stabilize_reference (ffecom_expr (expr));
11332 /* Transform expr for use as into write tree and stabilize the
11333 reference. Not for use on CHARACTER expressions.
11335 Recursive descent on expr while making corresponding tree nodes and
11336 attaching type info and such. */
11338 #if FFECOM_targetCURRENT == FFECOM_targetGCC
11340 ffecom_expr_w (tree type, ffebld expr)
11342 assert (expr != NULL);
11343 /* Different target types not yet supported. */
11344 assert (type == NULL_TREE || type == ffecom_type_expr (expr));
11346 return stabilize_reference (ffecom_expr (expr));
11350 /* Do global stuff. */
11352 #if FFECOM_targetCURRENT == FFECOM_targetGCC
11354 ffecom_finish_compile ()
11356 assert (ffecom_outer_function_decl_ == NULL_TREE);
11357 assert (current_function_decl == NULL_TREE);
11359 ffeglobal_drive (ffecom_finish_global_);
11363 /* Public entry point for front end to access finish_decl. */
11365 #if FFECOM_targetCURRENT == FFECOM_targetGCC
11367 ffecom_finish_decl (tree decl, tree init, bool is_top_level)
11369 assert (!is_top_level);
11370 finish_decl (decl, init, FALSE);
11374 /* Finish a program unit. */
11376 #if FFECOM_targetCURRENT == FFECOM_targetGCC
11378 ffecom_finish_progunit ()
11380 ffecom_end_compstmt ();
11382 ffecom_previous_function_decl_ = current_function_decl;
11383 ffecom_which_entrypoint_decl_ = NULL_TREE;
11385 finish_function (0);
11390 /* Wrapper for get_identifier. pattern is sprintf-like. */
11392 #if FFECOM_targetCURRENT == FFECOM_targetGCC
11394 ffecom_get_invented_identifier (const char *pattern, ...)
11400 va_start (ap, pattern);
11401 if (vasprintf (&nam, pattern, ap) == 0)
11404 decl = get_identifier (nam);
11406 IDENTIFIER_INVENTED (decl) = 1;
11411 ffecom_gfrt_basictype (ffecomGfrt gfrt)
11413 assert (gfrt < FFECOM_gfrt);
11415 switch (ffecom_gfrt_type_[gfrt])
11417 case FFECOM_rttypeVOID_:
11418 case FFECOM_rttypeVOIDSTAR_:
11419 return FFEINFO_basictypeNONE;
11421 case FFECOM_rttypeFTNINT_:
11422 return FFEINFO_basictypeINTEGER;
11424 case FFECOM_rttypeINTEGER_:
11425 return FFEINFO_basictypeINTEGER;
11427 case FFECOM_rttypeLONGINT_:
11428 return FFEINFO_basictypeINTEGER;
11430 case FFECOM_rttypeLOGICAL_:
11431 return FFEINFO_basictypeLOGICAL;
11433 case FFECOM_rttypeREAL_F2C_:
11434 case FFECOM_rttypeREAL_GNU_:
11435 return FFEINFO_basictypeREAL;
11437 case FFECOM_rttypeCOMPLEX_F2C_:
11438 case FFECOM_rttypeCOMPLEX_GNU_:
11439 return FFEINFO_basictypeCOMPLEX;
11441 case FFECOM_rttypeDOUBLE_:
11442 case FFECOM_rttypeDOUBLEREAL_:
11443 return FFEINFO_basictypeREAL;
11445 case FFECOM_rttypeDBLCMPLX_F2C_:
11446 case FFECOM_rttypeDBLCMPLX_GNU_:
11447 return FFEINFO_basictypeCOMPLEX;
11449 case FFECOM_rttypeCHARACTER_:
11450 return FFEINFO_basictypeCHARACTER;
11453 return FFEINFO_basictypeANY;
11458 ffecom_gfrt_kindtype (ffecomGfrt gfrt)
11460 assert (gfrt < FFECOM_gfrt);
11462 switch (ffecom_gfrt_type_[gfrt])
11464 case FFECOM_rttypeVOID_:
11465 case FFECOM_rttypeVOIDSTAR_:
11466 return FFEINFO_kindtypeNONE;
11468 case FFECOM_rttypeFTNINT_:
11469 return FFEINFO_kindtypeINTEGER1;
11471 case FFECOM_rttypeINTEGER_:
11472 return FFEINFO_kindtypeINTEGER1;
11474 case FFECOM_rttypeLONGINT_:
11475 return FFEINFO_kindtypeINTEGER4;
11477 case FFECOM_rttypeLOGICAL_:
11478 return FFEINFO_kindtypeLOGICAL1;
11480 case FFECOM_rttypeREAL_F2C_:
11481 case FFECOM_rttypeREAL_GNU_:
11482 return FFEINFO_kindtypeREAL1;
11484 case FFECOM_rttypeCOMPLEX_F2C_:
11485 case FFECOM_rttypeCOMPLEX_GNU_:
11486 return FFEINFO_kindtypeREAL1;
11488 case FFECOM_rttypeDOUBLE_:
11489 case FFECOM_rttypeDOUBLEREAL_:
11490 return FFEINFO_kindtypeREAL2;
11492 case FFECOM_rttypeDBLCMPLX_F2C_:
11493 case FFECOM_rttypeDBLCMPLX_GNU_:
11494 return FFEINFO_kindtypeREAL2;
11496 case FFECOM_rttypeCHARACTER_:
11497 return FFEINFO_kindtypeCHARACTER1;
11500 return FFEINFO_kindtypeANY;
11514 tree double_ftype_double;
11515 tree float_ftype_float;
11516 tree ldouble_ftype_ldouble;
11517 tree ffecom_tree_ptr_to_fun_type_void;
11519 /* This block of code comes from the now-obsolete cktyps.c. It checks
11520 whether the compiler environment is buggy in known ways, some of which
11521 would, if not explicitly checked here, result in subtle bugs in g77. */
11523 if (ffe_is_do_internal_checks ())
11525 static char names[][12]
11527 {"bar", "bletch", "foo", "foobar"};
11532 name = bsearch ("foo", &names[0], ARRAY_SIZE (names), sizeof (names[0]),
11533 (int (*)(const void *, const void *)) strcmp);
11534 if (name != (char *) &names[2])
11536 assert ("bsearch doesn't work, #define FFEPROJ_BSEARCH 0 in proj.h"
11541 ul = strtoul ("123456789", NULL, 10);
11542 if (ul != 123456789L)
11544 assert ("strtoul doesn't have enough range, #define FFEPROJ_STRTOUL 0\
11545 in proj.h" == NULL);
11549 fl = atof ("56.789");
11550 if ((fl < 56.788) || (fl > 56.79))
11552 assert ("atof not type double, fix your #include <stdio.h>"
11558 #if FFECOM_GCC_INCLUDE
11559 ffecom_initialize_char_syntax_ ();
11562 ffecom_outer_function_decl_ = NULL_TREE;
11563 current_function_decl = NULL_TREE;
11564 named_labels = NULL_TREE;
11565 current_binding_level = NULL_BINDING_LEVEL;
11566 free_binding_level = NULL_BINDING_LEVEL;
11567 /* Make the binding_level structure for global names. */
11569 global_binding_level = current_binding_level;
11570 current_binding_level->prep_state = 2;
11572 build_common_tree_nodes (1);
11574 /* Define `int' and `char' first so that dbx will output them first. */
11575 pushdecl (build_decl (TYPE_DECL, get_identifier ("int"),
11576 integer_type_node));
11577 pushdecl (build_decl (TYPE_DECL, get_identifier ("char"),
11579 pushdecl (build_decl (TYPE_DECL, get_identifier ("long int"),
11580 long_integer_type_node));
11581 pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned int"),
11582 unsigned_type_node));
11583 pushdecl (build_decl (TYPE_DECL, get_identifier ("long unsigned int"),
11584 long_unsigned_type_node));
11585 pushdecl (build_decl (TYPE_DECL, get_identifier ("long long int"),
11586 long_long_integer_type_node));
11587 pushdecl (build_decl (TYPE_DECL, get_identifier ("long long unsigned int"),
11588 long_long_unsigned_type_node));
11589 pushdecl (build_decl (TYPE_DECL, get_identifier ("short int"),
11590 short_integer_type_node));
11591 pushdecl (build_decl (TYPE_DECL, get_identifier ("short unsigned int"),
11592 short_unsigned_type_node));
11594 /* Set the sizetype before we make other types. This *should* be the
11595 first type we create. */
11598 (TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (get_identifier (SIZE_TYPE))));
11599 ffecom_typesize_pointer_
11600 = TREE_INT_CST_LOW (TYPE_SIZE (sizetype)) / BITS_PER_UNIT;
11602 build_common_tree_nodes_2 (0);
11604 /* Define both `signed char' and `unsigned char'. */
11605 pushdecl (build_decl (TYPE_DECL, get_identifier ("signed char"),
11606 signed_char_type_node));
11608 pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned char"),
11609 unsigned_char_type_node));
11611 pushdecl (build_decl (TYPE_DECL, get_identifier ("float"),
11613 pushdecl (build_decl (TYPE_DECL, get_identifier ("double"),
11614 double_type_node));
11615 pushdecl (build_decl (TYPE_DECL, get_identifier ("long double"),
11616 long_double_type_node));
11618 /* For now, override what build_common_tree_nodes has done. */
11619 complex_integer_type_node = ffecom_make_complex_type_ (integer_type_node);
11620 complex_float_type_node = ffecom_make_complex_type_ (float_type_node);
11621 complex_double_type_node = ffecom_make_complex_type_ (double_type_node);
11622 complex_long_double_type_node
11623 = ffecom_make_complex_type_ (long_double_type_node);
11625 pushdecl (build_decl (TYPE_DECL, get_identifier ("complex int"),
11626 complex_integer_type_node));
11627 pushdecl (build_decl (TYPE_DECL, get_identifier ("complex float"),
11628 complex_float_type_node));
11629 pushdecl (build_decl (TYPE_DECL, get_identifier ("complex double"),
11630 complex_double_type_node));
11631 pushdecl (build_decl (TYPE_DECL, get_identifier ("complex long double"),
11632 complex_long_double_type_node));
11634 pushdecl (build_decl (TYPE_DECL, get_identifier ("void"),
11636 /* We are not going to have real types in C with less than byte alignment,
11637 so we might as well not have any types that claim to have it. */
11638 TYPE_ALIGN (void_type_node) = BITS_PER_UNIT;
11640 string_type_node = build_pointer_type (char_type_node);
11642 ffecom_tree_fun_type_void
11643 = build_function_type (void_type_node, NULL_TREE);
11645 ffecom_tree_ptr_to_fun_type_void
11646 = build_pointer_type (ffecom_tree_fun_type_void);
11648 endlink = tree_cons (NULL_TREE, void_type_node, NULL_TREE);
11651 = build_function_type (float_type_node,
11652 tree_cons (NULL_TREE, float_type_node, endlink));
11654 double_ftype_double
11655 = build_function_type (double_type_node,
11656 tree_cons (NULL_TREE, double_type_node, endlink));
11658 ldouble_ftype_ldouble
11659 = build_function_type (long_double_type_node,
11660 tree_cons (NULL_TREE, long_double_type_node,
11663 for (i = 0; ((size_t) i) < ARRAY_SIZE (ffecom_tree_type); ++i)
11664 for (j = 0; ((size_t) j) < ARRAY_SIZE (ffecom_tree_type[0]); ++j)
11666 ffecom_tree_type[i][j] = NULL_TREE;
11667 ffecom_tree_fun_type[i][j] = NULL_TREE;
11668 ffecom_tree_ptr_to_fun_type[i][j] = NULL_TREE;
11669 ffecom_f2c_typecode_[i][j] = -1;
11672 /* Set up standard g77 types. Note that INTEGER and LOGICAL are set
11673 to size FLOAT_TYPE_SIZE because they have to be the same size as
11674 REAL, which also is FLOAT_TYPE_SIZE, according to the standard.
11675 Compiler options and other such stuff that change the ways these
11676 types are set should not affect this particular setup. */
11678 ffecom_tree_type[FFEINFO_basictypeINTEGER][FFEINFO_kindtypeINTEGER1]
11679 = t = make_signed_type (FLOAT_TYPE_SIZE);
11680 pushdecl (build_decl (TYPE_DECL, get_identifier ("integer"),
11682 type = ffetype_new ();
11684 ffeinfo_set_type (FFEINFO_basictypeINTEGER, FFEINFO_kindtypeINTEGER1,
11686 ffetype_set_ams (type,
11687 TYPE_ALIGN (t) / BITS_PER_UNIT, 0,
11688 TREE_INT_CST_LOW (TYPE_SIZE (t)) / BITS_PER_UNIT);
11689 ffetype_set_star (base_type,
11690 TREE_INT_CST_LOW (TYPE_SIZE (t)) / CHAR_TYPE_SIZE,
11692 ffetype_set_kind (base_type, 1, type);
11693 ffecom_typesize_integer1_ = ffetype_size (type);
11694 assert (ffetype_size (type) == sizeof (ffetargetInteger1));
11696 ffecom_tree_type[FFEINFO_basictypeHOLLERITH][FFEINFO_kindtypeINTEGER1]
11697 = t = make_unsigned_type (FLOAT_TYPE_SIZE); /* HOLLERITH means unsigned. */
11698 pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned"),
11701 ffecom_tree_type[FFEINFO_basictypeINTEGER][FFEINFO_kindtypeINTEGER2]
11702 = t = make_signed_type (CHAR_TYPE_SIZE);
11703 pushdecl (build_decl (TYPE_DECL, get_identifier ("byte"),
11705 type = ffetype_new ();
11706 ffeinfo_set_type (FFEINFO_basictypeINTEGER, FFEINFO_kindtypeINTEGER2,
11708 ffetype_set_ams (type,
11709 TYPE_ALIGN (t) / BITS_PER_UNIT, 0,
11710 TREE_INT_CST_LOW (TYPE_SIZE (t)) / BITS_PER_UNIT);
11711 ffetype_set_star (base_type,
11712 TREE_INT_CST_LOW (TYPE_SIZE (t)) / CHAR_TYPE_SIZE,
11714 ffetype_set_kind (base_type, 3, type);
11715 assert (ffetype_size (type) == sizeof (ffetargetInteger2));
11717 ffecom_tree_type[FFEINFO_basictypeHOLLERITH][FFEINFO_kindtypeINTEGER2]
11718 = t = make_unsigned_type (CHAR_TYPE_SIZE);
11719 pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned byte"),
11722 ffecom_tree_type[FFEINFO_basictypeINTEGER][FFEINFO_kindtypeINTEGER3]
11723 = t = make_signed_type (CHAR_TYPE_SIZE * 2);
11724 pushdecl (build_decl (TYPE_DECL, get_identifier ("word"),
11726 type = ffetype_new ();
11727 ffeinfo_set_type (FFEINFO_basictypeINTEGER, FFEINFO_kindtypeINTEGER3,
11729 ffetype_set_ams (type,
11730 TYPE_ALIGN (t) / BITS_PER_UNIT, 0,
11731 TREE_INT_CST_LOW (TYPE_SIZE (t)) / BITS_PER_UNIT);
11732 ffetype_set_star (base_type,
11733 TREE_INT_CST_LOW (TYPE_SIZE (t)) / CHAR_TYPE_SIZE,
11735 ffetype_set_kind (base_type, 6, type);
11736 assert (ffetype_size (type) == sizeof (ffetargetInteger3));
11738 ffecom_tree_type[FFEINFO_basictypeHOLLERITH][FFEINFO_kindtypeINTEGER3]
11739 = t = make_unsigned_type (CHAR_TYPE_SIZE * 2);
11740 pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned word"),
11743 ffecom_tree_type[FFEINFO_basictypeINTEGER][FFEINFO_kindtypeINTEGER4]
11744 = t = make_signed_type (FLOAT_TYPE_SIZE * 2);
11745 pushdecl (build_decl (TYPE_DECL, get_identifier ("integer4"),
11747 type = ffetype_new ();
11748 ffeinfo_set_type (FFEINFO_basictypeINTEGER, FFEINFO_kindtypeINTEGER4,
11750 ffetype_set_ams (type,
11751 TYPE_ALIGN (t) / BITS_PER_UNIT, 0,
11752 TREE_INT_CST_LOW (TYPE_SIZE (t)) / BITS_PER_UNIT);
11753 ffetype_set_star (base_type,
11754 TREE_INT_CST_LOW (TYPE_SIZE (t)) / CHAR_TYPE_SIZE,
11756 ffetype_set_kind (base_type, 2, type);
11757 assert (ffetype_size (type) == sizeof (ffetargetInteger4));
11759 ffecom_tree_type[FFEINFO_basictypeHOLLERITH][FFEINFO_kindtypeINTEGER4]
11760 = t = make_unsigned_type (FLOAT_TYPE_SIZE * 2);
11761 pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned4"),
11765 if (ffe_is_do_internal_checks ()
11766 && LONG_TYPE_SIZE != FLOAT_TYPE_SIZE
11767 && LONG_TYPE_SIZE != CHAR_TYPE_SIZE
11768 && LONG_TYPE_SIZE != SHORT_TYPE_SIZE
11769 && LONG_TYPE_SIZE != LONG_LONG_TYPE_SIZE)
11771 fprintf (stderr, "Sorry, no g77 support for LONG_TYPE_SIZE (%d bits) yet.\n",
11776 ffecom_tree_type[FFEINFO_basictypeLOGICAL][FFEINFO_kindtypeLOGICAL1]
11777 = t = make_signed_type (FLOAT_TYPE_SIZE);
11778 pushdecl (build_decl (TYPE_DECL, get_identifier ("logical"),
11780 type = ffetype_new ();
11782 ffeinfo_set_type (FFEINFO_basictypeLOGICAL, FFEINFO_kindtypeLOGICAL1,
11784 ffetype_set_ams (type,
11785 TYPE_ALIGN (t) / BITS_PER_UNIT, 0,
11786 TREE_INT_CST_LOW (TYPE_SIZE (t)) / BITS_PER_UNIT);
11787 ffetype_set_star (base_type,
11788 TREE_INT_CST_LOW (TYPE_SIZE (t)) / CHAR_TYPE_SIZE,
11790 ffetype_set_kind (base_type, 1, type);
11791 assert (ffetype_size (type) == sizeof (ffetargetLogical1));
11793 ffecom_tree_type[FFEINFO_basictypeLOGICAL][FFEINFO_kindtypeLOGICAL2]
11794 = t = make_signed_type (CHAR_TYPE_SIZE);
11795 pushdecl (build_decl (TYPE_DECL, get_identifier ("logical2"),
11797 type = ffetype_new ();
11798 ffeinfo_set_type (FFEINFO_basictypeLOGICAL, FFEINFO_kindtypeLOGICAL2,
11800 ffetype_set_ams (type,
11801 TYPE_ALIGN (t) / BITS_PER_UNIT, 0,
11802 TREE_INT_CST_LOW (TYPE_SIZE (t)) / BITS_PER_UNIT);
11803 ffetype_set_star (base_type,
11804 TREE_INT_CST_LOW (TYPE_SIZE (t)) / CHAR_TYPE_SIZE,
11806 ffetype_set_kind (base_type, 3, type);
11807 assert (ffetype_size (type) == sizeof (ffetargetLogical2));
11809 ffecom_tree_type[FFEINFO_basictypeLOGICAL][FFEINFO_kindtypeLOGICAL3]
11810 = t = make_signed_type (CHAR_TYPE_SIZE * 2);
11811 pushdecl (build_decl (TYPE_DECL, get_identifier ("logical3"),
11813 type = ffetype_new ();
11814 ffeinfo_set_type (FFEINFO_basictypeLOGICAL, FFEINFO_kindtypeLOGICAL3,
11816 ffetype_set_ams (type,
11817 TYPE_ALIGN (t) / BITS_PER_UNIT, 0,
11818 TREE_INT_CST_LOW (TYPE_SIZE (t)) / BITS_PER_UNIT);
11819 ffetype_set_star (base_type,
11820 TREE_INT_CST_LOW (TYPE_SIZE (t)) / CHAR_TYPE_SIZE,
11822 ffetype_set_kind (base_type, 6, type);
11823 assert (ffetype_size (type) == sizeof (ffetargetLogical3));
11825 ffecom_tree_type[FFEINFO_basictypeLOGICAL][FFEINFO_kindtypeLOGICAL4]
11826 = t = make_signed_type (FLOAT_TYPE_SIZE * 2);
11827 pushdecl (build_decl (TYPE_DECL, get_identifier ("logical4"),
11829 type = ffetype_new ();
11830 ffeinfo_set_type (FFEINFO_basictypeLOGICAL, FFEINFO_kindtypeLOGICAL4,
11832 ffetype_set_ams (type,
11833 TYPE_ALIGN (t) / BITS_PER_UNIT, 0,
11834 TREE_INT_CST_LOW (TYPE_SIZE (t)) / BITS_PER_UNIT);
11835 ffetype_set_star (base_type,
11836 TREE_INT_CST_LOW (TYPE_SIZE (t)) / CHAR_TYPE_SIZE,
11838 ffetype_set_kind (base_type, 2, type);
11839 assert (ffetype_size (type) == sizeof (ffetargetLogical4));
11841 ffecom_tree_type[FFEINFO_basictypeREAL][FFEINFO_kindtypeREAL1]
11842 = t = make_node (REAL_TYPE);
11843 TYPE_PRECISION (t) = FLOAT_TYPE_SIZE;
11844 pushdecl (build_decl (TYPE_DECL, get_identifier ("real"),
11847 type = ffetype_new ();
11849 ffeinfo_set_type (FFEINFO_basictypeREAL, FFEINFO_kindtypeREAL1,
11851 ffetype_set_ams (type,
11852 TYPE_ALIGN (t) / BITS_PER_UNIT, 0,
11853 TREE_INT_CST_LOW (TYPE_SIZE (t)) / BITS_PER_UNIT);
11854 ffetype_set_star (base_type,
11855 TREE_INT_CST_LOW (TYPE_SIZE (t)) / CHAR_TYPE_SIZE,
11857 ffetype_set_kind (base_type, 1, type);
11858 ffecom_f2c_typecode_[FFEINFO_basictypeREAL][FFEINFO_kindtypeREAL1]
11859 = FFETARGET_f2cTYREAL;
11860 assert (ffetype_size (type) == sizeof (ffetargetReal1));
11862 ffecom_tree_type[FFEINFO_basictypeREAL][FFEINFO_kindtypeREALDOUBLE]
11863 = t = make_node (REAL_TYPE);
11864 TYPE_PRECISION (t) = FLOAT_TYPE_SIZE * 2; /* Always twice REAL. */
11865 pushdecl (build_decl (TYPE_DECL, get_identifier ("double precision"),
11868 type = ffetype_new ();
11869 ffeinfo_set_type (FFEINFO_basictypeREAL, FFEINFO_kindtypeREALDOUBLE,
11871 ffetype_set_ams (type,
11872 TYPE_ALIGN (t) / BITS_PER_UNIT, 0,
11873 TREE_INT_CST_LOW (TYPE_SIZE (t)) / BITS_PER_UNIT);
11874 ffetype_set_star (base_type,
11875 TREE_INT_CST_LOW (TYPE_SIZE (t)) / CHAR_TYPE_SIZE,
11877 ffetype_set_kind (base_type, 2, type);
11878 ffecom_f2c_typecode_[FFEINFO_basictypeREAL][FFEINFO_kindtypeREAL2]
11879 = FFETARGET_f2cTYDREAL;
11880 assert (ffetype_size (type) == sizeof (ffetargetReal2));
11882 ffecom_tree_type[FFEINFO_basictypeCOMPLEX][FFEINFO_kindtypeREAL1]
11883 = t = ffecom_make_complex_type_ (ffecom_tree_type[FFEINFO_basictypeREAL][FFEINFO_kindtypeREAL1]);
11884 pushdecl (build_decl (TYPE_DECL, get_identifier ("complex"),
11886 type = ffetype_new ();
11888 ffeinfo_set_type (FFEINFO_basictypeCOMPLEX, FFEINFO_kindtypeREAL1,
11890 ffetype_set_ams (type,
11891 TYPE_ALIGN (t) / BITS_PER_UNIT, 0,
11892 TREE_INT_CST_LOW (TYPE_SIZE (t)) / BITS_PER_UNIT);
11893 ffetype_set_star (base_type,
11894 TREE_INT_CST_LOW (TYPE_SIZE (t)) / CHAR_TYPE_SIZE,
11896 ffetype_set_kind (base_type, 1, type);
11897 ffecom_f2c_typecode_[FFEINFO_basictypeCOMPLEX][FFEINFO_kindtypeREAL1]
11898 = FFETARGET_f2cTYCOMPLEX;
11899 assert (ffetype_size (type) == sizeof (ffetargetComplex1));
11901 ffecom_tree_type[FFEINFO_basictypeCOMPLEX][FFEINFO_kindtypeREALDOUBLE]
11902 = t = ffecom_make_complex_type_ (ffecom_tree_type[FFEINFO_basictypeREAL][FFEINFO_kindtypeREAL2]);
11903 pushdecl (build_decl (TYPE_DECL, get_identifier ("double complex"),
11905 type = ffetype_new ();
11906 ffeinfo_set_type (FFEINFO_basictypeCOMPLEX, FFEINFO_kindtypeREALDOUBLE,
11908 ffetype_set_ams (type,
11909 TYPE_ALIGN (t) / BITS_PER_UNIT, 0,
11910 TREE_INT_CST_LOW (TYPE_SIZE (t)) / BITS_PER_UNIT);
11911 ffetype_set_star (base_type,
11912 TREE_INT_CST_LOW (TYPE_SIZE (t)) / CHAR_TYPE_SIZE,
11914 ffetype_set_kind (base_type, 2,
11916 ffecom_f2c_typecode_[FFEINFO_basictypeCOMPLEX][FFEINFO_kindtypeREAL2]
11917 = FFETARGET_f2cTYDCOMPLEX;
11918 assert (ffetype_size (type) == sizeof (ffetargetComplex2));
11920 /* Make function and ptr-to-function types for non-CHARACTER types. */
11922 for (i = 0; ((size_t) i) < ARRAY_SIZE (ffecom_tree_type); ++i)
11923 for (j = 0; ((size_t) j) < ARRAY_SIZE (ffecom_tree_type[0]); ++j)
11925 if ((t = ffecom_tree_type[i][j]) != NULL_TREE)
11927 if (i == FFEINFO_basictypeINTEGER)
11929 /* Figure out the smallest INTEGER type that can hold
11930 a pointer on this machine. */
11931 if (GET_MODE_SIZE (TYPE_MODE (t))
11932 >= GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (null_pointer_node))))
11934 if ((ffecom_pointer_kind_ == FFEINFO_kindtypeNONE)
11935 || (GET_MODE_SIZE (TYPE_MODE (ffecom_tree_type[i][ffecom_pointer_kind_]))
11936 > GET_MODE_SIZE (TYPE_MODE (t))))
11937 ffecom_pointer_kind_ = j;
11940 else if (i == FFEINFO_basictypeCOMPLEX)
11941 t = void_type_node;
11942 /* For f2c compatibility, REAL functions are really
11943 implemented as DOUBLE PRECISION. */
11944 else if ((i == FFEINFO_basictypeREAL)
11945 && (j == FFEINFO_kindtypeREAL1))
11946 t = ffecom_tree_type
11947 [FFEINFO_basictypeREAL][FFEINFO_kindtypeREAL2];
11949 t = ffecom_tree_fun_type[i][j] = build_function_type (t,
11951 ffecom_tree_ptr_to_fun_type[i][j] = build_pointer_type (t);
11955 /* Set up pointer types. */
11957 if (ffecom_pointer_kind_ == FFEINFO_basictypeNONE)
11958 fatal ("no INTEGER type can hold a pointer on this configuration");
11959 else if (0 && ffe_is_do_internal_checks ())
11960 fprintf (stderr, "Pointer type kt=%d\n", ffecom_pointer_kind_);
11961 ffetype_set_kind (ffeinfo_type (FFEINFO_basictypeINTEGER,
11962 FFEINFO_kindtypeINTEGERDEFAULT),
11964 ffeinfo_type (FFEINFO_basictypeINTEGER,
11965 ffecom_pointer_kind_));
11967 if (ffe_is_ugly_assign ())
11968 ffecom_label_kind_ = ffecom_pointer_kind_; /* Require ASSIGN etc to this. */
11970 ffecom_label_kind_ = FFEINFO_kindtypeINTEGERDEFAULT;
11971 if (0 && ffe_is_do_internal_checks ())
11972 fprintf (stderr, "Label type kt=%d\n", ffecom_label_kind_);
11974 ffecom_integer_type_node
11975 = ffecom_tree_type[FFEINFO_basictypeINTEGER][FFEINFO_kindtypeINTEGER1];
11976 ffecom_integer_zero_node = convert (ffecom_integer_type_node,
11977 integer_zero_node);
11978 ffecom_integer_one_node = convert (ffecom_integer_type_node,
11981 /* Yes, the "FLOAT_TYPE_SIZE" references below are intentional.
11982 Turns out that by TYLONG, runtime/libI77/lio.h really means
11983 "whatever size an ftnint is". For consistency and sanity,
11984 com.h and runtime/f2c.h.in agree that flag, ftnint, and ftlen
11985 all are INTEGER, which we also make out of whatever back-end
11986 integer type is FLOAT_TYPE_SIZE bits wide. This change, from
11987 LONG_TYPE_SIZE, for TYLONG and TYLOGICAL, was necessary to
11988 accommodate machines like the Alpha. Note that this suggests
11989 f2c and libf2c are missing a distinction perhaps needed on
11990 some machines between "int" and "long int". -- burley 0.5.5 950215 */
11992 ffecom_f2c_set_lio_code_ (FFEINFO_basictypeINTEGER, FLOAT_TYPE_SIZE,
11993 FFETARGET_f2cTYLONG);
11994 ffecom_f2c_set_lio_code_ (FFEINFO_basictypeINTEGER, SHORT_TYPE_SIZE,
11995 FFETARGET_f2cTYSHORT);
11996 ffecom_f2c_set_lio_code_ (FFEINFO_basictypeINTEGER, CHAR_TYPE_SIZE,
11997 FFETARGET_f2cTYINT1);
11998 ffecom_f2c_set_lio_code_ (FFEINFO_basictypeINTEGER, LONG_LONG_TYPE_SIZE,
11999 FFETARGET_f2cTYQUAD);
12000 ffecom_f2c_set_lio_code_ (FFEINFO_basictypeLOGICAL, FLOAT_TYPE_SIZE,
12001 FFETARGET_f2cTYLOGICAL);
12002 ffecom_f2c_set_lio_code_ (FFEINFO_basictypeLOGICAL, SHORT_TYPE_SIZE,
12003 FFETARGET_f2cTYLOGICAL2);
12004 ffecom_f2c_set_lio_code_ (FFEINFO_basictypeLOGICAL, CHAR_TYPE_SIZE,
12005 FFETARGET_f2cTYLOGICAL1);
12006 /* ~~~Not really such a type in libf2c, e.g. I/O support? */
12007 ffecom_f2c_set_lio_code_ (FFEINFO_basictypeLOGICAL, LONG_LONG_TYPE_SIZE,
12008 FFETARGET_f2cTYQUAD);
12010 /* CHARACTER stuff is all special-cased, so it is not handled in the above
12011 loop. CHARACTER items are built as arrays of unsigned char. */
12013 ffecom_tree_type[FFEINFO_basictypeCHARACTER]
12014 [FFEINFO_kindtypeCHARACTER1] = t = char_type_node;
12015 type = ffetype_new ();
12017 ffeinfo_set_type (FFEINFO_basictypeCHARACTER,
12018 FFEINFO_kindtypeCHARACTER1,
12020 ffetype_set_ams (type,
12021 TYPE_ALIGN (t) / BITS_PER_UNIT, 0,
12022 TREE_INT_CST_LOW (TYPE_SIZE (t)) / BITS_PER_UNIT);
12023 ffetype_set_kind (base_type, 1, type);
12024 assert (ffetype_size (type)
12025 == sizeof (((ffetargetCharacter1) { 0, NULL }).text[0]));
12027 ffecom_tree_fun_type[FFEINFO_basictypeCHARACTER]
12028 [FFEINFO_kindtypeCHARACTER1] = ffecom_tree_fun_type_void;
12029 ffecom_tree_ptr_to_fun_type[FFEINFO_basictypeCHARACTER]
12030 [FFEINFO_kindtypeCHARACTER1]
12031 = ffecom_tree_ptr_to_fun_type_void;
12032 ffecom_f2c_typecode_[FFEINFO_basictypeCHARACTER][FFEINFO_kindtypeCHARACTER1]
12033 = FFETARGET_f2cTYCHAR;
12035 ffecom_f2c_typecode_[FFEINFO_basictypeANY][FFEINFO_kindtypeANY]
12038 /* Make multi-return-value type and fields. */
12040 ffecom_multi_type_node_ = make_node (UNION_TYPE);
12044 for (i = 0; ((size_t) i) < ARRAY_SIZE (ffecom_tree_type); ++i)
12045 for (j = 0; ((size_t) j) < ARRAY_SIZE (ffecom_tree_type[0]); ++j)
12049 if (ffecom_tree_type[i][j] == NULL_TREE)
12050 continue; /* Not supported. */
12051 sprintf (&name[0], "bt_%s_kt_%s",
12052 ffeinfo_basictype_string ((ffeinfoBasictype) i),
12053 ffeinfo_kindtype_string ((ffeinfoKindtype) j));
12054 ffecom_multi_fields_[i][j] = build_decl (FIELD_DECL,
12055 get_identifier (name),
12056 ffecom_tree_type[i][j]);
12057 DECL_CONTEXT (ffecom_multi_fields_[i][j])
12058 = ffecom_multi_type_node_;
12059 DECL_FRAME_SIZE (ffecom_multi_fields_[i][j]) = 0;
12060 TREE_CHAIN (ffecom_multi_fields_[i][j]) = field;
12061 field = ffecom_multi_fields_[i][j];
12064 TYPE_FIELDS (ffecom_multi_type_node_) = field;
12065 layout_type (ffecom_multi_type_node_);
12067 /* Subroutines usually return integer because they might have alternate
12070 ffecom_tree_subr_type
12071 = build_function_type (integer_type_node, NULL_TREE);
12072 ffecom_tree_ptr_to_subr_type
12073 = build_pointer_type (ffecom_tree_subr_type);
12074 ffecom_tree_blockdata_type
12075 = build_function_type (void_type_node, NULL_TREE);
12077 builtin_function ("__builtin_sqrtf", float_ftype_float,
12078 BUILT_IN_FSQRT, BUILT_IN_NORMAL, "sqrtf");
12079 builtin_function ("__builtin_fsqrt", double_ftype_double,
12080 BUILT_IN_FSQRT, BUILT_IN_NORMAL, "sqrt");
12081 builtin_function ("__builtin_sqrtl", ldouble_ftype_ldouble,
12082 BUILT_IN_FSQRT, BUILT_IN_NORMAL, "sqrtl");
12083 builtin_function ("__builtin_sinf", float_ftype_float,
12084 BUILT_IN_SIN, BUILT_IN_NORMAL, "sinf");
12085 builtin_function ("__builtin_sin", double_ftype_double,
12086 BUILT_IN_SIN, BUILT_IN_NORMAL, "sin");
12087 builtin_function ("__builtin_sinl", ldouble_ftype_ldouble,
12088 BUILT_IN_SIN, BUILT_IN_NORMAL, "sinl");
12089 builtin_function ("__builtin_cosf", float_ftype_float,
12090 BUILT_IN_COS, BUILT_IN_NORMAL, "cosf");
12091 builtin_function ("__builtin_cos", double_ftype_double,
12092 BUILT_IN_COS, BUILT_IN_NORMAL, "cos");
12093 builtin_function ("__builtin_cosl", ldouble_ftype_ldouble,
12094 BUILT_IN_COS, BUILT_IN_NORMAL, "cosl");
12097 pedantic_lvalues = FALSE;
12100 ffecom_f2c_make_type_ (&ffecom_f2c_integer_type_node,
12103 ffecom_f2c_make_type_ (&ffecom_f2c_address_type_node,
12106 ffecom_f2c_make_type_ (&ffecom_f2c_real_type_node,
12109 ffecom_f2c_make_type_ (&ffecom_f2c_doublereal_type_node,
12110 FFECOM_f2cDOUBLEREAL,
12112 ffecom_f2c_make_type_ (&ffecom_f2c_complex_type_node,
12115 ffecom_f2c_make_type_ (&ffecom_f2c_doublecomplex_type_node,
12116 FFECOM_f2cDOUBLECOMPLEX,
12118 ffecom_f2c_make_type_ (&ffecom_f2c_longint_type_node,
12121 ffecom_f2c_make_type_ (&ffecom_f2c_logical_type_node,
12124 ffecom_f2c_make_type_ (&ffecom_f2c_flag_type_node,
12127 ffecom_f2c_make_type_ (&ffecom_f2c_ftnlen_type_node,
12130 ffecom_f2c_make_type_ (&ffecom_f2c_ftnint_type_node,
12134 ffecom_f2c_ftnlen_zero_node
12135 = convert (ffecom_f2c_ftnlen_type_node, integer_zero_node);
12137 ffecom_f2c_ftnlen_one_node
12138 = convert (ffecom_f2c_ftnlen_type_node, integer_one_node);
12140 ffecom_f2c_ftnlen_two_node = build_int_2 (2, 0);
12141 TREE_TYPE (ffecom_f2c_ftnlen_two_node) = ffecom_integer_type_node;
12143 ffecom_f2c_ptr_to_ftnlen_type_node
12144 = build_pointer_type (ffecom_f2c_ftnlen_type_node);
12146 ffecom_f2c_ptr_to_ftnint_type_node
12147 = build_pointer_type (ffecom_f2c_ftnint_type_node);
12149 ffecom_f2c_ptr_to_integer_type_node
12150 = build_pointer_type (ffecom_f2c_integer_type_node);
12152 ffecom_f2c_ptr_to_real_type_node
12153 = build_pointer_type (ffecom_f2c_real_type_node);
12155 ffecom_float_zero_ = build_real (float_type_node, dconst0);
12156 ffecom_double_zero_ = build_real (double_type_node, dconst0);
12158 REAL_VALUE_TYPE point_5;
12160 #ifdef REAL_ARITHMETIC
12161 REAL_ARITHMETIC (point_5, RDIV_EXPR, dconst1, dconst2);
12165 ffecom_float_half_ = build_real (float_type_node, point_5);
12166 ffecom_double_half_ = build_real (double_type_node, point_5);
12169 /* Do "extern int xargc;". */
12171 ffecom_tree_xargc_ = build_decl (VAR_DECL,
12172 get_identifier ("f__xargc"),
12173 integer_type_node);
12174 DECL_EXTERNAL (ffecom_tree_xargc_) = 1;
12175 TREE_STATIC (ffecom_tree_xargc_) = 1;
12176 TREE_PUBLIC (ffecom_tree_xargc_) = 1;
12177 ffecom_tree_xargc_ = start_decl (ffecom_tree_xargc_, FALSE);
12178 finish_decl (ffecom_tree_xargc_, NULL_TREE, FALSE);
12180 #if 0 /* This is being fixed, and seems to be working now. */
12181 if ((FLOAT_TYPE_SIZE != 32)
12182 || (TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (null_pointer_node))) != 32))
12184 warning ("configuration: REAL, INTEGER, and LOGICAL are %d bits wide,",
12185 (int) FLOAT_TYPE_SIZE);
12186 warning ("and pointers are %d bits wide, but g77 doesn't yet work",
12187 (int) TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (null_pointer_node))));
12188 warning ("properly unless they all are 32 bits wide.");
12189 warning ("Please keep this in mind before you report bugs. g77 should");
12190 warning ("support non-32-bit machines better as of version 0.6.");
12194 #if 0 /* Code in ste.c that would crash has been commented out. */
12195 if (TYPE_PRECISION (ffecom_f2c_ftnlen_type_node)
12196 < TYPE_PRECISION (string_type_node))
12197 /* I/O will probably crash. */
12198 warning ("configuration: char * holds %d bits, but ftnlen only %d",
12199 TYPE_PRECISION (string_type_node),
12200 TYPE_PRECISION (ffecom_f2c_ftnlen_type_node));
12203 #if 0 /* ASSIGN-related stuff has been changed to accommodate this. */
12204 if (TYPE_PRECISION (ffecom_integer_type_node)
12205 < TYPE_PRECISION (string_type_node))
12206 /* ASSIGN 10 TO I will crash. */
12207 warning ("configuration: char * holds %d bits, but INTEGER only %d --\n\
12208 ASSIGN statement might fail",
12209 TYPE_PRECISION (string_type_node),
12210 TYPE_PRECISION (ffecom_integer_type_node));
12215 /* ffecom_init_2 -- Initialize
12217 ffecom_init_2(); */
12219 #if FFECOM_targetCURRENT == FFECOM_targetGCC
12223 assert (ffecom_outer_function_decl_ == NULL_TREE);
12224 assert (current_function_decl == NULL_TREE);
12225 assert (ffecom_which_entrypoint_decl_ == NULL_TREE);
12227 ffecom_master_arglist_ = NULL;
12229 ffecom_primary_entry_ = NULL;
12230 ffecom_is_altreturning_ = FALSE;
12231 ffecom_func_result_ = NULL_TREE;
12232 ffecom_multi_retval_ = NULL_TREE;
12236 /* ffecom_list_expr -- Transform list of exprs into gcc tree
12239 ffebld expr; // FFE opITEM list.
12240 tree = ffecom_list_expr(expr);
12242 List of actual args is transformed into corresponding gcc backend list. */
12244 #if FFECOM_targetCURRENT == FFECOM_targetGCC
12246 ffecom_list_expr (ffebld expr)
12249 tree *plist = &list;
12250 tree trail = NULL_TREE; /* Append char length args here. */
12251 tree *ptrail = &trail;
12254 while (expr != NULL)
12256 tree texpr = ffecom_arg_expr (ffebld_head (expr), &length);
12258 if (texpr == error_mark_node)
12259 return error_mark_node;
12261 *plist = build_tree_list (NULL_TREE, texpr);
12262 plist = &TREE_CHAIN (*plist);
12263 expr = ffebld_trail (expr);
12264 if (length != NULL_TREE)
12266 *ptrail = build_tree_list (NULL_TREE, length);
12267 ptrail = &TREE_CHAIN (*ptrail);
12277 /* ffecom_list_ptr_to_expr -- Transform list of exprs into gcc tree
12280 ffebld expr; // FFE opITEM list.
12281 tree = ffecom_list_ptr_to_expr(expr);
12283 List of actual args is transformed into corresponding gcc backend list for
12284 use in calling an external procedure (vs. a statement function). */
12286 #if FFECOM_targetCURRENT == FFECOM_targetGCC
12288 ffecom_list_ptr_to_expr (ffebld expr)
12291 tree *plist = &list;
12292 tree trail = NULL_TREE; /* Append char length args here. */
12293 tree *ptrail = &trail;
12296 while (expr != NULL)
12298 tree texpr = ffecom_arg_ptr_to_expr (ffebld_head (expr), &length);
12300 if (texpr == error_mark_node)
12301 return error_mark_node;
12303 *plist = build_tree_list (NULL_TREE, texpr);
12304 plist = &TREE_CHAIN (*plist);
12305 expr = ffebld_trail (expr);
12306 if (length != NULL_TREE)
12308 *ptrail = build_tree_list (NULL_TREE, length);
12309 ptrail = &TREE_CHAIN (*ptrail);
12319 /* Obtain gcc's LABEL_DECL tree for label. */
12321 #if FFECOM_targetCURRENT == FFECOM_targetGCC
12323 ffecom_lookup_label (ffelab label)
12327 if (ffelab_hook (label) == NULL_TREE)
12329 char labelname[16];
12331 switch (ffelab_type (label))
12333 case FFELAB_typeLOOPEND:
12334 case FFELAB_typeNOTLOOP:
12335 case FFELAB_typeENDIF:
12336 sprintf (labelname, "%" ffelabValue_f "u", ffelab_value (label));
12337 glabel = build_decl (LABEL_DECL, get_identifier (labelname),
12339 DECL_CONTEXT (glabel) = current_function_decl;
12340 DECL_MODE (glabel) = VOIDmode;
12343 case FFELAB_typeFORMAT:
12344 glabel = build_decl (VAR_DECL,
12345 ffecom_get_invented_identifier
12346 ("__g77_format_%d", (int) ffelab_value (label)),
12347 build_type_variant (build_array_type
12351 TREE_CONSTANT (glabel) = 1;
12352 TREE_STATIC (glabel) = 1;
12353 DECL_CONTEXT (glabel) = 0;
12354 DECL_INITIAL (glabel) = NULL;
12355 make_decl_rtl (glabel, NULL, 0);
12356 expand_decl (glabel);
12358 ffecom_save_tree_forever (glabel);
12362 case FFELAB_typeANY:
12363 glabel = error_mark_node;
12367 assert ("bad label type" == NULL);
12371 ffelab_set_hook (label, glabel);
12375 glabel = ffelab_hook (label);
12382 /* Stabilizes the arguments. Don't use this if the lhs and rhs come from
12383 a single source specification (as in the fourth argument of MVBITS).
12384 If the type is NULL_TREE, the type of lhs is used to make the type of
12385 the MODIFY_EXPR. */
12387 #if FFECOM_targetCURRENT == FFECOM_targetGCC
12389 ffecom_modify (tree newtype, tree lhs,
12392 if (lhs == error_mark_node || rhs == error_mark_node)
12393 return error_mark_node;
12395 if (newtype == NULL_TREE)
12396 newtype = TREE_TYPE (lhs);
12398 if (TREE_SIDE_EFFECTS (lhs))
12399 lhs = stabilize_reference (lhs);
12401 return ffecom_2s (MODIFY_EXPR, newtype, lhs, rhs);
12406 /* Register source file name. */
12409 ffecom_file (const char *name)
12411 #if FFECOM_GCC_INCLUDE
12412 ffecom_file_ (name);
12416 /* ffecom_notify_init_storage -- An aggregate storage is now fully init'ed
12419 ffecom_notify_init_storage(st);
12421 Gets called when all possible units in an aggregate storage area (a LOCAL
12422 with equivalences or a COMMON) have been initialized. The initialization
12423 info either is in ffestorag_init or, if that is NULL,
12424 ffestorag_accretion:
12426 ffestorag_init may contain an opCONTER or opARRTER. opCONTER may occur
12427 even for an array if the array is one element in length!
12429 ffestorag_accretion will contain an opACCTER. It is much like an
12430 opARRTER except it has an ffebit object in it instead of just a size.
12431 The back end can use the info in the ffebit object, if it wants, to
12432 reduce the amount of actual initialization, but in any case it should
12433 kill the ffebit object when done. Also, set accretion to NULL but
12434 init to a non-NULL value.
12436 After performing initialization, DO NOT set init to NULL, because that'll
12437 tell the front end it is ok for more initialization to happen. Instead,
12438 set init to an opANY expression or some such thing that you can use to
12439 tell that you've already initialized the object.
12442 Support two-pass FFE. */
12445 ffecom_notify_init_storage (ffestorag st)
12447 ffebld init; /* The initialization expression. */
12448 #if 0 && FFECOM_targetCURRENT == FFECOM_targetGCC
12449 ffetargetOffset size; /* The size of the entity. */
12450 ffetargetAlign pad; /* Its initial padding. */
12453 if (ffestorag_init (st) == NULL)
12455 init = ffestorag_accretion (st);
12456 assert (init != NULL);
12457 ffestorag_set_accretion (st, NULL);
12458 ffestorag_set_accretes (st, 0);
12460 #if 0 && FFECOM_targetCURRENT == FFECOM_targetGCC
12461 /* For GNU backend, just turn ACCTER into ARRTER and proceed. */
12462 size = ffebld_accter_size (init);
12463 pad = ffebld_accter_pad (init);
12464 ffebit_kill (ffebld_accter_bits (init));
12465 ffebld_set_op (init, FFEBLD_opARRTER);
12466 ffebld_set_arrter (init, ffebld_accter (init));
12467 ffebld_arrter_set_size (init, size);
12468 ffebld_arrter_set_pad (init, size);
12472 ffestorag_set_init (st, init);
12477 init = ffestorag_init (st);
12480 #if FFECOM_ONEPASS /* Process the inits, wipe 'em out. */
12481 ffestorag_set_init (st, ffebld_new_any ());
12483 if (ffebld_op (init) == FFEBLD_opANY)
12484 return; /* Oh, we already did this! */
12486 #if FFECOM_targetCURRENT == FFECOM_targetFFE
12490 if (ffestorag_symbol (st) != NULL)
12491 s = ffestorag_symbol (st);
12493 s = ffestorag_typesymbol (st);
12495 fprintf (dmpout, "= initialize_storage \"%s\" ",
12496 (s != NULL) ? ffesymbol_text (s) : "(unnamed)");
12497 ffebld_dump (init);
12498 fputc ('\n', dmpout);
12502 #endif /* if FFECOM_ONEPASS */
12505 /* ffecom_notify_init_symbol -- A symbol is now fully init'ed
12508 ffecom_notify_init_symbol(s);
12510 Gets called when all possible units in a symbol (not placed in COMMON
12511 or involved in EQUIVALENCE, unless it as yet has no ffestorag object)
12512 have been initialized. The initialization info either is in
12513 ffesymbol_init or, if that is NULL, ffesymbol_accretion:
12515 ffesymbol_init may contain an opCONTER or opARRTER. opCONTER may occur
12516 even for an array if the array is one element in length!
12518 ffesymbol_accretion will contain an opACCTER. It is much like an
12519 opARRTER except it has an ffebit object in it instead of just a size.
12520 The back end can use the info in the ffebit object, if it wants, to
12521 reduce the amount of actual initialization, but in any case it should
12522 kill the ffebit object when done. Also, set accretion to NULL but
12523 init to a non-NULL value.
12525 After performing initialization, DO NOT set init to NULL, because that'll
12526 tell the front end it is ok for more initialization to happen. Instead,
12527 set init to an opANY expression or some such thing that you can use to
12528 tell that you've already initialized the object.
12531 Support two-pass FFE. */
12534 ffecom_notify_init_symbol (ffesymbol s)
12536 ffebld init; /* The initialization expression. */
12537 #if 0 && FFECOM_targetCURRENT == FFECOM_targetGCC
12538 ffetargetOffset size; /* The size of the entity. */
12539 ffetargetAlign pad; /* Its initial padding. */
12542 if (ffesymbol_storage (s) == NULL)
12543 return; /* Do nothing until COMMON/EQUIVALENCE
12544 possibilities checked. */
12546 if ((ffesymbol_init (s) == NULL)
12547 && ((init = ffesymbol_accretion (s)) != NULL))
12549 ffesymbol_set_accretion (s, NULL);
12550 ffesymbol_set_accretes (s, 0);
12552 #if 0 && FFECOM_targetCURRENT == FFECOM_targetGCC
12553 /* For GNU backend, just turn ACCTER into ARRTER and proceed. */
12554 size = ffebld_accter_size (init);
12555 pad = ffebld_accter_pad (init);
12556 ffebit_kill (ffebld_accter_bits (init));
12557 ffebld_set_op (init, FFEBLD_opARRTER);
12558 ffebld_set_arrter (init, ffebld_accter (init));
12559 ffebld_arrter_set_size (init, size);
12560 ffebld_arrter_set_pad (init, size);
12564 ffesymbol_set_init (s, init);
12569 init = ffesymbol_init (s);
12573 ffesymbol_set_init (s, ffebld_new_any ());
12575 if (ffebld_op (init) == FFEBLD_opANY)
12576 return; /* Oh, we already did this! */
12578 #if FFECOM_targetCURRENT == FFECOM_targetFFE
12579 fprintf (dmpout, "= initialize_symbol \"%s\" ", ffesymbol_text (s));
12580 ffebld_dump (init);
12581 fputc ('\n', dmpout);
12584 #endif /* if FFECOM_ONEPASS */
12587 /* ffecom_notify_primary_entry -- Learn which is the primary entry point
12590 ffecom_notify_primary_entry(s);
12592 Gets called when implicit or explicit PROGRAM statement seen or when
12593 FUNCTION, SUBROUTINE, or BLOCK DATA statement seen, with the primary
12594 global symbol that serves as the entry point. */
12597 ffecom_notify_primary_entry (ffesymbol s)
12599 ffecom_primary_entry_ = s;
12600 ffecom_primary_entry_kind_ = ffesymbol_kind (s);
12602 if ((ffecom_primary_entry_kind_ == FFEINFO_kindFUNCTION)
12603 || (ffecom_primary_entry_kind_ == FFEINFO_kindSUBROUTINE))
12604 ffecom_primary_entry_is_proc_ = TRUE;
12606 ffecom_primary_entry_is_proc_ = FALSE;
12608 if (!ffe_is_silent ())
12610 if (ffecom_primary_entry_kind_ == FFEINFO_kindPROGRAM)
12611 fprintf (stderr, "%s:\n", ffesymbol_text (s));
12613 fprintf (stderr, " %s:\n", ffesymbol_text (s));
12616 #if FFECOM_targetCURRENT == FFECOM_targetGCC
12617 if (ffecom_primary_entry_kind_ == FFEINFO_kindSUBROUTINE)
12622 for (list = ffesymbol_dummyargs (s);
12624 list = ffebld_trail (list))
12626 arg = ffebld_head (list);
12627 if (ffebld_op (arg) == FFEBLD_opSTAR)
12629 ffecom_is_altreturning_ = TRUE;
12638 ffecom_open_include (char *name, ffewhereLine l, ffewhereColumn c)
12640 #if FFECOM_GCC_INCLUDE
12641 return ffecom_open_include_ (name, l, c);
12643 return fopen (name, "r");
12647 /* ffecom_ptr_to_expr -- Transform expr into gcc tree with & in front
12650 ffebld expr; // FFE expression.
12651 tree = ffecom_ptr_to_expr(expr);
12653 Like ffecom_expr, but sticks address-of in front of most things. */
12655 #if FFECOM_targetCURRENT == FFECOM_targetGCC
12657 ffecom_ptr_to_expr (ffebld expr)
12660 ffeinfoBasictype bt;
12661 ffeinfoKindtype kt;
12664 assert (expr != NULL);
12666 switch (ffebld_op (expr))
12668 case FFEBLD_opSYMTER:
12669 s = ffebld_symter (expr);
12670 if (ffesymbol_where (s) == FFEINFO_whereINTRINSIC)
12674 ix = ffeintrin_gfrt_indirect (ffebld_symter_implementation (expr));
12675 assert (ix != FFECOM_gfrt);
12676 if ((item = ffecom_gfrt_[ix]) == NULL_TREE)
12678 ffecom_make_gfrt_ (ix);
12679 item = ffecom_gfrt_[ix];
12684 item = ffesymbol_hook (s).decl_tree;
12685 if (item == NULL_TREE)
12687 s = ffecom_sym_transform_ (s);
12688 item = ffesymbol_hook (s).decl_tree;
12691 assert (item != NULL);
12692 if (item == error_mark_node)
12694 if (!ffesymbol_hook (s).addr)
12695 item = ffecom_1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (item)),
12699 case FFEBLD_opARRAYREF:
12700 return ffecom_arrayref_ (NULL_TREE, expr, 1);
12702 case FFEBLD_opCONTER:
12704 bt = ffeinfo_basictype (ffebld_info (expr));
12705 kt = ffeinfo_kindtype (ffebld_info (expr));
12707 item = ffecom_constantunion (&ffebld_constant_union
12708 (ffebld_conter (expr)), bt, kt,
12709 ffecom_tree_type[bt][kt]);
12710 if (item == error_mark_node)
12711 return error_mark_node;
12712 item = ffecom_1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (item)),
12717 return error_mark_node;
12720 bt = ffeinfo_basictype (ffebld_info (expr));
12721 kt = ffeinfo_kindtype (ffebld_info (expr));
12723 item = ffecom_expr (expr);
12724 if (item == error_mark_node)
12725 return error_mark_node;
12727 /* The back end currently optimizes a bit too zealously for us, in that
12728 we fail JCB001 if the following block of code is omitted. It checks
12729 to see if the transformed expression is a symbol or array reference,
12730 and encloses it in a SAVE_EXPR if that is the case. */
12733 if ((TREE_CODE (item) == VAR_DECL)
12734 || (TREE_CODE (item) == PARM_DECL)
12735 || (TREE_CODE (item) == RESULT_DECL)
12736 || (TREE_CODE (item) == INDIRECT_REF)
12737 || (TREE_CODE (item) == ARRAY_REF)
12738 || (TREE_CODE (item) == COMPONENT_REF)
12740 || (TREE_CODE (item) == OFFSET_REF)
12742 || (TREE_CODE (item) == BUFFER_REF)
12743 || (TREE_CODE (item) == REALPART_EXPR)
12744 || (TREE_CODE (item) == IMAGPART_EXPR))
12746 item = ffecom_save_tree (item);
12749 item = ffecom_1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (item)),
12754 assert ("fall-through error" == NULL);
12755 return error_mark_node;
12759 /* Obtain a temp var with given data type.
12761 size is FFETARGET_charactersizeNONE for a non-CHARACTER type
12762 or >= 0 for a CHARACTER type.
12764 elements is -1 for a scalar or > 0 for an array of type. */
12766 #if FFECOM_targetCURRENT == FFECOM_targetGCC
12768 ffecom_make_tempvar (const char *commentary, tree type,
12769 ffetargetCharacterSize size, int elements)
12773 static int mynumber;
12775 assert (current_binding_level->prep_state < 2);
12777 if (type == error_mark_node)
12778 return error_mark_node;
12780 yes = suspend_momentary ();
12782 if (size != FFETARGET_charactersizeNONE)
12783 type = build_array_type (type,
12784 build_range_type (ffecom_f2c_ftnlen_type_node,
12785 ffecom_f2c_ftnlen_one_node,
12786 build_int_2 (size, 0)));
12787 if (elements != -1)
12788 type = build_array_type (type,
12789 build_range_type (integer_type_node,
12791 build_int_2 (elements - 1,
12793 t = build_decl (VAR_DECL,
12794 ffecom_get_invented_identifier ("__g77_%s_%d",
12799 t = start_decl (t, FALSE);
12800 finish_decl (t, NULL_TREE, FALSE);
12802 resume_momentary (yes);
12808 /* Prepare argument pointer to expression.
12810 Like ffecom_prepare_expr, except for expressions to be evaluated
12811 via ffecom_arg_ptr_to_expr. */
12814 ffecom_prepare_arg_ptr_to_expr (ffebld expr)
12816 /* ~~For now, it seems to be the same thing. */
12817 ffecom_prepare_expr (expr);
12821 /* End of preparations. */
12824 ffecom_prepare_end (void)
12826 int prep_state = current_binding_level->prep_state;
12828 assert (prep_state < 2);
12829 current_binding_level->prep_state = 2;
12831 return (prep_state == 1) ? TRUE : FALSE;
12834 /* Prepare expression.
12836 This is called before any code is generated for the current block.
12837 It scans the expression, declares any temporaries that might be needed
12838 during evaluation of the expression, and stores those temporaries in
12839 the appropriate "hook" fields of the expression. `dest', if not NULL,
12840 specifies the destination that ffecom_expr_ will see, in case that
12841 helps avoid generating unused temporaries.
12843 ~~Improve to avoid allocating unused temporaries by taking `dest'
12844 into account vis-a-vis aliasing requirements of complex/character
12848 ffecom_prepare_expr_ (ffebld expr, ffebld dest UNUSED)
12850 ffeinfoBasictype bt;
12851 ffeinfoKindtype kt;
12852 ffetargetCharacterSize sz;
12853 tree tempvar = NULL_TREE;
12855 assert (current_binding_level->prep_state < 2);
12860 bt = ffeinfo_basictype (ffebld_info (expr));
12861 kt = ffeinfo_kindtype (ffebld_info (expr));
12862 sz = ffeinfo_size (ffebld_info (expr));
12864 /* Generate whatever temporaries are needed to represent the result
12865 of the expression. */
12867 if (bt == FFEINFO_basictypeCHARACTER)
12869 while (ffebld_op (expr) == FFEBLD_opPAREN)
12870 expr = ffebld_left (expr);
12873 switch (ffebld_op (expr))
12876 /* Don't make temps for SYMTER, CONTER, etc. */
12877 if (ffebld_arity (expr) == 0)
12882 case FFEINFO_basictypeCOMPLEX:
12883 if (ffebld_op (expr) == FFEBLD_opFUNCREF)
12887 if (ffebld_op (ffebld_left (expr)) != FFEBLD_opSYMTER)
12890 s = ffebld_symter (ffebld_left (expr));
12891 if (ffesymbol_where (s) == FFEINFO_whereCONSTANT
12892 || (ffesymbol_where (s) != FFEINFO_whereINTRINSIC
12893 && ! ffesymbol_is_f2c (s))
12894 || (ffesymbol_where (s) == FFEINFO_whereINTRINSIC
12895 && ! ffe_is_f2c_library ()))
12898 else if (ffebld_op (expr) == FFEBLD_opPOWER)
12900 /* Requires special treatment. There's no POW_CC function
12901 in libg2c, so POW_ZZ is used, which means we always
12902 need a double-complex temp, not a single-complex. */
12903 kt = FFEINFO_kindtypeREAL2;
12905 else if (ffebld_op (expr) != FFEBLD_opDIVIDE)
12906 /* The other ops don't need temps for complex operands. */
12909 /* ~~~Avoid making temps for some intrinsics, such as AIMAG(C),
12910 REAL(C). See 19990325-0.f, routine `check', for cases. */
12911 tempvar = ffecom_make_tempvar ("complex",
12913 [FFEINFO_basictypeCOMPLEX][kt],
12914 FFETARGET_charactersizeNONE,
12918 case FFEINFO_basictypeCHARACTER:
12919 if (ffebld_op (expr) != FFEBLD_opFUNCREF)
12922 if (sz == FFETARGET_charactersizeNONE)
12923 /* ~~Kludge alert! This should someday be fixed. */
12926 tempvar = ffecom_make_tempvar ("char", char_type_node, sz, -1);
12935 case FFEBLD_opPOWER:
12938 tree rtmp, ltmp, result;
12940 ltype = ffecom_type_expr (ffebld_left (expr));
12941 rtype = ffecom_type_expr (ffebld_right (expr));
12943 rtmp = ffecom_make_tempvar (rtype, FFETARGET_charactersizeNONE, -1);
12944 ltmp = ffecom_make_tempvar (ltype, FFETARGET_charactersizeNONE, -1);
12945 result = ffecom_make_tempvar (ltype, FFETARGET_charactersizeNONE, -1);
12947 tempvar = make_tree_vec (3);
12948 TREE_VEC_ELT (tempvar, 0) = rtmp;
12949 TREE_VEC_ELT (tempvar, 1) = ltmp;
12950 TREE_VEC_ELT (tempvar, 2) = result;
12955 case FFEBLD_opCONCATENATE:
12957 /* This gets special handling, because only one set of temps
12958 is needed for a tree of these -- the tree is treated as
12959 a flattened list of concatenations when generating code. */
12961 ffecomConcatList_ catlist;
12962 tree ltmp, itmp, result;
12966 catlist = ffecom_concat_list_new_ (expr, FFETARGET_charactersizeNONE);
12967 count = ffecom_concat_list_count_ (catlist);
12972 = ffecom_make_tempvar ("concat_len",
12973 ffecom_f2c_ftnlen_type_node,
12974 FFETARGET_charactersizeNONE, count);
12976 = ffecom_make_tempvar ("concat_item",
12977 ffecom_f2c_address_type_node,
12978 FFETARGET_charactersizeNONE, count);
12980 = ffecom_make_tempvar ("concat_res",
12982 ffecom_concat_list_maxlen_ (catlist),
12985 tempvar = make_tree_vec (3);
12986 TREE_VEC_ELT (tempvar, 0) = ltmp;
12987 TREE_VEC_ELT (tempvar, 1) = itmp;
12988 TREE_VEC_ELT (tempvar, 2) = result;
12991 for (i = 0; i < count; ++i)
12992 ffecom_prepare_arg_ptr_to_expr (ffecom_concat_list_expr_ (catlist,
12995 ffecom_concat_list_kill_ (catlist);
12999 ffebld_nonter_set_hook (expr, tempvar);
13000 current_binding_level->prep_state = 1;
13005 case FFEBLD_opCONVERT:
13006 if (bt == FFEINFO_basictypeCHARACTER
13007 && ((ffebld_size_known (ffebld_left (expr))
13008 == FFETARGET_charactersizeNONE)
13009 || (ffebld_size_known (ffebld_left (expr)) >= sz)))
13010 tempvar = ffecom_make_tempvar ("convert", char_type_node, sz, -1);
13016 ffebld_nonter_set_hook (expr, tempvar);
13017 current_binding_level->prep_state = 1;
13020 /* Prepare subexpressions for this expr. */
13022 switch (ffebld_op (expr))
13024 case FFEBLD_opPERCENT_LOC:
13025 ffecom_prepare_ptr_to_expr (ffebld_left (expr));
13028 case FFEBLD_opPERCENT_VAL:
13029 case FFEBLD_opPERCENT_REF:
13030 ffecom_prepare_expr (ffebld_left (expr));
13033 case FFEBLD_opPERCENT_DESCR:
13034 ffecom_prepare_arg_ptr_to_expr (ffebld_left (expr));
13037 case FFEBLD_opITEM:
13043 item = ffebld_trail (item))
13044 if (ffebld_head (item) != NULL)
13045 ffecom_prepare_expr (ffebld_head (item));
13050 /* Need to handle character conversion specially. */
13051 switch (ffebld_arity (expr))
13054 ffecom_prepare_expr (ffebld_left (expr));
13055 ffecom_prepare_expr (ffebld_right (expr));
13059 ffecom_prepare_expr (ffebld_left (expr));
13070 /* Prepare expression for reading and writing.
13072 Like ffecom_prepare_expr, except for expressions to be evaluated
13073 via ffecom_expr_rw. */
13076 ffecom_prepare_expr_rw (tree type, ffebld expr)
13078 /* This is all we support for now. */
13079 assert (type == NULL_TREE || type == ffecom_type_expr (expr));
13081 /* ~~For now, it seems to be the same thing. */
13082 ffecom_prepare_expr (expr);
13086 /* Prepare expression for writing.
13088 Like ffecom_prepare_expr, except for expressions to be evaluated
13089 via ffecom_expr_w. */
13092 ffecom_prepare_expr_w (tree type, ffebld expr)
13094 /* This is all we support for now. */
13095 assert (type == NULL_TREE || type == ffecom_type_expr (expr));
13097 /* ~~For now, it seems to be the same thing. */
13098 ffecom_prepare_expr (expr);
13102 /* Prepare expression for returning.
13104 Like ffecom_prepare_expr, except for expressions to be evaluated
13105 via ffecom_return_expr. */
13108 ffecom_prepare_return_expr (ffebld expr)
13110 assert (current_binding_level->prep_state < 2);
13112 if (ffecom_primary_entry_kind_ == FFEINFO_kindSUBROUTINE
13113 && ffecom_is_altreturning_
13115 ffecom_prepare_expr (expr);
13118 /* Prepare pointer to expression.
13120 Like ffecom_prepare_expr, except for expressions to be evaluated
13121 via ffecom_ptr_to_expr. */
13124 ffecom_prepare_ptr_to_expr (ffebld expr)
13126 /* ~~For now, it seems to be the same thing. */
13127 ffecom_prepare_expr (expr);
13131 /* Transform expression into constant pointer-to-expression tree.
13133 If the expression can be transformed into a pointer-to-expression tree
13134 that is constant, that is done, and the tree returned. Else NULL_TREE
13137 That way, a caller can attempt to provide compile-time initialization
13138 of a variable and, if that fails, *then* choose to start a new block
13139 and resort to using temporaries, as appropriate. */
13142 ffecom_ptr_to_const_expr (ffebld expr)
13145 return integer_zero_node;
13147 if (ffebld_op (expr) == FFEBLD_opANY)
13148 return error_mark_node;
13150 if (ffebld_arity (expr) == 0
13151 && (ffebld_op (expr) != FFEBLD_opSYMTER
13152 || ffebld_where (expr) == FFEINFO_whereCOMMON
13153 || ffebld_where (expr) == FFEINFO_whereGLOBAL
13154 || ffebld_where (expr) == FFEINFO_whereINTRINSIC))
13158 t = ffecom_ptr_to_expr (expr);
13159 assert (TREE_CONSTANT (t));
13166 /* ffecom_return_expr -- Returns return-value expr given alt return expr
13168 tree rtn; // NULL_TREE means use expand_null_return()
13169 ffebld expr; // NULL if no alt return expr to RETURN stmt
13170 rtn = ffecom_return_expr(expr);
13172 Based on the program unit type and other info (like return function
13173 type, return master function type when alternate ENTRY points,
13174 whether subroutine has any alternate RETURN points, etc), returns the
13175 appropriate expression to be returned to the caller, or NULL_TREE
13176 meaning no return value or the caller expects it to be returned somewhere
13177 else (which is handled by other parts of this module). */
13179 #if FFECOM_targetCURRENT == FFECOM_targetGCC
13181 ffecom_return_expr (ffebld expr)
13185 switch (ffecom_primary_entry_kind_)
13187 case FFEINFO_kindPROGRAM:
13188 case FFEINFO_kindBLOCKDATA:
13192 case FFEINFO_kindSUBROUTINE:
13193 if (!ffecom_is_altreturning_)
13194 rtn = NULL_TREE; /* No alt returns, never an expr. */
13195 else if (expr == NULL)
13196 rtn = integer_zero_node;
13198 rtn = ffecom_expr (expr);
13201 case FFEINFO_kindFUNCTION:
13202 if ((ffecom_multi_retval_ != NULL_TREE)
13203 || (ffesymbol_basictype (ffecom_primary_entry_)
13204 == FFEINFO_basictypeCHARACTER)
13205 || ((ffesymbol_basictype (ffecom_primary_entry_)
13206 == FFEINFO_basictypeCOMPLEX)
13207 && (ffecom_num_entrypoints_ == 0)
13208 && ffesymbol_is_f2c (ffecom_primary_entry_)))
13209 { /* Value is returned by direct assignment
13210 into (implicit) dummy. */
13214 rtn = ffecom_func_result_;
13216 /* Spurious error if RETURN happens before first reference! So elide
13217 this code. In particular, for debugging registry, rtn should always
13218 be non-null after all, but TREE_USED won't be set until we encounter
13219 a reference in the code. Perfectly okay (but weird) code that,
13220 e.g., has "GOTO 20;10 RETURN;20 RTN=0;GOTO 10", would result in
13221 this diagnostic for no reason. Have people use -O -Wuninitialized
13222 and leave it to the back end to find obviously weird cases. */
13224 /* Used to "assert(rtn != NULL_TREE);" here, but it's kind of a valid
13225 situation; if the return value has never been referenced, it won't
13226 have a tree under 2pass mode. */
13227 if ((rtn == NULL_TREE)
13228 || !TREE_USED (rtn))
13230 ffebad_start (FFEBAD_RETURN_VALUE_UNSET);
13231 ffebad_here (0, ffesymbol_where_line (ffecom_primary_entry_),
13232 ffesymbol_where_column (ffecom_primary_entry_));
13233 ffebad_string (ffesymbol_text (ffesymbol_funcresult
13234 (ffecom_primary_entry_)));
13241 assert ("bad unit kind" == NULL);
13242 case FFEINFO_kindANY:
13243 rtn = error_mark_node;
13251 /* Do save_expr only if tree is not error_mark_node. */
13253 #if FFECOM_targetCURRENT == FFECOM_targetGCC
13255 ffecom_save_tree (tree t)
13257 return save_expr (t);
13261 /* Start a compound statement (block). */
13263 #if FFECOM_targetCURRENT == FFECOM_targetGCC
13265 ffecom_start_compstmt (void)
13267 bison_rule_pushlevel_ ();
13269 #endif /* FFECOM_targetCURRENT == FFECOM_targetGCC */
13271 /* Public entry point for front end to access start_decl. */
13273 #if FFECOM_targetCURRENT == FFECOM_targetGCC
13275 ffecom_start_decl (tree decl, bool is_initialized)
13277 DECL_INITIAL (decl) = is_initialized ? error_mark_node : NULL_TREE;
13278 return start_decl (decl, FALSE);
13282 /* ffecom_sym_commit -- Symbol's state being committed to reality
13285 ffecom_sym_commit(s);
13287 Does whatever the backend needs when a symbol is committed after having
13288 been backtrackable for a period of time. */
13290 #if FFECOM_targetCURRENT == FFECOM_targetGCC
13292 ffecom_sym_commit (ffesymbol s UNUSED)
13294 assert (!ffesymbol_retractable ());
13298 /* ffecom_sym_end_transition -- Perform end transition on all symbols
13300 ffecom_sym_end_transition();
13302 Does backend-specific stuff and also calls ffest_sym_end_transition
13303 to do the necessary FFE stuff.
13305 Backtracking is never enabled when this fn is called, so don't worry
13309 ffecom_sym_end_transition (ffesymbol s)
13313 assert (!ffesymbol_retractable ());
13315 s = ffest_sym_end_transition (s);
13317 #if FFECOM_targetCURRENT == FFECOM_targetGCC
13318 if ((ffesymbol_kind (s) == FFEINFO_kindBLOCKDATA)
13319 && (ffesymbol_where (s) == FFEINFO_whereGLOBAL))
13321 ffecom_list_blockdata_
13322 = ffebld_new_item (ffebld_new_symter (s, FFEINTRIN_genNONE,
13323 FFEINTRIN_specNONE,
13324 FFEINTRIN_impNONE),
13325 ffecom_list_blockdata_);
13329 /* This is where we finally notice that a symbol has partial initialization
13330 and finalize it. */
13332 if (ffesymbol_accretion (s) != NULL)
13334 assert (ffesymbol_init (s) == NULL);
13335 ffecom_notify_init_symbol (s);
13337 else if (((st = ffesymbol_storage (s)) != NULL)
13338 && ((st = ffestorag_parent (st)) != NULL)
13339 && (ffestorag_accretion (st) != NULL))
13341 assert (ffestorag_init (st) == NULL);
13342 ffecom_notify_init_storage (st);
13345 #if FFECOM_targetCURRENT == FFECOM_targetGCC
13346 if ((ffesymbol_kind (s) == FFEINFO_kindCOMMON)
13347 && (ffesymbol_where (s) == FFEINFO_whereLOCAL)
13348 && (ffesymbol_storage (s) != NULL))
13350 ffecom_list_common_
13351 = ffebld_new_item (ffebld_new_symter (s, FFEINTRIN_genNONE,
13352 FFEINTRIN_specNONE,
13353 FFEINTRIN_impNONE),
13354 ffecom_list_common_);
13361 /* ffecom_sym_exec_transition -- Perform exec transition on all symbols
13363 ffecom_sym_exec_transition();
13365 Does backend-specific stuff and also calls ffest_sym_exec_transition
13366 to do the necessary FFE stuff.
13368 See the long-winded description in ffecom_sym_learned for info
13369 on handling the situation where backtracking is inhibited. */
13372 ffecom_sym_exec_transition (ffesymbol s)
13374 s = ffest_sym_exec_transition (s);
13379 /* ffecom_sym_learned -- Initial or more info gained on symbol after exec
13382 s = ffecom_sym_learned(s);
13384 Called when a new symbol is seen after the exec transition or when more
13385 info (perhaps) is gained for an UNCERTAIN symbol. The symbol state when
13386 it arrives here is that all its latest info is updated already, so its
13387 state may be UNCERTAIN or UNDERSTOOD, it might already have the hook
13388 field filled in if its gone through here or exec_transition first, and
13391 The backend probably wants to check ffesymbol_retractable() to see if
13392 backtracking is in effect. If so, the FFE's changes to the symbol may
13393 be retracted (undone) or committed (ratified), at which time the
13394 appropriate ffecom_sym_retract or _commit function will be called
13397 If the backend has its own backtracking mechanism, great, use it so that
13398 committal is a simple operation. Though it doesn't make much difference,
13399 I suppose: the reason for tentative symbol evolution in the FFE is to
13400 enable error detection in weird incorrect statements early and to disable
13401 incorrect error detection on a correct statement. The backend is not
13402 likely to introduce any information that'll get involved in these
13403 considerations, so it is probably just fine that the implementation
13404 model for this fn and for _exec_transition is to not do anything
13405 (besides the required FFE stuff) if ffesymbol_retractable() returns TRUE
13406 and instead wait until ffecom_sym_commit is called (which it never
13407 will be as long as we're using ambiguity-detecting statement analysis in
13408 the FFE, which we are initially to shake out the code, but don't depend
13409 on this), otherwise go ahead and do whatever is needed.
13411 In essence, then, when this fn and _exec_transition get called while
13412 backtracking is enabled, a general mechanism would be to flag which (or
13413 both) of these were called (and in what order? neat question as to what
13414 might happen that I'm too lame to think through right now) and then when
13415 _commit is called reproduce the original calling sequence, if any, for
13416 the two fns (at which point backtracking will, of course, be disabled). */
13419 ffecom_sym_learned (ffesymbol s)
13421 ffestorag_exec_layout (s);
13426 /* ffecom_sym_retract -- Symbol's state being retracted from reality
13429 ffecom_sym_retract(s);
13431 Does whatever the backend needs when a symbol is retracted after having
13432 been backtrackable for a period of time. */
13434 #if FFECOM_targetCURRENT == FFECOM_targetGCC
13436 ffecom_sym_retract (ffesymbol s UNUSED)
13438 assert (!ffesymbol_retractable ());
13440 #if 0 /* GCC doesn't commit any backtrackable sins,
13441 so nothing needed here. */
13442 switch (ffesymbol_hook (s).state)
13444 case 0: /* nothing happened yet. */
13447 case 1: /* exec transition happened. */
13450 case 2: /* learned happened. */
13453 case 3: /* learned then exec. */
13456 case 4: /* exec then learned. */
13460 assert ("bad hook state" == NULL);
13467 /* Create temporary gcc label. */
13469 #if FFECOM_targetCURRENT == FFECOM_targetGCC
13471 ffecom_temp_label ()
13474 static int mynumber = 0;
13476 glabel = build_decl (LABEL_DECL,
13477 ffecom_get_invented_identifier ("__g77_label_%d",
13480 DECL_CONTEXT (glabel) = current_function_decl;
13481 DECL_MODE (glabel) = VOIDmode;
13487 /* Return an expression that is usable as an arg in a conditional context
13488 (IF, DO WHILE, .NOT., and so on).
13490 Use the one provided for the back end as of >2.6.0. */
13492 #if FFECOM_targetCURRENT == FFECOM_targetGCC
13494 ffecom_truth_value (tree expr)
13496 return truthvalue_conversion (expr);
13500 /* Return the inversion of a truth value (the inversion of what
13501 ffecom_truth_value builds).
13503 Apparently invert_truthvalue, which is properly in the back end, is
13504 enough for now, so just use it. */
13506 #if FFECOM_targetCURRENT == FFECOM_targetGCC
13508 ffecom_truth_value_invert (tree expr)
13510 return invert_truthvalue (ffecom_truth_value (expr));
13515 /* Return the tree that is the type of the expression, as would be
13516 returned in TREE_TYPE(ffecom_expr(expr)), without otherwise
13517 transforming the expression, generating temporaries, etc. */
13520 ffecom_type_expr (ffebld expr)
13522 ffeinfoBasictype bt;
13523 ffeinfoKindtype kt;
13526 assert (expr != NULL);
13528 bt = ffeinfo_basictype (ffebld_info (expr));
13529 kt = ffeinfo_kindtype (ffebld_info (expr));
13530 tree_type = ffecom_tree_type[bt][kt];
13532 switch (ffebld_op (expr))
13534 case FFEBLD_opCONTER:
13535 case FFEBLD_opSYMTER:
13536 case FFEBLD_opARRAYREF:
13537 case FFEBLD_opUPLUS:
13538 case FFEBLD_opPAREN:
13539 case FFEBLD_opUMINUS:
13541 case FFEBLD_opSUBTRACT:
13542 case FFEBLD_opMULTIPLY:
13543 case FFEBLD_opDIVIDE:
13544 case FFEBLD_opPOWER:
13546 case FFEBLD_opFUNCREF:
13547 case FFEBLD_opSUBRREF:
13551 case FFEBLD_opNEQV:
13553 case FFEBLD_opCONVERT:
13560 case FFEBLD_opPERCENT_LOC:
13563 case FFEBLD_opACCTER:
13564 case FFEBLD_opARRTER:
13565 case FFEBLD_opITEM:
13566 case FFEBLD_opSTAR:
13567 case FFEBLD_opBOUNDS:
13568 case FFEBLD_opREPEAT:
13569 case FFEBLD_opLABTER:
13570 case FFEBLD_opLABTOK:
13571 case FFEBLD_opIMPDO:
13572 case FFEBLD_opCONCATENATE:
13573 case FFEBLD_opSUBSTR:
13575 assert ("bad op for ffecom_type_expr" == NULL);
13576 /* Fall through. */
13578 return error_mark_node;
13582 /* Return PARM_DECL for arg#1 of master fn containing alternate ENTRY points
13584 If the PARM_DECL already exists, return it, else create it. It's an
13585 integer_type_node argument for the master function that implements a
13586 subroutine or function with more than one entrypoint and is bound at
13587 run time with the entrypoint number (0 for SUBROUTINE/FUNCTION, 1 for
13588 first ENTRY statement, and so on). */
13590 #if FFECOM_targetCURRENT == FFECOM_targetGCC
13592 ffecom_which_entrypoint_decl ()
13594 assert (ffecom_which_entrypoint_decl_ != NULL_TREE);
13596 return ffecom_which_entrypoint_decl_;
13601 /* The following sections consists of private and public functions
13602 that have the same names and perform roughly the same functions
13603 as counterparts in the C front end. Changes in the C front end
13604 might affect how things should be done here. Only functions
13605 needed by the back end should be public here; the rest should
13606 be private (static in the C sense). Functions needed by other
13607 g77 front-end modules should be accessed by them via public
13608 ffecom_* names, which should themselves call private versions
13609 in this section so the private versions are easy to recognize
13610 when upgrading to a new gcc and finding interesting changes
13613 Functions named after rule "foo:" in c-parse.y are named
13614 "bison_rule_foo_" so they are easy to find. */
13616 #if FFECOM_targetCURRENT == FFECOM_targetGCC
13619 bison_rule_pushlevel_ ()
13621 emit_line_note (input_filename, lineno);
13623 clear_last_expr ();
13625 expand_start_bindings (0);
13629 bison_rule_compstmt_ ()
13632 int keep = kept_level_p ();
13634 /* Make the temps go away. */
13636 current_binding_level->names = NULL_TREE;
13638 emit_line_note (input_filename, lineno);
13639 expand_end_bindings (getdecls (), keep, 0);
13640 t = poplevel (keep, 1, 0);
13646 /* Return a definition for a builtin function named NAME and whose data type
13647 is TYPE. TYPE should be a function type with argument types.
13648 FUNCTION_CODE tells later passes how to compile calls to this function.
13649 See tree.h for its possible values.
13651 If LIBRARY_NAME is nonzero, use that for DECL_ASSEMBLER_NAME,
13652 the name to be called if we can't opencode the function. */
13655 builtin_function (const char *name, tree type, int function_code,
13656 enum built_in_class class,
13657 const char *library_name)
13659 tree decl = build_decl (FUNCTION_DECL, get_identifier (name), type);
13660 DECL_EXTERNAL (decl) = 1;
13661 TREE_PUBLIC (decl) = 1;
13663 DECL_ASSEMBLER_NAME (decl) = get_identifier (library_name);
13664 make_decl_rtl (decl, NULL_PTR, 1);
13666 DECL_BUILT_IN_CLASS (decl) = class;
13667 DECL_FUNCTION_CODE (decl) = function_code;
13672 /* Handle when a new declaration NEWDECL
13673 has the same name as an old one OLDDECL
13674 in the same binding contour.
13675 Prints an error message if appropriate.
13677 If safely possible, alter OLDDECL to look like NEWDECL, and return 1.
13678 Otherwise, return 0. */
13681 duplicate_decls (tree newdecl, tree olddecl)
13683 int types_match = 1;
13684 int new_is_definition = (TREE_CODE (newdecl) == FUNCTION_DECL
13685 && DECL_INITIAL (newdecl) != 0);
13686 tree oldtype = TREE_TYPE (olddecl);
13687 tree newtype = TREE_TYPE (newdecl);
13689 if (olddecl == newdecl)
13692 if (TREE_CODE (newtype) == ERROR_MARK
13693 || TREE_CODE (oldtype) == ERROR_MARK)
13696 /* New decl is completely inconsistent with the old one =>
13697 tell caller to replace the old one.
13698 This is always an error except in the case of shadowing a builtin. */
13699 if (TREE_CODE (olddecl) != TREE_CODE (newdecl))
13702 /* For real parm decl following a forward decl,
13703 return 1 so old decl will be reused. */
13704 if (types_match && TREE_CODE (newdecl) == PARM_DECL
13705 && TREE_ASM_WRITTEN (olddecl) && ! TREE_ASM_WRITTEN (newdecl))
13708 /* The new declaration is the same kind of object as the old one.
13709 The declarations may partially match. Print warnings if they don't
13710 match enough. Ultimately, copy most of the information from the new
13711 decl to the old one, and keep using the old one. */
13713 if (TREE_CODE (olddecl) == FUNCTION_DECL
13714 && DECL_BUILT_IN (olddecl))
13716 /* A function declaration for a built-in function. */
13717 if (!TREE_PUBLIC (newdecl))
13719 else if (!types_match)
13721 /* Accept the return type of the new declaration if same modes. */
13722 tree oldreturntype = TREE_TYPE (TREE_TYPE (olddecl));
13723 tree newreturntype = TREE_TYPE (TREE_TYPE (newdecl));
13725 if (TYPE_MODE (oldreturntype) == TYPE_MODE (newreturntype))
13727 /* Function types may be shared, so we can't just modify
13728 the return type of olddecl's function type. */
13730 = build_function_type (newreturntype,
13731 TYPE_ARG_TYPES (TREE_TYPE (olddecl)));
13735 TREE_TYPE (olddecl) = newtype;
13741 else if (TREE_CODE (olddecl) == FUNCTION_DECL
13742 && DECL_SOURCE_LINE (olddecl) == 0)
13744 /* A function declaration for a predeclared function
13745 that isn't actually built in. */
13746 if (!TREE_PUBLIC (newdecl))
13748 else if (!types_match)
13750 /* If the types don't match, preserve volatility indication.
13751 Later on, we will discard everything else about the
13752 default declaration. */
13753 TREE_THIS_VOLATILE (newdecl) |= TREE_THIS_VOLATILE (olddecl);
13757 /* Copy all the DECL_... slots specified in the new decl
13758 except for any that we copy here from the old type.
13760 Past this point, we don't change OLDTYPE and NEWTYPE
13761 even if we change the types of NEWDECL and OLDDECL. */
13765 /* Merge the data types specified in the two decls. */
13766 if (TREE_CODE (newdecl) != FUNCTION_DECL || !DECL_BUILT_IN (olddecl))
13767 TREE_TYPE (newdecl)
13768 = TREE_TYPE (olddecl)
13769 = TREE_TYPE (newdecl);
13771 /* Lay the type out, unless already done. */
13772 if (oldtype != TREE_TYPE (newdecl))
13774 if (TREE_TYPE (newdecl) != error_mark_node)
13775 layout_type (TREE_TYPE (newdecl));
13776 if (TREE_CODE (newdecl) != FUNCTION_DECL
13777 && TREE_CODE (newdecl) != TYPE_DECL
13778 && TREE_CODE (newdecl) != CONST_DECL)
13779 layout_decl (newdecl, 0);
13783 /* Since the type is OLDDECL's, make OLDDECL's size go with. */
13784 DECL_SIZE (newdecl) = DECL_SIZE (olddecl);
13785 DECL_SIZE_UNIT (newdecl) = DECL_SIZE_UNIT (olddecl);
13786 if (TREE_CODE (olddecl) != FUNCTION_DECL)
13787 if (DECL_ALIGN (olddecl) > DECL_ALIGN (newdecl))
13788 DECL_ALIGN (newdecl) = DECL_ALIGN (olddecl);
13791 /* Keep the old rtl since we can safely use it. */
13792 DECL_RTL (newdecl) = DECL_RTL (olddecl);
13794 /* Merge the type qualifiers. */
13795 if (DECL_BUILT_IN_NONANSI (olddecl) && TREE_THIS_VOLATILE (olddecl)
13796 && !TREE_THIS_VOLATILE (newdecl))
13797 TREE_THIS_VOLATILE (olddecl) = 0;
13798 if (TREE_READONLY (newdecl))
13799 TREE_READONLY (olddecl) = 1;
13800 if (TREE_THIS_VOLATILE (newdecl))
13802 TREE_THIS_VOLATILE (olddecl) = 1;
13803 if (TREE_CODE (newdecl) == VAR_DECL)
13804 make_var_volatile (newdecl);
13807 /* Keep source location of definition rather than declaration.
13808 Likewise, keep decl at outer scope. */
13809 if ((DECL_INITIAL (newdecl) == 0 && DECL_INITIAL (olddecl) != 0)
13810 || (DECL_CONTEXT (newdecl) != 0 && DECL_CONTEXT (olddecl) == 0))
13812 DECL_SOURCE_LINE (newdecl) = DECL_SOURCE_LINE (olddecl);
13813 DECL_SOURCE_FILE (newdecl) = DECL_SOURCE_FILE (olddecl);
13815 if (DECL_CONTEXT (olddecl) == 0
13816 && TREE_CODE (newdecl) != FUNCTION_DECL)
13817 DECL_CONTEXT (newdecl) = 0;
13820 /* Merge the unused-warning information. */
13821 if (DECL_IN_SYSTEM_HEADER (olddecl))
13822 DECL_IN_SYSTEM_HEADER (newdecl) = 1;
13823 else if (DECL_IN_SYSTEM_HEADER (newdecl))
13824 DECL_IN_SYSTEM_HEADER (olddecl) = 1;
13826 /* Merge the initialization information. */
13827 if (DECL_INITIAL (newdecl) == 0)
13828 DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
13830 /* Merge the section attribute.
13831 We want to issue an error if the sections conflict but that must be
13832 done later in decl_attributes since we are called before attributes
13834 if (DECL_SECTION_NAME (newdecl) == NULL_TREE)
13835 DECL_SECTION_NAME (newdecl) = DECL_SECTION_NAME (olddecl);
13838 if (TREE_CODE (newdecl) == FUNCTION_DECL)
13840 DECL_STATIC_CONSTRUCTOR(newdecl) |= DECL_STATIC_CONSTRUCTOR(olddecl);
13841 DECL_STATIC_DESTRUCTOR (newdecl) |= DECL_STATIC_DESTRUCTOR (olddecl);
13845 /* If cannot merge, then use the new type and qualifiers,
13846 and don't preserve the old rtl. */
13849 TREE_TYPE (olddecl) = TREE_TYPE (newdecl);
13850 TREE_READONLY (olddecl) = TREE_READONLY (newdecl);
13851 TREE_THIS_VOLATILE (olddecl) = TREE_THIS_VOLATILE (newdecl);
13852 TREE_SIDE_EFFECTS (olddecl) = TREE_SIDE_EFFECTS (newdecl);
13855 /* Merge the storage class information. */
13856 /* For functions, static overrides non-static. */
13857 if (TREE_CODE (newdecl) == FUNCTION_DECL)
13859 TREE_PUBLIC (newdecl) &= TREE_PUBLIC (olddecl);
13860 /* This is since we don't automatically
13861 copy the attributes of NEWDECL into OLDDECL. */
13862 TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl);
13863 /* If this clears `static', clear it in the identifier too. */
13864 if (! TREE_PUBLIC (olddecl))
13865 TREE_PUBLIC (DECL_NAME (olddecl)) = 0;
13867 if (DECL_EXTERNAL (newdecl))
13869 TREE_STATIC (newdecl) = TREE_STATIC (olddecl);
13870 DECL_EXTERNAL (newdecl) = DECL_EXTERNAL (olddecl);
13871 /* An extern decl does not override previous storage class. */
13872 TREE_PUBLIC (newdecl) = TREE_PUBLIC (olddecl);
13876 TREE_STATIC (olddecl) = TREE_STATIC (newdecl);
13877 TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl);
13880 /* If either decl says `inline', this fn is inline,
13881 unless its definition was passed already. */
13882 if (DECL_INLINE (newdecl) && DECL_INITIAL (olddecl) == 0)
13883 DECL_INLINE (olddecl) = 1;
13884 DECL_INLINE (newdecl) = DECL_INLINE (olddecl);
13886 /* Get rid of any built-in function if new arg types don't match it
13887 or if we have a function definition. */
13888 if (TREE_CODE (newdecl) == FUNCTION_DECL
13889 && DECL_BUILT_IN (olddecl)
13890 && (!types_match || new_is_definition))
13892 TREE_TYPE (olddecl) = TREE_TYPE (newdecl);
13893 DECL_BUILT_IN_CLASS (olddecl) = NOT_BUILT_IN;
13896 /* If redeclaring a builtin function, and not a definition,
13898 Also preserve various other info from the definition. */
13899 if (TREE_CODE (newdecl) == FUNCTION_DECL && !new_is_definition)
13901 if (DECL_BUILT_IN (olddecl))
13903 DECL_BUILT_IN_CLASS (newdecl) = DECL_BUILT_IN_CLASS (olddecl);
13904 DECL_FUNCTION_CODE (newdecl) = DECL_FUNCTION_CODE (olddecl);
13907 DECL_FRAME_SIZE (newdecl) = DECL_FRAME_SIZE (olddecl);
13909 DECL_RESULT (newdecl) = DECL_RESULT (olddecl);
13910 DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
13911 DECL_SAVED_INSNS (newdecl) = DECL_SAVED_INSNS (olddecl);
13912 DECL_ARGUMENTS (newdecl) = DECL_ARGUMENTS (olddecl);
13915 /* Copy most of the decl-specific fields of NEWDECL into OLDDECL.
13916 But preserve olddecl's DECL_UID. */
13918 register unsigned olddecl_uid = DECL_UID (olddecl);
13920 memcpy ((char *) olddecl + sizeof (struct tree_common),
13921 (char *) newdecl + sizeof (struct tree_common),
13922 sizeof (struct tree_decl) - sizeof (struct tree_common));
13923 DECL_UID (olddecl) = olddecl_uid;
13929 /* Finish processing of a declaration;
13930 install its initial value.
13931 If the length of an array type is not known before,
13932 it must be determined now, from the initial value, or it is an error. */
13935 finish_decl (tree decl, tree init, bool is_top_level)
13937 register tree type = TREE_TYPE (decl);
13938 int was_incomplete = (DECL_SIZE (decl) == 0);
13939 int temporary = allocation_temporary_p ();
13940 bool at_top_level = (current_binding_level == global_binding_level);
13941 bool top_level = is_top_level || at_top_level;
13943 /* Caller should pass TRUE for is_top_level only if we wouldn't be at top
13945 assert (!is_top_level || !at_top_level);
13947 if (TREE_CODE (decl) == PARM_DECL)
13948 assert (init == NULL_TREE);
13949 /* Remember that PARM_DECL doesn't have a DECL_INITIAL field per se -- it
13950 overlaps DECL_ARG_TYPE. */
13951 else if (init == NULL_TREE)
13952 assert (DECL_INITIAL (decl) == NULL_TREE);
13954 assert (DECL_INITIAL (decl) == error_mark_node);
13956 if (init != NULL_TREE)
13958 if (TREE_CODE (decl) != TYPE_DECL)
13959 DECL_INITIAL (decl) = init;
13962 /* typedef foo = bar; store the type of bar as the type of foo. */
13963 TREE_TYPE (decl) = TREE_TYPE (init);
13964 DECL_INITIAL (decl) = init = 0;
13968 /* Pop back to the obstack that is current for this binding level. This is
13969 because MAXINDEX, rtl, etc. to be made below must go in the permanent
13970 obstack. But don't discard the temporary data yet. */
13973 /* Deduce size of array from initialization, if not already known */
13975 if (TREE_CODE (type) == ARRAY_TYPE
13976 && TYPE_DOMAIN (type) == 0
13977 && TREE_CODE (decl) != TYPE_DECL)
13979 assert (top_level);
13980 assert (was_incomplete);
13982 layout_decl (decl, 0);
13985 if (TREE_CODE (decl) == VAR_DECL)
13987 if (DECL_SIZE (decl) == NULL_TREE
13988 && TYPE_SIZE (TREE_TYPE (decl)) != NULL_TREE)
13989 layout_decl (decl, 0);
13991 if (DECL_SIZE (decl) == NULL_TREE
13992 && (TREE_STATIC (decl)
13994 /* A static variable with an incomplete type is an error if it is
13995 initialized. Also if it is not file scope. Otherwise, let it
13996 through, but if it is not `extern' then it may cause an error
13998 (DECL_INITIAL (decl) != 0 || DECL_CONTEXT (decl) != 0)
14000 /* An automatic variable with an incomplete type is an error. */
14001 !DECL_EXTERNAL (decl)))
14003 assert ("storage size not known" == NULL);
14007 if ((DECL_EXTERNAL (decl) || TREE_STATIC (decl))
14008 && (DECL_SIZE (decl) != 0)
14009 && (TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST))
14011 assert ("storage size not constant" == NULL);
14016 /* Output the assembler code and/or RTL code for variables and functions,
14017 unless the type is an undefined structure or union. If not, it will get
14018 done when the type is completed. */
14020 if (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == FUNCTION_DECL)
14022 rest_of_decl_compilation (decl, NULL,
14023 DECL_CONTEXT (decl) == 0,
14026 if (DECL_CONTEXT (decl) != 0)
14028 /* Recompute the RTL of a local array now if it used to be an
14029 incomplete type. */
14031 && !TREE_STATIC (decl) && !DECL_EXTERNAL (decl))
14033 /* If we used it already as memory, it must stay in memory. */
14034 TREE_ADDRESSABLE (decl) = TREE_USED (decl);
14035 /* If it's still incomplete now, no init will save it. */
14036 if (DECL_SIZE (decl) == 0)
14037 DECL_INITIAL (decl) = 0;
14038 expand_decl (decl);
14040 /* Compute and store the initial value. */
14041 if (TREE_CODE (decl) != FUNCTION_DECL)
14042 expand_decl_init (decl);
14045 else if (TREE_CODE (decl) == TYPE_DECL)
14047 rest_of_decl_compilation (decl, NULL_PTR,
14048 DECL_CONTEXT (decl) == 0,
14052 if (!(TREE_CODE (decl) == FUNCTION_DECL && DECL_INLINE (decl))
14054 /* DECL_INITIAL is not defined in PARM_DECLs, since it shares space with
14056 && TREE_CODE (decl) != PARM_DECL)
14058 /* We need to remember that this array HAD an initialization, but
14059 discard the actual temporary nodes, since we can't have a permanent
14060 node keep pointing to them. */
14061 /* We make an exception for inline functions, since it's normal for a
14062 local extern redeclaration of an inline function to have a copy of
14063 the top-level decl's DECL_INLINE. */
14064 if ((DECL_INITIAL (decl) != 0)
14065 && (DECL_INITIAL (decl) != error_mark_node))
14067 /* If this is a const variable, then preserve the
14068 initializer instead of discarding it so that we can optimize
14069 references to it. */
14070 /* This test used to include TREE_STATIC, but this won't be set
14071 for function level initializers. */
14072 if (TREE_READONLY (decl))
14074 preserve_initializer ();
14076 /* The initializer and DECL must have the same (or equivalent
14077 types), but if the initializer is a STRING_CST, its type
14078 might not be on the right obstack, so copy the type
14080 TREE_TYPE (DECL_INITIAL (decl)) = type;
14083 DECL_INITIAL (decl) = error_mark_node;
14087 /* If we have gone back from temporary to permanent allocation, actually
14088 free the temporary space that we no longer need. */
14089 if (temporary && !allocation_temporary_p ())
14090 permanent_allocation (0);
14092 /* At the end of a declaration, throw away any variable type sizes of types
14093 defined inside that declaration. There is no use computing them in the
14094 following function definition. */
14095 if (current_binding_level == global_binding_level)
14096 get_pending_sizes ();
14099 /* Finish up a function declaration and compile that function
14100 all the way to assembler language output. The free the storage
14101 for the function definition.
14103 This is called after parsing the body of the function definition.
14105 NESTED is nonzero if the function being finished is nested in another. */
14108 finish_function (int nested)
14110 register tree fndecl = current_function_decl;
14112 assert (fndecl != NULL_TREE);
14113 if (TREE_CODE (fndecl) != ERROR_MARK)
14116 assert (DECL_CONTEXT (fndecl) != NULL_TREE);
14118 assert (DECL_CONTEXT (fndecl) == NULL_TREE);
14121 /* TREE_READONLY (fndecl) = 1;
14122 This caused &foo to be of type ptr-to-const-function
14123 which then got a warning when stored in a ptr-to-function variable. */
14125 poplevel (1, 0, 1);
14127 if (TREE_CODE (fndecl) != ERROR_MARK)
14129 BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
14131 /* Must mark the RESULT_DECL as being in this function. */
14133 DECL_CONTEXT (DECL_RESULT (fndecl)) = fndecl;
14135 /* Obey `register' declarations if `setjmp' is called in this fn. */
14136 /* Generate rtl for function exit. */
14137 expand_function_end (input_filename, lineno, 0);
14139 /* So we can tell if jump_optimize sets it to 1. */
14142 /* If this is a nested function, protect the local variables in the stack
14143 above us from being collected while we're compiling this function. */
14144 if (ggc_p && nested)
14145 ggc_push_context ();
14147 /* Run the optimizers and output the assembler code for this function. */
14148 rest_of_compilation (fndecl);
14150 /* Undo the GC context switch. */
14151 if (ggc_p && nested)
14152 ggc_pop_context ();
14155 /* Free all the tree nodes making up this function. */
14156 /* Switch back to allocating nodes permanently until we start another
14159 permanent_allocation (1);
14161 if (TREE_CODE (fndecl) != ERROR_MARK
14163 && DECL_SAVED_INSNS (fndecl) == 0)
14165 /* Stop pointing to the local nodes about to be freed. */
14166 /* But DECL_INITIAL must remain nonzero so we know this was an actual
14167 function definition. */
14168 /* For a nested function, this is done in pop_f_function_context. */
14169 /* If rest_of_compilation set this to 0, leave it 0. */
14170 if (DECL_INITIAL (fndecl) != 0)
14171 DECL_INITIAL (fndecl) = error_mark_node;
14172 DECL_ARGUMENTS (fndecl) = 0;
14177 /* Let the error reporting routines know that we're outside a function.
14178 For a nested function, this value is used in pop_c_function_context
14179 and then reset via pop_function_context. */
14180 ffecom_outer_function_decl_ = current_function_decl = NULL;
14184 /* Plug-in replacement for identifying the name of a decl and, for a
14185 function, what we call it in diagnostics. For now, "program unit"
14186 should suffice, since it's a bit of a hassle to figure out which
14187 of several kinds of things it is. Note that it could conceivably
14188 be a statement function, which probably isn't really a program unit
14189 per se, but if that comes up, it should be easy to check (being a
14190 nested function and all). */
14192 static const char *
14193 lang_printable_name (tree decl, int v)
14195 /* Just to keep GCC quiet about the unused variable.
14196 In theory, differing values of V should produce different
14201 if (TREE_CODE (decl) == ERROR_MARK)
14202 return "erroneous code";
14203 return IDENTIFIER_POINTER (DECL_NAME (decl));
14207 /* g77's function to print out name of current function that caused
14212 lang_print_error_function (const char *file)
14214 static ffeglobal last_g = NULL;
14215 static ffesymbol last_s = NULL;
14220 if ((ffecom_primary_entry_ == NULL)
14221 || (ffesymbol_global (ffecom_primary_entry_) == NULL))
14229 g = ffesymbol_global (ffecom_primary_entry_);
14230 if (ffecom_nested_entry_ == NULL)
14232 s = ffecom_primary_entry_;
14233 switch (ffesymbol_kind (s))
14235 case FFEINFO_kindFUNCTION:
14239 case FFEINFO_kindSUBROUTINE:
14240 kind = "subroutine";
14243 case FFEINFO_kindPROGRAM:
14247 case FFEINFO_kindBLOCKDATA:
14248 kind = "block-data";
14252 kind = ffeinfo_kind_message (ffesymbol_kind (s));
14258 s = ffecom_nested_entry_;
14259 kind = "statement function";
14263 if ((last_g != g) || (last_s != s))
14266 fprintf (stderr, "%s: ", file);
14269 fprintf (stderr, "Outside of any program unit:\n");
14272 const char *name = ffesymbol_text (s);
14274 fprintf (stderr, "In %s `%s':\n", kind, name);
14283 /* Similar to `lookup_name' but look only at current binding level. */
14286 lookup_name_current_level (tree name)
14290 if (current_binding_level == global_binding_level)
14291 return IDENTIFIER_GLOBAL_VALUE (name);
14293 if (IDENTIFIER_LOCAL_VALUE (name) == 0)
14296 for (t = current_binding_level->names; t; t = TREE_CHAIN (t))
14297 if (DECL_NAME (t) == name)
14303 /* Create a new `struct binding_level'. */
14305 static struct binding_level *
14306 make_binding_level ()
14309 return (struct binding_level *) xmalloc (sizeof (struct binding_level));
14312 /* Save and restore the variables in this file and elsewhere
14313 that keep track of the progress of compilation of the current function.
14314 Used for nested functions. */
14318 struct f_function *next;
14320 tree shadowed_labels;
14321 struct binding_level *binding_level;
14324 struct f_function *f_function_chain;
14326 /* Restore the variables used during compilation of a C function. */
14329 pop_f_function_context ()
14331 struct f_function *p = f_function_chain;
14334 /* Bring back all the labels that were shadowed. */
14335 for (link = shadowed_labels; link; link = TREE_CHAIN (link))
14336 if (DECL_NAME (TREE_VALUE (link)) != 0)
14337 IDENTIFIER_LABEL_VALUE (DECL_NAME (TREE_VALUE (link)))
14338 = TREE_VALUE (link);
14340 if (current_function_decl != error_mark_node
14341 && DECL_SAVED_INSNS (current_function_decl) == 0)
14343 /* Stop pointing to the local nodes about to be freed. */
14344 /* But DECL_INITIAL must remain nonzero so we know this was an actual
14345 function definition. */
14346 DECL_INITIAL (current_function_decl) = error_mark_node;
14347 DECL_ARGUMENTS (current_function_decl) = 0;
14350 pop_function_context ();
14352 f_function_chain = p->next;
14354 named_labels = p->named_labels;
14355 shadowed_labels = p->shadowed_labels;
14356 current_binding_level = p->binding_level;
14361 /* Save and reinitialize the variables
14362 used during compilation of a C function. */
14365 push_f_function_context ()
14367 struct f_function *p
14368 = (struct f_function *) xmalloc (sizeof (struct f_function));
14370 push_function_context ();
14372 p->next = f_function_chain;
14373 f_function_chain = p;
14375 p->named_labels = named_labels;
14376 p->shadowed_labels = shadowed_labels;
14377 p->binding_level = current_binding_level;
14381 push_parm_decl (tree parm)
14383 int old_immediate_size_expand = immediate_size_expand;
14385 /* Don't try computing parm sizes now -- wait till fn is called. */
14387 immediate_size_expand = 0;
14389 push_obstacks_nochange ();
14391 /* Fill in arg stuff. */
14393 DECL_ARG_TYPE (parm) = TREE_TYPE (parm);
14394 DECL_ARG_TYPE_AS_WRITTEN (parm) = TREE_TYPE (parm);
14395 TREE_READONLY (parm) = 1; /* All implementation args are read-only. */
14397 parm = pushdecl (parm);
14399 immediate_size_expand = old_immediate_size_expand;
14401 finish_decl (parm, NULL_TREE, FALSE);
14404 /* Like pushdecl, only it places X in GLOBAL_BINDING_LEVEL, if appropriate. */
14407 pushdecl_top_level (x)
14411 register struct binding_level *b = current_binding_level;
14412 register tree f = current_function_decl;
14414 current_binding_level = global_binding_level;
14415 current_function_decl = NULL_TREE;
14417 current_binding_level = b;
14418 current_function_decl = f;
14422 /* Store the list of declarations of the current level.
14423 This is done for the parameter declarations of a function being defined,
14424 after they are modified in the light of any missing parameters. */
14430 return current_binding_level->names = decls;
14433 /* Store the parameter declarations into the current function declaration.
14434 This is called after parsing the parameter declarations, before
14435 digesting the body of the function.
14437 For an old-style definition, modify the function's type
14438 to specify at least the number of arguments. */
14441 store_parm_decls (int is_main_program UNUSED)
14443 register tree fndecl = current_function_decl;
14445 if (fndecl == error_mark_node)
14448 /* This is a chain of PARM_DECLs from old-style parm declarations. */
14449 DECL_ARGUMENTS (fndecl) = storedecls (nreverse (getdecls ()));
14451 /* Initialize the RTL code for the function. */
14453 init_function_start (fndecl, input_filename, lineno);
14455 /* Set up parameters and prepare for return, for the function. */
14457 expand_function_start (fndecl, 0);
14461 start_decl (tree decl, bool is_top_level)
14464 bool at_top_level = (current_binding_level == global_binding_level);
14465 bool top_level = is_top_level || at_top_level;
14467 /* Caller should pass TRUE for is_top_level only if we wouldn't be at top
14469 assert (!is_top_level || !at_top_level);
14471 /* The corresponding pop_obstacks is in finish_decl. */
14472 push_obstacks_nochange ();
14474 if (DECL_INITIAL (decl) != NULL_TREE)
14476 assert (DECL_INITIAL (decl) == error_mark_node);
14477 assert (!DECL_EXTERNAL (decl));
14479 else if (top_level)
14480 assert ((TREE_STATIC (decl) == 1) || DECL_EXTERNAL (decl) == 1);
14482 /* For Fortran, we by default put things in .common when possible. */
14483 DECL_COMMON (decl) = 1;
14485 /* Add this decl to the current binding level. TEM may equal DECL or it may
14486 be a previous decl of the same name. */
14488 tem = pushdecl_top_level (decl);
14490 tem = pushdecl (decl);
14492 /* For a local variable, define the RTL now. */
14494 /* But not if this is a duplicate decl and we preserved the rtl from the
14495 previous one (which may or may not happen). */
14496 && DECL_RTL (tem) == 0)
14498 if (TYPE_SIZE (TREE_TYPE (tem)) != 0)
14500 else if (TREE_CODE (TREE_TYPE (tem)) == ARRAY_TYPE
14501 && DECL_INITIAL (tem) != 0)
14505 if (DECL_INITIAL (tem) != NULL_TREE)
14507 /* When parsing and digesting the initializer, use temporary storage.
14508 Do this even if we will ignore the value. */
14510 temporary_allocation ();
14516 /* Create the FUNCTION_DECL for a function definition.
14517 DECLSPECS and DECLARATOR are the parts of the declaration;
14518 they describe the function's name and the type it returns,
14519 but twisted together in a fashion that parallels the syntax of C.
14521 This function creates a binding context for the function body
14522 as well as setting up the FUNCTION_DECL in current_function_decl.
14524 Returns 1 on success. If the DECLARATOR is not suitable for a function
14525 (it defines a datum instead), we return 0, which tells
14526 yyparse to report a parse error.
14528 NESTED is nonzero for a function nested within another function. */
14531 start_function (tree name, tree type, int nested, int public)
14535 int old_immediate_size_expand = immediate_size_expand;
14538 shadowed_labels = 0;
14540 /* Don't expand any sizes in the return type of the function. */
14541 immediate_size_expand = 0;
14546 assert (current_function_decl != NULL_TREE);
14547 assert (DECL_CONTEXT (current_function_decl) == NULL_TREE);
14551 assert (current_function_decl == NULL_TREE);
14554 if (TREE_CODE (type) == ERROR_MARK)
14555 decl1 = current_function_decl = error_mark_node;
14558 decl1 = build_decl (FUNCTION_DECL,
14561 TREE_PUBLIC (decl1) = public ? 1 : 0;
14563 DECL_INLINE (decl1) = 1;
14564 TREE_STATIC (decl1) = 1;
14565 DECL_EXTERNAL (decl1) = 0;
14567 announce_function (decl1);
14569 /* Make the init_value nonzero so pushdecl knows this is not tentative.
14570 error_mark_node is replaced below (in poplevel) with the BLOCK. */
14571 DECL_INITIAL (decl1) = error_mark_node;
14573 /* Record the decl so that the function name is defined. If we already have
14574 a decl for this name, and it is a FUNCTION_DECL, use the old decl. */
14576 current_function_decl = pushdecl (decl1);
14580 ffecom_outer_function_decl_ = current_function_decl;
14583 current_binding_level->prep_state = 2;
14585 if (TREE_CODE (current_function_decl) != ERROR_MARK)
14587 make_function_rtl (current_function_decl);
14589 restype = TREE_TYPE (TREE_TYPE (current_function_decl));
14590 DECL_RESULT (current_function_decl)
14591 = build_decl (RESULT_DECL, NULL_TREE, restype);
14595 /* Allocate further tree nodes temporarily during compilation of this
14597 temporary_allocation ();
14599 if (!nested && (TREE_CODE (current_function_decl) != ERROR_MARK))
14600 TREE_ADDRESSABLE (current_function_decl) = 1;
14602 immediate_size_expand = old_immediate_size_expand;
14605 /* Here are the public functions the GNU back end needs. */
14608 convert (type, expr)
14611 register tree e = expr;
14612 register enum tree_code code = TREE_CODE (type);
14614 if (type == TREE_TYPE (e)
14615 || TREE_CODE (e) == ERROR_MARK)
14617 if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (e)))
14618 return fold (build1 (NOP_EXPR, type, e));
14619 if (TREE_CODE (TREE_TYPE (e)) == ERROR_MARK
14620 || code == ERROR_MARK)
14621 return error_mark_node;
14622 if (TREE_CODE (TREE_TYPE (e)) == VOID_TYPE)
14624 assert ("void value not ignored as it ought to be" == NULL);
14625 return error_mark_node;
14627 if (code == VOID_TYPE)
14628 return build1 (CONVERT_EXPR, type, e);
14629 if ((code != RECORD_TYPE)
14630 && (TREE_CODE (TREE_TYPE (e)) == RECORD_TYPE))
14631 e = ffecom_1 (REALPART_EXPR, TREE_TYPE (TYPE_FIELDS (TREE_TYPE (e))),
14633 if (code == INTEGER_TYPE || code == ENUMERAL_TYPE)
14634 return fold (convert_to_integer (type, e));
14635 if (code == POINTER_TYPE)
14636 return fold (convert_to_pointer (type, e));
14637 if (code == REAL_TYPE)
14638 return fold (convert_to_real (type, e));
14639 if (code == COMPLEX_TYPE)
14640 return fold (convert_to_complex (type, e));
14641 if (code == RECORD_TYPE)
14642 return fold (ffecom_convert_to_complex_ (type, e));
14644 assert ("conversion to non-scalar type requested" == NULL);
14645 return error_mark_node;
14648 /* integrate_decl_tree calls this function, but since we don't use the
14649 DECL_LANG_SPECIFIC field, this is a no-op. */
14652 copy_lang_decl (node)
14657 /* Return the list of declarations of the current level.
14658 Note that this list is in reverse order unless/until
14659 you nreverse it; and when you do nreverse it, you must
14660 store the result back using `storedecls' or you will lose. */
14665 return current_binding_level->names;
14668 /* Nonzero if we are currently in the global binding level. */
14671 global_bindings_p ()
14673 return current_binding_level == global_binding_level;
14676 /* Print an error message for invalid use of an incomplete type.
14677 VALUE is the expression that was used (or 0 if that isn't known)
14678 and TYPE is the type that was invalid. */
14681 incomplete_type_error (value, type)
14685 if (TREE_CODE (type) == ERROR_MARK)
14688 assert ("incomplete type?!?" == NULL);
14691 /* Mark ARG for GC. */
14693 mark_binding_level (void *arg)
14695 struct binding_level *level = *(struct binding_level **) arg;
14699 ggc_mark_tree (level->names);
14700 ggc_mark_tree (level->blocks);
14701 ggc_mark_tree (level->this_block);
14702 level = level->level_chain;
14707 init_decl_processing ()
14709 static tree *const tree_roots[] = {
14710 ¤t_function_decl,
14712 &ffecom_tree_fun_type_void,
14713 &ffecom_integer_zero_node,
14714 &ffecom_integer_one_node,
14715 &ffecom_tree_subr_type,
14716 &ffecom_tree_ptr_to_subr_type,
14717 &ffecom_tree_blockdata_type,
14718 &ffecom_tree_xargc_,
14719 &ffecom_f2c_integer_type_node,
14720 &ffecom_f2c_ptr_to_integer_type_node,
14721 &ffecom_f2c_address_type_node,
14722 &ffecom_f2c_real_type_node,
14723 &ffecom_f2c_ptr_to_real_type_node,
14724 &ffecom_f2c_doublereal_type_node,
14725 &ffecom_f2c_complex_type_node,
14726 &ffecom_f2c_doublecomplex_type_node,
14727 &ffecom_f2c_longint_type_node,
14728 &ffecom_f2c_logical_type_node,
14729 &ffecom_f2c_flag_type_node,
14730 &ffecom_f2c_ftnlen_type_node,
14731 &ffecom_f2c_ftnlen_zero_node,
14732 &ffecom_f2c_ftnlen_one_node,
14733 &ffecom_f2c_ftnlen_two_node,
14734 &ffecom_f2c_ptr_to_ftnlen_type_node,
14735 &ffecom_f2c_ftnint_type_node,
14736 &ffecom_f2c_ptr_to_ftnint_type_node,
14737 &ffecom_outer_function_decl_,
14738 &ffecom_previous_function_decl_,
14739 &ffecom_which_entrypoint_decl_,
14740 &ffecom_float_zero_,
14741 &ffecom_float_half_,
14742 &ffecom_double_zero_,
14743 &ffecom_double_half_,
14744 &ffecom_func_result_,
14745 &ffecom_func_length_,
14746 &ffecom_multi_type_node_,
14747 &ffecom_multi_retval_,
14755 /* Record our roots. */
14756 for (i = 0; i < sizeof(tree_roots)/sizeof(tree_roots[0]); i++)
14757 ggc_add_tree_root (tree_roots[i], 1);
14758 ggc_add_tree_root (&ffecom_tree_type[0][0],
14759 FFEINFO_basictype*FFEINFO_kindtype);
14760 ggc_add_tree_root (&ffecom_tree_fun_type[0][0],
14761 FFEINFO_basictype*FFEINFO_kindtype);
14762 ggc_add_tree_root (&ffecom_tree_ptr_to_fun_type[0][0],
14763 FFEINFO_basictype*FFEINFO_kindtype);
14764 ggc_add_tree_root (ffecom_gfrt_, FFECOM_gfrt);
14765 ggc_add_root (¤t_binding_level, 1, sizeof current_binding_level,
14766 mark_binding_level);
14767 ggc_add_root (&free_binding_level, 1, sizeof current_binding_level,
14768 mark_binding_level);
14769 ggc_add_root (&tracker_head, 1, sizeof tracker_head, mark_tracker_head);
14775 init_parse (filename)
14778 /* Open input file. */
14779 if (filename == 0 || !strcmp (filename, "-"))
14782 filename = "stdin";
14785 finput = fopen (filename, "r");
14787 pfatal_with_name (filename);
14789 #ifdef IO_BUFFER_SIZE
14790 setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
14793 /* Make identifier nodes long enough for the language-specific slots. */
14794 set_identifier_size (sizeof (struct lang_identifier));
14795 decl_printable_name = lang_printable_name;
14797 print_error_function = lang_print_error_function;
14809 /* Delete the node BLOCK from the current binding level.
14810 This is used for the block inside a stmt expr ({...})
14811 so that the block can be reinserted where appropriate. */
14814 delete_block (block)
14818 if (current_binding_level->blocks == block)
14819 current_binding_level->blocks = TREE_CHAIN (block);
14820 for (t = current_binding_level->blocks; t;)
14822 if (TREE_CHAIN (t) == block)
14823 TREE_CHAIN (t) = TREE_CHAIN (block);
14825 t = TREE_CHAIN (t);
14827 TREE_CHAIN (block) = NULL;
14828 /* Clear TREE_USED which is always set by poplevel.
14829 The flag is set again if insert_block is called. */
14830 TREE_USED (block) = 0;
14834 insert_block (block)
14837 TREE_USED (block) = 1;
14838 current_binding_level->blocks
14839 = chainon (current_binding_level->blocks, block);
14843 lang_decode_option (argc, argv)
14847 return ffe_decode_option (argc, argv);
14850 /* used by print-tree.c */
14853 lang_print_xnode (file, node, indent)
14863 ffe_terminate_0 ();
14865 if (ffe_is_ffedebug ())
14866 malloc_pool_display (malloc_pool_image ());
14876 lang_init_options ()
14878 /* Set default options for Fortran. */
14879 flag_move_all_movables = 1;
14880 flag_reduce_all_givs = 1;
14881 flag_argument_noalias = 2;
14882 flag_errno_math = 0;
14883 flag_complex_divide_method = 1;
14889 /* If the file is output from cpp, it should contain a first line
14890 `# 1 "real-filename"', and the current design of gcc (toplev.c
14891 in particular and the way it sets up information relied on by
14892 INCLUDE) requires that we read this now, and store the
14893 "real-filename" info in master_input_filename. Ask the lexer
14894 to try doing this. */
14895 ffelex_hash_kludge (finput);
14899 mark_addressable (exp)
14902 register tree x = exp;
14904 switch (TREE_CODE (x))
14907 case COMPONENT_REF:
14909 x = TREE_OPERAND (x, 0);
14913 TREE_ADDRESSABLE (x) = 1;
14920 if (DECL_REGISTER (x) && !TREE_ADDRESSABLE (x)
14921 && DECL_NONLOCAL (x))
14923 if (TREE_PUBLIC (x))
14925 assert ("address of global register var requested" == NULL);
14928 assert ("address of register variable requested" == NULL);
14930 else if (DECL_REGISTER (x) && !TREE_ADDRESSABLE (x))
14932 if (TREE_PUBLIC (x))
14934 assert ("address of global register var requested" == NULL);
14937 assert ("address of register var requested" == NULL);
14939 put_var_into_stack (x);
14942 case FUNCTION_DECL:
14943 TREE_ADDRESSABLE (x) = 1;
14944 #if 0 /* poplevel deals with this now. */
14945 if (DECL_CONTEXT (x) == 0)
14946 TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (x)) = 1;
14954 /* If DECL has a cleanup, build and return that cleanup here.
14955 This is a callback called by expand_expr. */
14958 maybe_build_cleanup (decl)
14961 /* There are no cleanups in Fortran. */
14965 /* Exit a binding level.
14966 Pop the level off, and restore the state of the identifier-decl mappings
14967 that were in effect when this level was entered.
14969 If KEEP is nonzero, this level had explicit declarations, so
14970 and create a "block" (a BLOCK node) for the level
14971 to record its declarations and subblocks for symbol table output.
14973 If FUNCTIONBODY is nonzero, this level is the body of a function,
14974 so create a block as if KEEP were set and also clear out all
14977 If REVERSE is nonzero, reverse the order of decls before putting
14978 them into the BLOCK. */
14981 poplevel (keep, reverse, functionbody)
14986 register tree link;
14987 /* The chain of decls was accumulated in reverse order.
14988 Put it into forward order, just for cleanliness. */
14990 tree subblocks = current_binding_level->blocks;
14993 int block_previously_created;
14995 /* Get the decls in the order they were written.
14996 Usually current_binding_level->names is in reverse order.
14997 But parameter decls were previously put in forward order. */
15000 current_binding_level->names
15001 = decls = nreverse (current_binding_level->names);
15003 decls = current_binding_level->names;
15005 /* Output any nested inline functions within this block
15006 if they weren't already output. */
15008 for (decl = decls; decl; decl = TREE_CHAIN (decl))
15009 if (TREE_CODE (decl) == FUNCTION_DECL
15010 && ! TREE_ASM_WRITTEN (decl)
15011 && DECL_INITIAL (decl) != 0
15012 && TREE_ADDRESSABLE (decl))
15014 /* If this decl was copied from a file-scope decl
15015 on account of a block-scope extern decl,
15016 propagate TREE_ADDRESSABLE to the file-scope decl.
15018 DECL_ABSTRACT_ORIGIN can be set to itself if warn_return_type is
15019 true, since then the decl goes through save_for_inline_copying. */
15020 if (DECL_ABSTRACT_ORIGIN (decl) != 0
15021 && DECL_ABSTRACT_ORIGIN (decl) != decl)
15022 TREE_ADDRESSABLE (DECL_ABSTRACT_ORIGIN (decl)) = 1;
15023 else if (DECL_SAVED_INSNS (decl) != 0)
15025 push_function_context ();
15026 output_inline_function (decl);
15027 pop_function_context ();
15031 /* If there were any declarations or structure tags in that level,
15032 or if this level is a function body,
15033 create a BLOCK to record them for the life of this function. */
15036 block_previously_created = (current_binding_level->this_block != 0);
15037 if (block_previously_created)
15038 block = current_binding_level->this_block;
15039 else if (keep || functionbody)
15040 block = make_node (BLOCK);
15043 BLOCK_VARS (block) = decls;
15044 BLOCK_SUBBLOCKS (block) = subblocks;
15047 /* In each subblock, record that this is its superior. */
15049 for (link = subblocks; link; link = TREE_CHAIN (link))
15050 BLOCK_SUPERCONTEXT (link) = block;
15052 /* Clear out the meanings of the local variables of this level. */
15054 for (link = decls; link; link = TREE_CHAIN (link))
15056 if (DECL_NAME (link) != 0)
15058 /* If the ident. was used or addressed via a local extern decl,
15059 don't forget that fact. */
15060 if (DECL_EXTERNAL (link))
15062 if (TREE_USED (link))
15063 TREE_USED (DECL_NAME (link)) = 1;
15064 if (TREE_ADDRESSABLE (link))
15065 TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (link)) = 1;
15067 IDENTIFIER_LOCAL_VALUE (DECL_NAME (link)) = 0;
15071 /* If the level being exited is the top level of a function,
15072 check over all the labels, and clear out the current
15073 (function local) meanings of their names. */
15077 /* If this is the top level block of a function,
15078 the vars are the function's parameters.
15079 Don't leave them in the BLOCK because they are
15080 found in the FUNCTION_DECL instead. */
15082 BLOCK_VARS (block) = 0;
15085 /* Pop the current level, and free the structure for reuse. */
15088 register struct binding_level *level = current_binding_level;
15089 current_binding_level = current_binding_level->level_chain;
15091 level->level_chain = free_binding_level;
15092 free_binding_level = level;
15095 /* Dispose of the block that we just made inside some higher level. */
15097 && current_function_decl != error_mark_node)
15098 DECL_INITIAL (current_function_decl) = block;
15101 if (!block_previously_created)
15102 current_binding_level->blocks
15103 = chainon (current_binding_level->blocks, block);
15105 /* If we did not make a block for the level just exited,
15106 any blocks made for inner levels
15107 (since they cannot be recorded as subblocks in that level)
15108 must be carried forward so they will later become subblocks
15109 of something else. */
15110 else if (subblocks)
15111 current_binding_level->blocks
15112 = chainon (current_binding_level->blocks, subblocks);
15115 TREE_USED (block) = 1;
15120 print_lang_decl (file, node, indent)
15128 print_lang_identifier (file, node, indent)
15133 print_node (file, "global", IDENTIFIER_GLOBAL_VALUE (node), indent + 4);
15134 print_node (file, "local", IDENTIFIER_LOCAL_VALUE (node), indent + 4);
15138 print_lang_statistics ()
15143 print_lang_type (file, node, indent)
15150 /* Record a decl-node X as belonging to the current lexical scope.
15151 Check for errors (such as an incompatible declaration for the same
15152 name already seen in the same scope).
15154 Returns either X or an old decl for the same name.
15155 If an old decl is returned, it may have been smashed
15156 to agree with what X says. */
15163 register tree name = DECL_NAME (x);
15164 register struct binding_level *b = current_binding_level;
15166 if ((TREE_CODE (x) == FUNCTION_DECL)
15167 && (DECL_INITIAL (x) == 0)
15168 && DECL_EXTERNAL (x))
15169 DECL_CONTEXT (x) = NULL_TREE;
15171 DECL_CONTEXT (x) = current_function_decl;
15175 if (IDENTIFIER_INVENTED (name))
15178 DECL_ARTIFICIAL (x) = 1;
15180 DECL_IN_SYSTEM_HEADER (x) = 1;
15183 t = lookup_name_current_level (name);
15185 assert ((t == NULL_TREE) || (DECL_CONTEXT (x) == NULL_TREE));
15187 /* Don't push non-parms onto list for parms until we understand
15188 why we're doing this and whether it works. */
15190 assert ((b == global_binding_level)
15191 || !ffecom_transform_only_dummies_
15192 || TREE_CODE (x) == PARM_DECL);
15194 if ((t != NULL_TREE) && duplicate_decls (x, t))
15197 /* If we are processing a typedef statement, generate a whole new
15198 ..._TYPE node (which will be just an variant of the existing
15199 ..._TYPE node with identical properties) and then install the
15200 TYPE_DECL node generated to represent the typedef name as the
15201 TYPE_NAME of this brand new (duplicate) ..._TYPE node.
15203 The whole point here is to end up with a situation where each and every
15204 ..._TYPE node the compiler creates will be uniquely associated with
15205 AT MOST one node representing a typedef name. This way, even though
15206 the compiler substitutes corresponding ..._TYPE nodes for TYPE_DECL
15207 (i.e. "typedef name") nodes very early on, later parts of the
15208 compiler can always do the reverse translation and get back the
15209 corresponding typedef name. For example, given:
15211 typedef struct S MY_TYPE; MY_TYPE object;
15213 Later parts of the compiler might only know that `object' was of type
15214 `struct S' if it were not for code just below. With this code
15215 however, later parts of the compiler see something like:
15217 struct S' == struct S typedef struct S' MY_TYPE; struct S' object;
15219 And they can then deduce (from the node for type struct S') that the
15220 original object declaration was:
15224 Being able to do this is important for proper support of protoize, and
15225 also for generating precise symbolic debugging information which
15226 takes full account of the programmer's (typedef) vocabulary.
15228 Obviously, we don't want to generate a duplicate ..._TYPE node if the
15229 TYPE_DECL node that we are now processing really represents a
15230 standard built-in type.
15232 Since all standard types are effectively declared at line zero in the
15233 source file, we can easily check to see if we are working on a
15234 standard type by checking the current value of lineno. */
15236 if (TREE_CODE (x) == TYPE_DECL)
15238 if (DECL_SOURCE_LINE (x) == 0)
15240 if (TYPE_NAME (TREE_TYPE (x)) == 0)
15241 TYPE_NAME (TREE_TYPE (x)) = x;
15243 else if (TREE_TYPE (x) != error_mark_node)
15245 tree tt = TREE_TYPE (x);
15247 tt = build_type_copy (tt);
15248 TYPE_NAME (tt) = x;
15249 TREE_TYPE (x) = tt;
15253 /* This name is new in its binding level. Install the new declaration
15255 if (b == global_binding_level)
15256 IDENTIFIER_GLOBAL_VALUE (name) = x;
15258 IDENTIFIER_LOCAL_VALUE (name) = x;
15261 /* Put decls on list in reverse order. We will reverse them later if
15263 TREE_CHAIN (x) = b->names;
15269 /* Nonzero if the current level needs to have a BLOCK made. */
15276 for (decl = current_binding_level->names;
15278 decl = TREE_CHAIN (decl))
15280 if (TREE_USED (decl) || TREE_CODE (decl) != VAR_DECL
15281 || (DECL_NAME (decl) && ! DECL_ARTIFICIAL (decl)))
15282 /* Currently, there aren't supposed to be non-artificial names
15283 at other than the top block for a function -- they're
15284 believed to always be temps. But it's wise to check anyway. */
15290 /* Enter a new binding level.
15291 If TAG_TRANSPARENT is nonzero, do so only for the name space of variables,
15292 not for that of tags. */
15295 pushlevel (tag_transparent)
15296 int tag_transparent;
15298 register struct binding_level *newlevel = NULL_BINDING_LEVEL;
15300 assert (! tag_transparent);
15302 if (current_binding_level == global_binding_level)
15307 /* Reuse or create a struct for this binding level. */
15309 if (free_binding_level)
15311 newlevel = free_binding_level;
15312 free_binding_level = free_binding_level->level_chain;
15316 newlevel = make_binding_level ();
15319 /* Add this level to the front of the chain (stack) of levels that
15322 *newlevel = clear_binding_level;
15323 newlevel->level_chain = current_binding_level;
15324 current_binding_level = newlevel;
15327 /* Set the BLOCK node for the innermost scope
15328 (the one we are currently in). */
15332 register tree block;
15334 current_binding_level->this_block = block;
15337 /* ~~gcc/tree.h *should* declare this, because toplev.c references it. */
15339 /* Can't 'yydebug' a front end not generated by yacc/bison! */
15342 set_yydebug (value)
15346 fprintf (stderr, "warning: no yacc/bison-generated output to debug!\n");
15350 signed_or_unsigned_type (unsignedp, type)
15356 if (! INTEGRAL_TYPE_P (type))
15358 if (TYPE_PRECISION (type) == TYPE_PRECISION (signed_char_type_node))
15359 return unsignedp ? unsigned_char_type_node : signed_char_type_node;
15360 if (TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node))
15361 return unsignedp ? unsigned_type_node : integer_type_node;
15362 if (TYPE_PRECISION (type) == TYPE_PRECISION (short_integer_type_node))
15363 return unsignedp ? short_unsigned_type_node : short_integer_type_node;
15364 if (TYPE_PRECISION (type) == TYPE_PRECISION (long_integer_type_node))
15365 return unsignedp ? long_unsigned_type_node : long_integer_type_node;
15366 if (TYPE_PRECISION (type) == TYPE_PRECISION (long_long_integer_type_node))
15367 return (unsignedp ? long_long_unsigned_type_node
15368 : long_long_integer_type_node);
15370 type2 = type_for_size (TYPE_PRECISION (type), unsignedp);
15371 if (type2 == NULL_TREE)
15381 tree type1 = TYPE_MAIN_VARIANT (type);
15382 ffeinfoKindtype kt;
15385 if (type1 == unsigned_char_type_node || type1 == char_type_node)
15386 return signed_char_type_node;
15387 if (type1 == unsigned_type_node)
15388 return integer_type_node;
15389 if (type1 == short_unsigned_type_node)
15390 return short_integer_type_node;
15391 if (type1 == long_unsigned_type_node)
15392 return long_integer_type_node;
15393 if (type1 == long_long_unsigned_type_node)
15394 return long_long_integer_type_node;
15395 #if 0 /* gcc/c-* files only */
15396 if (type1 == unsigned_intDI_type_node)
15397 return intDI_type_node;
15398 if (type1 == unsigned_intSI_type_node)
15399 return intSI_type_node;
15400 if (type1 == unsigned_intHI_type_node)
15401 return intHI_type_node;
15402 if (type1 == unsigned_intQI_type_node)
15403 return intQI_type_node;
15406 type2 = type_for_size (TYPE_PRECISION (type1), 0);
15407 if (type2 != NULL_TREE)
15410 for (kt = 0; kt < ARRAY_SIZE (ffecom_tree_type[0]); ++kt)
15412 type2 = ffecom_tree_type[FFEINFO_basictypeHOLLERITH][kt];
15414 if (type1 == type2)
15415 return ffecom_tree_type[FFEINFO_basictypeINTEGER][kt];
15421 /* Prepare expr to be an argument of a TRUTH_NOT_EXPR,
15422 or validate its data type for an `if' or `while' statement or ?..: exp.
15424 This preparation consists of taking the ordinary
15425 representation of an expression expr and producing a valid tree
15426 boolean expression describing whether expr is nonzero. We could
15427 simply always do build_binary_op (NE_EXPR, expr, integer_zero_node, 1),
15428 but we optimize comparisons, &&, ||, and !.
15430 The resulting type should always be `integer_type_node'. */
15433 truthvalue_conversion (expr)
15436 if (TREE_CODE (expr) == ERROR_MARK)
15439 #if 0 /* This appears to be wrong for C++. */
15440 /* These really should return error_mark_node after 2.4 is stable.
15441 But not all callers handle ERROR_MARK properly. */
15442 switch (TREE_CODE (TREE_TYPE (expr)))
15445 error ("struct type value used where scalar is required");
15446 return integer_zero_node;
15449 error ("union type value used where scalar is required");
15450 return integer_zero_node;
15453 error ("array type value used where scalar is required");
15454 return integer_zero_node;
15461 switch (TREE_CODE (expr))
15463 /* It is simpler and generates better code to have only TRUTH_*_EXPR
15464 or comparison expressions as truth values at this level. */
15466 case COMPONENT_REF:
15467 /* A one-bit unsigned bit-field is already acceptable. */
15468 if (1 == TREE_INT_CST_LOW (DECL_SIZE (TREE_OPERAND (expr, 1)))
15469 && TREE_UNSIGNED (TREE_OPERAND (expr, 1)))
15475 /* It is simpler and generates better code to have only TRUTH_*_EXPR
15476 or comparison expressions as truth values at this level. */
15478 if (integer_zerop (TREE_OPERAND (expr, 1)))
15479 return build_unary_op (TRUTH_NOT_EXPR, TREE_OPERAND (expr, 0), 0);
15481 case NE_EXPR: case LE_EXPR: case GE_EXPR: case LT_EXPR: case GT_EXPR:
15482 case TRUTH_ANDIF_EXPR:
15483 case TRUTH_ORIF_EXPR:
15484 case TRUTH_AND_EXPR:
15485 case TRUTH_OR_EXPR:
15486 case TRUTH_XOR_EXPR:
15487 TREE_TYPE (expr) = integer_type_node;
15494 return integer_zerop (expr) ? integer_zero_node : integer_one_node;
15497 return real_zerop (expr) ? integer_zero_node : integer_one_node;
15500 if (TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 0)))
15501 return build (COMPOUND_EXPR, integer_type_node,
15502 TREE_OPERAND (expr, 0), integer_one_node);
15504 return integer_one_node;
15507 return ffecom_2 ((TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 1))
15508 ? TRUTH_OR_EXPR : TRUTH_ORIF_EXPR),
15510 truthvalue_conversion (TREE_OPERAND (expr, 0)),
15511 truthvalue_conversion (TREE_OPERAND (expr, 1)));
15517 /* These don't change whether an object is non-zero or zero. */
15518 return truthvalue_conversion (TREE_OPERAND (expr, 0));
15522 /* These don't change whether an object is zero or non-zero, but
15523 we can't ignore them if their second arg has side-effects. */
15524 if (TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 1)))
15525 return build (COMPOUND_EXPR, integer_type_node, TREE_OPERAND (expr, 1),
15526 truthvalue_conversion (TREE_OPERAND (expr, 0)));
15528 return truthvalue_conversion (TREE_OPERAND (expr, 0));
15531 /* Distribute the conversion into the arms of a COND_EXPR. */
15532 return fold (build (COND_EXPR, integer_type_node, TREE_OPERAND (expr, 0),
15533 truthvalue_conversion (TREE_OPERAND (expr, 1)),
15534 truthvalue_conversion (TREE_OPERAND (expr, 2))));
15537 /* Don't cancel the effect of a CONVERT_EXPR from a REFERENCE_TYPE,
15538 since that affects how `default_conversion' will behave. */
15539 if (TREE_CODE (TREE_TYPE (expr)) == REFERENCE_TYPE
15540 || TREE_CODE (TREE_TYPE (TREE_OPERAND (expr, 0))) == REFERENCE_TYPE)
15542 /* fall through... */
15544 /* If this is widening the argument, we can ignore it. */
15545 if (TYPE_PRECISION (TREE_TYPE (expr))
15546 >= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (expr, 0))))
15547 return truthvalue_conversion (TREE_OPERAND (expr, 0));
15551 /* With IEEE arithmetic, x - x may not equal 0, so we can't optimize
15553 if (TARGET_FLOAT_FORMAT == IEEE_FLOAT_FORMAT
15554 && TREE_CODE (TREE_TYPE (expr)) == REAL_TYPE)
15556 /* fall through... */
15558 /* This and MINUS_EXPR can be changed into a comparison of the
15560 if (TREE_TYPE (TREE_OPERAND (expr, 0))
15561 == TREE_TYPE (TREE_OPERAND (expr, 1)))
15562 return ffecom_2 (NE_EXPR, integer_type_node,
15563 TREE_OPERAND (expr, 0),
15564 TREE_OPERAND (expr, 1));
15565 return ffecom_2 (NE_EXPR, integer_type_node,
15566 TREE_OPERAND (expr, 0),
15567 fold (build1 (NOP_EXPR,
15568 TREE_TYPE (TREE_OPERAND (expr, 0)),
15569 TREE_OPERAND (expr, 1))));
15572 if (integer_onep (TREE_OPERAND (expr, 1)))
15577 #if 0 /* No such thing in Fortran. */
15578 if (warn_parentheses && C_EXP_ORIGINAL_CODE (expr) == MODIFY_EXPR)
15579 warning ("suggest parentheses around assignment used as truth value");
15587 if (TREE_CODE (TREE_TYPE (expr)) == COMPLEX_TYPE)
15589 ((TREE_SIDE_EFFECTS (expr)
15590 ? TRUTH_OR_EXPR : TRUTH_ORIF_EXPR),
15592 truthvalue_conversion (ffecom_1 (REALPART_EXPR,
15593 TREE_TYPE (TREE_TYPE (expr)),
15595 truthvalue_conversion (ffecom_1 (IMAGPART_EXPR,
15596 TREE_TYPE (TREE_TYPE (expr)),
15599 return ffecom_2 (NE_EXPR, integer_type_node,
15601 convert (TREE_TYPE (expr), integer_zero_node));
15605 type_for_mode (mode, unsignedp)
15606 enum machine_mode mode;
15613 if (mode == TYPE_MODE (integer_type_node))
15614 return unsignedp ? unsigned_type_node : integer_type_node;
15616 if (mode == TYPE_MODE (signed_char_type_node))
15617 return unsignedp ? unsigned_char_type_node : signed_char_type_node;
15619 if (mode == TYPE_MODE (short_integer_type_node))
15620 return unsignedp ? short_unsigned_type_node : short_integer_type_node;
15622 if (mode == TYPE_MODE (long_integer_type_node))
15623 return unsignedp ? long_unsigned_type_node : long_integer_type_node;
15625 if (mode == TYPE_MODE (long_long_integer_type_node))
15626 return unsignedp ? long_long_unsigned_type_node : long_long_integer_type_node;
15628 #if HOST_BITS_PER_WIDE_INT >= 64
15629 if (mode == TYPE_MODE (intTI_type_node))
15630 return unsignedp ? unsigned_intTI_type_node : intTI_type_node;
15633 if (mode == TYPE_MODE (float_type_node))
15634 return float_type_node;
15636 if (mode == TYPE_MODE (double_type_node))
15637 return double_type_node;
15639 if (mode == TYPE_MODE (build_pointer_type (char_type_node)))
15640 return build_pointer_type (char_type_node);
15642 if (mode == TYPE_MODE (build_pointer_type (integer_type_node)))
15643 return build_pointer_type (integer_type_node);
15645 for (i = 0; ((size_t) i) < ARRAY_SIZE (ffecom_tree_type); ++i)
15646 for (j = 0; ((size_t) j) < ARRAY_SIZE (ffecom_tree_type[0]); ++j)
15648 if (((t = ffecom_tree_type[i][j]) != NULL_TREE)
15649 && (mode == TYPE_MODE (t)))
15651 if ((i == FFEINFO_basictypeINTEGER) && unsignedp)
15652 return ffecom_tree_type[FFEINFO_basictypeHOLLERITH][j];
15662 type_for_size (bits, unsignedp)
15666 ffeinfoKindtype kt;
15669 if (bits == TYPE_PRECISION (integer_type_node))
15670 return unsignedp ? unsigned_type_node : integer_type_node;
15672 if (bits == TYPE_PRECISION (signed_char_type_node))
15673 return unsignedp ? unsigned_char_type_node : signed_char_type_node;
15675 if (bits == TYPE_PRECISION (short_integer_type_node))
15676 return unsignedp ? short_unsigned_type_node : short_integer_type_node;
15678 if (bits == TYPE_PRECISION (long_integer_type_node))
15679 return unsignedp ? long_unsigned_type_node : long_integer_type_node;
15681 if (bits == TYPE_PRECISION (long_long_integer_type_node))
15682 return (unsignedp ? long_long_unsigned_type_node
15683 : long_long_integer_type_node);
15685 for (kt = 0; kt < ARRAY_SIZE (ffecom_tree_type[0]); ++kt)
15687 type_node = ffecom_tree_type[FFEINFO_basictypeINTEGER][kt];
15689 if ((type_node != NULL_TREE) && (bits == TYPE_PRECISION (type_node)))
15690 return unsignedp ? ffecom_tree_type[FFEINFO_basictypeHOLLERITH][kt]
15698 unsigned_type (type)
15701 tree type1 = TYPE_MAIN_VARIANT (type);
15702 ffeinfoKindtype kt;
15705 if (type1 == signed_char_type_node || type1 == char_type_node)
15706 return unsigned_char_type_node;
15707 if (type1 == integer_type_node)
15708 return unsigned_type_node;
15709 if (type1 == short_integer_type_node)
15710 return short_unsigned_type_node;
15711 if (type1 == long_integer_type_node)
15712 return long_unsigned_type_node;
15713 if (type1 == long_long_integer_type_node)
15714 return long_long_unsigned_type_node;
15715 #if 0 /* gcc/c-* files only */
15716 if (type1 == intDI_type_node)
15717 return unsigned_intDI_type_node;
15718 if (type1 == intSI_type_node)
15719 return unsigned_intSI_type_node;
15720 if (type1 == intHI_type_node)
15721 return unsigned_intHI_type_node;
15722 if (type1 == intQI_type_node)
15723 return unsigned_intQI_type_node;
15726 type2 = type_for_size (TYPE_PRECISION (type1), 1);
15727 if (type2 != NULL_TREE)
15730 for (kt = 0; kt < ARRAY_SIZE (ffecom_tree_type[0]); ++kt)
15732 type2 = ffecom_tree_type[FFEINFO_basictypeINTEGER][kt];
15734 if (type1 == type2)
15735 return ffecom_tree_type[FFEINFO_basictypeHOLLERITH][kt];
15741 /* Callback routines for garbage collection. */
15747 union tree_node *t ATTRIBUTE_UNUSED;
15749 if (TREE_CODE (t) == IDENTIFIER_NODE)
15751 struct lang_identifier *i = (struct lang_identifier *) t;
15752 ggc_mark_tree (IDENTIFIER_GLOBAL_VALUE (i));
15753 ggc_mark_tree (IDENTIFIER_LOCAL_VALUE (i));
15754 ggc_mark_tree (IDENTIFIER_LABEL_VALUE (i));
15756 else if (TYPE_P (t) && TYPE_LANG_SPECIFIC (t))
15757 ggc_mark (TYPE_LANG_SPECIFIC (t));
15761 lang_mark_false_label_stack (l)
15762 struct label_node *l;
15764 /* Fortran doesn't use false_label_stack. It better be NULL. */
15769 #endif /* FFECOM_targetCURRENT == FFECOM_targetGCC */
15771 #if FFECOM_GCC_INCLUDE
15773 /* From gcc/cccp.c, the code to handle -I. */
15775 /* Skip leading "./" from a directory name.
15776 This may yield the empty string, which represents the current directory. */
15778 static const char *
15779 skip_redundant_dir_prefix (const char *dir)
15781 while (dir[0] == '.' && dir[1] == '/')
15782 for (dir += 2; *dir == '/'; dir++)
15784 if (dir[0] == '.' && !dir[1])
15789 /* The file_name_map structure holds a mapping of file names for a
15790 particular directory. This mapping is read from the file named
15791 FILE_NAME_MAP_FILE in that directory. Such a file can be used to
15792 map filenames on a file system with severe filename restrictions,
15793 such as DOS. The format of the file name map file is just a series
15794 of lines with two tokens on each line. The first token is the name
15795 to map, and the second token is the actual name to use. */
15797 struct file_name_map
15799 struct file_name_map *map_next;
15804 #define FILE_NAME_MAP_FILE "header.gcc"
15806 /* Current maximum length of directory names in the search path
15807 for include files. (Altered as we get more of them.) */
15809 static int max_include_len = 0;
15811 struct file_name_list
15813 struct file_name_list *next;
15815 /* Mapping of file names for this directory. */
15816 struct file_name_map *name_map;
15817 /* Non-zero if name_map is valid. */
15821 static struct file_name_list *include = NULL; /* First dir to search */
15822 static struct file_name_list *last_include = NULL; /* Last in chain */
15824 /* I/O buffer structure.
15825 The `fname' field is nonzero for source files and #include files
15826 and for the dummy text used for -D and -U.
15827 It is zero for rescanning results of macro expansion
15828 and for expanding macro arguments. */
15829 #define INPUT_STACK_MAX 400
15830 static struct file_buf {
15832 /* Filename specified with #line command. */
15833 const char *nominal_fname;
15834 /* Record where in the search path this file was found.
15835 For #include_next. */
15836 struct file_name_list *dir;
15838 ffewhereColumn column;
15839 } instack[INPUT_STACK_MAX];
15841 static int last_error_tick = 0; /* Incremented each time we print it. */
15842 static int input_file_stack_tick = 0; /* Incremented when status changes. */
15844 /* Current nesting level of input sources.
15845 `instack[indepth]' is the level currently being read. */
15846 static int indepth = -1;
15848 typedef struct file_buf FILE_BUF;
15850 typedef unsigned char U_CHAR;
15852 /* table to tell if char can be part of a C identifier. */
15853 U_CHAR is_idchar[256];
15854 /* table to tell if char can be first char of a c identifier. */
15855 U_CHAR is_idstart[256];
15856 /* table to tell if c is horizontal space. */
15857 U_CHAR is_hor_space[256];
15858 /* table to tell if c is horizontal or vertical space. */
15859 static U_CHAR is_space[256];
15861 #define SKIP_WHITE_SPACE(p) do { while (is_hor_space[*p]) p++; } while (0)
15862 #define SKIP_ALL_WHITE_SPACE(p) do { while (is_space[*p]) p++; } while (0)
15864 /* Nonzero means -I- has been seen,
15865 so don't look for #include "foo" the source-file directory. */
15866 static int ignore_srcdir;
15868 #ifndef INCLUDE_LEN_FUDGE
15869 #define INCLUDE_LEN_FUDGE 0
15872 static void append_include_chain (struct file_name_list *first,
15873 struct file_name_list *last);
15874 static FILE *open_include_file (char *filename,
15875 struct file_name_list *searchptr);
15876 static void print_containing_files (ffebadSeverity sev);
15877 static const char *skip_redundant_dir_prefix (const char *);
15878 static char *read_filename_string (int ch, FILE *f);
15879 static struct file_name_map *read_name_map (const char *dirname);
15881 /* Append a chain of `struct file_name_list's
15882 to the end of the main include chain.
15883 FIRST is the beginning of the chain to append, and LAST is the end. */
15886 append_include_chain (first, last)
15887 struct file_name_list *first, *last;
15889 struct file_name_list *dir;
15891 if (!first || !last)
15897 last_include->next = first;
15899 for (dir = first; ; dir = dir->next) {
15900 int len = strlen (dir->fname) + INCLUDE_LEN_FUDGE;
15901 if (len > max_include_len)
15902 max_include_len = len;
15908 last_include = last;
15911 /* Try to open include file FILENAME. SEARCHPTR is the directory
15912 being tried from the include file search path. This function maps
15913 filenames on file systems based on information read by
15917 open_include_file (filename, searchptr)
15919 struct file_name_list *searchptr;
15921 register struct file_name_map *map;
15922 register char *from;
15925 if (searchptr && ! searchptr->got_name_map)
15927 searchptr->name_map = read_name_map (searchptr->fname
15928 ? searchptr->fname : ".");
15929 searchptr->got_name_map = 1;
15932 /* First check the mapping for the directory we are using. */
15933 if (searchptr && searchptr->name_map)
15936 if (searchptr->fname)
15937 from += strlen (searchptr->fname) + 1;
15938 for (map = searchptr->name_map; map; map = map->map_next)
15940 if (! strcmp (map->map_from, from))
15942 /* Found a match. */
15943 return fopen (map->map_to, "r");
15948 /* Try to find a mapping file for the particular directory we are
15949 looking in. Thus #include <sys/types.h> will look up sys/types.h
15950 in /usr/include/header.gcc and look up types.h in
15951 /usr/include/sys/header.gcc. */
15952 p = rindex (filename, '/');
15953 #ifdef DIR_SEPARATOR
15954 if (! p) p = rindex (filename, DIR_SEPARATOR);
15956 char *tmp = rindex (filename, DIR_SEPARATOR);
15957 if (tmp != NULL && tmp > p) p = tmp;
15963 && searchptr->fname
15964 && strlen (searchptr->fname) == (size_t) (p - filename)
15965 && ! strncmp (searchptr->fname, filename, (int) (p - filename)))
15967 /* FILENAME is in SEARCHPTR, which we've already checked. */
15968 return fopen (filename, "r");
15974 map = read_name_map (".");
15978 dir = (char *) xmalloc (p - filename + 1);
15979 memcpy (dir, filename, p - filename);
15980 dir[p - filename] = '\0';
15982 map = read_name_map (dir);
15985 for (; map; map = map->map_next)
15986 if (! strcmp (map->map_from, from))
15987 return fopen (map->map_to, "r");
15989 return fopen (filename, "r");
15992 /* Print the file names and line numbers of the #include
15993 commands which led to the current file. */
15996 print_containing_files (ffebadSeverity sev)
15998 FILE_BUF *ip = NULL;
16004 /* If stack of files hasn't changed since we last printed
16005 this info, don't repeat it. */
16006 if (last_error_tick == input_file_stack_tick)
16009 for (i = indepth; i >= 0; i--)
16010 if (instack[i].fname != NULL) {
16015 /* Give up if we don't find a source file. */
16019 /* Find the other, outer source files. */
16020 for (i--; i >= 0; i--)
16021 if (instack[i].fname != NULL)
16027 str1 = "In file included";
16039 ffebad_start_msg ("%A from %B at %0%C", sev);
16040 ffebad_here (0, ip->line, ip->column);
16041 ffebad_string (str1);
16042 ffebad_string (ip->nominal_fname);
16043 ffebad_string (str2);
16047 /* Record we have printed the status as of this time. */
16048 last_error_tick = input_file_stack_tick;
16051 /* Read a space delimited string of unlimited length from a stdio
16055 read_filename_string (ch, f)
16063 set = alloc = xmalloc (len + 1);
16064 if (! is_space[ch])
16067 while ((ch = getc (f)) != EOF && ! is_space[ch])
16069 if (set - alloc == len)
16072 alloc = xrealloc (alloc, len + 1);
16073 set = alloc + len / 2;
16083 /* Read the file name map file for DIRNAME. */
16085 static struct file_name_map *
16086 read_name_map (dirname)
16087 const char *dirname;
16089 /* This structure holds a linked list of file name maps, one per
16091 struct file_name_map_list
16093 struct file_name_map_list *map_list_next;
16094 char *map_list_name;
16095 struct file_name_map *map_list_map;
16097 static struct file_name_map_list *map_list;
16098 register struct file_name_map_list *map_list_ptr;
16102 int separator_needed;
16104 dirname = skip_redundant_dir_prefix (dirname);
16106 for (map_list_ptr = map_list; map_list_ptr;
16107 map_list_ptr = map_list_ptr->map_list_next)
16108 if (! strcmp (map_list_ptr->map_list_name, dirname))
16109 return map_list_ptr->map_list_map;
16111 map_list_ptr = ((struct file_name_map_list *)
16112 xmalloc (sizeof (struct file_name_map_list)));
16113 map_list_ptr->map_list_name = xstrdup (dirname);
16114 map_list_ptr->map_list_map = NULL;
16116 dirlen = strlen (dirname);
16117 separator_needed = dirlen != 0 && dirname[dirlen - 1] != '/';
16118 name = (char *) xmalloc (dirlen + strlen (FILE_NAME_MAP_FILE) + 2);
16119 strcpy (name, dirname);
16120 name[dirlen] = '/';
16121 strcpy (name + dirlen + separator_needed, FILE_NAME_MAP_FILE);
16122 f = fopen (name, "r");
16125 map_list_ptr->map_list_map = NULL;
16130 while ((ch = getc (f)) != EOF)
16133 struct file_name_map *ptr;
16137 from = read_filename_string (ch, f);
16138 while ((ch = getc (f)) != EOF && is_hor_space[ch])
16140 to = read_filename_string (ch, f);
16142 ptr = ((struct file_name_map *)
16143 xmalloc (sizeof (struct file_name_map)));
16144 ptr->map_from = from;
16146 /* Make the real filename absolute. */
16151 ptr->map_to = xmalloc (dirlen + strlen (to) + 2);
16152 strcpy (ptr->map_to, dirname);
16153 ptr->map_to[dirlen] = '/';
16154 strcpy (ptr->map_to + dirlen + separator_needed, to);
16158 ptr->map_next = map_list_ptr->map_list_map;
16159 map_list_ptr->map_list_map = ptr;
16161 while ((ch = getc (f)) != '\n')
16168 map_list_ptr->map_list_next = map_list;
16169 map_list = map_list_ptr;
16171 return map_list_ptr->map_list_map;
16175 ffecom_file_ (const char *name)
16179 /* Do partial setup of input buffer for the sake of generating
16180 early #line directives (when -g is in effect). */
16182 fp = &instack[++indepth];
16183 memset ((char *) fp, 0, sizeof (FILE_BUF));
16186 fp->nominal_fname = fp->fname = name;
16189 /* Initialize syntactic classifications of characters. */
16192 ffecom_initialize_char_syntax_ ()
16197 * Set up is_idchar and is_idstart tables. These should be
16198 * faster than saying (is_alpha (c) || c == '_'), etc.
16199 * Set up these things before calling any routines tthat
16202 for (i = 'a'; i <= 'z'; i++) {
16203 is_idchar[i - 'a' + 'A'] = 1;
16205 is_idstart[i - 'a' + 'A'] = 1;
16208 for (i = '0'; i <= '9'; i++)
16210 is_idchar['_'] = 1;
16211 is_idstart['_'] = 1;
16213 /* horizontal space table */
16214 is_hor_space[' '] = 1;
16215 is_hor_space['\t'] = 1;
16216 is_hor_space['\v'] = 1;
16217 is_hor_space['\f'] = 1;
16218 is_hor_space['\r'] = 1;
16221 is_space['\t'] = 1;
16222 is_space['\v'] = 1;
16223 is_space['\f'] = 1;
16224 is_space['\n'] = 1;
16225 is_space['\r'] = 1;
16229 ffecom_close_include_ (FILE *f)
16234 input_file_stack_tick++;
16236 ffewhere_line_kill (instack[indepth].line);
16237 ffewhere_column_kill (instack[indepth].column);
16241 ffecom_decode_include_option_ (char *spec)
16243 struct file_name_list *dirtmp;
16245 if (! ignore_srcdir && !strcmp (spec, "-"))
16249 dirtmp = (struct file_name_list *)
16250 xmalloc (sizeof (struct file_name_list));
16251 dirtmp->next = 0; /* New one goes on the end */
16253 dirtmp->fname = spec;
16255 fatal ("Directory name must immediately follow -I option with no intervening spaces, as in `-Idir', not `-I dir'");
16256 dirtmp->got_name_map = 0;
16257 append_include_chain (dirtmp, dirtmp);
16262 /* Open INCLUDEd file. */
16265 ffecom_open_include_ (char *name, ffewhereLine l, ffewhereColumn c)
16268 size_t flen = strlen (fbeg);
16269 struct file_name_list *search_start = include; /* Chain of dirs to search */
16270 struct file_name_list dsp[1]; /* First in chain, if #include "..." */
16271 struct file_name_list *searchptr = 0;
16272 char *fname; /* Dynamically allocated fname buffer */
16279 dsp[0].fname = NULL;
16281 /* If -I- was specified, don't search current dir, only spec'd ones. */
16282 if (!ignore_srcdir)
16284 for (fp = &instack[indepth]; fp >= instack; fp--)
16290 if ((nam = fp->nominal_fname) != NULL)
16292 /* Found a named file. Figure out dir of the file,
16293 and put it in front of the search list. */
16294 dsp[0].next = search_start;
16295 search_start = dsp;
16297 ep = rindex (nam, '/');
16298 #ifdef DIR_SEPARATOR
16299 if (ep == NULL) ep = rindex (nam, DIR_SEPARATOR);
16301 char *tmp = rindex (nam, DIR_SEPARATOR);
16302 if (tmp != NULL && tmp > ep) ep = tmp;
16306 ep = rindex (nam, ']');
16307 if (ep == NULL) ep = rindex (nam, '>');
16308 if (ep == NULL) ep = rindex (nam, ':');
16309 if (ep != NULL) ep++;
16314 dsp[0].fname = (char *) xmalloc (n + 1);
16315 strncpy (dsp[0].fname, nam, n);
16316 dsp[0].fname[n] = '\0';
16317 if (n + INCLUDE_LEN_FUDGE > max_include_len)
16318 max_include_len = n + INCLUDE_LEN_FUDGE;
16321 dsp[0].fname = NULL; /* Current directory */
16322 dsp[0].got_name_map = 0;
16328 /* Allocate this permanently, because it gets stored in the definitions
16330 fname = xmalloc (max_include_len + flen + 4);
16331 /* + 2 above for slash and terminating null. */
16332 /* + 2 added for '.h' on VMS (to support '#include filename') (NOT USED
16335 /* If specified file name is absolute, just open it. */
16338 #ifdef DIR_SEPARATOR
16339 || *fbeg == DIR_SEPARATOR
16343 strncpy (fname, (char *) fbeg, flen);
16345 f = open_include_file (fname, NULL_PTR);
16351 /* Search directory path, trying to open the file.
16352 Copy each filename tried into FNAME. */
16354 for (searchptr = search_start; searchptr; searchptr = searchptr->next)
16356 if (searchptr->fname)
16358 /* The empty string in a search path is ignored.
16359 This makes it possible to turn off entirely
16360 a standard piece of the list. */
16361 if (searchptr->fname[0] == 0)
16363 strcpy (fname, skip_redundant_dir_prefix (searchptr->fname));
16364 if (fname[0] && fname[strlen (fname) - 1] != '/')
16365 strcat (fname, "/");
16366 fname[strlen (fname) + flen] = 0;
16371 strncat (fname, fbeg, flen);
16373 /* Change this 1/2 Unix 1/2 VMS file specification into a
16374 full VMS file specification */
16375 if (searchptr->fname && (searchptr->fname[0] != 0))
16377 /* Fix up the filename */
16378 hack_vms_include_specification (fname);
16382 /* This is a normal VMS filespec, so use it unchanged. */
16383 strncpy (fname, (char *) fbeg, flen);
16385 #if 0 /* Not for g77. */
16386 /* if it's '#include filename', add the missing .h */
16387 if (index (fname, '.') == NULL)
16388 strcat (fname, ".h");
16392 f = open_include_file (fname, searchptr);
16394 if (f == NULL && errno == EACCES)
16396 print_containing_files (FFEBAD_severityWARNING);
16397 ffebad_start_msg ("At %0, INCLUDE file %A exists, but is not readable",
16398 FFEBAD_severityWARNING);
16399 ffebad_string (fname);
16400 ffebad_here (0, l, c);
16411 /* A file that was not found. */
16413 strncpy (fname, (char *) fbeg, flen);
16415 print_containing_files (ffebad_severity (FFEBAD_OPEN_INCLUDE));
16416 ffebad_start (FFEBAD_OPEN_INCLUDE);
16417 ffebad_here (0, l, c);
16418 ffebad_string (fname);
16422 if (dsp[0].fname != NULL)
16423 free (dsp[0].fname);
16428 if (indepth >= (INPUT_STACK_MAX - 1))
16430 print_containing_files (FFEBAD_severityFATAL);
16431 ffebad_start_msg ("At %0, INCLUDE nesting too deep",
16432 FFEBAD_severityFATAL);
16433 ffebad_string (fname);
16434 ffebad_here (0, l, c);
16439 instack[indepth].line = ffewhere_line_use (l);
16440 instack[indepth].column = ffewhere_column_use (c);
16442 fp = &instack[indepth + 1];
16443 memset ((char *) fp, 0, sizeof (FILE_BUF));
16444 fp->nominal_fname = fp->fname = fname;
16445 fp->dir = searchptr;
16448 input_file_stack_tick++;
16452 #endif /* FFECOM_GCC_INCLUDE */
16454 /**INDENT* (Do not reformat this comment even with -fca option.)
16455 Data-gathering files: Given the source file listed below, compiled with
16456 f2c I obtained the output file listed after that, and from the output
16457 file I derived the above code.
16459 -------- (begin input file to f2c)
16465 double precision D1,D2
16467 call getem(A1,A2,C1,C2,I1,I2,R1,R2,D1,D2)
16494 c FFEINTRIN_impACOS
16495 call fooR(ACOS(R1))
16496 c FFEINTRIN_impAIMAG
16497 call fooR(AIMAG(C1))
16498 c FFEINTRIN_impAINT
16499 call fooR(AINT(R1))
16500 c FFEINTRIN_impALOG
16501 call fooR(ALOG(R1))
16502 c FFEINTRIN_impALOG10
16503 call fooR(ALOG10(R1))
16504 c FFEINTRIN_impAMAX0
16505 call fooR(AMAX0(I1,I2))
16506 c FFEINTRIN_impAMAX1
16507 call fooR(AMAX1(R1,R2))
16508 c FFEINTRIN_impAMIN0
16509 call fooR(AMIN0(I1,I2))
16510 c FFEINTRIN_impAMIN1
16511 call fooR(AMIN1(R1,R2))
16512 c FFEINTRIN_impAMOD
16513 call fooR(AMOD(R1,R2))
16514 c FFEINTRIN_impANINT
16515 call fooR(ANINT(R1))
16516 c FFEINTRIN_impASIN
16517 call fooR(ASIN(R1))
16518 c FFEINTRIN_impATAN
16519 call fooR(ATAN(R1))
16520 c FFEINTRIN_impATAN2
16521 call fooR(ATAN2(R1,R2))
16522 c FFEINTRIN_impCABS
16523 call fooR(CABS(C1))
16524 c FFEINTRIN_impCCOS
16525 call fooC(CCOS(C1))
16526 c FFEINTRIN_impCEXP
16527 call fooC(CEXP(C1))
16528 c FFEINTRIN_impCHAR
16529 call fooA(CHAR(I1))
16530 c FFEINTRIN_impCLOG
16531 call fooC(CLOG(C1))
16532 c FFEINTRIN_impCONJG
16533 call fooC(CONJG(C1))
16536 c FFEINTRIN_impCOSH
16537 call fooR(COSH(R1))
16538 c FFEINTRIN_impCSIN
16539 call fooC(CSIN(C1))
16540 c FFEINTRIN_impCSQRT
16541 call fooC(CSQRT(C1))
16542 c FFEINTRIN_impDABS
16543 call fooD(DABS(D1))
16544 c FFEINTRIN_impDACOS
16545 call fooD(DACOS(D1))
16546 c FFEINTRIN_impDASIN
16547 call fooD(DASIN(D1))
16548 c FFEINTRIN_impDATAN
16549 call fooD(DATAN(D1))
16550 c FFEINTRIN_impDATAN2
16551 call fooD(DATAN2(D1,D2))
16552 c FFEINTRIN_impDCOS
16553 call fooD(DCOS(D1))
16554 c FFEINTRIN_impDCOSH
16555 call fooD(DCOSH(D1))
16556 c FFEINTRIN_impDDIM
16557 call fooD(DDIM(D1,D2))
16558 c FFEINTRIN_impDEXP
16559 call fooD(DEXP(D1))
16561 call fooR(DIM(R1,R2))
16562 c FFEINTRIN_impDINT
16563 call fooD(DINT(D1))
16564 c FFEINTRIN_impDLOG
16565 call fooD(DLOG(D1))
16566 c FFEINTRIN_impDLOG10
16567 call fooD(DLOG10(D1))
16568 c FFEINTRIN_impDMAX1
16569 call fooD(DMAX1(D1,D2))
16570 c FFEINTRIN_impDMIN1
16571 call fooD(DMIN1(D1,D2))
16572 c FFEINTRIN_impDMOD
16573 call fooD(DMOD(D1,D2))
16574 c FFEINTRIN_impDNINT
16575 call fooD(DNINT(D1))
16576 c FFEINTRIN_impDPROD
16577 call fooD(DPROD(R1,R2))
16578 c FFEINTRIN_impDSIGN
16579 call fooD(DSIGN(D1,D2))
16580 c FFEINTRIN_impDSIN
16581 call fooD(DSIN(D1))
16582 c FFEINTRIN_impDSINH
16583 call fooD(DSINH(D1))
16584 c FFEINTRIN_impDSQRT
16585 call fooD(DSQRT(D1))
16586 c FFEINTRIN_impDTAN
16587 call fooD(DTAN(D1))
16588 c FFEINTRIN_impDTANH
16589 call fooD(DTANH(D1))
16592 c FFEINTRIN_impIABS
16593 call fooI(IABS(I1))
16594 c FFEINTRIN_impICHAR
16595 call fooI(ICHAR(A1))
16596 c FFEINTRIN_impIDIM
16597 call fooI(IDIM(I1,I2))
16598 c FFEINTRIN_impIDNINT
16599 call fooI(IDNINT(D1))
16600 c FFEINTRIN_impINDEX
16601 call fooI(INDEX(A1,A2))
16602 c FFEINTRIN_impISIGN
16603 call fooI(ISIGN(I1,I2))
16607 call fooL(LGE(A1,A2))
16609 call fooL(LGT(A1,A2))
16611 call fooL(LLE(A1,A2))
16613 call fooL(LLT(A1,A2))
16614 c FFEINTRIN_impMAX0
16615 call fooI(MAX0(I1,I2))
16616 c FFEINTRIN_impMAX1
16617 call fooI(MAX1(R1,R2))
16618 c FFEINTRIN_impMIN0
16619 call fooI(MIN0(I1,I2))
16620 c FFEINTRIN_impMIN1
16621 call fooI(MIN1(R1,R2))
16623 call fooI(MOD(I1,I2))
16624 c FFEINTRIN_impNINT
16625 call fooI(NINT(R1))
16626 c FFEINTRIN_impSIGN
16627 call fooR(SIGN(R1,R2))
16630 c FFEINTRIN_impSINH
16631 call fooR(SINH(R1))
16632 c FFEINTRIN_impSQRT
16633 call fooR(SQRT(R1))
16636 c FFEINTRIN_impTANH
16637 call fooR(TANH(R1))
16638 c FFEINTRIN_imp_CMPLX_C
16639 call fooC(cmplx(C1,C2))
16640 c FFEINTRIN_imp_CMPLX_D
16641 call fooZ(cmplx(D1,D2))
16642 c FFEINTRIN_imp_CMPLX_I
16643 call fooC(cmplx(I1,I2))
16644 c FFEINTRIN_imp_CMPLX_R
16645 call fooC(cmplx(R1,R2))
16646 c FFEINTRIN_imp_DBLE_C
16647 call fooD(dble(C1))
16648 c FFEINTRIN_imp_DBLE_D
16649 call fooD(dble(D1))
16650 c FFEINTRIN_imp_DBLE_I
16651 call fooD(dble(I1))
16652 c FFEINTRIN_imp_DBLE_R
16653 call fooD(dble(R1))
16654 c FFEINTRIN_imp_INT_C
16656 c FFEINTRIN_imp_INT_D
16658 c FFEINTRIN_imp_INT_I
16660 c FFEINTRIN_imp_INT_R
16662 c FFEINTRIN_imp_REAL_C
16663 call fooR(real(C1))
16664 c FFEINTRIN_imp_REAL_D
16665 call fooR(real(D1))
16666 c FFEINTRIN_imp_REAL_I
16667 call fooR(real(I1))
16668 c FFEINTRIN_imp_REAL_R
16669 call fooR(real(R1))
16671 c FFEINTRIN_imp_INT_D:
16673 c FFEINTRIN_specIDINT
16674 call fooI(IDINT(D1))
16676 c FFEINTRIN_imp_INT_R:
16678 c FFEINTRIN_specIFIX
16679 call fooI(IFIX(R1))
16680 c FFEINTRIN_specINT
16683 c FFEINTRIN_imp_REAL_D:
16685 c FFEINTRIN_specSNGL
16686 call fooR(SNGL(D1))
16688 c FFEINTRIN_imp_REAL_I:
16690 c FFEINTRIN_specFLOAT
16691 call fooR(FLOAT(I1))
16692 c FFEINTRIN_specREAL
16693 call fooR(REAL(I1))
16696 -------- (end input file to f2c)
16698 -------- (begin output from providing above input file as input to:
16699 -------- `f2c | gcc -E -C - | sed -e "s:/[*]*://:g" -e "s:[*]*[/]://:g" \
16700 -------- -e "s:^#.*$::g"')
16702 // -- translated by f2c (version 19950223).
16703 You must link the resulting object file with the libraries:
16704 -lf2c -lm (in that order)
16708 // f2c.h -- Standard Fortran to C header file //
16710 /// barf [ba:rf] 2. "He suggested using FORTRAN, and everybody barfed."
16712 - From The Shogakukan DICTIONARY OF NEW ENGLISH (Second edition) //
16717 // F2C_INTEGER will normally be `int' but would be `long' on 16-bit systems //
16718 // we assume short, float are OK //
16719 typedef long int // long int // integer;
16720 typedef char *address;
16721 typedef short int shortint;
16722 typedef float real;
16723 typedef double doublereal;
16724 typedef struct { real r, i; } complex;
16725 typedef struct { doublereal r, i; } doublecomplex;
16726 typedef long int // long int // logical;
16727 typedef short int shortlogical;
16728 typedef char logical1;
16729 typedef char integer1;
16730 // typedef long long longint; // // system-dependent //
16735 // Extern is for use with -E //
16749 typedef long int // int or long int // flag;
16750 typedef long int // int or long int // ftnlen;
16751 typedef long int // int or long int // ftnint;
16754 //external read, write//
16763 //internal read, write//
16793 //rewind, backspace, endfile//
16805 ftnint *inex; //parameters in standard's order//
16831 union Multitype { // for multiple entry points //
16842 typedef union Multitype Multitype;
16844 typedef long Long; // No longer used; formerly in Namelist //
16846 struct Vardesc { // for Namelist //
16852 typedef struct Vardesc Vardesc;
16859 typedef struct Namelist Namelist;
16868 // procedure parameter types for -A and -C++ //
16873 typedef int // Unknown procedure type // (*U_fp)();
16874 typedef shortint (*J_fp)();
16875 typedef integer (*I_fp)();
16876 typedef real (*R_fp)();
16877 typedef doublereal (*D_fp)(), (*E_fp)();
16878 typedef // Complex // void (*C_fp)();
16879 typedef // Double Complex // void (*Z_fp)();
16880 typedef logical (*L_fp)();
16881 typedef shortlogical (*K_fp)();
16882 typedef // Character // void (*H_fp)();
16883 typedef // Subroutine // int (*S_fp)();
16885 // E_fp is for real functions when -R is not specified //
16886 typedef void C_f; // complex function //
16887 typedef void H_f; // character function //
16888 typedef void Z_f; // double complex function //
16889 typedef doublereal E_f; // real function with -R not specified //
16891 // undef any lower-case symbols that your C compiler predefines, e.g.: //
16894 // (No such symbols should be defined in a strict ANSI C compiler.
16895 We can avoid trouble with f2c-translated code by using
16896 gcc -ansi [-traditional].) //
16920 // Main program // MAIN__()
16922 // System generated locals //
16925 doublereal d__1, d__2;
16927 doublecomplex z__1, z__2, z__3;
16931 // Builtin functions //
16934 double pow_ri(), pow_di();
16938 double acos(), r_imag(), r_int(), log(), r_lg10(), r_mod(), r_nint(),
16939 asin(), atan(), atan2(), c_abs();
16940 void c_cos(), c_exp(), c_log(), r_cnjg();
16941 double cos(), cosh();
16942 void c_sin(), c_sqrt();
16943 double d_dim(), exp(), r_dim(), d_int(), d_lg10(), d_mod(), d_nint(),
16944 d_sign(), sin(), sinh(), sqrt(), tan(), tanh();
16945 integer i_dim(), i_dnnt(), i_indx(), i_sign(), i_len();
16946 logical l_ge(), l_gt(), l_le(), l_lt();
16950 // Local variables //
16951 extern // Subroutine // int fooa_(), fooc_(), food_(), fooi_(), foor_(),
16952 fool_(), fooz_(), getem_();
16953 static char a1[10], a2[10];
16954 static complex c1, c2;
16955 static doublereal d1, d2;
16956 static integer i1, i2;
16957 static real r1, r2;
16960 getem_(a1, a2, &c1, &c2, &i1, &i2, &r1, &r2, &d1, &d2, 10L, 10L);
16968 d__1 = (doublereal) i1;
16969 q__1.r = c1.r / d__1, q__1.i = c1.i / d__1;
16979 c_div(&q__1, &c1, &c2);
16981 q__1.r = c1.r / r1, q__1.i = c1.i / r1;
16983 z__1.r = c1.r / d1, z__1.i = c1.i / d1;
16986 i__1 = pow_ii(&i1, &i2);
16988 r__1 = pow_ri(&r1, &i1);
16990 d__1 = pow_di(&d1, &i1);
16992 pow_ci(&q__1, &c1, &i1);
16994 d__1 = (doublereal) r1;
16995 d__2 = (doublereal) r2;
16996 r__1 = pow_dd(&d__1, &d__2);
16998 d__2 = (doublereal) r1;
16999 d__1 = pow_dd(&d__2, &d1);
17001 d__1 = pow_dd(&d1, &d2);
17003 d__2 = (doublereal) r1;
17004 d__1 = pow_dd(&d1, &d__2);
17006 z__2.r = c1.r, z__2.i = c1.i;
17007 z__3.r = c2.r, z__3.i = c2.i;
17008 pow_zz(&z__1, &z__2, &z__3);
17009 q__1.r = z__1.r, q__1.i = z__1.i;
17011 z__2.r = c1.r, z__2.i = c1.i;
17012 z__3.r = r1, z__3.i = 0.;
17013 pow_zz(&z__1, &z__2, &z__3);
17014 q__1.r = z__1.r, q__1.i = z__1.i;
17016 z__2.r = c1.r, z__2.i = c1.i;
17017 z__3.r = d1, z__3.i = 0.;
17018 pow_zz(&z__1, &z__2, &z__3);
17020 // FFEINTRIN_impABS //
17021 r__1 = (doublereal)(( r1 ) >= 0 ? ( r1 ) : -( r1 )) ;
17023 // FFEINTRIN_impACOS //
17026 // FFEINTRIN_impAIMAG //
17027 r__1 = r_imag(&c1);
17029 // FFEINTRIN_impAINT //
17032 // FFEINTRIN_impALOG //
17035 // FFEINTRIN_impALOG10 //
17036 r__1 = r_lg10(&r1);
17038 // FFEINTRIN_impAMAX0 //
17039 r__1 = (real) (( i1 ) >= ( i2 ) ? ( i1 ) : ( i2 )) ;
17041 // FFEINTRIN_impAMAX1 //
17042 r__1 = (doublereal)(( r1 ) >= ( r2 ) ? ( r1 ) : ( r2 )) ;
17044 // FFEINTRIN_impAMIN0 //
17045 r__1 = (real) (( i1 ) <= ( i2 ) ? ( i1 ) : ( i2 )) ;
17047 // FFEINTRIN_impAMIN1 //
17048 r__1 = (doublereal)(( r1 ) <= ( r2 ) ? ( r1 ) : ( r2 )) ;
17050 // FFEINTRIN_impAMOD //
17051 r__1 = r_mod(&r1, &r2);
17053 // FFEINTRIN_impANINT //
17054 r__1 = r_nint(&r1);
17056 // FFEINTRIN_impASIN //
17059 // FFEINTRIN_impATAN //
17062 // FFEINTRIN_impATAN2 //
17063 r__1 = atan2(r1, r2);
17065 // FFEINTRIN_impCABS //
17068 // FFEINTRIN_impCCOS //
17071 // FFEINTRIN_impCEXP //
17074 // FFEINTRIN_impCHAR //
17075 *(unsigned char *)&ch__1[0] = i1;
17077 // FFEINTRIN_impCLOG //
17080 // FFEINTRIN_impCONJG //
17081 r_cnjg(&q__1, &c1);
17083 // FFEINTRIN_impCOS //
17086 // FFEINTRIN_impCOSH //
17089 // FFEINTRIN_impCSIN //
17092 // FFEINTRIN_impCSQRT //
17093 c_sqrt(&q__1, &c1);
17095 // FFEINTRIN_impDABS //
17096 d__1 = (( d1 ) >= 0 ? ( d1 ) : -( d1 )) ;
17098 // FFEINTRIN_impDACOS //
17101 // FFEINTRIN_impDASIN //
17104 // FFEINTRIN_impDATAN //
17107 // FFEINTRIN_impDATAN2 //
17108 d__1 = atan2(d1, d2);
17110 // FFEINTRIN_impDCOS //
17113 // FFEINTRIN_impDCOSH //
17116 // FFEINTRIN_impDDIM //
17117 d__1 = d_dim(&d1, &d2);
17119 // FFEINTRIN_impDEXP //
17122 // FFEINTRIN_impDIM //
17123 r__1 = r_dim(&r1, &r2);
17125 // FFEINTRIN_impDINT //
17128 // FFEINTRIN_impDLOG //
17131 // FFEINTRIN_impDLOG10 //
17132 d__1 = d_lg10(&d1);
17134 // FFEINTRIN_impDMAX1 //
17135 d__1 = (( d1 ) >= ( d2 ) ? ( d1 ) : ( d2 )) ;
17137 // FFEINTRIN_impDMIN1 //
17138 d__1 = (( d1 ) <= ( d2 ) ? ( d1 ) : ( d2 )) ;
17140 // FFEINTRIN_impDMOD //
17141 d__1 = d_mod(&d1, &d2);
17143 // FFEINTRIN_impDNINT //
17144 d__1 = d_nint(&d1);
17146 // FFEINTRIN_impDPROD //
17147 d__1 = (doublereal) r1 * r2;
17149 // FFEINTRIN_impDSIGN //
17150 d__1 = d_sign(&d1, &d2);
17152 // FFEINTRIN_impDSIN //
17155 // FFEINTRIN_impDSINH //
17158 // FFEINTRIN_impDSQRT //
17161 // FFEINTRIN_impDTAN //
17164 // FFEINTRIN_impDTANH //
17167 // FFEINTRIN_impEXP //
17170 // FFEINTRIN_impIABS //
17171 i__1 = (( i1 ) >= 0 ? ( i1 ) : -( i1 )) ;
17173 // FFEINTRIN_impICHAR //
17174 i__1 = *(unsigned char *)a1;
17176 // FFEINTRIN_impIDIM //
17177 i__1 = i_dim(&i1, &i2);
17179 // FFEINTRIN_impIDNINT //
17180 i__1 = i_dnnt(&d1);
17182 // FFEINTRIN_impINDEX //
17183 i__1 = i_indx(a1, a2, 10L, 10L);
17185 // FFEINTRIN_impISIGN //
17186 i__1 = i_sign(&i1, &i2);
17188 // FFEINTRIN_impLEN //
17189 i__1 = i_len(a1, 10L);
17191 // FFEINTRIN_impLGE //
17192 L__1 = l_ge(a1, a2, 10L, 10L);
17194 // FFEINTRIN_impLGT //
17195 L__1 = l_gt(a1, a2, 10L, 10L);
17197 // FFEINTRIN_impLLE //
17198 L__1 = l_le(a1, a2, 10L, 10L);
17200 // FFEINTRIN_impLLT //
17201 L__1 = l_lt(a1, a2, 10L, 10L);
17203 // FFEINTRIN_impMAX0 //
17204 i__1 = (( i1 ) >= ( i2 ) ? ( i1 ) : ( i2 )) ;
17206 // FFEINTRIN_impMAX1 //
17207 i__1 = (integer) (doublereal)(( r1 ) >= ( r2 ) ? ( r1 ) : ( r2 )) ;
17209 // FFEINTRIN_impMIN0 //
17210 i__1 = (( i1 ) <= ( i2 ) ? ( i1 ) : ( i2 )) ;
17212 // FFEINTRIN_impMIN1 //
17213 i__1 = (integer) (doublereal)(( r1 ) <= ( r2 ) ? ( r1 ) : ( r2 )) ;
17215 // FFEINTRIN_impMOD //
17218 // FFEINTRIN_impNINT //
17219 i__1 = i_nint(&r1);
17221 // FFEINTRIN_impSIGN //
17222 r__1 = r_sign(&r1, &r2);
17224 // FFEINTRIN_impSIN //
17227 // FFEINTRIN_impSINH //
17230 // FFEINTRIN_impSQRT //
17233 // FFEINTRIN_impTAN //
17236 // FFEINTRIN_impTANH //
17239 // FFEINTRIN_imp_CMPLX_C //
17242 q__1.r = r__1, q__1.i = r__2;
17244 // FFEINTRIN_imp_CMPLX_D //
17245 z__1.r = d1, z__1.i = d2;
17247 // FFEINTRIN_imp_CMPLX_I //
17250 q__1.r = r__1, q__1.i = r__2;
17252 // FFEINTRIN_imp_CMPLX_R //
17253 q__1.r = r1, q__1.i = r2;
17255 // FFEINTRIN_imp_DBLE_C //
17256 d__1 = (doublereal) c1.r;
17258 // FFEINTRIN_imp_DBLE_D //
17261 // FFEINTRIN_imp_DBLE_I //
17262 d__1 = (doublereal) i1;
17264 // FFEINTRIN_imp_DBLE_R //
17265 d__1 = (doublereal) r1;
17267 // FFEINTRIN_imp_INT_C //
17268 i__1 = (integer) c1.r;
17270 // FFEINTRIN_imp_INT_D //
17271 i__1 = (integer) d1;
17273 // FFEINTRIN_imp_INT_I //
17276 // FFEINTRIN_imp_INT_R //
17277 i__1 = (integer) r1;
17279 // FFEINTRIN_imp_REAL_C //
17282 // FFEINTRIN_imp_REAL_D //
17285 // FFEINTRIN_imp_REAL_I //
17288 // FFEINTRIN_imp_REAL_R //
17292 // FFEINTRIN_imp_INT_D: //
17294 // FFEINTRIN_specIDINT //
17295 i__1 = (integer) d1;
17298 // FFEINTRIN_imp_INT_R: //
17300 // FFEINTRIN_specIFIX //
17301 i__1 = (integer) r1;
17303 // FFEINTRIN_specINT //
17304 i__1 = (integer) r1;
17307 // FFEINTRIN_imp_REAL_D: //
17309 // FFEINTRIN_specSNGL //
17313 // FFEINTRIN_imp_REAL_I: //
17315 // FFEINTRIN_specFLOAT //
17318 // FFEINTRIN_specREAL //
17324 -------- (end output file from f2c)