[LLVMdev] cast instruction
Nick Lewycky
nicholas at mxc.ca
Fri Feb 23 20:20:12 PST 2007
Ryan M. Lefever wrote:
> I need to create a cast instruction that casts an sbyte* to another
> pointer type.
A pointer to pointer cast is a bitcast.
Previously I was using the CastInst::createInferredCast()
> function to do that; however, that function has been removed. Which of
> the create() functions from CastInst should I use to do that?
new BitCastInst(SourcePtr, DestTy, InstToInsertBefore);
It seems
> like the obdvious answer should be createPointerCast(). However, the
> documentation for createPointerCast says, "Create a BitCast or a
> PtrToInt cast instruction," and I'm not wanting to cast a pointer to an int.
createPointerCast is for cases when the pass doesn't know in advance
(statically) whether the destination type is pointer or int. In your
case, you know that the result is a pointer, so you can use the direct
constructor.
Nick Lewycky
More information about the llvm-dev
mailing list