mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-17 21:29:20 +00:00
Vector args passed in registers don't reserve stack space.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28333 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7c65a309ac
commit
be4849aabe
@ -765,20 +765,43 @@ static SDOperand LowerFORMAL_ARGUMENTS(SDOperand Op, SelectionDAG &DAG,
|
|||||||
MVT::ValueType ObjectVT = Op.getValue(ArgNo).getValueType();
|
MVT::ValueType ObjectVT = Op.getValue(ArgNo).getValueType();
|
||||||
unsigned ObjSize = MVT::getSizeInBits(ObjectVT)/8;
|
unsigned ObjSize = MVT::getSizeInBits(ObjectVT)/8;
|
||||||
|
|
||||||
|
unsigned CurArgOffset = ArgOffset;
|
||||||
|
|
||||||
switch (ObjectVT) {
|
switch (ObjectVT) {
|
||||||
default: assert(0 && "Unhandled argument type!");
|
default: assert(0 && "Unhandled argument type!");
|
||||||
case MVT::i32:
|
case MVT::i32:
|
||||||
if (!ArgLive) break;
|
// All int arguments reserve stack space.
|
||||||
|
ArgOffset += 4;
|
||||||
|
|
||||||
|
if (!ArgLive) {
|
||||||
|
if (GPR_remaining > 0) {
|
||||||
|
--GPR_remaining;
|
||||||
|
++GPR_idx;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (GPR_remaining > 0) {
|
if (GPR_remaining > 0) {
|
||||||
unsigned VReg = RegMap->createVirtualRegister(&PPC::GPRCRegClass);
|
unsigned VReg = RegMap->createVirtualRegister(&PPC::GPRCRegClass);
|
||||||
MF.addLiveIn(GPR[GPR_idx], VReg);
|
MF.addLiveIn(GPR[GPR_idx], VReg);
|
||||||
ArgVal = DAG.getCopyFromReg(Root, VReg, MVT::i32);
|
ArgVal = DAG.getCopyFromReg(Root, VReg, MVT::i32);
|
||||||
|
--GPR_remaining;
|
||||||
|
++GPR_idx;
|
||||||
} else {
|
} else {
|
||||||
needsLoad = true;
|
needsLoad = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MVT::f32:
|
case MVT::f32:
|
||||||
case MVT::f64:
|
case MVT::f64:
|
||||||
|
// All FP arguments reserve stack space.
|
||||||
|
ArgOffset += ObjSize;
|
||||||
|
|
||||||
|
// Every 4 bytes of argument space consumes one of the GPRs available for
|
||||||
|
// argument passing.
|
||||||
|
if (GPR_remaining > 0) {
|
||||||
|
unsigned delta = (GPR_remaining > 1 && ObjSize == 8) ? 2 : 1;
|
||||||
|
GPR_remaining -= delta;
|
||||||
|
GPR_idx += delta;
|
||||||
|
}
|
||||||
if (!ArgLive) {
|
if (!ArgLive) {
|
||||||
if (FPR_remaining > 0) {
|
if (FPR_remaining > 0) {
|
||||||
--FPR_remaining;
|
--FPR_remaining;
|
||||||
@ -804,6 +827,7 @@ static SDOperand LowerFORMAL_ARGUMENTS(SDOperand Op, SelectionDAG &DAG,
|
|||||||
case MVT::v4i32:
|
case MVT::v4i32:
|
||||||
case MVT::v8i16:
|
case MVT::v8i16:
|
||||||
case MVT::v16i8:
|
case MVT::v16i8:
|
||||||
|
// Note that vector arguments in registers don't reserve stack space.
|
||||||
if (!ArgLive) {
|
if (!ArgLive) {
|
||||||
if (VR_remaining > 0) {
|
if (VR_remaining > 0) {
|
||||||
--VR_remaining;
|
--VR_remaining;
|
||||||
@ -829,21 +853,12 @@ static SDOperand LowerFORMAL_ARGUMENTS(SDOperand Op, SelectionDAG &DAG,
|
|||||||
// We need to load the argument to a virtual register if we determined above
|
// We need to load the argument to a virtual register if we determined above
|
||||||
// that we ran out of physical registers of the appropriate type
|
// that we ran out of physical registers of the appropriate type
|
||||||
if (needsLoad) {
|
if (needsLoad) {
|
||||||
int FI = MFI->CreateFixedObject(ObjSize, ArgOffset);
|
int FI = MFI->CreateFixedObject(ObjSize, CurArgOffset);
|
||||||
SDOperand FIN = DAG.getFrameIndex(FI, MVT::i32);
|
SDOperand FIN = DAG.getFrameIndex(FI, MVT::i32);
|
||||||
ArgVal = DAG.getLoad(ObjectVT, Root, FIN,
|
ArgVal = DAG.getLoad(ObjectVT, Root, FIN,
|
||||||
DAG.getSrcValue(NULL));
|
DAG.getSrcValue(NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Every 4 bytes of argument space consumes one of the GPRs available for
|
|
||||||
// argument passing.
|
|
||||||
if (GPR_remaining > 0) {
|
|
||||||
unsigned delta = (GPR_remaining > 1 && ObjSize == 8) ? 2 : 1;
|
|
||||||
GPR_remaining -= delta;
|
|
||||||
GPR_idx += delta;
|
|
||||||
}
|
|
||||||
ArgOffset += ObjSize;
|
|
||||||
|
|
||||||
if (ArgVal.Val == 0)
|
if (ArgVal.Val == 0)
|
||||||
ArgVal = DAG.getNode(ISD::UNDEF, ObjectVT);
|
ArgVal = DAG.getNode(ISD::UNDEF, ObjectVT);
|
||||||
ArgValues.push_back(ArgVal);
|
ArgValues.push_back(ArgVal);
|
||||||
|
Loading…
Reference in New Issue
Block a user