[LLVMdev] hard values in SequentialType::indexValid () method

Chris Lattner clattner at apple.com
Mon Aug 18 16:32:57 PDT 2008


On Aug 18, 2008, at 4:20 PM, Alireza.Moshtaghi at microchip.com wrote:

> This method is defined in:
> Lib/VMCore/Type.cpp
> And it makes hard assumption that size of integer is 32 or 64.
> This gives us trouble because we have 16 bit integer.
> Is there a reason for this assumption? Or we can just add the 16-bit
> integer to it as well?

Hi Alireza,

The reason for this is that the getelementptr instruction is spec'd to  
take either an i32 or i64.  We could extend this, but it probably  
won't make a difference in practice.  If the front-end generates code  
like:


%tmp = sext i16 %idx to i32
%tmp2 = getelementptr float* %P, i32 %tmp

Then the llvm code generator will squish the sign extension etc when  
it lowers GEP to pointer arithmetic.

-Chris



More information about the llvm-dev mailing list