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

Kuan Hsu Chen (Zakk) via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 6 10:18:57 PDT 2020


khchen updated this revision to Diff 255377.
khchen added reviewers: evandro, HsiangKai.
khchen added a comment.
Herald added a subscriber: hiraditya.

update implementation and handle `-mcpu` with explicitly specified `-march`.
If `-mcpu` has default march, explicitly `-march` will overwrite it.

1. reference ARM/AArch64 and X86 to implement RISCVTargetParser.def
2. in clang, `-mtune` option alias <https://github.com/llvm/llvm-project/blob/1d42c0db9a2b27c149c5bac373caa5a6d38d1f74/clang/include/clang/Driver/Options.td#L2869-L2870> to `-mcpu`. This patch supports `-mtune` option via `-mcpu`.
3. propose two category of CPUs in TargetParser and backend. First is similar gcc's -mtune option (it includes micro architecture related feature only, ex. `rocket-rv32` has different schedule model), another also has default `-march` (isa string).
4. add two sifive cpu which has default `-march`
5. changed default march logic.

march: in order:

1. Explicit choices using -march
2. A default based on `-mcpu`, if target cpu has default -march
3. A default based on -mabi, if provided
4. A default based on the target triple's arch

I think it's also okay if we want to only support `-mcpu` which is similar to gcc's `-mtune` in current stage.  Because in current implementation,
users can query available CPUs via ` -mcpu=?` on clang but `mcpu` option is not workable.


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

https://reviews.llvm.org/D71124

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.h
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/riscv-cpus.c
  llvm/include/llvm/Support/RISCVTargetParser.def
  llvm/include/llvm/Support/TargetParser.h
  llvm/lib/Support/TargetParser.cpp
  llvm/lib/Target/RISCV/RISCV.td

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71124.255377.patch
Type: text/x-patch
Size: 15631 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200406/ef86edab/attachment-0001.bin>


More information about the cfe-commits mailing list