CodeGenTBAA.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. //
  10. // This is the code that manages TBAA information and defines the TBAA policy
  11. // for the optimizer to use.
  12. //
  13. //===----------------------------------------------------------------------===//
  14. #ifndef CLANG_CODEGEN_CODEGENTBAA_H
  15. #define CLANG_CODEGEN_CODEGENTBAA_H
  16. #include "clang/Basic/LLVM.h"
  17. #include "llvm/ADT/DenseMap.h"
  18. namespace llvm {
  19. class LLVMContext;
  20. class MDNode;
  21. }
  22. namespace clang {
  23. class ASTContext;
  24. class LangOptions;
  25. class MangleContext;
  26. class QualType;
  27. class Type;
  28. namespace CodeGen {
  29. class CGRecordLayout;
  30. /// CodeGenTBAA - This class organizes the cross-module state that is used
  31. /// while lowering AST types to LLVM types.
  32. class CodeGenTBAA {
  33. ASTContext &Context;
  34. llvm::LLVMContext& VMContext;
  35. const LangOptions &Features;
  36. MangleContext &MContext;
  37. /// MetadataCache - This maps clang::Types to llvm::MDNodes describing them.
  38. llvm::DenseMap<const Type *, llvm::MDNode *> MetadataCache;
  39. llvm::MDNode *Root;
  40. llvm::MDNode *Char;
  41. /// getRoot - This is the mdnode for the root of the metadata type graph
  42. /// for this translation unit.
  43. llvm::MDNode *getRoot();
  44. /// getChar - This is the mdnode for "char", which is special, and any types
  45. /// considered to be equivalent to it.
  46. llvm::MDNode *getChar();
  47. llvm::MDNode *getTBAAInfoForNamedType(StringRef NameStr,
  48. llvm::MDNode *Parent,
  49. bool Readonly = false);
  50. public:
  51. CodeGenTBAA(ASTContext &Ctx, llvm::LLVMContext &VMContext,
  52. const LangOptions &Features,
  53. MangleContext &MContext);
  54. ~CodeGenTBAA();
  55. /// getTBAAInfo - Get the TBAA MDNode to be used for a dereference
  56. /// of the given type.
  57. llvm::MDNode *getTBAAInfo(QualType QTy);
  58. };
  59. } // end namespace CodeGen
  60. } // end namespace clang
  61. #endif