LLVM floating point rounding modes

Hi,

I am not sure if this is the right mailing list to ask my question, if not, please refer me to the proper one.

Is there any support for rounding modes in LLVM floating point? I looked in the assembler reference manual, and it doesn't seem so. I am thinking about choosing LLVM as one of the backends for my programming language Babel-17 (www.babel-17.com). Babel-17 features interval arithmetic, which can be implemented sub-optimally without proper rounding modes, but it would be so much better and faster if rounding modes were provided. Are there any plans of introducing this in LLVM or of making any IEEE guarantees concerning floating point arithmetic?

Cheers,

Steven

Steven,

The LLVM IR does not specify the rounding mode. On X86/SSE, the rounding mode of FP operations is controlled by the mxcsr register. You can use the set/get mxcsr intrinsic to control it (declaration below). However, there is an old bug (#6393) which makes the LLVM scheduler schedule fp instructions past this call. To get around this bug you will have to place the 'stmxcsr' call in an external function, thus forcing a full barrier.

Cheers,
Nadav

Bug report:
http://llvm.org/bugs/show_bug.cgi?id=6393

Intrinsics:

declare void @llvm.x86.sse.stmxcsr(i32*) nounwind
declare void @llvm.x86.sse.ldmxcsr(i32*) nounwind