[LLVMdev] C API: LLVMBuildIntCast for unsigned integers

Manuel Jacob me at manueljacob.de
Sun Mar 2 08:37:27 PST 2014


Hi,

I noticed that LLVMBuildIntCast is only defined for signed integers, 
while the underlying CastInst::CreateIntegerCast accepts an "isSigned" 
argument.  I'm currently working on a language binding for the LLVM C 
API and would like to provide an unsigned version for completeness.  I 
can think of two ways to add this feature (I hope the definitions don't 
get mangled by my mail client):

1) Adding an isSigned parameter, breaking API compatibility:
LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, 
LLVMTypeRef DestTy, LLVMBool isSigned, const char *Name);

2) Adding a new function LLVMBuildUnsignedIntCast:
LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, 
LLVMTypeRef DestTy, const char *Name);
LLVMValueRef LLVMBuildUnsignedIntCast(LLVMBuilderRef, LLVMValueRef Val, 
LLVMTypeRef DestTy, const char *Name);

While I like the first version more, I see that it might be desirable to 
preserve API compatibility.

-Manuel



More information about the llvm-dev mailing list