#ifndef CLANG_CODEGEN_CODEGENTYPES_H
#define CLANG_CODEGEN_CODEGENTYPES_H
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallSet.h"
#include <vector>
#include "CGCall.h"
namespace llvm {
class FunctionType;
class Module;
class OpaqueType;
class PATypeHolder;
class TargetData;
class Type;
}
namespace clang {
class ABIInfo;
class ASTContext;
class CXXMethodDecl;
class FieldDecl;
class FunctionProtoType;
class ObjCInterfaceDecl;
class ObjCIvarDecl;
class PointerType;
class QualType;
class RecordDecl;
class TagDecl;
class TargetInfo;
class Type;
namespace CodeGen {
class CodeGenTypes;
class CGRecordLayout {
CGRecordLayout(); public:
CGRecordLayout(llvm::Type *T, llvm::SmallSet<unsigned, 8> &PF)
: STy(T), PaddingFields(PF) {
}
llvm::Type *getLLVMType() const {
return STy;
}
bool isPaddingField(unsigned No) const {
return PaddingFields.count(No) != 0;
}
unsigned getNumPaddingFields() {
return PaddingFields.size();
}
private:
llvm::Type *STy;
llvm::SmallSet<unsigned, 8> PaddingFields;
};
class CodeGenTypes {
ASTContext &Context;
TargetInfo &Target;
llvm::Module& TheModule;
const llvm::TargetData& TheTargetData;
mutable const ABIInfo* TheABIInfo;
llvm::SmallVector<std::pair<QualType,
llvm::OpaqueType *>, 8> PointersToResolve;
llvm::DenseMap<const Type*, llvm::PATypeHolder> TagDeclTypes;
llvm::DenseMap<const Type*, llvm::PATypeHolder> FunctionTypes;
llvm::DenseMap<const ObjCInterfaceType*, const llvm::Type *> InterfaceTypes;
llvm::DenseMap<const Type*, CGRecordLayout *> CGRecordLayouts;
llvm::DenseMap<const FieldDecl *, unsigned> FieldInfo;
llvm::FoldingSet<CGFunctionInfo> FunctionInfos;
public:
class BitFieldInfo {
public:
explicit BitFieldInfo(unsigned short B, unsigned short S)
: Begin(B), Size(S) {}
unsigned short Begin;
unsigned short Size;
};
private:
llvm::DenseMap<const FieldDecl *, BitFieldInfo> BitFields;
llvm::DenseMap<Type *, llvm::PATypeHolder> TypeCache;
const llvm::Type *ConvertNewType(QualType T);
public:
CodeGenTypes(ASTContext &Ctx, llvm::Module &M, const llvm::TargetData &TD);
~CodeGenTypes();
const llvm::TargetData &getTargetData() const { return TheTargetData; }
TargetInfo &getTarget() const { return Target; }
ASTContext &getContext() const { return Context; }
const ABIInfo &getABIInfo() const;
const llvm::Type *ConvertType(QualType T);
const llvm::Type *ConvertTypeRecursive(QualType T);
const llvm::Type *ConvertTypeForMem(QualType T);
const llvm::Type *ConvertTypeForMemRecursive(QualType T);
const llvm::FunctionType *GetFunctionType(const CGFunctionInfo &Info,
bool IsVariadic);
const CGRecordLayout *getCGRecordLayout(const TagDecl*) const;
unsigned getLLVMFieldNo(const FieldDecl *FD);
void UpdateCompletedType(const TagDecl *TD);
const CGFunctionInfo &getFunctionInfo(QualType RetTy,
const llvm::SmallVector<QualType,16>
&ArgTys);
const CGFunctionInfo &getFunctionInfo(const FunctionNoProtoType *FTNP);
const CGFunctionInfo &getFunctionInfo(const FunctionProtoType *FTP);
const CGFunctionInfo &getFunctionInfo(const FunctionDecl *FD);
const CGFunctionInfo &getFunctionInfo(const CXXMethodDecl *MD);
const CGFunctionInfo &getFunctionInfo(const ObjCMethodDecl *MD);
const CGFunctionInfo &getFunctionInfo(QualType ResTy,
const CallArgList &Args);
public:
const CGFunctionInfo &getFunctionInfo(QualType ResTy,
const FunctionArgList &Args);
public: void addFieldInfo(const FieldDecl *FD, unsigned No);
void addBitFieldInfo(const FieldDecl *FD, unsigned Begin, unsigned Size);
BitFieldInfo getBitFieldInfo(const FieldDecl *FD);
const llvm::Type *ConvertTagDeclType(const TagDecl *TD);
void GetExpandedTypes(QualType Ty, std::vector<const llvm::Type*> &ArgTys);
};
} }
#endif