RecordStreamer.h revision cd81d94322a39503e4a3e87b6ee03d4fcb3465fb
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_OBJECT_RECORD_STREAMER
11#define LLVM_OBJECT_RECORD_STREAMER
12
13#include "llvm/MC/MCStreamer.h"
14
15namespace llvm {
16class RecordStreamer : public MCStreamer {
17public:
18  enum State { NeverSeen, Global, Defined, DefinedGlobal, Used };
19
20private:
21  StringMap<State> Symbols;
22  void markDefined(const MCSymbol &Symbol);
23  void markGlobal(const MCSymbol &Symbol);
24  void markUsed(const MCSymbol &Symbol);
25  void visitUsedSymbol(const MCSymbol &Sym) override;
26
27public:
28  typedef StringMap<State>::const_iterator const_iterator;
29  const_iterator begin();
30  const_iterator end();
31  RecordStreamer(MCContext &Context);
32  void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override;
33  void EmitLabel(MCSymbol *Symbol) override;
34  void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) override;
35  bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
36  void EmitZerofill(const MCSection *Section, MCSymbol *Symbol, uint64_t Size,
37                    unsigned ByteAlignment) override;
38  void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
39                        unsigned ByteAlignment) override;
40};
41}
42#endif
43