Path: blob/main/contrib/llvm-project/llvm/lib/DWARFLinker/Parallel/StringEntryToDwarfStringPoolEntryMap.h
35291 views
//===- StringEntryToDwarfStringPoolEntryMap.h -------------------*- 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_DWARFLINKER_PARALLEL_STRINGENTRYTODWARFSTRINGPOOLENTRYMAP_H9#define LLVM_LIB_DWARFLINKER_PARALLEL_STRINGENTRYTODWARFSTRINGPOOLENTRYMAP_H1011#include "DWARFLinkerGlobalData.h"12#include "llvm/ADT/SmallVector.h"13#include "llvm/DWARFLinker/StringPool.h"1415namespace llvm {16namespace dwarf_linker {17namespace parallel {1819/// This class creates a DwarfStringPoolEntry for the corresponding StringEntry.20class StringEntryToDwarfStringPoolEntryMap {21public:22StringEntryToDwarfStringPoolEntryMap(LinkingGlobalData &GlobalData)23: GlobalData(GlobalData) {}24~StringEntryToDwarfStringPoolEntryMap() {}2526/// Create DwarfStringPoolEntry for specified StringEntry if necessary.27/// Initialize DwarfStringPoolEntry with initial values.28DwarfStringPoolEntryWithExtString *add(const StringEntry *String) {29DwarfStringPoolEntriesTy::iterator it = DwarfStringPoolEntries.find(String);3031if (it == DwarfStringPoolEntries.end()) {32DwarfStringPoolEntryWithExtString *DataPtr =33GlobalData.getAllocator()34.Allocate<DwarfStringPoolEntryWithExtString>();35DataPtr->String = String->getKey();36DataPtr->Index = DwarfStringPoolEntry::NotIndexed;37DataPtr->Offset = 0;38DataPtr->Symbol = nullptr;39it = DwarfStringPoolEntries.insert(std::make_pair(String, DataPtr)).first;40}4142assert(it->second != nullptr);43return it->second;44}4546/// Returns already existed DwarfStringPoolEntry for the specified47/// StringEntry.48DwarfStringPoolEntryWithExtString *49getExistingEntry(const StringEntry *String) const {50DwarfStringPoolEntriesTy::const_iterator it =51DwarfStringPoolEntries.find(String);5253assert(it != DwarfStringPoolEntries.end());54assert(it->second != nullptr);55return it->second;56}5758/// Erase contents of StringsForEmission.59void clear() { DwarfStringPoolEntries.clear(); }6061protected:62using DwarfStringPoolEntriesTy =63DenseMap<const StringEntry *, DwarfStringPoolEntryWithExtString *>;64DwarfStringPoolEntriesTy DwarfStringPoolEntries;6566LinkingGlobalData &GlobalData;67};6869} // end of namespace parallel70} // end of namespace dwarf_linker71} // end of namespace llvm7273#endif // LLVM_LIB_DWARFLINKER_PARALLEL_STRINGENTRYTODWARFSTRINGPOOLENTRYMAP_H747576