llvm.org GIT mirror llvm / 4a408d4
add support for calling functions that have double arguments git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30765 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 13 years ago
2 changed file(s) with 30 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
264264 // and flag operands which copy the outgoing args into the appropriate regs.
265265 SDOperand InFlag;
266266 for (unsigned i = 0, e = Layout.lastRegArg(); i <= e; ++i) {
267 SDOperand Arg = Op.getOperand(5+2*i);
268 unsigned Reg = regs[Layout.getRegisterNum(i)];
269 assert(Layout.getType(i) == Arg.getValueType());
270 assert(Layout.getType(i) == MVT::i32);
271 Chain = DAG.getCopyToReg(Chain, Reg, Arg, InFlag);
272 InFlag = Chain.getValue(1);
267 SDOperand Arg = Op.getOperand(5+2*i);
268 unsigned RegNum = Layout.getRegisterNum(i);
269 unsigned Reg1 = regs[RegNum];
270 MVT::ValueType VT = Layout.getType(i);
271 assert(VT == Arg.getValueType());
272 assert(VT == MVT::i32 || VT == MVT::f32 || VT == MVT::f64);
273273
274274 // Add argument register to the end of the list so that it is known live
275275 // into the call.
276 Ops.push_back(DAG.getRegister(Reg, Arg.getValueType()));
276 Ops.push_back(DAG.getRegister(Reg1, MVT::i32));
277 if (VT == MVT::f64) {
278 unsigned Reg2 = regs[RegNum + 1];
279 SDOperand SDReg1 = DAG.getRegister(Reg1, MVT::i32);
280 SDOperand SDReg2 = DAG.getRegister(Reg2, MVT::i32);
281
282 Ops.push_back(DAG.getRegister(Reg2, MVT::i32));
283 SDVTList VTs = DAG.getVTList(MVT::Other, MVT::Flag);
284 SDOperand Ops[] = {Chain, SDReg1, SDReg2, Arg}; //missing flag
285 Chain = DAG.getNode(ARMISD::FMRRD, VTs, Ops, 4);
286 } else {
287 if (VT == MVT::f32)
288 Arg = DAG.getNode(ISD::BIT_CONVERT, MVT::i32, Arg);
289 Chain = DAG.getCopyToReg(Chain, Reg1, Arg, InFlag);
290 }
291 InFlag = Chain.getValue(1);
277292 }
278293
279294 std::vector NodeTys;
22 ; RUN: llvm-as < %s | llc -march=arm | grep fsitos &&
33 ; RUN: llvm-as < %s | llc -march=arm | grep fmrs &&
44 ; RUN: llvm-as < %s | llc -march=arm | grep fsitod &&
5 ; RUN: llvm-as < %s | llc -march=arm | grep fmrrd | wc -l | grep 2 &&
6 ; RUN: llvm-as < %s | llc -march=arm | grep fmdrr | wc -l | grep 1 &&
5 ; RUN: llvm-as < %s | llc -march=arm | grep fmrrd | wc -l | grep 3 &&
6 ; RUN: llvm-as < %s | llc -march=arm | grep fmdrr | wc -l | grep 2 &&
77 ; RUN: llvm-as < %s | llc -march=arm | grep flds &&
88 ; RUN: llvm-as < %s | llc -march=arm | grep ".word.*1065353216"
99
2727 double %f2(double %a) {
2828 ret double %a
2929 }
30
31 void %f3(double %a) {
32 call void %f4( double %a)
33 ret void
34 }
35 declare void %f4(double)