1 /* Operation with 128 bit bitmask.
2 Copyright (C) 2013-2020 Free Software Foundation, Inc.
4 This file is part of GCC.
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
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
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/>. */
20 #ifndef GCC_WIDE_INT_BITMASK_H
21 #define GCC_WIDE_INT_BITMASK_H
23 class wide_int_bitmask
26 inline wide_int_bitmask ();
27 inline wide_int_bitmask (uint64_t l);
28 inline 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 inline wide_int_bitmask operator ~ () const;
32 inline wide_int_bitmask operator & (wide_int_bitmask) const;
33 inline 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;
42 wide_int_bitmask::wide_int_bitmask ()
48 wide_int_bitmask::wide_int_bitmask (uint64_t l)
54 wide_int_bitmask::wide_int_bitmask (uint64_t l, uint64_t h)
59 inline wide_int_bitmask &
60 wide_int_bitmask::operator &= (wide_int_bitmask b)
67 inline wide_int_bitmask &
68 wide_int_bitmask::operator |= (wide_int_bitmask b)
75 inline wide_int_bitmask
76 wide_int_bitmask::operator ~ () const
78 wide_int_bitmask ret (~low, ~high);
82 inline wide_int_bitmask
83 wide_int_bitmask::operator | (wide_int_bitmask b) const
85 wide_int_bitmask ret (low | b.low, high | b.high);
89 inline wide_int_bitmask
90 wide_int_bitmask::operator & (wide_int_bitmask b) const
92 wide_int_bitmask ret (low & b.low, high & b.high);
96 inline wide_int_bitmask
97 wide_int_bitmask::operator << (int amount)
103 ret.high = low << (amount - 64);
105 else if (amount == 0)
109 ret.low = low << amount;
110 ret.high = (low >> (64 - amount)) | (high << amount);
115 inline wide_int_bitmask
116 wide_int_bitmask::operator >> (int amount)
118 wide_int_bitmask ret;
121 ret.low = high >> (amount - 64);
124 else if (amount == 0)
128 ret.low = (high << (64 - amount)) | (low >> amount);
129 ret.high = high >> amount;
135 wide_int_bitmask::operator == (wide_int_bitmask b) const
137 return low == b.low && high == b.high;
141 wide_int_bitmask::operator != (wide_int_bitmask b) const
143 return low != b.low || high != b.high;
146 #endif /* ! GCC_WIDE_INT_BITMASK_H */