[LLVMdev] Operand, instruction

help__me_please krishnadhan at cse.iitb.ac.in
Thu Apr 22 09:54:54 PDT 2010


Thanks for the quick reply.
I am able to get the numerical value. But i also need the numerical value to
be in value type, so that it can be used as operand of other instruction.
For that i am trying to create a new ConstantInt, but i am unable to find
create() function for ConstantInt. 

Thanks again for the quick and helpful reply.

Ben Perry-3 wrote:
> 
> if (ConstantInt *c = (ConstantInt *) dyn_cast<ConstantInt>(index)){
>   errs() << "And it's a constant!!!!!!1111oneone!!  (" <<c->getZExtValue()
> << ")\n";
> }
> 
> --
> "Believe you can, believe you can't; either way you're right."  -Henry
> Ford
> 
> 
> -----Original Message-----
> From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On
> Behalf Of help__me_please
> Sent: Thursday, April 22, 2010 8:38 AM
> To: llvmdev at cs.uiuc.edu
> Subject: Re: [LLVMdev] Operand, instruction
> 
> 
> Hello, how to get the numerical value of an constant operand? For ex. %tmp
> =
> mul i32 %indvar, 6 , in this instruction second operand is a numerical
> constant with value 6. But i am only able to print it by using
> getOperand(1), not able to store it in any integer variable. Using
> getName()
> returns a empty string. Is there any way to solve this problem?
> Thank you. 
> 
> John Criswell-2 wrote:
>> 
>> help__me_please wrote:
>>> Can you please give an example of creating an instruction (for example
>>> add
>>> instructions with two operand a and b)? I am trying instruction() for a
>>> while, but no success yet.
>>>   
>> 
>> 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.
>> 
>> 
>> _______________________________________________
>> 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-tp21961718p28329007.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
> 
> 
> _______________________________________________
> 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-tp21961718p28331688.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.





More information about the llvm-dev mailing list