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 c[0][0].
It is just that I don't how to get c, 0, 0 from the instruction.
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. I couldn't move further into
the pointer to get the index of the element.
Anyone could give me some suggestions on this?
Hi Cheng,
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 c[0][0].
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 can
tell because it is printed inline).
If SI is your store instruction (with type StoreInst*) then using
SI->getPointerOperand()
you get the stored to pointer. Call the result Ptr.
You can cast that to a ConstantExpr* using
cast<ConstantExpr>(Ptr)
This will assert if Ptr isn't a constant expression. You can use dyn_cast
instead which will return null if it isn't a constant expression. At this
point you can rummage around inside the constant expression. It is probably
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
View this message in context: Sent from the at Nabble.com.