mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-10 20:33:15 +00:00
Teach ReturnInst lowering about aggregate return values.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52522 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6fafe847b2
commit
ab8ec0a26c
@ -1270,32 +1270,38 @@ void SelectionDAGLowering::visitRet(ReturnInst &I) {
|
|||||||
NewValues.push_back(getControlRoot());
|
NewValues.push_back(getControlRoot());
|
||||||
for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i) {
|
for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i) {
|
||||||
SDOperand RetOp = getValue(I.getOperand(i));
|
SDOperand RetOp = getValue(I.getOperand(i));
|
||||||
MVT VT = RetOp.getValueType();
|
|
||||||
|
|
||||||
// FIXME: C calling convention requires the return type to be promoted to
|
SmallVector<MVT, 4> ValueVTs;
|
||||||
// at least 32-bit. But this is not necessary for non-C calling conventions.
|
ComputeValueVTs(TLI, I.getOperand(i)->getType(), ValueVTs);
|
||||||
if (VT.isInteger()) {
|
for (unsigned j = 0, f = ValueVTs.size(); j != f; ++j) {
|
||||||
MVT MinVT = TLI.getRegisterType(MVT::i32);
|
MVT VT = ValueVTs[j];
|
||||||
if (VT.bitsLT(MinVT))
|
|
||||||
VT = MinVT;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned NumParts = TLI.getNumRegisters(VT);
|
// FIXME: C calling convention requires the return type to be promoted to
|
||||||
MVT PartVT = TLI.getRegisterType(VT);
|
// at least 32-bit. But this is not necessary for non-C calling conventions.
|
||||||
SmallVector<SDOperand, 4> Parts(NumParts);
|
if (VT.isInteger()) {
|
||||||
ISD::NodeType ExtendKind = ISD::ANY_EXTEND;
|
MVT MinVT = TLI.getRegisterType(MVT::i32);
|
||||||
|
if (VT.bitsLT(MinVT))
|
||||||
|
VT = MinVT;
|
||||||
|
}
|
||||||
|
|
||||||
const Function *F = I.getParent()->getParent();
|
unsigned NumParts = TLI.getNumRegisters(VT);
|
||||||
if (F->paramHasAttr(0, ParamAttr::SExt))
|
MVT PartVT = TLI.getRegisterType(VT);
|
||||||
ExtendKind = ISD::SIGN_EXTEND;
|
SmallVector<SDOperand, 4> Parts(NumParts);
|
||||||
else if (F->paramHasAttr(0, ParamAttr::ZExt))
|
ISD::NodeType ExtendKind = ISD::ANY_EXTEND;
|
||||||
ExtendKind = ISD::ZERO_EXTEND;
|
|
||||||
|
const Function *F = I.getParent()->getParent();
|
||||||
|
if (F->paramHasAttr(0, ParamAttr::SExt))
|
||||||
|
ExtendKind = ISD::SIGN_EXTEND;
|
||||||
|
else if (F->paramHasAttr(0, ParamAttr::ZExt))
|
||||||
|
ExtendKind = ISD::ZERO_EXTEND;
|
||||||
|
|
||||||
getCopyToParts(DAG, RetOp, &Parts[0], NumParts, PartVT, ExtendKind);
|
getCopyToParts(DAG, SDOperand(RetOp.Val, RetOp.ResNo + j),
|
||||||
|
&Parts[0], NumParts, PartVT, ExtendKind);
|
||||||
|
|
||||||
for (unsigned i = 0; i < NumParts; ++i) {
|
for (unsigned i = 0; i < NumParts; ++i) {
|
||||||
NewValues.push_back(Parts[i]);
|
NewValues.push_back(Parts[i]);
|
||||||
NewValues.push_back(DAG.getArgFlags(ISD::ArgFlagsTy()));
|
NewValues.push_back(DAG.getArgFlags(ISD::ArgFlagsTy()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DAG.setRoot(DAG.getNode(ISD::RET, MVT::Other,
|
DAG.setRoot(DAG.getNode(ISD::RET, MVT::Other,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user