lowRISC / lowRISC/riscv-llvm

disassembly printing

Open
#57 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Shell
Stars
277
Forks
55
PR merge metrics
No merged PRs in 30d

Description

This is based on the https://github.com/lowRISC/riscv-llvm-integration repo at Latest commit 74e4050 on 3 Oct 2017.

Running llvm-objdump does not disassemble the instructions from the M extension and the jalr is formatted differently from the gnu objdump. Is this expected?

My command line is: (on windows msys2):
$ ./llvm-objdump.exe -arch=riscv32 -disassemble my_folder/riscv_blocks.elf

Corresponding gnu command:
$ bin/riscv64-unknown-elf-objdump.exe -d -M no-aliases blocks.elf

Sample output 1:
42000028: b7 57 c6 41 lui a5, 269413
4200002c: 93 87 d7 e6 addi a5, a5, -403
42000030: 33 07 f7 02
42000034: b7 07 00 42 lui a5, 270336
42000038: 23 a6 e7 2a sw a4, 684(a5)
4200003c: b7 07 00 42 lui a5, 270336

gnu objdump output: multiplication instruction expected (ignore hex/$ formatting/comments)
42000028: 41c657b7 lui a5,0x41c65
4200002c: e6d78793 addi a5,a5,-403 # 41c64e6d <STACK_SIZE+0x41c64a6d>
42000030: 02f70733 mul a4,a4,a5
42000034: 420007b7 lui a5,0x42000
42000038: 2ae7a623 sw a4,684(a5) # 420002ac
4200003c: 420007b7 lui a5,0x42000

Sample output 1: uses comma formatting for jalr

gnu objdump output: uses register offset bracket formatting for jalr (ignore hex/$ formatting/comments)
42000118: f8f714e3 bne a4,a5,420000a0 <draw_block+0x2c>
4200011c: 00000013 addi zero,zero,0
42000120: 03c12403 lw s0,60(sp)
42000124: 04010113 addi sp,sp,64
42000128: 00008067 jalr zero,0(ra)

The jalr difference can can be seen by using table-gen with gen-asm-writer option
$ ./bin/llvm-tblgen.exe -gen-asm-writer -I=../include -I=../lib/Target/RISCV ../lib/Target/RISCV/RISCV.td

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the comparison with llvm-objdump.exe, riscv64-unknown-elf-objdump.exe, and the supplied ELF samples. Read lib/Target/RISCV/RISCV.td and inspect the output from llvm-tblgen with -gen-asm-writer. Done means determining whether M-extension instructions and jalr formatting should match the GNU disassembly and recording the required behavior.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.