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/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(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