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 
21 #include "clang/CodeGen/CGFunctionInfo.h"
22 #include "clang/Frontend/CodeGenOptions.h"
23 #include "CodeGenModule.h"
24 
25 using namespace clang;
26 using namespace CodeGen;
27 
28 CodeGenABITypes::CodeGenABITypes(ASTContext &C,
29                                  llvm::Module &M,
30                                  const llvm::DataLayout &TD)
31   : CGO(new CodeGenOptions),
32     CGM(new CodeGen::CodeGenModule(C, *CGO, M, TD, C.getDiagnostics())) {
33 }
34 
35 CodeGenABITypes::~CodeGenABITypes()
36 {
37   delete CGO;
38   delete CGM;
39 }
40 
41 const CGFunctionInfo &
42 CodeGenABITypes::arrangeObjCMessageSendSignature(const ObjCMethodDecl *MD,
43                                                  QualType receiverType) {
44   return CGM->getTypes().arrangeObjCMessageSendSignature(MD, receiverType);
45 }
46 
47 const CGFunctionInfo &
48 CodeGenABITypes::arrangeFreeFunctionType(CanQual<FunctionProtoType> Ty) {
49   return CGM->getTypes().arrangeFreeFunctionType(Ty);
50 }
51 
52 const CGFunctionInfo &
53 CodeGenABITypes::arrangeFreeFunctionType(CanQual<FunctionNoProtoType> Ty) {
54   return CGM->getTypes().arrangeFreeFunctionType(Ty);
55 }
56 
57 const CGFunctionInfo &
58 CodeGenABITypes::arrangeCXXMethodType(const CXXRecordDecl *RD,
59                                       const FunctionProtoType *FTP) {
60   return CGM->getTypes().arrangeCXXMethodType(RD, FTP);
61 }
62 
63 const CGFunctionInfo &
64 CodeGenABITypes::arrangeLLVMFunctionInfo(CanQualType returnType,
65                                          llvm::ArrayRef<CanQualType> argTypes,
66                                          FunctionType::ExtInfo info,
67                                          RequiredArgs args) {
68   return CGM->getTypes().arrangeLLVMFunctionInfo(returnType, argTypes,
69                                                 info, args);
70 }
71