Skip to content

Commit 9b61d3c

Browse files
FORTRAN!!! :( and other similarly unfortunate things mean that on ia64
one sometimes needs to pass FP args in both FP *and* integer registers. llvm-svn: 24134
1 parent b81b613 commit 9b61d3c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

llvm/lib/Target/IA64/IA64ISelDAGToDAG.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,13 @@ SDOperand IA64DAGToDAGISel::SelectCALL(SDOperand Op) {
208208
CallOpcode = IA64::BRCALL_INDIRECT;
209209
}
210210

211+
// see section 8.5.8 of "Itanium Software Conventions and
212+
// Runtime Architecture Guide to see some examples of what's going
213+
// on here. (in short: int args get mapped 1:1 'slot-wise' to out0->out7,
214+
// while FP args get mapped to F8->F15 as needed)
215+
211216
// TODO: support in-memory arguments
217+
212218
unsigned used_FPArgs=0; // how many FP args have been used so far?
213219

214220
unsigned intArgs[] = {IA64::out0, IA64::out1, IA64::out2, IA64::out3,
@@ -236,6 +242,20 @@ SDOperand IA64DAGToDAGISel::SelectCALL(SDOperand Op) {
236242
Chain = CurDAG->getCopyToReg(Chain, DestReg, Val, InFlag);
237243
InFlag = Chain.getValue(1);
238244
CallOperands.push_back(CurDAG->getRegister(DestReg, RegTy));
245+
// some functions (e.g. printf) want floating point arguments
246+
// *also* passed as in-memory representations in integer registers
247+
// this is FORTRAN legacy junk which we don't _always_ need
248+
// to do, but to be on the safe side, we do.
249+
if(MVT::isFloatingPoint(N->getOperand(i).getValueType())) {
250+
assert((i-2) < 8 && "FP args alone would fit, but no int regs left");
251+
DestReg = intArgs[i-2]; // this FP arg goes in an int reg
252+
// GETFD takes an FP reg and writes a GP reg
253+
Chain = CurDAG->getTargetNode(IA64::GETFD, MVT::i64, Val, InFlag);
254+
// FIXME: this next line is a bit unfortunate
255+
Chain = CurDAG->getCopyToReg(Chain, DestReg, Chain, InFlag);
256+
InFlag = Chain.getValue(1);
257+
CallOperands.push_back(CurDAG->getRegister(DestReg, MVT::i64));
258+
}
239259
}
240260
}
241261

0 commit comments

Comments
 (0)