[LLVMdev] How to get the indices in an getelementptr Value?

Qiuping Yi yiqiuping at gmail.com
Sat Nov 22 01:10:45 PST 2014


Hi Michael,

Thank you very much.

But idx_begin/idx_end iterators can only be used through a getelementptr
instruction, right? However, I think value "i32* getelementptr inbounds
(%struct.Args* @globalArg, i64 0, i32 2)" itself is not a getelementptr
instruction, so? Or could you tell me how can I get a getelementptr
instruction first from this value?


--------------------------------------------
Qiuping Yi
Institute Of Software
Chinese Academy of Sciences

On Sat, Nov 22, 2014 at 4:49 PM, Michael Zolotukhin <mzolotukhin at apple.com>
wrote:

> Hi Qiuping,
>
> I guess you need to use getPointerOperand to access the pointer operand
> (@globalArg in your example) and idx_begin/idx_end iterators to access
> indexes. You can find a short description of these functions in
> documentation [1], or look at examples of their uses in the code, e.g.
> in lib/Transforms/InstCombine/*.cpp.
>
> [1] http://llvm.org/doxygen/classllvm_1_1GetElementPtrInst.html
>
> Best regards,
> Michael
>
> On Nov 22, 2014, at 12:32 AM, Qiuping Yi <yiqiuping at gmail.com> wrote:
>
> Hi, all
>
> I am a LLVM user. I want to get every element in the next instruction:
>
> %0 = load i32* getelementptr inbounds (%struct.Args* @globalArg, i64 0,
> i32 2), align 4, !dbg !85, !clap !86
>
> Now I can only get value "i32* getelementptr inbounds (%struct.Args*
> @globalArg, i64 0, i32 2)" through "getOperand(0)",
> but I can not get "%struct.Args* @globalArg", "i64 0", and "i32 2" in this
> instruction.
>
> I know I can get the indices of getelementptr instructions through
> "getOperand()", but now in the previous example,
> I want to get the indices from a getlementptr value. How should I do?
> Thank you in advance.
>
>
> Best Regards!
>
> --------------------------------------------
> Qiuping Yi
> Institute Of Software
> Chinese Academy of Sciences
>  _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141122/aff62509/attachment.html>


More information about the llvm-dev mailing list