//===--- CodeGenTypes.cpp - Type translation for LLVM CodeGen -------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This is the code that handles AST -> LLVM type lowering. // //===----------------------------------------------------------------------===// #include "CodeGenTypes.h" #include "CGCXXABI.h" #include "CGCall.h" #include "CGHLSLRuntime.h" #include "CGOpenCLRuntime.h" #include "CGRecordLayout.h" #include "TargetInfo.h" #include "clang/AST/ASTContext.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclObjC.h" #include "clang/AST/Expr.h" #include "clang/AST/RecordLayout.h" #include "clang/CodeGen/CGFunctionInfo.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Module.h" usingnamespaceclang; usingnamespaceCodeGen; CodeGenTypes::CodeGenTypes(CodeGenModule &cgm) : … { … } CodeGenTypes::~CodeGenTypes() { … } CGCXXABI &CodeGenTypes::getCXXABI() const { … } const CodeGenOptions &CodeGenTypes::getCodeGenOpts() const { … } void CodeGenTypes::addRecordTypeName(const RecordDecl *RD, llvm::StructType *Ty, StringRef suffix) { … } /// ConvertTypeForMem - Convert type T into a llvm::Type. This differs from /// ConvertType in that it is used to convert to the memory representation for /// a type. For example, the scalar representation for _Bool is i1, but the /// memory representation is usually i8 or i32, depending on the target. /// /// We generally assume that the alloc size of this type under the LLVM /// data layout is the same as the size of the AST type. The alignment /// does not have to match: Clang should always use explicit alignments /// and packed structs as necessary to produce the layout it needs. /// But the size does need to be exactly right or else things like struct /// layout will break. llvm::Type *CodeGenTypes::ConvertTypeForMem(QualType T) { … } bool CodeGenTypes::typeRequiresSplitIntoByteArray(QualType ASTTy, llvm::Type *LLVMTy) { … } llvm::Type *CodeGenTypes::convertTypeForLoadStore(QualType T, llvm::Type *LLVMTy) { … } /// isRecordLayoutComplete - Return true if the specified type is already /// completely laid out. bool CodeGenTypes::isRecordLayoutComplete(const Type *Ty) const { … } /// isFuncParamTypeConvertible - Return true if the specified type in a /// function parameter or result position can be converted to an IR type at this /// point. This boils down to being whether it is complete. bool CodeGenTypes::isFuncParamTypeConvertible(QualType Ty) { … } /// Code to verify a given function type is complete, i.e. the return type /// and all of the parameter types are complete. Also check to see if we are in /// a RS_StructPointer context, and if so whether any struct types have been /// pended. If so, we don't want to ask the ABI lowering code to handle a type /// that cannot be converted to an IR type. bool CodeGenTypes::isFuncTypeConvertible(const FunctionType *FT) { … } /// UpdateCompletedType - When we find the full definition for a TagDecl, /// replace the 'opaque' type we previously made for it if applicable. void CodeGenTypes::UpdateCompletedType(const TagDecl *TD) { … } void CodeGenTypes::RefreshTypeCacheForClass(const CXXRecordDecl *RD) { … } static llvm::Type *getTypeForFormat(llvm::LLVMContext &VMContext, const llvm::fltSemantics &format, bool UseNativeHalf = false) { … } llvm::Type *CodeGenTypes::ConvertFunctionTypeInternal(QualType QFT) { … } /// ConvertType - Convert the specified type to its LLVM form. llvm::Type *CodeGenTypes::ConvertType(QualType T) { … } bool CodeGenModule::isPaddedAtomicType(QualType type) { … } bool CodeGenModule::isPaddedAtomicType(const AtomicType *type) { … } /// ConvertRecordDeclType - Lay out a tagged decl type like struct or union. llvm::StructType *CodeGenTypes::ConvertRecordDeclType(const RecordDecl *RD) { … } /// getCGRecordLayout - Return record layout info for the given record decl. const CGRecordLayout & CodeGenTypes::getCGRecordLayout(const RecordDecl *RD) { … } bool CodeGenTypes::isPointerZeroInitializable(QualType T) { … } bool CodeGenTypes::isZeroInitializable(QualType T) { … } bool CodeGenTypes::isZeroInitializable(const RecordDecl *RD) { … } unsigned CodeGenTypes::getTargetAddressSpace(QualType T) const { … }