Revert " [LoongArch][ISel] Check the number of sign bits in `PatGprGpr_32` (#107432)"
[llvm-project.git] / llvm / lib / DWARFLinker / Parallel / StringEntryToDwarfStringPoolEntryMap.h
blobf67536ef7a1a84c813658524cfc064f82829055a
1 //===- StringEntryToDwarfStringPoolEntryMap.h -------------------*- 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_DWARFLINKER_PARALLEL_STRINGENTRYTODWARFSTRINGPOOLENTRYMAP_H
10 #define LLVM_LIB_DWARFLINKER_PARALLEL_STRINGENTRYTODWARFSTRINGPOOLENTRYMAP_H
12 #include "DWARFLinkerGlobalData.h"
13 #include "llvm/ADT/SmallVector.h"
14 #include "llvm/DWARFLinker/StringPool.h"
16 namespace llvm {
17 namespace dwarf_linker {
18 namespace parallel {
20 /// This class creates a DwarfStringPoolEntry for the corresponding StringEntry.
21 class StringEntryToDwarfStringPoolEntryMap {
22 public:
23 StringEntryToDwarfStringPoolEntryMap(LinkingGlobalData &GlobalData)
24 : GlobalData(GlobalData) {}
25 ~StringEntryToDwarfStringPoolEntryMap() {}
27 /// Create DwarfStringPoolEntry for specified StringEntry if necessary.
28 /// Initialize DwarfStringPoolEntry with initial values.
29 DwarfStringPoolEntryWithExtString *add(const StringEntry *String) {
30 DwarfStringPoolEntriesTy::iterator it = DwarfStringPoolEntries.find(String);
32 if (it == DwarfStringPoolEntries.end()) {
33 DwarfStringPoolEntryWithExtString *DataPtr =
34 GlobalData.getAllocator()
35 .Allocate<DwarfStringPoolEntryWithExtString>();
36 DataPtr->String = String->getKey();
37 DataPtr->Index = DwarfStringPoolEntry::NotIndexed;
38 DataPtr->Offset = 0;
39 DataPtr->Symbol = nullptr;
40 it = DwarfStringPoolEntries.insert(std::make_pair(String, DataPtr)).first;
43 assert(it->second != nullptr);
44 return it->second;
47 /// Returns already existed DwarfStringPoolEntry for the specified
48 /// StringEntry.
49 DwarfStringPoolEntryWithExtString *
50 getExistingEntry(const StringEntry *String) const {
51 DwarfStringPoolEntriesTy::const_iterator it =
52 DwarfStringPoolEntries.find(String);
54 assert(it != DwarfStringPoolEntries.end());
55 assert(it->second != nullptr);
56 return it->second;
59 /// Erase contents of StringsForEmission.
60 void clear() { DwarfStringPoolEntries.clear(); }
62 protected:
63 using DwarfStringPoolEntriesTy =
64 DenseMap<const StringEntry *, DwarfStringPoolEntryWithExtString *>;
65 DwarfStringPoolEntriesTy DwarfStringPoolEntries;
67 LinkingGlobalData &GlobalData;
70 } // end of namespace parallel
71 } // end of namespace dwarf_linker
72 } // end of namespace llvm
74 #endif // LLVM_LIB_DWARFLINKER_PARALLEL_STRINGENTRYTODWARFSTRINGPOOLENTRYMAP_H