[LLVMdev] How to create an IntegerType of the native word size

Duncan Sands baldrick at free.fr
Mon Jan 24 02:22:09 PST 2011


Hi Harel Cain,

> I couldn't find any reasonable way to create the IntegerType that would match,
> say, intptr_t, that is the native word size of the machine I'm building on. More
> accurately defined, when compiling on a 64 bit Mac OS machine I want it to be
> Int64Ty, but if for example I'm using the "-arch i386" command line option on
> that machine during compilation, I want it to be Int32Ty.
>
> I'm sure that has to be some perfect solution out there, does anyone know?

try the getIntPtrType method defined in TargetData.  It is defined in TargetData
because you need to know the target in order to know the size of a pointer.

Ciao, Duncan.



More information about the llvm-dev mailing list