================ @@ -337,12 +350,77 @@ CharUnits PPC32_SVR4_ABIInfo::getParamTypeAlignment(QualType Ty) const { return CharUnits::fromQuantity(4); } +ABIArgInfo PPC32_SVR4_ABIInfo::handleComplex(QualType Ty, + uint64_t &TypeSize) const { + + assert(Ty->isAnyComplexType()); + llvm::Type *ElemTy; + unsigned SizeRegs; + + if (TypeSize == 64) { + ElemTy = llvm::Type::getInt64Ty(getVMContext()); + SizeRegs = 1; + } else { + ElemTy = llvm::Type::getInt32Ty(getVMContext()); + SizeRegs = (TypeSize + 31) / 32; + } + return ABIArgInfo::getDirect(llvm::ArrayType::get(ElemTy, SizeRegs)); +} + +ABIArgInfo PPC32_SVR4_ABIInfo::classifyArgumentType(QualType Ty, + int &ArgGPRsLeft) const { + + assert(ArgGPRsLeft <= NumArgGPRs && "Arg GPR tracking underflow"); + Ty = useFirstFieldIfTransparentUnion(Ty); + + ASTContext &Context = getContext(); + + uint64_t TypeSize = Context.getTypeSize(Ty); + + if (isComplexInRegABI && Ty->isAnyComplexType() && + TypeSize <= RLen * ArgGPRsLeft) { + ArgGPRsLeft -= TypeSize / RLen; + return handleComplex(Ty, TypeSize); + } + + if (isAggregateTypeForABI(Ty)) { + if (ArgGPRsLeft) + ArgGPRsLeft -= 1; + // Records with non-trivial destructors/copy-constructors should not be + // passed by value. + if (CGCXXABI::RecordArgABI RAA = getRecordArgABI(Ty, getCXXABI())) { + return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory); + } + return getNaturalAlignIndirect(Ty); + } + + if (!Ty->isFloatingType()) { + if (TypeSize > RLen && TypeSize <= 2 * RLen) + ArgGPRsLeft -= 2; + else + ArgGPRsLeft--; ---------------- diggerlin wrote:
There is a bug here, you decrease the ArgGPRsLeft no mater whether ArgGPRsLeft >0; I think you can put after `Ty = useFirstFieldIfTransparentUnion(Ty);` ``` Ty = useFirstFieldIfTransparentUnion(Ty); if(Ty->isFloatingType()) return; ``` and change the code here as ``` if(TypeSize <= RLen * ArgGPRsLeft) ArgGPRsLeft -= TypeSize / RLen; ``` https://github.com/llvm/llvm-project/pull/77732 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits