1 //==---- CodeGenABITypes.h - Convert Clang types to LLVM types for ABI -----==//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // CodeGenABITypes is a simple interface for getting LLVM types for
10 // the parameters and the return value of a function given the Clang
13 // The class is implemented as a public wrapper around the private
14 // CodeGenTypes class in lib/CodeGen.
16 // It allows other clients, like LLDB, to determine the LLVM types that are
17 // actually used in function calls, which makes it possible to then determine
18 // the actual ABI locations (e.g. registers, stack locations, etc.) that
19 // these parameters are stored in.
21 //===----------------------------------------------------------------------===//
23 #ifndef LLVM_CLANG_CODEGEN_CODEGENABITYPES_H
24 #define LLVM_CLANG_CODEGEN_CODEGENABITYPES_H
26 #include "clang/AST/CanonicalType.h"
27 #include "clang/AST/Type.h"
28 #include "clang/CodeGen/CGFunctionInfo.h"
43 class CoverageSourceInfo;
44 class DiagnosticsEngine;
45 class HeaderSearchOptions;
47 class PreprocessorOptions;
53 const CGFunctionInfo &arrangeObjCMessageSendSignature(CodeGenModule &CGM,
54 const ObjCMethodDecl *MD,
55 QualType receiverType);
57 const CGFunctionInfo &arrangeFreeFunctionType(CodeGenModule &CGM,
58 CanQual<FunctionProtoType> Ty);
60 const CGFunctionInfo &arrangeFreeFunctionType(CodeGenModule &CGM,
61 CanQual<FunctionNoProtoType> Ty);
63 const CGFunctionInfo &arrangeCXXMethodType(CodeGenModule &CGM,
64 const CXXRecordDecl *RD,
65 const FunctionProtoType *FTP,
66 const CXXMethodDecl *MD);
68 const CGFunctionInfo &arrangeFreeFunctionCall(CodeGenModule &CGM,
69 CanQualType returnType,
70 ArrayRef<CanQualType> argTypes,
71 FunctionType::ExtInfo info,
74 /// Returns null if the function type is incomplete and can't be lowered.
75 llvm::FunctionType *convertFreeFunctionType(CodeGenModule &CGM,
76 const FunctionDecl *FD);
78 llvm::Type *convertTypeForMemory(CodeGenModule &CGM, QualType T);
80 /// Given a non-bitfield struct field, return its index within the elements of
81 /// the struct's converted type. The returned index refers to a field number in
82 /// the complete object type which is returned by convertTypeForMemory. FD must
83 /// be a field in RD directly (i.e. not an inherited field).
84 unsigned getLLVMFieldNumber(CodeGenModule &CGM,
85 const RecordDecl *RD, const FieldDecl *FD);
87 /// Returns the default constructor for a C struct with non-trivially copyable
88 /// fields, generating it if necessary. The returned function uses the `cdecl`
89 /// calling convention, returns void, and takes a single argument that is a
90 /// pointer to the address of the struct.
91 llvm::Function *getNonTrivialCStructDefaultConstructor(CodeGenModule &GCM,
92 CharUnits DstAlignment,
96 /// Returns the copy constructor for a C struct with non-trivially copyable
97 /// fields, generating it if necessary. The returned function uses the `cdecl`
98 /// calling convention, returns void, and takes two arguments: pointers to the
99 /// addresses of the destination and source structs, respectively.
100 llvm::Function *getNonTrivialCStructCopyConstructor(CodeGenModule &CGM,
101 CharUnits DstAlignment,
102 CharUnits SrcAlignment,
106 /// Returns the move constructor for a C struct with non-trivially copyable
107 /// fields, generating it if necessary. The returned function uses the `cdecl`
108 /// calling convention, returns void, and takes two arguments: pointers to the
109 /// addresses of the destination and source structs, respectively.
110 llvm::Function *getNonTrivialCStructMoveConstructor(CodeGenModule &CGM,
111 CharUnits DstAlignment,
112 CharUnits SrcAlignment,
116 /// Returns the copy assignment operator for a C struct with non-trivially
117 /// copyable fields, generating it if necessary. The returned function uses the
118 /// `cdecl` calling convention, returns void, and takes two arguments: pointers
119 /// to the addresses of the destination and source structs, respectively.
120 llvm::Function *getNonTrivialCStructCopyAssignmentOperator(
121 CodeGenModule &CGM, CharUnits DstAlignment, CharUnits SrcAlignment,
122 bool IsVolatile, QualType QT);
124 /// Return the move assignment operator for a C struct with non-trivially
125 /// copyable fields, generating it if necessary. The returned function uses the
126 /// `cdecl` calling convention, returns void, and takes two arguments: pointers
127 /// to the addresses of the destination and source structs, respectively.
128 llvm::Function *getNonTrivialCStructMoveAssignmentOperator(
129 CodeGenModule &CGM, CharUnits DstAlignment, CharUnits SrcAlignment,
130 bool IsVolatile, QualType QT);
132 /// Returns the destructor for a C struct with non-trivially copyable fields,
133 /// generating it if necessary. The returned function uses the `cdecl` calling
134 /// convention, returns void, and takes a single argument that is a pointer to
135 /// the address of the struct.
136 llvm::Function *getNonTrivialCStructDestructor(CodeGenModule &CGM,
137 CharUnits DstAlignment,
138 bool IsVolatile, QualType QT);
140 } // end namespace CodeGen
141 } // end namespace clang