<div dir="ltr">Awesome, thanks! <div><br></div><div>‘

--mattr=m  ’ works well, I can see mul & mulh instructions.<br><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Mar 27, 2020 at 7:07 PM Simon Cook <<a href="mailto:simon.cook@embecosm.com">simon.cook@embecosm.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
Unlike GNU objdump, llvm-objdump doesn't assume that for RISC-V all<br>
standard extensions are available by default, and so need to be<br>
provided on the command line. I'm not aware of a flag that you can<br>
pass a RISC-V ISA string to (from your command it seems --arch doesn't<br>
do this for you), but you can enable the disassembly of instructions<br>
using the underlying attributes and the --mattr flag, so in your case<br>
adding `--mattr=+m` to your llvm-objdump command (I think `--mattr=m`<br>
should work as well).<br>
<br>
Hope this helps.<br>
<br>
Thanks,<br>
Simon<br>
<br>
On Fri, Mar 27, 2020 at 9:23 AM Junning Wu via llvm-dev<br>
<<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
><br>
> I am using llvm-project compiling risc-v programs.<br>
><br>
> llvm-project version:dd8a2013dc1804be1b7d9cffacad2e984300bd22<br>
><br>
> Instructons to build LLVM+clang:<br>
><br>
> ```<br>
> cmake -G Ninja -DCMAKE_INSTALL_PREFIX=/home/llvm/workspace/llvm/llvm-project/llvm_install -DCMAKE_BUILD_TYPE="Release" -DDEFAULT_SYSROOT="/home/llvm/workspace/riscv/riscv-tc-20200220/bin/riscv32-unknown-elf" -DGCC_INSTALL_PREFIX="/home/llvm/workspace/riscv/riscv-tc-20200220" -DLLVM_DEFAULT_TARGET_TRIPLE="riscv32-unknown-elf" -DLLVM_ENABLE_PROJECTS="clang;lld;libc" -DLLVM_TARGETS_TO_BUILD="RISCV" ../llvm<br>
> ```<br>
><br>
> Instructions to compile and dump:<br>
><br>
> ```<br>
> RISCV_GCC_OPTS ?= -mcmodel=medany -static -O3 -std=gnu99 -fno-common -fno-builtin -march=rv32im -mabi=ilp32 -DMB_ADDR=0x80FFFFC --target=riscv64-unknown-elf --sysroot=/home/llvm/workspace/riscv/riscv-tc-20200220/bin/riscv64-unknown-elf --gcc-toolchain=/home/llvm/workspace/riscv/riscv-tc-20200220<br>
> RISCV_LINK_OPTS ?= -static -nostdlib -nostartfiles -lm -lgcc -T /home/llvm/workspace/HRV_IDE/common/test.ld<br>
> newlib_dir := /home/llvm/workspace/llvm/llvm-project/llvm_install/riscv64-unknown-elf/include<br>
> src_dir := $(WORK_DIR)/src/$(PROJ)<br>
> incs  += -I$(WORK_DIR)/env -I$(WORK_DIR)/common -I$(src_dir) -I$(newlib_dir)<br>
> src := $(wildcard $(src_dir)/*.c) $(wildcard $(WORK_DIR)/common/*.c) $(wildcard $(WORK_DIR)/common/*.S)<br>
><br>
> $(RISCV_clang) $(incs) $(RISCV_GCC_OPTS) -o $(WORK_DIR)/build/$@/$@ $(src) $(RISCV_LINK_OPTS) --verbose<br>
> $(RISCV_OBJDUMP) -d $(WORK_DIR)/build/$@/$@ > $(WORK_DIR)/build/$@/$@.S<br>
> $(RISCV_LLVM_OBJDUMP) --arch=rv32imac -D $(WORK_DIR)/build/$@/$@ > $(WORK_DIR)/build/$@/$@.ASM<br>
> ```<br>
> gcc objdump result:<br>
> ```<br>
> 4001168: 00052383           lw t2,0(a0)<br>
>  400116c: 979a                 add a5,a5,t1<br>
>  400116e: 439c                 lw a5,0(a5)<br>
>  4001170: 0308a533           mulhsu a0,a7,a6<br>
> ```<br>
><br>
> llvm-objdump result:<br>
><br>
> ```<br>
>  4001168: 83 23 05 00                   lw t2, 0(a0)<br>
>  400116c: 9a 97                         add a5, a5, t1<br>
>  400116e: 9c 43                         lw a5, 0(a5)<br>
>  4001170: 33 a5 08 03                   <unknown><br>
> ```<br>
><br>
> Does anyone knows what is the problem and how to fix it?<br>
> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>