[LLVMdev] How to get more details from storeInst ?
liucheng at eee.hku.hk
Mon Jan 21 20:15:51 PST 2013
Dear Duancan Ciao,
Your suggestion is really helpful.
Thank you very much.
On 1/18/2013 5:04 PM, Duncan Sands [via LLVM] wrote:
> Hi Cheng,
> On 18/01/13 03:00, Cheng Liu wrote:
> > I have a loop fully unrolled and got the following store instruction.
> > store i32 %add.3, i32* getelementptr inbounds ([20 x [20 x i32]]*
> @c, i32 0,
> > i32 0, i32 0), align 4
> > I want to know exactly which element of the array that is going to be
> > stored, which help me to transform the high level language to
> hardware. Take
> > the instruction above as an example, I know the data is stored into
> > It is just that I don't how to get c, 0, 0 from the instruction.
> this bit
> i32* getelementptr inbounds ([20 x [20 x i32]]* @c, i32 0, i32 0,
> i32 0)
> is a constant expression (ConstantExpr class), not an instruction (you
> tell because it is printed inline).
> If SI is your store instruction (with type StoreInst*) then using
> you get the stored to pointer. Call the result Ptr.
> You can cast that to a ConstantExpr* using
> This will assert if Ptr isn't a constant expression. You can use
> instead which will return null if it isn't a constant expression. At
> point you can rummage around inside the constant expression. It is
> simpler though to #include the Operator.h header, and cast Ptr to the
> GEPOperator class instead.
> Ciao, Duncan.
> > At the moment, I use the method getNumOperands() and getOperand( int
> i) to
> > check all the operands of the instruction. However, I can only get two
> > operands. One of them is the data %add.s, and the other is the
> pointer. The
> > pointer has no name and it is not a constant.
> Yes, it is a constant (Constant class).
> I couldn't move further into
> > the pointer to get the index of the element.
> > Anyone could give me some suggestions on this?
> > --
> > View this message in context:
> > Sent from the LLVM - Dev mailing list archive at Nabble.com.
> > _______________________________________________
> > LLVM Developers mailing list
> > [hidden email] </user/SendEmail.jtp?type=node&node=53853&i=0>
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
> LLVM Developers mailing list
> [hidden email] </user/SendEmail.jtp?type=node&node=53853&i=1>
> If you reply to this email, your message will be added to the
> discussion below:
> To unsubscribe from How to get more details from storeInst ?, click
Electrical and Electronic Engineering
The University of Hong Kong
View this message in context: http://llvm.1065342.n5.nabble.com/How-to-get-more-details-from-storeInst-tp53841p54002.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev