LCOV - code coverage report
Current view: top level - gcc/go - go-lang.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 85.8 % 239 205
Test Date: 2024-04-13 14:00:49 Functions: 83.3 % 18 15
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* go-lang.cc -- Go frontend gcc interface.
       2                 :             :    Copyright (C) 2009-2024 Free Software Foundation, Inc.
       3                 :             : 
       4                 :             : This file is part of GCC.
       5                 :             : 
       6                 :             : GCC is free software; you can redistribute it and/or modify it under
       7                 :             : the terms of the GNU General Public License as published by the Free
       8                 :             : Software Foundation; either version 3, or (at your option) any later
       9                 :             : version.
      10                 :             : 
      11                 :             : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      12                 :             : WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13                 :             : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      14                 :             : for more details.
      15                 :             : 
      16                 :             : You should have received a copy of the GNU General Public License
      17                 :             : along with GCC; see the file COPYING3.  If not see
      18                 :             : <http://www.gnu.org/licenses/>.  */
      19                 :             : 
      20                 :             : #include "config.h"
      21                 :             : #include "system.h"
      22                 :             : #include "coretypes.h"
      23                 :             : #include "target.h"
      24                 :             : #include "tree.h"
      25                 :             : #include "gimple-expr.h"
      26                 :             : #include "diagnostic.h"
      27                 :             : #include "opts.h"
      28                 :             : #include "fold-const.h"
      29                 :             : #include "gimplify.h"
      30                 :             : #include "stor-layout.h"
      31                 :             : #include "debug.h"
      32                 :             : #include "convert.h"
      33                 :             : #include "langhooks.h"
      34                 :             : #include "langhooks-def.h"
      35                 :             : #include "common/common-target.h"
      36                 :             : 
      37                 :             : #include <mpfr.h>
      38                 :             : 
      39                 :             : #include "go-c.h"
      40                 :             : #include "go-gcc.h"
      41                 :             : 
      42                 :             : #ifndef TARGET_AIX_OS
      43                 :             : #define TARGET_AIX_OS 0
      44                 :             : #endif
      45                 :             : 
      46                 :             : /* Language-dependent contents of a type.  */
      47                 :             : 
      48                 :             : struct GTY(()) lang_type
      49                 :             : {
      50                 :             :   char dummy;
      51                 :             : };
      52                 :             : 
      53                 :             : /* Language-dependent contents of a decl.  */
      54                 :             : 
      55                 :             : struct GTY(()) lang_decl
      56                 :             : {
      57                 :             :   char dummy;
      58                 :             : };
      59                 :             : 
      60                 :             : /* Language-dependent contents of an identifier.  This must include a
      61                 :             :    tree_identifier.  */
      62                 :             : 
      63                 :             : struct GTY(()) lang_identifier
      64                 :             : {
      65                 :             :   struct tree_identifier common;
      66                 :             : };
      67                 :             : 
      68                 :             : /* The resulting tree type.  */
      69                 :             : 
      70                 :             : union GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"),
      71                 :             :            chain_next ("CODE_CONTAINS_STRUCT (TREE_CODE (&%h.generic), TS_COMMON) ? ((union lang_tree_node *) TREE_CHAIN (&%h.generic)) : NULL")))
      72                 :             : lang_tree_node
      73                 :             : {
      74                 :             :   union tree_node GTY((tag ("0"),
      75                 :             :                        desc ("tree_node_structure (&%h)"))) generic;
      76                 :             :   struct lang_identifier GTY((tag ("1"))) identifier;
      77                 :             : };
      78                 :             : 
      79                 :             : /* We don't use language_function.  */
      80                 :             : 
      81                 :             : struct GTY(()) language_function
      82                 :             : {
      83                 :             :   int dummy;
      84                 :             : };
      85                 :             : 
      86                 :             : /* Option information we need to pass to go_create_gogo.  */
      87                 :             : 
      88                 :             : static const char *go_pkgpath = NULL;
      89                 :             : static const char *go_prefix = NULL;
      90                 :             : static const char *go_relative_import_path = NULL;
      91                 :             : static const char *go_c_header = NULL;
      92                 :             : static const char *go_embedcfg = NULL;
      93                 :             : static const char *go_importcfg = NULL;
      94                 :             : 
      95                 :             : /* Language hooks.  */
      96                 :             : 
      97                 :             : static bool
      98                 :        4642 : go_langhook_init (void)
      99                 :             : {
     100                 :        4642 :   build_common_tree_nodes (false);
     101                 :             : 
     102                 :             :   /* We must create the gogo IR after calling build_common_tree_nodes
     103                 :             :      (because Gogo::define_builtin_function_trees refers indirectly
     104                 :             :      to, e.g., unsigned_char_type_node) but before calling
     105                 :             :      build_common_builtin_nodes (because it calls, indirectly,
     106                 :             :      go_type_for_size).  */
     107                 :        4642 :   struct go_create_gogo_args args;
     108                 :        4642 :   args.int_type_size = INT_TYPE_SIZE;
     109                 :        4642 :   args.pointer_size = POINTER_SIZE;
     110                 :        4642 :   args.pkgpath = go_pkgpath;
     111                 :        4642 :   args.prefix = go_prefix;
     112                 :        4642 :   args.relative_import_path = go_relative_import_path;
     113                 :        4642 :   args.c_header = go_c_header;
     114                 :        4642 :   args.embedcfg = go_embedcfg;
     115                 :        4642 :   args.importcfg = go_importcfg;
     116                 :        4642 :   args.check_divide_by_zero = go_check_divide_zero;
     117                 :        4642 :   args.check_divide_overflow = go_check_divide_overflow;
     118                 :        4642 :   args.compiling_runtime = go_compiling_runtime;
     119                 :        4642 :   args.debug_escape_level = go_debug_escape_level;
     120                 :        4642 :   args.debug_escape_hash = go_debug_escape_hash;
     121                 :        4642 :   args.nil_check_size_threshold = TARGET_AIX_OS ? -1 : 4096;
     122                 :        4642 :   args.debug_optimization = go_debug_optimization;
     123                 :        4642 :   args.need_eqtype = TARGET_AIX_OS ? true : false;
     124                 :        4642 :   args.linemap = go_get_linemap();
     125                 :        4642 :   args.backend = go_get_backend();
     126                 :        4642 :   go_create_gogo (&args);
     127                 :             : 
     128                 :        4642 :   build_common_builtin_nodes ();
     129                 :             : 
     130                 :             :   /* The default precision for floating point numbers.  This is used
     131                 :             :      for floating point constants with abstract type.  This may
     132                 :             :      eventually be controllable by a command line option.  */
     133                 :        4642 :   mpfr_set_default_prec (256);
     134                 :             : 
     135                 :             :   /* If necessary, override GCC's choice of minimum and maximum
     136                 :             :      exponents.  This should only affect GCC middle-end
     137                 :             :      compilation-time, not correctness.  */
     138                 :        4642 :   mpfr_exp_t exp = mpfr_get_emax ();
     139                 :        4642 :   if (exp < (1 << 16) - 1)
     140                 :        4642 :     mpfr_set_emax ((1 << 16) - 1);
     141                 :        4642 :   exp = mpfr_get_emin ();
     142                 :        4642 :   if (exp > - ((1 << 16) - 1))
     143                 :        4642 :     mpfr_set_emin (- ((1 << 16) - 1));
     144                 :             : 
     145                 :             :   /* Go uses exceptions.  */
     146                 :        4642 :   using_eh_for_cleanups ();
     147                 :             : 
     148                 :        4642 :   return true;
     149                 :             : }
     150                 :             : 
     151                 :             : /* The option mask.  */
     152                 :             : 
     153                 :             : static unsigned int
     154                 :       55889 : go_langhook_option_lang_mask (void)
     155                 :             : {
     156                 :       55889 :   return CL_Go;
     157                 :             : }
     158                 :             : 
     159                 :             : /* Initialize the options structure.  */
     160                 :             : 
     161                 :             : static void
     162                 :        4642 : go_langhook_init_options_struct (struct gcc_options *opts)
     163                 :             : {
     164                 :             :   /* Go says that signed overflow is precisely defined.  */
     165                 :        4642 :   opts->x_flag_wrapv = 1;
     166                 :             : 
     167                 :             :   /* We default to using strict aliasing, since Go pointers are safe.
     168                 :             :      This is turned off for code that imports the "unsafe" package,
     169                 :             :      because using unsafe.pointer violates C style aliasing
     170                 :             :      requirements.  */
     171                 :        4642 :   opts->x_flag_strict_aliasing = 1;
     172                 :             : 
     173                 :             :   /* Default to avoiding range issues for complex multiply and
     174                 :             :      divide.  */
     175                 :        4642 :   opts->x_flag_complex_method = 2;
     176                 :        4642 :   opts->x_flag_default_complex_method = opts->x_flag_complex_method;
     177                 :             : 
     178                 :             :   /* The builtin math functions should not set errno.  */
     179                 :        4642 :   opts->x_flag_errno_math = 0;
     180                 :        4642 :   opts->frontend_set_flag_errno_math = true;
     181                 :             : 
     182                 :             :   /* Exceptions are used to handle recovering from panics.  */
     183                 :        4642 :   opts->x_flag_exceptions = 1;
     184                 :        4642 :   opts->x_flag_non_call_exceptions = 1;
     185                 :             : 
     186                 :             :   /* We need to keep pointers live for the garbage collector.  */
     187                 :        4642 :   opts->x_flag_keep_gc_roots_live = 1;
     188                 :             : 
     189                 :             :   /* Go programs expect runtime.Callers to work, and that uses
     190                 :             :      libbacktrace that uses debug info.  Set the debug info level to 1
     191                 :             :      by default.  In post_options we will set the debug type if the
     192                 :             :      debug info level was not set back to 0 on the command line.  */
     193                 :        4642 :   opts->x_debug_info_level = DINFO_LEVEL_TERSE;
     194                 :        4642 : }
     195                 :             : 
     196                 :             : /* Infrastructure for a vector of char * pointers.  */
     197                 :             : 
     198                 :             : typedef const char *go_char_p;
     199                 :             : 
     200                 :             : /* The list of directories to search after all the Go specific
     201                 :             :    directories have been searched.  */
     202                 :             : 
     203                 :             : static vec<go_char_p> go_search_dirs;
     204                 :             : 
     205                 :             : /* Handle Go specific options.  Return 0 if we didn't do anything.  */
     206                 :             : 
     207                 :             : static bool
     208                 :       36597 : go_langhook_handle_option (
     209                 :             :     size_t scode,
     210                 :             :     const char *arg,
     211                 :             :     HOST_WIDE_INT value,
     212                 :             :     int kind ATTRIBUTE_UNUSED,
     213                 :             :     location_t loc ATTRIBUTE_UNUSED,
     214                 :             :     const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED)
     215                 :             : {
     216                 :       36597 :   enum opt_code code = (enum opt_code) scode;
     217                 :       36597 :   bool ret = true;
     218                 :             : 
     219                 :       36597 :   switch (code)
     220                 :             :     {
     221                 :        4483 :     case OPT_I:
     222                 :        4483 :       go_add_search_path (arg);
     223                 :        4483 :       break;
     224                 :             : 
     225                 :       25029 :     case OPT_L:
     226                 :             :       /* A -L option is assumed to come from the compiler driver.
     227                 :             :          This is a system directory.  We search the following
     228                 :             :          directories, if they exist, before this one:
     229                 :             :            dir/go/VERSION
     230                 :             :            dir/go/VERSION/MACHINE
     231                 :             :          This is like include/c++.  */
     232                 :       25029 :       {
     233                 :       25029 :         static const char dir_separator_str[] = { DIR_SEPARATOR, 0 };
     234                 :       25029 :         size_t len;
     235                 :       25029 :         char *p;
     236                 :       25029 :         struct stat st;
     237                 :             : 
     238                 :       25029 :         len = strlen (arg);
     239                 :       25029 :         p = XALLOCAVEC (char,
     240                 :             :                         (len + sizeof "go" + sizeof DEFAULT_TARGET_VERSION
     241                 :             :                          + sizeof DEFAULT_TARGET_MACHINE + 3));
     242                 :       25029 :         strcpy (p, arg);
     243                 :       25029 :         if (len > 0 && !IS_DIR_SEPARATOR (p[len - 1]))
     244                 :       25029 :           strcat (p, dir_separator_str);
     245                 :       25029 :         strcat (p, "go");
     246                 :       25029 :         strcat (p, dir_separator_str);
     247                 :       25029 :         strcat (p, DEFAULT_TARGET_VERSION);
     248                 :       25029 :         if (stat (p, &st) == 0 && S_ISDIR (st.st_mode))
     249                 :             :           {
     250                 :           0 :             go_add_search_path (p);
     251                 :           0 :             strcat (p, dir_separator_str);
     252                 :           0 :             strcat (p, DEFAULT_TARGET_MACHINE);
     253                 :           0 :             if (stat (p, &st) == 0 && S_ISDIR (st.st_mode))
     254                 :           0 :               go_add_search_path (p);
     255                 :             :           }
     256                 :             : 
     257                 :             :         /* Search ARG too, but only after we've searched to Go
     258                 :             :            specific directories for all -L arguments.  */
     259                 :       25029 :         go_search_dirs.safe_push (arg);
     260                 :             :       }
     261                 :       25029 :       break;
     262                 :             : 
     263                 :           0 :     case OPT_fgo_dump_:
     264                 :           0 :       ret = go_enable_dump (arg) ? true : false;
     265                 :           0 :       break;
     266                 :             : 
     267                 :           0 :     case OPT_fgo_optimize_:
     268                 :           0 :       ret = go_enable_optimize (arg, value) ? true : false;
     269                 :           0 :       break;
     270                 :             : 
     271                 :        2012 :     case OPT_fgo_pkgpath_:
     272                 :        2012 :       go_pkgpath = arg;
     273                 :        2012 :       break;
     274                 :             : 
     275                 :           0 :     case OPT_fgo_prefix_:
     276                 :           0 :       go_prefix = arg;
     277                 :           0 :       break;
     278                 :             : 
     279                 :          16 :     case OPT_fgo_relative_import_path_:
     280                 :          16 :       go_relative_import_path = arg;
     281                 :          16 :       break;
     282                 :             : 
     283                 :           4 :     case OPT_fgo_c_header_:
     284                 :           4 :       go_c_header = arg;
     285                 :           4 :       break;
     286                 :             : 
     287                 :           8 :     case OPT_fgo_embedcfg_:
     288                 :           8 :       go_embedcfg = arg;
     289                 :           8 :       break;
     290                 :             : 
     291                 :         377 :     case OPT_fgo_importcfg_:
     292                 :         377 :       go_importcfg = arg;
     293                 :         377 :       break;
     294                 :             : 
     295                 :             :     default:
     296                 :             :       /* Just return 1 to indicate that the option is valid.  */
     297                 :             :       break;
     298                 :             :     }
     299                 :             : 
     300                 :       36597 :   return ret;
     301                 :             : }
     302                 :             : 
     303                 :             : /* Run after parsing options.  */
     304                 :             : 
     305                 :             : static bool
     306                 :        4642 : go_langhook_post_options (const char **pfilename ATTRIBUTE_UNUSED)
     307                 :             : {
     308                 :        4642 :   unsigned int ix;
     309                 :        4642 :   const char *dir;
     310                 :             : 
     311                 :        4642 :   gcc_assert (num_in_fnames > 0);
     312                 :             : 
     313                 :       29671 :   FOR_EACH_VEC_ELT (go_search_dirs, ix, dir)
     314                 :       25029 :     go_add_search_path (dir);
     315                 :        4642 :   go_search_dirs.release ();
     316                 :             : 
     317                 :        4642 :   if (flag_excess_precision == EXCESS_PRECISION_DEFAULT)
     318                 :        4642 :     flag_excess_precision = EXCESS_PRECISION_STANDARD;
     319                 :             : 
     320                 :             :   /* Tail call optimizations can confuse uses of runtime.Callers.  */
     321                 :        4642 :   SET_OPTION_IF_UNSET (&global_options, &global_options_set,
     322                 :             :                        flag_optimize_sibling_calls, 0);
     323                 :             : 
     324                 :             :   /* Partial inlining can confuses uses of runtime.Callers.
     325                 :             :      See https://gcc.gnu.org/PR91663.  */
     326                 :        4642 :   SET_OPTION_IF_UNSET (&global_options, &global_options_set,
     327                 :             :                        flag_partial_inlining, 0);
     328                 :             : 
     329                 :             :   /* Go programs expect runtime.Callers to give the right answers,
     330                 :             :      which means that we can't combine functions even if they look the
     331                 :             :      same.  */
     332                 :        4642 :   SET_OPTION_IF_UNSET (&global_options, &global_options_set,
     333                 :             :                        flag_ipa_icf_functions, 0);
     334                 :             : 
     335                 :             :   /* If the debug info level is still 1, as set in init_options, make
     336                 :             :      sure that some debugging type is selected.  */
     337                 :        4642 :   if (global_options.x_debug_info_level == DINFO_LEVEL_TERSE
     338                 :        1275 :       && global_options.x_write_symbols == NO_DEBUG)
     339                 :           0 :     global_options.x_write_symbols = PREFERRED_DEBUGGING_TYPE;
     340                 :             : 
     341                 :             :   /* We turn on stack splitting if we can.  */
     342                 :        4642 :   if (targetm_common.supports_split_stack (false, &global_options))
     343                 :        4642 :     SET_OPTION_IF_UNSET (&global_options, &global_options_set,
     344                 :             :                          flag_split_stack, 1);
     345                 :             : 
     346                 :             :   /* If stack splitting is turned on, and the user did not explicitly
     347                 :             :      request function partitioning, turn off partitioning, as it
     348                 :             :      confuses the linker when trying to handle partitioned split-stack
     349                 :             :      code that calls a non-split-stack function.  */
     350                 :        4642 :   if (global_options.x_flag_split_stack
     351                 :        4642 :       && global_options.x_flag_reorder_blocks_and_partition)
     352                 :        2672 :     SET_OPTION_IF_UNSET (&global_options, &global_options_set,
     353                 :             :                          flag_reorder_blocks_and_partition, 0);
     354                 :             : 
     355                 :             :   /* Returning false means that the backend should be used.  */
     356                 :        4642 :   return false;
     357                 :             : }
     358                 :             : 
     359                 :             : static void
     360                 :        4642 : go_langhook_parse_file (void)
     361                 :             : {
     362                 :        4642 :   go_parse_input_files (in_fnames, num_in_fnames, flag_syntax_only,
     363                 :        4642 :                         go_require_return_statement);
     364                 :             : 
     365                 :             :   /* Final processing of globals and early debug info generation.  */
     366                 :        4642 :   go_write_globals ();
     367                 :        4642 : }
     368                 :             : 
     369                 :             : static tree
     370                 :     5645002 : go_langhook_type_for_size (unsigned int bits, int unsignedp)
     371                 :             : {
     372                 :     5645002 :   tree type;
     373                 :     5645002 :   if (unsignedp)
     374                 :             :     {
     375                 :     5360419 :       if (bits == INT_TYPE_SIZE)
     376                 :     2443914 :         type = unsigned_type_node;
     377                 :     2916505 :       else if (bits == CHAR_TYPE_SIZE)
     378                 :       51137 :         type = unsigned_char_type_node;
     379                 :     2865368 :       else if (bits == SHORT_TYPE_SIZE)
     380                 :        1893 :         type = short_unsigned_type_node;
     381                 :     2924108 :       else if (bits == LONG_TYPE_SIZE)
     382                 :     2802689 :         type = long_unsigned_type_node;
     383                 :       60786 :       else if (bits == LONG_LONG_TYPE_SIZE)
     384                 :       60633 :         type = long_long_unsigned_type_node;
     385                 :             :       else
     386                 :         153 :         type = make_unsigned_type(bits);
     387                 :             :     }
     388                 :             :   else
     389                 :             :     {
     390                 :      284583 :       if (bits == INT_TYPE_SIZE)
     391                 :      100245 :         type = integer_type_node;
     392                 :      184338 :       else if (bits == CHAR_TYPE_SIZE)
     393                 :         761 :         type = signed_char_type_node;
     394                 :      183577 :       else if (bits == SHORT_TYPE_SIZE)
     395                 :         658 :         type = short_integer_type_node;
     396                 :      185048 :       else if (bits == LONG_TYPE_SIZE)
     397                 :      180704 :         type = long_integer_type_node;
     398                 :        2215 :       else if (bits == LONG_LONG_TYPE_SIZE)
     399                 :        2043 :         type = long_long_integer_type_node;
     400                 :             :       else
     401                 :         172 :         type = make_signed_type(bits);
     402                 :             :     }
     403                 :     5645002 :   return type;
     404                 :             : }
     405                 :             : 
     406                 :             : static tree
     407                 :     5469431 : go_langhook_type_for_mode (machine_mode mode, int unsignedp)
     408                 :             : {
     409                 :     5469431 :   tree type;
     410                 :             :   /* Go has no vector types.  Build them here.  FIXME: It does not
     411                 :             :      make sense for the middle-end to ask the frontend for a type
     412                 :             :      which the frontend does not support.  However, at least for now
     413                 :             :      it is required.  See PR 46805.  */
     414                 :     5469431 :   if (GET_MODE_CLASS (mode) == MODE_VECTOR_BOOL
     415                 :     5469431 :       && valid_vector_subparts_p (GET_MODE_NUNITS (mode)))
     416                 :             :     {
     417                 :           0 :       unsigned int elem_bits = vector_element_size (GET_MODE_PRECISION (mode),
     418                 :             :                                                     GET_MODE_NUNITS (mode));
     419                 :           0 :       tree bool_type = build_nonstandard_boolean_type (elem_bits);
     420                 :           0 :       return build_vector_type_for_mode (bool_type, mode);
     421                 :             :     }
     422                 :     5461362 :   else if (VECTOR_MODE_P (mode)
     423                 :     5477500 :            && valid_vector_subparts_p (GET_MODE_NUNITS (mode)))
     424                 :             :     {
     425                 :        8069 :       tree inner;
     426                 :             : 
     427                 :       16138 :       inner = go_langhook_type_for_mode (GET_MODE_INNER (mode), unsignedp);
     428                 :        8069 :       if (inner != NULL_TREE)
     429                 :        8069 :         return build_vector_type_for_mode (inner, mode);
     430                 :             :       return NULL_TREE;
     431                 :             :     }
     432                 :             : 
     433                 :     5461362 :   scalar_int_mode imode;
     434                 :     5461362 :   scalar_float_mode fmode;
     435                 :     5461362 :   complex_mode cmode;
     436                 :     5461362 :   if (is_int_mode (mode, &imode))
     437                 :    10790452 :     return go_langhook_type_for_size (GET_MODE_BITSIZE (imode), unsignedp);
     438                 :       66136 :   else if (is_float_mode (mode, &fmode))
     439                 :             :     {
     440                 :       70562 :       switch (GET_MODE_BITSIZE (fmode))
     441                 :             :         {
     442                 :         320 :         case 32:
     443                 :         320 :           return float_type_node;
     444                 :       23834 :         case 64:
     445                 :       23834 :           return double_type_node;
     446                 :       11127 :         default:
     447                 :             :           // We have to check for long double in order to support
     448                 :             :           // i386 excess precision.
     449                 :       11127 :           if (fmode == TYPE_MODE(long_double_type_node))
     450                 :       11127 :             return long_double_type_node;
     451                 :             :         }
     452                 :             :     }
     453                 :       30855 :   else if (is_complex_float_mode (mode, &cmode))
     454                 :             :     {
     455                 :       55712 :       switch (GET_MODE_BITSIZE (cmode))
     456                 :             :         {
     457                 :        4646 :         case 64:
     458                 :        4646 :           return complex_float_type_node;
     459                 :        4642 :         case 128:
     460                 :        4642 :           return complex_double_type_node;
     461                 :       18568 :         default:
     462                 :             :           // We have to check for long double in order to support
     463                 :             :           // i386 excess precision.
     464                 :       18568 :           if (cmode == TYPE_MODE(complex_long_double_type_node))
     465                 :        4642 :             return complex_long_double_type_node;
     466                 :             :         }
     467                 :             :     }
     468                 :             : 
     469                 :             : #if HOST_BITS_PER_WIDE_INT >= 64
     470                 :             :   /* The middle-end and some backends rely on TImode being supported
     471                 :             :      for 64-bit HWI.  */
     472                 :       16925 :   if (mode == TImode)
     473                 :             :     {
     474                 :           0 :       type = build_nonstandard_integer_type (GET_MODE_BITSIZE (TImode),
     475                 :             :                                              unsignedp);
     476                 :           0 :       if (type && TYPE_MODE (type) == TImode)
     477                 :             :         return type;
     478                 :             :     }
     479                 :             : #endif
     480                 :             :   return NULL_TREE;
     481                 :             : }
     482                 :             : 
     483                 :             : /* Record a builtin function.  We just ignore builtin functions.  */
     484                 :             : 
     485                 :             : static tree
     486                 :      798424 : go_langhook_builtin_function (tree decl)
     487                 :             : {
     488                 :      798424 :   return decl;
     489                 :             : }
     490                 :             : 
     491                 :             : /* Return true if we are in the global binding level.  */
     492                 :             : 
     493                 :             : static bool
     494                 :       91234 : go_langhook_global_bindings_p (void)
     495                 :             : {
     496                 :       91234 :   return current_function_decl == NULL_TREE;
     497                 :             : }
     498                 :             : 
     499                 :             : /* Push a declaration into the current binding level.  We can't
     500                 :             :    usefully implement this since we don't want to convert from tree
     501                 :             :    back to one of our internal data structures.  I think the only way
     502                 :             :    this is used is to record a decl which is to be returned by
     503                 :             :    getdecls, and we could implement it for that purpose if
     504                 :             :    necessary.  */
     505                 :             : 
     506                 :             : static tree
     507                 :           0 : go_langhook_pushdecl (tree decl ATTRIBUTE_UNUSED)
     508                 :             : {
     509                 :           0 :   gcc_unreachable ();
     510                 :             : }
     511                 :             : 
     512                 :             : /* This hook is used to get the current list of declarations as trees.
     513                 :             :    We don't support that; instead we use the write_globals hook.  */
     514                 :             : 
     515                 :             : static tree
     516                 :           0 : go_langhook_getdecls (void)
     517                 :             : {
     518                 :           0 :   return NULL;
     519                 :             : }
     520                 :             : 
     521                 :             : /* Go specific gimplification.  We need to gimplify
     522                 :             :    CALL_EXPR_STATIC_CHAIN, because the gimplifier doesn't handle
     523                 :             :    it.  */
     524                 :             : 
     525                 :             : static int
     526                 :    91738700 : go_langhook_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
     527                 :             : {
     528                 :    91738700 :   if (TREE_CODE (*expr_p) == CALL_EXPR
     529                 :    91738700 :       && CALL_EXPR_STATIC_CHAIN (*expr_p) != NULL_TREE)
     530                 :       28144 :     gimplify_expr (&CALL_EXPR_STATIC_CHAIN (*expr_p), pre_p, post_p,
     531                 :             :                    is_gimple_val, fb_rvalue);
     532                 :    91738700 :   return GS_UNHANDLED;
     533                 :             : }
     534                 :             : 
     535                 :             : /* Return a decl for the exception personality function.  The function
     536                 :             :    itself is implemented in libgo/runtime/go-unwind.c.  */
     537                 :             : 
     538                 :             : static tree
     539                 :        8784 : go_langhook_eh_personality (void)
     540                 :             : {
     541                 :        8784 :   static tree personality_decl;
     542                 :        8784 :   if (personality_decl == NULL_TREE)
     543                 :             :     {
     544                 :         920 :       personality_decl = build_personality_function ("gccgo");
     545                 :         920 :       go_preserve_from_gc (personality_decl);
     546                 :             :     }
     547                 :        8784 :   return personality_decl;
     548                 :             : }
     549                 :             : 
     550                 :             : /* Get a value for the SARIF v2.1.0 "artifact.sourceLanguage" property,
     551                 :             :    based on the list in SARIF v2.1.0 Appendix J.  */
     552                 :             : 
     553                 :             : static const char *
     554                 :           0 : go_get_sarif_source_language (const char *)
     555                 :             : {
     556                 :           0 :   return "go";
     557                 :             : }
     558                 :             : 
     559                 :             : /* Functions called directly by the generic backend.  */
     560                 :             : 
     561                 :             : tree
     562                 :       25682 : convert (tree type, tree expr)
     563                 :             : {
     564                 :       25682 :   if (type == error_mark_node
     565                 :       25682 :       || expr == error_mark_node
     566                 :       51364 :       || TREE_TYPE (expr) == error_mark_node)
     567                 :             :     return error_mark_node;
     568                 :             : 
     569                 :       25682 :   if (type == TREE_TYPE (expr))
     570                 :             :     return expr;
     571                 :             : 
     572                 :       24477 :   if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (expr)))
     573                 :         126 :     return fold_convert (type, expr);
     574                 :             : 
     575                 :       24351 :   switch (TREE_CODE (type))
     576                 :             :     {
     577                 :           0 :     case VOID_TYPE:
     578                 :           0 :     case BOOLEAN_TYPE:
     579                 :           0 :       return fold_convert (type, expr);
     580                 :        5769 :     case INTEGER_TYPE:
     581                 :        5769 :       return fold (convert_to_integer (type, expr));
     582                 :           0 :     case POINTER_TYPE:
     583                 :           0 :       return fold (convert_to_pointer (type, expr));
     584                 :       18346 :     case REAL_TYPE:
     585                 :       18346 :       return fold (convert_to_real (type, expr));
     586                 :         236 :     case COMPLEX_TYPE:
     587                 :         236 :       return fold (convert_to_complex (type, expr));
     588                 :           0 :     default:
     589                 :           0 :       break;
     590                 :             :     }
     591                 :             : 
     592                 :           0 :   gcc_unreachable ();
     593                 :             : }
     594                 :             : 
     595                 :             : /* FIXME: This is a hack to preserve trees that we create from the
     596                 :             :    garbage collector.  */
     597                 :             : 
     598                 :             : static GTY(()) tree go_gc_root;
     599                 :             : 
     600                 :             : void
     601                 :     3885186 : go_preserve_from_gc (tree t)
     602                 :             : {
     603                 :     3885186 :   go_gc_root = tree_cons (NULL_TREE, t, go_gc_root);
     604                 :     3885186 : }
     605                 :             : 
     606                 :             : /* Convert an identifier for use in an error message.  */
     607                 :             : 
     608                 :             : const char *
     609                 :      274722 : go_localize_identifier (const char *ident)
     610                 :             : {
     611                 :      274722 :   return identifier_to_locale (ident);
     612                 :             : }
     613                 :             : 
     614                 :             : #undef LANG_HOOKS_NAME
     615                 :             : #undef LANG_HOOKS_INIT
     616                 :             : #undef LANG_HOOKS_OPTION_LANG_MASK
     617                 :             : #undef LANG_HOOKS_INIT_OPTIONS_STRUCT
     618                 :             : #undef LANG_HOOKS_HANDLE_OPTION
     619                 :             : #undef LANG_HOOKS_POST_OPTIONS
     620                 :             : #undef LANG_HOOKS_PARSE_FILE
     621                 :             : #undef LANG_HOOKS_TYPE_FOR_MODE
     622                 :             : #undef LANG_HOOKS_TYPE_FOR_SIZE
     623                 :             : #undef LANG_HOOKS_BUILTIN_FUNCTION
     624                 :             : #undef LANG_HOOKS_GLOBAL_BINDINGS_P
     625                 :             : #undef LANG_HOOKS_PUSHDECL
     626                 :             : #undef LANG_HOOKS_GETDECLS
     627                 :             : #undef LANG_HOOKS_GIMPLIFY_EXPR
     628                 :             : #undef LANG_HOOKS_EH_PERSONALITY
     629                 :             : #undef LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE
     630                 :             : 
     631                 :             : #define LANG_HOOKS_NAME                 "GNU Go"
     632                 :             : #define LANG_HOOKS_INIT                 go_langhook_init
     633                 :             : #define LANG_HOOKS_OPTION_LANG_MASK     go_langhook_option_lang_mask
     634                 :             : #define LANG_HOOKS_INIT_OPTIONS_STRUCT  go_langhook_init_options_struct
     635                 :             : #define LANG_HOOKS_HANDLE_OPTION        go_langhook_handle_option
     636                 :             : #define LANG_HOOKS_POST_OPTIONS         go_langhook_post_options
     637                 :             : #define LANG_HOOKS_PARSE_FILE           go_langhook_parse_file
     638                 :             : #define LANG_HOOKS_TYPE_FOR_MODE        go_langhook_type_for_mode
     639                 :             : #define LANG_HOOKS_TYPE_FOR_SIZE        go_langhook_type_for_size
     640                 :             : #define LANG_HOOKS_BUILTIN_FUNCTION     go_langhook_builtin_function
     641                 :             : #define LANG_HOOKS_GLOBAL_BINDINGS_P    go_langhook_global_bindings_p
     642                 :             : #define LANG_HOOKS_PUSHDECL             go_langhook_pushdecl
     643                 :             : #define LANG_HOOKS_GETDECLS             go_langhook_getdecls
     644                 :             : #define LANG_HOOKS_GIMPLIFY_EXPR        go_langhook_gimplify_expr
     645                 :             : #define LANG_HOOKS_EH_PERSONALITY       go_langhook_eh_personality
     646                 :             : #define LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE go_get_sarif_source_language
     647                 :             : 
     648                 :             : struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
     649                 :             : 
     650                 :             : #include "gt-go-go-lang.h"
     651                 :             : #include "gtype-go.h"
        

Generated by: LCOV version 2.1-beta

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