Operand, instruction

Hi Ben,

if (ConstantInt *c = (ConstantInt *) dyn_cast<ConstantInt>(index)){
   errs()<< "And it's a constant!!!!!!1111oneone!! ("<<c->getZExtValue()
<< ")\n";
}

I don't think you need the "(ConstantInt *)" cast. The getZExtValue will fail
if the constant doesn't fit in 64 bits.

Ciao,

Duncan.

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:

help__me_please wrote:

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.
  
There is no need to do that. If you look at the inheritance hierarchy in doxygen, ConstantInt inherits (indirectly) from Value. You can use a ConstantInt in any place where a Value can be used.

-- John T.

Thanks again for your reply.
You are right. But i am looking to change the value of that constant value
and use that as operand in other instruction. For example there is one
constant operand with value 6, i will multiply it with 2, and then use 12 as
operand in other instruction. So i need to convert 12 to value class and
then i will be able to set it as operand.
Hope i am clear now.
Thanks.

John Criswell-2 wrote:

Thanks again for your reply.
You are right. But i am looking to change the value of that constant value
and use that as operand in other instruction. For example there is one
constant operand with value 6, i will multiply it with 2, and then use 12 as
operand in other instruction. So i need to convert 12 to value class and
then i will be able to set it as operand.
Hope i am clear now.
Thanks.

I think you're looking for ConstantInt::get; the naming is a bit
different from instructions because constants values are reused.

-Eli