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

             Branch data     Line data    Source code
       1                 :             : /* Gimple prediction routines.
       2                 :             : 
       3                 :             :    Copyright (C) 2007-2024 Free Software Foundation, Inc.
       4                 :             : 
       5                 :             : This file is part of GCC.
       6                 :             : 
       7                 :             : GCC is free software; you can redistribute it and/or modify it under
       8                 :             : the terms of the GNU General Public License as published by the Free
       9                 :             : Software Foundation; either version 3, or (at your option) any later
      10                 :             : version.
      11                 :             : 
      12                 :             : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      13                 :             : WARRANTY; without even the implied warranty of MERCHANTABILITY or
      14                 :             : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      15                 :             : 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                 :             : #ifndef GCC_GIMPLE_PREDICT_H
      22                 :             : #define GCC_GIMPLE_PREDICT_H
      23                 :             : 
      24                 :             : #include "predict.h"
      25                 :             : 
      26                 :             : /* Return the predictor of GIMPLE_PREDICT statement GS.  */
      27                 :             : 
      28                 :             : inline enum br_predictor
      29                 :      782249 : gimple_predict_predictor (const gimple *gs)
      30                 :             : {
      31                 :      782249 :   GIMPLE_CHECK (gs, GIMPLE_PREDICT);
      32                 :      782249 :   return (enum br_predictor) (gs->subcode & ~GF_PREDICT_TAKEN);
      33                 :             : }
      34                 :             : 
      35                 :             : 
      36                 :             : /* Set the predictor of GIMPLE_PREDICT statement GS to PREDICT.  */
      37                 :             : 
      38                 :             : inline void
      39                 :      522277 : gimple_predict_set_predictor (gimple *gs, enum br_predictor predictor)
      40                 :             : {
      41                 :      522277 :   GIMPLE_CHECK (gs, GIMPLE_PREDICT);
      42                 :      522277 :   gs->subcode = (gs->subcode & GF_PREDICT_TAKEN)
      43                 :      522277 :                        | (unsigned) predictor;
      44                 :      522277 : }
      45                 :             : 
      46                 :             : 
      47                 :             : /* Return the outcome of GIMPLE_PREDICT statement GS.  */
      48                 :             : 
      49                 :             : inline enum prediction
      50                 :      436578 : gimple_predict_outcome (const gimple *gs)
      51                 :             : {
      52                 :      436578 :   GIMPLE_CHECK (gs, GIMPLE_PREDICT);
      53                 :      436578 :   return (gs->subcode & GF_PREDICT_TAKEN) ? TAKEN : NOT_TAKEN;
      54                 :             : }
      55                 :             : 
      56                 :             : 
      57                 :             : /* Set the outcome of GIMPLE_PREDICT statement GS to OUTCOME.  */
      58                 :             : 
      59                 :             : inline void
      60                 :      522277 : gimple_predict_set_outcome (gimple *gs, enum prediction outcome)
      61                 :             : {
      62                 :      522277 :   GIMPLE_CHECK (gs, GIMPLE_PREDICT);
      63                 :      522277 :   if (outcome == TAKEN)
      64                 :        1734 :     gs->subcode |= GF_PREDICT_TAKEN;
      65                 :             :   else
      66                 :      520543 :     gs->subcode &= ~GF_PREDICT_TAKEN;
      67                 :      522277 : }
      68                 :             : 
      69                 :             : /* Build a GIMPLE_PREDICT statement.  PREDICT is one of the predictors from
      70                 :             :    predict.def, OUTCOME is NOT_TAKEN or TAKEN.  */
      71                 :             : 
      72                 :             : inline gimple *
      73                 :      522277 : gimple_build_predict (enum br_predictor predictor, enum prediction outcome)
      74                 :             : {
      75                 :      522277 :   gimple *p = gimple_alloc (GIMPLE_PREDICT, 0);
      76                 :             :   /* Ensure all the predictors fit into the lower bits of the subcode.  */
      77                 :      522277 :   gcc_assert ((int) END_PREDICTORS <= GF_PREDICT_TAKEN);
      78                 :      522277 :   gimple_predict_set_predictor (p, predictor);
      79                 :      522277 :   gimple_predict_set_outcome (p, outcome);
      80                 :      522277 :   return p;
      81                 :             : }
      82                 :             : 
      83                 :             : /* Return true if GS is a GIMPLE_PREDICT statement.  */
      84                 :             : 
      85                 :             : inline bool
      86                 :             : is_gimple_predict (const gimple *gs)
      87                 :             : {
      88                 :             :   return gimple_code (gs) == GIMPLE_PREDICT;
      89                 :             : }
      90                 :             : 
      91                 :             : #endif  /* GCC_GIMPLE_PREDICT_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.