LCOV - code coverage report
Current view: top level - gcc - langhooks.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 70.4 % 331 233
Test Date: 2026-10-17 16:30:31 Functions: 69.4 % 72 50
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* Default language-specific hooks.
       2              :    Copyright (C) 2001-2026 Free Software Foundation, Inc.
       3              :    Contributed by Alexandre Oliva  <aoliva@redhat.com>
       4              : 
       5              : This file is part of GCC.
       6              : 
       7              : GCC is free software; you can redistribute it and/or modify
       8              : it under the terms of the GNU General Public License as published by
       9              : the Free Software Foundation; either version 3, or (at your option)
      10              : any later version.
      11              : 
      12              : GCC is distributed in the hope that it will be useful,
      13              : but WITHOUT ANY WARRANTY; without even the implied warranty of
      14              : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15              : GNU General Public License for more details.
      16              : 
      17              : You should have received a copy of the GNU General Public License
      18              : along with GCC; see the file COPYING3.  If not see
      19              : <http://www.gnu.org/licenses/>.  */
      20              : 
      21              : #define INCLUDE_VECTOR
      22              : #include "config.h"
      23              : #include "system.h"
      24              : #include "coretypes.h"
      25              : #include "target.h"
      26              : #include "rtl.h"
      27              : #include "tree.h"
      28              : #include "timevar.h"
      29              : #include "stringpool.h"
      30              : #include "diagnostic.h"
      31              : #include "intl.h"
      32              : #include "toplev.h"
      33              : #include "attribs.h"
      34              : #include "gimplify.h"
      35              : #include "langhooks.h"
      36              : #include "tree-diagnostic.h"
      37              : #include "output.h"
      38              : #include "stor-layout.h"
      39              : #include "cgraph.h"
      40              : #include "debug.h"
      41              : #include "diagnostics/text-sink.h"
      42              : 
      43              : /* Do nothing; in many cases the default hook.  */
      44              : 
      45              : void
      46        72326 : lhd_do_nothing (void)
      47              : {
      48        72326 : }
      49              : 
      50              : /* Do nothing (tree).  */
      51              : 
      52              : void
      53      4896233 : lhd_do_nothing_t (tree ARG_UNUSED (t))
      54              : {
      55      4896233 : }
      56              : 
      57              : /* Pass through (tree).  */
      58              : tree
      59          424 : lhd_pass_through_t (tree t)
      60              : {
      61          424 :   return t;
      62              : }
      63              : 
      64              : /* Do nothing (int, int, int).  Return NULL_TREE.  */
      65              : 
      66              : tree
      67            0 : lhd_do_nothing_iii_return_null_tree (int ARG_UNUSED (i),
      68              :                                      int ARG_UNUSED (j),
      69              :                                      int ARG_UNUSED (k))
      70              : {
      71            0 :   return NULL_TREE;
      72              : }
      73              : 
      74              : /* Do nothing (function).  */
      75              : 
      76              : void
      77            0 : lhd_do_nothing_f (struct function * ARG_UNUSED (f))
      78              : {
      79            0 : }
      80              : 
      81              : /* Do nothing (return NULL_TREE).  */
      82              : 
      83              : tree
      84            0 : lhd_return_null_tree (tree ARG_UNUSED (t))
      85              : {
      86            0 :   return NULL_TREE;
      87              : }
      88              : 
      89              : /* Do nothing (return NULL_TREE).  */
      90              : 
      91              : tree
      92         9286 : lhd_return_null_const_tree (const_tree ARG_UNUSED (t))
      93              : {
      94         9286 :   return NULL_TREE;
      95              : }
      96              : 
      97              : /* The default post options hook.  */
      98              : 
      99              : bool
     100         1371 : lhd_post_options (const char ** ARG_UNUSED (pfilename))
     101              : {
     102              :   /* Excess precision other than "fast" requires front-end
     103              :      support.  */
     104         1371 :   flag_excess_precision = EXCESS_PRECISION_FAST;
     105         1371 :   return false;
     106              : }
     107              : 
     108              : /* Called from by print-tree.cc.  */
     109              : 
     110              : void
     111           71 : lhd_print_tree_nothing (FILE * ARG_UNUSED (file),
     112              :                         tree ARG_UNUSED (node),
     113              :                         int ARG_UNUSED (indent))
     114              : {
     115           71 : }
     116              : 
     117              : /* Called from check_global_declaration.  */
     118              : 
     119              : bool
     120            5 : lhd_warn_unused_global_decl (const_tree decl)
     121              : {
     122              :   /* This is what used to exist in check_global_declaration.  Probably
     123              :      not many of these actually apply to non-C languages.  */
     124              : 
     125            5 :   if (TREE_CODE (decl) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (decl))
     126              :     return false;
     127            5 :   if (VAR_P (decl) && TREE_READONLY (decl))
     128              :     return false;
     129            5 :   if (DECL_IN_SYSTEM_HEADER (decl))
     130            0 :     return false;
     131              : 
     132              :   return true;
     133              : }
     134              : 
     135              : /* Set the DECL_ASSEMBLER_NAME for DECL.  */
     136              : void
     137      6406999 : lhd_set_decl_assembler_name (tree decl)
     138              : {
     139      6406999 :   tree id;
     140              : 
     141              :   /* set_decl_assembler_name may be called on TYPE_DECL to record ODR
     142              :      name for C++ types.  By default types have no ODR names.  */
     143      6406999 :   if (TREE_CODE (decl) == TYPE_DECL)
     144              :     return;
     145              : 
     146              :   /* The language-independent code should never use the
     147              :      DECL_ASSEMBLER_NAME for lots of DECLs.  Only FUNCTION_DECLs and
     148              :      VAR_DECLs for variables with static storage duration need a real
     149              :      DECL_ASSEMBLER_NAME.  */
     150      6362593 :   gcc_assert (TREE_CODE (decl) == FUNCTION_DECL
     151              :               || (VAR_P (decl)
     152              :                   && (TREE_STATIC (decl)
     153              :                       || DECL_EXTERNAL (decl)
     154              :                       || TREE_PUBLIC (decl))));
     155              : 
     156              :   /* By default, assume the name to use in assembly code is the same
     157              :      as that used in the source language.  (That's correct for C, and
     158              :      GCC used to set DECL_ASSEMBLER_NAME to the same value as
     159              :      DECL_NAME in build_decl, so this choice provides backwards
     160              :      compatibility with existing front-ends.  This assumption is wrapped
     161              :      in a target hook, to allow for target-specific modification of the
     162              :      identifier.
     163              : 
     164              :      Can't use just the variable's own name for a variable whose scope
     165              :      is less than the whole compilation.  Concatenate a distinguishing
     166              :      number.  */
     167              : 
     168      6362593 :   if (TREE_PUBLIC (decl) || DECL_FILE_SCOPE_P (decl))
     169      6121957 :     id = targetm.mangle_decl_assembler_name (decl, DECL_NAME (decl));
     170              :   else
     171              :     {
     172       240636 :       const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
     173       240636 :       static unsigned long num;
     174       240636 :       char *label;
     175              : 
     176       240636 :       ASM_FORMAT_PRIVATE_NAME (label, name, num++);
     177       240636 :       id = get_identifier (label);
     178              :     }
     179              : 
     180      6362593 :   SET_DECL_ASSEMBLER_NAME (decl, id);
     181              : }
     182              : 
     183              : /* Forcibly overwrite the DECL_ASSEMBLER_NAME for DECL to NAME.  */
     184              : void
     185    178123479 : lhd_overwrite_decl_assembler_name (tree decl, tree name)
     186              : {
     187    178123479 :   DECL_ASSEMBLER_NAME_RAW (decl) = name;
     188    178123479 : }
     189              : 
     190              : /* Type promotion for variable arguments.  */
     191              : tree
     192            0 : lhd_type_promotes_to (tree ARG_UNUSED (type))
     193              : {
     194            0 :   gcc_unreachable ();
     195              : }
     196              : 
     197              : /* Registration of machine- or os-specific builtin types.  */
     198              : void
     199       155840 : lhd_register_builtin_type (tree ARG_UNUSED (type),
     200              :                            const char * ARG_UNUSED (name))
     201              : {
     202       155840 : }
     203              : 
     204              : /* Invalid use of an incomplete type.  */
     205              : void
     206            0 : lhd_incomplete_type_error (location_t ARG_UNUSED (loc),
     207              :                            const_tree ARG_UNUSED (value), const_tree type)
     208              : {
     209            0 :   gcc_assert (TREE_CODE (type) == ERROR_MARK);
     210            0 :   return;
     211              : }
     212              : 
     213              : /* Provide a default routine for alias sets that always returns -1.  This
     214              :    is used by languages that don't need to do anything special.  */
     215              : 
     216              : alias_set_type
     217   1048219745 : lhd_get_alias_set (tree ARG_UNUSED (t))
     218              : {
     219   1048219745 :   return -1;
     220              : }
     221              : 
     222              : /* This is the default decl_printable_name function.  */
     223              : 
     224              : const char *
     225      8041827 : lhd_decl_printable_name (tree decl, int ARG_UNUSED (verbosity))
     226              : {
     227      8041827 :   gcc_assert (decl && DECL_NAME (decl));
     228      8041827 :   return IDENTIFIER_POINTER (DECL_NAME (decl));
     229              : }
     230              : 
     231              : /* This is the default dwarf_name function.  */
     232              : 
     233              : const char *
     234      7631480 : lhd_dwarf_name (tree t, int verbosity)
     235              : {
     236      7631480 :   gcc_assert (DECL_P (t));
     237              : 
     238      7631480 :   return lang_hooks.decl_printable_name (t, verbosity);
     239              : }
     240              : 
     241              : /* This compares two types for equivalence ("compatible" in C-based languages).
     242              :    This routine should only return 1 if it is sure.  It should not be used
     243              :    in contexts where erroneously returning 0 causes problems.  */
     244              : 
     245              : int
     246            0 : lhd_types_compatible_p (tree x, tree y)
     247              : {
     248            0 :   return TYPE_MAIN_VARIANT (x) == TYPE_MAIN_VARIANT (y);
     249              : }
     250              : 
     251              : /* lang_hooks.tree_dump.dump_tree:  Dump language-specific parts of tree
     252              :    nodes.  Returns nonzero if it does not want the usual dumping of the
     253              :    second argument.  */
     254              : 
     255              : bool
     256          622 : lhd_tree_dump_dump_tree (void *di ATTRIBUTE_UNUSED, tree t ATTRIBUTE_UNUSED)
     257              : {
     258          622 :   return false;
     259              : }
     260              : 
     261              : /* lang_hooks.tree_dump.type_qual:  Determine type qualifiers in a
     262              :    language-specific way.  */
     263              : 
     264              : int
     265          103 : lhd_tree_dump_type_quals (const_tree t)
     266              : {
     267          103 :   return TYPE_QUALS (t);
     268              : }
     269              : 
     270              : /* lang_hooks.gimplify_expr re-writes *EXPR_P into GIMPLE form.  */
     271              : 
     272              : int
     273     89342992 : lhd_gimplify_expr (tree *expr_p ATTRIBUTE_UNUSED,
     274              :                    gimple_seq *pre_p ATTRIBUTE_UNUSED,
     275              :                    gimple_seq *post_p ATTRIBUTE_UNUSED)
     276              : {
     277     89342992 :   return GS_UNHANDLED;
     278              : }
     279              : 
     280              : /* lang_hooks.tree_size: Determine the size of a tree with code C,
     281              :    which is a language-specific tree code in category tcc_constant,
     282              :    tcc_exceptional or tcc_type.  The default expects never to be called.  */
     283              : size_t
     284            0 : lhd_tree_size (enum tree_code c ATTRIBUTE_UNUSED)
     285              : {
     286            0 :   gcc_unreachable ();
     287              : }
     288              : 
     289              : /* Return true if decl, which is a function decl, may be called by a
     290              :    sibcall.  */
     291              : 
     292              : bool
     293       132250 : lhd_decl_ok_for_sibcall (const_tree decl ATTRIBUTE_UNUSED)
     294              : {
     295       132250 :   return true;
     296              : }
     297              : 
     298              : /* Generic global declaration processing.  This is meant to be called
     299              :    by the front-ends at the end of parsing.  C/C++ do their own thing,
     300              :    but other front-ends may call this.  */
     301              : 
     302              : void
     303        32427 : global_decl_processing (void)
     304              : {
     305        32427 :   tree globals, decl, *vec;
     306        32427 :   int len, i;
     307              : 
     308        32427 :   timevar_stop (TV_PHASE_PARSING);
     309        32427 :   timevar_start (TV_PHASE_DEFERRED);
     310              :   /* Really define vars that have had only a tentative definition.
     311              :      Really output inline functions that must actually be callable
     312              :      and have not been output so far.  */
     313              : 
     314        32427 :   globals = lang_hooks.decls.getdecls ();
     315        32427 :   len = list_length (globals);
     316        32427 :   vec = XNEWVEC (tree, len);
     317              : 
     318              :   /* Process the decls in reverse order--earliest first.
     319              :      Put them into VEC from back to front, then take out from front.  */
     320              : 
     321    149318035 :   for (i = 0, decl = globals; i < len; i++, decl = DECL_CHAIN (decl))
     322    149253181 :     vec[len - i - 1] = decl;
     323              : 
     324        32427 :   wrapup_global_declarations (vec, len);
     325        32427 :   timevar_stop (TV_PHASE_DEFERRED);
     326              : 
     327        32427 :   timevar_start (TV_PHASE_PARSING);
     328        32427 :   free (vec);
     329        32427 : }
     330              : 
     331              : /* Called to perform language-specific initialization of CTX.  */
     332              : void
     333        79730 : lhd_initialize_diagnostics (diagnostics::context *ctx ATTRIBUTE_UNUSED)
     334              : {
     335        79730 : }
     336              : 
     337              : /* Called to register dumps.  */
     338              : void
     339       171937 : lhd_register_dumps (gcc::dump_manager *)
     340              : {
     341       171937 : }
     342              : 
     343              : /* Called to perform language-specific options initialization.  */
     344              : void
     345        31823 : lhd_init_options (unsigned int decoded_options_count ATTRIBUTE_UNUSED,
     346              :                   struct cl_decoded_option *decoded_options ATTRIBUTE_UNUSED)
     347              : {
     348        31823 : }
     349              : 
     350              : /* By default, always complain about options for the wrong language.  */
     351              : bool
     352            6 : lhd_complain_wrong_lang_p (const struct cl_option *option ATTRIBUTE_UNUSED)
     353              : {
     354            6 :   return true;
     355              : }
     356              : 
     357              : /* By default, no language-specific options are valid.  */
     358              : bool
     359            0 : lhd_handle_option (size_t code ATTRIBUTE_UNUSED,
     360              :                    const char *arg ATTRIBUTE_UNUSED,
     361              :                    HOST_WIDE_INT value ATTRIBUTE_UNUSED,
     362              :                    int kind ATTRIBUTE_UNUSED,
     363              :                    location_t loc ATTRIBUTE_UNUSED,
     364              :                    const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED)
     365              : {
     366            0 :   return false;
     367              : }
     368              : 
     369              : /* The default function to print out name of current function that caused
     370              :    an error.  */
     371              : void
     372       106864 : lhd_print_error_function (diagnostics::text_sink &text_output,
     373              :                           const char *file,
     374              :                           const diagnostics::diagnostic_info *diagnostic)
     375              : {
     376       106864 :   diagnostics::context *const context = &text_output.get_context ();
     377       106864 :   if (diagnostic_last_function_changed (context, diagnostic))
     378              :     {
     379        16123 :       pretty_printer *const pp = text_output.get_printer ();
     380        16123 :       char *old_prefix = pp_take_prefix (pp);
     381        16123 :       tree abstract_origin = diagnostic_abstract_origin (diagnostic);
     382        16123 :       char *new_prefix = (file && abstract_origin == NULL)
     383        16123 :                          ? text_output.file_name_as_prefix (file) : NULL;
     384              : 
     385        16123 :       pp_set_prefix (pp, new_prefix);
     386              : 
     387        16123 :       if (current_function_decl == NULL)
     388          600 :         pp_printf (pp, _("At top level:"));
     389              :       else
     390              :         {
     391        15523 :           tree fndecl, ao;
     392              : 
     393        15523 :           if (abstract_origin)
     394              :             {
     395          317 :               ao = BLOCK_ABSTRACT_ORIGIN (abstract_origin);
     396          317 :               gcc_assert (TREE_CODE (ao) == FUNCTION_DECL);
     397              :               fndecl = ao;
     398              :             }
     399              :           else
     400              :             fndecl = current_function_decl;
     401              : 
     402        15523 :           if (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE)
     403            8 :             pp_printf
     404            8 :               (pp, _("In member function %qs"),
     405            8 :                identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)));
     406              :           else
     407        15515 :             pp_printf
     408        15515 :               (pp, _("In function %qs"),
     409        15515 :                identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)));
     410              : 
     411        15994 :           while (abstract_origin)
     412              :             {
     413          471 :               location_t *locus;
     414          471 :               tree block = abstract_origin;
     415              : 
     416          471 :               locus = &BLOCK_SOURCE_LOCATION (block);
     417          471 :               fndecl = NULL;
     418          471 :               block = BLOCK_SUPERCONTEXT (block);
     419         1082 :               while (block && TREE_CODE (block) == BLOCK
     420         1206 :                      && BLOCK_ABSTRACT_ORIGIN (block))
     421              :                 {
     422          294 :                   ao = BLOCK_ABSTRACT_ORIGIN (block);
     423          294 :                   if (TREE_CODE (ao) == FUNCTION_DECL)
     424              :                     {
     425              :                       fndecl = ao;
     426              :                       break;
     427              :                     }
     428          140 :                   else if (TREE_CODE (ao) != BLOCK)
     429              :                     break;
     430              : 
     431          140 :                   block = BLOCK_SUPERCONTEXT (block);
     432              :                 }
     433          471 :               if (fndecl)
     434              :                 abstract_origin = block;
     435              :               else
     436              :                 {
     437          687 :                   while (block && TREE_CODE (block) == BLOCK)
     438          370 :                     block = BLOCK_SUPERCONTEXT (block);
     439              : 
     440          317 :                   if (block && TREE_CODE (block) == FUNCTION_DECL)
     441              :                     fndecl = block;
     442              :                   abstract_origin = NULL;
     443              :                 }
     444              :               if (fndecl)
     445              :                 {
     446          471 :                   expanded_location s = expand_location (*locus);
     447          471 :                   pp_comma (pp);
     448          471 :                   pp_newline (pp);
     449          471 :                   if (s.file != NULL)
     450              :                     {
     451          471 :                       if (context->m_show_column)
     452          471 :                         pp_printf (pp,
     453          471 :                                    _("    inlined from %qs at %r%s:%d:%d%R"),
     454          471 :                                    identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)),
     455              :                                    "locus", s.file, s.line, s.column);
     456              :                       else
     457            0 :                         pp_printf (pp,
     458            0 :                                    _("    inlined from %qs at %r%s:%d%R"),
     459            0 :                                    identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)),
     460              :                                    "locus", s.file, s.line);
     461              : 
     462              :                     }
     463              :                   else
     464            0 :                     pp_printf (pp, _("    inlined from %qs"),
     465            0 :                                identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)));
     466              :                 }
     467              :             }
     468        15523 :           pp_colon (pp);
     469              :         }
     470              : 
     471        16123 :       diagnostic_set_last_function (context, diagnostic);
     472        16123 :       pp_newline_and_flush (pp);
     473        16123 :       pp->set_prefix (old_prefix);
     474              :     }
     475       106864 : }
     476              : 
     477              : tree
     478       228742 : lhd_make_node (enum tree_code code)
     479              : {
     480       228742 :   return make_node (code);
     481              : }
     482              : 
     483              : /* Default implementation of LANG_HOOKS_SIMULATE_ENUM_DECL.  Assume a
     484              :    simple int-based enumerator (which is all the hook can be used for
     485              :    at present) and push each decl individually without any decoration.
     486              : 
     487              :    This definition is suitable for LTO and is generic enough that it
     488              :    might be reusable elsewhere.  */
     489              : tree
     490            0 : lhd_simulate_enum_decl (location_t loc, const char *name,
     491              :                         vec<string_int_pair> *values_ptr)
     492              : {
     493            0 :   tree enumtype = lang_hooks.types.make_type (ENUMERAL_TYPE);
     494            0 :   tree enumdecl = build_decl (loc, TYPE_DECL, get_identifier (name), enumtype);
     495            0 :   TYPE_STUB_DECL (enumtype) = enumdecl;
     496              : 
     497            0 :   tree value_chain = NULL_TREE;
     498            0 :   string_int_pair *value;
     499            0 :   vec<string_int_pair> values = *values_ptr;
     500            0 :   unsigned int i;
     501            0 :   FOR_EACH_VEC_ELT (values, i, value)
     502              :     {
     503            0 :       tree value_decl = build_decl (loc, CONST_DECL,
     504              :                                     get_identifier (value->first), enumtype);
     505            0 :       DECL_INITIAL (value_decl) = build_int_cst (integer_type_node,
     506            0 :                                                  value->second);
     507            0 :       lang_hooks.decls.pushdecl (value_decl);
     508            0 :       value_chain = tree_cons (value_decl, DECL_INITIAL (value_decl),
     509              :                                value_chain);
     510              :     }
     511              : 
     512            0 :   TYPE_MIN_VALUE (enumtype) = TYPE_MIN_VALUE (integer_type_node);
     513            0 :   TYPE_MAX_VALUE (enumtype) = TYPE_MAX_VALUE (integer_type_node);
     514            0 :   SET_TYPE_ALIGN (enumtype, TYPE_ALIGN (integer_type_node));
     515            0 :   TYPE_PRECISION (enumtype) = TYPE_PRECISION (integer_type_node);
     516            0 :   layout_type (enumtype);
     517            0 :   lang_hooks.decls.pushdecl (enumdecl);
     518              : 
     519            0 :   return enumtype;
     520              : }
     521              : 
     522              : /* Default implementation of LANG_HOOKS_SIMULATE_RECORD_DECL.
     523              :    Just create a normal RECORD_TYPE and a TYPE_DECL for it.  */
     524              : tree
     525            0 : lhd_simulate_record_decl (location_t loc, const char *name,
     526              :                           array_slice<const tree> fields)
     527              : {
     528            0 :   for (unsigned int i = 1; i < fields.size (); ++i)
     529              :     /* Reversed by finish_builtin_struct.  */
     530            0 :     DECL_CHAIN (fields[i]) = fields[i - 1];
     531              : 
     532            0 :   tree type = lang_hooks.types.make_type (RECORD_TYPE);
     533            0 :   finish_builtin_struct (type, name, fields.back (), NULL_TREE);
     534              : 
     535            0 :   tree decl = build_decl (loc, TYPE_DECL, get_identifier (name), type);
     536            0 :   lang_hooks.decls.pushdecl (decl);
     537              : 
     538            0 :   return type;
     539              : }
     540              : 
     541              : /* Default implementation of LANG_HOOKS_TYPE_FOR_SIZE.
     542              :    Return an integer type with PRECISION bits of precision,
     543              :    that is unsigned if UNSIGNEDP is nonzero, otherwise signed.  */
     544              : 
     545              : tree
     546       129117 : lhd_type_for_size (unsigned precision, int unsignedp)
     547              : {
     548       129117 :   int i;
     549              : 
     550       129117 :   if (precision == TYPE_PRECISION (integer_type_node))
     551        25849 :     return unsignedp ? unsigned_type_node : integer_type_node;
     552              : 
     553       103268 :   if (precision == TYPE_PRECISION (signed_char_type_node))
     554        25807 :     return unsignedp ? unsigned_char_type_node : signed_char_type_node;
     555              : 
     556        77461 :   if (precision == TYPE_PRECISION (short_integer_type_node))
     557        25808 :     return unsignedp ? short_unsigned_type_node : short_integer_type_node;
     558              : 
     559        51653 :   if (precision == TYPE_PRECISION (long_integer_type_node))
     560        25848 :     return unsignedp ? long_unsigned_type_node : long_integer_type_node;
     561              : 
     562        25805 :   if (precision == TYPE_PRECISION (long_long_integer_type_node))
     563            0 :     return unsignedp
     564            0 :            ? long_long_unsigned_type_node
     565            0 :            : long_long_integer_type_node;
     566              : 
     567        25805 :   for (i = 0; i < NUM_INT_N_ENTS; i ++)
     568        25805 :     if (int_n_enabled_p[i]
     569        25805 :         && precision == int_n_data[i].bitsize)
     570        25805 :       return (unsignedp ? int_n_trees[i].unsigned_type
     571        25805 :               : int_n_trees[i].signed_type);
     572              : 
     573            0 :   if (precision <= TYPE_PRECISION (intQI_type_node))
     574            0 :     return unsignedp ? unsigned_intQI_type_node : intQI_type_node;
     575              : 
     576            0 :   if (precision <= TYPE_PRECISION (intHI_type_node))
     577            0 :     return unsignedp ? unsigned_intHI_type_node : intHI_type_node;
     578              : 
     579            0 :   if (precision <= TYPE_PRECISION (intSI_type_node))
     580            0 :     return unsignedp ? unsigned_intSI_type_node : intSI_type_node;
     581              : 
     582            0 :   if (precision <= TYPE_PRECISION (intDI_type_node))
     583            0 :     return unsignedp ? unsigned_intDI_type_node : intDI_type_node;
     584              : 
     585            0 :   if (precision <= TYPE_PRECISION (intTI_type_node))
     586            0 :     return unsignedp ? unsigned_intTI_type_node : intTI_type_node;
     587              : 
     588              :   return NULL_TREE;
     589              : }
     590              : 
     591              : HOST_WIDE_INT
     592      4656557 : lhd_to_target_charset (HOST_WIDE_INT c)
     593              : {
     594      4656557 :   return c;
     595              : }
     596              : 
     597              : tree
     598   1335621515 : lhd_expr_to_decl (tree expr, bool *tc ATTRIBUTE_UNUSED, bool *se ATTRIBUTE_UNUSED)
     599              : {
     600   1335621515 :   return expr;
     601              : }
     602              : 
     603              : /* Return sharing kind if OpenMP sharing attribute of DECL is
     604              :    predetermined, OMP_CLAUSE_DEFAULT_UNSPECIFIED otherwise.  */
     605              : 
     606              : enum omp_clause_default_kind
     607            0 : lhd_omp_predetermined_sharing (tree decl)
     608              : {
     609            0 :   if (DECL_ARTIFICIAL (decl))
     610            0 :     return OMP_CLAUSE_DEFAULT_SHARED;
     611              :   return OMP_CLAUSE_DEFAULT_UNSPECIFIED;
     612              : }
     613              : 
     614              : /* Return sharing kind if OpenMP mapping attribute of DECL is
     615              :    predetermined, OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED otherwise.  */
     616              : 
     617              : enum omp_clause_defaultmap_kind
     618            0 : lhd_omp_predetermined_mapping (tree decl)
     619              : {
     620            0 :   if (DECL_ARTIFICIAL (decl))
     621            0 :     return OMP_CLAUSE_DEFAULTMAP_TO;
     622              :   return OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED;
     623              : }
     624              : 
     625              : /* Generate code to copy SRC to DST.  */
     626              : 
     627              : tree
     628            0 : lhd_omp_assignment (tree clause ATTRIBUTE_UNUSED, tree dst, tree src)
     629              : {
     630            0 :   return build2 (MODIFY_EXPR, TREE_TYPE (dst), dst, src);
     631              : }
     632              : 
     633              : /* Finalize clause C.  */
     634              : 
     635              : void
     636        49765 : lhd_omp_finish_clause (tree, gimple_seq *, bool)
     637              : {
     638        49765 : }
     639              : 
     640              : /* Return array size; cf. omp_array_data.  */
     641              : 
     642              : tree
     643            0 : lhd_omp_array_size (tree, gimple_seq *)
     644              : {
     645            0 :   return NULL_TREE;
     646              : }
     647              : 
     648              : /* Return false, implying that no additional data-mapping operations
     649              :    are required for the tree containing a map clause.  */
     650              : 
     651              : bool
     652        37348 : lhd_omp_deep_mapping_p (const gimple *, tree)
     653              : {
     654        37348 :   return false;
     655              : }
     656              : 
     657              : /* Return NULL_TREE, implying that no additional data-mapping operations
     658              :    are required for the tree containing a map clause.  */
     659              : 
     660              : tree
     661        41592 : lhd_omp_deep_mapping_cnt (const gimple *, tree, gimple_seq *)
     662              : {
     663        41592 :   return NULL_TREE;
     664              : }
     665              : 
     666              : /* Do nothing as no additional data-mapping operations
     667              :    are required for the second argument that contains a map clause.  */
     668              : 
     669              : void
     670            0 : lhd_omp_deep_mapping (const gimple *, tree, unsigned HOST_WIDE_INT, tree, tree,
     671              :                       tree, tree, tree, gimple_seq *)
     672              : {
     673            0 : }
     674              : 
     675              : /* Look up an OpenMP "declare mapper" mapper.  */
     676              : 
     677              : tree
     678            0 : lhd_omp_mapper_lookup (tree, tree)
     679              : {
     680            0 :   return NULL_TREE;
     681              : }
     682              : 
     683              : /* Given the representation used by the front-end to contain a mapper
     684              :    directive, return the statement for the directive itself.  */
     685              : 
     686              : tree
     687            0 : lhd_omp_extract_mapper_directive (tree)
     688              : {
     689            0 :   return error_mark_node;
     690              : }
     691              : 
     692              : /* Return a simplified form for OMP_ARRAY_SECTION argument, or
     693              :    error_mark_node if impossible.  */
     694              : 
     695              : tree
     696            0 : lhd_omp_map_array_section (location_t, tree)
     697              : {
     698            0 :   return error_mark_node;
     699              : }
     700              : 
     701              : /* Return true if DECL is a scalar variable (for the purpose of
     702              :    implicit firstprivatization & mapping). Only if alloc_ptr_ok
     703              :    are allocatables and pointers accepted. */
     704              : 
     705              : bool
     706        23174 : lhd_omp_scalar_p (tree decl, bool ptr_ok)
     707              : {
     708        23174 :   tree type = TREE_TYPE (decl);
     709        23174 :   if (TREE_CODE (type) == REFERENCE_TYPE)
     710         3785 :     type = TREE_TYPE (type);
     711        23174 :   if (TREE_CODE (type) == COMPLEX_TYPE)
     712           39 :     type = TREE_TYPE (type);
     713        23174 :   if (INTEGRAL_TYPE_P (type)
     714        23174 :       || SCALAR_FLOAT_TYPE_P (type)
     715        10156 :       || (ptr_ok && TREE_CODE (type) == POINTER_TYPE))
     716        13038 :     return true;
     717              :   return false;
     718              : }
     719              : 
     720              : /* Return static initializer for DECL.  */
     721              : 
     722              : tree *
     723         4581 : lhd_omp_get_decl_init (tree decl)
     724              : {
     725         4581 :   return &DECL_INITIAL (decl);
     726              : }
     727              : 
     728              : /* Free any extra memory used to hold initializer information for
     729              :    variable declarations.  */
     730              : 
     731              : void
     732         5559 : lhd_omp_finish_decl_inits (void)
     733              : {
     734         5559 : }
     735              : 
     736              : /* Register language specific type size variables as potentially OpenMP
     737              :    firstprivate variables.  */
     738              : 
     739              : void
     740         8949 : lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *c ATTRIBUTE_UNUSED,
     741              :                                    tree t ATTRIBUTE_UNUSED)
     742              : {
     743         8949 : }
     744              : 
     745              : /* Common function for add_builtin_function, add_builtin_function_ext_scope
     746              :    and simulate_builtin_function_decl.  */
     747              : 
     748              : static tree
     749    875499345 : build_builtin_function (location_t location, const char *name, tree type,
     750              :                         int function_code, enum built_in_class cl,
     751              :                         const char *library_name, tree attrs)
     752              : {
     753    875499345 :   tree   id = get_identifier (name);
     754    875499345 :   tree decl = build_decl (location, FUNCTION_DECL, id, type);
     755              : 
     756    875499345 :   TREE_PUBLIC (decl)         = 1;
     757    875499345 :   DECL_EXTERNAL (decl)       = 1;
     758              : 
     759    875499345 :   set_decl_built_in_function (decl, cl, function_code);
     760              : 
     761    875499345 :   if (library_name)
     762              :     {
     763    275799787 :       tree libname = get_identifier (library_name);
     764              : 
     765    275799787 :       libname = targetm.mangle_decl_assembler_name (decl, libname);
     766    275799787 :       SET_DECL_ASSEMBLER_NAME (decl, libname);
     767              :     }
     768              : 
     769              :   /* Possibly apply some default attributes to this built-in function.  */
     770    875499345 :   if (attrs)
     771    497823946 :     decl_attributes (&decl, attrs, ATTR_FLAG_BUILT_IN);
     772              :   else
     773    377675399 :     decl_attributes (&decl, NULL_TREE, 0);
     774              : 
     775    875499345 :   return decl;
     776              : }
     777              : 
     778              : /* Create a builtin function.  */
     779              : 
     780              : tree
     781    863685669 : add_builtin_function (const char *name,
     782              :                       tree type,
     783              :                       int function_code,
     784              :                       enum built_in_class cl,
     785              :                       const char *library_name,
     786              :                       tree attrs)
     787              : {
     788    863685669 :   tree decl = build_builtin_function (BUILTINS_LOCATION, name, type,
     789              :                                       function_code, cl, library_name, attrs);
     790    863685669 :   return lang_hooks.builtin_function (decl);
     791              : }
     792              : 
     793              : /* Like add_builtin_function, but make sure the scope is the external scope.
     794              :    This is used to delay putting in back end builtin functions until the ISA
     795              :    that defines the builtin is declared via function specific target options,
     796              :    which can save memory for machines like the x86_64 that have multiple ISAs.
     797              :    If this points to the same function as builtin_function, the backend must
     798              :    add all of the builtins at program initialization time.  */
     799              : 
     800              : tree
     801     11813676 : add_builtin_function_ext_scope (const char *name,
     802              :                                 tree type,
     803              :                                 int function_code,
     804              :                                 enum built_in_class cl,
     805              :                                 const char *library_name,
     806              :                                 tree attrs)
     807              : {
     808     11813676 :   tree decl = build_builtin_function (BUILTINS_LOCATION, name, type,
     809              :                                       function_code, cl, library_name, attrs);
     810     11813676 :   return lang_hooks.builtin_function_ext_scope (decl);
     811              : }
     812              : 
     813              : /* Simulate a declaration of a target-specific built-in function at
     814              :    location LOCATION, as though it had been declared directly in the
     815              :    source language.  NAME is the name of the function, TYPE is its function
     816              :    type, FUNCTION_CODE is the target-specific function code, LIBRARY_NAME
     817              :    is the name of the underlying library function (NULL if none) and
     818              :    ATTRS is a list of function attributes.
     819              : 
     820              :    Return the decl of the declared function.  */
     821              : 
     822              : tree
     823            0 : simulate_builtin_function_decl (location_t location, const char *name,
     824              :                                 tree type, int function_code,
     825              :                                 const char *library_name, tree attrs)
     826              : {
     827            0 :   tree decl = build_builtin_function (location, name, type,
     828              :                                       function_code, BUILT_IN_MD,
     829              :                                       library_name, attrs);
     830            0 :   tree new_decl = lang_hooks.simulate_builtin_function_decl (decl);
     831              : 
     832              :   /* Give the front end a chance to create a new decl if necessary,
     833              :      but if the front end discards the decl in favour of a conflicting
     834              :      (erroneous) previous definition, return the decl that we tried but
     835              :      failed to add.  This allows the caller to process the returned decl
     836              :      normally, even though the source code won't be able to use it.  */
     837            0 :   if (TREE_CODE (new_decl) == FUNCTION_DECL
     838            0 :       && fndecl_built_in_p (new_decl, function_code, BUILT_IN_MD))
     839            0 :     return new_decl;
     840              : 
     841              :   return decl;
     842              : }
     843              : 
     844              : tree
     845            0 : lhd_builtin_function (tree decl)
     846              : {
     847            0 :   lang_hooks.decls.pushdecl (decl);
     848            0 :   return decl;
     849              : }
     850              : 
     851              : /* Create a builtin type.  */
     852              : 
     853              : tree
     854            0 : add_builtin_type (const char *name, tree type)
     855              : {
     856            0 :   tree   id = get_identifier (name);
     857            0 :   tree decl = build_decl (BUILTINS_LOCATION, TYPE_DECL, id, type);
     858            0 :   return lang_hooks.decls.pushdecl (decl);
     859              : }
     860              : 
     861              : /* LTO hooks.  */
     862              : 
     863              : /* Used to save and restore any previously active section.  */
     864              : static section *saved_section;
     865              : 
     866              : 
     867              : /* Begin a new LTO output section named NAME.  This default implementation
     868              :    saves the old section and emits assembly code to switch to the new
     869              :    section.  */
     870              : 
     871              : void
     872       454729 : lhd_begin_section (const char *name)
     873              : {
     874       454729 :   section *section;
     875              : 
     876              :   /* Save the old section so we can restore it in lto_end_asm_section.  */
     877       454729 :   gcc_assert (!saved_section);
     878       454729 :   saved_section = in_section;
     879       454729 :   if (!saved_section)
     880        22086 :     saved_section = text_section;
     881              : 
     882              :   /* Create a new section and switch to it.  */
     883       454729 :   section = get_section (name, SECTION_DEBUG | SECTION_EXCLUDE, NULL, true);
     884       454729 :   switch_to_section (section);
     885       454729 : }
     886              : 
     887              : 
     888              : /* Write DATA of length LEN to the current LTO output section.  This default
     889              :    implementation just calls assemble_string.  */
     890              : 
     891              : void
     892      4789234 : lhd_append_data (const void *data, size_t len, void *)
     893              : {
     894      4789234 :   if (data)
     895              :     {
     896      4789234 :       timevar_push (TV_IPA_LTO_OUTPUT);
     897      4789234 :       assemble_string ((const char *)data, len);
     898      4789234 :       timevar_pop (TV_IPA_LTO_OUTPUT);
     899              :     }
     900      4789234 : }
     901              : 
     902              : 
     903              : /* Finish the current LTO output section.  This default implementation emits
     904              :    assembly code to switch to any section previously saved by
     905              :    lhd_begin_section.  */
     906              : 
     907              : void
     908       454729 : lhd_end_section (void)
     909              : {
     910       454729 :   if (saved_section)
     911              :     {
     912       454729 :       switch_to_section (saved_section);
     913       454729 :       saved_section = NULL;
     914              :     }
     915       454729 : }
     916              : 
     917              : /* Default implementation of enum_underlying_base_type using type_for_size.  */
     918              : 
     919              : tree
     920         1243 : lhd_enum_underlying_base_type (const_tree enum_type)
     921              : {
     922         1243 :   return lang_hooks.types.type_for_size (TYPE_PRECISION (enum_type),
     923         1243 :                                          TYPE_UNSIGNED (enum_type));
     924              : }
     925              : 
     926              : /* Default implementation of LANG_HOOKS_GET_SUBSTRING_LOCATION.  */
     927              : 
     928              : const char *
     929          544 : lhd_get_substring_location (const substring_loc &, location_t *)
     930              : {
     931          544 :   return "unimplemented";
     932              : }
     933              : 
     934              : /* Default implementation of LANG_HOOKS_DECL_DWARF_ATTRIBUTE.  Don't add
     935              :    any attributes.  */
     936              : 
     937              : int
     938      6129195 : lhd_decl_dwarf_attribute (const_tree, int)
     939              : {
     940      6129195 :   return -1;
     941              : }
     942              : 
     943              : /* Default implementation of LANG_HOOKS_TYPE_DWARF_ATTRIBUTE.  Don't add
     944              :    any attributes.  */
     945              : 
     946              : int
     947       114332 : lhd_type_dwarf_attribute (const_tree, int)
     948              : {
     949       114332 :   return -1;
     950              : }
     951              : 
     952              : /* Default implementation of LANG_HOOKS_UNIT_SIZE_WITHOUT_REUSABLE_PADDING.
     953              :    Just return TYPE_SIZE_UNIT unadjusted.  */
     954              : 
     955              : tree
     956         7744 : lhd_unit_size_without_reusable_padding (tree t)
     957              : {
     958         7744 :   return TYPE_SIZE_UNIT (t);
     959              : }
     960              : 
     961              : /* Default implementation for the finalize_early_debug hook.  */
     962              : 
     963              : void
     964        53992 : lhd_finalize_early_debug (void)
     965              : {
     966              :   /* Emit early debug for reachable functions, and by consequence,
     967              :      locally scoped symbols.  */
     968        53992 :   struct cgraph_node *cnode;
     969       589442 :   FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (cnode)
     970       535450 :     (*debug_hooks->early_global_decl) (cnode->decl);
     971        53992 : }
     972              : 
     973              : /* Default implementation of LANG_HOOKS_GET_SARIF_SOURCE_LANGUAGE.  */
     974              : 
     975              : const char *
     976            0 : lhd_get_sarif_source_language (const char *)
     977              : {
     978            0 :   return NULL;
     979              : }
     980              : 
     981              : /* Returns true if the current lang_hooks represents the GNU C frontend.  */
     982              : 
     983              : bool
     984       539710 : lang_GNU_C (void)
     985              : {
     986       539710 :   return (startswith (lang_hooks.name, "GNU C")
     987       539710 :           && (lang_hooks.name[5] == '\0' || ISDIGIT (lang_hooks.name[5])));
     988              : }
     989              : 
     990              : /* Returns true if the current lang_hooks represents the GNU C++ frontend.  */
     991              : 
     992              : bool
     993        19236 : lang_GNU_CXX (void)
     994              : {
     995        19236 :   return startswith (lang_hooks.name, "GNU C++");
     996              : }
     997              : 
     998              : /* Returns true if the current lang_hooks represents the GNU Fortran frontend.  */
     999              : 
    1000              : bool
    1001       217711 : lang_GNU_Fortran (void)
    1002              : {
    1003       217711 :   return startswith (lang_hooks.name, "GNU Fortran");
    1004              : }
    1005              : 
    1006              : /* Returns true if the current lang_hooks represents the GNU Objective-C
    1007              :    frontend.  */
    1008              : 
    1009              : bool
    1010       127864 : lang_GNU_OBJC (void)
    1011              : {
    1012       127864 :   return startswith (lang_hooks.name, "GNU Objective-C");
    1013              : }
        

Generated by: LCOV version 2.5.0-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.