mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-26 07:29:55 +00:00
Support: Return ScaledNumbers::MaxScale from getQuotient()
Return MaxScale now that it's available. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211559 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
784bb5992a
commit
8e52bcc591
@ -148,7 +148,7 @@ std::pair<uint32_t, int16_t> divide32(uint32_t Dividend, uint32_t Divisor);
|
|||||||
///
|
///
|
||||||
/// Implemented with one 64-bit integer divide/remainder pair.
|
/// Implemented with one 64-bit integer divide/remainder pair.
|
||||||
///
|
///
|
||||||
/// Returns \c (DigitsT_MAX, INT16_MAX) for divide-by-zero (0 for 0/0).
|
/// Returns \c (DigitsT_MAX, MaxScale) for divide-by-zero (0 for 0/0).
|
||||||
template <class DigitsT>
|
template <class DigitsT>
|
||||||
std::pair<DigitsT, int16_t> getQuotient(DigitsT Dividend, DigitsT Divisor) {
|
std::pair<DigitsT, int16_t> getQuotient(DigitsT Dividend, DigitsT Divisor) {
|
||||||
static_assert(!std::numeric_limits<DigitsT>::is_signed, "expected unsigned");
|
static_assert(!std::numeric_limits<DigitsT>::is_signed, "expected unsigned");
|
||||||
@ -159,7 +159,7 @@ std::pair<DigitsT, int16_t> getQuotient(DigitsT Dividend, DigitsT Divisor) {
|
|||||||
if (!Dividend)
|
if (!Dividend)
|
||||||
return std::make_pair(0, 0);
|
return std::make_pair(0, 0);
|
||||||
if (!Divisor)
|
if (!Divisor)
|
||||||
return std::make_pair(std::numeric_limits<DigitsT>::max(), INT16_MAX);
|
return std::make_pair(std::numeric_limits<DigitsT>::max(), MaxScale);
|
||||||
|
|
||||||
if (getWidth<DigitsT>() == 64)
|
if (getWidth<DigitsT>() == 64)
|
||||||
return divide64(Dividend, Divisor);
|
return divide64(Dividend, Divisor);
|
||||||
|
@ -137,8 +137,8 @@ TEST(ScaledNumberHelpersTest, getQuotient) {
|
|||||||
EXPECT_EQ(SP32(0, 0), getQuotient32(0, 0));
|
EXPECT_EQ(SP32(0, 0), getQuotient32(0, 0));
|
||||||
EXPECT_EQ(SP32(0, 0), getQuotient32(0, 1));
|
EXPECT_EQ(SP32(0, 0), getQuotient32(0, 1));
|
||||||
EXPECT_EQ(SP32(0, 0), getQuotient32(0, 73));
|
EXPECT_EQ(SP32(0, 0), getQuotient32(0, 73));
|
||||||
EXPECT_EQ(SP32(UINT32_MAX, INT16_MAX), getQuotient32(1, 0));
|
EXPECT_EQ(SP32(UINT32_MAX, MaxScale), getQuotient32(1, 0));
|
||||||
EXPECT_EQ(SP32(UINT32_MAX, INT16_MAX), getQuotient32(6, 0));
|
EXPECT_EQ(SP32(UINT32_MAX, MaxScale), getQuotient32(6, 0));
|
||||||
|
|
||||||
// Powers of two.
|
// Powers of two.
|
||||||
EXPECT_EQ(SP32(1u << 31, -31), getQuotient32(1, 1));
|
EXPECT_EQ(SP32(1u << 31, -31), getQuotient32(1, 1));
|
||||||
@ -171,8 +171,8 @@ TEST(ScaledNumberHelpersTest, getQuotient) {
|
|||||||
EXPECT_EQ(SP64(0, 0), getQuotient64(0, 0));
|
EXPECT_EQ(SP64(0, 0), getQuotient64(0, 0));
|
||||||
EXPECT_EQ(SP64(0, 0), getQuotient64(0, 1));
|
EXPECT_EQ(SP64(0, 0), getQuotient64(0, 1));
|
||||||
EXPECT_EQ(SP64(0, 0), getQuotient64(0, 73));
|
EXPECT_EQ(SP64(0, 0), getQuotient64(0, 73));
|
||||||
EXPECT_EQ(SP64(UINT64_MAX, INT16_MAX), getQuotient64(1, 0));
|
EXPECT_EQ(SP64(UINT64_MAX, MaxScale), getQuotient64(1, 0));
|
||||||
EXPECT_EQ(SP64(UINT64_MAX, INT16_MAX), getQuotient64(6, 0));
|
EXPECT_EQ(SP64(UINT64_MAX, MaxScale), getQuotient64(6, 0));
|
||||||
|
|
||||||
// Powers of two.
|
// Powers of two.
|
||||||
EXPECT_EQ(SP64(1, 0), getQuotient64(1, 1));
|
EXPECT_EQ(SP64(1, 0), getQuotient64(1, 1));
|
||||||
|
Loading…
Reference in New Issue
Block a user