[llvm] r312833 - bpf: proper print imm64 expression in inst printer

Yonghong Song via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 8 16:32:38 PDT 2017


Author: yhs
Date: Fri Sep  8 16:32:38 2017
New Revision: 312833

URL: http://llvm.org/viewvc/llvm-project?rev=312833&view=rev
Log:
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 = <MCOperand Expr:(tx_port)>ll
With the patch, the printout will be
  r1 = tx_port

Suggested-by: Jiong Wang <jiong.wang at netronome.com>
Signed-off-by: Yonghong Song <yhs at fb.com>
Acked-by: Alexei Starovoitov <ast at kernel.org>

Modified:
    llvm/trunk/lib/Target/BPF/BPFInstrInfo.td
    llvm/trunk/lib/Target/BPF/InstPrinter/BPFInstPrinter.cpp

Modified: llvm/trunk/lib/Target/BPF/BPFInstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/BPF/BPFInstrInfo.td?rev=312833&r1=312832&r2=312833&view=diff
==============================================================================
--- llvm/trunk/lib/Target/BPF/BPFInstrInfo.td (original)
+++ llvm/trunk/lib/Target/BPF/BPFInstrInfo.td Fri Sep  8 16:32:38 2017
@@ -249,7 +249,7 @@ class MOV_RI<string OpcodeStr>
 
 class LD_IMM64<bits<4> 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;

Modified: llvm/trunk/lib/Target/BPF/InstPrinter/BPFInstPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/BPF/InstPrinter/BPFInstPrinter.cpp?rev=312833&r1=312832&r2=312833&view=diff
==============================================================================
--- llvm/trunk/lib/Target/BPF/InstPrinter/BPFInstPrinter.cpp (original)
+++ llvm/trunk/lib/Target/BPF/InstPrinter/BPFInstPrinter.cpp Fri Sep  8 16:32:38 2017
@@ -88,7 +88,9 @@ void BPFInstPrinter::printImm64Operand(c
                                        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;
 }




More information about the llvm-commits mailing list