blob: 16d2d7fd7e990ca989c0b921cbc1d213df702794 [file] [log] [blame]
Alexey Samsonov414b6fb2014-04-30 21:34:11 +00001//===-- 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 Kramera7c40ef2014-08-13 16:26:38 +000010#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DBGVALUEHISTORYCALCULATOR_H
11#define LLVM_LIB_CODEGEN_ASMPRINTER_DBGVALUEHISTORYCALCULATOR_H
Alexey Samsonov414b6fb2014-04-30 21:34:11 +000012
Alexey Samsonov0436caa2014-04-30 23:02:40 +000013#include "llvm/ADT/MapVector.h"
Alexey Samsonov414b6fb2014-04-30 21:34:11 +000014#include "llvm/ADT/SmallVector.h"
Benjamin Kramer391be792016-01-27 19:29:56 +000015#include "llvm/IR/DebugInfoMetadata.h"
Alexey Samsonov414b6fb2014-04-30 21:34:11 +000016
17namespace llvm {
18
19class MachineFunction;
20class MachineInstr;
Alexey Samsonov414b6fb2014-04-30 21:34:11 +000021class TargetRegisterInfo;
22
Alexey Samsonovbb2990d2014-05-27 23:09:50 +000023// For each user variable, keep a list of instruction ranges where this variable
24// is accessible. The variables are listed in order of appearance.
25class 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.
Adrian Prantlb1416832014-08-01 22:11:58 +000031public:
Alexey Samsonovbb2990d2014-05-27 23:09:50 +000032 typedef std::pair<const MachineInstr *, const MachineInstr *> InstrRange;
33 typedef SmallVector<InstrRange, 4> InstrRanges;
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000034 typedef std::pair<const DILocalVariable *, const DILocation *>
Duncan P. N. Exon Smith62e0f452015-04-15 22:29:27 +000035 InlinedVariable;
36 typedef MapVector<InlinedVariable, InstrRanges> InstrRangesMap;
37
Adrian Prantlb1416832014-08-01 22:11:58 +000038private:
Alexey Samsonovbb2990d2014-05-27 23:09:50 +000039 InstrRangesMap VarInstrRanges;
40
41public:
Duncan P. N. Exon Smith62e0f452015-04-15 22:29:27 +000042 void startInstrRange(InlinedVariable Var, const MachineInstr &MI);
43 void endInstrRange(InlinedVariable Var, const MachineInstr &MI);
Alexey Samsonovbb2990d2014-05-27 23:09:50 +000044 // Returns register currently describing @Var. If @Var is currently
45 // unaccessible or is not described by a register, returns 0.
Duncan P. N. Exon Smith62e0f452015-04-15 22:29:27 +000046 unsigned getRegisterForVar(InlinedVariable Var) const;
Alexey Samsonovbb2990d2014-05-27 23:09:50 +000047
48 bool empty() const { return VarInstrRanges.empty(); }
49 void clear() { VarInstrRanges.clear(); }
50 InstrRangesMap::const_iterator begin() const { return VarInstrRanges.begin(); }
51 InstrRangesMap::const_iterator end() const { return VarInstrRanges.end(); }
52};
Alexey Samsonov414b6fb2014-04-30 21:34:11 +000053
54void calculateDbgValueHistory(const MachineFunction *MF,
55 const TargetRegisterInfo *TRI,
56 DbgValueHistoryMap &Result);
Alexander Kornienkof00654e2015-06-23 09:49:53 +000057}
Alexey Samsonov414b6fb2014-04-30 21:34:11 +000058
59#endif