1 /* global.h -- Public #include File (module.h template V1.0)
2    Copyright (C) 1995, 1997, 2003 Free Software Foundation, Inc.
3    Contributed by James Craig Burley.
4 
5 This file is part of GNU Fortran.
6 
7 GNU Fortran is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11 
12 GNU Fortran is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with GNU Fortran; see the file COPYING.  If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA.
21 
22    Owning Modules:
23       global.c
24 
25    Modifications:
26 */
27 
28 /* Allow multiple inclusion to work. */
29 
30 #ifndef GCC_F_GLOBAL_H
31 #define GCC_F_GLOBAL_H
32 
33 /* Simple definitions and enumerations. */
34 
35 typedef 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 
48 typedef 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 
64 typedef struct _ffeglobal_arginfo_ *ffeglobalArgInfo_;
65 typedef 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 
78 struct _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 
88 struct _ffeglobal_
89 {
90   ffelexToken t;
91   ffename n;
92   ffecomGlobal hook;
93   ffeCounter tick;		/* Recent transition in this progunit. */
94   ffeglobalType type;
95   bool intrinsic;		/* Known as intrinsic? */
96   bool explicit_intrinsic;	/* Explicit intrinsic? */
97   union {
98     struct {
99       ffelexToken initt;	/* First initial value. */
100       bool have_pad;		/* Padding info avail for COMMON? */
101       ffetargetAlign pad;	/* Initial padding for COMMON. */
102       ffewhereLine pad_where_line;
103       ffewhereColumn pad_where_col;
104       bool have_save;		/* Save info avail for COMMON? */
105       bool save;		/* Save info for COMMON. */
106       ffewhereLine save_where_line;
107       ffewhereColumn save_where_col;
108       bool have_size;		/* Size info avail for COMMON? */
109       ffetargetOffset size;	/* Size info for COMMON. */
110       bool blank;		/* TRUE if blank COMMON. */
111     } common;
112     struct {
113       bool defined;		/* Seen actual code yet? */
114       ffeinfoBasictype bt;	/* NONE for non-function. */
115       ffeinfoKindtype kt;	/* NONE for non-function. */
116       ffetargetCharacterSize sz;
117       int n_args;		/* 0 for main/blockdata. */
118       ffelexToken other_t;	/* Location of reference. */
119       ffeglobalArgInfo_ arg_info;	/* Info on each argument. */
120     } proc;
121   } u;
122 };
123 
124 /* Global objects accessed by users of this module. */
125 
126 
127 /* Declare functions with prototypes. */
128 
129 void ffeglobal_drive (ffeglobal (*fn) (ffeglobal));
130 void ffeglobal_init_1 (void);
131 void ffeglobal_init_common (ffesymbol s, ffelexToken t);
132 void ffeglobal_new_progunit_ (ffesymbol s, ffelexToken t, ffeglobalType type);
133 void ffeglobal_new_common (ffesymbol s, ffelexToken t, bool blank);
134 void ffeglobal_pad_common (ffesymbol s, ffetargetAlign pad, ffewhereLine wl,
135 			   ffewhereColumn wc);
136 void ffeglobal_proc_def_arg (ffesymbol s, int argno, const char *name, ffeglobalArgSummary as,
137 			     ffeinfoBasictype bt, ffeinfoKindtype kt,
138 			     bool array);
139 void ffeglobal_proc_def_nargs (ffesymbol s, int n_args);
140 bool ffeglobal_proc_ref_arg (ffesymbol s, int argno, ffeglobalArgSummary as,
141 			     ffeinfoBasictype bt, ffeinfoKindtype kt,
142 			     bool array, ffelexToken t);
143 bool ffeglobal_proc_ref_nargs (ffesymbol s, int n_args, ffelexToken t);
144 ffeglobal ffeglobal_promoted (ffesymbol s);
145 void ffeglobal_ref_intrinsic (ffesymbol s, ffelexToken t, bool explicit);
146 bool ffeglobal_ref_progunit_ (ffesymbol s, ffelexToken t, ffeglobalType type);
147 void ffeglobal_save_common (ffesymbol s, bool save, ffewhereLine wl,
148 			    ffewhereColumn wc);
149 bool ffeglobal_size_common (ffesymbol s, ffetargetOffset size);
150 void ffeglobal_terminate_1 (void);
151 
152 /* Define macros. */
153 
154 #define FFEGLOBAL_ENABLED 1
155 
156 #define ffeglobal_common_init(g) ((g)->tick != 0)
157 #define ffeglobal_common_have_pad(g) ((g)->u.common.have_pad)
158 #define ffeglobal_common_have_size(g) ((g)->u.common.have_size)
159 #define ffeglobal_common_pad(g) ((g)->u.common.pad)
160 #define ffeglobal_common_size(g) ((g)->u.common.size)
161 #define ffeglobal_hook(g) ((g)->hook)
162 #define ffeglobal_init_0()
163 #define ffeglobal_init_2()
164 #define ffeglobal_init_3()
165 #define ffeglobal_init_4()
166 #define ffeglobal_new_blockdata(s,t) \
167       ffeglobal_new_progunit_(s,t,FFEGLOBAL_typeBDATA)
168 #define ffeglobal_new_function(s,t) \
169       ffeglobal_new_progunit_(s,t,FFEGLOBAL_typeFUNC)
170 #define ffeglobal_new_program(s,t) \
171       ffeglobal_new_progunit_(s,t,FFEGLOBAL_typeMAIN)
172 #define ffeglobal_new_subroutine(s,t) \
173       ffeglobal_new_progunit_(s,t,FFEGLOBAL_typeSUBR)
174 #define ffeglobal_ref_blockdata(s,t) \
175       ffeglobal_ref_progunit_(s,t,FFEGLOBAL_typeBDATA)
176 #define ffeglobal_ref_external(s,t) \
177       ffeglobal_ref_progunit_(s,t,FFEGLOBAL_typeEXT)
178 #define ffeglobal_ref_function(s,t) \
179       ffeglobal_ref_progunit_(s,t,FFEGLOBAL_typeFUNC)
180 #define ffeglobal_ref_subroutine(s,t) \
181       ffeglobal_ref_progunit_(s,t,FFEGLOBAL_typeSUBR)
182 #define ffeglobal_set_hook(g,h) ((g)->hook = (h))
183 #define ffeglobal_terminate_0()
184 #define ffeglobal_terminate_2()
185 #define ffeglobal_terminate_3()
186 #define ffeglobal_terminate_4()
187 #define ffeglobal_text(g) ffename_text((g)->n)
188 #define ffeglobal_type(g) ((g)->type)
189 
190 /* End of #include file. */
191 
192 #endif /* ! GCC_F_GLOBAL_H */
193 
194