| 2813 | } |
| 2814 | |
| 2815 | APInt llvm::APIntOps::RoundingUDiv(const APInt &A, const APInt &B, |
| 2816 | APInt::Rounding RM) { |
| 2817 | // Currently udivrem always rounds down. |
| 2818 | switch (RM) { |
| 2819 | case APInt::Rounding::DOWN: |
| 2820 | case APInt::Rounding::TOWARD_ZERO: |
| 2821 | return A.udiv(B); |
| 2822 | case APInt::Rounding::UP: { |
| 2823 | APInt Quo, Rem; |
| 2824 | APInt::udivrem(A, B, Quo, Rem); |
| 2825 | if (Rem == 0) |
| 2826 | return Quo; |
| 2827 | return Quo + 1; |
| 2828 | } |
| 2829 | } |
| 2830 | llvm_unreachable("Unknown APInt::Rounding enum"); |
| 2831 | } |
| 2832 | |
| 2833 | APInt llvm::APIntOps::RoundingSDiv(const APInt &A, const APInt &B, |
| 2834 | APInt::Rounding RM) { |