Taking the address of an array?

Hello,

I'm trying to write an annotation pass which will pass a C function a number of parameters including one of type [16 x i8*]. However, when I write the C function, this parameter type is compiled to type i8** because of the semantics of arrays in C. I think that to convert this parameter to i8**, I would need to take the address of the array. Is there any way I can do this? If not, is there any way for me to accomplish what I want here?

If anyone cares, the type [16 x i8*] is the type of a pool descriptor in PoolAlloc.

Thanks,
--Patrick

Patrick Simmons <simmon12@illinois.edu> writes:

[snip]

Is there any way I can do this? If not, is there any way for me to
accomplish what I want here?

http://www.llvm.org/docs/LangRef.html#i_getelementptr

I read this before posting; however, that article says that the first operand to this instruction must be a pointer type. The type I have is [16 x i8*], not [16 x i8*]*.

--Patrick

Óscar Fuentes wrote:

You can not take the address of anything that lives in a virtual
register. You must store it to memory through some pointer, and then
use that pointer (pass it to GEP, pass it to a C function, whatever).

alloca will allocate that memory for you in the function's local
stack. It will return a pointer - store the array through that
pointer, pass the pointer to GEP, then pass the resulting pointer to
the C function.

Patrick Alexander Simmons <simmon12@cs.uiuc.edu> writes:

I read this before posting; however, that article says that the first
operand to this instruction must be a pointer type. The type I have is
[16 x i8*], not [16 x i8*]*.

Sorry, I read your question too quickly. What you actually need is to
`alloca' space for the array, which will give you the [16 x i8*]*,
`store' your register there, and either `bitcast' the [16 x i8*]*
pointer to i8** or use `getelementptr'.