GCC Middle and Back End API Reference
wide-int-bitmask.h
Go to the documentation of this file.
1/* Operation with 128 bit bitmask.
2 Copyright (C) 2013-2024 Free Software Foundation, Inc.
3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
8Software Foundation; either version 3, or (at your option) any later
9version.
10
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14for more details.
15
16You should have received a copy of the GNU General Public License
17along 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
24{
25public:
26 constexpr wide_int_bitmask ();
27 constexpr wide_int_bitmask (uint64_t l);
28 constexpr wide_int_bitmask (uint64_t l, uint64_t h);
31 constexpr wide_int_bitmask operator ~ () const;
36 inline bool operator == (wide_int_bitmask) const;
37 inline bool operator != (wide_int_bitmask) const;
39};
40
41constexpr
43: low (0), high (0)
44{
45}
46
47constexpr
49: low (l), high (0)
50{
51}
52
53constexpr
55: low (l), high (h)
56{
57}
58
59inline wide_int_bitmask &
61{
62 low &= b.low;
63 high &= b.high;
64 return *this;
65}
66
67inline wide_int_bitmask &
69{
70 low |= b.low;
71 high |= b.high;
72 return *this;
73}
74
75constexpr wide_int_bitmask
80
81constexpr wide_int_bitmask
83{
84 return wide_int_bitmask (low | b.low, high | b.high);
85}
86
87constexpr wide_int_bitmask
89{
90 return wide_int_bitmask (low & b.low, high & b.high);
91}
92
95{
97 if (amount >= 64)
98 {
99 ret.low = 0;
100 ret.high = low << (amount - 64);
101 }
102 else if (amount == 0)
103 ret = *this;
104 else
105 {
106 ret.low = low << amount;
107 ret.high = (low >> (64 - amount)) | (high << amount);
108 }
109 return ret;
110}
111
112inline wide_int_bitmask
114{
116 if (amount >= 64)
117 {
118 ret.low = high >> (amount - 64);
119 ret.high = 0;
120 }
121 else if (amount == 0)
122 ret = *this;
123 else
124 {
125 ret.low = (high << (64 - amount)) | (low >> amount);
126 ret.high = high >> amount;
127 }
128 return ret;
129}
130
131inline bool
133{
134 return low == b.low && high == b.high;
135}
136
137inline bool
139{
140 return low != b.low || high != b.high;
141}
142
143#endif /* ! GCC_WIDE_INT_BITMASK_H */
Definition wide-int-bitmask.h:24
wide_int_bitmask operator<<(int)
Definition wide-int-bitmask.h:94
uint64_t low
Definition wide-int-bitmask.h:38
uint64_t high
Definition wide-int-bitmask.h:38
wide_int_bitmask operator>>(int)
Definition wide-int-bitmask.h:113
wide_int_bitmask & operator|=(wide_int_bitmask)
Definition wide-int-bitmask.h:68
bool operator!=(wide_int_bitmask) const
Definition wide-int-bitmask.h:138
constexpr wide_int_bitmask operator&(wide_int_bitmask) const
Definition wide-int-bitmask.h:88
constexpr wide_int_bitmask operator|(wide_int_bitmask) const
Definition wide-int-bitmask.h:82
constexpr wide_int_bitmask()
Definition wide-int-bitmask.h:42
bool operator==(wide_int_bitmask) const
Definition wide-int-bitmask.h:132
constexpr wide_int_bitmask operator~() const
Definition wide-int-bitmask.h:76
wide_int_bitmask & operator&=(wide_int_bitmask)
Definition wide-int-bitmask.h:60
T * ggc_alloc(ALONE_CXX_MEM_STAT_INFO)
Definition ggc.h:184
Ca const poly_int< N, Cb > & b
Definition poly-int.h:767