RFC for Arbitrary Precision Integers-

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.

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.

There are further details in the commit message, and I would love review input both from a high level perspective as well as a code review on this.

Thanks,
Erich

Dear Erich,

Hi! Thanks a lot for your sharing!!!

The arbitrary integer type you extended is exactly what I am trying to implement. However, the solution to dealing with the source code with arbitrary precision integer, which I am trying to implement at the IR level, is quite ugly, since I am new to Clang infrastructures.

Your extension is really helpful for people who deal with FPGAs and the source codes for High-Level Synthesis!!!

Best regards,

Hi Keane,

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.