| 1 |
/* m2expr.h header file for m2expr.cc. |
| 2 |
|
| 3 |
Copyright (C) 2012-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 |
#if !defined(m2expr_h) |
| 23 |
#define m2expr_h |
| 24 |
#if defined(m2expr_c) |
| 25 |
#if defined(__GNUG__) |
| 26 |
#define EXTERN extern "C" |
| 27 |
#else /* !__GNUG__. */ |
| 28 |
#define EXTERN |
| 29 |
#endif /* !__GNUG__. */ |
| 30 |
#else /* !m2expr_c. */ |
| 31 |
#if defined(__GNUG__) |
| 32 |
#define EXTERN extern "C" |
| 33 |
#else /* !__GNUG__. */ |
| 34 |
#define EXTERN extern |
| 35 |
#endif /* !__GNUG__. */ |
| 36 |
#endif /* !m2expr_c. */ |
| 37 |
|
| 38 |
|
| 39 |
EXTERN char m2expr_CSTIntToChar (tree t); |
| 40 |
EXTERN char *m2expr_CSTIntToString (tree t); |
| 41 |
EXTERN bool m2expr_StrToWideInt (location_t location, const char *str, unsigned int base, |
| 42 |
widest_int &wval, bool issueError); |
| 43 |
EXTERN void m2expr_BuildBinaryForeachWordDo ( |
| 44 |
location_t location, tree type, tree op1, tree op2, tree op3, |
| 45 |
tree (*binop) (location_t, tree, tree, bool), bool is_op1lvalue, |
| 46 |
bool is_op2lvalue, bool is_op3lvalue, bool is_op1const, bool is_op2const, |
| 47 |
bool is_op3const); |
| 48 |
EXTERN tree m2expr_BuildCmplx (location_t location, tree type, tree real, |
| 49 |
tree imag); |
| 50 |
EXTERN tree m2expr_BuildIm (tree op1); |
| 51 |
EXTERN tree m2expr_BuildRe (tree op1); |
| 52 |
EXTERN tree m2expr_BuildAbs (location_t location, tree t); |
| 53 |
EXTERN tree m2expr_BuildCap (location_t location, tree t); |
| 54 |
EXTERN int m2expr_DetermineSign (tree e); |
| 55 |
EXTERN bool m2expr_AreRealOrComplexConstantsEqual (tree e1, tree e2); |
| 56 |
EXTERN bool m2expr_AreConstantsEqual (tree e1, tree e2); |
| 57 |
EXTERN bool m2expr_IsFalse (tree t); |
| 58 |
EXTERN bool m2expr_IsTrue (tree t); |
| 59 |
EXTERN tree m2expr_BuildIndirect (location_t location, tree target, tree type); |
| 60 |
EXTERN tree m2expr_BuildComponentRef (location_t location, tree record, |
| 61 |
tree field); |
| 62 |
EXTERN tree m2expr_BuildArray (location_t location, tree type, tree array, |
| 63 |
tree index, tree lowIndice); |
| 64 |
EXTERN void m2expr_BuildIfNotInRangeGoto (location_t location, tree var, |
| 65 |
tree low, tree high, char *label); |
| 66 |
EXTERN void m2expr_BuildIfInRangeGoto (location_t location, tree var, tree low, |
| 67 |
tree high, char *label); |
| 68 |
EXTERN void m2expr_BuildForeachWordInSetDoIfExpr ( |
| 69 |
location_t location, tree type, tree op1, tree op2, bool is_op1lvalue, |
| 70 |
bool is_op2lvalue, bool is_op1const, bool is_op2const, |
| 71 |
tree (*expr) (location_t, tree, tree), char *label); |
| 72 |
EXTERN void m2expr_BuildIfNotVarInVar (location_t location, tree type, |
| 73 |
tree varset, tree varel, bool is_lvalue, |
| 74 |
tree low, tree high ATTRIBUTE_UNUSED, |
| 75 |
char *label); |
| 76 |
EXTERN void m2expr_BuildIfVarInVar (location_t location, tree type, |
| 77 |
tree varset, tree varel, bool is_lvalue, |
| 78 |
tree low, tree high ATTRIBUTE_UNUSED, |
| 79 |
char *label); |
| 80 |
EXTERN void m2expr_BuildIfNotConstInVar (location_t location, tree type, |
| 81 |
tree varset, tree constel, |
| 82 |
bool is_lvalue, int fieldno, |
| 83 |
char *label); |
| 84 |
EXTERN void m2expr_BuildIfConstInVar (location_t location, tree type, |
| 85 |
tree varset, tree constel, bool is_lvalue, |
| 86 |
int fieldno, char *label); |
| 87 |
EXTERN tree m2expr_BuildIsNotSubset (location_t location, tree op1, tree op2); |
| 88 |
EXTERN tree m2expr_BuildIsSubset (location_t location, tree op1, tree op2); |
| 89 |
EXTERN tree m2expr_BuildIsNotSuperset (location_t location, tree op1, |
| 90 |
tree op2); |
| 91 |
EXTERN tree m2expr_BuildIsSuperset (location_t location, tree op1, tree op2); |
| 92 |
EXTERN tree m2expr_BuildNotEqualTo (location_t location, tree op1, tree op2); |
| 93 |
EXTERN tree m2expr_BuildEqualTo (location_t location, tree op1, tree op2); |
| 94 |
EXTERN tree m2expr_BuildGreaterThanOrEqual (location_t location, tree op1, |
| 95 |
tree op2); |
| 96 |
EXTERN tree m2expr_BuildLessThanOrEqual (location_t location, tree op1, |
| 97 |
tree op2); |
| 98 |
EXTERN tree m2expr_BuildGreaterThan (location_t location, tree op1, tree op2); |
| 99 |
EXTERN tree m2expr_BuildLessThan (location_t location, tree op1, tree op2); |
| 100 |
EXTERN tree m2expr_BuildLogicalDifference (location_t location, tree op1, |
| 101 |
tree op2, bool needconvert); |
| 102 |
EXTERN tree m2expr_BuildSymmetricDifference (location_t location, tree op1, |
| 103 |
tree op2, bool needconvert); |
| 104 |
EXTERN tree m2expr_BuildLogicalAnd (location_t location, tree op1, tree op2, |
| 105 |
bool needconvert); |
| 106 |
EXTERN tree m2expr_BuildLogicalOr (location_t location, tree op1, tree op2, |
| 107 |
bool needconvert); |
| 108 |
EXTERN tree m2expr_BuildLogicalOrAddress (location_t location, tree op1, |
| 109 |
tree op2, bool needconvert); |
| 110 |
EXTERN tree m2expr_BuildOffset (location_t location, tree record, tree field, |
| 111 |
bool needconvert ATTRIBUTE_UNUSED); |
| 112 |
EXTERN tree m2expr_BuildOffset1 (location_t location, tree field, |
| 113 |
bool needconvert ATTRIBUTE_UNUSED); |
| 114 |
EXTERN tree m2expr_BuildAddr (location_t location, tree op1, bool needconvert); |
| 115 |
EXTERN tree m2expr_BuildSize (location_t location, tree op1, |
| 116 |
bool needconvert ATTRIBUTE_UNUSED); |
| 117 |
EXTERN tree m2expr_BuildTBitSize (location_t location, tree type); |
| 118 |
EXTERN tree m2expr_BuildSetNegate (location_t location, tree op1, |
| 119 |
bool needconvert); |
| 120 |
EXTERN tree m2expr_BuildNegate (location_t location, tree op1, |
| 121 |
bool needconvert); |
| 122 |
EXTERN tree m2expr_BuildNegateCheck (location_t location, tree arg, |
| 123 |
tree lowest, tree min, tree max); |
| 124 |
EXTERN tree m2expr_BuildTrunc (tree op1); |
| 125 |
EXTERN tree m2expr_BuildCoerce (location_t location, tree des, tree type, |
| 126 |
tree expr); |
| 127 |
EXTERN tree m2expr_RemoveOverflow (tree t); |
| 128 |
EXTERN bool m2expr_TreeOverflow (tree t); |
| 129 |
|
| 130 |
EXTERN unsigned int m2expr_StringLength (tree string); |
| 131 |
EXTERN tree m2expr_FoldAndStrip (tree t); |
| 132 |
EXTERN int m2expr_interpret_integer (location_t location, |
| 133 |
const char *str, unsigned int base, |
| 134 |
unsigned HOST_WIDE_INT *low, |
| 135 |
HOST_WIDE_INT *high); |
| 136 |
EXTERN int m2expr_interpret_m2_integer (location_t location, |
| 137 |
const char *str, unsigned int base, |
| 138 |
unsigned int *low, int *high, |
| 139 |
bool *needsLong, bool *needsUnsigned); |
| 140 |
|
| 141 |
EXTERN tree m2expr_BuildAddCheck (location_t location, tree op1, tree op2, |
| 142 |
tree lowest, tree min, tree max); |
| 143 |
EXTERN tree m2expr_BuildSubCheck (location_t location, tree op1, tree op2, |
| 144 |
tree lowest, tree min, tree max); |
| 145 |
EXTERN tree m2expr_BuildMultCheck (location_t location, tree op1, tree op2, |
| 146 |
tree lowest, tree min, tree max); |
| 147 |
|
| 148 |
EXTERN tree m2expr_BuildAdd (location_t location, tree op1, tree op2, |
| 149 |
bool needconvert); |
| 150 |
EXTERN tree m2expr_BuildSub (location_t location, tree op1, tree op2, |
| 151 |
bool needconvert); |
| 152 |
EXTERN tree m2expr_BuildDivTrunc (location_t location, tree op1, tree op2, |
| 153 |
bool needconvert); |
| 154 |
EXTERN tree m2expr_BuildDivTruncCheck (location_t location, tree op1, tree op2, |
| 155 |
tree lowest, tree min, tree max); |
| 156 |
EXTERN tree m2expr_BuildModTrunc (location_t location, tree op1, tree op2, |
| 157 |
bool needconvert); |
| 158 |
|
| 159 |
EXTERN tree m2expr_BuildDivCeil (location_t location, tree op1, tree op2, |
| 160 |
bool needconvert); |
| 161 |
EXTERN tree m2expr_BuildModCeil (location_t location, tree op1, tree op2, |
| 162 |
bool needconvert); |
| 163 |
|
| 164 |
EXTERN tree m2expr_BuildDivFloor (location_t location, tree op1, tree op2, |
| 165 |
bool needconvert); |
| 166 |
EXTERN tree m2expr_BuildModFloor (location_t location, tree op1, tree op2, |
| 167 |
bool needconvert); |
| 168 |
|
| 169 |
EXTERN tree m2expr_BuildDivM2 (location_t location, tree op1, tree op2, |
| 170 |
bool needsconvert); |
| 171 |
EXTERN tree m2expr_BuildModM2 (location_t location, tree op1, tree op2, |
| 172 |
bool needsconvert); |
| 173 |
EXTERN tree m2expr_BuildDivM2Check (location_t location, tree op1, tree op2, |
| 174 |
tree lowest, tree min, tree max); |
| 175 |
|
| 176 |
EXTERN tree m2expr_BuildModM2Check (location_t location, tree op1, tree op2, |
| 177 |
tree lowest, tree min, tree max); |
| 178 |
|
| 179 |
EXTERN tree m2expr_BuildLSL (location_t location, tree op1, tree op2, |
| 180 |
bool needconvert); |
| 181 |
|
| 182 |
EXTERN tree m2expr_BuildLSR (location_t location, tree op1, tree op2, |
| 183 |
bool needconvert); |
| 184 |
|
| 185 |
EXTERN void m2expr_BuildLogicalShift (location_t location, tree op1, tree op2, |
| 186 |
tree op3, tree nBits ATTRIBUTE_UNUSED, |
| 187 |
bool needconvert); |
| 188 |
|
| 189 |
EXTERN tree m2expr_BuildLRL (location_t location, tree op1, tree op2, |
| 190 |
bool needconvert); |
| 191 |
|
| 192 |
EXTERN tree m2expr_BuildLRR (location_t location, tree op1, tree op2, |
| 193 |
bool needconvert); |
| 194 |
EXTERN tree m2expr_BuildMult (location_t location, tree op1, tree op2, |
| 195 |
bool needconvert); |
| 196 |
|
| 197 |
EXTERN tree m2expr_BuildRRotate (location_t location, tree op1, tree nBits, |
| 198 |
bool needconvert); |
| 199 |
EXTERN tree m2expr_BuildLRotate (location_t location, tree op1, tree nBits, |
| 200 |
bool needconvert); |
| 201 |
|
| 202 |
EXTERN tree m2expr_BuildMask (location_t location, tree nBits, |
| 203 |
bool needconvert); |
| 204 |
EXTERN tree m2expr_BuildLRLn (location_t location, tree op1, tree op2, |
| 205 |
tree nBits, bool needconvert); |
| 206 |
EXTERN tree m2expr_BuildLRRn (location_t location, tree op1, tree op2, |
| 207 |
tree nBits, bool needconvert); |
| 208 |
EXTERN void m2expr_BuildLogicalRotate (location_t location, tree op1, tree op2, |
| 209 |
tree op3, tree nBits, bool needconvert); |
| 210 |
EXTERN void m2expr_BuildBinarySetDo ( |
| 211 |
location_t location, tree settype, tree op1, tree op2, tree op3, |
| 212 |
void (*binop) (location_t, tree, tree, tree, tree, bool), bool is_op1lvalue, |
| 213 |
bool is_op2lvalue, bool is_op3lvalue, tree nBits, tree unbounded, |
| 214 |
tree varproc, tree leftproc, tree rightproc); |
| 215 |
|
| 216 |
EXTERN tree m2expr_GetSizeOf (location_t location, tree type); |
| 217 |
EXTERN tree m2expr_GetSizeOfInBits (tree type); |
| 218 |
|
| 219 |
EXTERN tree m2expr_GetCardinalZero (location_t location); |
| 220 |
EXTERN tree m2expr_GetCardinalOne (location_t location); |
| 221 |
EXTERN tree m2expr_GetIntegerZero (location_t location); |
| 222 |
EXTERN tree m2expr_GetIntegerOne (location_t location); |
| 223 |
EXTERN tree m2expr_GetWordZero (location_t location); |
| 224 |
EXTERN tree m2expr_GetWordOne (location_t location); |
| 225 |
EXTERN tree m2expr_GetPointerZero (location_t location); |
| 226 |
EXTERN tree m2expr_GetPointerOne (location_t location); |
| 227 |
|
| 228 |
EXTERN int m2expr_CompareTrees (tree e1, tree e2); |
| 229 |
EXTERN tree m2expr_build_unary_op (location_t location ATTRIBUTE_UNUSED, |
| 230 |
enum tree_code code, tree arg, |
| 231 |
int flag ATTRIBUTE_UNUSED); |
| 232 |
EXTERN tree m2expr_build_binary_op (location_t location, enum tree_code code, |
| 233 |
tree op1, tree op2, int convert); |
| 234 |
EXTERN tree m2expr_build_binary_op_check (location_t location, |
| 235 |
enum tree_code code, tree op1, |
| 236 |
tree op2, bool needconvert, |
| 237 |
tree lowest, tree min, tree max); |
| 238 |
EXTERN void m2expr_ConstantExpressionWarning (tree value); |
| 239 |
EXTERN tree m2expr_BuildAddAddress (location_t location, tree op1, tree op2); |
| 240 |
EXTERN tree m2expr_BuildRDiv (location_t location, tree op1, tree op2, |
| 241 |
bool needconvert); |
| 242 |
EXTERN tree m2expr_BuildCondIfExpression (tree condition, tree type, |
| 243 |
tree left, tree right); |
| 244 |
EXTERN int m2expr_GetCstInteger (tree cst); |
| 245 |
EXTERN tree m2expr_calcNbits (location_t location, tree min, tree max); |
| 246 |
EXTERN bool m2expr_OverflowZType (location_t location, const char *str, |
| 247 |
unsigned int base, bool issueError); |
| 248 |
EXTERN tree m2expr_BuildSystemTBitSize (location_t location, tree type); |
| 249 |
EXTERN void m2expr_init (location_t location); |
| 250 |
|
| 251 |
#undef EXTERN |
| 252 |
#endif /* m2expr_h. */ |