LLVM API Documentation

SDNodeDbgValue.h
Go to the documentation of this file.
00001 //===-- llvm/CodeGen/SDNodeDbgValue.h - SelectionDAG dbg_value --*- 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 // This file declares the SDDbgValue class.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_LIB_CODEGEN_SELECTIONDAG_SDNODEDBGVALUE_H
00015 #define LLVM_LIB_CODEGEN_SELECTIONDAG_SDNODEDBGVALUE_H
00016 
00017 #include "llvm/ADT/SmallVector.h"
00018 #include "llvm/IR/DebugLoc.h"
00019 #include "llvm/Support/DataTypes.h"
00020 
00021 namespace llvm {
00022 
00023 class MDNode;
00024 class SDNode;
00025 class Value;
00026 
00027 /// SDDbgValue - Holds the information from a dbg_value node through SDISel.
00028 /// We do not use SDValue here to avoid including its header.
00029 
00030 class SDDbgValue {
00031 public:
00032   enum DbgValueKind {
00033     SDNODE = 0,             // value is the result of an expression
00034     CONST = 1,              // value is a constant
00035     FRAMEIX = 2             // value is contents of a stack location
00036   };
00037 private:
00038   enum DbgValueKind kind;
00039   union {
00040     struct {
00041       SDNode *Node;         // valid for expressions
00042       unsigned ResNo;       // valid for expressions
00043     } s;
00044     const Value *Const;     // valid for constants
00045     unsigned FrameIx;       // valid for stack objects
00046   } u;
00047   MDNode *mdPtr;
00048   bool IsIndirect;
00049   uint64_t Offset;
00050   DebugLoc DL;
00051   unsigned Order;
00052   bool Invalid;
00053 public:
00054   // Constructor for non-constants.
00055   SDDbgValue(MDNode *mdP, SDNode *N, unsigned R,
00056        bool indir, uint64_t off, DebugLoc dl,
00057              unsigned O) : mdPtr(mdP), IsIndirect(indir),
00058          Offset(off), DL(dl), Order(O),
00059                            Invalid(false) {
00060     kind = SDNODE;
00061     u.s.Node = N;
00062     u.s.ResNo = R;
00063   }
00064 
00065   // Constructor for constants.
00066   SDDbgValue(MDNode *mdP, const Value *C, uint64_t off, DebugLoc dl,
00067              unsigned O) : 
00068     mdPtr(mdP), IsIndirect(false), Offset(off), DL(dl), Order(O),
00069     Invalid(false) {
00070     kind = CONST;
00071     u.Const = C;
00072   }
00073 
00074   // Constructor for frame indices.
00075   SDDbgValue(MDNode *mdP, unsigned FI, uint64_t off, DebugLoc dl, unsigned O) : 
00076     mdPtr(mdP), IsIndirect(false), Offset(off), DL(dl), Order(O),
00077     Invalid(false) {
00078     kind = FRAMEIX;
00079     u.FrameIx = FI;
00080   }
00081 
00082   // Returns the kind.
00083   DbgValueKind getKind() { return kind; }
00084 
00085   // Returns the MDNode pointer.
00086   MDNode *getMDPtr() { return mdPtr; }
00087 
00088   // Returns the SDNode* for a register ref
00089   SDNode *getSDNode() { assert (kind==SDNODE); return u.s.Node; }
00090 
00091   // Returns the ResNo for a register ref
00092   unsigned getResNo() { assert (kind==SDNODE); return u.s.ResNo; }
00093 
00094   // Returns the Value* for a constant
00095   const Value *getConst() { assert (kind==CONST); return u.Const; }
00096 
00097   // Returns the FrameIx for a stack object
00098   unsigned getFrameIx() { assert (kind==FRAMEIX); return u.FrameIx; }
00099 
00100   // Returns whether this is an indirect value.
00101   bool isIndirect() { return IsIndirect; }
00102 
00103   // Returns the offset.
00104   uint64_t getOffset() { return Offset; }
00105 
00106   // Returns the DebugLoc.
00107   DebugLoc getDebugLoc() { return DL; }
00108 
00109   // Returns the SDNodeOrder.  This is the order of the preceding node in the
00110   // input.
00111   unsigned getOrder() { return Order; }
00112 
00113   // setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated"
00114   // property. A SDDbgValue is invalid if the SDNode that produces the value is
00115   // deleted.
00116   void setIsInvalidated() { Invalid = true; }
00117   bool isInvalidated() { return Invalid; }
00118 };
00119 
00120 } // end llvm namespace
00121 
00122 #endif