diff options
author | Eli Bendersky <eliben@google.com> | 2013-04-04 22:49:35 +0000 |
---|---|---|
committer | Eli Bendersky <eliben@google.com> | 2013-04-04 22:49:35 +0000 |
commit | e45dfd15d9d821b0f2066bc0cad525eef2e307c3 (patch) | |
tree | 3085b03f1b3c56acc3d72c48bb7ff94bc8d8f746 /lib/CodeGen | |
parent | 0b602836c63e702b2ba893e8439996b226fc248f (diff) |
Add some documentation for PNaClABIInfo.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178802 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/TargetInfo.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp index 931502d779..7cc63b7db1 100644 --- a/lib/CodeGen/TargetInfo.cpp +++ b/lib/CodeGen/TargetInfo.cpp @@ -421,6 +421,8 @@ class PNaClTargetCodeGenInfo : public TargetCodeGenInfo { void PNaClABIInfo::computeInfo(CGFunctionInfo &FI) const { FI.getReturnInfo() = classifyReturnType(FI.getReturnType()); + // Obtain the initial number of registers available for passing integers + // from the function's regparm attribute. unsigned FreeRegs = FI.getHasRegParm() ? FI.getRegParm() : 0; for (CGFunctionInfo::arg_iterator it = FI.arg_begin(), ie = FI.arg_end(); @@ -433,15 +435,18 @@ llvm::Value *PNaClABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty, return 0; } +// \brief Classify argument of given type \p Ty. \p FreeRegs is the number of +// registers available for passing arguments - it can be updated by this +// method. ABIArgInfo PNaClABIInfo::classifyArgumentType(QualType Ty, unsigned &FreeRegs) const { if (isAggregateTypeForABI(Ty)) { - // Records with non trivial destructors/constructors should not be passed - // by value. + // In the PNaCl ABI we always pass records/structures on the stack. The + // byval attribute can be used if the record doesn't have non-trivial + // constructors/destructors. FreeRegs = 0; if (isRecordWithNonTrivialDestructorOrCopyConstructor(Ty)) return ABIArgInfo::getIndirect(0, /*ByVal=*/false); - return ABIArgInfo::getIndirect(0); } @@ -452,14 +457,17 @@ ABIArgInfo PNaClABIInfo::classifyArgumentType(QualType Ty, ABIArgInfo BaseInfo = (Ty->isPromotableIntegerType() ? ABIArgInfo::getExtend() : ABIArgInfo::getDirect()); - // Regparm regs hold 32 bits. - unsigned SizeInRegs = (getContext().getTypeSize(Ty) + 31) / 32; - if (SizeInRegs == 0) return BaseInfo; - if (SizeInRegs > FreeRegs) { + // Figure out how many of the free registers can be occupied by this type. + // regparm registers are 32-bit. + unsigned NumRegsRequired = (getContext().getTypeSize(Ty) + 31) / 32; + if (NumRegsRequired == 0) return BaseInfo; + if (NumRegsRequired > FreeRegs) { + // If this type needs more registers than we have available, no more + // passing in-registers can happen. FreeRegs = 0; return BaseInfo; } - FreeRegs -= SizeInRegs; + FreeRegs -= NumRegsRequired; return BaseInfo.isDirect() ? ABIArgInfo::getDirectInReg(BaseInfo.getCoerceToType()) : ABIArgInfo::getExtendInReg(BaseInfo.getCoerceToType()); @@ -469,6 +477,7 @@ ABIArgInfo PNaClABIInfo::classifyReturnType(QualType RetTy) const { if (RetTy->isVoidType()) return ABIArgInfo::getIgnore(); + // In the PNaCl ABI we always return records/structures on the stack. if (isAggregateTypeForABI(RetTy)) return ABIArgInfo::getIndirect(0); |