llvm.org GIT mirror llvm / 594d37e
propagate struct size and alignment of byval arguments to the DAG git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40986 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 13 years ago
6 changed file(s) with 40 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
189189 StackOffset += Size;
190190 return Result;
191191 }
192
193 void HandleStruct(unsigned ValNo, MVT::ValueType ValVT,
194 MVT::ValueType LocVT, CCValAssign::LocInfo LocInfo,
195 unsigned ArgFlags);
192196 private:
193197 /// MarkAllocated - Mark a register and all of its aliases as allocated.
194198 void MarkAllocated(unsigned Reg);
6767 ByValOffs = 4,
6868 Nest = 1<<5, ///< Parameter is nested function static chain
6969 NestOffs = 5,
70 ByValAlign = 0xF << 6, //< The alignment of the struct
71 ByValAlignOffs = 6,
72 ByValSize = 0x1ffff << 10, //< The size of the struct
73 ByValSizeOffs = 10,
7074 OrigAlignment = 0x1F<<27,
7175 OrigAlignmentOffs = 27
7276 };
199203 /// Bit 0 - signness
200204 /// Bit 1 - 'inreg' attribute
201205 /// Bit 2 - 'sret' attribute
206 /// Bit 4 - 'byval' attribute
207 /// Bit 5 - 'nest' attribute
208 /// Bit 6-9 - alignment of byval structures
209 /// Bit 10-26 - size of byval structures
202210 /// Bits 31:27 - argument ABI alignment in the first argument piece and
203211 /// alignment '1' in other argument pieces.
204212 CALL,
2727 UsedRegs.resize(MRI.getNumRegs());
2828 }
2929
30 void CCState::HandleStruct(unsigned ValNo, MVT::ValueType ValVT,
31 MVT::ValueType LocVT, CCValAssign::LocInfo LocInfo,
32 unsigned ArgFlags) {
33 unsigned Align = 1 << ((ArgFlags & ISD::ParamFlags::ByValAlign) >>
34 ISD::ParamFlags::ByValAlignOffs);
35 unsigned Size = (ArgFlags & ISD::ParamFlags::ByValSize) >>
36 ISD::ParamFlags::ByValSizeOffs;
37 unsigned Offset = AllocateStack(Size, Align);
38
39 addLoc(CCValAssign::getMem(ValNo, ValVT, Offset, LocVT, LocInfo));
40 }
3041
3142 /// MarkAllocated - Mark a register and all of its aliases as allocated.
3243 void CCState::MarkAllocated(unsigned Reg) {
98109 }
99110 }
100111 }
101
38353835 Flags |= ISD::ParamFlags::InReg;
38363836 if (Attrs && Attrs->paramHasAttr(j, ParamAttr::StructRet))
38373837 Flags |= ISD::ParamFlags::StructReturn;
3838 if (Attrs && Attrs->paramHasAttr(j, ParamAttr::ByVal))
3838 if (Attrs && Attrs->paramHasAttr(j, ParamAttr::ByVal)) {
38393839 Flags |= ISD::ParamFlags::ByVal;
3840 const PointerType *Ty = cast(I->getType());
3841 const StructType *STy = cast(Ty->getElementType());
3842 unsigned StructAlign = Log2_32(getTargetData()->getABITypeAlignment(STy));
3843 unsigned StructSize = getTargetData()->getTypeSize(STy);
3844 Flags |= (StructAlign << ISD::ParamFlags::ByValAlignOffs);
3845 Flags |= (StructSize << ISD::ParamFlags::ByValSizeOffs);
3846 }
38403847 if (Attrs && Attrs->paramHasAttr(j, ParamAttr::Nest))
38413848 Flags |= ISD::ParamFlags::Nest;
38423849 Flags |= (OriginalAlignment << ISD::ParamFlags::OrigAlignmentOffs);
12591259 int FI = MFI->CreateFixedObject(MVT::getSizeInBits(VA.getValVT())/8,
12601260 VA.getLocMemOffset());
12611261 SDOperand FIN = DAG.getFrameIndex(FI, getPointerTy());
1262 ArgValues.push_back(DAG.getLoad(VA.getValVT(), Root, FIN, NULL, 0));
1262
1263 unsigned Flags = cast(Op.getOperand(3 + i))->getValue();
1264 if (Flags & ISD::ParamFlags::ByVal)
1265 ArgValues.push_back(FIN);
1266 else
1267 ArgValues.push_back(DAG.getLoad(VA.getValVT(), Root, FIN, NULL, 0));
12631268 }
12641269 }
12651270
129129 << IndentStr << "else\n"
130130 << IndentStr << IndentStr << "LocInfo = CCValAssign::AExt;\n";
131131 } else if (Action->isSubClassOf("CCStructAssign")) {
132 O << "assert(0 && \"Not Implemented\");\n";
132 O << IndentStr <<
133 "State.HandleStruct(ValNo, ValVT, LocVT, LocInfo, ArgFlags);\n";
134 O << IndentStr << "return false;\n";
133135 } else {
134136 Action->dump();
135137 throw "Unknown CCAction!";