Hi, Let say i am writing a code inside basic block pass and iterating all the instructions inside, and i encountered in this instruction : %3 = add i32 %1, 2 I want to convert this instruction to something like this: add R1, 2, R3 I know the opocode, but i what i need is, the operands %1 and 2 (in this example). I will be grateful if some one will tell me how to do so . -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090509/acfd0df2/attachment.html>
yes, thank you for your quick reply. On Sat, May 9, 2009 at 10:38 PM, John Criswell <criswell at uiuc.edu> wrote:> Rotem Varon wrote: > > Hi, > > > > Let say i am writing a code inside basic block pass and iterating all > > the instructions inside, > > and i encountered in this instruction : > If you're asking how to get the operands of an Instruction, use the > getOperand() method: > > Value * Operand1 = I->getOperand(0); > Value * Operand2 = I->getOperand(1); > > The LLVM doxygen documentation (http://llvm.org/doxygen/) is an > invaluable resource. You may also want to read the Programmer's Guide > (http://llvm.org/docs/ProgrammersManual.html). > > Does this answer your question? > > -- John T. > > > > > %3 = add i32 %1, 2 > > > > I want to convert this instruction to something like this: > > > > add R1, 2, R3 > > > > I know the opocode, but i what i need is, the operands %1 and 2 (in > > this example). > > > > I will be grateful if some one will tell me how to do so . > > _______________________________________________ > 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/20090509/63a0b703/attachment.html>
Rotem Varon wrote:> Hi, > > Let say i am writing a code inside basic block pass and iterating all > the instructions inside, > and i encountered in this instruction :If you're asking how to get the operands of an Instruction, use the getOperand() method: Value * Operand1 = I->getOperand(0); Value * Operand2 = I->getOperand(1); The LLVM doxygen documentation (http://llvm.org/doxygen/) is an invaluable resource. You may also want to read the Programmer's Guide (http://llvm.org/docs/ProgrammersManual.html). Does this answer your question? -- John T.> > %3 = add i32 %1, 2 > > I want to convert this instruction to something like this: > > add R1, 2, R3 > > I know the opocode, but i what i need is, the operands %1 and 2 (in > this example). > > I will be grateful if some one will tell me how to do so .