[LLVMdev] common type at compile time?
ret val
retval386 at gmail.com
Thu Oct 20 09:34:16 PDT 2011
I'm a bit confused. For the Type did you mean something like:
ArrayType *type = ArrayType::get(Type::getInt8PtrTy(M.getContext()), 4);
This does not work, it gives me ""Wrong type in array element
initializer" at runtime.
Also it doesn't look like ConstantExpr inherits ConstantArray, so I'm
not sure how I could use this instead.
Thanks
On Thu, Oct 20, 2011 at 12:04 PM, John Criswell <criswell at illinois.edu> wrote:
> 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