clang API Documentation
00001 //===--- CodeGenTBAA.h - TBAA information for LLVM CodeGen ------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This is the code that manages TBAA information and defines the TBAA policy 00011 // for the optimizer to use. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #ifndef CLANG_CODEGEN_CODEGENTBAA_H 00016 #define CLANG_CODEGEN_CODEGENTBAA_H 00017 00018 #include "clang/Basic/LLVM.h" 00019 #include "llvm/ADT/DenseMap.h" 00020 #include "llvm/Support/MDBuilder.h" 00021 00022 namespace llvm { 00023 class LLVMContext; 00024 class MDNode; 00025 } 00026 00027 namespace clang { 00028 class ASTContext; 00029 class CodeGenOptions; 00030 class LangOptions; 00031 class MangleContext; 00032 class QualType; 00033 class Type; 00034 00035 namespace CodeGen { 00036 class CGRecordLayout; 00037 00038 /// CodeGenTBAA - This class organizes the cross-module state that is used 00039 /// while lowering AST types to LLVM types. 00040 class CodeGenTBAA { 00041 ASTContext &Context; 00042 llvm::LLVMContext& VMContext; 00043 const CodeGenOptions &CodeGenOpts; 00044 const LangOptions &Features; 00045 MangleContext &MContext; 00046 00047 // MDHelper - Helper for creating metadata. 00048 llvm::MDBuilder MDHelper; 00049 00050 /// MetadataCache - This maps clang::Types to llvm::MDNodes describing them. 00051 llvm::DenseMap<const Type *, llvm::MDNode *> MetadataCache; 00052 00053 llvm::MDNode *Root; 00054 llvm::MDNode *Char; 00055 00056 /// getRoot - This is the mdnode for the root of the metadata type graph 00057 /// for this translation unit. 00058 llvm::MDNode *getRoot(); 00059 00060 /// getChar - This is the mdnode for "char", which is special, and any types 00061 /// considered to be equivalent to it. 00062 llvm::MDNode *getChar(); 00063 00064 public: 00065 CodeGenTBAA(ASTContext &Ctx, llvm::LLVMContext &VMContext, 00066 const CodeGenOptions &CGO, 00067 const LangOptions &Features, 00068 MangleContext &MContext); 00069 ~CodeGenTBAA(); 00070 00071 /// getTBAAInfo - Get the TBAA MDNode to be used for a dereference 00072 /// of the given type. 00073 llvm::MDNode *getTBAAInfo(QualType QTy); 00074 00075 /// getTBAAInfoForVTablePtr - Get the TBAA MDNode to be used for a 00076 /// dereference of a vtable pointer. 00077 llvm::MDNode *getTBAAInfoForVTablePtr(); 00078 }; 00079 00080 } // end namespace CodeGen 00081 } // end namespace clang 00082 00083 #endif