diff options
Diffstat (limited to 'contrib/llvm/lib/Target/BPF/InstPrinter/BPFInstPrinter.cpp')
-rw-r--r-- | contrib/llvm/lib/Target/BPF/InstPrinter/BPFInstPrinter.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/contrib/llvm/lib/Target/BPF/InstPrinter/BPFInstPrinter.cpp b/contrib/llvm/lib/Target/BPF/InstPrinter/BPFInstPrinter.cpp index 552288b..ffd29f3 100644 --- a/contrib/llvm/lib/Target/BPF/InstPrinter/BPFInstPrinter.cpp +++ b/contrib/llvm/lib/Target/BPF/InstPrinter/BPFInstPrinter.cpp @@ -67,15 +67,21 @@ void BPFInstPrinter::printMemOperand(const MCInst *MI, int OpNo, raw_ostream &O, const char *Modifier) { const MCOperand &RegOp = MI->getOperand(OpNo); const MCOperand &OffsetOp = MI->getOperand(OpNo + 1); - // offset - if (OffsetOp.isImm()) - O << formatDec(OffsetOp.getImm()); - else - assert(0 && "Expected an immediate"); // register assert(RegOp.isReg() && "Register operand not a register"); - O << '(' << getRegisterName(RegOp.getReg()) << ')'; + O << getRegisterName(RegOp.getReg()); + + // offset + if (OffsetOp.isImm()) { + auto Imm = OffsetOp.getImm(); + if (Imm >= 0) + O << " + " << formatDec(Imm); + else + O << " - " << formatDec(-Imm); + } else { + assert(0 && "Expected an immediate"); + } } void BPFInstPrinter::printImm64Operand(const MCInst *MI, unsigned OpNo, |