[PATCH] D33310: [APInt] Add support for dividing or remainder by a uint64_t or int64_t.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 17 23:26:13 PDT 2017


craig.topper created this revision.

This patch adds udiv/sdiv/urem/srem/udivrem/sdivrem methods that can divide by a uint64_t. This makes division consistent with all the other arithmetic operations.

This modifies the interface of the divide helper method to work on raw arrays instead of APInts. This way we can pass the uint64_t in for the RHS without wrapping it in an APInt. This required moving all the Quotient and Remainder allocation handling up to the callers. For udiv/urem this was as simple as just creating the Quotient/Remainder with the right size when they were declared. For udivrem we have to rely on reallocate not changing the contents of the variable LHS or RHS is aliased with the Quotient or Remainder APInts. We also have to zero the upper bits of Remainder and Quotient that divide doesn't write to if lhsWords/rhsWords is smaller than the width.

I've update the toString method to use the new udivrem.


https://reviews.llvm.org/D33310

Files:
  include/llvm/ADT/APInt.h
  lib/Support/APInt.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33310.99398.patch
Type: text/x-patch
Size: 13545 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170518/c761624a/attachment.bin>


More information about the llvm-commits mailing list