1205218Srdivacky//===-- llvm/CodeGen/SDNodeDbgValue.h - SelectionDAG dbg_value --*- C++ -*-===// 2205218Srdivacky// 3205218Srdivacky// The LLVM Compiler Infrastructure 4205218Srdivacky// 5205218Srdivacky// This file is distributed under the University of Illinois Open Source 6205218Srdivacky// License. See LICENSE.TXT for details. 7205218Srdivacky// 8205218Srdivacky//===----------------------------------------------------------------------===// 9205218Srdivacky// 10205218Srdivacky// This file declares the SDDbgValue class. 11205218Srdivacky// 12205218Srdivacky//===----------------------------------------------------------------------===// 13205218Srdivacky 14280031Sdim#ifndef LLVM_LIB_CODEGEN_SELECTIONDAG_SDNODEDBGVALUE_H 15280031Sdim#define LLVM_LIB_CODEGEN_SELECTIONDAG_SDNODEDBGVALUE_H 16205218Srdivacky 17205218Srdivacky#include "llvm/ADT/SmallVector.h" 18276479Sdim#include "llvm/IR/DebugLoc.h" 19249423Sdim#include "llvm/Support/DataTypes.h" 20205218Srdivacky 21205218Srdivackynamespace llvm { 22205218Srdivacky 23205218Srdivackyclass MDNode; 24205218Srdivackyclass SDNode; 25205218Srdivackyclass Value; 26205218Srdivacky 27205218Srdivacky/// SDDbgValue - Holds the information from a dbg_value node through SDISel. 28205218Srdivacky/// We do not use SDValue here to avoid including its header. 29205218Srdivacky 30205218Srdivackyclass SDDbgValue { 31205218Srdivackypublic: 32205218Srdivacky enum DbgValueKind { 33205218Srdivacky SDNODE = 0, // value is the result of an expression 34205218Srdivacky CONST = 1, // value is a constant 35205218Srdivacky FRAMEIX = 2 // value is contents of a stack location 36205218Srdivacky }; 37205218Srdivackyprivate: 38205218Srdivacky union { 39205218Srdivacky struct { 40205218Srdivacky SDNode *Node; // valid for expressions 41205218Srdivacky unsigned ResNo; // valid for expressions 42205218Srdivacky } s; 43207618Srdivacky const Value *Const; // valid for constants 44205218Srdivacky unsigned FrameIx; // valid for stack objects 45205218Srdivacky } u; 46280031Sdim MDNode *Var; 47280031Sdim MDNode *Expr; 48205218Srdivacky uint64_t Offset; 49205218Srdivacky DebugLoc DL; 50205218Srdivacky unsigned Order; 51288943Sdim enum DbgValueKind kind; 52288943Sdim bool IsIndirect; 53288943Sdim bool Invalid = false; 54288943Sdim 55205218Srdivackypublic: 56205218Srdivacky // Constructor for non-constants. 57280031Sdim SDDbgValue(MDNode *Var, MDNode *Expr, SDNode *N, unsigned R, bool indir, 58280031Sdim uint64_t off, DebugLoc dl, unsigned O) 59288943Sdim : Var(Var), Expr(Expr), Offset(off), DL(dl), Order(O), IsIndirect(indir) { 60205218Srdivacky kind = SDNODE; 61205218Srdivacky u.s.Node = N; 62205218Srdivacky u.s.ResNo = R; 63205218Srdivacky } 64205218Srdivacky 65205218Srdivacky // Constructor for constants. 66280031Sdim SDDbgValue(MDNode *Var, MDNode *Expr, const Value *C, uint64_t off, 67280031Sdim DebugLoc dl, unsigned O) 68288943Sdim : Var(Var), Expr(Expr), Offset(off), DL(dl), Order(O), IsIndirect(false) { 69205218Srdivacky kind = CONST; 70205218Srdivacky u.Const = C; 71205218Srdivacky } 72205218Srdivacky 73205218Srdivacky // Constructor for frame indices. 74280031Sdim SDDbgValue(MDNode *Var, MDNode *Expr, unsigned FI, uint64_t off, DebugLoc dl, 75280031Sdim unsigned O) 76288943Sdim : Var(Var), Expr(Expr), Offset(off), DL(dl), Order(O), IsIndirect(false) { 77205218Srdivacky kind = FRAMEIX; 78205218Srdivacky u.FrameIx = FI; 79205218Srdivacky } 80205218Srdivacky 81205218Srdivacky // Returns the kind. 82280031Sdim DbgValueKind getKind() const { return kind; } 83205218Srdivacky 84280031Sdim // Returns the MDNode pointer for the variable. 85280031Sdim MDNode *getVariable() const { return Var; } 86205218Srdivacky 87280031Sdim // Returns the MDNode pointer for the expression. 88280031Sdim MDNode *getExpression() const { return Expr; } 89280031Sdim 90205218Srdivacky // Returns the SDNode* for a register ref 91280031Sdim SDNode *getSDNode() const { assert (kind==SDNODE); return u.s.Node; } 92205218Srdivacky 93205218Srdivacky // Returns the ResNo for a register ref 94280031Sdim unsigned getResNo() const { assert (kind==SDNODE); return u.s.ResNo; } 95205218Srdivacky 96205218Srdivacky // Returns the Value* for a constant 97280031Sdim const Value *getConst() const { assert (kind==CONST); return u.Const; } 98205218Srdivacky 99205218Srdivacky // Returns the FrameIx for a stack object 100280031Sdim unsigned getFrameIx() const { assert (kind==FRAMEIX); return u.FrameIx; } 101205218Srdivacky 102276479Sdim // Returns whether this is an indirect value. 103280031Sdim bool isIndirect() const { return IsIndirect; } 104276479Sdim 105205218Srdivacky // Returns the offset. 106280031Sdim uint64_t getOffset() const { return Offset; } 107205218Srdivacky 108205218Srdivacky // Returns the DebugLoc. 109280031Sdim DebugLoc getDebugLoc() const { return DL; } 110205218Srdivacky 111205218Srdivacky // Returns the SDNodeOrder. This is the order of the preceding node in the 112205218Srdivacky // input. 113280031Sdim unsigned getOrder() const { return Order; } 114206083Srdivacky 115206083Srdivacky // setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated" 116206083Srdivacky // property. A SDDbgValue is invalid if the SDNode that produces the value is 117206083Srdivacky // deleted. 118206083Srdivacky void setIsInvalidated() { Invalid = true; } 119280031Sdim bool isInvalidated() const { return Invalid; } 120205218Srdivacky}; 121205218Srdivacky 122205218Srdivacky} // end llvm namespace 123205218Srdivacky 124205218Srdivacky#endif 125