LLVM: llvm::ScaledNumbers Namespace Reference (original) (raw)
| Functions | |
|---|---|
| template | |
| int | getWidth () |
| Get the width of a number. | |
| template | |
| std::pair< DigitsT, int16_t > | getRounded (DigitsT Digits, int16_t Scale, bool ShouldRound) |
| Conditionally round up a scaled number. | |
| std::pair< uint32_t, int16_t > | getRounded32 (uint32_t Digits, int16_t Scale, bool ShouldRound) |
| Convenience helper for 32-bit rounding. | |
| std::pair< uint64_t, int16_t > | getRounded64 (uint64_t Digits, int16_t Scale, bool ShouldRound) |
| Convenience helper for 64-bit rounding. | |
| template | |
| std::pair< DigitsT, int16_t > | getAdjusted (uint64_t Digits, int16_t Scale=0) |
| Adjust a 64-bit scaled number down to the appropriate width. | |
| std::pair< uint32_t, int16_t > | getAdjusted32 (uint64_t Digits, int16_t Scale=0) |
| Convenience helper for adjusting to 32 bits. | |
| std::pair< uint64_t, int16_t > | getAdjusted64 (uint64_t Digits, int16_t Scale=0) |
| Convenience helper for adjusting to 64 bits. | |
| LLVM_ABI 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. | |
| template | |
| std::pair< DigitsT, int16_t > | getProduct (DigitsT LHS, DigitsT RHS) |
| Multiply two 32-bit integers to create a 32-bit scaled number. | |
| std::pair< uint32_t, int16_t > | getProduct32 (uint32_t LHS, uint32_t RHS) |
| Convenience helper for 32-bit product. | |
| std::pair< uint64_t, int16_t > | getProduct64 (uint64_t LHS, uint64_t RHS) |
| Convenience helper for 64-bit product. | |
| LLVM_ABI 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. | |
| LLVM_ABI 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. | |
| template | |
| std::pair< DigitsT, int16_t > | getQuotient (DigitsT Dividend, DigitsT Divisor) |
| Divide two 32-bit numbers to create a 32-bit scaled number. | |
| std::pair< uint32_t, int16_t > | getQuotient32 (uint32_t Dividend, uint32_t Divisor) |
| Convenience helper for 32-bit quotient. | |
| std::pair< uint64_t, int16_t > | getQuotient64 (uint64_t Dividend, uint64_t Divisor) |
| Convenience helper for 64-bit quotient. | |
| template | |
| std::pair< int32_t, int > | getLgImpl (DigitsT Digits, int16_t Scale) |
| Implementation of getLg() and friends. | |
| template | |
| int32_t | getLg (DigitsT Digits, int16_t Scale) |
| Get the lg (rounded) of a scaled number. | |
| template | |
| int32_t | getLgFloor (DigitsT Digits, int16_t Scale) |
| Get the lg floor of a scaled number. | |
| template | |
| int32_t | getLgCeiling (DigitsT Digits, int16_t Scale) |
| Get the lg ceiling of a scaled number. | |
| LLVM_ABI int | compareImpl (uint64_t L, uint64_t R, int ScaleDiff) |
| Implementation for comparing scaled numbers. | |
| template | |
| int | compare (DigitsT LDigits, int16_t LScale, DigitsT RDigits, int16_t RScale) |
| Compare two scaled numbers. | |
| template | |
| int16_t | matchScales (DigitsT &LDigits, int16_t &LScale, DigitsT &RDigits, int16_t &RScale) |
| Match scales of two numbers. | |
| template | |
| std::pair< DigitsT, int16_t > | getSum (DigitsT LDigits, int16_t LScale, DigitsT RDigits, int16_t RScale) |
| Get the sum of two scaled numbers. | |
| 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. | |
| 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. | |
| template | |
| std::pair< DigitsT, int16_t > | getDifference (DigitsT LDigits, int16_t LScale, DigitsT RDigits, int16_t RScale) |
| Get the difference of two scaled numbers. | |
| 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. | |
| 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. |
| Variables | |
|---|---|
| const int32_t | MaxScale = 16383 |
| Maximum scale; same as APFloat for easy debug printing. | |
| const int32_t | MinScale = -16382 |
| Maximum scale; same as APFloat for easy debug printing. |
◆ compare()
template
| int llvm::ScaledNumbers::compare | ( | DigitsT | LDigits, |
|---|---|---|---|
| int16_t | LScale, | ||
| DigitsT | RDigits, | ||
| int16_t | RScale ) |
◆ compareImpl()
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.
Precondition
0 <= ScaleDiff < 64.
Definition at line 124 of file ScaledNumber.cpp.
References assert().
Referenced by compare().
◆ divide32()
◆ divide64()
◆ getAdjusted()
template
| std::pair< DigitsT, int16_t > llvm::ScaledNumbers::getAdjusted ( uint64_t Digits, int16_t Scale = 0 ) | inline |
|---|
◆ getAdjusted32()
| std::pair< uint32_t, int16_t > llvm::ScaledNumbers::getAdjusted32 ( uint64_t Digits, int16_t Scale = 0 ) | inline |
|---|
◆ getAdjusted64()
| std::pair< uint64_t, int16_t > llvm::ScaledNumbers::getAdjusted64 ( uint64_t Digits, int16_t Scale = 0 ) | inline |
|---|
◆ getDifference()
template
| std::pair< DigitsT, int16_t > llvm::ScaledNumbers::getDifference | ( | DigitsT | LDigits, |
|---|---|---|---|
| int16_t | LScale, | ||
| DigitsT | RDigits, | ||
| int16_t | RScale ) |
◆ getDifference32()
| std::pair< uint32_t, int16_t > llvm::ScaledNumbers::getDifference32 ( uint32_t LDigits, int16_t LScale, uint32_t RDigits, int16_t RScale ) | inline |
|---|
◆ getDifference64()
| std::pair< uint64_t, int16_t > llvm::ScaledNumbers::getDifference64 ( uint64_t LDigits, int16_t LScale, uint64_t RDigits, int16_t RScale ) | inline |
|---|
◆ getLg()
template
| int32_t llvm::ScaledNumbers::getLg | ( | DigitsT | Digits, |
|---|---|---|---|
| int16_t | Scale ) |
◆ getLgCeiling()
template
| int32_t llvm::ScaledNumbers::getLgCeiling | ( | DigitsT | Digits, |
|---|---|---|---|
| int16_t | Scale ) |
◆ getLgFloor()
template
| int32_t llvm::ScaledNumbers::getLgFloor | ( | DigitsT | Digits, |
|---|---|---|---|
| int16_t | Scale ) |
◆ getLgImpl()
template
| std::pair< int32_t, int > llvm::ScaledNumbers::getLgImpl ( DigitsT Digits, int16_t Scale ) | inline |
|---|
◆ getProduct()
template
| std::pair< DigitsT, int16_t > llvm::ScaledNumbers::getProduct ( DigitsT LHS, DigitsT RHS ) | inline |
|---|
◆ getProduct32()
◆ getProduct64()
◆ getQuotient()
template
| std::pair< DigitsT, int16_t > llvm::ScaledNumbers::getQuotient | ( | DigitsT | Dividend, |
|---|---|---|---|
| DigitsT | Divisor ) |
◆ getQuotient32()
◆ getQuotient64()
◆ getRounded()
template
| std::pair< DigitsT, int16_t > llvm::ScaledNumbers::getRounded ( DigitsT Digits, int16_t Scale, bool ShouldRound ) | inline |
|---|
◆ getRounded32()
| std::pair< uint32_t, int16_t > llvm::ScaledNumbers::getRounded32 ( uint32_t Digits, int16_t Scale, bool ShouldRound ) | inline |
|---|
◆ getRounded64()
| std::pair< uint64_t, int16_t > llvm::ScaledNumbers::getRounded64 ( uint64_t Digits, int16_t Scale, bool ShouldRound ) | inline |
|---|
◆ getSum()
template
| std::pair< DigitsT, int16_t > llvm::ScaledNumbers::getSum | ( | DigitsT | LDigits, |
|---|---|---|---|
| int16_t | LScale, | ||
| DigitsT | RDigits, | ||
| int16_t | RScale ) |
◆ getSum32()
| std::pair< uint32_t, int16_t > llvm::ScaledNumbers::getSum32 ( uint32_t LDigits, int16_t LScale, uint32_t RDigits, int16_t RScale ) | inline |
|---|
◆ getSum64()
| std::pair< uint64_t, int16_t > llvm::ScaledNumbers::getSum64 ( uint64_t LDigits, int16_t LScale, uint64_t RDigits, int16_t RScale ) | inline |
|---|
◆ getWidth()
template
| int llvm::ScaledNumbers::getWidth ( ) | inline |
|---|
◆ matchScales()
template
| 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 290 of file ScaledNumber.h.
References assert(), llvm::countl_zero(), getWidth(), and matchScales().
Referenced by getDifference(), getSum(), and matchScales().
◆ multiply64()
◆ MaxScale
const int32_t llvm::ScaledNumbers::MaxScale = 16383
◆ MinScale
const int32_t llvm::ScaledNumbers::MinScale = -16382