Rafael Espindola | 13b69d6 | 2014-07-03 18:59:23 +0000 | [diff] [blame] | 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 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 10 | #ifndef LLVM_LIB_OBJECT_RECORDSTREAMER_H |
| 11 | #define LLVM_LIB_OBJECT_RECORDSTREAMER_H |
Rafael Espindola | 13b69d6 | 2014-07-03 18:59:23 +0000 | [diff] [blame] | 12 | |
| 13 | #include "llvm/MC/MCStreamer.h" |
| 14 | |
| 15 | namespace llvm { |
| 16 | class RecordStreamer : public MCStreamer { |
| 17 | public: |
| 18 | enum State { NeverSeen, Global, Defined, DefinedGlobal, Used }; |
| 19 | |
| 20 | private: |
| 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 | |
| 27 | public: |
| 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 |