diff --git a/backends/cxxrtl/cxxrtl.h b/backends/cxxrtl/cxxrtl.h index d4e2fa7fc..4abb27be5 100644 --- a/backends/cxxrtl/cxxrtl.h +++ b/backends/cxxrtl/cxxrtl.h @@ -661,61 +661,6 @@ struct value : public expr_base> { chunk::type part2 = (x == num.chunks) ? 0 : (num.data[x] << y); return part1 | part2; } - - // parallel to BigInteger::divideWithRemainder; quotient is stored in q, - // *this is left with the remainder. See that function for commentary describing - // how/why this works. - void signedDivideWithRemainder(const value &b, value &q) { - assert(this != &q); - - if (this == &b || &q == &b) { - value tmpB(b); - signedDivideWithRemainder(tmpB, q); - return; - } - - if (b.is_zero()) { - q = value{0u}; - return; - } - - if (is_zero()) { - q = value{0u}; - return; - } - - // BigInteger has a separate 'mag' to its sign. We don't, so the lazy - // approach is to improvise said. - auto mag = *this; - bool neg = mag.is_neg(); - if (neg) - mag = mag.neg(); - - auto bmag = b; - bool bneg = bmag.is_neg(); - if (bneg) - bmag = bmag.neg(); - - bool qneg = false; - if (neg != b.is_neg()) { - qneg = true; - mag = mag.sub(value{1u}); - } - - mag.divideWithRemainder(bmag, q); - - if (neg != bneg) { - q = q.add(value{1u}); - mag = bmag.sub(mag); - mag = mag.sub(value{1u}); - } - - neg = bneg; - - *this = neg ? mag.neg() : mag; - if (qneg) - q = q.neg(); - } }; // Expression template for a slice, usable as lvalue or rvalue, and composable with other expression templates here.