clang  9.0.0svn
CodeGenABITypes.cpp
Go to the documentation of this file.
1 //==--- CodeGenABITypes.cpp - Convert Clang types to LLVM types for ABI ----==//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // CodeGenABITypes is a simple interface for getting LLVM types for
11 // the parameters and the return value of a function given the Clang
12 // types.
13 //
14 // The class is implemented as a public wrapper around the private
15 // CodeGenTypes class in lib/CodeGen.
16 //
17 //===----------------------------------------------------------------------===//
18 
20 #include "CGRecordLayout.h"
21 #include "CodeGenModule.h"
25 
26 using namespace clang;
27 using namespace CodeGen;
28 
29 const CGFunctionInfo &
31  const ObjCMethodDecl *MD,
32  QualType receiverType) {
33  return CGM.getTypes().arrangeObjCMessageSendSignature(MD, receiverType);
34 }
35 
36 const CGFunctionInfo &
39  const FunctionDecl *FD) {
40  return CGM.getTypes().arrangeFreeFunctionType(Ty, FD);
41 }
42 
43 const CGFunctionInfo &
46  return CGM.getTypes().arrangeFreeFunctionType(Ty);
47 }
48 
49 const CGFunctionInfo &
51  const CXXRecordDecl *RD,
52  const FunctionProtoType *FTP,
53  const CXXMethodDecl *MD) {
54  return CGM.getTypes().arrangeCXXMethodType(RD, FTP, MD);
55 }
56 
57 const CGFunctionInfo &
59  CanQualType returnType,
60  ArrayRef<CanQualType> argTypes,
62  RequiredArgs args) {
63  return CGM.getTypes().arrangeLLVMFunctionInfo(
64  returnType, /*IsInstanceMethod=*/false, /*IsChainCall=*/false, argTypes,
65  info, {}, args);
66 }
67 
68 llvm::FunctionType *
70  assert(FD != nullptr && "Expected a non-null function declaration!");
71  llvm::Type *T = CGM.getTypes().ConvertFunctionType(FD->getType(), FD);
72 
73  if (auto FT = dyn_cast<llvm::FunctionType>(T))
74  return FT;
75 
76  return nullptr;
77 }
78 
79 llvm::Type *
81  return CGM.getTypes().ConvertTypeForMem(T);
82 }
83 
85  const RecordDecl *RD,
86  const FieldDecl *FD) {
87  return CGM.getTypes().getCGRecordLayout(RD).getLLVMFieldNo(FD);
88 }
Represents a function declaration or definition.
Definition: Decl.h:1738
A (possibly-)qualified type.
Definition: Type.h:638
const CGFunctionInfo & arrangeFreeFunctionType(CanQual< FunctionProtoType > Ty, const FunctionDecl *FD)
Arrange the argument and result information for a value of the given freestanding function type...
Definition: CGCall.cpp:190
const CGFunctionInfo & arrangeCXXMethodType(const CXXRecordDecl *RD, const FunctionProtoType *FTP, const CXXMethodDecl *MD)
Arrange the argument and result information for a call to an unknown C++ non-static member function o...
Definition: CGCall.cpp:248
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:139
const CGFunctionInfo & arrangeCXXMethodType(CodeGenModule &CGM, const CXXRecordDecl *RD, const FunctionProtoType *FTP, const CXXMethodDecl *MD)
llvm::Type * ConvertTypeForMem(QualType T)
ConvertTypeForMem - Convert type T into a llvm::Type.
Represents a struct/union/class.
Definition: Decl.h:3593
Represents a member of a struct/union/class.
Definition: Decl.h:2579
const CGFunctionInfo & arrangeFreeFunctionType(CodeGenModule &CGM, CanQual< FunctionProtoType > Ty, const FunctionDecl *FD)
const CGFunctionInfo & arrangeObjCMessageSendSignature(const ObjCMethodDecl *MD, QualType receiverType)
Arrange the argument and result information for the function type through which to perform a send to ...
Definition: CGCall.cpp:474
const CGFunctionInfo & arrangeLLVMFunctionInfo(CanQualType returnType, bool instanceMethod, bool chainCall, ArrayRef< CanQualType > argTypes, FunctionType::ExtInfo info, ArrayRef< FunctionProtoType::ExtParameterInfo > paramInfos, RequiredArgs args)
"Arrange" the LLVM information for a call or type with the given signature.
Definition: CGCall.cpp:743
const CGFunctionInfo & arrangeObjCMessageSendSignature(CodeGenModule &CGM, const ObjCMethodDecl *MD, QualType receiverType)
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3690
A class for recording the number of arguments that a function signature requires. ...
llvm::FunctionType * convertFreeFunctionType(CodeGenModule &CGM, const FunctionDecl *FD)
Returns null if the function type is incomplete and can&#39;t be lowered.
The l-value was considered opaque, so the alignment was determined from a type.
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:2041
const CGFunctionInfo & arrangeFreeFunctionCall(CodeGenModule &CGM, CanQualType returnType, ArrayRef< CanQualType > argTypes, FunctionType::ExtInfo info, RequiredArgs args)
CGFunctionInfo - Class to encapsulate the information about a function definition.
This class organizes the cross-function state that is used while generating LLVM code.
Dataflow Directional Tag Classes.
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 * ConvertFunctionType(QualType FT, const FunctionDecl *FD=nullptr)
Converts the GlobalDecl into an llvm::Type.
llvm::Type * convertTypeForMemory(CodeGenModule &CGM, QualType T)
Represents a C++ struct/union/class.
Definition: DeclCXX.h:300
QualType getType() const
Definition: Decl.h:648
const CGRecordLayout & getCGRecordLayout(const RecordDecl *)
getCGRecordLayout - Return record layout info for the given record decl.
A class which abstracts out some details necessary for making a call.
Definition: Type.h:3469
unsigned getLLVMFieldNo(const FieldDecl *FD) const
Return llvm::StructType element number that corresponds to the field FD.