Lines Matching +full:loongson +full:- +full:1 +full:c

1 //===- LoongArch.cpp ------------------------------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
16 // https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html
18 //===----------------------------------------------------------------------===//
27 // Number of general-purpose argument registers.
29 // Number of floating-point argument registers.
74 if (!IsRetIndirect && RetTy->isScalarType() && in computeInfo()
76 if (RetTy->isComplexType() && FRLen) { in computeInfo()
77 QualType EltTy = RetTy->castAs<ComplexType>()->getElementType(); in computeInfo()
88 int GARsLeft = IsRetIndirect ? NumGARs - 1 : NumGARs; in computeInfo()
106 bool IsInt = Ty->isIntegralOrEnumerationType(); in detectFARsEligibleStructHelper()
107 bool IsFloat = Ty->isRealFloatingType(); in detectFARsEligibleStructHelper()
120 if (IsInt && Field1Ty && Field1Ty->isIntegerTy()) in detectFARsEligibleStructHelper()
135 if (auto CTy = Ty->getAs<ComplexType>()) { in detectFARsEligibleStructHelper()
138 QualType EltTy = CTy->getElementType(); in detectFARsEligibleStructHelper()
149 uint64_t ArraySize = ATy->getZExtSize(); in detectFARsEligibleStructHelper()
150 QualType EltTy = ATy->getElementType(); in detectFARsEligibleStructHelper()
151 // Non-zero-length arrays of empty records make the struct ineligible to be in detectFARsEligibleStructHelper()
152 // passed via FARs in C++. in detectFARsEligibleStructHelper()
153 if (const auto *RTy = EltTy->getAs<RecordType>()) { in detectFARsEligibleStructHelper()
154 if (ArraySize != 0 && isa<CXXRecordDecl>(RTy->getDecl()) && in detectFARsEligibleStructHelper()
168 if (const auto *RTy = Ty->getAs<RecordType>()) { in detectFARsEligibleStructHelper()
169 // Structures with either a non-trivial destructor or a non-trivial in detectFARsEligibleStructHelper()
173 const RecordDecl *RD = RTy->getDecl(); in detectFARsEligibleStructHelper()
175 (!RD->isUnion() || !isa<CXXRecordDecl>(RD))) in detectFARsEligibleStructHelper()
177 // Unions aren't eligible unless they're empty in C (which is caught above). in detectFARsEligibleStructHelper()
178 if (RD->isUnion()) in detectFARsEligibleStructHelper()
181 // If this is a C++ record, check the bases first. in detectFARsEligibleStructHelper()
183 for (const CXXBaseSpecifier &B : CXXRD->bases()) { in detectFARsEligibleStructHelper()
185 cast<CXXRecordDecl>(B.getType()->castAs<RecordType>()->getDecl()); in detectFARsEligibleStructHelper()
192 for (const FieldDecl *FD : RD->fields()) { in detectFARsEligibleStructHelper()
193 QualType QTy = FD->getType(); in detectFARsEligibleStructHelper()
194 if (FD->isBitField()) { in detectFARsEligibleStructHelper()
195 unsigned BitWidth = FD->getBitWidthValue(getContext()); in detectFARsEligibleStructHelper()
196 // Zero-width bitfields are ignored. in detectFARsEligibleStructHelper()
209 Layout.getFieldOffset(FD->getFieldIndex())), in detectFARsEligibleStructHelper()
236 if (Field1Ty && !Field2Ty && !Field1Ty->isFloatingPointTy()) in detectFARsEligibleStruct()
238 if (Field1Ty && Field1Ty->isFloatingPointTy()) in detectFARsEligibleStruct()
242 if (Field2Ty && Field2Ty->isFloatingPointTy()) in detectFARsEligibleStruct()
249 // Call getCoerceAndExpand for the two-element flattened struct described by
279 Padding = Field2Off - Field2OffNoPadNoPack; in coerceAndExpandFARsEligibleStruct()
281 Padding = Field2Off - Field1End; in coerceAndExpandFARsEligibleStruct()
303 // Structures with either a non-trivial destructor or a non-trivial in classifyArgumentType()
307 GARsLeft -= 1; in classifyArgumentType()
314 // Ignore empty struct or union whose size is zero, e.g. `struct { }` in C or in classifyArgumentType()
315 // `struct { int a[0]; }` in C++. In C++, `struct { }` is empty but it's size in classifyArgumentType()
316 // is 1 byte and g++ doesn't ignore it; clang++ matches this behaviour. in classifyArgumentType()
321 if (IsFixed && Ty->isFloatingType() && !Ty->isComplexType() && in classifyArgumentType()
323 FARsLeft--; in classifyArgumentType()
329 if (IsFixed && Ty->isComplexType() && FRLen && FARsLeft >= 2) { in classifyArgumentType()
330 QualType EltTy = Ty->castAs<ComplexType>()->getElementType(); in classifyArgumentType()
332 FARsLeft -= 2; in classifyArgumentType()
337 if (IsFixed && FRLen && Ty->isStructureOrClassType()) { in classifyArgumentType()
347 GARsLeft -= NeededGARs; in classifyArgumentType()
348 FARsLeft -= NeededFARs; in classifyArgumentType()
356 // according to the ABI. 2*GRLen-aligned varargs are passed in "aligned" in classifyArgumentType()
358 int NeededGARs = 1; in classifyArgumentType()
367 GARsLeft -= NeededGARs; in classifyArgumentType()
369 if (!isAggregateTypeForABI(Ty) && !Ty->isVectorType()) { in classifyArgumentType()
371 if (const EnumType *EnumTy = Ty->getAs<EnumType>()) in classifyArgumentType()
372 Ty = EnumTy->getDecl()->getIntegerType(); in classifyArgumentType()
375 if (Size < GRLen && Ty->isIntegralOrEnumerationType()) in classifyArgumentType()
378 if (const auto *EIT = Ty->getAs<BitIntType>()) { in classifyArgumentType()
379 if (EIT->getNumBits() < GRLen) in classifyArgumentType()
381 if (EIT->getNumBits() > 128 || in classifyArgumentType()
383 EIT->getNumBits() > 64)) in classifyArgumentType()
394 // required, and a 2-element GRLen array if only GRLen alignment is in classifyArgumentType()
411 if (RetTy->isVoidType()) in classifyReturnType()
440 if (GRLen == 64 && Ty->isUnsignedIntegerOrEnumerationType() && TySize == 32) in extendType()