RecordStreamer.h 1.5 KB

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