Can anyone tell how to get the result name or instruction name of all instruction? For example if the instruction is "x=add y,z", here i need "x". Using getName(), i am getting some instructions result name, but llvm produces some instruction like "%0=add i32 tmp, 1", here getName() shows empty string as result name. So please help. John Criswell wrote:> > Nipun Arora wrote: >> Hi, >> >> How can one extract the operand of an instruction in an LLVM pass? >> Like I can get the opcode bt I'd like to get the operands as well >> > Use the getOperand() method of class Instruction (which I think is > inherited from Value or User or some other LLVM class). It takes a > single parameter that is an index specifying which operand to return. > The return value is a llvm::Value *, IIRC. > > If you haven't used it yet, I'd recommend using the LLVM doxygen > documentation (http://llvm.org/doxygen/hierarchy.html). I've found it > to be an invaluable resource for answering these sorts of questions. In > this case, just look up the llvm::Instruction class and see if it has a > method that does what you want. If it doesn't, check its parent class, > the grandparent class, etc. until you find the method you want. > > -- John T. > >> Thanks >> Nipun >> >> > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-- View this message in context: http://old.nabble.com/Operand%2C-instruction-tp21961718p28042767.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
Hi,> Can anyone tell how to get the result name or instruction name of all > instruction? For example if the instruction is "x=add y,z", here i need "x". > Using getName(), i am getting some instructions result name, but llvm > produces some instruction like "%0=add i32 tmp, 1", here getName() shows > empty string as result name. > So please help.as you have noticed, names are optional: instructions may not have names. That said, you can give names to all instructions by running the instnamer pass. Ciao, Duncan.
On Fri, Mar 26, 2010 at 6:53 AM, help__me_please <krishnadhan at cse.iitb.ac.in> wrote:> > Can anyone tell how to get the result name or instruction name of all > instruction? For example if the instruction is "x=add y,z", here i need "x". > Using getName(), i am getting some instructions result name, but llvm > produces some instruction like "%0=add i32 tmp, 1", here getName() shows > empty string as result name. > So please help. >Instruction names are optional and not reliable. Why do you need a name ? You can use use_iterator to find instruction's uses. - Devang
Actually i have to implement strength reduction, for that i have to first detect induction variables using ALLEN-COCKE-KENNEDY algorithm. To find out induction variables, i need the name of the instruction. Thanks for the reply. Devang Patel-2 wrote:> > On Fri, Mar 26, 2010 at 6:53 AM, help__me_please > <krishnadhan at cse.iitb.ac.in> wrote: >> >> Can anyone tell how to get the result name or instruction name of all >> instruction? For example if the instruction is "x=add y,z", here i need >> "x". >> Using getName(), i am getting some instructions result name, but llvm >> produces some instruction like "%0=add i32 tmp, 1", here getName() shows >> empty string as result name. >> So please help. >> > > Instruction names are optional and not reliable. Why do you need a > name ? You can use use_iterator to find instruction's uses. > - > Devang > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-- View this message in context: http://old.nabble.com/Operand%2C-instruction-tp21961718p28064581.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
Thanks for the reply. My problem is solved. Thanks once again. Duncan Sands wrote:> > Hi, > >> Can anyone tell how to get the result name or instruction name of all >> instruction? For example if the instruction is "x=add y,z", here i need >> "x". >> Using getName(), i am getting some instructions result name, but llvm >> produces some instruction like "%0=add i32 tmp, 1", here getName() shows >> empty string as result name. >> So please help. > > as you have noticed, names are optional: instructions may not have names. > That said, you can give names to all instructions by running the instnamer > pass. > > Ciao, > > Duncan. > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-- View this message in context: http://old.nabble.com/Operand%2C-instruction-tp21961718p28064599.html Sent from the LLVM - Dev mailing list archive at Nabble.com.