[llvm-dev] Get the address of ConstantDataArray

Alberto Barbaro via llvm-dev
Fri, 22 Nov 2019 07:01:31 -0000

Thanks a lot Sam,
I'll try to follow your suggestion and see if it works :)

Thanks again

On Thu, Nov 21, 2019, 13:36 Sam Elliott <selliott at lowrisc.org> wrote:

> Pointer arithmetic in LLVM is done using the getelementptr (GEP)
> instruction.
>
> There’s a document which explains them [1], but I found this tutorial [2]
> from EuroLLVM 2019 was the first resource to explain it in a way I
> understood.
>
> I hope this helps!
>
> Sam
>
> [1]: https://llvm.org/docs/GetElementPtr.html
> [2]: https://www.youtube.com/watch?v=m8G_S5LwlTo
>
> > On 20 Nov 2019, at 12:24 pm, Alberto Barbaro via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
> >
> > Hi all,
> > I have a global array declared as: table = internal constant [8 x [256
x
> i32]] ...
> >
> > At the moment I'm able to get the reference to table using
Constant*
> g_var = cast<GlobalVariable>(I.getOperand(0))->getInitializer(); (
please
> consider I to be a GetElementPtrInst object ).
> >
> > Now I would like to understand how to get the address of table[2][3],
> for instance, considering that I have the g_var variable.
> >
> > In addition, I was able to access to the value table[2][3] so for me
> would be also OK to have the address of that specific value once I already
> have access to the value.
> >
> > Thanks
> > Alberto
> > _______________________________________________
> > LLVM Developers mailing list
> > llvm-dev at lists.llvm.org
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
> --
> Sam Elliott
> Software Developer - LLVM
> lowRISC CIC
> --
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20191122/55190b23/attachment.html>