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 // 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 //===----------------------------------------------------------------------===//
17 
19 #include "CGRecordLayout.h"
20 #include "CodeGenModule.h"
24 
25 using namespace clang;
26 using namespace CodeGen;
27 
28 const CGFunctionInfo &
30  const ObjCMethodDecl *MD,
31  QualType receiverType) {
32  return CGM.getTypes().arrangeObjCMessageSendSignature(MD, receiverType);
33 }
34 
35 const CGFunctionInfo &
38  return CGM.getTypes().arrangeFreeFunctionType(Ty);
39 }
40 
41 const CGFunctionInfo &
44  return CGM.getTypes().arrangeFreeFunctionType(Ty);
45 }
46 
47 const CGFunctionInfo &
49  const CXXRecordDecl *RD,
50  const FunctionProtoType *FTP,
51  const CXXMethodDecl *MD) {
52  return CGM.getTypes().arrangeCXXMethodType(RD, FTP, MD);
53 }
54 
55 const CGFunctionInfo &
57  CanQualType returnType,
58  ArrayRef<CanQualType> argTypes,
60  RequiredArgs args) {
61  return CGM.getTypes().arrangeLLVMFunctionInfo(
62  returnType, /*IsInstanceMethod=*/false, /*IsChainCall=*/false, argTypes,
63  info, {}, args);
64 }
65 
66 llvm::FunctionType *
68  assert(FD != nullptr && "Expected a non-null function declaration!");
69  llvm::Type *T = CGM.getTypes().ConvertType(FD->getType());
70 
71  if (auto FT = dyn_cast<llvm::FunctionType>(T))
72  return FT;
73 
74  return nullptr;
75 }
76 
77 llvm::Type *
79  return CGM.getTypes().ConvertTypeForMem(T);
80 }
81 
83  const RecordDecl *RD,
84  const FieldDecl *FD) {
85  return CGM.getTypes().getCGRecordLayout(RD).getLLVMFieldNo(FD);
86 }
Represents a function declaration or definition.
Definition: Decl.h:1737
A (possibly-)qualified type.
Definition: Type.h:639
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:250
const CGFunctionInfo & arrangeFreeFunctionType(CodeGenModule &CGM, CanQual< FunctionProtoType > Ty)
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:138
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.
const CGFunctionInfo & arrangeFreeFunctionType(CanQual< FunctionProtoType > Ty)
Arrange the argument and result information for a value of the given freestanding function type...
Definition: CGCall.cpp:193
Represents a struct/union/class.
Definition: Decl.h:3592
llvm::Type * ConvertType(QualType T)
ConvertType - Convert type T into a llvm::Type.
Represents a member of a struct/union/class.
Definition: Decl.h:2578
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:470
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:736
const CGFunctionInfo & arrangeObjCMessageSendSignature(CodeGenModule &CGM, const ObjCMethodDecl *MD, QualType receiverType)
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3699
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:2048
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 * convertTypeForMemory(CodeGenModule &CGM, QualType T)
Represents a C++ struct/union/class.
Definition: DeclCXX.h:299
QualType getType() const
Definition: Decl.h:647
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:3478
unsigned getLLVMFieldNo(const FieldDecl *FD) const
Return llvm::StructType element number that corresponds to the field FD.