Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 1 | //===- llvm/CodeGen/AsmPrinter/DbgValueHistoryCalculator.h ------*- C++ -*-===// |
Alexey Samsonov | 414b6fb | 2014-04-30 21:34:11 +0000 | [diff] [blame] | 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" |
David Blaikie | 8699f71 | 2017-10-27 22:12:46 +0000 | [diff] [blame] | 15 | #include "llvm/IR/DebugInfoMetadata.h" |
Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 16 | #include <utility> |
Alexey Samsonov | 414b6fb | 2014-04-30 21:34:11 +0000 | [diff] [blame] | 17 | |
| 18 | namespace llvm { |
| 19 | |
Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 20 | class DILocalVariable; |
Alexey Samsonov | 414b6fb | 2014-04-30 21:34:11 +0000 | [diff] [blame] | 21 | class MachineFunction; |
| 22 | class MachineInstr; |
Alexey Samsonov | 414b6fb | 2014-04-30 21:34:11 +0000 | [diff] [blame] | 23 | class TargetRegisterInfo; |
| 24 | |
Alexey Samsonov | bb2990d | 2014-05-27 23:09:50 +0000 | [diff] [blame] | 25 | // For each user variable, keep a list of instruction ranges where this variable |
| 26 | // is accessible. The variables are listed in order of appearance. |
| 27 | class DbgValueHistoryMap { |
| 28 | // Each instruction range starts with a DBG_VALUE instruction, specifying the |
| 29 | // location of a variable, which is assumed to be valid until the end of the |
| 30 | // range. If end is not specified, location is valid until the start |
| 31 | // instruction of the next instruction range, or until the end of the |
| 32 | // function. |
Adrian Prantl | b141683 | 2014-08-01 22:11:58 +0000 | [diff] [blame] | 33 | public: |
Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 34 | using InstrRange = std::pair<const MachineInstr *, const MachineInstr *>; |
| 35 | using InstrRanges = SmallVector<InstrRange, 4>; |
| 36 | using InlinedVariable = |
| 37 | std::pair<const DILocalVariable *, const DILocation *>; |
| 38 | using InstrRangesMap = MapVector<InlinedVariable, InstrRanges>; |
Duncan P. N. Exon Smith | 62e0f45 | 2015-04-15 22:29:27 +0000 | [diff] [blame] | 39 | |
Adrian Prantl | b141683 | 2014-08-01 22:11:58 +0000 | [diff] [blame] | 40 | private: |
Alexey Samsonov | bb2990d | 2014-05-27 23:09:50 +0000 | [diff] [blame] | 41 | InstrRangesMap VarInstrRanges; |
| 42 | |
| 43 | public: |
Duncan P. N. Exon Smith | 62e0f45 | 2015-04-15 22:29:27 +0000 | [diff] [blame] | 44 | void startInstrRange(InlinedVariable Var, const MachineInstr &MI); |
| 45 | void endInstrRange(InlinedVariable Var, const MachineInstr &MI); |
Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 46 | |
Alexey Samsonov | bb2990d | 2014-05-27 23:09:50 +0000 | [diff] [blame] | 47 | // Returns register currently describing @Var. If @Var is currently |
| 48 | // 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] | 49 | unsigned getRegisterForVar(InlinedVariable Var) const; |
Alexey Samsonov | bb2990d | 2014-05-27 23:09:50 +0000 | [diff] [blame] | 50 | |
| 51 | bool empty() const { return VarInstrRanges.empty(); } |
| 52 | void clear() { VarInstrRanges.clear(); } |
| 53 | InstrRangesMap::const_iterator begin() const { return VarInstrRanges.begin(); } |
| 54 | InstrRangesMap::const_iterator end() const { return VarInstrRanges.end(); } |
| 55 | }; |
Alexey Samsonov | 414b6fb | 2014-04-30 21:34:11 +0000 | [diff] [blame] | 56 | |
| 57 | void calculateDbgValueHistory(const MachineFunction *MF, |
| 58 | const TargetRegisterInfo *TRI, |
| 59 | DbgValueHistoryMap &Result); |
Alexey Samsonov | 414b6fb | 2014-04-30 21:34:11 +0000 | [diff] [blame] | 60 | |
Eugene Zelenko | 6e07bfd | 2017-08-17 21:26:39 +0000 | [diff] [blame] | 61 | } // end namespace llvm |
| 62 | |
| 63 | #endif // LLVM_LIB_CODEGEN_ASMPRINTER_DBGVALUEHISTORYCALCULATOR_H |