Cheng Liu
2012-May-09 13:55 UTC
[LLVMdev] How can I get the destination operand of an instruction?
Sorry, I have typo in my question.
I will be careful next time.
This is how I obtain the source operands of an instruction.
// -----------------------------------------------------------------
BasicBlock::iterator it;
...
for(int k=0; k<OpNum; k++){
errs()<<it->getOperand(k)<<" ";
}
...
// --------------------------------------------------------------------
Also I try
it->getVaueID(), and it->InstructionVal
to get destination operand.
They don't work and I know what they return now ).
<ofv at wanadoo.es>(My computer can't display your name correctly, and
I am
sorry for this.) is right,
getOperand() actually returns Value*. The reason that I see string like
'0x9063489' is that I print it using
'errs()<<'. I notice that all the variables with different names
have
different strings like '0x9063489' and
I think I can use it to identify different variables as well as
instruction instances (I need this to extract data
dependence graph/data flow graph from each basicblcok). I guess there
may be operator<< overload
in value.h and I looked into the source code value.h, but I didn't find
it. I still do not know how to get
strings/number like '0x9063489' without using errs()<<.
As for destination operand or instruction, I need similar numbers or
strings to identify all the variables
and instruction instances. John gave a suggestion, but I am not sure
whether I got it right.
//----------------------------------------------------------------------------------------------
--In LLVM, the instruction *is* the same as it's result. Let us say
that instruction pointer I1 points to an add instruction and I2 points
to a subtract instruction. Then:
--I2->setOperand (I1, 1);
--will make instruction I1 the first operand of instruction I2 (note
that I didn't check the exact arguments of the setOperand() method, so
they may be off, but I think you get the --idea).
//----------------------------------------------------------------------------------------
Since I can get the representation (I mean the strings like 0x9063489 )
of all source operands, and I can trace back to get the instruction's
representation.
It seems a little bit wired for me because I am finding unique
representations for variables and instruction instances to determine the
instruction dependence.
In this case, now finding dependence turns to be a preliminary issue ).
--------------------------------------------------------------------
I think people may get confused about what I am talking. Just make it
short and clear.
For example, I have a few instructions in the same basic block.
instruction1: add %a %b %c
...
instruction10: add %e %d %a
Now I use this code to identify the source operands.
for(int k=0; k<OpNum; k++){
errs()<<it->getOperand(k)<<" ";
}
I find that
%b->0x90
%c->0x91
%d->0x92
%a->0x93
but I do not know
%a->?
%e->?
Actually I am expecting that %a->0x93, and then I can declare that
instruction10 depends instruction1.
On 5/9/2012 11:14 AM, =?utf-8?Q?=C3=93scar_Fuentes?=
wrote:> ::getValueID, don't you?
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20120509/19879381/attachment.html>
Duncan Sands
2012-May-09 14:38 UTC
[LLVMdev] How can I get the destination operand of an instruction?
Hi,> Sorry, I have typo in my question. > I will be careful next time. > > This is how I obtain the source operands of an instruction. > // ----------------------------------------------------------------- > BasicBlock::iterator it; > ... > for(int k=0; k<OpNum; k++){ > errs()<<it->getOperand(k)<<" ";try this: it->getOperand(k)->dump()> } > ... > // -------------------------------------------------------------------- > > Also I try > it->getVaueID(), and it->InstructionVal > to get destination operand.What do you mean by "destination operand"? Ciao, Duncan.
陳韋任
2012-May-09 14:51 UTC
[LLVMdev] How can I get the destination operand of an instruction?
> > Also I try > > it->getVaueID(), and it->InstructionVal > > to get destination operand. > > What do you mean by "destination operand"?I believe he mean the result, see http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-May/049603.html Regards, chenwj -- Wei-Ren Chen (陳韋任) Computer Systems Lab, Institute of Information Science, Academia Sinica, Taiwan (R.O.C.) Tel:886-2-2788-3799 #1667 Homepage: http://people.cs.nctu.edu.tw/~chenwj
Reasonably Related Threads
- [LLVMdev] How can I get the destination operand of an instruction?
- [LLVMdev] How can I get the destination operand of an instruction?
- [LLVMdev] How can I get the destination operand of an instruction?
- [LLVMdev] ValueTy not set appropriately in Value.h?
- [LLVMdev] patch for pointer-to-array conversion