LCOV - code coverage report
Current view: top level - lib/CodeGen/SelectionDAG - SDNodeDbgValue.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 12 12 100.0 %
Date: 2017-09-14 15:23:50 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             : /// SDDbgValue - Holds the information from a dbg_value node through SDISel.
      29             : /// We do not use SDValue here to avoid including its header.
      30             : 
      31             : class SDDbgValue {
      32             : public:
      33             :   enum DbgValueKind {
      34             :     SDNODE = 0,             // value is the result of an expression
      35             :     CONST = 1,              // value is a constant
      36             :     FRAMEIX = 2             // value is contents of a stack location
      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             :   } u;
      47             :   DIVariable *Var;
      48             :   DIExpression *Expr;
      49             :   DebugLoc DL;
      50             :   unsigned Order;
      51             :   enum DbgValueKind kind;
      52             :   bool IsIndirect;
      53             :   bool Invalid = false;
      54             : 
      55             : public:
      56             :   // Constructor for non-constants.
      57             :   SDDbgValue(DIVariable *Var, DIExpression *Expr, SDNode *N, unsigned R,
      58             :              bool indir, DebugLoc dl, unsigned O)
      59       25370 :       : Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(indir) {
      60       12685 :     kind = SDNODE;
      61       12685 :     u.s.Node = N;
      62       12685 :     u.s.ResNo = R;
      63             :   }
      64             : 
      65             :   // Constructor for constants.
      66             :   SDDbgValue(DIVariable *Var, DIExpression *Expr, const Value *C, DebugLoc dl,
      67             :              unsigned O)
      68       11756 :       : Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(false) {
      69        5878 :     kind = CONST;
      70        5878 :     u.Const = C;
      71             :   }
      72             : 
      73             :   // Constructor for frame indices.
      74             :   SDDbgValue(DIVariable *Var, DIExpression *Expr, unsigned FI, DebugLoc dl,
      75             :              unsigned O)
      76        6240 :       : Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(false) {
      77        3120 :     kind = FRAMEIX;
      78        3120 :     u.FrameIx = FI;
      79             :   }
      80             : 
      81             :   // Returns the kind.
      82             :   DbgValueKind getKind() const { return kind; }
      83             : 
      84             :   // Returns the DIVariable pointer for the variable.
      85             :   DIVariable *getVariable() const { return Var; }
      86             : 
      87             :   // Returns the DIExpression pointer for the expression.
      88             :   DIExpression *getExpression() const { return Expr; }
      89             : 
      90             :   // Returns the SDNode* for a register ref
      91             :   SDNode *getSDNode() const { assert (kind==SDNODE); return u.s.Node; }
      92             : 
      93             :   // Returns the ResNo for a register ref
      94             :   unsigned getResNo() const { assert (kind==SDNODE); return u.s.ResNo; }
      95             : 
      96             :   // Returns the Value* for a constant
      97             :   const Value *getConst() const { assert (kind==CONST); return u.Const; }
      98             : 
      99             :   // Returns the FrameIx for a stack object
     100             :   unsigned getFrameIx() const { assert (kind==FRAMEIX); return u.FrameIx; }
     101             : 
     102             :   // Returns whether this is an indirect value.
     103             :   bool isIndirect() const { return IsIndirect; }
     104             : 
     105             :   // Returns the DebugLoc.
     106       35428 :   DebugLoc getDebugLoc() const { return DL; }
     107             : 
     108             :   // Returns the SDNodeOrder.  This is the order of the preceding node in the
     109             :   // input.
     110             :   unsigned getOrder() const { return Order; }
     111             : 
     112             :   // setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated"
     113             :   // property. A SDDbgValue is invalid if the SDNode that produces the value is
     114             :   // deleted.
     115       25220 :   void setIsInvalidated() { Invalid = true; }
     116             :   bool isInvalidated() const { return Invalid; }
     117             : };
     118             : 
     119             : } // end llvm namespace
     120             : 
     121             : #endif

Generated by: LCOV version 1.13