Line data Source code
1 : /* do not edit automatically generated by mc from M2System. */
2 : /* M2System.mod defines the SYSTEM builtin types.
3 :
4 : Copyright (C) 2001-2026 Free Software Foundation, Inc.
5 : Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 :
7 : This file is part of GNU Modula-2.
8 :
9 : GNU Modula-2 is free software; you can redistribute it and/or modify
10 : it under the terms of the GNU General Public License as published by
11 : the Free Software Foundation; either version 3, or (at your option)
12 : any later version.
13 :
14 : GNU Modula-2 is distributed in the hope that it will be useful, but
15 : WITHOUT ANY WARRANTY; without even the implied warranty of
16 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 : General Public License for more details.
18 :
19 : You should have received a copy of the GNU General Public License
20 : along with GNU Modula-2; see the file COPYING3. If not see
21 : <http://www.gnu.org/licenses/>. */
22 :
23 : #include "config.h"
24 : #include "system.h"
25 : #include "gcc-consolidation.h"
26 :
27 : #include <stdbool.h>
28 : # if !defined (PROC_D)
29 : # define PROC_D
30 : typedef void (*PROC_t) (void);
31 : typedef struct { PROC_t proc; } PROC;
32 : # endif
33 :
34 : # if !defined (TRUE)
35 : # define TRUE (1==1)
36 : # endif
37 :
38 : # if !defined (FALSE)
39 : # define FALSE (1==0)
40 : # endif
41 :
42 : # include "Gmcrts.h"
43 : #if defined(__cplusplus)
44 : # undef NULL
45 : # define NULL 0
46 : #endif
47 : #define _M2System_C
48 :
49 : #include "GM2System.h"
50 : # include "GSymbolTable.h"
51 : # include "GAssertion.h"
52 : # include "GM2LexBuf.h"
53 : # include "GM2Options.h"
54 : # include "GNameKey.h"
55 : # include "GM2Batch.h"
56 : # include "GM2Base.h"
57 : # include "GM2Size.h"
58 : # include "GM2ALU.h"
59 : # include "GM2Error.h"
60 : # include "GLists.h"
61 : # include "GSymbolKey.h"
62 : # include "GStrLib.h"
63 : # include "GM2Printf.h"
64 : # include "GSymbolConversion.h"
65 : # include "Ggcctypes.h"
66 : # include "Gm2linemap.h"
67 : # include "Gm2decl.h"
68 : # include "Gm2type.h"
69 : # include "Gm2expr.h"
70 :
71 : typedef struct M2System_IsP_p M2System_IsP;
72 :
73 : typedef bool (*M2System_IsP_t) (unsigned int);
74 : struct M2System_IsP_p { M2System_IsP_t proc; };
75 :
76 : static SymbolKey_SymbolTree MinValues;
77 : static SymbolKey_SymbolTree MaxValues;
78 : static Lists_List SystemTypes;
79 :
80 : /*
81 : InitSystem - creates the system dependant types and procedures.
82 : Note that they are not exported here, but they are
83 : exported in the textual module: SYSTEM.def.
84 : We build our system types from those given in the gcc
85 : backend. Essentially we perform double book keeping.
86 : */
87 :
88 : extern "C" void M2System_InitSystem (void);
89 :
90 : /*
91 : GetSystemTypeMinMax - returns the minimum and maximum values for a given system type.
92 : */
93 :
94 : extern "C" void M2System_GetSystemTypeMinMax (unsigned int type, unsigned int *min, unsigned int *max);
95 :
96 : /*
97 : IsPseudoSystemFunction - returns true if sym is a SYSTEM pseudo function.
98 : */
99 :
100 : extern "C" bool M2System_IsPseudoSystemFunction (unsigned int sym);
101 :
102 : /*
103 : IsPseudoSystemProcedure - returns true if sym is a SYSTEM pseudo procedure.
104 : */
105 :
106 : extern "C" bool M2System_IsPseudoSystemProcedure (unsigned int sym);
107 :
108 : /*
109 : IsPseudoSystemFunctionConstExpression - returns TRUE if this procedure
110 : is legal in a constant expression.
111 : */
112 :
113 : extern "C" bool M2System_IsPseudoSystemFunctionConstExpression (unsigned int sym);
114 :
115 : /*
116 : IsSystemType - returns TRUE if sym is a SYSTEM (inbuilt) type.
117 : It does not search your SYSTEM implementation module.
118 : */
119 :
120 : extern "C" bool M2System_IsSystemType (unsigned int sym);
121 :
122 : /*
123 : IntegerN - returns the symbol associated with INTEGER[N].
124 : NulSym is returned if the type does not exist.
125 : */
126 :
127 : extern "C" unsigned int M2System_IntegerN (unsigned int bitlength);
128 :
129 : /*
130 : CardinalN - returns the symbol associated with CARDINAL[N].
131 : NulSym is returned if the type does not exist.
132 : */
133 :
134 : extern "C" unsigned int M2System_CardinalN (unsigned int bitlength);
135 :
136 : /*
137 : WordN - returns the symbol associated with WORD[N].
138 : NulSym is returned if the type does not exist.
139 : */
140 :
141 : extern "C" unsigned int M2System_WordN (unsigned int bitlength);
142 :
143 : /*
144 : SetN - returns the symbol associated with SET[N].
145 : NulSym is returned if the type does not exist.
146 : */
147 :
148 : extern "C" unsigned int M2System_SetN (unsigned int bitlength);
149 :
150 : /*
151 : RealN - returns the symbol associated with REAL[N].
152 : NulSym is returned if the type does not exist.
153 : */
154 :
155 : extern "C" unsigned int M2System_RealN (unsigned int bitlength);
156 :
157 : /*
158 : ComplexN - returns the symbol associated with COMPLEX[N].
159 : NulSym is returned if the type does not exist.
160 : */
161 :
162 : extern "C" unsigned int M2System_ComplexN (unsigned int bitlength);
163 :
164 : /*
165 : IsIntegerN - returns the TRUE if, sym, is one of the SYSTEM
166 : INTEGER types (not the base INTEGER type).
167 : */
168 :
169 : extern "C" bool M2System_IsIntegerN (unsigned int sym);
170 :
171 : /*
172 : IsCardinalN - returns the TRUE if, sym, is one of the SYSTEM
173 : CARDINAL types (not the base CARDINAL type).
174 : */
175 :
176 : extern "C" bool M2System_IsCardinalN (unsigned int sym);
177 :
178 : /*
179 : IsWordN - returns the TRUE if, sym, is one of the SYSTEM
180 : WORD[n] types (not the default SYSTEM WORD type).
181 : */
182 :
183 : extern "C" bool M2System_IsWordN (unsigned int sym);
184 :
185 : /*
186 : IsSetN - returns the TRUE if, sym, is one of the SYSTEM
187 : SET[n] types (not the default SYSTEM BITSET type).
188 : */
189 :
190 : extern "C" bool M2System_IsSetN (unsigned int sym);
191 :
192 : /*
193 : IsRealN - returns the TRUE if, sym, is one of the SYSTEM
194 : REAL[n] types (not the default base REAL type).
195 : */
196 :
197 : extern "C" bool M2System_IsRealN (unsigned int sym);
198 :
199 : /*
200 : IsComplexN - returns the TRUE if, sym, is one of the SYSTEM
201 : COMPLEX[n] types (not the default base COMPLEX,
202 : LONGCOMPLEX or SHORTCOMPLEX types).
203 : */
204 :
205 : extern "C" bool M2System_IsComplexN (unsigned int sym);
206 :
207 : /*
208 : IsGenericSystemType - returns TRUE if, sym, is of type
209 : BYTE, WORD or any other length.
210 : */
211 :
212 : extern "C" bool M2System_IsGenericSystemType (unsigned int sym);
213 :
214 : /*
215 : IsSameSizePervasiveType - returns TRUE if a or b are CARDINAL, INTEGER, REAL,
216 : LONGREAL, SHORTREAL and the other type is the same
217 : size and of the same type.
218 : */
219 :
220 : extern "C" bool M2System_IsSameSizePervasiveType (unsigned int a, unsigned int b);
221 :
222 : /*
223 : IsSameSize - return TRUE if SIZE(a)=SIZE(b)
224 : */
225 :
226 : extern "C" bool M2System_IsSameSize (unsigned int a, unsigned int b);
227 :
228 : /*
229 : Init -
230 : */
231 :
232 : static void Init (void);
233 :
234 : /*
235 : CreateMinMaxFor - creates the min and max values for type given gccType.
236 : */
237 :
238 : static void CreateMinMaxFor (unsigned int type, const char *min_, unsigned int _min_high, const char *max_, unsigned int _max_high, tree gccType, bool realtype);
239 :
240 : /*
241 : MapType - create a mapping of the M2 frontend type to gcctype.
242 : */
243 :
244 : static void MapType (unsigned int type, const char *name_, unsigned int _name_high, const char *min_, unsigned int _min_high, const char *max_, unsigned int _max_high, bool needsExporting, tree gcctype, bool realtype);
245 :
246 : /*
247 : CreateType - create and return a frontend type which matches the GCC tree type.
248 : */
249 :
250 : static unsigned int CreateType (const char *name_, unsigned int _name_high, const char *min_, unsigned int _min_high, const char *max_, unsigned int _max_high, bool needsExporting, tree gccType, bool realtype);
251 :
252 : /*
253 : AttemptToCreateType - attempts to create a frontend type which matches the
254 : GCC tree type.
255 : */
256 :
257 : static void AttemptToCreateType (const char *name_, unsigned int _name_high, const char *min_, unsigned int _min_high, const char *max_, unsigned int _max_high, bool needsExporting, tree gccType, bool realtype);
258 :
259 : /*
260 : CreateSetType - creates and returns a, SET OF [0..highBit], type.
261 : It maps this type onto the GCC type.
262 : */
263 :
264 : static unsigned int CreateSetType (const char *name_, unsigned int _name_high, const char *highBit_, unsigned int _highBit_high, bool needsExporting, tree gccType);
265 :
266 : /*
267 : AttemptToCreateSetType - creates and returns a, SET OF [0..highBit], type.
268 : It maps this type onto the GCC type.
269 : */
270 :
271 : static void AttemptToCreateSetType (const char *name_, unsigned int _name_high, const char *highBit_, unsigned int _highBit_high, bool needsExporting, tree gccType);
272 :
273 : /*
274 : MakeFixedSizedTypes - creates the SYSTEM fixed sized types providing the
275 : gcc backend supports them.
276 : */
277 :
278 : static void MakeFixedSizedTypes (void);
279 :
280 : /*
281 : InitPIMTypes -
282 : */
283 :
284 : static void InitPIMTypes (void);
285 :
286 : /*
287 : InitISOTypes -
288 : */
289 :
290 : static void InitISOTypes (void);
291 :
292 : /*
293 : MakeExtraSystemTypes - create any extra system types required
294 : for portability.
295 : */
296 :
297 : static void MakeExtraSystemTypes (void);
298 :
299 : /*
300 : IsISOPseudoSystemFunction -
301 : */
302 :
303 : static bool IsISOPseudoSystemFunction (unsigned int sym);
304 :
305 : /*
306 : IsPIMPseudoSystemFunction - returns TRUE if sym is specifically a PIM
307 : system function.
308 : */
309 :
310 : static bool IsPIMPseudoSystemFunction (unsigned int sym);
311 :
312 : /*
313 : GetSafeSystem -
314 : */
315 :
316 : static unsigned int GetSafeSystem (NameKey_Name name);
317 :
318 : /*
319 : IsSameType - returns TRUE if, t, is the same type as a or b
320 : and a or b are a type, p.
321 : */
322 :
323 : static bool IsSameType (unsigned int t, M2System_IsP p, unsigned int a, unsigned int b);
324 :
325 :
326 : /*
327 : Init -
328 : */
329 :
330 14952 : static void Init (void)
331 : {
332 14952 : Lists_InitList (&SystemTypes);
333 14952 : SymbolKey_InitTree (&MinValues);
334 14952 : SymbolKey_InitTree (&MaxValues);
335 14952 : }
336 :
337 :
338 : /*
339 : CreateMinMaxFor - creates the min and max values for type given gccType.
340 : */
341 :
342 213629 : static void CreateMinMaxFor (unsigned int type, const char *min_, unsigned int _min_high, const char *max_, unsigned int _max_high, tree gccType, bool realtype)
343 : {
344 213629 : unsigned int maxval;
345 213629 : unsigned int minval;
346 213629 : char min[_min_high+1];
347 213629 : char max[_max_high+1];
348 :
349 : /* make a local copy of each unbounded array. */
350 213629 : memcpy (min, min_, _min_high+1);
351 213629 : memcpy (max, max_, _max_high+1);
352 :
353 213629 : maxval = SymbolTable_MakeConstVar (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) max, _max_high));
354 213629 : if (realtype)
355 : {
356 44856 : M2ALU_PushRealTree (m2type_GetMaxFrom (m2linemap_BuiltinsLocation (), gccType));
357 : }
358 : else
359 : {
360 168773 : M2ALU_PushIntegerTree (m2type_GetMaxFrom (m2linemap_BuiltinsLocation (), gccType));
361 : }
362 213629 : SymbolTable_PopValue (maxval);
363 213629 : SymbolTable_PutVar (maxval, type);
364 213629 : SymbolKey_PutSymKey (MaxValues, SymbolTable_GetSymName (type), maxval);
365 213629 : minval = SymbolTable_MakeConstVar (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) min, _min_high));
366 213629 : if (realtype)
367 : {
368 44856 : M2ALU_PushRealTree (m2type_GetMinFrom (m2linemap_BuiltinsLocation (), gccType));
369 : }
370 : else
371 : {
372 168773 : M2ALU_PushIntegerTree (m2type_GetMinFrom (m2linemap_BuiltinsLocation (), gccType));
373 : }
374 213629 : SymbolTable_PopValue (minval);
375 213629 : SymbolTable_PutVar (minval, type);
376 213629 : SymbolKey_PutSymKey (MinValues, SymbolTable_GetSymName (type), minval);
377 213629 : }
378 :
379 :
380 : /*
381 : MapType - create a mapping of the M2 frontend type to gcctype.
382 : */
383 :
384 403704 : static void MapType (unsigned int type, const char *name_, unsigned int _name_high, const char *min_, unsigned int _min_high, const char *max_, unsigned int _max_high, bool needsExporting, tree gcctype, bool realtype)
385 : {
386 403704 : NameKey_Name n;
387 403704 : char name[_name_high+1];
388 403704 : char min[_min_high+1];
389 403704 : char max[_max_high+1];
390 :
391 : /* make a local copy of each unbounded array. */
392 403704 : memcpy (name, name_, _name_high+1);
393 403704 : memcpy (min, min_, _min_high+1);
394 403704 : memcpy (max, max_, _max_high+1);
395 :
396 403704 : M2ALU_PushIntegerTree (m2expr_BuildSize (m2linemap_BuiltinsLocation (), gcctype, false));
397 403704 : SymbolTable_PopSize (type);
398 403704 : if (Lists_IsItemInList (SystemTypes, type))
399 : {
400 0 : M2Error_InternalError ((const char *) "not expecting system type to already be declared", 48);
401 : }
402 403704 : Lists_PutItemIntoList (SystemTypes, type);
403 : /* Create min, max constants if type is ordinal or a floating point type. */
404 403704 : if ((! (StrLib_StrEqual ((const char *) min, _min_high, (const char *) "", 0))) && (! (StrLib_StrEqual ((const char *) max, _max_high, (const char *) "", 0))))
405 : {
406 168773 : CreateMinMaxFor (type, (const char *) min, _min_high, (const char *) max, _max_high, gcctype, realtype);
407 : }
408 403704 : if (needsExporting && M2Options_DumpSystemExports)
409 : {
410 594 : n = SymbolTable_GetSymName (type);
411 594 : M2Printf_printf1 ((const char *) "SYSTEM module creates type: %a\\n", 32, (const unsigned char *) &n, (sizeof (n)-1));
412 : }
413 403704 : }
414 :
415 :
416 : /*
417 : CreateType - create and return a frontend type which matches the GCC tree type.
418 : */
419 :
420 373800 : static unsigned int CreateType (const char *name_, unsigned int _name_high, const char *min_, unsigned int _min_high, const char *max_, unsigned int _max_high, bool needsExporting, tree gccType, bool realtype)
421 : {
422 373800 : unsigned int type;
423 373800 : char name[_name_high+1];
424 373800 : char min[_min_high+1];
425 373800 : char max[_max_high+1];
426 :
427 : /* make a local copy of each unbounded array. */
428 373800 : memcpy (name, name_, _name_high+1);
429 373800 : memcpy (min, min_, _min_high+1);
430 373800 : memcpy (max, max_, _max_high+1);
431 :
432 373800 : if (gccType == NULL)
433 : {
434 : /* GCC backend does not support this type. */
435 : return SymbolTable_NulSym;
436 : }
437 : else
438 : {
439 : /* Create base type. */
440 343896 : type = SymbolTable_MakeType (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) name, _name_high));
441 343896 : SymbolTable_PutType (type, SymbolTable_NulSym); /* a Base Type */
442 343896 : MapType (type, (const char *) name, _name_high, (const char *) min, _min_high, (const char *) max, _max_high, needsExporting, gccType, realtype); /* a Base Type */
443 343896 : return type;
444 : }
445 : /* static analysis guarentees a RETURN statement will be used before here. */
446 : __builtin_unreachable ();
447 373800 : }
448 :
449 :
450 : /*
451 : AttemptToCreateType - attempts to create a frontend type which matches the
452 : GCC tree type.
453 : */
454 :
455 284088 : static void AttemptToCreateType (const char *name_, unsigned int _name_high, const char *min_, unsigned int _min_high, const char *max_, unsigned int _max_high, bool needsExporting, tree gccType, bool realtype)
456 : {
457 284088 : char name[_name_high+1];
458 284088 : char min[_min_high+1];
459 284088 : char max[_max_high+1];
460 :
461 : /* make a local copy of each unbounded array. */
462 284088 : memcpy (name, name_, _name_high+1);
463 284088 : memcpy (min, min_, _min_high+1);
464 284088 : memcpy (max, max_, _max_high+1);
465 :
466 284088 : Assertion_Assert (SymbolTable_IsLegal (CreateType ((const char *) name, _name_high, (const char *) min, _min_high, (const char *) max, _max_high, needsExporting, gccType, realtype)));
467 284088 : }
468 :
469 :
470 : /*
471 : CreateSetType - creates and returns a, SET OF [0..highBit], type.
472 : It maps this type onto the GCC type.
473 : */
474 :
475 44856 : static unsigned int CreateSetType (const char *name_, unsigned int _name_high, const char *highBit_, unsigned int _highBit_high, bool needsExporting, tree gccType)
476 : {
477 44856 : unsigned int low;
478 44856 : unsigned int high;
479 44856 : unsigned int subrange;
480 44856 : unsigned int type;
481 44856 : char name[_name_high+1];
482 44856 : char highBit[_highBit_high+1];
483 :
484 : /* make a local copy of each unbounded array. */
485 44856 : memcpy (name, name_, _name_high+1);
486 44856 : memcpy (highBit, highBit_, _highBit_high+1);
487 :
488 44856 : if (gccType == NULL)
489 : {
490 : /* GCC backend does not support this type */
491 : return SymbolTable_NulSym;
492 : }
493 : else
494 : {
495 : /* create base type */
496 44856 : type = SymbolTable_MakeSet (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) name, _name_high));
497 44856 : low = SymbolTable_MakeConstLit (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "0", 1), M2Base_Cardinal);
498 44856 : high = SymbolTable_MakeConstLit (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) highBit, _highBit_high), M2Base_Cardinal);
499 44856 : subrange = SymbolTable_MakeSubrange (M2LexBuf_BuiltinTokenNo, NameKey_NulName);
500 44856 : SymbolTable_PutSubrange (subrange, low, high, M2Base_Cardinal);
501 44856 : SymbolTable_PutSet (type, subrange, false);
502 44856 : MapType (type, (const char *) name, _name_high, (const char *) "", 0, (const char *) "", 0, needsExporting, gccType, false);
503 44856 : return type;
504 : }
505 : /* static analysis guarentees a RETURN statement will be used before here. */
506 : __builtin_unreachable ();
507 44856 : }
508 :
509 :
510 : /*
511 : AttemptToCreateSetType - creates and returns a, SET OF [0..highBit], type.
512 : It maps this type onto the GCC type.
513 : */
514 :
515 44856 : static void AttemptToCreateSetType (const char *name_, unsigned int _name_high, const char *highBit_, unsigned int _highBit_high, bool needsExporting, tree gccType)
516 : {
517 44856 : char name[_name_high+1];
518 44856 : char highBit[_highBit_high+1];
519 :
520 : /* make a local copy of each unbounded array. */
521 44856 : memcpy (name, name_, _name_high+1);
522 44856 : memcpy (highBit, highBit_, _highBit_high+1);
523 :
524 44856 : Assertion_Assert (SymbolTable_IsLegal (CreateSetType ((const char *) name, _name_high, (const char *) highBit, _highBit_high, needsExporting, gccType)));
525 44856 : }
526 :
527 :
528 : /*
529 : MakeFixedSizedTypes - creates the SYSTEM fixed sized types providing the
530 : gcc backend supports them.
531 : */
532 :
533 14952 : static void MakeFixedSizedTypes (void)
534 : {
535 14952 : AttemptToCreateType ((const char *) "INTEGER8", 8, (const char *) "MinInteger8", 11, (const char *) "MaxInteger8", 11, true, m2type_GetM2Integer8 (), false);
536 14952 : AttemptToCreateType ((const char *) "INTEGER16", 9, (const char *) "MinInteger16", 12, (const char *) "MaxInteger16", 12, true, m2type_GetM2Integer16 (), false);
537 14952 : AttemptToCreateType ((const char *) "INTEGER32", 9, (const char *) "MinInteger32", 12, (const char *) "MaxInteger32", 12, true, m2type_GetM2Integer32 (), false);
538 14952 : AttemptToCreateType ((const char *) "INTEGER64", 9, (const char *) "MinInteger64", 12, (const char *) "MaxInteger64", 12, true, m2type_GetM2Integer64 (), false);
539 14952 : AttemptToCreateType ((const char *) "CARDINAL8", 9, (const char *) "MinCardinal8", 12, (const char *) "MaxCardinal8", 12, true, m2type_GetM2Cardinal8 (), false);
540 14952 : AttemptToCreateType ((const char *) "CARDINAL16", 10, (const char *) "MinCardinal16", 13, (const char *) "MaxCardinal16", 13, true, m2type_GetM2Cardinal16 (), false);
541 14952 : AttemptToCreateType ((const char *) "CARDINAL32", 10, (const char *) "MinCardinal32", 13, (const char *) "MaxCardinal32", 13, true, m2type_GetM2Cardinal32 (), false);
542 14952 : AttemptToCreateType ((const char *) "CARDINAL64", 10, (const char *) "MinCardinal64", 13, (const char *) "MaxCardinal64", 13, true, m2type_GetM2Cardinal64 (), false);
543 14952 : AttemptToCreateType ((const char *) "WORD16", 6, (const char *) "", 0, (const char *) "", 0, true, m2type_GetM2Word16 (), false);
544 14952 : AttemptToCreateType ((const char *) "WORD32", 6, (const char *) "", 0, (const char *) "", 0, true, m2type_GetM2Word32 (), false);
545 14952 : AttemptToCreateType ((const char *) "WORD64", 6, (const char *) "", 0, (const char *) "", 0, true, m2type_GetM2Word64 (), false);
546 14952 : AttemptToCreateSetType ((const char *) "BITSET8", 7, (const char *) "7", 1, true, m2type_GetM2Bitset8 ());
547 14952 : AttemptToCreateSetType ((const char *) "BITSET16", 8, (const char *) "15", 2, true, m2type_GetM2Bitset16 ());
548 14952 : AttemptToCreateSetType ((const char *) "BITSET32", 8, (const char *) "31", 2, true, m2type_GetM2Bitset32 ());
549 14952 : AttemptToCreateType ((const char *) "REAL32", 6, (const char *) "MinReal32", 9, (const char *) "MaxReal32", 9, true, m2type_GetM2Real32 (), true);
550 14952 : AttemptToCreateType ((const char *) "REAL64", 6, (const char *) "MinReal64", 9, (const char *) "MaxReal64", 9, true, m2type_GetM2Real64 (), true);
551 14952 : AttemptToCreateType ((const char *) "REAL96", 6, (const char *) "MinReal96", 9, (const char *) "MaxReal96", 9, true, m2type_GetM2Real96 (), true);
552 14952 : AttemptToCreateType ((const char *) "REAL128", 7, (const char *) "MinReal128", 10, (const char *) "MaxReal128", 10, true, m2type_GetM2Real128 (), true);
553 14952 : AttemptToCreateType ((const char *) "COMPLEX32", 9, (const char *) "", 0, (const char *) "", 0, true, m2type_GetM2Complex32 (), true);
554 14952 : AttemptToCreateType ((const char *) "COMPLEX64", 9, (const char *) "", 0, (const char *) "", 0, true, m2type_GetM2Complex64 (), true);
555 14952 : AttemptToCreateType ((const char *) "COMPLEX96", 9, (const char *) "", 0, (const char *) "", 0, true, m2type_GetM2Complex96 (), true);
556 14952 : AttemptToCreateType ((const char *) "COMPLEX128", 10, (const char *) "", 0, (const char *) "", 0, true, m2type_GetM2Complex128 (), true);
557 14952 : }
558 :
559 :
560 : /*
561 : InitPIMTypes -
562 : */
563 :
564 10651 : static void InitPIMTypes (void)
565 : {
566 10651 : M2System_Loc = CreateType ((const char *) "LOC", 3, (const char *) "", 0, (const char *) "", 0, true, m2type_GetISOLocType (), false);
567 10651 : m2type_InitSystemTypes (m2linemap_BuiltinsLocation (), static_cast<int> (M2System_Loc));
568 10651 : M2System_Word = CreateType ((const char *) "WORD", 4, (const char *) "", 0, (const char *) "", 0, true, m2type_GetWordType (), false);
569 10651 : M2System_Byte = CreateType ((const char *) "BYTE", 4, (const char *) "", 0, (const char *) "", 0, true, m2type_GetByteType (), false);
570 : /* ADDRESS = POINTER TO BYTE */
571 10651 : M2System_Address = SymbolTable_MakePointer (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "ADDRESS", 7));
572 10651 : SymbolTable_PutPointer (M2System_Address, M2System_Byte); /* Base Type */
573 10651 : MapType (M2System_Address, (const char *) "ADDRESS", 7, (const char *) "", 0, (const char *) "", 0, true, m2type_GetPointerType (), false); /* Base Type */
574 10651 : }
575 :
576 :
577 : /*
578 : InitISOTypes -
579 : */
580 :
581 4301 : static void InitISOTypes (void)
582 : {
583 4301 : M2System_Loc = CreateType ((const char *) "LOC", 3, (const char *) "MinLoc", 6, (const char *) "MaxLoc", 6, true, m2type_GetISOLocType (), false);
584 4301 : m2type_InitSystemTypes (m2linemap_BuiltinsLocation (), static_cast<int> (M2System_Loc));
585 4301 : M2System_Address = SymbolTable_MakePointer (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "ADDRESS", 7));
586 4301 : SymbolTable_PutPointer (M2System_Address, M2System_Loc); /* Base Type */
587 4301 : MapType (M2System_Address, (const char *) "ADDRESS", 7, (const char *) "", 0, (const char *) "", 0, true, m2type_GetPointerType (), false); /* Base Type */
588 4301 : M2System_Byte = CreateType ((const char *) "BYTE", 4, (const char *) "", 0, (const char *) "", 0, true, m2type_GetISOByteType (), false);
589 4301 : M2System_Word = CreateType ((const char *) "WORD", 4, (const char *) "", 0, (const char *) "", 0, true, m2type_GetISOWordType (), false);
590 4301 : }
591 :
592 :
593 : /*
594 : MakeExtraSystemTypes - create any extra system types required
595 : for portability.
596 : */
597 :
598 14952 : static void MakeExtraSystemTypes (void)
599 : {
600 14952 : M2System_CSizeT = CreateType ((const char *) "CSIZE_T", 7, (const char *) "", 0, (const char *) "", 0, true, m2type_GetCSizeTType (), false);
601 14952 : M2System_CSSizeT = CreateType ((const char *) "CSSIZE_T", 8, (const char *) "", 0, (const char *) "", 0, true, m2type_GetCSSizeTType (), false);
602 14952 : M2System_COffT = CreateType ((const char *) "COFF_T", 6, (const char *) "", 0, (const char *) "", 0, true, m2type_GetCOffTType (), false);
603 14952 : }
604 :
605 :
606 : /*
607 : IsISOPseudoSystemFunction -
608 : */
609 :
610 4687549 : static bool IsISOPseudoSystemFunction (unsigned int sym)
611 : {
612 4687549 : return M2Options_Iso && (((((((sym == M2System_AddAdr) || (sym == M2System_SubAdr)) || (sym == M2System_DifAdr)) || (sym == M2System_MakeAdr)) || (sym == M2System_Rotate)) || (sym == M2System_Shift)) || (sym == M2System_Cast));
613 : /* static analysis guarentees a RETURN statement will be used before here. */
614 : __builtin_unreachable ();
615 : }
616 :
617 :
618 : /*
619 : IsPIMPseudoSystemFunction - returns TRUE if sym is specifically a PIM
620 : system function.
621 : */
622 :
623 4710921 : static bool IsPIMPseudoSystemFunction (unsigned int sym)
624 : {
625 4710921 : return ! M2Options_Iso && (((sym == M2Size_Size) || (sym == M2System_Shift)) || (sym == M2System_Rotate));
626 : /* static analysis guarentees a RETURN statement will be used before here. */
627 : __builtin_unreachable ();
628 : }
629 :
630 :
631 : /*
632 : GetSafeSystem -
633 : */
634 :
635 55965926 : static unsigned int GetSafeSystem (NameKey_Name name)
636 : {
637 55965926 : unsigned int sym;
638 55965926 : unsigned int i;
639 55965926 : unsigned int n;
640 :
641 55965926 : n = Lists_NoOfItemsInList (SystemTypes);
642 55965926 : i = 1;
643 1053214621 : while (i <= n)
644 : {
645 990561001 : sym = static_cast<unsigned int> (Lists_GetItemFromList (SystemTypes, i));
646 990561001 : if ((SymbolTable_GetSymName (sym)) == name)
647 : {
648 : return sym;
649 : }
650 941282769 : i += 1;
651 : }
652 : return SymbolTable_NulSym;
653 : /* static analysis guarentees a RETURN statement will be used before here. */
654 : __builtin_unreachable ();
655 : }
656 :
657 :
658 : /*
659 : IsSameType - returns TRUE if, t, is the same type as a or b
660 : and a or b are a type, p.
661 : */
662 :
663 0 : static bool IsSameType (unsigned int t, M2System_IsP p, unsigned int a, unsigned int b)
664 : {
665 0 : if (t == a)
666 : {
667 0 : return ((*p.proc) (b)) && (M2System_IsSameSize (a, b));
668 : }
669 0 : else if (t == b)
670 : {
671 : /* avoid dangling else. */
672 0 : return ((*p.proc) (a)) && (M2System_IsSameSize (a, b));
673 : }
674 : else
675 : {
676 : /* avoid dangling else. */
677 : return false;
678 : }
679 : /* static analysis guarentees a RETURN statement will be used before here. */
680 : __builtin_unreachable ();
681 : }
682 :
683 :
684 : /*
685 : InitSystem - creates the system dependant types and procedures.
686 : Note that they are not exported here, but they are
687 : exported in the textual module: SYSTEM.def.
688 : We build our system types from those given in the gcc
689 : backend. Essentially we perform double book keeping.
690 : */
691 :
692 14952 : extern "C" void M2System_InitSystem (void)
693 : {
694 14952 : unsigned int Previous;
695 :
696 14952 : Init ();
697 : /* create SYSTEM module */
698 14952 : M2System_System = M2Batch_MakeDefinitionSource (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "SYSTEM", 6));
699 14952 : SymbolTable_StartScope (M2System_System);
700 14952 : Previous = SymbolTable_GetCurrentModule ();
701 14952 : SymbolTable_SetCurrentModule (M2System_System);
702 14952 : if (M2Options_Iso)
703 : {
704 4301 : InitISOTypes ();
705 4301 : M2Size_MakeSize ();
706 4301 : SymbolTable_PutExportQualified (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "SIZE", 4));
707 : }
708 : else
709 : {
710 10651 : InitPIMTypes ();
711 : /* SIZE is declared in SYSTEM.def in PIM-2 but not PIM-[34] */
712 10651 : if (M2Options_Pedantic)
713 : {
714 : /* avoid dangling else. */
715 0 : if (M2Options_Pim2)
716 : {
717 0 : M2Size_MakeSize ();
718 0 : SymbolTable_PutExportQualified (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "SIZE", 4));
719 : }
720 : }
721 : else
722 : {
723 10651 : M2Size_MakeSize ();
724 10651 : SymbolTable_PutExportQualified (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "SIZE", 4));
725 : }
726 : }
727 : /* The predefined pseudo functions. */
728 14952 : M2System_Adr = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "ADR", 3)); /* Function */
729 14952 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, M2System_Adr, SymbolTable_DefProcedure, M2System_Address);
730 : /* Address */
731 14952 : M2System_TSize = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "TSIZE", 5)); /* Function */
732 14952 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, M2System_TSize, SymbolTable_DefProcedure, M2Base_ZType);
733 : /* ZType */
734 14952 : M2System_TBitSize = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "TBITSIZE", 8)); /* GNU extension */
735 : /* Function */
736 14952 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, M2System_TBitSize, SymbolTable_DefProcedure, M2Base_ZType);
737 : /* The ISO specific predefined pseudo functions. */
738 14952 : M2System_AddAdr = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "ADDADR", 6)); /* Function */
739 14952 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, M2System_AddAdr, SymbolTable_DefProcedure, M2System_Address);
740 : /* Return Type */
741 14952 : M2System_SubAdr = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "SUBADR", 6)); /* Function */
742 14952 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, M2System_SubAdr, SymbolTable_DefProcedure, M2System_Address);
743 : /* Return Type */
744 14952 : M2System_DifAdr = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "DIFADR", 6)); /* Function */
745 14952 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, M2System_DifAdr, SymbolTable_DefProcedure, M2System_Address);
746 : /* Return Type */
747 14952 : M2System_MakeAdr = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "MAKEADR", 7)); /* Function */
748 14952 : SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, M2System_MakeAdr, SymbolTable_DefProcedure, M2System_Address);
749 : /* The return value for ROTATE, SHIFT and CAST is the
750 : same as the first parameter and is faked in M2Quads. */
751 14952 : M2System_Rotate = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "ROTATE", 6)); /* Function */
752 14952 : M2System_Shift = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "SHIFT", 5)); /* Function */
753 14952 : M2System_Cast = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "CAST", 4)); /* Function */
754 14952 : M2System_Throw = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "THROW", 5)); /* Procedure */
755 14952 : SymbolTable_PutProcedureNoReturn (M2System_Throw, SymbolTable_DefProcedure, true); /* Procedure */
756 14952 : CreateMinMaxFor (M2System_Word, (const char *) "MinWord", 7, (const char *) "MaxWord", 7, m2type_GetWordType (), false);
757 14952 : CreateMinMaxFor (M2System_Address, (const char *) "MinAddress", 10, (const char *) "MaxAddress", 10, m2type_GetPointerType (), false);
758 14952 : CreateMinMaxFor (M2System_Byte, (const char *) "MinByte", 7, (const char *) "MaxByte", 7, m2type_GetByteType (), false);
759 14952 : MakeFixedSizedTypes ();
760 14952 : MakeExtraSystemTypes ();
761 14952 : SymbolTable_EndScope ();
762 14952 : SymbolTable_SetCurrentModule (Previous);
763 14952 : }
764 :
765 :
766 : /*
767 : GetSystemTypeMinMax - returns the minimum and maximum values for a given system type.
768 : */
769 :
770 388 : extern "C" void M2System_GetSystemTypeMinMax (unsigned int type, unsigned int *min, unsigned int *max)
771 : {
772 388 : if (Lists_IsItemInList (SystemTypes, type))
773 : {
774 388 : (*min) = static_cast<unsigned int> (SymbolKey_GetSymKey (MinValues, SymbolTable_GetSymName (type)));
775 388 : (*max) = static_cast<unsigned int> (SymbolKey_GetSymKey (MaxValues, SymbolTable_GetSymName (type)));
776 : }
777 : else
778 : {
779 0 : M2Error_InternalError ((const char *) "system does not know about this type", 36);
780 : }
781 388 : }
782 :
783 :
784 : /*
785 : IsPseudoSystemFunction - returns true if sym is a SYSTEM pseudo function.
786 : */
787 :
788 4775078 : extern "C" bool M2System_IsPseudoSystemFunction (unsigned int sym)
789 : {
790 4775078 : return ((((sym == M2System_Adr) || (sym == M2System_TSize)) || (sym == M2System_TBitSize)) || (IsPIMPseudoSystemFunction (sym))) || (IsISOPseudoSystemFunction (sym));
791 : /* static analysis guarentees a RETURN statement will be used before here. */
792 : __builtin_unreachable ();
793 : }
794 :
795 :
796 : /*
797 : IsPseudoSystemProcedure - returns true if sym is a SYSTEM pseudo procedure.
798 : */
799 :
800 152626 : extern "C" bool M2System_IsPseudoSystemProcedure (unsigned int sym)
801 : {
802 152626 : return sym == M2System_Throw;
803 : /* static analysis guarentees a RETURN statement will be used before here. */
804 : __builtin_unreachable ();
805 : }
806 :
807 :
808 : /*
809 : IsPseudoSystemFunctionConstExpression - returns TRUE if this procedure
810 : is legal in a constant expression.
811 : */
812 :
813 11172 : extern "C" bool M2System_IsPseudoSystemFunctionConstExpression (unsigned int sym)
814 : {
815 11172 : return (((((sym == M2Size_Size) || (sym == M2System_TSize)) || (sym == M2System_TBitSize)) || (sym == M2System_Rotate)) || (sym == M2System_Shift)) || (M2Options_Iso && (((sym == M2System_Cast) || (sym == M2System_MakeAdr)) || (sym == M2System_TBitSize)));
816 : /* static analysis guarentees a RETURN statement will be used before here. */
817 : __builtin_unreachable ();
818 : }
819 :
820 :
821 : /*
822 : IsSystemType - returns TRUE if sym is a SYSTEM (inbuilt) type.
823 : It does not search your SYSTEM implementation module.
824 : */
825 :
826 1660826 : extern "C" bool M2System_IsSystemType (unsigned int sym)
827 : {
828 1660826 : return Lists_IsItemInList (SystemTypes, sym);
829 : /* static analysis guarentees a RETURN statement will be used before here. */
830 : __builtin_unreachable ();
831 : }
832 :
833 :
834 : /*
835 : IntegerN - returns the symbol associated with INTEGER[N].
836 : NulSym is returned if the type does not exist.
837 : */
838 :
839 4568600 : extern "C" unsigned int M2System_IntegerN (unsigned int bitlength)
840 : {
841 4568600 : switch (bitlength)
842 : {
843 1200152 : case 8:
844 1200152 : return GetSafeSystem (NameKey_MakeKey ((const char *) "INTEGER8", 8));
845 1159634 : break;
846 :
847 1159634 : case 16:
848 1159634 : return GetSafeSystem (NameKey_MakeKey ((const char *) "INTEGER16", 9));
849 1122050 : break;
850 :
851 1122050 : case 32:
852 1122050 : return GetSafeSystem (NameKey_MakeKey ((const char *) "INTEGER32", 9));
853 1086764 : break;
854 :
855 1086764 : case 64:
856 1086764 : return GetSafeSystem (NameKey_MakeKey ((const char *) "INTEGER64", 9));
857 0 : break;
858 :
859 :
860 0 : default:
861 0 : M2Error_InternalError ((const char *) "system does not know about this type", 36);
862 : break;
863 : }
864 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2System.def", 20, 1);
865 : __builtin_unreachable ();
866 : }
867 :
868 :
869 : /*
870 : CardinalN - returns the symbol associated with CARDINAL[N].
871 : NulSym is returned if the type does not exist.
872 : */
873 :
874 3991448 : extern "C" unsigned int M2System_CardinalN (unsigned int bitlength)
875 : {
876 3991448 : switch (bitlength)
877 : {
878 1054520 : case 8:
879 1054520 : return GetSafeSystem (NameKey_MakeKey ((const char *) "CARDINAL8", 9));
880 1014454 : break;
881 :
882 1014454 : case 16:
883 1014454 : return GetSafeSystem (NameKey_MakeKey ((const char *) "CARDINAL16", 10));
884 979738 : break;
885 :
886 979738 : case 32:
887 979738 : return GetSafeSystem (NameKey_MakeKey ((const char *) "CARDINAL32", 10));
888 942736 : break;
889 :
890 942736 : case 64:
891 942736 : return GetSafeSystem (NameKey_MakeKey ((const char *) "CARDINAL64", 10));
892 0 : break;
893 :
894 :
895 0 : default:
896 0 : M2Error_InternalError ((const char *) "system does not know about this type", 36);
897 : break;
898 : }
899 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2System.def", 20, 1);
900 : __builtin_unreachable ();
901 : }
902 :
903 :
904 : /*
905 : WordN - returns the symbol associated with WORD[N].
906 : NulSym is returned if the type does not exist.
907 : */
908 :
909 19153212 : extern "C" unsigned int M2System_WordN (unsigned int bitlength)
910 : {
911 19153212 : switch (bitlength)
912 : {
913 6387208 : case 16:
914 6387208 : return GetSafeSystem (NameKey_MakeKey ((const char *) "WORD16", 6));
915 6387208 : break;
916 :
917 6387208 : case 32:
918 6387208 : return GetSafeSystem (NameKey_MakeKey ((const char *) "WORD32", 6));
919 6378796 : break;
920 :
921 6378796 : case 64:
922 6378796 : return GetSafeSystem (NameKey_MakeKey ((const char *) "WORD64", 6));
923 0 : break;
924 :
925 :
926 0 : default:
927 0 : M2Error_InternalError ((const char *) "system does not know about this type", 36);
928 : break;
929 : }
930 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2System.def", 20, 1);
931 : __builtin_unreachable ();
932 : }
933 :
934 :
935 : /*
936 : SetN - returns the symbol associated with SET[N].
937 : NulSym is returned if the type does not exist.
938 : */
939 :
940 1484856 : extern "C" unsigned int M2System_SetN (unsigned int bitlength)
941 : {
942 1484856 : switch (bitlength)
943 : {
944 494952 : case 8:
945 494952 : return GetSafeSystem (NameKey_MakeKey ((const char *) "BITSET8", 7));
946 494952 : break;
947 :
948 494952 : case 16:
949 494952 : return GetSafeSystem (NameKey_MakeKey ((const char *) "BITSET16", 8));
950 494952 : break;
951 :
952 494952 : case 32:
953 494952 : return GetSafeSystem (NameKey_MakeKey ((const char *) "BITSET32", 8));
954 0 : break;
955 :
956 :
957 0 : default:
958 0 : M2Error_InternalError ((const char *) "system does not know about this type", 36);
959 : break;
960 : }
961 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2System.def", 20, 1);
962 : __builtin_unreachable ();
963 : }
964 :
965 :
966 : /*
967 : RealN - returns the symbol associated with REAL[N].
968 : NulSym is returned if the type does not exist.
969 : */
970 :
971 7302730 : extern "C" unsigned int M2System_RealN (unsigned int bitlength)
972 : {
973 7302730 : switch (bitlength)
974 : {
975 1838215 : case 32:
976 1838215 : return GetSafeSystem (NameKey_MakeKey ((const char *) "REAL32", 6));
977 1821649 : break;
978 :
979 1821649 : case 64:
980 1821649 : return GetSafeSystem (NameKey_MakeKey ((const char *) "REAL64", 6));
981 1821433 : break;
982 :
983 1821433 : case 96:
984 1821433 : return GetSafeSystem (NameKey_MakeKey ((const char *) "REAL96", 6));
985 1821433 : break;
986 :
987 1821433 : case 128:
988 1821433 : return GetSafeSystem (NameKey_MakeKey ((const char *) "REAL128", 7));
989 0 : break;
990 :
991 :
992 0 : default:
993 0 : M2Error_InternalError ((const char *) "system does not know about this type", 36);
994 : break;
995 : }
996 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2System.def", 20, 1);
997 : __builtin_unreachable ();
998 : }
999 :
1000 :
1001 : /*
1002 : ComplexN - returns the symbol associated with COMPLEX[N].
1003 : NulSym is returned if the type does not exist.
1004 : */
1005 :
1006 19465080 : extern "C" unsigned int M2System_ComplexN (unsigned int bitlength)
1007 : {
1008 19465080 : switch (bitlength)
1009 : {
1010 4866297 : case 32:
1011 4866297 : return GetSafeSystem (NameKey_MakeKey ((const char *) "COMPLEX32", 9));
1012 4866261 : break;
1013 :
1014 4866261 : case 64:
1015 4866261 : return GetSafeSystem (NameKey_MakeKey ((const char *) "COMPLEX64", 9));
1016 4866261 : break;
1017 :
1018 4866261 : case 96:
1019 4866261 : return GetSafeSystem (NameKey_MakeKey ((const char *) "COMPLEX96", 9));
1020 4866261 : break;
1021 :
1022 4866261 : case 128:
1023 4866261 : return GetSafeSystem (NameKey_MakeKey ((const char *) "COMPLEX128", 10));
1024 0 : break;
1025 :
1026 :
1027 0 : default:
1028 0 : M2Error_InternalError ((const char *) "system does not know about this type", 36);
1029 : break;
1030 : }
1031 : ReturnException ("/home/worker/buildworker/tiber-lcov/build/gcc/m2/gm2-compiler/M2System.def", 20, 1);
1032 : __builtin_unreachable ();
1033 : }
1034 :
1035 :
1036 : /*
1037 : IsIntegerN - returns the TRUE if, sym, is one of the SYSTEM
1038 : INTEGER types (not the base INTEGER type).
1039 : */
1040 :
1041 707092 : extern "C" bool M2System_IsIntegerN (unsigned int sym)
1042 : {
1043 707092 : return (sym != SymbolTable_NulSym) && ((((sym == (M2System_IntegerN (8))) || (sym == (M2System_IntegerN (16)))) || (sym == (M2System_IntegerN (32)))) || (sym == (M2System_IntegerN (64))));
1044 : /* static analysis guarentees a RETURN statement will be used before here. */
1045 : __builtin_unreachable ();
1046 : }
1047 :
1048 :
1049 : /*
1050 : IsCardinalN - returns the TRUE if, sym, is one of the SYSTEM
1051 : CARDINAL types (not the base CARDINAL type).
1052 : */
1053 :
1054 706744 : extern "C" bool M2System_IsCardinalN (unsigned int sym)
1055 : {
1056 706744 : return (sym != SymbolTable_NulSym) && ((((sym == (M2System_CardinalN (8))) || (sym == (M2System_CardinalN (16)))) || (sym == (M2System_CardinalN (32)))) || (sym == (M2System_CardinalN (64))));
1057 : /* static analysis guarentees a RETURN statement will be used before here. */
1058 : __builtin_unreachable ();
1059 : }
1060 :
1061 :
1062 : /*
1063 : IsWordN - returns the TRUE if, sym, is one of the SYSTEM
1064 : WORD[n] types (not the default SYSTEM WORD type).
1065 : */
1066 :
1067 6201910 : extern "C" bool M2System_IsWordN (unsigned int sym)
1068 : {
1069 6201910 : return (sym != SymbolTable_NulSym) && (((sym == (M2System_WordN (16))) || (sym == (M2System_WordN (32)))) || (sym == (M2System_WordN (64))));
1070 : /* static analysis guarentees a RETURN statement will be used before here. */
1071 : __builtin_unreachable ();
1072 : }
1073 :
1074 :
1075 : /*
1076 : IsSetN - returns the TRUE if, sym, is one of the SYSTEM
1077 : SET[n] types (not the default SYSTEM BITSET type).
1078 : */
1079 :
1080 300218 : extern "C" bool M2System_IsSetN (unsigned int sym)
1081 : {
1082 300218 : return (sym != SymbolTable_NulSym) && (((sym == (M2System_SetN (8))) || (sym == (M2System_SetN (16)))) || (sym == (M2System_SetN (32))));
1083 : /* static analysis guarentees a RETURN statement will be used before here. */
1084 : __builtin_unreachable ();
1085 : }
1086 :
1087 :
1088 : /*
1089 : IsRealN - returns the TRUE if, sym, is one of the SYSTEM
1090 : REAL[n] types (not the default base REAL type).
1091 : */
1092 :
1093 1644527 : extern "C" bool M2System_IsRealN (unsigned int sym)
1094 : {
1095 1644527 : return (sym != SymbolTable_NulSym) && ((((sym == (M2System_RealN (32))) || (sym == (M2System_RealN (64)))) || (sym == (M2System_RealN (96)))) || (sym == (M2System_RealN (128))));
1096 : /* static analysis guarentees a RETURN statement will be used before here. */
1097 : __builtin_unreachable ();
1098 : }
1099 :
1100 :
1101 : /*
1102 : IsComplexN - returns the TRUE if, sym, is one of the SYSTEM
1103 : COMPLEX[n] types (not the default base COMPLEX,
1104 : LONGCOMPLEX or SHORTCOMPLEX types).
1105 : */
1106 :
1107 4758131 : extern "C" bool M2System_IsComplexN (unsigned int sym)
1108 : {
1109 4758131 : return (sym != SymbolTable_NulSym) && ((((sym == (M2System_ComplexN (32))) || (sym == (M2System_ComplexN (64)))) || (sym == (M2System_ComplexN (96)))) || (sym == (M2System_ComplexN (128))));
1110 : /* static analysis guarentees a RETURN statement will be used before here. */
1111 : __builtin_unreachable ();
1112 : }
1113 :
1114 :
1115 : /*
1116 : IsGenericSystemType - returns TRUE if, sym, is of type
1117 : BYTE, WORD or any other length.
1118 : */
1119 :
1120 3795429 : extern "C" bool M2System_IsGenericSystemType (unsigned int sym)
1121 : {
1122 3795429 : return (sym != SymbolTable_NulSym) && ((((M2System_IsWordN (sym)) || (sym == M2System_Word)) || (sym == M2System_Byte)) || (sym == M2System_Loc));
1123 : /* static analysis guarentees a RETURN statement will be used before here. */
1124 : __builtin_unreachable ();
1125 : }
1126 :
1127 :
1128 : /*
1129 : IsSameSizePervasiveType - returns TRUE if a or b are CARDINAL, INTEGER, REAL,
1130 : LONGREAL, SHORTREAL and the other type is the same
1131 : size and of the same type.
1132 : */
1133 :
1134 0 : extern "C" bool M2System_IsSameSizePervasiveType (unsigned int a, unsigned int b)
1135 : {
1136 0 : return ((((((((((((IsSameType (M2Base_Integer, (M2System_IsP) {(M2System_IsP_t) M2System_IsIntegerN}, a, b)) || (IsSameType (M2Base_Cardinal, (M2System_IsP) {(M2System_IsP_t) M2System_IsCardinalN}, a, b))) || (IsSameType (M2System_Word, (M2System_IsP) {(M2System_IsP_t) M2System_IsWordN}, a, b))) || (IsSameType (M2Base_Real, (M2System_IsP) {(M2System_IsP_t) M2System_IsRealN}, a, b))) || (IsSameType (M2Base_Complex, (M2System_IsP) {(M2System_IsP_t) M2System_IsComplexN}, a, b))) || (IsSameType (M2Base_LongInt, (M2System_IsP) {(M2System_IsP_t) M2System_IsIntegerN}, a, b))) || (IsSameType (M2Base_LongCard, (M2System_IsP) {(M2System_IsP_t) M2System_IsCardinalN}, a, b))) || (IsSameType (M2Base_LongComplex, (M2System_IsP) {(M2System_IsP_t) M2System_IsComplexN}, a, b))) || (IsSameType (M2Base_LongReal, (M2System_IsP) {(M2System_IsP_t) M2System_IsRealN}, a, b))) || (IsSameType (M2Base_ShortInt, (M2System_IsP) {(M2System_IsP_t) M2System_IsIntegerN}, a, b))) || (IsSameType (M2Base_ShortCard, (M2System_IsP) {(M2System_IsP_t) M2System_IsCardinalN}, a, b))) || (IsSameType (M2Base_ShortComplex, (M2System_IsP) {(M2System_IsP_t) M2System_IsComplexN}, a, b))) || (IsSameType (M2Base_ShortReal, (M2System_IsP) {(M2System_IsP_t) M2System_IsRealN}, a, b));
1137 : /* static analysis guarentees a RETURN statement will be used before here. */
1138 : __builtin_unreachable ();
1139 : }
1140 :
1141 :
1142 : /*
1143 : IsSameSize - return TRUE if SIZE(a)=SIZE(b)
1144 : */
1145 :
1146 12646 : extern "C" bool M2System_IsSameSize (unsigned int a, unsigned int b)
1147 : {
1148 12646 : return m2expr_AreConstantsEqual (m2expr_BuildSize (m2linemap_BuiltinsLocation (), SymbolConversion_Mod2Gcc (a), false), m2expr_BuildSize (m2linemap_BuiltinsLocation (), SymbolConversion_Mod2Gcc (b), false));
1149 : /* static analysis guarentees a RETURN statement will be used before here. */
1150 : __builtin_unreachable ();
1151 : }
1152 :
1153 14952 : extern "C" void _M2_M2System_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
1154 : {
1155 14952 : }
1156 :
1157 0 : extern "C" void _M2_M2System_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
1158 : {
1159 0 : }
|