diff options
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGCall.cpp | 42 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 2 | ||||
-rw-r--r-- | clang/lib/CodeGen/TargetInfo.cpp | 25 |
3 files changed, 28 insertions, 41 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 56004f3..972a7c8 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -158,23 +158,6 @@ static CallingConv getCallingConventionForDecl(const Decl *D, bool IsWindows) { return CC_C; } -static bool isAAPCSVFP(const CGFunctionInfo &FI, const TargetInfo &Target) { - switch (FI.getEffectiveCallingConvention()) { - case llvm::CallingConv::C: - switch (Target.getTriple().getEnvironment()) { - case llvm::Triple::EABIHF: - case llvm::Triple::GNUEABIHF: - return true; - default: - return false; - } - case llvm::CallingConv::ARM_AAPCS_VFP: - return true; - default: - return false; - } -} - /// Arrange the argument and result information for a call to an /// unknown C++ non-static member function of the given abstract type. /// (Zero value of RD means we don't have any meaningful "this" argument type, @@ -1012,11 +995,8 @@ CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI) { // If the coerce-to type is a first class aggregate, flatten it. Either // way is semantically identical, but fast-isel and the optimizer // generally likes scalar values better than FCAs. - // We cannot do this for functions using the AAPCS calling convention, - // as structures are treated differently by that calling convention. llvm::Type *argType = argAI.getCoerceToType(); - llvm::StructType *st = dyn_cast<llvm::StructType>(argType); - if (st && !isAAPCSVFP(FI, getTarget())) { + if (llvm::StructType *st = dyn_cast<llvm::StructType>(argType)) { for (unsigned i = 0, e = st->getNumElements(); i != e; ++i) argTypes.push_back(st->getElementType(i)); } else { @@ -1219,15 +1199,14 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, else if (ParamType->isUnsignedIntegerOrEnumerationType()) Attrs.addAttribute(llvm::Attribute::ZExt); // FALL THROUGH - case ABIArgInfo::Direct: { + case ABIArgInfo::Direct: if (AI.getInReg()) Attrs.addAttribute(llvm::Attribute::InReg); // FIXME: handle sseregparm someday... - llvm::StructType *STy = - dyn_cast<llvm::StructType>(AI.getCoerceToType()); - if (!isAAPCSVFP(FI, getTarget()) && STy) { + if (llvm::StructType *STy = + dyn_cast<llvm::StructType>(AI.getCoerceToType())) { unsigned Extra = STy->getNumElements()-1; // 1 will be added below. if (Attrs.hasAttributes()) for (unsigned I = 0; I < Extra; ++I) @@ -1236,7 +1215,7 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, Index += Extra; } break; - } + case ABIArgInfo::Indirect: if (AI.getInReg()) Attrs.addAttribute(llvm::Attribute::InReg); @@ -1495,10 +1474,8 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI, // If the coerce-to type is a first class aggregate, we flatten it and // pass the elements. Either way is semantically identical, but fast-isel // and the optimizer generally likes scalar values better than FCAs. - // We cannot do this for functions using the AAPCS calling convention, - // as structures are treated differently by that calling convention. llvm::StructType *STy = dyn_cast<llvm::StructType>(ArgI.getCoerceToType()); - if (!isAAPCSVFP(FI, getTarget()) && STy && STy->getNumElements() > 1) { + if (STy && STy->getNumElements() > 1) { uint64_t SrcSize = CGM.getDataLayout().getTypeAllocSize(STy); llvm::Type *DstTy = cast<llvm::PointerType>(Ptr->getType())->getElementType(); @@ -2758,11 +2735,8 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, // If the coerce-to type is a first class aggregate, we flatten it and // pass the elements. Either way is semantically identical, but fast-isel // and the optimizer generally likes scalar values better than FCAs. - // We cannot do this for functions using the AAPCS calling convention, - // as structures are treated differently by that calling convention. - llvm::StructType *STy = - dyn_cast<llvm::StructType>(ArgInfo.getCoerceToType()); - if (STy && !isAAPCSVFP(CallInfo, getTarget())) { + if (llvm::StructType *STy = + dyn_cast<llvm::StructType>(ArgInfo.getCoerceToType())) { llvm::Type *SrcTy = cast<llvm::PointerType>(SrcPtr->getType())->getElementType(); uint64_t SrcSize = CGM.getDataLayout().getTypeAllocSize(SrcTy); diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index d474c1b..bf639bf 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -2670,7 +2670,7 @@ CodeGenModule::GetConstantArrayFromStringLiteral(const StringLiteral *E) { llvm::Constant * CodeGenModule::GetAddrOfConstantStringFromLiteral(const StringLiteral *S) { CharUnits Align = getContext().getAlignOfGlobalVarInChars(S->getType()); - + Align = std::max(Align, getContext().); llvm::StringMapEntry<llvm::GlobalVariable *> *Entry = nullptr; llvm::GlobalVariable *GV = nullptr; if (!LangOpts.WritableStrings) { diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index 64f9e7b..d539ffc 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -3796,7 +3796,7 @@ public: private: ABIArgInfo classifyReturnType(QualType RetTy, bool isVariadic) const; - ABIArgInfo classifyArgumentType(QualType RetTy, bool isVariadic, + ABIArgInfo classifyArgumentType(QualType RetTy, bool &IsHA, bool isVariadic, bool &IsCPRC) const; bool isIllegalVectorType(QualType Ty) const; @@ -3901,10 +3901,22 @@ void ARMABIInfo::computeInfo(CGFunctionInfo &FI) const { for (auto &I : FI.arguments()) { unsigned PreAllocationVFPs = AllocatedVFPs; unsigned PreAllocationGPRs = AllocatedGPRs; + bool IsHA = false; bool IsCPRC = false; // 6.1.2.3 There is one VFP co-processor register class using registers // s0-s15 (d0-d7) for passing arguments. - I.info = classifyArgumentType(I.type, FI.isVariadic(), IsCPRC); + I.info = classifyArgumentType(I.type, IsHA, FI.isVariadic(), IsCPRC); + assert((IsCPRC || !IsHA) && "Homogeneous aggregates must be CPRCs"); + // If we do not have enough VFP registers for the HA, any VFP registers + // that are unallocated are marked as unavailable. To achieve this, we add + // padding of (NumVFPs - PreAllocationVFP) floats. + // Note that IsHA will only be set when using the AAPCS-VFP calling convention, + // and the callee is not variadic. + if (IsHA && AllocatedVFPs > NumVFPs && PreAllocationVFPs < NumVFPs) { + llvm::Type *PaddingTy = llvm::ArrayType::get( + llvm::Type::getFloatTy(getVMContext()), NumVFPs - PreAllocationVFPs); + I.info = ABIArgInfo::getExpandWithPadding(false, PaddingTy); + } // If we have allocated some arguments onto the stack (due to running // out of VFP registers), we cannot split an argument between GPRs and @@ -3918,7 +3930,6 @@ void ARMABIInfo::computeInfo(CGFunctionInfo &FI) const { llvm::Type::getInt32Ty(getVMContext()), NumGPRs - PreAllocationGPRs); I.info = ABIArgInfo::getDirect(nullptr /* type */, 0 /* offset */, PaddingTy); - } } @@ -4102,7 +4113,8 @@ void ARMABIInfo::resetAllocatedRegs(void) const { VFPRegs[i] = 0; } -ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty, bool isVariadic, +ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty, bool &IsHA, + bool isVariadic, bool &IsCPRC) const { // We update number of allocated VFPs according to // 6.1.2.1 The following argument types are VFP CPRCs: @@ -4214,8 +4226,9 @@ ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty, bool isVariadic, Base->isSpecificBuiltinType(BuiltinType::LongDouble)); markAllocatedVFPs(2, Members * 2); } + IsHA = true; IsCPRC = true; - return ABIArgInfo::getDirect(); + return ABIArgInfo::getExpand(); } } @@ -4229,7 +4242,7 @@ ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty, bool isVariadic, getABIKind() == ARMABIInfo::AAPCS) ABIAlign = std::min(std::max(TyAlign, (uint64_t)4), (uint64_t)8); if (getContext().getTypeSizeInChars(Ty) > CharUnits::fromQuantity(64)) { - // Update Allocated GPRs + // Update Allocated GPRs markAllocatedGPRs(1, 1); return ABIArgInfo::getIndirect(TyAlign, /*ByVal=*/true, /*Realign=*/TyAlign > ABIAlign); |