getOperand(i). See Instruction.h and User.h
-
Devang
_______________________________________________
LLVM Developers mailing list
LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
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
--
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.
> 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.
Instruction names are optional and not reliable. Why do you need a
name ? You can use use_iterator to find instruction's uses.
-
Devang
--
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.
_______________________________________________
--
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.
_______________________________________________
> 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.
I suspect you are confused. Surely you only need a way of referring to each
instruction. For this you can use a pointer to the instruction.
Ciao,
Duncan.
--
View this message in context: http://old.nabble.com/Operand%2C-instruction-tp21961718p28087559.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.
_______________________________________________
Instead of a basic block function call....You might want to use a module
function call...then iterate through functions and then iterate through
basic blocks...
Hope this helped.
Best Regards
Arvind
------------------------------------------------------------------------
------------
Arvind Sudarsanam Phone: (435) 512-7769
CPU Technology, Inc Fax: (866) 848-5599
1500 Kansas Ave, Suite 3E
Longmont, CO 80501
--
View this message in context: http://old.nabble.com/Operand%2C-instruction-tp21961718p28235150.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.
_______________________________________________
You need to look for the appropriate subclass of llvm::Instruction and
find the method for creating a new instruction. The method is usually a
static method and takes arguments pointing to the values to use as
operands. Doxygen is your best resource for finding these methods.
For example, if you look at
http://llvm.org/doxygen/classllvm_1_1AllocaInst.html, you can see that
the AllocaInst class (which represents an alloca instruction) has a
standard constructor method that takes the type of object to allocate,
the name of the new alloca instruction, an instruction before which to
insert the alloca instruction, etc.
As another example, the CallInst class
(http://llvm.org/doxygen/classllvm_1_1CallInst.html) represents a call
instruction and has a static Create() method that you can use to create
a new call instruction.
-- John T.
I used function instruction(), which gives me error "error: cannot allocate
an object of abstract type ‘llvm::Instruction’" and also "Instruction.h:28:
note: because the following virtual functions are pure within
‘llvm::Instruction’:", "Instruction.h:50: note: virtual llvm::Instruction*
llvm::Instruction::clone(llvm::LLVMContext&) const"
Also i have used BinaryOperator::create(), but it gives error that there is
no function called create().
Thanks again for your reply.
--
View this message in context: http://old.nabble.com/Operand%2C-instruction-tp21961718p28238512.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.
An add or sub should be a BinaryOperator, if memory serves me
correctly. Looking at mainline doxygen, there's a whole bunch of
CreateNSWAdd, CreateNSWMul, etc. methods. It's one of those that you want.
-- John T.
> Also i have used BinaryOperator::create(), but it gives error that there is
Nick
--
View this message in context: http://old.nabble.com/Operand%2C-instruction-tp21961718p28239236.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.
--
View this message in context: http://old.nabble.com/Operand%2C-instruction-tp21961718p28239244.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.