[llvm] r198019 - [Mips] Does not take in account 'use-soft-float' attribute's value when

reed kotler rkotler at mips.com
Mon Sep 29 14:52:10 PDT 2014


There is a useful hidden option for testing this dual 32/16 capability 
in the Mips code generator.

See MipsOS16.cpp

static cl::opt<std::string> Mips32FunctionMask(
   "mips32-function-mask",
   cl::init(""),
   cl::desc("Force function to be mips32"),
   cl::Hidden);

You can give it a bit mask (which is a repeatable pattern) and it will 
compile
functions as Mip32 or Mips16 depending on how the bit is set.

It's a little confusing but this Os16 was originally just an 
experimental pass I did one day
just to toy with the idea of having a Os16 compiler option for Mips 
which compiles
everything as Mips16 that can possibly be compiled that way without the 
need for emulation
libraries. So it will basically compile as Mips32 any functions that do 
any floating point.
Os16 means optimized for space using Mips16 whenever possible.

I adapted this experimental pass for testing purposes to beat up this 
ability to switch
compiling as Mips32/Mips16.

I have not used this is ages but basically for example, a function mask 
like "1011"

will compile function 1 as mips32, function 2 as mips16 and functions 
3,4 as Mips32

I think you have to enable MipsOS16 pass to make this work.

there is a little more to it than that and you can look at the code.

Reed

