LCOV - code coverage report
Current view: top level - gcc/m2/gm2-gcc - m2builtins.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 92.0 % 425 391
Test Date: 2023-09-09 13:19:57 Functions: 89.7 % 39 35
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* m2builtins.cc provides an interface to the GCC builtins.
       2                 :             : 
       3                 :             : Copyright (C) 2012-2023 Free Software Foundation, Inc.
       4                 :             : Contributed by Gaius Mulley <gaius@glam.ac.uk>.
       5                 :             : 
       6                 :             : This file is part of GNU Modula-2.
       7                 :             : 
       8                 :             : GNU Modula-2 is free software; you can redistribute it and/or modify
       9                 :             : it under the terms of the GNU General Public License as published by
      10                 :             : the Free Software Foundation; either version 3, or (at your option)
      11                 :             : any later version.
      12                 :             : 
      13                 :             : GNU Modula-2 is distributed in the hope that it will be useful, but
      14                 :             : WITHOUT ANY WARRANTY; without even the implied warranty of
      15                 :             : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      16                 :             : General Public License for more details.
      17                 :             : 
      18                 :             : You should have received a copy of the GNU General Public License
      19                 :             : along with GNU Modula-2; see the file COPYING3.  If not see
      20                 :             : <http://www.gnu.org/licenses/>.  */
      21                 :             : 
      22                 :             : #include "gcc-consolidation.h"
      23                 :             : 
      24                 :             : #include "m2block.h"
      25                 :             : #include "m2convert.h"
      26                 :             : #include "m2decl.h"
      27                 :             : #include "m2expr.h"
      28                 :             : #include "m2statement.h"
      29                 :             : #include "m2tree.h"
      30                 :             : #include "m2treelib.h"
      31                 :             : #include "m2type.h"
      32                 :             : 
      33                 :             : #define GM2
      34                 :             : #define GM2_BUG_REPORT                                                        \
      35                 :             :   "Please report this crash to the GNU Modula-2 mailing list "                \
      36                 :             :   "<gm2@nongnu.org>\n"
      37                 :             : 
      38                 :             : #define ASSERT(X, Y)                                                          \
      39                 :             :   {                                                                           \
      40                 :             :     if (!(X))                                                                 \
      41                 :             :       {                                                                       \
      42                 :             :         debug_tree (Y);                                                       \
      43                 :             :         internal_error ("%s:%d:assertion of condition %qs failed", __FILE__, __LINE__,  \
      44                 :             :                         #X);                                                  \
      45                 :             :       }                                                                       \
      46                 :             :   }
      47                 :             : #define ERROR(X)                                                              \
      48                 :             :   {                                                                           \
      49                 :             :     internal_error ("%s:%d:%s", __FILE__, __LINE__, X);                     \
      50                 :             :   }
      51                 :             : 
      52                 :             : typedef enum {
      53                 :             :   BT_FN_NONE,
      54                 :             :   BT_FN_PTR_SIZE,
      55                 :             :   BT_FN_TRAD_PTR_PTR_CONST_PTR_SIZE,
      56                 :             :   BT_FN_FLOAT,
      57                 :             :   BT_FN_DOUBLE,
      58                 :             :   BT_FN_LONG_DOUBLE,
      59                 :             :   BT_FN_FLOAT_FLOAT,
      60                 :             :   BT_FN_DOUBLE_DOUBLE,
      61                 :             :   BT_FN_LONG_DOUBLE_LONG_DOUBLE,
      62                 :             :   BT_FN_STRING_CONST_STRING_INT,
      63                 :             :   BT_FN_INT_CONST_PTR_CONST_PTR_SIZE,
      64                 :             :   BT_FN_TRAD_PTR_PTR_INT_SIZE,
      65                 :             :   BT_FN_STRING_STRING_CONST_STRING,
      66                 :             :   BT_FN_STRING_STRING_CONST_STRING_SIZE,
      67                 :             :   BT_FN_INT_CONST_STRING_CONST_STRING,
      68                 :             :   BT_FN_INT_CONST_STRING_CONST_STRING_SIZE,
      69                 :             :   BT_FN_INT_CONST_STRING,
      70                 :             :   BT_FN_STRING_CONST_STRING_CONST_STRING,
      71                 :             :   BT_FN_SIZE_CONST_STRING_CONST_STRING,
      72                 :             :   BT_FN_PTR_UNSIGNED,
      73                 :             :   BT_FN_VOID_PTR_INT,
      74                 :             :   BT_FN_INT_PTR,
      75                 :             :   BT_FN_INT_FLOAT,
      76                 :             :   BT_FN_INT_DOUBLE,
      77                 :             :   BT_FN_INT_LONG_DOUBLE,
      78                 :             :   BT_FN_FLOAT_FCOMPLEX,
      79                 :             :   BT_FN_DOUBLE_DCOMPLEX,
      80                 :             :   BT_FN_LONG_DOUBLE_LDCOMPLEX,
      81                 :             : 
      82                 :             :   BT_FN_FCOMPLEX_FCOMPLEX,
      83                 :             :   BT_FN_DCOMPLEX_DCOMPLEX,
      84                 :             :   BT_FN_LDCOMPLEX_LDCOMPLEX,
      85                 :             : 
      86                 :             :   BT_FN_DCOMPLEX_DOUBLE_DCOMPLEX,
      87                 :             :   BT_FN_FCOMPLEX_FLOAT_FCOMPLEX,
      88                 :             :   BT_FN_LDCOMPLEX_LONG_DOUBLE_LDCOMPLEX,
      89                 :             : 
      90                 :             :   BT_FN_FLOAT_FLOAT_FLOATPTR,
      91                 :             :   BT_FN_DOUBLE_DOUBLE_DOUBLEPTR,
      92                 :             :   BT_FN_LONG_DOUBLE_LONG_DOUBLE_LONG_DOUBLEPTR,
      93                 :             : 
      94                 :             :   BT_FN_FLOAT_FLOAT_LONG_DOUBLE,
      95                 :             :   BT_FN_DOUBLE_DOUBLE_LONG_DOUBLE,
      96                 :             :   BT_FN_LONG_DOUBLE_LONG_DOUBLE_LONG_DOUBLE,
      97                 :             : 
      98                 :             :   BT_FN_FLOAT_FLOAT_LONG,
      99                 :             :   BT_FN_DOUBLE_DOUBLE_LONG,
     100                 :             :   BT_FN_LONG_DOUBLE_LONG_DOUBLE_LONG,
     101                 :             : 
     102                 :             :   BT_FN_FLOAT_FLOAT_INT,
     103                 :             :   BT_FN_DOUBLE_DOUBLE_INT,
     104                 :             :   BT_FN_LONG_DOUBLE_LONG_DOUBLE_INT,
     105                 :             : 
     106                 :             :   BT_FN_FLOAT_FLOAT_FLOAT,
     107                 :             :   BT_FN_DOUBLE_DOUBLE_DOUBLE,
     108                 :             : } builtin_prototype;
     109                 :             : 
     110                 :             : struct builtin_function_entry
     111                 :             : {
     112                 :             :   const char *name;
     113                 :             :   builtin_prototype defn;
     114                 :             :   int function_code;
     115                 :             :   enum built_in_class fclass;
     116                 :             :   const char *library_name;
     117                 :             :   tree function_node;
     118                 :             :   tree return_node;
     119                 :             : };
     120                 :             : 
     121                 :             : /* Entries are added by examining gcc/builtins.def and copying those
     122                 :             :    functions which can be applied to Modula-2.  */
     123                 :             : 
     124                 :             : static struct builtin_function_entry list_of_builtins[] = {
     125                 :             :   { "__builtin_alloca", BT_FN_PTR_SIZE, BUILT_IN_ALLOCA, BUILT_IN_NORMAL,
     126                 :             :     "alloca", NULL, NULL },
     127                 :             :   { "__builtin_memcpy", BT_FN_TRAD_PTR_PTR_CONST_PTR_SIZE, BUILT_IN_MEMCPY,
     128                 :             :     BUILT_IN_NORMAL, "memcpy", NULL, NULL },
     129                 :             : 
     130                 :             :   { "__builtin_isfinite", BT_FN_INT_DOUBLE, BUILT_IN_ISFINITE, BUILT_IN_NORMAL,
     131                 :             :     "isfinite", NULL, NULL },
     132                 :             : 
     133                 :             :   { "__builtin_sinf", BT_FN_FLOAT_FLOAT, BUILT_IN_SINF, BUILT_IN_NORMAL,
     134                 :             :     "sinf", NULL, NULL },
     135                 :             :   { "__builtin_sin", BT_FN_DOUBLE_DOUBLE, BUILT_IN_SIN, BUILT_IN_NORMAL, "sin",
     136                 :             :     NULL, NULL },
     137                 :             :   { "__builtin_sinl", BT_FN_LONG_DOUBLE_LONG_DOUBLE, BUILT_IN_SINL,
     138                 :             :     BUILT_IN_NORMAL, "sinl", NULL, NULL },
     139                 :             :   { "__builtin_cosf", BT_FN_FLOAT_FLOAT, BUILT_IN_SINF, BUILT_IN_NORMAL,
     140                 :             :     "cosf", NULL, NULL },
     141                 :             :   { "__builtin_cos", BT_FN_DOUBLE_DOUBLE, BUILT_IN_COS, BUILT_IN_NORMAL, "cos",
     142                 :             :     NULL, NULL },
     143                 :             :   { "__builtin_cosl", BT_FN_LONG_DOUBLE_LONG_DOUBLE, BUILT_IN_COSL,
     144                 :             :     BUILT_IN_NORMAL, "cosl", NULL, NULL },
     145                 :             :   { "__builtin_sqrtf", BT_FN_FLOAT_FLOAT, BUILT_IN_SQRTF, BUILT_IN_NORMAL,
     146                 :             :     "sqrtf", NULL, NULL },
     147                 :             :   { "__builtin_sqrt", BT_FN_DOUBLE_DOUBLE, BUILT_IN_SQRT, BUILT_IN_NORMAL,
     148                 :             :     "sqrt", NULL, NULL },
     149                 :             :   { "__builtin_sqrtl", BT_FN_LONG_DOUBLE_LONG_DOUBLE, BUILT_IN_SQRTL,
     150                 :             :     BUILT_IN_NORMAL, "sqrtl", NULL, NULL },
     151                 :             :   { "__builtin_fabsf", BT_FN_FLOAT_FLOAT, BUILT_IN_FABSF, BUILT_IN_NORMAL,
     152                 :             :     "fabsf", NULL, NULL },
     153                 :             :   { "__builtin_fabs", BT_FN_DOUBLE_DOUBLE, BUILT_IN_FABS, BUILT_IN_NORMAL,
     154                 :             :     "fabs", NULL, NULL },
     155                 :             :   { "__builtin_fabsl", BT_FN_LONG_DOUBLE_LONG_DOUBLE, BUILT_IN_FABSL,
     156                 :             :     BUILT_IN_NORMAL, "fabsl", NULL, NULL },
     157                 :             :   { "__builtin_logf", BT_FN_FLOAT_FLOAT, BUILT_IN_LOGF, BUILT_IN_NORMAL,
     158                 :             :     "logf", NULL, NULL },
     159                 :             :   { "__builtin_log", BT_FN_DOUBLE_DOUBLE, BUILT_IN_LOG, BUILT_IN_NORMAL, "log",
     160                 :             :     NULL, NULL },
     161                 :             :   { "__builtin_logl", BT_FN_LONG_DOUBLE_LONG_DOUBLE, BUILT_IN_LOGL,
     162                 :             :     BUILT_IN_NORMAL, "logl", NULL, NULL },
     163                 :             :   { "__builtin_expf", BT_FN_FLOAT_FLOAT, BUILT_IN_EXPF, BUILT_IN_NORMAL,
     164                 :             :     "expf", NULL, NULL },
     165                 :             :   { "__builtin_exp", BT_FN_DOUBLE_DOUBLE, BUILT_IN_EXP, BUILT_IN_NORMAL, "exp",
     166                 :             :     NULL, NULL },
     167                 :             :   { "__builtin_expl", BT_FN_LONG_DOUBLE_LONG_DOUBLE, BUILT_IN_EXPL,
     168                 :             :     BUILT_IN_NORMAL, "expl", NULL, NULL },
     169                 :             :   { "__builtin_log10f", BT_FN_FLOAT_FLOAT, BUILT_IN_LOG10F, BUILT_IN_NORMAL,
     170                 :             :     "log10f", NULL, NULL },
     171                 :             :   { "__builtin_log10", BT_FN_DOUBLE_DOUBLE, BUILT_IN_LOG10, BUILT_IN_NORMAL,
     172                 :             :     "log10", NULL, NULL },
     173                 :             :   { "__builtin_log10l", BT_FN_LONG_DOUBLE_LONG_DOUBLE, BUILT_IN_LOG10L,
     174                 :             :     BUILT_IN_NORMAL, "log10l", NULL, NULL },
     175                 :             :   { "__builtin_ilogbf", BT_FN_INT_FLOAT, BUILT_IN_ILOGBF, BUILT_IN_NORMAL,
     176                 :             :     "ilogbf", NULL, NULL },
     177                 :             :   { "__builtin_ilogb", BT_FN_INT_DOUBLE, BUILT_IN_ILOGB, BUILT_IN_NORMAL,
     178                 :             :     "ilogb", NULL, NULL },
     179                 :             :   { "__builtin_ilogbl", BT_FN_INT_LONG_DOUBLE, BUILT_IN_ILOGBL,
     180                 :             :     BUILT_IN_NORMAL, "ilogbl", NULL, NULL },
     181                 :             : 
     182                 :             :   { "__builtin_atan2f", BT_FN_FLOAT_FLOAT_FLOAT, BUILT_IN_ATAN2F,
     183                 :             :     BUILT_IN_NORMAL, "atan2f", NULL, NULL },
     184                 :             :   { "__builtin_atan2", BT_FN_DOUBLE_DOUBLE_DOUBLE, BUILT_IN_ATAN2,
     185                 :             :     BUILT_IN_NORMAL, "atan2", NULL, NULL },
     186                 :             :   { "__builtin_atan2l", BT_FN_LONG_DOUBLE_LONG_DOUBLE_LONG_DOUBLE,
     187                 :             :     BUILT_IN_ATAN2L, BUILT_IN_NORMAL, "atan2l", NULL, NULL },
     188                 :             : 
     189                 :             :   { "__builtin_signbit", BT_FN_INT_DOUBLE, BUILT_IN_SIGNBIT, BUILT_IN_NORMAL,
     190                 :             :     "signbit", NULL, NULL },
     191                 :             :   { "__builtin_signbitf", BT_FN_INT_FLOAT, BUILT_IN_SIGNBITF, BUILT_IN_NORMAL,
     192                 :             :     "signbitf", NULL, NULL },
     193                 :             :   { "__builtin_signbitl", BT_FN_INT_LONG_DOUBLE, BUILT_IN_SIGNBITL,
     194                 :             :     BUILT_IN_NORMAL, "signbitl", NULL, NULL },
     195                 :             :   { "__builtin_modf", BT_FN_DOUBLE_DOUBLE_DOUBLEPTR, BUILT_IN_MODF,
     196                 :             :     BUILT_IN_NORMAL, "modf", NULL, NULL },
     197                 :             :   { "__builtin_modff", BT_FN_FLOAT_FLOAT_FLOATPTR, BUILT_IN_MODFF,
     198                 :             :     BUILT_IN_NORMAL, "modff", NULL, NULL },
     199                 :             :   { "__builtin_modfl", BT_FN_LONG_DOUBLE_LONG_DOUBLE_LONG_DOUBLEPTR,
     200                 :             :     BUILT_IN_MODFL, BUILT_IN_NORMAL, "modfl", NULL, NULL },
     201                 :             :   { "__builtin_nextafter", BT_FN_DOUBLE_DOUBLE_DOUBLE, BUILT_IN_NEXTAFTER,
     202                 :             :     BUILT_IN_NORMAL, "nextafter", NULL, NULL },
     203                 :             :   { "__builtin_nextafterf", BT_FN_FLOAT_FLOAT_FLOAT, BUILT_IN_NEXTAFTERF,
     204                 :             :     BUILT_IN_NORMAL, "nextafterf", NULL, NULL },
     205                 :             :   { "__builtin_nextafterl", BT_FN_LONG_DOUBLE_LONG_DOUBLE_LONG_DOUBLE,
     206                 :             :     BUILT_IN_NEXTAFTERL, BUILT_IN_NORMAL, "nextafterl", NULL, NULL },
     207                 :             :   { "__builtin_nexttoward", BT_FN_DOUBLE_DOUBLE_LONG_DOUBLE,
     208                 :             :     BUILT_IN_NEXTTOWARD, BUILT_IN_NORMAL, "nexttoward", NULL, NULL },
     209                 :             :   { "__builtin_nexttowardf", BT_FN_FLOAT_FLOAT_LONG_DOUBLE,
     210                 :             :     BUILT_IN_NEXTTOWARDF, BUILT_IN_NORMAL, "nexttowardf", NULL, NULL },
     211                 :             :   { "__builtin_nexttowardl", BT_FN_LONG_DOUBLE_LONG_DOUBLE_LONG_DOUBLE,
     212                 :             :     BUILT_IN_NEXTTOWARDL, BUILT_IN_NORMAL, "nexttowardl", NULL, NULL },
     213                 :             :   { "__builtin_scalbln", BT_FN_DOUBLE_DOUBLE_LONG, BUILT_IN_SCALBLN,
     214                 :             :     BUILT_IN_NORMAL, "scalbln", NULL, NULL },
     215                 :             :   { "__builtin_scalblnf", BT_FN_FLOAT_FLOAT_LONG, BUILT_IN_SCALBLNF,
     216                 :             :     BUILT_IN_NORMAL, "scalblnf", NULL, NULL },
     217                 :             :   { "__builtin_scalblnl", BT_FN_LONG_DOUBLE_LONG_DOUBLE_LONG,
     218                 :             :     BUILT_IN_SCALBLNL, BUILT_IN_NORMAL, "scalblnl", NULL, NULL },
     219                 :             :   { "__builtin_scalbn", BT_FN_DOUBLE_DOUBLE_INT, BUILT_IN_SCALBN,
     220                 :             :     BUILT_IN_NORMAL, "scalbln", NULL, NULL },
     221                 :             :   { "__builtin_scalbnf", BT_FN_FLOAT_FLOAT_INT, BUILT_IN_SCALBNF,
     222                 :             :     BUILT_IN_NORMAL, "scalblnf", NULL, NULL },
     223                 :             :   { "__builtin_scalbnl", BT_FN_LONG_DOUBLE_LONG_DOUBLE_INT, BUILT_IN_SCALBNL,
     224                 :             :     BUILT_IN_NORMAL, "scalblnl", NULL, NULL },
     225                 :             : 
     226                 :             :   /* Complex intrinsic functions.  */
     227                 :             :   { "__builtin_cabs", BT_FN_DOUBLE_DCOMPLEX, BUILT_IN_CABS, BUILT_IN_NORMAL,
     228                 :             :     "cabs", NULL, NULL },
     229                 :             :   { "__builtin_cabsf", BT_FN_FLOAT_FCOMPLEX, BUILT_IN_CABSF, BUILT_IN_NORMAL,
     230                 :             :     "cabsf", NULL, NULL },
     231                 :             :   { "__builtin_cabsl", BT_FN_LONG_DOUBLE_LDCOMPLEX, BUILT_IN_CABSL,
     232                 :             :     BUILT_IN_NORMAL, "cabsl", NULL, NULL },
     233                 :             : 
     234                 :             :   { "__builtin_carg", BT_FN_DOUBLE_DCOMPLEX, BUILT_IN_CABS, BUILT_IN_NORMAL,
     235                 :             :     "carg", NULL, NULL },
     236                 :             :   { "__builtin_cargf", BT_FN_FLOAT_FCOMPLEX, BUILT_IN_CABSF, BUILT_IN_NORMAL,
     237                 :             :     "cargf", NULL, NULL },
     238                 :             :   { "__builtin_cargl", BT_FN_LONG_DOUBLE_LDCOMPLEX, BUILT_IN_CABSL,
     239                 :             :     BUILT_IN_NORMAL, "cargl", NULL, NULL },
     240                 :             : 
     241                 :             :   { "__builtin_conj", BT_FN_DCOMPLEX_DCOMPLEX, BUILT_IN_CONJ, BUILT_IN_NORMAL,
     242                 :             :     "carg", NULL, NULL },
     243                 :             :   { "__builtin_conjf", BT_FN_FCOMPLEX_FCOMPLEX, BUILT_IN_CONJF,
     244                 :             :     BUILT_IN_NORMAL, "conjf", NULL, NULL },
     245                 :             :   { "__builtin_conjl", BT_FN_LDCOMPLEX_LDCOMPLEX, BUILT_IN_CONJL,
     246                 :             :     BUILT_IN_NORMAL, "conjl", NULL, NULL },
     247                 :             : 
     248                 :             :   { "__builtin_cpow", BT_FN_DCOMPLEX_DOUBLE_DCOMPLEX, BUILT_IN_CPOW,
     249                 :             :     BUILT_IN_NORMAL, "cpow", NULL, NULL },
     250                 :             :   { "__builtin_cpowf", BT_FN_FCOMPLEX_FLOAT_FCOMPLEX, BUILT_IN_CPOWF,
     251                 :             :     BUILT_IN_NORMAL, "cpowf", NULL, NULL },
     252                 :             :   { "__builtin_cpowl", BT_FN_LDCOMPLEX_LONG_DOUBLE_LDCOMPLEX, BUILT_IN_CPOWL,
     253                 :             :     BUILT_IN_NORMAL, "cpowl", NULL, NULL },
     254                 :             : 
     255                 :             :   { "__builtin_csqrt", BT_FN_DCOMPLEX_DCOMPLEX, BUILT_IN_CSQRT,
     256                 :             :     BUILT_IN_NORMAL, "csqrt", NULL, NULL },
     257                 :             :   { "__builtin_csqrtf", BT_FN_FCOMPLEX_FCOMPLEX, BUILT_IN_CSQRTF,
     258                 :             :     BUILT_IN_NORMAL, "csqrtf", NULL, NULL },
     259                 :             :   { "__builtin_csqrtl", BT_FN_LDCOMPLEX_LDCOMPLEX, BUILT_IN_CSQRTL,
     260                 :             :     BUILT_IN_NORMAL, "csqrtl", NULL, NULL },
     261                 :             : 
     262                 :             :   { "__builtin_cexp", BT_FN_DCOMPLEX_DCOMPLEX, BUILT_IN_CEXP, BUILT_IN_NORMAL,
     263                 :             :     "cexp", NULL, NULL },
     264                 :             :   { "__builtin_cexpf", BT_FN_FCOMPLEX_FCOMPLEX, BUILT_IN_CEXPF,
     265                 :             :     BUILT_IN_NORMAL, "cexpf", NULL, NULL },
     266                 :             :   { "__builtin_cexpl", BT_FN_LDCOMPLEX_LDCOMPLEX, BUILT_IN_CEXPL,
     267                 :             :     BUILT_IN_NORMAL, "cexpl", NULL, NULL },
     268                 :             : 
     269                 :             :   { "__builtin_cln", BT_FN_DCOMPLEX_DCOMPLEX, BUILT_IN_CLOG, BUILT_IN_NORMAL,
     270                 :             :     "cln", NULL, NULL },
     271                 :             :   { "__builtin_clnf", BT_FN_FCOMPLEX_FCOMPLEX, BUILT_IN_CLOGF, BUILT_IN_NORMAL,
     272                 :             :     "clnf", NULL, NULL },
     273                 :             :   { "__builtin_clnl", BT_FN_LDCOMPLEX_LDCOMPLEX, BUILT_IN_CLOGL,
     274                 :             :     BUILT_IN_NORMAL, "clnl", NULL, NULL },
     275                 :             : 
     276                 :             :   { "__builtin_csin", BT_FN_DCOMPLEX_DCOMPLEX, BUILT_IN_CSIN, BUILT_IN_NORMAL,
     277                 :             :     "csin", NULL, NULL },
     278                 :             :   { "__builtin_csinf", BT_FN_FCOMPLEX_FCOMPLEX, BUILT_IN_CSINF,
     279                 :             :     BUILT_IN_NORMAL, "csinf", NULL, NULL },
     280                 :             :   { "__builtin_csinl", BT_FN_LDCOMPLEX_LDCOMPLEX, BUILT_IN_CSINL,
     281                 :             :     BUILT_IN_NORMAL, "csinl", NULL, NULL },
     282                 :             : 
     283                 :             :   { "__builtin_ccos", BT_FN_DCOMPLEX_DCOMPLEX, BUILT_IN_CCOS, BUILT_IN_NORMAL,
     284                 :             :     "ccos", NULL, NULL },
     285                 :             :   { "__builtin_ccosf", BT_FN_FCOMPLEX_FCOMPLEX, BUILT_IN_CCOSF,
     286                 :             :     BUILT_IN_NORMAL, "ccosf", NULL, NULL },
     287                 :             :   { "__builtin_ccosl", BT_FN_LDCOMPLEX_LDCOMPLEX, BUILT_IN_CCOSL,
     288                 :             :     BUILT_IN_NORMAL, "ccosl", NULL, NULL },
     289                 :             : 
     290                 :             :   { "__builtin_ctan", BT_FN_DCOMPLEX_DCOMPLEX, BUILT_IN_CTAN, BUILT_IN_NORMAL,
     291                 :             :     "ctan", NULL, NULL },
     292                 :             :   { "__builtin_ctanf", BT_FN_FCOMPLEX_FCOMPLEX, BUILT_IN_CTANF,
     293                 :             :     BUILT_IN_NORMAL, "ctanf", NULL, NULL },
     294                 :             :   { "__builtin_ctanl", BT_FN_LDCOMPLEX_LDCOMPLEX, BUILT_IN_CTANL,
     295                 :             :     BUILT_IN_NORMAL, "ctanl", NULL, NULL },
     296                 :             : 
     297                 :             :   { "__builtin_casin", BT_FN_DCOMPLEX_DCOMPLEX, BUILT_IN_CASIN,
     298                 :             :     BUILT_IN_NORMAL, "casin", NULL, NULL },
     299                 :             :   { "__builtin_casinf", BT_FN_FCOMPLEX_FCOMPLEX, BUILT_IN_CASINF,
     300                 :             :     BUILT_IN_NORMAL, "casinf", NULL, NULL },
     301                 :             :   { "__builtin_casinl", BT_FN_LDCOMPLEX_LDCOMPLEX, BUILT_IN_CASINL,
     302                 :             :     BUILT_IN_NORMAL, "casinl", NULL, NULL },
     303                 :             : 
     304                 :             :   { "__builtin_cacos", BT_FN_DCOMPLEX_DCOMPLEX, BUILT_IN_CACOS,
     305                 :             :     BUILT_IN_NORMAL, "cacos", NULL, NULL },
     306                 :             :   { "__builtin_cacosf", BT_FN_FCOMPLEX_FCOMPLEX, BUILT_IN_CACOSF,
     307                 :             :     BUILT_IN_NORMAL, "cacosf", NULL, NULL },
     308                 :             :   { "__builtin_cacosl", BT_FN_LDCOMPLEX_LDCOMPLEX, BUILT_IN_CACOSL,
     309                 :             :     BUILT_IN_NORMAL, "cacosl", NULL, NULL },
     310                 :             : 
     311                 :             :   { "__builtin_catan", BT_FN_DCOMPLEX_DCOMPLEX, BUILT_IN_CATAN,
     312                 :             :     BUILT_IN_NORMAL, "catan", NULL, NULL },
     313                 :             :   { "__builtin_catanf", BT_FN_FCOMPLEX_FCOMPLEX, BUILT_IN_CATANF,
     314                 :             :     BUILT_IN_NORMAL, "catanf", NULL, NULL },
     315                 :             :   { "__builtin_catanl", BT_FN_LDCOMPLEX_LDCOMPLEX, BUILT_IN_CATANL,
     316                 :             :     BUILT_IN_NORMAL, "catanl", NULL, NULL },
     317                 :             : 
     318                 :             :   { "__builtin_huge_val", BT_FN_DOUBLE, BUILT_IN_HUGE_VAL, BUILT_IN_NORMAL,
     319                 :             :     "huge_val", NULL, NULL },
     320                 :             :   { "__builtin_huge_valf", BT_FN_FLOAT, BUILT_IN_HUGE_VALF, BUILT_IN_NORMAL,
     321                 :             :     "huge_valf", NULL, NULL },
     322                 :             :   { "__builtin_huge_vall", BT_FN_LONG_DOUBLE, BUILT_IN_HUGE_VALL,
     323                 :             :     BUILT_IN_NORMAL, "huge_vall", NULL, NULL },
     324                 :             : 
     325                 :             :   { "__builtin_index", BT_FN_STRING_CONST_STRING_INT, BUILT_IN_INDEX,
     326                 :             :     BUILT_IN_NORMAL, "index", NULL, NULL },
     327                 :             :   { "__builtin_rindex", BT_FN_STRING_CONST_STRING_INT, BUILT_IN_RINDEX,
     328                 :             :     BUILT_IN_NORMAL, "rindex", NULL, NULL },
     329                 :             :   { "__builtin_memcmp", BT_FN_INT_CONST_PTR_CONST_PTR_SIZE, BUILT_IN_MEMCMP,
     330                 :             :     BUILT_IN_NORMAL, "memcmp", NULL, NULL },
     331                 :             :   { "__builtin_memmove", BT_FN_TRAD_PTR_PTR_CONST_PTR_SIZE, BUILT_IN_MEMMOVE,
     332                 :             :     BUILT_IN_NORMAL, "memmove", NULL, NULL },
     333                 :             :   { "__builtin_memset", BT_FN_TRAD_PTR_PTR_INT_SIZE, BUILT_IN_MEMSET,
     334                 :             :     BUILT_IN_NORMAL, "memset", NULL, NULL },
     335                 :             :   { "__builtin_strcat", BT_FN_STRING_STRING_CONST_STRING, BUILT_IN_STRCAT,
     336                 :             :     BUILT_IN_NORMAL, "strcat", NULL, NULL },
     337                 :             :   { "__builtin_strncat", BT_FN_STRING_STRING_CONST_STRING_SIZE,
     338                 :             :     BUILT_IN_STRNCAT, BUILT_IN_NORMAL, "strncat", NULL, NULL },
     339                 :             :   { "__builtin_strcpy", BT_FN_STRING_STRING_CONST_STRING, BUILT_IN_STRCPY,
     340                 :             :     BUILT_IN_NORMAL, "strcpy", NULL, NULL },
     341                 :             :   { "__builtin_strncpy", BT_FN_STRING_STRING_CONST_STRING_SIZE,
     342                 :             :     BUILT_IN_STRNCPY, BUILT_IN_NORMAL, "strncpy", NULL, NULL },
     343                 :             :   { "__builtin_strcmp", BT_FN_INT_CONST_STRING_CONST_STRING, BUILT_IN_STRCMP,
     344                 :             :     BUILT_IN_NORMAL, "strcmp", NULL, NULL },
     345                 :             :   { "__builtin_strncmp", BT_FN_INT_CONST_STRING_CONST_STRING_SIZE,
     346                 :             :     BUILT_IN_STRNCMP, BUILT_IN_NORMAL, "strncmp", NULL, NULL },
     347                 :             :   { "__builtin_strlen", BT_FN_INT_CONST_STRING, BUILT_IN_STRLEN,
     348                 :             :     BUILT_IN_NORMAL, "strlen", NULL, NULL },
     349                 :             :   { "__builtin_strstr", BT_FN_STRING_CONST_STRING_CONST_STRING,
     350                 :             :     BUILT_IN_STRSTR, BUILT_IN_NORMAL, "strstr", NULL, NULL },
     351                 :             :   { "__builtin_strpbrk", BT_FN_STRING_CONST_STRING_CONST_STRING,
     352                 :             :     BUILT_IN_STRPBRK, BUILT_IN_NORMAL, "strpbrk", NULL, NULL },
     353                 :             :   { "__builtin_strspn", BT_FN_SIZE_CONST_STRING_CONST_STRING, BUILT_IN_STRSPN,
     354                 :             :     BUILT_IN_NORMAL, "strspn", NULL, NULL },
     355                 :             :   { "__builtin_strcspn", BT_FN_SIZE_CONST_STRING_CONST_STRING,
     356                 :             :     BUILT_IN_STRCSPN, BUILT_IN_NORMAL, "strcspn", NULL, NULL },
     357                 :             :   { "__builtin_strchr", BT_FN_STRING_CONST_STRING_INT, BUILT_IN_STRCHR,
     358                 :             :     BUILT_IN_NORMAL, "strchr", NULL, NULL },
     359                 :             :   { "__builtin_strrchr", BT_FN_STRING_CONST_STRING_INT, BUILT_IN_STRCHR,
     360                 :             :     BUILT_IN_NORMAL, "strrchr", NULL, NULL },
     361                 :             :   //{ "__builtin_constant_p", BT_FN_INT_VAR, BUILT_IN_CONSTANT_P,
     362                 :             :   //BUILT_IN_NORMAL, "constant_p", NULL, NULL},
     363                 :             :   { "__builtin_frame_address", BT_FN_PTR_UNSIGNED, BUILT_IN_FRAME_ADDRESS,
     364                 :             :     BUILT_IN_NORMAL, "frame_address", NULL, NULL },
     365                 :             :   { "__builtin_return_address", BT_FN_PTR_UNSIGNED, BUILT_IN_RETURN_ADDRESS,
     366                 :             :     BUILT_IN_NORMAL, "return_address", NULL, NULL },
     367                 :             :   //{ "__builtin_aggregate_incoming_address", BT_FN_PTR_VAR,
     368                 :             :   //BUILT_IN_AGGREGATE_INCOMING_ADDRESS, BUILT_IN_NORMAL,
     369                 :             :   //"aggregate_incoming_address", NULL, NULL},
     370                 :             :   { "__builtin_longjmp", BT_FN_VOID_PTR_INT, BUILT_IN_LONGJMP, BUILT_IN_NORMAL,
     371                 :             :     "longjmp", NULL, NULL },
     372                 :             :   { "__builtin_setjmp", BT_FN_INT_PTR, BUILT_IN_SETJMP, BUILT_IN_NORMAL,
     373                 :             :     "setjmp", NULL, NULL },
     374                 :             :   { NULL, BT_FN_NONE, 0, NOT_BUILT_IN, "", NULL, NULL }
     375                 :             : };
     376                 :             : 
     377                 :             : struct builtin_type_info
     378                 :             : {
     379                 :             :   const char *name;
     380                 :             :   unsigned int returnType;
     381                 :             :   tree (*functionHandler) (location_t, tree);
     382                 :             : };
     383                 :             : 
     384                 :             : static GTY (()) tree sizetype_endlink;
     385                 :             : static GTY (()) tree unsigned_endlink;
     386                 :             : static GTY (()) tree endlink;
     387                 :             : static GTY (()) tree math_endlink;
     388                 :             : static GTY (()) tree int_endlink;
     389                 :             : static GTY (()) tree ptr_endlink;
     390                 :             : static GTY (()) tree const_ptr_endlink;
     391                 :             : static GTY (()) tree double_ftype_void;
     392                 :             : static GTY (()) tree float_ftype_void;
     393                 :             : static GTY (()) tree ldouble_ftype_void;
     394                 :             : static GTY (()) tree float_ftype_float;
     395                 :             : static GTY (()) tree double_ftype_double;
     396                 :             : static GTY (()) tree ldouble_ftype_ldouble;
     397                 :             : static GTY (()) tree gm2_alloca_node;
     398                 :             : static GTY (()) tree gm2_memcpy_node;
     399                 :             : static GTY (()) tree gm2_isfinite_node;
     400                 :             : static GTY (()) tree gm2_huge_valf_node;
     401                 :             : static GTY (()) tree gm2_huge_val_node;
     402                 :             : static GTY (()) tree gm2_huge_vall_node;
     403                 :             : static GTY (()) tree long_doubleptr_type_node;
     404                 :             : static GTY (()) tree doubleptr_type_node;
     405                 :             : static GTY (()) tree floatptr_type_node;
     406                 :             : static GTY (()) tree builtin_ftype_int_var;
     407                 :             : 
     408                 :             : /* Prototypes for locally defined functions.  */
     409                 :             : static tree DoBuiltinAlloca (location_t location, tree n);
     410                 :             : static tree DoBuiltinMemCopy (location_t location, tree dest, tree src,
     411                 :             :                               tree n);
     412                 :             : static tree DoBuiltinIsfinite (location_t location, tree value);
     413                 :             : static void create_function_prototype (location_t location,
     414                 :             :                                        struct builtin_function_entry *fe);
     415                 :             : static tree doradix (location_t location, tree type);
     416                 :             : static tree doplaces (location_t location, tree type);
     417                 :             : static tree doexponentmin (location_t location, tree type);
     418                 :             : static tree doexponentmax (location_t location, tree type);
     419                 :             : static tree dolarge (location_t location, tree type);
     420                 :             : static tree dosmall (location_t location, tree type);
     421                 :             : static tree doiec559 (location_t location, tree type);
     422                 :             : static tree dolia1 (location_t location, tree type);
     423                 :             : static tree doiso (location_t location, tree type);
     424                 :             : static tree doieee (location_t location, tree type);
     425                 :             : static tree dorounds (location_t location, tree type);
     426                 :             : static tree dogUnderflow (location_t location, tree type);
     427                 :             : static tree doexception (location_t location, tree type);
     428                 :             : static tree doextend (location_t location, tree type);
     429                 :             : static tree donModes (location_t location, tree type);
     430                 :             : /* Prototypes finish here.  */
     431                 :             : 
     432                 :             : #define m2builtins_c
     433                 :             : #include "m2builtins.h"
     434                 :             : 
     435                 :             : static struct builtin_type_info m2_type_info[] = {
     436                 :             :   { "radix", 2, doradix },
     437                 :             :   { "places", 2, doplaces },
     438                 :             :   { "expoMin", 2, doexponentmin },
     439                 :             :   { "expoMax", 2, doexponentmax },
     440                 :             :   { "large", 3, dolarge },
     441                 :             :   { "small", 3, dosmall },
     442                 :             :   { "IEC559", 1, doiec559 },
     443                 :             :   { "LIA1", 1, dolia1 },
     444                 :             :   { "ISO", 1, doiso },
     445                 :             :   { "IEEE", 1, doieee },
     446                 :             :   { "rounds", 1, dorounds },
     447                 :             :   { "gUnderflow", 1, dogUnderflow },
     448                 :             :   { "exception", 1, doexception },
     449                 :             :   { "extend", 1, doextend },
     450                 :             :   { "nModes", 2, donModes },
     451                 :             :   { NULL, 0, NULL },
     452                 :             : };
     453                 :             : 
     454                 :             : /* Return a definition for a builtin function named NAME and whose
     455                 :             : data type is TYPE.  TYPE should be a function type with argument
     456                 :             : types.  FUNCTION_CODE tells later passes how to compile calls to this
     457                 :             : function.  See tree.h for its possible values.
     458                 :             : 
     459                 :             : If LIBRARY_NAME is nonzero, use that for DECL_ASSEMBLER_NAME, the
     460                 :             : name to be called if we can't opencode the function.  */
     461                 :             : 
     462                 :             : tree
     463                 :     1305024 : builtin_function (location_t location, const char *name, tree type,
     464                 :             :                   int function_code, enum built_in_class fclass,
     465                 :             :                   const char *library_name, tree attrs)
     466                 :             : {
     467                 :     1305024 :   tree decl = add_builtin_function (name, type, function_code, fclass,
     468                 :             :                                     library_name, attrs);
     469                 :     1305024 :   DECL_SOURCE_LOCATION (decl) = location;
     470                 :             : 
     471                 :     1305024 :   m2block_pushDecl (decl);
     472                 :     1305024 :   return decl;
     473                 :             : }
     474                 :             : 
     475                 :             : /* GetBuiltinConst - returns the gcc tree of a builtin constant,
     476                 :             :    name.  NIL is returned if the constant is unknown.  */
     477                 :             : 
     478                 :             : tree
     479                 :       22354 : m2builtins_GetBuiltinConst (char *name)
     480                 :             : {
     481                 :       22354 :   if (strcmp (name, "BITS_PER_UNIT") == 0)
     482                 :       11177 :     return m2decl_BuildIntegerConstant (BITS_PER_UNIT);
     483                 :       11177 :   if (strcmp (name, "BITS_PER_WORD") == 0)
     484                 :           0 :     return m2decl_BuildIntegerConstant (BITS_PER_WORD);
     485                 :       11177 :   if (strcmp (name, "BITS_PER_CHAR") == 0)
     486                 :           0 :     return m2decl_BuildIntegerConstant (CHAR_TYPE_SIZE);
     487                 :       11177 :   if (strcmp (name, "UNITS_PER_WORD") == 0)
     488                 :       11457 :     return m2decl_BuildIntegerConstant (UNITS_PER_WORD);
     489                 :             : 
     490                 :             :   return NULL_TREE;
     491                 :             : }
     492                 :             : 
     493                 :             : /* GetBuiltinConstType - returns the type of a builtin constant,
     494                 :             :    name.  0 = unknown constant name 1 = integer 2 = real.  */
     495                 :             : 
     496                 :             : unsigned int
     497                 :           0 : m2builtins_GetBuiltinConstType (char *name)
     498                 :             : {
     499                 :           0 :   if (strcmp (name, "BITS_PER_UNIT") == 0)
     500                 :             :     return 1;
     501                 :           0 :   if (strcmp (name, "BITS_PER_WORD") == 0)
     502                 :             :     return 1;
     503                 :           0 :   if (strcmp (name, "BITS_PER_CHAR") == 0)
     504                 :             :     return 1;
     505                 :           0 :   if (strcmp (name, "UNITS_PER_WORD") == 0)
     506                 :           0 :     return 1;
     507                 :             : 
     508                 :             :   return 0;
     509                 :             : }
     510                 :             : 
     511                 :             : /* GetBuiltinTypeInfoType - returns value: 0 is ident is unknown.  1
     512                 :             :    if ident is IEC559, LIA1, ISO, IEEE, rounds, underflow, exception,
     513                 :             :    extend.  2 if ident is radix, places, exponentmin, exponentmax,
     514                 :             :    noofmodes.  3 if ident is large, small.  */
     515                 :             : 
     516                 :             : unsigned int
     517                 :         180 : m2builtins_GetBuiltinTypeInfoType (const char *ident)
     518                 :             : {
     519                 :         180 :   int i = 0;
     520                 :             : 
     521                 :        1440 :   while (m2_type_info[i].name != NULL)
     522                 :        1440 :     if (strcmp (m2_type_info[i].name, ident) == 0)
     523                 :         180 :       return m2_type_info[i].returnType;
     524                 :             :     else
     525                 :        1260 :       i++;
     526                 :             :   return 0;
     527                 :             : }
     528                 :             : 
     529                 :             : /* GetBuiltinTypeInfo - returns value: NULL_TREE if ident is unknown.
     530                 :             :    boolean Tree if ident is IEC559, LIA1, ISO, IEEE, rounds,
     531                 :             :    underflow, exception, extend.  ZType Tree if ident is radix,
     532                 :             :    places, exponentmin, exponentmax, noofmodes.
     533                 :             :    RType Tree if ident is large, small.  */
     534                 :             : 
     535                 :             : tree
     536                 :         180 : m2builtins_GetBuiltinTypeInfo (location_t location, tree type,
     537                 :             :                                const char *ident)
     538                 :             : {
     539                 :         180 :   int i = 0;
     540                 :             : 
     541                 :         180 :   type = m2tree_skip_type_decl (type);
     542                 :        1620 :   while (m2_type_info[i].name != NULL)
     543                 :        1440 :     if (strcmp (m2_type_info[i].name, ident) == 0)
     544                 :         180 :       return (*m2_type_info[i].functionHandler) (location, type);
     545                 :             :     else
     546                 :        1260 :       i++;
     547                 :             :   return NULL_TREE;
     548                 :             : }
     549                 :             : 
     550                 :             : /* doradix - returns the radix of the floating point, type.  */
     551                 :             : 
     552                 :             : static tree
     553                 :          12 : doradix (location_t location ATTRIBUTE_UNUSED, tree type)
     554                 :             : {
     555                 :          12 :   if (SCALAR_FLOAT_TYPE_P (type))
     556                 :             :     {
     557                 :          12 :       enum machine_mode mode = TYPE_MODE (type);
     558                 :          12 :       int radix = REAL_MODE_FORMAT (mode)->b;
     559                 :          12 :       return m2decl_BuildIntegerConstant (radix);
     560                 :             :     }
     561                 :             :   else
     562                 :             :     return NULL_TREE;
     563                 :             : }
     564                 :             : 
     565                 :             : /* doplaces - returns the whole number value of the number of radix
     566                 :             :    places used to store values of the corresponding real number type.  */
     567                 :             : 
     568                 :             : static tree
     569                 :          12 : doplaces (location_t location ATTRIBUTE_UNUSED, tree type)
     570                 :             : {
     571                 :          12 :   if (SCALAR_FLOAT_TYPE_P (type))
     572                 :             :     {
     573                 :             :       /* Taken from c-family/c-cppbuiltin.cc.  */
     574                 :             :       /* The number of decimal digits, q, such that any floating-point
     575                 :             :          number with q decimal digits can be rounded into a
     576                 :             :          floating-point number with p radix b digits and back again
     577                 :             :          without change to the q decimal digits, p log10 b if b is a
     578                 :             :          power of 10 floor((p - 1) log10 b) otherwise.  */
     579                 :          12 :       enum machine_mode mode = TYPE_MODE (type);
     580                 :          12 :       const struct real_format *fmt = REAL_MODE_FORMAT (mode);
     581                 :          12 :       const double log10_2 = .30102999566398119521;
     582                 :          12 :       double log10_b = log10_2;
     583                 :          12 :       int digits = (fmt->p - 1) * log10_b;
     584                 :          12 :       return m2decl_BuildIntegerConstant (digits);
     585                 :             :     }
     586                 :             :   else
     587                 :             :     return NULL_TREE;
     588                 :             : }
     589                 :             : 
     590                 :             : /* doexponentmin - returns the whole number of the exponent minimum.  */
     591                 :             : 
     592                 :             : static tree
     593                 :          12 : doexponentmin (location_t location ATTRIBUTE_UNUSED, tree type)
     594                 :             : {
     595                 :          12 :   if (SCALAR_FLOAT_TYPE_P (type))
     596                 :             :     {
     597                 :          12 :       enum machine_mode mode = TYPE_MODE (type);
     598                 :          12 :       int emin = REAL_MODE_FORMAT (mode)->emin;
     599                 :          12 :       return m2decl_BuildIntegerConstant (emin);
     600                 :             :     }
     601                 :             :   else
     602                 :             :     return NULL_TREE;
     603                 :             : }
     604                 :             : 
     605                 :             : /* doexponentmax - returns the whole number of the exponent maximum.  */
     606                 :             : 
     607                 :             : static tree
     608                 :          12 : doexponentmax (location_t location ATTRIBUTE_UNUSED, tree type)
     609                 :             : {
     610                 :          12 :   if (SCALAR_FLOAT_TYPE_P (type))
     611                 :             :     {
     612                 :          12 :       enum machine_mode mode = TYPE_MODE (type);
     613                 :          12 :       int emax = REAL_MODE_FORMAT (mode)->emax;
     614                 :          12 :       return m2decl_BuildIntegerConstant (emax);
     615                 :             :     }
     616                 :             :   else
     617                 :             :     return NULL_TREE;
     618                 :             : }
     619                 :             : 
     620                 :             : static tree
     621                 :          12 : computeLarge (tree type)
     622                 :             : {
     623                 :          12 :   enum machine_mode mode = TYPE_MODE (type);
     624                 :          12 :   const struct real_format *fmt = REAL_MODE_FORMAT (mode);
     625                 :          12 :   REAL_VALUE_TYPE real;
     626                 :          12 :   char buf[128];
     627                 :             : 
     628                 :             :   /* Shamelessly taken from c-cppbuiltin.cc:builtin_define_float_constants.  */
     629                 :             : 
     630                 :             :   /* Since, for the supported formats, B is always a power of 2, we
     631                 :             :   construct the following numbers directly as a hexadecimal constants.  */
     632                 :             : 
     633                 :          12 :   get_max_float (fmt, buf, sizeof (buf), false);
     634                 :          12 :   real_from_string (&real, buf);
     635                 :          12 :   return build_real (type, real);
     636                 :             : }
     637                 :             : 
     638                 :             : /* dolarge - return the largest value of the corresponding real type.  */
     639                 :             : 
     640                 :             : static tree
     641                 :          12 : dolarge (location_t location ATTRIBUTE_UNUSED, tree type)
     642                 :             : {
     643                 :          12 :   if (SCALAR_FLOAT_TYPE_P (type))
     644                 :          12 :     return computeLarge (type);
     645                 :             :   return NULL_TREE;
     646                 :             : }
     647                 :             : 
     648                 :             : static tree
     649                 :          12 : computeSmall (tree type)
     650                 :             : {
     651                 :          12 :   enum machine_mode mode = TYPE_MODE (type);
     652                 :          12 :   const struct real_format *fmt = REAL_MODE_FORMAT (mode);
     653                 :          12 :   REAL_VALUE_TYPE real;
     654                 :          12 :   char buf[128];
     655                 :             : 
     656                 :             :   /* The minimum normalized positive floating-point number,
     657                 :             :   b**(emin-1).  */
     658                 :             : 
     659                 :          12 :   sprintf (buf, "0x1p%d", fmt->emin - 1);
     660                 :          12 :   real_from_string (&real, buf);
     661                 :          12 :   return build_real (type, real);
     662                 :             : }
     663                 :             : 
     664                 :             : /* dosmall - return the smallest positive value of the corresponding
     665                 :             :    real type.  */
     666                 :             : 
     667                 :             : static tree
     668                 :          12 : dosmall (location_t location ATTRIBUTE_UNUSED, tree type)
     669                 :             : {
     670                 :          12 :   if (SCALAR_FLOAT_TYPE_P (type))
     671                 :          12 :     return computeSmall (type);
     672                 :             :   return NULL_TREE;
     673                 :             : }
     674                 :             : 
     675                 :             : /* doiec559 - a boolean value that is true if and only if the
     676                 :             :    implementation of the corresponding real number type conforms to
     677                 :             :    IEC 559:1989 (also known as IEEE 754:1987) in all regards.  */
     678                 :             : 
     679                 :             : static tree
     680                 :          12 : doiec559 (location_t location, tree type)
     681                 :             : {
     682                 :          12 :   if (m2expr_IsTrue (m2expr_BuildEqualTo (location,
     683                 :             :                                           m2decl_BuildIntegerConstant (32),
     684                 :             :                                           m2expr_GetSizeOfInBits (type))))
     685                 :           0 :     return m2type_GetBooleanTrue ();
     686                 :          12 :   if (m2expr_IsTrue (m2expr_BuildEqualTo (location,
     687                 :             :                                           m2decl_BuildIntegerConstant (64),
     688                 :             :                                           m2expr_GetSizeOfInBits (type))))
     689                 :           0 :     return m2type_GetBooleanTrue ();
     690                 :          12 :   return m2type_GetBooleanFalse ();
     691                 :             : }
     692                 :             : 
     693                 :             : /* dolia1 - returns TRUE if using ieee (currently always TRUE).  */
     694                 :             : 
     695                 :             : static tree
     696                 :          12 : dolia1 (location_t location, tree type)
     697                 :             : {
     698                 :          24 :   return doieee (location, type);
     699                 :             : }
     700                 :             : 
     701                 :             : /* doiso - returns TRUE if using ieee (--fixme--).  */
     702                 :             : 
     703                 :             : static tree
     704                 :          12 : doiso (location_t location, tree type)
     705                 :             : {
     706                 :          24 :   return doieee (location, type);
     707                 :             : }
     708                 :             : 
     709                 :             : /* doieee - returns TRUE if ieee arithmetic is being used.  */
     710                 :             : 
     711                 :             : static tree
     712                 :          36 : doieee (location_t location ATTRIBUTE_UNUSED, tree type ATTRIBUTE_UNUSED)
     713                 :             : {
     714                 :             :   /* --fixme-- maybe we should look for the -mno-ieee flag and return this
     715                 :             :      result.  */
     716                 :          36 :   return m2type_GetBooleanTrue ();
     717                 :             : }
     718                 :             : 
     719                 :             : /* dorounds - returns TRUE if and only if each operation produces a
     720                 :             :    result that is one of the values of the corresponding real number
     721                 :             :    type nearest to the mathematical result.  */
     722                 :             : 
     723                 :             : static tree
     724                 :          12 : dorounds (location_t location ATTRIBUTE_UNUSED, tree type ATTRIBUTE_UNUSED)
     725                 :             : {
     726                 :          12 :   if (FLT_ROUNDS)
     727                 :          12 :     return m2type_GetBooleanTrue ();
     728                 :             :   else
     729                 :             :     return m2type_GetBooleanFalse ();
     730                 :             : }
     731                 :             : 
     732                 :             : /* dogUnderflow - returns TRUE if and only if there are values of the
     733                 :             :    corresponding real number type between 0.0 and small.  */
     734                 :             : 
     735                 :             : static tree
     736                 :          12 : dogUnderflow (location_t location ATTRIBUTE_UNUSED, tree type)
     737                 :             : {
     738                 :          12 :   if (SCALAR_FLOAT_TYPE_P (type))
     739                 :             :     {
     740                 :          12 :       enum machine_mode mode = TYPE_MODE (type);
     741                 :          12 :       const struct real_format *fmt = REAL_MODE_FORMAT (mode);
     742                 :          12 :       if (fmt->has_denorm)
     743                 :          12 :         return m2type_GetBooleanTrue ();
     744                 :             :       else
     745                 :           0 :         return m2type_GetBooleanFalse ();
     746                 :             :     }
     747                 :             :   return NULL_TREE;
     748                 :             : }
     749                 :             : 
     750                 :             : /* doexception - */
     751                 :             : 
     752                 :             : static tree
     753                 :          12 : doexception (location_t location ATTRIBUTE_UNUSED, tree type ATTRIBUTE_UNUSED)
     754                 :             : {
     755                 :          12 :   return m2type_GetBooleanTrue ();
     756                 :             : }
     757                 :             : 
     758                 :             : /* doextend - */
     759                 :             : 
     760                 :             : static tree
     761                 :          12 : doextend (location_t location ATTRIBUTE_UNUSED, tree type ATTRIBUTE_UNUSED)
     762                 :             : {
     763                 :          12 :   return m2type_GetBooleanTrue ();
     764                 :             : }
     765                 :             : 
     766                 :             : /* donModes - */
     767                 :             : 
     768                 :             : static tree
     769                 :          12 : donModes (location_t location ATTRIBUTE_UNUSED, tree type ATTRIBUTE_UNUSED)
     770                 :             : {
     771                 :          12 :   return m2decl_BuildIntegerConstant (1);
     772                 :             : }
     773                 :             : 
     774                 :             : /* BuiltInMemCopy - copy n bytes of memory efficiently from address
     775                 :             :    src to dest.  */
     776                 :             : 
     777                 :             : tree
     778                 :        5487 : m2builtins_BuiltInMemCopy (location_t location, tree dest, tree src, tree n)
     779                 :             : {
     780                 :        5487 :   return DoBuiltinMemCopy (location, dest, src, n);
     781                 :             : }
     782                 :             : 
     783                 :             : /* BuiltInAlloca - given an expression, n, allocate, n, bytes on the
     784                 :             :    stack for the life of the current function.  */
     785                 :             : 
     786                 :             : tree
     787                 :        4201 : m2builtins_BuiltInAlloca (location_t location, tree n)
     788                 :             : {
     789                 :        4201 :   return DoBuiltinAlloca (location, n);
     790                 :             : }
     791                 :             : 
     792                 :             : /* BuiltInIsfinite - return integer 1 if the real expression is
     793                 :             :    finite otherwise return integer 0.  */
     794                 :             : 
     795                 :             : tree
     796                 :        2390 : m2builtins_BuiltInIsfinite (location_t location, tree expression)
     797                 :             : {
     798                 :        2390 :   return DoBuiltinIsfinite (location, expression);
     799                 :             : }
     800                 :             : 
     801                 :             : /* BuiltinExists - returns TRUE if the builtin function, name, exists
     802                 :             :    for this target architecture.  */
     803                 :             : 
     804                 :             : bool
     805                 :        3324 : m2builtins_BuiltinExists (char *name)
     806                 :             : {
     807                 :        3324 :   struct builtin_function_entry *fe;
     808                 :             : 
     809                 :      148516 :   for (fe = &list_of_builtins[0]; fe->name != NULL; fe++)
     810                 :      148516 :     if (strcmp (name, fe->name) == 0)
     811                 :             :       return TRUE;
     812                 :             : 
     813                 :             :   return FALSE;
     814                 :             : }
     815                 :             : 
     816                 :             : /* BuildBuiltinTree - returns a Tree containing the builtin function,
     817                 :             :    name.  */
     818                 :             : 
     819                 :             : tree
     820                 :         500 : m2builtins_BuildBuiltinTree (location_t location, char *name)
     821                 :             : {
     822                 :         500 :   struct builtin_function_entry *fe;
     823                 :         500 :   tree t;
     824                 :             : 
     825                 :         500 :   m2statement_SetLastFunction (NULL_TREE);
     826                 :       23568 :   for (fe = &list_of_builtins[0]; fe->name != NULL; fe++)
     827                 :       23568 :     if (strcmp (name, fe->name) == 0)
     828                 :             :       {
     829                 :         500 :         tree functype = TREE_TYPE (fe->function_node);
     830                 :         500 :         tree funcptr = build1 (ADDR_EXPR, build_pointer_type (functype),
     831                 :             :                                fe->function_node);
     832                 :             : 
     833                 :         500 :         m2statement_SetLastFunction (m2treelib_DoCall (
     834                 :             :             location, fe->return_node, funcptr, m2statement_GetParamList ()));
     835                 :         500 :         m2statement_SetParamList (NULL_TREE);
     836                 :         500 :         t = m2statement_GetLastFunction ();
     837                 :         500 :         if (fe->return_node == void_type_node)
     838                 :          24 :           m2statement_SetLastFunction (NULL_TREE);
     839                 :         500 :         return t;
     840                 :             :       }
     841                 :             : 
     842                 :           0 :   m2statement_SetParamList (NULL_TREE);
     843                 :           0 :   return m2statement_GetLastFunction ();
     844                 :             : }
     845                 :             : 
     846                 :             : static tree
     847                 :        5487 : DoBuiltinMemCopy (location_t location, tree dest, tree src, tree bytes)
     848                 :             : {
     849                 :        5487 :   tree functype = TREE_TYPE (gm2_memcpy_node);
     850                 :        5487 :   tree funcptr
     851                 :        5487 :       = build1 (ADDR_EXPR, build_pointer_type (functype), gm2_memcpy_node);
     852                 :        5487 :   tree call
     853                 :        5487 :       = m2treelib_DoCall3 (location, ptr_type_node, funcptr, dest, src, bytes);
     854                 :        5487 :   return call;
     855                 :             : }
     856                 :             : 
     857                 :             : static tree
     858                 :        4201 : DoBuiltinAlloca (location_t location, tree bytes)
     859                 :             : {
     860                 :        4201 :   tree functype = TREE_TYPE (gm2_alloca_node);
     861                 :        4201 :   tree funcptr
     862                 :        4201 :       = build1 (ADDR_EXPR, build_pointer_type (functype), gm2_alloca_node);
     863                 :        4201 :   tree call = m2treelib_DoCall1 (location, ptr_type_node, funcptr, bytes);
     864                 :             : 
     865                 :        4201 :   return call;
     866                 :             : }
     867                 :             : 
     868                 :             : static tree
     869                 :        2390 : DoBuiltinIsfinite (location_t location, tree value)
     870                 :             : {
     871                 :        2390 :   tree functype = TREE_TYPE (gm2_isfinite_node);
     872                 :        2390 :   tree funcptr
     873                 :        2390 :       = build1 (ADDR_EXPR, build_pointer_type (functype), gm2_isfinite_node);
     874                 :        2390 :   tree call = m2treelib_DoCall1 (location, ptr_type_node, funcptr, value);
     875                 :             : 
     876                 :        2390 :   return call;
     877                 :             : }
     878                 :             : 
     879                 :             : tree
     880                 :           0 : m2builtins_BuiltInHugeVal (location_t location)
     881                 :             : {
     882                 :           0 :   tree functype = TREE_TYPE (gm2_huge_val_node);
     883                 :           0 :   tree funcptr
     884                 :           0 :       = build1 (ADDR_EXPR, build_pointer_type (functype), gm2_huge_val_node);
     885                 :           0 :   tree call = m2treelib_DoCall0 (location, ptr_type_node, funcptr);
     886                 :           0 :   return call;
     887                 :             : }
     888                 :             : 
     889                 :             : tree
     890                 :           0 : m2builtins_BuiltInHugeValShort (location_t location)
     891                 :             : {
     892                 :           0 :   tree functype = TREE_TYPE (gm2_huge_valf_node);
     893                 :           0 :   tree funcptr
     894                 :           0 :       = build1 (ADDR_EXPR, build_pointer_type (functype), gm2_huge_valf_node);
     895                 :           0 :   tree call = m2treelib_DoCall0 (location, ptr_type_node, funcptr);
     896                 :           0 :   return call;
     897                 :             : }
     898                 :             : 
     899                 :             : tree
     900                 :           0 : m2builtins_BuiltInHugeValLong (location_t location)
     901                 :             : {
     902                 :           0 :   tree functype = TREE_TYPE (gm2_huge_vall_node);
     903                 :           0 :   tree funcptr
     904                 :           0 :       = build1 (ADDR_EXPR, build_pointer_type (functype), gm2_huge_vall_node);
     905                 :           0 :   tree call = m2treelib_DoCall0 (location, ptr_type_node, funcptr);
     906                 :           0 :   return call;
     907                 :             : }
     908                 :             : 
     909                 :             : static void
     910                 :     1305024 : create_function_prototype (location_t location,
     911                 :             :                            struct builtin_function_entry *fe)
     912                 :             : {
     913                 :     1305024 :   tree ftype;
     914                 :             : 
     915                 :     1305024 :   switch (fe->defn)
     916                 :             :     {
     917                 :             : 
     918                 :       11652 :     case BT_FN_PTR_SIZE:
     919                 :       11652 :       ftype = build_function_type (ptr_type_node, sizetype_endlink);
     920                 :       11652 :       fe->return_node = ptr_type_node;
     921                 :       11652 :       break;
     922                 :             : 
     923                 :       46608 :     case BT_FN_STRING_STRING_CONST_STRING_SIZE:
     924                 :       46608 :     case BT_FN_TRAD_PTR_PTR_CONST_PTR_SIZE:
     925                 :       46608 :       ftype = build_function_type (
     926                 :             :           ptr_type_node, tree_cons (NULL_TREE, ptr_type_node,
     927                 :             :                                     tree_cons (NULL_TREE, const_ptr_type_node,
     928                 :             :                                                sizetype_endlink)));
     929                 :       46608 :       fe->return_node = ptr_type_node;
     930                 :       46608 :       break;
     931                 :       11652 :     case BT_FN_FLOAT:
     932                 :       11652 :       ftype = float_ftype_void;
     933                 :       11652 :       fe->return_node = float_type_node;
     934                 :       11652 :       break;
     935                 :       11652 :     case BT_FN_DOUBLE:
     936                 :       11652 :       ftype = double_ftype_void;
     937                 :       11652 :       fe->return_node = double_type_node;
     938                 :       11652 :       break;
     939                 :       11652 :     case BT_FN_LONG_DOUBLE:
     940                 :       11652 :       ftype = ldouble_ftype_void;
     941                 :       11652 :       fe->return_node = long_double_type_node;
     942                 :       11652 :       break;
     943                 :       81564 :     case BT_FN_FLOAT_FLOAT:
     944                 :       81564 :       ftype = float_ftype_float;
     945                 :       81564 :       fe->return_node = float_type_node;
     946                 :       81564 :       break;
     947                 :       81564 :     case BT_FN_DOUBLE_DOUBLE:
     948                 :       81564 :       ftype = double_ftype_double;
     949                 :       81564 :       fe->return_node = double_type_node;
     950                 :       81564 :       break;
     951                 :       81564 :     case BT_FN_LONG_DOUBLE_LONG_DOUBLE:
     952                 :       81564 :       ftype = ldouble_ftype_ldouble;
     953                 :       81564 :       fe->return_node = long_double_type_node;
     954                 :       81564 :       break;
     955                 :       46608 :     case BT_FN_STRING_CONST_STRING_INT:
     956                 :       46608 :       ftype = build_function_type (
     957                 :             :           ptr_type_node, tree_cons (NULL_TREE, ptr_type_node, int_endlink));
     958                 :       46608 :       fe->return_node = ptr_type_node;
     959                 :       46608 :       break;
     960                 :       11652 :     case BT_FN_INT_CONST_PTR_CONST_PTR_SIZE:
     961                 :       11652 :       ftype = build_function_type (
     962                 :             :           integer_type_node,
     963                 :             :           tree_cons (NULL_TREE, const_ptr_type_node,
     964                 :             :                      tree_cons (NULL_TREE, const_ptr_type_node, int_endlink)));
     965                 :       11652 :       fe->return_node = integer_type_node;
     966                 :       11652 :       break;
     967                 :       11652 :     case BT_FN_TRAD_PTR_PTR_INT_SIZE:
     968                 :       11652 :       ftype = build_function_type (
     969                 :             :           ptr_type_node, tree_cons (NULL_TREE, ptr_type_node,
     970                 :             :                                     tree_cons (NULL_TREE, integer_type_node,
     971                 :             :                                                sizetype_endlink)));
     972                 :       11652 :       fe->return_node = ptr_type_node;
     973                 :       11652 :       break;
     974                 :       23304 :     case BT_FN_STRING_STRING_CONST_STRING:
     975                 :       23304 :       ftype = build_function_type (
     976                 :             :           ptr_type_node, tree_cons (NULL_TREE, ptr_type_node, ptr_endlink));
     977                 :       23304 :       fe->return_node = ptr_type_node;
     978                 :       23304 :       break;
     979                 :       11652 :     case BT_FN_INT_CONST_STRING_CONST_STRING:
     980                 :       11652 :       ftype = build_function_type (
     981                 :             :           integer_type_node,
     982                 :             :           tree_cons (NULL_TREE, const_ptr_type_node, ptr_endlink));
     983                 :       11652 :       fe->return_node = integer_type_node;
     984                 :       11652 :       break;
     985                 :       11652 :     case BT_FN_INT_CONST_STRING_CONST_STRING_SIZE:
     986                 :       11652 :       ftype = build_function_type (
     987                 :             :           integer_type_node,
     988                 :             :           tree_cons (
     989                 :             :               NULL_TREE, const_ptr_type_node,
     990                 :             :               tree_cons (NULL_TREE, const_ptr_type_node, sizetype_endlink)));
     991                 :       11652 :       fe->return_node = integer_type_node;
     992                 :       11652 :       break;
     993                 :       11652 :     case BT_FN_INT_CONST_STRING:
     994                 :       11652 :       ftype = build_function_type (integer_type_node, ptr_endlink);
     995                 :       11652 :       fe->return_node = integer_type_node;
     996                 :       11652 :       break;
     997                 :       23304 :     case BT_FN_STRING_CONST_STRING_CONST_STRING:
     998                 :       23304 :       ftype = build_function_type (
     999                 :             :           ptr_type_node,
    1000                 :             :           tree_cons (NULL_TREE, const_ptr_type_node, const_ptr_endlink));
    1001                 :       23304 :       fe->return_node = ptr_type_node;
    1002                 :       23304 :       break;
    1003                 :       23304 :     case BT_FN_SIZE_CONST_STRING_CONST_STRING:
    1004                 :       23304 :       ftype = build_function_type (
    1005                 :             :           sizetype,
    1006                 :             :           tree_cons (NULL_TREE, const_ptr_type_node, const_ptr_endlink));
    1007                 :       23304 :       fe->return_node = sizetype;
    1008                 :       23304 :       break;
    1009                 :       23304 :     case BT_FN_PTR_UNSIGNED:
    1010                 :       23304 :       ftype = build_function_type (ptr_type_node, unsigned_endlink);
    1011                 :       23304 :       fe->return_node = ptr_type_node;
    1012                 :       23304 :       break;
    1013                 :       11652 :     case BT_FN_VOID_PTR_INT:
    1014                 :       11652 :       ftype = build_function_type (
    1015                 :             :           void_type_node, tree_cons (NULL_TREE, ptr_type_node, int_endlink));
    1016                 :       11652 :       fe->return_node = void_type_node;
    1017                 :       11652 :       break;
    1018                 :       11652 :     case BT_FN_INT_PTR:
    1019                 :       11652 :       ftype = build_function_type (integer_type_node, ptr_endlink);
    1020                 :       11652 :       fe->return_node = integer_type_node;
    1021                 :       11652 :       break;
    1022                 :       23304 :     case BT_FN_INT_FLOAT:
    1023                 :       23304 :       ftype = build_function_type (
    1024                 :             :           integer_type_node, tree_cons (NULL_TREE, float_type_node, endlink));
    1025                 :       23304 :       fe->return_node = integer_type_node;
    1026                 :       23304 :       break;
    1027                 :       34956 :     case BT_FN_INT_DOUBLE:
    1028                 :       34956 :       ftype = build_function_type (
    1029                 :             :           integer_type_node, tree_cons (NULL_TREE, double_type_node, endlink));
    1030                 :       34956 :       fe->return_node = integer_type_node;
    1031                 :       34956 :       break;
    1032                 :       23304 :     case BT_FN_INT_LONG_DOUBLE:
    1033                 :       23304 :       ftype = build_function_type (
    1034                 :             :           integer_type_node,
    1035                 :             :           tree_cons (NULL_TREE, long_double_type_node, endlink));
    1036                 :       23304 :       fe->return_node = integer_type_node;
    1037                 :       23304 :       break;
    1038                 :       23304 :     case BT_FN_FLOAT_FCOMPLEX:
    1039                 :       23304 :       ftype = build_function_type (
    1040                 :             :           float_type_node,
    1041                 :             :           tree_cons (NULL_TREE, complex_float_type_node, endlink));
    1042                 :       23304 :       fe->return_node = float_type_node;
    1043                 :       23304 :       break;
    1044                 :       23304 :     case BT_FN_DOUBLE_DCOMPLEX:
    1045                 :       23304 :       ftype = build_function_type (
    1046                 :             :           double_type_node,
    1047                 :             :           tree_cons (NULL_TREE, complex_double_type_node, endlink));
    1048                 :       23304 :       fe->return_node = double_type_node;
    1049                 :       23304 :       break;
    1050                 :       23304 :     case BT_FN_LONG_DOUBLE_LDCOMPLEX:
    1051                 :       23304 :       ftype = build_function_type (
    1052                 :             :           long_double_type_node,
    1053                 :             :           tree_cons (NULL_TREE, complex_long_double_type_node, endlink));
    1054                 :       23304 :       fe->return_node = long_double_type_node;
    1055                 :       23304 :       break;
    1056                 :      116520 :     case BT_FN_FCOMPLEX_FCOMPLEX:
    1057                 :      116520 :       ftype = build_function_type (
    1058                 :             :           complex_float_type_node,
    1059                 :             :           tree_cons (NULL_TREE, complex_float_type_node, endlink));
    1060                 :      116520 :       fe->return_node = complex_float_type_node;
    1061                 :      116520 :       break;
    1062                 :      116520 :     case BT_FN_DCOMPLEX_DCOMPLEX:
    1063                 :      116520 :       ftype = build_function_type (
    1064                 :             :           complex_double_type_node,
    1065                 :             :           tree_cons (NULL_TREE, complex_double_type_node, endlink));
    1066                 :      116520 :       fe->return_node = complex_double_type_node;
    1067                 :      116520 :       break;
    1068                 :      116520 :     case BT_FN_LDCOMPLEX_LDCOMPLEX:
    1069                 :      116520 :       ftype = build_function_type (
    1070                 :             :           complex_long_double_type_node,
    1071                 :             :           tree_cons (NULL_TREE, complex_long_double_type_node, endlink));
    1072                 :      116520 :       fe->return_node = complex_long_double_type_node;
    1073                 :      116520 :       break;
    1074                 :       11652 :     case BT_FN_DCOMPLEX_DOUBLE_DCOMPLEX:
    1075                 :       11652 :       ftype = build_function_type (
    1076                 :             :           complex_double_type_node,
    1077                 :             :           tree_cons (NULL_TREE, complex_double_type_node,
    1078                 :             :                      tree_cons (NULL_TREE, double_type_node, endlink)));
    1079                 :       11652 :       fe->return_node = complex_double_type_node;
    1080                 :       11652 :       break;
    1081                 :       11652 :     case BT_FN_FCOMPLEX_FLOAT_FCOMPLEX:
    1082                 :       11652 :       ftype = build_function_type (
    1083                 :             :           complex_float_type_node,
    1084                 :             :           tree_cons (NULL_TREE, complex_float_type_node,
    1085                 :             :                      tree_cons (NULL_TREE, float_type_node, endlink)));
    1086                 :       11652 :       fe->return_node = complex_float_type_node;
    1087                 :       11652 :       break;
    1088                 :       11652 :     case BT_FN_LDCOMPLEX_LONG_DOUBLE_LDCOMPLEX:
    1089                 :       11652 :       ftype = build_function_type (
    1090                 :             :           complex_long_double_type_node,
    1091                 :             :           tree_cons (NULL_TREE, complex_long_double_type_node,
    1092                 :             :                      tree_cons (NULL_TREE, long_double_type_node, endlink)));
    1093                 :       11652 :       fe->return_node = complex_long_double_type_node;
    1094                 :       11652 :       break;
    1095                 :       11652 :     case BT_FN_FLOAT_FLOAT_FLOATPTR:
    1096                 :       11652 :       ftype = build_function_type (
    1097                 :             :           float_type_node,
    1098                 :             :           tree_cons (NULL_TREE, float_type_node,
    1099                 :             :                      tree_cons (NULL_TREE, floatptr_type_node, endlink)));
    1100                 :       11652 :       fe->return_node = float_type_node;
    1101                 :       11652 :       break;
    1102                 :       11652 :     case BT_FN_DOUBLE_DOUBLE_DOUBLEPTR:
    1103                 :       11652 :       ftype = build_function_type (
    1104                 :             :           double_type_node,
    1105                 :             :           tree_cons (NULL_TREE, double_type_node,
    1106                 :             :                      tree_cons (NULL_TREE, doubleptr_type_node, endlink)));
    1107                 :       11652 :       fe->return_node = double_type_node;
    1108                 :       11652 :       break;
    1109                 :       11652 :     case BT_FN_LONG_DOUBLE_LONG_DOUBLE_LONG_DOUBLEPTR:
    1110                 :       11652 :       ftype = build_function_type (
    1111                 :             :           long_double_type_node,
    1112                 :             :           tree_cons (
    1113                 :             :               NULL_TREE, long_double_type_node,
    1114                 :             :               tree_cons (NULL_TREE, long_doubleptr_type_node, endlink)));
    1115                 :       11652 :       fe->return_node = long_double_type_node;
    1116                 :       11652 :       break;
    1117                 :       11652 :     case BT_FN_FLOAT_FLOAT_LONG_DOUBLE:
    1118                 :       11652 :       ftype = build_function_type (
    1119                 :             :           float_type_node,
    1120                 :             :           tree_cons (NULL_TREE, float_type_node,
    1121                 :             :                      tree_cons (NULL_TREE, long_double_type_node, endlink)));
    1122                 :       11652 :       fe->return_node = float_type_node;
    1123                 :       11652 :       break;
    1124                 :       11652 :     case BT_FN_DOUBLE_DOUBLE_LONG_DOUBLE:
    1125                 :       11652 :       ftype = build_function_type (
    1126                 :             :           double_type_node,
    1127                 :             :           tree_cons (NULL_TREE, double_type_node,
    1128                 :             :                      tree_cons (NULL_TREE, long_double_type_node, endlink)));
    1129                 :       11652 :       fe->return_node = double_type_node;
    1130                 :       11652 :       break;
    1131                 :       34956 :     case BT_FN_LONG_DOUBLE_LONG_DOUBLE_LONG_DOUBLE:
    1132                 :       34956 :       ftype = build_function_type (
    1133                 :             :           long_double_type_node,
    1134                 :             :           tree_cons (NULL_TREE, long_double_type_node,
    1135                 :             :                      tree_cons (NULL_TREE, long_double_type_node, endlink)));
    1136                 :       34956 :       fe->return_node = long_double_type_node;
    1137                 :       34956 :       break;
    1138                 :       11652 :     case BT_FN_FLOAT_FLOAT_LONG:
    1139                 :       11652 :       ftype = build_function_type (
    1140                 :             :           float_type_node,
    1141                 :             :           tree_cons (NULL_TREE, float_type_node,
    1142                 :             :                      tree_cons (NULL_TREE, long_integer_type_node, endlink)));
    1143                 :       11652 :       fe->return_node = float_type_node;
    1144                 :       11652 :       break;
    1145                 :       11652 :     case BT_FN_DOUBLE_DOUBLE_LONG:
    1146                 :       11652 :       ftype = build_function_type (
    1147                 :             :           double_type_node,
    1148                 :             :           tree_cons (NULL_TREE, double_type_node,
    1149                 :             :                      tree_cons (NULL_TREE, long_integer_type_node, endlink)));
    1150                 :       11652 :       fe->return_node = double_type_node;
    1151                 :       11652 :       break;
    1152                 :       11652 :     case BT_FN_LONG_DOUBLE_LONG_DOUBLE_LONG:
    1153                 :       11652 :       ftype = build_function_type (
    1154                 :             :           long_double_type_node,
    1155                 :             :           tree_cons (NULL_TREE, long_double_type_node,
    1156                 :             :                      tree_cons (NULL_TREE, long_integer_type_node, endlink)));
    1157                 :       11652 :       fe->return_node = long_double_type_node;
    1158                 :       11652 :       break;
    1159                 :       11652 :     case BT_FN_FLOAT_FLOAT_INT:
    1160                 :       11652 :       ftype = build_function_type (
    1161                 :             :           float_type_node,
    1162                 :             :           tree_cons (NULL_TREE, float_type_node,
    1163                 :             :                      tree_cons (NULL_TREE, integer_type_node, endlink)));
    1164                 :       11652 :       fe->return_node = float_type_node;
    1165                 :       11652 :       break;
    1166                 :       11652 :     case BT_FN_DOUBLE_DOUBLE_INT:
    1167                 :       11652 :       ftype = build_function_type (
    1168                 :             :           double_type_node,
    1169                 :             :           tree_cons (NULL_TREE, double_type_node,
    1170                 :             :                      tree_cons (NULL_TREE, integer_type_node, endlink)));
    1171                 :       11652 :       fe->return_node = double_type_node;
    1172                 :       11652 :       break;
    1173                 :       11652 :     case BT_FN_LONG_DOUBLE_LONG_DOUBLE_INT:
    1174                 :       11652 :       ftype = build_function_type (
    1175                 :             :           long_double_type_node,
    1176                 :             :           tree_cons (NULL_TREE, long_double_type_node,
    1177                 :             :                      tree_cons (NULL_TREE, integer_type_node, endlink)));
    1178                 :       11652 :       fe->return_node = long_double_type_node;
    1179                 :       11652 :       break;
    1180                 :       23304 :     case BT_FN_FLOAT_FLOAT_FLOAT:
    1181                 :       23304 :       ftype = build_function_type (
    1182                 :             :           float_type_node,
    1183                 :             :           tree_cons (NULL_TREE, float_type_node,
    1184                 :             :                      tree_cons (NULL_TREE, float_type_node, endlink)));
    1185                 :       23304 :       fe->return_node = float_type_node;
    1186                 :       23304 :       break;
    1187                 :       23304 :     case BT_FN_DOUBLE_DOUBLE_DOUBLE:
    1188                 :       23304 :       ftype = build_function_type (
    1189                 :             :           double_type_node,
    1190                 :             :           tree_cons (NULL_TREE, double_type_node,
    1191                 :             :                      tree_cons (NULL_TREE, double_type_node, endlink)));
    1192                 :       23304 :       fe->return_node = double_type_node;
    1193                 :       23304 :       break;
    1194                 :           0 :     default:
    1195                 :           0 :       ERROR ("enum has no case");
    1196                 :             :     }
    1197                 :     1305024 :   fe->function_node
    1198                 :     1305024 :       = builtin_function (location, fe->name, ftype, fe->function_code,
    1199                 :             :                           fe->fclass, fe->library_name, NULL);
    1200                 :     1305024 : }
    1201                 :             : 
    1202                 :             : static tree
    1203                 :       69912 : find_builtin_tree (const char *name)
    1204                 :             : {
    1205                 :       69912 :   struct builtin_function_entry *fe;
    1206                 :             : 
    1207                 :     3180996 :   for (fe = &list_of_builtins[0]; fe->name != NULL; fe++)
    1208                 :     3180996 :     if (strcmp (name, fe->name) == 0)
    1209                 :       69912 :       return fe->function_node;
    1210                 :             : 
    1211                 :           0 :   ERROR ("cannot find builtin function");
    1212                 :             :   return NULL_TREE;
    1213                 :             : }
    1214                 :             : 
    1215                 :             : 
    1216                 :             : static void
    1217                 :       81564 : set_decl_built_in_class (tree decl, built_in_class c)
    1218                 :             : {
    1219                 :       81564 :   FUNCTION_DECL_CHECK (decl)->function_decl.built_in_class = c;
    1220                 :       81564 : }
    1221                 :             : 
    1222                 :             : 
    1223                 :             : static void
    1224                 :       81564 : set_decl_function_code (tree decl, built_in_function f)
    1225                 :             : {
    1226                 :       81564 :   tree_function_decl &fndecl = FUNCTION_DECL_CHECK (decl)->function_decl;
    1227                 :       81564 :   fndecl.function_code = f;
    1228                 :       81564 : }
    1229                 :             : 
    1230                 :             : /* Define a single builtin.  */
    1231                 :             : static void
    1232                 :       81564 : define_builtin (enum built_in_function val, const char *name, tree type,
    1233                 :             :                 const char *libname, int flags)
    1234                 :             : {
    1235                 :       81564 :   tree decl;
    1236                 :             : 
    1237                 :       81564 :   decl = build_decl (BUILTINS_LOCATION, FUNCTION_DECL, get_identifier (name),
    1238                 :             :                      type);
    1239                 :       81564 :   DECL_EXTERNAL (decl) = 1;
    1240                 :       81564 :   TREE_PUBLIC (decl) = 1;
    1241                 :       81564 :   SET_DECL_ASSEMBLER_NAME (decl, get_identifier (libname));
    1242                 :       81564 :   m2block_pushDecl (decl);
    1243                 :       81564 :   set_decl_built_in_class (decl, BUILT_IN_NORMAL);
    1244                 :       81564 :   set_decl_function_code (decl, val);
    1245                 :       81564 :   set_call_expr_flags (decl, flags);
    1246                 :             : 
    1247                 :       81564 :   set_builtin_decl (val, decl, true);
    1248                 :       81564 : }
    1249                 :             : 
    1250                 :             : void
    1251                 :       11652 : m2builtins_init (location_t location)
    1252                 :             : {
    1253                 :       11652 :   int i;
    1254                 :             : 
    1255                 :       11652 :   m2block_pushGlobalScope ();
    1256                 :       11652 :   endlink = void_list_node;
    1257                 :       11652 :   sizetype_endlink = tree_cons (NULL_TREE, sizetype, endlink);
    1258                 :       11652 :   math_endlink = tree_cons (NULL_TREE, void_type_node, NULL_TREE);
    1259                 :       11652 :   int_endlink = tree_cons (NULL_TREE, integer_type_node, NULL_TREE);
    1260                 :       11652 :   ptr_endlink = tree_cons (NULL_TREE, ptr_type_node, NULL_TREE);
    1261                 :       11652 :   const_ptr_endlink = tree_cons (NULL_TREE, const_ptr_type_node, NULL_TREE);
    1262                 :       11652 :   unsigned_endlink = tree_cons (NULL_TREE, unsigned_type_node, NULL_TREE);
    1263                 :             : 
    1264                 :       11652 :   float_ftype_void = build_function_type (float_type_node, math_endlink);
    1265                 :       11652 :   double_ftype_void = build_function_type (double_type_node, math_endlink);
    1266                 :       11652 :   ldouble_ftype_void
    1267                 :       11652 :       = build_function_type (long_double_type_node, math_endlink);
    1268                 :             : 
    1269                 :       11652 :   long_doubleptr_type_node = build_pointer_type (long_double_type_node);
    1270                 :       11652 :   doubleptr_type_node = build_pointer_type (double_type_node);
    1271                 :       11652 :   floatptr_type_node = build_pointer_type (float_type_node);
    1272                 :             : 
    1273                 :       11652 :   float_ftype_float = build_function_type (
    1274                 :             :       float_type_node, tree_cons (NULL_TREE, float_type_node, math_endlink));
    1275                 :             : 
    1276                 :       11652 :   double_ftype_double = build_function_type (
    1277                 :             :       double_type_node, tree_cons (NULL_TREE, double_type_node, math_endlink));
    1278                 :             : 
    1279                 :       11652 :   ldouble_ftype_ldouble = build_function_type (
    1280                 :             :       long_double_type_node,
    1281                 :             :       tree_cons (NULL_TREE, long_double_type_node, endlink));
    1282                 :             : 
    1283                 :       11652 :   builtin_ftype_int_var = build_function_type (
    1284                 :             :       integer_type_node, tree_cons (NULL_TREE, double_type_node, endlink));
    1285                 :             : 
    1286                 :     1316676 :   for (i = 0; list_of_builtins[i].name != NULL; i++)
    1287                 :     1305024 :     create_function_prototype (location, &list_of_builtins[i]);
    1288                 :             : 
    1289                 :       11652 :   define_builtin (BUILT_IN_TRAP, "__builtin_trap",
    1290                 :             :                   build_function_type_list (void_type_node, NULL_TREE),
    1291                 :             :                   "__builtin_trap", ECF_NOTHROW | ECF_LEAF | ECF_NORETURN);
    1292                 :       11652 :   define_builtin (BUILT_IN_ISGREATER, "isgreater", builtin_ftype_int_var,
    1293                 :             :                   "__builtin_isgreater", ECF_CONST | ECF_NOTHROW | ECF_LEAF);
    1294                 :       11652 :   define_builtin (BUILT_IN_ISGREATEREQUAL, "isgreaterequal",
    1295                 :             :                   builtin_ftype_int_var, "__builtin_isgreaterequal",
    1296                 :             :                   ECF_CONST | ECF_NOTHROW | ECF_LEAF);
    1297                 :       11652 :   define_builtin (BUILT_IN_ISLESS, "isless", builtin_ftype_int_var,
    1298                 :             :                   "__builtin_isless", ECF_CONST | ECF_NOTHROW | ECF_LEAF);
    1299                 :       11652 :   define_builtin (BUILT_IN_ISLESSEQUAL, "islessequal", builtin_ftype_int_var,
    1300                 :             :                   "__builtin_islessequal", ECF_CONST | ECF_NOTHROW | ECF_LEAF);
    1301                 :       11652 :   define_builtin (BUILT_IN_ISLESSGREATER, "islessgreater",
    1302                 :             :                   builtin_ftype_int_var, "__builtin_islessgreater",
    1303                 :             :                   ECF_CONST | ECF_NOTHROW | ECF_LEAF);
    1304                 :       11652 :   define_builtin (BUILT_IN_ISUNORDERED, "isunordered", builtin_ftype_int_var,
    1305                 :             :                   "__builtin_isunordered", ECF_CONST | ECF_NOTHROW | ECF_LEAF);
    1306                 :             : 
    1307                 :       11652 :   gm2_alloca_node = find_builtin_tree ("__builtin_alloca");
    1308                 :       11652 :   gm2_memcpy_node = find_builtin_tree ("__builtin_memcpy");
    1309                 :       11652 :   gm2_huge_valf_node = find_builtin_tree ("__builtin_huge_valf");
    1310                 :       11652 :   gm2_huge_val_node = find_builtin_tree ("__builtin_huge_val");
    1311                 :       11652 :   gm2_huge_vall_node = find_builtin_tree ("__builtin_huge_vall");
    1312                 :       11652 :   gm2_isfinite_node = find_builtin_tree ("__builtin_isfinite");
    1313                 :       11652 :   m2block_popGlobalScope ();
    1314                 :       11652 : }
    1315                 :             : 
    1316                 :             : #include "gt-m2-m2builtins.h"
    1317                 :             : 
    1318                 :             : /* END m2builtins.  */
        

Generated by: LCOV version 2.0-1

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.