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 LLVM_LIB_CODEGEN_ASMPRINTER_DBGVALUEHISTORYCALCULATOR_H 11 #define LLVM_LIB_CODEGEN_ASMPRINTER_DBGVALUEHISTORYCALCULATOR_H 12 13 #include "llvm/ADT/MapVector.h" 14 #include "llvm/ADT/SmallVector.h" 15 #include "llvm/IR/DebugInfoMetadata.h" 16 17 namespace llvm { 18 19 class MachineFunction; 20 class MachineInstr; 21 class TargetRegisterInfo; 22 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 public: 32 typedef std::pair<const MachineInstr *, const MachineInstr *> InstrRange; 33 typedef SmallVector<InstrRange, 4> InstrRanges; 34 typedef std::pair<const DILocalVariable *, const DILocation *> 35 InlinedVariable; 36 typedef MapVector<InlinedVariable, InstrRanges> InstrRangesMap; 37 38 private: 39 InstrRangesMap VarInstrRanges; 40 41 public: 42 void startInstrRange(InlinedVariable Var, const MachineInstr &MI); 43 void endInstrRange(InlinedVariable Var, const MachineInstr &MI); 44 // Returns register currently describing @Var. If @Var is currently 45 // unaccessible or is not described by a register, returns 0. 46 unsigned getRegisterForVar(InlinedVariable Var) const; 47 empty()48 bool empty() const { return VarInstrRanges.empty(); } clear()49 void clear() { VarInstrRanges.clear(); } begin()50 InstrRangesMap::const_iterator begin() const { return VarInstrRanges.begin(); } end()51 InstrRangesMap::const_iterator end() const { return VarInstrRanges.end(); } 52 }; 53 54 void calculateDbgValueHistory(const MachineFunction *MF, 55 const TargetRegisterInfo *TRI, 56 DbgValueHistoryMap &Result); 57 } 58 59 #endif 60