[LLVMdev] Support for Soft-float

Renato Golin renato.golin at linaro.org
Mon Sep 29 04:06:43 PDT 2014


On 24 September 2014 07:02, Eric Cheng <eccheng at stanford.edu> wrote:
> Running "clang -c -emit-llvm -msoft-float test.c -o test.bc" doesn't
> generate IR with soft-float library calls (perhaps understandably) - only
> hard float instructions. I would expect the frontend to at least be able to
> generate the library calls even though I'm not asking it to link to any
> library yet.

Hi Eric,

If you mean "IR floating point instructions", than this is correct.
The front-end doesn't know what the back-end is capable of (hard
multiply, divide etc), so it emits "fp instructions" and the back-end
will then generate the correct call/instruction for each separate
case.


> Running "llc -march=sparc -soft-float test.bc -o test.s" next still does not
> replace the hard float instructions with soft-float calls. Is this a known
> issue, am I doing something wrong, etc.?

Maybe the Sparc back-end is not able (or willing) to transform the
instructions into library calls. The ARM back-end certainly does.


> Is there a reason many of the backend targets will not generate the library
> call? Is there some way to fix this?

It may be that they never found it relevant? Or that your options is
not correctly propagated (as Asiri commented).

Looking at X86ISelLowering.cpp, there aren't that many calls to
setLibcallName(), which there are zillions for ARM. The Sparc back-end
has more than the X86, but mostly to round numbers and convert from FP
to Int and vice-versa, so I doubt it'll ever call a library function
to multiply or divide floating points.

If that's the only problem, the way to fix this is to repeat the
pattern in the ARM back-end, and add *all* library call hooks and make
sure they're called when -msoft-float is specified. Also, if you do
so, please add as many tests as necessary to make sure both soft and
hard float are covered correctly.

cheers,
--renato



More information about the llvm-dev mailing list