Dan Gohman | 3d5aff5 | 2010-10-14 23:06:10 +0000 | [diff] [blame] | 1 | //===--- 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 Gohman | 565cc44 | 2010-10-21 18:49:12 +0000 | [diff] [blame] | 10 | // This is the code that manages TBAA information and defines the TBAA policy |
| 11 | // for the optimizer to use. |
Dan Gohman | 3d5aff5 | 2010-10-14 23:06:10 +0000 | [diff] [blame] | 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef CLANG_CODEGEN_CODEGENTBAA_H |
| 16 | #define CLANG_CODEGEN_CODEGENTBAA_H |
| 17 | |
Chris Lattner | 686775d | 2011-07-20 06:58:45 +0000 | [diff] [blame] | 18 | #include "clang/Basic/LLVM.h" |
Dan Gohman | 3d5aff5 | 2010-10-14 23:06:10 +0000 | [diff] [blame] | 19 | #include "llvm/ADT/DenseMap.h" |
Duncan Sands | 2d7cb06 | 2012-04-15 18:04:54 +0000 | [diff] [blame] | 20 | #include "llvm/Support/MDBuilder.h" |
Dan Gohman | 3d5aff5 | 2010-10-14 23:06:10 +0000 | [diff] [blame] | 21 | |
| 22 | namespace llvm { |
| 23 | class LLVMContext; |
| 24 | class MDNode; |
| 25 | } |
| 26 | |
| 27 | namespace clang { |
| 28 | class ASTContext; |
Kostya Serebryany | c9fe605 | 2012-04-24 06:57:01 +0000 | [diff] [blame] | 29 | class CodeGenOptions; |
Dan Gohman | 3d5aff5 | 2010-10-14 23:06:10 +0000 | [diff] [blame] | 30 | class LangOptions; |
Peter Collingbourne | 1411047 | 2011-01-13 18:57:25 +0000 | [diff] [blame] | 31 | class MangleContext; |
Dan Gohman | 3d5aff5 | 2010-10-14 23:06:10 +0000 | [diff] [blame] | 32 | class QualType; |
| 33 | class Type; |
| 34 | |
| 35 | namespace CodeGen { |
Dan Gohman | 3d5aff5 | 2010-10-14 23:06:10 +0000 | [diff] [blame] | 36 | class CGRecordLayout; |
| 37 | |
| 38 | /// CodeGenTBAA - This class organizes the cross-module state that is used |
| 39 | /// while lowering AST types to LLVM types. |
| 40 | class CodeGenTBAA { |
| 41 | ASTContext &Context; |
Kostya Serebryany | c9fe605 | 2012-04-24 06:57:01 +0000 | [diff] [blame] | 42 | const CodeGenOptions &CodeGenOpts; |
Dan Gohman | 3d5aff5 | 2010-10-14 23:06:10 +0000 | [diff] [blame] | 43 | const LangOptions &Features; |
Dan Gohman | 0b5c4fc | 2010-10-15 20:23:12 +0000 | [diff] [blame] | 44 | MangleContext &MContext; |
Dan Gohman | 3d5aff5 | 2010-10-14 23:06:10 +0000 | [diff] [blame] | 45 | |
Duncan Sands | 2d7cb06 | 2012-04-15 18:04:54 +0000 | [diff] [blame] | 46 | // MDHelper - Helper for creating metadata. |
| 47 | llvm::MDBuilder MDHelper; |
| 48 | |
Dan Gohman | 3d5aff5 | 2010-10-14 23:06:10 +0000 | [diff] [blame] | 49 | /// MetadataCache - This maps clang::Types to llvm::MDNodes describing them. |
| 50 | llvm::DenseMap<const Type *, llvm::MDNode *> MetadataCache; |
| 51 | |
Dan Gohman | 3d5aff5 | 2010-10-14 23:06:10 +0000 | [diff] [blame] | 52 | llvm::MDNode *Root; |
Dan Gohman | 3d5aff5 | 2010-10-14 23:06:10 +0000 | [diff] [blame] | 53 | llvm::MDNode *Char; |
| 54 | |
Dan Gohman | 224d759 | 2010-10-25 21:48:30 +0000 | [diff] [blame] | 55 | /// getRoot - This is the mdnode for the root of the metadata type graph |
| 56 | /// for this translation unit. |
| 57 | llvm::MDNode *getRoot(); |
| 58 | |
| 59 | /// getChar - This is the mdnode for "char", which is special, and any types |
| 60 | /// considered to be equivalent to it. |
| 61 | llvm::MDNode *getChar(); |
| 62 | |
Dan Gohman | 3d5aff5 | 2010-10-14 23:06:10 +0000 | [diff] [blame] | 63 | public: |
| 64 | CodeGenTBAA(ASTContext &Ctx, llvm::LLVMContext &VMContext, |
Kostya Serebryany | c9fe605 | 2012-04-24 06:57:01 +0000 | [diff] [blame] | 65 | const CodeGenOptions &CGO, |
Dan Gohman | 0b5c4fc | 2010-10-15 20:23:12 +0000 | [diff] [blame] | 66 | const LangOptions &Features, |
| 67 | MangleContext &MContext); |
Dan Gohman | 3d5aff5 | 2010-10-14 23:06:10 +0000 | [diff] [blame] | 68 | ~CodeGenTBAA(); |
| 69 | |
Dan Gohman | 565cc44 | 2010-10-21 18:49:12 +0000 | [diff] [blame] | 70 | /// getTBAAInfo - Get the TBAA MDNode to be used for a dereference |
| 71 | /// of the given type. |
Dan Gohman | 3d5aff5 | 2010-10-14 23:06:10 +0000 | [diff] [blame] | 72 | llvm::MDNode *getTBAAInfo(QualType QTy); |
Kostya Serebryany | 8cb4a07 | 2012-03-26 17:03:51 +0000 | [diff] [blame] | 73 | |
| 74 | /// getTBAAInfoForVTablePtr - Get the TBAA MDNode to be used for a |
| 75 | /// dereference of a vtable pointer. |
| 76 | llvm::MDNode *getTBAAInfoForVTablePtr(); |
Dan Gohman | 3d5aff5 | 2010-10-14 23:06:10 +0000 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | } // end namespace CodeGen |
| 80 | } // end namespace clang |
| 81 | |
| 82 | #endif |