clang  6.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"
26 
27 using namespace clang;
28 using namespace CodeGen;
29 
30 const CGFunctionInfo &
32  const ObjCMethodDecl *MD,
33  QualType receiverType) {
34  return CGM.getTypes().arrangeObjCMessageSendSignature(MD, receiverType);
35 }
36 
37 const CGFunctionInfo &
40  const FunctionDecl *FD) {
41  return CGM.getTypes().arrangeFreeFunctionType(Ty, FD);
42 }
43 
44 const CGFunctionInfo &
47  return CGM.getTypes().arrangeFreeFunctionType(Ty);
48 }
49 
50 const CGFunctionInfo &
52  const CXXRecordDecl *RD,
53  const FunctionProtoType *FTP,
54  const CXXMethodDecl *MD) {
55  return CGM.getTypes().arrangeCXXMethodType(RD, FTP, MD);
56 }
57 
58 const CGFunctionInfo &
60  CanQualType returnType,
61  ArrayRef<CanQualType> argTypes,
63  RequiredArgs args) {
64  return CGM.getTypes().arrangeLLVMFunctionInfo(
65  returnType, /*IsInstanceMethod=*/false, /*IsChainCall=*/false, argTypes,
66  info, {}, args);
67 }
68 
69 llvm::FunctionType *
71  assert(FD != nullptr && "Expected a non-null function declaration!");
72  llvm::Type *T = CGM.getTypes().ConvertFunctionType(FD->getType(), FD);
73 
74  if (auto FT = dyn_cast<llvm::FunctionType>(T))
75  return FT;
76 
77  return nullptr;
78 }
79 
80 llvm::Type *
82  return CGM.getTypes().ConvertTypeForMem(T);
83 }
84 
86  const RecordDecl *RD,
87  const FieldDecl *FD) {
88  return CGM.getTypes().getCGRecordLayout(RD).getLLVMFieldNo(FD);
89 }
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
Definition: Decl.h:1698
A (possibly-)qualified type.
Definition: Type.h:653
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:187
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:242
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.
RecordDecl - Represents a struct/union/class.
Definition: Decl.h:3482
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
Definition: Decl.h:2461
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:455
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:724
const CGFunctionInfo & arrangeObjCMessageSendSignature(CodeGenModule &CGM, const ObjCMethodDecl *MD, QualType receiverType)
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3270
const FunctionProtoType * T
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:1964
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:299
QualType getType() const
Definition: Decl.h:639
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:3083
unsigned getLLVMFieldNo(const FieldDecl *FD) const
Return llvm::StructType element number that corresponds to the field FD.