[LLVMdev] Disabling x87 instructions for a sub-target

Benjamin Kramer
Wed, 04 Apr 2012 20:04:35 -0000

On 04.04.2012, at 21:45, Murali, Sriram wrote:

> Hello there,
> I recently started working on the LLVM backend for a target that doesn’t
support x87 instructions.
> Currently, I am in the process of completely disabling some x87
instructions such as fcomi, fcompi,… for a specific sub-target. I also do not
have SSE enabled for my sub-target, and llvm resorts to fcomi* instructions for
FP compare instructions.
>
> Is there a way to bypass the automatic optimization that generates the x87
instructions when SSE is disabled, and completely eliminate the code generation
for the same(error out)?

A simple trick without requiring code changes is forcing the code generator to
use soft fp (llc -soft-float). It will generate libcalls instead of x87
instructions for any floating point operations. The compile will then fail at
link time because libcompiler-rt/libgcc don't supply those function for x86.

- Ben