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