<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, May 17, 2015 at 9:39 PM, Alexander Poddey <span dir="ltr"><<a href="mailto:alexander.poddey@gmx.net" target="_blank">alexander.poddey@gmx.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
getInitializer returns the complete initializer of the global.<br>
My globals are complex nested structs, from which I want to extract e.g. one<br>
double datafield.<br>
<br>
Example:<br>
>From a struct Stuct having double,array(3xint),float fields, I could extract<br>
the second int value using the index sequence 0,1,1 with getGetElementPtr.<br>
This gives me a constantPointer, but I would need to get a constInt...<br></blockquote><div><br>You want a global with the same value - or a global that points into the subobject in the original global? If you want a separate global, I guess you'd need to walk the constant yourself rather than using GEP.<br><br>- David<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Alex<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
David Blaikie wrote:<br>
<br>
> On Sat, May 16, 2015 at 10:28 PM, Alexander Poddey<br>
> <<a href="mailto:alexander.poddey@gmx.net">alexander.poddey@gmx.net</a><br>
>> wrote:<br>
><br>
>> Hi all,<br>
>><br>
>> I can get access to the data stored in globals as follows:<br>
>><br>
>> GlobalVariable* pGvarAct=_set_a_valid_global_;<br>
>> const_ptr_indicesVec=_the_indexes_<br>
>><br>
>> llvm::Constant* pConst;<br>
>> pConst=ConstantExpr::getGetElementPtr(pGvarAct, const_ptr_indicesVec);<br>
>><br>
>> and e.g. use this to repalece an argumrnt of an instruction like:<br>
>><br>
>> I->setOperand(someArgumentIndex,pConst);<br>
>><br>
>> However, getGetElementPtr returns a pointerType, which holds the actual<br>
>> type<br>
>> as sub_type.<br>
>> This is a problem when I want to use the data from one global for the<br>
>> initializer of another<br>
>><br>
>> pGvar->setInitializer(__NeedsAFloatTy_here__); //not pointerTy<br>
>><br>
>> So what I'm trying to do is copy some data-fields of one global to<br>
>> another. I know the 'index-trace' used in getGetElementPtr, but I need<br>
>> the actual type, not 'covered' by a pointerType.<br>
>><br>
><br>
> Perhaps you want getInitializer on the other GlobalVariable?<br>
><br>
><br>
>><br>
>><br>
>> Thank You!<br>
>> Alexander<br>
>><br>
>><br>
>> _______________________________________________<br>
>> LLVM Developers mailing list<br>
>> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
>><br>
<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</div></div></blockquote></div><br></div></div>