LCOV - code coverage report
Current view: top level - /mnt/build/buildbot/bld/build-lcov/gcc/m2/gm2-compiler-boot - M2System.c (source / functions) Coverage Total Hit
Test: gcc.info Lines: 90.4 % 332 300
Test Date: 2025-07-12 13:27:34 Functions: 92.1 % 38 35
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     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-2025 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                 :       14720 : static void Init (void)
     331                 :             : {
     332                 :       14720 :   Lists_InitList (&SystemTypes);
     333                 :       14720 :   SymbolKey_InitTree (&MinValues);
     334                 :       14720 :   SymbolKey_InitTree (&MaxValues);
     335                 :       14720 : }
     336                 :             : 
     337                 :             : 
     338                 :             : /*
     339                 :             :    CreateMinMaxFor - creates the min and max values for type given gccType.
     340                 :             : */
     341                 :             : 
     342                 :      210186 : 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                 :      210186 :   unsigned int maxval;
     345                 :      210186 :   unsigned int minval;
     346                 :      210186 :   char min[_min_high+1];
     347                 :      210186 :   char max[_max_high+1];
     348                 :             : 
     349                 :             :   /* make a local copy of each unbounded array.  */
     350                 :      210186 :   memcpy (min, min_, _min_high+1);
     351                 :      210186 :   memcpy (max, max_, _max_high+1);
     352                 :             : 
     353                 :      210186 :   maxval = SymbolTable_MakeConstVar (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) max, _max_high));
     354                 :      210186 :   if (realtype)
     355                 :             :     {
     356                 :       44160 :       M2ALU_PushRealTree (m2type_GetMaxFrom (m2linemap_BuiltinsLocation (), gccType));
     357                 :             :     }
     358                 :             :   else
     359                 :             :     {
     360                 :      166026 :       M2ALU_PushIntegerTree (m2type_GetMaxFrom (m2linemap_BuiltinsLocation (), gccType));
     361                 :             :     }
     362                 :      210186 :   SymbolTable_PopValue (maxval);
     363                 :      210186 :   SymbolTable_PutVar (maxval, type);
     364                 :      210186 :   SymbolKey_PutSymKey (MaxValues, SymbolTable_GetSymName (type), maxval);
     365                 :      210186 :   minval = SymbolTable_MakeConstVar (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) min, _min_high));
     366                 :      210186 :   if (realtype)
     367                 :             :     {
     368                 :       44160 :       M2ALU_PushRealTree (m2type_GetMinFrom (m2linemap_BuiltinsLocation (), gccType));
     369                 :             :     }
     370                 :             :   else
     371                 :             :     {
     372                 :      166026 :       M2ALU_PushIntegerTree (m2type_GetMinFrom (m2linemap_BuiltinsLocation (), gccType));
     373                 :             :     }
     374                 :      210186 :   SymbolTable_PopValue (minval);
     375                 :      210186 :   SymbolTable_PutVar (minval, type);
     376                 :      210186 :   SymbolKey_PutSymKey (MinValues, SymbolTable_GetSymName (type), minval);
     377                 :      210186 : }
     378                 :             : 
     379                 :             : 
     380                 :             : /*
     381                 :             :    MapType - create a mapping of the M2 frontend type to gcctype.
     382                 :             : */
     383                 :             : 
     384                 :      397440 : 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                 :      397440 :   NameKey_Name n;
     387                 :      397440 :   char name[_name_high+1];
     388                 :      397440 :   char min[_min_high+1];
     389                 :      397440 :   char max[_max_high+1];
     390                 :             : 
     391                 :             :   /* make a local copy of each unbounded array.  */
     392                 :      397440 :   memcpy (name, name_, _name_high+1);
     393                 :      397440 :   memcpy (min, min_, _min_high+1);
     394                 :      397440 :   memcpy (max, max_, _max_high+1);
     395                 :             : 
     396                 :      397440 :   M2ALU_PushIntegerTree (m2expr_BuildSize (m2linemap_BuiltinsLocation (), gcctype, false));
     397                 :      397440 :   SymbolTable_PopSize (type);
     398                 :      397440 :   if (Lists_IsItemInList (SystemTypes, type))
     399                 :             :     {
     400                 :           0 :       M2Error_InternalError ((const char *) "not expecting system type to already be declared", 48);
     401                 :             :     }
     402                 :      397440 :   Lists_PutItemIntoList (SystemTypes, type);
     403                 :             :   /* Create min, max constants if type is ordinal or a floating point type.  */
     404                 :      397440 :   if ((! (StrLib_StrEqual ((const char *) min, _min_high, (const char *) "", 0))) && (! (StrLib_StrEqual ((const char *) max, _max_high, (const char *) "", 0))))
     405                 :             :     {
     406                 :      166026 :       CreateMinMaxFor (type, (const char *) min, _min_high, (const char *) max, _max_high, gcctype, realtype);
     407                 :             :     }
     408                 :      397440 :   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                 :      397440 : }
     414                 :             : 
     415                 :             : 
     416                 :             : /*
     417                 :             :    CreateType - create and return a frontend type which matches the GCC tree type.
     418                 :             : */
     419                 :             : 
     420                 :      368000 : 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                 :      368000 :   unsigned int type;
     423                 :      368000 :   char name[_name_high+1];
     424                 :      368000 :   char min[_min_high+1];
     425                 :      368000 :   char max[_max_high+1];
     426                 :             : 
     427                 :             :   /* make a local copy of each unbounded array.  */
     428                 :      368000 :   memcpy (name, name_, _name_high+1);
     429                 :      368000 :   memcpy (min, min_, _min_high+1);
     430                 :      368000 :   memcpy (max, max_, _max_high+1);
     431                 :             : 
     432                 :      368000 :   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                 :      338560 :       type = SymbolTable_MakeType (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) name, _name_high));
     441                 :      338560 :       SymbolTable_PutType (type, SymbolTable_NulSym);  /* a Base Type  */
     442                 :      338560 :       MapType (type, (const char *) name, _name_high, (const char *) min, _min_high, (const char *) max, _max_high, needsExporting, gccType, realtype);  /* a Base Type  */
     443                 :      338560 :       return type;
     444                 :             :     }
     445                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     446                 :             :   __builtin_unreachable ();
     447                 :      368000 : }
     448                 :             : 
     449                 :             : 
     450                 :             : /*
     451                 :             :    AttemptToCreateType - attempts to create a frontend type which matches the
     452                 :             :                          GCC tree type.
     453                 :             : */
     454                 :             : 
     455                 :      279680 : 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                 :      279680 :   char name[_name_high+1];
     458                 :      279680 :   char min[_min_high+1];
     459                 :      279680 :   char max[_max_high+1];
     460                 :             : 
     461                 :             :   /* make a local copy of each unbounded array.  */
     462                 :      279680 :   memcpy (name, name_, _name_high+1);
     463                 :      279680 :   memcpy (min, min_, _min_high+1);
     464                 :      279680 :   memcpy (max, max_, _max_high+1);
     465                 :             : 
     466                 :      279680 :   Assertion_Assert (SymbolTable_IsLegal (CreateType ((const char *) name, _name_high, (const char *) min, _min_high, (const char *) max, _max_high, needsExporting, gccType, realtype)));
     467                 :      279680 : }
     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                 :       44160 : static unsigned int CreateSetType (const char *name_, unsigned int _name_high, const char *highBit_, unsigned int _highBit_high, bool needsExporting, tree gccType)
     476                 :             : {
     477                 :       44160 :   unsigned int low;
     478                 :       44160 :   unsigned int high;
     479                 :       44160 :   unsigned int subrange;
     480                 :       44160 :   unsigned int type;
     481                 :       44160 :   char name[_name_high+1];
     482                 :       44160 :   char highBit[_highBit_high+1];
     483                 :             : 
     484                 :             :   /* make a local copy of each unbounded array.  */
     485                 :       44160 :   memcpy (name, name_, _name_high+1);
     486                 :       44160 :   memcpy (highBit, highBit_, _highBit_high+1);
     487                 :             : 
     488                 :       44160 :   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                 :       44160 :       type = SymbolTable_MakeSet (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) name, _name_high));
     497                 :       44160 :       low = SymbolTable_MakeConstLit (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "0", 1), M2Base_Cardinal);
     498                 :       44160 :       high = SymbolTable_MakeConstLit (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) highBit, _highBit_high), M2Base_Cardinal);
     499                 :       44160 :       subrange = SymbolTable_MakeSubrange (M2LexBuf_BuiltinTokenNo, NameKey_NulName);
     500                 :       44160 :       SymbolTable_PutSubrange (subrange, low, high, M2Base_Cardinal);
     501                 :       44160 :       SymbolTable_PutSet (type, subrange, false);
     502                 :       44160 :       MapType (type, (const char *) name, _name_high, (const char *) "", 0, (const char *) "", 0, needsExporting, gccType, false);
     503                 :       44160 :       return type;
     504                 :             :     }
     505                 :             :   /* static analysis guarentees a RETURN statement will be used before here.  */
     506                 :             :   __builtin_unreachable ();
     507                 :       44160 : }
     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                 :       44160 : static void AttemptToCreateSetType (const char *name_, unsigned int _name_high, const char *highBit_, unsigned int _highBit_high, bool needsExporting, tree gccType)
     516                 :             : {
     517                 :       44160 :   char name[_name_high+1];
     518                 :       44160 :   char highBit[_highBit_high+1];
     519                 :             : 
     520                 :             :   /* make a local copy of each unbounded array.  */
     521                 :       44160 :   memcpy (name, name_, _name_high+1);
     522                 :       44160 :   memcpy (highBit, highBit_, _highBit_high+1);
     523                 :             : 
     524                 :       44160 :   Assertion_Assert (SymbolTable_IsLegal (CreateSetType ((const char *) name, _name_high, (const char *) highBit, _highBit_high, needsExporting, gccType)));
     525                 :       44160 : }
     526                 :             : 
     527                 :             : 
     528                 :             : /*
     529                 :             :    MakeFixedSizedTypes - creates the SYSTEM fixed sized types providing the
     530                 :             :                          gcc backend supports them.
     531                 :             : */
     532                 :             : 
     533                 :       14720 : static void MakeFixedSizedTypes (void)
     534                 :             : {
     535                 :       14720 :   AttemptToCreateType ((const char *) "INTEGER8", 8, (const char *) "MinInteger8", 11, (const char *) "MaxInteger8", 11, true, m2type_GetM2Integer8 (), false);
     536                 :       14720 :   AttemptToCreateType ((const char *) "INTEGER16", 9, (const char *) "MinInteger16", 12, (const char *) "MaxInteger16", 12, true, m2type_GetM2Integer16 (), false);
     537                 :       14720 :   AttemptToCreateType ((const char *) "INTEGER32", 9, (const char *) "MinInteger32", 12, (const char *) "MaxInteger32", 12, true, m2type_GetM2Integer32 (), false);
     538                 :       14720 :   AttemptToCreateType ((const char *) "INTEGER64", 9, (const char *) "MinInteger64", 12, (const char *) "MaxInteger64", 12, true, m2type_GetM2Integer64 (), false);
     539                 :       14720 :   AttemptToCreateType ((const char *) "CARDINAL8", 9, (const char *) "MinCardinal8", 12, (const char *) "MaxCardinal8", 12, true, m2type_GetM2Cardinal8 (), false);
     540                 :       14720 :   AttemptToCreateType ((const char *) "CARDINAL16", 10, (const char *) "MinCardinal16", 13, (const char *) "MaxCardinal16", 13, true, m2type_GetM2Cardinal16 (), false);
     541                 :       14720 :   AttemptToCreateType ((const char *) "CARDINAL32", 10, (const char *) "MinCardinal32", 13, (const char *) "MaxCardinal32", 13, true, m2type_GetM2Cardinal32 (), false);
     542                 :       14720 :   AttemptToCreateType ((const char *) "CARDINAL64", 10, (const char *) "MinCardinal64", 13, (const char *) "MaxCardinal64", 13, true, m2type_GetM2Cardinal64 (), false);
     543                 :       14720 :   AttemptToCreateType ((const char *) "WORD16", 6, (const char *) "", 0, (const char *) "", 0, true, m2type_GetM2Word16 (), false);
     544                 :       14720 :   AttemptToCreateType ((const char *) "WORD32", 6, (const char *) "", 0, (const char *) "", 0, true, m2type_GetM2Word32 (), false);
     545                 :       14720 :   AttemptToCreateType ((const char *) "WORD64", 6, (const char *) "", 0, (const char *) "", 0, true, m2type_GetM2Word64 (), false);
     546                 :       14720 :   AttemptToCreateSetType ((const char *) "BITSET8", 7, (const char *) "7", 1, true, m2type_GetM2Bitset8 ());
     547                 :       14720 :   AttemptToCreateSetType ((const char *) "BITSET16", 8, (const char *) "15", 2, true, m2type_GetM2Bitset16 ());
     548                 :       14720 :   AttemptToCreateSetType ((const char *) "BITSET32", 8, (const char *) "31", 2, true, m2type_GetM2Bitset32 ());
     549                 :       14720 :   AttemptToCreateType ((const char *) "REAL32", 6, (const char *) "MinReal32", 9, (const char *) "MaxReal32", 9, true, m2type_GetM2Real32 (), true);
     550                 :       14720 :   AttemptToCreateType ((const char *) "REAL64", 6, (const char *) "MinReal64", 9, (const char *) "MaxReal64", 9, true, m2type_GetM2Real64 (), true);
     551                 :       14720 :   AttemptToCreateType ((const char *) "REAL96", 6, (const char *) "MinReal96", 9, (const char *) "MaxReal96", 9, true, m2type_GetM2Real96 (), true);
     552                 :       14720 :   AttemptToCreateType ((const char *) "REAL128", 7, (const char *) "MinReal128", 10, (const char *) "MaxReal128", 10, true, m2type_GetM2Real128 (), true);
     553                 :       14720 :   AttemptToCreateType ((const char *) "COMPLEX32", 9, (const char *) "", 0, (const char *) "", 0, true, m2type_GetM2Complex32 (), true);
     554                 :       14720 :   AttemptToCreateType ((const char *) "COMPLEX64", 9, (const char *) "", 0, (const char *) "", 0, true, m2type_GetM2Complex64 (), true);
     555                 :       14720 :   AttemptToCreateType ((const char *) "COMPLEX96", 9, (const char *) "", 0, (const char *) "", 0, true, m2type_GetM2Complex96 (), true);
     556                 :       14720 :   AttemptToCreateType ((const char *) "COMPLEX128", 10, (const char *) "", 0, (const char *) "", 0, true, m2type_GetM2Complex128 (), true);
     557                 :       14720 : }
     558                 :             : 
     559                 :             : 
     560                 :             : /*
     561                 :             :    InitPIMTypes -
     562                 :             : */
     563                 :             : 
     564                 :       10614 : static void InitPIMTypes (void)
     565                 :             : {
     566                 :       10614 :   M2System_Loc = CreateType ((const char *) "LOC", 3, (const char *) "", 0, (const char *) "", 0, true, m2type_GetISOLocType (), false);
     567                 :       10614 :   m2type_InitSystemTypes (m2linemap_BuiltinsLocation (), static_cast<int> (M2System_Loc));
     568                 :       10614 :   M2System_Word = CreateType ((const char *) "WORD", 4, (const char *) "", 0, (const char *) "", 0, true, m2type_GetWordType (), false);
     569                 :       10614 :   M2System_Byte = CreateType ((const char *) "BYTE", 4, (const char *) "", 0, (const char *) "", 0, true, m2type_GetByteType (), false);
     570                 :             :   /* ADDRESS = POINTER TO BYTE  */
     571                 :       10614 :   M2System_Address = SymbolTable_MakePointer (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "ADDRESS", 7));
     572                 :       10614 :   SymbolTable_PutPointer (M2System_Address, M2System_Byte);  /* Base Type  */
     573                 :       10614 :   MapType (M2System_Address, (const char *) "ADDRESS", 7, (const char *) "", 0, (const char *) "", 0, true, m2type_GetPointerType (), false);  /* Base Type  */
     574                 :       10614 : }
     575                 :             : 
     576                 :             : 
     577                 :             : /*
     578                 :             :    InitISOTypes -
     579                 :             : */
     580                 :             : 
     581                 :        4106 : static void InitISOTypes (void)
     582                 :             : {
     583                 :        4106 :   M2System_Loc = CreateType ((const char *) "LOC", 3, (const char *) "MinLoc", 6, (const char *) "MaxLoc", 6, true, m2type_GetISOLocType (), false);
     584                 :        4106 :   m2type_InitSystemTypes (m2linemap_BuiltinsLocation (), static_cast<int> (M2System_Loc));
     585                 :        4106 :   M2System_Address = SymbolTable_MakePointer (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "ADDRESS", 7));
     586                 :        4106 :   SymbolTable_PutPointer (M2System_Address, M2System_Loc);  /* Base Type  */
     587                 :        4106 :   MapType (M2System_Address, (const char *) "ADDRESS", 7, (const char *) "", 0, (const char *) "", 0, true, m2type_GetPointerType (), false);  /* Base Type  */
     588                 :        4106 :   M2System_Byte = CreateType ((const char *) "BYTE", 4, (const char *) "", 0, (const char *) "", 0, true, m2type_GetISOByteType (), false);
     589                 :        4106 :   M2System_Word = CreateType ((const char *) "WORD", 4, (const char *) "", 0, (const char *) "", 0, true, m2type_GetISOWordType (), false);
     590                 :        4106 : }
     591                 :             : 
     592                 :             : 
     593                 :             : /*
     594                 :             :    MakeExtraSystemTypes - create any extra system types required
     595                 :             :                           for portability.
     596                 :             : */
     597                 :             : 
     598                 :       14720 : static void MakeExtraSystemTypes (void)
     599                 :             : {
     600                 :       14720 :   M2System_CSizeT = CreateType ((const char *) "CSIZE_T", 7, (const char *) "", 0, (const char *) "", 0, true, m2type_GetCSizeTType (), false);
     601                 :       14720 :   M2System_CSSizeT = CreateType ((const char *) "CSSIZE_T", 8, (const char *) "", 0, (const char *) "", 0, true, m2type_GetCSSizeTType (), false);
     602                 :       14720 :   M2System_COffT = CreateType ((const char *) "COFF_T", 6, (const char *) "", 0, (const char *) "", 0, true, m2type_GetCOffTType (), false);
     603                 :       14720 : }
     604                 :             : 
     605                 :             : 
     606                 :             : /*
     607                 :             :    IsISOPseudoSystemFunction -
     608                 :             : */
     609                 :             : 
     610                 :     3020752 : static bool IsISOPseudoSystemFunction (unsigned int sym)
     611                 :             : {
     612                 :     3020752 :   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                 :     3043926 : static bool IsPIMPseudoSystemFunction (unsigned int sym)
     624                 :             : {
     625                 :     3043926 :   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                 :    46443665 : static unsigned int GetSafeSystem (NameKey_Name name)
     636                 :             : {
     637                 :    46443665 :   unsigned int sym;
     638                 :    46443665 :   unsigned int i;
     639                 :    46443665 :   unsigned int n;
     640                 :             : 
     641                 :    46443665 :   n = Lists_NoOfItemsInList (SystemTypes);
     642                 :    46443665 :   i = 1;
     643                 :   870716542 :   while (i <= n)
     644                 :             :     {
     645                 :   818748644 :       sym = static_cast<unsigned int> (Lists_GetItemFromList (SystemTypes, i));
     646                 :   818748644 :       if ((SymbolTable_GetSymName (sym)) == name)
     647                 :             :         {
     648                 :             :           return sym;
     649                 :             :         }
     650                 :   777829212 :       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                 :       14720 : extern "C" void M2System_InitSystem (void)
     693                 :             : {
     694                 :       14720 :   unsigned int Previous;
     695                 :             : 
     696                 :       14720 :   Init ();
     697                 :             :   /* create SYSTEM module  */
     698                 :       14720 :   M2System_System = M2Batch_MakeDefinitionSource (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "SYSTEM", 6));
     699                 :       14720 :   SymbolTable_StartScope (M2System_System);
     700                 :       14720 :   Previous = SymbolTable_GetCurrentModule ();
     701                 :       14720 :   SymbolTable_SetCurrentModule (M2System_System);
     702                 :       14720 :   if (M2Options_Iso)
     703                 :             :     {
     704                 :        4106 :       InitISOTypes ();
     705                 :        4106 :       M2Size_MakeSize ();
     706                 :        4106 :       SymbolTable_PutExportQualified (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "SIZE", 4));
     707                 :             :     }
     708                 :             :   else
     709                 :             :     {
     710                 :       10614 :       InitPIMTypes ();
     711                 :             :       /* SIZE is declared in SYSTEM.def in PIM-2 but not PIM-[34]  */
     712                 :       10614 :       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                 :       10614 :           M2Size_MakeSize ();
     724                 :       10614 :           SymbolTable_PutExportQualified (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "SIZE", 4));
     725                 :             :         }
     726                 :             :     }
     727                 :             :   /* The predefined pseudo functions.  */
     728                 :       14720 :   M2System_Adr = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "ADR", 3));  /* Function  */
     729                 :       14720 :   SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, M2System_Adr, SymbolTable_DefProcedure, M2System_Address);
     730                 :             :   /* Address  */
     731                 :       14720 :   M2System_TSize = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "TSIZE", 5));  /* Function  */
     732                 :       14720 :   SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, M2System_TSize, SymbolTable_DefProcedure, M2Base_ZType);
     733                 :             :   /* ZType  */
     734                 :       14720 :   M2System_TBitSize = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "TBITSIZE", 8));  /* GNU extension  */
     735                 :             :   /* Function  */
     736                 :       14720 :   SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, M2System_TBitSize, SymbolTable_DefProcedure, M2Base_ZType);
     737                 :             :   /* The ISO specific predefined pseudo functions.  */
     738                 :       14720 :   M2System_AddAdr = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "ADDADR", 6));  /* Function  */
     739                 :       14720 :   SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, M2System_AddAdr, SymbolTable_DefProcedure, M2System_Address);
     740                 :             :   /* Return Type  */
     741                 :       14720 :   M2System_SubAdr = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "SUBADR", 6));  /* Function  */
     742                 :       14720 :   SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, M2System_SubAdr, SymbolTable_DefProcedure, M2System_Address);
     743                 :             :   /* Return Type  */
     744                 :       14720 :   M2System_DifAdr = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "DIFADR", 6));  /* Function  */
     745                 :       14720 :   SymbolTable_PutFunction (M2LexBuf_BuiltinTokenNo, M2System_DifAdr, SymbolTable_DefProcedure, M2System_Address);
     746                 :             :   /* Return Type  */
     747                 :       14720 :   M2System_MakeAdr = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "MAKEADR", 7));  /* Function  */
     748                 :       14720 :   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                 :       14720 :   M2System_Rotate = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "ROTATE", 6));  /* Function  */
     752                 :       14720 :   M2System_Shift = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "SHIFT", 5));  /* Function  */
     753                 :       14720 :   M2System_Cast = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "CAST", 4));  /* Function  */
     754                 :       14720 :   M2System_Throw = SymbolTable_MakeProcedure (M2LexBuf_BuiltinTokenNo, NameKey_MakeKey ((const char *) "THROW", 5));  /* Procedure  */
     755                 :       14720 :   SymbolTable_PutProcedureNoReturn (M2System_Throw, SymbolTable_DefProcedure, true);  /* Procedure  */
     756                 :       14720 :   CreateMinMaxFor (M2System_Word, (const char *) "MinWord", 7, (const char *) "MaxWord", 7, m2type_GetWordType (), false);
     757                 :       14720 :   CreateMinMaxFor (M2System_Address, (const char *) "MinAddress", 10, (const char *) "MaxAddress", 10, m2type_GetPointerType (), false);
     758                 :       14720 :   CreateMinMaxFor (M2System_Byte, (const char *) "MinByte", 7, (const char *) "MaxByte", 7, m2type_GetByteType (), false);
     759                 :       14720 :   MakeFixedSizedTypes ();
     760                 :       14720 :   MakeExtraSystemTypes ();
     761                 :       14720 :   SymbolTable_EndScope ();
     762                 :       14720 :   SymbolTable_SetCurrentModule (Previous);
     763                 :       14720 : }
     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                 :     3099767 : extern "C" bool M2System_IsPseudoSystemFunction (unsigned int sym)
     789                 :             : {
     790                 :     3099767 :   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                 :      142556 : extern "C" bool M2System_IsPseudoSystemProcedure (unsigned int sym)
     801                 :             : {
     802                 :      142556 :   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                 :         324 : extern "C" bool M2System_IsPseudoSystemFunctionConstExpression (unsigned int sym)
     814                 :             : {
     815                 :         324 :   return ((((sym == M2Size_Size) || (sym == M2System_TSize)) || (sym == M2System_Rotate)) || (sym == M2System_Shift)) || (M2Options_Iso && ((sym == M2System_Cast) || (sym == M2System_MakeAdr)));
     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                 :     1373835 : extern "C" bool M2System_IsSystemType (unsigned int sym)
     827                 :             : {
     828                 :     1373835 :   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                 :     3968440 : extern "C" unsigned int M2System_IntegerN (unsigned int bitlength)
     840                 :             : {
     841                 :     3968440 :   switch (bitlength)
     842                 :             :     {
     843                 :     1037212 :       case 8:
     844                 :     1037212 :         return GetSafeSystem (NameKey_MakeKey ((const char *) "INTEGER8", 8));
     845                 :     1005694 :         break;
     846                 :             : 
     847                 :     1005694 :       case 16:
     848                 :     1005694 :         return GetSafeSystem (NameKey_MakeKey ((const char *) "INTEGER16", 9));
     849                 :      976510 :         break;
     850                 :             : 
     851                 :      976510 :       case 32:
     852                 :      976510 :         return GetSafeSystem (NameKey_MakeKey ((const char *) "INTEGER32", 9));
     853                 :      949024 :         break;
     854                 :             : 
     855                 :      949024 :       case 64:
     856                 :      949024 :         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                 :     3514888 : extern "C" unsigned int M2System_CardinalN (unsigned int bitlength)
     875                 :             : {
     876                 :     3514888 :   switch (bitlength)
     877                 :             :     {
     878                 :      923980 :       case 8:
     879                 :      923980 :         return GetSafeSystem (NameKey_MakeKey ((const char *) "CARDINAL8", 9));
     880                 :      891114 :         break;
     881                 :             : 
     882                 :      891114 :       case 16:
     883                 :      891114 :         return GetSafeSystem (NameKey_MakeKey ((const char *) "CARDINAL16", 10));
     884                 :      864198 :         break;
     885                 :             : 
     886                 :      864198 :       case 32:
     887                 :      864198 :         return GetSafeSystem (NameKey_MakeKey ((const char *) "CARDINAL32", 10));
     888                 :      835596 :         break;
     889                 :             : 
     890                 :      835596 :       case 64:
     891                 :      835596 :         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                 :    15550164 : extern "C" unsigned int M2System_WordN (unsigned int bitlength)
     910                 :             : {
     911                 :    15550164 :   switch (bitlength)
     912                 :             :     {
     913                 :     5185520 :       case 16:
     914                 :     5185520 :         return GetSafeSystem (NameKey_MakeKey ((const char *) "WORD16", 6));
     915                 :     5185520 :         break;
     916                 :             : 
     917                 :     5185520 :       case 32:
     918                 :     5185520 :         return GetSafeSystem (NameKey_MakeKey ((const char *) "WORD32", 6));
     919                 :     5179124 :         break;
     920                 :             : 
     921                 :     5179124 :       case 64:
     922                 :     5179124 :         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                 :     1299387 : extern "C" unsigned int M2System_SetN (unsigned int bitlength)
     941                 :             : {
     942                 :     1299387 :   switch (bitlength)
     943                 :             :     {
     944                 :      433129 :       case 8:
     945                 :      433129 :         return GetSafeSystem (NameKey_MakeKey ((const char *) "BITSET8", 7));
     946                 :      433129 :         break;
     947                 :             : 
     948                 :      433129 :       case 16:
     949                 :      433129 :         return GetSafeSystem (NameKey_MakeKey ((const char *) "BITSET16", 8));
     950                 :      433129 :         break;
     951                 :             : 
     952                 :      433129 :       case 32:
     953                 :      433129 :         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                 :     6251598 : extern "C" unsigned int M2System_RealN (unsigned int bitlength)
     972                 :             : {
     973                 :     6251598 :   switch (bitlength)
     974                 :             :     {
     975                 :     1573071 :       case 32:
     976                 :     1573071 :         return GetSafeSystem (NameKey_MakeKey ((const char *) "REAL32", 6));
     977                 :     1559637 :         break;
     978                 :             : 
     979                 :     1559637 :       case 64:
     980                 :     1559637 :         return GetSafeSystem (NameKey_MakeKey ((const char *) "REAL64", 6));
     981                 :     1559445 :         break;
     982                 :             : 
     983                 :     1559445 :       case 96:
     984                 :     1559445 :         return GetSafeSystem (NameKey_MakeKey ((const char *) "REAL96", 6));
     985                 :     1559445 :         break;
     986                 :             : 
     987                 :     1559445 :       case 128:
     988                 :     1559445 :         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                 :    15859188 : extern "C" unsigned int M2System_ComplexN (unsigned int bitlength)
    1007                 :             : {
    1008                 :    15859188 :   switch (bitlength)
    1009                 :             :     {
    1010                 :     3964824 :       case 32:
    1011                 :     3964824 :         return GetSafeSystem (NameKey_MakeKey ((const char *) "COMPLEX32", 9));
    1012                 :     3964788 :         break;
    1013                 :             : 
    1014                 :     3964788 :       case 64:
    1015                 :     3964788 :         return GetSafeSystem (NameKey_MakeKey ((const char *) "COMPLEX64", 9));
    1016                 :     3964788 :         break;
    1017                 :             : 
    1018                 :     3964788 :       case 96:
    1019                 :     3964788 :         return GetSafeSystem (NameKey_MakeKey ((const char *) "COMPLEX96", 9));
    1020                 :     3964788 :         break;
    1021                 :             : 
    1022                 :     3964788 :       case 128:
    1023                 :     3964788 :         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                 :      641239 : extern "C" bool M2System_IsIntegerN (unsigned int sym)
    1042                 :             : {
    1043                 :      641239 :   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                 :      640891 : extern "C" bool M2System_IsCardinalN (unsigned int sym)
    1055                 :             : {
    1056                 :      640891 :   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                 :     5020981 : extern "C" bool M2System_IsWordN (unsigned int sym)
    1068                 :             : {
    1069                 :     5020981 :   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                 :      270106 : extern "C" bool M2System_IsSetN (unsigned int sym)
    1081                 :             : {
    1082                 :      270106 :   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                 :     1410030 : extern "C" bool M2System_IsRealN (unsigned int sym)
    1094                 :             : {
    1095                 :     1410030 :   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                 :     3871306 : extern "C" bool M2System_IsComplexN (unsigned int sym)
    1108                 :             : {
    1109                 :     3871306 :   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                 :     3065133 : extern "C" bool M2System_IsGenericSystemType (unsigned int sym)
    1121                 :             : {
    1122                 :     3065133 :   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                 :        5324 : extern "C" bool M2System_IsSameSize (unsigned int a, unsigned int b)
    1147                 :             : {
    1148                 :        5324 :   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                 :       14720 : extern "C" void _M2_M2System_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
    1154                 :             : {
    1155                 :       14720 : }
    1156                 :             : 
    1157                 :           0 : extern "C" void _M2_M2System_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
    1158                 :             : {
    1159                 :           0 : }
        

Generated by: LCOV version 2.1-beta

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto,rust,m2 --enable-host-shared. GCC test suite is run with the built compiler.