clang  10.0.0svn
CodeGenABITypes.h
Go to the documentation of this file.
1 //==---- CodeGenABITypes.h - Convert Clang types to LLVM types for ABI -----==//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // CodeGenABITypes is a simple interface for getting LLVM types for
10 // the parameters and the return value of a function given the Clang
11 // types.
12 //
13 // The class is implemented as a public wrapper around the private
14 // CodeGenTypes class in lib/CodeGen.
15 //
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.
20 //
21 //===----------------------------------------------------------------------===//
22 
23 #ifndef LLVM_CLANG_CODEGEN_CODEGENABITYPES_H
24 #define LLVM_CLANG_CODEGEN_CODEGENABITYPES_H
25 
27 #include "clang/AST/Type.h"
29 
30 namespace llvm {
31  class DataLayout;
32  class Module;
33  class Function;
34  class FunctionType;
35  class Type;
36 }
37 
38 namespace clang {
39 class ASTContext;
40 class CXXRecordDecl;
41 class CXXMethodDecl;
42 class CodeGenOptions;
43 class CoverageSourceInfo;
44 class DiagnosticsEngine;
45 class HeaderSearchOptions;
46 class ObjCMethodDecl;
47 class PreprocessorOptions;
48 
49 namespace CodeGen {
50 class CGFunctionInfo;
51 class CodeGenModule;
52 
53 const CGFunctionInfo &arrangeObjCMessageSendSignature(CodeGenModule &CGM,
54  const ObjCMethodDecl *MD,
55  QualType receiverType);
56 
57 const CGFunctionInfo &arrangeFreeFunctionType(CodeGenModule &CGM,
58  CanQual<FunctionProtoType> Ty);
59 
60 const CGFunctionInfo &arrangeFreeFunctionType(CodeGenModule &CGM,
61  CanQual<FunctionNoProtoType> Ty);
62 
63 const CGFunctionInfo &arrangeCXXMethodType(CodeGenModule &CGM,
64  const CXXRecordDecl *RD,
65  const FunctionProtoType *FTP,
66  const CXXMethodDecl *MD);
67 
68 const CGFunctionInfo &arrangeFreeFunctionCall(CodeGenModule &CGM,
69  CanQualType returnType,
70  ArrayRef<CanQualType> argTypes,
71  FunctionType::ExtInfo info,
72  RequiredArgs args);
73 
74 /// Returns null if the function type is incomplete and can't be lowered.
75 llvm::FunctionType *convertFreeFunctionType(CodeGenModule &CGM,
76  const FunctionDecl *FD);
77 
78 llvm::Type *convertTypeForMemory(CodeGenModule &CGM, QualType T);
79 
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);
86 
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,
93  bool IsVolatile,
94  QualType QT);
95 
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,
103  bool IsVolatile,
104  QualType QT);
105 
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,
113  bool IsVolatile,
114  QualType QT);
115 
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.
121  CodeGenModule &CGM, CharUnits DstAlignment, CharUnits SrcAlignment,
122  bool IsVolatile, QualType QT);
123 
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.
129  CodeGenModule &CGM, CharUnits DstAlignment, CharUnits SrcAlignment,
130  bool IsVolatile, QualType QT);
131 
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);
139 
140 } // end namespace CodeGen
141 } // end namespace clang
142 
143 #endif
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion...
Definition: Dominators.h:30
C Language Family Type Representation.
constexpr XRayInstrMask Function
Definition: XRayInstr.h:38
const CGFunctionInfo & arrangeCXXMethodType(CodeGenModule &CGM, const CXXRecordDecl *RD, const FunctionProtoType *FTP, const CXXMethodDecl *MD)
llvm::Function * getNonTrivialCStructCopyConstructor(CodeGenModule &CGM, CharUnits DstAlignment, CharUnits SrcAlignment, bool IsVolatile, QualType QT)
Returns the copy constructor for a C struct with non-trivially copyable fields, generating it if nece...
const CGFunctionInfo & arrangeObjCMessageSendSignature(CodeGenModule &CGM, const ObjCMethodDecl *MD, QualType receiverType)
llvm::FunctionType * convertFreeFunctionType(CodeGenModule &CGM, const FunctionDecl *FD)
Returns null if the function type is incomplete and can&#39;t be lowered.
llvm::Function * getNonTrivialCStructMoveAssignmentOperator(CodeGenModule &CGM, CharUnits DstAlignment, CharUnits SrcAlignment, bool IsVolatile, QualType QT)
Return the move assignment operator for a C struct with non-trivially copyable fields, generating it if necessary.
const CGFunctionInfo & arrangeFreeFunctionCall(CodeGenModule &CGM, CanQualType returnType, ArrayRef< CanQualType > argTypes, FunctionType::ExtInfo info, RequiredArgs args)
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
const CGFunctionInfo & arrangeFreeFunctionType(CodeGenModule &CGM, CanQual< FunctionNoProtoType > Ty)
llvm::Function * getNonTrivialCStructDestructor(CodeGenModule &CGM, CharUnits DstAlignment, bool IsVolatile, QualType QT)
Returns the destructor for a C struct with non-trivially copyable fields, generating it if necessary...
Optional< types::ID > Type
Dataflow Directional Tag Classes.
llvm::Function * getNonTrivialCStructDefaultConstructor(CodeGenModule &GCM, CharUnits DstAlignment, bool IsVolatile, QualType QT)
Returns the default constructor for a C struct with non-trivially copyable fields, generating it if necessary.
llvm::Function * getNonTrivialCStructCopyAssignmentOperator(CodeGenModule &CGM, CharUnits DstAlignment, CharUnits SrcAlignment, bool IsVolatile, QualType QT)
Returns the copy assignment operator for a C struct with non-trivially copyable fields, generating it if necessary.
unsigned getLLVMFieldNumber(CodeGenModule &CGM, const RecordDecl *RD, const FieldDecl *FD)
Given a non-bitfield struct field, return its index within the elements of the struct&#39;s converted typ...
llvm::Type * convertTypeForMemory(CodeGenModule &CGM, QualType T)
llvm::Function * getNonTrivialCStructMoveConstructor(CodeGenModule &CGM, CharUnits DstAlignment, CharUnits SrcAlignment, bool IsVolatile, QualType QT)
Returns the move constructor for a C struct with non-trivially copyable fields, generating it if nece...