Path: blob/main/contrib/llvm-project/llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.h
35271 views
//===- llvm/CodeGen/DwarfStringPool.h - Dwarf Debug Framework ---*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFSTRINGPOOL_H9#define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFSTRINGPOOL_H1011#include "llvm/ADT/StringMap.h"12#include "llvm/ADT/StringRef.h"13#include "llvm/CodeGen/DwarfStringPoolEntry.h"14#include "llvm/Support/Allocator.h"1516namespace llvm {1718class AsmPrinter;19class MCSection;20class MCSymbol;2122// Collection of strings for this unit and assorted symbols.23// A String->Symbol mapping of strings used by indirect24// references.25class DwarfStringPool {26using EntryTy = DwarfStringPoolEntry;2728StringMap<EntryTy, BumpPtrAllocator &> Pool;29StringRef Prefix;30uint64_t NumBytes = 0;31unsigned NumIndexedStrings = 0;32bool ShouldCreateSymbols;3334StringMapEntry<EntryTy> &getEntryImpl(AsmPrinter &Asm, StringRef Str);3536public:37using EntryRef = DwarfStringPoolEntryRef;3839DwarfStringPool(BumpPtrAllocator &A, AsmPrinter &Asm, StringRef Prefix);4041void emitStringOffsetsTableHeader(AsmPrinter &Asm, MCSection *OffsetSection,42MCSymbol *StartSym);4344void emit(AsmPrinter &Asm, MCSection *StrSection,45MCSection *OffsetSection = nullptr,46bool UseRelativeOffsets = false);4748bool empty() const { return Pool.empty(); }4950unsigned size() const { return Pool.size(); }5152unsigned getNumIndexedStrings() const { return NumIndexedStrings; }5354/// Get a reference to an entry in the string pool.55EntryRef getEntry(AsmPrinter &Asm, StringRef Str);5657/// Same as getEntry, except that you can use EntryRef::getIndex to obtain a58/// unique ID of this entry (e.g., for use in indexed forms like59/// DW_FORM_strx).60EntryRef getIndexedEntry(AsmPrinter &Asm, StringRef Str);61};6263} // end namespace llvm6465#endif // LLVM_LIB_CODEGEN_ASMPRINTER_DWARFSTRINGPOOL_H666768