LLVM
8.0.1
|
Functions | |
template<class DigitsT > | |
int | getWidth () |
Get the width of a number. More... | |
template<class DigitsT > | |
std::pair< DigitsT, int16_t > | getRounded (DigitsT Digits, int16_t Scale, bool ShouldRound) |
Conditionally round up a scaled number. More... | |
std::pair< uint32_t, int16_t > | getRounded32 (uint32_t Digits, int16_t Scale, bool ShouldRound) |
Convenience helper for 32-bit rounding. More... | |
std::pair< uint64_t, int16_t > | getRounded64 (uint64_t Digits, int16_t Scale, bool ShouldRound) |
Convenience helper for 64-bit rounding. More... | |
template<class DigitsT > | |
std::pair< DigitsT, int16_t > | getAdjusted (uint64_t Digits, int16_t Scale=0) |
Adjust a 64-bit scaled number down to the appropriate width. More... | |
std::pair< uint32_t, int16_t > | getAdjusted32 (uint64_t Digits, int16_t Scale=0) |
Convenience helper for adjusting to 32 bits. More... | |
std::pair< uint64_t, int16_t > | getAdjusted64 (uint64_t Digits, int16_t Scale=0) |
Convenience helper for adjusting to 64 bits. More... | |
std::pair< uint64_t, int16_t > | multiply64 (uint64_t LHS, uint64_t RHS) |
Multiply two 64-bit integers to create a 64-bit scaled number. More... | |
template<class DigitsT > | |
std::pair< DigitsT, int16_t > | getProduct (DigitsT LHS, DigitsT RHS) |
Multiply two 32-bit integers to create a 32-bit scaled number. More... | |
std::pair< uint32_t, int16_t > | getProduct32 (uint32_t LHS, uint32_t RHS) |
Convenience helper for 32-bit product. More... | |
std::pair< uint64_t, int16_t > | getProduct64 (uint64_t LHS, uint64_t RHS) |
Convenience helper for 64-bit product. More... | |
std::pair< uint64_t, int16_t > | divide64 (uint64_t Dividend, uint64_t Divisor) |
Divide two 64-bit integers to create a 64-bit scaled number. More... | |
std::pair< uint32_t, int16_t > | divide32 (uint32_t Dividend, uint32_t Divisor) |
Divide two 32-bit integers to create a 32-bit scaled number. More... | |
template<class DigitsT > | |
std::pair< DigitsT, int16_t > | getQuotient (DigitsT Dividend, DigitsT Divisor) |
Divide two 32-bit numbers to create a 32-bit scaled number. More... | |
std::pair< uint32_t, int16_t > | getQuotient32 (uint32_t Dividend, uint32_t Divisor) |
Convenience helper for 32-bit quotient. More... | |
std::pair< uint64_t, int16_t > | getQuotient64 (uint64_t Dividend, uint64_t Divisor) |
Convenience helper for 64-bit quotient. More... | |
template<class DigitsT > | |
std::pair< int32_t, int > | getLgImpl (DigitsT Digits, int16_t Scale) |
Implementation of getLg() and friends. More... | |
template<class DigitsT > | |
int32_t | getLg (DigitsT Digits, int16_t Scale) |
Get the lg (rounded) of a scaled number. More... | |
template<class DigitsT > | |
int32_t | getLgFloor (DigitsT Digits, int16_t Scale) |
Get the lg floor of a scaled number. More... | |
template<class DigitsT > | |
int32_t | getLgCeiling (DigitsT Digits, int16_t Scale) |
Get the lg ceiling of a scaled number. More... | |
int | compareImpl (uint64_t L, uint64_t R, int ScaleDiff) |
Implementation for comparing scaled numbers. More... | |
template<class DigitsT > | |
int | compare (DigitsT LDigits, int16_t LScale, DigitsT RDigits, int16_t RScale) |
Compare two scaled numbers. More... | |
template<class DigitsT > | |
int16_t | matchScales (DigitsT &LDigits, int16_t &LScale, DigitsT &RDigits, int16_t &RScale) |
Match scales of two numbers. More... | |
template<class DigitsT > | |
std::pair< DigitsT, int16_t > | getSum (DigitsT LDigits, int16_t LScale, DigitsT RDigits, int16_t RScale) |
Get the sum of two scaled numbers. More... | |
std::pair< uint32_t, int16_t > | getSum32 (uint32_t LDigits, int16_t LScale, uint32_t RDigits, int16_t RScale) |
Convenience helper for 32-bit sum. More... | |
std::pair< uint64_t, int16_t > | getSum64 (uint64_t LDigits, int16_t LScale, uint64_t RDigits, int16_t RScale) |
Convenience helper for 64-bit sum. More... | |
template<class DigitsT > | |
std::pair< DigitsT, int16_t > | getDifference (DigitsT LDigits, int16_t LScale, DigitsT RDigits, int16_t RScale) |
Get the difference of two scaled numbers. More... | |
std::pair< uint32_t, int16_t > | getDifference32 (uint32_t LDigits, int16_t LScale, uint32_t RDigits, int16_t RScale) |
Convenience helper for 32-bit difference. More... | |
std::pair< uint64_t, int16_t > | getDifference64 (uint64_t LDigits, int16_t LScale, uint64_t RDigits, int16_t RScale) |
Convenience helper for 64-bit difference. More... | |
Variables | |
const int32_t | MaxScale = 16383 |
Maximum scale; same as APFloat for easy debug printing. More... | |
const int32_t | MinScale = -16382 |
Maximum scale; same as APFloat for easy debug printing. More... | |
int llvm::ScaledNumbers::compare | ( | DigitsT | LDigits, |
int16_t | LScale, | ||
DigitsT | RDigits, | ||
int16_t | RScale | ||
) |
Compare two scaled numbers.
Compare two scaled numbers. Returns 0 for equal, -1 for less than, and 1 for greater than.
Definition at line 252 of file ScaledNumber.h.
References compareImpl(), and getLgFloor().
Referenced by canCreateAliasFor(), llvm::cl::OptionValueCopy< cl::boolOrDefault >::compare(), llvm::ScaledNumber< uint64_t >::compare(), despeculateCountZeros(), llvm::FunctionComparator::FunctionComparator(), getDifference(), llvm::detail::DoubleAPFloat::getSecond(), llvm::detail::IEEEFloat::isInteger(), llvm::detail::IEEEFloat::needsCleanup(), llvm::ScaledNumber< uint64_t >::operator!=(), llvm::ScaledNumber< uint64_t >::operator<(), llvm::ScaledNumber< uint64_t >::operator<=(), llvm::ScaledNumber< uint64_t >::operator==(), llvm::ScaledNumber< uint64_t >::operator>(), llvm::ScaledNumber< uint64_t >::operator>=(), llvm::APInt::tcDivide(), llvm::APInt::ule(), and llvm::APInt::ult().
int llvm::ScaledNumbers::compareImpl | ( | uint64_t | L, |
uint64_t | R, | ||
int | ScaleDiff | ||
) |
Implementation for comparing scaled numbers.
Compare two 64-bit numbers with different scales. Given that the scale of L
is higher than that of R
by ScaleDiff
, compare them. Return -1, 1, and 0 for less than, greater than, and equal, respectively.
Definition at line 125 of file ScaledNumber.cpp.
References assert().
Referenced by compare(), and getLgCeiling().
std::pair< uint32_t, int16_t > llvm::ScaledNumbers::divide32 | ( | uint32_t | Dividend, |
uint32_t | Divisor | ||
) |
Divide two 32-bit integers to create a 32-bit scaled number.
Implemented with one 64-bit integer divide/remainder pair.
Dividend
and Divisor
are non-zero. Definition at line 58 of file ScaledNumber.cpp.
References assert(), llvm::countLeadingZeros(), and getHalf().
Referenced by getProduct64(), and getQuotient().
std::pair< uint64_t, int16_t > llvm::ScaledNumbers::divide64 | ( | uint64_t | Dividend, |
uint64_t | Divisor | ||
) |
Divide two 64-bit integers to create a 64-bit scaled number.
Implemented with long division.
Dividend
and Divisor
are non-zero. Definition at line 81 of file ScaledNumber.cpp.
References assert(), llvm::countLeadingZeros(), llvm::countTrailingZeros(), getHalf(), and getRounded().
Referenced by getProduct64(), and getQuotient().
|
inline |
Adjust a 64-bit scaled number down to the appropriate width.
Scale
will not overflow INT16_MAX. Definition at line 80 of file ScaledNumber.h.
References llvm::countLeadingZeros(), and llvm::max().
|
inline |
Convenience helper for adjusting to 32 bits.
Definition at line 95 of file ScaledNumber.h.
|
inline |
Convenience helper for adjusting to 64 bits.
Definition at line 101 of file ScaledNumber.h.
References multiply64().
std::pair<DigitsT, int16_t> llvm::ScaledNumbers::getDifference | ( | DigitsT | LDigits, |
int16_t | LScale, | ||
DigitsT | RDigits, | ||
int16_t | RScale | ||
) |
Get the difference of two scaled numbers.
Get LHS minus RHS with as much precision as possible.
Returns (0, 0) if the RHS is larger than the LHS.
Definition at line 373 of file ScaledNumber.h.
References compare(), getLgFloor(), matchScales(), and llvm::max().
Referenced by getDifference32(), getDifference64(), and llvm::ScaledNumber< uint64_t >::operator-=().
|
inline |
Convenience helper for 32-bit difference.
Definition at line 399 of file ScaledNumber.h.
References getDifference().
|
inline |
Convenience helper for 64-bit difference.
Definition at line 407 of file ScaledNumber.h.
References getDifference().
int32_t llvm::ScaledNumbers::getLg | ( | DigitsT | Digits, |
int16_t | Scale | ||
) |
Get the lg (rounded) of a scaled number.
Get the lg of Digits*2^Scale
.
Returns INT32_MIN
when Digits
is zero.
Definition at line 214 of file ScaledNumber.h.
References getLgImpl().
Referenced by llvm::ScaledNumber< uint64_t >::lg().
int32_t llvm::ScaledNumbers::getLgCeiling | ( | DigitsT | Digits, |
int16_t | Scale | ||
) |
Get the lg ceiling of a scaled number.
Get the ceiling of the lg of Digits*2^Scale
.
Returns INT32_MIN
when Digits
is zero.
Definition at line 233 of file ScaledNumber.h.
References compareImpl(), and getLgImpl().
Referenced by llvm::ScaledNumber< uint64_t >::lgCeiling().
int32_t llvm::ScaledNumbers::getLgFloor | ( | DigitsT | Digits, |
int16_t | Scale | ||
) |
Get the lg floor of a scaled number.
Get the floor of the lg of Digits*2^Scale
.
Returns INT32_MIN
when Digits
is zero.
Definition at line 223 of file ScaledNumber.h.
References getLgImpl().
Referenced by compare(), getDifference(), and llvm::ScaledNumber< uint64_t >::lgFloor().
|
inline |
Implementation of getLg() and friends.
Returns the rounded lg of Digits*2^Scale
and an int specifying whether this was rounded up (1), down (-1), or exact (0).
Returns INT32_MIN
when Digits
is zero.
Definition at line 189 of file ScaledNumber.h.
References assert(), and llvm::countLeadingZeros().
Referenced by getLg(), getLgCeiling(), and getLgFloor().
|
inline |
Multiply two 32-bit integers to create a 32-bit scaled number.
Implemented with one 64-bit integer multiply.
Definition at line 115 of file ScaledNumber.h.
References multiply64().
Referenced by getProduct32(), getProduct64(), llvm::ScaledNumber< uint64_t >::inverse(), and llvm::ScaledNumber< uint64_t >::operator*=().
|
inline |
Convenience helper for 32-bit product.
Definition at line 125 of file ScaledNumber.h.
References getProduct().
|
inline |
Convenience helper for 64-bit product.
Definition at line 130 of file ScaledNumber.h.
References divide32(), divide64(), and getProduct().
std::pair<DigitsT, int16_t> llvm::ScaledNumbers::getQuotient | ( | DigitsT | Dividend, |
DigitsT | Divisor | ||
) |
Divide two 32-bit numbers to create a 32-bit scaled number.
Implemented with one 64-bit integer divide/remainder pair.
Returns (DigitsT_MAX, MaxScale) for divide-by-zero (0 for 0/0).
Definition at line 154 of file ScaledNumber.h.
References divide32(), divide64(), and llvm::max().
Referenced by llvm::ScaledNumber< uint64_t >::getFraction(), getQuotient32(), getQuotient64(), llvm::ScaledNumber< uint64_t >::inverse(), and llvm::ScaledNumber< uint64_t >::operator/=().
|
inline |
Convenience helper for 32-bit quotient.
Definition at line 171 of file ScaledNumber.h.
References getQuotient().
|
inline |
Convenience helper for 64-bit quotient.
Definition at line 177 of file ScaledNumber.h.
References getQuotient().
|
inline |
Conditionally round up a scaled number.
Given Digits
and Scale
, round up iff ShouldRound
is true
. Always returns Scale
unless there's an overflow, in which case it returns 1+Scale
.
Scale
will not overflow INT16_MAX. Definition at line 53 of file ScaledNumber.h.
Referenced by divide64(), getRounded32(), getRounded64(), llvm::ScaledNumber< uint64_t >::inverse(), and multiply64().
|
inline |
Convenience helper for 32-bit rounding.
Definition at line 65 of file ScaledNumber.h.
References getRounded().
|
inline |
Convenience helper for 64-bit rounding.
Definition at line 71 of file ScaledNumber.h.
References getRounded().
std::pair<DigitsT, int16_t> llvm::ScaledNumbers::getSum | ( | DigitsT | LDigits, |
int16_t | LScale, | ||
DigitsT | RDigits, | ||
int16_t | RScale | ||
) |
Get the sum of two scaled numbers.
Get the sum of two scaled numbers with as much precision as possible.
LScale
(or RScale
) will not overflow INT16_MAX. Definition at line 333 of file ScaledNumber.h.
References assert(), and matchScales().
Referenced by getSum32(), getSum64(), and llvm::ScaledNumber< uint64_t >::operator+=().
|
inline |
Convenience helper for 32-bit sum.
Definition at line 356 of file ScaledNumber.h.
References getSum().
|
inline |
Convenience helper for 64-bit sum.
Definition at line 362 of file ScaledNumber.h.
References getSum().
|
inline |
Get the width of a number.
Definition at line 43 of file ScaledNumber.h.
int16_t llvm::ScaledNumbers::matchScales | ( | DigitsT & | LDigits, |
int16_t & | LScale, | ||
DigitsT & | RDigits, | ||
int16_t & | RScale | ||
) |
Match scales of two numbers.
Given two scaled numbers, match up their scales. Change the digits and scales in place. Shift the digits as necessary to form equivalent numbers, losing precision only when necessary.
If the output value of LDigits
(RDigits
) is 0
, the output value of LScale
(RScale
) is unspecified.
As a convenience, returns the matching scale. If the output value of one number is zero, returns the scale of the other. If both are zero, which scale is returned is unspecified.
Definition at line 287 of file ScaledNumber.h.
References assert(), and llvm::countLeadingZeros().
Referenced by getDifference(), getSum(), and llvm::ScaledNumber< uint64_t >::operator>>=().
std::pair< uint64_t, int16_t > llvm::ScaledNumbers::multiply64 | ( | uint64_t | LHS, |
uint64_t | RHS | ||
) |
Multiply two 64-bit integers to create a 64-bit scaled number.
Implemented with four 64-bit integer multiplies.
Definition at line 23 of file ScaledNumber.cpp.
References llvm::countLeadingZeros(), getRounded(), getU(), llvm::LegalizeActions::Lower, N, and llvm::Upper.
Referenced by getAdjusted64(), and getProduct().
const int32_t llvm::ScaledNumbers::MaxScale = 16383 |
Maximum scale; same as APFloat for easy debug printing.
Definition at line 37 of file ScaledNumber.h.
Referenced by llvm::ScaledNumber< uint64_t >::getLargest(), llvm::ScaledNumber< uint64_t >::inverse(), matchUnaryVectorShuffle(), llvm::ScaledNumber< uint64_t >::operator+=(), llvm::ScaledNumber< uint64_t >::operator/=(), and toStringAPFloat().
const int32_t llvm::ScaledNumbers::MinScale = -16382 |
Maximum scale; same as APFloat for easy debug printing.
Definition at line 40 of file ScaledNumber.h.
Referenced by llvm::ScaledNumber< uint64_t >::inverse(), llvm::ScaledNumber< uint64_t >::operator/=(), and toStringAPFloat().