[LLVMdev] Adding multiples-of-8 integer types to MVT

Duncan Sands
Sat, 05 Dec 2009 12:33:38 -0000

>> Would there be any interest/opposition to extending the set of simple
>> integer types in MVT to include the missing multiples of 8 (up to 64
>> bits)? That is: i24, i40, i48, i56?

By the way, the integer type legalization logic should probably go like
this: let T be an integer type.

(1) If T is legal, do nothing.
(2) If there is a legal integer type which is bigger (in bitwidth) than T,
then promote T to the smallest legal type which is bigger than T.
(3) In the remaining case, T is necessarily bigger than the largest legal
integer type (call this type L).  Take the smallest positive N such that
  (bitwidth of T) <= (bitwidth of L) * 2^N
If you have equality in the equation, i.e. if the bitwidth of T is a power
of two multiple of the bitwidth of L, then expand T into two equal integer
types of half the size.  Otherwise promote T to the type with bitwidth equal
to the right-hand-side of the equation, i.e. (bitwidth of L) * 2^N.

If all legal integer types have a power of two size, then this coincides
with what we have today.  If some legal types do not have a power of 2
size then finding the type to promote to in (2) requires more computation
than in the power-of-two case.  For (3), you need to know the largest legal
type L, which currently isn't exposed in a convenient way for this.  For
simple integer types everything can of course be pre-calculated in tables,
like now.  For extended integer types it would be good to have an efficient
algorithm for calculating this on the fly.  At worst, values can be cached.

Ciao,

Duncan.