]>
Commit | Line | Data |
---|---|---|
1eee94d3 GM |
1 | (* m2expr.def definition module for m2expr.cc. |
2 | ||
a945c346 | 3 | Copyright (C) 2011-2024 Free Software Foundation, Inc. |
1eee94d3 GM |
4 | Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>. |
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" m2expr ; | |
23 | ||
24 | FROM SYSTEM IMPORT ADDRESS ; | |
25 | FROM m2tree IMPORT Tree ; | |
26 | FROM m2linemap IMPORT location_t ; | |
27 | ||
28 | ||
29 | TYPE | |
30 | BuildBinCheckProcedure = PROCEDURE (location_t, Tree, Tree, Tree, Tree, Tree) : Tree ; | |
31 | BuildBinProcedure = PROCEDURE (location_t, Tree, Tree, BOOLEAN) : Tree ; | |
32 | BuildUnaryProcedure = PROCEDURE (location_t, Tree, BOOLEAN) : Tree ; | |
33 | BuildUnaryCheckProcedure = PROCEDURE (location_t, Tree, Tree, Tree, Tree) : Tree ; | |
34 | BuildExprProcedure = PROCEDURE (location_t, Tree, Tree) : Tree ; | |
35 | BuildSetProcedure = PROCEDURE (location_t, Tree, Tree, Tree, Tree, BOOLEAN) ; | |
36 | BuildUnarySetProcedure = PROCEDURE (location_t, Tree, BOOLEAN) ; | |
37 | BuildUnarySetFunction = PROCEDURE (location_t, Tree, BOOLEAN) : Tree ; | |
38 | ||
39 | ||
40 | (* | |
4e1c5d5f | 41 | init - initialize this module. |
1eee94d3 GM |
42 | *) |
43 | ||
44 | PROCEDURE init (location: location_t) ; | |
45 | ||
46 | ||
4e1c5d5f GM |
47 | (* |
48 | CSTIntToString - return an integer string using base 10 and no padding. | |
49 | The string returned will have been malloc'd. | |
50 | *) | |
51 | ||
52 | PROCEDURE CSTIntToString (t: Tree) : ADDRESS ; | |
53 | ||
54 | (* | |
55 | CSTIntToChar - return the CHAR representation of tree t. | |
56 | *) | |
57 | ||
58 | PROCEDURE CSTIntToChar (t: Tree) : CHAR ; | |
59 | ||
68201409 GM |
60 | |
61 | PROCEDURE CheckConstStrZtypeRange (location: location_t; | |
62 | str: ADDRESS; base: CARDINAL) : BOOLEAN ; | |
63 | ||
1eee94d3 GM |
64 | (* |
65 | CompareTrees - returns -1 if e1 < e2, 0 if e1 == e2, and 1 if e1 > e2. | |
66 | *) | |
67 | ||
68 | PROCEDURE CompareTrees (e1: Tree; e2: Tree) : INTEGER ; | |
69 | ||
70 | ||
71 | PROCEDURE GetPointerOne (location: location_t) : Tree ; | |
72 | ||
73 | ||
74 | PROCEDURE GetPointerZero (location: location_t) : Tree ; | |
75 | ||
76 | ||
77 | PROCEDURE GetWordOne (location: location_t) : Tree ; | |
78 | ||
79 | ||
80 | PROCEDURE GetWordZero (location: location_t) : Tree ; | |
81 | ||
82 | ||
83 | PROCEDURE GetIntegerOne (location: location_t) : Tree ; | |
84 | ||
85 | ||
86 | PROCEDURE GetIntegerZero (location: location_t) : Tree ; | |
87 | ||
88 | ||
89 | PROCEDURE GetCardinalOne (location: location_t) : Tree ; | |
90 | ||
91 | ||
92 | PROCEDURE GetCardinalZero (location: location_t) : Tree ; | |
93 | ||
94 | ||
95 | PROCEDURE GetSizeOfInBits (type: Tree) : Tree ; | |
96 | ||
97 | ||
98 | PROCEDURE GetSizeOf (location: location_t; type: Tree) : Tree ; | |
99 | ||
100 | ||
101 | (* | |
102 | BuildLogicalRotate - builds the ISO Modula-2 ROTATE operator | |
103 | for a fundamental data type. | |
104 | *) | |
105 | ||
106 | PROCEDURE BuildLogicalRotate (location: location_t; op1: Tree; op2: Tree; op3: Tree; nBits: Tree; needconvert: BOOLEAN) ; | |
107 | ||
108 | ||
109 | (* | |
110 | BuildLRRn - builds and returns tree (op1 rotate right by op2 bits) | |
111 | it rotates a set of size, nBits. | |
112 | *) | |
113 | ||
114 | PROCEDURE BuildLRRn (location: location_t; op1: Tree; op2: Tree; nBits: Tree; needconvert: BOOLEAN) : Tree ; | |
115 | ||
116 | ||
117 | (* | |
118 | BuildLRLn - builds and returns tree (op1 rotate left by op2 bits) | |
119 | it rotates a set of size, nBits. | |
120 | *) | |
121 | ||
122 | PROCEDURE BuildLRLn (location: location_t; op1: Tree; op2: Tree; nBits: Tree; needconvert: BOOLEAN) : Tree ; | |
123 | ||
124 | ||
125 | ||
126 | PROCEDURE BuildMask (location: location_t; nBits: Tree; needconvert: BOOLEAN) : Tree ; | |
127 | ||
128 | ||
129 | (* | |
130 | BuildMult - builds a multiplication tree. | |
131 | *) | |
132 | ||
133 | PROCEDURE BuildMult (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; | |
134 | ||
135 | ||
136 | (* | |
137 | BuildMultCheck - builds a multiplication tree after checking for overflow. | |
138 | *) | |
139 | ||
140 | PROCEDURE BuildMultCheck (location: location_t; op1, op2, lowest, min, max: Tree) : Tree ; | |
141 | ||
142 | ||
143 | (* | |
144 | BuildLRR - builds and returns tree (op1 rotate right by op2 bits) | |
145 | *) | |
146 | ||
147 | PROCEDURE BuildLRR (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; | |
148 | ||
149 | ||
150 | (* | |
151 | BuildLRL - builds and returns tree (op1 rotate left by op2 bits) | |
152 | *) | |
153 | ||
154 | PROCEDURE BuildLRL (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; | |
155 | ||
156 | ||
157 | (* | |
158 | BuildLogicalShift - builds the ISO Modula-2 SHIFT operator | |
159 | for a fundamental data type. | |
160 | *) | |
161 | ||
162 | PROCEDURE BuildLogicalShift (location: location_t; op1: Tree; op2: Tree; op3: Tree; nBits: Tree; needconvert: BOOLEAN) ; | |
163 | ||
164 | ||
165 | (* | |
166 | BuildLSR - builds and returns tree (op1 >> op2) | |
167 | *) | |
168 | ||
169 | PROCEDURE BuildLSR (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; | |
170 | ||
171 | ||
172 | (* | |
173 | BuildLSL - builds and returns tree (op1 << op2) | |
174 | *) | |
175 | ||
176 | PROCEDURE BuildLSL (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; | |
177 | ||
178 | ||
179 | (* | |
180 | BuildDivM2 - build and return ((op2 < 0) : (op1 divtrunc op2) ? (op1 divfloor op2)) | |
181 | when -fiso, -fpim4 or -fpositive-mod-floor-div is present else | |
182 | return op1 div trunc op2 | |
183 | *) | |
184 | ||
185 | PROCEDURE BuildDivM2 (location: location_t; op1, op2: Tree; needsconvert: BOOLEAN) : Tree ; | |
186 | ||
187 | ||
188 | (* | |
189 | BuildDivM2Check - build and return ((op2 < 0) : (op1 divtrunc op2) ? (op1 divfloor op2)) | |
190 | when -fiso, -fpim4 or -fpositive-mod-floor-div is present else | |
191 | return op1 div trunc op2. Use the checking div equivalents. | |
192 | *) | |
193 | ||
194 | PROCEDURE BuildDivM2Check (location: location_t; op1, op2, lowest, min, max: Tree) : Tree ; | |
195 | ||
196 | ||
197 | (* | |
198 | BuildModM2 - build and return ((op2 < 0) : (op1 divtrunc op2) ? (op1 divfloor op2)) | |
199 | when -fiso, -fpim4 or -fpositive-mod-floor-div is present else | |
200 | return op1 div trunc op2 | |
201 | *) | |
202 | ||
203 | PROCEDURE BuildModM2 (location: location_t; op1, op2: Tree; needsconvert: BOOLEAN) : Tree ; | |
204 | ||
205 | ||
206 | (* | |
207 | BuildModM2Check - if iso or pim4 then build and return ((op2 < 0) : (op1 | |
208 | modceil op2) ? (op1 modfloor op2)) otherwise use modtrunc. | |
209 | Use the checking mod equivalents. | |
210 | build and return ((op2 < 0) : (op1 divtrunc op2) ? (op1 divfloor op2)) | |
211 | when -fiso, -fpim4 or -fpositive-mod-floor-div is present else | |
212 | return op1 div trunc op2. Use the checking div equivalents. | |
213 | *) | |
214 | ||
215 | PROCEDURE BuildModM2Check (location: location_t; op1, op2, lowest, min, max: Tree) : Tree ; | |
216 | ||
217 | ||
218 | (* | |
219 | BuildModFloor - builds a modulus tree. | |
220 | *) | |
221 | ||
222 | PROCEDURE BuildModFloor (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; | |
223 | ||
224 | ||
225 | (* | |
226 | BuildDivCeil - builds a division tree. | |
227 | *) | |
228 | ||
229 | PROCEDURE BuildDivCeil (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; | |
230 | ||
231 | ||
232 | (* | |
233 | BuildModCeil - builds a modulus tree. | |
234 | *) | |
235 | ||
236 | PROCEDURE BuildModCeil (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; | |
237 | ||
238 | ||
239 | (* | |
240 | BuildDivFloor - builds a division tree. | |
241 | *) | |
242 | ||
243 | PROCEDURE BuildDivFloor (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; | |
244 | ||
245 | ||
246 | (* | |
247 | BuildModTrunc - builds a modulus tree. | |
248 | *) | |
249 | ||
250 | PROCEDURE BuildModTrunc (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; | |
251 | ||
252 | ||
253 | (* | |
254 | BuildDivTrunc - builds a division tree. | |
255 | *) | |
256 | ||
257 | PROCEDURE BuildDivTrunc (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; | |
258 | ||
259 | ||
260 | (* | |
261 | BuildDivTruncCheck - builds a division tree after checking for overflow. | |
262 | *) | |
263 | ||
264 | PROCEDURE BuildDivTruncCheck (location: location_t; op1, op2, lowest, min, max: Tree) : Tree ; | |
265 | ||
266 | ||
267 | (* | |
268 | BuildRDiv - builds a division tree (this should only be used for REAL and COMPLEX | |
269 | types and NEVER for integer based types). | |
270 | *) | |
271 | ||
272 | PROCEDURE BuildRDiv (location: location_t; op1, op2: Tree; needconvert: BOOLEAN) : Tree ; | |
273 | ||
274 | ||
275 | (* | |
276 | BuildSubCheck - builds a subtraction tree after checking for overflow. | |
277 | *) | |
278 | ||
279 | PROCEDURE BuildSubCheck (location: location_t; op1, op2, lowest, min, max: Tree) : Tree ; | |
280 | ||
281 | ||
282 | (* | |
283 | BuildAddCheck - builds an addition tree after checking for overflow. | |
284 | *) | |
285 | ||
286 | PROCEDURE BuildAddCheck (location: location_t; op1, op2, lowest, min, max: Tree) : Tree ; | |
287 | ||
288 | ||
289 | (* | |
290 | BuildSub - builds a subtraction tree. | |
291 | *) | |
292 | ||
293 | PROCEDURE BuildSub (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; | |
294 | ||
295 | ||
296 | (* | |
297 | BuildAdd - builds an addition tree. | |
298 | *) | |
299 | ||
300 | PROCEDURE BuildAdd (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; | |
301 | ||
302 | ||
303 | (* | |
304 | FoldAndStrip - return expression, t, after it has been folded (if possible). | |
305 | *) | |
306 | ||
307 | PROCEDURE FoldAndStrip (t: Tree) : Tree ; | |
308 | ||
309 | ||
310 | (* | |
311 | StringLength - returns an unsigned int which is the length | |
312 | of, string. | |
313 | *) | |
314 | ||
315 | PROCEDURE StringLength (string: Tree) : CARDINAL ; | |
316 | ||
317 | ||
318 | (* | |
319 | TreeOverflow - returns TRUE if the contant expression, t, has | |
320 | caused an overflow. No error message or warning | |
321 | is emitted and no modification is made to, t. | |
322 | *) | |
323 | ||
324 | PROCEDURE TreeOverflow (t: Tree) : BOOLEAN ; | |
325 | ||
326 | ||
327 | (* | |
328 | RemoveOverflow - if tree, t, is a constant expression it removes | |
329 | any overflow flag and returns, t. | |
330 | *) | |
331 | ||
332 | PROCEDURE RemoveOverflow (t: Tree) : Tree ; | |
333 | ||
334 | ||
335 | (* | |
336 | BuildCoerce - returns a tree containing the expression, expr, after | |
337 | it has been coersed to, type. | |
338 | *) | |
339 | ||
340 | PROCEDURE BuildCoerce (location: location_t; des: Tree; type: Tree; expr: Tree) : Tree ; | |
341 | ||
342 | ||
343 | (* | |
344 | BuildTrunc - returns an integer expression from a REAL or LONGREAL op1. | |
345 | *) | |
346 | ||
347 | PROCEDURE BuildTrunc (op1: Tree) : Tree ; | |
348 | ||
349 | ||
350 | (* | |
351 | BuildNegate - builds a negate expression and returns the tree. | |
352 | *) | |
353 | ||
354 | PROCEDURE BuildNegate (location: location_t; op1: Tree; needconvert: BOOLEAN) : Tree ; | |
355 | ||
356 | ||
357 | (* | |
358 | BuildNegateCheck - builds a negate expression and returns the tree. | |
359 | *) | |
360 | ||
361 | PROCEDURE BuildNegateCheck (location: location_t; arg, lowest, min, max: Tree) : Tree ; | |
362 | ||
363 | ||
364 | (* | |
365 | BuildSetNegate - builds a set negate expression and returns the tree. | |
366 | *) | |
367 | ||
368 | PROCEDURE BuildSetNegate (location: location_t; op1: Tree; needconvert: BOOLEAN) : Tree ; | |
369 | ||
370 | ||
371 | (* | |
372 | BuildTBitSize - returns the minimum number of bits to represent, type. | |
373 | *) | |
374 | ||
375 | PROCEDURE BuildTBitSize (location: location_t; type: Tree) : Tree ; | |
376 | ||
377 | ||
378 | (* | |
379 | BuildSize - builds a SIZE function expression and returns the tree. | |
380 | *) | |
381 | ||
382 | PROCEDURE BuildSize (location: location_t; op1: Tree; needconvert: BOOLEAN) : Tree ; | |
383 | ||
384 | ||
385 | (* | |
386 | BuildAddr - builds an expression which calculates the address of | |
387 | op1 and returns the tree. | |
388 | *) | |
389 | ||
390 | PROCEDURE BuildAddr (location: location_t; op1: Tree; needconvert: BOOLEAN) : Tree ; | |
391 | ||
392 | ||
393 | (* | |
394 | BuildOffset1 - builds an expression containing the number of bytes the field | |
395 | is offset from the start of the record structure. | |
396 | This function is the same as the above, except that it | |
397 | derives the record from the field and then calls BuildOffset. | |
398 | The expression is returned. | |
399 | *) | |
400 | ||
401 | PROCEDURE BuildOffset1 (location: location_t; field: Tree; needconvert: BOOLEAN) : Tree ; | |
402 | ||
403 | ||
404 | (* | |
405 | BuildOffset - builds an expression containing the number of bytes the field | |
406 | is offset from the start of the record structure. | |
407 | The expression is returned. | |
408 | *) | |
409 | ||
410 | PROCEDURE BuildOffset (location: location_t; record: Tree; field: Tree; needconvert: BOOLEAN) : Tree ; | |
411 | ||
412 | ||
413 | (* | |
414 | BuildLogicalOrAddress - build a logical or expressions and return the tree. | |
415 | *) | |
416 | ||
417 | PROCEDURE BuildLogicalOrAddress (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; | |
418 | ||
419 | ||
420 | (* | |
421 | BuildLogicalOr - build a logical or expressions and return the tree. | |
422 | *) | |
423 | ||
424 | PROCEDURE BuildLogicalOr (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; | |
425 | ||
426 | ||
427 | (* | |
428 | BuildLogicalAnd - build a logical and expression and return the tree. | |
429 | *) | |
430 | ||
431 | PROCEDURE BuildLogicalAnd (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; | |
432 | ||
433 | ||
434 | ||
435 | PROCEDURE BuildSymmetricDifference (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; | |
436 | ||
437 | ||
438 | (* | |
439 | BuildLogicalDifference - build a logical difference expression and | |
440 | return the tree. | |
441 | (op1 and (not op2)) | |
442 | *) | |
443 | ||
444 | PROCEDURE BuildLogicalDifference (location: location_t; op1: Tree; op2: Tree; needconvert: BOOLEAN) : Tree ; | |
445 | ||
446 | ||
447 | (* | |
448 | BuildLessThan - return a tree which computes < | |
449 | *) | |
450 | ||
451 | PROCEDURE BuildLessThan (location: location_t; op1: Tree; op2: Tree) : Tree ; | |
452 | ||
453 | ||
454 | (* | |
455 | BuildGreaterThan - return a tree which computes > | |
456 | *) | |
457 | ||
458 | PROCEDURE BuildGreaterThan (location: location_t; op1: Tree; op2: Tree) : Tree ; | |
459 | ||
460 | ||
461 | (* | |
462 | BuildLessThanOrEqual - return a tree which computes < | |
463 | *) | |
464 | ||
465 | PROCEDURE BuildLessThanOrEqual (location: location_t; op1: Tree; op2: Tree) : Tree ; | |
466 | ||
467 | ||
468 | (* | |
469 | BuildGreaterThanOrEqual - return a tree which computes >= | |
470 | *) | |
471 | ||
472 | PROCEDURE BuildGreaterThanOrEqual (location: location_t; op1: Tree; op2: Tree) : Tree ; | |
473 | ||
474 | ||
475 | (* | |
476 | BuildEqualTo - return a tree which computes = | |
477 | *) | |
478 | ||
479 | PROCEDURE BuildEqualTo (location: location_t; op1: Tree; op2: Tree) : Tree ; | |
480 | ||
481 | ||
482 | ||
483 | PROCEDURE BuildNotEqualTo (location: location_t; op1: Tree; op2: Tree) : Tree ; | |
484 | ||
485 | ||
486 | (* | |
487 | BuildIsSuperset - return a tree which computes: op1 & op2 == op2 | |
488 | *) | |
489 | ||
490 | PROCEDURE BuildIsSuperset (location: location_t; op1: Tree; op2: Tree) : Tree ; | |
491 | ||
492 | ||
493 | (* | |
494 | BuildIsNotSuperset - return a tree which computes: op1 & op2 != op2 | |
495 | *) | |
496 | ||
497 | PROCEDURE BuildIsNotSuperset (location: location_t; op1: Tree; op2: Tree) : Tree ; | |
498 | ||
499 | ||
500 | (* | |
501 | BuildIsSubset - return a tree which computes: op1 & op2 == op1 | |
502 | *) | |
503 | ||
504 | PROCEDURE BuildIsSubset (location: location_t; op1: Tree; op2: Tree) : Tree ; | |
505 | ||
506 | ||
507 | (* | |
508 | BuildIsNotSubset - return a tree which computes: op1 & op2 != op1 | |
509 | *) | |
510 | ||
511 | PROCEDURE BuildIsNotSubset (location: location_t; op1: Tree; op2: Tree) : Tree ; | |
512 | ||
513 | ||
514 | (* | |
515 | BuildIfConstInVar - generates: if constel in varset then goto label. | |
516 | *) | |
517 | ||
518 | PROCEDURE BuildIfConstInVar (location: location_t; type: Tree; varset: Tree; constel: Tree; is_lvalue: BOOLEAN; fieldno: INTEGER; label: ADDRESS) ; | |
519 | ||
520 | ||
521 | ||
522 | PROCEDURE BuildIfNotConstInVar (location: location_t; type: Tree; varset: Tree; constel: Tree; is_lvalue: BOOLEAN; fieldno: INTEGER; label: ADDRESS) ; | |
523 | ||
524 | ||
525 | (* | |
526 | BuildIfVarInVar - generates: if varel in varset then goto label | |
527 | *) | |
528 | ||
529 | PROCEDURE BuildIfVarInVar (location: location_t; type: Tree; varset: Tree; varel: Tree; is_lvalue: BOOLEAN; low: Tree; high: Tree; label: ADDRESS) ; | |
530 | ||
531 | ||
532 | (* | |
533 | BuildIfNotVarInVar - generates: if not (varel in varset) then goto label | |
534 | *) | |
535 | ||
536 | PROCEDURE BuildIfNotVarInVar (location: location_t; type: Tree; varset: Tree; varel: Tree; is_lvalue: BOOLEAN; low: Tree; high: Tree; label: ADDRESS) ; | |
537 | ||
538 | ||
539 | (* | |
540 | BuildForeachWordInSetDoIfExpr - foreach word in set, type, compute the expression, expr, and if true | |
541 | goto label. | |
542 | *) | |
543 | ||
544 | PROCEDURE BuildForeachWordInSetDoIfExpr (location: location_t; | |
545 | type, op1, op2: Tree; | |
546 | is_op1lvalue, is_op2lvalue, | |
547 | is_op1const, isop2const: BOOLEAN; | |
548 | expr: BuildExprProcedure; label: ADDRESS) ; | |
549 | ||
550 | ||
551 | (* | |
552 | BuildIfInRangeGoto - if var is in the range low..high then goto label | |
553 | *) | |
554 | ||
555 | PROCEDURE BuildIfInRangeGoto (location: location_t; var: Tree; low: Tree; high: Tree; label: ADDRESS) ; | |
556 | ||
557 | ||
558 | (* | |
559 | BuildIfNotInRangeGoto - if var is not in the range low..high then goto label | |
560 | *) | |
561 | ||
562 | PROCEDURE BuildIfNotInRangeGoto (location: location_t; var: Tree; low: Tree; high: Tree; label: ADDRESS) ; | |
563 | ||
564 | ||
565 | (* | |
566 | BuildArray - returns a tree which accesses array[index] | |
567 | given, lowIndice. | |
568 | *) | |
569 | ||
570 | PROCEDURE BuildArray (location: location_t; type: Tree; array: Tree; index: Tree; lowIndice: Tree) : Tree ; | |
571 | ||
572 | ||
573 | (* | |
574 | BuildComponentRef - build a component reference tree which accesses record.field. | |
575 | If field does not belong to record it calls | |
576 | BuildComponentRef on the penultimate field. | |
577 | *) | |
578 | ||
579 | PROCEDURE BuildComponentRef (location: location_t; record: Tree; field: Tree) : Tree ; | |
580 | ||
581 | ||
582 | (* | |
583 | BuildIndirect - build: ( *target) given that the object to be copied is of, type. | |
584 | *) | |
585 | ||
586 | PROCEDURE BuildIndirect (location: location_t; target: Tree; type: Tree) : Tree ; | |
587 | ||
588 | ||
589 | (* | |
590 | IsTrue - returns TRUE if, t, is known to be TRUE. | |
591 | *) | |
592 | ||
593 | PROCEDURE IsTrue (t: Tree) : BOOLEAN ; | |
594 | ||
595 | ||
596 | (* | |
597 | IsFalse - returns FALSE if, t, is known to be FALSE. | |
598 | *) | |
599 | ||
600 | PROCEDURE IsFalse (t: Tree) : BOOLEAN ; | |
601 | ||
602 | ||
a1afdc6e GM |
603 | (* |
604 | GetCstInteger - return the integer value of the cst tree. | |
605 | *) | |
606 | ||
607 | PROCEDURE GetCstInteger (cst: Tree) : INTEGER ; | |
608 | ||
609 | ||
1eee94d3 GM |
610 | (* |
611 | AreConstantsEqual - maps onto tree.c (tree_int_cst_equal). It returns | |
612 | TRUE if the value of e1 is the same as e2. | |
613 | *) | |
614 | ||
615 | PROCEDURE AreConstantsEqual (e1: Tree; e2: Tree) : BOOLEAN ; | |
616 | ||
617 | ||
618 | (* | |
619 | AreRealOrComplexConstantsEqual - returns TRUE if constants, | |
620 | e1 and e2 are equal according | |
621 | to IEEE rules. This does not | |
622 | perform bit equivalence for | |
623 | example IEEE states that | |
624 | -0 == 0 and NaN != NaN. | |
625 | *) | |
626 | ||
627 | PROCEDURE AreRealOrComplexConstantsEqual (e1: Tree; e2: Tree) : BOOLEAN ; | |
628 | ||
629 | ||
630 | (* | |
631 | DetermineSign - returns -1 if e<0 | |
632 | 0 if e==0 | |
633 | 1 if e>0 | |
634 | ||
635 | an unsigned constant will never return -1 | |
636 | *) | |
637 | ||
638 | PROCEDURE DetermineSign (e: Tree) : INTEGER ; | |
639 | ||
640 | ||
641 | (* | |
642 | BuildCap - builds the Modula-2 function CAP(t) and returns | |
643 | the result in a gcc Tree. | |
644 | *) | |
645 | ||
646 | PROCEDURE BuildCap (location: location_t; t: Tree) : Tree ; | |
647 | ||
648 | ||
649 | (* | |
650 | BuildAbs - builds the Modula-2 function ABS(t) and returns | |
651 | the result in a gcc Tree. | |
652 | *) | |
653 | ||
654 | PROCEDURE BuildAbs (location: location_t; t: Tree) : Tree ; | |
655 | ||
656 | ||
657 | (* | |
658 | BuildRe - builds an expression for the function RE. | |
659 | *) | |
660 | ||
661 | PROCEDURE BuildRe (op1: Tree) : Tree ; | |
662 | ||
663 | ||
664 | (* | |
665 | BuildIm - builds an expression for the function IM. | |
666 | *) | |
667 | ||
668 | PROCEDURE BuildIm (op1: Tree) : Tree ; | |
669 | ||
670 | ||
671 | (* | |
672 | BuildCmplx - builds an expression for the function CMPLX. | |
673 | *) | |
674 | ||
675 | PROCEDURE BuildCmplx (location: location_t; type: Tree; real: Tree; imag: Tree) : Tree ; | |
676 | ||
677 | ||
678 | (* | |
679 | BuildBinaryForeachWordDo - provides the large set operators. Each word | |
680 | (or less) of the set can be calculated by binop. | |
681 | This procedure runs along each word of the | |
682 | large set invoking the binop. | |
683 | *) | |
684 | ||
685 | PROCEDURE BuildBinaryForeachWordDo (location: location_t; | |
686 | type, op1, op2, op3: Tree; | |
687 | binop: BuildBinProcedure; | |
688 | is_op1lvalue, | |
689 | is_op2lvalue, | |
690 | is_op3lvalue, | |
691 | is_op1_const, | |
692 | is_op2_const, | |
693 | is_op3_const: BOOLEAN) ; | |
694 | ||
695 | (* | |
696 | BuildBinarySetDo - if the size of the set is <= TSIZE(WORD) then | |
697 | op1 := binop(op2, op3) | |
698 | else | |
699 | call m2rtsprocedure(op1, op2, op3) | |
700 | *) | |
701 | ||
702 | PROCEDURE BuildBinarySetDo (location: location_t; | |
703 | settype, op1, op2, op3: Tree; | |
704 | binop: BuildSetProcedure; | |
705 | is_op1lvalue, is_op2lvalue, is_op3lvalue: BOOLEAN; | |
706 | nBits, unbounded: Tree; | |
707 | varproc, leftproc, rightproc: Tree) ; | |
708 | ||
709 | (* | |
710 | ConstantExpressionWarning - issue a warning if the constant has overflowed. | |
711 | *) | |
712 | ||
713 | PROCEDURE ConstantExpressionWarning (value: Tree) ; | |
714 | ||
715 | ||
716 | (* | |
717 | BuildAddAddress - returns an expression op1+op2 where op1 is a pointer type | |
718 | and op2 is not a pointer type. | |
719 | *) | |
720 | ||
721 | PROCEDURE BuildAddAddress (location: location_t; op1, op2: Tree) : Tree ; | |
722 | ||
723 | ||
2b783fe2 GM |
724 | (* |
725 | calcNbits - return the smallest number of bits required to | |
726 | represent: min..max. | |
727 | *) | |
728 | ||
729 | PROCEDURE calcNbits (location: location_t; min, max: Tree) : Tree ; | |
730 | ||
731 | ||
9693459e GM |
732 | (* |
733 | OverflowZType - return TRUE if str exceeds the ZTYPE range. | |
734 | *) | |
735 | ||
736 | PROCEDURE OverflowZType (location: location_t; | |
737 | str: ADDRESS; base: CARDINAL; | |
738 | issueError: BOOLEAN) : BOOLEAN ; | |
739 | ||
740 | ||
1eee94d3 | 741 | END m2expr. |