[LLVMdev] Dereference PointerType?
Óscar Fuentes
ofv at wanadoo.es
Tue Oct 20 04:54:26 PDT 2009
Daniel Waterworth <da.waterworth at googlemail.com> writes:
> It may not be the best way to do what I'm trying to do, but it's not useless
> and bogus. Consider the following:
>
> %1 = alloca i32* ; %1 is of type i32**, dereferenced it becomes a type i32*
> and
> ; the size of that is sizeof(void *) bytes
What Duncan says is that any valid method for obtaining the size of a
Type should work for a PointerType, which is just another kind of Type.
>>>>> if (isa<PointerType>(allocated_type)) {
>>>>> size = sizeof(void*) * 8;
>>>>> } else {
>>>>> size = allocated_type->getPrimitiveSizeInBits();
>>>>> }
>>>>> // size now equals the size (in bits) of the type allocated
--
Óscar
More information about the llvm-dev
mailing list