blob: 9463b6110cf8ec8d9f8ce03fa2fd0b07485918ba [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
Chris Lattner686775d2011-07-20 06:58:45 +000018#include "clang/Basic/LLVM.h"
Dan Gohman3d5aff52010-10-14 23:06:10 +000019#include "llvm/ADT/DenseMap.h"
Duncan Sands2d7cb062012-04-15 18:04:54 +000020#include "llvm/Support/MDBuilder.h"
Dan Gohman3d5aff52010-10-14 23:06:10 +000021
22namespace llvm {
23 class LLVMContext;
24 class MDNode;
25}
26
27namespace clang {
28 class ASTContext;
Kostya Serebryanyc9fe6052012-04-24 06:57:01 +000029 class CodeGenOptions;
Dan Gohman3d5aff52010-10-14 23:06:10 +000030 class LangOptions;
Peter Collingbourne14110472011-01-13 18:57:25 +000031 class MangleContext;
Dan Gohman3d5aff52010-10-14 23:06:10 +000032 class QualType;
33 class Type;
34
35namespace CodeGen {
Dan Gohman3d5aff52010-10-14 23:06:10 +000036 class CGRecordLayout;
37
38/// CodeGenTBAA - This class organizes the cross-module state that is used
39/// while lowering AST types to LLVM types.
40class CodeGenTBAA {
41 ASTContext &Context;
42 llvm::LLVMContext& VMContext;
Kostya Serebryanyc9fe6052012-04-24 06:57:01 +000043 const CodeGenOptions &CodeGenOpts;
Dan Gohman3d5aff52010-10-14 23:06:10 +000044 const LangOptions &Features;
Dan Gohman0b5c4fc2010-10-15 20:23:12 +000045 MangleContext &MContext;
Dan Gohman3d5aff52010-10-14 23:06:10 +000046
Duncan Sands2d7cb062012-04-15 18:04:54 +000047 // MDHelper - Helper for creating metadata.
48 llvm::MDBuilder MDHelper;
49
Dan Gohman3d5aff52010-10-14 23:06:10 +000050 /// MetadataCache - This maps clang::Types to llvm::MDNodes describing them.
51 llvm::DenseMap<const Type *, llvm::MDNode *> MetadataCache;
52
Dan Gohman3d5aff52010-10-14 23:06:10 +000053 llvm::MDNode *Root;
Dan Gohman3d5aff52010-10-14 23:06:10 +000054 llvm::MDNode *Char;
55
Dan Gohman224d7592010-10-25 21:48:30 +000056 /// getRoot - This is the mdnode for the root of the metadata type graph
57 /// for this translation unit.
58 llvm::MDNode *getRoot();
59
60 /// getChar - This is the mdnode for "char", which is special, and any types
61 /// considered to be equivalent to it.
62 llvm::MDNode *getChar();
63
Dan Gohman3d5aff52010-10-14 23:06:10 +000064public:
65 CodeGenTBAA(ASTContext &Ctx, llvm::LLVMContext &VMContext,
Kostya Serebryanyc9fe6052012-04-24 06:57:01 +000066 const CodeGenOptions &CGO,
Dan Gohman0b5c4fc2010-10-15 20:23:12 +000067 const LangOptions &Features,
68 MangleContext &MContext);
Dan Gohman3d5aff52010-10-14 23:06:10 +000069 ~CodeGenTBAA();
70
Dan Gohman565cc442010-10-21 18:49:12 +000071 /// getTBAAInfo - Get the TBAA MDNode to be used for a dereference
72 /// of the given type.
Dan Gohman3d5aff52010-10-14 23:06:10 +000073 llvm::MDNode *getTBAAInfo(QualType QTy);
Kostya Serebryany8cb4a072012-03-26 17:03:51 +000074
75 /// getTBAAInfoForVTablePtr - Get the TBAA MDNode to be used for a
76 /// dereference of a vtable pointer.
77 llvm::MDNode *getTBAAInfoForVTablePtr();
Dan Gohman3d5aff52010-10-14 23:06:10 +000078};
79
80} // end namespace CodeGen
81} // end namespace clang
82
83#endif