1 /* m2expr.h header file for m2expr.c.
3 Copyright (C) 2012-2021 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <gaius@glam.ac.uk>.
6 This file is part of GNU Modula-2.
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)
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.
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/>. */
22 #if !defined(m2expr_h)
26 #define EXTERN extern "C"
27 #else /* !__GNUG__. */
29 #endif /* !__GNUG__. */
30 #else /* !m2expr_c. */
32 #define EXTERN extern "C"
33 #else /* !__GNUG__. */
35 #endif /* !__GNUG__. */
36 #endif /* !m2expr_c. */
38 EXTERN
void m2expr_BuildBinaryForeachWordDo (
39 location_t location
, tree type
, tree op1
, tree op2
, tree op3
,
40 tree (*binop
) (location_t
, tree
, tree
, int), int is_op1lvalue
,
41 int is_op2lvalue
, int is_op3lvalue
, int is_op1const
, int is_op2const
,
43 EXTERN tree
m2expr_BuildCmplx (location_t location
, tree type
, tree real
,
45 EXTERN tree
m2expr_BuildIm (tree op1
);
46 EXTERN tree
m2expr_BuildRe (tree op1
);
47 EXTERN tree
m2expr_BuildAbs (location_t location
, tree t
);
48 EXTERN tree
m2expr_BuildCap (location_t location
, tree t
);
49 EXTERN
int m2expr_DetermineSign (tree e
);
50 EXTERN
int m2expr_AreRealOrComplexConstantsEqual (tree e1
, tree e2
);
51 EXTERN
int m2expr_AreConstantsEqual (tree e1
, tree e2
);
52 EXTERN
int m2expr_IsFalse (tree t
);
53 EXTERN
int m2expr_IsTrue (tree t
);
54 EXTERN tree
m2expr_BuildIndirect (location_t location
, tree target
, tree type
);
55 EXTERN tree
m2expr_BuildComponentRef (location_t location
, tree record
,
57 EXTERN tree
m2expr_BuildArray (location_t location
, tree type
, tree array
,
58 tree index
, tree lowIndice
);
59 EXTERN
void m2expr_BuildIfNotInRangeGoto (location_t location
, tree var
,
60 tree low
, tree high
, char *label
);
61 EXTERN
void m2expr_BuildIfInRangeGoto (location_t location
, tree var
, tree low
,
62 tree high
, char *label
);
63 EXTERN
void m2expr_BuildForeachWordInSetDoIfExpr (
64 location_t location
, tree type
, tree op1
, tree op2
, int is_op1lvalue
,
65 int is_op2lvalue
, int is_op1const
, int is_op2const
,
66 tree (*expr
) (location_t
, tree
, tree
), char *label
);
67 EXTERN
void m2expr_BuildIfNotVarInVar (location_t location
, tree type
,
68 tree varset
, tree varel
, int is_lvalue
,
69 tree low
, tree high ATTRIBUTE_UNUSED
,
71 EXTERN
void m2expr_BuildIfVarInVar (location_t location
, tree type
,
72 tree varset
, tree varel
, int is_lvalue
,
73 tree low
, tree high ATTRIBUTE_UNUSED
,
75 EXTERN
void m2expr_BuildIfNotConstInVar (location_t location
, tree type
,
76 tree varset
, tree constel
,
77 int is_lvalue
, int fieldno
,
79 EXTERN
void m2expr_BuildIfConstInVar (location_t location
, tree type
,
80 tree varset
, tree constel
, int is_lvalue
,
81 int fieldno
, char *label
);
82 EXTERN tree
m2expr_BuildIsNotSubset (location_t location
, tree op1
, tree op2
);
83 EXTERN tree
m2expr_BuildIsSubset (location_t location
, tree op1
, tree op2
);
84 EXTERN tree
m2expr_BuildIsNotSuperset (location_t location
, tree op1
,
86 EXTERN tree
m2expr_BuildIsSuperset (location_t location
, tree op1
, tree op2
);
87 EXTERN tree
m2expr_BuildNotEqualTo (location_t location
, tree op1
, tree op2
);
88 EXTERN tree
m2expr_BuildEqualTo (location_t location
, tree op1
, tree op2
);
89 EXTERN tree
m2expr_BuildGreaterThanOrEqual (location_t location
, tree op1
,
91 EXTERN tree
m2expr_BuildLessThanOrEqual (location_t location
, tree op1
,
93 EXTERN tree
m2expr_BuildGreaterThan (location_t location
, tree op1
, tree op2
);
94 EXTERN tree
m2expr_BuildLessThan (location_t location
, tree op1
, tree op2
);
95 EXTERN tree
m2expr_BuildLogicalDifference (location_t location
, tree op1
,
96 tree op2
, int needconvert
);
97 EXTERN tree
m2expr_BuildSymmetricDifference (location_t location
, tree op1
,
98 tree op2
, int needconvert
);
99 EXTERN tree
m2expr_BuildLogicalAnd (location_t location
, tree op1
, tree op2
,
101 EXTERN tree
m2expr_BuildLogicalOr (location_t location
, tree op1
, tree op2
,
103 EXTERN tree
m2expr_BuildLogicalOrAddress (location_t location
, tree op1
,
104 tree op2
, int needconvert
);
105 EXTERN tree
m2expr_BuildOffset (location_t location
, tree record
, tree field
,
106 int needconvert ATTRIBUTE_UNUSED
);
107 EXTERN tree
m2expr_BuildOffset1 (location_t location
, tree field
,
108 int needconvert ATTRIBUTE_UNUSED
);
109 EXTERN tree
m2expr_BuildAddr (location_t location
, tree op1
, int needconvert
);
110 EXTERN tree
m2expr_BuildSize (location_t location
, tree op1
,
111 int needconvert ATTRIBUTE_UNUSED
);
112 EXTERN tree
m2expr_BuildTBitSize (location_t location
, tree type
);
113 EXTERN tree
m2expr_BuildSetNegate (location_t location
, tree op1
,
115 EXTERN tree
m2expr_BuildNegate (location_t location
, tree op1
,
117 EXTERN tree
m2expr_BuildNegateCheck (location_t location
, tree arg
,
118 tree lowest
, tree min
, tree max
);
119 EXTERN tree
m2expr_BuildTrunc (tree op1
);
120 EXTERN tree
m2expr_BuildCoerce (location_t location
, tree des
, tree type
,
122 EXTERN tree
m2expr_RemoveOverflow (tree t
);
123 EXTERN
int m2expr_TreeOverflow (tree t
);
125 EXTERN
unsigned int m2expr_StringLength (tree string
);
126 EXTERN tree
m2expr_FoldAndStrip (tree t
);
127 EXTERN
int m2expr_interpret_integer (const char *str
, unsigned int base
,
128 unsigned HOST_WIDE_INT
*low
,
129 HOST_WIDE_INT
*high
);
130 EXTERN
int m2expr_interpret_m2_integer (const char *str
, unsigned int base
,
131 unsigned int *low
, int *high
);
133 EXTERN tree
m2expr_BuildAddCheck (location_t location
, tree op1
, tree op2
,
134 tree lowest
, tree min
, tree max
);
135 EXTERN tree
m2expr_BuildSubCheck (location_t location
, tree op1
, tree op2
,
136 tree lowest
, tree min
, tree max
);
137 EXTERN tree
m2expr_BuildMultCheck (location_t location
, tree op1
, tree op2
,
138 tree lowest
, tree min
, tree max
);
140 EXTERN tree
m2expr_BuildAdd (location_t location
, tree op1
, tree op2
,
142 EXTERN tree
m2expr_BuildSub (location_t location
, tree op1
, tree op2
,
144 EXTERN tree
m2expr_BuildDivTrunc (location_t location
, tree op1
, tree op2
,
146 EXTERN tree
m2expr_BuildDivTruncCheck (location_t location
, tree op1
, tree op2
,
147 tree lowest
, tree min
, tree max
);
148 EXTERN tree
m2expr_BuildModTrunc (location_t location
, tree op1
, tree op2
,
151 EXTERN tree
m2expr_BuildDivCeil (location_t location
, tree op1
, tree op2
,
153 EXTERN tree
m2expr_BuildModCeil (location_t location
, tree op1
, tree op2
,
156 EXTERN tree
m2expr_BuildDivFloor (location_t location
, tree op1
, tree op2
,
158 EXTERN tree
m2expr_BuildModFloor (location_t location
, tree op1
, tree op2
,
161 EXTERN tree
m2expr_BuildDivM2 (location_t location
, tree op1
, tree op2
,
162 unsigned int needsconvert
);
163 EXTERN tree
m2expr_BuildModM2 (location_t location
, tree op1
, tree op2
,
164 unsigned int needsconvert
);
165 EXTERN tree
m2expr_BuildDivM2Check (location_t location
, tree op1
, tree op2
,
166 tree lowest
, tree min
, tree max
);
168 EXTERN tree
m2expr_BuildModM2Check (location_t location
, tree op1
, tree op2
,
169 tree lowest
, tree min
, tree max
);
171 EXTERN tree
m2expr_BuildLSL (location_t location
, tree op1
, tree op2
,
174 EXTERN tree
m2expr_BuildLSR (location_t location
, tree op1
, tree op2
,
177 EXTERN
void m2expr_BuildLogicalShift (location_t location
, tree op1
, tree op2
,
178 tree op3
, tree nBits ATTRIBUTE_UNUSED
,
181 EXTERN tree
m2expr_BuildLRL (location_t location
, tree op1
, tree op2
,
184 EXTERN tree
m2expr_BuildLRR (location_t location
, tree op1
, tree op2
,
186 EXTERN tree
m2expr_BuildMult (location_t location
, tree op1
, tree op2
,
189 EXTERN tree
m2expr_BuildRRotate (location_t location
, tree op1
, tree nBits
,
191 EXTERN tree
m2expr_BuildLRotate (location_t location
, tree op1
, tree nBits
,
194 EXTERN tree
m2expr_BuildMask (location_t location
, tree nBits
,
196 EXTERN tree
m2expr_BuildLRLn (location_t location
, tree op1
, tree op2
,
197 tree nBits
, int needconvert
);
198 EXTERN tree
m2expr_BuildLRRn (location_t location
, tree op1
, tree op2
,
199 tree nBits
, int needconvert
);
200 EXTERN
void m2expr_BuildLogicalRotate (location_t location
, tree op1
, tree op2
,
201 tree op3
, tree nBits
, int needconvert
);
202 EXTERN
void m2expr_BuildBinarySetDo (
203 location_t location
, tree settype
, tree op1
, tree op2
, tree op3
,
204 void (*binop
) (location_t
, tree
, tree
, tree
, tree
, int), int is_op1lvalue
,
205 int is_op2lvalue
, int is_op3lvalue
, tree nBits
, tree unbounded
,
206 tree varproc
, tree leftproc
, tree rightproc
);
208 EXTERN tree
m2expr_GetSizeOf (location_t location
, tree type
);
209 EXTERN tree
m2expr_GetSizeOfInBits (tree type
);
211 EXTERN tree
m2expr_GetCardinalZero (location_t location
);
212 EXTERN tree
m2expr_GetCardinalOne (location_t location
);
213 EXTERN tree
m2expr_GetIntegerZero (location_t location
);
214 EXTERN tree
m2expr_GetIntegerOne (location_t location
);
215 EXTERN tree
m2expr_GetWordZero (location_t location
);
216 EXTERN tree
m2expr_GetWordOne (location_t location
);
217 EXTERN tree
m2expr_GetPointerZero (location_t location
);
218 EXTERN tree
m2expr_GetPointerOne (location_t location
);
221 EXTERN tree
m2expr_GetBooleanTrue (void);
222 EXTERN tree
m2expr_GetBooleanFalse (void);
225 EXTERN
int m2expr_CompareTrees (tree e1
, tree e2
);
226 EXTERN tree
m2expr_build_unary_op (location_t location ATTRIBUTE_UNUSED
,
227 enum tree_code code
, tree arg
,
228 int flag ATTRIBUTE_UNUSED
);
229 EXTERN tree
m2expr_build_binary_op (location_t location
, enum tree_code code
,
230 tree op1
, tree op2
, int convert
);
231 EXTERN tree
m2expr_build_binary_op_check (location_t location
,
232 enum tree_code code
, tree op1
,
233 tree op2
, int needconvert
,
234 tree lowest
, tree min
, tree max
);
235 EXTERN
void m2expr_ConstantExpressionWarning (tree value
);
236 EXTERN tree
m2expr_BuildAddAddress (location_t location
, tree op1
, tree op2
);
237 EXTERN tree
m2expr_BuildRDiv (location_t location
, tree op1
, tree op2
,
240 EXTERN
void m2expr_init (location_t location
);
243 #endif /* m2expr_h. */