SDNodeDbgValue.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. #ifndef LLVM_LIB_CODEGEN_SELECTIONDAG_SDNODEDBGVALUE_H
  14. #define LLVM_LIB_CODEGEN_SELECTIONDAG_SDNODEDBGVALUE_H
  15. #include "llvm/ADT/SmallVector.h"
  16. #include "llvm/IR/DebugLoc.h"
  17. #include "llvm/Support/DataTypes.h"
  18. namespace llvm {
  19. class MDNode;
  20. class SDNode;
  21. class Value;
  22. /// SDDbgValue - Holds the information from a dbg_value node through SDISel.
  23. /// We do not use SDValue here to avoid including its header.
  24. class SDDbgValue {
  25. public:
  26. enum DbgValueKind {
  27. SDNODE = 0, // value is the result of an expression
  28. CONST = 1, // value is a constant
  29. FRAMEIX = 2 // value is contents of a stack location
  30. };
  31. private:
  32. union {
  33. struct {
  34. SDNode *Node; // valid for expressions
  35. unsigned ResNo; // valid for expressions
  36. } s;
  37. const Value *Const; // valid for constants
  38. unsigned FrameIx; // valid for stack objects
  39. } u;
  40. MDNode *Var;
  41. MDNode *Expr;
  42. uint64_t Offset;
  43. DebugLoc DL;
  44. unsigned Order;
  45. enum DbgValueKind kind;
  46. bool IsIndirect;
  47. bool Invalid = false;
  48. public:
  49. // Constructor for non-constants.
  50. SDDbgValue(MDNode *Var, MDNode *Expr, SDNode *N, unsigned R, bool indir,
  51. uint64_t off, DebugLoc dl, unsigned O)
  52. : Var(Var), Expr(Expr), Offset(off), DL(dl), Order(O), IsIndirect(indir) {
  53. kind = SDNODE;
  54. u.s.Node = N;
  55. u.s.ResNo = R;
  56. }
  57. // Constructor for constants.
  58. SDDbgValue(MDNode *Var, MDNode *Expr, const Value *C, uint64_t off,
  59. DebugLoc dl, unsigned O)
  60. : Var(Var), Expr(Expr), Offset(off), DL(dl), Order(O), IsIndirect(false) {
  61. kind = CONST;
  62. u.Const = C;
  63. }
  64. // Constructor for frame indices.
  65. SDDbgValue(MDNode *Var, MDNode *Expr, unsigned FI, uint64_t off, DebugLoc dl,
  66. unsigned O)
  67. : Var(Var), Expr(Expr), Offset(off), DL(dl), Order(O), IsIndirect(false) {
  68. kind = FRAMEIX;
  69. u.FrameIx = FI;
  70. }
  71. // Returns the kind.
  72. DbgValueKind getKind() const { return kind; }
  73. // Returns the MDNode pointer for the variable.
  74. MDNode *getVariable() const { return Var; }
  75. // Returns the MDNode pointer for the expression.
  76. MDNode *getExpression() const { return Expr; }
  77. // Returns the SDNode* for a register ref
  78. SDNode *getSDNode() const { assert (kind==SDNODE); return u.s.Node; }
  79. // Returns the ResNo for a register ref
  80. unsigned getResNo() const { assert (kind==SDNODE); return u.s.ResNo; }
  81. // Returns the Value* for a constant
  82. const Value *getConst() const { assert (kind==CONST); return u.Const; }
  83. // Returns the FrameIx for a stack object
  84. unsigned getFrameIx() const { assert (kind==FRAMEIX); return u.FrameIx; }
  85. // Returns whether this is an indirect value.
  86. bool isIndirect() const { return IsIndirect; }
  87. // Returns the offset.
  88. uint64_t getOffset() const { return Offset; }
  89. // Returns the DebugLoc.
  90. DebugLoc getDebugLoc() const { return DL; }
  91. // Returns the SDNodeOrder. This is the order of the preceding node in the
  92. // input.
  93. unsigned getOrder() const { return Order; }
  94. // setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated"
  95. // property. A SDDbgValue is invalid if the SDNode that produces the value is
  96. // deleted.
  97. void setIsInvalidated() { Invalid = true; }
  98. bool isInvalidated() const { return Invalid; }
  99. };
  100. } // end llvm namespace
  101. #endif