Thanks to visit codestin.com
Credit goes to llvm.org

LLVM 22.0.0git
RecordStreamer.h
Go to the documentation of this file.
1//===- RecordStreamer.h - Record asm defined and used symbols ---*- 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_LIB_OBJECT_RECORDSTREAMER_H
10#define LLVM_LIB_OBJECT_RECORDSTREAMER_H
11
12#include "llvm/ADT/DenseMap.h"
13#include "llvm/ADT/MapVector.h"
14#include "llvm/ADT/StringMap.h"
16#include "llvm/MC/MCStreamer.h"
17#include "llvm/Support/SMLoc.h"
18#include <vector>
19
20namespace llvm {
21
22class MCSymbol;
23class Module;
24
25class RecordStreamer : public MCStreamer {
26public:
29
30private:
31 const Module &M;
32 StringMap<State> Symbols;
33 // Map of aliases created by .symver directives, saved so we can update
34 // their symbol binding after parsing complete. This maps from each
35 // aliasee to its list of aliases.
37
38 /// Get the state recorded for the given symbol.
39 State getSymbolState(const MCSymbol *Sym);
40
41 void markDefined(const MCSymbol &Symbol);
42 void markGlobal(const MCSymbol &Symbol, MCSymbolAttr Attribute);
43 void markUsed(const MCSymbol &Symbol);
44 void visitUsedSymbol(const MCSymbol &Sym) override;
45
46public:
47 RecordStreamer(MCContext &Context, const Module &M);
48
49 void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
50 void emitAssignment(MCSymbol *Symbol, const MCExpr *Value) override;
51 bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
52 void emitZerofill(MCSection *Section, MCSymbol *Symbol, uint64_t Size,
53 Align ByteAlignment, SMLoc Loc = SMLoc()) override;
55 Align ByteAlignment) override;
56
57 // Ignore format-specific directives; we do not need any information from
58 // them, but the default implementation of these methods crashes, so we
59 // override them with versions that do nothing.
60 void emitSubsectionsViaSymbols() override {};
61 void beginCOFFSymbolDef(const MCSymbol *Symbol) override {}
63 void emitCOFFSymbolType(int Type) override {}
64 void endCOFFSymbolDef() override {}
65
66 /// Record .symver aliases for later processing.
67 void emitELFSymverDirective(const MCSymbol *OriginalSym, StringRef Name,
68 bool KeepOriginalSym) override;
69
70 // Emit ELF .symver aliases and ensure they have the same binding as the
71 // defined symbol they alias with.
73
74 // Symbols iterators
78
79 // SymverAliasMap iterators
80 using const_symver_iterator = decltype(SymverAliasMap)::const_iterator;
82};
83
84} // end namespace llvm
85
86#endif // LLVM_LIB_OBJECT_RECORDSTREAMER_H
This file defines the StringMap class.
This file defines the DenseMap class.
This file implements a map that provides insertion order iteration.
Functions, function parameters, and return types can have attributes to indicate how they should be t...
Definition Attributes.h:69
Context object for machine code objects.
Definition MCContext.h:83
Base class for the full range of assembler expressions which are needed for parsing.
Definition MCExpr.h:34
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition MCSection.h:521
MCStreamer(MCContext &Ctx)
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
This class implements a map that also provides access to all stored values in a deterministic order.
Definition MapVector.h:36
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
decltype(SymverAliasMap)::const_iterator const_symver_iterator
void emitZerofill(MCSection *Section, MCSymbol *Symbol, uint64_t Size, Align ByteAlignment, SMLoc Loc=SMLoc()) override
Emit the zerofill section and an optional symbol.
void endCOFFSymbolDef() override
Marks the end of the symbol definition.
bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override
Add the given Attribute to Symbol.
void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, Align ByteAlignment) override
Emit a common symbol.
void emitELFSymverDirective(const MCSymbol *OriginalSym, StringRef Name, bool KeepOriginalSym) override
Record .symver aliases for later processing.
void emitAssignment(MCSymbol *Symbol, const MCExpr *Value) override
Emit an assignment of Value to Symbol.
iterator_range< const_symver_iterator > symverAliases()
void emitCOFFSymbolStorageClass(int StorageClass) override
Emit the storage class of the symbol.
StringMap< State >::const_iterator const_iterator
const_iterator end()
void beginCOFFSymbolDef(const MCSymbol *Symbol) override
Start emitting COFF symbol definition.
RecordStreamer(MCContext &Context, const Module &M)
void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc()) override
Emit a label for Symbol into the current section.
void emitSubsectionsViaSymbols() override
Emit a .subsection_via_symbols directive.
void emitCOFFSymbolType(int Type) override
Emit the type of the symbol.
const_iterator begin()
Represents a location in source code.
Definition SMLoc.h:23
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition StringMap.h:133
StringMapIterBase< ValueTy, true > const_iterator
Definition StringMap.h:220
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:45
LLVM Value Representation.
Definition Value.h:75
A range adaptor for a pair of iterators.
This is an optimization pass for GlobalISel generic memory operations.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39