LLVM  8.0.1
RecordStreamer.h
Go to the documentation of this file.
1 //===- RecordStreamer.h - Record asm defined and used symbols ---*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_LIB_OBJECT_RECORDSTREAMER_H
11 #define LLVM_LIB_OBJECT_RECORDSTREAMER_H
12 
13 #include "llvm/ADT/DenseMap.h"
14 #include "llvm/ADT/StringMap.h"
15 #include "llvm/MC/MCDirectives.h"
16 #include "llvm/MC/MCStreamer.h"
17 #include "llvm/MC/MCSymbol.h"
18 #include "llvm/Support/SMLoc.h"
19 #include <vector>
20 
21 namespace llvm {
22 
23 class GlobalValue;
24 class Module;
25 
26 class RecordStreamer : public MCStreamer {
27 public:
30 
31 private:
32  const Module &M;
33  StringMap<State> Symbols;
34  // Map of aliases created by .symver directives, saved so we can update
35  // their symbol binding after parsing complete. This maps from each
36  // aliasee to its list of aliases.
38 
39  /// Get the state recorded for the given symbol.
40  State getSymbolState(const MCSymbol *Sym);
41 
42  void markDefined(const MCSymbol &Symbol);
43  void markGlobal(const MCSymbol &Symbol, MCSymbolAttr Attribute);
44  void markUsed(const MCSymbol &Symbol);
45  void visitUsedSymbol(const MCSymbol &Sym) override;
46 
47 public:
48  RecordStreamer(MCContext &Context, const Module &M);
49 
50  void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI,
51  bool) override;
52  void EmitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
53  void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) override;
54  bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
55  void EmitZerofill(MCSection *Section, MCSymbol *Symbol, uint64_t Size,
56  unsigned ByteAlignment, SMLoc Loc = SMLoc()) override;
57  void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
58  unsigned ByteAlignment) override;
59  /// Record .symver aliases for later processing.
60  void emitELFSymverDirective(StringRef AliasName,
61  const MCSymbol *Aliasee) override;
62 
63  // Emit ELF .symver aliases and ensure they have the same binding as the
64  // defined symbol they alias with.
65  void flushSymverDirectives();
66 
67  // Symbols iterators
71 
72  // SymverAliasMap iterators
73  using const_symver_iterator = decltype(SymverAliasMap)::const_iterator;
75 };
76 
77 } // end namespace llvm
78 
79 #endif // LLVM_LIB_OBJECT_RECORDSTREAMER_H
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:39
This class represents lattice values for constants.
Definition: AllocatorList.h:24
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:42
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:65
void emitELFSymverDirective(StringRef AliasName, const MCSymbol *Aliasee) override
Record .symver aliases for later processing.
bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override
Add the given Attribute to Symbol.
void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) override
Emit an assignment of Value to Symbol.
StringMap< State >::const_iterator const_iterator
const_iterator end()
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:36
Context object for machine code objects.
Definition: MCContext.h:63
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:161
decltype(SymverAliasMap)::const_iterator const_symver_iterator
Streaming machine code generation interface.
Definition: MCStreamer.h:189
void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI, bool) override
Emit the given Instruction into the current section.
MCSymbolAttr
Definition: MCDirectives.h:19
A range adaptor for a pair of iterators.
void EmitZerofill(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment, SMLoc Loc=SMLoc()) override
Emit the zerofill section and an optional symbol.
Generic base class for all target subtargets.
uint32_t Size
Definition: Profile.cpp:47
void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override
Emit a common symbol.
void EmitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc()) override
Emit a label for Symbol into the current section.
LLVM Value Representation.
Definition: Value.h:73
iterator_range< const_symver_iterator > symverAliases()
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
Represents a location in source code.
Definition: SMLoc.h:24
const_iterator begin()
RecordStreamer(MCContext &Context, const Module &M)