|
|
|||
File indexing completed on 2026-05-10 08:36:52
0001 //==---- CodeGenABITypes.h - Convert Clang types to LLVM types for ABI -----==// 0002 // 0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0004 // See https://llvm.org/LICENSE.txt for license information. 0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0006 // 0007 //===----------------------------------------------------------------------===// 0008 // 0009 // CodeGenABITypes is a simple interface for getting LLVM types for 0010 // the parameters and the return value of a function given the Clang 0011 // types. 0012 // 0013 // The class is implemented as a public wrapper around the private 0014 // CodeGenTypes class in lib/CodeGen. 0015 // 0016 // It allows other clients, like LLDB, to determine the LLVM types that are 0017 // actually used in function calls, which makes it possible to then determine 0018 // the actual ABI locations (e.g. registers, stack locations, etc.) that 0019 // these parameters are stored in. 0020 // 0021 //===----------------------------------------------------------------------===// 0022 0023 #ifndef LLVM_CLANG_CODEGEN_CODEGENABITYPES_H 0024 #define LLVM_CLANG_CODEGEN_CODEGENABITYPES_H 0025 0026 #include "clang/AST/CanonicalType.h" 0027 #include "clang/AST/Type.h" 0028 #include "clang/Basic/ABI.h" 0029 #include "clang/CodeGen/CGFunctionInfo.h" 0030 #include "llvm/IR/BasicBlock.h" 0031 0032 namespace llvm { 0033 class AttrBuilder; 0034 class Constant; 0035 class Function; 0036 class FunctionType; 0037 class Type; 0038 } 0039 0040 namespace clang { 0041 class CXXConstructorDecl; 0042 class CXXDestructorDecl; 0043 class CXXRecordDecl; 0044 class CXXMethodDecl; 0045 class GlobalDecl; 0046 class ObjCMethodDecl; 0047 class ObjCProtocolDecl; 0048 0049 namespace CodeGen { 0050 class CGFunctionInfo; 0051 class CodeGenModule; 0052 0053 /// Additional implicit arguments to add to a constructor argument list. 0054 struct ImplicitCXXConstructorArgs { 0055 /// Implicit arguments to add before the explicit arguments, but after the 0056 /// `*this` argument (which always comes first). 0057 SmallVector<llvm::Value *, 1> Prefix; 0058 0059 /// Implicit arguments to add after the explicit arguments. 0060 SmallVector<llvm::Value *, 1> Suffix; 0061 }; 0062 0063 const CGFunctionInfo &arrangeObjCMessageSendSignature(CodeGenModule &CGM, 0064 const ObjCMethodDecl *MD, 0065 QualType receiverType); 0066 0067 const CGFunctionInfo &arrangeFreeFunctionType(CodeGenModule &CGM, 0068 CanQual<FunctionProtoType> Ty); 0069 0070 const CGFunctionInfo &arrangeFreeFunctionType(CodeGenModule &CGM, 0071 CanQual<FunctionNoProtoType> Ty); 0072 0073 const CGFunctionInfo &arrangeCXXMethodType(CodeGenModule &CGM, 0074 const CXXRecordDecl *RD, 0075 const FunctionProtoType *FTP, 0076 const CXXMethodDecl *MD); 0077 0078 const CGFunctionInfo & 0079 arrangeCXXMethodCall(CodeGenModule &CGM, CanQualType returnType, 0080 ArrayRef<CanQualType> argTypes, FunctionType::ExtInfo info, 0081 ArrayRef<FunctionProtoType::ExtParameterInfo> paramInfos, 0082 RequiredArgs args); 0083 0084 const CGFunctionInfo &arrangeFreeFunctionCall( 0085 CodeGenModule &CGM, CanQualType returnType, ArrayRef<CanQualType> argTypes, 0086 FunctionType::ExtInfo info, 0087 ArrayRef<FunctionProtoType::ExtParameterInfo> paramInfos, 0088 RequiredArgs args); 0089 0090 // An overload with an empty `paramInfos` 0091 inline const CGFunctionInfo & 0092 arrangeFreeFunctionCall(CodeGenModule &CGM, CanQualType returnType, 0093 ArrayRef<CanQualType> argTypes, 0094 FunctionType::ExtInfo info, RequiredArgs args) { 0095 return arrangeFreeFunctionCall(CGM, returnType, argTypes, info, {}, args); 0096 } 0097 0098 /// Returns the implicit arguments to add to a complete, non-delegating C++ 0099 /// constructor call. 0100 ImplicitCXXConstructorArgs 0101 getImplicitCXXConstructorArgs(CodeGenModule &CGM, const CXXConstructorDecl *D); 0102 0103 llvm::Value * 0104 getCXXDestructorImplicitParam(CodeGenModule &CGM, llvm::BasicBlock *InsertBlock, 0105 llvm::BasicBlock::iterator InsertPoint, 0106 const CXXDestructorDecl *D, CXXDtorType Type, 0107 bool ForVirtualBase, bool Delegating); 0108 0109 /// Returns null if the function type is incomplete and can't be lowered. 0110 llvm::FunctionType *convertFreeFunctionType(CodeGenModule &CGM, 0111 const FunctionDecl *FD); 0112 0113 llvm::Type *convertTypeForMemory(CodeGenModule &CGM, QualType T); 0114 0115 /// Given a non-bitfield struct field, return its index within the elements of 0116 /// the struct's converted type. The returned index refers to a field number in 0117 /// the complete object type which is returned by convertTypeForMemory. FD must 0118 /// be a field in RD directly (i.e. not an inherited field). 0119 unsigned getLLVMFieldNumber(CodeGenModule &CGM, 0120 const RecordDecl *RD, const FieldDecl *FD); 0121 0122 /// Return a declaration discriminator for the given global decl. 0123 uint16_t getPointerAuthDeclDiscriminator(CodeGenModule &CGM, GlobalDecl GD); 0124 0125 /// Return a type discriminator for the given function type. 0126 uint16_t getPointerAuthTypeDiscriminator(CodeGenModule &CGM, 0127 QualType FunctionType); 0128 0129 /// Given the language and code-generation options that Clang was configured 0130 /// with, set the default LLVM IR attributes for a function definition. 0131 /// The attributes set here are mostly global target-configuration and 0132 /// pipeline-configuration options like the target CPU, variant stack 0133 /// rules, whether to optimize for size, and so on. This is useful for 0134 /// frontends (such as Swift) that generally intend to interoperate with 0135 /// C code and rely on Clang's target configuration logic. 0136 /// 0137 /// As a general rule, this function assumes that meaningful attributes 0138 /// haven't already been added to the builder. It won't intentionally 0139 /// displace any existing attributes, but it also won't check to avoid 0140 /// overwriting them. Callers should generally apply customizations after 0141 /// making this call. 0142 /// 0143 /// This function assumes that the caller is not defining a function that 0144 /// requires special no-builtin treatment. 0145 void addDefaultFunctionDefinitionAttributes(CodeGenModule &CGM, 0146 llvm::AttrBuilder &attrs); 0147 0148 /// Returns the default constructor for a C struct with non-trivially copyable 0149 /// fields, generating it if necessary. The returned function uses the `cdecl` 0150 /// calling convention, returns void, and takes a single argument that is a 0151 /// pointer to the address of the struct. 0152 llvm::Function *getNonTrivialCStructDefaultConstructor(CodeGenModule &GCM, 0153 CharUnits DstAlignment, 0154 bool IsVolatile, 0155 QualType QT); 0156 0157 /// Returns the copy constructor for a C struct with non-trivially copyable 0158 /// fields, generating it if necessary. The returned function uses the `cdecl` 0159 /// calling convention, returns void, and takes two arguments: pointers to the 0160 /// addresses of the destination and source structs, respectively. 0161 llvm::Function *getNonTrivialCStructCopyConstructor(CodeGenModule &CGM, 0162 CharUnits DstAlignment, 0163 CharUnits SrcAlignment, 0164 bool IsVolatile, 0165 QualType QT); 0166 0167 /// Returns the move constructor for a C struct with non-trivially copyable 0168 /// fields, generating it if necessary. The returned function uses the `cdecl` 0169 /// calling convention, returns void, and takes two arguments: pointers to the 0170 /// addresses of the destination and source structs, respectively. 0171 llvm::Function *getNonTrivialCStructMoveConstructor(CodeGenModule &CGM, 0172 CharUnits DstAlignment, 0173 CharUnits SrcAlignment, 0174 bool IsVolatile, 0175 QualType QT); 0176 0177 /// Returns the copy assignment operator for a C struct with non-trivially 0178 /// copyable fields, generating it if necessary. The returned function uses the 0179 /// `cdecl` calling convention, returns void, and takes two arguments: pointers 0180 /// to the addresses of the destination and source structs, respectively. 0181 llvm::Function *getNonTrivialCStructCopyAssignmentOperator( 0182 CodeGenModule &CGM, CharUnits DstAlignment, CharUnits SrcAlignment, 0183 bool IsVolatile, QualType QT); 0184 0185 /// Return the move assignment operator for a C struct with non-trivially 0186 /// copyable fields, generating it if necessary. The returned function uses the 0187 /// `cdecl` calling convention, returns void, and takes two arguments: pointers 0188 /// to the addresses of the destination and source structs, respectively. 0189 llvm::Function *getNonTrivialCStructMoveAssignmentOperator( 0190 CodeGenModule &CGM, CharUnits DstAlignment, CharUnits SrcAlignment, 0191 bool IsVolatile, QualType QT); 0192 0193 /// Returns the destructor for a C struct with non-trivially copyable fields, 0194 /// generating it if necessary. The returned function uses the `cdecl` calling 0195 /// convention, returns void, and takes a single argument that is a pointer to 0196 /// the address of the struct. 0197 llvm::Function *getNonTrivialCStructDestructor(CodeGenModule &CGM, 0198 CharUnits DstAlignment, 0199 bool IsVolatile, QualType QT); 0200 0201 /// Get a pointer to a protocol object for the given declaration, emitting it if 0202 /// it hasn't already been emitted in this translation unit. Note that the ABI 0203 /// for emitting a protocol reference in code (e.g. for a protocol expression) 0204 /// in most runtimes is not as simple as just materializing a pointer to this 0205 /// object. 0206 llvm::Constant *emitObjCProtocolObject(CodeGenModule &CGM, 0207 const ObjCProtocolDecl *p); 0208 } // end namespace CodeGen 0209 } // end namespace clang 0210 0211 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|