LCOV - code coverage report
Current view: top level - lib/CodeGen/SelectionDAG - SDNodeDbgValue.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 14 15 93.3 %
Date: 2018-06-17 00:07:59 Functions: 0 0 -
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===-- llvm/CodeGen/SDNodeDbgValue.h - SelectionDAG dbg_value --*- 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             : // This file declares the SDDbgValue class.
      11             : //
      12             : //===----------------------------------------------------------------------===//
      13             : 
      14             : #ifndef LLVM_LIB_CODEGEN_SELECTIONDAG_SDNODEDBGVALUE_H
      15             : #define LLVM_LIB_CODEGEN_SELECTIONDAG_SDNODEDBGVALUE_H
      16             : 
      17             : #include "llvm/IR/DebugLoc.h"
      18             : #include "llvm/Support/DataTypes.h"
      19             : #include <utility>
      20             : 
      21             : namespace llvm {
      22             : 
      23             : class DIVariable;
      24             : class DIExpression;
      25             : class SDNode;
      26             : class Value;
      27             : 
      28             : /// Holds the information from a dbg_value node through SDISel.
      29             : /// We do not use SDValue here to avoid including its header.
      30             : class SDDbgValue {
      31             : public:
      32             :   enum DbgValueKind {
      33             :     SDNODE = 0,             ///< Value is the result of an expression.
      34             :     CONST = 1,              ///< Value is a constant.
      35             :     FRAMEIX = 2,            ///< Value is contents of a stack location.
      36             :     VREG = 3                ///< Value is a virtual register.
      37             :   };
      38             : private:
      39             :   union {
      40             :     struct {
      41             :       SDNode *Node;         ///< Valid for expressions.
      42             :       unsigned ResNo;       ///< Valid for expressions.
      43             :     } s;
      44             :     const Value *Const;     ///< Valid for constants.
      45             :     unsigned FrameIx;       ///< Valid for stack objects.
      46             :     unsigned VReg;          ///< Valid for registers.
      47             :   } u;
      48             :   DIVariable *Var;
      49             :   DIExpression *Expr;
      50             :   DebugLoc DL;
      51             :   unsigned Order;
      52             :   enum DbgValueKind kind;
      53             :   bool IsIndirect;
      54             :   bool Invalid = false;
      55             : 
      56             : public:
      57             :   /// Constructor for non-constants.
      58             :   SDDbgValue(DIVariable *Var, DIExpression *Expr, SDNode *N, unsigned R,
      59             :              bool indir, DebugLoc dl, unsigned O)
      60       28380 :       : Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(indir) {
      61       14190 :     kind = SDNODE;
      62       14190 :     u.s.Node = N;
      63       14190 :     u.s.ResNo = R;
      64             :   }
      65             : 
      66             :   /// Constructor for constants.
      67             :   SDDbgValue(DIVariable *Var, DIExpression *Expr, const Value *C, DebugLoc dl,
      68             :              unsigned O)
      69       18548 :       : Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(false) {
      70        9274 :     kind = CONST;
      71        9274 :     u.Const = C;
      72             :   }
      73             : 
      74             :   /// Constructor for frame indices.
      75             :   SDDbgValue(DIVariable *Var, DIExpression *Expr, unsigned FI, DebugLoc dl,
      76             :              unsigned O)
      77       15100 :       : Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(false) {
      78        7550 :     kind = FRAMEIX;
      79        7550 :     u.FrameIx = FI;
      80             :   }
      81             : 
      82             :   /// Constructor for virtual registers.
      83             :   SDDbgValue(DIVariable *Var, DIExpression *Expr, unsigned VReg, bool indir,
      84             :              DebugLoc dl, unsigned O)
      85        7610 :       : Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(indir) {
      86        3805 :     kind = VREG;
      87        3805 :     u.VReg = VReg;
      88             :   }
      89             : 
      90             :   /// Returns the kind.
      91             :   DbgValueKind getKind() const { return kind; }
      92             : 
      93             :   /// Returns the DIVariable pointer for the variable.
      94             :   DIVariable *getVariable() const { return Var; }
      95             : 
      96             :   /// Returns the DIExpression pointer for the expression.
      97             :   DIExpression *getExpression() const { return Expr; }
      98             : 
      99             :   /// Returns the SDNode* for a register ref
     100             :   SDNode *getSDNode() const { assert (kind==SDNODE); return u.s.Node; }
     101             : 
     102             :   /// Returns the ResNo for a register ref
     103             :   unsigned getResNo() const { assert (kind==SDNODE); return u.s.ResNo; }
     104             : 
     105             :   /// Returns the Value* for a constant
     106             :   const Value *getConst() const { assert (kind==CONST); return u.Const; }
     107             : 
     108             :   /// Returns the FrameIx for a stack object
     109             :   unsigned getFrameIx() const { assert (kind==FRAMEIX); return u.FrameIx; }
     110             : 
     111             :   /// Returns the Virtual Register for a VReg
     112             :   unsigned getVReg() const { assert (kind==VREG); return u.VReg; }
     113             : 
     114             :   /// Returns whether this is an indirect value.
     115             :   bool isIndirect() const { return IsIndirect; }
     116             : 
     117             :   /// Returns the DebugLoc.
     118             :   DebugLoc getDebugLoc() const { return DL; }
     119             : 
     120             :   /// Returns the SDNodeOrder.  This is the order of the preceding node in the
     121             :   /// input.
     122             :   unsigned getOrder() const { return Order; }
     123             : 
     124             :   /// setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated"
     125             :   /// property. A SDDbgValue is invalid if the SDNode that produces the value is
     126             :   /// deleted.
     127       34407 :   void setIsInvalidated() { Invalid = true; }
     128             :   bool isInvalidated() const { return Invalid; }
     129             : };
     130             : 
     131             : /// Holds the information from a dbg_label node through SDISel.
     132             : /// We do not use SDValue here to avoid including its header.
     133             : class SDDbgLabel {
     134             :   MDNode *Label;
     135             :   DebugLoc DL;
     136             :   unsigned Order;
     137             : 
     138             : public:
     139             :   SDDbgLabel(MDNode *Label, DebugLoc dl, unsigned O)
     140           0 :       : Label(Label), DL(std::move(dl)), Order(O) {}
     141             : 
     142             :   /// Returns the MDNode pointer for the label.
     143             :   MDNode *getLabel() const { return Label; }
     144             : 
     145             :   /// Returns the DebugLoc.
     146             :   DebugLoc getDebugLoc() const { return DL; }
     147             : 
     148             :   /// Returns the SDNodeOrder.  This is the order of the preceding node in the
     149             :   /// input.
     150             :   unsigned getOrder() const { return Order; }
     151             : };
     152             : 
     153             : } // end llvm namespace
     154             : 
     155             : #endif

Generated by: LCOV version 1.13