]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - opencl/llvm.git/blobdiff - lib/CodeGen/AsmPrinter/DwarfExpression.h
Debug Info: Move support for constants into DwarfExpression.
[opencl/llvm.git] / lib / CodeGen / AsmPrinter / DwarfExpression.h
index 8f7cba48fa8436c113b59b938a2934b8e7f6cb67..9e93a573a3d11f631196b351163792912770116f 100644 (file)
 
 namespace llvm {
 
-class TargetMachine;
+class AsmPrinter;
+class ByteStreamer;
+class TargetRegisterInfo;
 
 /// Base class containing the logic for constructing DWARF expressions
 /// independently of whether they are emitted into a DIE or into a .debug_loc
 /// entry.
 class DwarfExpression {
 protected:
-  TargetMachine &TM;
+  const AsmPrinter ≈
+  // Various convenience accessors that extract things out of AsmPrinter.
+  const TargetRegisterInfo *getTRI() const;
+  unsigned getDwarfVersion() const;
+
 public:
-  DwarfExpression(TargetMachine &TM) : TM(TM) {}
-  virtual ~DwarfExpression() {};
+  DwarfExpression(const AsmPrinter &AP) : AP(AP) {}
+  virtual ~DwarfExpression() {}
 
   virtual void EmitOp(uint8_t Op, const char* Comment = nullptr) = 0;
   virtual void EmitSigned(int Value) = 0;
@@ -67,6 +73,26 @@ public:
   void 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);
+};
+
+
+/// DwarfExpression implementation for .debug_loc entries.
+class DebugLocDwarfExpression : public DwarfExpression {
+  ByteStreamer &BS;
+
+public:
+  DebugLocDwarfExpression(const AsmPrinter &AP, ByteStreamer &BS)
+      : DwarfExpression(AP), BS(BS) {}
+
+  void EmitOp(uint8_t Op, const char *Comment) override;
+  void EmitSigned(int Value) override;
+  void EmitUnsigned(unsigned Value) override;
+  unsigned getFrameRegister() override;
 };
 
 }