[iovisor-dev] [v2][PATCH RFC] Add BPF AsmParser support in LLVM

Y Song ys114321 at gmail.com
Mon Sep 11 23:54:31 UTC 2017

Hi, Jiong,

Thanks for the patch. Comments inlined.

> Changes since the initial version:
>   * Addressed all comments on instruction unit tests.
>     - Renamed test file to "insn-unit.s".
>     - Removed unnecessary comments.
>     - Added BPF_B tests for load and store.
>     - Added BPF_K test for jmp and alu.
>       (Noticed a seperate issue with unsigned compare then jump. Looks like
>        backend is alway printing the immediate as signed, I guess we need to
>        change the operand types in instruction patterns.)

Right. We may need to separate out signed comparison vs. others. Will do
that later.

>     - Adjusted constant load tests.
>     - Interleaved the expected results with input insns.
>   * Changed the disassembly output "ll" to "LL" in BPFInstPrinter.cpp.
>     This is because I noticed MC parser only accept "LL" as long long
> suffix.

Sorry for the confusion caused by "ll". I tested your patch and found that
both r = 5 and r = 5LL generated ld_imm64 insn. This is not what compiler
will do. Further debugging I found that this is due to my change to remove
"ll" from asmstring in the insn definition (.td file). Since the assembler is
patten matching based on asmstring. "r = 5" matched to ld_imm64 as well.

I just fixed the issue and restored " ll" suffix for ld_imm64 asmstring.
You can then restore your previous change to add "ll" as a valid identifier
in the middle of asm statement.


More information about the iovisor-dev mailing list