1 //===-- llvm/MC/MCSymbolTableEntry.h - Symbol table entry -------*- 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 //===----------------------------------------------------------------------===// 8 9 #ifndef LLVM_MC_MCSYMBOLTABLEENTRY_H 10 #define LLVM_MC_MCSYMBOLTABLEENTRY_H 11 12 #include "llvm/ADT/StringMapEntry.h" 13 14 namespace llvm { 15 16 class MCSymbol; 17 18 /// The value for an entry in the symbol table of an MCContext. 19 /// 20 /// This is in a separate file, because MCSymbol uses MCSymbolTableEntry (see 21 /// below) to reuse the name that is stored in the symbol table. 22 struct MCSymbolTableValue { 23 /// The symbol associated with the name, if any. 24 MCSymbol *Symbol = nullptr; 25 26 /// The next ID to dole out to an unnamed assembler temporary symbol with 27 /// the prefix (symbol table key). 28 unsigned NextUniqueID = 0; 29 30 /// Whether the name associated with this value is used for a symbol. This is 31 /// not necessarily true: sometimes, we use a symbol table value without an 32 /// associated symbol for accessing NextUniqueID when a suffix is added to a 33 /// name. However, Used might be true even if Symbol is nullptr: temporary 34 /// named symbols are not added to the symbol table. 35 bool Used = false; 36 }; 37 38 /// MCContext stores MCSymbolTableValue in a string map (see MCSymbol::operator 39 /// new). To avoid redundant storage of the name, MCSymbol stores a pointer (8 40 /// bytes -- half the size of a StringRef) to the entry to access it. 41 using MCSymbolTableEntry = StringMapEntry<MCSymbolTableValue>; 42 43 } // end namespace llvm 44 45 #endif 46