LLVM  3.7.0
RecordStreamer.cpp
Go to the documentation of this file.
1 //===-- RecordStreamer.cpp - Record asm definde 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 using namespace llvm;
13 
14 void RecordStreamer::markDefined(const MCSymbol &Symbol) {
15  State &S = Symbols[Symbol.getName()];
16  switch (S) {
17  case DefinedGlobal:
18  case Global:
19  S = DefinedGlobal;
20  break;
21  case NeverSeen:
22  case Defined:
23  case Used:
24  S = Defined;
25  break;
26  }
27 }
28 
29 void RecordStreamer::markGlobal(const MCSymbol &Symbol) {
30  State &S = Symbols[Symbol.getName()];
31  switch (S) {
32  case DefinedGlobal:
33  case Defined:
34  S = DefinedGlobal;
35  break;
36 
37  case NeverSeen:
38  case Global:
39  case Used:
40  S = Global;
41  break;
42  }
43 }
44 
45 void RecordStreamer::markUsed(const MCSymbol &Symbol) {
46  State &S = Symbols[Symbol.getName()];
47  switch (S) {
48  case DefinedGlobal:
49  case Defined:
50  case Global:
51  break;
52 
53  case NeverSeen:
54  case Used:
55  S = Used;
56  break;
57  }
58 }
59 
60 void RecordStreamer::visitUsedSymbol(const MCSymbol &Sym) { markUsed(Sym); }
61 
63  return Symbols.begin();
64 }
65 
67 
69 
71  const MCSubtargetInfo &STI) {
72  MCStreamer::EmitInstruction(Inst, STI);
73 }
74 
76  MCStreamer::EmitLabel(Symbol);
77  markDefined(*Symbol);
78 }
79 
81  markDefined(*Symbol);
82  MCStreamer::EmitAssignment(Symbol, Value);
83 }
84 
87  if (Attribute == MCSA_Global)
88  markGlobal(*Symbol);
89  return true;
90 }
91 
93  uint64_t Size, unsigned ByteAlignment) {
94  markDefined(*Symbol);
95 }
96 
97 void RecordStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
98  unsigned ByteAlignment) {
99  markDefined(*Symbol);
100 }
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:48
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:39
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.
const_iterator end()
virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
Definition: MCStreamer.cpp:639
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:33
virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
Definition: MCStreamer.cpp:596
Context object for machine code objects.
Definition: MCContext.h:48
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:150
Streaming machine code generation interface.
Definition: MCStreamer.h:157
RecordStreamer(MCContext &Context)
void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override
Emit the given Instruction into the current section.
virtual void EmitLabel(MCSymbol *Symbol)
Emit a label for Symbol into the current section.
Definition: MCStreamer.cpp:203
MCSymbolAttr
Definition: MCDirectives.h:19
StringRef getName() const
getName - Get the symbol name.
Definition: MCSymbol.h:205
StringMap< State >::const_iterator const_iterator
iterator begin()
Definition: StringMap.h:252
.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) override
Emit a label for Symbol into the current section.
LLVM Value Representation.
Definition: Value.h:69
const_iterator begin()
iterator end()
Definition: StringMap.h:255