LLVM API Documentation

DbgValueHistoryCalculator.h
Go to the documentation of this file.
00001 //===-- llvm/CodeGen/AsmPrinter/DbgValueHistoryCalculator.h ----*- C++ -*--===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 
00010 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DBGVALUEHISTORYCALCULATOR_H
00011 #define LLVM_LIB_CODEGEN_ASMPRINTER_DBGVALUEHISTORYCALCULATOR_H
00012 
00013 #include "llvm/ADT/MapVector.h"
00014 #include "llvm/ADT/SmallVector.h"
00015 
00016 namespace llvm {
00017 
00018 class MachineFunction;
00019 class MachineInstr;
00020 class MDNode;
00021 class TargetRegisterInfo;
00022 
00023 // For each user variable, keep a list of instruction ranges where this variable
00024 // is accessible. The variables are listed in order of appearance.
00025 class DbgValueHistoryMap {
00026   // Each instruction range starts with a DBG_VALUE instruction, specifying the
00027   // location of a variable, which is assumed to be valid until the end of the
00028   // range. If end is not specified, location is valid until the start
00029   // instruction of the next instruction range, or until the end of the
00030   // function.
00031 public:
00032   typedef std::pair<const MachineInstr *, const MachineInstr *> InstrRange;
00033   typedef SmallVector<InstrRange, 4> InstrRanges;
00034   typedef MapVector<const MDNode *, InstrRanges> InstrRangesMap;
00035 private:
00036   InstrRangesMap VarInstrRanges;
00037 
00038 public:
00039   void startInstrRange(const MDNode *Var, const MachineInstr &MI);
00040   void endInstrRange(const MDNode *Var, const MachineInstr &MI);
00041   // Returns register currently describing @Var. If @Var is currently
00042   // unaccessible or is not described by a register, returns 0.
00043   unsigned getRegisterForVar(const MDNode *Var) const;
00044 
00045   bool empty() const { return VarInstrRanges.empty(); }
00046   void clear() { VarInstrRanges.clear(); }
00047   InstrRangesMap::const_iterator begin() const { return VarInstrRanges.begin(); }
00048   InstrRangesMap::const_iterator end() const { return VarInstrRanges.end(); }
00049 };
00050 
00051 void calculateDbgValueHistory(const MachineFunction *MF,
00052                               const TargetRegisterInfo *TRI,
00053                               DbgValueHistoryMap &Result);
00054 }
00055 
00056 #endif