DbgValueHistoryCalculator.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //===-- llvm/CodeGen/AsmPrinter/DbgValueHistoryCalculator.h ----*- 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_CODEGEN_ASMPRINTER_DBGVALUEHISTORYCALCULATOR_H
  10. #define LLVM_LIB_CODEGEN_ASMPRINTER_DBGVALUEHISTORYCALCULATOR_H
  11. #include "llvm/ADT/MapVector.h"
  12. #include "llvm/ADT/SmallVector.h"
  13. namespace llvm {
  14. class MachineFunction;
  15. class MachineInstr;
  16. class DILocalVariable;
  17. class DILocation;
  18. class TargetRegisterInfo;
  19. // For each user variable, keep a list of instruction ranges where this variable
  20. // is accessible. The variables are listed in order of appearance.
  21. class DbgValueHistoryMap {
  22. // Each instruction range starts with a DBG_VALUE instruction, specifying the
  23. // location of a variable, which is assumed to be valid until the end of the
  24. // range. If end is not specified, location is valid until the start
  25. // instruction of the next instruction range, or until the end of the
  26. // function.
  27. public:
  28. typedef std::pair<const MachineInstr *, const MachineInstr *> InstrRange;
  29. typedef SmallVector<InstrRange, 4> InstrRanges;
  30. typedef std::pair<const DILocalVariable *, const DILocation *>
  31. InlinedVariable;
  32. typedef MapVector<InlinedVariable, InstrRanges> InstrRangesMap;
  33. private:
  34. InstrRangesMap VarInstrRanges;
  35. public:
  36. void startInstrRange(InlinedVariable Var, const MachineInstr &MI);
  37. void endInstrRange(InlinedVariable Var, const MachineInstr &MI);
  38. // Returns register currently describing @Var. If @Var is currently
  39. // unaccessible or is not described by a register, returns 0.
  40. unsigned getRegisterForVar(InlinedVariable Var) const;
  41. bool empty() const { return VarInstrRanges.empty(); }
  42. void clear() { VarInstrRanges.clear(); }
  43. InstrRangesMap::const_iterator begin() const { return VarInstrRanges.begin(); }
  44. InstrRangesMap::const_iterator end() const { return VarInstrRanges.end(); }
  45. };
  46. void calculateDbgValueHistory(const MachineFunction *MF,
  47. const TargetRegisterInfo *TRI,
  48. DbgValueHistoryMap &Result);
  49. }
  50. #endif