1 //==--- CodeGenABITypes.cpp - Convert Clang types to LLVM types for ABI ----==//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // CodeGenABITypes is a simple interface for getting LLVM types for
11 // the parameters and the return value of a function given the Clang
14 // The class is implemented as a public wrapper around the private
15 // CodeGenTypes class in lib/CodeGen.
17 //===----------------------------------------------------------------------===//
19 #include "clang/CodeGen/CodeGenABITypes.h"
20 #include "CGRecordLayout.h"
21 #include "CodeGenModule.h"
22 #include "clang/CodeGen/CGFunctionInfo.h"
23 #include "clang/Frontend/CodeGenOptions.h"
24 #include "clang/Lex/HeaderSearchOptions.h"
25 #include "clang/Lex/PreprocessorOptions.h"
27 using namespace clang;
28 using namespace CodeGen;
30 const CGFunctionInfo &
31 CodeGen::arrangeObjCMessageSendSignature(CodeGenModule &CGM,
32 const ObjCMethodDecl *MD,
33 QualType receiverType) {
34 return CGM.getTypes().arrangeObjCMessageSendSignature(MD, receiverType);
37 const CGFunctionInfo &
38 CodeGen::arrangeFreeFunctionType(CodeGenModule &CGM,
39 CanQual<FunctionProtoType> Ty,
40 const FunctionDecl *FD) {
41 return CGM.getTypes().arrangeFreeFunctionType(Ty, FD);
44 const CGFunctionInfo &
45 CodeGen::arrangeFreeFunctionType(CodeGenModule &CGM,
46 CanQual<FunctionNoProtoType> Ty) {
47 return CGM.getTypes().arrangeFreeFunctionType(Ty);
50 const CGFunctionInfo &
51 CodeGen::arrangeCXXMethodType(CodeGenModule &CGM,
52 const CXXRecordDecl *RD,
53 const FunctionProtoType *FTP,
54 const CXXMethodDecl *MD) {
55 return CGM.getTypes().arrangeCXXMethodType(RD, FTP, MD);
58 const CGFunctionInfo &
59 CodeGen::arrangeFreeFunctionCall(CodeGenModule &CGM,
60 CanQualType returnType,
61 ArrayRef<CanQualType> argTypes,
62 FunctionType::ExtInfo info,
64 return CGM.getTypes().arrangeLLVMFunctionInfo(
65 returnType, /*IsInstanceMethod=*/false, /*IsChainCall=*/false, argTypes,
70 CodeGen::convertFreeFunctionType(CodeGenModule &CGM, const FunctionDecl *FD) {
71 assert(FD != nullptr && "Expected a non-null function declaration!");
72 llvm::Type *T = CGM.getTypes().ConvertFunctionType(FD->getType(), FD);
74 if (auto FT = dyn_cast<llvm::FunctionType>(T))
81 CodeGen::convertTypeForMemory(CodeGenModule &CGM, QualType T) {
82 return CGM.getTypes().ConvertTypeForMem(T);
85 unsigned CodeGen::getLLVMFieldNumber(CodeGenModule &CGM,
87 const FieldDecl *FD) {
88 return CGM.getTypes().getCGRecordLayout(RD).getLLVMFieldNo(FD);