| 1 |
(* m2expr.def definition module for m2expr.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" m2expr ; |
| 23 |
|
| 24 |
FROM gcctypes IMPORT location_t, tree ; |
| 25 |
FROM CDataTypes IMPORT CharStar, ConstCharStar ; |
| 26 |
|
| 27 |
|
| 28 |
TYPE |
| 29 |
BuildBinCheckProcedure = PROCEDURE (location_t, tree, tree, tree, tree, tree) : tree ; |
| 30 |
BuildBinProcedure = PROCEDURE (location_t, tree, tree, BOOLEAN) : tree ; |
| 31 |
BuildUnaryProcedure = PROCEDURE (location_t, tree, BOOLEAN) : tree ; |
| 32 |
BuildUnaryCheckProcedure = PROCEDURE (location_t, tree, tree, tree, tree) : tree ; |
| 33 |
BuildExprProcedure = PROCEDURE (location_t, tree, tree) : tree ; |
| 34 |
BuildSetProcedure = PROCEDURE (location_t, tree, tree, tree, tree, BOOLEAN) ; |
| 35 |
BuildUnarySetProcedure = PROCEDURE (location_t, tree, BOOLEAN) ; |
| 36 |
BuildUnarySetFunction = PROCEDURE (location_t, tree, BOOLEAN) : tree ; |
| 37 |
|
| 38 |
|
| 39 |
(* |
| 40 |
init - initialize this module. |
| 41 |
*) |
| 42 |
|
| 43 |
PROCEDURE init (location: location_t) ; |
| 44 |
|
| 45 |
|
| 46 |
(* |
| 47 |
CSTIntToString - return an integer string using base 10 and no padding. |
| 48 |
The string returned will have been mallocd. |
| 49 |
*) |
| 50 |
|
| 51 |
PROCEDURE CSTIntToString (t: tree) : CharStar ; |
| 52 |
|
| 53 |
|
| 54 |
(* |
| 55 |
CSTIntToChar - return the CHAR representation of tree t. |
| 56 |
*) |
| 57 |
|
| 58 |
PROCEDURE CSTIntToChar (t: tree) : CHAR ; |
| 59 |
|
| 60 |
|
| 61 |
PROCEDURE CheckConstStrZtypeRange (location: location_t; |
| 62 |
str: CharStar; base: CARDINAL) : BOOLEAN ; |
| 63 |
|
| 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: CharStar) ; |
| 519 |
|
| 520 |
|
| 521 |
|
| 522 |
PROCEDURE BuildIfNotConstInVar (location: location_t; type: tree; varset: tree; constel: tree; is_lvalue: BOOLEAN; fieldno: INTEGER; label: CharStar) ; |
| 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: CharStar) ; |
| 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: CharStar) ; |
| 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: CharStar) ; |
| 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: CharStar) ; |
| 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: CharStar) ; |
| 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 |
|
| 603 |
(* |
| 604 |
GetCstInteger - return the integer value of the cst tree. |
| 605 |
*) |
| 606 |
|
| 607 |
PROCEDURE GetCstInteger (cst: tree) : INTEGER ; |
| 608 |
|
| 609 |
|
| 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 |
|
| 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 |
|
| 732 |
(* |
| 733 |
OverflowZType - return TRUE if str exceeds the ZTYPE range. |
| 734 |
*) |
| 735 |
|
| 736 |
PROCEDURE OverflowZType (location: location_t; |
| 737 |
str: ConstCharStar; base: CARDINAL; |
| 738 |
issueError: BOOLEAN) : BOOLEAN ; |
| 739 |
|
| 740 |
(* |
| 741 |
BuildCondIfExpression - returns a tree containing |
| 742 |
(condition) ? (left) : right. |
| 743 |
*) |
| 744 |
|
| 745 |
PROCEDURE BuildCondIfExpression (condition, type, left, right: tree) : tree ; |
| 746 |
|
| 747 |
|
| 748 |
(* |
| 749 |
BuildSystemTBitSize - return the minimum number of bits to represent type. |
| 750 |
This function is called when evaluating |
| 751 |
SYSTEM.TBITSIZE. |
| 752 |
*) |
| 753 |
|
| 754 |
PROCEDURE BuildSystemTBitSize (location: location_t; type: tree) : tree ; |
| 755 |
|
| 756 |
|
| 757 |
END m2expr. |