Subversion Repositories QNX 8.QNX8 LLVM/Clang compiler suite

Rev

Blame | Last modification | View Log | Download | RSS feed

  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.  
  26. #include "clang/AST/CanonicalType.h"
  27. #include "clang/AST/Type.h"
  28. #include "clang/Basic/ABI.h"
  29. #include "clang/CodeGen/CGFunctionInfo.h"
  30. #include "llvm/IR/BasicBlock.h"
  31.  
  32. namespace llvm {
  33. class AttrBuilder;
  34. class Constant;
  35. class Function;
  36. class FunctionType;
  37. class Type;
  38. }
  39.  
  40. namespace clang {
  41. class CXXConstructorDecl;
  42. class CXXDestructorDecl;
  43. class CXXRecordDecl;
  44. class CXXMethodDecl;
  45. class ObjCMethodDecl;
  46. class ObjCProtocolDecl;
  47.  
  48. namespace CodeGen {
  49. class CGFunctionInfo;
  50. class CodeGenModule;
  51.  
  52. /// Additional implicit arguments to add to a constructor argument list.
  53. struct ImplicitCXXConstructorArgs {
  54.   /// Implicit arguments to add before the explicit arguments, but after the
  55.   /// `*this` argument (which always comes first).
  56.   SmallVector<llvm::Value *, 1> Prefix;
  57.  
  58.   /// Implicit arguments to add after the explicit arguments.
  59.   SmallVector<llvm::Value *, 1> Suffix;
  60. };
  61.  
  62. const CGFunctionInfo &arrangeObjCMessageSendSignature(CodeGenModule &CGM,
  63.                                                       const ObjCMethodDecl *MD,
  64.                                                       QualType receiverType);
  65.  
  66. const CGFunctionInfo &arrangeFreeFunctionType(CodeGenModule &CGM,
  67.                                               CanQual<FunctionProtoType> Ty);
  68.  
  69. const CGFunctionInfo &arrangeFreeFunctionType(CodeGenModule &CGM,
  70.                                               CanQual<FunctionNoProtoType> Ty);
  71.  
  72. const CGFunctionInfo &arrangeCXXMethodType(CodeGenModule &CGM,
  73.                                            const CXXRecordDecl *RD,
  74.                                            const FunctionProtoType *FTP,
  75.                                            const CXXMethodDecl *MD);
  76.  
  77. const CGFunctionInfo &arrangeFreeFunctionCall(CodeGenModule &CGM,
  78.                                               CanQualType returnType,
  79.                                               ArrayRef<CanQualType> argTypes,
  80.                                               FunctionType::ExtInfo info,
  81.                                               RequiredArgs args);
  82.  
  83. /// Returns the implicit arguments to add to a complete, non-delegating C++
  84. /// constructor call.
  85. ImplicitCXXConstructorArgs
  86. getImplicitCXXConstructorArgs(CodeGenModule &CGM, const CXXConstructorDecl *D);
  87.  
  88. llvm::Value *
  89. getCXXDestructorImplicitParam(CodeGenModule &CGM, llvm::BasicBlock *InsertBlock,
  90.                               llvm::BasicBlock::iterator InsertPoint,
  91.                               const CXXDestructorDecl *D, CXXDtorType Type,
  92.                               bool ForVirtualBase, bool Delegating);
  93.  
  94. /// Returns null if the function type is incomplete and can't be lowered.
  95. llvm::FunctionType *convertFreeFunctionType(CodeGenModule &CGM,
  96.                                             const FunctionDecl *FD);
  97.  
  98. llvm::Type *convertTypeForMemory(CodeGenModule &CGM, QualType T);
  99.  
  100. /// Given a non-bitfield struct field, return its index within the elements of
  101. /// the struct's converted type.  The returned index refers to a field number in
  102. /// the complete object type which is returned by convertTypeForMemory.  FD must
  103. /// be a field in RD directly (i.e. not an inherited field).
  104. unsigned getLLVMFieldNumber(CodeGenModule &CGM,
  105.                             const RecordDecl *RD, const FieldDecl *FD);
  106.  
  107. /// Given the language and code-generation options that Clang was configured
  108. /// with, set the default LLVM IR attributes for a function definition.
  109. /// The attributes set here are mostly global target-configuration and
  110. /// pipeline-configuration options like the target CPU, variant stack
  111. /// rules, whether to optimize for size, and so on.  This is useful for
  112. /// frontends (such as Swift) that generally intend to interoperate with
  113. /// C code and rely on Clang's target configuration logic.
  114. ///
  115. /// As a general rule, this function assumes that meaningful attributes
  116. /// haven't already been added to the builder.  It won't intentionally
  117. /// displace any existing attributes, but it also won't check to avoid
  118. /// overwriting them.  Callers should generally apply customizations after
  119. /// making this call.
  120. ///
  121. /// This function assumes that the caller is not defining a function that
  122. /// requires special no-builtin treatment.
  123. void addDefaultFunctionDefinitionAttributes(CodeGenModule &CGM,
  124.                                             llvm::AttrBuilder &attrs);
  125.  
  126. /// Returns the default constructor for a C struct with non-trivially copyable
  127. /// fields, generating it if necessary. The returned function uses the `cdecl`
  128. /// calling convention, returns void, and takes a single argument that is a
  129. /// pointer to the address of the struct.
  130. llvm::Function *getNonTrivialCStructDefaultConstructor(CodeGenModule &GCM,
  131.                                                        CharUnits DstAlignment,
  132.                                                        bool IsVolatile,
  133.                                                        QualType QT);
  134.  
  135. /// Returns the copy constructor for a C struct with non-trivially copyable
  136. /// fields, generating it if necessary. The returned function uses the `cdecl`
  137. /// calling convention, returns void, and takes two arguments: pointers to the
  138. /// addresses of the destination and source structs, respectively.
  139. llvm::Function *getNonTrivialCStructCopyConstructor(CodeGenModule &CGM,
  140.                                                     CharUnits DstAlignment,
  141.                                                     CharUnits SrcAlignment,
  142.                                                     bool IsVolatile,
  143.                                                     QualType QT);
  144.  
  145. /// Returns the move constructor for a C struct with non-trivially copyable
  146. /// fields, generating it if necessary. The returned function uses the `cdecl`
  147. /// calling convention, returns void, and takes two arguments: pointers to the
  148. /// addresses of the destination and source structs, respectively.
  149. llvm::Function *getNonTrivialCStructMoveConstructor(CodeGenModule &CGM,
  150.                                                     CharUnits DstAlignment,
  151.                                                     CharUnits SrcAlignment,
  152.                                                     bool IsVolatile,
  153.                                                     QualType QT);
  154.  
  155. /// Returns the copy assignment operator for a C struct with non-trivially
  156. /// copyable fields, generating it if necessary. The returned function uses the
  157. /// `cdecl` calling convention, returns void, and takes two arguments: pointers
  158. /// to the addresses of the destination and source structs, respectively.
  159. llvm::Function *getNonTrivialCStructCopyAssignmentOperator(
  160.     CodeGenModule &CGM, CharUnits DstAlignment, CharUnits SrcAlignment,
  161.     bool IsVolatile, QualType QT);
  162.  
  163. /// Return the move assignment operator for a C struct with non-trivially
  164. /// copyable fields, generating it if necessary. The returned function uses the
  165. /// `cdecl` calling convention, returns void, and takes two arguments: pointers
  166. /// to the addresses of the destination and source structs, respectively.
  167. llvm::Function *getNonTrivialCStructMoveAssignmentOperator(
  168.     CodeGenModule &CGM, CharUnits DstAlignment, CharUnits SrcAlignment,
  169.     bool IsVolatile, QualType QT);
  170.  
  171. /// Returns the destructor for a C struct with non-trivially copyable fields,
  172. /// generating it if necessary. The returned function uses the `cdecl` calling
  173. /// convention, returns void, and takes a single argument that is a pointer to
  174. /// the address of the struct.
  175. llvm::Function *getNonTrivialCStructDestructor(CodeGenModule &CGM,
  176.                                                CharUnits DstAlignment,
  177.                                                bool IsVolatile, QualType QT);
  178.  
  179. /// Get a pointer to a protocol object for the given declaration, emitting it if
  180. /// it hasn't already been emitted in this translation unit. Note that the ABI
  181. /// for emitting a protocol reference in code (e.g. for a protocol expression)
  182. /// in most runtimes is not as simple as just materializing a pointer to this
  183. /// object.
  184. llvm::Constant *emitObjCProtocolObject(CodeGenModule &CGM,
  185.                                        const ObjCProtocolDecl *p);
  186. }  // end namespace CodeGen
  187. }  // end namespace clang
  188.  
  189. #endif
  190.