[cfe-dev] RFC for Arbitrary Precision Integers-

Dan Liew via cfe-dev cfe-dev at lists.llvm.org
Thu Mar 14 08:54:29 PDT 2019


Hi Keane,

On Thu, 7 Mar 2019 at 20:33, Keane, Erich via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
>
> Hi all, I’ve just uploaded a review here: https://reviews.llvm.org/D59105
>
>
>
> A little more than a year ago, I created an arbitrary precision integer for an internal customer, and have now been cleared to release this to community.  I’m hoping that this will be sufficiently interesting to others to be of value.

Nice. This is something I've been thinking about for a while but I was
thinking about doing this a runtime in compiler-rt. The use case I was
thinking of was more to do with representing path conditions for use
in LibFuzzer using constraints in the SMT-LIB language (includes
"BitVectors" which are basically arbitrary width integers).

I have a partial implementation (for 64-bit or less) that implements
the SMT-LIB standard here:
https://github.com/delcypher/jfs/blob/master/runtime/SMTLIB/SMTLIB/NativeBitVector.h
I never got around to extending it to the more general case of wider
than 64-bits or wider. My plan was to do some tricks with tagged
pointers (i.e. tag a pointer to represent small constants inside the
pointer itself, for larger constants malloc memory to represent the
cosntant) but unfortunately I never got around to it.

>
>
> The “elevator pitch” is that we expose the iN LLVM-IR integer types in Clang such that a sufficiently motivated code generator could take advantage of the smaller sizes.  This is particularly useful for FPGAs, though I’d imagine other users are around.
>

The approach I mention might work if you have highly optimized
versions of the bitvector functions that I sketched above, for your
platform. Of course there's the cost of the function call for every
operation, so perhaps that's to high a cost for your use case.

Something to think about anyway.

HTH,
Dan.



More information about the cfe-dev mailing list