1/* global.h -- Public #include File (module.h template V1.0)
2   Copyright (C) 1995, 1997 Free Software Foundation, Inc.
3   Contributed by James Craig Burley.
4
5This file is part of GNU Fortran.
6
7GNU Fortran is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12GNU Fortran is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU Fortran; see the file COPYING.  If not, write to
19the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
2002111-1307, USA.
21
22   Owning Modules:
23      global.c
24
25   Modifications:
26*/
27
28/* Allow multiple inclusion to work. */
29
30#ifndef _H_f_global
31#define _H_f_global
32
33/* Simple definitions and enumerations. */
34
35typedef enum
36  {
37    FFEGLOBAL_typeNONE,
38    FFEGLOBAL_typeMAIN,
39    FFEGLOBAL_typeEXT,		/* EXTERNAL is all we know. */
40    FFEGLOBAL_typeSUBR,
41    FFEGLOBAL_typeFUNC,
42    FFEGLOBAL_typeBDATA,
43    FFEGLOBAL_typeCOMMON,
44    FFEGLOBAL_typeANY,		/* Confusion reigns, so just ignore. */
45    FFEGLOBAL_type
46  } ffeglobalType;
47
48typedef enum
49  {
50    FFEGLOBAL_argsummaryNONE,	/* No arg present. */
51    FFEGLOBAL_argsummaryVAL,	/* Pass-by-value. */
52    FFEGLOBAL_argsummaryREF,	/* Pass-by-reference. */
53    FFEGLOBAL_argsummaryDESCR,	/* Pass-by-descriptor. */
54    FFEGLOBAL_argsummaryPROC,	/* Procedure (intrinsic, external). */
55    FFEGLOBAL_argsummarySUBR,	/* Subroutine (intrinsic, external). */
56    FFEGLOBAL_argsummaryFUNC,	/* Function (intrinsic, external). */
57    FFEGLOBAL_argsummaryALTRTN,	/* Alternate-return (label). */
58    FFEGLOBAL_argsummaryANY,
59    FFEGLOBAL_argsummary
60  } ffeglobalArgSummary;
61
62/* Typedefs. */
63
64typedef struct _ffeglobal_arginfo_ *ffeglobalArgInfo_;
65typedef struct _ffeglobal_ *ffeglobal;
66
67/* Include files needed by this one. */
68
69#include "info.h"
70#include "lex.h"
71#include "name.h"
72#include "symbol.h"
73#include "target.h"
74#include "top.h"
75
76/* Structure definitions. */
77
78struct _ffeglobal_arginfo_
79{
80  ffelexToken t;	/* Different from master token when difference is important. */
81  char *name;		/* Name of dummy arg, or NULL if not yet known. */
82  ffeglobalArgSummary as;
83  ffeinfoBasictype bt;
84  ffeinfoKindtype kt;
85  bool array;
86};
87
88struct _ffeglobal_
89{
90  ffelexToken t;
91  ffename n;
92#ifdef FFECOM_globalHOOK
93  ffecomGlobal hook;
94#endif
95  ffeCounter tick;		/* Recent transition in this progunit. */
96  ffeglobalType type;
97  bool intrinsic;		/* Known as intrinsic? */
98  bool explicit_intrinsic;	/* Explicit intrinsic? */
99  union {
100    struct {
101      ffelexToken initt;	/* First initial value. */
102      bool have_pad;		/* Padding info avail for COMMON? */
103      ffetargetAlign pad;	/* Initial padding for COMMON. */
104      ffewhereLine pad_where_line;
105      ffewhereColumn pad_where_col;
106      bool have_save;		/* Save info avail for COMMON? */
107      bool save;		/* Save info for COMMON. */
108      ffewhereLine save_where_line;
109      ffewhereColumn save_where_col;
110      bool have_size;		/* Size info avail for COMMON? */
111      ffetargetOffset size;	/* Size info for COMMON. */
112      bool blank;		/* TRUE if blank COMMON. */
113    } common;
114    struct {
115      bool defined;		/* Seen actual code yet? */
116      ffeinfoBasictype bt;	/* NONE for non-function. */
117      ffeinfoKindtype kt;	/* NONE for non-function. */
118      ffetargetCharacterSize sz;
119      int n_args;		/* 0 for main/blockdata. */
120      ffelexToken other_t;	/* Location of reference. */
121      ffeglobalArgInfo_ arg_info;	/* Info on each argument. */
122    } proc;
123  } u;
124};
125
126/* Global objects accessed by users of this module. */
127
128
129/* Declare functions with prototypes. */
130
131void ffeglobal_drive (ffeglobal (*fn) (ffeglobal));
132void ffeglobal_init_1 (void);
133void ffeglobal_init_common (ffesymbol s, ffelexToken t);
134void ffeglobal_new_progunit_ (ffesymbol s, ffelexToken t, ffeglobalType type);
135void ffeglobal_new_common (ffesymbol s, ffelexToken t, bool blank);
136void ffeglobal_pad_common (ffesymbol s, ffetargetAlign pad, ffewhereLine wl,
137			   ffewhereColumn wc);
138void ffeglobal_proc_def_arg (ffesymbol s, int argno, const char *name, ffeglobalArgSummary as,
139			     ffeinfoBasictype bt, ffeinfoKindtype kt,
140			     bool array);
141void ffeglobal_proc_def_nargs (ffesymbol s, int n_args);
142bool ffeglobal_proc_ref_arg (ffesymbol s, int argno, ffeglobalArgSummary as,
143			     ffeinfoBasictype bt, ffeinfoKindtype kt,
144			     bool array, ffelexToken t);
145bool ffeglobal_proc_ref_nargs (ffesymbol s, int n_args, ffelexToken t);
146ffeglobal ffeglobal_promoted (ffesymbol s);
147void ffeglobal_ref_intrinsic (ffesymbol s, ffelexToken t, bool explicit);
148bool ffeglobal_ref_progunit_ (ffesymbol s, ffelexToken t, ffeglobalType type);
149void ffeglobal_save_common (ffesymbol s, bool save, ffewhereLine wl,
150			    ffewhereColumn wc);
151bool ffeglobal_size_common (ffesymbol s, ffetargetOffset size);
152void ffeglobal_terminate_1 (void);
153
154/* Define macros. */
155
156#if FFECOM_targetCURRENT == FFECOM_targetFFE
157#define FFEGLOBAL_ENABLED 0
158#elif FFECOM_targetCURRENT == FFECOM_targetGCC
159#define FFEGLOBAL_ENABLED 1
160#else
161#error
162#endif
163
164#define ffeglobal_common_init(g) ((g)->tick != 0)
165#define ffeglobal_common_have_pad(g) ((g)->u.common.have_pad)
166#define ffeglobal_common_have_size(g) ((g)->u.common.have_size)
167#define ffeglobal_common_pad(g) ((g)->u.common.pad)
168#define ffeglobal_common_size(g) ((g)->u.common.size)
169#define ffeglobal_hook(g) ((g)->hook)
170#define ffeglobal_init_0()
171#define ffeglobal_init_2()
172#define ffeglobal_init_3()
173#define ffeglobal_init_4()
174#define ffeglobal_new_blockdata(s,t) \
175      ffeglobal_new_progunit_(s,t,FFEGLOBAL_typeBDATA)
176#define ffeglobal_new_function(s,t) \
177      ffeglobal_new_progunit_(s,t,FFEGLOBAL_typeFUNC)
178#define ffeglobal_new_program(s,t) \
179      ffeglobal_new_progunit_(s,t,FFEGLOBAL_typeMAIN)
180#define ffeglobal_new_subroutine(s,t) \
181      ffeglobal_new_progunit_(s,t,FFEGLOBAL_typeSUBR)
182#define ffeglobal_ref_blockdata(s,t) \
183      ffeglobal_ref_progunit_(s,t,FFEGLOBAL_typeBDATA)
184#define ffeglobal_ref_external(s,t) \
185      ffeglobal_ref_progunit_(s,t,FFEGLOBAL_typeEXT)
186#define ffeglobal_ref_function(s,t) \
187      ffeglobal_ref_progunit_(s,t,FFEGLOBAL_typeFUNC)
188#define ffeglobal_ref_subroutine(s,t) \
189      ffeglobal_ref_progunit_(s,t,FFEGLOBAL_typeSUBR)
190#define ffeglobal_set_hook(g,h) ((g)->hook = (h))
191#define ffeglobal_terminate_0()
192#define ffeglobal_terminate_2()
193#define ffeglobal_terminate_3()
194#define ffeglobal_terminate_4()
195#define ffeglobal_text(g) ffename_text((g)->n)
196#define ffeglobal_type(g) ((g)->type)
197
198/* End of #include file. */
199
200#endif
201