83 c_hi = (((a_int * b_int) >> 128) - hi_operand) &
static_cast<uint256_t>(
MASK_64);
120 throw AluException(
"DIV, Cannot perform integer division on a field element");
166 throw AluException(
"FDIV, Cannot perform field division on an integer");
192 if (
a.get_tag() !=
b.get_tag()) {
194 throw AluException(
"EQ, Tag mismatch between operands.");
214 if (
a.get_tag() !=
b.get_tag()) {
216 throw AluException(
"LT, Tag mismatch between operands.");
236 if (
a.get_tag() !=
b.get_tag()) {
238 throw AluException(
"LT, Tag mismatch between operands.");
286 bool overflow = b_num > max_bits;
287 uint128_t a_lo_bits = overflow ? max_bits : max_bits - b_num;
293 uint128_t a_lo = overflow ? b_num - max_bits : a_num & mask;
294 uint128_t a_hi = a_lo_bits >= 128 ? 0 : a_num >> a_lo_bits;
295 uint128_t a_hi_bits = overflow ? max_bits : b_num;
297 range_check.assert_range(a_lo,
static_cast<uint8_t
>(a_lo_bits));
298 range_check.assert_range(a_hi,
static_cast<uint8_t
>(a_hi_bits));
328 bool overflow = b_num > max_bits;
329 uint128_t a_lo_bits = overflow ? max_bits : b_num;
335 uint128_t a_lo = overflow ? b_num - max_bits : a_num & mask;
336 uint128_t a_hi = a_lo_bits >= 128 ? 0 : a_num >> a_lo_bits;
337 uint128_t a_hi_bits = overflow ? max_bits : max_bits - b_num;
339 range_check.assert_range(a_lo,
static_cast<uint8_t
>(a_lo_bits));
340 range_check.assert_range(a_hi,
static_cast<uint8_t
>(a_hi_bits));
371 a_lo = decomposition.
lo;
static TaggedValue from_tag_truncating(ValueTag tag, FF value)
static TaggedValue from_tag(ValueTag tag, FF value)
MemoryValue lte(const MemoryValue &a, const MemoryValue &b) override
Check if the first memory value is less than or equal to the second and emit an event of type AluEven...
MemoryValue fdiv(const MemoryValue &a, const MemoryValue &b) override
Perform field division on two memory values and emit an event of type AluEvent.
MemoryValue truncate(const FF &a, MemoryTag dst_tag) override
Truncate a field element to a specific memory tag and emit an event of type AluEvent.
MemoryValue eq(const MemoryValue &a, const MemoryValue &b) override
Check if two memory values are equal and emit an event of type AluEvent.
MemoryValue lt(const MemoryValue &a, const MemoryValue &b) override
Check if the first memory value is less than the second and emit an event of type AluEvent.
MemoryValue shl(const MemoryValue &a, const MemoryValue &b) override
Perform left shift operation on a memory value and emit an event of type AluEvent.
MemoryValue add(const MemoryValue &a, const MemoryValue &b) override
Add two memory values and emit an event of type AluEvent.
MemoryValue sub(const MemoryValue &a, const MemoryValue &b) override
Subtract two memory values and emit an event of type AluEvent.
FieldGreaterThanInterface & field_gt
MemoryValue mul(const MemoryValue &a, const MemoryValue &b) override
Multiply two memory values and emit an event of type AluEvent.
MemoryValue shr(const MemoryValue &a, const MemoryValue &b) override
Perform right shift operation on a memory value and emit an event of type AluEvent.
EventEmitterInterface< AluEvent > & events
MemoryValue op_not(const MemoryValue &a) override
Perform bitwise NOT operation on a memory value and emit an event of type AluEvent.
GreaterThanInterface & greater_than
MemoryValue div(const MemoryValue &a, const MemoryValue &b) override
Divide two memory values and emit an event of type AluEvent.
virtual U256Decomposition canon_dec(const FF &a)=0
virtual bool gt(const FF &a, const FF &b)=0
static constexpr uint256_t from_uint128(const uint128_t a) noexcept
U128Decomposition decompose_128(const uint128_t &x)
constexpr uint128_t MASK_64
uint8_t get_tag_bits(ValueTag tag)
uint256_t get_tag_max_value(ValueTag tag)
unsigned __int128 uint128_t