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