StackOffset += Size;
return Result;
}
+
+ void HandleStruct(unsigned ValNo, MVT::ValueType ValVT,
+ MVT::ValueType LocVT, CCValAssign::LocInfo LocInfo,
+ unsigned ArgFlags);
private:
/// MarkAllocated - Mark a register and all of its aliases as allocated.
void MarkAllocated(unsigned Reg);
ByValOffs = 4,
Nest = 1<<5, ///< Parameter is nested function static chain
NestOffs = 5,
+ ByValAlign = 0xF << 6, //< The alignment of the struct
+ ByValAlignOffs = 6,
+ ByValSize = 0x1ffff << 10, //< The size of the struct
+ ByValSizeOffs = 10,
OrigAlignment = 0x1F<<27,
OrigAlignmentOffs = 27
};
/// Bit 0 - signness
/// Bit 1 - 'inreg' attribute
/// Bit 2 - 'sret' attribute
+ /// Bit 4 - 'byval' attribute
+ /// Bit 5 - 'nest' attribute
+ /// Bit 6-9 - alignment of byval structures
+ /// Bit 10-26 - size of byval structures
/// Bits 31:27 - argument ABI alignment in the first argument piece and
/// alignment '1' in other argument pieces.
CALL,
UsedRegs.resize(MRI.getNumRegs());
}
+void CCState::HandleStruct(unsigned ValNo, MVT::ValueType ValVT,
+ MVT::ValueType LocVT, CCValAssign::LocInfo LocInfo,
+ unsigned ArgFlags) {
+ unsigned Align = 1 << ((ArgFlags & ISD::ParamFlags::ByValAlign) >>
+ ISD::ParamFlags::ByValAlignOffs);
+ unsigned Size = (ArgFlags & ISD::ParamFlags::ByValSize) >>
+ ISD::ParamFlags::ByValSizeOffs;
+ unsigned Offset = AllocateStack(Size, Align);
+
+ addLoc(CCValAssign::getMem(ValNo, ValVT, Offset, LocVT, LocInfo));
+}
/// MarkAllocated - Mark a register and all of its aliases as allocated.
void CCState::MarkAllocated(unsigned Reg) {
}
}
}
-
Flags |= ISD::ParamFlags::InReg;
if (Attrs && Attrs->paramHasAttr(j, ParamAttr::StructRet))
Flags |= ISD::ParamFlags::StructReturn;
- if (Attrs && Attrs->paramHasAttr(j, ParamAttr::ByVal))
+ if (Attrs && Attrs->paramHasAttr(j, ParamAttr::ByVal)) {
Flags |= ISD::ParamFlags::ByVal;
+ const PointerType *Ty = cast<PointerType>(I->getType());
+ const StructType *STy = cast<StructType>(Ty->getElementType());
+ unsigned StructAlign = Log2_32(getTargetData()->getABITypeAlignment(STy));
+ unsigned StructSize = getTargetData()->getTypeSize(STy);
+ Flags |= (StructAlign << ISD::ParamFlags::ByValAlignOffs);
+ Flags |= (StructSize << ISD::ParamFlags::ByValSizeOffs);
+ }
if (Attrs && Attrs->paramHasAttr(j, ParamAttr::Nest))
Flags |= ISD::ParamFlags::Nest;
Flags |= (OriginalAlignment << ISD::ParamFlags::OrigAlignmentOffs);
int FI = MFI->CreateFixedObject(MVT::getSizeInBits(VA.getValVT())/8,
VA.getLocMemOffset());
SDOperand FIN = DAG.getFrameIndex(FI, getPointerTy());
- ArgValues.push_back(DAG.getLoad(VA.getValVT(), Root, FIN, NULL, 0));
+
+ unsigned Flags = cast<ConstantSDNode>(Op.getOperand(3 + i))->getValue();
+ if (Flags & ISD::ParamFlags::ByVal)
+ ArgValues.push_back(FIN);
+ else
+ ArgValues.push_back(DAG.getLoad(VA.getValVT(), Root, FIN, NULL, 0));
}
}
<< IndentStr << "else\n"
<< IndentStr << IndentStr << "LocInfo = CCValAssign::AExt;\n";
} else if (Action->isSubClassOf("CCStructAssign")) {
- O << "assert(0 && \"Not Implemented\");\n";
+ O << IndentStr <<
+ "State.HandleStruct(ValNo, ValVT, LocVT, LocInfo, ArgFlags);\n";
+ O << IndentStr << "return false;\n";
} else {
Action->dump();
throw "Unknown CCAction!";