[LLVMdev] How do downcast signed integers?
Anton Korobeynikov
anton at korobeynikov.info
Sun Nov 24 21:57:02 PST 2013
Hello
> I was looking at "trunc" to downcast a signed integer, say sint32 to sint16,
> but it seems to handle unsigned integers only.
No. In twos-complement notation (which LLVM assumes) there no
difference between signed and unsigned truncation - you just throw out
the spare sign bits and that's all.
Please note that that the "numbers" in LLVM IR is neither signed nor
unsigned. They are just raw bits. It's up to the instruction in
question how to interpret them. I'd suggest to clearly outline this in
the document, since this is the important point.
--
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University
More information about the llvm-dev
mailing list