blob: 9fe51fb331414c1671abe215b9ca5b98244cab2d [file] [log] [blame]
Dan Gohman947c9af2010-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 Gohman5419ce62010-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 Gohman947c9af2010-10-14 23:06:10 +000012//
13//===----------------------------------------------------------------------===//
14
15#ifndef CLANG_CODEGEN_CODEGENTBAA_H
16#define CLANG_CODEGEN_CODEGENTBAA_H
17
Chris Lattner01cf8db2011-07-20 06:58:45 +000018#include "clang/Basic/LLVM.h"
Dan Gohman947c9af2010-10-14 23:06:10 +000019#include "llvm/ADT/DenseMap.h"
20
21namespace llvm {
22 class LLVMContext;
23 class MDNode;
24}
25
26namespace clang {
27 class ASTContext;
28 class LangOptions;
Peter Collingbourne0ff0b372011-01-13 18:57:25 +000029 class MangleContext;
Dan Gohman947c9af2010-10-14 23:06:10 +000030 class QualType;
31 class Type;
32
33namespace CodeGen {
Dan Gohman947c9af2010-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 Gohman2e29eb52010-10-15 20:23:12 +000042 MangleContext &MContext;
Dan Gohman947c9af2010-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
Dan Gohman947c9af2010-10-14 23:06:10 +000047 llvm::MDNode *Root;
Dan Gohman947c9af2010-10-14 23:06:10 +000048 llvm::MDNode *Char;
49
Dan Gohman7dfd13c2010-10-25 21:48:30 +000050 /// getRoot - This is the mdnode for the root of the metadata type graph
51 /// for this translation unit.
52 llvm::MDNode *getRoot();
53
54 /// getChar - This is the mdnode for "char", which is special, and any types
55 /// considered to be equivalent to it.
56 llvm::MDNode *getChar();
57
Chris Lattner01cf8db2011-07-20 06:58:45 +000058 llvm::MDNode *getTBAAInfoForNamedType(StringRef NameStr,
Dan Gohmandc2c4db2010-10-25 23:51:23 +000059 llvm::MDNode *Parent,
60 bool Readonly = false);
Dan Gohman947c9af2010-10-14 23:06:10 +000061
62public:
63 CodeGenTBAA(ASTContext &Ctx, llvm::LLVMContext &VMContext,
Dan Gohman2e29eb52010-10-15 20:23:12 +000064 const LangOptions &Features,
65 MangleContext &MContext);
Dan Gohman947c9af2010-10-14 23:06:10 +000066 ~CodeGenTBAA();
67
Dan Gohman5419ce62010-10-21 18:49:12 +000068 /// getTBAAInfo - Get the TBAA MDNode to be used for a dereference
69 /// of the given type.
Dan Gohman947c9af2010-10-14 23:06:10 +000070 llvm::MDNode *getTBAAInfo(QualType QTy);
71};
72
73} // end namespace CodeGen
74} // end namespace clang
75
76#endif