summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp26
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h3
2 files changed, 21 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
index d8d1a5e8f84..af51d276634 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
@@ -24,6 +24,20 @@
using namespace llvm;
+void DwarfExpression::emitConstu(uint64_t Value) {
+ if (Value < 32)
+ emitOp(dwarf::DW_OP_lit0 + Value);
+ else if (Value == std::numeric_limits<uint64_t>::max()) {
+ // Only do this for 64-bit values as the DWARF expression stack uses
+ // target-address-size values.
+ emitOp(dwarf::DW_OP_lit0);
+ emitOp(dwarf::DW_OP_not);
+ } else {
+ emitOp(dwarf::DW_OP_constu);
+ emitUnsigned(Value);
+ }
+}
+
void DwarfExpression::addReg(int DwarfReg, const char *Comment) {
assert(DwarfReg >= 0 && "invalid negative dwarf register number");
assert((LocationKind == Unknown || LocationKind == Register) &&
@@ -72,14 +86,12 @@ void DwarfExpression::addOpPiece(unsigned SizeInBits, unsigned OffsetInBits) {
}
void DwarfExpression::addShr(unsigned ShiftBy) {
- emitOp(dwarf::DW_OP_constu);
- emitUnsigned(ShiftBy);
+ emitConstu(ShiftBy);
emitOp(dwarf::DW_OP_shr);
}
void DwarfExpression::addAnd(unsigned Mask) {
- emitOp(dwarf::DW_OP_constu);
- emitUnsigned(Mask);
+ emitConstu(Mask);
emitOp(dwarf::DW_OP_and);
}
@@ -181,8 +193,7 @@ void DwarfExpression::addSignedConstant(int64_t Value) {
void DwarfExpression::addUnsignedConstant(uint64_t Value) {
assert(LocationKind == Implicit || LocationKind == Unknown);
LocationKind = Implicit;
- emitOp(dwarf::DW_OP_constu);
- emitUnsigned(Value);
+ emitConstu(Value);
}
void DwarfExpression::addUnsignedConstant(const APInt &Value) {
@@ -373,8 +384,7 @@ void DwarfExpression::addExpression(DIExpressionCursor &&ExprCursor,
break;
case dwarf::DW_OP_constu:
assert(LocationKind != Register);
- emitOp(dwarf::DW_OP_constu);
- emitUnsigned(Op->getArg(0));
+ emitConstu(Op->getArg(0));
break;
case dwarf::DW_OP_stack_value:
LocationKind = Implicit;
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
index 0637d952eba..d47c4d1d296 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
@@ -138,6 +138,9 @@ protected:
/// Emit a raw unsigned value.
virtual void emitUnsigned(uint64_t Value) = 0;
+ /// Emit a normalized unsigned constant.
+ void emitConstu(uint64_t Value);
+
/// Return whether the given machine register is the frame register in the
/// current function.
virtual bool isFrameRegister(const TargetRegisterInfo &TRI, unsigned MachineReg) = 0;
OpenPOWER on IntegriCloud