CodeGenTBAA.h revision 218887
1218887Sdim//===--- CodeGenTBAA.h - TBAA information for LLVM CodeGen ------*- C++ -*-===// 2218887Sdim// 3218887Sdim// The LLVM Compiler Infrastructure 4218887Sdim// 5218887Sdim// This file is distributed under the University of Illinois Open Source 6218887Sdim// License. See LICENSE.TXT for details. 7218887Sdim// 8218887Sdim//===----------------------------------------------------------------------===// 9218887Sdim// 10218887Sdim// This is the code that manages TBAA information and defines the TBAA policy 11218887Sdim// for the optimizer to use. 12218887Sdim// 13218887Sdim//===----------------------------------------------------------------------===// 14218887Sdim 15218887Sdim#ifndef CLANG_CODEGEN_CODEGENTBAA_H 16218887Sdim#define CLANG_CODEGEN_CODEGENTBAA_H 17218887Sdim 18218887Sdim#include "llvm/LLVMContext.h" 19218887Sdim#include "llvm/ADT/DenseMap.h" 20218887Sdim 21218887Sdimnamespace llvm { 22218887Sdim class LLVMContext; 23218887Sdim class MDNode; 24218887Sdim} 25218887Sdim 26218887Sdimnamespace clang { 27218887Sdim class ASTContext; 28218887Sdim class LangOptions; 29218887Sdim class MangleContext; 30218887Sdim class QualType; 31218887Sdim class Type; 32218887Sdim 33218887Sdimnamespace CodeGen { 34218887Sdim class CGRecordLayout; 35218887Sdim 36218887Sdim/// CodeGenTBAA - This class organizes the cross-module state that is used 37218887Sdim/// while lowering AST types to LLVM types. 38218887Sdimclass CodeGenTBAA { 39218887Sdim ASTContext &Context; 40218887Sdim llvm::LLVMContext& VMContext; 41218887Sdim const LangOptions &Features; 42218887Sdim MangleContext &MContext; 43218887Sdim 44218887Sdim /// MetadataCache - This maps clang::Types to llvm::MDNodes describing them. 45218887Sdim llvm::DenseMap<const Type *, llvm::MDNode *> MetadataCache; 46218887Sdim 47218887Sdim llvm::MDNode *Root; 48218887Sdim llvm::MDNode *Char; 49218887Sdim 50218887Sdim /// getRoot - This is the mdnode for the root of the metadata type graph 51218887Sdim /// for this translation unit. 52218887Sdim llvm::MDNode *getRoot(); 53218887Sdim 54218887Sdim /// getChar - This is the mdnode for "char", which is special, and any types 55218887Sdim /// considered to be equivalent to it. 56218887Sdim llvm::MDNode *getChar(); 57218887Sdim 58218887Sdim llvm::MDNode *getTBAAInfoForNamedType(llvm::StringRef NameStr, 59218887Sdim llvm::MDNode *Parent, 60218887Sdim bool Readonly = false); 61218887Sdim 62218887Sdimpublic: 63218887Sdim CodeGenTBAA(ASTContext &Ctx, llvm::LLVMContext &VMContext, 64218887Sdim const LangOptions &Features, 65218887Sdim MangleContext &MContext); 66218887Sdim ~CodeGenTBAA(); 67218887Sdim 68218887Sdim /// getTBAAInfo - Get the TBAA MDNode to be used for a dereference 69218887Sdim /// of the given type. 70218887Sdim llvm::MDNode *getTBAAInfo(QualType QTy); 71218887Sdim}; 72218887Sdim 73218887Sdim} // end namespace CodeGen 74218887Sdim} // end namespace clang 75218887Sdim 76218887Sdim#endif 77