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