mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-12 13:38:21 +00:00
Add an argument to APInt's magic udiv calculation to specify the number of bits that are known zero in the divided number.
This will come in handy soon. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127828 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -1517,13 +1517,15 @@ APInt::ms APInt::magic() const {
|
||||
/// division by a constant as a sequence of multiplies, adds and shifts.
|
||||
/// Requires that the divisor not be 0. Taken from "Hacker's Delight", Henry
|
||||
/// S. Warren, Jr., chapter 10.
|
||||
APInt::mu APInt::magicu() const {
|
||||
/// LeadingZeros can be used to simplify the calculation if the upper bits
|
||||
/// of the devided value are known zero.
|
||||
APInt::mu APInt::magicu(unsigned LeadingZeros) const {
|
||||
const APInt& d = *this;
|
||||
unsigned p;
|
||||
APInt nc, delta, q1, r1, q2, r2;
|
||||
struct mu magu;
|
||||
magu.a = 0; // initialize "add" indicator
|
||||
APInt allOnes = APInt::getAllOnesValue(d.getBitWidth());
|
||||
APInt allOnes = APInt::getAllOnesValue(d.getBitWidth()).lshr(LeadingZeros);
|
||||
APInt signedMin = APInt::getSignedMinValue(d.getBitWidth());
|
||||
APInt signedMax = APInt::getSignedMaxValue(d.getBitWidth());
|
||||
|
||||
|
Reference in New Issue
Block a user