LLVM  8.0.1
Classes | Namespaces | Macros | Functions | Variables
ScaledNumber.h File Reference
#include "llvm/Support/MathExtras.h"
#include <algorithm>
#include <cstdint>
#include <limits>
#include <string>
#include <tuple>
#include <utility>
Include dependency graph for ScaledNumber.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  llvm::ScaledNumberBase
 
class  llvm::ScaledNumber< DigitsT >
 Simple representation of a scaled number. More...
 
struct  llvm::isPodLike< T >
 isPodLike - This is a type trait that is used to determine whether a given type can be copied around with memcpy instead of running ctors etc. More...
 
struct  llvm::isPodLike< ScaledNumber< T > >
 

Namespaces

 llvm
 This class represents lattice values for constants.
 
 llvm::ScaledNumbers
 

Macros

#define SCALED_NUMBER_BOP(op, base)
 
#define SCALED_NUMBER_COMPARE_TO_TYPE(op, T1, T2)
 
#define SCALED_NUMBER_COMPARE_TO(op)
 

Functions

template<class DigitsT >
int llvm::ScaledNumbers::getWidth ()
 Get the width of a number. More...
 
template<class DigitsT >
std::pair< DigitsT, int16_t > llvm::ScaledNumbers::getRounded (DigitsT Digits, int16_t Scale, bool ShouldRound)
 Conditionally round up a scaled number. More...
 
std::pair< uint32_t, int16_t > llvm::ScaledNumbers::getRounded32 (uint32_t Digits, int16_t Scale, bool ShouldRound)
 Convenience helper for 32-bit rounding. More...
 
std::pair< uint64_t, int16_t > llvm::ScaledNumbers::getRounded64 (uint64_t Digits, int16_t Scale, bool ShouldRound)
 Convenience helper for 64-bit rounding. More...
 
template<class DigitsT >
std::pair< DigitsT, int16_t > llvm::ScaledNumbers::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 > llvm::ScaledNumbers::getAdjusted32 (uint64_t Digits, int16_t Scale=0)
 Convenience helper for adjusting to 32 bits. More...
 
std::pair< uint64_t, int16_t > llvm::ScaledNumbers::getAdjusted64 (uint64_t Digits, int16_t Scale=0)
 Convenience helper for adjusting to 64 bits. More...
 
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. More...
 
template<class DigitsT >
std::pair< DigitsT, int16_t > llvm::ScaledNumbers::getProduct (DigitsT LHS, DigitsT RHS)
 Multiply two 32-bit integers to create a 32-bit scaled number. More...
 
std::pair< uint32_t, int16_t > llvm::ScaledNumbers::getProduct32 (uint32_t LHS, uint32_t RHS)
 Convenience helper for 32-bit product. More...
 
std::pair< uint64_t, int16_t > llvm::ScaledNumbers::getProduct64 (uint64_t LHS, uint64_t RHS)
 Convenience helper for 64-bit product. More...
 
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. More...
 
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. More...
 
template<class DigitsT >
std::pair< DigitsT, int16_t > llvm::ScaledNumbers::getQuotient (DigitsT Dividend, DigitsT Divisor)
 Divide two 32-bit numbers to create a 32-bit scaled number. More...
 
std::pair< uint32_t, int16_t > llvm::ScaledNumbers::getQuotient32 (uint32_t Dividend, uint32_t Divisor)
 Convenience helper for 32-bit quotient. More...
 
std::pair< uint64_t, int16_t > llvm::ScaledNumbers::getQuotient64 (uint64_t Dividend, uint64_t Divisor)
 Convenience helper for 64-bit quotient. More...
 
template<class DigitsT >
std::pair< int32_t, int > llvm::ScaledNumbers::getLgImpl (DigitsT Digits, int16_t Scale)
 Implementation of getLg() and friends. More...
 
