[LLVMdev] Checked arithmetic

Jonathan S. Shapiro shap at eros-os.com
Tue Mar 25 20:25:16 PDT 2008


In looking at the LLVM reference manual, it is conspicuous that (a) the
IR does not define condition codes, and (b) the IR does not define
opcodes that return condition results in addition to their computational
results.

Given the IR as it stands, how does one go about *efficiently*
implementing a language that requires checked arithmetic? I do
understand that it can be done using intrinsics, but that implementation
is (to put it mildly) suboptimal.

For integer ops, I really want to be able to get at the carry/overflow
bit. For floating point ops, I really want to be able to get out the
floating point NaN state in order to exploit the NaN propagation
features provided by some hardware.

I'm sure this has been considered, but no means for dealing with this
sort of thing is jumping out at me from looking at the IR spec. What am
I missing?

Note: I can see at least two ways to deal with this by extending the IR,
but I would like to understand the current intentions first.


shap




More information about the llvm-dev mailing list