Typecasting int32ty to int64ty

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Typecasting int32ty to int64ty

Abhinash Jain
I have something like this on my code :-

vector<Value*> args3;
args3.push_back(instr->getOperand(0)); //where 'instr' is store instruction

Now when I check the Type of instr->getOperand(0).
It varies to i32 and i64, depending on the operand(0) of instruction.
Due to which my vector<Value*> has different Type of Value*.

How can I convert i32 to i64 type before pushing it to the vector<Value*>, so that all Value* on my vector is of same Type?

Reply | Threaded
Open this post in threaded view
|

Re: Typecasting int32ty to int64ty

Tim Northover-2
> How can I convert i32 to i64 type before pushing it to the vector<Value*>,
> so that all Value* on my vector is of same Type?

You have to decide whether your i32s are signed or unsigned (should
0xffffffff give an i64 of -1 or 0xffffffff?). After that you can
insert an appropriate ZExt or SExt instruction into the basic block
and push its result onto your vector.

If inserting a sext/zext into the IR isn't appropriate then your only
option is to adapt your own code to deal with both i32 and i64 Values
being in that vector.

Cheers.

Tim.
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev