LCOV - code coverage report
Current view: top level - gcc - lists.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 88.5 % 96 85
Test Date: 2024-04-20 14:03:02 Functions: 80.0 % 15 12
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* List management for the GCC expander.
       2                 :             :    Copyright (C) 1987-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 "tm.h"
      24                 :             : #include "rtl.h"
      25                 :             : 
      26                 :             : static void free_list (rtx *, rtx *);
      27                 :             : 
      28                 :             : /* Functions for maintaining cache-able lists of EXPR_LIST and INSN_LISTs.  */
      29                 :             : 
      30                 :             : /* An INSN_LIST containing all INSN_LISTs allocated but currently unused.  */
      31                 :             : static GTY ((deletable)) rtx unused_insn_list;
      32                 :             : 
      33                 :             : /* An EXPR_LIST containing all EXPR_LISTs allocated but currently unused.  */
      34                 :             : static GTY ((deletable)) rtx unused_expr_list;
      35                 :             : 
      36                 :             : /* This function will free an entire list of either EXPR_LIST, INSN_LIST
      37                 :             :    or DEPS_LIST nodes.  This is to be used only on lists that consist
      38                 :             :    exclusively of nodes of one type only.  This is only called by
      39                 :             :    free_EXPR_LIST_list, free_INSN_LIST_list and free_DEPS_LIST_list.  */
      40                 :             : static void
      41                 :   788852637 : free_list (rtx *listp, rtx *unused_listp)
      42                 :             : {
      43                 :   788852637 :   rtx link, prev_link;
      44                 :             : 
      45                 :   788852637 :   prev_link = *listp;
      46                 :   788852637 :   link = XEXP (prev_link, 1);
      47                 :             : 
      48                 :   788852637 :   gcc_assert (unused_listp != &unused_insn_list
      49                 :             :               || GET_CODE (prev_link) == INSN_LIST);
      50                 :             : 
      51                 :   968207395 :   while (link)
      52                 :             :     {
      53                 :   179354758 :       gcc_assert (unused_listp != &unused_insn_list
      54                 :             :                   || GET_CODE (prev_link) == INSN_LIST);
      55                 :             : 
      56                 :   179354758 :       prev_link = link;
      57                 :   179354758 :       link = XEXP (link, 1);
      58                 :             :     }
      59                 :             : 
      60                 :   788852637 :   XEXP (prev_link, 1) = *unused_listp;
      61                 :   788852637 :   *unused_listp = *listp;
      62                 :   788852637 :   *listp = 0;
      63                 :   788852637 : }
      64                 :             : 
      65                 :             : /* Find corresponding to ELEM node in the list pointed to by LISTP.
      66                 :             :    This node must exist in the list.  Returns pointer to that node.  */
      67                 :             : static rtx *
      68                 :      117915 : find_list_elem (rtx elem, rtx *listp)
      69                 :             : {
      70                 :      174257 :   while (XEXP (*listp, 0) != elem)
      71                 :       56342 :     listp = &XEXP (*listp, 1);
      72                 :      117915 :   return listp;
      73                 :             : }
      74                 :             : 
      75                 :             : /* Remove the node pointed to by LISTP from the list.  */
      76                 :             : static void
      77                 :      134121 : remove_list_node (rtx *listp)
      78                 :             : {
      79                 :      134121 :   rtx node;
      80                 :             : 
      81                 :      134121 :   node = *listp;
      82                 :      134121 :   *listp = XEXP (node, 1);
      83                 :      134121 :   XEXP (node, 1) = 0;
      84                 :           0 : }
      85                 :             : 
      86                 :             : /* Removes corresponding to ELEM node from the list pointed to by LISTP.
      87                 :             :    Returns that node.  */
      88                 :             : rtx
      89                 :      117915 : remove_list_elem (rtx elem, rtx *listp)
      90                 :             : {
      91                 :      117915 :   rtx node;
      92                 :             : 
      93                 :      117915 :   listp = find_list_elem (elem, listp);
      94                 :      117915 :   node = *listp;
      95                 :      117915 :   remove_list_node (listp);
      96                 :      117915 :   return node;
      97                 :             : }
      98                 :             : 
      99                 :             : /* This call is used in place of a gen_rtx_INSN_LIST. If there is a cached
     100                 :             :    node available, we'll use it, otherwise a call to gen_rtx_INSN_LIST
     101                 :             :    is made.  */
     102                 :             : rtx_insn_list *
     103                 :   950126375 : alloc_INSN_LIST (rtx val, rtx next)
     104                 :             : {
     105                 :   950126375 :   rtx_insn_list *r;
     106                 :             : 
     107                 :   950126375 :   if (unused_insn_list)
     108                 :             :     {
     109                 :   901331065 :       r = as_a <rtx_insn_list *> (unused_insn_list);
     110                 :   901331065 :       unused_insn_list = r->next ();
     111                 :   901331065 :       XEXP (r, 0) = val;
     112                 :   901331065 :       XEXP (r, 1) = next;
     113                 :   901331065 :       PUT_REG_NOTE_KIND (r, VOIDmode);
     114                 :             : 
     115                 :   901331065 :       gcc_assert (GET_CODE (r) == INSN_LIST);
     116                 :             :     }
     117                 :             :   else
     118                 :    48795310 :     r = gen_rtx_INSN_LIST (VOIDmode, val, next);
     119                 :             : 
     120                 :   950126375 :   return r;
     121                 :             : }
     122                 :             : 
     123                 :             : /* This call is used in place of a gen_rtx_EXPR_LIST. If there is a cached
     124                 :             :    node available, we'll use it, otherwise a call to gen_rtx_EXPR_LIST
     125                 :             :    is made.  */
     126                 :             : rtx_expr_list *
     127                 :   753992545 : alloc_EXPR_LIST (int kind, rtx val, rtx next)
     128                 :             : {
     129                 :   753992545 :   rtx_expr_list *r;
     130                 :             : 
     131                 :   753992545 :   if (unused_expr_list)
     132                 :             :     {
     133                 :   581350343 :       r = as_a <rtx_expr_list *> (unused_expr_list);
     134                 :   581350343 :       unused_expr_list = XEXP (r, 1);
     135                 :   581350343 :       XEXP (r, 0) = val;
     136                 :   581350343 :       XEXP (r, 1) = next;
     137                 :   581350343 :       PUT_REG_NOTE_KIND (r, kind);
     138                 :             :     }
     139                 :             :   else
     140                 :   172642202 :     r = gen_rtx_EXPR_LIST ((machine_mode) kind, val, next);
     141                 :             : 
     142                 :   753992545 :   return r;
     143                 :             : }
     144                 :             : 
     145                 :             : /* This function will free up an entire list of EXPR_LIST nodes.  */
     146                 :             : void
     147                 :    55775235 : free_EXPR_LIST_list (rtx_expr_list **listp)
     148                 :             : {
     149                 :    55775235 :   if (*listp == 0)
     150                 :             :     return;
     151                 :    13361567 :   free_list ((rtx *)listp, &unused_expr_list);
     152                 :             : }
     153                 :             : 
     154                 :             : /* This function will free up an entire list of INSN_LIST nodes.  */
     155                 :             : void
     156                 :  1745090883 : free_INSN_LIST_list (rtx_insn_list **listp)
     157                 :             : {
     158                 :  1745090883 :   if (*listp == 0)
     159                 :             :     return;
     160                 :   775491070 :   free_list ((rtx *)listp, &unused_insn_list);
     161                 :             : }
     162                 :             : 
     163                 :             : /* Make a copy of the INSN_LIST list LINK and return it.  */
     164                 :             : rtx_insn_list *
     165                 :           0 : copy_INSN_LIST (rtx_insn_list *link)
     166                 :             : {
     167                 :           0 :   rtx_insn_list *new_queue;
     168                 :           0 :   rtx_insn_list **pqueue = &new_queue;
     169                 :             : 
     170                 :           0 :   for (; link; link = link->next ())
     171                 :             :     {
     172                 :           0 :       rtx_insn *x = link->insn ();
     173                 :           0 :       rtx_insn_list *newlink = alloc_INSN_LIST (x, NULL);
     174                 :           0 :       *pqueue = newlink;
     175                 :           0 :       pqueue = (rtx_insn_list **)&XEXP (newlink, 1);
     176                 :             :     }
     177                 :           0 :   *pqueue = NULL;
     178                 :           0 :   return new_queue;
     179                 :             : }
     180                 :             : 
     181                 :             : /* Duplicate the INSN_LIST elements of COPY and prepend them to OLD.  */
     182                 :             : rtx_insn_list *
     183                 :       99390 : concat_INSN_LIST (rtx_insn_list *copy, rtx_insn_list *old)
     184                 :             : {
     185                 :       99390 :   rtx_insn_list *new_rtx = old;
     186                 :      148181 :   for (; copy ; copy = copy->next ())
     187                 :             :     {
     188                 :       48791 :       new_rtx = alloc_INSN_LIST (copy->insn (), new_rtx);
     189                 :       48791 :       PUT_REG_NOTE_KIND (new_rtx, REG_NOTE_KIND (copy));
     190                 :             :     }
     191                 :       99390 :   return new_rtx;
     192                 :             : }
     193                 :             : 
     194                 :             : /* This function will free up an individual EXPR_LIST node.  */
     195                 :             : void
     196                 :   545787089 : free_EXPR_LIST_node (rtx ptr)
     197                 :             : {
     198                 :   545787089 :   XEXP (ptr, 1) = unused_expr_list;
     199                 :   545787089 :   unused_expr_list = ptr;
     200                 :   545787089 : }
     201                 :             : 
     202                 :             : /* This function will free up an individual INSN_LIST node.  */
     203                 :             : void
     204                 :      133364 : free_INSN_LIST_node (rtx ptr)
     205                 :             : {
     206                 :      133364 :   gcc_assert (GET_CODE (ptr) == INSN_LIST);
     207                 :      133364 :   XEXP (ptr, 1) = unused_insn_list;
     208                 :      133364 :   unused_insn_list = ptr;
     209                 :      133364 : }
     210                 :             : 
     211                 :             : /* Remove and free corresponding to ELEM node in the INSN_LIST pointed to
     212                 :             :    by LISTP.  */
     213                 :             : void
     214                 :      117915 : remove_free_INSN_LIST_elem (rtx_insn *elem, rtx_insn_list **listp)
     215                 :             : {
     216                 :      117915 :   free_INSN_LIST_node (remove_list_elem (elem, (rtx *)listp));
     217                 :      117915 : }
     218                 :             : 
     219                 :             : /* Remove and free the first node in the INSN_LIST pointed to by LISTP.  */
     220                 :             : rtx_insn *
     221                 :       15444 : remove_free_INSN_LIST_node (rtx_insn_list **listp)
     222                 :             : {
     223                 :       15444 :   rtx_insn_list *node = *listp;
     224                 :       15444 :   rtx_insn *elem = node->insn ();
     225                 :             : 
     226                 :       15444 :   remove_list_node ((rtx *)listp);
     227                 :       15444 :   free_INSN_LIST_node (node);
     228                 :             : 
     229                 :       15444 :   return elem;
     230                 :             : }
     231                 :             : 
     232                 :             : /* Remove and free the first node in the EXPR_LIST pointed to by LISTP.  */
     233                 :             : rtx
     234                 :         762 : remove_free_EXPR_LIST_node (rtx_expr_list **listp)
     235                 :             : {
     236                 :         762 :   rtx_expr_list *node = *listp;
     237                 :         762 :   rtx elem = XEXP (node, 0);
     238                 :             : 
     239                 :         762 :   remove_list_node ((rtx *)listp);
     240                 :         762 :   free_EXPR_LIST_node (node);
     241                 :             : 
     242                 :         762 :   return elem;
     243                 :             : }
     244                 :             : 
     245                 :             : #include "gt-lists.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.