diff options
Diffstat (limited to 'contrib/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h')
-rw-r--r-- | contrib/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h b/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h index 728f8ad9225b..ea5cbc40ba35 100644 --- a/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h +++ b/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h @@ -1,4 +1,4 @@ -//===-- llvm/CodeGen/DwarfExpression.h - Dwarf Compile Unit ---*- C++ -*--===// +//===- llvm/CodeGen/DwarfExpression.h - Dwarf Compile Unit ------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -14,21 +14,29 @@ #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXPRESSION_H #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXPRESSION_H -#include "llvm/IR/DebugInfo.h" -#include "llvm/Support/DataTypes.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/None.h" +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/IR/DebugInfoMetadata.h" +#include <cassert> +#include <cstdint> +#include <iterator> namespace llvm { class AsmPrinter; +class APInt; class ByteStreamer; -class TargetRegisterInfo; class DwarfUnit; class DIELoc; +class TargetRegisterInfo; /// Holds a DIExpression and keeps track of how many operands have been consumed /// so far. class DIExpressionCursor { DIExpression::expr_op_iterator Start, End; + public: DIExpressionCursor(const DIExpression *Expr) { if (!Expr) { @@ -42,8 +50,7 @@ public: DIExpressionCursor(ArrayRef<uint64_t> Expr) : Start(Expr.begin()), End(Expr.end()) {} - DIExpressionCursor(const DIExpressionCursor &C) - : Start(C.Start), End(C.End) {} + DIExpressionCursor(const DIExpressionCursor &) = default; /// Consume one operation. Optional<DIExpression::ExprOperand> take() { @@ -73,8 +80,10 @@ public: return *Next; } + /// Determine whether there are any operations left in this expression. operator bool() const { return Start != End; } + DIExpression::expr_op_iterator begin() const { return Start; } DIExpression::expr_op_iterator end() const { return End; } @@ -122,10 +131,13 @@ protected: /// 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(int64_t Value) = 0; + /// Emit a raw unsigned value. virtual void emitUnsigned(uint64_t Value) = 0; + /// Return whether the given machine register is the frame register in the /// current function. virtual bool isFrameRegister(const TargetRegisterInfo &TRI, unsigned MachineReg) = 0; @@ -133,8 +145,10 @@ protected: /// Emit a DW_OP_reg operation. Note that this is only legal inside a DWARF /// register location description. void addReg(int DwarfReg, const char *Comment = nullptr); + /// Emit a DW_OP_breg operation. void addBReg(int DwarfReg, int Offset); + /// Emit DW_OP_fbreg <Offset>. void addFBReg(int Offset); @@ -156,7 +170,6 @@ protected: bool addMachineReg(const TargetRegisterInfo &TRI, unsigned MachineReg, unsigned MaxSize = ~1U); - /// Emit a DW_OP_piece or DW_OP_bit_piece operation for a variable fragment. /// \param OffsetInBits This is an optional offset into the location that /// is at the top of the DWARF stack. @@ -164,6 +177,7 @@ protected: /// Emit a shift-right dwarf operation. void addShr(unsigned ShiftBy); + /// Emit a bitwise and dwarf operation. void addAnd(unsigned Mask); @@ -181,6 +195,7 @@ protected: void addStackValue(); ~DwarfExpression() = default; + public: DwarfExpression(unsigned DwarfVersion) : DwarfVersion(DwarfVersion) {} @@ -189,8 +204,10 @@ public: /// Emit a signed constant. void addSignedConstant(int64_t Value); + /// Emit an unsigned constant. void addUnsignedConstant(uint64_t Value); + /// Emit an unsigned constant. void addUnsignedConstant(const APInt &Value); @@ -213,6 +230,7 @@ public: bool addMachineRegExpression(const TargetRegisterInfo &TRI, DIExpressionCursor &Expr, unsigned MachineReg, unsigned FragmentOffsetInBits = 0); + /// Emit all remaining operations in the DIExpressionCursor. /// /// \param FragmentOffsetInBits If this is one fragment out of multiple @@ -235,6 +253,7 @@ class DebugLocDwarfExpression final : public DwarfExpression { void emitUnsigned(uint64_t Value) override; bool isFrameRegister(const TargetRegisterInfo &TRI, unsigned MachineReg) override; + public: DebugLocDwarfExpression(unsigned DwarfVersion, ByteStreamer &BS) : DwarfExpression(DwarfVersion), BS(BS) {} @@ -253,11 +272,13 @@ const AsmPrinter &AP; unsigned MachineReg) override; public: DIEDwarfExpression(const AsmPrinter &AP, DwarfUnit &DU, DIELoc &DIE); + DIELoc *finalize() { DwarfExpression::finalize(); return &DIE; } }; -} -#endif +} // end namespace llvm + +#endif // LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXPRESSION_H |