]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/lib/CodeGen/CodeGenABITypes.cpp
Merge clang trunk r351319, resolve conflicts, and update FREEBSD-Xlist.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / lib / CodeGen / CodeGenABITypes.cpp
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
19 #include "clang/CodeGen/CodeGenABITypes.h"
20 #include "CGRecordLayout.h"
21 #include "CodeGenModule.h"
22 #include "clang/CodeGen/CGFunctionInfo.h"
23 #include "clang/Lex/HeaderSearchOptions.h"
24 #include "clang/Lex/PreprocessorOptions.h"
25
26 using namespace clang;
27 using namespace CodeGen;
28
29 const CGFunctionInfo &
30 CodeGen::arrangeObjCMessageSendSignature(CodeGenModule &CGM,
31                                          const ObjCMethodDecl *MD,
32                                          QualType receiverType) {
33   return CGM.getTypes().arrangeObjCMessageSendSignature(MD, receiverType);
34 }
35
36 const CGFunctionInfo &
37 CodeGen::arrangeFreeFunctionType(CodeGenModule &CGM,
38                                  CanQual<FunctionProtoType> Ty,
39                                  const FunctionDecl *FD) {
40   return CGM.getTypes().arrangeFreeFunctionType(Ty, FD);
41 }
42
43 const CGFunctionInfo &
44 CodeGen::arrangeFreeFunctionType(CodeGenModule &CGM,
45                                  CanQual<FunctionNoProtoType> Ty) {
46   return CGM.getTypes().arrangeFreeFunctionType(Ty);
47 }
48
49 const CGFunctionInfo &
50 CodeGen::arrangeCXXMethodType(CodeGenModule &CGM,
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 &
58 CodeGen::arrangeFreeFunctionCall(CodeGenModule &CGM,
59                                  CanQualType returnType,
60                                  ArrayRef<CanQualType> argTypes,
61                                  FunctionType::ExtInfo info,
62                                  RequiredArgs args) {
63   return CGM.getTypes().arrangeLLVMFunctionInfo(
64       returnType, /*IsInstanceMethod=*/false, /*IsChainCall=*/false, argTypes,
65       info, {}, args);
66 }
67
68 llvm::FunctionType *
69 CodeGen::convertFreeFunctionType(CodeGenModule &CGM, const FunctionDecl *FD) {
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 *
80 CodeGen::convertTypeForMemory(CodeGenModule &CGM, QualType T) {
81   return CGM.getTypes().ConvertTypeForMem(T);
82 }
83
84 unsigned CodeGen::getLLVMFieldNumber(CodeGenModule &CGM,
85                                      const RecordDecl *RD,
86                                      const FieldDecl *FD) {
87   return CGM.getTypes().getCGRecordLayout(RD).getLLVMFieldNo(FD);
88 }