[LLVMdev] common type at compile time?

John Criswell criswell at illinois.edu
Thu Oct 20 09:04:00 PDT 2011

On 10/20/11 10:43 AM, ret val wrote:
> I'm trying to create a ConstantArray(whose contents will be of types
> Function*, GlobalVariable *) so I can immediately create a new
> GlobalVariable(that will be in its own section). I'm doing this so I
> have these address stored. In order to create this ConstantArray I
> need a valid ArrayType, but I'm not sure what to use for the element
> type.
> I want this to be done at compile time, so I cant use a BitCastInst to
> make them all generic pointers. What else can I do?

You can use a ConstantExpr (constant expression) for Function  and 
GlobalVariable objects.  The ArrayType can be an array of pointers to 
8-byte characters (basically a void pointer type).

-- John T.

> In other words
> * I built up a vector id like to eventually store as a GlobalVariable
> array: vector<Constant *>  v_elements;
> * Turned it into something for the ConstantArray::get can use:
> ArrayRef<Constant *>  a_elements(v_elements);
> * And now I need to come up with the ArrayType arg for the
> ConstantArray::get() method where I only know: ArrayType::get(???, 4);
> Thanks
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

More information about the llvm-dev mailing list