[InstCombine] Signed saturation patterns
[llvm-core.git] / lib / CodeGen / AsmPrinter / DwarfStringPool.h
blobc5f5637fdae3fa4a5facd86582c62bf2ceedb00c
1 //===- llvm/CodeGen/DwarfStringPool.h - Dwarf Debug Framework ---*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFSTRINGPOOL_H
10 #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFSTRINGPOOL_H
12 #include "llvm/ADT/StringMap.h"
13 #include "llvm/ADT/StringRef.h"
14 #include "llvm/CodeGen/DwarfStringPoolEntry.h"
15 #include "llvm/Support/Allocator.h"
17 namespace llvm {
19 class AsmPrinter;
20 class MCSection;
21 class MCSymbol;
23 // Collection of strings for this unit and assorted symbols.
24 // A String->Symbol mapping of strings used by indirect
25 // references.
26 class DwarfStringPool {
27 using EntryTy = DwarfStringPoolEntry;
29 StringMap<EntryTy, BumpPtrAllocator &> Pool;
30 StringRef Prefix;
31 unsigned NumBytes = 0;
32 unsigned NumIndexedStrings = 0;
33 bool ShouldCreateSymbols;
35 StringMapEntry<EntryTy> &getEntryImpl(AsmPrinter &Asm, StringRef Str);
37 public:
38 using EntryRef = DwarfStringPoolEntryRef;
40 DwarfStringPool(BumpPtrAllocator &A, AsmPrinter &Asm, StringRef Prefix);
42 void emitStringOffsetsTableHeader(AsmPrinter &Asm, MCSection *OffsetSection,
43 MCSymbol *StartSym);
45 void emit(AsmPrinter &Asm, MCSection *StrSection,
46 MCSection *OffsetSection = nullptr,
47 bool UseRelativeOffsets = false);
49 bool empty() const { return Pool.empty(); }
51 unsigned size() const { return Pool.size(); }
53 unsigned getNumIndexedStrings() const { return NumIndexedStrings; }
55 /// Get a reference to an entry in the string pool.
56 EntryRef getEntry(AsmPrinter &Asm, StringRef Str);
58 /// Same as getEntry, except that you can use EntryRef::getIndex to obtain a
59 /// unique ID of this entry (e.g., for use in indexed forms like
60 /// DW_FORM_strx).
61 EntryRef getIndexedEntry(AsmPrinter &Asm, StringRef Str);
64 } // end namespace llvm
66 #endif // LLVM_LIB_CODEGEN_ASMPRINTER_DWARFSTRINGPOOL_H