]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - opencl/llvm.git/blobdiff - lib/CodeGen/AsmPrinter/DwarfExpression.h
Rename DIExpressionIterator to DIExpression::iterator.
[opencl/llvm.git] / lib / CodeGen / AsmPrinter / DwarfExpression.h
index 9aba3f82ffb8a6be986f06902a7b240b7350641b..14e07fcdb98ba41b8b0b3c35a0a25ac93fc4401f 100644 (file)
@@ -14,6 +14,7 @@
 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXPRESSION_H
 #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXPRESSION_H
 
 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXPRESSION_H
 #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXPRESSION_H
 
+#include "llvm/IR/DebugInfo.h"
 #include "llvm/Support/DataTypes.h"
 
 namespace llvm {
 #include "llvm/Support/DataTypes.h"
 
 namespace llvm {
@@ -21,6 +22,8 @@ namespace llvm {
 class AsmPrinter;
 class ByteStreamer;
 class TargetRegisterInfo;
 class AsmPrinter;
 class ByteStreamer;
 class TargetRegisterInfo;
+class DwarfUnit;
+class DIELoc;
 
 /// Base class containing the logic for constructing DWARF expressions
 /// independently of whether they are emitted into a DIE or into a .debug_loc
 
 /// Base class containing the logic for constructing DWARF expressions
 /// independently of whether they are emitted into a DIE or into a .debug_loc
@@ -36,14 +39,18 @@ public:
   DwarfExpression(const AsmPrinter &AP) : AP(AP) {}
   virtual ~DwarfExpression() {}
 
   DwarfExpression(const AsmPrinter &AP) : AP(AP) {}
   virtual ~DwarfExpression() {}
 
-  virtual void EmitOp(uint8_t Op, const char* Comment = nullptr) = 0;
+  /// Output a dwarf operand and an optional assembler comment.
+  virtual void EmitOp(uint8_t Op, const char *Comment = nullptr) = 0;
+  /// Emit a raw signed value.
   virtual void EmitSigned(int Value) = 0;
   virtual void EmitSigned(int Value) = 0;
+  /// Emit a raw unsigned value.
   virtual void EmitUnsigned(unsigned Value) = 0;
   virtual void EmitUnsigned(unsigned Value) = 0;
-
+  /// Return whether the given machine register is the frame register in the
+  /// current function.
   virtual bool isFrameRegister(unsigned MachineReg) = 0;
 
   /// Emit a dwarf register operation.
   virtual bool isFrameRegister(unsigned MachineReg) = 0;
 
   /// Emit a dwarf register operation.
-  void AddReg(int DwarfReg, const charComment = nullptr);
+  void AddReg(int DwarfReg, const char *Comment = nullptr);
   /// Emit an (double-)indirect dwarf register operation.
   void AddRegIndirect(int DwarfReg, int Offset, bool Deref = false);
 
   /// Emit an (double-)indirect dwarf register operation.
   void AddRegIndirect(int DwarfReg, int Offset, bool Deref = false);
 
@@ -55,14 +62,14 @@ public:
   void AddShr(unsigned ShiftBy);
 
   /// Emit an indirect dwarf register operation for the given machine register.
   void AddShr(unsigned ShiftBy);
 
   /// Emit an indirect dwarf register operation for the given machine register.
-  /// Returns false if no DWARF register exists for MachineReg.
-  bool AddMachineRegIndirect(unsigned MachineReg, int Offset);
+  /// \return false if no DWARF register exists for MachineReg.
+  bool AddMachineRegIndirect(unsigned MachineReg, int Offset = 0);
 
   /// \brief Emit a partial DWARF register operation.
 
   /// \brief Emit a partial DWARF register operation.
-  /// \param MLoc             the register
-  /// \param PieceSize        size and
-  /// \param PieceOffset      offset of the piece in bits, if this is one
-  ///                         piece of an aggregate value.
+  /// \param MachineReg        the register
+  /// \param PieceSizeInBits   size and
+  /// \param PieceOffsetInBits offset of the piece in bits, if this is one
+  ///                          piece of an aggregate value.
   ///
   /// If size and offset is zero an operation for the entire
   /// register is emitted: Some targets do not provide a DWARF
   ///
   /// If size and offset is zero an operation for the entire
   /// register is emitted: Some targets do not provide a DWARF
@@ -70,16 +77,27 @@ public:
   /// function will attempt to emit a DWARF register by emitting a
   /// piece of a super-register or by piecing together multiple
   /// subregisters that alias the register.
   /// function will attempt to emit a DWARF register by emitting a
   /// piece of a super-register or by piecing together multiple
   /// subregisters that alias the register.
-  void AddMachineRegPiece(unsigned MachineReg,
-                          unsigned PieceSizeInBits = 0,
+  ///
+  /// \return false if no DWARF register exists for MachineReg.
+  bool AddMachineRegPiece(unsigned MachineReg, unsigned PieceSizeInBits = 0,
                           unsigned PieceOffsetInBits = 0);
 
   /// Emit a signed constant.
   void AddSignedConstant(int Value);
   /// Emit an unsigned constant.
   void AddUnsignedConstant(unsigned Value);
                           unsigned PieceOffsetInBits = 0);
 
   /// Emit a signed constant.
   void AddSignedConstant(int Value);
   /// Emit an unsigned constant.
   void AddUnsignedConstant(unsigned Value);
-};
 
 
+  /// Emit an entire DIExpression on top of a machine register location.
+  /// \param PieceOffsetInBits If this is one piece out of a fragmented
+  /// location, this is the offset of the piece inside the entire variable.
+  /// \return false if no DWARF register exists for MachineReg.
+  bool AddMachineRegExpression(DIExpression Expr, unsigned MachineReg,
+                               unsigned PieceOffsetInBits = 0);
+  /// Emit a the operations remaining the DIExpressionIterator I.
+  /// \param PieceOffsetInBits If this is one piece out of a fragmented
+  /// location, this is the offset of the piece inside the entire variable.
+void AddExpression(DIExpression::iterator I, unsigned PieceOffsetInBits = 0);
+};
 
 /// DwarfExpression implementation for .debug_loc entries.
 class DebugLocDwarfExpression : public DwarfExpression {
 
 /// DwarfExpression implementation for .debug_loc entries.
 class DebugLocDwarfExpression : public DwarfExpression {
@@ -89,12 +107,26 @@ public:
   DebugLocDwarfExpression(const AsmPrinter &AP, ByteStreamer &BS)
       : DwarfExpression(AP), BS(BS) {}
 
   DebugLocDwarfExpression(const AsmPrinter &AP, ByteStreamer &BS)
       : DwarfExpression(AP), BS(BS) {}
 
-  void EmitOp(uint8_t Op, const char *Comment) override;
+  void EmitOp(uint8_t Op, const char *Comment = nullptr) override;
   void EmitSigned(int Value) override;
   void EmitUnsigned(unsigned Value) override;
   bool isFrameRegister(unsigned MachineReg) override;
 };
 
   void EmitSigned(int Value) override;
   void EmitUnsigned(unsigned Value) override;
   bool isFrameRegister(unsigned MachineReg) override;
 };
 
+/// DwarfExpression implementation for singular DW_AT_location.
+class DIEDwarfExpression : public DwarfExpression {
+  DwarfUnit &DU;
+  DIELoc ¨
+
+public:
+  DIEDwarfExpression(const AsmPrinter &AP, DwarfUnit &DU, DIELoc &DIE)
+      : DwarfExpression(AP), DU(DU), DIE(DIE) {}
+
+  void EmitOp(uint8_t Op, const char *Comment = nullptr) override;
+  void EmitSigned(int Value) override;
+  void EmitUnsigned(unsigned Value) override;
+  bool isFrameRegister(unsigned MachineReg) override;
+};
 }
 
 #endif
 }
 
 #endif