@@ -31,7 +31,7 @@ class SystemZABIInfo : public ABIInfo {
3131 bool isPromotableIntegerTypeForABI (QualType Ty) const ;
3232 bool isCompoundType (QualType Ty) const ;
3333 bool isVectorArgumentType (QualType Ty) const ;
34- bool isFPArgumentType (QualType Ty) const ;
34+ llvm::Type * getFPArgumentType (QualType Ty, uint64_t Size ) const ;
3535 QualType GetSingleElementType (QualType Ty) const ;
3636
3737 ABIArgInfo classifyReturnType (QualType RetTy) const ;
@@ -107,7 +107,8 @@ class SystemZTargetCodeGenInfo : public TargetCodeGenInfo {
107107 return nullptr ;
108108
109109 llvm::Type *Ty = V->getType ();
110- if (Ty->isFloatTy () || Ty->isDoubleTy () || Ty->isFP128Ty ()) {
110+ if (Ty->isHalfTy () || Ty->isFloatTy () || Ty->isDoubleTy () ||
111+ Ty->isFP128Ty ()) {
111112 llvm::Module &M = CGM.getModule ();
112113 auto &Ctx = M.getContext ();
113114 llvm::Function *TDCFunc = llvm::Intrinsic::getOrInsertDeclaration (
@@ -179,21 +180,31 @@ bool SystemZABIInfo::isVectorArgumentType(QualType Ty) const {
179180 getContext ().getTypeSize (Ty) <= 128 );
180181}
181182
182- bool SystemZABIInfo::isFPArgumentType (QualType Ty) const {
183+ // The Size argument will in case of af an overaligned single element struct
184+ // reflect the overalignment value. In such a case the argument will be
185+ // passed using the type matching Size.
186+ llvm::Type *SystemZABIInfo::getFPArgumentType (QualType Ty,
187+ uint64_t Size) const {
183188 if (IsSoftFloatABI)
184- return false ;
189+ return nullptr ;
185190
186191 if (const BuiltinType *BT = Ty->getAs <BuiltinType>())
187192 switch (BT->getKind ()) {
188- case BuiltinType::Float16: // _Float16
193+ case BuiltinType::Float16:
194+ if (Size == 16 )
195+ return llvm::Type::getHalfTy (getVMContext ());
196+ LLVM_FALLTHROUGH;
189197 case BuiltinType::Float:
198+ if (Size == 32 )
199+ return llvm::Type::getFloatTy (getVMContext ());
200+ LLVM_FALLTHROUGH;
190201 case BuiltinType::Double:
191- return true ;
202+ return llvm::Type::getDoubleTy ( getVMContext ()) ;
192203 default :
193- return false ;
204+ return nullptr ;
194205 }
195206
196- return false ;
207+ return nullptr ;
197208}
198209
199210QualType SystemZABIInfo::GetSingleElementType (QualType Ty) const {
@@ -449,13 +460,11 @@ ABIArgInfo SystemZABIInfo::classifyArgumentType(QualType Ty) const {
449460 return getNaturalAlignIndirect (Ty, getDataLayout ().getAllocaAddrSpace (),
450461 /* ByVal=*/ false );
451462
452- // The structure is passed as an unextended integer, a float, or a double.
453- if (isFPArgumentType (SingleElementTy)) {
463+ // The structure is passed as an unextended integer, a half, a float,
464+ // or a double.
465+ if (llvm::Type *FPArgTy = getFPArgumentType (SingleElementTy, Size)) {
454466 assert (Size == 16 || Size == 32 || Size == 64 );
455- return ABIArgInfo::getDirect (
456- Size == 16 ? llvm::Type::getHalfTy (getVMContext ())
457- : Size == 32 ? llvm::Type::getFloatTy (getVMContext ())
458- : llvm::Type::getDoubleTy (getVMContext ()));
467+ return ABIArgInfo::getDirect (FPArgTy);
459468 } else {
460469 llvm::IntegerType *PassTy = llvm::IntegerType::get (getVMContext (), Size);
461470 return Size <= 32 ? ABIArgInfo::getNoExtend (PassTy)
0 commit comments