Lines Matching +full:1 +full:a
4 * A tnum tracks knowledge about the bits of a value. Each bit can be either
5 * known (0 or 1), or unknown (x). Arithmetic operations on tnums will
13 /* A completely unknown value */
14 const struct tnum tnum_unknown = { .value = 0, .mask = -1 };
26 /* special case, needed because 1ULL << 64 is undefined */ in tnum_range()
29 /* e.g. if chi = 4, bits = 3, delta = (1<<3) - 1 = 7. in tnum_range()
30 * if chi = 0, bits = 0, delta = (1<<0) - 1 = 0, so we return in tnum_range()
33 delta = (1ULL << bits) - 1; in tnum_range()
37 struct tnum tnum_lshift(struct tnum a, u8 shift) in tnum_lshift() argument
39 return TNUM(a.value << shift, a.mask << shift); in tnum_lshift()
42 struct tnum tnum_rshift(struct tnum a, u8 shift) in tnum_rshift() argument
44 return TNUM(a.value >> shift, a.mask >> shift); in tnum_rshift()
47 struct tnum tnum_arshift(struct tnum a, u8 min_shift, u8 insn_bitness) in tnum_arshift() argument
49 /* if a.value is negative, arithmetic shifting by minimum shift in tnum_arshift()
51 * If a.value is nonnegative, arithmetic shifting by minimum shift in tnum_arshift()
55 return TNUM((u32)(((s32)a.value) >> min_shift), in tnum_arshift()
56 (u32)(((s32)a.mask) >> min_shift)); in tnum_arshift()
58 return TNUM((s64)a.value >> min_shift, in tnum_arshift()
59 (s64)a.mask >> min_shift); in tnum_arshift()
62 struct tnum tnum_add(struct tnum a, struct tnum b) in tnum_add() argument
66 sm = a.mask + b.mask; in tnum_add()
67 sv = a.value + b.value; in tnum_add()
70 mu = chi | a.mask | b.mask; in tnum_add()
74 struct tnum tnum_sub(struct tnum a, struct tnum b) in tnum_sub() argument
78 dv = a.value - b.value; in tnum_sub()
79 alpha = dv + a.mask; in tnum_sub()
82 mu = chi | a.mask | b.mask; in tnum_sub()
86 struct tnum tnum_and(struct tnum a, struct tnum b) in tnum_and() argument
90 alpha = a.value | a.mask; in tnum_and()
92 v = a.value & b.value; in tnum_and()
96 struct tnum tnum_or(struct tnum a, struct tnum b) in tnum_or() argument
100 v = a.value | b.value; in tnum_or()
101 mu = a.mask | b.mask; in tnum_or()
105 struct tnum tnum_xor(struct tnum a, struct tnum b) in tnum_xor() argument
109 v = a.value ^ b.value; in tnum_xor()
110 mu = a.mask | b.mask; in tnum_xor()
114 /* Generate partial products by multiplying each bit in the multiplier (tnum a)
122 struct tnum tnum_mul(struct tnum a, struct tnum b) in tnum_mul() argument
124 u64 acc_v = a.value * b.value; in tnum_mul()
127 while (a.value || a.mask) { in tnum_mul()
128 /* LSB of tnum a is a certain 1 */ in tnum_mul()
129 if (a.value & 1) in tnum_mul()
131 /* LSB of tnum a is uncertain */ in tnum_mul()
132 else if (a.mask & 1) in tnum_mul()
135 a = tnum_rshift(a, 1); in tnum_mul()
136 b = tnum_lshift(b, 1); in tnum_mul()
141 /* Note that if a and b disagree - i.e. one has a 'known 1' where the other has
142 * a 'known 0' - this will return a 'known 1' for that bit.
144 struct tnum tnum_intersect(struct tnum a, struct tnum b) in tnum_intersect() argument
148 v = a.value | b.value; in tnum_intersect()
149 mu = a.mask & b.mask; in tnum_intersect()
153 struct tnum tnum_cast(struct tnum a, u8 size) in tnum_cast() argument
155 a.value &= (1ULL << (size * 8)) - 1; in tnum_cast()
156 a.mask &= (1ULL << (size * 8)) - 1; in tnum_cast()
157 return a; in tnum_cast()
160 bool tnum_is_aligned(struct tnum a, u64 size) in tnum_is_aligned() argument
164 return !((a.value | a.mask) & (size - 1)); in tnum_is_aligned()
167 bool tnum_in(struct tnum a, struct tnum b) in tnum_in() argument
169 if (b.mask & ~a.mask) in tnum_in()
171 b.value &= ~a.mask; in tnum_in()
172 return a.value == b.value; in tnum_in()
175 int tnum_sbin(char *str, size_t size, struct tnum a) in tnum_sbin() argument
181 if (a.mask & 1) in tnum_sbin()
182 str[n - 1] = 'x'; in tnum_sbin()
183 else if (a.value & 1) in tnum_sbin()
184 str[n - 1] = '1'; in tnum_sbin()
186 str[n - 1] = '0'; in tnum_sbin()
188 a.mask >>= 1; in tnum_sbin()
189 a.value >>= 1; in tnum_sbin()
191 str[min(size - 1, (size_t)64)] = 0; in tnum_sbin()
195 struct tnum tnum_subreg(struct tnum a) in tnum_subreg() argument
197 return tnum_cast(a, 4); in tnum_subreg()
200 struct tnum tnum_clear_subreg(struct tnum a) in tnum_clear_subreg() argument
202 return tnum_lshift(tnum_rshift(a, 32), 32); in tnum_clear_subreg()
210 struct tnum tnum_const_subreg(struct tnum a, u32 value) in tnum_const_subreg() argument
212 return tnum_with_subreg(a, tnum_const(value)); in tnum_const_subreg()