From be9c00347fa7dcfb78f9f3a6c6c61a00a9071d31 Mon Sep 17 00:00:00 2001 From: Yonghong Song Date: Mon, 11 Sep 2017 23:43:35 +0000 Subject: [PATCH] bpf: add " ll" in the LD_IMM64 asmstring This partially revert previous fix in commit f5858045aa0b ("bpf: proper print imm64 expression in inst printer"). In that commit, the original suffix "ll" is removed from LD_IMM64 asmstring. In the customer print method, the "ll" suffix is printed if the rhs is an immediate. For example, "r2 = 5ll" => "r2 = 5ll", and "r3 = varll" => "r3 = var". This has an issue though for assembler. Since assembler relies on asmstring to do pattern matching, it will not be able to distiguish between "mov r2, 5" and "ld_imm64 r2, 5" since both asmstring is "r2 = 5". In such cases, the assembler uses 64bit load for all "r = " asm insts. This patch adds back " ll" suffix for ld_imm64 with one additional space for "#reg = #global_var" case. Signed-off-by: Yonghong Song Acked-by: Alexei Starovoitov llvm-svn: 312978 --- llvm/lib/Target/BPF/BPFInstrInfo.td | 2 +- llvm/lib/Target/BPF/InstPrinter/BPFInstPrinter.cpp | 2 +- llvm/test/CodeGen/BPF/cc_args.ll | 4 ++-- llvm/test/CodeGen/BPF/cc_args_be.ll | 4 ++-- llvm/test/CodeGen/BPF/cc_ret.ll | 2 +- llvm/test/CodeGen/BPF/ex1.ll | 2 +- llvm/test/CodeGen/BPF/intrinsics.ll | 2 +- llvm/test/CodeGen/BPF/mem_offset_be.ll | 2 +- llvm/test/CodeGen/BPF/sanity.ll | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/llvm/lib/Target/BPF/BPFInstrInfo.td b/llvm/lib/Target/BPF/BPFInstrInfo.td index d4c50e768f74..bef6ce0852aa 100644 --- a/llvm/lib/Target/BPF/BPFInstrInfo.td +++ b/llvm/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}", + "$dst "#OpcodeStr#" ${imm} ll", [(set GPR:$dst, (i64 imm:$imm))]> { bits<3> mode; diff --git a/llvm/lib/Target/BPF/InstPrinter/BPFInstPrinter.cpp b/llvm/lib/Target/BPF/InstPrinter/BPFInstPrinter.cpp index bb5546ea40ed..536ae4df9372 100644 --- a/llvm/lib/Target/BPF/InstPrinter/BPFInstPrinter.cpp +++ b/llvm/lib/Target/BPF/InstPrinter/BPFInstPrinter.cpp @@ -88,7 +88,7 @@ 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() << "ll"; + O << (uint64_t)Op.getImm(); else if (Op.isExpr()) printExpr(Op.getExpr(), O); else diff --git a/llvm/test/CodeGen/BPF/cc_args.ll b/llvm/test/CodeGen/BPF/cc_args.ll index a2ac03f0da12..6a0a07ae8e87 100644 --- a/llvm/test/CodeGen/BPF/cc_args.ll +++ b/llvm/test/CodeGen/BPF/cc_args.ll @@ -12,7 +12,7 @@ entry: ; CHECK: call f_i32 call void @f_i32(i32 12345678) -; CHECK: r1 = 72623859790382856ll # encoding: [0x18,0x01,0x00,0x00,0x08,0x07,0x06,0x05,0x00,0x00,0x00,0x00,0x04,0x03,0x02,0x01] +; CHECK: r1 = 72623859790382856 ll # encoding: [0x18,0x01,0x00,0x00,0x08,0x07,0x06,0x05,0x00,0x00,0x00,0x00,0x04,0x03,0x02,0x01] ; CHECK: call f_i64 call void @f_i64(i64 72623859790382856) @@ -28,7 +28,7 @@ entry: call void @f_i16_i32_i16(i16 2, i32 3, i16 4) ; CHECK: r1 = 5 -; CHECK: r2 = 7262385979038285ll +; CHECK: r2 = 7262385979038285 ll ; CHECK: r3 = 6 ; CHECK: call f_i16_i64_i16 call void @f_i16_i64_i16(i16 5, i64 7262385979038285, i16 6) diff --git a/llvm/test/CodeGen/BPF/cc_args_be.ll b/llvm/test/CodeGen/BPF/cc_args_be.ll index dc41ee0d8a7d..a2f1956319e7 100644 --- a/llvm/test/CodeGen/BPF/cc_args_be.ll +++ b/llvm/test/CodeGen/BPF/cc_args_be.ll @@ -13,7 +13,7 @@ entry: ; CHECK: call f_i32 call void @f_i32(i32 12345678) -; CHECK: r1 = 72623859790382856ll # encoding: [0x18,0x10,0x00,0x00,0x05,0x06,0x07,0x08,0x00,0x00,0x00,0x00,0x01,0x02,0x03,0x04] +; CHECK: r1 = 72623859790382856 ll # encoding: [0x18,0x10,0x00,0x00,0x05,0x06,0x07,0x08,0x00,0x00,0x00,0x00,0x01,0x02,0x03,0x04] ; CHECK: call f_i64 call void @f_i64(i64 72623859790382856) @@ -29,7 +29,7 @@ entry: call void @f_i16_i32_i16(i16 2, i32 3, i16 4) ; CHECK: r1 = 5 -; CHECK: r2 = 7262385979038285ll +; CHECK: r2 = 7262385979038285 ll ; CHECK: r3 = 6 ; CHECK: call f_i16_i64_i16 call void @f_i16_i64_i16(i16 5, i64 7262385979038285, i16 6) diff --git a/llvm/test/CodeGen/BPF/cc_ret.ll b/llvm/test/CodeGen/BPF/cc_ret.ll index eab2a359b8f2..be198f5d15ff 100644 --- a/llvm/test/CodeGen/BPF/cc_ret.ll +++ b/llvm/test/CodeGen/BPF/cc_ret.ll @@ -42,7 +42,7 @@ define i32 @f_i32() #0 { define i64 @f_i64() #0 { ; CHECK: f_i64: -; CHECK: r0 = 72623859790382856ll +; CHECK: r0 = 72623859790382856 ll ; CHECK: exit ret i64 72623859790382856 } diff --git a/llvm/test/CodeGen/BPF/ex1.ll b/llvm/test/CodeGen/BPF/ex1.ll index 2f77884f5ef0..97cc7e07ab9b 100644 --- a/llvm/test/CodeGen/BPF/ex1.ll +++ b/llvm/test/CodeGen/BPF/ex1.ll @@ -32,7 +32,7 @@ define i32 @bpf_prog1(%struct.bpf_context* nocapture %ctx) #0 section "events/ne ; CHECK: call 9 ; CHECK: if r0 != 0 ; CHECK: r1 = 622884453 -; CHECK: r1 = 7214898703899978611ll +; CHECK: r1 = 7214898703899978611 ll ; CHECK: call 11 ; CHECK: r0 = 0 ; CHECK: exit diff --git a/llvm/test/CodeGen/BPF/intrinsics.ll b/llvm/test/CodeGen/BPF/intrinsics.ll index 18d14a08fd9a..88aba805adad 100644 --- a/llvm/test/CodeGen/BPF/intrinsics.ll +++ b/llvm/test/CodeGen/BPF/intrinsics.ll @@ -55,7 +55,7 @@ entry: tail call void inttoptr (i64 4 to void (i64, i32)*)(i64 %call, i32 4) #2 ret i32 0 ; CHECK-LABEL: ld_pseudo: -; CHECK: ld_pseudo r1, 2, 3ll # encoding: [0x18,0x21,0x00,0x00,0x03,0x00 +; CHECK: ld_pseudo r1, 2, 3 # encoding: [0x18,0x21,0x00,0x00,0x03,0x00 } declare i64 @llvm.bpf.pseudo(i64, i64) #2 diff --git a/llvm/test/CodeGen/BPF/mem_offset_be.ll b/llvm/test/CodeGen/BPF/mem_offset_be.ll index e5e352783d70..7d7243a6667c 100644 --- a/llvm/test/CodeGen/BPF/mem_offset_be.ll +++ b/llvm/test/CodeGen/BPF/mem_offset_be.ll @@ -2,7 +2,7 @@ ; Function Attrs: nounwind define i32 @bpf_prog1(i8* nocapture readnone) local_unnamed_addr #0 { -; CHECK: r1 = 590618314553ll # encoding: [0x18,0x10,0x00,0x00,0x83,0x98,0x47,0x39,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x89] +; CHECK: r1 = 590618314553 ll # encoding: [0x18,0x10,0x00,0x00,0x83,0x98,0x47,0x39,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x89] ; CHECK: r1 += -1879113726 # encoding: [0x07,0x10,0x00,0x00,0x8f,0xff,0x00,0x02] ; CHECK: r0 = *(u64 *)(r1 + 0) # encoding: [0x79,0x01,0x00,0x00,0x00,0x00,0x00,0x00] %2 = alloca i64, align 8 diff --git a/llvm/test/CodeGen/BPF/sanity.ll b/llvm/test/CodeGen/BPF/sanity.ll index a7aed65b821e..ebee851fbfb6 100644 --- a/llvm/test/CodeGen/BPF/sanity.ll +++ b/llvm/test/CodeGen/BPF/sanity.ll @@ -105,7 +105,7 @@ define void @foo_printf() #1 { %1 = getelementptr inbounds [9 x i8], [9 x i8]* %fmt, i64 0, i64 0 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @foo_printf.fmt, i64 0, i64 0), i64 9, i32 1, i1 false) ; CHECK-LABEL: foo_printf: -; CHECK: r1 = 729618802566522216ll +; CHECK: r1 = 729618802566522216 ll %2 = call i32 (i8*, ...) @printf(i8* %1) #3 ret void } -- GitLab