[PATCH] D71124: [RISCV] support clang driver to select cpu

Kuan Hsu Chen (Zakk) via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 14 18:46:35 PDT 2020


khchen added a comment.

Hi @lenary 
This is normal behavior in current clang implementation, 
`-mcpu=?` flag does not interact with any flags, it just print out the all of ProcessorModel registered in backend.
https://github.com/llvm/llvm-project/blob/master/clang/tools/driver/cc1_main.cpp#L213-L215

You can reference this <https://github.com/llvm/llvm-project/blob/master/clang/tools/driver/cc1_main.cpp#L180>, so the `clang -mcpu=?` result is exactly equal to `./bin/llc -mattr=+cpuhelp`.

  ./bin/llc -mattr=+cpuhelp  foo.ll  --mtriple=riscv32
  Available CPUs for this target:
  
          generic-rv32
          generic-rv64
          rocket-rv32
          rocket-rv64
  
  Use -mcpu or -mtune to specify the target's processor.
  For example, clang --target=aarch64-unknown-linux-gui -mcpu=cortex-a35

You can try `clang -mcpu=? --target=mips64el` or other target too.

But you are right, this behavior is very confusing users.

In D71124#2150535 <https://reviews.llvm.org/D71124#2150535>, @lenary wrote:

> I've got one major issue (inline below), and I'm confused by some other behaviour:
>
> When I run `clang --target=riscv64 -mcpu=?`, the list includes both `generic-rv32` and `generic-rv64`. It doesn't show only the 64-bit cpus. This is not changed by giving a full triple, or by additionally specifying `-march=rv64gc`. Should it be?
>
> For instance, this output:
>
>   $ clang --target=riscv64-unknown-elf -mcpu=\? -march=rv64gc
>   clang version 11.0.0
>   Target: riscv64-unknown-unknown-elf
>   Thread model: posix
>   InstalledDir: /home/selliott/llvm-project/./build/llvm_clang/all/bin
>   Available CPUs for this target:
>  
>   	generic-rv32
>   	generic-rv64
>   	rocket-rv32
>   	rocket-rv64
>   	sifive-e31
>   	sifive-u54
>  
>   Use -mcpu or -mtune to specify the target's processor.
>   For example, clang --target=aarch64-unknown-linux-gui -mcpu=cortex-a35
>





Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71124/new/

https://reviews.llvm.org/D71124





More information about the llvm-commits mailing list