hi everyone, here i have a question: is there any chance in llvm intermediate representation to compare whether a operand (ie a value) is used as a user without iterating over all the instructions in a basic block. i will explain this with an example: i=p+4; j=i+p; in the above example i mean p,4,i,p which are on the RHS are operands and the terms i,j which are on the LHS are users. so what i mean is: is there any chance to find whether a value is used as an user whithin the instructions of a basic block without iterating over all the instructions and (variables in instructions) in that block. Anubham Suresh Measurement and Instrumentation Electrical Department IIT Roorkee Current location:Darmstadt, Germany mobile: +49-1762-3924878 __________________________________________________________ Yahoo! India Matrimony: Find your partner now. Go to http://yahoo.shaadi.com
On Wed, 2006-02-15 at 04:29, anubham suresh wrote:> hi everyone, > here i have a question: > is there any chance in llvm intermediate > representation to compare whether a operand (ie a > value) is used as a user without iterating over all > the instructions in a basic block. > i will explain this with an example: > i=p+4; > j=i+p; > > in the above example i mean p,4,i,p which are on the > RHS are operands and the terms i,j which are on the > LHS are users. > > so what i mean is: > is there any chance to find whether a value is used as > an user whithin the instructions of a basic block > without iterating over all the instructions and > (variables in instructions) in that block.You can iterate over the uses of a value by using the iterator returned by Value::use_begin. Then you simply check whether the use is an instruction and if so if the instruction's parent is the same parent as the value you are interested in. Andrew> > > > Anubham Suresh > Measurement and Instrumentation > Electrical Department > IIT Roorkee > Current location:Darmstadt, Germany > mobile: +49-1762-3924878 > > > > __________________________________________________________ > Yahoo! India Matrimony: Find your partner now. Go to http://yahoo.shaadi.com > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
On Wed, 15 Feb 2006, Andrew Lenharth wrote:> You can iterate over the uses of a value by using the iterator returned > by Value::use_begin. Then you simply check whether the use is an > instruction and if so if the instruction's parent is the same parent as > the value you are interested in.Andrew is right. Here are some more details: http://llvm.cs.uiuc.edu/docs/ProgrammersManual.html#iterate_chains The programmer's manual has a lot of good information: it's worth a skim for anyone working with LLVM that hasn't done so yet. -Chris -- http://nondot.org/sabre/ http://llvm.org/