[cfe-dev] An unlimited-width integer type
Levi Aul via cfe-dev
cfe-dev at lists.llvm.org
Thu Nov 7 09:41:51 PST 2019
Hi, I'm considering writing an LLVM backend to target an abstract machine,
encoding to a bytecode ISA.
This abstract machine has integers, but not in the sense of having
fixed-size machine words; rather, each abstract-machine register and memory
location can losslessly hold onto a distinct (non-aliasing) unlimited
bit-width value, and math/bitwise ops will operate losslessly on these
values to produce new values of unlimited bit-width, without any need for
overflow into neighbouring registers/memory locations.
A VM implementing this abstract machine would, of course, use some kind of
bignum library to implement these semantics, with each such integer value
actually being a pointer to a VM-heap-allocated bignum; or, perhaps, the VM
would do load-time optimization to strength-reduce some of the bignums to
regular host-CPU integer types.
But, from the perspective of a compiler targeting the abstract machine
itself, the ISA just "has" registers and ops of an 'iUNLIMITED' type.
Does LLVM, and specifically the LLVM IR type system, support anything like
this? If not, would it be the work of days, or of months, to make it happen?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev