[llvm] r234286 - DebugInfo: Move DIExpression bit-piece API to MDExpression

Duncan P. N. Exon Smith dexonsmith at apple.com
Mon Apr 6 20:50:00 PDT 2015


Author: dexonsmith
Date: Mon Apr  6 22:49:59 2015
New Revision: 234286

URL: http://llvm.org/viewvc/llvm-project?rev=234286&view=rev
Log:
DebugInfo: Move DIExpression bit-piece API to MDExpression

Modified:
    llvm/trunk/include/llvm/IR/DebugInfo.h
    llvm/trunk/include/llvm/IR/DebugInfoMetadata.h
    llvm/trunk/lib/IR/DebugInfo.cpp
    llvm/trunk/lib/IR/DebugInfoMetadata.cpp

Modified: llvm/trunk/include/llvm/IR/DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfo.h?rev=234286&r1=234285&r2=234286&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugInfo.h (original)
+++ llvm/trunk/include/llvm/IR/DebugInfo.h Mon Apr  6 22:49:59 2015
@@ -860,18 +860,11 @@ public:
     return *get();
   }
 
-  /// \brief Return the number of elements in the complex expression.
   unsigned getNumElements() const { return get()->getNumElements(); }
-
-  /// \brief return the Idx'th complex address element.
   uint64_t getElement(unsigned I) const { return get()->getElement(I); }
-
-  /// \brief Return whether this is a piece of an aggregate variable.
-  bool isBitPiece() const;
-  /// \brief Return the offset of this piece in bits.
-  uint64_t getBitPieceOffset() const;
-  /// \brief Return the size of this piece in bits.
-  uint64_t getBitPieceSize() const;
+  bool isBitPiece() const { return get()->isBitPiece(); }
+  uint64_t getBitPieceOffset() const { return get()->getBitPieceOffset(); }
+  uint64_t getBitPieceSize() const { return get()->getBitPieceSize(); }
 };
 
 /// \brief This object holds location information.

Modified: llvm/trunk/include/llvm/IR/DebugInfoMetadata.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfoMetadata.h?rev=234286&r1=234285&r2=234286&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugInfoMetadata.h (original)
+++ llvm/trunk/include/llvm/IR/DebugInfoMetadata.h Mon Apr  6 22:49:59 2015
@@ -1831,6 +1831,15 @@ public:
     return Elements[I];
   }
 
+  /// \brief Return whether this is a piece of an aggregate variable.
+  bool isBitPiece() const;
+
+  /// \brief Return the offset of this piece in bits.
+  uint64_t getBitPieceOffset() const;
+
+  /// \brief Return the size of this piece in bits.
+  uint64_t getBitPieceSize() const;
+
   typedef ArrayRef<uint64_t>::iterator element_iterator;
   element_iterator elements_begin() const { return getElements().begin(); }
   element_iterator elements_end() const { return getElements().end(); }

Modified: llvm/trunk/lib/IR/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=234286&r1=234285&r2=234286&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DebugInfo.cpp (original)
+++ llvm/trunk/lib/IR/DebugInfo.cpp Mon Apr  6 22:49:59 2015
@@ -65,21 +65,6 @@ unsigned DIVariable::getSizeInBits(const
   return Ty.getSizeInBits();
 }
 
-bool DIExpression::isBitPiece() const {
-  unsigned N = getNumElements();
-  return N >=3 && getElement(N-3) == dwarf::DW_OP_bit_piece;
-}
-
-uint64_t DIExpression::getBitPieceOffset() const {
-  assert(isBitPiece() && "not a piece");
-  return getElement(getNumElements()-2);
-}
-
-uint64_t DIExpression::getBitPieceSize() const {
-  assert(isBitPiece() && "not a piece");
-  return getElement(getNumElements()-1);
-}
-
 //===----------------------------------------------------------------------===//
 // Simple Descriptor Constructors and other Methods
 //===----------------------------------------------------------------------===//

Modified: llvm/trunk/lib/IR/DebugInfoMetadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfoMetadata.cpp?rev=234286&r1=234285&r2=234286&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DebugInfoMetadata.cpp (original)
+++ llvm/trunk/lib/IR/DebugInfoMetadata.cpp Mon Apr  6 22:49:59 2015
@@ -445,6 +445,24 @@ bool MDExpression::isValid() const {
   return true;
 }
 
+bool MDExpression::isBitPiece() const {
+  assert(isValid() && "Expected valid expression");
+  if (unsigned N = getNumElements())
+    if (N >= 3)
+      return getElement(N - 3) == dwarf::DW_OP_bit_piece;
+  return false;
+}
+
+uint64_t MDExpression::getBitPieceOffset() const {
+  assert(isBitPiece() && "Expected bit piece");
+  return getElement(getNumElements() - 2);
+}
+
+uint64_t MDExpression::getBitPieceSize() const {
+  assert(isBitPiece() && "Expected bit piece");
+  return getElement(getNumElements() - 1);
+}
+
 MDObjCProperty *MDObjCProperty::getImpl(
     LLVMContext &Context, MDString *Name, Metadata *File, unsigned Line,
     MDString *GetterName, MDString *SetterName, unsigned Attributes,





More information about the llvm-commits mailing list