LLVM API Documentation

AddressPool.h
Go to the documentation of this file.
00001 //===-- llvm/CodeGen/AddressPool.h - Dwarf Debug Framework -----*- C++ -*--===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 
00010 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_ADDRESSPOOL_H
00011 #define LLVM_LIB_CODEGEN_ASMPRINTER_ADDRESSPOOL_H
00012 
00013 #include "llvm/ADT/DenseMap.h"
00014 
00015 namespace llvm {
00016 class MCSection;
00017 class MCSymbol;
00018 class AsmPrinter;
00019 // Collection of addresses for this unit and assorted labels.
00020 // A Symbol->unsigned mapping of addresses used by indirect
00021 // references.
00022 class AddressPool {
00023   struct AddressPoolEntry {
00024     unsigned Number;
00025     bool TLS;
00026     AddressPoolEntry(unsigned Number, bool TLS) : Number(Number), TLS(TLS) {}
00027   };
00028   DenseMap<const MCSymbol *, AddressPoolEntry> Pool;
00029 
00030   /// Record whether the AddressPool has been queried for an address index since
00031   /// the last "resetUsedFlag" call. Used to implement type unit fallback - a
00032   /// type that references addresses cannot be placed in a type unit when using
00033   /// fission.
00034   bool HasBeenUsed;
00035 
00036 public:
00037   AddressPool() : HasBeenUsed(false) {}
00038 
00039   /// \brief Returns the index into the address pool with the given
00040   /// label/symbol.
00041   unsigned getIndex(const MCSymbol *Sym, bool TLS = false);
00042 
00043   void emit(AsmPrinter &Asm, const MCSection *AddrSection);
00044 
00045   bool isEmpty() { return Pool.empty(); }
00046 
00047   bool hasBeenUsed() const { return HasBeenUsed; }
00048 
00049   void resetUsedFlag() { HasBeenUsed = false; }
00050 };
00051 }
00052 #endif