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 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 10 | #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DBGVALUEHISTORYCALCULATOR_H |
| 11 | #define LLVM_LIB_CODEGEN_ASMPRINTER_DBGVALUEHISTORYCALCULATOR_H |
Alexey Samsonov | 414b6fb | 2014-04-30 21:34:11 +0000 | [diff] [blame] | 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; |
Duncan P. N. Exon Smith | 62e0f45 | 2015-04-15 22:29:27 +0000 | [diff] [blame] | 20 | class MDLocalVariable; |
| 21 | class MDLocation; |
Alexey Samsonov | 414b6fb | 2014-04-30 21:34:11 +0000 | [diff] [blame] | 22 | class TargetRegisterInfo; |
| 23 | |
Alexey Samsonov | bb2990d | 2014-05-27 23:09:50 +0000 | [diff] [blame] | 24 | // For each user variable, keep a list of instruction ranges where this variable |
| 25 | // is accessible. The variables are listed in order of appearance. |
| 26 | class DbgValueHistoryMap { |
| 27 | // Each instruction range starts with a DBG_VALUE instruction, specifying the |
| 28 | // location of a variable, which is assumed to be valid until the end of the |
| 29 | // range. If end is not specified, location is valid until the start |
| 30 | // instruction of the next instruction range, or until the end of the |
| 31 | // function. |
Adrian Prantl | b141683 | 2014-08-01 22:11:58 +0000 | [diff] [blame] | 32 | public: |
Alexey Samsonov | bb2990d | 2014-05-27 23:09:50 +0000 | [diff] [blame] | 33 | typedef std::pair<const MachineInstr *, const MachineInstr *> InstrRange; |
| 34 | typedef SmallVector<InstrRange, 4> InstrRanges; |
Duncan P. N. Exon Smith | 62e0f45 | 2015-04-15 22:29:27 +0000 | [diff] [blame] | 35 | typedef std::pair<const MDLocalVariable *, const MDLocation *> |
| 36 | InlinedVariable; |
| 37 | typedef MapVector<InlinedVariable, InstrRanges> InstrRangesMap; |
| 38 | |
Adrian Prantl | b141683 | 2014-08-01 22:11:58 +0000 | [diff] [blame] | 39 | private: |
Alexey Samsonov | bb2990d | 2014-05-27 23:09:50 +0000 | [diff] [blame] | 40 | InstrRangesMap VarInstrRanges; |
| 41 | |
| 42 | public: |
Duncan P. N. Exon Smith | 62e0f45 | 2015-04-15 22:29:27 +0000 | [diff] [blame] | 43 | void startInstrRange(InlinedVariable Var, const MachineInstr &MI); |
| 44 | void endInstrRange(InlinedVariable Var, const MachineInstr &MI); |
Alexey Samsonov | bb2990d | 2014-05-27 23:09:50 +0000 | [diff] [blame] | 45 | // Returns register currently describing @Var. If @Var is currently |
| 46 | // unaccessible or is not described by a register, returns 0. |
Duncan P. N. Exon Smith | 62e0f45 | 2015-04-15 22:29:27 +0000 | [diff] [blame] | 47 | unsigned getRegisterForVar(InlinedVariable Var) const; |
Alexey Samsonov | bb2990d | 2014-05-27 23:09:50 +0000 | [diff] [blame] | 48 | |
| 49 | bool empty() const { return VarInstrRanges.empty(); } |
| 50 | void clear() { VarInstrRanges.clear(); } |
| 51 | InstrRangesMap::const_iterator begin() const { return VarInstrRanges.begin(); } |
| 52 | InstrRangesMap::const_iterator end() const { return VarInstrRanges.end(); } |
| 53 | }; |
Alexey Samsonov | 414b6fb | 2014-04-30 21:34:11 +0000 | [diff] [blame] | 54 | |
| 55 | void calculateDbgValueHistory(const MachineFunction *MF, |
| 56 | const TargetRegisterInfo *TRI, |
| 57 | DbgValueHistoryMap &Result); |
| 58 | } |
| 59 | |
| 60 | #endif |