On 09/29/2014 02:29 PM, Eric Christopher wrote:
> On Mon, Sep 29, 2014 at 2:18 PM, reed kotler <rkotler at mips.com> wrote:
>> Hi Eric,
>>
>> It's been a while since I worked on Mips16 floating point.
>>
>> Be careful though because in LLVM target independent terms, Mips16 hard
>> float is still soft float;
>> the difference just being which version of the fp emulation library is being
>> used.
>>
> Yes, with the exception that the calling convention is soft float, but
> mips16 hard float can still use floating point operations in
> libraries.
>
>> When Mips16 hard float is on, there is a lot of difference though internally
>> to the Mips specific targe code.
>>
>> Be careful in this area too because it's very complicated and we have this
>> ability to switch between Mips16 and Mips32
>> in the same .c file and that was tricky for me to get to work within LLVM.
>>
> Yes. I'm fixing up some of those issues.
>
>> There is one test that is failing locally for us that started to fail around
>> the time when you were making changes
>> and it may be unrelated to that, but it's a test for this dual 32/16 mode
>> switching ability. I have been busy and
>> did not look at this failure yet because I did not know about it when it
>> first happened because we had some other
>> issues unrelated to that in our local build bots at exactly that moment that
>> masked the problem.
>>
> Likely the problem I'm fixing here. If you change the order of
> functions in the test suite for the test I have modified you'll see a
> failure.
>
>> This patch Simon made was to fix some problem we had in Mips16 build bots
>> for test-suite and I think it's correct
>> and for sure fixed the problem we were having. But I don't remember any of
>> the issues.
> I'm almost certain it's not correct, but may have successfully hidden
> the problem. I've also verified that with gcc and soft-float enabled
> the stub is not emitted.
>
> Since I've verified the behavior with gcc I'm going to go ahead and
> commit here. Let me know if you see any further problems.
>
> -eric
>
>> I will try and find some time later this week to really think about this and
>> remember the issues.
>>
>> Reed
>>
>>
>>
>>
>> On 09/29/2014 12:18 AM, Eric Christopher wrote:
>>> Hi Simon,
>>>
>>> Sorry for the thread necromancy here, but I don't think this patch is
>>> correct.
>>>
>>> a) It's a bit confusing that you have bar_hf for the function with
>>> use-soft-float set to true and vice versa for bar_sf, but
>>> b) As far as I can recall, the stubs are only used for calling hard
>>> float functions but the testcase currently tests that we emit it for
>>> both.
>>> c) The emission of the stubs should be dependent upon the subtarget
>>> and the value of the soft-float on the function (which would be the
>>> TM.Options.UseSoftFloat that is reset between each function, but only
>>> in SelectionDAG or the version in the function attributes).
>>>
>>> With the work I've been doing plus the attached patch we'll get this
>>> as far as I can tell correct for this - it's been a while since I've
>>> hacked on this aspect of mips.
>>>
>>> -eric
>>>
>>>
>>> On Wed, Dec 25, 2013 at 9:00 AM, Simon Atanasyan <simon at atanasyan.com>
>>> wrote:
>>>> Author: atanasyan
>>>> Date: Wed Dec 25 11:00:27 2013
>>>> New Revision: 198019
>>>>
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=198019&view=rev
>>>> Log:
>>>> [Mips] Does not take in account 'use-soft-float' attribute's value when
>>>> consider to generate stubs for mips16 hard-float mode.
>>>>
>>>> The patch reviewed by Reed Kotler.
>>>>
>>>> Added:
>>>>       llvm/trunk/test/CodeGen/Mips/mips16-hf-attr.ll
>>>> Modified:
>>>>       llvm/trunk/lib/Target/Mips/Mips16ISelLowering.cpp
>>>>
>>>> Modified: llvm/trunk/lib/Target/Mips/Mips16ISelLowering.cpp
>>>> URL:
>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/Mips16ISelLowering.cpp?rev=198019&r1=198018&r2=198019&view=diff
>>>>
>>>> ==============================================================================
>>>> --- llvm/trunk/lib/Target/Mips/Mips16ISelLowering.cpp (original)
>>>> +++ llvm/trunk/lib/Target/Mips/Mips16ISelLowering.cpp Wed Dec 25 11:00:27
>>>> 2013
>>>> @@ -429,8 +429,7 @@ getOpndList(SmallVectorImpl<SDValue> &Op
>>>>      const char* Mips16HelperFunction = 0;
>>>>      bool NeedMips16Helper = false;
>>>>
>>>> -  if (getTargetMachine().Options.UseSoftFloat &&
>>>> -      Subtarget->inMips16HardFloat()) {
>>>> +  if (Subtarget->inMips16HardFloat()) {
>>>>        //
>>>>        // currently we don't have symbols tagged with the mips16 or mips32
>>>>        // qualifier so we will assume that we don't know what kind it is.
>>>>
>>>> Added: llvm/trunk/test/CodeGen/Mips/mips16-hf-attr.ll
>>>> URL:
>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/mips16-hf-attr.ll?rev=198019&view=auto
>>>>
>>>> ==============================================================================
>>>> --- llvm/trunk/test/CodeGen/Mips/mips16-hf-attr.ll (added)
>>>> +++ llvm/trunk/test/CodeGen/Mips/mips16-hf-attr.ll Wed Dec 25 11:00:27
>>>> 2013
>>>> @@ -0,0 +1,45 @@
>>>> +; Check that stubs generation for mips16 hard-float mode does not depend
>>>> +; on the function 'use-soft-float' attribute's value.
>>>> +; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel \
>>>> +; RUN:     -mcpu=mips16 -relocation-model=pic < %s | FileCheck %s
>>>> +
>>>> +define void @bar_sf() #0 {
>>>> +; CHECK: bar_sf:
>>>> +entry:
>>>> +  %call1 = call float @foo(float 1.000000e+00)
>>>> +; CHECK: lw $2, %call16(foo)($3)
>>>> +; CHECK: lw $5, %got(__mips16_call_stub_sf_1)($3)
>>>> +  ret void
>>>> +}
>>>> +
>>>> +define void @bar_hf() #1 {
>>>> +; CHECK: bar_hf:
>>>> +entry:
>>>> +  %call1 = call float @foo(float 1.000000e+00)
>>>> +; CHECK: lw $2, %call16(foo)($3)
>>>> +; CHECK: lw $5, %got(__mips16_call_stub_sf_1)($3)
>>>> +  ret void
>>>> +}
>>>> +
>>>> +declare float @foo(float) #2
>>>> +
>>>> +attributes #0 = {
>>>> +  nounwind
>>>> +  "less-precise-fpmad"="false" "no-frame-pointer-elim"="true"
>>>> +  "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false"
>>>> +  "no-nans-fp-math"="false" "stack-protector-buffer-size"="8"
>>>> +  "unsafe-fp-math"="false" "use-soft-float"="false"
>>>> +}
>>>> +attributes #1 = {
>>>> +  nounwind
>>>> +  "less-precise-fpmad"="false" "no-frame-pointer-elim"="true"
>>>> +  "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false"
>>>> +  "no-nans-fp-math"="false" "stack-protector-buffer-size"="8"
>>>> +  "unsafe-fp-math"="false" "use-soft-float"="true"
>>>> +}
>>>> +attributes #2 = {
>>>> +  "less-precise-fpmad"="false" "no-frame-pointer-elim"="true"
>>>> +  "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false"
>>>> +  "no-nans-fp-math"="false" "stack-protector-buffer-size"="8"
>>>> +  "unsafe-fp-math"="false" "use-soft-float"="true"
>>>> +}
>>>>
>>>>
>>>> _______________________________________________
>>>> llvm-commits mailing list
>>>> llvm-commits at cs.uiuc.edu
>>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>




More information about the llvm-commits mailing list