LLVM API Documentation
00001 //===-- llvm/CodeGen/DwarfStringPool.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_DWARFSTRINGPOOL_H 00011 #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFSTRINGPOOL_H 00012 00013 #include "llvm/ADT/StringMap.h" 00014 #include "llvm/CodeGen/AsmPrinter.h" 00015 #include "llvm/Support/Allocator.h" 00016 00017 #include <utility> 00018 00019 namespace llvm { 00020 00021 class MCSymbol; 00022 class MCSection; 00023 class StringRef; 00024 00025 // Collection of strings for this unit and assorted symbols. 00026 // A String->Symbol mapping of strings used by indirect 00027 // references. 00028 class DwarfStringPool { 00029 StringMap<std::pair<MCSymbol *, unsigned>, BumpPtrAllocator &> Pool; 00030 StringRef Prefix; 00031 00032 public: 00033 DwarfStringPool(BumpPtrAllocator &A, AsmPrinter &Asm, StringRef Prefix) 00034 : Pool(A), Prefix(Prefix) {} 00035 00036 void emit(AsmPrinter &Asm, const MCSection *StrSection, 00037 const MCSection *OffsetSection = nullptr); 00038 00039 /// \brief Returns an entry into the string pool with the given 00040 /// string text. 00041 MCSymbol *getSymbol(AsmPrinter &Asm, StringRef Str); 00042 00043 /// \brief Returns the index into the string pool with the given 00044 /// string text. 00045 unsigned getIndex(AsmPrinter &Asm, StringRef Str); 00046 00047 bool empty() const { return Pool.empty(); } 00048 }; 00049 } 00050 #endif