LCOV - code coverage report
Current view: top level - gcc - value-query.h (source / functions) Coverage Total Hit
Test: gcc.info Lines: 100.0 % 5 5
Test Date: 2024-03-23 14:05:01 Functions: - 0 0
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* Support routines for value queries.
       2                 :             :    Copyright (C) 2020-2024 Free Software Foundation, Inc.
       3                 :             :    Contributed by Aldy Hernandez <aldyh@redhat.com> and
       4                 :             :    Andrew Macleod <amacleod@redhat.com>.
       5                 :             : 
       6                 :             : This file is part of GCC.
       7                 :             : 
       8                 :             : GCC is free software; you can redistribute it and/or modify
       9                 :             : it under the terms of the GNU General Public License as published by
      10                 :             : the Free Software Foundation; either version 3, or (at your option)
      11                 :             : any later version.
      12                 :             : 
      13                 :             : GCC is distributed in the hope that it will be useful,
      14                 :             : but WITHOUT ANY WARRANTY; without even the implied warranty of
      15                 :             : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16                 :             : GNU General Public License for more details.
      17                 :             : 
      18                 :             : You should have received a copy of the GNU General Public License
      19                 :             : along with GCC; see the file COPYING3.  If not see
      20                 :             : <http://www.gnu.org/licenses/>.  */
      21                 :             : 
      22                 :             : #ifndef GCC_QUERY_H
      23                 :             : #define GCC_QUERY_H
      24                 :             : 
      25                 :             : #include "value-relation.h"
      26                 :             : 
      27                 :             : // The value_query class is used by optimization passes that require
      28                 :             : // valueizing SSA names in terms of a tree value, but have no need
      29                 :             : // for ranges.
      30                 :             : //
      31                 :             : // value_of_expr must be provided.  The default for value_on_edge and
      32                 :             : // value_of_stmt is to call value_of_expr.
      33                 :             : //
      34                 :             : // This implies the valuation is global in nature.  If a pass can make
      35                 :             : // use of more specific information, it can override the other queries.
      36                 :             : //
      37                 :             : // Proper usage of the correct query in passes will enable other
      38                 :             : // valuation mechanisms to produce more precise results.
      39                 :             : 
      40                 :             : // The range_query class is used by optimization passes which are
      41                 :             : // range aware.
      42                 :             : //
      43                 :             : // range_of_expr must be provided.  The default for range_on_edge and
      44                 :             : // range_of_stmt is to call range_of_expr.  If a pass can make use of
      45                 :             : // more specific information, then it can override the other queries.
      46                 :             : //
      47                 :             : // The default for the value_* routines is to call the equivalent
      48                 :             : // range_* routines, check if the range is a singleton, and return it
      49                 :             : // if so.
      50                 :             : //
      51                 :             : // The get_value_range method is currently provided for compatibility
      52                 :             : // with vr-values.  It will be deprecated when possible.
      53                 :             : 
      54                 :             : class range_query
      55                 :             : {
      56                 :             : public:
      57                 :             :   range_query ();
      58                 :             :   virtual ~range_query ();
      59                 :             : 
      60                 :             :   virtual tree value_of_expr (tree expr, gimple * = NULL);
      61                 :             :   virtual tree value_on_edge (edge, tree expr);
      62                 :             :   virtual tree value_of_stmt (gimple *, tree name = NULL);
      63                 :             : 
      64                 :             :   // These are the range equivalents of the value_* methods.  Instead
      65                 :             :   // of returning a singleton, they calculate a range and return it in
      66                 :             :   // R.  TRUE is returned on success or FALSE if no range was found.
      67                 :             :   //
      68                 :             :   // Note that range_of_expr must always return TRUE unless ranges are
      69                 :             :   // unsupported for EXPR's type (supports_type_p is false).
      70                 :             :   virtual bool range_of_expr (vrange &r, tree expr, gimple * = NULL) = 0;
      71                 :             :   virtual bool range_on_edge (vrange &r, edge, tree expr);
      72                 :             :   virtual bool range_of_stmt (vrange &r, gimple *, tree name = NULL);
      73                 :             : 
      74                 :             :   // Query if there is any relation between SSA1 and SSA2.
      75                 :             :   relation_kind query_relation (gimple *s, tree ssa1, tree ssa2,
      76                 :             :                                 bool get_range = true);
      77                 :             :   relation_kind query_relation (edge e, tree ssa1, tree ssa2,
      78                 :             :                                 bool get_range = true);
      79                 :             :   // If present, Access relation oracle for more advanced uses.
      80                 :   210467618 :   inline relation_oracle *oracle () const  { return m_oracle; }
      81                 :             : 
      82                 :             :   virtual void dump (FILE *);
      83                 :             : 
      84                 :             : protected:
      85                 :             :   bool get_tree_range (vrange &v, tree expr, gimple *stmt);
      86                 :             :   bool get_arith_expr_range (vrange &r, tree expr, gimple *stmt);
      87                 :             :   relation_oracle *m_oracle;
      88                 :             : };
      89                 :             : 
      90                 :             : // Global ranges for SSA names using SSA_NAME_RANGE_INFO.
      91                 :             : 
      92                 :             : class global_range_query : public range_query
      93                 :             : {
      94                 :             : public:
      95                 :             :   bool range_of_expr (vrange &r, tree expr, gimple * = NULL) override;
      96                 :             : };
      97                 :             : 
      98                 :             : extern global_range_query global_ranges;
      99                 :             : 
     100                 :             : inline range_query *
     101                 :    90094155 : get_global_range_query ()
     102                 :             : {
     103                 :    90094155 :   return &global_ranges;
     104                 :             : }
     105                 :             : 
     106                 :             : /* Returns the currently active range access class.  When there is no active
     107                 :             :    range class, global ranges are used.  Never returns null.  */
     108                 :             : 
     109                 :             : ATTRIBUTE_RETURNS_NONNULL inline range_query *
     110                 :   278968734 : get_range_query (const struct function *fun)
     111                 :             : {
     112                 :   278968734 :   return (fun && fun->x_range_query) ? fun->x_range_query : &global_ranges;
     113                 :             : }
     114                 :             : 
     115                 :             : // Query the global range of NAME in function F.  Default to cfun.
     116                 :             : extern void gimple_range_global (vrange &v, tree name,
     117                 :             :                                  struct function *f = cfun);
     118                 :             : 
     119                 :             : #endif // GCC_QUERY_H
        

Generated by: LCOV version 2.0-1

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