[LLVMdev] FPU cannot be compatible with -soft-float code on mips by llc

108 views
Skip to first unread message

刘亚龙

unread,
Jul 24, 2014, 9:36:16 PM7/24/14
to llv...@cs.uiuc.edu
Hi all,
    -soft-float can not be rightly use by llc. All float function operation will call soft float, but not hard.
    My mips device cannot support half float type, so I hack the llvm, and add soft half float and add -soft-float option.
    I add the function define for __gnu_f2h_ieee() and __gnu_h2f_ieee (), and it can call the soft half float.
    However, all the others function about float also call the soft float, how I do make only __gnu_f2h_ieee() use soft float, other use hard float???

    Thank you all !!

Cheers, 
    Robin

Jim Grosbach

unread,
Jul 25, 2014, 1:53:39 PM7/25/14
to 刘亚龙, llv...@cs.uiuc.edu
Hi Robin,

It sounds like you want to support half (f16 in LLVM terms) as a storage only interchange format. AArch64 and X86 (among others) do the same thing. You shouldn’t need the “-soft-float” option or anything of that nature at all. That, as you’ve found, disables all hard float operations. There’s been some recent cleanup in how this is handled in LLVM that should help guide you in what the Mips backend needs to do. In particular, Tim Northover’s recent patch, r213374.

Regards,
  Jim

_______________________________________________
LLVM Developers mailing list
LLV...@cs.uiuc.edu         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

Tim Northover

unread,
Jul 25, 2014, 2:20:54 PM7/25/14
to 刘亚龙, LLVM Developers Mailing List
On 25 July 2014 18:50, Jim Grosbach <gros...@apple.com> wrote:
> It sounds like you want to support half (f16 in LLVM terms) as a storage
> only interchange format. AArch64 and X86 (among others) do the same thing.
> You shouldn’t need the “-soft-float” option or anything of that nature at
> all. That, as you’ve found, disables all hard float operations. There’s been
> some recent cleanup in how this is handled in LLVM that should help guide
> you in what the Mips backend needs to do. In particular, Tim Northover’s
> recent patch, r213374.

As well as what's in that commit, you probably want to mark
ISD::FP16_TO_FP and ISD::FP_TO_FP16 as "Expand" in
MipsISelLowering.cpp. Then your implementations of "__gnu_..." should
be called for fp16 conversions, but not normal floating point
arithmetic.

Cheers.

Tim.

Robin Lau

unread,
Jul 27, 2014, 11:03:25 PM7/27/14
to Tim Northover, LLVM Developers Mailing List
Hi Tim,
   I already have done your words.  But I don't know how to only fp16, no others floating point.
 

 
Date: 2014-07-25 11:17
Subject: Re: [LLVMdev] FPU cannot be compatible with -soft-float code on mips by llc
On 25 July 2014 18:50, Jim Grosbach <gros...@apple.com> wrote:
> It sounds like you want to support half (f16 in LLVM terms) as a storage
> only interchange format. AArch64 and X86 (among others) do the same thing.
> You shouldn’t need the “-soft-float” option or anything of that nature at
> all. That, as you’ve found, disables all hard float operations. There’s been
> some recent cleanup in how this is handled in LLVM that should help guide
> you in what the Mips backend needs to do. In particular, Tim Northover’s
> recent patch, r213374.
 

刘亚龙

unread,
Jul 28, 2014, 4:23:32 AM7/28/14
to Jim Grosbach, llv...@cs.uiuc.edu
Hi Jim,
    X86 and ARM have the assembly instruction convert float to half/covert half to float, so they need not to call libcall, but MIPS have not.  So we must add -soft-float option. The terrible thing is all function will be using soft, not FPU (hard).

Cheers,
Robin


  
Date: 2014-07-25 10:50
CC: llvmdev
Subject: Re: [LLVMdev] FPU cannot be compatible with -soft-float code on mips by llc

Daniel Sanders

unread,
Jul 28, 2014, 5:16:36 AM7/28/14
to 刘亚龙, Jim Grosbach, llv...@cs.uiuc.edu

The –soft-float option won't be necessary once FP16_TO_FP and FP_TO_FP16 are set to 'Expand' as Tim suggested. This will cause LLVM to replace these nodes with a libcall while everything else continues to use the hardware support.

 

I believe you need to add these calls to MipsISelLowering.cpp:

setOperationAction(ISD::FP16_TO_FP, MVT::f32, Expand); // Conversion from half -> float

setOperationAction(ISD::FP_TO_FP16, MVT::f32, Expand); // Conversion from float -> half

setOperationAction(ISD::FP16_TO_FP, MVT::f64, Expand); // Conversion from half -> double

setOperationAction(ISD::FP_TO_FP16, MVT::f64, Expand); // Conversion from double -> half

Reply all
Reply to author
Forward
0 new messages