From f5858045aa0b89b28bc49965f238c077423b2ac7 Mon Sep 17 00:00:00 2001 From: Yonghong Song Date: Fri, 8 Sep 2017 23:32:38 +0000 Subject: [PATCH] bpf: proper print imm64 expression in inst printer Fixed an issue in printImm64Operand where if the value is an expression, print out the expression properly. Currently, it will print r1 = ll With the patch, the printout will be r1 = tx_port Suggested-by: Jiong Wang Signed-off-by: Yonghong Song Acked-by: Alexei Starovoitov git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312833 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/BPF/BPFInstrInfo.td | 2 +- lib/Target/BPF/InstPrinter/BPFInstPrinter.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Target/BPF/BPFInstrInfo.td b/lib/Target/BPF/BPFInstrInfo.td index 3b239e7463d..d4c50e768f7 100644 --- a/lib/Target/BPF/BPFInstrInfo.td +++ b/lib/Target/BPF/BPFInstrInfo.td @@ -249,7 +249,7 @@ class MOV_RI class LD_IMM64 Pseudo, string OpcodeStr> : InstBPF<(outs GPR:$dst), (ins u64imm:$imm), - "$dst "#OpcodeStr#" ${imm}ll", + "$dst "#OpcodeStr#" ${imm}", [(set GPR:$dst, (i64 imm:$imm))]> { bits<3> mode; diff --git a/lib/Target/BPF/InstPrinter/BPFInstPrinter.cpp b/lib/Target/BPF/InstPrinter/BPFInstPrinter.cpp index 64e986fe0f0..bb5546ea40e 100644 --- a/lib/Target/BPF/InstPrinter/BPFInstPrinter.cpp +++ b/lib/Target/BPF/InstPrinter/BPFInstPrinter.cpp @@ -88,7 +88,9 @@ void BPFInstPrinter::printImm64Operand(const MCInst *MI, unsigned OpNo, raw_ostream &O) { const MCOperand &Op = MI->getOperand(OpNo); if (Op.isImm()) - O << (uint64_t)Op.getImm(); + O << (uint64_t)Op.getImm() << "ll"; + else if (Op.isExpr()) + printExpr(Op.getExpr(), O); else O << Op; } -- 2.50.0