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

             Branch data     Line data    Source code
       1                 :             : /* Operation with 128 bit bitmask.
       2                 :             :    Copyright (C) 2013-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                 :             : #ifndef GCC_WIDE_INT_BITMASK_H
      21                 :             : #define GCC_WIDE_INT_BITMASK_H
      22                 :             : 
      23                 :             : class wide_int_bitmask
      24                 :             : {
      25                 :             : public:
      26                 :             :   constexpr wide_int_bitmask ();
      27                 :             :   constexpr wide_int_bitmask (uint64_t l);
      28                 :             :   constexpr wide_int_bitmask (uint64_t l, uint64_t h);
      29                 :             :   inline wide_int_bitmask &operator &= (wide_int_bitmask);
      30                 :             :   inline wide_int_bitmask &operator |= (wide_int_bitmask);
      31                 :             :   constexpr wide_int_bitmask operator ~ () const;
      32                 :             :   constexpr wide_int_bitmask operator & (wide_int_bitmask) const;
      33                 :             :   constexpr wide_int_bitmask operator | (wide_int_bitmask) const;
      34                 :             :   inline wide_int_bitmask operator >> (int);
      35                 :             :   inline wide_int_bitmask operator << (int);
      36                 :             :   inline bool operator == (wide_int_bitmask) const;
      37                 :             :   inline bool operator != (wide_int_bitmask) const;
      38                 :             :   uint64_t low, high;
      39                 :             : };
      40                 :             : 
      41                 :             : constexpr
      42                 :             : wide_int_bitmask::wide_int_bitmask ()
      43                 :             : : low (0), high (0)
      44                 :             : {
      45                 :             : }
      46                 :             : 
      47                 :             : constexpr
      48                 :   232408401 : wide_int_bitmask::wide_int_bitmask (uint64_t l)
      49                 :         958 : : low (l), high (0)
      50                 :             : {
      51                 :             : }
      52                 :             : 
      53                 :             : constexpr
      54                 :  5318208111 : wide_int_bitmask::wide_int_bitmask (uint64_t l, uint64_t h)
      55                 :             : : low (l), high (h)
      56                 :             : {
      57                 :             : }
      58                 :             : 
      59                 :             : inline wide_int_bitmask &
      60                 :       18440 : wide_int_bitmask::operator &= (wide_int_bitmask b)
      61                 :             : {
      62                 :       18440 :   low &= b.low;
      63                 :       18440 :   high &= b.high;
      64                 :       18440 :   return *this;
      65                 :             : }
      66                 :             : 
      67                 :             : inline wide_int_bitmask &
      68                 :       67609 : wide_int_bitmask::operator |= (wide_int_bitmask b)
      69                 :             : {
      70                 :       67609 :   low |= b.low;
      71                 :       67609 :   high |= b.high;
      72                 :       67609 :   return *this;
      73                 :             : }
      74                 :             : 
      75                 :             : constexpr wide_int_bitmask
      76                 :       18440 : wide_int_bitmask::operator ~ () const
      77                 :             : {
      78                 :       18440 :   return wide_int_bitmask (~low, ~high);
      79                 :             : }
      80                 :             : 
      81                 :             : constexpr wide_int_bitmask
      82                 :      128742 : wide_int_bitmask::operator | (wide_int_bitmask b) const
      83                 :             : {
      84                 :       21873 :   return wide_int_bitmask (low | b.low, high | b.high);
      85                 :             : }
      86                 :             : 
      87                 :             : constexpr wide_int_bitmask
      88                 :  5318097684 : wide_int_bitmask::operator & (wide_int_bitmask b) const
      89                 :             : {
      90                 :   233805858 :   return wide_int_bitmask (low & b.low, high & b.high);
      91                 :             : }
      92                 :             : 
      93                 :             : inline wide_int_bitmask
      94                 :         715 : wide_int_bitmask::operator << (int amount)
      95                 :             : {
      96                 :      376896 :   wide_int_bitmask ret;
      97                 :         715 :   if (amount >= 64)
      98                 :             :     {
      99                 :        1502 :       ret.low = 0;
     100                 :         242 :       ret.high = low << (amount - 64);
     101                 :             :     }
     102                 :         473 :   else if (amount == 0)
     103                 :             :     ret = *this;
     104                 :             :   else
     105                 :             :     {
     106                 :      128245 :       ret.low = low << amount;
     107                 :         473 :       ret.high = (low >> (64 - amount)) | (high << amount);
     108                 :             :     }
     109                 :         715 :   return ret;
     110                 :             : }
     111                 :             : 
     112                 :             : inline wide_int_bitmask
     113                 :      115571 : wide_int_bitmask::operator >> (int amount)
     114                 :             : {
     115                 :      115571 :   wide_int_bitmask ret;
     116                 :      106140 :   if (amount >= 64)
     117                 :             :     {
     118                 :       16595 :       ret.low = high >> (amount - 64);
     119                 :       16595 :       ret.high = 0;
     120                 :             :     }
     121                 :       89545 :   else if (amount == 0)
     122                 :           0 :     ret = *this;
     123                 :             :   else
     124                 :             :     {
     125                 :       98976 :       ret.low = (high << (64 - amount)) | (low >> amount);
     126                 :       89545 :       ret.high = high >> amount;
     127                 :             :     }
     128                 :      115571 :   return ret;
     129                 :             : }
     130                 :             : 
     131                 :             : inline bool
     132                 :    93592425 : wide_int_bitmask::operator == (wide_int_bitmask b) const
     133                 :             : {
     134                 :    93553063 :   return low == b.low && high == b.high;
     135                 :             : }
     136                 :             : 
     137                 :             : inline bool
     138                 :  5224505259 : wide_int_bitmask::operator != (wide_int_bitmask b) const
     139                 :             : {
     140                 :   525266076 :   return low != b.low || high != b.high;
     141                 :             : }
     142                 :             : 
     143                 :             : #endif /* ! GCC_WIDE_INT_BITMASK_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.