add support for calling functions that return double

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30771 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2006-10-06 19:10:05 +00:00
parent 3cff9f8947
commit 614057b843
2 changed files with 26 additions and 11 deletions

View File

@ -308,14 +308,25 @@ static SDOperand LowerCALL(SDOperand Op, SelectionDAG &DAG) {
NodeTys.clear(); NodeTys.clear();
// If the call has results, copy the values out of the ret val registers. // If the call has results, copy the values out of the ret val registers.
switch (Op.Val->getValueType(0)) { MVT::ValueType VT = Op.Val->getValueType(0);
default: assert(0 && "Unexpected ret value!"); if (VT != MVT::Other) {
case MVT::Other: assert(VT == MVT::i32 || VT == MVT::f32 || VT == MVT::f64);
break; SDOperand Value;
case MVT::i32:
Chain = DAG.getCopyFromReg(Chain, ARM::R0, MVT::i32, InFlag).getValue(1); SDOperand Value1 = DAG.getCopyFromReg(Chain, ARM::R0, MVT::i32, InFlag);
ResultVals.push_back(Chain.getValue(0)); Chain = Value1.getValue(1);
NodeTys.push_back(MVT::i32); InFlag = Value1.getValue(2);
if (VT == MVT::i32)
Value = Value1;
if (VT == MVT::f32)
Value = DAG.getNode(ISD::BIT_CONVERT, MVT::f32, Value1);
if (VT == MVT::f64) {
SDOperand Value2 = DAG.getCopyFromReg(Chain, ARM::R1, MVT::i32, InFlag);
Chain = Value2.getValue(1);
Value = DAG.getNode(ARMISD::FMDRR, MVT::f64, Value1, Value2);
}
ResultVals.push_back(Value);
NodeTys.push_back(VT);
} }
Chain = DAG.getNode(ISD::CALLSEQ_END, MVT::Other, Chain, Chain = DAG.getNode(ISD::CALLSEQ_END, MVT::Other, Chain,

View File

@ -29,8 +29,12 @@ double %f2(double %a) {
ret double %a ret double %a
} }
void %f3(double %a) { void %f3() {
call void %f4( double %a) entry:
ret void %tmp = call double %f5() ; <double> [#uses=1]
call void %f4(double %tmp )
ret void
} }
declare void %f4(double) declare void %f4(double)
declare double %f5()