summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2015-03-02 22:02:33 +0000
committerAdrian Prantl <aprantl@apple.com>2015-03-02 22:02:33 +0000
commit92da14b24402ece7602f4ee5d283e8baad7959c5 (patch)
tree0b7cc3d94029975c102a4f511e96149b45e46f53 /llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
parent446a0d1329b7621f41d229c7108962d7b554db37 (diff)
downloadbcm5719-llvm-92da14b24402ece7602f4ee5d283e8baad7959c5.tar.gz
bcm5719-llvm-92da14b24402ece7602f4ee5d283e8baad7959c5.zip
Refactor DebugLocDWARFExpression so it doesn't require access to the
TargetRegisterInfo. DebugLocEntry now holds a buffer with the raw bytes of the pre-calculated DWARF expression. Ought to be NFC, but it does slightly alter the output format of the textual assembly. This reapplies 230930 without the assertion in DebugLocEntry::finalize() because not all Machine registers can be lowered into DWARF register numbers and floating point constants cannot be expressed. llvm-svn: 231023
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h37
1 files changed, 25 insertions, 12 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h b/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
index 6d55c038541..6f30d294f71 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DebugLocEntry.h
@@ -9,22 +9,24 @@
#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DEBUGLOCENTRY_H
#define LLVM_LIB_CODEGEN_ASMPRINTER_DEBUGLOCENTRY_H
+#include "llvm/ADT/SmallString.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MachineLocation.h"
namespace llvm {
+class AsmPrinter;
class MDNode;
/// \brief This struct describes location entries emitted in the .debug_loc
/// section.
class DebugLocEntry {
- // Begin and end symbols for the address range that this location is valid.
+ /// Begin and end symbols for the address range that this location is valid.
const MCSymbol *Begin;
const MCSymbol *End;
public:
- /// A single location or constant.
+ /// \brief A single location or constant.
struct Value {
Value(const MDNode *Var, const MDNode *Expr, int64_t i)
: Variable(Var), Expression(Expr), EntryKind(E_Integer) {
@@ -44,17 +46,17 @@ public:
assert(DIExpression(Expr).Verify());
}
- // The variable to which this location entry corresponds.
+ /// The variable to which this location entry corresponds.
const MDNode *Variable;
- // Any complex address location expression for this Value.
+ /// Any complex address location expression for this Value.
const MDNode *Expression;
- // Type of entry that this represents.
+ /// Type of entry that this represents.
enum EntryType { E_Location, E_Integer, E_ConstantFP, E_ConstantInt };
enum EntryType EntryKind;
- // Either a constant,
+ /// Either a constant,
union {
int64_t Int;
const ConstantFP *CFP;
@@ -84,6 +86,8 @@ private:
/// A nonempty list of locations/constants belonging to this entry,
/// sorted by offset.
SmallVector<Value, 1> Values;
+ SmallString<8> DWARFBytes;
+ SmallVector<std::string, 1> Comments;
public:
DebugLocEntry(const MCSymbol *B, const MCSymbol *E, Value Val)
@@ -92,9 +96,9 @@ public:
}
/// \brief If this and Next are describing different pieces of the same
- // variable, merge them by appending Next's values to the current
- // list of values.
- // Return true if the merge was successful.
+ /// variable, merge them by appending Next's values to the current
+ /// list of values.
+ /// Return true if the merge was successful.
bool MergeValues(const DebugLocEntry &Next) {
if (Begin == Next.Begin) {
DIExpression Expr(Values[0].Expression);
@@ -135,7 +139,7 @@ public:
}) && "value must be a piece");
}
- // Sort the pieces by offset.
+ // \brief Sort the pieces by offset.
// Remove any duplicate entries by dropping all but the first.
void sortUniqueValues() {
std::sort(Values.begin(), Values.end());
@@ -146,9 +150,18 @@ public:
}),
Values.end());
}
+
+ /// \brief Lower this entry into a DWARF expression.
+ void finalize(const AsmPrinter &AP,
+ const DITypeIdentifierMap &TypeIdentifierMap);
+
+ /// \brief Return the lowered DWARF expression.
+ StringRef getDWARFBytes() const { return DWARFBytes; }
+ /// \brief Return the assembler comments for the lowered DWARF expression.
+ const SmallVectorImpl<std::string> &getComments() const { return Comments; }
};
-/// Compare two Values for equality.
+/// \brief Compare two Values for equality.
inline bool operator==(const DebugLocEntry::Value &A,
const DebugLocEntry::Value &B) {
if (A.EntryKind != B.EntryKind)
@@ -173,7 +186,7 @@ inline bool operator==(const DebugLocEntry::Value &A,
llvm_unreachable("unhandled EntryKind");
}
-/// Compare two pieces based on their offset.
+/// \brief Compare two pieces based on their offset.
inline bool operator<(const DebugLocEntry::Value &A,
const DebugLocEntry::Value &B) {
return A.getExpression().getBitPieceOffset() <
OpenPOWER on IntegriCloud