Debian Codegraph @

gcc/m2/gm2-gcc/m2statement.def

raw
1 (* m2statement.def definition module for m2statement.cc.
2
3 Copyright (C) 2011-2025 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <[email protected]>.
5
6 This file is part of GNU Modula-2.
7
8 GNU Modula-2 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 3, or (at your option)
11 any later version.
12
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GNU Modula-2; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. *)
21
22 DEFINITION MODULE FOR "C" m2statement ;
23
24 FROM gcctypes IMPORT location_t, tree ;
25 FROM CDataTypes IMPORT CharStar ;
26 FROM m2expr IMPORT BuildUnarySetFunction ;
27
28
29 (*
30 DoJump - jump to the appropriate label depending whether
31 result of the expression is TRUE or FALSE.
32 *)
33
34 PROCEDURE DoJump (location: location_t; exp: tree; falselabel, truelabel: CharStar) ;
35
36
37 (*
38 BuildStartFunctionCode - generate function entry code.
39 *)
40
41 PROCEDURE BuildStartFunctionCode (location: location_t; fndecl: tree; isexported: BOOLEAN; isinline: BOOLEAN) ;
42
43
44 (*
45 BuildEndFunctionCode - generates the function epilogue.
46 *)
47
48 PROCEDURE BuildEndFunctionCode (location: location_t; fndecl: tree; nested: BOOLEAN) ;
49
50
51 (*
52 BuildReturnValueCode - generates the code associated with: RETURN( value )
53 *)
54
55 PROCEDURE BuildReturnValueCode (location: location_t; fndecl: tree; value: tree) ;
56
57
58 (*
59 BuildPushFunctionContext - pushes the current function context.
60 Maps onto push_function_context in ../function.c
61 *)
62
63 PROCEDURE BuildPushFunctionContext ;
64
65
66 (*
67 BuildPopFunctionContext - pops the current function context.
68 Maps onto pop_function_context in ../function.c
69 *)
70
71 PROCEDURE BuildPopFunctionContext ;
72
73
74 (*
75 BuildAssignmentTree - builds the assignment of, des, and, expr.
76 It returns, des.
77 *)
78
79 PROCEDURE BuildAssignmentTree (location: location_t; des, expr: tree) : tree ;
80
81
82 (*
83 BuildAssignmentStatement builds the assignment of, des, and, expr.
84 *)
85
86 PROCEDURE BuildAssignmentStatement (location: location_t; des, expr: tree) ;
87
88
89 (*
90 BuildGoto - builds a goto operation.
91 *)
92
93 PROCEDURE BuildGoto (location: location_t; name: CharStar) ;
94
95
96 (*
97 DeclareLabel - create a label, name.
98 *)
99
100 PROCEDURE DeclareLabel (location: location_t; name: CharStar) ;
101
102
103 (*
104 BuildIfThenDoEnd - returns a tree which will only execute
105 statement, s, if, condition, is true.
106 *)
107
108 PROCEDURE BuildIfThenDoEnd (condition: tree; then_block: tree) : tree ;
109
110
111 (*
112 BuildIfThenElseEnd - returns a tree which will execute
113 then_block or else_block depending upon,
114 condition.
115 *)
116
117 PROCEDURE BuildIfThenElseEnd (condition: tree; then_block: tree; else_block: tree) : tree ;
118
119
120 (*
121 BuildParam - build a list of parameters, ready for a subsequent procedure call.
122 *)
123
124 PROCEDURE BuildParam (location: location_t; param: tree) ;
125
126
127 (*
128 BuildFunctionCallTree - creates a procedure function call from
129 a procedure and parameter list and the
130 return type, rettype. No tree is returned
131 as the tree is held in the last_function
132 global variable. It is expected the
133 BuildFunctValue is to be called after
134 a call to BuildFunctionCallTree.
135 *)
136
137 PROCEDURE BuildFunctionCallTree (location: location_t; procedure: tree; rettype: tree) ;
138
139
140 (*
141 BuildProcedureCallTree - creates a procedure call from a procedure and
142 parameter list and the return type, rettype.
143 *)
144
145 PROCEDURE BuildProcedureCallTree (location: location_t; procedure: tree; rettype: tree) : tree ;
146
147
148 (*
149 BuildIndirectProcedureCallTree - creates a procedure call from a procedure and
150 parameter list and the return type, rettype.
151 *)
152
153 PROCEDURE BuildIndirectProcedureCallTree (location: location_t; procedure: tree; rettype: tree) : tree ;
154
155
156 (*
157 BuildFunctValue - generates code for value := last_function(foobar);
158 *)
159
160 PROCEDURE BuildFunctValue (location: location_t; value: tree) : tree ;
161
162
163 (*
164 BuildCall2 - builds a tree representing: function(arg1, arg2).
165 *)
166
167 PROCEDURE BuildCall2 (location: location_t;
168 function, rettype, arg1, arg2: tree) : tree ;
169
170
171 (*
172 BuildCall3 - builds a tree representing: function(arg1, arg2, arg3).
173 *)
174
175 PROCEDURE BuildCall3 (location: location_t;
176 function, rettype, arg1, arg2, arg3: tree) : tree ;
177
178
179 (*
180 SetLastFunction - set the last_function to, t.
181 *)
182
183 PROCEDURE SetLastFunction (t: tree) ;
184
185
186 (*
187 GetLastFunction - returns, last_function.
188 *)
189
190 PROCEDURE GetLastFunction () : tree ;
191
192
193 (*
194 GetParamTree - return parameter, i.
195 *)
196
197 PROCEDURE GetParamTree (call: tree; i: CARDINAL) : tree ;
198
199
200 (*
201 BuildTryFinally - returns a TRY_FINALL_EXPR with the call and cleanups
202 attached.
203 *)
204
205 PROCEDURE BuildTryFinally (location: location_t; call: tree; cleanups: tree) : tree ;
206
207
208 (*
209 BuildCleanUp - return a CLEANUP_POINT_EXPR which will clobber, param.
210 *)
211
212 PROCEDURE BuildCleanUp (param: tree) : tree ;
213
214
215 (*
216 BuildAsm - generates an inline assembler instruction.
217 *)
218
219 PROCEDURE BuildAsm (location: location_t; instr: tree;
220 isVolatile: BOOLEAN; isSimple: BOOLEAN;
221 inputs: tree; outputs: tree; trash: tree; labels: tree) ;
222
223
224 (*
225 BuildUnaryForeachWordDo - provides the large set operators.
226 Each word (or less) of the set can be
227 calculated by unop.
228 This procedure iterates over each word
229 of the large set invoking the unop.
230 *)
231
232 PROCEDURE BuildUnaryForeachWordDo (location: location_t; type: tree; op1: tree; op2: tree;
233 unop: BuildUnarySetFunction;
234 is_op1lvalue, is_op2lvalue, is_op1const, is_op2const: BOOLEAN) ;
235
236
237 (*
238 BuildExcludeVarConst - builds the EXCL(op1, 1<<op2) operation for a small sets. Large
239 sets call this routine to exclude the bit in the particular word.
240 op2 is a constant.
241 *)
242
243 PROCEDURE BuildExcludeVarConst (location: location_t; type: tree; op1: tree; op2: tree; is_lvalue: BOOLEAN; fieldno: INTEGER) ;
244
245
246 (*
247 BuildExcludeVarVar - builds the EXCL(varset, 1<<varel) operation for a small and large sets.
248 varel is a variable.
249 *)
250
251 PROCEDURE BuildExcludeVarVar (location: location_t; type: tree; varset: tree; varel: tree; is_lvalue: BOOLEAN; low: tree) ;
252
253
254 (*
255 BuildIncludeVarConst - builds the INCL(op1, 1<<op2) operation for a small sets. Large
256 sets call this routine to include the bit in the particular word.
257 op2 is a constant.
258 *)
259
260 PROCEDURE BuildIncludeVarConst (location: location_t; type: tree; op1: tree; op2: tree; is_lvalue: BOOLEAN; fieldno: INTEGER) ;
261
262
263 (*
264 BuildIncludeVarVar - builds the INCL(varset, 1<<varel) operation for a small and large sets.
265 op2 is a variable.
266 *)
267
268 PROCEDURE BuildIncludeVarVar (location: location_t; type: tree; varset: tree; varel: tree; is_lvalue: BOOLEAN; low: tree) ;
269
270
271 (*
272 BuildStart - creates a module initialization function. We make
273 this function public if it is not an inner module.
274 The linker will create a call list for all linked
275 modules which determines the initialization
276 sequence for all modules.
277 *)
278
279 PROCEDURE BuildStart (location: location_t; name: CharStar; inner_module: BOOLEAN) : tree ;
280
281
282 (*
283 BuildEnd - complete the initialisation function for this module.
284 *)
285
286 PROCEDURE BuildEnd (location: location_t; fndecl: tree; nested: BOOLEAN) ;
287
288
289 (*
290 BuildCallInner - call the inner module function. It has no parameters and no return value.
291 *)
292
293 PROCEDURE BuildCallInner (location: location_t; fndecl: tree) ;
294
295
296 (*
297 SetBeginLocation - sets the begin location for the function to obtain good debugging info.
298 *)
299
300 PROCEDURE SetBeginLocation (location: location_t) ;
301
302
303 (*
304 SetEndLocation - sets the end location for the function to obtain good debugging info.
305 *)
306
307 PROCEDURE SetEndLocation (location: location_t) ;
308
309
310 (*
311 BuildBuiltinCallTree - calls the builtin procedure.
312 *)
313
314 PROCEDURE BuildBuiltinCallTree (func: tree) : tree ;
315
316
317 (*
318 CopyByField - copy expr to des, if des is a record, union or an array
319 then check fields for GCC type equivalence and if necessary
320 call __builtin_strncpy and __builtin_memcpy.
321 This can occur if an expr contains a constant string
322 which is to be assigned into a field declared as
323 an ARRAY [0..n] OF CHAR.
324 *)
325
326 PROCEDURE CopyByField (location: location_t; des, expr: tree) ;
327
328
329 END m2statement.