template<class DigitsT >
int32_t llvm::ScaledNumbers::getLg (DigitsT Digits, int16_t Scale)
 Get the lg (rounded) of a scaled number. More...
 
template<class DigitsT >
int32_t llvm::ScaledNumbers::getLgFloor (DigitsT Digits, int16_t Scale)
 Get the lg floor of a scaled number. More...
 
template<class DigitsT >
int32_t llvm::ScaledNumbers::getLgCeiling (DigitsT Digits, int16_t Scale)
 Get the lg ceiling of a scaled number. More...
 
int llvm::ScaledNumbers::compareImpl (uint64_t L, uint64_t R, int ScaleDiff)
 Implementation for comparing scaled numbers. More...
 
template<class DigitsT >
int llvm::ScaledNumbers::compare (DigitsT LDigits, int16_t LScale, DigitsT RDigits, int16_t RScale)
 Compare two scaled numbers. More...
 
template<class DigitsT >
int16_t llvm::ScaledNumbers::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 > llvm::ScaledNumbers::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 > llvm::ScaledNumbers::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 > llvm::ScaledNumbers::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 > llvm::ScaledNumbers::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 > llvm::ScaledNumbers::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 > llvm::ScaledNumbers::getDifference64 (uint64_t LDigits, int16_t LScale, uint64_t RDigits, int16_t RScale)
 Convenience helper for 64-bit difference. More...
 
template<class DigitsT >
ScaledNumber< DigitsT > llvm::operator<< (const ScaledNumber< DigitsT > &L, int16_t Shift)
 
template<class DigitsT >
ScaledNumber< DigitsT > llvm::operator>> (const ScaledNumber< DigitsT > &L, int16_t Shift)
 
template<class DigitsT >
raw_ostream & llvm::operator<< (raw_ostream &OS, const ScaledNumber< DigitsT > &X)
 

Variables

const int32_t llvm::ScaledNumbers::MaxScale = 16383
 Maximum scale; same as APFloat for easy debug printing. More...
 
const int32_t llvm::ScaledNumbers::MinScale = -16382
 Maximum scale; same as APFloat for easy debug printing. More...
 

Macro Definition Documentation

◆ SCALED_NUMBER_BOP

#define SCALED_NUMBER_BOP (   op,
  base 
)
Value:
template <class DigitsT> \
ScaledNumber<DigitsT> operator op(const ScaledNumber<DigitsT> &L, \
const ScaledNumber<DigitsT> &R) { \
return ScaledNumber<DigitsT>(L) base R; \
}
#define op(i)

Definition at line 718 of file ScaledNumber.h.

◆ SCALED_NUMBER_COMPARE_TO

#define SCALED_NUMBER_COMPARE_TO (   op)
Value:
SCALED_NUMBER_COMPARE_TO_TYPE(op, uint64_t, uint64_t) \
SCALED_NUMBER_COMPARE_TO_TYPE(op, uint32_t, uint64_t) \
SCALED_NUMBER_COMPARE_TO_TYPE(op, int64_t, int64_t) \
SCALED_NUMBER_COMPARE_TO_TYPE(op, int32_t, int64_t)
#define op(i)
#define SCALED_NUMBER_COMPARE_TO_TYPE(op, T1, T2)
Definition: ScaledNumber.h:747

Definition at line 756 of file ScaledNumber.h.

◆ SCALED_NUMBER_COMPARE_TO_TYPE

#define SCALED_NUMBER_COMPARE_TO_TYPE (   op,
  T1,
  T2 
)
Value:
template <class DigitsT> \
bool operator op(const ScaledNumber<DigitsT> &L, T1 R) { \
return L.compareTo(T2(R)) op 0; \
} \
template <class DigitsT> \
bool operator op(T1 L, const ScaledNumber<DigitsT> &R) { \
return 0 op R.compareTo(T2(L)); \
}
#define op(i)
#define T1

Definition at line 747 of file ScaledNumber.h.