<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 29, 2014 at 2:57 PM, Eric Christopher <span dir="ltr"><<a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: echristo<br>
Date: Mon Sep 29 16:57:54 2014<br>
New Revision: 218632<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=218632&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=218632&view=rev</a><br>
Log:<br>
Add soft-float to the key for the subtarget lookup in the TargetMachine<br>
map, this makes sure that we can compile the same code for two different<br>
ABIs (hard and soft float) in the same module.<br></blockquote><div><br></div><div>Not sure I asked/gave the credit here - does this mean hard/soft float handling has transitioned to your new varying-subtarget infrastructure? (& the test demonstrates that it's not just a drop-in replacement for existing functionality, but addresses bugs in the previous implementation?) <br><br>Oh, I see, it was <span style="font-family:monospace">218492 - awesome. So that actually enabled per-function cpu feature attributes & such on MIPS? Very cool. (sounds like that change could've had at least one test that demonstrated the per-function attributes varying - your test change, while necessary for the tests to pass after the change (& thus, somewhat demonstrating the change in behavior) would now equally pass before your change, if I understand correctly - so not really testing to ensure we don't regress this behavior)<br><br>(do we get to delete any code that was handling this in other ways?)<br></span></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Update one testcase accordingly (and fix some confusing naming) and<br>
add a new testcase as well with the ordering swapped which would<br>
highlight the problem.<br>
<br>
Added:<br>
    llvm/trunk/test/CodeGen/Mips/mips16-hf-attr-2.ll<br>
      - copied, changed from r218631, llvm/trunk/test/CodeGen/Mips/mips16-hf-attr.ll<br>
Modified:<br>
    llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp<br>
    llvm/trunk/test/CodeGen/Mips/mips16-hf-attr.ll<br>
<br>
Modified: llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp?rev=218632&r1=218631&r2=218632&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp?rev=218632&r1=218631&r2=218632&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp (original)<br>
+++ llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp Mon Sep 29 16:57:54 2014<br>
@@ -105,12 +105,24 @@ MipsTargetMachine::getSubtargetImpl(cons<br>
       !FnAttrs.getAttribute(AttributeSet::FunctionIndex, "nomips16")<br>
            .hasAttribute(Attribute::None);<br>
<br>
+  // FIXME: This is related to the code below to reset the target options,<br>
+  // we need to know whether or not the soft float flag is set on the<br>
+  // function before we can generate a subtarget. We also need to use<br>
+  // it as a key for the subtarget since that can be the only difference<br>
+  // between two functions.<br>
+  Attribute SFAttr =<br>
+      FnAttrs.getAttribute(AttributeSet::FunctionIndex, "use-soft-float");<br>
+  bool softFloat = !SFAttr.hasAttribute(Attribute::None)<br>
+                       ? (SFAttr.getValueAsString() == "true" ? true : false)<br>
+                       : Options.UseSoftFloat;<br>
+<br>
   if (hasMips16Attr)<br>
     FS += FS.empty() ? "+mips16" : ",+mips16";<br>
   else if (hasNoMips16Attr)<br>
     FS += FS.empty() ? "-mips16" : ",-mips16";<br>
<br>
-  auto &I = SubtargetMap[CPU + FS];<br>
+  auto &I = SubtargetMap[CPU + FS + (softFloat ? "use-soft-float=true"<br>
+                                               : "use-soft-float=false")];<br>
   if (!I) {<br>
     // This needs to be done before we create a new subtarget since any<br>
     // creation will depend on the TM and the code generation flags on the<br>
<br>
Copied: llvm/trunk/test/CodeGen/Mips/mips16-hf-attr-2.ll (from r218631, llvm/trunk/test/CodeGen/Mips/mips16-hf-attr.ll)<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/mips16-hf-attr-2.ll?p2=llvm/trunk/test/CodeGen/Mips/mips16-hf-attr-2.ll&p1=llvm/trunk/test/CodeGen/Mips/mips16-hf-attr.ll&r1=218631&r2=218632&rev=218632&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/mips16-hf-attr-2.ll?p2=llvm/trunk/test/CodeGen/Mips/mips16-hf-attr-2.ll&p1=llvm/trunk/test/CodeGen/Mips/mips16-hf-attr.ll&r1=218631&r2=218632&rev=218632&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/CodeGen/Mips/mips16-hf-attr.ll (original)<br>
+++ llvm/trunk/test/CodeGen/Mips/mips16-hf-attr-2.ll Mon Sep 29 16:57:54 2014<br>
@@ -3,16 +3,16 @@<br>
 ; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel \<br>
 ; RUN:     -mcpu=mips16 -relocation-model=pic < %s | FileCheck %s<br>
<br>
-define void @bar_sf() #0 {<br>
+define void @bar_sf() #1 {<br>
 ; CHECK: bar_sf:<br>
 entry:<br>
   %call1 = call float @foo(float 1.000000e+00)<br>
-; CHECK: lw $2, %call16(foo)($3)<br>
-; CHECK: lw $5, %got(__mips16_call_stub_sf_1)($3)<br>
+; CHECK: lw $3, %call16(foo)($2)<br>
+; CHECK-NOT: lw $5, %got(__mips16_call_stub_sf_1)($3)<br>
   ret void<br>
 }<br>
<br>
-define void @bar_hf() #1 {<br>
+define void @bar_hf() #0 {<br>
 ; CHECK: bar_hf:<br>
 entry:<br>
   %call1 = call float @foo(float 1.000000e+00)<br>
<br>
Modified: llvm/trunk/test/CodeGen/Mips/mips16-hf-attr.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/mips16-hf-attr.ll?rev=218632&r1=218631&r2=218632&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/mips16-hf-attr.ll?rev=218632&r1=218631&r2=218632&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/CodeGen/Mips/mips16-hf-attr.ll (original)<br>
+++ llvm/trunk/test/CodeGen/Mips/mips16-hf-attr.ll Mon Sep 29 16:57:54 2014<br>
@@ -3,8 +3,8 @@<br>
 ; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel \<br>
 ; RUN:     -mcpu=mips16 -relocation-model=pic < %s | FileCheck %s<br>
<br>
-define void @bar_sf() #0 {<br>
-; CHECK: bar_sf:<br>
+define void @bar_hf() #0 {<br>
+; CHECK: bar_hf:<br>
 entry:<br>
   %call1 = call float @foo(float 1.000000e+00)<br>
 ; CHECK: lw $2, %call16(foo)($3)<br>
@@ -12,12 +12,12 @@ entry:<br>
   ret void<br>
 }<br>
<br>
-define void @bar_hf() #1 {<br>
-; CHECK: bar_hf:<br>
+define void @bar_sf() #1 {<br>
+; CHECK: bar_sf:<br>
 entry:<br>
   %call1 = call float @foo(float 1.000000e+00)<br>
-; CHECK: lw $2, %call16(foo)($3)<br>
-; CHECK: lw $5, %got(__mips16_call_stub_sf_1)($3)<br>
+; CHECK: lw $3, %call16(foo)($2)<br>
+; CHECK-NOT: lw $5, %got(__mips16_call_stub_sf_1)($3)<br>
   ret void<br>
 }<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>