[SparcV9] For codegen generated library calls that return float, set inreg flag manua...
authorVenkatraman Govindaraju <venkatra@cs.wisc.edu>
Sun, 29 Dec 2013 04:27:21 +0000 (04:27 +0000)
committerVenkatraman Govindaraju <venkatra@cs.wisc.edu>
Sun, 29 Dec 2013 04:27:21 +0000 (04:27 +0000)
 This makes the sparc backend to generate Sparc64 ABI compliant code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198149 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/Sparc/SparcISelLowering.cpp
test/CodeGen/SPARC/64abi.ll

index b794f8702bef1dc05f9b1817dc7f2a1732661936..a1137f7ec3ea36afe4bc458d6997af0aa6f0b5d3 100644 (file)
@@ -1252,6 +1252,12 @@ SparcTargetLowering::LowerCall_64(TargetLowering::CallLoweringInfo &CLI,
   SmallVector<CCValAssign, 16> RVLocs;
   CCState RVInfo(CLI.CallConv, CLI.IsVarArg, DAG.getMachineFunction(),
                  DAG.getTarget(), RVLocs, *DAG.getContext());
+
+  // Set inreg flag manually for codegen generated library calls that
+  // return float.
+  if (CLI.Ins.size() == 1 && CLI.Ins[0].VT == MVT::f32 && CLI.CS == 0)
+    CLI.Ins[0].Flags.setInReg();
+
   RVInfo.AnalyzeCallResult(CLI.Ins, CC_Sparc64);
 
   // Copy all of the result registers out of their specified physreg.
index fbafabcaa8887f2aa574692ef583b0e39659c33a..7f9d216e52e6eaf21d54a479a6da9499db5eff8c 100644 (file)
@@ -440,4 +440,25 @@ entry:
   ret i64 %0
 }
 
+; CHECK-LABEL: test_call_libfunc
+; CHECK:       st %f1, [%fp+[[Offset0:[0-9]+]]]
+; CHECK:       fmovs %f3, %f1
+; CHECK:       call cosf
+; CHECK:       st %f0, [%fp+[[Offset1:[0-9]+]]]
+; CHECK:       ld [%fp+[[Offset0]]], %f1
+; CHECK:       call sinf
+; CHECK:       ld [%fp+[[Offset1]]], %f1
+; CHECK:       fmuls %f1, %f0, %f0
+
+define inreg float @test_call_libfunc(float %arg0, float %arg1) {
+entry:
+  %0 = tail call inreg float @cosf(float %arg1)
+  %1 = tail call inreg float @sinf(float %arg0)
+  %2 = fmul float %0, %1
+  ret float %2
+}
+
+declare inreg float @cosf(float %arg) readnone nounwind
+declare inreg float @sinf(float %arg) readnone nounwind
+