Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1 | //===--- CodeGenTypes.h - Type translation for LLVM CodeGen -----*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 0bc735f | 2007-12-29 19:59:25 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 10 | // This is the code that handles AST -> LLVM type lowering. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Chris Lattner | ef52a2f | 2008-02-29 17:10:38 +0000 | [diff] [blame] | 14 | #ifndef CLANG_CODEGEN_CODEGENTYPES_H |
| 15 | #define CLANG_CODEGEN_CODEGENTYPES_H |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 16 | |
Chris Lattner | 800588f | 2010-07-29 06:26:06 +0000 | [diff] [blame] | 17 | #include "CGCall.h" |
Peter Collingbourne | fd05ca0 | 2011-06-14 04:02:39 +0000 | [diff] [blame] | 18 | #include "clang/AST/GlobalDecl.h" |
Anders Carlsson | c9e2091 | 2007-08-21 00:21:21 +0000 | [diff] [blame] | 19 | #include "llvm/ADT/DenseMap.h" |
Chandler Carruth | 3b844ba | 2013-01-02 11:45:17 +0000 | [diff] [blame] | 20 | #include "llvm/IR/Module.h" |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 21 | #include <vector> |
| 22 | |
| 23 | namespace llvm { |
Daniel Dunbar | 45c25ba | 2008-09-10 04:01:49 +0000 | [diff] [blame] | 24 | class FunctionType; |
Anders Carlsson | 4e53328 | 2007-08-17 22:00:32 +0000 | [diff] [blame] | 25 | class Module; |
Micah Villmow | 25a6a84 | 2012-10-08 16:25:52 +0000 | [diff] [blame] | 26 | class DataLayout; |
Daniel Dunbar | 45c25ba | 2008-09-10 04:01:49 +0000 | [diff] [blame] | 27 | class Type; |
Benjamin Kramer | f21efe9 | 2009-08-11 17:46:57 +0000 | [diff] [blame] | 28 | class LLVMContext; |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 29 | class StructType; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | namespace clang { |
Daniel Dunbar | 6b1da0e | 2008-10-13 17:02:26 +0000 | [diff] [blame] | 33 | class ABIInfo; |
Chris Lattner | d2d2a11 | 2007-07-14 01:29:45 +0000 | [diff] [blame] | 34 | class ASTContext; |
John McCall | ead608a | 2010-02-26 00:48:12 +0000 | [diff] [blame] | 35 | template <typename> class CanQual; |
Anders Carlsson | f6c56e2 | 2009-11-25 03:15:49 +0000 | [diff] [blame] | 36 | class CXXConstructorDecl; |
| 37 | class CXXDestructorDecl; |
Anders Carlsson | f6f8ae5 | 2009-04-03 22:48:58 +0000 | [diff] [blame] | 38 | class CXXMethodDecl; |
Daniel Dunbar | 08d4792 | 2011-06-21 18:54:39 +0000 | [diff] [blame] | 39 | class CodeGenOptions; |
Devang Patel | b1e3989 | 2007-10-23 23:26:46 +0000 | [diff] [blame] | 40 | class FieldDecl; |
Douglas Gregor | 72564e7 | 2009-02-26 23:50:07 +0000 | [diff] [blame] | 41 | class FunctionProtoType; |
Chris Lattner | 391d77a | 2008-03-30 23:03:07 +0000 | [diff] [blame] | 42 | class ObjCInterfaceDecl; |
| 43 | class ObjCIvarDecl; |
Daniel Dunbar | 45c25ba | 2008-09-10 04:01:49 +0000 | [diff] [blame] | 44 | class PointerType; |
| 45 | class QualType; |
| 46 | class RecordDecl; |
| 47 | class TagDecl; |
| 48 | class TargetInfo; |
| 49 | class Type; |
John McCall | ead608a | 2010-02-26 00:48:12 +0000 | [diff] [blame] | 50 | typedef CanQual<Type> CanQualType; |
Devang Patel | b84a06e | 2007-10-23 02:10:49 +0000 | [diff] [blame] | 51 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 52 | namespace CodeGen { |
John McCall | f16aa10 | 2010-08-22 21:01:12 +0000 | [diff] [blame] | 53 | class CGCXXABI; |
Daniel Dunbar | 2924ade | 2010-03-30 22:26:10 +0000 | [diff] [blame] | 54 | class CGRecordLayout; |
John McCall | de5d3c7 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 55 | class CodeGenModule; |
| 56 | class RequiredArgs; |
Devang Patel | b84a06e | 2007-10-23 02:10:49 +0000 | [diff] [blame] | 57 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 58 | /// CodeGenTypes - This class organizes the cross-module state that is used |
| 59 | /// while lowering AST types to LLVM types. |
| 60 | class CodeGenTypes { |
John McCall | e56bb36 | 2012-12-07 07:03:17 +0000 | [diff] [blame] | 61 | public: |
John McCall | de5d3c7 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 62 | // Some of this stuff should probably be left on the CGM. |
Chris Lattner | d2d2a11 | 2007-07-14 01:29:45 +0000 | [diff] [blame] | 63 | ASTContext &Context; |
Daniel Dunbar | 444be73 | 2009-11-13 05:51:54 +0000 | [diff] [blame] | 64 | const TargetInfo &Target; |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 65 | llvm::Module &TheModule; |
Micah Villmow | 25a6a84 | 2012-10-08 16:25:52 +0000 | [diff] [blame] | 66 | const llvm::DataLayout &TheDataLayout; |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 67 | const ABIInfo &TheABIInfo; |
John McCall | f16aa10 | 2010-08-22 21:01:12 +0000 | [diff] [blame] | 68 | CGCXXABI &TheCXXABI; |
Daniel Dunbar | 08d4792 | 2011-06-21 18:54:39 +0000 | [diff] [blame] | 69 | const CodeGenOptions &CodeGenOpts; |
John McCall | de5d3c7 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 70 | CodeGenModule &CGM; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 71 | |
John McCall | e56bb36 | 2012-12-07 07:03:17 +0000 | [diff] [blame] | 72 | private: |
Daniel Dunbar | 412f59b | 2009-04-22 10:28:39 +0000 | [diff] [blame] | 73 | /// The opaque type map for Objective-C interfaces. All direct |
| 74 | /// manipulation is done by the runtime interfaces, which are |
| 75 | /// responsible for coercing to the appropriate type; these opaque |
| 76 | /// types are never refined. |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 77 | llvm::DenseMap<const ObjCInterfaceType*, llvm::Type *> InterfaceTypes; |
Daniel Dunbar | 412f59b | 2009-04-22 10:28:39 +0000 | [diff] [blame] | 78 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 79 | /// CGRecordLayouts - This maps llvm struct type with corresponding |
| 80 | /// record layout info. |
Daniel Dunbar | efb6d0d | 2008-09-06 02:26:43 +0000 | [diff] [blame] | 81 | llvm::DenseMap<const Type*, CGRecordLayout *> CGRecordLayouts; |
Devang Patel | b84a06e | 2007-10-23 02:10:49 +0000 | [diff] [blame] | 82 | |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 83 | /// RecordDeclTypes - This contains the LLVM IR type for any converted |
| 84 | /// RecordDecl. |
| 85 | llvm::DenseMap<const Type*, llvm::StructType *> RecordDeclTypes; |
| 86 | |
Daniel Dunbar | 40a6be6 | 2009-02-03 00:07:12 +0000 | [diff] [blame] | 87 | /// FunctionInfos - Hold memoized CGFunctionInfo results. |
| 88 | llvm::FoldingSet<CGFunctionInfo> FunctionInfos; |
| 89 | |
Chris Lattner | 71305cc | 2011-07-15 05:16:14 +0000 | [diff] [blame] | 90 | /// RecordsBeingLaidOut - This set keeps track of records that we're currently |
| 91 | /// converting to an IR type. For example, when converting: |
| 92 | /// struct A { struct B { int x; } } when processing 'x', the 'A' and 'B' |
| 93 | /// types will be in this set. |
| 94 | llvm::SmallPtrSet<const Type*, 4> RecordsBeingLaidOut; |
| 95 | |
| 96 | llvm::SmallPtrSet<const CGFunctionInfo*, 4> FunctionsBeingProcessed; |
| 97 | |
| 98 | /// SkippedLayout - True if we didn't layout a function due to a being inside |
| 99 | /// a recursive struct conversion, set this to true. |
Chris Lattner | 57eb23f | 2011-07-10 05:39:13 +0000 | [diff] [blame] | 100 | bool SkippedLayout; |
| 101 | |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 102 | SmallVector<const RecordDecl *, 8> DeferredRecords; |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 103 | |
Lauro Ramos Venancio | 3b8c22d | 2008-01-22 20:17:04 +0000 | [diff] [blame] | 104 | private: |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 105 | /// TypeCache - This map keeps cache of llvm::Types |
| 106 | /// and maps llvm::Types to corresponding clang::Type. |
| 107 | llvm::DenseMap<const Type *, llvm::Type *> TypeCache; |
Anders Carlsson | e9742b0 | 2011-04-17 21:36:59 +0000 | [diff] [blame] | 108 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 109 | public: |
John McCall | de5d3c7 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 110 | CodeGenTypes(CodeGenModule &CGM); |
Devang Patel | b84a06e | 2007-10-23 02:10:49 +0000 | [diff] [blame] | 111 | ~CodeGenTypes(); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 112 | |
Micah Villmow | 25a6a84 | 2012-10-08 16:25:52 +0000 | [diff] [blame] | 113 | const llvm::DataLayout &getDataLayout() const { return TheDataLayout; } |
Daniel Dunbar | 444be73 | 2009-11-13 05:51:54 +0000 | [diff] [blame] | 114 | const TargetInfo &getTarget() const { return Target; } |
Devang Patel | 86522b9 | 2007-10-29 20:50:19 +0000 | [diff] [blame] | 115 | ASTContext &getContext() const { return Context; } |
Anton Korobeynikov | 82d0a41 | 2010-01-10 12:58:08 +0000 | [diff] [blame] | 116 | const ABIInfo &getABIInfo() const { return TheABIInfo; } |
Daniel Dunbar | 08d4792 | 2011-06-21 18:54:39 +0000 | [diff] [blame] | 117 | const CodeGenOptions &getCodeGenOpts() const { return CodeGenOpts; } |
John McCall | f16aa10 | 2010-08-22 21:01:12 +0000 | [diff] [blame] | 118 | CGCXXABI &getCXXABI() const { return TheCXXABI; } |
Owen Anderson | 47a434f | 2009-08-05 23:18:46 +0000 | [diff] [blame] | 119 | llvm::LLVMContext &getLLVMContext() { return TheModule.getContext(); } |
Devang Patel | 5825ac2 | 2007-10-25 21:40:12 +0000 | [diff] [blame] | 120 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 121 | /// ConvertType - Convert type T into a llvm::Type. |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 122 | llvm::Type *ConvertType(QualType T); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 123 | |
Chris Lattner | 4581fff | 2008-02-06 05:21:55 +0000 | [diff] [blame] | 124 | /// ConvertTypeForMem - Convert type T into a llvm::Type. This differs from |
| 125 | /// ConvertType in that it is used to convert to the memory representation for |
| 126 | /// a type. For example, the scalar representation for _Bool is i1, but the |
| 127 | /// memory representation is usually i8 or i32, depending on the target. |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 128 | llvm::Type *ConvertTypeForMem(QualType T); |
Daniel Dunbar | 45c25ba | 2008-09-10 04:01:49 +0000 | [diff] [blame] | 129 | |
Daniel Dunbar | 36b5f5e | 2009-01-31 03:05:44 +0000 | [diff] [blame] | 130 | /// GetFunctionType - Get the LLVM function type for \arg Info. |
John McCall | de5d3c7 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 131 | llvm::FunctionType *GetFunctionType(const CGFunctionInfo &Info); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 132 | |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 133 | llvm::FunctionType *GetFunctionType(GlobalDecl GD); |
John McCall | c0bf462 | 2010-02-23 00:48:20 +0000 | [diff] [blame] | 134 | |
Chris Lattner | f742eb0 | 2011-07-10 00:18:59 +0000 | [diff] [blame] | 135 | /// isFuncTypeConvertible - Utility to check whether a function type can |
Eli Friedman | c00129a | 2010-05-30 06:03:20 +0000 | [diff] [blame] | 136 | /// be converted to an LLVM type (i.e. doesn't depend on an incomplete tag |
| 137 | /// type). |
Chris Lattner | f742eb0 | 2011-07-10 00:18:59 +0000 | [diff] [blame] | 138 | bool isFuncTypeConvertible(const FunctionType *FT); |
| 139 | bool isFuncTypeArgumentConvertible(QualType Ty); |
| 140 | |
Anders Carlsson | 046c294 | 2010-04-17 20:15:18 +0000 | [diff] [blame] | 141 | /// GetFunctionTypeForVTable - Get the LLVM function type for use in a vtable, |
Michael J. Spencer | 9cac494 | 2010-10-19 06:39:39 +0000 | [diff] [blame] | 142 | /// given a CXXMethodDecl. If the method to has an incomplete return type, |
Anders Carlsson | ecf282b | 2009-11-24 05:08:52 +0000 | [diff] [blame] | 143 | /// and/or incomplete argument types, this will return the opaque type. |
Chris Lattner | 2acc6e3 | 2011-07-18 04:24:23 +0000 | [diff] [blame] | 144 | llvm::Type *GetFunctionTypeForVTable(GlobalDecl GD); |
Michael J. Spencer | 9cac494 | 2010-10-19 06:39:39 +0000 | [diff] [blame] | 145 | |
Anders Carlsson | c8f01eb | 2010-11-24 19:51:04 +0000 | [diff] [blame] | 146 | const CGRecordLayout &getCGRecordLayout(const RecordDecl*); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 147 | |
Chris Lattner | c5b8806 | 2008-02-06 05:08:19 +0000 | [diff] [blame] | 148 | /// UpdateCompletedType - When we find the full definition for a TagDecl, |
| 149 | /// replace the 'opaque' type we previously made for it if applicable. |
| 150 | void UpdateCompletedType(const TagDecl *TD); |
Daniel Dunbar | 541b63b | 2009-02-02 23:23:47 +0000 | [diff] [blame] | 151 | |
John McCall | d26bc76 | 2011-03-09 04:27:21 +0000 | [diff] [blame] | 152 | /// getNullaryFunctionInfo - Get the function info for a void() |
| 153 | /// function with standard CC. |
John McCall | de5d3c7 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 154 | const CGFunctionInfo &arrangeNullaryFunction(); |
John McCall | d26bc76 | 2011-03-09 04:27:21 +0000 | [diff] [blame] | 155 | |
John McCall | de5d3c7 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 156 | // The arrangement methods are split into three families: |
| 157 | // - those meant to drive the signature and prologue/epilogue |
| 158 | // of a function declaration or definition, |
| 159 | // - those meant for the computation of the LLVM type for an abstract |
| 160 | // appearance of a function, and |
| 161 | // - those meant for performing the IR-generation of a call. |
| 162 | // They differ mainly in how they deal with optional (i.e. variadic) |
| 163 | // arguments, as well as unprototyped functions. |
| 164 | // |
| 165 | // Key points: |
| 166 | // - The CGFunctionInfo for emitting a specific call site must include |
| 167 | // entries for the optional arguments. |
| 168 | // - The function type used at the call site must reflect the formal |
| 169 | // signature of the declaration being called, or else the call will |
| 170 | // go awry. |
| 171 | // - For the most part, unprototyped functions are called by casting to |
| 172 | // a formal signature inferred from the specific argument types used |
| 173 | // at the call-site. However, some targets (e.g. x86-64) screw with |
| 174 | // this for compatibility reasons. |
Michael J. Spencer | 9cac494 | 2010-10-19 06:39:39 +0000 | [diff] [blame] | 175 | |
John McCall | de5d3c7 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 176 | const CGFunctionInfo &arrangeGlobalDeclaration(GlobalDecl GD); |
| 177 | const CGFunctionInfo &arrangeFunctionDeclaration(const FunctionDecl *FD); |
| 178 | const CGFunctionInfo &arrangeFunctionDeclaration(QualType ResTy, |
| 179 | const FunctionArgList &Args, |
| 180 | const FunctionType::ExtInfo &Info, |
| 181 | bool isVariadic); |
Anders Carlsson | f6c56e2 | 2009-11-25 03:15:49 +0000 | [diff] [blame] | 182 | |
John McCall | de5d3c7 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 183 | const CGFunctionInfo &arrangeObjCMethodDeclaration(const ObjCMethodDecl *MD); |
| 184 | const CGFunctionInfo &arrangeObjCMessageSendSignature(const ObjCMethodDecl *MD, |
| 185 | QualType receiverType); |
Chris Lattner | bcaedae | 2010-06-30 19:14:05 +0000 | [diff] [blame] | 186 | |
John McCall | de5d3c7 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 187 | const CGFunctionInfo &arrangeCXXMethodDeclaration(const CXXMethodDecl *MD); |
| 188 | const CGFunctionInfo &arrangeCXXConstructorDeclaration( |
| 189 | const CXXConstructorDecl *D, |
| 190 | CXXCtorType Type); |
| 191 | const CGFunctionInfo &arrangeCXXDestructor(const CXXDestructorDecl *D, |
| 192 | CXXDtorType Type); |
John McCall | 04a67a6 | 2010-02-05 21:31:56 +0000 | [diff] [blame] | 193 | |
John McCall | 0f3d097 | 2012-07-07 06:41:13 +0000 | [diff] [blame] | 194 | const CGFunctionInfo &arrangeFreeFunctionCall(const CallArgList &Args, |
| 195 | const FunctionType *Ty); |
| 196 | const CGFunctionInfo &arrangeFreeFunctionCall(QualType ResTy, |
| 197 | const CallArgList &args, |
| 198 | FunctionType::ExtInfo info, |
| 199 | RequiredArgs required); |
John McCall | e56bb36 | 2012-12-07 07:03:17 +0000 | [diff] [blame] | 200 | const CGFunctionInfo &arrangeBlockFunctionCall(const CallArgList &args, |
| 201 | const FunctionType *type); |
Michael J. Spencer | 9cac494 | 2010-10-19 06:39:39 +0000 | [diff] [blame] | 202 | |
John McCall | 0f3d097 | 2012-07-07 06:41:13 +0000 | [diff] [blame] | 203 | const CGFunctionInfo &arrangeCXXMethodCall(const CallArgList &args, |
| 204 | const FunctionProtoType *type, |
| 205 | RequiredArgs required); |
| 206 | |
| 207 | const CGFunctionInfo &arrangeFreeFunctionType(CanQual<FunctionProtoType> Ty); |
| 208 | const CGFunctionInfo &arrangeFreeFunctionType(CanQual<FunctionNoProtoType> Ty); |
John McCall | de5d3c7 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 209 | const CGFunctionInfo &arrangeCXXMethodType(const CXXRecordDecl *RD, |
| 210 | const FunctionProtoType *FTP); |
John McCall | ead608a | 2010-02-26 00:48:12 +0000 | [diff] [blame] | 211 | |
John McCall | 0f3d097 | 2012-07-07 06:41:13 +0000 | [diff] [blame] | 212 | /// "Arrange" the LLVM information for a call or type with the given |
| 213 | /// signature. This is largely an internal method; other clients |
| 214 | /// should use one of the above routines, which ultimately defer to |
| 215 | /// this. |
Michael J. Spencer | 9cac494 | 2010-10-19 06:39:39 +0000 | [diff] [blame] | 216 | /// |
John McCall | de5d3c7 | 2012-02-17 03:33:10 +0000 | [diff] [blame] | 217 | /// \param argTypes - must all actually be canonical as params |
John McCall | 0f3d097 | 2012-07-07 06:41:13 +0000 | [diff] [blame] | 218 | const CGFunctionInfo &arrangeLLVMFunctionInfo(CanQualType returnType, |
| 219 | ArrayRef<CanQualType> argTypes, |
| 220 | FunctionType::ExtInfo info, |
| 221 | RequiredArgs args); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 222 | |
Daniel Dunbar | 270e203 | 2010-03-31 00:11:27 +0000 | [diff] [blame] | 223 | /// \brief Compute a new LLVM record layout object for the given record. |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 224 | CGRecordLayout *ComputeRecordLayout(const RecordDecl *D, |
| 225 | llvm::StructType *Ty); |
| 226 | |
| 227 | /// addRecordTypeName - Compute a name from the given record decl with an |
| 228 | /// optional suffix and name the given LLVM type using it. |
| 229 | void addRecordTypeName(const RecordDecl *RD, llvm::StructType *Ty, |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 230 | StringRef suffix); |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 231 | |
Daniel Dunbar | 270e203 | 2010-03-31 00:11:27 +0000 | [diff] [blame] | 232 | |
Chris Lattner | 19009e6 | 2008-01-09 18:47:25 +0000 | [diff] [blame] | 233 | public: // These are internal details of CGT that shouldn't be used externally. |
Chris Lattner | 9cbe4f0 | 2011-07-09 17:41:47 +0000 | [diff] [blame] | 234 | /// ConvertRecordDeclType - Lay out a tagged decl type like struct or union. |
| 235 | llvm::StructType *ConvertRecordDeclType(const RecordDecl *TD); |
Daniel Dunbar | 5627377 | 2008-09-17 00:51:38 +0000 | [diff] [blame] | 236 | |
| 237 | /// GetExpandedTypes - Expand the type \arg Ty into the LLVM |
| 238 | /// argument types it would be passed as on the provided vector \arg |
| 239 | /// ArgTys. See ABIArgInfo::Expand. |
John McCall | 42e0611 | 2011-05-15 02:19:42 +0000 | [diff] [blame] | 240 | void GetExpandedTypes(QualType type, |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 241 | SmallVectorImpl<llvm::Type*> &expanded); |
Michael J. Spencer | 9cac494 | 2010-10-19 06:39:39 +0000 | [diff] [blame] | 242 | |
John McCall | f16aa10 | 2010-08-22 21:01:12 +0000 | [diff] [blame] | 243 | /// IsZeroInitializable - Return whether a type can be |
| 244 | /// zero-initialized (in the C++ sense) with an LLVM zeroinitializer. |
| 245 | bool isZeroInitializable(QualType T); |
Michael J. Spencer | 9cac494 | 2010-10-19 06:39:39 +0000 | [diff] [blame] | 246 | |
John McCall | f16aa10 | 2010-08-22 21:01:12 +0000 | [diff] [blame] | 247 | /// IsZeroInitializable - Return whether a record type can be |
| 248 | /// zero-initialized (in the C++ sense) with an LLVM zeroinitializer. |
| 249 | bool isZeroInitializable(const CXXRecordDecl *RD); |
Chris Lattner | 71305cc | 2011-07-15 05:16:14 +0000 | [diff] [blame] | 250 | |
| 251 | bool isRecordLayoutComplete(const Type *Ty) const; |
| 252 | bool noRecordsBeingLaidOut() const { |
| 253 | return RecordsBeingLaidOut.empty(); |
| 254 | } |
| 255 | bool isRecordBeingLaidOut(const Type *Ty) const { |
| 256 | return RecordsBeingLaidOut.count(Ty); |
| 257 | } |
| 258 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 259 | }; |
Chris Lattner | a7674d8 | 2007-07-13 22:13:22 +0000 | [diff] [blame] | 260 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 261 | } // end namespace CodeGen |
| 262 | } // end namespace clang |
| 263 | |
| 264 | #endif |