[llvm-commits] [llvm] r45897 - /llvm/trunk/utils/TableGen/CallingConvEmitter.cpp
Evan Cheng
evan.cheng at apple.com
Fri Jan 11 17:07:41 PST 2008
Author: evancheng
Date: Fri Jan 11 19:07:41 2008
New Revision: 45897
URL: http://llvm.org/viewvc/llvm-project?rev=45897&view=rev
Log:
ByVal arguments are passed on stack. Make sure to allocate a slot using size and alignment information on the parameter attribute.
Modified:
llvm/trunk/utils/TableGen/CallingConvEmitter.cpp
Modified: llvm/trunk/utils/TableGen/CallingConvEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CallingConvEmitter.cpp?rev=45897&r1=45896&r2=45897&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CallingConvEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/CallingConvEmitter.cpp Fri Jan 11 19:07:41 2008
@@ -115,19 +115,32 @@
int Size = Action->getValueAsInt("Size");
int Align = Action->getValueAsInt("Align");
- O << IndentStr << "unsigned Offset" << ++Counter
- << " = State.AllocateStack(";
+ O << IndentStr << "unsigned Size = ";
if (Size)
- O << Size << ", ";
+ O << Size;
else
- O << "\n" << IndentStr << " State.getTarget().getTargetData()"
- "->getABITypeSize(MVT::getTypeForValueType(LocVT)), ";
+ O << "State.getTarget().getTargetData()"
+ "->getABITypeSize(MVT::getTypeForValueType(LocVT))";
+ O << ";\n"
+ << IndentStr << "unsigned Align = ";
if (Align)
O << Align;
else
- O << "\n" << IndentStr << " State.getTarget().getTargetData()"
+ O << "State.getTarget().getTargetData()"
"->getABITypeAlignment(MVT::getTypeForValueType(LocVT))";
- O << ");\n" << IndentStr
+ O << ";\n";
+ O << IndentStr << "if (ArgFlags & ISD::ParamFlags::ByVal) {\n";
+ O << IndentStr << " " <<
+ "Size = (ArgFlags & ISD::ParamFlags::ByValSize) >> "
+ "ISD::ParamFlags::ByValSizeOffs;\n";
+ O << IndentStr << " " <<
+ "unsigned ParamAlign = 1 << ((ArgFlags & ISD::ParamFlags::ByValAlign) "
+ ">> ISD::ParamFlags::ByValAlignOffs);\n";
+ O << IndentStr << " Align = std::max(Align, ParamAlign);\n"
+ << IndentStr << "}\n";
+ O << IndentStr << "unsigned Offset" << ++Counter
+ << " = State.AllocateStack(Size, Align);\n";
+ O << IndentStr
<< "State.addLoc(CCValAssign::getMem(ValNo, ValVT, Offset"
<< Counter << ", LocVT, LocInfo));\n";
O << IndentStr << "return false;\n";
More information about the llvm-commits
mailing list