LLVM  5.0.0
RecordStreamer.cpp
Go to the documentation of this file.
1 //===-- RecordStreamer.cpp - Record asm defined and used symbols ----------===//
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 #include "RecordStreamer.h"
11 #include "llvm/MC/MCSymbol.h"
12 
13 using namespace llvm;
14 
15 void RecordStreamer::markDefined(const MCSymbol &Symbol) {
16  State &S = Symbols[Symbol.getName()];
17  switch (S) {
18  case DefinedGlobal:
19  case Global:
20  S = DefinedGlobal;
21  break;
22  case NeverSeen:
23  case Defined:
24  case Used:
25  S = Defined;
26  break;
27  case DefinedWeak:
28  break;
29  case UndefinedWeak:
30  S = DefinedWeak;
31  }
32 }
33 
34 void RecordStreamer::markGlobal(const MCSymbol &Symbol,
36  State &S = Symbols[Symbol.getName()];
37  switch (S) {
38  case DefinedGlobal:
39  case Defined:
40  S = (Attribute == MCSA_Weak) ? DefinedWeak : DefinedGlobal;
41  break;
42 
43  case NeverSeen:
44  case Global:
45  case Used:
46  S = (Attribute == MCSA_Weak) ? UndefinedWeak : Global;
47  break;
48  case UndefinedWeak:
49  case DefinedWeak:
50  break;
51  }
52 }
53 
54 void RecordStreamer::markUsed(const MCSymbol &Symbol) {
55  State &S = Symbols[Symbol.getName()];
56  switch (S) {
57  case DefinedGlobal:
58  case Defined:
59  case Global:
60  case DefinedWeak:
61  case UndefinedWeak:
62  break;
63 
64  case NeverSeen:
65  case Used:
66  S = Used;
67  break;
68  }
69 }
70 
71 void RecordStreamer::visitUsedSymbol(const MCSymbol &Sym) { markUsed(Sym); }
72 
74 
76  return Symbols.begin();
77 }
78 
80 
82  const MCSubtargetInfo &STI, bool) {
83  MCStreamer::EmitInstruction(Inst, STI);
84 }
85 
87  MCStreamer::EmitLabel(Symbol);
88  markDefined(*Symbol);
89 }
90 
92  markDefined(*Symbol);
93  MCStreamer::EmitAssignment(Symbol, Value);
94 }
95 
97  MCSymbolAttr Attribute) {
98  if (Attribute == MCSA_Global || Attribute == MCSA_Weak)
99  markGlobal(*Symbol, Attribute);
100  if (Attribute == MCSA_LazyReference)
101  markUsed(*Symbol);
102  return true;
103 }
104 
106  uint64_t Size, unsigned ByteAlignment) {
107  markDefined(*Symbol);
108 }
109 
111  unsigned ByteAlignment) {
112  markDefined(*Symbol);
113 }
114 
116  const MCSymbol *Aliasee) {
117  SymverAliasMap[Aliasee].push_back(Alias);
118 }
void emitELFSymverDirective(MCSymbol *Alias, const MCSymbol *Aliasee) override
Record .symver aliases for later processing.
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:39
LLVMContext & Context
void EmitZerofill(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override
Emit the zerofill section and an optional symbol.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:42
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()
virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI, bool PrintSchedInfo=false)
Emit the given Instruction into the current section.
Definition: MCStreamer.cpp:780
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:36
virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
Definition: MCStreamer.cpp:737
Context object for machine code objects.
Definition: MCContext.h:59
.lazy_reference (MachO)
Definition: MCDirectives.h:34
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:159
Streaming machine code generation interface.
Definition: MCStreamer.h:167
RecordStreamer(MCContext &Context)
void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI, bool) override
Emit the given Instruction into the current section.
MCSymbolAttr
Definition: MCDirectives.h:19
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
StringRef getName() const
getName - Get the symbol name.
Definition: MCSymbol.h:203
iterator begin()
Definition: StringMap.h:315
.type _foo,
Definition: MCDirectives.h:30
MCSubtargetInfo - Generic base class for all target subtargets.
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
virtual void EmitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())
Emit a label for Symbol into the current section.
Definition: MCStreamer.cpp:301
Represents a location in source code.
Definition: SMLoc.h:24
const_iterator begin()
iterator end()
Definition: StringMap.h:318