How can I get the name of the virtual Registers present on an instruction. eg. %add18 = add nsw i32 %mul17, %37 in this case I want to extract the name of the virutal registers as "add18", "mul17","37". This can easily be done in the case of store Instruction eg. store i32 %add20, i32* %t, align 4 in this case functions like instr->getOperand(0)->getName() and instr->getOperand(1)->getName() will fetch me "add20" and "t" respectively. But I want this for every Instruction, So How can I achieve this?? -- View this message in context: http://llvm.1065342.n5.nabble.com/Name-of-Virtual-Registers-tp62256.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
On 10/19/13 7:20 AM, Abhinash Jain wrote:> How can I get the name of the virtual Registers present on an instruction. > eg. %add18 = add nsw i32 %mul17, %37 > > in this case I want to extract the name of the virutal registers as "add18", > "mul17","37". > > This can easily be done in the case of store Instruction > eg. store i32 %add20, i32* %t, align 4 > > in this case functions like instr->getOperand(0)->getName() and > instr->getOperand(1)->getName() will fetch me "add20" and "t" respectively. > > But I want this for every Instruction, So How can I achieve this??First, be aware that an Instruction and the virtual register to which it is assigned are one and the same. So, for example, the add instruction and the %add18 register are, in fact, the same entity represented in memory as a single object of class Instruction. Second, to answer your question, you're wanting the name of the instruction and of every value that it uses. To get the name of the instruction, call its getName() method. For the instruction's operands, just iterate through the operands and call their getName() methods: for (unsigned index = 0; index < I->getNumOperands(); ++index) { I->getOperand(index)->getName(); } -- John T.> > > > > -- > View this message in context: http://llvm.1065342.n5.nabble.com/Name-of-Virtual-Registers-tp62256.html > Sent from the LLVM - Dev mailing list archive at Nabble.com. > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
On Sat, Oct 19, 2013 at 8:20 AM, Abhinash Jain <omnia at mailinator.com> wrote:> How can I get the name of the virtual Registers present on an instruction. > eg. %add18 = add nsw i32 %mul17, %37 > > in this case I want to extract the name of the virutal registers as > "add18", > "mul17","37". > > This can easily be done in the case of store Instruction > eg. store i32 %add20, i32* %t, align 4 > > in this case functions like instr->getOperand(0)->getName() and > instr->getOperand(1)->getName() will fetch me "add20" and "t" respectively. > > But I want this for every Instruction, So How can I achieve this?? >The number is not stored with the instruction. Only the name (see getName()). The number is computed when the module/function is printed and requires global information (since it depends on all the previous values in the function). See the class SlotTracker in lib/IR/AsmWriter.cpp. Also, see this: http://llvm.org/docs/FAQ.html#what-api-do-i-use-to-store-a-value-to-one-of-the-virtual-registers-in-llvm-ir-s-ssa-representation -- Sean Silva> > > > > -- > View this message in context: > http://llvm.1065342.n5.nabble.com/Name-of-Virtual-Registers-tp62256.html > Sent from the LLVM - Dev mailing list archive at Nabble.com. > _______________________________________________ > 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/20131019/3a6abb09/attachment.html>
Apparently Analagous Threads
- [LLVMdev] Trying to optimize out store/load pair
- [LLVMdev] Trying to optimize out store/load pair
- [LLVMdev] How to fix the operand references of cloned instruction
- Packet modification on Xen virutal Bridge
- [LLVMdev] Issue with Machine Verifier and earlyclobber