blob: e49d336d381d4399e331c24d9781737178cce57a [file] [log] [blame]
Dan Gohman3d5aff52010-10-14 23:06:10 +00001//===--- CodeGenTBAA.h - TBAA information for LLVM CodeGen ------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
Dan Gohman565cc442010-10-21 18:49:12 +000010// This is the code that manages TBAA information and defines the TBAA policy
11// for the optimizer to use.
Dan Gohman3d5aff52010-10-14 23:06:10 +000012//
13//===----------------------------------------------------------------------===//
14
15#ifndef CLANG_CODEGEN_CODEGENTBAA_H
16#define CLANG_CODEGEN_CODEGENTBAA_H
17
18#include "llvm/LLVMContext.h"
19#include "llvm/ADT/DenseMap.h"
20
21namespace llvm {
22 class LLVMContext;
23 class MDNode;
24}
25
26namespace clang {
27 class ASTContext;
28 class LangOptions;
29 class QualType;
30 class Type;
31
32namespace CodeGen {
Dan Gohman0b5c4fc2010-10-15 20:23:12 +000033 class MangleContext;
Dan Gohman3d5aff52010-10-14 23:06:10 +000034 class CGRecordLayout;
35
36/// CodeGenTBAA - This class organizes the cross-module state that is used
37/// while lowering AST types to LLVM types.
38class CodeGenTBAA {
39 ASTContext &Context;
40 llvm::LLVMContext& VMContext;
41 const LangOptions &Features;
Dan Gohman0b5c4fc2010-10-15 20:23:12 +000042 MangleContext &MContext;
Dan Gohman3d5aff52010-10-14 23:06:10 +000043
44 /// MetadataCache - This maps clang::Types to llvm::MDNodes describing them.
45 llvm::DenseMap<const Type *, llvm::MDNode *> MetadataCache;
46
47 /// Root - This is the mdnode for the root of the metadata type graph
48 /// for this translation unit.
49 llvm::MDNode *Root;
50
51 /// Char - This is the mdnode for "char", which is special, and any types
52 /// considered to be equivalent to it.
53 llvm::MDNode *Char;
54
Dan Gohman0b5c4fc2010-10-15 20:23:12 +000055 llvm::MDNode *getTBAAInfoForNamedType(llvm::StringRef NameStr,
Dan Gohman3d5aff52010-10-14 23:06:10 +000056 llvm::MDNode *Parent);
57
58public:
59 CodeGenTBAA(ASTContext &Ctx, llvm::LLVMContext &VMContext,
Dan Gohman0b5c4fc2010-10-15 20:23:12 +000060 const LangOptions &Features,
61 MangleContext &MContext);
Dan Gohman3d5aff52010-10-14 23:06:10 +000062 ~CodeGenTBAA();
63
Dan Gohman565cc442010-10-21 18:49:12 +000064 /// getTBAAInfo - Get the TBAA MDNode to be used for a dereference
65 /// of the given type.
Dan Gohman3d5aff52010-10-14 23:06:10 +000066 llvm::MDNode *getTBAAInfo(QualType QTy);
67};
68
69} // end namespace CodeGen
70} // end namespace clang
71
72#endif