[PATCH] D140693: [Driver][RISCV] Adjust the priority between -mcpu, -mtune and -march

Kito Cheng via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 27 06:02:26 PST 2022


kito-cheng created this revision.
kito-cheng added reviewers: craig.topper, asb, reames.
Herald added subscribers: sunshaoce, VincentWu, StephenFan, vkmr, frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, arichardson.
Herald added a project: All.
kito-cheng requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, eopXD, MaskRay.
Herald added a project: clang.

RISC-V supports `-march`, `-mtune`, and `-mcpu`: `-march` provides the
architecture extension information, `-mtune` provide the pipeline model, and
`-mcpu` provides both.

What's the priority among those options for now(w/o this patch)?

Pipeline model:

- Take from `-mtune` if present.
- Take from `-mcpu` if present
- Use the default pipeline model: `generic-rv32` or `generic-rv64`

Architecture extension:

- Take from `-mcpu` if present.
- Take from `-march` if present.
- Use the default architecture depending on the target triple

We treat `-mcpu`/`-mtune` and `-mcpu`/`-march` differently, and it's
kind of counterintuitive: -march is explicitly specified but ignored.

This patch adjusts the priority between `-mcpu`/`-march`, letting it use
architecture extension information from `-march` if it's present.

So the priority of architecture extension information becomes:

- Take from `-march` if present.
- Take from `-mcpu` if present.
- Use the default architecture depending on the target triple

And this also match what we implement in RISC-V GCC too.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140693

Files:
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/riscv-cpus.c
  clang/test/Driver/riscv-march-mcpu-mtune.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140693.485373.patch
Type: text/x-patch
Size: 16666 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221227/ba1a91b0/attachment-0001.bin>


More information about the cfe-commits mailing list